diff --git a/src/app/babylon/controller/scene-manager.ts b/src/app/babylon/controller/scene-manager.ts index 648567e..4f1d9fc 100644 --- a/src/app/babylon/controller/scene-manager.ts +++ b/src/app/babylon/controller/scene-manager.ts @@ -58,6 +58,7 @@ import { ModelInfo_mark_multiArrow } from '../model/info/mark/other/mark-plan-mu import { ModelInfo_mark_particle } from '../model/info/mark/other/mark-plan-particle-info'; import { FacilityPosType, ModelData_facility } from '../model/data/model-data/model-data-facility'; import { LoadTool } from '../tool/load-tool'; +import { flatten } from 'earcut'; //场景管理器 @@ -78,7 +79,7 @@ export class SceneManager { static s_openLight: boolean = true;//开启光照效果(关闭是要同时关闭阴影) - static s_openShadow: boolean = true;//开启阴影(必须开启阴影) + static s_openShadow: boolean = true;//开启阴影(必须开启光照) static s_openSkyBox: boolean = true;//使用天空盒 static s_environmentCubeTexture: CubeTexture;//环境所用的cubeTexture static s_openEnvironmentReflection: boolean = true;//使用环境反射 @@ -232,7 +233,7 @@ export class SceneManager { } else { - if (this.sunLight == null) { + if (this.sunLight != null) { this.sunLight.setEnabled(false); } @@ -244,7 +245,7 @@ export class SceneManager { * 初始化阴影 */ public updateShadow() { - if (SceneManager.s_openShadow) { + if (SceneManager.s_openLight && SceneManager.s_openShadow) { if (this.shadowGenerator == null) { this.shadowGenerator = new ShadowGenerator(2048, this.sunLight); } diff --git a/src/app/babylon/tool/babylon-tool.ts b/src/app/babylon/tool/babylon-tool.ts index 9fd3dac..4209798 100644 --- a/src/app/babylon/tool/babylon-tool.ts +++ b/src/app/babylon/tool/babylon-tool.ts @@ -147,10 +147,14 @@ export class BabylonTool { ).then(function (result) { LoadTool.remove(modelPath); isSuccess = true; - onSuccess(result.meshes, result.particleSystems, result.skeletons, result.animationGroups); - }).catch(function (result) { - onError(scene, "load error", result); + if (onSuccess) { + onSuccess(result.meshes, result.particleSystems, result.skeletons, result.animationGroups); + } + }).catch(function (result) { + if (onError) { + onError(scene, "load error", result); + } }); // setTimeout(() => { diff --git a/src/app/babylon/tool/mesh-pool.ts b/src/app/babylon/tool/mesh-pool.ts index 101ff0d..3a927e7 100644 --- a/src/app/babylon/tool/mesh-pool.ts +++ b/src/app/babylon/tool/mesh-pool.ts @@ -307,7 +307,7 @@ export class MeshPoolInfo { // let box = MeshBuilder.CreateBox("box", { size: 1 }); //用于测试阴影 // box.setParent(modelInfo.modelBox); // box.position = new Vector3(0, 2, 0); - if (SceneManager.s_openShadow) { + if (SceneManager.s_openLight && SceneManager.s_openShadow) { SceneManager.Instance.shadowGenerator.addShadowCaster(modelInfo.modelBox, true); // console.log("添加到阴影", modelInfo.modelBox.name); }