刘向辉 3 years ago
parent
commit
12a60d0389
  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. 22
      src/app/babylon/view/mark-window/mark-window.ts

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

22
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";
@ -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);
}
}

Loading…
Cancel
Save