Преглед изворни кода

fix tp when not in vr mode

Trevor Baron пре 7 година
родитељ
комит
aca4bb4379
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 7 - 2
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -1050,8 +1050,13 @@ module BABYLON {
 
             // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
             // offset of the headset from the anchor. Then add the helper's position to account for user's height offset
-            this.webVRCamera.leftCamera!.globalPosition.subtractToRef(this.webVRCamera.position, this._workingVector);
-            this._haloCenter.subtractToRef(this._workingVector, this._workingVector);
+            if(this.webVRCamera.leftCamera){
+                this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
+                this._workingVector.subtractInPlace(this.webVRCamera.position);
+                this._haloCenter.subtractToRef(this._workingVector, this._workingVector);
+            }else{
+                this._workingVector.copyFrom(this._haloCenter);
+            }
             this._workingVector.y += this._defaultHeight;
 
             // Create animation from the camera's position to the new location