Hello!
I created a .glb model with Blender and able to successfully start an animation on click.
I’m not very fond of Blender and would prefer to program the animation to play reversed, rather than animate the reversed animation…
Is there a simple way to play the animation reversed?
in THREE you can simply set the AnimationMixer.timeScale to a minus number i believe, I’m not 100% on this but you should be able to use something like the following in r3f…
The AnimationAction.timeScale has the same effects.
The Mixer.timeScale is the global effects for all AnimationActions controlled by the mixer, while the AnimationAction.timeScale is the independent effects for AnimationAction self.
I found that the negative timeScale alone simply moved the animation instantly back to its starting point. I tried the solution suggested at Animation jump when timeScale changes sign in the first loop when using LoopPingPong mode · Issue #19151 · mrdoob/three.js · GitHub, but got errors, so adapted it by setting the loop initially to ping pong as suggested there:
action.setLoop( THREE.LoopPingPong );
then, after it started, but before it reached the desired endpoint, resetting it to run only once:
setTimeout(function(){ action.setLoop( THREE.LoopOnce );}, 1000);
I tested it down to 100ms, which was ok, but it failed to instant at 10ms. If the reset time is too late, it will loop one extra time, then stop.
For me setting the time again wasn’t necessary. Setting the time was causing it to jump to the end for some reason. Instead, I set the timeScale to its inverse:
action.timeScale = -action.timeScale
This also preserves the duration that I had set on the action, which was different than the underlying clip.