360 degree rotationQuaternion animation?

hello guys,

I’m trying to animate a quaternion to rotate multiple times (more than 360 degrees).
it doesn’t seem to work since 1 or more complete turns are the same as no turns at all and for eg 1,5 turn is the same as 0.5 turn

one approach is adding is middle keyframe and go from 0 to 180 then from 180 to 360 like so : https://playground.babylonjs.com/#KUUK7X#1

is there a better way to achieve that in 2 keyframes ? (especially if I want to rotate the object multiple times)

here’s a playground describing the situation


There’s no way to have quaternions (or rotation matrices for that matter) encode a rotation outside the 0…2*PI range because of the way they are constructed (they use the sin/cos functions).

The easiest way would be to reschedule the animation once it is over (with animationGroup.onAnimationGroupEndObservable for eg).

Or you can loop the animation and stop it after some time.

1 Like

true true,

I totally agree. but looping or rescheduling it onAnimationEnd will not be the optimal solution if we’re sequencing multiple animations. (e.g :object rotates on Z axis 45 degrees, then perform a 360 on Y)

I think to most optimal solution here is to add that middle keyframe, but it will have a not smooth output if the animation has an easing applied, Like so :

Just came across this forum post and I was super excited for this new feature !
Thanks @Evgeni_Popov

this will allow us to have that half rotation solution even with easing applied, just tested it and the results are really promising :grin: