Skip repeated Three texture disposal scans

This commit is contained in:
flash555588 2026-06-27 06:28:25 +08:00
parent b7c348c710
commit afe4787fe4
3 changed files with 7 additions and 5 deletions

View file

@ -32,6 +32,7 @@
- Performance: capture disassembly original transforms only for dragged parts and cache repeated Live Preview embed path resolution, reducing large-assembly interaction and workspace editor setup work.
- Performance: update Three.js focus selection incrementally so switching selected parts in large assemblies no longer restores and re-dims every mesh.
- Performance: prepare each unique Three.js material once during model load, avoiding repeated texture audit and anisotropy updates on shared-material large models.
- Performance: skip repeated Three.js texture scans when disposing shared materials during model switches, reducing large-model close/reload stalls.
- Performance: avoid forcing an unchanged plugin `data.json` rewrite during unload; only pending dirty state is flushed.
- Performance: load inline preview modules in parallel and defer heading-pin DOM observers until the workspace layout is ready, reducing plugin startup work.
- Performance: read absolute-path model files without an extra full-buffer copy when Node returns a whole file buffer, reducing memory spikes for large converted GLB assets.

File diff suppressed because one or more lines are too long

View file

@ -1862,6 +1862,9 @@ export class ThreeModelPreview implements WorkbenchPreview {
materialIds: Set<string>,
textureIds: Set<string>,
): void {
if (materialIds.has(material.uuid)) {
return;
}
const record = material as unknown as Record<string, unknown>;
for (const value of Object.values(record)) {
if (value instanceof Texture && !textureIds.has(value.uuid)) {
@ -1877,10 +1880,8 @@ export class ThreeModelPreview implements WorkbenchPreview {
}
}
if (!materialIds.has(material.uuid)) {
material.dispose();
materialIds.add(material.uuid);
}
material.dispose();
materialIds.add(material.uuid);
}
private fitCameraToObject(root: Object3D, rootBounds?: PreviewBounds): void {