From 9f40ae46a10a1d4e8fd8e58b216d7dcc0b1c9a80 Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 22 Apr 2026 16:28:36 +0200 Subject: [PATCH] auto-git: [change] src/runtime-three/runtime-project-time.ts --- src/runtime-three/runtime-project-time.ts | 24 ++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/runtime-three/runtime-project-time.ts b/src/runtime-three/runtime-project-time.ts index a983ec03..712af2df 100644 --- a/src/runtime-three/runtime-project-time.ts +++ b/src/runtime-three/runtime-project-time.ts @@ -478,20 +478,29 @@ export function resolveRuntimeDayNightPhaseWeights( } function resolveTimeDrivenSunOrbitRadians( + noonDirection: Vec3, settings: ProjectTimeSettings, timeOfDayHours: number ): number { - const sunrise = settings.sunriseTimeOfDayHours; + const boundaries = resolveRuntimeDayPhaseWindowBoundaries(settings); + const daytimeStart = boundaries.dawnEnd; + const daytimeEnd = boundaries.duskEnd; const daytimeDuration = Math.max( - settings.sunsetTimeOfDayHours - settings.sunriseTimeOfDayHours, + wrapTimeForward(daytimeEnd, daytimeStart) - daytimeStart, + 0.001 + ); + const relativeTime = + wrapTimeForward(timeOfDayHours, daytimeStart) - daytimeStart; + const noonAltitudeRadians = Math.acos(clamp(noonDirection.y, -1, 1)); + const horizonOrbitRadians = Math.max( + Math.PI / 2 - noonAltitudeRadians, 0.001 ); - const relativeTime = wrapTimeForward(timeOfDayHours, sunrise) - sunrise; if (relativeTime <= daytimeDuration) { const daytimeProgress = clamp(relativeTime / daytimeDuration, 0, 1); - return lerp(-Math.PI / 2, Math.PI / 2, daytimeProgress); + return lerp(-horizonOrbitRadians, horizonOrbitRadians, daytimeProgress); } const nighttimeDuration = Math.max(HOURS_PER_DAY - daytimeDuration, 0.001); @@ -501,7 +510,11 @@ function resolveTimeDrivenSunOrbitRadians( 1 ); - return lerp(Math.PI / 2, Math.PI * 1.5, nighttimeProgress); + return lerp( + horizonOrbitRadians, + Math.PI * 2 - horizonOrbitRadians, + nighttimeProgress + ); } function resolveTimeDrivenSunDirection( @@ -523,6 +536,7 @@ function resolveTimeDrivenSunDirection( } : normalizeVec3(orbitAxisCandidate); const orbitRadians = resolveTimeDrivenSunOrbitRadians( + noonDirection, settings, timeOfDayHours );