auto-git:

[change] src/rendering/precomputed-shader-sky-environment-cache.ts
 [change] src/rendering/quantized-environment-blend-cache.ts
 [change] src/rendering/world-background-renderer.ts
 [change] src/rendering/world-shader-sky.ts
 [change] src/runtime-three/runtime-host.ts
This commit is contained in:
2026-04-22 17:57:03 +02:00
parent 7c73d9bc86
commit 23d0be0d2c
7 changed files with 69 additions and 63 deletions

View File

@@ -106,14 +106,14 @@ class RendererShaderSkyEnvironmentTextureBuilder {
}
}
export class PrecomputedShaderSkyEnvironmentCache
implements WorldShaderSkyEnvironmentTextureResolver
{
export class PrecomputedShaderSkyEnvironmentCache implements WorldShaderSkyEnvironmentTextureResolver {
private currentKey: string | null = null;
private readonly phaseEntries = createEmptyPhaseEntries();
private disposed = false;
constructor(private readonly options: PrecomputedShaderSkyEnvironmentCacheOptions) {}
constructor(
private readonly options: PrecomputedShaderSkyEnvironmentCacheOptions
) {}
syncPhaseTextures(states: WorldShaderSkyEnvironmentPhaseStates) {
if (this.disposed) {
@@ -132,9 +132,7 @@ export class PrecomputedShaderSkyEnvironmentCache
for (const phase of SHADER_SKY_PHASES) {
const state = states[phase];
nextEntries[phase] =
state === null
? null
: this.options.buildEnvironmentTexture(state);
state === null ? null : this.options.buildEnvironmentTexture(state);
}
} catch (error) {
disposePhaseEntries(nextEntries);
@@ -166,7 +164,8 @@ export class PrecomputedShaderSkyEnvironmentCache
return null;
}
const baseTexture = this.phaseEntries[phaseBlend.basePhase]?.texture ?? null;
const baseTexture =
this.phaseEntries[phaseBlend.basePhase]?.texture ?? null;
if (baseTexture === null) {
return null;
@@ -188,8 +187,7 @@ export class PrecomputedShaderSkyEnvironmentCache
baseTexture,
overlayTexture,
phaseBlend.blendAmount
) ??
(phaseBlend.blendAmount >= 0.5 ? overlayTexture : baseTexture)
) ?? (phaseBlend.blendAmount >= 0.5 ? overlayTexture : baseTexture)
);
}

View File

