소스 검색

getTarget stopped working - now fixed

_currentTarget did not take rotation into account.
Raanan Weber 8 년 전
부모
커밋
d60ac2285c
2개의 변경된 파일8개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 3
      src/Cameras/VR/babylon.webVRCamera.ts
  2. 1 1
      src/Cameras/babylon.targetCamera.ts

+ 7 - 3
src/Cameras/VR/babylon.webVRCamera.ts

@@ -60,9 +60,6 @@ module BABYLON {
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = false, private webVROptions: WebVROptions = {}) {
         constructor(name: string, position: Vector3, scene: Scene, compensateDistortion = false, private webVROptions: WebVROptions = {}) {
             super(name, position, scene);
             super(name, position, scene);
 
 
-            //using the position provided as the current position offset
-            this._positionOffset = position;
-
             if (this.webVROptions && this.webVROptions.positionScale) {
             if (this.webVROptions && this.webVROptions.positionScale) {
                 this.deviceScaleFactor = this.webVROptions.positionScale;
                 this.deviceScaleFactor = this.webVROptions.positionScale;
             }
             }
@@ -241,6 +238,13 @@ module BABYLON {
                 this._tempMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
                 this._tempMatrix.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
             }
             }
 
 
+            this._updateCameraRotationMatrix();
+            Vector3.TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
+
+            // Computing target for getTarget()
+            this._webvrViewMatrix.getTranslationToRef(this._positionOffset);
+            this._positionOffset.addToRef(this._transformedReferencePoint, this._currentTarget);
+
             return this._webvrViewMatrix;
             return this._webvrViewMatrix;
         }
         }
 
 

+ 1 - 1
src/Cameras/babylon.targetCamera.ts

@@ -219,7 +219,7 @@ module BABYLON {
             super._checkInputs();
             super._checkInputs();
         }
         }
 
 
-        private _updateCameraRotationMatrix() {
+        protected _updateCameraRotationMatrix() {
             if (this.rotationQuaternion) {
             if (this.rotationQuaternion) {
                 this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
                 this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
                 //update the up vector!
                 //update the up vector!