Browse Source

修复无光、无阴影时,与InstanceMesh的兼容性问题

dev
刘向辉 3 years ago
parent
commit
d641ab01d3
  1. 7
      src/app/babylon/controller/scene-manager.ts
  2. 6
      src/app/babylon/tool/babylon-tool.ts
  3. 2
      src/app/babylon/tool/mesh-pool.ts

7
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);
}

6
src/app/babylon/tool/babylon-tool.ts

@ -147,10 +147,14 @@ export class BabylonTool {
).then(function (result) {
LoadTool.remove(modelPath);
isSuccess = true;
if (onSuccess) {
onSuccess(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
}
}).catch(function (result) {
if (onError) {
onError(scene, "load error", result);
}
});
// setTimeout(() => {

2
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);
}

Loading…
Cancel
Save