perf(editor): 轻微降低内存占用;

This commit is contained in:
ErSan 2025-12-21 01:28:27 +08:00
parent fed4277a7c
commit 1f810ef5e2
8 changed files with 19 additions and 6 deletions

View File

@ -9,7 +9,7 @@
"docs:build": "pnpm run -C packages/docs docs:build", "docs:build": "pnpm run -C packages/docs docs:build",
"docs:preview": "pnpm run -C packages/docs docs:preview", "docs:preview": "pnpm run -C packages/docs docs:preview",
"editor:dev": "pnpm run -C packages/editor dev", "editor:dev": "pnpm run -C packages/editor dev",
"editor:build": "pnpm run -C packages/editor build", "editor:build": "pnpm run sdk:build && pnpm run -C packages/editor build",
"editor:tsc": "pnpm run -C packages/editor tsc", "editor:tsc": "pnpm run -C packages/editor tsc",
"editor:preview": "pnpm run -C packages/editor preview", "editor:preview": "pnpm run -C packages/editor preview",
"sdk:dev": "pnpm run -C packages/sdk dev", "sdk:dev": "pnpm run -C packages/sdk dev",

View File

@ -11,4 +11,4 @@ VITE_GLOB_AUTHOR='ErSan'
VITE_GLOB_VERSION='1.0.0' VITE_GLOB_VERSION='1.0.0'
# 备案号 # 备案号
VITE_GLOB_BEIAN='滇ICP备2022001592号-2' VITE_GLOB_BEIAN='滇ICP备XXXXXX号'

View File

@ -19,4 +19,4 @@ VITE_ENABLE_CONFIG_GENERATE=true
VITE_GLOB_ORIGIN=https://editor.astraljs.com/ VITE_GLOB_ORIGIN=https://editor.astraljs.com/
#ws接口 #ws接口
VITE_GLOB_SOCKET_URL=wss://editor.astraljs.com/api/sys/ws VITE_GLOB_SOCKET_URL=wss://editor.astraljs.com/socket

Binary file not shown.

View File

@ -0,0 +1,8 @@
import { injectWasm } from "@/utils/wasm/inject";
export function clearBuffer() {
injectWasm({ wasmUrl: "/wasm/Astral3DEditor.wasm" }).then(() => {
// 加载完wasm后自动注册了清除缓存的函数调用
window.clearBuffer();
});
}

View File

@ -18,12 +18,13 @@
import {onMounted, ref, nextTick, onBeforeUnmount} from 'vue'; import {onMounted, ref, nextTick, onBeforeUnmount} from 'vue';
import {App,Viewer,Hooks} from "@astral3d/engine"; import {App,Viewer,Hooks} from "@astral3d/engine";
import Toolbar from "./Toolbar.vue"; import Toolbar from "./Toolbar.vue";
import ViewportInfo from "./ViewportInfo.vue";
import BIMProperties from "./BIMProperties.vue";
import IFCProperties from "./IFCProperties.vue";
import {useGlobalConfigStore} from "@/store/modules/globalConfig"; import {useGlobalConfigStore} from "@/store/modules/globalConfig";
import {usePluginStore} from "@/store/modules/plugin"; import {usePluginStore} from "@/store/modules/plugin";
import {installBuiltinPlugin} from "@/plugin"; import {installBuiltinPlugin} from "@/plugin";
import { clearBuffer } from "@/utils/wasm/optimize";
import ViewportInfo from "./ViewportInfo.vue";
import BIMProperties from "./BIMProperties.vue";
import IFCProperties from "./IFCProperties.vue";
const globalStore = useGlobalConfigStore(); const globalStore = useGlobalConfigStore();
const pluginStore = usePluginStore(); const pluginStore = usePluginStore();
@ -55,6 +56,9 @@ onMounted(async () => {
// astral editor // astral editor
installBuiltinPlugin(window.viewer); installBuiltinPlugin(window.viewer);
// wasm
clearBuffer();
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {

View File

@ -12,6 +12,7 @@ declare interface Window {
VRButton: any; VRButton: any;
log: import('loglevel').RootLogger; log: import('loglevel').RootLogger;
// wasm // wasm
clearBuffer: () => void
glTFHandlerEncodeGLB: (u: Uint8Array, jsonStr: string) => Uint8Array glTFHandlerEncodeGLB: (u: Uint8Array, jsonStr: string) => Uint8Array
glTFHandlerEncodePNG: (png: Uint8Array) => Uint8Array glTFHandlerEncodePNG: (png: Uint8Array) => Uint8Array
} }