TargetCamera rotationQuaternion bug

There appears to be a bug where setting the “rotationQuaternion” of a target camera will not cause the view matrix to be updated for very specific quaternion values. See the linked playground to demonstrate the bug: https://playground.babylonjs.com/#WH5VU0#2

The source of this issue looks to be the following lines of code in the TargetCamera class where it only updates the “UpVector” if the Z component of either the rotationQuaternion or the rotation vector has changed. This is not a safe optimization though since the up vector is only the same if only the y component changes, so therefore checking for only a change in the Z component is insufficient to determine that the up vector is still unchanged (see my comments on the affected lines).

cc @PolygonalSun

I don’t see any reason why it shouldn’t rotate if z = 0 and x != 0 but lemme check with the team first to see why this check was set up this way.

Just wanted to update that I have a PR out to address this: TargetCamera: Check for changes on all axes when handling rotations by PolygonalSun · Pull Request #13700 · BabylonJS/Babylon.js (github.com)

1 Like