@margoengine/scenes 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +619 -2
  4. package/dist/dune-coast-info-D9yQIv8G.js +218 -0
  5. package/dist/dune-coast-info.d.ts +3 -0
  6. package/dist/dune-coast.d.ts +179 -0
  7. package/dist/dune-coast.js +778 -0
  8. package/dist/errors-fc4i1pSL.js +7 -0
  9. package/dist/fauld-blast.d.ts +165 -0
  10. package/dist/fauld-blast.js +1034 -0
  11. package/dist/fauld-countryside.d.ts +13 -0
  12. package/dist/fauld-countryside.js +10 -0
  13. package/dist/fauld-crater.d.ts +13 -0
  14. package/dist/fauld-crater.js +10 -0
  15. package/dist/fauld-dig.d.ts +89 -0
  16. package/dist/fauld-dustfall-fines-grid-MA6XPrq6.js +14 -0
  17. package/dist/fauld-dustfall-fines-grid.d.ts +11 -0
  18. package/dist/fauld-dustfall-grid-Bb4X8b-u.js +14 -0
  19. package/dist/fauld-dustfall-grid.d.ts +11 -0
  20. package/dist/fauld-explosion.d.ts +135 -0
  21. package/dist/fauld-grains.d.ts +27 -0
  22. package/dist/fauld-mud.d.ts +104 -0
  23. package/dist/fauld-surge.d.ts +71 -0
  24. package/dist/fauld-tunnels-info-8qv9X4OJ.js +70 -0
  25. package/dist/fauld-tunnels-info.d.ts +5 -0
  26. package/dist/fauld-tunnels-plan.d.ts +1069 -0
  27. package/dist/fauld-tunnels.d.ts +281 -0
  28. package/dist/fauld-tunnels.js +6801 -0
  29. package/dist/fauld-world-CNNSonJF.js +863 -0
  30. package/dist/fauld-world-info.d.ts +7 -0
  31. package/dist/fauld-world.d.ts +243 -0
  32. package/dist/index.d.ts +53 -0
  33. package/dist/index.js +160 -0
  34. package/dist/library-mesh-CjTG-mVZ.js +329 -0
  35. package/dist/library-mesh.d.ts +108 -0
  36. package/dist/library-parts.d.ts +55 -0
  37. package/dist/library.d.ts +52 -0
  38. package/dist/library.js +48 -0
  39. package/dist/look-family.d.ts +63 -0
  40. package/dist/look-family.js +57 -0
  41. package/dist/shared/settings.d.ts +89 -0
  42. package/dist/shot-settings.d.ts +40 -0
  43. package/dist/shot-settings.js +94 -0
  44. package/dist/timber-valley-info-vVI2nwDs.js +253 -0
  45. package/dist/timber-valley-info.d.ts +3 -0
  46. package/dist/timber-valley.d.ts +229 -0
  47. package/dist/timber-valley.js +424 -0
  48. package/package.json +104 -4
