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.
RaananW
September 2, 2024, 12:19pm
2
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.
RaananW
September 2, 2024, 12:38pm
4
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).
RaananW
September 2, 2024, 1:15pm
5
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.
RaananW
September 2, 2024, 1:43pm
6