Animatable not working

var extrude = scene.getAnimationGroupByName("Key.Action.001"); // works!
extrude.pause(true); // works! stops the whole animation
extrude.animatables[0].goToFrame(30); //works which goes to the first animatable at frame 30

//This code isn't working
extrude.animatables[0].play(); //plays the whole animation group instead of the first animatable

Please write a valid repro PG that we can test.

ok sure, give me a min

play is not part of animatable Babylon.js docs
use restart instead

yes, but i just wanted to play it once, when i set it to restart() it keeps looping

cc @Evgeni_Popov

animatables[1].goToFrame(number)is only noticeable when paused or when animation is running.

Also, the relationship between play and pause is related, and the relationship between start and stop is related.

Check the following PG for all cases where no error occurs in the given relationship.
As @Cedric said, you can use restart, but it seems to me that it only works with the play and pause rules.


so what do i do to only play it once, the example you gave plays both animatable 0 and 1 at the same time even if it played it once. I just want to play animatable 1 by itself

It’s not smooth
I have an appointment, so I’ll check further tomorrow. Can someone answer that question?

1 Like

Animatables of an animation group are not really meant to be manipulated individually. They should be managed through the AnimationGroup methods only.

If you want to manage animatables individually, you should probably create them yourself by calling scene.beginDirectAnimation. See how AnimationGroup.start does it:

PG from @11128 does work, but a small correction must be performed in the “3” case:


I’m not sure if that playground demo will scale with my project, for example:

I will have 1 mesh with, say, 15 extrude animations under animatables.
Using the logic of the playground you made, would I have to stop the remaining 14 animatables manually? how would that even look like

Are all of them morph targets? Would it be easier for you manipulating the morph targets directly?

Maybe you could create separate animations in the DCC tool (so that you have separate animation groups), and only play the ones that have to be played?

1 Like

The animations are made using blender shape keys, so all the animatable are placed into one animation group. In the playground the mesh has 2 shape keys stored inside, later on it will consist of 15 shape keys under the same animation group.

Solution 1: Have the ability to point to a shape key, aka target, by it’s name

const morph = scene.getMeshByName("Cube.010").morphTargetManager;


^^^Here we see that the target name is stored

//But when you try to extract it using the morph.getTarget it doesn't seem to work

const ext = morph.getTarget("scale_1"); 
console.log(ext); //returns undefined?

@Joe_Kerr showed in their attempt

Which means i can’t use the name system to properly locate the shape keys i want to play or stop.
So, when it comes to managing large numbers of shape keys and individually stopping them and playing them it’s hard to work with using arrays

Solution 2: Just make it so that you can play the animatable by just calling 1 line of code
morph.animatables[0].play(); //this can simply isolate that target and play it.
^^^Here is my blender shape Key property, in babylon it keeps the same array structure so i can know which arrays will store my scale animations and which array will store my extrude animations.

For example i will know:
my scale array is from [0] to [1]
my extrude array is from [2] to [3]
So, working with the array system will be sufficient as long as it give me the ability to only play the specified target.

morph.getTarget("scale_1"); //returns undefined?? wtf??!

I laught :smiley:

getTarget gets a number :wink:

And because I’m a lovely person:

add getTargetByName to MorphTargetManager by deltakosh · Pull Request #15134 · BabylonJS/Babylon.js (


Oh oops sorry, I forget that one. It was more like a comment to self which got cut off due to split screen :flushed:

1 Like