I give a try to GLTF But everything goes wrong for the animations

Hello,

I always use the babylon extension to load my 3d models. And today I wanted to give gltf a try to load my characters to see how it would perform in terms of performance. (the character seems to load much faster, which is cool)
I’m hitting a wall with animations now.
I understood that there is an animation group now. But I don’t understand how it works.
I was able to stop all animations with animationGroups[0].stop();

But then I’m lost.

Before I used:
avatar.skeleton.createAnimationRange('walk', 0, 100);
Then I could play the animation with:
avatar.skeleton.beginAnimation('walk', true, 1.0);

with gltf and animation groups I no longer understand. I have a single animation from 0 to 3000 (which represents several different animations, but joined into one.)
Can I still use createAnimationRange()?

How can I give a name and a start and end key with animation groups as I did with createAnimationRange()

Thanks for your help

cc @bghgary

Do you have a playground? I’m not sure I understand what you mean.

I feel like my model which only contains one long animation of several is not suitable for gltf.
Does that mean that I have to export my animations one by one in a separate file?

I saw this in SceneLoader:

BABYLON.SceneLoader.ImportAnimations('./animations/', 'walk.gltf', scene);
BABYLON.SceneLoader.ImportAnimations('./animations/', 'run.gltf', scene);

let walk = animationGroups[0];
let run = animationGroups[1];

Is this how I should do it?

Sorry I can’t create a PG. I don’t have a server to send my character file.

Probably not. glTF can have multiple animation clips in one asset. glTF Animation is equivalent to Babylon AnimationGroup.

One of these options? Using External Assets In the Playground | Babylon.js Documentation (babylonjs.com)

@Dad72 How are you creating the glTF? Is it a custom exporter or some existing tool?

I made a PG using gitHub.

I just don’t know what to do compared to what I was doing before

I am using 3ds max 2017 to create and export the model

I see. The main issue is that all of the animation clips are in one animation in the glTF. This is not what you should do for glTF. glTF expects separate animation clips to be in separate glTF animations.

Here is a canonical example from the glTF sample models:
Babylon.js - Fox.gltf (babylonjs.com)

There are 3 distinct animations in the model: Survey, Walk, Run. Each of these are in the glTF as separate glTF animations and are loaded as separate Babylon AnimationGroups.

Ideally, in your case, if you can do this on the export of the glTF, then you can simply use Babylon AnimationGroups to play the correct animation instead of trying to split the animation clips at runtime.

1 Like

I’m assuming you are using the Babylon glTF exporter? If so, there should be options to separate the full animation track into individual clips.

1 Like

Oh, I see in 3ds max that I can create separate group animations with the right click.
I will take a closer look at this. I think I figured out what was wrong.
Thank you very much for your light bghgary

1 Like

@bghgary I don’t know if I’m doing things right. But that didn’t change anything in my character file.

I started by doing this:

Then I export (here are the parameters that I check)

I specify that I tried to check (animation group) expor No-animated Object But that does not change anything, even seeing my character disappears in Babylon

Results :
I see that the animation groups are present in the log in the export

But in Babylon I have nothing:

2022-08-03 20_53_43-Greenshot

Did I miss something?

Looks right. Can you send me the exported asset?

[edit] Ok, you had to select all the object and the skeleton included to add the group animations in 3ds max and add the viewport selection

So is has been exporting correctly now.
I will be able to test the following.

thanks again

1 Like

Ok, everything works fine now for animations.

Thank you bghgary

2 Likes