|
|
@ -11,6 +11,7 @@ import { |
|
|
|
EventState, |
|
|
|
EventState, |
|
|
|
HemisphericLight, |
|
|
|
HemisphericLight, |
|
|
|
HighlightLayer, |
|
|
|
HighlightLayer, |
|
|
|
|
|
|
|
InstancedMesh, |
|
|
|
IParticleSystem, |
|
|
|
IParticleSystem, |
|
|
|
ISceneLoaderProgressEvent, |
|
|
|
ISceneLoaderProgressEvent, |
|
|
|
Mesh, |
|
|
|
Mesh, |
|
|
@ -57,10 +58,13 @@ 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 { 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 { FacilityPosType, ModelData_facility } from '../model/data/model-data/model-data-facility'; |
|
|
|
import { LoadTool } from '../tool/load-tool'; |
|
|
|
import { LoadTool } from '../tool/load-tool'; |
|
|
|
|
|
|
|
import { flatten } from 'earcut'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//场景管理器
|
|
|
|
//场景管理器
|
|
|
|
export class SceneManager { |
|
|
|
export class SceneManager { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------Camera-----------------\\
|
|
|
|
//----------------Camera-----------------\\
|
|
|
|
|
|
|
|
|
|
|
|
public engine: Engine; |
|
|
|
public engine: Engine; |
|
|
@ -75,7 +79,7 @@ export class SceneManager { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static s_openLight: boolean = true;//开启光照效果(关闭是要同时关闭阴影)
|
|
|
|
static s_openLight: boolean = true;//开启光照效果(关闭是要同时关闭阴影)
|
|
|
|
static s_openShadow: boolean = true;//开启阴影(必须开启阴影)
|
|
|
|
static s_openShadow: boolean = true;//开启阴影(必须开启光照)
|
|
|
|
static s_openSkyBox: boolean = true;//使用天空盒
|
|
|
|
static s_openSkyBox: boolean = true;//使用天空盒
|
|
|
|
static s_environmentCubeTexture: CubeTexture;//环境所用的cubeTexture
|
|
|
|
static s_environmentCubeTexture: CubeTexture;//环境所用的cubeTexture
|
|
|
|
static s_openEnvironmentReflection: boolean = true;//使用环境反射
|
|
|
|
static s_openEnvironmentReflection: boolean = true;//使用环境反射
|
|
|
@ -161,7 +165,7 @@ export class SceneManager { |
|
|
|
); |
|
|
|
); |
|
|
|
camera.minZ = 0;//最近拍摄距离
|
|
|
|
camera.minZ = 0;//最近拍摄距离
|
|
|
|
camera.maxZ = 6000; //摄像机拍摄的最远距离
|
|
|
|
camera.maxZ = 6000; //摄像机拍摄的最远距离
|
|
|
|
// camera.upperBetaLimit = 1.5; //beta方向上的旋转限制(防止看到模型底面)
|
|
|
|
camera.upperBetaLimit = 1.5; //beta方向上的旋转限制(防止看到模型底面)
|
|
|
|
camera.lowerRadiusLimit = 1; //相机距离拍摄目标的最小距离(防止穿插)
|
|
|
|
camera.lowerRadiusLimit = 1; //相机距离拍摄目标的最小距离(防止穿插)
|
|
|
|
camera.setTarget(Vector3.Zero()); //设置拍摄目标
|
|
|
|
camera.setTarget(Vector3.Zero()); //设置拍摄目标
|
|
|
|
camera.radius = 100; |
|
|
|
camera.radius = 100; |
|
|
@ -229,7 +233,7 @@ export class SceneManager { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (this.sunLight == null) { |
|
|
|
if (this.sunLight != null) { |
|
|
|
this.sunLight.setEnabled(false); |
|
|
|
this.sunLight.setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -241,7 +245,7 @@ export class SceneManager { |
|
|
|
* 初始化阴影 |
|
|
|
* 初始化阴影 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public updateShadow() { |
|
|
|
public updateShadow() { |
|
|
|
if (SceneManager.s_openShadow) { |
|
|
|
if (SceneManager.s_openLight && SceneManager.s_openShadow) { |
|
|
|
if (this.shadowGenerator == null) { |
|
|
|
if (this.shadowGenerator == null) { |
|
|
|
this.shadowGenerator = new ShadowGenerator(2048, this.sunLight); |
|
|
|
this.shadowGenerator = new ShadowGenerator(2048, this.sunLight); |
|
|
|
} |
|
|
|
} |
|
|
@ -663,7 +667,7 @@ export class SceneManager { |
|
|
|
canPick = true; |
|
|
|
canPick = true; |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
if (SceneManager.s_openShadow) { |
|
|
|
if (SceneManager.s_openShadow && !(newMeshes[i] instanceof InstancedMesh)) { |
|
|
|
newMeshes[i].receiveShadows = true; |
|
|
|
newMeshes[i].receiveShadows = true; |
|
|
|
|
|
|
|
|
|
|
|
// let mat = newMeshes[i].material;
|
|
|
|
// let mat = newMeshes[i].material;
|
|
|
@ -873,13 +877,22 @@ export class SceneManager { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static meshAdsorbY(mover: AbstractMesh, target: AbstractMesh, pickPos: Vector3) { |
|
|
|
public static meshAdsorbY(mover: AbstractMesh, target: AbstractMesh, pickPos: Vector3) { |
|
|
|
|
|
|
|
|
|
|
|
ModeManager.log("吸附模型" + target); |
|
|
|
// console.log("吸附模型" + target);
|
|
|
|
|
|
|
|
|
|
|
|
let targetRoot = SceneManager.getRootTransformNode(target); |
|
|
|
let targetRoot = SceneManager.getRootTransformNode(target) as AbstractMesh; |
|
|
|
|
|
|
|
|
|
|
|
if (mover == targetRoot) { |
|
|
|
if (mover == targetRoot) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//先通过吸附点吸附
|
|
|
|
|
|
|
|
let byAdsorbPoint = BabylonTool.adsorb2MeshByPoint(mover, targetRoot, "WAI") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//完成吸附了
|
|
|
|
|
|
|
|
if (byAdsorbPoint) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let aimPos_y: number = 0; |
|
|
|
let aimPos_y: number = 0; |
|
|
|
|
|
|
|
|
|
|
|
let direction = 0.5; |
|
|
|
let direction = 0.5; |
|
|
|