@margoengine/scenes 0.0.0-stage → 0.1.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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +387 -3
- package/dist/dune-coast-info-e8eDZXBu.js +208 -0
- package/dist/dune-coast-info.d.ts +3 -0
- package/dist/dune-coast.d.ts +160 -0
- package/dist/dune-coast.js +591 -0
- package/dist/fauld-blast.d.ts +67 -0
- package/dist/fauld-blast.js +283 -0
- package/dist/fauld-countryside.d.ts +13 -0
- package/dist/fauld-countryside.js +10 -0
- package/dist/fauld-crater.d.ts +13 -0
- package/dist/fauld-crater.js +10 -0
- package/dist/fauld-tunnels-info-8qv9X4OJ.js +70 -0
- package/dist/fauld-tunnels-info.d.ts +5 -0
- package/dist/fauld-tunnels-plan.d.ts +1069 -0
- package/dist/fauld-tunnels.d.ts +208 -0
- package/dist/fauld-tunnels.js +6476 -0
- package/dist/fauld-world-85dg03jo.js +582 -0
- package/dist/fauld-world-info.d.ts +7 -0
- package/dist/fauld-world.d.ts +160 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +160 -0
- package/dist/library-mesh-BRk4Ycnn.js +306 -0
- package/dist/library-mesh.d.ts +108 -0
- package/dist/library-parts.d.ts +45 -0
- package/dist/library.d.ts +52 -0
- package/dist/library.js +48 -0
- package/dist/look-family.d.ts +48 -0
- package/dist/look-family.js +34 -0
- package/dist/shared/settings.d.ts +89 -0
- package/dist/shot-settings.d.ts +40 -0
- package/dist/shot-settings.js +94 -0
- package/dist/timber-valley-info-BB6GvcsL.js +242 -0
- package/dist/timber-valley-info.d.ts +3 -0
- package/dist/timber-valley.d.ts +163 -0
- package/dist/timber-valley.js +362 -0
- package/package.json +104 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Scott Campbell
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,387 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @margoengine/scenes
|
|
2
|
+
|
|
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 grass follows the ecology of American beachgrass (Ammophila breviligulata): it grows where blown sand buries it
|
|
73
|
+
and spreads in clumps, and the sand it traps builds the hummocks, so hummock tops carry the most and the hollows the
|
|
74
|
+
least (Hesp 2002, "Foredunes and blowouts: initiation, geomorphology and dynamics", Geomorphology 48; Maun 2009, *The
|
|
75
|
+
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,
|
|
76
|
+
which were bare moving sand in 1903 (LC-W86-120, LC-W85-110). Clumps stand in patches 3 to 10 m across, in groups,
|
|
77
|
+
with a lone clump between them; `grass` sets the share of ground in patches.
|
|
78
|
+
|
|
79
|
+
The page `examples/dune-coast/index.html` shows the scene and is ready for the shot tool (tools/shot): it takes
|
|
80
|
+
`view`, `fov` and any setting as URL options, sets `#viewport[data-ready="true"]` 30 frames after `scene.ready` and exposes
|
|
81
|
+
`window.duneCoast = {engine, scene}` (shot `page.engine`: `duneCoast.engine`).
|
|
82
|
+
|
|
83
|
+
| Setting | Default | Range or values | Meaning |
|
|
84
|
+
| --- | --- | --- | --- |
|
|
85
|
+
| `date` | `'1903-12-17'` | `YYYY-MM-DD` | the day, for the sun's place |
|
|
86
|
+
| `hour` | 10.6 | 0 to 24 h | local solar time (10:35 eastern time at 75.67 W) |
|
|
87
|
+
| `latitude` | 36.02 | -90 to 90 deg | degrees north |
|
|
88
|
+
| `weather` | `'overcast'` | `'overcast'`, `'clear'` | the photographs' grey sky and soft light, or sun and broken cloud |
|
|
89
|
+
| `visibility` | 6000 | 500 to 50,000 m | haze distance |
|
|
90
|
+
| `wind` | 11 | 0 to 25 m/s | wind speed: grass sway, whitecaps, chop and the wind sea |
|
|
91
|
+
| `windFrom` | 0 | 0 to 360 deg | compass direction the wind blows from; dunes face away from it |
|
|
92
|
+
| `sand` | [0.52, 0.46, 0.35] | linear RGB | dry sand albedo |
|
|
93
|
+
| `grass` | 0.5 | 0 to 1 | share of the ground in grass patches, most on the hummocks (0 removes it) |
|
|
94
|
+
| `grassColor` | [0.36, 0.31, 0.16] | linear RGB 0 to 1 | dune grass albedo (winter straw with olive bases) |
|
|
95
|
+
| `grassHeight` | 0.8 | 0.2 to 2 m | tallest grass leaf |
|
|
96
|
+
| `grassBlades` | 30 | whole number 4 to 64 | leaves to a clump |
|
|
97
|
+
| `grassVariety` | 0.035 | 0 to 0.2 | hue spread between clumps: straw and olive clumps side by side |
|
|
98
|
+
| `grassTranslucency` | 0 | 0 to 1 | sunlight seen through the leaves (`GrassScatter` `blades.translucency`), so a field against a low sun reads as thin leaves |
|
|
99
|
+
| `grassWidth` | 0.016 | 0.004 to 0.05 m | leaf width at the root |
|
|
100
|
+
| `hill` | 30 | 0 to 40 m | crest of the big dune above the flat |
|
|
101
|
+
| `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) |
|
|
102
|
+
| `sandBands` | 0 | 0 to 1 | broad scour bands along the wind on the sand (`TerrainColors` `sandSurface.broad`), seen at any distance |
|
|
103
|
+
| `surf` | 1.2 | 0 to 3 m | swell height at the beach (0 removes the sea) |
|
|
104
|
+
| `camp` | true | | the sheds and the rail |
|
|
105
|
+
| `boards` | [0.258, 0.205, 0.147] | linear RGB 0 to 1 | albedo of the sheds' wall boards and the rail (the `weatheredWood` preset) |
|
|
106
|
+
| `roof` | [0.258, 0.205, 0.147] | linear RGB 0 to 1 | albedo of the sheds' roof boards |
|
|
107
|
+
| `shedOverhang` | 0.2 | 0 to 1 m | roof overhang past the shed walls |
|
|
108
|
+
| `shedWeathering` | 0.5 | 0 to 1 | board tilts, uneven ends and gaps |
|
|
109
|
+
| `shedWindows` | false | | two windows in the hangar's back wall and one in each shed's end wall |
|
|
110
|
+
| `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 |
|
|
111
|
+
| `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) |
|
|
112
|
+
| `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 |
|
|
113
|
+
| `quality` | `'film'` | `'film'`, `'preview'` | ground cells, sea segments, shadow map and grass count |
|
|
114
|
+
| `seed` | 1903 | | seed of the hummocks and small dunes |
|
|
115
|
+
|
|
116
|
+
Presets (`info.presets`): `first-flight` (the defaults), `clear-morning`, `calm-summer`. Anchors: `rail`, `camp`,
|
|
117
|
+
`flightLine`, `bigHill`, `beach`. Views: the six Library of Congress photographs' camera places (`first-flight`,
|
|
118
|
+
`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).
|
|
119
|
+
|
|
120
|
+
Sources for the layout: Library of Congress, Wright Brothers negatives LC-W861-35, LC-W86-15, LC-W86-21, LC-W86-38,
|
|
121
|
+
LC-W86-120 and LC-W85-110 (public domain, https://www.loc.gov/pictures/collection/wri/); USGS 3D Elevation Program
|
|
122
|
+
1 m bare-earth heights (public domain, https://www.usgs.gov/3d-elevation-program) for the distances from the camp flat
|
|
123
|
+
to the hill and the shore; McFarland (ed.) 1953, *The Papers of Wilbur and Orville Wright*, for the hangar and the
|
|
124
|
+
rail. The ground, the sky and the sea come from their packages' own sources (terrain/dunes, sky/sun, water).
|
|
125
|
+
|
|
126
|
+
## Fauld tunnels: `@margoengine/scenes/fauld-tunnels`
|
|
127
|
+
|
|
128
|
+
The RAF Fauld underground bomb store in Staffordshire (the explosion of 27 November 1944): the arched gypsum bays with
|
|
129
|
+
their racks of 1,000 lb and 500 lb bombs, the narrow-gauge rails and trolleys, the brick blast walls, the work bay, the
|
|
130
|
+
timbered Old Mine roadways beyond, and the portal yard in the hillside. Plan metres (+x into the hill, +y north, z up)
|
|
131
|
+
map to Margo as (x, z, -y). Every model is a library glTF with full PBR maps (`<library>/fauld-1944/tunnels/<id>`,
|
|
132
|
+
converted from the film's kit in Blender), drawn once each and repeated by GPU instancing.
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
import {dressState, FAULD_STATE_EV, FAULD_TUNNEL_STATES} from 'margoengine/scenes/fauld-tunnels';
|
|
136
|
+
const working = dressState('working');
|
|
137
|
+
console.log(FAULD_TUNNEL_STATES.length, working.lamps.length, FAULD_STATE_EV.working); // 10 55 2
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`attach(engine, settings)` (async) loads the state's models and draws them with clustered lights: each bulkhead bulb
|
|
141
|
+
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
|
|
142
|
+
hemisphere only) in candela, hand lamps as 40 lm cones, the nearest and brightest lamps shadowed (`LocalShadows` with
|
|
143
|
+
`shadowBudget`, 16 in `film`, 8 in `preview`), one `LightBounce`, a glowing bulb at each fitting (`flameEmission`),
|
|
144
|
+
lamp-lit `VolumetricFog` (gypsum dust, or smoke after the blast and in the fire), `Fire` and `Smoke` of the state,
|
|
145
|
+
and a `PostStack` of `GTAO`, `DOF`, `Bloom`, an AgX `Tonemap` white-balanced to 3200 K at the state's one metered
|
|
146
|
+
exposure (`FAULD_STATE_EV`, EV100) and `SMAA`. The yard states use the overcast `PresetScene` sky. `frame(position,
|
|
147
|
+
target, focal, stop)` sets the camera, its field of view on a 36 mm gate and the focus; `advanceTime(seconds)` runs
|
|
148
|
+
the fires; `counts`, `parts` and `dispose()` as the other places. The page `examples/fauld` draws one row of the
|
|
149
|
+
film's shot list (`tools/shot/shots/fauld-frNNN.json`) and `examples/fauld/stills.mjs` renders their stills.
|
|
150
|
+
|
|
151
|
+
| Setting | Default | Range or values |
|
|
152
|
+
| --- | --- | --- |
|
|
153
|
+
| `state` | `working` | `working`, `blast`, `fire`, `after`, `flooded`, `sealed`, `yard_day`, `yard_night`, `yard_fire`, `yard_sealed` |
|
|
154
|
+
| `time` | 0 | 0 to 600 s of fire and smoke |
|
|
155
|
+
| `quality` | `film` | `film` (16 shadowed lamps, 1,024 maps), `preview` (8, 512) |
|
|
156
|
+
| `library` | `/asset-library/` | the URL root of the asset library |
|
|
157
|
+
|
|
158
|
+
Sources: the film's reference bible and lighting plan (fauld-reference-bible.md and fauld-tunnel-lighting-plan.md);
|
|
159
|
+
the store's records at Kew (AIR 17/8, 17/10, 17/12, plan MFQ 1/1003); McCamley, *Disasters Underground* (2004);
|
|
160
|
+
Waltham 2001, *Mercian Geologist* 15(2), 123 to 125, for the white gypsum about 35 m down; the Osram-GEC 60 W 240 V
|
|
161
|
+
coiled-coil lamp, 690 lm at 2700 K (lamptech.co.uk); Lagarde and de Rousiers 2014, *Moving Frostbite to PBR*, s5.1,
|
|
162
|
+
for EV100 metering. Fauld's own lamp wattage and spacing are not on record online, so the rig follows period practice.
|
|
163
|
+
|
|
164
|
+
## Timber valley: `@margoengine/scenes/timber-valley`
|
|
165
|
+
|
|
166
|
+
A northern Rockies mountain valley in the 1910 fires (the Big Burn of 20 and 21 August 1910, Idaho and Montana). The
|
|
167
|
+
defaults are the blowup afternoon of 20 August 1910 round Wallace, Idaho: a level floor 870 m up with the creek and the
|
|
168
|
+
rail grade on it, walls of about 30 degrees cut into side gulches (`rockiesValleyWorld` of `@margoengine/biomes`, a
|
|
169
|
+
4 km world), western white pine, larch, red cedar, Douglas-fir and grand fir on them, a mining and railway town laid out
|
|
170
|
+
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
|
|
171
|
+
columns, flames on the hottest stretches of the front and embers. x is east, z south, y up, metres; the valley drains
|
|
172
|
+
west out of the world's west edge.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import {layout, world} from 'margoengine/scenes/timber-valley';
|
|
176
|
+
const w = await world({seed: 1910});
|
|
177
|
+
const plan = layout(w, {houses: 48});
|
|
178
|
+
console.log(plan.structures.length > 0, plan.rail.length > 100); // true true: town lots, and the rail line up the valley
|
|
179
|
+
w.dispose();
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
`attach(engine, settings)` (async) builds the world and draws it with `BiomeView` (terrain, the forest by species with
|
|
183
|
+
LOD rings, the creek's water, rocks and ground cover; nothing is placed on the rail, the creek or the lots), the sky,
|
|
184
|
+
bloom and tone curve of a `PresetScene` with the sun where it was for the date and hour, `VolumetricClouds`, shadows, a
|
|
185
|
+
`GTAO` occlusion pass, one `WeatherMachine` and a `WeatherDrive` that writes the wind, cloud and smoke haze into every
|
|
186
|
+
part and dries the fire's dead fuel from the weather's humidity and temperature, the fuel map of the forest
|
|
187
|
+
(`fuelMap`, Anderson's models 8 and 10 under timber, 1, 2 and 5 in the openings, none on the rail, the creek and the
|
|
188
|
+
streets) and a `FireFront` on it with the town lots as structures. The look family (`look`, default `animatedFeature`)
|
|
189
|
+
is written through each package's settings. The handle gives `height`, `anchors`, `views` and `view(name, fov)`,
|
|
190
|
+
`shots` (eight, from the catalogue) and `tracks` (a camera track per shot for `shotFilesFromScene` of `tools/shot`),
|
|
191
|
+
`targets`, `layout`, `applyLook(name)`, `applySettings({weather, sky, fire})` for per-shot rows, `advanceTime(seconds)`
|
|
192
|
+
(fire and sky), `settle()` (the forest tiles around the camera), the `parts` and `dispose()`.
|
|
193
|
+
|
|
194
|
+
| Setting | Default | Range or values |
|
|
195
|
+
| --- | --- | --- |
|
|
196
|
+
| `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`) |
|
|
197
|
+
| `look` | `animatedFeature` | `animatedFeature`, `natural` |
|
|
198
|
+
| `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` |
|
|
199
|
+
| `windFrom` | 225 | 0 to 360 degrees, the compass direction the wind blows from |
|
|
200
|
+
| `fire` | `running` | `none`, `running` (for `fireTime` seconds), `burnt` (run until nothing burns) |
|
|
201
|
+
| `fireTime` | 1,800 | 0 to 21,600 s |
|
|
202
|
+
| `houses` | 48 | 0 to 256 lots |
|
|
203
|
+
| `meshes` | none | library models by species key (`BiomeViewOptions.meshes`) |
|
|
204
|
+
| `quality` | `film` | `film` (2 km of objects, 4 m fire cells), `preview` (1 km, 8 m) |
|
|
205
|
+
| `seed` | 1910 | the valley, the forest, the town and the embers |
|
|
206
|
+
|
|
207
|
+
Presets: `blowup` (the defaults), `calm-august` (no fire, late morning), `red-flag` (ten minutes of fire on a red-flag
|
|
208
|
+
afternoon), `aftermath` (two days later, the fire burned out, under smoke). The town draws no buildings: its 1910 frame
|
|
209
|
+
and brick blocks, depot, mine works and locomotive have no models yet; the lots are laid out, burn as structures and
|
|
210
|
+
keep the forest off. `libraryMesh(url, options)` of `@margoengine/scenes/library` loads a library glTF as one mesh part
|
|
211
|
+
(base on the ground) for `meshes`, so a rock or plant model draws by key. A model whose material has a base colour map
|
|
212
|
+
keeps its maps: the part carries `textures` (its uvs and its base colour, normal and occlusion-roughness-metal images)
|
|
213
|
+
and draws textured; one of several textured materials goes to `libraryParts` (a coded `unsupported` error says so).
|
|
214
|
+
Pass `color` to draw it as one flat colour instead, as here:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
import {libraryMesh} from 'margoengine/scenes/library';
|
|
218
|
+
const files: Record<string, unknown> = {
|
|
219
|
+
'r.gltf': {asset: {version: '2.0'}, buffers: [{uri: 'r.bin', byteLength: 78}],
|
|
220
|
+
bufferViews: [{buffer: 0, byteLength: 72}, {buffer: 0, byteOffset: 72, byteLength: 6}],
|
|
221
|
+
accessors: [{bufferView: 0, componentType: 5126, count: 3, type: 'VEC3'},
|
|
222
|
+
{bufferView: 0, byteOffset: 36, componentType: 5126, count: 3, type: 'VEC3'},
|
|
223
|
+
{bufferView: 1, componentType: 5123, count: 3, type: 'SCALAR'}],
|
|
224
|
+
meshes: [{primitives: [{attributes: {POSITION: 0, NORMAL: 1}, indices: 2}]}], nodes: [{mesh: 0}]},
|
|
225
|
+
};
|
|
226
|
+
const bin = new ArrayBuffer(78);
|
|
227
|
+
new Float32Array(bin, 0, 18).set([0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1]);
|
|
228
|
+
new Uint16Array(bin, 72, 3).set([0, 1, 2]);
|
|
229
|
+
const fetch = async (url: string) =>
|
|
230
|
+
({ok: true, status: 200, json: async () => files[url], arrayBuffer: async () => bin});
|
|
231
|
+
const rock = await libraryMesh('r.gltf', {fetch, color: [0.3, 0.29, 0.27]});
|
|
232
|
+
console.log(rock.geometry.indices.length / 3, rock.kind); // 1 stone
|
|
233
|
+
// attach(engine, {meshes: {'procedural:rock': [rock]}}) draws it in place of the procedural rock.
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`libraryParts(url, options)` loads a scanned model with its textures instead: one part per glTF material, each with its
|
|
237
|
+
TEXCOORD_0 (KHR_texture_transform applied), base colour, normal and metallic-roughness images (R read as occlusion, the
|
|
238
|
+
packing of Poly Haven scans), MASK and BLEND materials and names with twig, leaf or needle as `foliage` with an alpha
|
|
239
|
+
cut-out. Three URLs (near, middle and far levels of one model) give each part a geometry per LOD ring. Scans are heavy:
|
|
240
|
+
decimate them into levels first (the 1910 conifer is `plants/fir_tree_01/forest/fir_tree_01_a_{near,middle,far}.gltf`
|
|
241
|
+
in the asset library, 90,000, 20,000 and 11,371 faces).
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
import {libraryParts} from 'margoengine/scenes/library';
|
|
245
|
+
const base = '/asset-library/big-burn-1910/plants/fir_tree_01/forest/fir_tree_01_a';
|
|
246
|
+
const load = () => libraryParts([base + '_near.gltf', base + '_middle.gltf', base + '_far.gltf']);
|
|
247
|
+
// attach(engine, {meshes: {'procedural:douglas-fir/pole': await load()}}) draws the scanned fir as every Douglas-fir.
|
|
248
|
+
console.log(typeof load); // function
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Sources: Pyne, *Year of the Fires: The Story of the Great Fires of 1910*, 2001 (the blowup, the south-west gale, the
|
|
252
|
+
burning of part of Wallace); Koch, "History of the 1910 forest fires in Idaho and western Montana", USDA Forest Service,
|
|
253
|
+
1942. The valley, forest, fuel and fire come from their packages' own sources (biomes docs/relief-and-hydrology.md and
|
|
254
|
+
docs/fuel.md, vfx fire-front).
|
|
255
|
+
|
|
256
|
+
## Fauld, Staffordshire: `@margoengine/scenes/fauld-countryside` and `@margoengine/scenes/fauld-crater`
|
|
257
|
+
|
|
258
|
+
The hills round Hanbury and Fauld on the real ground (Ordnance Survey OS Terrain 50, tiles SK12, SK13, SK22 and SK23,
|
|
259
|
+
resampled to 5 m; Open Government Licence v3.0, "Contains OS data (c) Crown copyright and database right"), the farm
|
|
260
|
+
quilt of `@margoengine/biomes/farmland` (hedged fields, hedge oaks, ashes and hollies, lanes that end at a junction, the
|
|
261
|
+
edge or a gate), hedgerows and woods grown by the biome view from library trees with Poly Haven bark maps, fields,
|
|
262
|
+
lanes, mud and woodland floor from Poly Haven ground scans (CC0) at their own repeats, and an overcast late-November
|
|
263
|
+
sky, clouds and weather calibrated to photographs of the area. `fauld-crater` stamps the 1944 crater (`era: '1944'`, bare
|
|
264
|
+
marl and gypsum) or the wooded hollow today (`era: 'today'`) into the terrain from its model's heights. Models, scans and
|
|
265
|
+
the height grid are served from `library` (default `/asset-library/`, which holds `margo-library/fauld/` and `dem/`);
|
|
266
|
+
the buildings, the fire tender, the WVS van and a grazing herd stand in their slots (`FAULD_SLOTS`, each with its eras),
|
|
267
|
+
from Tripo models decimated to real size in `margo-library/fauld/buildings/`, drawn by `@margoengine/gltf/textured`
|
|
268
|
+
with their base colour maps and stood on the ground; shots keep them 150 m or more away. Origin: the crater's centre,
|
|
269
|
+
OS grid E 418225, N 327725; x east, z south.
|
|
270
|
+
|
|
271
|
+
```ts
|
|
272
|
+
import { Engine } from 'margoengine';
|
|
273
|
+
import { attach, FAULD_PLACES, FAULD_SLOTS } from 'margoengine/scenes/fauld-countryside';
|
|
274
|
+
|
|
275
|
+
// Needs the asset library served at /asset-library/ (the OS Terrain 50 grid and the crater and tree models).
|
|
276
|
+
async function show(canvas: HTMLCanvasElement) {
|
|
277
|
+
const engine = await Engine.create(canvas, { camera: { far: 40000 } });
|
|
278
|
+
const scene = await attach(engine, { sky: 'dawn', focus: [...FAULD_PLACES.hanbury] });
|
|
279
|
+
const [x, z] = FAULD_PLACES.hanbury;
|
|
280
|
+
scene.look([x + 900, scene.height(x + 900, z + 1200) + 120, z + 1200], [x, scene.height(x, z) + 20, z], 30);
|
|
281
|
+
engine.start();
|
|
282
|
+
return scene;
|
|
283
|
+
}
|
|
284
|
+
console.log(typeof show, FAULD_PLACES.hanbury, Object.keys(FAULD_SLOTS).length); // function [-1225, -175] 9
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
| Setting | Default | What it does |
|
|
288
|
+
| --- | --- | --- |
|
|
289
|
+
| `era` | `before` (countryside), `1944` (crater) | `before`, `1944` or `today` |
|
|
290
|
+
| `sky` | `lowSun` | `dawn`, `lowSun`, `overcast`, `grey`, `dusk`, `night`, `snow`, `rain` or `mist` |
|
|
291
|
+
| `hour` | by `sky` | local solar time on 27 November |
|
|
292
|
+
| `focus` | `[0, 0]` | the shot's subject (the shot files keep it) |
|
|
293
|
+
| `radius` | 2,500 | how far round the camera the view grows plants (hedges, trees, woods), 200 to 3,000 m |
|
|
294
|
+
| `dem`, `library` | under `/asset-library/` | the height grid and the model library |
|
|
295
|
+
| `buildings` | `true` | draws the `FAULD_SLOTS` models of the era (church, inn, cottages, kiln works, guard hut, tender, van, cattle) |
|
|
296
|
+
| `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 |
|
|
297
|
+
|
|
298
|
+
Shot files for the film's crater and countryside rows: `node tools/shot/fauld-shots.mjs` (from the recut shot list).
|
|
299
|
+
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
|
|
300
|
+
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
|
|
301
|
+
width, and the page query carries the lens (`stop` f/8 or f/11, `focusDistance` at the harmonic mean of the subject's
|
|
302
|
+
near and far faces, so the thin-lens depth of field covers it);
|
|
303
|
+
stills through the shot tool, which adds the page's ground under each camera (`shot.page.ground`):
|
|
304
|
+
`node tools/shot/cli.mjs tools/shot/shots/fauld-fr008.json --stills --out <folder>`, or by hand
|
|
305
|
+
`node packages/scenes/test/fauld-still.mjs --shots=fr008,fr074 --out=<folder>`.
|
|
306
|
+
|
|
307
|
+
## The Fauld explosion: `@margoengine/scenes/fauld-blast`
|
|
308
|
+
|
|
309
|
+
The countryside above at 11:11 on 27 November 1944, with the explosion drawn into it on film time. Two releases 1.6 s
|
|
310
|
+
apart (`FAULD_BLASTS`, 4,000 t of TNT equivalent split 55 / 45) rise as one merging mushroom cloud (`BlastCloud` of
|
|
311
|
+
`@margoengine/weather/eruption` in `Clouds` of `@margoengine/vfx/clouds`, the fire inside it in a second, unlit
|
|
312
|
+
`Clouds`); earth clods and gypsum blocks fly and land with dust (`Debris` of `@margoengine/vfx/debris`); the incendiary
|
|
313
|
+
dump catches at `FAULD_FIRE_AT` (`Fire` of `@margoengine/vfx/fire`); and with `mud: true` the burst reservoir's mud
|
|
314
|
+
pours down to the works from `FAULD_MUD_AT` (`Flood` of `@margoengine/water/flood`, a GPU solver). Every part is a
|
|
315
|
+
function of the film time, so `seek(t)` shows the same frame in any order, and each engine frame moves the film on by
|
|
316
|
+
its delta unless `clock: false`. It takes the countryside's settings (the `sky` default is `overcast`) plus:
|
|
317
|
+
|
|
318
|
+
| Setting | Default | What it does |
|
|
319
|
+
| --- | --- | --- |
|
|
320
|
+
| `time` | 0 | film seconds since the first explosion, 0 to 3,600; checked before the world is built |
|
|
321
|
+
| `mud` | `false` | the burst reservoir's mud flows to the works |
|
|
322
|
+
| `clock` | `true` | each engine frame moves the film on; `false` leaves it where `seek` puts it (a shot tool's own clock) |
|
|
323
|
+
| `puffs` | `{cap: 2040, stem: 1020}` | puffs of each cap and each stem drawn by `BlastCloud.draw` |
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
import { Engine } from 'margoengine';
|
|
327
|
+
import { attach, FAULD_BLASTS, FAULD_CLOUD_DECK } from 'margoengine/scenes/fauld-blast';
|
|
328
|
+
|
|
329
|
+
// Needs the asset library served at /asset-library/, like the countryside.
|
|
330
|
+
async function show(canvas: HTMLCanvasElement) {
|
|
331
|
+
const engine = await Engine.create(canvas, { camera: { far: 40000 } });
|
|
332
|
+
const scene = await attach(engine, { time: 30 });
|
|
333
|
+
scene.look([-1800, 150, 900], [0, 900, 0], 30);
|
|
334
|
+
scene.seek(60); // the column a minute after the first explosion
|
|
335
|
+
engine.start();
|
|
336
|
+
return scene;
|
|
337
|
+
}
|
|
338
|
+
console.log(typeof show, FAULD_BLASTS.length, FAULD_CLOUD_DECK.bottom); // function 2 1000
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The blast rows of the shot list (`margo:scenes/fauld-blast`) come from the same `node tools/shot/fauld-shots.mjs`. Every
|
|
342
|
+
blast camera stays over the 6.4 km world and 150 m or more under the overcast deck's base in world height; the
|
|
343
|
+
generator records the OS Terrain 50 ground under each camera key in `packages/scenes/test/fauld-blast-ground.json`
|
|
344
|
+
for the scenes test, so the world and the weather are never moved for one camera.
|
|
345
|
+
|
|
346
|
+
## Look families: one call, every package
|
|
347
|
+
|
|
348
|
+
`applyLookFamily(name, targets)` (`@margoengine/scenes/look-family`) applies a look family by name through each package's own
|
|
349
|
+
apply function, for each part of the scene you give it. `LOOK_FAMILIES` is `['natural', 'animatedFeature']`. `natural` writes
|
|
350
|
+
every row at its default (each part draws as it does with no settings); `animatedFeature` is the animated-feature picture
|
|
351
|
+
style: a fuller zenith and warm horizon, a larger sun disc and rounder clouds in the sky; clear blue-green water with wide
|
|
352
|
+
soft foam; larger colour masses on the ground; air at 0.6 of the clear-air visibility; soft pale sand and smoke; one warm
|
|
353
|
+
grade with the saturation up 12 percent, no grain and dither on; a gentle bloom, a 180 degree shutter and GTAO and SSGI on.
|
|
354
|
+
A family is a picture style for any hour, never a time of day: the sky keeps the scene's clock (`hours`, `timeScale`)
|
|
355
|
+
and sun direction, so a night scene stays night and an afternoon keeps its sun under either family.
|
|
356
|
+
Both families live in each package's own table, `natural` (no rows: the defaults) beside `animatedFeature`
|
|
357
|
+
(`SKY_LOOKS`, `WATER_LOOKS`, `TERRAIN_LOOKS`, `WEATHER_LOOKS`, `ENVIRONMENT_LOOKS`, `SAND_LOOKS`, `SMOKE_LOOKS`, `FLAME_LOOKS`
|
|
358
|
+
(a `fire` target), `TONEMAP_LOOKS`, `POST_LOOKS` and the ground-material multipliers `BIOME_LOOKS`), so a page can also pick
|
|
359
|
+
one package's family alone. The `biomes` target is the options of a `BiomeView` before `BiomeView.attach` (the ground
|
|
360
|
+
materials are read when the view is built): its `materials` becomes `biomeMaterials(name)`.
|
|
361
|
+
|
|
362
|
+
| Target | Package apply function | Notes |
|
|
363
|
+
| --- | --- | --- |
|
|
364
|
+
| `sky` | `applySkySettings` | `{ sky }`, optionally its tonemap, grade and volumetric clouds |
|
|
365
|
+
| `water` | `applyWaterSettings` | a `Water`; a wind or chop the family set goes back to the Water's own under `natural` |
|
|
366
|
+
| `terrain` | `applyTerrainSettings` | a `TerrainColors` |
|
|
367
|
+
| `weather` | `applyWeatherSettings` | writes the family's state: give it only when nothing else owns the weather |
|
|
368
|
+
| `environment` | `applyEnvironmentSettings` | `{ air }` (a `VolumetricFog`) and/or the scene `fog`, `environment`, `background` |
|
|
369
|
+
| `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` |
|
|
370
|
+
| `tonemap` | `applyTonemapSettings` | `{ tonemap, grade }`: the family's `grade.saturation` needs a `Grade` in `grade` |
|
|
371
|
+
| `post` | `applyPostSettings` | `{ bloom, gtao, ssgi, dof, lens, motionBlur }`: the family turns GTAO and SSGI on, so it needs both |
|
|
372
|
+
| `biomes` | `biomeMaterials` | `{ materials }` of a `BiomeView` not yet attached |
|
|
373
|
+
|
|
374
|
+
Every part is proved on the CPU (test/look-family-parts.test.js: the family by name gives the package's own table values,
|
|
375
|
+
`natural` gives the defaults back byte for byte) and on a real GPU on WebGPU and the WebGL2 layer
|
|
376
|
+
(test/look-family-gpu.mjs: the family changes the picture and `natural` gives back the first frame).
|
|
377
|
+
|
|
378
|
+
```ts
|
|
379
|
+
import { Sky } from '@margoengine/sky';
|
|
380
|
+
import { applyLookFamily } from '@margoengine/scenes/look-family';
|
|
381
|
+
|
|
382
|
+
const sky = new Sky();
|
|
383
|
+
const smoke = { options: {} }; // any target with an options object, such as a Smoke
|
|
384
|
+
applyLookFamily('animatedFeature', { sky: { sky }, smoke });
|
|
385
|
+
console.log(sky.options.look); // { cloudDensity: 1.2, zenithStrength: 0.35, horizonStrength: 0.3, sunDiscSize: 2.2, sunDiscSoftness: 0.6 }
|
|
386
|
+
applyLookFamily('natural', { sky: { sky }, smoke }); // every row back at its default
|
|
387
|
+
```
|