浏览代码

set default non-vr camera

Raanan Weber 5 年之前
父节点
当前提交
61c7a4cc2f
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/Cameras/XR/webXRCamera.ts

+ 4 - 1
src/Cameras/XR/webXRCamera.ts

@@ -73,7 +73,10 @@ export class WebXRCamera extends FreeCamera {
      * @param otherCamera the non-vr camera to copy the transformation from
      * @param resetToBaseReferenceSpace should XR reset to the base reference space
      */
-    public setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace: boolean = true) {
+    public setTransformationFromNonVRCamera(otherCamera: Camera = this.getScene().activeCamera!, resetToBaseReferenceSpace: boolean = true) {
+        if (!otherCamera || otherCamera === this) {
+            return;
+        }
         const mat = otherCamera.computeWorldMatrix();
         mat.decompose(undefined, this.rotationQuaternion, this.position);
         // set the ground level