diff --git a/src/app/babylon/controller/info-manager.ts b/src/app/babylon/controller/info-manager.ts index 7a8fc35..c3746bf 100644 --- a/src/app/babylon/controller/info-manager.ts +++ b/src/app/babylon/controller/info-manager.ts @@ -174,12 +174,13 @@ export class InfoManager { let mesh: AbstractMesh = null; let facilityData = facilities[i].facilities[j] - if (facilityData.posType == FacilityPosType.In) { - mesh = SceneManager.Instance.scene.getMeshByID(facilityData.resName); - console.log("找到内置设备", mesh.uniqueId); + if (facilityData.posType == FacilityPosType.In && buildingInfo.ModelInfo != null) { + mesh = buildingInfo.ModelInfo.getChildrenByName(facilityData.resName); + console.log("内建模型找到", mesh); } + FacilityWindow.instance.createFacility( modelEditData.facilities[i].facilities[j], false, diff --git a/src/app/babylon/controller/scene-manager.ts b/src/app/babylon/controller/scene-manager.ts index 5e14706..dd219a5 100644 --- a/src/app/babylon/controller/scene-manager.ts +++ b/src/app/babylon/controller/scene-manager.ts @@ -252,11 +252,13 @@ export class SceneManager { */ addToHighLight(mesh: Mesh, color: Color3) { if (this.highLightLayer == null) { - this.highLightLayer = new HighlightLayer("highLight", this.scene); + this.highLightLayer = new HighlightLayer("highLight", this.scene, + { + mainTextureRatio: 1, + }); this.highLightLayer.innerGlow = false; } - let allMesh = mesh.getChildMeshes(); this.highLightLayer.addMesh(mesh, color); allMesh.push(mesh); @@ -268,9 +270,6 @@ export class SceneManager { } } - - - } highLightNum = 0; diff --git a/src/app/babylon/model/info/model/model-info-building.ts b/src/app/babylon/model/info/model/model-info-building.ts index 2d47b2a..2e50775 100644 --- a/src/app/babylon/model/info/model/model-info-building.ts +++ b/src/app/babylon/model/info/model/model-info-building.ts @@ -46,6 +46,16 @@ export class ModelInfo_building extends ModelInfo { } } + if (this.neiRoot == null) { + for (let i = 0; i < allTransformNode.length; i++) { + if (TsTool.stringContain(allTransformNode[i].name, "wai")) { + this.neiRoot = allTransformNode[i]; + break; + } + } + } + + if (this.neiRoot == null) { this.neiRoot = this.modelBox; diff --git a/src/app/babylon/model/info/model/model-info.ts b/src/app/babylon/model/info/model/model-info.ts index 066d77a..06ca14d 100644 --- a/src/app/babylon/model/info/model/model-info.ts +++ b/src/app/babylon/model/info/model/model-info.ts @@ -144,7 +144,7 @@ export class ModelInfo { playShowAnim(play: boolean) { if (this.modelBox != null) { if (play) { - SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Red()); + SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Green()); } else { diff --git a/src/app/babylon/view/building-window/building-window.ts b/src/app/babylon/view/building-window/building-window.ts index 298de6a..b16dc32 100644 --- a/src/app/babylon/view/building-window/building-window.ts +++ b/src/app/babylon/view/building-window/building-window.ts @@ -1,4 +1,5 @@ +import { AbstractMesh, Material, Mesh } from "@babylonjs/core"; import { PlanComponent } from "src/app/pages/plan/plan.component"; import { DataManager } from "../../controller/data-manager"; import { InfoManager } from "../../controller/info-manager"; @@ -23,6 +24,11 @@ import { BuildingUIItem } from "./building-ui-item"; //建筑界面 export class BuildingWindow extends UIBase { + /** + * uv动画材质的特殊命名 + */ + readonly c_MAT_UV = "MAT_UV"; + static instance: BuildingWindow; buldingStatus: BuildingStatus; @@ -370,6 +376,9 @@ export class BuildingWindow extends UIBase { if (updateFacility) { InfoManager.createFacilityInfos(buildingInfo.buildingData.outdoorData, buildingInfo); + + + } if (buildingInfo instanceof BuildingInfo_Environment) { buildingInfo.updateFuGaiCeng(); @@ -581,11 +590,14 @@ export class BuildingWindow extends UIBase { for (let i = 0; i < allNode.length; i++) { let nodeName = allNode[i].name; - if (TsTool.stringContain(nodeName, this.c_xiaoFang)) //消防 + if (TsTool.stringContain(nodeName, "primitive")) { + //复合材质被分解为多个子mesh,不看做特殊意义的对象 + } + else if (TsTool.stringContain(nodeName, this.c_xiaoFang)) //消防 { this.currentBuidngItem.createFacilityByMesh(allNode[i]); } - else if (TsTool.stringContain(nodeName, this.c_xiaoFang))//加油站 + else if (TsTool.stringContain(nodeName, this.c_jiaYou))//加油站 { this.currentBuidngItem.createOilingByMesh(allNode[i]); } @@ -621,6 +633,11 @@ export class BuildingWindow extends UIBase { */ zdByMoudle: Map = new Map(); + /** + * uv动画所需材质 + */ + mat_UV: Map = new Map(); + /** * 展示加油站信息模块 * @param type @@ -652,10 +669,12 @@ export class BuildingWindow extends UIBase { if (this.zdByMoudle.has(type)) { zdByType = this.zdByMoudle.get(type); } + console.log("阻挡物", zdByType); for (let i = 0; i < zdByType.length; i++) { let infos = zdByType[i].facilityInfo; if (infos != null) { for (let j = 0; j < infos.length; j++) { + console.log("隐藏阻挡物", infos[j]); infos[j].setEnable(!show); } } @@ -694,24 +713,18 @@ export class BuildingWindow extends UIBase { return; //没有设备 } - - for (let i = 0; i < allFacilityByType.length; i++) { let l_facilityByType = allFacilityByType[i]; if (TsTool.stringContain(l_facilityByType.type, zdKey)) { + if (!this.zdByMoudle.has(moudleType)) { + this.zdByMoudle.set(moudleType, []); + } 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) { - - - - - // } } /** @@ -731,7 +744,78 @@ export class BuildingWindow extends UIBase { } } + /** + * 获取设备所需UV材质(如果有的话) + * @param facilityType + * @param mesh + */ + getUVMat(facilityType: FacilityType, mesh: AbstractMesh) { + let moudleType: JYZInfoMoudleType = null; + switch (facilityType) { + case FacilityType.XF_TSLX: + moudleType = JYZInfoMoudleType.TSLX; + break; + case FacilityType.JY_SYGX: + moudleType = JYZInfoMoudleType.SYG; + break; + case FacilityType.JY_YQHSGX: + moudleType = JYZInfoMoudleType.YQHSGX; + break; + } + + if (moudleType != null) { + if (!this.mat_UV.has(moudleType)) { + this.mat_UV.set(moudleType, []); + } + + let mats = this.findUVMat(mesh); //找到mesh上的uv材质 + + for (let i = 0; i < mats.length; i++) { + let l_mat = mats[i]; + + let mat_uvByType = this.mat_UV.get(moudleType); + let isRepeat = false;//是重复的 + for (let j = 0; j < mat_uvByType.length; j++) { + if (isRepeat) { + continue; + } + if (l_mat == mat_uvByType[j]) { + isRepeat = true; + } + } + + if (!isRepeat)//不重复,就添加进去 + { + this.mat_UV.get(moudleType).push(l_mat); + } + } + } + } + /** + * 查找mesh中uv动画所需的材质 + * @param mesh + */ + private findUVMat(mesh: AbstractMesh) { + let result = []; + + let childMesh = mesh.getChildMeshes(); + childMesh.push(mesh); + + for (let i = 0; i < childMesh.length; i++) { + let mat = childMesh[i].material; + if (TsTool.stringContain(mat.name, this.c_MAT_UV)) { + // for(let j =0;j< result.length;j++) + // { + // if(mat != result[j]) + // { + result.push(mat); + // } + // } + } + } + return result; + } //#endregion diff --git a/src/app/babylon/view/facility-window/facility-window.ts b/src/app/babylon/view/facility-window/facility-window.ts index feb8e24..25d2447 100644 --- a/src/app/babylon/view/facility-window/facility-window.ts +++ b/src/app/babylon/view/facility-window/facility-window.ts @@ -32,6 +32,7 @@ import { BabylonTool } from '../../tool/babylon-tool'; import { BabylonUIStyleTool } from '../../tool/babylon-ui-style-tool'; import { GizmoTool } from '../../tool/gizmo-tool'; import { TsTool } from '../../tool/ts-tool'; +import { BuildingWindow } from '../building-window/building-window'; import { CopyFacilityInfo, FacilityInfoInSceneWindow } from '../facilityinfoinscene-window/facilityinfoinscene-window'; import { ToolbarWindow } from '../toolbar-window/toobar-window'; import { UIBase } from '../window-base/ui-base'; @@ -413,6 +414,8 @@ export class FacilityWindow extends UIBase { onSuccess?: (modelInfo: ModelInfo_facility) => void ): ModelInfo_facility { + BuildingWindow.instance.getUVMat(facilityData.facilityType, mesh); + if (buildingInfo == null) { buildingInfo = this.getCurrentBuildingInfo(); } @@ -613,15 +616,19 @@ export class FacilityWindow extends UIBase { createOilingByMesh(mesh: AbstractMesh) { if (TsTool.stringContain(mesh.name, FacilityType.JY_JYJ)) { + console.log("找到加油机", mesh) this.createNewFacilityByMesh(mesh, FacilityType.JY_JYJ); } else if (TsTool.stringContain(mesh.name, FacilityType.JY_SYGX)) { + console.log("找到输油管线", mesh) this.createNewFacilityByMesh(mesh, FacilityType.JY_SYGX); } else if (TsTool.stringContain(mesh.name, FacilityType.JY_YG)) { + console.log("找到油罐", mesh) this.createNewFacilityByMesh(mesh, FacilityType.JY_YG); } else if (TsTool.stringContain(mesh.name, FacilityType.JY_YQHSGX)) { + console.log("找到油气回收", mesh) this.createNewFacilityByMesh(mesh, FacilityType.JY_YQHSGX); } }