Anes
May 28, 2019, 8:19am
1
Hello guys,
I export a blender file in BJS, and I get a mesh by name where I want to change color uner a condition (clicked button):
MyMesh= scene.getMeshByName("group_72");
boxMaterial = new BABYLON.StandardMaterial("material", scene);
boxMaterial.diffuseColor= new BABYLON.Color3(1,0,0);
and to apply color I use :
$("#btn1").click(function(){
MyMesh.material=boxMaterial;
});
So I want when I click to another button I turn back the original mesh color of (original texture)
Thanks
Anes
Anes
May 28, 2019, 10:54am
2
I tried to recover the original material and apply it again but it doesn’t work
OriginalMaterial = scene.getMaterialByID("coffrageLightBis1.Multimaterial#2");
MyMesh.material=OriginalMaterial;
nogalo
May 28, 2019, 11:14am
3
Hi.
Are you sure that’s the ID of the material. Or the name. If it is the name then you need to use
scene.getMaterialByName(“yourMaterialName”);
Anes
May 28, 2019, 11:17am
4
@nogalo no it’s the ID, the name is “_0040_Peru”, I already try it and it doesn’t work
nogalo
May 28, 2019, 11:31am
5
Can you create a playground with your mesh imported? It will help to narrow down the problem.
Here is how you can reference external resources (your mesh) into playground.
https://doc.babylonjs.com/resources/external_pg_assets
Anes
May 28, 2019, 12:47pm
6
I recreate a new material in blender and it works now.
OriginalMaterial = scene.getMaterialByID("coffrageLightBis1._0040_Peru");
2 Likes