Animation current frame

I’m not sure if the conversation has moved on from this point, but would using speedRatio be an option?

Load Animated Character | Babylon.js Playground (babylonjs.com)

After clicking on the canvas, press (or repeatedly press) the spacebar to see the animation get “wound up,” then slow to a stop again once you stop pressing. I didn’t do it with scrolling in this case (I think the Playground was eating my scroll, so I just switched to keydown to save time), but the idea is the same. If you look at lines 64 through 75, I essentially tether the animation’s speedRatio to a variable that decays to zero (line 71), then boost that value whenever I receive a certain event (in my case keydown, but you could use scroll). This is tantamount to the “winding it up” operation you mentioned, and by changing the increment and decay rate you can change the behavior by which the animation slows down or speeds up. You can even go backwards, I think, by setting your speedRatio negative. Not sure if this does quite what you’re looking for or if you’ve already solved it a way you’re happy with, but this might at least give another possibility. :slight_smile:

1 Like