Update weather system to improve accuracy and detail; increase weather grid size to 12x12 for finer resolution, enhance weather layer rendering to accurately reflect localized conditions, and implement new sampling methods for precipitation and cloud cover. Refactor related components for better performance and clarity in weather data handling.

This commit is contained in:
Leonid Pershin
2026-08-17 10:26:01 +03:00
parent cb5117edba
commit c80c9f14e2
11 changed files with 387 additions and 104 deletions
+16 -8
View File
@@ -108,7 +108,7 @@ them without reworking the data model.
| `GET /api/worlds/{id}` | Status of one world |
| `GET /api/worlds/{id}/map` | Metadata plus the chunk index |
| `GET /api/worlds/{id}/chunks/{x}/{y}` | One chunk of geometry |
| `GET /api/worlds/{id}/weather` | The weather field over the map: an 8×8 grid of samples, row-major from the south-west corner |
| `GET /api/worlds/{id}/weather` | The weather field over the map: a 12×12 grid of samples, row-major from the south-west corner |
| `PATCH /api/worlds/{id}/clock` | Pause / resume or set speed (`timeScale` 14). Body: `{ paused?, timeScale? }` |
| `DELETE /api/worlds/{id}` | Remove a world and its chunks |
| `GET /api/climates` | The climate catalogue for the create form, with the latitude band each preset is the default for |
@@ -191,13 +191,21 @@ floor so hairlines stay visible. At street level the map picks up the things tha
- gentle bends in roads and watercourses are rounded off by Chaikin corner cutting; corners sharper than 50°
are left alone, because a gridded town is full of genuine right angles
`WeatherLayer` sits over the map in screen space, so the weather does not slide about when you pan. Below the
place names goes a wash: a colour for the time of day, interpolated from the sun's elevation through golden
hour, dusk and night, greyed down by cloud while the sun is up; then white for lying snow; then a pale haze
for fog, blizzards and sandstorms. Above the names falls the precipitation — slanted streaks for rain,
drifting dots for snow — leaning downwind at a slant taken from the local wind and capped so a gale still
looks like weather rather than a barcode. The whole thing is read from the server grid under the middle of
the screen, so panning towards a front walks into the rain.
`WeatherLayer` sits over the map. **What it draws is about the ground, not about the viewport.** Only the
light of the time of day covers the screen evenly — the sun sets on a whole town at once — and that is the
one flat rectangle: a colour interpolated from the sun's elevation through golden hour, dusk and night.
Everything else is read from the field under each patch of screen and painted where it is actually
happening: lying snow, the dimming under cloud, and the precipitation map itself, which darkens the ground a
shower is standing over so the shape of a front is legible from any zoom. The patches are a coarse grid,
drawn oversized and blurred, which turns ten steps into a gradient. Falling rain and snow are drawn above
the place names, and each drop is only drawn if the ground beneath it is wet, so the fall thins out across
the edge of a front instead of the whole screen raining together.
Pressure systems are sized to be cells on the map rather than the whole sky. A real depression spans a
thousand kilometres and would sit over a town as one flat value with no edge at all — the same trade already
made for drift speed. Their lower bound is set by the export grid: a system narrower than about two node
spacings aliases into it and the client interpolates a lie.
The maths lives in `sky.ts` and `weatherField.ts`, which import no PixiJS and are unit-tested; `weatherLayer.ts`
only knows how to paint the result. A dark theme pulls the night wash back rather than switching it off,