Tanuky Posted November 30, 2018 Share Posted November 30, 2018 How can I add a Texture to the following sample https://www.babylonjs-playground.com/#4GBWI5 I tried the following code: mat = new BABYLON.StandardMaterial("", scene); mat.diffuseTexture = new BABYLON.Texture("textures/texture.jpg", scene); // mat.diffuseColor = new BABYLON.Color3(1, 1, 1); //mat.diffuseTexture.hasAlpha = true; build.material = mat; I get the following error: .WebGL-0x7f8fa201c400]GL ERROR :GL_INVALID_OPERATION : glDrawElements: attempt to access out of range vertices in attribute 1 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 30, 2018 Share Posted November 30, 2018 Your model does not have UVs and UVs are mandatory when you rely on textures: https://en.wikipedia.org/wiki/UV_mapping You should create them when you create the positions: https://www.babylonjs-playground.com/#4GBWI5#183 This is just an example, they should be created in a meaningful way. I just try to highlight the need of UVs here. Tanuky 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.