How to clone a model that's loaded with GLTFLoader()?

@Rene_Veerman
I had the same issue where const model = gltf.scene.clone(); didn’t show the cloned model even though there were no errors.

@WilliamBagel 's suggestion worked for me (SkeletonUtils.clone()), and here’s an example of the code I used:

import { clone } from 'three/examples/jsm/utils/SkeletonUtils.js';

let tree = {};
const gltfLoader = new GLTFLoader();
gltfLoader.load(
  '/models/tree/scene.gltf',
  (gltf) => {
    tree = gltf.scene;
    tree.position.x = 20;
    scene.add(tree);

    const tree2 = clone(tree);
    tree2.position.x = -20;
    scene.add(tree2);
  }
);

I hope this helps the next person!

1 Like