From 24ae2821f2a145ebc565af648b6768a25a3408c6 Mon Sep 17 00:00:00 2001 From: luoyifan Date: Sun, 25 May 2025 15:18:32 +0800 Subject: [PATCH] =?UTF-8?q?WorldMode=20/=20Viewport=20/=20editor=20?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E6=A8=A1=E5=BC=8F=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/designer/Viewport.ts | 12 ++++++++++-- src/designer/model2DEditor/Model2DEditor.vue | 12 +++++++----- src/designer/model2DEditor/Model2DEditorJs.js | 26 ++++++++++++++++---------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/designer/Viewport.ts b/src/designer/Viewport.ts index 8ed2e73..81431c5 100644 --- a/src/designer/Viewport.ts +++ b/src/designer/Viewport.ts @@ -21,6 +21,7 @@ export default class Viewport { statsControls: Stats controls: OrbitControls worldModel: WorldModel + animationFrameId: any = null /** * 监听窗口大小变化 @@ -46,7 +47,9 @@ export default class Viewport { /** * 初始化 THREE 渲染器 */ - initThree(viewerDom: HTMLElement) { + initThree(viewerDom: HTMLElement, floor: string) { + console.log('init floor', floor) + this.state.currentFloor = floor this.viewerDom = viewerDom this.worldModel.registerViewport(this) @@ -195,7 +198,7 @@ export default class Viewport { * 动画循环 */ animate() { - requestAnimationFrame(this.animate.bind(this)) + this.animationFrameId = requestAnimationFrame(this.animate.bind(this)) this.renderView() } @@ -282,6 +285,11 @@ export default class Viewport { destroy() { this.state.isReady = false + if (this.animationFrameId !== null) { + cancelAnimationFrame(this.animationFrameId) + this.animationFrameId = null + } + if (this.unwatchList) { _.forEach(this.unwatchList, (unWatchFn => { unWatchFn() diff --git a/src/designer/model2DEditor/Model2DEditor.vue b/src/designer/model2DEditor/Model2DEditor.vue index d1dcd97..0e9a4a4 100644 --- a/src/designer/model2DEditor/Model2DEditor.vue +++ b/src/designer/model2DEditor/Model2DEditor.vue @@ -4,13 +4,15 @@ - +
-
-
+
-