Hello!
I have been working on a WebXR experience, which made easy thanks to you!
When I test the WebXR scene with a Meta Quest 3S device, I inconsistently have a TypeError at XRRigidTransform constructor “invalid position”, at WebXRCamera’s _updateReferenceSpacemethod. To guard against this issue, I am setting the reference space after entering XR as follows:
xrExperience.baseExperience.enterXRAsync('immersive-vr', 'local-floor').then((sessionManager) => {
sessionManager.referenceSpace = sessionManager.referenceSpace.getOffsetReferenceSpace(new XRRigidTransform(
XR_INIT_QUATERNION, // 0, 0, 0, 1; it gives error if w !== 1
XR_INIT_QUATERNION, // 0, 0, 0, 1
));
This seemed to be helping a little, but still I have the same error sometimes. It freezes the front frame and everything around becomes black. Unfortunately I am not able to debug or reproduce the issue in a PG. It is either occurring randomly or some specific headset transformation causes the calculations to throw the error.
I tried to reproduce with WebXR Emulator by Meta, but it works fine. A side note is I am using webxr-polyfill if navigator.xr is not present.
Thank you very much!
// @babylonjs/core/XR/webXRCamera.js
...
_updateReferenceSpace() {
// were position & rotation updated OUTSIDE of the xr update loop
...
transformMat.decompose(undefined, this._referenceQuaternion, this._referencedPosition);
const transform = new XRRigidTransform({
x: this._referencedPosition.x / this._xrSessionManager.worldScalingFactor,
y: this._referencedPosition.y / this._xrSessionManager.worldScalingFactor,
z: this._referencedPosition.z / this._xrSessionManager.worldScalingFactor,
}, {
x: this._referenceQuaternion.x,
y: this._referenceQuaternion.y,
z: this._referenceQuaternion.z,
w: this._referenceQuaternion.w,
});
this._xrSessionManager.referenceSpace = this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(transform);
}
}
