浏览代码

adding "enabled"flag

Raanan Weber 5 年之前
父节点
当前提交
78a29430eb
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      src/Cameras/XR/webXRControllerTeleportation.ts

+ 7 - 2
src/Cameras/XR/webXRControllerTeleportation.ts

@@ -18,6 +18,8 @@ export class WebXRControllerTeleportation {
     private _tmpRay = new Ray(new Vector3(), new Vector3());
     private _tmpVector = new Vector3();
 
+    public enabled: boolean = true;
+
     /**
      * Creates a WebXRControllerTeleportation
      * @param input input manager to add teleportation to
@@ -81,7 +83,10 @@ export class WebXRControllerTeleportation {
 
             // Handle user input on every frame
             let renderObserver = scene.onBeforeRenderObservable.add(() => {
-                // Move the teleportationTarget to where the user is targetting to teleport to
+                if (!this.enabled) {
+                    return;
+                }
+                // Move the teleportationTarget to where the user is targeting to teleport to
                 if (forwardReadyToTeleport) {
                     c.getWorldPointerRayToRef(this._tmpRay);
                     let pick = scene.pickWithRay(this._tmpRay, (o) => {
@@ -135,7 +140,7 @@ export class WebXRControllerTeleportation {
                                 });
 
                                 if (pick && pick.pickedPoint) {
-                                    // Teleport the users feet to where they targetted
+                                    // Teleport the users feet to where they targeted
                                     this._tmpVector.copyFrom(pick.pickedPoint);
                                     this._tmpVector.y += input.baseExperience.camera.position.y;
                                     input.baseExperience.setPositionOfCameraUsingContainer(this._tmpVector);