瀏覽代碼

Fix global position of webVRCamera

Gary Hsu 7 年之前
父節點
當前提交
29c9c287b1
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/Cameras/VR/babylon.webVRCamera.ts

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

@@ -602,6 +602,14 @@ module BABYLON {
             }
 
             parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
+
+            // Compute global position
+            this._workingMatrix = this._workingMatrix || Matrix.Identity();
+            this._webvrViewMatrix.invertToRef(this._workingMatrix);
+            this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
+            this._workingMatrix.getTranslationToRef(this._globalPosition);
+            this._markSyncedWithParent();
+
             return this._webvrViewMatrix;
         }