How to run actions contained in the glb using Babylon.js?

So, I have a .glb file and when I open it in the Sandbox, there is a drop-down list in which about 5 actions are there. But when I open the glb via Babylon.js on a website, only 1st action is being played, on a loop. How can I run all the actions which is in the Blender file(.glb)?

Hello,

There are several ways.


For example you can use

const anim = scene.getAnimationGroupByName("Annimation Name");
anim.start(params)

To select an animation and play it at any moment.
Have a look at this Playground


Also a usefull trigger is :

anim_0.onAnimationGroupEndObservable.add(function() {
    anim_1.start(params)
})

Where you trigger anim_1 when anim_0 ends, etc…


++
Tricotou

2 Likes

Alright, many thanks. But when I’m playing the 2nd action, 1st action is playing alongside with the 2nd one. Is there a way each animation is played after the previous one ended? Like when 1st ends, 2nd starts.

You can stop the first one using animationGroup.stop(), or prevent it from looping by setting loopAnimation to be false (on the animation you have referenced)