【Question】About Loaded resource

I wanna load a model once,but display 2 of em.
This is my code

new GLTFLoader().load(url,gltf=>{
    const m1 = gltf.scene
    const m2 = m1.clone()
    scene.add(m1)
    scene.add(m2)
})

what’s wrong with this code?

At first glance the code looks fine. What exactly does not work?

1 Like


This is normally the model added to the scene
code here

new GLTFLoader().load(url,gltf=>{
    const m1 = gltf.scene
    m1.scale.set(0.01,0.01,0.01)
    scene.add(gltf.scene)
})

but something’s wrong when i clone it and add to the scene
like this pics


code here

new GLTFLoader().load(url,gltf=>{
    const m1 = gltf.scene.clone()
    m1.scale.set(0.01,0.01,0.01)
    scene.add(gltf.scene)
})

if i run this code below it’ll be like the first pic,only m1 was loaded,at least only m1 is visible,cant see m2.

new GLTFLoader().load(url,gltf=>{
    const m1 = gltf.scene
    m1.scale.set(0.01,0.01,0.01)
    const m2 = m1.clone()
    scene.add(m1)
    scene.add(m2)
})

i used to use this method once,it’s all works fine.but this time,i change multiple model,but all twisted.
this eagle model is from here

https://sketchfab.com/3d-models/white-eagle-animation-fast-fly-30203bf39e5145f19c79e83c550139d3

I also tried the following models

https://sketchfab.com/3d-models/low-poly-bird-animated-82ada91f0ac64ab595fbc3dc994a3590
https://sketchfab.com/3d-models/pc-spider-88f519a508ff42889deea7d17e652c23

To clone a skinned mesh you need to use SkeletonUtils.clone:

2 Likes

ah yes,now i know why this happens.Huge thanks!
by the way,how can we tell if a model is skinnedMesh?

You can log the gltf.scene to the console and look through it’s children. Or use traverse:

gltf.scene.traverse((child) => {
    if(child.isSkinnedMesh) {
       // do stuff
   }
}
2 Likes

Thanks a million!