Browse Source

dispose vrHelper when scene is disposed

Trevor Baron 7 years ago
parent
commit
bc94fba93f
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/Cameras/VR/babylon.vrExperienceHelper.ts

+ 4 - 0
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -310,6 +310,10 @@ module BABYLON {
             scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
             scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
             window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
             window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
 
 
+            scene.onDisposeObservable.add(()=>{
+                this.dispose();
+            })
+
             // Gamepad connection events
             // Gamepad connection events
             this._webVRCamera.onControllerMeshLoadedObservable.add((webVRController) => this._onDefaultMeshLoaded(webVRController));
             this._webVRCamera.onControllerMeshLoadedObservable.add((webVRController) => this._onDefaultMeshLoaded(webVRController));
             this._scene.gamepadManager.onGamepadConnectedObservable.add((pad) => this._onNewGamepadConnected(pad));
             this._scene.gamepadManager.onGamepadConnectedObservable.add((pad) => this._onNewGamepadConnected(pad));