Browse Source

高亮问题修复

dev
刘向辉 3 years ago
parent
commit
d3dfe25e8f
  1. 6
      src/app/babylon/controller/info-manager.ts
  2. 20
      src/app/babylon/controller/scene-manager.ts
  3. 5
      src/app/babylon/model/info/model/model-info.ts
  4. 18
      src/app/babylon/view/building-window/building-window.ts

6
src/app/babylon/controller/info-manager.ts

@ -2,7 +2,7 @@
import { AbstractMesh } from "@babylonjs/core"; import { AbstractMesh } from "@babylonjs/core";
import { MarkData } from "../model/data/mark/mark-data"; import { MarkData } from "../model/data/mark/mark-data";
import { ModelData } from "../model/data/model-data/model-data"; import { ModelData } from "../model/data/model-data/model-data";
import { FacilityInBuildingType, FacilityPosType, FacilityType, ModelData_facility } from "../model/data/model-data/model-data-facility"; import { FacilityPosType, FacilityType, ModelData_facility } from "../model/data/model-data/model-data-facility";
import { ModelEditData } from "../model/data/model-data/model-edit-data"; import { ModelEditData } from "../model/data/model-data/model-edit-data";
import { TransformData } from "../model/data/transform-data"; import { TransformData } from "../model/data/transform-data";
import { BuildingInfo } from "../model/info/building/building-info"; import { BuildingInfo } from "../model/info/building/building-info";
@ -164,6 +164,7 @@ export class InfoManager {
modelEditData: ModelEditData, modelEditData: ModelEditData,
buildingInfo: BuildingInfo = null buildingInfo: BuildingInfo = null
) { ) {
console.trace("创建设备", buildingInfo);
let facilities = modelEditData.facilities; let facilities = modelEditData.facilities;
@ -171,10 +172,11 @@ export class InfoManager {
for (let j = 0; j < facilities[i].facilities.length; j++) { for (let j = 0; j < facilities[i].facilities.length; j++) {
let mesh = null; let mesh: AbstractMesh = null;
let facilityData = facilities[i].facilities[j] let facilityData = facilities[i].facilities[j]
if (facilityData.posType == FacilityPosType.In) { if (facilityData.posType == FacilityPosType.In) {
mesh = SceneManager.Instance.scene.getMeshByID(facilityData.resName); mesh = SceneManager.Instance.scene.getMeshByID(facilityData.resName);
console.log("找到内置设备", mesh.uniqueId);
} }

20
src/app/babylon/controller/scene-manager.ts

@ -259,16 +259,22 @@ export class SceneManager {
let allMesh = mesh.getChildMeshes(); let allMesh = mesh.getChildMeshes();
this.highLightLayer.addMesh(mesh, color); this.highLightLayer.addMesh(mesh, color);
allMesh.push(mesh);
for (let i = 0; i < allMesh.length; i++) { for (let i = 0; i < allMesh.length; i++) {
let childMesh = allMesh[i]; let childMesh = allMesh[i];
if (childMesh instanceof Mesh) { if (childMesh instanceof Mesh) {
this.highLightLayer.addMesh(childMesh, color); this.highLightLayer.addMesh(childMesh, color);
this.highLightNum++;
} }
} }
} }
highLightNum = 0;
/** /**
* *
* @param mesh * @param mesh
@ -278,21 +284,23 @@ export class SceneManager {
return; return;
} }
let allMesh = mesh.getChildMeshes(); let allMesh = mesh.getChildMeshes();
allMesh.push(mesh);
for (let i = 0; i < allMesh.length; i++) { for (let i = 0; i < allMesh.length; i++) {
let childMesh = allMesh[i]; let childMesh = allMesh[i];
if (childMesh instanceof Mesh) { if (childMesh instanceof Mesh) {
this.highLightLayer.removeMesh(childMesh); this.highLightLayer.removeMesh(childMesh);
this.highLightNum--;
} }
} }
} }
/** // /**
* // * 清空高亮层
*/ // */
clearHighLight() { // clearHighLight() {
this.highLightLayer.removeAllMeshes(); // this.highLightLayer.removeAllMeshes();
} // }
//#endregion //#endregion

5
src/app/babylon/model/info/model/model-info.ts

@ -12,6 +12,7 @@ import { classToClass } from 'class-transformer';
import { SceneManager } from 'src/app/babylon/controller/scene-manager'; import { SceneManager } from 'src/app/babylon/controller/scene-manager';
import { UIManager } from 'src/app/babylon/controller/ui-manager'; import { UIManager } from 'src/app/babylon/controller/ui-manager';
import { BabylonTool } from 'src/app/babylon/tool/babylon-tool'; import { BabylonTool } from 'src/app/babylon/tool/babylon-tool';
import { BabylonUIStyleTool } from 'src/app/babylon/tool/babylon-ui-style-tool';
import { GizmoTool } from 'src/app/babylon/tool/gizmo-tool'; import { GizmoTool } from 'src/app/babylon/tool/gizmo-tool';
@ -143,10 +144,12 @@ export class ModelInfo {
playShowAnim(play: boolean) { playShowAnim(play: boolean) {
if (this.modelBox != null) { if (this.modelBox != null) {
if (play) { if (play) {
SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Green()); SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Red());
} }
else { else {
SceneManager.Instance.removeFromHighLight(this.modelBox as Mesh); SceneManager.Instance.removeFromHighLight(this.modelBox as Mesh);
} }
} }
} }

18
src/app/babylon/view/building-window/building-window.ts

@ -62,8 +62,8 @@ export class BuildingWindow extends UIBase {
let uiItem = this.addBuildingItem(buildingInfo); let uiItem = this.addBuildingItem(buildingInfo);
if (buildingData.outdoorData != null && buildingData.outdoorData.modelData != null && buildingData.outdoorData.modelData.resName != null) { if (buildingData.outdoorData != null && buildingData.outdoorData.modelData != null && buildingData.outdoorData.modelData.resName != null) {
this.updateBuildingModel(buildingInfo, false, () => { this.updateBuildingModel(buildingInfo, true, () => {
buildingInfo.initFacility(); // buildingInfo.initFacility();
BuildingStatus.enterSuccessObservable.notifyObservers(uiItem); BuildingStatus.enterSuccessObservable.notifyObservers(uiItem);
if (onSuccess) { if (onSuccess) {
onSuccess(uiItem, index); onSuccess(uiItem, index);
@ -208,6 +208,7 @@ export class BuildingWindow extends UIBase {
* @param show true表示显示 * @param show true表示显示
*/ */
showJYZInfoModel(type: JYZInfoMoudleType, show: boolean) { showJYZInfoModel(type: JYZInfoMoudleType, show: boolean) {
console.log("showJYZInfoModel", type, show);
if (this.currentJYZInfoMoudleType == type) { if (this.currentJYZInfoMoudleType == type) {
if (show) { if (show) {
return; //与上次显示的模块相同 return; //与上次显示的模块相同
@ -217,7 +218,9 @@ export class BuildingWindow extends UIBase {
} }
} }
else { else {
this.showJYZModules(this.currentJYZInfoMoudleType, false); //先恢复之前隐藏的内容 if (this.currentJYZInfoMoudleType != null) {
this.showJYZModules(this.currentJYZInfoMoudleType, false); //先恢复之前隐藏的内容
}
this.showJYZModules(type, show);//展示本次要展示的内容 this.showJYZModules(type, show);//展示本次要展示的内容
} }
@ -365,6 +368,7 @@ export class BuildingWindow extends UIBase {
buildingInfo.ModelInfo = modelInfo as ModelInfo_building; buildingInfo.ModelInfo = modelInfo as ModelInfo_building;
buildingInfo.ModelInfo.updateName(buildingInfo.buildingData.normalData.name); buildingInfo.ModelInfo.updateName(buildingInfo.buildingData.normalData.name);
if (updateFacility) { if (updateFacility) {
InfoManager.createFacilityInfos(buildingInfo.buildingData.outdoorData, buildingInfo); InfoManager.createFacilityInfos(buildingInfo.buildingData.outdoorData, buildingInfo);
} }
if (buildingInfo instanceof BuildingInfo_Environment) { if (buildingInfo instanceof BuildingInfo_Environment) {
@ -656,8 +660,14 @@ export class BuildingWindow extends UIBase {
} }
} }
} }
if (!show) { if (show) {
this.currentJYZInfoMoudleType = type;
}
else {
console.log("隐藏", this.currentJYZInfoMoudleType);
this.currentJYZInfoMoudleType = null; this.currentJYZInfoMoudleType = null;
// SceneManager.Instance.highLightLayer.removeAllMeshes();
} }
} }

Loading…
Cancel
Save