auto-git:

[change] src/rendering/world-background-renderer.ts
 [change] src/runtime-three/runtime-host.ts
 [change] src/viewport-three/viewport-host.ts
This commit is contained in:
2026-04-22 13:15:06 +02:00
parent 3172cac299
commit 899ca9170b
3 changed files with 2 additions and 85 deletions

View File

@@ -59,23 +59,6 @@ export interface WorldEnvironmentState {
intensity: number; 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( export function resolveWorldEnvironmentState(
background: WorldBackgroundSettings, background: WorldBackgroundSettings,
backgroundTexture: Texture | null, backgroundTexture: Texture | null,
@@ -260,10 +243,6 @@ export class WorldBackgroundRenderer {
this.anchor.position.copy(camera.position); this.anchor.position.copy(camera.position);
} }
syncToOrigin() {
this.anchor.position.set(0, 0, 0);
}
dispose() { dispose() {
this.geometry.dispose(); this.geometry.dispose();
this.gradientMaterial.dispose(); this.gradientMaterial.dispose();

View File

@@ -20,7 +20,6 @@ import {
MeshPhysicalMaterial, MeshPhysicalMaterial,
MeshStandardMaterial, MeshStandardMaterial,
PerspectiveCamera, PerspectiveCamera,
PMREMGenerator,
PointLight, PointLight,
Quaternion, Quaternion,
Scene, Scene,
@@ -29,7 +28,6 @@ import {
SpotLight, SpotLight,
TextureLoader, TextureLoader,
Texture, Texture,
WebGLCubeRenderTarget,
WebGLRenderTarget, WebGLRenderTarget,
WebGLRenderer WebGLRenderer
} from "three"; } from "three";
@@ -80,7 +78,6 @@ import {
} from "../rendering/advanced-rendering"; } from "../rendering/advanced-rendering";
import { import {
resolveWorldEnvironmentState, resolveWorldEnvironmentState,
shouldUseDynamicWorldEnvironment,
WorldBackgroundRenderer WorldBackgroundRenderer
} from "../rendering/world-background-renderer"; } from "../rendering/world-background-renderer";
import { import {
@@ -357,8 +354,6 @@ export class RuntimeHost {
private readonly instanceAnimationClips = new Map<string, AnimationClip[]>(); private readonly instanceAnimationClips = new Map<string, AnimationClip[]>();
private readonly controllerContext: RuntimeControllerContext; private readonly controllerContext: RuntimeControllerContext;
private readonly renderer: WebGLRenderer | null; private readonly renderer: WebGLRenderer | null;
private readonly pmremGenerator: PMREMGenerator | null;
private dynamicWorldEnvironmentTarget: WebGLRenderTarget | null = null;
private runtimeScene: RuntimeSceneDefinition | null = null; private runtimeScene: RuntimeSceneDefinition | null = null;
private collisionWorld: RapierCollisionWorld | null = null; private collisionWorld: RapierCollisionWorld | null = null;
private collisionWorldRequestId = 0; private collisionWorldRequestId = 0;
@@ -441,8 +436,6 @@ export class RuntimeHost {
this.renderer = enableRendering this.renderer = enableRendering
? new WebGLRenderer({ antialias: false, alpha: true }) ? new WebGLRenderer({ antialias: false, alpha: true })
: null; : null;
this.pmremGenerator =
this.renderer === null ? null : new PMREMGenerator(this.renderer);
this.domElement = this.domElement =
this.renderer?.domElement ?? document.createElement("canvas"); this.renderer?.domElement ?? document.createElement("canvas");
@@ -850,9 +843,6 @@ export class RuntimeHost {
} }
this.materialTextureCache.clear(); this.materialTextureCache.clear();
this.dynamicWorldEnvironmentTarget?.dispose();
this.dynamicWorldEnvironmentTarget = null;
this.pmremGenerator?.dispose();
this.worldBackgroundRenderer.dispose(); this.worldBackgroundRenderer.dispose();
this.renderer?.forceContextLoss(); this.renderer?.forceContextLoss();
this.renderer?.dispose(); this.renderer?.dispose();
@@ -1090,12 +1080,7 @@ export class RuntimeHost {
opacity: nightBackgroundOverlay.opacity, opacity: nightBackgroundOverlay.opacity,
environmentIntensity: nightBackgroundOverlay.environmentIntensity environmentIntensity: nightBackgroundOverlay.environmentIntensity
}; };
let environmentState = resolveWorldEnvironmentState( const environmentState = resolveWorldEnvironmentState(
resolvedWorld.background,
backgroundTexture,
backgroundOverlayState
);
const useDynamicEnvironment = shouldUseDynamicWorldEnvironment(
resolvedWorld.background, resolvedWorld.background,
backgroundTexture, backgroundTexture,
backgroundOverlayState backgroundOverlayState
@@ -1106,22 +1091,6 @@ export class RuntimeHost {
backgroundTexture, backgroundTexture,
backgroundOverlayState 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.background = null;
this.scene.environment = environmentState.texture; this.scene.environment = environmentState.texture;
this.scene.environmentIntensity = environmentState.intensity; this.scene.environmentIntensity = environmentState.intensity;

View File

@@ -25,7 +25,6 @@ import {
OrthographicCamera, OrthographicCamera,
Plane, Plane,
PerspectiveCamera, PerspectiveCamera,
PMREMGenerator,
PointLight, PointLight,
Quaternion, Quaternion,
Raycaster, Raycaster,
@@ -37,7 +36,6 @@ import {
SpotLight, SpotLight,
TextureLoader, TextureLoader,
Texture, Texture,
WebGLCubeRenderTarget,
Vector2, Vector2,
Vector3, Vector3,
WebGLRenderTarget, WebGLRenderTarget,
@@ -215,7 +213,6 @@ import {
} from "../rendering/terrain-layer-material"; } from "../rendering/terrain-layer-material";
import { import {
resolveWorldEnvironmentState, resolveWorldEnvironmentState,
shouldUseDynamicWorldEnvironment,
WorldBackgroundRenderer WorldBackgroundRenderer
} from "../rendering/world-background-renderer"; } from "../rendering/world-background-renderer";
import { import {
@@ -440,7 +437,6 @@ export class ViewportHost {
antialias: false, antialias: false,
alpha: true alpha: true
}); });
private readonly pmremGenerator = new PMREMGenerator(this.renderer);
private readonly cameraTarget = new Vector3(0, 0, 0); private readonly cameraTarget = new Vector3(0, 0, 0);
private readonly cameraOffset = new Vector3(); private readonly cameraOffset = new Vector3();
private readonly cameraForward = new Vector3(); private readonly cameraForward = new Vector3();
@@ -513,7 +509,6 @@ export class ViewportHost {
string, string,
CachedMaterialTexture CachedMaterialTexture
>(); >();
private dynamicWorldEnvironmentTarget: WebGLRenderTarget | null = null;
private readonly materialTextureLoader = new TextureLoader(); private readonly materialTextureLoader = new TextureLoader();
private currentDocument: SceneDocument | null = null; private currentDocument: SceneDocument | null = null;
private currentWorld: WorldSettings | null = null; private currentWorld: WorldSettings | null = null;
@@ -1240,9 +1235,6 @@ export class ViewportHost {
this.terrainBrushPreviewLine.material.dispose(); this.terrainBrushPreviewLine.material.dispose();
this.terrainBrushPreviewCenter.geometry.dispose(); this.terrainBrushPreviewCenter.geometry.dispose();
this.terrainBrushPreviewCenter.material.dispose(); this.terrainBrushPreviewCenter.material.dispose();
this.dynamicWorldEnvironmentTarget?.dispose();
this.dynamicWorldEnvironmentTarget = null;
this.pmremGenerator.dispose();
this.worldBackgroundRenderer.dispose(); this.worldBackgroundRenderer.dispose();
this.renderer.forceContextLoss(); this.renderer.forceContextLoss();
this.renderer.dispose(); this.renderer.dispose();
@@ -1534,18 +1526,11 @@ export class ViewportHost {
this.localLightGroup.visible = this.displayMode !== "wireframe"; this.localLightGroup.visible = this.displayMode !== "wireframe";
if (this.displayMode !== "normal") { if (this.displayMode !== "normal") {
this.dynamicWorldEnvironmentTarget?.dispose();
this.dynamicWorldEnvironmentTarget = null;
this.scene.background = null; this.scene.background = null;
this.scene.environment = null; this.scene.environment = null;
this.scene.environmentIntensity = 1; this.scene.environmentIntensity = 1;
} else { } else {
let environmentState = resolveWorldEnvironmentState( const environmentState = resolveWorldEnvironmentState(
displayedBackground,
backgroundTexture,
backgroundOverlayState
);
const useDynamicEnvironment = shouldUseDynamicWorldEnvironment(
displayedBackground, displayedBackground,
backgroundTexture, backgroundTexture,
backgroundOverlayState backgroundOverlayState
@@ -1556,22 +1541,6 @@ export class ViewportHost {
backgroundTexture, backgroundTexture,
backgroundOverlayState backgroundOverlayState
); );
if (useDynamicEnvironment) {
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.background = null;
this.scene.environment = environmentState.texture; this.scene.environment = environmentState.texture;
this.scene.environmentIntensity = environmentState.intensity; this.scene.environmentIntensity = environmentState.intensity;