Przeglądaj źródła

WebVR 1.0 adjustments

Now falling back to WebVR 1.0 correctly.
Raanan Weber 8 lat temu
rodzic
commit
e5c9231ded
2 zmienionych plików z 17 dodań i 16 usunięć
  1. 9 8
      src/Cameras/VR/babylon.webVRCamera.ts
  2. 8 8
      src/Math/babylon.math.ts

+ 9 - 8
src/Cameras/VR/babylon.webVRCamera.ts

@@ -290,7 +290,7 @@ module BABYLON {
                 if (this.getScene().useRightHandedSystem) {
                     offset[2] *= -1;
                 }
-                Matrix.TranslationToRef(offset[0], offset[1], -offset[2], Tmp.Matrix[0]);
+                Matrix.TranslationToRef(-offset[0], offset[1], -offset[2], Tmp.Matrix[0]);
 
                 this._webvrViewMatrix.multiplyToRef(Tmp.Matrix[0], this._webvrViewMatrix);
 
@@ -304,6 +304,13 @@ module BABYLON {
                         this._webvrViewMatrix.m[num] *= -1;
                     });
                 }
+
+                // update the camera rotation matrix
+                this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
+                Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
+
+                // Computing target and final matrix
+                this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
             }
 
 
@@ -322,12 +329,6 @@ module BABYLON {
                 this._webvrViewMatrix.invert();
             }
 
-            // update the camera rotation matrix
-            this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
-            Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
-
-            // Computing target and final matrix
-            this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
             return this._webvrViewMatrix;
         }
 
@@ -335,7 +336,7 @@ module BABYLON {
             if (this._cameraRigParams["specs"] === 1.0) {
                 var eyeParams = this._cameraRigParams["eyeParameters"];
                 // deprecated!!
-                Matrix.PerspectiveFovWebVRToRef(eyeParams.fieldOfView, this.minZ, this.maxZ, this._projectionMatrix, this.getScene().useRightHandedSystem);
+                Matrix.PerspectiveFovWebVRToRef(eyeParams.fieldOfView, 0.1, 1000, this._projectionMatrix, this.getScene().useRightHandedSystem);
             } else /*WebVR 1.1*/ {
                 var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
                 Matrix.FromArrayToRef(projectionArray, 0, this._projectionMatrix);

+ 8 - 8
src/Math/babylon.math.ts

@@ -516,7 +516,7 @@
          * Returns the updated Color4.  
          */
         public set(r: number, g: number, b: number, a: number): Color4 {
-            return this.copyFromFloats(r, g, b,a);
+            return this.copyFromFloats(r, g, b, a);
         }
         /**
          * Returns a string containing the hexadecimal Color4 code.  
@@ -2144,7 +2144,7 @@
         /**
          * Returns a new Vector4 set from the starting index of the passed array.  
          */
-        public static FromArray(array: number[]  | Float32Array, offset?: number): Vector4 {
+        public static FromArray(array: number[] | Float32Array, offset?: number): Vector4 {
             if (!offset) {
                 offset = 0;
             }
@@ -2328,7 +2328,7 @@
          */
         public set(width: number, height: number): Size {
             return this.copyFromFloats(width, height);
-        }        
+        }
         /**
          * Returns a new Size set with the multiplication result of the current Size and the passed floats.  
          */
@@ -2465,7 +2465,7 @@
          */
         public set(x: number, y: number, z: number, w: number): Quaternion {
             return this.copyFromFloats(x, y, z, w);
-        }        
+        }
         /**
          * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.  
          */
@@ -3949,10 +3949,10 @@
             result.m[1] = result.m[2] = result.m[3] = result.m[4] = 0.0;
             result.m[5] = yScale;
             result.m[6] = result.m[7] = 0.0;
-            result.m[8] = ((leftTan - rightTan) * xScale * 0.5) * rightHandedFactor;
-            result.m[9] = -((upTan - downTan) * yScale * 0.5) * rightHandedFactor;
-            result.m[10] = -(znear + zfar) / (zfar - znear) * rightHandedFactor;
-            // result.m[10] = -zfar / (znear - zfar);
+            result.m[8] = ((leftTan - rightTan) * xScale * 0.5)// * rightHandedFactor;
+            result.m[9] = -((upTan - downTan) * yScale * 0.5)// * rightHandedFactor;
+            //result.m[10] = -(znear + zfar) / (zfar - znear) * rightHandedFactor;
+            result.m[10] = -zfar / (znear - zfar);
             result.m[11] = 1.0 * rightHandedFactor;
             result.m[12] = result.m[13] = result.m[15] = 0.0;
             result.m[14] = -(2.0 * zfar * znear) / (zfar - znear);