浏览代码

Moving ground creation to after model load (due to camera behavior)

Raanan Weber 7 年之前
父节点
当前提交
fabdbed181
共有 2 个文件被更改,包括 65673 次插入38438 次删除
  1. 65665 38428
      Viewer/dist/viewer.js
  2. 8 10
      Viewer/src/viewer/defaultViewer.ts

文件差异内容过多而无法显示
+ 65665 - 38428
Viewer/dist/viewer.js


+ 8 - 10
Viewer/src/viewer/defaultViewer.ts

@@ -74,13 +74,10 @@ export class DefaultViewer extends AbstractViewer {
     }
 
     public onModelLoaded(meshes) {
-        this.hideLoadingScreen();
-
         this.scene.createDefaultCameraOrLight(true, true, true);
 
         // TODO do it better, no casting!
         let camera: ArcRotateCamera = <ArcRotateCamera>this.scene.activeCamera;
-
         // We want framing to move the camera at the best spot
         camera.useFramingBehavior = true;
         camera.useAutoRotationBehavior = true;
@@ -98,8 +95,11 @@ export class DefaultViewer extends AbstractViewer {
 
         // TODO - move it away from here.
 
-        let ground = this.scene.getMeshByName('ground');
-        ground.position.y = bounding.min.y;
+        var ground = Mesh.CreatePlane('ground', 100, this.scene)
+        ground.rotation.x = Math.PI / 2
+        ground.receiveShadows = true;
+        ground.material = new ShadowOnlyMaterial('shadow-only-mat', this.scene)
+        ground.material.alpha = 0.4;
 
         var shadowGenerator = new BABYLON.ShadowGenerator(512, light)
         shadowGenerator.useBlurExponentialShadowMap = true;
@@ -112,6 +112,8 @@ export class DefaultViewer extends AbstractViewer {
             shadowGenerator.getShadowMap().renderList.push(meshes[index]);
         }
 
+        this.hideLoadingScreen();
+
         return Promise.resolve(this.scene);
     }
 
@@ -142,11 +144,7 @@ export class DefaultViewer extends AbstractViewer {
         backgroundImageProcessingConfiguration.colorCurves = curve;
         backgroundImageProcessingConfiguration.colorCurvesEnabled = true;*/
 
-        var ground = Mesh.CreatePlane('ground', 100, this.scene)
-        ground.rotation.x = Math.PI / 2
-        ground.receiveShadows = true;
-        ground.material = new ShadowOnlyMaterial('shadow-only-mat', this.scene)
-        ground.material.alpha = 0.4;
+        /**/
 
         // Our skybox with the color curve
         /*var box = this.scene.createDefaultSkybox(hdrTexture, true, (this.scene.activeCamera.maxZ - this.scene.activeCamera.minZ) / 2, 0.7);