Negative animation speed ratio behaves differently between beginAnimation and beginDirectAnimation

When have negative speed ratio, beginAnimation will jump to the last frame and stop, while beginDirectAnimation will just stop at the first frame.

I think the expected result for both functions is to reverse the animation, like animationGroup do.

The most weird thing is the two function behaves differently.

There is no shared playground in the link, would you be able to provide the snippet?

Sorry for the wrong link. I have updated it.

1 Like

So - I agree with everything you wrote TBH.

The reason for the different behavior are these lines:

Babylon.js/packages/dev/core/src/Animations/animatable.ts at master · BabylonJS/Babylon.js (github.com)

This flips the to and from (but not the speed ratio). I will need to dig in a bit and see why it is done this way. If we are already flipping to and from, we should also revert the speed ratio (which would reverse the animation).

1 Like

Just something quick - the to/from should have been adjusted. If adjusting to the actual frames you have provided, the direct animation works as expected: Negative Animation Speed | Babylon.js Playground (babylonjs.com). Still figuring out a few things.

1 Like

This solves the issue, but I would be happy to get the opinion of other members of the team :slight_smile:
treat negative speed ratio at the animate function by RaananW · Pull Request #15509 · BabylonJS/Babylon.js (github.com)

1 Like