Browse Source

新增加油设备属性

dev
刘向辉 3 years ago
parent
commit
57ae37ba16
  1. 9
      src/app/babylon/controller/data-manager.ts
  2. 22
      src/app/babylon/model/data/institution/facility/property-data/in/property-data-jyj.ts
  3. 25
      src/app/babylon/model/data/institution/facility/property-data/in/property-data-sygx.ts
  4. 20
      src/app/babylon/model/data/institution/facility/property-data/in/property-data-yg.ts
  5. 25
      src/app/babylon/model/data/institution/facility/property-data/in/property-data-yqhsgx.ts
  6. 2
      src/app/babylon/model/data/institution/facility/property-data/out/property-data-q.ts
  7. 2
      src/app/babylon/model/data/model-data/model-data-facility.ts
  8. 50
      src/app/babylon/model/info/model/facilityinfo-tool/facility-area.ts
  9. 34
      src/app/babylon/model/info/model/model-info-facility.ts
  10. 16
      src/app/babylon/model/info/model/model-info.ts
  11. 7
      src/app/babylon/tool/pos-point-tool.ts
  12. 147
      src/app/babylon/view/facility-window/facility-window.ts

9
src/app/babylon/controller/data-manager.ts

@ -11,7 +11,11 @@ import {
} from '../model/data/institution/building/building-data';
import { AllFacilityData } from '../model/data/institution/facility/all-facility-data';
import { PropertyData_Base_IMG } from '../model/data/institution/facility/property-data/base/property-data-base-img';
import { PropertyData_JYJ } from '../model/data/institution/facility/property-data/in/property-data-jyj';
import { PropertyData_MHQ } from '../model/data/institution/facility/property-data/in/property-data-mhq';
import { PropertyData_SYGX } from '../model/data/institution/facility/property-data/in/property-data-sygx';
import { PropertyData_YG } from '../model/data/institution/facility/property-data/in/property-data-yg';
import { PropertyData_YQHSGX } from '../model/data/institution/facility/property-data/in/property-data-yqhsgx';
import { PropertyData_DWBZ } from '../model/data/institution/facility/property-data/out/property-data-dwbz';
import { PropertyData_PL } from '../model/data/institution/facility/property-data/out/property-data-pl';
import { PropertyData_Q } from '../model/data/institution/facility/property-data/out/property-data-q';
@ -439,7 +443,10 @@ export class DataManager {
case FacilityType.XF_MHQ_GF_4:
case FacilityType.XF_MHQ_GF_8:
case FacilityType.XF_MHQ_GF_35: result = new PropertyData_MHQ(key, facilityType); break;
case FacilityType.JY_JYJ: result = new PropertyData_JYJ(key); break;
case FacilityType.JY_YG: result = new PropertyData_YG(key); break;
case FacilityType.JY_SYGX: result = new PropertyData_SYGX(key); break;
case FacilityType.JY_YQHSGX: result = new PropertyData_YQHSGX(key); break;
}

22
src/app/babylon/model/data/institution/facility/property-data/in/property-data-jyj.ts

@ -0,0 +1,22 @@
import { FacilityType } from "../../../../model-data/model-data-facility";
import { PropertyData_Base } from "../property-data-base";
/**
*
*/
export class PropertyData_JYJ extends PropertyData_Base {
constructor(key: string) {
super(key, FacilityType.JY_JYJ);
}
clone(key: string) {
let result = new PropertyData_JYJ(key);
return result;
}
}

25
src/app/babylon/model/data/institution/facility/property-data/in/property-data-sygx.ts

@ -0,0 +1,25 @@
import { FacilityType } from "../../../../model-data/model-data-facility";
import { PropertyData_Base_IMG } from "../base/property-data-base-img";
import { PropertyData_Base } from "../property-data-base";
/**
*
*/
export class PropertyData_SYGX extends PropertyData_Base_IMG {
constructor(key: string) {
super(key, "", "", "", FacilityType.JY_SYGX);
}
clone(key: string) {
let result = new PropertyData_SYGX(key);
result.img = this.img;
result.pos = this.pos;
result.info = this.info,
result.is360 = this.is360;
return result;
}
}

20
src/app/babylon/model/data/institution/facility/property-data/in/property-data-yg.ts

@ -0,0 +1,20 @@
import { FacilityType } from "../../../../model-data/model-data-facility";
import { PropertyData_Base } from "../property-data-base";
/**
*
*/
export class PropertyData_YG extends PropertyData_Base {
constructor(key: string) {
super(key, FacilityType.JY_YG);
}
clone(key: string) {
let result = new PropertyData_YG(key);
return result;
}
}

