Yoyo/mirror looping

If would be great IMO to support yoyo/mirror animating, where it loops by reversing direction when it reaches the end instead of restarting at the beginning. It seems pretty common to want to animate the position or rotation back and forth this way but it’s not so convenient ATM… Can manually duplicate and reverse the keys, but that’s not as convenient (e.g. requires manual easing) and doesn’t work with CreateAndStartAnimation.

2 Likes

You can also simply add a callback to onAnimationEnd and set the speed to speed x -1

1 Like

Thanks I tried it and it works the first time the animation ends, but the callback is only ever called that first time so it stops working after the first loop… Not sure if I did it how you meant thou? :thinking:

1 Like

Will get back to you tomorrow:)

2 Likes

This was bothering me as well and I use the duplicated keys approach as well but it would be really nice to have Animation.ANIMATIONLOOPMODE_YOYO :slight_smile:

1 Like

Here we are: Babylon.js Playground (babylonjs.com)

But I agree with you: do you mind creating an issue on the repo? I will add that YOYO mode after 5.0 release :slight_smile:

2 Likes

Thanks @Deltakosh - here’s the issue/request for it. :slight_smile:

2 Likes

Will work on it as soon as 5.0 is out :wink:

2 Likes