Log inGet started
World

The Second Sun

Branchmain
Branchesmain
Commit32fbe997bb

README.md

secondsun.shore — the place

Stage 1 of THE SECOND SUN. The tidal flat, the lagoon, the sea and its drawdown and return, and everything standing on the ground.

local Shore = require("secondsun.shore")

Shore.tick(t, dt, frame)   -- the director calls this; nobody else does
Shore.waterlineZ(sea)      -- world Z the sea's edge stands at for a sea level
Shore.groundY(z)           -- ground height along the centreline, in metres
Shore.trees()              -- every standing conifer: { x, y, z, scale, lag }
Shore.ready()              -- whether the shore is standing yet

What it owns

the grounda 4 km square .terrainData raster at 5 m per cell: one 0.92 % seaward grade, a backshore rise the forest stands on, the land behind it, two octaves of relief, a sand bar and a drainage channel
the seaone Ocean (preset moonlit), its level driven from Film.seaLevel(t) and nothing else
the wet bandthe mirror-wet mud the retreating edge has just uncovered
the borethe wall the sea comes back as, riding the waterline the sea level puts there
what stands on it700 conifers, 110 coral heads, 70 driftwood logs, 26 ash rafts, 9 ripple rings, 48 outflow flecks, 12 trunks on the bore

Everything hangs off shore_root, a temporary child of the Shore anchor — the stage rebuilds itself from this module on every load, so a saved copy would come back beside the rebuilt one and the stand would double every session.

The one number

Film.seaLevel(t) is the only water fact this stage takes from outside itself. Where the waterline stands, where the wet band lies, how much of the channel is still running out and where the bore rides are all derived from it against the ground's own measured profile — sampled off the standing raster at build, not computed from the arithmetic that made it.

What another stage can read

Shore.trees() is the standing conifer edge, so the treefall front at BLAST can be driven without a second forest being placed. Shore.waterlineZ(sea) and Shore.groundY(z) answer where the ground and the edge of the sea are on any frame.

Notes for whoever touches this next

  • A terrain.ramp holds its end heights past both ends of its segment, over its whole width. Three of them chained along one axis do not make a piecewise profile — the last one wins over the entire raster. The grade here is one ramp over the whole rect; the backshore and the land behind it are terrain.ridge additions, and the channel's min cut is masked to the distance from its own centreline so it does not run on north as a trench through the forest.
  • The Ocean module's colour fields are parsed from CSS-style strings, not from { r, g, b } triples.
  • An Ocean outlives the entity that carried it, so clearShore releases every standing ocean by hand before it despawns anything.
  • The sea's level is written straight onto the ocean instance. configure merges a seaLevel into the config but the surface, the shoaling and the underwater effect all read the instance's own field, which only attach ever sets.