AnimationGroup questions

I have few questions related to animationGroup.
Curently I’m working on a demo with a character which should have morphtargets, and when I searched for samples or doc I saw that we don;t have too many examples related
to this, and I want to change this,… with little help. :slight_smile: So

  1. - line20 Param is false, so it’s expecting to stop on finish or?
  2. If uncomment line 13,14,15 it’ll stop on finish. Or it is a bug or i understood wrong.
  3. Is there a way to reverse animation, like on beginAnimation function where if I put speedRatio -1 the the animation reverse (If i remember corect). Here doesn’t work.
  4. If I understood well, on export, morphtargets are exported as animationGroup, and in scene I have to play with animationGroup if I want to simulate somehow morphs. Do I understood well?
  5. If answer of question above is yes, then how I can do this?
    In the same playground I tried something, line 52,53, but I’m not sure that this is ok. I think this is not working as expected.

I think just these for now.
I need a break :yum:


Ok let’s go!

  1. This is because the animation is already running. You need to first stop it and then restart it with your loop = false parameter:
  2. Nope this is expected as thanks to this line no animation will be started by default and thus 1. will really start the animation
  3. Yes you can: :smiley:
  4. For gltf yes (pinging @bghgary for confirmation)
  5. Waiting for gary’s confirmation first :slight_smile:

Hey @Deltakosh, thanks for tips.
I’m trying to summarize. And maybe at the end we’ll add this info to doc.
Please corect me if I’m wrong.

AnimationGroup for gltf/glb files

  1. The only import function which has ‘directly’ acces to animationGroup from your gltf/glb file is importMesh, where the 4th param is animationGroup. For all other functions like Load, Apend, or if we are using taskManager, we can acces it only with scene.animationGroup, or, with scene.getAnimationGroupByName

  2. By default animationGroup is playing. So when we import a model its animations is already playing. We can avoid this using

    BABYLON.SceneLoader.OnPluginActivatedObservable.addOnce(loader => {
    	loader.animationStartMode = BABYLON.GLTFLoaderAnimationStartMode.NONE;
  3. We can reverse an animation from animationGroup with speedRatio -1, but we need to specify from and to frames (I tried without :slight_smile:, because of this it didn’t work)

  4. Morptargets are exported as animationGroup, so if we want to play with morph influence in our scene, we have to play with animationGroup to simulate interaction with morph.

  5. How to add events to animationGroup. Is required to add the even to each animatable from group, but do the action from event only one time, not for all animatable.

To add.
clone - How to clone a GLB model and play seperate animation on each clone?, -

1 Like

One more question
6. I saw files which has skeleton and animationGroup too. (I’m talking only about gltf/glb files)
Are there situations when we can use animations from skeleton instead of animationGroup? Or for these extensions animationGroup is like a ‘must’, and it is not recomanded to use skeleton?

This is correct!

1 Like
  1. Animationgroups are helper and you can decide to use animations directly if you want. Up to you
1 Like

I’m not totally sure I understand the question, but if you mean morph targets are animated by animations which are grouped in animation groups, then yes. Each part can also be manipulated individually.

1 Like

Hey @bghgary, this is clear now.

It remains the 5th question, related to this.
I want to manipulate them somehow, as example here I can use a slider and play with morph influence, but
with animationGroup how to do this?
I tried with animation weight but seems is not working very well.

Thanks for your time :wink:

Perhaps you are looking for the goToFrame function?

1 Like

Oki, I’ll try it and let you know.

Yeeeees. This was
Thanks. I’ll try with a mesh with multiple morphtargets.

1 Like

One more question here :slight_smile:

This is the best way to add events to animationGroup?
Or there is a better way?
I’m asking because this looks a little bit too complicate, and ‘heavy’ if I have more than 400 animatable in the animationGroup. Thanks :wink:

We could simplify it with a function at Animationgroup level but ultimately it will do exactly that

1 Like

Great! Thanks :muscle: