From f40efab9e23553beaa0eb7cc1850fba65caf85d0 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Thu, 28 Oct 2021 15:20:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AE=8C=E5=96=84=E9=87=8A=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/babylon/controller/scene-manager.ts | 4 ++++ src/app/babylon/game.ts | 10 ++++++++-- src/app/pages/plan/plan.component.ts | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/app/babylon/controller/scene-manager.ts b/src/app/babylon/controller/scene-manager.ts index dab79dd..535da51 100644 --- a/src/app/babylon/controller/scene-manager.ts +++ b/src/app/babylon/controller/scene-manager.ts @@ -111,6 +111,10 @@ export class SceneManager { } //#endregion + dispose() { + SceneManager.instance = null; + } + //#region 摄像机 /** diff --git a/src/app/babylon/game.ts b/src/app/babylon/game.ts index ba9a346..c331dd7 100644 --- a/src/app/babylon/game.ts +++ b/src/app/babylon/game.ts @@ -1,5 +1,4 @@ import { Database, Engine, RenderingManager, Scene } from "@babylonjs/core"; -import { AdvancedDynamicTexture } from "@babylonjs/gui"; import { SceneManager } from "./controller/scene-manager"; import { LoginSatus } from "./controller/status/login-status"; @@ -11,7 +10,6 @@ export class Game { public canvas: HTMLCanvasElement; public engine: Engine; public scene: Scene; - public uiRoot: AdvancedDynamicTexture; static instance: Game; @@ -54,5 +52,13 @@ export class Game { sceneManager.initSceneEvent(); } + dispose() { + SceneManager.Instance.dispose(); + this.scene.dispose() + this.scene = null; + this.engine.dispose(); + this.engine = null; + } + } diff --git a/src/app/pages/plan/plan.component.ts b/src/app/pages/plan/plan.component.ts index c74cb66..a393299 100644 --- a/src/app/pages/plan/plan.component.ts +++ b/src/app/pages/plan/plan.component.ts @@ -21,7 +21,8 @@ export class PlanComponent implements OnInit { } ngOnDestroy(): void { //组件销毁前 销毁canvas - + this.game.dispose(); + this.game = null; } } From a2d9ecf19bd1b06aa860d63f921b2ab5f10de0e1 Mon Sep 17 00:00:00 2001 From: liuxianghui <519646741@qq.com> Date: Thu, 28 Oct 2021 17:07:28 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/babylon/controller/mode-manager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/babylon/controller/mode-manager.ts b/src/app/babylon/controller/mode-manager.ts index c8b1743..e2d4fa4 100644 --- a/src/app/babylon/controller/mode-manager.ts +++ b/src/app/babylon/controller/mode-manager.ts @@ -15,15 +15,21 @@ export enum ModeType { export class ModeManager { /** - * 当前模式的类型 + * 当前模式的类型(在查看模式下,可编辑某些内容的权限) */ private static s_currentMode: ModeType = ModeType.Edit; + /** * 调试模式 */ public static isDebug = true; + /** + * 是编辑人员(内部编辑人员,可新增单位、上传模型) + */ + public static isEditor = true; + //#region 演示单单位