Browse Source

Fixed VR Helper to only enable interactions when in VR mode

David Catuhe 7 years ago
parent
commit
b1c2fa5a22
1 changed files with 9 additions and 6 deletions
  1. 9 6
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 9 - 6
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -2,7 +2,6 @@ module BABYLON {
     export interface VRTeleportationOptions {
         floorMeshName?: string; // If you'd like to provide a mesh acting as the floor
         floorMeshes?: Mesh[];
-        disableInteractions?: boolean
     }
 
     export interface VRExperienceHelperOptions extends WebVROptions {
@@ -513,6 +512,10 @@ module BABYLON {
             if (this._scene.activeCamera && this._canvas) {
                 this._scene.activeCamera.attachControl(this._canvas);
             }
+
+            if (this._interactionsEnabled) {
+                this._scene.registerBeforeRender(this.beforeRender);
+            }
         }
 
         /**
@@ -547,6 +550,10 @@ module BABYLON {
             }
 
             this.updateButtonVisibility();
+
+            if (this._interactionsEnabled) {
+                this._scene.unregisterBeforeRender(this.beforeRender);
+            }
         }
 
         public get position(): Vector3 {
@@ -592,8 +599,6 @@ module BABYLON {
                     return false;
                 }
 
-                this._scene.registerBeforeRender(this.beforeRender);
-
                 this._interactionsEnabled = true;
             }
         }
@@ -641,9 +646,7 @@ module BABYLON {
             if (!this._teleportationEnabled) {
                 this._teleportationRequested = true;
 
-                if (!vrTeleportationOptions.disableInteractions) {
-                    this.enableInteractions();
-                }
+                this.enableInteractions();
 
                 if (vrTeleportationOptions.floorMeshName) {
                     this._floorMeshName = vrTeleportationOptions.floorMeshName;