From 084e680e12babffb39ebf451202cb073adacf090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=94=E8=B7=91=E7=9A=84=E9=9D=A2=E6=9D=A1?= <1262327911@qq.com> Date: Wed, 12 Oct 2022 21:15:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E4=B8=89=E7=BB=B4?= =?UTF-8?q?=E5=9C=B0=E7=90=83=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Decorates/Three/ThreeEarth01/code/world/Word.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts index c4a13bda..cc03c907 100644 --- a/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts +++ b/src/packages/components/Decorates/Three/ThreeEarth01/code/world/Word.ts @@ -96,9 +96,17 @@ export default class World { // 数据更新重新渲染 public updateData(data?: any) { - if(!this.earth.group) return + if (!this.earth.group) return // 先删除旧的 this.scene.remove(this.earth.group) + // 递归遍历组对象group释放所有后代网格模型绑定几何体占用内存 + this.earth.group.traverse((obj: any) => { + if (obj.type === 'Mesh') { + obj.geometry.dispose() + obj.material.dispose() + } + }) + // 重新创建 this.createEarth(data) } }