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;
}
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,
@@ -260,10 +243,6 @@ export class WorldBackgroundRenderer {
this.anchor.position.copy(camera.position);
}
syncToOrigin() {
this.anchor.position.set(0, 0, 0);
}
dispose() {
this.geometry.dispose();
this.gradientMaterial.dispose();

View File

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

View File

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