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

Slow down the tween on update

Open samuelbelolo opened this issue 5 years ago • 1 comments

Hey,

I am currently moving an object with a tween, and i would like to slow down the tween when the mouse is upon it.

What did i try :

  • Raise the tween duration when mouse is upon it inside the update function (threw tween.duration() function)
  • Change the update time parameter

But i couldn't figure it out yet. Like the timeScale function from GSAP I would be more than grateful for any help

Thanks a lot

samuelbelolo avatar May 19 '20 23:05 samuelbelolo

Tween.js doesn't have time management built in (it would be cool to add though!). You have the right idea. You'll need to either

  • stop the current tween when mouse enters and make a new tween with new starting point and new to values. It can become more verbose to make multiple tweens.
  • or adjust the time values that you pass into the update calls. F.e. when no mouse, pass previousTime + deltaTime, and when the mouse enters, pass previousTime + deltaTime / 2 to make it play at half speed.

If you figure it out, it would be interesting to know how you do it. Maybe we can come up with something to add to Tween.js.

trusktr avatar May 29 '20 18:05 trusktr