Quellcode durchsuchen

Merge pull request #3376 from TrevorDev/removeRotationWhileTeleporting

remove the rotation when the teleport ray is active to avoid unwanted…
David Catuhe vor 7 Jahren
Ursprung
Commit
7b888aa8c4
1 geänderte Dateien mit 10 neuen und 1 gelöschten Zeilen
  1. 10 1
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 10 - 1
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -804,7 +804,7 @@ module BABYLON {
                 if (webVRController == null 
                 if (webVRController == null 
                     ||(webVRController.hand === "left" && this._leftLaserPointer && this._leftLaserPointer.isVisible)
                     ||(webVRController.hand === "left" && this._leftLaserPointer && this._leftLaserPointer.isVisible)
                     || (webVRController.hand === "right" && this._rightLaserPointer && this._rightLaserPointer.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) {
                         if (this._teleportationAllowed) {
                             this._teleportationAllowed = false;
                             this._teleportationAllowed = false;
                             this._teleportCamera();
                             this._teleportCamera();
@@ -827,6 +827,11 @@ module BABYLON {
             this._pointerDownOnMeshAsked = false;
             this._pointerDownOnMeshAsked = false;
         }
         }
         private _checkRotate(stateObject: StickValues){
         private _checkRotate(stateObject: StickValues){
+            // Only rotate when user is not currently selecting a teleportation location
+            if(this._teleportationRequestInitiated){
+                return;
+            }
+
             if (!this._rotationLeftAsked) {
             if (!this._rotationLeftAsked) {
                 if (stateObject.x < -this._padSensibilityUp) {
                 if (stateObject.x < -this._padSensibilityUp) {
                     this._rotationLeftAsked = true;
                     this._rotationLeftAsked = true;
@@ -854,6 +859,10 @@ module BABYLON {
             }
             }
         }
         }
         private _checkTeleportBackwards(stateObject: StickValues){
         private _checkTeleportBackwards(stateObject: StickValues){
+            // Only teleport backwards when user is not currently selecting a teleportation location
+            if(this._teleportationRequestInitiated){
+                return;
+            }
             // Teleport backwards
             // Teleport backwards
             if(stateObject.y > this._padSensibilityUp) {
             if(stateObject.y > this._padSensibilityUp) {
                 if(!this._teleportationBackRequestInitiated){
                 if(!this._teleportationBackRequestInitiated){