Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 years ago
parent
commit
a65a0f3ec4
1 changed files with 17 additions and 3 deletions
  1. 17 3
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 17 - 3
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -804,7 +804,7 @@ module BABYLON {
                 if (webVRController == null 
                     ||(webVRController.hand === "left" && this._leftLaserPointer && this._leftLaserPointer.isVisible)
                     || (webVRController.hand === "right" && this._rightLaserPointer && this._rightLaserPointer.isVisible)) {
-                    if (stateObject.y > -this._padSensibilityDown) {
+                    if (Math.sqrt(stateObject.y*stateObject.y + stateObject.x*stateObject.x) < this._padSensibilityDown) {
                         if (this._teleportationAllowed) {
                             this._teleportationAllowed = false;
                             this._teleportCamera();
@@ -827,6 +827,11 @@ module BABYLON {
             this._pointerDownOnMeshAsked = false;
         }
         private _checkRotate(stateObject: StickValues){
+            // Only rotate when user is not currently selecting a teleportation location
+            if(this._teleportationRequestInitiated){
+                return;
+            }
+
             if (!this._rotationLeftAsked) {
                 if (stateObject.x < -this._padSensibilityUp) {
                     this._rotationLeftAsked = true;
@@ -854,6 +859,10 @@ module BABYLON {
             }
         }
         private _checkTeleportBackwards(stateObject: StickValues){
+            // Only teleport backwards when user is not currently selecting a teleportation location
+            if(this._teleportationRequestInitiated){
+                return;
+            }
             // Teleport backwards
             if(stateObject.y > this._padSensibilityUp) {
                 if(!this._teleportationBackRequestInitiated){
@@ -1386,8 +1395,13 @@ module BABYLON {
                 this._deviceOrientationCamera.dispose();
             }
 
-            this._gazeTracker.dispose();
-            this._teleportationTarget.dispose();
+            if(this._gazeTracker){
+                this._gazeTracker.dispose();
+            }
+            
+            if(this._teleportationTarget){
+                this._teleportationTarget.dispose();
+            }
 
             this._floorMeshesCollection = [];