Animations with rotationQuaternion keys don't change target's rotation

Hi!
I have a question about rotation and rotationQuaternion.

I usually use glb files with animations.
And, as far as I experienced, animations about rotation are loaded as rotationQuaternion animations.
After some trials I found that rotationQuaternion Animation doesn’t change target’s rotation.
So, I just wonder if it works correctly…
(Because I went through Three.js a little bit and in Three.js I can get the updated rotation value after the quaternion animation played.)

I added PG link here
https://playground.babylonjs.com/#102L17#1

The local rotation, local rotationQuaternion, and absolute rotationQuaternion will be logged in the console after 1.5 sec.
(I used the transformNode to check something, but maybe you can ignore it.)

Sorry for my poor English and thanks in advance :slight_smile:

Hey @ynnek - I think I encountered the same issue a while back. I’ll take a look and report back.

1 Like

It’s expected, when you use rotationQuaternion (meaning when it is not null), rotation won’t be updated and will remain null (or 0/0/0), and the other way around, if you set a non null rotation, rotationQuaternion will stay null.

The local rotationQuaternion of the box is null because you don’t update it (you update the COT’s one), and box absolute rotationQuaternion is not null because it is the quaternion computed from all the box hierarchy (here, only COT).

3 Likes

Okay thank! Then I have another question.

So, if I want to get the CoT’s rotation value, do I have to compute it with q.toEulerAngles() like the PG below?

https://playground.babylonjs.com/#102L17#3

(And additionally, if there is a way to check whether an animatable is playing or not, please let me know…)

Speaking of the background, my team is making an animating tool with babylonjs and as a part of it we want our users can check the rotation value in degree.
And because I thought computations on every frame will be inefficient, I’m just trying to find the way to “get” rotation.

Yes, using toEulerAngles is the way to go to convert quaternion to rotation angles.

You can use animatable.animationStarted to know if an animation has started/ended, but you will need to set loopMode=false when calling beginAnimation(4th parameter).

1 Like

Thanks a lot for your help! :slight_smile: