瀏覽代碼

Have initial created camera oriented like the previous camera

Trevor Baron 7 年之前
父節點
當前提交
01f53c9fbb
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 11 - 0
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -113,6 +113,17 @@ module BABYLON {
                 this._deviceOrientationCamera = new BABYLON.DeviceOrientationCamera("deviceOrientationVRHelper", this._position, scene);
                 this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
                 this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
+                // Set rotation from previous camera
+                if(this._scene.activeCamera instanceof TargetCamera){
+                    var targetCamera = this._scene.activeCamera;
+                    if(targetCamera.rotationQuaternion && targetCamera.rotation){
+                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
+                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
+                    }else if(targetCamera.rotation){
+                        this._deviceOrientationCamera.rotationQuaternion.copyFrom(Quaternion.RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
+                        this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
+                    }
+                }
             }
             this._scene.activeCamera = this._deviceOrientationCamera;
             this._canvas = scene.getEngine().getRenderingCanvas();