浏览代码

when loading a model, only update required data

Raanan Weber 7 年之前
父节点
当前提交
81732c3792
共有 3 个文件被更改,包括 29 次插入13 次删除
  1. 3 1
      Viewer/src/viewer/defaultViewer.ts
  2. 19 9
      Viewer/src/viewer/sceneManager.ts
  3. 7 3
      Viewer/src/viewer/viewer.ts

+ 3 - 1
Viewer/src/viewer/defaultViewer.ts

@@ -187,7 +187,9 @@ export class DefaultViewer extends AbstractViewer {
             hideLoadingDelay = this._configuration.lab.hideLoadingDelay;
         }
         setTimeout(() => {
-            this.hideLoadingScreen();
+            this.sceneManager.scene.executeWhenReady(() => {
+                this.hideLoadingScreen();
+            });
         }, hideLoadingDelay);
 
         return;

+ 19 - 9
Viewer/src/viewer/sceneManager.ts

@@ -650,13 +650,14 @@ export class SceneManager {
             setupImageProcessing: false, // will be done at the scene level!,
         };
 
-        if (model) {
+        // will that cause problems with model ground configuration?
+        /*if (model) {
             const boundingInfo = model.rootMesh.getHierarchyBoundingVectors(true);
             const sizeVec = boundingInfo.max.subtract(boundingInfo.min);
             const halfSizeVec = sizeVec.scale(0.5);
             const center = boundingInfo.min.add(halfSizeVec);
             options.groundYBias = -center.y;
-        }
+        }*/
 
         if (groundConfiguration) {
             let groundConfig = (typeof groundConfiguration === 'boolean') ? {} : groundConfiguration;
@@ -798,6 +799,10 @@ export class SceneManager {
             }
         }
 
+        this._viewer.onModelLoadedObservable.add((model) => {
+            this._updateGroundMirrorRenderList(model);
+        });
+
         this.onEnvironmentConfiguredObservable.notifyObservers({
             sceneManager: this,
             object: this.environmentHelper,
@@ -920,11 +925,17 @@ export class SceneManager {
 
                     if (!shadowGenerator) {
                         shadowGenerator = new ShadowGenerator(bufferSize, light);
-                        // TODO blur kernel definition
+                        // TODO blur kernel definition ?
                     }
 
                     // add the focues meshes to the shadow list
+                    this._viewer.onModelLoadedObservable.add((model) => {
+                        this._updateShadowRenderList(shadowGenerator, model);
+                    });
+
+                    //if (model) {
                     this._updateShadowRenderList(shadowGenerator, model);
+                    //}
 
                     var blurKernel = this.getBlurKernel(light, bufferSize);
 
@@ -1130,12 +1141,11 @@ export class SceneManager {
             case CameraBehavior.BOUNCING:
                 break;
             case CameraBehavior.FRAMING:
-                if (config.zoomOnBoundingInfo) {
-                    //payload is an array of meshes
-                    let meshes = <Array<AbstractMesh>>payload;
-                    let bounding = meshes[0].getHierarchyBoundingVectors();
-                    (<FramingBehavior>behavior).zoomOnBoundingInfo(bounding.min, bounding.max);
-                }
+                this._viewer.onModelLoadedObservable.add((model) => {
+                    if (config.zoomOnBoundingInfo) {
+                        (<FramingBehavior>behavior).zoomOnMeshHierarchy(model.rootMesh);
+                    }
+                });
                 break;
         }
     }

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

@@ -195,7 +195,11 @@ export abstract class AbstractViewer {
         });
 
         this.onModelLoadedObservable.add((model) => {
-            this.updateConfiguration(this._configuration, model);
+            //this.updateConfiguration(this._configuration, model);
+        });
+
+        this.onSceneInitObservable.add(() => {
+            this.updateConfiguration();
         });
 
         this.onInitDoneObservable.add(() => {
@@ -455,9 +459,9 @@ export abstract class AbstractViewer {
                     return this.sceneManager.scene || this.sceneManager.initScene(this._configuration.scene);
                 }
             }).then((scene) => {
-                if (!autoLoad) {
+                /*if (!autoLoad) {
                     this.updateConfiguration();
-                }
+                }*/
                 return this.onSceneInitObservable.notifyObserversWithPromise(scene);
             }).then(() => {
                 return this.onInitDoneObservable.notifyObserversWithPromise(this);