ソースを参照

fixes
1) using _get instead of getViewMatrix for caching and global positioning
2) Gamepad now works correctly

Raanan Weber 8 年 前
コミット
7e0c474592

+ 5 - 1
src/Cameras/VR/babylon.webVRCamera.ts

@@ -233,12 +233,16 @@ module BABYLON {
             // is rotation offset set? 
             if (!Quaternion.IsIdentity(this.rotationQuaternion)) {
                 this.rotationQuaternion.toRotationMatrix(this._tempMatrix);
-                this._webvrViewMatrix.multiplyToRef(this._tempMatrix, this._webvrViewMatrix);
+                this._tempMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
             }
 
             return this._webvrViewMatrix;
         }
 
+        public _isSynchronizedViewMatrix() {
+            return false;
+        }
+
         protected _getWebVRProjectionMatrix(): Matrix {
             var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
             //babylon compatible matrix

+ 4 - 2
src/Cameras/babylon.camera.ts

@@ -617,7 +617,8 @@
                         //this._rigCameras[0].setCameraRigParameter('eyeParameters', leftEye);
                         this._rigCameras[0]._cameraRigParams.vrWorkMatrix = new Matrix();
                         this._rigCameras[0].getProjectionMatrix = this._getWebVRProjectionMatrix;
-                        this._rigCameras[0].getViewMatrix = this._getWebVRViewMatrix;
+                        this._rigCameras[0]._getViewMatrix = this._getWebVRViewMatrix;
+                        this._rigCameras[0]._isSynchronizedViewMatrix = this._isSynchronizedViewMatrix;
 
                         //Right eye
                         this._rigCameras[1].viewport = new Viewport(0.5, 0, 0.5, 1.0);
@@ -626,7 +627,8 @@
                         this._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
                         this._rigCameras[1]._cameraRigParams.vrWorkMatrix = new Matrix();
                         this._rigCameras[1].getProjectionMatrix = this._getWebVRProjectionMatrix;
-                        this._rigCameras[1].getViewMatrix = this._getWebVRViewMatrix;
+                        this._rigCameras[1]._getViewMatrix = this._getWebVRViewMatrix;
+                        this._rigCameras[1]._isSynchronizedViewMatrix = this._isSynchronizedViewMatrix;
                     }
                     break;
 

+ 3 - 2
src/Tools/babylon.extendedGamepad.ts

@@ -27,7 +27,7 @@ module BABYLON {
     export class PoseEnabledController extends Gamepad implements PoseControlled {
         devicePosition: Vector3;
         deviceRotationQuaternion: Quaternion;
-        deviceScaleFactor: number;
+        deviceScaleFactor: number = 1;
 
         public position: Vector3;
         public rotationQuaternion: Quaternion;
@@ -63,6 +63,7 @@ module BABYLON {
                 this.deviceScaleFactor = this._poseControlledCamera.deviceScaleFactor;
             }
             var pose: GamepadPose = this.vrGamepad.pose;
+            this.updateFromDevice(pose);
 
             if (this._mesh) {
                 this._mesh.position.copyFrom(this._calculatedPosition);
@@ -98,7 +99,7 @@ module BABYLON {
                     // if the camera is set, rotate to the camera's rotation
                     this.rotationQuaternion.multiplyToRef(this.deviceRotationQuaternion, this._calculatedRotation);
                     if (this._poseControlledCamera) {
-                        this._poseControlledCamera.rotationQuaternion.multiplyToRef(this._calculatedRotation, this._calculatedRotation);
+                        this._calculatedRotation.multiplyToRef(this._poseControlledCamera.rotationQuaternion, this._calculatedRotation);
                     }
                 }
             }