How can I import animation from 1 GLB file to different GLB file in BABYLON

Hi everyone.

I currently have 3 GLB files (head, body, animation). I currently using ImportMeshAsync to import these 3 files to the scene. But I’m struggling in adding animation from the animation group from animation file to the body mesh. When I do it in Blender I can do it by choosing the 2 and using Object Link animation. How can I do it in BabylonJS?

The head: https://raw.githubusercontent.com/namluu25/glb/main/scene.glb
The body: https://raw.githubusercontent.com/namluu25/glb/main/untitled.glb
The animation: https://raw.githubusercontent.com/namluu25/glb/main/animation.glb

Playground: https://playground.babylonjs.com/#N7EYC1#1

I have used Object link animation in Blender for the body and animation GLB and export it to view on Babylon Sandbox, and here is the structure

Hi @namleww !

Take a look at this code, maybe it could help you

2 Likes

If you don’t need them to be separate, how about constructing the meshes/animations in Blender via the NLA and then exporting a single GLB to babylon? That would be straightforward.

Hi @bigrig!
It’s a good idea, but sometimes you need to import different models and reuse the animations if they share the same skeleton, in this way the process becomes more optimized and you avoid using Blender to adjust the animations of each model.

An example using ReadyPlayerMe Model and some animations:

https://viseni.com/readyplayer_anim/

We have a feature that user can select different animation on the base model. That’s why I need to separate these two

Thanks for your help. I’m currently applying this git method but somehow it does not run the animation. Here is the updated PG: https://playground.babylonjs.com/#N7EYC1#3

Hi @namleww!

I may be wrong but I think the model and animation nodes in your files don’t match.

Use https://sandbox.babylonjs.com/ to check your models.

In my Git you have some examples of models and animations, as you will see the “Armature” nodes correspond:

Also when you make the animation with Mixamo it is recommended to use the same model that you have imported in Mixamo.

2 Likes

Actually, the hierarchy is under root in the mesh:

image

So, “skeleton_male” should be renamed “skeleton_male.001” and “root” “RL_BoneRoot” to match the names of the animation hierarchy.

Once it is done, you can create a new animation group by retargeting the transform nodes to the ones of the mesh:

There are still some nodes that don’t exist in the mesh (see the console log of the browser): for these ones, the animations are simply not created.

3 Likes