Selaa lähdekoodia

Rename teleportationEnabled to teleportationInitialized

Carlos Landeras Martínez 7 vuotta sitten
vanhempi
commit
7dfea7f6e3
1 muutettua tiedostoa jossa 14 lisäystä ja 24 poistoa
  1. 14 24
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 14 - 24
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -92,7 +92,6 @@ module BABYLON {
         private _rotationAllowed: boolean = true;
         private _rotationAllowed: boolean = true;
         private _teleportationRequestInitiated = false;
         private _teleportationRequestInitiated = false;
         private _teleportationBackRequestInitiated = false;
         private _teleportationBackRequestInitiated = false;
-        private _teleportationInputsEnabled = true;
         private teleportBackwardsVector = new Vector3(0, -1, -1);
         private teleportBackwardsVector = new Vector3(0, -1, -1);
         private _rotationRightAsked = false;
         private _rotationRightAsked = false;
         private _rotationLeftAsked = false;
         private _rotationLeftAsked = false;
@@ -140,11 +139,16 @@ module BABYLON {
          */
          */
         public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
         public meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
 
 
+        /**
+         * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
+         */
+        public teleportationEnabled : boolean = true;
+
         private _currentHit: Nullable<PickingInfo>;
         private _currentHit: Nullable<PickingInfo>;
         private _pointerDownOnMeshAsked = false;
         private _pointerDownOnMeshAsked = false;
         private _isActionableMesh = false;
         private _isActionableMesh = false;
         private _defaultHeight: number;
         private _defaultHeight: number;
-        private _teleportationEnabled = false;
+        private _teleportationInitialized = false;
         private _interactionsEnabled = false;
         private _interactionsEnabled = false;
         private _interactionsRequested = false;
         private _interactionsRequested = false;
         private _displayGaze = true;
         private _displayGaze = true;
@@ -156,20 +160,6 @@ module BABYLON {
             return this._teleportationTarget;
             return this._teleportationTarget;
         }
         }
 
 
-        /**
-        * Set if VR Controllers / Gamepad inputs are enabled to teleport camera
-        */
-        public set teleportationInputsEnabled(value: boolean) {
-            this._teleportationInputsEnabled = value;
-        }
-
-        /**
-        * Get if VR Controllers / Gamepad inputs are enabled to teleport camera
-        */
-        public get teleportationInputsEnabled() {
-            return this._teleportationInputsEnabled;
-        }
-
         public set teleportationTarget(value: Mesh) {
         public set teleportationTarget(value: Mesh) {
             if (value) {
             if (value) {
                 value.name = "teleportationTarget";
                 value.name = "teleportationTarget";
@@ -668,7 +658,7 @@ module BABYLON {
         }
         }
 
 
         public enableTeleportation(vrTeleportationOptions: VRTeleportationOptions = {}) {
         public enableTeleportation(vrTeleportationOptions: VRTeleportationOptions = {}) {
-            if (!this._teleportationEnabled) {
+            if (!this._teleportationInitialized) {
                 this._teleportationRequested = true;
                 this._teleportationRequested = true;
 
 
                 this.enableInteractions();
                 this.enableInteractions();
@@ -704,7 +694,7 @@ module BABYLON {
 
 
                 this._webVRCamera.detachPostProcess(this._postProcessMove)
                 this._webVRCamera.detachPostProcess(this._postProcessMove)
                 this._passProcessMove = new PassPostProcess("pass", 1.0, this._webVRCamera);
                 this._passProcessMove = new PassPostProcess("pass", 1.0, this._webVRCamera);
-                this._teleportationEnabled = true;
+                this._teleportationInitialized = true;
                 if (this._isDefaultTeleportationTarget) {
                 if (this._isDefaultTeleportationTarget) {
                     this._createTeleportationCircles();
                     this._createTeleportationCircles();
                 }
                 }
@@ -715,7 +705,7 @@ module BABYLON {
             if (gamepad.type !== Gamepad.POSE_ENABLED) {
             if (gamepad.type !== Gamepad.POSE_ENABLED) {
                 if (gamepad.leftStick) {
                 if (gamepad.leftStick) {
                     gamepad.onleftstickchanged((stickValues) => {
                     gamepad.onleftstickchanged((stickValues) => {
-                        if (this._teleportationEnabled && this._teleportationInputsEnabled) {
+                        if (this._teleportationInitialized && this.teleportationEnabled) {
                             // Listening to classic/xbox gamepad only if no VR controller is active
                             // Listening to classic/xbox gamepad only if no VR controller is active
                             if ((!this._leftLaserPointer && !this._rightLaserPointer) ||
                             if ((!this._leftLaserPointer && !this._rightLaserPointer) ||
                                 ((this._leftLaserPointer && !this._leftLaserPointer.isVisible) &&
                                 ((this._leftLaserPointer && !this._leftLaserPointer.isVisible) &&
@@ -728,7 +718,7 @@ module BABYLON {
                 }
                 }
                 if (gamepad.rightStick) {
                 if (gamepad.rightStick) {
                     gamepad.onrightstickchanged((stickValues) => {
                     gamepad.onrightstickchanged((stickValues) => {
-                        if (this._teleportationEnabled) {
+                        if (this._teleportationInitialized) {
                             this._checkRotate(stickValues);
                             this._checkRotate(stickValues);
                         }
                         }
                     });
                     });
@@ -1012,7 +1002,7 @@ module BABYLON {
                     });
                     });
                 }
                 }
                 webVRController.onPadValuesChangedObservable.add((stateObject) => {
                 webVRController.onPadValuesChangedObservable.add((stateObject) => {
-                    if (this._teleportationInputsEnabled) {
+                    if (this.teleportationEnabled) {
                         this._checkTeleportBackwards(stateObject);
                         this._checkTeleportBackwards(stateObject);
                         this._checkTeleportWithRay(stateObject, webVRController);
                         this._checkTeleportWithRay(stateObject, webVRController);
                     }
                     }
@@ -1097,7 +1087,7 @@ module BABYLON {
         }
         }
 
 
         private _displayTeleportationTarget() {
         private _displayTeleportationTarget() {
-            if (this._teleportationEnabled) {
+            if (this._teleportationInitialized) {
                 this._teleportationTarget.isVisible = true;
                 this._teleportationTarget.isVisible = true;
                 if (this._isDefaultTeleportationTarget) {
                 if (this._isDefaultTeleportationTarget) {
                     (<Mesh>this._teleportationTarget.getChildren()[0]).isVisible = true;
                     (<Mesh>this._teleportationTarget.getChildren()[0]).isVisible = true;
@@ -1106,7 +1096,7 @@ module BABYLON {
         }
         }
 
 
         private _hideTeleportationTarget() {
         private _hideTeleportationTarget() {
-            if (this._teleportationEnabled) {
+            if (this._teleportationInitialized) {
                 this._teleportationTarget.isVisible = false;
                 this._teleportationTarget.isVisible = false;
                 if (this._isDefaultTeleportationTarget) {
                 if (this._isDefaultTeleportationTarget) {
                     (<Mesh>this._teleportationTarget.getChildren()[0]).isVisible = false;
                     (<Mesh>this._teleportationTarget.getChildren()[0]).isVisible = false;
@@ -1405,7 +1395,7 @@ module BABYLON {
                     this._scene.simulatePointerMove(this._currentHit);
                     this._scene.simulatePointerMove(this._currentHit);
                 }
                 }
                 // The object selected is the floor, we're in a teleportation scenario
                 // The object selected is the floor, we're in a teleportation scenario
-                if (this._teleportationEnabled && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
+                if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
                     // Moving the teleportation area to this targetted point
                     // Moving the teleportation area to this targetted point
                     this._moveTeleportationSelectorTo(hit);
                     this._moveTeleportationSelectorTo(hit);
                     return;
                     return;