@@ -109,20 +109,16 @@ function resolveTextureDimensions(texture: Texture): {
height?: number;
}
| undefined;
const sourceData = texture.source.data as
| {
width?: number;
height?: number;
}
| null;
const sourceData = texture.source.data as {
width?: number;
height?: number;
} | null;
return {
width: Math.max(
1,
Math.floor(
image?.width ??
sourceData?.width ??
DEFAULT_BLEND_RENDER_TARGET_WIDTH
image?.width ?? sourceData?.width ?? DEFAULT_BLEND_RENDER_TARGET_WIDTH
)
),
height: Math.max(
@@ -186,9 +182,7 @@ export function createQuantizedEnvironmentBlendCacheKey(
return `${getOrderedPairCacheKey(baseTexture, overlayTexture)}@${bucketIndex}`;
}
export class QuantizedEnvironmentBlendCache
implements WorldEnvironmentBlendTextureResolver
{
export class QuantizedEnvironmentBlendCache implements WorldEnvironmentBlendTextureResolver {
private readonly bucketCount: number;
private readonly buildBlendTexture: QuantizedEnvironmentBlendCacheOptions["buildBlendTexture"];
private readonly disposeBuildResources: (() => void) | undefined;
@@ -208,9 +202,7 @@ export class QuantizedEnvironmentBlendCache
constructor(options: QuantizedEnvironmentBlendCacheOptions) {
this.bucketCount = Math.max(
1,
Math.floor(
options.bucketCount ?? DEFAULT_QUANTIZED_BLEND_BUCKET_COUNT
)
Math.floor(options.bucketCount ?? DEFAULT_QUANTIZED_BLEND_BUCKET_COUNT)
);
this.buildBlendTexture = options.buildBlendTexture;
this.disposeBuildResources = options.disposeBuildResources;
@@ -359,7 +351,11 @@ export class QuantizedEnvironmentBlendCache
}
private schedulePendingBuilds() {
if (this.disposed || this.buildScheduled || this.pendingBuilds.length === 0) {
if (
this.disposed ||
this.buildScheduled ||
this.pendingBuilds.length === 0
) {
return;
}

View File

@@ -756,8 +756,7 @@ function applyShaderSkyStateToMaterial(
material.uniforms.uCloudSoftness.value = state.clouds.softness;
material.uniforms.uCloudScale.value = state.clouds.scale;
material.uniforms.uCloudHeight.value = state.clouds.height;
material.uniforms.uCloudHeightVariation.value =
state.clouds.heightVariation;
material.uniforms.uCloudHeightVariation.value = state.clouds.heightVariation;
material.uniforms.uCloudTint.value.set(state.clouds.tintHex);
material.uniforms.uCloudOpacity.value = state.clouds.opacity;
material.uniforms.uCloudOpacityRandomness.value =
@@ -904,7 +903,9 @@ export class WorldBackgroundRenderer {
}
applyShaderSkyStateToMaterial(this.shaderSkyMaterial, shaderSkyState);
this.syncEnvironmentCaptureState(showShaderBackground ? shaderSkyState : null);
this.syncEnvironmentCaptureState(
showShaderBackground ? shaderSkyState : null
);
this.shaderMesh.visible = showShaderBackground;
this.gradientMesh.visible = !showShaderBackground && !showImageBackground;
this.imageMesh.visible = showImageBackground;

View File

@@ -98,7 +98,10 @@ function resolveTimeWindowMidpoint(
startTimeOfDayHours: number,
endTimeOfDayHours: number
): number {
const wrappedEndTime = wrapTimeForward(endTimeOfDayHours, startTimeOfDayHours);
const wrappedEndTime = wrapTimeForward(
endTimeOfDayHours,
startTimeOfDayHours
);
return normalizeTimeOfDayHours(
startTimeOfDayHours + (wrappedEndTime - startTimeOfDayHours) / 2
@@ -423,10 +426,8 @@ export function resolveWorldShaderSkyEnvironmentPhaseStates(
};
}
const dawnHalfDuration =
Math.max(timeSettings.dawnDurationHours, 0.001) / 2;
const duskHalfDuration =
Math.max(timeSettings.duskDurationHours, 0.001) / 2;
const dawnHalfDuration = Math.max(timeSettings.dawnDurationHours, 0.001) / 2;
const duskHalfDuration = Math.max(timeSettings.duskDurationHours, 0.001) / 2;
const dawnStart = timeSettings.sunriseTimeOfDayHours - dawnHalfDuration;
const dawnEnd = timeSettings.sunriseTimeOfDayHours + dawnHalfDuration;
const duskStart = timeSettings.sunsetTimeOfDayHours - duskHalfDuration;
@@ -549,9 +550,9 @@ export function createWorldShaderSkyEnvironmentPhaseCacheKey(
export function resolveWorldShaderSkyEnvironmentPhaseBlend(
state: Pick<WorldShaderSkyRenderState, "time">
): WorldShaderSkyEnvironmentPhaseBlend | null {
const activePhases = (
["day", "dawn", "dusk", "night"] as const
).filter((phase) => state.time.phaseWeights[phase] > 1e-4);
const activePhases = (["day", "dawn", "dusk", "night"] as const).filter(
(phase) => state.time.phaseWeights[phase] > 1e-4
);
if (activePhases.length === 0) {
return null;