Set Bone Position won't work

Before I shoot the question, here are the testbeds

The gltf I am trying to animate - https://playground.babylonjs.com/#88CB6A#76

Example from Babylon - https://playground.babylonjs.com/#1BZJVJ#33

Here is my problem:

The example from Babylon uses bone.setAbsolutePosition() to manipulate the 7th bone of the dude mesh (head bone). And as you can see the head does move in the playground.

I tried something similar with my gltf mesh and I can’t seem to use setAbsolutePosition with my bones. The only thing that seems to work is doing a setRotation on the Local space (not world or not Bone space).

To prove that setAbsolutePosition doesn’t work, I created a cube at 0, 0, 0 and I try to move my mesh from there. As you can see in the playground the mesh doesn’t move from it’s original position even though I operate on the root bone.

How would I go about debugging this problem? At this point I understand it has to be my gltf. But I have no idea where to look. Any help is appreciated. Thanks.

When dealing with bones from glTF files you must use the linked TransformNode and not directly the bone:

https://playground.babylonjs.com/#88CB6A#77

That’s because of the way skeleton/bones are handled in glTF files.

3 Likes

Woaaah love it! Thanks @Evgeni_Popov! Is there any we can add this to the documentation for Bones and Skeletons (Bones and Skeletons | Babylon.js Documentation)? That way future travelers are aware of this situation. Unless this was mentioned somewhere and I missed it :slight_smile:

Thanks!

Of course: do you want to make a PR for it? We have some docs that explain how to do it: Contribute To The Documentation | Babylon.js Documentation

2 Likes

@Evgeni_Popov Follow up on this. I was testing out a few things with this, my bad for delaying with the documentation as well. The bounding box for the mesh doesn’t seem to update when I update the bone positions.

I did a simple test on the playground by doing showBoudingBox = true on the skeleton Mesh and then updating the root bone position. Thoughts on what’s going wrong?

The bounding box is not recomputed based on the skeleton/bones. It’s up to you to set a bounding box that is large enough to encompass all frames of an animation (or set mesh.alwaysSelectAsActiveMesh = true to avoid culling based on the bounding box).

1 Like