From 1220983f9813cfc39a445447b0914a1af798577f Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 22 Apr 2026 13:11:49 +0200 Subject: [PATCH] auto-git: [change] src/runtime-three/runtime-host.ts --- src/runtime-three/runtime-host.ts | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/runtime-three/runtime-host.ts b/src/runtime-three/runtime-host.ts index 13d13f61..2160fc9c 100644 --- a/src/runtime-three/runtime-host.ts +++ b/src/runtime-three/runtime-host.ts @@ -1087,7 +1087,12 @@ export class RuntimeHost { opacity: nightBackgroundOverlay.opacity, environmentIntensity: nightBackgroundOverlay.environmentIntensity }; - const environmentState = resolveWorldEnvironmentState( + let environmentState = resolveWorldEnvironmentState( + resolvedWorld.background, + backgroundTexture, + backgroundOverlayState + ); + const useDynamicEnvironment = shouldUseDynamicWorldEnvironment( resolvedWorld.background, backgroundTexture, backgroundOverlayState @@ -1098,6 +1103,22 @@ export class RuntimeHost { backgroundTexture, backgroundOverlayState ); + + if (useDynamicEnvironment && this.pmremGenerator !== null) { + this.worldBackgroundRenderer.syncToOrigin(); + this.dynamicWorldEnvironmentTarget?.dispose(); + this.dynamicWorldEnvironmentTarget = this.pmremGenerator.fromScene( + this.worldBackgroundRenderer.scene + ) as WebGLCubeRenderTarget; + environmentState = { + texture: this.dynamicWorldEnvironmentTarget.texture, + intensity: environmentState.intensity + }; + } else if (this.dynamicWorldEnvironmentTarget !== null) { + this.dynamicWorldEnvironmentTarget.dispose(); + this.dynamicWorldEnvironmentTarget = null; + } + this.scene.background = null; this.scene.environment = environmentState.texture; this.scene.environmentIntensity = environmentState.intensity;