diff --git a/src/app/babylon/model/info/model/model-info.ts b/src/app/babylon/model/info/model/model-info.ts index e9f0235..a2b6690 100644 --- a/src/app/babylon/model/info/model/model-info.ts +++ b/src/app/babylon/model/info/model/model-info.ts @@ -1,16 +1,15 @@ import { AbstractMesh, AnimationGroup, + Color3, EventState, - GizmoManager, Mesh, PointerDragBehavior, - TransformNode, - Node, Vector3, } from '@babylonjs/core'; import { Button, Rectangle, Vector2WithInfo } from '@babylonjs/gui'; import { classToClass } from 'class-transformer'; +import { SceneManager } from 'src/app/babylon/controller/scene-manager'; import { UIManager } from 'src/app/babylon/controller/ui-manager'; import { BabylonTool } from 'src/app/babylon/tool/babylon-tool'; import { GizmoTool } from 'src/app/babylon/tool/gizmo-tool'; @@ -137,6 +136,20 @@ export class ModelInfo { } } + /** + * 播放展示动画(高亮) + * @param play false表示停止,并恢复正常 + */ + playShowAnim(play: boolean) { + if (this.modelBox != null) { + if (play) { + SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Green()); + } + else { + SceneManager.Instance.removeFromHighLight(this.modelBox as Mesh); + } + } + } /** * 克隆 diff --git a/src/app/babylon/view/building-window/building-window.ts b/src/app/babylon/view/building-window/building-window.ts index 26062b7..59a1d5a 100644 --- a/src/app/babylon/view/building-window/building-window.ts +++ b/src/app/babylon/view/building-window/building-window.ts @@ -6,8 +6,8 @@ import { SceneManager } from "../../controller/scene-manager"; import { ServeManager } from "../../controller/serve-manager"; import { BuildingStatus } from "../../controller/status/building-status"; import { StatusManager } from "../../controller/status/status-manager"; -import { BuildingData_Normal, BuildingData_Environment, BuildingData_ChemicalPlant, BuildingType, BuildingData } from "../../model/data/institution/building/building-data"; -import { BuildingPosType, ModelType } from "../../model/data/model-data/model-data"; +import { BuildingData, BuildingData_ChemicalPlant, BuildingData_Environment, BuildingData_Normal, BuildingType } from "../../model/data/institution/building/building-data"; +import { ModelType } from "../../model/data/model-data/model-data"; import { FacilityType } from "../../model/data/model-data/model-data-facility"; import { ModelEditData } from "../../model/data/model-data/model-edit-data"; import { BuildingInfo } from "../../model/info/building/building-info"; @@ -15,6 +15,7 @@ import { BuildingInfo_ChemicalPlant } from "../../model/info/building/building-i import { BuildingInfo_Environment } from "../../model/info/building/building-info-environment"; import { BuildingInfo_Normal } from "../../model/info/building/building-info-normal"; import { ModelInfo_building } from "../../model/info/model/model-info-building"; +import { FacilityInfoByType } from "../../model/info/model/model-info-facility"; import { TsTool } from "../../tool/ts-tool"; import { UIBase } from "../window-base/ui-base"; import { BuildingUIItem } from "./building-ui-item"; @@ -201,6 +202,29 @@ export class BuildingWindow extends UIBase { } + /** + * 加油站信息各个模块的显示、隐藏 + * @param type + * @param show true表示显示 + */ + showJYZInfoModel(type: JYZInfoMoudleType, show: boolean) { + if (this.currentJYZInfoMoudleType == type) { + if (show) { + return; //与上次显示的模块相同 + } + else { + this.showJYZModules(type, show); + } + } + else { + this.showJYZModules(this.currentJYZInfoMoudleType, false); //先恢复之前隐藏的内容 + this.showJYZModules(type, show);//展示本次要展示的内容 + } + + } + + + //#endregion @@ -571,4 +595,141 @@ export class BuildingWindow extends UIBase { //#endregion + + //#region 加油站基本信息模块的显隐表现 + + /** + * 当前查看的加油站信息模块类型 + */ + currentJYZInfoMoudleType: JYZInfoMoudleType = null; + + /** + * 当前模块需要显示的各类设备 + */ + facilitysByMoudle: Map = new Map(); + + /** + * 当前模块需要隐藏的设备 + */ + zdByMoudle: Map = new Map(); + + /** + * 展示加油站信息模块 + * @param type + * @param show + */ + showJYZModules(type: JYZInfoMoudleType, show: boolean) { + + if (this.currentBuidngItem == null) { + return; + } + this.initFacilityTypeByMoudleType(type, this.currentBuidngItem.buildingInfo); + + //设备: 显示UI + let facilityByType: FacilityInfoByType[] = []; + if (this.facilitysByMoudle.has(type)) { + facilityByType = this.facilitysByMoudle.get(type); + } + for (let i = 0; i < facilityByType.length; i++) { + let infos = facilityByType[i].facilityInfo; + if (infos != null) { + for (let j = 0; j < infos.length; j++) { + infos[j].playShowAnim(show); + } + } + } + + //阻挡类物体 + let zdByType: FacilityInfoByType[] = []; + if (this.zdByMoudle.has(type)) { + zdByType = this.zdByMoudle.get(type); + } + for (let i = 0; i < zdByType.length; i++) { + let infos = zdByType[i].facilityInfo; + if (infos != null) { + for (let j = 0; j < infos.length; j++) { + infos[j].setEnable(!show); + } + } + } + + } + + /** + * 根据功能模块,获取所需的设备类型 + * @param moudleType + */ + initFacilityTypeByMoudleType(moudleType: JYZInfoMoudleType, buildingInfo: BuildingInfo) { + + let moudleTypeKey = moudleType + "_"; //当前模块物体的特殊字段 + let zdKey = "ZD_" + moudleType; //阻挡类物体特殊字段 + + if (this.facilitysByMoudle.has(moudleType)) { + //已经初始化过了 + return; + } + else { + this.facilitysByMoudle.set(moudleType, []); + } + + let allFacilityByType = buildingInfo.ModelInfo.facilityInfos; + if (allFacilityByType == null) { + return; //没有设备 + } + + + + for (let i = 0; i < allFacilityByType.length; i++) { + let l_facilityByType = allFacilityByType[i]; + if (TsTool.stringContain(l_facilityByType.type, zdKey)) { + this.zdByMoudle.get(moudleType).push(l_facilityByType); + } + else if (TsTool.stringContain(l_facilityByType.type, moudleTypeKey)) { + this.facilitysByMoudle.get(moudleType).push(l_facilityByType); + } + } + + // for (var l_facility in FacilityType) { + + + + + // } + } + + + + //#endregion + + +} + +/** + * 加油站信息模块类型 + */ +export enum JYZInfoMoudleType { + /** + * 消防 + */ + XF = "XF", + /** + * 加油机 + */ + JYJ = "JYJ", + /** + * 油罐 + */ + YG = "YG", + /** + * 输油管 + */ + SYG = "SYG", + /** + * 油气回收管线 + */ + YQHSGX = "YQHSGX", + /** + * 逃生路线 + */ + TSLX = "TSLX", } \ No newline at end of file