25
src/app/babylon/model/data/institution/facility/property-data/in/property-data-yqhsgx.ts

@ -0,0 +1,25 @@
import { FacilityType } from "../../../../model-data/model-data-facility";
import { PropertyData_Base_IMG } from "../base/property-data-base-img";
import { PropertyData_Base } from "../property-data-base";
/**
*
*/
export class PropertyData_YQHSGX extends PropertyData_Base_IMG {
constructor(key: string) {
super(key, "", "", "", FacilityType.JY_YQHSGX);
}
clone(key: string) {
let result = new PropertyData_YQHSGX(key);
result.img = this.img;
result.pos = this.pos;
result.info = this.info,
result.is360 = this.is360;
return result;
}
}

2
src/app/babylon/model/data/institution/facility/property-data/out/property-data-q.ts

@ -6,7 +6,7 @@ import { PropertyData_Base_IMG } from "../base/property-data-base-img";
import { PropertyData_Base } from "../property-data-base";
/**
*
*
*/
export class PropertyData_Q extends PropertyData_Base_IMG {

2
src/app/babylon/model/data/model-data/model-data-facility.ts

@ -67,7 +67,7 @@ export class ModelData_facility extends ModelData {
//新建区域位点
newAreapPoints(): Vector3[] {
let size = 10;
let size = 3;
let x = 0.75 * size;
let z = 0.5 * size;
let result: Vector3[] = [];

50
src/app/babylon/model/info/model/facilityinfo-tool/facility-area.ts

@ -1,6 +1,6 @@
//#region 区域
import { AbstractMesh, Color3, Mesh, MeshBuilder, Observer, PolygonMeshBuilder, Quaternion, Scene, StandardMaterial, Vector2, Vector3 } from "@babylonjs/core";
import { AbstractMesh, Color3, Mesh, MeshBuilder, Observer, PointerDragBehavior, PolygonMeshBuilder, Quaternion, Scene, StandardMaterial, Vector2, Vector3 } from "@babylonjs/core";
import { Button, Vector2WithInfo } from "@babylonjs/gui";
import { ModelInfo_facility } from "../model-info-facility";
@ -197,9 +197,9 @@ export class AreaInfo {
//更新顶点
updateMeshPoint(index = -1) {
this.clearMeshPoint();
let select = null;
let select: PolygonMeshPoint = null;
for (let i = 0; i < this.pointData.length; i++) {
let l_meshPoint = new PolygonMeshPoint(PosPointTool.c_key + "_" + i, i, 0.2, this.root, this.pointData[i], this);
let l_meshPoint = new PolygonMeshPoint(PosPointTool.c_key + "_" + i, i, 0.5, this.root, this.pointData[i], this);
this.pointMesh.push(l_meshPoint);
if (i == index) {
@ -266,6 +266,7 @@ export class PolygonMeshPoint {
area: AreaInfo
mesh: Mesh;
pos: Vector3;
pointMat: StandardMaterial; //顶点材质
index: number;
@ -273,6 +274,7 @@ export class PolygonMeshPoint {
onGizmoAimMeshObservor: Observer<AbstractMesh>;
onPointerClickObservor: Observer<Vector2WithInfo>;
pointerDragBehavior: PointerDragBehavior;//拖拽事件
constructor(name: string, index: number, size: number, parent: Mesh, pos: Vector3, area: AreaInfo) {
@ -289,23 +291,37 @@ export class PolygonMeshPoint {
//初始化编辑UI
initEditUI(name: string, size: number, parent: Mesh, pos: Vector3) {
if (ModeManager.currentMode == ModeType.Edit) {
this.mesh = MeshBuilder.CreateBox(name, { size: size });
let instance = this;
this.mesh = MeshBuilder.CreateSphere(name, { diameter: size });
this.mesh.setParent(parent);
this.mesh.position = pos;
this.mesh.isVisible = false;
this.mesh.isVisible = true;
let instance = this;
this.uiRoot = Button.CreateSimpleButton("ui_" + name, this.index.toString());
UIManager.Instance.uiRoot.addControl(this.uiRoot);
this.uiRoot.linkWithMesh(this.mesh);
BabylonUIStyleTool.setStyle_size(this.uiRoot, "20px", "20px");
this.uiRoot.background = BabylonUIStyleTool.c_color_blue;
this.uiRoot.color = BabylonUIStyleTool.c_color_white;
this.uiRoot.onPointerClickObservable.add(() => {
this.pointMat = new StandardMaterial("mat_areaPoint", SceneManager.Instance.scene);
this.pointMat.emissiveColor = Color3.FromHexString("#A9FF00");
this.pointMat.disableLighting = true;
this.pointMat.alpha = 0.87;
this.mesh.material = this.pointMat;
this.pointerDragBehavior = new PointerDragBehavior({ dragPlaneNormal: Vector3.Up() }); //平面内移动
this.mesh.addBehavior(this.pointerDragBehavior);
this.pointerDragBehavior.onDragEndObservable.add(() => {
instance.changeAim();
});
this.showUI(false);
// this.uiRoot = Button.CreateSimpleButton("ui_" + name, this.index.toString());
// UIManager.Instance.uiRoot.addControl(this.uiRoot);
// this.uiRoot.linkWithMesh(this.mesh);
// BabylonUIStyleTool.setStyle_size(this.uiRoot, "20px", "20px");
// this.uiRoot.background = BabylonUIStyleTool.c_color_blue;
// this.uiRoot.color = BabylonUIStyleTool.c_color_white;
// this.uiRoot.onPointerClickObservable.add(() => {
// instance.changeAim();
// });
// this.showUI(false);
}
}
@ -318,7 +334,7 @@ export class PolygonMeshPoint {
//改变选中的目标
changeAim() {
let instance = this;
GizmoTool.changeGizmoAim(instance.mesh);
//GizmoTool.changeGizmoAim(instance.mesh);
PosPointTool.attachMesh(instance.mesh as Mesh, instance.pos,
() => {
instance.addPoint();
@ -337,6 +353,10 @@ export class PolygonMeshPoint {
this.mesh.dispose();
this.uiRoot.dispose();
}
if (this.pointMat != null) {
this.pointMat.dispose();
this.pointMat = null;
}
}

34
src/app/babylon/model/info/model/model-info-facility.ts

@ -8,7 +8,7 @@ import { FacilityWindow } from "src/app/babylon/view/facility-window/facility-wi
import { FacilityInfoInSceneWindow } from "src/app/babylon/view/facilityinfoinscene-window/facilityinfoinscene-window";
import { PropertyBaseWindow } from "src/app/babylon/view/property-window/property-base-window";
import { ModelData } from "../../data/model-data/model-data";
import { FacilityShowType, FacilityType, ModelData_facility } from "../../data/model-data/model-data-facility";
import { FacilityPosType, FacilityShowType, FacilityType, ModelData_facility } from "../../data/model-data/model-data-facility";
import { BuildingInfo } from "../building/building-info";
import { AreaInfo } from "./facilityinfo-tool/facility-area";
@ -16,6 +16,9 @@ import { ModelInfo } from "./model-info";
//设施数据
export class ModelInfo_facility extends ModelInfo {
static readonly c_hightLightColor = Color3.Yellow();
belongToBuilding: BuildingInfo;//属于哪个建筑
pickDown: boolean;//按下
facilityShowType: FacilityShowType;//设备展示状态
@ -39,15 +42,15 @@ export class ModelInfo_facility extends ModelInfo {
}
onCreateFollowUI() {
let modelData = this.modelData as ModelData_facility;
if (!ConfigManager.getFacilityNeedIcon(modelData.facilityType)) {
let facilityData = this.modelData as ModelData_facility;
if (!ConfigManager.getFacilityNeedIcon(facilityData.facilityType)) {
return;
}
super.onCreateFollowUI();
let instance = this;
let posType = ConfigManager.getPosType(modelData.facilityType);
let iconPath = ConfigManager.getFacilityIconUrl(modelData.facilityType, posType);
let posType = ConfigManager.getPosType(facilityData.facilityType);
let iconPath = ConfigManager.getFacilityIconUrl(facilityData.facilityType, posType);
BabylonUIStyleTool.setStyle_size(this.uiFollowRoot, ConfigManager.c_size_facilityIconSize + "px", ConfigManager.c_size_facilityIconSize + "px");
this.uiFollowRoot.thickness = 0;
@ -93,7 +96,13 @@ export class ModelInfo_facility extends ModelInfo {
});
this.uiFollowRoot.zIndex = BabylonUIStyleTool.c_zIndex_facilityIcon;
this.showFollowUI(false);
if (facilityData.posType == FacilityPosType.In) {
this.showFollowUI(false); //内置设备,默认隐藏
}
}
@ -141,7 +150,10 @@ export class ModelInfo_facility extends ModelInfo {
* @param enable
*/
setSelectEnable(enable: boolean) {
this.ui_select.isVisible = enable;
if (this.ui_select != null) {
this.ui_select.isVisible = enable;
}
}
/**
@ -159,14 +171,14 @@ export class ModelInfo_facility extends ModelInfo {
}
/**
* ()
* @param play false表示停止
*/
* ()
* @param play false表示停止
*/
playShowAnim(play: boolean) {
this.showFollowUI(play);
if (this.modelBox != null) {
if (play) {
SceneManager.Instance.addToHighLight(this.modelBox as Mesh, Color3.Yellow());
SceneManager.Instance.addToHighLight(this.modelBox as Mesh, ModelInfo_facility.c_hightLightColor);
}
else {
SceneManager.Instance.removeFromHighLight(this.modelBox as Mesh);

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

@ -25,7 +25,7 @@ export class ModelInfo {
/**
*
*/
models: AbstractMesh[];
_models: AbstractMesh[];
/**
* 使modelBox 访
*/
@ -121,6 +121,20 @@ export class ModelInfo {
}
}
/**
*
*/
get models(): AbstractMesh[] {
if (this._models == null) {
this._models = this.modelBox.getChildMeshes();
}
return this._models;
}
set models(value: AbstractMesh[]) {
this._models = value;
}
//创建跟随UI
onCreateFollowUI() {

7
src/app/babylon/tool/pos-point-tool.ts

@ -19,14 +19,19 @@ export class PosPointTool {
initUI() {
let instance = this;
this.uiRoot = new Rectangle("PosPointTooUI");
this.uiRoot.color = BabylonUIStyleTool.c_color_3d_blueLight;
this.uiRoot.shadowBlur = 5;
UIManager.Instance.uiRoot.addControl(this.uiRoot);
BabylonUIStyleTool.setStyle_size(this.uiRoot, "40px", "20px");
let stack = new StackPanel("stack");
this.uiRoot.addControl(stack);
stack.width = 1;
stack.height = 1;
stack.isVertical = false;
let btn_add = Button.CreateSimpleButton("add", "+");
stack.addControl(btn_add);
btn_add.background = BabylonUIStyleTool.c_color_blue;
@ -52,7 +57,7 @@ export class PosPointTool {
showUI(show: boolean) {
this.uiRoot.isVisible = show;
this.uiRoot.linkWithMesh(this.mesh);
this.uiRoot.linkOffsetY = "-50px";
this.uiRoot.linkOffsetY = "-30px";
}
//#endregion

147
src/app/babylon/view/facility-window/facility-window.ts

@ -1,8 +1,10 @@
import {
AbstractMesh,
Color3,
EventState,
Mesh,
MeshBuilder,
PickingInfo,
PointerEventTypes,
PointerInfo,
Vector3,
@ -23,6 +25,7 @@ import { BuildingStatus } from '../../controller/status/building-status';
import { IndoorStatus } from '../../controller/status/indoor-status';
import { StatusManager } from '../../controller/status/status-manager';
import { UIManager } from '../../controller/ui-manager';
import { JYZInfoMoudleType } from '../../model/data/institution/jyz-show-data';
import { FacilityPosType, ModelData_facility, FacilityShowType, FacilityType } from '../../model/data/model-data/model-data-facility';
import { TransformData } from '../../model/data/transform-data';
import { BuildingInfo } from '../../model/info/building/building-info';
@ -33,6 +36,7 @@ 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 { FacilityInfoUIItem } from '../facilityinfoinscene-window/facilityinfo-ui-item';
import { CopyFacilityInfo, FacilityInfoInSceneWindow } from '../facilityinfoinscene-window/facilityinfoinscene-window';
import { ToolbarWindow } from '../toolbar-window/toobar-window';
import { UIBase } from '../window-base/ui-base';
@ -49,6 +53,8 @@ export class FacilityWindow extends UIBase {
static s_currentFacilityItem: FacilityUIItem;
static instance: FacilityWindow;
createIconRoot: Rectangle;//创建状态的跟随icon
createIcon: Image;
static readonly c_createIcon_width = 40;
@ -237,7 +243,12 @@ export class FacilityWindow extends UIBase {
case PointerEventTypes.POINTERUP:
if (eventData.event.button == 0) { //左键正常
if (eventData.pickInfo.hit && !SceneManager.s_isPointerDrag) {
instance.selectJYJFrom3D(eventData.pickInfo);
if (FacilityWindow.s_currentFacilityItem != null) {
instance.createNewFacilityByPos(eventData.pickInfo.pickedPoint);
return;
@ -258,6 +269,7 @@ export class FacilityWindow extends UIBase {
}
}
//寻找设备预设
getFacilityPrefab(resName: string): Mesh {
let result = null;
@ -309,24 +321,8 @@ export class FacilityWindow extends UIBase {
}
/**
* mesh创建设备
* @param mesh
* @param type
*/
createNewFacilityByMesh(mesh: AbstractMesh, type: FacilityType) {
let facilityData = this.createFacilityDataFromMesh(mesh, type);
//let facilityInfo = this.createFacilityInfoFromMesh(facilityData, mesh, buildingInfo);
if (!this.isRepeatFacilityFromMesh(type, mesh.id)) //不重复
{
console.log("获取到设备" + type, mesh);
this.createNewFacility(facilityData, mesh);
}
}
/**
@ -730,4 +726,123 @@ export class FacilityWindow extends UIBase {
//#endregion
//#region 加油机特殊表现
/**
*
*/
static readonly c_selectJYJColor = Color3.Green();
/**
*
*/
currentSelectJYJInfo: ModelInfo_facility;
/**
* mesh创建设备
* @param mesh
* @param type
*/
createNewFacilityByMesh(mesh: AbstractMesh, type: FacilityType) {
let facilityData = this.createFacilityDataFromMesh(mesh, type);
//let facilityInfo = this.createFacilityInfoFromMesh(facilityData, mesh, buildingInfo);
if (!this.isRepeatFacilityFromMesh(type, mesh.id)) //不重复
{
console.log("获取到设备" + type, mesh);
this.createNewFacility(facilityData, mesh);
}
}
/**
*
* @param pickInfo null
*/
selectJYJFrom3D(pickInfo: PickingInfo) {
if (this.currentSelectJYJInfo != null) {
this.playJYJSelectEffect(false, this.currentSelectJYJInfo);
this.currentSelectJYJInfo = null;
}
if (pickInfo == null) {
return;
}
let allJYJInfo: ModelInfo_facility[] = [];
try {
let facilityInfosByType = BuildingWindow.instance.currentBuidngItem.buildingInfo.ModelInfo.facilityInfos;
for (let i = 0; i < facilityInfosByType.length; i++) {
if (facilityInfosByType[i].type == FacilityType.JY_JYJ || facilityInfosByType[i].type == FacilityType.JY_YG) {
allJYJInfo = allJYJInfo.concat(facilityInfosByType[i].facilityInfo);
}
}
} catch (error) {
console.log("没找到加油机", error);
}
let result: ModelInfo_facility = null;
for (let i = 0; i < allJYJInfo.length; i++) {
let childMesh = allJYJInfo[i].models;
childMesh.push(allJYJInfo[i].modelBox);
for (let j = 0; j < childMesh.length; j++) {
if (pickInfo.pickedMesh == childMesh[j]) {
result = allJYJInfo[i];
console.log("通过点击,找到加油机了");
break;
}
}
}
if (result != null) {
this.currentSelectJYJInfo = result;
this.playJYJSelectEffect(true, this.currentSelectJYJInfo);
let facilityItem: FacilityInfoUIItem = FacilityInfoInSceneWindow.instance.getFacilityItem(result);
console.log("场景中选中设备", facilityItem); //通知前端
FacilityInfoInSceneWindow.instance.selectFacilityItemToThree([facilityItem], true);
}
}
/**
*
* @param play false,
*/
playJYJSelectEffect(play: boolean, facilityInfo: ModelInfo_facility) {
if (play) {
//正在展示加油机或油罐
if (BuildingWindow.instance.currentJYZInfoMoudleType == JYZInfoMoudleType.JYJ
|| BuildingWindow.instance.currentJYZInfoMoudleType == JYZInfoMoudleType.YG) {
SceneManager.Instance.removeFromHighLight(facilityInfo.modelBox as Mesh);
}
SceneManager.Instance.addToHighLight(facilityInfo.modelBox as Mesh, FacilityWindow.c_selectJYJColor);
}
else {
SceneManager.Instance.removeFromHighLight(facilityInfo.modelBox as Mesh);
//正在展示加油机或油罐
if (BuildingWindow.instance.currentJYZInfoMoudleType == JYZInfoMoudleType.JYJ
|| BuildingWindow.instance.currentJYZInfoMoudleType == JYZInfoMoudleType.YG) {
SceneManager.Instance.addToHighLight(facilityInfo.modelBox as Mesh, ModelInfo_facility.c_hightLightColor);
}
}
}
//#endregion
}

Loading…
Cancel
Save