邵佳豪 3 years ago
parent
commit
d13158f0d1
  1. 8
      src/app/babylon/controller/mode-manager.ts
  2. 4
      src/app/babylon/controller/scene-manager.ts
  3. 10
      src/app/babylon/game.ts
  4. 3
      src/app/pages/plan/plan.component.ts

8
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 演示单单位

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

@ -111,6 +111,10 @@ export class SceneManager {
}
//#endregion
dispose() {
SceneManager.instance = null;
}
//#region 摄像机
/**

10
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;
}
}

3
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;
}
}

Loading…
Cancel
Save