Browse Source

getTarget stopped working - now fixed

_currentTarget did not take rotation into account.
Raanan Weber 8 năm trước cách đây
mục cha
commit
d60ac2285c

+ 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 = {}) {
             super(name, position, scene);
 
-            //using the position provided as the current position offset
-            this._positionOffset = position;
-
             if (this.webVROptions && this.webVROptions.positionScale) {
                 this.deviceScaleFactor = this.webVROptions.positionScale;
             }
@@ -241,6 +238,13 @@ module BABYLON {
                 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;
         }
 

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

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