How to move the bones of the GLB 3D model?

Hello everyone.

On the website of the game engine there is a demo of the use bones of the game character:
https://www.babylonjs-playground.com/#1BZJVJ#33

My problem is this: When I load another model with bones, nothing happens.
I thought this was due to the fact that the downloadable 3d model has the .glb format, while in the demo the model has the .babylon format.
I decided to check if the engine sees the bones of the GLB 3d model.

console.log(skeleton.bones[1]);

Yes, the engine sees the bones of the model in the format glb. But for some reason he does not want to rotate them, move them and so on.
You can find a link to the GLB 3D model in this demo:
https://playground.babylonjs.com/#ZQPDEF#7

To scale an airplane 3D model when loading into the first demo, change the parameters:

mesh.scaling = new BABYLON.Vector3(20.1,20.1,20.1);

Hey! and welcome to the family :slight_smile:

This is because your glb has animations for the bones so the animations are overwriting your changes

I turned off the animation using this code:

scene.animationsEnabled = false;

It did not work. The bones don’t move anyway.

Let me check that :slight_smile:

https://www.babylonjs-playground.com/#1BZJVJ#126

OK I know why :slight_smile:
GLTF works the same way UNity works with Bones: the bones are linked to nodes and reproduce the nodes transform

In your example, instead of moving the bones, you need to move the root meshes:

Thank you. I found a propeller :smile:

var propellor = scene.rootNodes[2]._children[0]._children[1]._children[0]._children[0]._children[3];
propellor.rotate(BABYLON.Axis.Z, .01, BABYLON.Space.WORLD, mesh);

Is there any other way to find it?

You can also find it by name with scene.getMeshByName("…")

scene.getMeshByName("Propellor_Joint.9");

This code returns ‘null’.

Try:

   scene.getTransformNodeByName("Propellor_Joint.9")

They are not meshes but only TransformNodes

3 Likes

Thank! It worked.

1 Like