Browse Source

update environment if possible. if not, recreate env helper

Raanan Weber 7 năm trước cách đây
mục cha
commit
cacfb93c2e
1 tập tin đã thay đổi với 8 bổ sung5 xóa
  1. 8 5
      Viewer/src/viewer/viewer.ts

+ 8 - 5
Viewer/src/viewer/viewer.ts

@@ -544,12 +544,15 @@ export abstract class AbstractViewer {
         }
         else {
             // there might be a new scene! we need to dispose.
-            // Need to decide if a scene should stay or be disposed.
-            this.environmentHelper.dispose();
-            //this.environmentHelper.updateOptions(options);
-            this.environmentHelper = this.scene.createDefaultEnvironment(options)!;
+            // get the scene used by the envHelper
+            let scene: Scene = this.environmentHelper.rootMesh.getScene();
+            if (scene !== this.scene) {
+                this.environmentHelper.dispose();
+                this.environmentHelper = this.scene.createDefaultEnvironment(options)!;
+            } else {
+                this.environmentHelper.updateOptions(options)!;
+            }
         }
-        console.log(options);
 
         if (postInitSkyboxMaterial) {
             let skyboxMaterial = this.environmentHelper.skyboxMaterial;