From d9995144f1353ec0b59f4d005d359b80c9d1d9e5 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 04 九月 2024 01:35:04 +0800
Subject: [PATCH] 权限配置
---
src/views/screen/components/screen-map-three/experience/index.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/src/views/screen/components/screen-map-three/experience/index.js b/src/views/screen/components/screen-map-three/experience/index.js
index 17affbd..df12788 100644
--- a/src/views/screen/components/screen-map-three/experience/index.js
+++ b/src/views/screen/components/screen-map-three/experience/index.js
@@ -1,4 +1,4 @@
-import { Scene, GridHelper,AxesHelper } from 'three';
+import { Scene, GridHelper, AxesHelper } from 'three';
import Stats from "three/examples/jsm/libs/stats.module";
import World from "./world/world";
@@ -28,10 +28,10 @@
// const gridHelper = new GridHelper(size, divisions);
// this.scene.add(gridHelper);
- this.stats = new Stats();
- document.querySelector('.map-container').appendChild(this.stats.dom);
+ // this.stats = new Stats();
+ // document.querySelector('.map-container').appendChild(this.stats.dom);
-
+
// 甯�
this.time.on('tick', () => {
@@ -44,6 +44,52 @@
this.world.update();
this.renderer.update();
this.cssRenderer.update();
- this.stats.update();
+ // this.stats.update();
+ }
+
+ /**
+ * 閿�姣佸満鏅�
+ */
+ destroy() {
+ this.disposeObject();
+ this.resetObject();
+ }
+
+ disposeObject() {
+ this.time.destroy();
+ this.world.destroy();
+ this.camera.destroy();
+ this.renderer.destroy();
+ this.cssRenderer.destroy();
+ this.scene.traverse((child) => {
+ if (child.material) {
+ // 鍙兘瀛樺湪鏉愯川涓烘暟缁勭殑鎯呭喌
+ if (child.material instanceof Array) {
+ child.material.forEach((item) => item.dispose());
+ } else {
+ child.material.dispose();
+ if (child.material.map) {
+ child.material.map.dispose();
+ }
+ }
+ }
+ if (child.geometry) {
+ child.geometry.dispose();
+ child.geometry.attributes = null; // 杩欎簺灞炴�у寘鎷琾osition, normal, uv绛夌瓑
+ }
+ child = null;
+ });
+ }
+
+ resetObject() {
+ this.world = null;
+ this.camera = null;
+ this.renderer = null;
+ this.cssRenderer = null;
+ this.scene = null;
+ this.canvas = null;
+ this.container = null;
+ this.time = null;
+ this.sizes = null;
}
}
\ No newline at end of file
--
Gitblit v1.8.0