Lighting & Day/Night Cycle
The lighting system progressively shifts from day to night as players advance through trail markers.
Architecture
- LightingService (server) — Watches chunk progression, sets
dayNightatom - LightingController (client) — Smooth visual transitions between Day/Night states
Progressive Tiers
Configured in shared/data/configs/lighting.ts:
| Marker Range | Day Chunks | Night Chunks | Daylight % | Feel |
|---|---|---|---|---|
| 1–20 | 3 | 2 | 60% | Learning phase |
| 21–40 | 2 | 3 | 40% | Dusk — sun setting |
| 41–60 | 1 | 4 | 20% | Twilight — mostly dark |
| 61–80 | 1 | 9 | 10% | Deep night |
| 81–100 | 0 | 1 | 0% | Total darkness |
Within each tier, the pattern repeats. For tier 1: Day, Day, Day, Night, Night, Day, Day, Day...
Prewarm Offset
The server generates 3 chunks ahead at startup. To prevent the cycle from advancing before the player moves, LightingService captures the initial chunk count and offsets progression:
const progression = chunkCount - this.initialChunkCount + 1;
This ensures the game starts on Day regardless of prewarmed chunks.
Client Transitions
Transition duration: 8 seconds with easing.
Lerped properties:
| Property | Day | Night |
|---|---|---|
| ClockTime | 7.1 | 0 |
| Atmosphere.Color | White | Blue-grey |
| EnvironmentDiffuseScale | 1.0 | 0.0 |
| OutdoorAmbient | Dark blue | Purple |
Fog density increases progressively via fogOverrideAlpha atom.