tweenjs / tween.js

JavaScript/TypeScript animation engine

Home Page:https://tweenjs.github.io/tween.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to reverse chained tweens?

romarybi opened this issue · comments

commented

I'm trying to animate an object in three.js. I have a tween group that contains chained tweens. The tweens basically change the position of an object over time. I allow the user to select the 'currentTime' which calls tweenGroup.update(currentTime). The problem is that once a tween has finished, it is impossible to go back to it, only forward. Reversing inside the current tween however works fine. Am I missing something or is this impossible to achieve?

commented

Solved by adding true as second param of update(). This stops the group from deleting the tween after it finishes. This should really be included somewhere in the docs though.

Glad you got it figured out!

If you can provide a small code sample or doc improvement, that'd be great.

There are certainly use cases we may not have thought about, but we've been adding all the ones we can think of to the unit tests.

I've also been contemplating removing chaining, yoyo, and similar things from Tween, and moving those concepts to a better organized Timeline class with Keyframe instances, etc, and Tween would be literally just a tween. So far it's just ideas in my head though.

commented

I don't think a code sample is necessary in this case, the feature is quite self-explanatory. The problem was finding that it exists so a simple mention of it would suffice in my opinion.

Regarding the addition of timeline and keyframes, that would be amazing! That's exactly what I needed. At the moment I create a bunch of chained tweens and save the start time of the first one. I then update the tween group by startTime + elapsedTime where elapsedTime can be changed by the user.

I'm sure I'm not the only one who will find a Timeline class useful. Hopefully it'll happen :)