GLTF mesh with skeleton, clone problem

Hello fellow babylonians :slight_smile:

I’ve run into a weird behavior : I import a skinned GLTF mesh into a scene, using babylon 4.0.3,

BABYLON.SceneLoader.ImportMeshAsync("", "FOLDER_PATH", "robot.gltf", scene)

Then I modify the bones rotations to a random quaternion.
Note : the robot is made of several mesh, all sharing the same skeleton. So i only change the first mesh skeleton.

mesh.skeleton.bones.forEach((b) => {
       b.setRotationQuaternion(BABYLON.Quaternion.FromEulerAngles(0.2, 0.5, 0.3));

The mesh is properly following the bones structure (See image on the left)

Now : I need to clone this mesh to have several of these in the scene

let clonedRobot  = new BABYLON.AbstractMesh(id, scene);
let clonedSkeleton: BABYLON.Skeleton;
let clonedParts: BABYLON.AbstractMesh[] = []; // used to clone proper hierarchy
meshes.forEach(originalPart => {

	let clonedPart = originalPart.clone(id + "." +, clonedRobot );
	clonedParts[] = clonedPart;
	if (!originalPart.parent) {
		clonedPart.parent = clonedRobot ;
	} else {
		clonedPart.parent = clonedParts[];
	if (originalPart.skeleton) {
		if (!clonedSkeleton) { // use only one skeleton per clone, shared by all meshes
			clonedSkeleton = originalPart.skeleton.clone(id + "." +, id + "." +;
		clonedPart.skeleton = clonedSkeleton;

Now, using the same bone rotation as before, the result is weird. The bones are in the same location, but the skinning seems to fail.

See image on the right

I could really use some help. I can’t share the model, I could maybe try to use a similar one to replicate in the playground if needed.

I’m guessing i’m doing something wrong while cloning, OR maybe there is a bug in the clone process of babylonJS.


Here is a Playground example

There is many thinngs don’t understand.

  • Why is the “original robot” not moving with it’s skeleton ?
  • Why the cloned robot has every meshes twice, one moving, not the other ?
  • Whe the cloned robot mesh that is moving skinning is broken ?

Fixed original mesh not moving (another problem, another ticket)

Ok, it seems it’s a GLTF importer problem

I fixed everything, it works properly on a .babylon file.

but the very same code bug on .gltf file

pinging @bghgary

Cloning a glTF asset with skinning is not easy right now. There are a bunch of features we added to support glTF like skeleton.overrideMesh and bone.linkTransformNode() which are not cloned and can’t really be cloned easily.

We’re currently thinking about adding a clone method to an AssetContainer: Make sure we can clone an asset container · Issue #6358 · BabylonJS/Babylon.js · GitHub

For now, the best option is to load the glTF multiple times.

Ok, good to know.
Thanks for the reply.


Yo @bghgary
Please let me know what you come up with here as well :slight_smile:

The support for this was added by @Deltakosh. See Use an AssetContainer - Babylon.js Documentation

1 Like

So are you saying to manually create asset container… add GLTF Mesh with skeleton to asset container and then call asset instantiate to scene ?

No, use loadAssetContainer :slight_smile:

I’m sorry, I don’t get it… use loadAssetContainer to load the whole GLTF scene ???

Use LoadAssetContainer to load from a glTF into an asset container. Then you can call instantiateModelsToScene on the asset container multiple times to get duplicates.

Here is the PG referenced from the docs: Babylon.js Playground

@Deltakosh This scene seems to be broken though? It works in 4.1 but not the latest preview.

On it!

Will be in next nightly!

1 Like