Gltf material shared instance?

I imported a 3D modele in gltf.
In this model are many meshes, with different materials.
mesh number 1 and mesh number 5 are the same color (same material indeed).

When I modify the color of mesh number 1 (mesh1.material.emissive.set(mycolor) ), it will change also the color of mesh number 5. So I assume it’s because they share the same instance of “material” somehow.

What is the right way in this condition to change the color only of the mesh 1 ?
(my goal is to just change the emissive, but keep the original material color as it is).

And by the way, is there an easy way to make a “flashing” material? I wanna make the mesh flashing at low frequency while it is moving.

You can clone the mesh material before updating it (you must do it only the first time - it’s not necessary to clone it for each change):

submesh1.material = submesh1.material.clone(); // Clone the shared material and make it unique to this mesh

submesh1.material.color = new Three.Color3(0x99ff99); // This will affect only submesh1, submesh2 will keep the original color
1 Like

Thank you!