|
|
|
|
|
|
|
import { Vector2 } from "@babylonjs/core";
|
|
|
|
import { SceneManager } from "../../controller/scene-manager";
|
|
|
|
import { PropertyData_Base } from "../../model/data/institution/facility/property-data/property-data-base";
|
|
|
|
import { FacilityType, ModelData_facility } from "../../model/data/model-data/model-data-facility";
|
|
|
|
import { ModelInfo_facility } from "../../model/info/model/model-info-facility";
|
|
|
|
import { BabylonTool } from "../../tool/babylon-tool";
|
|
|
|
import { GizmoTool } from "../../tool/gizmo-tool";
|
|
|
|
import { TsTool } from "../../tool/ts-tool";
|
|
|
|
import { FacilityInfoInSceneWindow } from "./facilityinfoinscene-window";
|
|
|
|
|
|
|
|
//单个场景中的设备 UI item
|
|
|
|
export class FacilityInfoUIItem {
|
|
|
|
modelInfo: ModelInfo_facility;
|
|
|
|
facilityInfoInSceneWindow: FacilityInfoInSceneWindow;
|
|
|
|
isSelect: boolean = false;
|
|
|
|
isChecked: boolean = false; //是否 选中
|
|
|
|
// facilityBtn: Button;
|
|
|
|
|
|
|
|
constructor(modelInfo: ModelInfo_facility, facilityInfoInSceneWindow: FacilityInfoInSceneWindow) {
|
|
|
|
this.modelInfo = modelInfo;
|
|
|
|
this.facilityInfoInSceneWindow = facilityInfoInSceneWindow;
|
|
|
|
this.initUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#region 前端对接
|
|
|
|
|
|
|
|
l_name = null;
|
|
|
|
/**
|
|
|
|
* 获取设备名
|
|
|
|
*/
|
|
|
|
getName(): string {
|
|
|
|
return this.modelInfo.modelData.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 设备类型
|
|
|
|
*/
|
|
|
|
getType(): FacilityType {
|
|
|
|
return (this.modelInfo.modelData as ModelData_facility).facilityType;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 设备ID
|
|
|
|
*/
|
|
|
|
getID(): string {
|
|
|
|
return this.modelInfo.key;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 获取 设备属性
|
|
|
|
*/
|
|
|
|
getPropertyData() {
|
|
|
|
let facilityData = (this.modelInfo.modelData as ModelData_facility).propertyData as any;
|
|
|
|
|
|
|
|
return facilityData
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 粘贴属性
|
|
|
|
* @param propertyData
|
|
|
|
*/
|
|
|
|
pasteProperty(propertyData: PropertyData_Base) {
|
|
|
|
let facilityData = this.modelInfo.modelData as ModelData_facility;
|
|
|
|
let key = facilityData.propertyData.key;
|
|
|
|
facilityData.propertyData = propertyData.clone(key);
|
|
|
|
|
|
|
|
console.log("粘贴属性");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 询问删除
|
|
|
|
* @param ask true表示询问,false表示不询问
|
|
|
|
*/
|
|
|
|
askDelete(ask: boolean = true) {
|
|
|
|
this.modelInfo.askDelete(this.modelInfo, ask);
|
|
|
|
}
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
initUI() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dispose() {
|
|
|
|
|
|
|
|
TsTool.arrayRemove(this.facilityInfoInSceneWindow.facilityInfoUIItemes, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onSelect(select: boolean) {
|
|
|
|
|
|
|
|
this.isSelect = select;
|
|
|
|
this.modelInfo.setSelectEnable(select);
|
|
|
|
if (select) {
|
|
|
|
// console.log("选中设备==" + this.modelInfo.key);
|
|
|
|
GizmoTool.onPickMeshInfoObservable.notifyObservers(this.modelInfo);
|
|
|
|
this.facilityInfoInSceneWindow.selectFacilityItemToThree([this], true);
|
|
|
|
this.modelInfo.setIconEnable(select);
|
|
|
|
this.facilityInfoInSceneWindow.playJYJSelectEffect(select, this.modelInfo)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.facilityInfoInSceneWindow.selectFacilityItemToThree([this], false);
|
|
|
|
// if (!this.facilityInfoInSceneWindow.getFacilityUIShowType(this.getType())) {
|
|
|
|
// this.modelInfo.setIconEnable(select);
|
|
|
|
|
|
|
|
// }
|
|
|
|
this.facilityInfoInSceneWindow.playJYJSelectEffect(select, this.modelInfo)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 相机聚焦
|
|
|
|
*/
|
|
|
|
lookAt() {
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.canLookAt()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let size = null;
|
|
|
|
|
|
|
|
if (this.modelInfo.areaInfo != null) {
|
|
|
|
//计算多边形size
|
|
|
|
}
|
|
|
|
BabylonTool.changeCameraTarget(SceneManager.Instance.defaultCamera, this.modelInfo.modelBox, true, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 是否可以聚焦
|
|
|
|
*/
|
|
|
|
canLookAt(): boolean {
|
|
|
|
let result = this.modelInfo != null && this.modelInfo.modelBox != null;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取头部UI的位置(像素)
|
|
|
|
*/
|
|
|
|
getHeadUIPos(): Vector2 {
|
|
|
|
if (this.modelInfo != null) {
|
|
|
|
return this.modelInfo.getHeadUIPos();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|