speedRatio effect in animation?

I was going to update the documentation on speedRatio needing to be negative for reversing animations in AnimationGroup.

i found a different section of documentation that mentions speedRatio. and I went to the playground.

for fun, i just changed speed to a negative value, and the animation…changed?


it appears that the speedRatio signage is applied to the value of of the key frame. so when i make it a negative number, instead of scaling in, it scales out.

is this by design? All of the documentation I’ve seen indicates the speedRatio is about speed of animation. I guess when going backwards in an animation, to reverse the operation, negating the value in the key is how you do it.

I feel like speedRatio should be an absolute value, and the engine determines neg/positive depending on if frame From is < frame To.

also, a helper .reverse() (or .playReverse) function might nice. right now to start an animation, you invoke .start(). to reverse, you have to use .start(true/false, speed, from, to)

Well this is how it is intended to work :slight_smile:
Speed can be negative to go back in time

It was initially only a positive value but per users demand we allowed it to be negative to go backward as it was apparently the more obvious way for a majority of users

I guess I’m confused about the definition of backward.

to me, when i say “reverse an animation” i basically mean flip the keys, so it goes from last to first.

but maybe people mean a negative speed should invert the effect?

I created a PG to help illustrate the different effects possible.

If you notice, Play and Reverse keys look proper.

going from key 0 to 100 with a negative speedRatio (-1) though, seems to reverse the scaling to go out to 2.5 times, which I don’t know where that math comes from, tbh. it also ignores the looping value, and keeps looping. (its set to false)

thanks to your update last night, using negative speedRatio with keys 100 to 0 doesn’t cause an error, and it properly reverses the animation keys.

but the inconsistency with the forward with negative remains. not sure what is expected behavior.


This could be a bug, or maybe just a documentation clarification about what to expect is all that is needed.

although if an inversion effect is wanted, maybe that should be a seperate method, like play/stop/etc?

This is definitely a bug. Your PG should work.
It will be fixed with next nightly (but not before Monday as I’m in a airport now with a terrible connection)

Sounds good. Does that mean the preview babylon.js will also be updated? Or is that a different release cycle?

Also, I kind of like the inverse thing as a feature. No idea if that’s something the community cares for, but take the animation and multiply the value by -1 / vector3.negate sounds like a way to save creating a brand new animation for that.

Yep the preview is updated byt the nightly process

If you are ok to submit a PR for your idea, we can discuss about it there :wink: