diff --git a/src/rendering/world-background-renderer.ts b/src/rendering/world-background-renderer.ts index d958599b..8875b015 100644 --- a/src/rendering/world-background-renderer.ts +++ b/src/rendering/world-background-renderer.ts @@ -59,6 +59,23 @@ export interface WorldEnvironmentState { intensity: number; } +export function shouldUseDynamicWorldEnvironment( + background: WorldBackgroundSettings, + backgroundTexture: Texture | null, + overlay: WorldBackgroundOverlayState | null +): boolean { + const overlayTexture = overlay?.texture ?? null; + const overlayOpacity = clamp(overlay?.opacity ?? 0, 0, 1); + + return ( + background.mode === "image" && + backgroundTexture !== null && + overlayTexture !== null && + overlayOpacity > NIGHT_BACKGROUND_EPSILON && + overlayOpacity < 1 - NIGHT_BACKGROUND_EPSILON + ); +} + export function resolveWorldEnvironmentState( background: WorldBackgroundSettings, backgroundTexture: Texture | null, @@ -243,6 +260,10 @@ export class WorldBackgroundRenderer { this.anchor.position.copy(camera.position); } + syncToOrigin() { + this.anchor.position.set(0, 0, 0); + } + dispose() { this.geometry.dispose(); this.gradientMaterial.dispose();