Key order for animations matters

I have a situation where I get sporadic updates from nodes on the network. These then get used to generate paths and timelines. I was dumping them into Animations and recalculating an AnimationGroup. Nothing was moving but all the isStarted isPlaying were true, from & to were correct.

https://www.babylonjs-playground.com/#CBGEQX#46

To display the bug I took the animation example and reordered… out of order.

In the same vain, animation.goToFrame doesn’t appear so have any effect. Am I not understanding how to use animation groups?

Your key frames MUST be sorted , you cannot have them in random order
https://www.babylonjs-playground.com/#CBGEQX#47

Yeah I see that, I’m saying there is no doc saying that. Also goToFrame https://www.babylonjs-playground.com/#CBGEQX#48 doesn’t seem to have an effect.

Yes I will update the doc (but you can also help by doing a PR on the doc itself :wink: ). Having a doc is clearly the more complex task of an OSS project

for goToFrame, the animationGroup must be playing first: https://www.babylonjs-playground.com/#CBGEQX#49

Gotcha, I have a “scrubber” situation so I’ll have to turn the group on and off to “snap” the group. I’m happy to add the docs, just checking that I understood the behavior. I mean if it must maybe I should add a sort on setKeys()?

In regards to the must be playing constraint I saw the check in goToFrame. In my case it’d probably work if I removed that. Is there a requirement somewhere down the chain that make playing necessary?

We try to stay performant at first so adding a sort is not a “by default” options but this could be a fucntion that people can call if they need it

for the constraint on goToFrame it is for all the events linked to a playing animations (we want to make sure that everything is in place before moving)