So i have a gltf.scene file contains multiple coral models, i load it in with GLTFLoader and use a map to store all the children mesh. Later I try cloning those mesh and it works just fine but the scale is 10 times larger than the mesh that i stored in my map, when i try to debug the new object that i just cloned the scale is still 1, 1, 1. I can still set the scale to 0.1, 0.1, 0.1 to get the size I wanted but still I want to know why the cloned object is suddenly larger.
Is the cloned object parented to the exact same parent as the original?
No, I don’t think so I just call object.clone() without setting any parent. I tried to set up jsfiddle here https://jsfiddle.net/minhle2512/37qLcua6/2/ but couldn’t upload the local file for the model so you can only read the code sorry about that.
There’s a great chance that it’s the parent scale that influences scale of the original mesh that you clone.
When exporting from Blender - it’s a good idea to A -> Space / F3 -> Apply Scale
, which will make all models scale recalculate to (1.0, 1.0, 1.0)
properly - then cloning any part of the scene should result in an exact clone.
I see so if I were to set the object’s parent to the model that I loaded in would it change the object’s scale?
Depends on the parent. Transformation of an object is equal to it’s own transformation multiplied by all it’s parents’ transformations. So if parent is scaled / rotated / moved, child will also be scaled / rotated / moved. But if you move that child to another parent - this transformation will disappear from the child.
I see thank you so much for replying to this post!