From 9a77f7a719bcf95897e5b116d38cb2ae3773ea27 Mon Sep 17 00:00:00 2001 From: JouChun Date: Tue, 22 Oct 2024 22:58:57 -0400 Subject: [PATCH] =?UTF-8?q?forge=20api=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/forge/ForgeForSystem.vue | 4 ++-- src/hooks/forge/useForgeSprite.js | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/forge/ForgeForSystem.vue b/src/components/forge/ForgeForSystem.vue index 0210a2b..3e111b8 100644 --- a/src/components/forge/ForgeForSystem.vue +++ b/src/components/forge/ForgeForSystem.vue @@ -33,7 +33,7 @@ const updateHeatBarIsShow = (isShow) => { heat_bar_isShow.value = isShow; }; -const { updateDataVisualization, createSprites, hideAllObjects, forgeClickListener } = useForgeSprite() +const { updateDataVisualization, createSprites, hideAllObjects, forgeClickListener, clear } = useForgeSprite() const forgeDom = ref(null); @@ -194,7 +194,7 @@ const getCurrentInfoModalData = (e, position, value) => { onUnmounted(() => { console.log("Forge 銷毀"); - NOP_VIEWER.tearDown(); + clear(); }); diff --git a/src/hooks/forge/useForgeSprite.js b/src/hooks/forge/useForgeSprite.js index eae8cfb..6a6678c 100644 --- a/src/hooks/forge/useForgeSprite.js +++ b/src/hooks/forge/useForgeSprite.js @@ -24,7 +24,7 @@ export default function useForgeSprite() { }; function onSpriteClicked(event) { - event.hasStopped = false; + event.hasStopped = true; if (event.type === Autodesk.DataVisualization.Core.MOUSE_CLICK_OUT) return; @@ -154,10 +154,23 @@ export default function useForgeSprite() { forgeViewer.value.impl.invalidate(true); }; + const clear = () => { + forgeViewer.value.removeEventListener( + Autodesk.DataVisualization.Core.MOUSE_CLICK, + onSpriteClicked + ); + forgeViewer.value.removeEventListener( + Autodesk.DataVisualization.Core.MOUSE_CLICK_OUT, + onSpriteClicked + ); + forgeViewer.value.tearDown(); + }; + return { createSprites, updateDataVisualization, hideAllObjects, forgeClickListener, + clear }; }