Jelajahi Sumber

Addressed PR comments.

Atulya Ravishankar 7 tahun lalu
induk
melakukan
77af9825d9

+ 6 - 15
Viewer/src/managers/sceneManager.ts

@@ -60,15 +60,6 @@ export class SceneManager {
     onVRConfiguredObservable: Observable<IPostConfigurationCallback<VRExperienceHelper, IVRConfiguration>>;
 
     /**
-     * Will notify when VR mode is entered.
-     */
-    onEnteringVRObservable: Observable<any>;
-    /**
-     * Will notify when VR mode is exited.
-     */
-    onExitingVRObservable: Observable<any>;
-
-    /**
      * The Babylon Scene of this viewer
      */
     public scene: Scene;
@@ -142,8 +133,6 @@ export class SceneManager {
         this.onSceneOptimizerConfiguredObservable = new Observable();
         this.onEnvironmentConfiguredObservable = new Observable();
         this.onVRConfiguredObservable = new Observable();
-        this.onEnteringVRObservable = new Observable();
-        this.onExitingVRObservable = new Observable();
 
         //this._viewer.onEngineInitObservable.add(() => {
         this._handleHardwareLimitations();
@@ -810,10 +799,14 @@ export class SceneManager {
             });
         }
         this._vrHelper.onEnteringVRObservable.add(() => {
-            this.onEnteringVRObservable.notifyObservers(this);
+            if (this._observablesManager) {
+                this._observablesManager.onEnteringVRObservable.notifyObservers(this);
+            }
         });
         this._vrHelper.onExitingVRObservable.add(() => {
-            this.onExitingVRObservable.notifyObservers(this);
+            if (this._observablesManager) {
+                this._observablesManager.onExitingVRObservable.notifyObservers(this);
+            }
         });
         this.onVRConfiguredObservable.notifyObservers({
             sceneManager: this,
@@ -1436,8 +1429,6 @@ export class SceneManager {
         this.onSceneInitObservable.clear();
         this.onSceneOptimizerConfiguredObservable.clear();
         this.onVRConfiguredObservable.clear();
-        this.onEnteringVRObservable.clear();
-        this.onExitingVRObservable.clear();
 
         if (this.sceneOptimizer) {
             this.sceneOptimizer.stop();

+ 7 - 7
Viewer/src/viewer/viewer.ts

@@ -352,7 +352,7 @@ export abstract class AbstractViewer {
     protected _initVR() {
 
         if (this.sceneManager.vrHelper) {
-            this.sceneManager.onExitingVRObservable.add(() => {
+            this.observablesManager.onExitingVRObservable.add(() => {
                 if (this._vrToggled) {
                     this._vrToggled = false;
                     
@@ -673,13 +673,13 @@ export abstract class AbstractViewer {
         // create a new template manager for this viewer
         this.sceneManager = new SceneManager(this.engine, this._configurationContainer, this.observablesManager);
         
-        this.sceneManager.onEnteringVRObservable.add(() => {
-            this.onEnteringVRObservable.notifyObservers(this);
-        });
+        // this.observablesManager.onEnteringVRObservable.add(() => {
+        //     this.onEnteringVRObservable.notifyObservers(this);
+        // });
         
-        this.sceneManager.onExitingVRObservable.add(() => {
-            this.onExitingVRObservable.notifyObservers(this);
-        });
+        // this.observablesManager.onExitingVRObservable.add(() => {
+        //     this.onExitingVRObservable.notifyObservers(this);
+        // });
 
         return Promise.resolve(this.engine);
     }

+ 7 - 7
src/Cameras/VR/babylon.vrExperienceHelper.ts

@@ -254,10 +254,10 @@ module BABYLON {
         private _webVRready = false;
         // Are we waiting for the requestPresent callback to complete?
         private _webVRrequesting = false;
-        // Are we presenting to the headset right now?
+        // Are we presenting to the headset right now? (this is the vrDevice state)
         private _webVRpresenting = false;
-        // Have we entered VR?
-        private hasEnteredVR: boolean;
+        // Have we entered VR? (this is the VRExperienceHelper state)
+        private _hasEnteredVR: boolean;
 
         // Are we presenting in the fullscreen fallback?
         private _fullscreenVRpresenting = false;
@@ -568,7 +568,7 @@ module BABYLON {
                 this._defaultHeight *= webVROptions.positionScale;
             }
 
-            this.hasEnteredVR = false;
+            this._hasEnteredVR = false;
 
             // Set position
             if (this._scene.activeCamera) {
@@ -871,14 +871,14 @@ module BABYLON {
                 this._scene.registerBeforeRender(this.beforeRender);
             }
 
-            this.hasEnteredVR = true;
+            this._hasEnteredVR = true;
         }
 
         /**
          * Attempt to exit VR, or fullscreen.
          */
         public exitVR() {
-            if (this.hasEnteredVR) {
+            if (this._hasEnteredVR) {
                 if (this.onExitingVRObservable) {
                     try {
                         this.onExitingVRObservable.notifyObservers(this);
@@ -922,7 +922,7 @@ module BABYLON {
                 // resize to update width and height when exiting vr exits fullscreen
                 this._scene.getEngine().resize();
 
-                this.hasEnteredVR = false;
+                this._hasEnteredVR = false;
             }
         }