|
|
|
|
|
|
|
|
|
|
|
import { AbstractMesh, Mesh, TransformNode } from "@babylonjs/core";
|
|
|
|
import { ConfigManager } from "../../controller/config-manager";
|
|
|
|
import { InfoManager } from "../../controller/info-manager";
|
|
|
|
import { ModeManager, ModeType } from "../../controller/mode-manager";
|
|
|
|
import { SceneManager } from "../../controller/scene-manager";
|
|
|
|
import { IndoorStatus } from "../../controller/status/indoor-status";
|
|
|
|
import { StatusManager } from "../../controller/status/status-manager";
|
|
|
|
import { BuildingType, BuildingData_Normal } from "../../model/data/institution/building/building-data";
|
|
|
|
import { FacilityPosType, FacilityType, ModelData_facility } from "../../model/data/model-data/model-data-facility";
|
|
|
|
import { ModelEditData } from "../../model/data/model-data/model-edit-data";
|
|
|
|
import { TransformData } from "../../model/data/transform-data";
|
|
|
|
import { BuildingInfo } from "../../model/info/building/building-info";
|
|
|
|
import { ModelInfo_building } from "../../model/info/model/model-info-building";
|
|
|
|
import { BabylonTool } from "../../tool/babylon-tool";
|
|
|
|
import { GizmoTool } from "../../tool/gizmo-tool";
|
|
|
|
import { TsTool } from "../../tool/ts-tool";
|
|
|
|
import { FacilityWindow } from "../facility-window/facility-window";
|
|
|
|
import { MarkWindow } from "../mark-window/mark-window";
|
|
|
|
// import { BuildingCreateWindow } from "./building-create-window";
|
|
|
|
import { BuildingWindow } from "./building-window";
|
|
|
|
|
|
|
|
//建筑UI Item
|
|
|
|
export class BuildingUIItem {
|
|
|
|
buildingInfo: BuildingInfo;
|
|
|
|
buildingWindow: BuildingWindow;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(buildingInfo: BuildingInfo, buildingWindow: BuildingWindow) {
|
|
|
|
|
|
|
|
this.buildingWindow = buildingWindow;
|
|
|
|
this.buildingInfo = buildingInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dispose() {
|
|
|
|
|
|
|
|
this.buildingInfo.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
//#region 前端对接
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取建筑ID
|
|
|
|
*/
|
|
|
|
getBuildingID(): string {
|
|
|
|
return this.buildingInfo.buildingData.normalData.key;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取建筑显示的名称
|
|
|
|
*/
|
|
|
|
getBuildingName(): string {
|
|
|
|
return this.buildingInfo.buildingData.normalData.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改建筑名称
|
|
|
|
*/
|
|
|
|
setBuildingName(newName: string) {
|
|
|
|
this.changeName(newName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取建筑类型
|
|
|
|
*/
|
|
|
|
getBuildingType(): BuildingType {
|
|
|
|
return this.buildingInfo.buildingData.buildingType;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取室内数据 (null ,表示没有室内)
|
|
|
|
*/
|
|
|
|
getAllIndoorData(): ModelEditData[] {
|
|
|
|
if (this.buildingInfo.buildingData instanceof BuildingData_Normal) {
|
|
|
|
let buildingData: BuildingData_Normal = this.buildingInfo.buildingData as BuildingData_Normal;
|
|
|
|
|
|
|
|
let result = buildingData.indoorsData;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 进入室内
|
|
|
|
* 来自ui的切换(不是因为切换沙盘节点而导致的切层)
|
|
|
|
*/
|
|
|
|
enterIndoor(key: string = null, fromUI: boolean = true) {
|
|
|
|
GizmoTool.onPickMeshInfoObservable.notifyObservers(null);
|
|
|
|
IndoorStatus.changeStatusFromUI = fromUI;
|
|
|
|
|
|
|
|
if (fromUI && MarkWindow.instance != null && MarkWindow.instance.isShow && MarkWindow.instance.currentMarkNodeInfo != null) {
|
|
|
|
if (key == null) {
|
|
|
|
let indoorsData = (this.buildingInfo.buildingData as BuildingData_Normal).indoorsData;
|
|
|
|
if (indoorsData != null && indoorsData.length > 0) {
|
|
|
|
key = indoorsData[0].modelData.key;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//ThreeDimensionalHomeComponent.instance.openSnackBar("暂无室内信息");
|
|
|
|
// alert("暂无室内信息");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
MarkWindow.instance.changeBuilding(false, this.buildingInfo.buildingData.normalData.key, key);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log("进入室内");
|
|
|
|
let indoorStatus = StatusManager.enterStatus<IndoorStatus>(IndoorStatus);
|
|
|
|
indoorStatus.init(this.buildingInfo, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 修改模型
|
|
|
|
* @param buildingData
|
|
|
|
*/
|
|
|
|
changeModel(file: File[]) {
|
|
|
|
|
|
|
|
this.buildingWindow.changeModel(file, this.buildingInfo.buildingData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关联预案管理平台的建筑id
|
|
|
|
* @param id
|
|
|
|
*/
|
|
|
|
linkingBuildingID(id: string) {
|
|
|
|
this.buildingInfo.buildingData.buildingIDFromPlatform = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 读取关联的预案管理平台的建筑id
|
|
|
|
*/
|
|
|
|
getlinkedBuildingID(): string {
|
|
|
|
return this.buildingInfo.buildingData.buildingIDFromPlatform;
|
|
|
|
}
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
//#region 外部公有
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 选中
|
|
|
|
*/
|
|
|
|
select() {
|
|
|
|
this.buildingWindow.onChangeCurrentBuildingItem(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 当选中时的表现
|
|
|
|
* @param select true表示选中
|
|
|
|
*/
|
|
|
|
onSelect(select: boolean, animMove = true) {
|
|
|
|
if (select) {
|
|
|
|
if (this.buildingInfo.ModelInfo != null && this.buildingInfo.ModelInfo.modelBox != null && ModeManager.currentMode == ModeType.Edit) {
|
|
|
|
GizmoTool.onPickMeshInfoObservable.notifyObservers(this.buildingInfo.ModelInfo);
|
|
|
|
//BabylonTool.changeCameraTarget(SceneManager.Instance.defaultCamera, this.buildingInfo.ModelInfo.modelBox, animMove);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (this.buildingInfo != null) {
|
|
|
|
GizmoTool.leaveTheGizmoAim(this.buildingInfo.ModelInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 相机注释、聚焦
|
|
|
|
*/
|
|
|
|
lookAt(anim: boolean = true) {
|
|
|
|
if (this.canLookAt()) {
|
|
|
|
BabylonTool.changeCameraTarget(SceneManager.Instance.defaultCamera, this.buildingInfo.ModelInfo.modelBox, anim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 是否可以聚焦
|
|
|
|
*/
|
|
|
|
canLookAt(): boolean {
|
|
|
|
let result = this.buildingInfo != null && this.buildingInfo.ModelInfo != null && this.buildingInfo.ModelInfo.modelBox != null;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置模型的显示状态
|
|
|
|
*/
|
|
|
|
setModelEnable(show: boolean) {
|
|
|
|
if (this.buildingInfo != null) {
|
|
|
|
this.buildingInfo.setEnable(show);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 从模型中创建消防设备信息
|
|
|
|
* @param mesh
|
|
|
|
*/
|
|
|
|
createFacilityByMesh(mesh: AbstractMesh) {
|
|
|
|
FacilityWindow.instance.createFacilityByMesh(mesh);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 从模型中创建安全疏散
|
|
|
|
* @param mesh
|
|
|
|
*/
|
|
|
|
createAQSSFromMesh(mesh: AbstractMesh) {
|
|
|
|
FacilityWindow.instance.createAQSSFromMesh(mesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 从模型中创建加油站相关信息
|
|
|
|
* @param mesh
|
|
|
|
*/
|
|
|
|
createOilingByMesh(mesh: AbstractMesh) {
|
|
|
|
FacilityWindow.instance.createOilingByMesh(mesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 从模型创建阻挡物信息
|
|
|
|
* @param mesh
|
|
|
|
*/
|
|
|
|
createStopByMesh(mesh: AbstractMesh) {
|
|
|
|
FacilityWindow.instance.createStopByMesh(mesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 清空从mesh中寻找的设备信息
|
|
|
|
*/
|
|
|
|
clearFacilityFromMesh() {
|
|
|
|
|
|
|
|
this.buildingInfo.ModelInfo.clearFacilityFromMesh();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region 内部私有
|
|
|
|
|
|
|
|
//修改建筑名称
|
|
|
|
private changeName(name: string) {
|
|
|
|
this.buildingInfo.buildingData.normalData.name = name;
|
|
|
|
if (this.buildingInfo.ModelInfo != null) {
|
|
|
|
(this.buildingInfo.ModelInfo as ModelInfo_building).updateName(name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//#endregion
|
|
|
|
}
|