package/README.md CHANGED
@@ -1,3 +1,620 @@
1
- # Temporary Holding Version
1
+ # @margoengine/scenes
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Ready places in one call. Each scene composes the engine's own packages (terrain, sky, water, scatter, procedural,
4
+ shadows, post) at their best settings, and every look value is a documented setting with a default, a range and a
5
+ unit. The root is the catalogue, plain data that loads no package; each scene is its own entry.
6
+
7
+ ```ts
8
+ import {scenes, sceneInfo} from 'margoengine/scenes';
9
+ console.log(scenes.map((s) => s.name), sceneInfo('dune-coast').settings.hour.default); // ['dune-coast'] 10.6
10
+ ```
11
+
12
+ ## Assets by id and per-shot settings: `@margoengine/scenes/library`, `@margoengine/scenes/shot-settings`
13
+
14
+ A scene asks for a model or a sky by id; the library says where its file is. `node tools/library-index.mjs <folder>` writes `library.json` in an asset folder (`<subject>/<kind>/<id>/<id>_2k.gltf` for models, `<subject>/hdri/<id>_2k.hdr` for skies; textures sit beside their model; the folder is never in git). `fetchLibrary(root, {signal})` reads and checks it, `parseLibrary(data, root)` checks an index you already have (a repeated id, an unknown type, or a path that is absolute or climbs out of the root throws `RangeError` naming the asset), `assetUrl(library, id)` gives the file URL and `findAssets(library, {subject, kind, type})` lists. With no library a scene draws its procedural pieces and fetches nothing.
15
+
16
+ `checkShotSettings(block, tables, seconds)` and `shotSettingsAt(block, tables, seconds)` give each shot its own settings. A block is `{target: {row: value | {keys: [{time, value, ease}]}}}`; `tables` maps each target to a package settings table (`WEATHER_SETTINGS`, `SKY_SETTINGS`, `TONEMAP_SETTINGS`, ...), so the packages stay the only source of rows. A plain value holds for the whole shot; keys move a number through each key's ease (`linear`, `in`, `out`, `inOut`), a colour per channel in linear RGB, a gradient stop by stop when both keys have the same stops; a choice, a null and a gradient with other stops step at each key; before the first key and after the last the nearest holds. Only `live` rows can be keyed; a held row that is not live (`shotHeldRebuilds`) is written once before the warm-up. The check names the target and row for an unknown name, a value out of range (the package's own rule), a null on a row that is not nullable, a keyed row that is not live, or key times that do not rise or leave `[0, seconds]`. `SceneInfo` gains optional `looks`, `shots` (each with `settings`) and `targets` (target name to package entry).
17
+
18
+ ```ts
19
+ import {checkShotSettings, shotSettingsAt} from 'margoengine/scenes/shot-settings';
20
+ import {WEATHER_SETTINGS} from 'margoengine/weather/settings';
21
+ import {TONEMAP_SETTINGS} from 'margoengine/tonemap/settings';
22
+
23
+ const tables = {weather: WEATHER_SETTINGS, tonemap: TONEMAP_SETTINGS};
24
+ const shot = {tonemap: {'tonemap.exposure': {keys: [{time: 0, value: -1}, {time: 8, value: 0.5, ease: 'out'}]}}};
25
+ checkShotSettings(shot, tables, 8);
26
+ console.log(shotSettingsAt(shot, tables, 4).tonemap['tonemap.exposure']);
27
+ ```
28
+
29
+ ## Dune coast: `@margoengine/scenes/dune-coast`
30
+
31
+ A winter barrier-island coast. The defaults are Kill Devil Hills, North Carolina, on 17 December 1903 at 10:35, the
32
+ morning of the first powered flight: a bare sand flat around the launch rail, low hummocks with sparse winter grass
33
+ around it, the big dune 430 m to the south (30 m, windward side toward the camp), two smaller dunes, the camp's two
34
+ board sheds, the 60 ft launch rail, the foredune and the winter Atlantic surf 900 m to the east, under a grey sky
35
+ with a north wind. x is east, z south, y up, metres, sea level at y = 0; the rail's south end is at the origin.
36
+
37
+ ```ts
38
+ import {Engine} from 'margoengine';
39
+ import {attach} from 'margoengine/scenes/dune-coast';
40
+ const canvas = document.querySelector('canvas')!;
41
+ const engine = await Engine.create(canvas, {camera: {near: 0.3, far: 30000}});
42
+ const scene = attach(engine, {weather: 'overcast', wind: 11, blownSand: 0.5});
43
+ await scene.ready; // the blown sand loads on demand; await before the first frame you keep
44
+ scene.view('first-flight');
45
+ console.log(scene.height(0, 0).toFixed(1), Object.keys(scene.anchors).length); // ground at the rail, anchors
46
+ ```
47
+
48
+ `attach(engine, settings)` builds the ground (one mesh, from `@margoengine/terrain/dunes`: hummocks, `duneHill` dunes,
49
+ the foredune and a beach of 1 in 28 above the water and 1 in 50 below), sand colours with a wet band that follows the
50
+ surf (`TerrainColors` wetness), the sky, fog, bloom and tone curve of the weather's `PresetScene` with the sun put
51
+ where it was for the date and hour (`sunPath`), shadows, the sea (`Water` coupled to the beach), the dune grass
52
+ (`GrassScatter` from `@margoengine/scatter/grass`: clumps of 30 arching blades, 0.4 to 1 m, straw with olive bases,
53
+ swaying in the wind, on a grid that follows the camera out to 230 m) and the camp (`generatePlankShed`, `generateLaunchRail` from `@margoengine/procedural/sheds`). The handle
54
+ gives `height(x, z)`, named `anchors` and `views` (`view(name, fov)` moves the engine camera there),
55
+ `advanceTime(seconds)` for film frames (sky, sea and grass sway), the `parts` (the PresetScene, the water, the
56
+ shadows, the grass, the occlusion pass) and `dispose()`. A gltf/pbr model placed in the scene joins the shadows with
57
+ `scene.parts.shadows.add(model.root, {})` and the occlusion with `scene.parts.occlusion?.add(model)`. `ground(settings)` gives the same height function with no engine, for placing
58
+ subjects and cameras, and `grassCover(settings)` where the grass grows, 0 (bare sand) to 1 (a full clump):
59
+
60
+ ```ts
61
+ import {ground} from 'margoengine/scenes/dune-coast';
62
+ const height = ground();
63
+ console.log(height(0, 0).toFixed(1), height(-40, 430).toFixed(1), height(900, 0).toFixed(1)); // rail, big dune crest, waterline
64
+ ```
65
+
66
+ ```ts
67
+ import {grassCover} from 'margoengine/scenes/dune-coast';
68
+ const cover = grassCover({grass: 0.5});
69
+ console.log(cover(-40, 0).toFixed(2), cover(-40, 430), cover(900, 0)); // the flat, the bare dune crest, the wet beach
70
+ ```
71
+
72
+ The camp yard is bare, trodden sand: no grass grows inside the hangar and the shed or within a metre of them
73
+ (x -98 to -60.5, z 26 to 34), also when `camp: false` leaves the buildings to a film's own models at the same place.
74
+
75
+ The grass follows the ecology of American beachgrass (Ammophila breviligulata): it grows where blown sand buries it
76
+ and spreads in clumps, and the sand it traps builds the hummocks, so hummock tops carry the most and the hollows the
77
+ least (Hesp 2002, "Foredunes and blowouts: initiation, geomorphology and dynamics", Geomorphology 48; Maun 2009, *The
78
+ Biology of Coastal Sand Dunes*). None grows on the beach and wet band below 1.2 m or on the dunes above about 9 m,
79
+ which were bare moving sand in 1903 (LC-W86-120, LC-W85-110). Clumps stand in patches 3 to 10 m across, in groups,
80
+ with a lone clump between them; `grass` sets the share of ground in patches.
81
+
82
+ The page `examples/dune-coast/index.html` shows the scene and is ready for the shot tool (tools/shot): it takes
83
+ `view`, `fov` and any setting as URL options, sets `#viewport[data-ready="true"]` 30 frames after `scene.ready` and exposes
84
+ `window.duneCoast = {engine, scene}` (shot `page.engine`: `duneCoast.engine`).
85
+
86
+ | Setting | Default | Range or values | Meaning |
87
+ | --- | --- | --- | --- |
88
+ | `date` | `'1903-12-17'` | `YYYY-MM-DD` | the day, for the sun's place |
89
+ | `hour` | 10.6 | 0 to 24 h | local solar time (10:35 eastern time at 75.67 W) |
90
+ | `latitude` | 36.02 | -90 to 90 deg | degrees north |
91
+ | `weather` | `'overcast'` | `'overcast'`, `'clear'` | the photographs' grey sky and soft light, or sun and broken cloud |
92
+ | `visibility` | 6000 | 500 to 50,000 m | haze distance |
93
+ | `wind` | 11 | 0 to 25 m/s | wind speed: grass sway, whitecaps, chop and the wind sea |
94
+ | `windFrom` | 0 | 0 to 360 deg | compass direction the wind blows from; dunes face away from it |
95
+ | `sand` | [0.52, 0.46, 0.35] | linear RGB | dry sand albedo |
96
+ | `grass` | 0.5 | 0 to 1 | share of the ground in grass patches, most on the hummocks (0 removes it) |
97
+ | `grassColor` | [0.36, 0.31, 0.16] | linear RGB 0 to 1 | dune grass albedo (winter straw with olive bases) |
98
+ | `grassHeight` | 0.8 | 0.2 to 2 m | tallest grass leaf |
99
+ | `grassBlades` | 30 | whole number 4 to 64 | leaves to a clump |
100
+ | `grassVariety` | 0.035 | 0 to 0.2 | hue spread between clumps: straw and olive clumps side by side |
101
+ | `grassTranslucency` | 0 | 0 to 1 | sunlight seen through the leaves (`GrassScatter` `blades.translucency`), so a field against a low sun reads as thin leaves |
102
+ | `grassWidth` | 0.016 | 0.004 to 0.05 m | leaf width at the root |
103
+ | `hill` | 30 | 0 to 40 m | crest of the big dune above the flat |
104
+ | `crest` | 0 | 0 to 1 | sharpness of the big dune's brink: 0 rounds it over a third of its height (a settled crest), 1 over a twentieth (a crest the wind is building) |
105
+ | `sandBands` | 0 | 0 to 1 | broad scour bands along the wind on the sand (`TerrainColors` `sandSurface.broad`), seen at any distance |
106
+ | `surf` | 1.2 | 0 to 3 m | swell height at the beach (0 removes the sea) |
107
+ | `camp` | true | | the sheds and the rail |
108
+ | `boards` | [0.258, 0.205, 0.147] | linear RGB 0 to 1 | albedo of the sheds' wall boards and the rail (the `weatheredWood` preset) |
109
+ | `roof` | [0.258, 0.205, 0.147] | linear RGB 0 to 1 | albedo of the sheds' roof boards |
110
+ | `shedOverhang` | 0.2 | 0 to 1 m | roof overhang past the shed walls |
111
+ | `shedWeathering` | 0.5 | 0 to 1 | board tilts, uneven ends and gaps |
112
+ | `shedWindows` | false | | two windows in the hangar's back wall and one in each shed's end wall |
113
+ | `occlusion` | 1.5 | 0 to 10 m | reach of the ambient occlusion (`GTAO` of `@margoengine/post`, first in the post stack; 0 for none): the eaves, battens, rail and grass feet shut out the grey sky's light |
114
+ | `heights` | built landform | `{samples, width, depth, cellSize, origin, sea}` | real heights, such as a USGS 3DEP 1 m bare-earth grid (heights at or below `sea` are lowered under the water) |
115
+ | `footprints` | 1 | 0 to 1 | footprints trodden between the sheds, to the launch rail and along it, 4.5 cm deep at 1 (`TerrainDeformation` of `@margoengine/terrain/deform` on the ground mesh; they show within 45 m of the camera and need `camp`; `scene.parts.footprints?.walk(points)` lays more) |
116
+ | `scour` | 1 | 0 to 1 | sand the wind has shaped (`windScour` of `@margoengine/terrain/scour`): with `camp`, a moat along the sheds' windward walls and flanks, a deposit horseshoe in front and two tails; with `grass`, shadow dunes behind grass clumps round the camp and the rail; none at 6.6 m/s or less. `scene.height` includes it, and the ground mesh is split finer there |
117
+ | `blownSand` | 0 | 0 to 1 | sand blowing off the crests and over the dry sand (`BlownSand` from `@margoengine/vfx/blown-sand`), wherever the wind with its gusts is over 6.6 m/s; none on the wet beach or in the grass |
118
+ | `quality` | `'film'` | `'film'`, `'preview'` | ground cells, sea segments, shadow map and grass count |
119
+ | `seed` | 1903 | | seed of the hummocks and small dunes |
120
+
121
+ Presets (`info.presets`): `first-flight` (the defaults), `clear-morning`, `calm-summer`. Anchors: `rail`, `camp`,
122
+ `flightLine`, `bigHill`, `beach`. Views: the six Library of Congress photographs' camera places (`first-flight`,
123
+ `camp-buildings`, `killdevil-from-flat`, `flyer-on-rail`, `killdevil-back`, `landing-rail-view`), `surf` and `crest` (the big dune's crest seen side on, the wind blowing across the view).
124
+
125
+ Sources for the layout: Library of Congress, Wright Brothers negatives LC-W861-35, LC-W86-15, LC-W86-21, LC-W86-38,
126
+ LC-W86-120 and LC-W85-110 (public domain, https://www.loc.gov/pictures/collection/wri/); USGS 3D Elevation Program
127
+ 1 m bare-earth heights (public domain, https://www.usgs.gov/3d-elevation-program) for the distances from the camp flat
128
+ to the hill and the shore; McFarland (ed.) 1953, *The Papers of Wilbur and Orville Wright*, for the hangar and the
129
+ rail. The ground, the sky and the sea come from their packages' own sources (terrain/dunes, sky/sun, water).
130
+
131
+ ## Fauld tunnels: `@margoengine/scenes/fauld-tunnels`
132
+
133
+ The RAF Fauld underground bomb store in Staffordshire (the explosion of 27 November 1944): the arched gypsum bays with
134
+ their racks of 1,000 lb and 500 lb bombs, the narrow-gauge rails and trolleys, the brick blast walls, the work bay, the
135
+ timbered Old Mine roadways beyond, and the portal yard in the hillside. Plan metres (+x into the hill, +y north, z up)
136
+ map to Margo as (x, z, -y). Every model is a library glTF with full PBR maps (`<library>/fauld-1944/tunnels/<id>`,
137
+ converted from the film's kit in Blender), drawn once each and repeated by GPU instancing.
138
+
139
+ ```ts
140
+ import {dressState, FAULD_STATE_EV, FAULD_TUNNEL_STATES} from 'margoengine/scenes/fauld-tunnels';
141
+ const working = dressState('working');
142
+ console.log(FAULD_TUNNEL_STATES.length, working.lamps.length, FAULD_STATE_EV.working); // 10 55 2
143
+ ```
144
+
145
+ `attach(engine, settings)` (async) loads the state's models and draws them with clustered lights: each bulkhead bulb
146
+ a 2700 K lamp of the lighting plan's catalogue (40 W 400 lm, 60 W 690 lm, 100 W 1,250 lm, light output 0.65, lower
147
+ hemisphere only) in candela, hand lamps as 40 lm cones standing on the floor in their `tn_handlamp` fitting (the film has
148
+ no people, so no lamp hangs in the air at chest height; `HANDLAMP_ASSET`, `HANDLAMP_STAND`), the nearest and brightest lamps shadowed (`LocalShadows` with
149
+ `shadowBudget`, 16 in `film`, 8 in `preview`), one `LightBounce`, a glowing bulb at each fitting (`flameEmission`),
150
+ lamp-lit `VolumetricFog` (gypsum dust, or smoke after the blast and in the fire), `Fire` and `Smoke` of the state
151
+ (each smoke column added to the fog, so the lit air lies in front of it: `packages/scenes/test/fauld-smoke-fog.mjs`),
152
+ and a `PostStack` of `GTAO`, `DOF`, `Bloom`, an AgX `Tonemap` white-balanced to 3200 K at the state's one metered
153
+ exposure (`FAULD_STATE_EV`, EV100) and `SMAA`. The yard states use the overcast `PresetScene` sky. `frame(position,
154
+ target, focal, stop)` sets the camera, its field of view on a 36 mm gate and the focus; `advanceTime(seconds)` runs
155
+ the fires; `counts`, `parts` and `dispose()` as the other places. Every fire stands on clear floor: `dressState`
156
+ returns the state's `solids` (the plan boxes of the stacks, bomb rows, trolleys, walls and other solid pieces, from the
157
+ measured `FAULD_SOLIDS` bounds), and `clearFire` moves a fire that would stand in one the least way out of it:
158
+
159
+ ```ts
160
+ import {clearFire, dressState} from 'margoengine/scenes/fauld-tunnels';
161
+ const {solids} = dressState('fire');
162
+ console.log(clearFire(61, -9, 0, 0.6, solids)); // [61, -8.4]: beside the casing stack, not inside it
163
+ ```
164
+
165
+ The page `examples/fauld` draws one row of the
166
+ film's shot list (`tools/shot/shots/fauld-frNNN.json`) and `examples/fauld/stills.mjs` renders their stills.
167
+
168
+ | Setting | Default | Range or values |
169
+ | --- | --- | --- |
170
+ | `state` | `working` | `working`, `blast`, `fire`, `after`, `flooded`, `sealed`, `yard_day`, `yard_night`, `yard_fire`, `yard_sealed` |
171
+ | `time` | 0 | 0 to 600 s of fire and smoke |
172
+ | `quality` | `film` | `film` (16 shadowed lamps, 1,024 maps), `preview` (8, 512) |
173
+ | `library` | `/asset-library/` | the URL root of the asset library |
174
+
175
+ Sources: the film's reference bible and lighting plan (fauld-reference-bible.md and fauld-tunnel-lighting-plan.md);
176
+ the store's records at Kew (AIR 17/8, 17/10, 17/12, plan MFQ 1/1003); McCamley, *Disasters Underground* (2004);
177
+ Waltham 2001, *Mercian Geologist* 15(2), 123 to 125, for the white gypsum about 35 m down; the Osram-GEC 60 W 240 V
178
+ coiled-coil lamp, 690 lm at 2700 K (lamptech.co.uk); Lagarde and de Rousiers 2014, *Moving Frostbite to PBR*, s5.1,
179
+ for EV100 metering. Fauld's own lamp wattage and spacing are not on record online, so the rig follows period practice.
180
+
181
+ ## Timber valley: `@margoengine/scenes/timber-valley`
182
+
183
+ A northern Rockies mountain valley in the 1910 fires (the Big Burn of 20 and 21 August 1910, Idaho and Montana). The
184
+ defaults are the blowup afternoon of 20 August 1910 round Wallace, Idaho: a level floor 870 m up with the creek and the
185
+ rail grade on it, walls of about 30 degrees cut into side gulches (`rockiesValleyWorld` of `@margoengine/biomes`, a
186
+ 4 km world), western white pine, larch, red cedar, Douglas-fir and grand fir on them, a mining and railway town laid out
187
+ as lots in two places along the line, and a fire that has run for 30 minutes under a 20 m/s south-west gale, with smoke
188
+ columns, flames on the hottest stretches of the front and embers. x is east, z south, y up, metres; the valley drains
189
+ west out of the world's west edge.
190
+
191
+ ```ts
192
+ import {layout, world} from 'margoengine/scenes/timber-valley';
193
+ const w = await world({seed: 1910});
194
+ const plan = layout(w, {houses: 48});
195
+ console.log(plan.structures.length > 0, plan.rail.length > 100); // true true: town lots, and the rail line up the valley
196
+ w.dispose();
197
+ ```
198
+
199
+ `attach(engine, settings)` (async) builds the world and draws it with `BiomeView` (terrain, the forest by species with
200
+ LOD rings, the creek's water, rocks and ground cover; nothing is placed on the rail, the creek or the lots), the sky,
201
+ bloom and tone curve of a `PresetScene` with the sun where it was for the date and hour, `VolumetricClouds`, shadows, a
202
+ `GTAO` occlusion pass, one `WeatherMachine` and a `WeatherDrive` that writes the wind, cloud and smoke haze into every
203
+ part and dries the fire's dead fuel from the weather's humidity and temperature, the fuel map of the forest
204
+ (`fuelMap`, Anderson's models 8 and 10 under timber, 1, 2 and 5 in the openings, none on the rail, the creek and the
205
+ streets) and a `FireFront` on it with the town lots as structures. The look family (`look`, default `animatedFeature`)
206
+ is written through each package's settings (the sky and clouds, the ground materials, the creek's water and the fire).
207
+ The cumulus stand 2.5 to 4 km over the valley floor, and the terrain's fine rings follow the camera, so a view
208
+ anywhere along the valley keeps the creek's channel. The handle gives `height`, `anchors`, `views` and `view(name, fov)`,
209
+ `shots` (eight, from the catalogue) and `tracks` (a camera track per shot for `shotFilesFromScene` of `tools/shot`),
210
+ `targets`, `layout`, `applyLook(name)`, `applySettings({weather, sky, fire})` for per-shot rows, `advanceTime(seconds)`
211
+ (fire and sky), `settle()` (the forest tiles around the camera), the `parts` and `dispose()`.
212
+
213
+ At `film` quality the scene attaches `TAA` from `@margoengine/taa` (`parts.taa`, its defaults: history weight 0.9 and
214
+ the silhouette history of KB-TAA-EDGE1) on the post stack's depth, and gives it every swaying scatter of the forest
215
+ (`BiomeObjects.swaying`) as a `ScatterVelocity` pass from `@margoengine/scatter/velocity`, so swaying needles and grass
216
+ keep their history. The flames, smoke, rain and the creek mark their own pixels reactive, so they show each frame as
217
+ drawn, and the clouds' march moves its start each frame (`temporal: 'auto'`). History needs about 53 frames to settle
218
+ (`ln 255 / ln(1 / 0.9)`): a film render draws that many from the shot's first instant before frame 0.
219
+ After TAA's resolve, `MotionBlur` from `@margoengine/post/motion-blur` (`parts.motionBlur`, the reconstruction filter of
220
+ McGuire et al. 2012) blurs the frame along TAA's velocity with a 180 degree shutter (`options.shutter` 0.5). A shot drawn
221
+ in sub-frames sets that shutter per sub-frame through the shot tool's `page.shutter` hook (`timberShot.shutter`), so each
222
+ sub-frame blurs over its own slice of the shutter and a fast near branch shows one smear, not eight stepped copies
223
+ (KB-LOOK-TV-SUBSTEP1).
224
+
225
+ | Setting | Default | Range or values |
226
+ | --- | --- | --- |
227
+ | `date`, `hour`, `latitude`, `longitude` | `1910-08-20`, 16, 47.47, -115.93 | the sun's place by `sunPath` and the moon's by `moonPosition`; with the sun below the horizon the sky is a moonlit night (`sunScene`) |
228
+ | `look` | `animatedFeature` | `animatedFeature`, `natural` |
229
+ | `weather` | `blowup` | `calm` (2 m/s), `redFlag` (9 m/s, 15 percent humidity, 32 C), `blowup` (20 m/s gusting, 12 percent, 30 C), `smoke` (a day under wildfire smoke, the load of `WEATHER_LOOKS.wildfireSmoke`: about 1.6 km of visibility) |
230
+ | `windFrom` | 225 | 0 to 360 degrees, the compass direction the wind blows from |
231
+ | `fire` | `running` | `none`, `running` (for `fireTime` seconds), `burnt` (run until nothing burns: `burnOut`, days of fire time; the film grid takes about 11 minutes to build) |
232
+ | `fireTime` | 1,800 | 0 to 21,600 s |
233
+ | `grassMoisture` | 0.3 | 0.3 to 2.5, live herbaceous fuel moisture (dry weight): the share of cured, straw blades (`herbaceousCuring` of `@margoengine/biomes/fuel`; 0.3 all cured, the 1910 drought; 1.2 and above all living) |
234
+ | `houses` | 48 | 0 to 256 lots |
235
+ | `meshes` | none | library models by species key (`BiomeViewOptions.meshes`) |
236
+ | `quality` | `film` | `film` (2 km of objects, 4 m fire cells, temporal anti-aliasing), `preview` (1 km, 8 m, none) |
237
+ | `seed` | 1910 | the valley, the forest, the town and the embers |
238
+ | `standSeed` | 0 | 1 or more restocks the forest on the same valley (where trees stand and their meshes, `BiomeViewOptions.standSeed`); 0 the valley's own |
239
+
240
+ Presets: `blowup` (the defaults), `calm-august` (no fire, late morning), `red-flag` (ten minutes of fire on a red-flag
241
+ afternoon), `aftermath` (two days later, the fire burned out, under smoke). The town draws no buildings: its 1910 frame
242
+ and brick blocks, depot, mine works and locomotive have no models yet; the lots are laid out, burn as structures and
243
+ keep the forest off. `libraryMesh(url, options)` of `@margoengine/scenes/library` loads a library glTF as one mesh part
244
+ (base on the ground) for `meshes`, so a rock or plant model draws by key. A model whose material has a base colour map
245
+ keeps its maps: the part carries `textures` (its uvs and its base colour, normal and occlusion-roughness-metal images)
246
+ and draws textured; one of several textured materials goes to `libraryParts` (a coded `unsupported` error says so).
247
+ Pass `color` to draw it as one flat colour instead, as here:
248
+
249
+ ```ts
250
+ import {libraryMesh} from 'margoengine/scenes/library';
251
+ const files: Record<string, unknown> = {
252
+ 'r.gltf': {asset: {version: '2.0'}, buffers: [{uri: 'r.bin', byteLength: 78}],
253
+ bufferViews: [{buffer: 0, byteLength: 72}, {buffer: 0, byteOffset: 72, byteLength: 6}],
254
+ accessors: [{bufferView: 0, componentType: 5126, count: 3, type: 'VEC3'},
255
+ {bufferView: 0, byteOffset: 36, componentType: 5126, count: 3, type: 'VEC3'},
256
+ {bufferView: 1, componentType: 5123, count: 3, type: 'SCALAR'}],
257
+ meshes: [{primitives: [{attributes: {POSITION: 0, NORMAL: 1}, indices: 2}]}], nodes: [{mesh: 0}]},
258
+ };
259
+ const bin = new ArrayBuffer(78);
260
+ new Float32Array(bin, 0, 18).set([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1]);
261
+ new Uint16Array(bin, 72, 3).set([0, 1, 2]);
262
+ const fetch = async (url: string) =>
263
+ ({ok: true, status: 200, json: async () => files[url], arrayBuffer: async () => bin});
264
+ const rock = await libraryMesh('r.gltf', {fetch, color: [0.3, 0.29, 0.27]});
265
+ console.log(rock.geometry.indices.length / 3, rock.kind); // 1 stone
266
+ // attach(engine, {meshes: {'procedural:rock': [rock]}}) draws it in place of the procedural rock.
267
+ ```
268
+
269
+ `libraryParts(url, options)` loads a scanned model with its textures instead: one part per glTF material, each with its
270
+ TEXCOORD_0 (KHR_texture_transform applied), base colour, normal and metallic-roughness images (R read as occlusion, the
271
+ packing of Poly Haven scans), MASK and BLEND materials and names with twig, leaf or needle as `foliage` with an alpha
272
+ cut-out. Three URLs (near, middle and far levels of one model) give each part a geometry per LOD ring. Or give one URL
273
+ and `foliageTriangles: [near, middle, far]`: each foliage part's levels are made by `foliageLODs` of
274
+ `@margoengine/scatter/foliage`, which removes whole needles and grows the rest until each level covers what the model
275
+ covers, where an edge-collapse decimation leaves a skeleton; `node` reads one model of a file holding several (the whole
276
+ scan: `libraryParts('/asset-library/big-burn-1910/plants/fir_tree_01/fir_tree_01_2k.gltf', {node:
277
+ 'fir_tree_01_a_LOD0', foliageTriangles: [76000, 8000, 2000]})`, a 480 MB download). Scans are heavy:
278
+ decimate their wood into levels first (the 1910 conifer is `plants/fir_tree_01/forest/fir_tree_01_a_{near,middle,far}.gltf`
279
+ in the asset library, 90,000, 20,000 and 11,371 faces).
280
+
281
+ ```ts
282
+ import {libraryParts} from 'margoengine/scenes/library';
283
+ const base = '/asset-library/big-burn-1910/plants/fir_tree_01/forest/fir_tree_01_a';
284
+ const load = () => libraryParts([base + '_near.gltf', base + '_middle.gltf', base + '_far.gltf']);
285
+ // attach(engine, {meshes: {'procedural:douglas-fir/pole': await load()}}) draws the scanned fir as every Douglas-fir.
286
+ console.log(typeof load); // function
287
+ ```
288
+
289
+ Sources: Pyne, *Year of the Fires: The Story of the Great Fires of 1910*, 2001 (the blowup, the south-west gale, the
290
+ burning of part of Wallace); Koch, "History of the 1910 forest fires in Idaho and western Montana", USDA Forest Service,
291
+ 1942. The valley, forest, fuel and fire come from their packages' own sources (biomes docs/relief-and-hydrology.md and
292
+ docs/fuel.md, vfx fire-front).
293
+
294
+ ## Fauld, Staffordshire: `@margoengine/scenes/fauld-countryside` and `@margoengine/scenes/fauld-crater`
295
+
296
+ The hills round Hanbury and Fauld on the real ground (Ordnance Survey OS Terrain 50, tiles SK12, SK13, SK22 and SK23,
297
+ resampled to 5 m; Open Government Licence v3.0, "Contains OS data (c) Crown copyright and database right"), the farm
298
+ quilt of `@margoengine/biomes/farmland` (hedged fields, hedge oaks, ashes and hollies, lanes that end at a junction, the
299
+ edge or a gate), hedgerows and woods grown by the biome view from library trees with Poly Haven bark maps, fields,
300
+ lanes, mud and woodland floor from Poly Haven ground scans (CC0) at their own repeats, and an overcast late-November
301
+ sky, clouds and weather calibrated to photographs of the area; the haze lies in the boundary layer, thinning by e
302
+ every 500 m over the ground round the subject (`FAULD_HAZE_SCALE_HEIGHT`, the sky fog's `scaleHeight`), so drone views
303
+ look down through thin air. The fields' albedo is measured (`FAULD_GROUND_LOOKS`: @margoengine/materials' ECOSTRESS green
304
+ grass for the pasture, dry grass for the stubble, half each for the rough meadow, and the Mercia Mudstone's reddish soil
305
+ for the plough, the mud and the earth the blast throws over the fields) and the soil is wet: November ground at field
306
+ capacity keeps `FAULD_WET_SOIL`, 0.62, of its dry albedo (Lekner and Dorf 1988; Lobell and Asner 2002). Set by eye,
307
+ the pasture had been about twice the measured grass. `fauld-crater` shows the 1944 crater (`era: '1944'`, bare marl and gypsum) dug by physics
308
+ into the filled ridge and settled (`fauldDig` with the ground: EARTH-06's crater, its blocks' secondaries and its
309
+ blanket's rays, drawn by the terrain's GroundChange, cameras and props standing on the changed ground), or the wooded
310
+ hollow today (`era: 'today'`) stamped into the terrain from its model's heights. The blocks it threw lie where they came
311
+ to rest, half buried: one in five the store's white gypsum (`fauldGypsum`), drawn with the library's four gypsum blocks
312
+ scaled to each (white alabaster with thin marl partings, baked onto them by
313
+ `examples/assets/blender-library/fauld/bake_gypsum.py`), the rest red-brown mudstone as rock_07. In 1944 the clipmap has
314
+ twice its default vertices, so the rim seen from the bowl is not cut into straight segments. Every 1944 shot is
315
+ sight-checked by `tools/shot/fauld-shots.mjs` over this dug ground, its landed blocks and the plants its covers leave.
316
+ fr062 starts inside the bowl, looking across its floor to the far wall. fr065 starts at the nearest gypsum block of
317
+ about a tonne. Both then go through the normal search. In 1944 the column's sand lies on the
318
+ fields as well, grey where it is thick (the terrain's `fall` event):
319
+ - The lofted mass is graded by the Mercia Mudstone's measured grading into four sand classes, 0.06 to 4 mm
320
+ (`FAULD_SAND`).
321
+ - `fauldExplosion({ dust: true })` carries it up FIRE-03's column and down through ATMO-06's deposit field, in the scene's
322
+ wind with the day's boundary-layer turbulence.
323
+ - `node tools/shot/fauld-dustfall.mjs` runs that for 30 minutes of film and writes `src/fauld-dustfall-grid.ts`.
324
+
325
+ The column's colour comes from its load. FIRE-03's `plumeAlbedo` takes all the TNT's soot (Ornellas's yield) and
326
+ the dust its yield lofts as red-brown dust (physics/plume `burstDust`, NRC 1985's 0.3 kg a kg: 1,200 t, `FAULD_LOAD`'s
327
+ 0.04 % of the crater's mass; iron oxide 3 %, a model choice; see docs/limits.md, Plumes), giving a near-black cloud
328
+ (albedo about 0.1). The sand and silt that fall from it (`FAULD_SAND`, `FAULD_FINES`) are that same share. It is lit so that a puff's colour is its reflectance: a white puff's
329
+ top matches the overcast sky at the horizon and no more, as a matte surface under an even sky does (the Clouds' light at a
330
+ fifth of the scene's old setting). So the column reads darker than the sky, as the witnesses' smoke did.
331
+
332
+ The scene's wind is the day's (`FAULD_WIND`), from the Met Office's Daily Weather Report for 27 November 1944. A ridge of
333
+ high pressure was crossing the Midlands and the night's northerly was dying. Honiley and Cranfield had N to NNW at force
334
+ 1 to 2, and Ashbourne, 19 km north, was calm at noon. The scene takes 1.5 m/s from 345 degrees, so the column drifts
335
+ slowly south-south-east. The silt (0.006 to 0.06 mm, `FAULD_FINES`, `fauldExplosion({ dust: 'fines' })`) falls over hours.
336
+ `node tools/shot/fauld-dustfall.mjs --grains=fines` runs four hours of film and keeps the ground as it lay an hour after
337
+ the blast, which the 1944 places lay beside the sand. By then 2,545 t is down, on 1.6 km^2 of the rising fields 0.8 to 3
338
+ km south-south-east (at most about 10 kg/m^2), 5,479 t is aloft and 2,527 t has drifted past the
339
+ world's edge; by four hours none is aloft and 8,006 t is gone. The sand by 30 minutes: 8,470 t down on 1.5 km^2 round the
340
+ crater and south-south-east of it, 1,305 t still aloft. The finer clay and fine silt stays aloft for days and is not
341
+ carried. Hanbury, the works and the farms north of the crater get none of either: the dust that fell for hours over
342
+ miles, in the accounts, falls south-south-east of these places in the day's light north-north-west wind. Before the blast
343
+ (`era: 'before'`, the default) there is no crater: the survey is modern and holds today's hollow, so the disc 200 m round
344
+ the centre is filled with the harmonic surface its edge sets (the Poisson integral, 128 samples of the ground round it),
345
+ easing back into the survey from 160 m, and the farm stands on its ridge. Models, scans and
346
+ the height grid are served from `library` (default `/asset-library/`, which holds `margo-library/fauld/` and `dem/`);
347
+ the buildings, the fire tender, the WVS van and a grazing herd stand in their slots (`FAULD_SLOTS`, each with its eras),
348
+ from Tripo models decimated to real size in `margo-library/fauld/buildings/`, drawn by `@margoengine/gltf/textured`
349
+ with their base colour maps and stood on the ground; shots keep them 150 m or more away. Origin: the crater's centre,
350
+ OS grid E 418225, N 327725; x east, z south.
351
+
352
+ ```ts
353
+ import { Engine } from 'margoengine';
354
+ import { attach, FAULD_PLACES, FAULD_SLOTS } from 'margoengine/scenes/fauld-countryside';
355
+
356
+ // Needs the asset library served at /asset-library/ (the OS Terrain 50 grid and the crater and tree models).
357
+ async function show(canvas: HTMLCanvasElement) {
358
+ const engine = await Engine.create(canvas, { camera: { far: 40000 } });
359
+ const scene = await attach(engine, { sky: 'dawn', focus: [...FAULD_PLACES.hanbury] });
360
+ const [x, z] = FAULD_PLACES.hanbury;
361
+ scene.look([x + 900, scene.height(x + 900, z + 1200) + 120, z + 1200], [x, scene.height(x, z) + 20, z], 30);
362
+ engine.start();
363
+ return scene;
364
+ }
365
+ console.log(typeof show, FAULD_PLACES.hanbury, Object.keys(FAULD_SLOTS).length); // function [-1225, -175] 9
366
+ ```
367
+
368
+ | Setting | Default | What it does |
369
+ | --- | --- | --- |
370
+ | `era` | `before` (countryside), `1944` (crater) | `before`, `1944` or `today` |
371
+ | `sky` | `lowSun` | `dawn`, `lowSun`, `overcast`, `grey`, `dusk`, `night`, `snow`, `rain` or `mist` |
372
+ | `hour` | by `sky` | local solar time on 27 November |
373
+ | `focus` | `[0, 0]` | the shot's subject (the shot files keep it) |
374
+ | `radius` | 2,500 | how far round the camera the view grows plants (hedges, trees, woods), 200 to 3,000 m |
375
+ | `dem`, `library` | under `/asset-library/` | the height grid and the model library |
376
+ | `buildings` | `true` | draws the `FAULD_SLOTS` models of the era (church, inn, cottages, kiln works, guard hut, tender, van, cattle) |
377
+ | `lens` | `{stop: 8, focusDistance: 1000}` | the lens's f-number and focus distance (metres), drawn by `DOF` of `@margoengine/dof` on a Super 35 sensor (24.89 mm across), so its focal length follows the camera's field of view; the handle's `dof` is that effect |
378
+
379
+ Shot files for the film's crater and countryside rows: `node tools/shot/fauld-shots.mjs` (from the recut shot list).
380
+ Each lens is on the film's 24.89 x 14 mm filmback inside a named band (wide 18 to 24 mm, natural 35 to 50, portrait 85
381
+ to 135; a 28 or 200 mm row takes the nearest band edge), the aim drifts across the subject by 7 percent of the frame
382
+ width, and the page query carries the lens (`stop` f/8 or f/11, `focusDistance` at the harmonic mean of the subject's
383
+ near and far faces, so the thin-lens depth of field covers it);
384
+ every camera is checked against the scene's own ground, trees and hedges (`tools/shot/fauld-sight.mjs`,
385
+ `sightClearance`) and, where blocked, turned about its subject, stepped in towards the crater rim or lifted, the least
386
+ that works (`tools/shot/fauld-sight.json` records each row);
387
+ stills through the shot tool, which adds the page's ground under each camera (`shot.page.ground`):
388
+ `node tools/shot/cli.mjs tools/shot/shots/fauld-fr008.json --stills --out <folder>`, or by hand
389
+ `node packages/scenes/test/fauld-still.mjs --shots=fr008,fr074 --out=<folder>`.
390
+
391
+ ### The Fauld ground without an engine
392
+
393
+ Tools that must know where the hills, hedges and trees stand without rendering them (shot cameras kept clear with
394
+ `@margoengine/cameras/clearance`) build the same ground on the CPU: `layFauldGround({ dem, era, crater })` gives the
395
+ biome world, farm, planting exclusions and height, `fauldDem(meta, heights)` reads the height grid and
396
+ `FAULD_PLANT_MODELS` names the plant models. All three are exported by `/fauld-countryside`.
397
+
398
+ ```js
399
+ import { BiomePlacement } from '@margoengine/biomes/placement';
400
+ import { fauldDem, layFauldGround } from '@margoengine/scenes/fauld-countryside';
401
+
402
+ // Needs the asset library served at /asset-library/ (the OS Terrain 50 grid).
403
+ async function trees(url = '/asset-library/dem/os-terrain-50/fauld_sk12_sk23') {
404
+ const meta = await (await fetch(`${url}.json`)).json();
405
+ const dem = fauldDem(meta, new Float32Array(await (await fetch(`${url}.f32`)).arrayBuffer()));
406
+ using ground = await layFauldGround({ dem, era: 'before' });
407
+ const placement = BiomePlacement.attach(ground.world, { exclusions: ground.exclusions });
408
+ return { plants: (await placement.tile(12, 12)).count, height: ground.height(0, 0) };
409
+ }
410
+ console.log(typeof trees); // function
411
+ ```
412
+
413
+ ## The Fauld explosion: `@margoengine/scenes/fauld-blast`
414
+
415
+ The countryside above at 11:11 on 27 November 1944, with the explosion drawn into it on film time. Two releases 1.6 s
416
+ apart (`FAULD_BLASTS`, 4,000 t of TNT equivalent split 55 / 45) rise as one merging mushroom cloud (`BlastCloud` of
417
+ `@margoengine/weather/eruption` in `Clouds` of `@margoengine/vfx/clouds`, the fire inside it in a second, unlit
418
+ `Clouds`), its heat FIRE-05's air share for the store's depth, its fireball FIRE-05's and its spread FIRE-03's. The
419
+ store's rock flies and lands as physics, and the blast shakes the camera (`shake`, default true) and is the film's sound
420
+ (`scene.explosion`, below). The incendiary dump catches at `FAULD_FIRE_AT` (`Fire` of `@margoengine/vfx/fire`), and once the crater has formed
421
+ a bed of the store's magnesium incendiaries burns on its floor at each release for ten minutes (`FAULD_CRATER_FIRE`,
422
+ a model choice: 20,000 4 lb bombs over 700 m^2 lit by the blast's 6 s fire, `burningBed` and `INCENDIARY_4LB` of
423
+ `@margoengine/vfx/flame`; about 13 m flames under white MgO smoke at full burn; `fauldCraterFire`), each fire following
424
+ any seek (`fauldFireStep`); the ground heaves and the crater opens in the
425
+ terrain's own heightmap (`GroundChange` of `@margoengine/terrain/ground-change`, `scene.crater`), sized by the crater
426
+ physics (`fauldDig`, below); and with `mud: true` the store's blast cracks the reservoir's bank and its mud
427
+ pours down to the works. The mud is physics on the film clock (`fauldMud`, below). Every part is a
428
+ function of the film time, so `seek(t)` shows the same frame in any order, the mud and the surge included, and each engine frame moves
429
+ the film on by its delta unless `clock: false`. It takes the countryside's settings (the `sky` default is `overcast`) plus:
430
+
431
+ | Setting | Default | What it does |
432
+ | --- | --- | --- |
433
+ | `time` | 0 | film seconds since the first explosion, 0 to 3,600; checked before the world is built |
434
+ | `mud` | `false` | the burst reservoir's mud flows to the works |
435
+ | `surge` | `false` | the blast's base surge runs out over the fields as physics (`scene.surge`), drawn as dust in the smoke |
436
+ | `clock` | `true` | each engine frame moves the film on; `false` leaves it where `seek` puts it (a shot tool's own clock) |
437
+ | `puffs` | `{cap: 2040, stem: 1020}` | puffs of each cap and each stem drawn by `BlastCloud.draw` |
438
+ | `rocks` | 600 | pieces of the store's thrown rock flown (FIRE-05) and drawn |
439
+ | `shake` | `true` | the blast shakes the camera `look` puts, as a film camera on its tripod (`FAULD_CAMERA`) |
440
+
441
+ ```ts
442
+ import { Engine } from 'margoengine';
443
+ import { attach, FAULD_BLASTS, FAULD_CLOUD_DECK } from 'margoengine/scenes/fauld-blast';
444
+
445
+ // Needs the asset library served at /asset-library/, like the countryside.
446
+ async function show(canvas: HTMLCanvasElement) {
447
+ const engine = await Engine.create(canvas, { camera: { far: 40000 } });
448
+ const scene = await attach(engine, { time: 30 });
449
+ scene.look([-1800, 150, 900], [0, 900, 0], 30);
450
+ scene.seek(60); // the column a minute after the first explosion
451
+ engine.start();
452
+ return scene;
453
+ }
454
+ console.log(typeof show, FAULD_BLASTS.length, FAULD_CLOUD_DECK.bottom); // function 2 1000
455
+ ```
456
+
457
+ The explosion (`scene.explosion`, or `fauldExplosion({height, blasts})` alone) is one `PhysicsWorld` at 30 Hz:
458
+
459
+ - **The charges:** each release is a buried charge of FIRE-05's `ExplosionSolver`, `FAULD_STORE.depth` (35 m) down in
460
+ the waterlogged mudstone, its crater the one EARTH-06 digs there. Its rock flies as `pieces` pieces (default 600,
461
+ shared by TNT) at the crater ejecta's point-source speeds and Roth's flyrock speed. The pieces' sizes follow Kuz-Ram for
462
+ the store's rock (`FAULD_ROCK`: unweathered Mercia Mudstone, 2,480 kg/m^3, Young's modulus 250 MPa and blocky, from
463
+ the BGS's 2002 report RR/01/02), and they land on a `TerrainBed` of the scene's ground. `explosion.rocks()` gives them.
464
+ - **The blast:** FIRE-04's `BlastSolver`. `explosion.pressure(point)` is its overpressure now, and
465
+ `explosion.sound(point, start, seconds, rate)` samples it for the film's sound track.
466
+ `explosion.shake(point, t)` is a camera's shake: a film camera (`FAULD_CAMERA`: 10 kg, a 0.05 m^2 face, an 8 Hz
467
+ tripod mount with 5 % damping, model choices) driven by the blast's pressure on its face, along the way the blast
468
+ travels.
469
+ - **The column:** FIRE-03's `PlumeSolver`, the thermal each release's heat lifts in the scene's wind.
470
+ `explosion.column()` gives each one's centre, radius and top.
471
+ - **The landings:** `explosion.landings()` gives each piece's first ground contact (FIRE-05's `landings()`): its film
472
+ second, place and energy, and its dust puff's radius, the ejecta blanket (4 crater radii) of the crater that energy digs
473
+ in wet soil (`craterSize`, EARTH-06). The scene draws each puff in the smoke for 12 s, growing and fading.
474
+ - **The sound:** `explosion.recording(point, start, seconds)` and the scene's `soundtrack(start, seconds)` (at the camera
475
+ `look` put) are the blast as a microphone records it (`FAULD_MICROPHONE`: full scale 632 Pa, 150 dB SPL, a high-SPL
476
+ studio microphone's limit, a model choice; louder clips). It is a mono `MixSound` for a cutscene's `sounds`. The drawn cloud, given the same heat, fireball and
477
+ spread, stays within 10 % of these thermals from half a minute to four.
478
+ - **Scrubbing:** snapshots every ten film seconds let `seek` go back as well as on.
479
+
480
+ Measured on a test slope (`test/fauld-explosion.test.js`): nothing before the store goes off; the rock flies and is all
481
+ down on the ground within a minute, out past 300 m; a camera 2 km off hears silence and then the shock, over 1 kPa, and
482
+ shakes by under 5 cm; each landing's puff is the crater law's and the recording mixes in a cutscene's audio track; each release's column passes 1.5 km in two minutes, toward the history's column of about 3 km. Any
483
+ film second is the same reached in any order.
484
+
485
+ ```ts
486
+ import { FAULD_BLASTS, fauldExplosion } from 'margoengine/scenes/fauld-blast';
487
+
488
+ const boom = await fauldExplosion({ height: (x) => 90 - 0.02 * x, blasts: FAULD_BLASTS, pieces: 100 });
489
+ boom.seek(30);
490
+ console.log(boom.rocks().length, Math.round(boom.column()[0].top)); // 100 and the first column's top, m
491
+ ```
492
+
493
+ The mud (`scene.mud`, or `fauldMud({height, grid, outlet, toward, at})` alone) is one `PhysicsWorld` at 60 Hz:
494
+
495
+ - **The reservoir:** a `DamBreach` of `@margoengine/physics/breach` (HYDRO-05), holding `FAULD_RESERVOIR.volume` (27,300 m^3, the six million gallons the local histories give) in the 58 by 58 m pond the OS six-inch map shows 280 m NNW of the crater's centre, behind an 8 m ring bank.
496
+ - **The blast:** with `blasts` (the scene passes `FAULD_BLASTS`) and the pond's centre `pond`, the releases go off as one buried charge of their summed TNT (`ExplosionSolver`, FIRE-05) at their energy-weighted centre, `CraterSolver` (EARTH-06) digs its crater, and the side of the ring nearest it fails by that crater's zones: the charge's crater is the one EARTH-06 digs in the store's wet soft rock (`crater` on the ExplosionSolver), so FIRE-05, EARTH-06 and the breach agree. In the scene the bank stands 250 m from the charge, 1.87 apparent crater radii (134 m; the rim's crest at 1.25 radii, near the just over 250 m across Waltham measured), inside the 2.5-radius plastic zone and outside the 1.5-radius rupture zone (Glasstone and Dolan 1977), so it cracks at the blast, pipes, and breaches by Froehlich's 2008 law. On flat ground the pond lets out 23,100 m^3 in ten minutes, peaking at 176 m^3/s 3.5 minutes after the blast. Without `blasts`, the bank is cut at film second `at` and the breach widens over 40 s (the standalone example below). The 450,000 m^3 some accounts give (After the Battle, 1977, quoted by Wikipedia) is not used: it is unverified, and in the mapped pond it would stand more than 100 m deep.
497
+ - **The mud:** its outflow and the torn bank run down the slope as a `GranularFlowSolver` of `@margoengine/physics/granular-flow` (EARTH-02). The flow takes the breach's mud through an inflow and picks up the loose soil it runs over (`FAULD_MUD`).
498
+ - **Scrubbing:** snapshots every ten film seconds let `seek` go back as well as on.
499
+ - **Drawing:** `ShallowWaterSurface` of `@margoengine/water/shallow-surface` draws it on Water from `mud.surface` and `mud.sediment`.
500
+
501
+ Measured on a test slope (`test/fauld-mud.test.js`), a blast 2.1 crater radii from the bank cracks it and the pond lets out more than 80 percent of its water, one beyond 2.5 radii leaves it standing, and a cut reservoir lets out more than 80 percent of its water within 400 s, every cubic metre of it on the slope as mud, and the mud at a film second is the same reached in any order. The bank's height, the cut and the mud's friction are model choices; no source gives the bank's height or how the dam failed (Waltham 2001: it "failed").
502
+
503
+ ```ts
504
+ import { fauldMud, FAULD_RESERVOIR } from 'margoengine/scenes/fauld-blast';
505
+
506
+ const mud = await fauldMud({
507
+ height: (x, z) => 60 + 0.06 * z, // a slope falling south
508
+ grid: { cells: 40, origin: [-50, -500], size: [400, 400] },
509
+ outlet: [150, -140],
510
+ toward: [150, -480],
511
+ at: 5,
512
+ });
513
+ mud.seek(120);
514
+ mud.seek(60); // back a minute: the same mud as a straight run to 60 s
515
+ console.log(mud.breach.read().phase, FAULD_RESERVOIR.volume); // open 27300
516
+ ```
517
+
518
+ The base surge (`scene.surge`, or `fauldSurge({height, blasts})` alone) is one `PhysicsWorld` at 10 Hz:
519
+
520
+ - **The charge:** the releases as one buried charge of their summed TNT at their energy-weighted centre, `FAULD_STORE.depth` down (`ExplosionSolver`, FIRE-05), as the mud and the crater take them.
521
+ - **The surge:** a `GravityCurrentSolver` of `@margoengine/physics/gravity-current` (EARTH-03) reading that charge. When it goes off, its ejecta column falls back over the crater it digs in the wet mudstone and pours out as a dusty current over the ground, `FAULD_SURGE.size` (3.2 km) square in 96 cells. The column's height, its dust and how long it pours are the solver's defaults, calibrated on Pre-Schooner's surges and checked on Dugout's. The dust is silt (`FAULD_SURGE.grain`).
522
+ - **The deposit:** the dust it drops lands on a `TerrainBed` through `bedChange`; `surge.deposit(x, z)` is the bed's rise.
523
+ - **Scrubbing:** snapshots every ten film seconds let `seek` go back as well as on.
524
+ - **Reading it:** `surge.sample(x, z, out)` gives the depth, dust, velocity and the dust's optical depth (1 or more reads as a dark cloud).
525
+ - **Drawing:** `fauldSurgeDust(surge, height)` is a `DustCurrent` of `@margoengine/vfx/dust-current`: after each `seek`, `draw(smoke)` puts one puff in the smoke `Clouds` for each visible patch of the surge, standing on the ground as tall as it is deep, sized by the share of light its dust stops. The scene does this with `surge: true`.
526
+
527
+ Measured on a test slope (`test/fauld-surge.test.js`): nothing moves before the store goes off; its column's dust falls back from some 3 km for about 25 s, and by 60 s the surge has run more than 500 m out both ways, the bed holds exactly the dust the surge laid, and the surge at a film second is the same reached in any order. No survey of the real surge's reach or deposit is known, so neither is checked.
528
+
529
+ ```ts
530
+ import { FAULD_BLASTS, fauldSurge } from 'margoengine/scenes/fauld-blast';
531
+
532
+ const surge = await fauldSurge({ height: (x) => 90 - 0.02 * x, blasts: FAULD_BLASTS });
533
+ surge.seek(60);
534
+ const at = surge.sample(500, 0, { depth: 0, dust: 0, velocity: [0, 0], opacity: 0 });
535
+ console.log(surge.time, at.opacity >= 1); // 60 true
536
+ ```
537
+
538
+ The crater (`scene.dig`, or `fauldDig(releases)` alone) is the releases as one charge of their summed TNT at their
539
+ energy-weighted centre, `FAULD_STORE.depth` (35 m) down in waterlogged mudstone, wet soft rock whose walls slump, by
540
+ `craterSize` of `@margoengine/physics/crater` (EARTH-06, Holsapple and Housen's scaling). It sets the terrain's crater
541
+ event (its radius and depth, its formation time 0.8 sqrt(V^(1/3) / g), the bulked share thrown beyond the rim) and the
542
+ clods' and gypsum's launch speed at the rim, 0.78 sqrt(g R). For the scene's 4,000 t its rim (`dig.lip`) is 288 m
543
+ across where the survey's is 220 by 270 m, and it is 50 m deep where the survey found about 30 m. The scene's 4,000 t is
544
+ its own choice for the cloud; Fielder and Guest's 2,422 t TNT equivalent digs a 260 m rim, 44 m deep.
545
+
546
+ ```ts
547
+ import { fauldDig, FAULD_BLASTS } from 'margoengine/scenes/fauld-blast';
548
+
549
+ const dig = await fauldDig(FAULD_BLASTS);
550
+ console.log(Math.round(2 * dig.lip), dig.event.kind, Math.round(dig.launch)); // 288 crater 28
551
+ ```
552
+
553
+ Given the ground (`fauldDig(releases, gravity, { height })`, as the scene does), the crater throws its blocks too (EARTH-06's `ejectaBlocks`, 2 m and up). Each lands on that ground (`blockLanding`) and digs a secondary crater where it strikes the wet soil (`impactCrater`). They make `dig.secondaries`, one terrain `craters` event. The crater's blanket takes its `rays` from the mass that landed in each of 32 sectors, leaving its noise pits and blocks to the real ones. `dig.landed` gives where each block came to rest, and the 1944 places draw them there as library rocks, half buried, a fifth of them white gypsum:
554
+
555
+ ```ts
556
+ import { fauldDig, FAULD_BLASTS } from 'margoengine/scenes/fauld-blast';
557
+
558
+ const dig = await fauldDig(FAULD_BLASTS, 9.80665, { height: () => 0 });
559
+ console.log(dig.blocks, dig.secondaries.craters.length, dig.event.rays.length); // 14144 14144 32
560
+ ```
561
+
562
+ The blast rows of the shot list (`margo:scenes/fauld-blast`) come from the same `node tools/shot/fauld-shots.mjs`. Every
563
+ blast camera stays over the 6.4 km world and 150 m or more under the overcast deck's base in world height; the
564
+ generator records the OS Terrain 50 ground under each camera key in `packages/scenes/test/fauld-blast-ground.json`
565
+ for the scenes test, so the world and the weather are never moved for one camera.
566
+
567
+ ## Look families: one call, every package
568
+
569
+ `applyLookFamily(name, targets)` (`@margoengine/scenes/look-family`) applies a look family by name through each package's own
570
+ apply function, for each part of the scene you give it. `LOOK_FAMILIES` is `['natural', 'animatedFeature']`. `natural` writes
571
+ every row at its default (each part draws as it does with no settings); `animatedFeature` is the animated-feature picture
572
+ style: a fuller zenith and warm horizon, a larger sun disc and rounder clouds in the sky; clear blue-green water with wide
573
+ soft foam; larger colour masses on the ground; air at 0.6 of the clear-air visibility; soft pale sand and smoke; one warm
574
+ grade with the saturation up 12 percent, no grain and dither on; a gentle bloom, a 180 degree shutter and GTAO and SSGI on.
575
+ A family is a picture style for any hour, never a time of day: the sky keeps the scene's clock (`hours`, `timeScale`)
576
+ and sun direction, so a night scene stays night and an afternoon keeps its sun under either family. Nor is it an
577
+ exposure: the sky's and the tonemap's displays keep the exposure the scene gave them (a sky preset opens golden hour 1.5
578
+ stops and the night 2), unless the family sets `tonemap.exposure` itself (neither does).
579
+
580
+ `applyFamilySky(name, target, rows)` writes a shot's sky rows over a family: the family's sky values with `rows` on top,
581
+ so a row left out keeps the family's value (its warm key, saturation and air) instead of the row default, the sky keeps
582
+ the scene's clock and sun unless `rows` name a clock or sun row, the clouds keep the layer the scene placed unless
583
+ `rows` name it, and the display keeps its exposure unless `rows` give `tonemap.exposure`. Timber Valley writes its
584
+ shots' `sky` rows this way, and gives its look family both the sky target and the `tonemap` target with a `Grade`, so
585
+ the family's AgX curve, vignette, dither and saturation reach its frame (`lookTargets`, KB-SCENES-TVTONE1).
586
+ Both families live in each package's own table, `natural` (no rows: the defaults) beside `animatedFeature`
587
+ (`SKY_LOOKS`, `WATER_LOOKS`, `TERRAIN_LOOKS`, `WEATHER_LOOKS`, `ENVIRONMENT_LOOKS`, `SAND_LOOKS`, `SMOKE_LOOKS`, `FLAME_LOOKS`
588
+ (a `fire` target), `TONEMAP_LOOKS`, `POST_LOOKS` and the ground-material multipliers `BIOME_LOOKS`), so a page can also pick
589
+ one package's family alone. The `biomes` target is the options of a `BiomeView` before `BiomeView.attach` (the ground
590
+ materials are read when the view is built): its `materials` becomes `biomeMaterials(name)`.
591
+
592
+ | Target | Package apply function | Notes |
593
+ | --- | --- | --- |
594
+ | `sky` | `applySkySettings` | `{ sky }`, optionally its tonemap, grade and volumetric clouds |
595
+ | `water` | `applyWaterSettings` | a `Water`; a wind or chop the family set goes back to the Water's own under `natural` |
596
+ | `terrain` | `applyTerrainSettings` | a `TerrainColors` |
597
+ | `weather` | `applyWeatherSettings` | writes the family's state: give it only when nothing else owns the weather |
598
+ | `environment` | `applyEnvironmentSettings` | `{ air }` (a `VolumetricFog`) and/or the scene `fog`, `environment`, `background` |
599
+ | `sand`, `smoke`, `fire` | `applySandSettings`, `applySmokeSettings`, `applyFlameSettings` | a `BlownSand`, a `Smoke` or a `FireFront` (its smoke columns keep their heat and radius), a `Fire` or a `FireFront` |
600
+ | `tonemap` | `applyTonemapSettings` | `{ tonemap, grade }`: the family's `grade.saturation` needs a `Grade` in `grade`; the family's display curve (`tonemap.curve`, AgX under `animatedFeature`) reaches a scene only through this target |
601
+ | `post` | `applyPostSettings` | `{ bloom, gtao, ssgi, dof, lens, motionBlur }`: the family turns GTAO and SSGI on, so it needs both |
602
+ | `biomes` | `biomeMaterials` | `{ materials }` of a `BiomeView` not yet attached |
603
+
604
+ Every part is proved on the CPU (test/look-family-parts.test.js: the family by name gives the package's own table values,
605
+ `natural` gives the defaults back byte for byte) and on a real GPU on WebGPU and the WebGL2 layer
606
+ (test/look-family-gpu.mjs: the family changes the picture and `natural` gives back the first frame).
607
+
608
+ ```ts
609
+ import { Sky } from '@margoengine/sky';
610
+ import { applyFamilySky, applyLookFamily } from '@margoengine/scenes/look-family';
611
+
612
+ const sky = new Sky();
613
+ const smoke = { options: {} }; // any target with an options object, such as a Smoke
614
+ applyLookFamily('animatedFeature', { sky: { sky }, smoke });
615
+ console.log(sky.options.look); // { cloudDensity: 1.2, zenithStrength: 0.35, horizonStrength: 0.3, sunDiscSize: 0.33235714285714285, sunDiscSoftness: 0.6 }
616
+ const tonemap = { options: { curve: 'agx', exposure: 1.5 } }; // a Tonemap's options
617
+ applyFamilySky('animatedFeature', { sky, tonemap }, { 'tonemap.contrast': 1.1 });
618
+ console.log(tonemap.options.curve, tonemap.options.exposure, tonemap.options.temperature); // agx 1.5 5800
619
+ applyLookFamily('natural', { sky: { sky }, smoke }); // every row back at its default
620
+ ```