Issues transfering skeleton animation

I got a skeleton driven by mocap data. The bones of the skeleton all have both position and rotation animations.

I’ve used Maya to bind a mesh to a set of Maya joints and exported this rig using glTF.
Skinned mesh in Maya:

It imports fine in my Babylon scene, and the mesh reacts as expected when I rotate bones.

I managed to copy all animations from my animated skeleton (manually, copyAnimationRange does not play nice). Bones line up perfectly: the input skeleton (red) can’t be seen because the rig skeleton (white) is rendered exactly on top:

However, the mesh kind of explodes. I think it has to do with the translations. When I translate joints in Maya the rig reacts in a similar fashion.

Is this expected when the bones have animated positions?

If yes, I suppose I need to convert translations on the input skeleton to only rotation and scale transformations for things to look as expected.

Any pointers appreciated!

Can you provide a repro in the Playground so that we can see what’s going on?

@Drigax is the master of animations, but with a repro I think it can make things easier.

Does this still happen if you try to set:

Scene.useRightHandedSystem = true?

This feels like the skeleton is inverted somehow via your animation. You can also try disabling skinning via the inspector debug settings.

It’s correct that the imported scene is from a right handed system. I’ve compensated for that by scaling root. Removing that compensation and adding scene.useRightHandedSystem = true have no effect.

You shouldn’t have to do any scaling in-engine, or before exporting. We already compensate for glTF being right handed in our scene loading, we put the mesh in a right handed subtree via the _root_ generated node.

However, a concern I have here is if you’re trying to take the right handed animation, and applying them to your newly-created left handed skeleton

Setting the scene handedness to right handed removes that conversion, as we now use right handed world coordinates.

I’m trying to remove as many variables as possible, can you try looking at the position gizmo for your joint nodes? they might not be where they’re expected, even though the line rendered skeleton looks alright.

Also, an interactable playground via would be a large help in understanding what you’re doing here.

The animation I’ve loaded should be left-handed.

One strange thing though. I wasn’t able to get the skeleton to look right by copying animation keys to the bones, but to transform nodes with the same names as the bones.

I can try to create a Playground, but it’s some work to reduce my scene to something simple.

Looks like gizmos only work with meshes, not bones?

gizmos should work with bones (pinging @Cedric to confirm that)

I think we’re starting to get closer to the issue…

The animation I’ve loaded should be left-handed.

How are you loading this animation? as part of the glTF, or separately? If its part of the glTF, it will be interpreted as right handed by our glTF loader, since glTF is a right handed format.

One strange thing though. I wasn’t able to get the skeleton to look right by copying animation keys to the bones, but to transform nodes with the same names as the bones.

When we load a skeleton from glTF, the bones are no longer self-drivable, we link it to a node in scene (similar to how glTF represents bones, as a reference to a nodes in the scene that drives its transform, rather than their own entities) Any animation assigned to the given bone may not affect its transform, as we override it with its linked TransformNode’s transform each frame. You’ll have to apply animations to the linked transform node instead. You can see this via the inspector:

Yes it should work for rotation and translation.

The animation comes from a separate json file. The original mocap data is right-handed, but I convert it to be left-handed.

I’m working on a simplified example to put in a Playground.

Here’s a Playground with a reduced example.

Update: Probably unrelated, but for some reason the foot bone is not visible.

Update: Playground now has gizmos!

I wasn’t able to get gizmos working with bones though (as seen in the Playground they end up at the origin).

Update: Exporting to .babylon gives similar results, as seen in this Playground.