From 05dc5664365a65c80e7ca646981d110c2759e366 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 22 Apr 2026 13:45:36 +0200 Subject: [PATCH] auto-git: [change] src/viewport-three/viewport-host.ts --- src/viewport-three/viewport-host.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/viewport-three/viewport-host.ts b/src/viewport-three/viewport-host.ts index 7a389531..6aee0651 100644 --- a/src/viewport-three/viewport-host.ts +++ b/src/viewport-three/viewport-host.ts @@ -215,6 +215,10 @@ import { resolveWorldEnvironmentState, WorldBackgroundRenderer } from "../rendering/world-background-renderer"; +import { + createRendererQuantizedEnvironmentBlendCache, + type QuantizedEnvironmentBlendCache +} from "../rendering/quantized-environment-blend-cache"; import { applyWhiteboxBevelToMaterial, shouldApplyWhiteboxBevel @@ -510,6 +514,7 @@ export class ViewportHost { CachedMaterialTexture >(); private readonly materialTextureLoader = new TextureLoader(); + private readonly environmentBlendCache: QuantizedEnvironmentBlendCache; private currentDocument: SceneDocument | null = null; private currentWorld: WorldSettings | null = null; private currentSimulationScene: RuntimeSceneDefinition | null = null; @@ -679,6 +684,14 @@ export class ViewportHost { this.scene.add(this.boxCreatePreviewEdges); this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); this.renderer.setClearAlpha(0); + this.environmentBlendCache = createRendererQuantizedEnvironmentBlendCache( + this.renderer, + { + onTextureReady: () => { + this.applyWorld(); + } + } + ); this.applyViewModePose(); } @@ -805,6 +818,7 @@ export class ViewportHost { this.projectAssets = projectAssets; this.loadedModelAssets = loadedModelAssets; this.loadedImageAssets = loadedImageAssets; + this.environmentBlendCache.clear(); if (this.currentWorld !== null) { this.applyWorld(); @@ -1235,6 +1249,7 @@ export class ViewportHost { this.terrainBrushPreviewLine.material.dispose(); this.terrainBrushPreviewCenter.geometry.dispose(); this.terrainBrushPreviewCenter.material.dispose(); + this.environmentBlendCache.dispose(); this.worldBackgroundRenderer.dispose(); this.renderer.forceContextLoss(); this.renderer.dispose();