Issue when targeting AnimationGroup to TransformNodes

Hello,
I am trying to clone an AnimationGroup and reassigning it to some loaded TransformNodes.

When I try to start the cloned animation I have the error:
ERROR: Cannot read properties of undefined (reading 'getRestPose')

Is this the right way to assign the new targets of the animations?
The code can be found here https://www.babylonjs-playground.com/#ED8PE1#8

Thanks

btw the models are from https://twitter.com/KayLousberg :slight_smile:

Tried another approach with no success,
For each loaded transformationNode used linktransformNode to connect to a cloned skeleton
Maybe I misunderstood the documentation :slight_smile:

See the code here https://www.babylonjs-playground.com/#ED8PE1#16

I am pretty you would not be able to do it as the structure of the objects are completely different.

Let me also add @bghgary and @Evgeni_Popov to the thread

You need to return a valid target object in the function you pass to the clone method:
https://www.babylonjs-playground.com/#ED8PE1#18

But as @sebavan said, the structure of your two objects are different, so using an animation built for one won’t work correctly on the other (you can see the arms of the warrior are not animated correctly, as well as the body).

2 Likes

Ha! So if there is no match the oldTarget should be kept the same…
Maybe I need to load the arms as separated objects.

will take a look thanks!


I noticed that the arm seems flipped, not sure if it is related to the script I used to convert the animations from FBX to GLTF, will try later to experiment on that.

./FBX2glTF-linux-x64 --binary --draco --verbose --no-flip-v --input filename.fbx

The script I used

That may be because you need to set scene.useRightHandedSystem = true; just after scene creation. But that won’t fix the animation. I think the animation of the first mesh is simply not compatible with this mesh.

1 Like

For documentation, these are the steps I used to finally make it work.

And this is the code I am using to assign the bones from the AnimationGroup to the loaded node smallflatworld/mesh-loader.service.ts at 47c43c80a5a96d2ef065f95295df00cf45715e85 · hamilton-lima/smallflatworld · GitHub