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 { MarkData } from "../model/data/mark/mark-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 { TransformData } from "../model/data/transform-data";
import { BuildingInfo } from "../model/info/building/building-info";
@ -164,6 +164,7 @@ export class InfoManager {
modelEditData: ModelEditData,
buildingInfo: BuildingInfo = null
) {
console.trace("创建设备", buildingInfo);
let facilities = modelEditData.facilities;
@ -171,10 +172,11 @@ export class InfoManager {
for (let j = 0; j < facilities[i].facilities.length; j++) {
let mesh = null;
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);
}

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

@ -259,16 +259,22 @@ export class SceneManager {
let allMesh = mesh.getChildMeshes();
this.highLightLayer.addMesh(mesh, color);
allMesh.push(mesh);
for (let i = 0; i < allMesh.length; i++) {
let childMesh = allMesh[i];
if (childMesh instanceof Mesh) {
this.highLightLayer.addMesh(childMesh, color);
this.highLightNum++;
}
}
}
highLightNum = 0;
/**
*
* @param mesh
@ -278,21 +284,23 @@ export class SceneManager {
return;
}
let allMesh = mesh.getChildMeshes();
allMesh.push(mesh);
for (let i = 0; i < allMesh.length; i++) {
let childMesh = allMesh[i];
if (childMesh instanceof Mesh) {
this.highLightLayer.removeMesh(childMesh);
this.highLightNum--;
}
}
}
/**
*
*/
clearHighLight() {
this.highLightLayer.removeAllMeshes();
}
// /**
// * 清空高亮层
// */
// clearHighLight() {
// this.highLightLayer.removeAllMeshes();
// }
//#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 { UIManager } from 'src/app/babylon/controller/ui-manager';
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';
@ -143,10 +144,12 @@ export class ModelInfo {
playShowAnim(play: boolean) {
if (this.modelBox != null) {
if (play) {
SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Green());
SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Red());
}
else {
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);
if (buildingData.outdoorData != null && buildingData.outdoorData.modelData != null && buildingData.outdoorData.modelData.resName != null) {
this.updateBuildingModel(buildingInfo, false, () => {
buildingInfo.initFacility();
this.updateBuildingModel(buildingInfo, true, () => {
// buildingInfo.initFacility();
BuildingStatus.enterSuccessObservable.notifyObservers(uiItem);
if (onSuccess) {
onSuccess(uiItem, index);
@ -208,6 +208,7 @@ export class BuildingWindow extends UIBase {
* @param show true表示显示
*/
showJYZInfoModel(type: JYZInfoMoudleType, show: boolean) {
console.log("showJYZInfoModel", type, show);
if (this.currentJYZInfoMoudleType == type) {
if (show) {
return; //与上次显示的模块相同
@ -217,7 +218,9 @@ export class BuildingWindow extends UIBase {
}
}
else {
this.showJYZModules(this.currentJYZInfoMoudleType, false); //先恢复之前隐藏的内容
if (this.currentJYZInfoMoudleType != null) {
this.showJYZModules(this.currentJYZInfoMoudleType, false); //先恢复之前隐藏的内容
}
this.showJYZModules(type, show);//展示本次要展示的内容
}
@ -365,6 +368,7 @@ export class BuildingWindow extends UIBase {
buildingInfo.ModelInfo = modelInfo as ModelInfo_building;
buildingInfo.ModelInfo.updateName(buildingInfo.buildingData.normalData.name);
if (updateFacility) {
InfoManager.createFacilityInfos(buildingInfo.buildingData.outdoorData, buildingInfo);
}
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;
// SceneManager.Instance.highLightLayer.removeAllMeshes();
}
}

Loading…
Cancel
Save