Are there disadvantages to always using SkeletonUtils.clone()?

I’m building a virtual world[1] in which I need to load assets (such as glTFs) and add them to the world. Previously, when loading assets via GLTFLoader, I was using scene.clone() to create a copy of the glTF scene for a particular instance of a world object. (I do this in the general case so that geometries and other attributes, when modified, do not affect other instances).

Recently, I (re-)discovered that glTFs with bones need SkeletonUtils.clone() in order to be cloned correctly. It seems that it’s also fine to use SkeletonUtils.clone() for glTF scenes that do not contain skinned meshes or bones.

Is there any downside to always using SkeletonUtils.clone() to create an individual instance of an object3d/scene loaded via GLTFLoader (whether skinned mesh w/ bones, or regular mesh)? Speed penalties, or other things to consider?



In either case the real work is done by calling object.clone(), so you shouldn’t see any functional differences between the two. SkeletonUtils.clone() does allocate a bit more memory to create a mapping from source objects to cloned objects, used to fix some skinning issues, so if you’re doing a lot of cloning and having GC performance issues, that’s one place to look. But cloning will always allocate some memory, so that’s not fully avoidable.


1 Like