forge api 更新

This commit is contained in:
JouChun 2024-10-22 22:58:57 -04:00
parent faa267ff75
commit 9a77f7a719
2 changed files with 16 additions and 3 deletions

View File

@ -33,7 +33,7 @@ const updateHeatBarIsShow = (isShow) => {
heat_bar_isShow.value = isShow; heat_bar_isShow.value = isShow;
}; };
const { updateDataVisualization, createSprites, hideAllObjects, forgeClickListener } = useForgeSprite() const { updateDataVisualization, createSprites, hideAllObjects, forgeClickListener, clear } = useForgeSprite()
const forgeDom = ref(null); const forgeDom = ref(null);
@ -194,7 +194,7 @@ const getCurrentInfoModalData = (e, position, value) => {
onUnmounted(() => { onUnmounted(() => {
console.log("Forge 銷毀"); console.log("Forge 銷毀");
NOP_VIEWER.tearDown(); clear();
}); });
</script> </script>

View File

@ -24,7 +24,7 @@ export default function useForgeSprite() {
}; };
function onSpriteClicked(event) { function onSpriteClicked(event) {
event.hasStopped = false; event.hasStopped = true;
if (event.type === Autodesk.DataVisualization.Core.MOUSE_CLICK_OUT) return; if (event.type === Autodesk.DataVisualization.Core.MOUSE_CLICK_OUT) return;
@ -154,10 +154,23 @@ export default function useForgeSprite() {
forgeViewer.value.impl.invalidate(true); 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 { return {
createSprites, createSprites,
updateDataVisualization, updateDataVisualization,
hideAllObjects, hideAllObjects,
forgeClickListener, forgeClickListener,
clear
}; };
} }