tween.js icon indicating copy to clipboard operation
tween.js copied to clipboard

add setProgress to Tween

Open kanbang opened this issue 4 years ago • 1 comments

add Tween.setProgress to set current progress, then call update callback

kanbang avatar Apr 28 '21 05:04 kanbang

@kanbang Hello. Thanks for making this idea! A few things:

  1. Is it worth adding? We can currently update the tween by manually calling update. Are there any downsides you experience with that, compared to setProgress?
  2. 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).
  3. Automated tests didn't pass (needs formatting fixes)

trusktr avatar Apr 28 '21 23:04 trusktr

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

optimus007 avatar May 09 '23 06:05 optimus007

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).

trusktr avatar Jan 15 '24 07:01 trusktr

@kanbang thanks for trying this feature!

trusktr avatar Jan 15 '24 07:01 trusktr