|
@@ -44,6 +44,15 @@ export class WebXRCamera extends FreeCamera {
|
|
|
// first frame - camera's y position should be 0 for the correct offset
|
|
|
this._firstFrame = true;
|
|
|
});
|
|
|
+
|
|
|
+ // Check transformation changes on each frame. Callback is added to be first so that the transformation will be
|
|
|
+ // applied to the rest of the elements using the referenceSpace object
|
|
|
+ this._xrSessionManager.onXRFrameObservable.add((frame) => {
|
|
|
+ if (!this._firstFrame) {
|
|
|
+ this._updateReferenceSpace();
|
|
|
+ }
|
|
|
+ this._updateFromXRSession();
|
|
|
+ }, undefined, true);
|
|
|
}
|
|
|
|
|
|
private _updateNumberOfRigCameras(viewCount = 1) {
|
|
@@ -74,18 +83,6 @@ export class WebXRCamera extends FreeCamera {
|
|
|
this.rigCameras[1].outputRenderTarget = null;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Updates the cameras position from the current pose information of the XR session
|
|
|
- * @param xrSessionManager the session containing pose information
|
|
|
- */
|
|
|
- public update() {
|
|
|
- if (!this._firstFrame) {
|
|
|
- this._updateReferenceSpace();
|
|
|
- }
|
|
|
- this._updateFromXRSession();
|
|
|
- super.update();
|
|
|
- }
|
|
|
-
|
|
|
private _updateReferenceSpace(): boolean {
|
|
|
// were position & rotation updated OUTSIDE of the xr update loop
|
|
|
if (!this.position.equals(this._referencedPosition) || !this.rotationQuaternion.equals(this._referenceQuaternion)) {
|