add setProgress to Tween
add Tween.setProgress to set current progress, then call update callback
@kanbang Hello. Thanks for making this idea! A few things:
- Is it worth adding? We can currently update the tween by manually calling
update. Are there any downsides you experience with that, compared tosetProgress? - The new code has a duplicate of the following code for the most part: https://github.com/tweenjs/tween.js/blob/d8b4f09fb3e2f56676d262ba139391eb3b486b10/src/Tween.ts#L361-L371 If we were to get this in, we would need to consolidate the duplication so that it is easy to manage and won't break on accident (for example if someone changes one part but not the other).
- Automated tests didn't pass (needs formatting fixes)
this would be handy
- set progress to 0.5 then call .start(), it starts from this point
- this might be used to scrub a tween ?
- this will be useful when there's a very long tween and you just to playback the last quarter or from a certain section
I can see how it might be useful, but also trying to avoid complexity. The behavior of going backwards in time is not very well defined (f.e. other features like yoyo, repeat, etc, might break in unexpected ways).
For now, animating the time value backwards for a single tween should work. This is good enough for now. Just map a value between 0 and 1 to the time range.
When we eventually implement Timeline, we'll have a simple setup without everytying being tightly coupled in a single class, and scrubbing will be easier and cleaner. Closing in favor of going that direction (and for now just map your time values on a single Tween but don't expect all features to work with negative time progression).
@kanbang thanks for trying this feature!