Cloning material from a clone of a loaded obj+mtl is not working

Hello all,
So, the point is to duplicate/clone a loaded model+mtl, and changing the materials for the model selected ONLY.

Here’s a codepen to illustrate https://codepen.io/freuxdesbois/pen/MGjPvV

I tried to clone the .material and the .material.map too, but no matter what, if I change the color of one, it changes the color of all models. What am I missing ?

Mesh.clone() does not clone the geometry and material. But you can easily implement this via Object3D.traverse() like in the following code pen. You have to be aware though that mesh.material can be an array of materials.

Thanks for the tip Mugen87, I’ll study it to understand the material thing and the why thing (I’m still a newcomer to threejs)
In the meantime, I thought of a workaround that seemed to work too: (create an array of material clone then apply it after cloning the mesh)

I don’t know if it’s still ‘deep’ material clone, or if it’s performance friendly, but the result is here :wink: