Possible bug: Change in camera rotation behaviour in Babylon 8

I’ve found a change in behaviour in Babylon 8 which might be a bug.

In Babylon 7, when the scene is in right-handed mode, setting the rotation quaternion of a camera sets the absolute rotation of that camera to 180 degrees different to the rotation quaternion set. For example, if the camera’s rotation quaternion is set to identity (0, 0, 0, 1), then that camera’s absolute rotation is (0, 1, 0, 0).

In Babylon 8, the same thing happens if the scene is set into right-handed mode after the camera is created, but if the scene is already in right-handed mode then the behaviour is different: Setting the rotation quaternion of the camera causes the absolute rotation to be the same.

I have a repro here: https://playground.babylonjs.com/#FVBWQQ#3

Try running the scene and looking at the log with Babylon 7 and Babylon 8. Babylon 7:

Creating a camera with scene in left handed system
absoluteRotation = {X: 0 Y: 0 Z: 0 W: 1}
rotationQuaternion = undefined
Setting useRightHandedSystem = true
Setting rotationQuaternion to identity
absoluteRotation = {X: 0 Y: 1 Z: 0 W: 0}
rotationQuaternion = {X: 0 Y: 0 Z: 0 W: 1}
Creating a camera with scene already in right-handed system
absoluteRotation = {X: 0 Y: 1 Z: 0 W: 0}
rotationQuaternion = undefined
Setting rotationQuaternion to identity
absoluteRotation = {X: 0 Y: 1 Z: 0 W: 0}
rotationQuaternion = {X: 0 Y: 0 Z: 0 W: 1}

Babylon 8:

BJS - [18:30:02]: Babylon.js v8.19.1 - WebGL2 - Parallel shader compilation
Creating a camera with scene in left handed system
absoluteRotation = {X: 0 Y: 0 Z: 0 W: 1}
rotationQuaternion = undefined
Setting useRightHandedSystem = true
Setting rotationQuaternion to identity
absoluteRotation = {X: 0 Y: 1 Z: 0 W: 0}
rotationQuaternion = {X: 0 Y: 0 Z: 0 W: 1}
Creating a camera with scene already in right-handed system
absoluteRotation = {X: 0 Y: 1 Z: 0 W: 6.123234262925839e-17}
rotationQuaternion = undefined
Setting rotationQuaternion to identity
absoluteRotation = {X: 0 Y: 0 Z: 0 W: 1} <<< NOTE ABS IS SAME AS ROTATION SET
rotationQuaternion = {X: 0 Y: 0 Z: 0 W: 1}

I’m wondering what the desired behaviour is. Should the absoluteRotation and the set rotationQuaternion be the same, or is the idea that in right-handed mode absolute is always 180 degrees rotated vs. the rotationQuaternion that’s set, as was the case in Babylon 7?

@bghgary

It’s because of this: Breaking change in target camera rotations when using right-handed system - Breaking Changes - Babylon.js

Also note that changing handedness on a scene (i.e., changing useRightHandedSystem) after creating scene objects will result in undefined behavior.

2 Likes

Thank you! So the new behaviour is correct, and I should make sure I don’t create cameras before setting the scene to right handed (which would then mean I would consistently see the new, correct behaviour for all cameras).

Thanks!

2 Likes