|
|
|
@ -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
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|