Search the Community
Showing results for tags 'submaterial'.
-
solved [SOLVED] Changing SubMaterial turns Mesh Invisible
djeustice posted a topic in Questions & Answers
Hello. My Kayak model has 4 sub materials on it. I have a button called "KayakLime". I'd like this button to change sub material #2 from Peach.png to Lime.png when clicked. Example #1 below works, but it changes the 4 kayak sub materials all to Lime.png. var myKayak2; BABYLON.SceneLoader.ImportMesh("", "models/", "Kayak.gltf", scene, function (newMeshes) { myKayak2 = newMeshes[0]; }); var LimeTexture = new BABYLON.StandardMaterial("Lime", scene); LimeTexture.diffuseTexture = new BABYLON.Texture("models/Lime.png", scene); LimeTexture.diffuseTexture.hasAlpha = false; LimeTexture.backFaceCulling = false; document.getElementById("KayakLime").addEventListener("click",function () { myKayak2.material = LimeTexture; }); Example #2: I thought this click code below would change only sub material #2 to Lime.png. However it turns the kayak invisible. Do I need to add more properties in the LimeTexture material? Or is it something else I'm missing? document.getElementById("KayakLime").addEventListener("click",function () { myKayak2.material.subMaterials[2] = LimeTexture; }); -
Hi Gang! Many questions. (sorry) **** Does anyone know the history-of or reason-for... https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.subMesh.js#L14 During the creation of a SubMesh, it is automatically placed into the mesh.subMeshes array. Is this somewhat new? Anyone know? MY reason for wanting to know? Visit Kostar's cool Tiled Ground Tutorial... particularly playground demo #5. See line 61, where our friend is pushing newly-created subMesh into the tiledGround.subMeshes array? Well... that's no good. Inserting a console.log near line 65, reports that there are 128 subMeshes in Kostar's 64-tile ground. (double, and we know why) Here is my own clone of Kostar's demo #5 - with console.log line showing 128 count. A little adjustment to line 61, and things start working good, with a count of 64. Maybe Kostar needs a mail. Maybe auto-pushing subMesh upon creation... is a bad idea. Dunno. Anyone know any history? Is auto-pushing subMeshes... something new? Bad? Good? Thoughts? (thx)
- 9 replies
-
- tile
- tiledground
-
(and 2 more)
Tagged with: