浏览代码

Merge pull request #5006 from TrevorDev/fixedPositionVR

remove translation from view matrix
David Catuhe 7 年之前
父节点
当前提交
cde528f681
共有 2 个文件被更改,包括 9 次插入1 次删除
  1. 1 0
      dist/preview release/what's new.md
  2. 8 1
      src/Cameras/VR/babylon.webVRCamera.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -175,6 +175,7 @@
 - Set missing parentId in Mesh.serialize() for instances ([julien-moreau](https://github.com/julien-moreau))
 - Do not modify pivot point when using bounding box gizmo ([TrevorDev](https://github.com/TrevorDev))
 - GPUParticleSystem does not get stuck in burst loop when stopped and started ([TrevorDev](https://github.com/TrevorDev))
+- trackPosition not working in webVRCamera ([TrevorDev](https://github.com/TrevorDev))
 
 ### Core Engine
 

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

@@ -596,6 +596,7 @@ module BABYLON {
             return Matrix.Identity();
         }
 
+        private _tmpMatrix = new BABYLON.Matrix();
         /**
          * This function is called by the two RIG cameras.
          * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
@@ -635,9 +636,15 @@ module BABYLON {
 
                 this._webvrViewMatrix.invert();
             }
-
+             
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
 
+            // Remove translation from 6dof headset if trackposition is set to false
+            if(parentCamera.rawPose && parentCamera.rawPose.position && !parentCamera.webVROptions.trackPosition){
+                Matrix.TranslationToRef(parentCamera.rawPose.position[0], parentCamera.rawPose.position[1], -parentCamera.rawPose.position[2], parentCamera._tmpMatrix);
+                parentCamera._tmpMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+            }
+
             // Compute global position
             this._workingMatrix = this._workingMatrix || Matrix.Identity();
             this._webvrViewMatrix.invertToRef(this._workingMatrix);