Browse Source

Merge pull request #7976 from RaananW/TeleportationNoTouch

Teleportation now uses axis data only to teleport
David Catuhe 5 years ago
parent
commit
c172870dff

+ 1 - 0
dist/preview release/what's new.md

@@ -76,6 +76,7 @@
 - Playground doesn't update FPS when in XR in main and frame ([#7875](https://github.com/BabylonJS/Babylon.js/issues/7875)) ([RaananW](https://github.com/RaananW))
 - Added support for teleportation using pointer events ([RaananW](https://github.com/RaananW))
 - AR reference space type recommendation changed to 'unbounded' ([#7959](https://github.com/BabylonJS/Babylon.js/issues/7959)) ([RaananW](https://github.com/RaananW))
+- Teleportation plugin doesn't use the touched to finish teleportation ([#7916](https://github.com/BabylonJS/Babylon.js/issues/7916)) ([RaananW](https://github.com/RaananW))
 - Support for pointer selection and teleportation in right handed systems ([#7967](https://github.com/BabylonJS/Babylon.js/issues/7967)) ([RaananW](https://github.com/RaananW))
 
 ### Collisions

+ 9 - 8
src/XR/features/WebXRControllerTeleportation.ts

@@ -450,18 +450,10 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
                             }
                         });
                     } else {
-                        controllerData.onButtonChangedObserver = movementController.onButtonStateChangedObservable.add(() => {
-                            if (this._currentTeleportationControllerId === controllerData.xrController.uniqueId && controllerData.teleportationState.forward && !movementController.touched) {
-                                this._teleportForward(xrController.uniqueId);
-                            }
-                        });
                         // use thumbstick (or touchpad if thumbstick not available)
                         controllerData.onAxisChangedObserver = movementController.onAxisValueChangedObservable.add((axesData) => {
                             if (axesData.y <= 0.7 && controllerData.teleportationState.backwards) {
-                                //if (this._currentTeleportationControllerId === controllerData.xrController.uniqueId) {
                                 controllerData.teleportationState.backwards = false;
-                                //this._currentTeleportationControllerId = "";
-                                //}
                             }
                             if (axesData.y > 0.7 && !controllerData.teleportationState.forward && this.backwardsMovementEnabled && !this.snapPointsOnly) {
                                 // teleport backwards
@@ -513,6 +505,12 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
                             } else {
                                 controllerData.teleportationState.rotating = false;
                             }
+
+                            if (axesData.x === 0 && axesData.y === 0) {
+                                if (controllerData.teleportationState.forward) {
+                                    this._teleportForward(xrController.uniqueId);
+                                }
+                            }
                         });
                     }
                 }
@@ -721,6 +719,9 @@ export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
 
     private _teleportForward(controllerId: string) {
         const controllerData = this._controllers[controllerId];
+        if (!controllerData.teleportationState.forward) {
+            return;
+        }
         controllerData.teleportationState.forward = false;
         this._currentTeleportationControllerId = "";
         if (this.snapPointsOnly && !this._snappedToPoint) {