|
|
|
import { Vector3 } from "@babylonjs/core";
|
|
|
|
import { InfoManager } from "src/app/babylon/controller/info-manager";
|
|
|
|
import { SceneManager } from "src/app/babylon/controller/scene-manager";
|
|
|
|
import { BuildingStatus } from "src/app/babylon/controller/status/building-status";
|
|
|
|
import { StatusManager } from "src/app/babylon/controller/status/status-manager";
|
|
|
|
import { GizmoTool } from "src/app/babylon/tool/gizmo-tool";
|
|
|
|
|
|
|
|
import { BuildingData } from "../../data/institution/building/building-data";
|
|
|
|
import { TransformData } from "../../data/transform-data";
|
|
|
|
import { ModelInfo_building } from "../model/model-info-building";
|
|
|
|
|
|
|
|
//基本建筑信息
|
|
|
|
export class BuildingInfo {
|
|
|
|
/**
|
|
|
|
* 所属建筑的数据
|
|
|
|
*/
|
|
|
|
buildingData: BuildingData;
|
|
|
|
/**
|
|
|
|
* 本模型的数据(室外建筑或室内某层)
|
|
|
|
*/
|
|
|
|
private modelInfo: ModelInfo_building;
|
|
|
|
isDisposed = false;//已经释放了
|
|
|
|
isEnable = true;//显示状态
|
|
|
|
constructor(buildingData: BuildingData, modelInfo: ModelInfo_building) {
|
|
|
|
this.buildingData = buildingData;
|
|
|
|
this.ModelInfo = modelInfo;
|
|
|
|
this.isDisposed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 本模型的数据(室外建筑或室内某层)
|
|
|
|
*/
|
|
|
|
get ModelInfo() {
|
|
|
|
return this.modelInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
set ModelInfo(value: ModelInfo_building) {
|
|
|
|
this.modelInfo = value;
|
|
|
|
if (this.isDisposed) {
|
|
|
|
this.dispose();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (value != null) {
|
|
|
|
let modelInfo = this.modelInfo;
|
|
|
|
if (modelInfo.modelData.transformData == null) {
|
|
|
|
modelInfo.modelData.transformData = new TransformData();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
modelInfo.modelData.transformData.originalScaling.equals(Vector3.Zero())
|
|
|
|
) {
|
|
|
|
//表示是新建
|
|
|
|
modelInfo.modelData.transformData.position = modelInfo.modelBox.position;
|
|
|
|
modelInfo.modelData.transformData.rotation = modelInfo.modelBox.rotation;
|
|
|
|
modelInfo.modelData.transformData.rotationQuaternion =
|
|
|
|
modelInfo.modelBox.rotationQuaternion;
|
|
|
|
modelInfo.modelData.transformData.originalScaling = modelInfo.modelBox.absoluteScaling.clone();
|
|
|
|
modelInfo.modelData.transformData.scaling = modelInfo.modelBox.absoluteScaling.clone();
|
|
|
|
} //已有数据,进行还原
|
|
|
|
else {
|
|
|
|
modelInfo.modelBox.position = modelInfo.modelData.transformData.position;
|
|
|
|
modelInfo.modelBox.rotation = modelInfo.modelData.transformData.rotation;
|
|
|
|
modelInfo.modelBox.rotationQuaternion =
|
|
|
|
modelInfo.modelData.transformData.rotationQuaternion;
|
|
|
|
}
|
|
|
|
this.ModelInfo.buildingType = this.buildingData.buildingType;
|
|
|
|
this.ModelInfo.setEnable(this.isEnable);
|
|
|
|
this.onSetModel();
|
|
|
|
//this.initFacility();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// if (!this.isEnable) {
|
|
|
|
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 初始化设备
|
|
|
|
*/
|
|
|
|
initFacility() {
|
|
|
|
if (StatusManager.s_currentStatus instanceof BuildingStatus) {
|
|
|
|
InfoManager.createFacilityInfos(this.buildingData.outdoorData, this);
|
|
|
|
this.ModelInfo.showFacilityUI(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setEnable(enable: boolean) {
|
|
|
|
this.isEnable = enable;
|
|
|
|
if (this.ModelInfo != null) {
|
|
|
|
this.ModelInfo.setEnable(enable);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设置模型了
|
|
|
|
*/
|
|
|
|
onSetModel() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//释放
|
|
|
|
dispose() {
|
|
|
|
this.isDisposed = true;
|
|
|
|
StatusManager.getStatus(BuildingStatus).buildingWindow.clearFacilityInfos(this);
|
|
|
|
if (this.modelInfo != null) {
|
|
|
|
if (GizmoTool.s_nowPickAim == this.modelInfo) {
|
|
|
|
GizmoTool.onPickMeshInfoObservable.notifyObservers(null);
|
|
|
|
}
|
|
|
|
SceneManager.destroyModel(this.modelInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|