Texture applied on all copies

Hi All,

I took a copy of the gltf object, and after adding many of these copies to the scene, I tried to change the texture, but when I changed the texture of the selected object, the other copies were changed also.

.....
..
..

  function (gltf) { 
          let object = gltf.scene.children[0];
          clone = object.clone();
          let newUUID = await genRandonString(25);
          clone.uuid = newUUID;
          clone.geometry.uuid = newUUID;
          clone.userData.uuid = newUUID;
          ..
          ..

        });
..
..
..


Yes, that’s because you clone the object - not it’s materials. This should be enough:

clone.material = clone.material.clone();
clone.material.map = anotherTexture;

(Just keep in mind doing material clone for each copy could be sub-optimal, so clone materials only on demand.)

1 Like

Thank you so much @mjurczyk .