邵佳豪 3 years ago
parent
commit
8dc4b45782
  1. 31
      src/app/babylon/controller/scene-manager.ts
  2. 2
      src/app/babylon/model/data/mark/mark-property.ts
  3. 21
      src/app/babylon/tool/gizmo-tool.ts
  4. 29
      src/app/babylon/view/building-window/building-window.ts
  5. 24
      src/app/babylon/view/mark-window/mark-window.ts
  6. 2
      src/app/pages/left-domain/left-domain.component.html
  7. 10
      src/app/pages/left-domain/left-domain.component.ts
  8. 29
      src/app/pages/plan/plan.component.html
  9. 90
      src/app/pages/plan/plan.component.ts
  10. 10
      src/styles.scss

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

@ -15,8 +15,6 @@ import {
Mesh,
MeshBuilder,
Observable,
Observer,
PBRMaterial,
PickingInfo,
PointerEventTypes,
Quaternion,
@ -108,11 +106,37 @@ export class SceneManager {
SceneManager.instance.scene = scene;
SceneManager.instance.canvas = canvas;
scene.onBeforeRenderObservable.add(() => {
if (SceneManager.instance != null) {
SceneManager.instance.onUpdate();
}
});
}
return SceneManager.instance;
}
//#endregion
onUpdate() {
if (SceneManager.s_openSkyBox && this.skyBox != null) {
let skyMat = this.skyBox.material;
let skyTexture = ((skyMat as StandardMaterial).reflectionTexture as CubeTexture);
if (skyTexture != null) {
let addSpeed = SceneManager.instance.scene.deltaTime * 0.001 * 0.003;//天空盒旋转速度
if (addSpeed > 0) {
skyTexture.rotationY += addSpeed;
}
while (skyTexture.rotationY > Math.PI * 2) {
skyTexture.rotationY -= Math.PI * 2;
}
}
}
}
dispose() {
SceneManager.instance = null;
}
@ -334,11 +358,14 @@ export class SceneManager {
skyboxMaterial.backFaceCulling = false;
skyboxMaterial.reflectionTexture = new CubeTexture("assets/skybox/default/default", this.scene);
skyboxMaterial.reflectionTexture.coordinatesMode = Texture.SKYBOX_MODE;
(skyboxMaterial.reflectionTexture as CubeTexture).rotationY = 0;
skyboxMaterial.diffuseColor = new Color3(0, 0, 0);
skyboxMaterial.specularColor = new Color3(0, 0, 0);
skyboxMaterial.disableLighting = true;
this.skyBox.material = skyboxMaterial;
this.skyBox.renderingGroupId = -1;
}
else {
this.skyBox.setEnabled(true);

2
src/app/babylon/model/data/mark/mark-property.ts

@ -30,7 +30,7 @@ export class MarkProperty {
*/
description: string;
constructor(taskType?: MarkTask, institution: string = "辖区中队", index: number = 1, task: string = "待命", description?: string) {
constructor(taskType?: MarkTask, institution: string = "未命名", index: number = 1, task: string = "待命", description?: string) {
this.taskType = taskType
this.institution = institution
this.index = index

21
src/app/babylon/tool/gizmo-tool.ts

@ -1,6 +1,6 @@
import { AbstractMesh, ArcRotateCamera, BoundingBoxGizmo, Color3, EventState, GizmoManager, Mesh, Observable, PickingInfo, PointerEventTypes, PointerInfo, Quaternion, Scene, UtilityLayerRenderer, Vector3 } from "@babylonjs/core";
import { AdvancedDynamicTexture, Button, Container, InputText, Rectangle, StackPanel, TextBlock } from "@babylonjs/gui";
import { ModeManager, ModeType } from "../controller/mode-manager";
import { ModeManager } from "../controller/mode-manager";
import { SceneManager } from "../controller/scene-manager";
import { Game } from "../game";
import { ModelInfo } from "../model/info/model/model-info";
@ -33,6 +33,8 @@ export class GizmoTool {
static s_btn_rotation: Button;
static s_btn_scaling: Button;
static s_isOpen: boolean = true;//是否开启gizmo
static init(scene: Scene, uiRoot: AdvancedDynamicTexture, camera: ArcRotateCamera) {
GizmoTool.s_camera = camera;
GizmoTool.s_boundingBoxGizmo = new BoundingBoxGizmo();
@ -147,6 +149,13 @@ export class GizmoTool {
}
}
/**
* gizmo开关
* @param open
*/
static changeGizmoOpen(open: boolean) {
GizmoTool.s_isOpen = open;
}
/**
*
@ -187,7 +196,7 @@ export class GizmoTool {
GizmoTool.changeGizmoAim(mesh);
if (ModeManager.currentMode == ModeType.Edit) {
if (GizmoTool.s_isOpen) {
GizmoTool.s_boundingBoxGizmo.attachedMesh = mesh;
}
@ -409,21 +418,21 @@ export class GizmoTool {
// }
transformUIInfo.root.isVisible = ModeManager.isDebug;//先隐藏,因为效果图中没有
let isEditMode = ModeManager.currentMode == ModeType.Edit;
let isOpen = GizmoTool.s_isOpen;
let isPosition = uiType == TransformUIType.Position && isEditMode;
let isPosition = uiType == TransformUIType.Position && isOpen;
GizmoTool.s_btn_poisition.background = isPosition
? UIBase.color_yellow
: UIBase.color_null;
GizmoTool.s_gizmoManager.positionGizmoEnabled = isPosition;
let isRotation = uiType == TransformUIType.Rotation && isEditMode;
let isRotation = uiType == TransformUIType.Rotation && isOpen;
GizmoTool.s_btn_rotation.background = isRotation
? UIBase.color_yellow
: UIBase.color_null;
GizmoTool.s_gizmoManager.rotationGizmoEnabled = isRotation;
let isScaling = uiType == TransformUIType.Scale && isEditMode;
let isScaling = uiType == TransformUIType.Scale && isOpen;
GizmoTool.s_btn_scaling.background = isScaling
? UIBase.color_yellow
: UIBase.color_null;

29
src/app/babylon/view/building-window/building-window.ts

@ -1,5 +1,5 @@
import { AbstractMesh, Material, Mesh, PBRMaterial, Texture } from "@babylonjs/core";
import { AbstractMesh, GizmoManager, Material, Mesh, PBRMaterial, Texture } from "@babylonjs/core";
import { PlanComponent } from "src/app/pages/plan/plan.component";
import { ConfigManager } from "../../controller/config-manager";
import { DataManager } from "../../controller/data-manager";
@ -22,6 +22,7 @@ import { BuildingInfo_Normal } from "../../model/info/building/building-info-nor
import { ModelInfo_building } from "../../model/info/model/model-info-building";
import { FacilityInfoByType, 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/facilityinfoinscene-window";
import { MarkWindow } from "../mark-window/mark-window";
@ -299,6 +300,7 @@ export class BuildingWindow extends UIBase {
//#region 生命周期
onInit() {
super.onInit();
GizmoTool.changeGizmoOpen(ModeManager.s_isMakeMode); //内部模式才默认打开gizmo
this.buldingStatus = StatusManager.getStatus<BuildingStatus>(BuildingStatus);
@ -741,6 +743,10 @@ export class BuildingWindow extends UIBase {
return;
}
if (show) {
this.updateGizmoType(type);
}
if (type == JYZInfoMoudleType.YJCZ) {
if (show) {
console.log("进入应急处置");
@ -818,6 +824,27 @@ export class BuildingWindow extends UIBase {
}
/**
* gizmo状态
* @param type
*/
updateGizmoType(type: JYZInfoMoudleType) {
let open = false;
if (ModeManager.currentMode == ModeType.Edit) {
switch (type) {
case JYZInfoMoudleType.JBXX:
case JYZInfoMoudleType.YJCZ: open = true; break;
}
}
if (ModeManager.s_isMakeMode) {
open = true;
}
GizmoTool.changeGizmoOpen(open);
}
/**
*
* @param moudleType

24
src/app/babylon/view/mark-window/mark-window.ts

@ -1,4 +1,3 @@
import { AbstractMesh, Vector3 } from "@babylonjs/core";
import { PointerEventTypes, PointerInfo } from "@babylonjs/core/Events/pointerEvents";
import { EventState, Observer } from "@babylonjs/core/Misc/observable";
@ -11,13 +10,12 @@ import { Event_KeyboardInput } from "../../controller/event-manager/events/event
import { Event_MarkInfoChange, MarkInfoChangeType } from "../../controller/event-manager/events/event-mark-info-change";
import { InputController } from "../../controller/inputController";
import { SceneManager } from "../../controller/scene-manager";
import { ServeManager } from "../../controller/serve-manager";
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 { ArcRotateCameraData } from "../../model/data/camera-data";
import { MarkData, MarkTagPos, MarkType } from "../../model/data/mark/mark-data";
import { MarkData, MarkKindType, MarkTagPos, MarkType } from "../../model/data/mark/mark-data";
import { AllMarkPlanData, MarkNodeData, MarkPlanData, WeatherType, WindDirectionType, EnvironmentData, NatureData } from "../../model/data/mark/mark-plan-data";
import { ModelType } from "../../model/data/model-data/model-data";
import { FacilityType } from "../../model/data/model-data/model-data-facility";
@ -26,7 +24,6 @@ import { MarkNodeInfo } from "../../model/info/mark/mark-plan-info";
import { ModelInfo_mark } from "../../model/info/mark/model-info-mark";
import { ModelInfo_building } from "../../model/info/model/model-info-building";
import { ModelInfo_facility } from "../../model/info/model/model-info-facility";
import { BabylonTool } from "../../tool/babylon-tool";
import { LoadTool } from "../../tool/load-tool";
import { MeshPool, MeshPoolInfo } from "../../tool/mesh-pool";
import { ParticleSystemTool } from "../../tool/particle-system-tool";
@ -527,7 +524,7 @@ export class MarkWindow extends UIBase {
*/
openProperty(markInfo: ModelInfo_mark) {
if (markInfo != null) {
//ThreeDimensionalHomeComponent.instance.getSandTableNature(markInfo.markData);
PlanComponent.instance.getSandTableNature(markInfo.markData);
}
}
@ -842,18 +839,21 @@ export class MarkWindow extends UIBase {
break;
}
//创建标绘物
if (readyCreateMark) {
instance.createNewMark(pickPos, instance.currentMarkDataPrefab, true);
}
else if (pickMesh != null) {
if (pickMesh != null) {
//是标绘物
let l_markInfo = instance.getMarkInfoFromMesh(eventData.pickInfo.pickedMesh);
if (l_markInfo != null) {
if (instance.currentMarkDataPrefab != null && instance.currentMarkDataPrefab.markKindType != MarkKindType.Effect) //特效可以放在标绘物上
{
readyCreateMark = false;
}
if (eventData.type == PointerEventTypes.POINTERDOUBLETAP) {
//双击标绘物,打开任务界面
console.log("打开属性面板");
instance.openProperty(l_markInfo);
readyCreateMark = false; //双击,必然不创建标绘物
}
else if (eventData.type == PointerEventTypes.POINTERDOWN) {
if (eventData.event.button == 0)//左键
@ -887,6 +887,10 @@ export class MarkWindow extends UIBase {
}
}
//创建标绘物
if (readyCreateMark) {
instance.createNewMark(pickPos, instance.currentMarkDataPrefab, true);
}
}

2
src/app/pages/left-domain/left-domain.component.html

@ -149,7 +149,7 @@
</div>
<ul>
<li class="publicDisposal disposalContent" *ngFor="let items of item.nodes;let keys = index;">
<span nz-popconfirm nzPopconfirmTitle="切换节点后,没保存的信息将会丢失!" [nzCondition]="!editMode" (nzOnConfirm)="selectNode(item,items)" [ngClass]="{'selectNode': selectNodeId == items.id && selectPlanId == item.id}">{{items.name}}</span>
<span nz-popconfirm nzPopconfirmTitle="切换节点后,没保存的信息将会丢失!" [nzCondition]="!editMode" (nzOnConfirm)="selectNode(item,items,keys)" [ngClass]="{'selectNode': selectNodeId == items.id && selectPlanId == item.id}">{{items.name}}</span>
<label *ngIf="editMode"><i nz-icon nzType="save" nzTheme="outline" (click)="saveDisposal(item.id,items.id)"></i><i nz-icon nzType="delete" nzTheme="outline" (click)="deleteDisposal(item,items)"></i></label>
</li>
</ul>

10
src/app/pages/left-domain/left-domain.component.ts

@ -208,9 +208,9 @@ export class LeftDomainComponent implements OnInit {
}
//选中 数据节点
selectNode(item: MarkPlanData, e: MarkNodeData) {
selectNode(item: MarkPlanData, e: MarkNodeData, index: number) {
if (this.selectPlanId != item.id || this.selectNodeId != e.id) { //选中
this.updateFatherData() //更新/初始化父组件 数据
this.updateFatherData(index) //更新/初始化父组件 数据
this.selectPlanId = item.id
this.selectNodeId = e.id
MarkWindow.instance.selectMarkNode(item.id, e.id)
@ -219,7 +219,7 @@ export class LeftDomainComponent implements OnInit {
} else if (this.selectPlanId === item.id && this.selectNodeId === e.id) { //取消选中
PlanComponent.instance.beforeEmergencyPlan = new MarkPlanData(-99, "请选择节点")
PlanComponent.instance.beforePlanNode = new MarkNodeData(-99, "请选择节点")
this.updateFatherData() //更新/初始化父组件 数据
this.updateFatherData(index) //更新/初始化父组件 数据
this.selectPlanId = null
this.selectNodeId = null
MarkWindow.instance.selectMarkNode(null, null)
@ -227,8 +227,8 @@ export class LeftDomainComponent implements OnInit {
}
//更新/初始化父组件 数据
updateFatherData() {
PlanComponent.instance.nzCurrent = -1
updateFatherData(index) {
PlanComponent.instance.nzCurrent = index
PlanComponent.instance.isSuspend = true //暂停
PlanComponent.instance.timer? window.clearTimeout(PlanComponent.instance.timer) : null //清除定时器
PlanComponent.instance.updateTimer? window.clearTimeout(PlanComponent.instance.updateTimer) : null //清除定时器

29
src/app/pages/plan/plan.component.html

@ -204,6 +204,35 @@
</form>
</nz-modal>
<!-- 新增/编辑左侧建筑弹窗 -->
<!-- 应急预案设备任务弹窗 -->
<nz-modal nzClassName="taskDialog" [(nzVisible)]="contingencyPlanTask" nzTitle="设备任务栏" (nzOnCancel)="contingencyPlanTask = null;" (nzOnOk)="submitTaskForm(taskForm.value)" [nzOkDisabled]='companyName.invalid'>
<form nz-form #taskForm='ngForm'>
<nz-form-item>
<nz-form-label [nzSpan]="6">名称</nz-form-label>
<nz-form-control [nzSpan]="18" nzErrorTip="请输入必填项">
<input nz-input #companyName='ngModel' [(ngModel)]="taskDialog.institution" name="companyName" required/>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6">任务</nz-form-label>
<nz-form-control [nzSpan]="18" nzErrorTip="请输入必填项">
<input nz-input #taskName='ngModel' [(ngModel)]="taskDialog.task" name="taskName" autocomplete="off" nz-dropdown [nzDropdownMenu]="taskList"/>
<nz-dropdown-menu #taskList="nzDropdownMenu">
<ul nz-menu>
<li nz-menu-item *ngFor="let item of allTaskList" (click)="taskDialog.task = item.taskName;">{{item.taskName}}</li>
</ul>
</nz-dropdown-menu>
</nz-form-control>
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="6">备注</nz-form-label>
<nz-form-control [nzSpan]="18" nzErrorTip="请输入必填项">
<textarea nz-input #description='ngModel' [(ngModel)]="taskDialog.description" name="description"></textarea>
</nz-form-control>
</nz-form-item>
</form>
</nz-modal>
<!-- 应急预案设备任务弹窗 -->
</div>
</div>

90
src/app/pages/plan/plan.component.ts

@ -20,7 +20,7 @@ import { NzMessageService } from 'ng-zorro-antd/message';
import { LeftDomainComponent } from '../left-domain/left-domain.component';
import { JYZInfoMoudleType } from 'src/app/babylon/model/data/institution/jyz-show-data';
import { AllMarkData } from 'src/app/babylon/model/data/mark/all-mark-data';
import { MarkData } from 'src/app/babylon/model/data/mark/mark-data';
import { MarkData, MarkTask } from 'src/app/babylon/model/data/mark/mark-data';
import { MarkWindow } from 'src/app/babylon/view/mark-window/mark-window';
import { AllMarkPlanData, MarkNodeData, MarkPlanData } from 'src/app/babylon/model/data/mark/mark-plan-data';
@ -534,11 +534,41 @@ export class PlanComponent implements OnInit {
return `${percentage * 100}%`
}
contingencyPlanTask: MarkData = null; //应急预案选中 设备
taskDialog: taskDialog = new taskDialog("", "", ""); //设备任务 深拷贝数据
allTaskList: any[] = []; //所有任务 List
//选中应急预案 设备
selectSandTableMark(markData: MarkData, select: boolean) {
MarkWindow.instance.selectMarkData(markData, select)
}
//选中应急预案 设备任务窗口
getSandTableNature(markData: MarkData) {
if (markData.property.taskType != MarkTask.None) {
this.contingencyPlanTask = markData
this.taskDialog.institution = JSON.parse(JSON.stringify(markData.property.institution || ""))
this.taskDialog.description = JSON.parse(JSON.stringify(markData.property.description || ""))
this.taskDialog.task = JSON.parse(JSON.stringify(markData.property.task || ""))
if (markData.property.taskType === MarkTask.Person) {
this.allTaskList = (new taskList()).character
} else if (markData.property.taskType === MarkTask.Car) {
this.allTaskList = (new taskList()).car
} else {
this.allTaskList = []
}
}
}
//提交 设备任务窗口表单
submitTaskForm(e) {
this.contingencyPlanTask.property.institution = e.companyName
this.contingencyPlanTask.property.description = e.description
this.contingencyPlanTask.property.task = e.taskName
MarkWindow.instance.updateProperty()
this.contingencyPlanTask = null //关闭弹窗
}
selectRightTopFast: number = 0; //当前选择功能 快捷栏
selectAdsorb: boolean = false; //吸附状态
topLevelView: boolean = false; //顶视图状态
@ -614,6 +644,64 @@ export class PlanComponent implements OnInit {
}
//设备任务窗口 数据类型
export class taskDialog {
institution: string; //单位
task: string; //任务
description: string; //备注
constructor(institution: string, task: string, description: string) {
this.institution = institution
this.task = task
this.description = description
}
}
//设备任务list
export class taskList {
character: any[] = [
{ taskName: "外部控火" },
{ taskName: "内部控火" },
{ taskName: "外部侦察" },
{ taskName: "内部侦察" },
{ taskName: "外部观察" },
{ taskName: "外部疏散救生" },
{ taskName: "询问知情人" },
{ taskName: "占领消控室" },
{ taskName: "水源引导" },
{ taskName: "断电气" },
{ taskName: "灭火" },
{ taskName: "掩护" },
{ taskName: "警戒" },
{ taskName: "破拆" },
{ taskName: "排烟" },
{ taskName: "照明" },
{ taskName: "通信" },
{ taskName: "待命" },
];
car: any[] = [
{ taskName: "内攻" },
{ taskName: "出枪掩护" },
{ taskName: "出枪冷却" },
{ taskName: "出枪灭火" },
{ taskName: "供水" },
{ taskName: "供泡沫" },
{ taskName: "连接消火栓" },
{ taskName: "遥控水炮冷却" },
{ taskName: "遥控水炮灭火" },
{ taskName: "抢险救援" },
{ taskName: "救人" },
{ taskName: "指挥" },
{ taskName: "排烟" },
{ taskName: "提供器材" },
{ taskName: "照明" },
{ taskName: "供电" },
{ taskName: "待命" },
]
firemonitor: any[] = [
{ taskName: "遥控水炮冷却" },
{ taskName: "遥控水炮灭火" },
{ taskName: "待命" },
]
}
//属性栏 定位
export class naturePosition {
top: string = "1%"

10
src/styles.scss

@ -115,6 +115,16 @@ h1 {
box-shadow: 0px 0px 6px #2399FF;
li { color: #fff; }
}
//任务弹窗
.taskDialog{
.ant-modal-header,.ant-modal-content { background: radial-gradient(circle, #004988 0%, #00122D 100%); }
.ant-modal-header,.ant-modal-footer { border: none; }
.ant-modal-title,.ant-form-item-label > label,.ant-input { color: #C4E2FC; }
.ant-modal-footer .ant-btn:first-child { color: #C4E2FC; background: #000D21; border: 1px solid #C4E2FC; }
.ant-modal-footer .ant-btn:last-child { color: #C4E2FC; background: rgba(0, 129, 255, 0.6); border: 1px solid #36A2FF; }
.ant-input { background: rgba(145, 204, 255, 0.41); border: 1px solid #91CCFF; }
textarea { resize: none; outline: none; }
}
#threeDimensional {
.ant-tree{ color: #C4E2FC; } //tree
.ant-tree,.ant-tree-node-content-wrapper:hover,.ant-tree-node-content-wrapper.ant-tree-node-selected { background-color: transparent; } //tree

Loading…
Cancel
Save