20 changed files with 150 additions and 824 deletions
@ -1,31 +0,0 @@
|
||||
|
||||
import { FacilityType } from "../../../../model-data/model-data-facility"; |
||||
import { PropertyData_Base } from "../property-data-base"; |
||||
|
||||
/** |
||||
* 安全出口 |
||||
*/ |
||||
export class PropertyData_AQCK extends PropertyData_Base { |
||||
|
||||
img: string = ""; |
||||
is360: boolean;//全景图片
|
||||
name: string = "安全出口"; |
||||
width: string = ""; |
||||
constructor(key: string, img: string, is360: boolean, name: string, width: string) { |
||||
super(key, FacilityType.AQCK); |
||||
this.img = img; |
||||
this.is360 = is360; |
||||
this.name = name; |
||||
this.width = width; |
||||
} |
||||
|
||||
clone(key: string) { |
||||
let result = new PropertyData_AQCK(key, this.img, this.is360, "安全出口", "1"); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -1,26 +0,0 @@
|
||||
|
||||
import { FacilityType } from "../../../../model-data/model-data-facility"; |
||||
import { PropertyData_Base } from "../property-data-base"; |
||||
|
||||
/** |
||||
* 高度 |
||||
*/ |
||||
export class PropertyData_GD extends PropertyData_Base { |
||||
|
||||
|
||||
info: string = ""; |
||||
constructor(key: string, info: string) { |
||||
super(key, FacilityType.GD); |
||||
this.info = info; |
||||
} |
||||
|
||||
clone(key: string) { |
||||
let result = new PropertyData_GD(key, this.info); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -1,267 +0,0 @@
|
||||
//#region 高度
|
||||
|
||||
import { AbstractMesh, MeshBuilder, Color3, Vector3, Mesh, Observer, Scene, Vector2 } from "@babylonjs/core"; |
||||
import { Control, Button } from "@babylonjs/gui"; |
||||
import { GridMaterial } from "@babylonjs/materials"; |
||||
import { ModeManager, ModeType } from "src/app/babylon/controller/mode-manager"; |
||||
import { SceneManager } from "src/app/babylon/controller/scene-manager"; |
||||
import { UIManager } from "src/app/babylon/controller/ui-manager"; |
||||
import { BabylonUIStyleTool, UI_LineInfo } from "src/app/babylon/tool/babylon-ui-style-tool"; |
||||
import { GizmoTool, TransformUIType } from "src/app/babylon/tool/gizmo-tool"; |
||||
|
||||
import { PropertyData_GD } from "../../../data/institution/facility/property-data/outdoor/property-data-gd"; |
||||
import { ModelData_facility } from "../../../data/model-data/model-data-facility"; |
||||
|
||||
import { ModelInfo_facility } from "../model-info-facility"; |
||||
|
||||
/** |
||||
* 高度信息 |
||||
*/ |
||||
export class GdInfo { |
||||
|
||||
pointData_start: Vector3;//起位
|
||||
pointData_end: Vector3;//终点
|
||||
|
||||
material: GridMaterial; |
||||
belongToFacility: ModelInfo_facility; |
||||
|
||||
myPath: Vector3[] = []; |
||||
myTube: Mesh; |
||||
gdMeshPoints: GdMeshPoint[] = []; |
||||
|
||||
isShow: boolean; |
||||
onGizmoAimMeshObserver: Observer<AbstractMesh>; |
||||
updateObserver: Observer<Scene>; |
||||
|
||||
constructor(startPoint: Vector3, endPoint: Vector3, belongToFacility: ModelInfo_facility) { |
||||
let instance = this; |
||||
this.belongToFacility = belongToFacility; |
||||
this.pointData_start = startPoint; |
||||
|
||||
let point_start = new GdMeshPoint(this, this.pointData_start, false); |
||||
this.gdMeshPoints.push(point_start); |
||||
|
||||
this.pointData_end = endPoint; |
||||
let point_end = new GdMeshPoint(this, this.pointData_end, true); |
||||
this.gdMeshPoints.push(point_end); |
||||
|
||||
this.myPath.push(point_start.pos); |
||||
this.myPath.push(point_end.pos); |
||||
this.updateObserver = SceneManager.Instance.scene.onBeforeRenderObservable.add(() => { |
||||
instance.update(); |
||||
}); |
||||
this.onGizmoAimMeshObserver = GizmoTool.onGizmoAimMeshObservable.add((mesh) => { |
||||
instance.onChangeGizmo(mesh); |
||||
}) |
||||
|
||||
this.createMesh(); |
||||
|
||||
|
||||
} |
||||
|
||||
createMesh() { |
||||
this.myTube = MeshBuilder.CreateTube("tube", { path: this.myPath, radius: 2, sideOrientation: Mesh.DOUBLESIDE, updatable: true }, SceneManager.Instance.scene); |
||||
this.myTube.parent = this.belongToFacility.modelBox; |
||||
this.myTube.position = Vector3.Zero(); |
||||
this.material = new GridMaterial("mat_myTube", SceneManager.Instance.scene); |
||||
this.material.mainColor = Color3.FromHexString(BabylonUIStyleTool.c_color_3d_blue); // new Color3(0, 0.5, 1)
|
||||
this.material.lineColor = new Color3(0, 0, 0); |
||||
this.myTube.material = this.material; |
||||
} |
||||
|
||||
update() { |
||||
this.gdMeshPoints[1].mesh.position.x = 0; |
||||
this.gdMeshPoints[1].mesh.position.z = 0; |
||||
this.myPath[1] = this.gdMeshPoints[1].mesh.position; |
||||
this.myTube = MeshBuilder.CreateTube("tube", { path: this.myPath, radius: 2, sideOrientation: Mesh.DOUBLESIDE, updatable: true, instance: this.myTube }, SceneManager.Instance.scene); |
||||
let facilityData = this.belongToFacility.modelData as ModelData_facility; |
||||
let property = facilityData.propertyData as PropertyData_GD; |
||||
this.gdMeshPoints[1].updateInfo(property.info); |
||||
} |
||||
|
||||
|
||||
|
||||
//释放
|
||||
dispose() { |
||||
SceneManager.Instance.scene.onBeforeRenderObservable.remove(this.updateObserver); |
||||
GizmoTool.onGizmoAimMeshObservable.remove(this.onGizmoAimMeshObserver); |
||||
this.updateObserver = null; |
||||
|
||||
for (let i = 0; i < this.gdMeshPoints.length; i++) { |
||||
this.gdMeshPoints[i].dispose(); |
||||
} |
||||
|
||||
this.material.dispose(); |
||||
this.myTube.dispose(); |
||||
} |
||||
|
||||
onChangeGizmo(mesh: AbstractMesh) { |
||||
// if (mesh != null) {
|
||||
// this.isShow = mesh == this.belongToFacility.modelBox || this.isPosPointMesh(mesh);
|
||||
// this.setEnable(this.isShow);
|
||||
// }
|
||||
// else {
|
||||
// this.setEnable(false);
|
||||
// }
|
||||
|
||||
} |
||||
|
||||
//是否是位点mesh
|
||||
isPosPointMesh(mesh: AbstractMesh): boolean { |
||||
|
||||
if (mesh == null) { |
||||
return false; |
||||
} |
||||
|
||||
for (let i = 0; i < this.gdMeshPoints.length; i++) { |
||||
if (mesh == this.gdMeshPoints[i].mesh) { |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
|
||||
|
||||
setEnable(show: boolean) { |
||||
for (let i = 0; i < this.gdMeshPoints.length; i++) { |
||||
this.gdMeshPoints[i].setEnable(show); |
||||
} |
||||
} |
||||
|
||||
|
||||
setUIEnable(show: boolean) { |
||||
for (let i = 0; i < this.gdMeshPoints.length; i++) { |
||||
this.gdMeshPoints[i].showEditUI(show); |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
/** |
||||
* 高度mesh |
||||
*/ |
||||
export class GdMeshPoint { |
||||
|
||||
pos: Vector3; |
||||
canSet: boolean; |
||||
gdInfo: GdInfo; |
||||
uiRoot: Button; |
||||
|
||||
lineInfo: UI_LineInfo; |
||||
|
||||
mesh: Mesh; |
||||
constructor(gdInfo: GdInfo, pos: Vector3, canSet: boolean) { |
||||
this.pos = pos; |
||||
this.canSet = canSet; |
||||
if (canSet) { |
||||
this.gdInfo = gdInfo; |
||||
this.mesh = MeshBuilder.CreateBox(gdInfo.belongToFacility.modelBox.name + "_point", { size: 1 }); |
||||
this.mesh.setParent(gdInfo.belongToFacility.modelBox); |
||||
this.mesh.position = pos; |
||||
this.mesh.isVisible = false; |
||||
|
||||
|
||||
this.initEditUI(); |
||||
|
||||
this.lineInfo = BabylonUIStyleTool.createLineInfo(gdInfo.belongToFacility.modelBox.name, this.mesh); |
||||
|
||||
this.showEditUI(false); |
||||
|
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
//初始化 编辑UI
|
||||
initEditUI() { |
||||
if (ModeManager.currentMode == ModeType.Edit) { |
||||
let instance = this; |
||||
this.uiRoot = Button.CreateImageButton("ui_editPoint_" + this.gdInfo.belongToFacility.modelBox.name, "", "assets/images/ui/edit.png"); |
||||
UIManager.Instance.uiRoot.addControl(this.uiRoot); |
||||
this.uiRoot.linkWithMesh(this.mesh); |
||||
this.uiRoot.linkOffsetYInPixels = 20; |
||||
this.uiRoot.linkOffsetXInPixels = -40; |
||||
BabylonUIStyleTool.setStyle_size(this.uiRoot, "20px", "20px"); |
||||
this.uiRoot.image.width = 0.8; |
||||
this.uiRoot.image.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER; |
||||
this.uiRoot.image.verticalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER; |
||||
// this.uiRoot.thickness = 0;
|
||||
this.uiRoot.background = BabylonUIStyleTool.c_color_3d_blueBg; |
||||
this.uiRoot.color = BabylonUIStyleTool.c_color_3d_blue; |
||||
// this.uiRoot.alpha = 0.7;
|
||||
this.uiRoot.onPointerClickObservable.add(() => { |
||||
instance.changeAim(); |
||||
}); |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
//显示或隐藏 编辑UI
|
||||
showEditUI(show: boolean) { |
||||
if (this.uiRoot != null) { |
||||
this.uiRoot.isVisible = show && this.canSet; |
||||
} |
||||
|
||||
} |
||||
|
||||
//显示、隐藏标识UI
|
||||
setEnable(show: boolean) { |
||||
if (this.lineInfo != null) { |
||||
this.lineInfo.setEnable(show); |
||||
} |
||||
this.showEditUI(show && ModeManager.currentMode == ModeType.Edit); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
//改变选中的目标
|
||||
changeAim() { |
||||
let instance = this; |
||||
GizmoTool.onTransformUITypeChange(TransformUIType.Position);//强行变为position
|
||||
GizmoTool.changeGizmoAim(instance.mesh, false, true, false); |
||||
// PosPointTool.attachMesh(instance.mesh as Mesh, instance.pos,
|
||||
// () => {
|
||||
// instance.addPoint();
|
||||
// },
|
||||
// () => {
|
||||
// instance.reducePoint();
|
||||
// }
|
||||
// );
|
||||
//如果需要增加节点,在此拓展
|
||||
} |
||||
|
||||
dispose() { |
||||
|
||||
|
||||
if (this.canSet) { |
||||
if (this.uiRoot != null) { |
||||
this.uiRoot.dispose(); |
||||
} |
||||
|
||||
GizmoTool.leaveTheGizmoAimMesh(this.mesh); |
||||
this.mesh.dispose(); |
||||
this.lineInfo.dispose(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 更新显示内容 |
||||
* @param text
|
||||
*/ |
||||
updateInfo(text: string) { |
||||
if (this.lineInfo.info != null) { |
||||
this.lineInfo.info.text = "高度:" + text; |
||||
this.lineInfo.info.resizeToFit = true; |
||||
this.lineInfo.infoBg.height = (this.lineInfo.info.heightInPixels + 5) + "px"; |
||||
} |
||||
} |
||||
} |
||||
|
||||
//#endregion
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Loading…
Reference in new issue