# Tween.js how to do a yoyo animation

**URL:** <https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073>\
**Category:** Questions\
**Tags:** tweenjs\
**Created:** [February 2, 2021, 4:26pm UTC](https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073 "2021-02-02T16:26:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![espace3d](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/espace3d/32/26134_2.png) [@espace3d](https://discourse.threejs.org/u/espace3d)\
**Post date:** [February 2, 2021, 4:26pm UTC](https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073/1 "2021-02-02T16:26:53Z")

</div>

Hi,

Sorry first for this stupid question but really i don’t sucess to make a simple tween with yoyo on my cube. (i come from Phaser and tween is just a formality)

i have follow the RTFM but i don’t sucess…

> **[tweenjs/tween.js](https://github.com/tweenjs/tween.js/)**
>
> JavaScript animation engine. Contribute to tweenjs/tween.js development by creating an account on GitHub.

Could you tell me where i’m wrong ?  
https://codepen.io/ogames/embed/preview/vYyOaXY?height=300&slug-hash=vYyOaXY&default-tabs=js,result&host=https://codepen.io

Thanks

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/20864_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [February 2, 2021, 5:03pm UTC](https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073/2 "2021-02-02T17:03:54Z")

</div>

Use the tween lib included with threejs

[https://jsfiddle.net/26tgaufc/13/](https://jsfiddle.net/26tgaufc/13/)

![demo1](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/7/6/7655b753a762b31a9fcf00cb195f1f6000b7bf33.gif)

---

<div class="post-metadata">

**Author:** ![espace3d](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/espace3d/32/26134_2.png) [@espace3d](https://discourse.threejs.org/u/espace3d)\
**Post date:** [February 3, 2021, 3:36am UTC](https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073/3 "2021-02-03T03:36:41Z")

</div>

Hi,

Thanks for your jsfiddle. In fact the libs used in your snippet is the same that i would use : tween.js.

I miss tween.update() in animate (on phaser it’s not necessary) and i success with yoyo.  
https://codepen.io/ogames/embed/preview/vYyOaXY?height=300&slug-hash=vYyOaXY&default-tabs=js,result&host=https://codepen.io

Thanks

---

<div class="post-metadata">

**Author:** ![asdrubal](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/asdrubal/32/42795_2.png) [@asdrubal](https://discourse.threejs.org/u/asdrubal)\
**Post date:** [January 11, 2025, 5:57pm UTC](https://discourse.threejs.org/t/tween-js-how-to-do-a-yoyo-animation/23073/4 "2025-01-11T17:57:53Z")

</div>

This is a recurrent question. Most of the time, it’s because we don’t set a repetition.

```js
tween.repeat(0) // 1 normal

```

Tween.yoyo needs some repetition to happen:

```js
tween.repeat(1) // 1 normal, 1 reverse
tween.repeat(2) // 1 normal, 1 reverse, 1 normal
tween.repeat(3) // 1 normal, 1 reverse, 1 normal, 1 reverse
tween.repeat(-1) // infinity

```

Sometimes I fall into this question too 😄
