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
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)
Thank you so much. It worked!!! And how can I turn off the first animation, like I can switch the isEnabled in the debugLayer and it works but when I click on the āCopy to clipboardā and paste it, it is coming as āundefinedā. How can I disable the first animation?
you can call scene.stopAllAnimations()
on model-loaded to stop any animation running. would that do the job?
Ok, so implemented that and working when I donāt need any animations running. And for to disabling the specific animation, I used the scene.getNodeByName(āAnimation Nameā).setEnabled(false);
Many thanks!!!