scene: keep the terrain sky and baked tables out of the main chunk (stacked on #47) #48

Merged
void merged 4 commits from nibu/sky-bundle into dev 2026-11-09 23:35:25 +00:00 AGit
Member

Cuts the main-chunk cost of the sky consumer (#47, merged). Branch carries dev 913a66eb (merged in; includes #47 and #45).

Entry chunk (vite build, index-*.js, gzip -9), measured twice:

build raw gzip
dev a9a75fc6 (before #47) 3,731,592 944,178
dev 913a66eb (#47 + #45 merged) 3,855,494 998,398 (+54.2 KB over a9a75fc6)
this PR 3,733,993 944,888 (+0.7 KB over a9a75fc6; -53.5 KB vs dev 913a66eb)

The +0.7 KB over a9a75fc6 includes #45's title-bar code, so the sky-state part of this PR is under that. Baked tables are in the lazy terrainSky chunk (117,567 raw / 50,056 gz), loaded with the scenes; the entry has none.

Backdrop constants (skyBackdrop reads these; relative luminance, rounded outward to 6 places): Day 0.237309-0.928052, Dusk 0.016727-0.967912, Night 0.058099-0.077467, Auto 0.016727-0.967912. They come from terrainDrawn, which now finds the sun-glow peak and the darkest patch by compass search from the best coarse samples (3 degree grid, 0.5 degree horizon ring, zenith, 0.25 degree sun patch); the old 3 degree grid gave Day max 0.9192 and Dusk 0.9647. Contrast table: the 3 passing cells (night Light/Silver/Dark/Butter 4.78 / 4.69, Midnight text 5.05) did not move; day Noonday is 3.71 / 2.56 as before; every other cell is 1.00 or as before.

Drift test (skyForState.test.ts): the constants must bound the computed union, sit within 1e-5 of it, and bound an independent sweep (golden-angle spiral of 20,000 points plus a 0.05 degree grid around the sun) within 5e-4. Mutating the day top to the old value, the day bottom, the dusk top, and setting the refinement off each fail it. Scene suite 22 files / 364 tests pass; prettier and eslint clean on touched files.

Service-worker precache (Void's question): there is none. vite.config.js:105-113 runs VitePWA with strategies: 'injectManifest' and injectManifest: { injectionPoint: undefined }, so no manifest is injected, and src/sw.ts has no precache, no __WB_MANIFEST and no workbox import: it only proxies authenticated media (install, activate, message and fetch handlers). The built sw.js is 1,660 bytes on both dev 913a66eb and this PR, byte-identical, with no precache/workbox/asset references. So the lazy terrainSky, Scene and Terrain chunks are not precached by the service worker on either; total precache size is 0 on dev and on this PR; they load over the network (and the browser HTTP cache) when the scene starts. No SW config was changed.

Not measured: load time or first paint, brotli sizes, runtime caching by the browser or host (netlify.toml headers), the dev server, a deployed build, and anything in a browser. One build each; the dev builds used deps from npm ci on this lockfile.

Cuts the main-chunk cost of the sky consumer (#47, merged). Branch carries dev 913a66eb (merged in; includes #47 and #45). Entry chunk (`vite build`, index-*.js, `gzip -9`), measured twice: | build | raw | gzip | |---|---|---| | dev a9a75fc6 (before #47) | 3,731,592 | 944,178 | | dev 913a66eb (#47 + #45 merged) | 3,855,494 | 998,398 (+54.2 KB over a9a75fc6) | | this PR | 3,733,993 | 944,888 (+0.7 KB over a9a75fc6; -53.5 KB vs dev 913a66eb) | The +0.7 KB over a9a75fc6 includes #45's title-bar code, so the sky-state part of this PR is under that. Baked tables are in the lazy `terrainSky` chunk (117,567 raw / 50,056 gz), loaded with the scenes; the entry has none. Backdrop constants (skyBackdrop reads these; relative luminance, rounded outward to 6 places): Day 0.237309-0.928052, Dusk 0.016727-0.967912, Night 0.058099-0.077467, Auto 0.016727-0.967912. They come from `terrainDrawn`, which now finds the sun-glow peak and the darkest patch by compass search from the best coarse samples (3 degree grid, 0.5 degree horizon ring, zenith, 0.25 degree sun patch); the old 3 degree grid gave Day max 0.9192 and Dusk 0.9647. Contrast table: the 3 passing cells (night Light/Silver/Dark/Butter 4.78 / 4.69, Midnight text 5.05) did not move; day Noonday is 3.71 / 2.56 as before; every other cell is 1.00 or as before. Drift test (skyForState.test.ts): the constants must bound the computed union, sit within 1e-5 of it, and bound an independent sweep (golden-angle spiral of 20,000 points plus a 0.05 degree grid around the sun) within 5e-4. Mutating the day top to the old value, the day bottom, the dusk top, and setting the refinement off each fail it. Scene suite 22 files / 364 tests pass; prettier and eslint clean on touched files. Service-worker precache (Void's question): there is none. `vite.config.js:105-113` runs VitePWA with `strategies: 'injectManifest'` and `injectManifest: { injectionPoint: undefined }`, so no manifest is injected, and `src/sw.ts` has no precache, no `__WB_MANIFEST` and no workbox import: it only proxies authenticated media (install, activate, message and fetch handlers). The built `sw.js` is 1,660 bytes on both dev 913a66eb and this PR, byte-identical, with no `precache`/`workbox`/asset references. So the lazy terrainSky, Scene and Terrain chunks are not precached by the service worker on either; total precache size is 0 on dev and on this PR; they load over the network (and the browser HTTP cache) when the scene starts. No SW config was changed. Not measured: load time or first paint, brotli sizes, runtime caching by the browser or host (netlify.toml headers), the dev server, a deployed build, and anything in a browser. One build each; the dev builds used deps from `npm ci` on this lockfile.
scene: keep the terrain sky and baked tables out of the main chunk
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
0d26b71862
skyBackdrop reads constants (the union of the ridge and terrain skies, rounded
outward) instead of computing it, and the door imports skyForState lazily with
the scenes. A test fails when the constants drift from the computed union.
Main entry chunk vs dev: +0.4 KB gzip, down from +51.5 KB.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
scene: terrain backdrop range found by refinement, not a grid
Some checks failed
Build pull request / Build pull request (pull_request) Has been cancelled
8a05668d84
terrainDrawn finds the sun glow peak and the darkest patch with a compass
search from the best coarse samples; constants regenerated (Day 0.237309-0.92805,
Dusk 0.016727-0.967912). The drift test sweeps its own grid (golden-angle spiral
plus a 0.05 degree patch around the sun).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
scene: Day sky bound was 1.2e-6 low; refine to 1e-6 degrees and check both directions
Some checks failed
Build pull request / Build pull request (pull_request) Failing after 44s
eafa3eda79
Day lightest 0.92805 -> 0.928052 (true terrain peak 0.92805117...). The compass
refinement now halves to 5e-7 degrees; the drift test checks the constant against
the refined computation and an independent golden-section sweep, exact to
[extreme, extreme + 1e-6).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
void merged commit f0bad585b6 into dev 2026-11-09 23:35:25 +00:00
void referenced this pull request from a commit 2026-11-10 00:29:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Ratatoskr!48
No description provided.