From b2530191c147ba1ea32ad15f8a779acf48ef9e7e Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Mon, 18 May 2026 16:02:32 +0200 Subject: [PATCH] Refactor material cache cleanup and rebuild scene elements (terrains, roads, brushes) --- src/viewport-three/viewport-host.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 91ba133f..5c4e28a4 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -1881,12 +1881,20 @@ export class ViewportHost { this.loadedModelAssets = loadedModelAssets; this.loadedImageAssets = loadedImageAssets; this.environmentBlendCache.clear(); + this.clearMaterialTextureCache(); if (this.currentWorld !== null) { this.applyWorld(); } if (this.currentDocument !== null) { + this.rebuildBrushMeshes(this.currentDocument, this.currentSelection); + this.rebuildTerrains( + this.currentDocument, + this.currentSelection, + this.currentActiveSelectionId + ); + this.rebuildRoadSurfaces(this.currentDocument); this.rebuildEntityMarkers(this.currentDocument, this.currentSelection); this.rebuildModelInstances(this.currentDocument, this.currentSelection); this.applyTransformPreview(); @@ -2363,11 +2371,7 @@ export class ViewportHost { this.currentAdvancedRenderingSettings = null; this.renderer.autoClear = true; - for (const cachedTexture of this.materialTextureCache.values()) { - disposeMaterialTextureSet(cachedTexture.textureSet); - } - - this.materialTextureCache.clear(); + this.clearMaterialTextureCache(); this.boxCreatePreviewMesh.geometry.dispose(); this.boxCreatePreviewMesh.material.dispose(); this.boxCreatePreviewEdges.geometry.dispose();