浏览代码

use resetPose to reset the current rotation.

Raanan Weber 9 年之前
父节点
当前提交
767fe35257
共有 1 个文件被更改,包括 4 次插入23 次删除
  1. 4 23
      src/Cameras/VR/babylon.webVRCamera.ts

+ 4 - 23
src/Cameras/VR/babylon.webVRCamera.ts

@@ -17,7 +17,6 @@ module BABYLON {
         private _oldSize: BABYLON.Size;
         private _oldHardwareScaleFactor: number;
 
-        private _initialQuaternion: Quaternion;
         private _quaternionCache: Quaternion;
 
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = true, vrCameraMetrics: VRCameraMetrics = VRCameraMetrics.GetDefault(), private webVROptions: WebVROptions = {}) {
@@ -78,10 +77,6 @@ module BABYLON {
                     //Flip in XY plane
                     this.rotationQuaternion.z *= -1;
                     this.rotationQuaternion.w *= -1;
-                    if (this._initialQuaternion) {
-                        this._quaternionCache.copyFrom(this.rotationQuaternion);
-                        this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
-                    }
                 }
 
             }
@@ -115,24 +110,10 @@ module BABYLON {
             return "WebVRFreeCamera";
         }
 
-        public resetToCurrentRotation(axis: BABYLON.Axis = BABYLON.Axis.Y) {
-            //can only work if this camera has a rotation quaternion already.
-            if (!this.rotationQuaternion) return;
-
-            if (!this._initialQuaternion) {
-                this._initialQuaternion = new BABYLON.Quaternion();
-            }
-
-            this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
-
-            ['x', 'y', 'z'].forEach((axisName) => {
-                if (!axis[axisName]) {
-                    this._initialQuaternion[axisName] = 0;
-                } else {
-                    this._initialQuaternion[axisName] *= -1;
-                }
-            });
-            this._initialQuaternion.normalize();
+        public resetToCurrentRotation() {
+            //uses the vrDisplay's "resetPose()".
+            //pitch and roll won't be affected.
+            this._vrDevice.resetPose();
         }
     }
 }