Skip to content

Commit 286ecdd

Browse files
committed
RH WebXR camera fix
This change applies the recent right hand camera fixes from PR BabylonJS#16691 to the WebXR camera.
1 parent 073f3ec commit 286ecdd

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

packages/dev/core/src/XR/webXRCamera.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class WebXRCamera extends FreeCamera {
198198
target.subtractToRef(this.position, tmpVector);
199199
tmpVector.y = 0;
200200
tmpVector.normalize();
201-
const yRotation = Math.atan2(tmpVector.x, tmpVector.z);
201+
const yRotation = Math.atan2(tmpVector.x, tmpVector.z) + (this._scene.useRightHandedSystem ? Math.PI : 0);
202202
this.rotationQuaternion.toEulerAnglesToRef(tmpVector);
203203
Quaternion.FromEulerAnglesToRef(tmpVector.x, yRotation, tmpVector.z, this.rotationQuaternion);
204204
}
@@ -222,8 +222,6 @@ export class WebXRCamera extends FreeCamera {
222222
this._cache.maxZ = far;
223223
}
224224

225-
private _rotate180 = new Quaternion(0, 1, 0, 0);
226-
227225
private _updateFromXRSession() {
228226
const pose = this._xrSessionManager.currentFrame && this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);
229227
this._lastXRViewerPose = pose || undefined;
@@ -256,8 +254,6 @@ export class WebXRCamera extends FreeCamera {
256254
this._referencedPosition.z *= -1;
257255
this._referenceQuaternion.z *= -1;
258256
this._referenceQuaternion.w *= -1;
259-
} else {
260-
this._referenceQuaternion.multiplyInPlace(this._rotate180);
261257
}
262258

263259
if (this._firstFrame) {
@@ -314,8 +310,6 @@ export class WebXRCamera extends FreeCamera {
314310
currentRig.position.z *= -1;
315311
currentRig.rotationQuaternion.z *= -1;
316312
currentRig.rotationQuaternion.w *= -1;
317-
} else {
318-
currentRig.rotationQuaternion.multiplyInPlace(this._rotate180);
319313
}
320314
Matrix.FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, currentRig._projectionMatrix);
321315

0 commit comments

Comments
 (0)