@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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +619 -2
- package/dist/dune-coast-info-D9yQIv8G.js +218 -0
- package/dist/dune-coast-info.d.ts +3 -0
- package/dist/dune-coast.d.ts +179 -0
- package/dist/dune-coast.js +778 -0
- package/dist/errors-fc4i1pSL.js +7 -0
- package/dist/fauld-blast.d.ts +165 -0
- package/dist/fauld-blast.js +1034 -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-dig.d.ts +89 -0
- package/dist/fauld-dustfall-fines-grid-MA6XPrq6.js +14 -0
- package/dist/fauld-dustfall-fines-grid.d.ts +11 -0
- package/dist/fauld-dustfall-grid-Bb4X8b-u.js +14 -0
- package/dist/fauld-dustfall-grid.d.ts +11 -0
- package/dist/fauld-explosion.d.ts +135 -0
- package/dist/fauld-grains.d.ts +27 -0
- package/dist/fauld-mud.d.ts +104 -0
- package/dist/fauld-surge.d.ts +71 -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 +281 -0
- package/dist/fauld-tunnels.js +6801 -0
- package/dist/fauld-world-CNNSonJF.js +863 -0
- package/dist/fauld-world-info.d.ts +7 -0
- package/dist/fauld-world.d.ts +243 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +160 -0
- package/dist/library-mesh-CjTG-mVZ.js +329 -0
- package/dist/library-mesh.d.ts +108 -0
- package/dist/library-parts.d.ts +55 -0
- package/dist/library.d.ts +52 -0
- package/dist/library.js +48 -0
- package/dist/look-family.d.ts +63 -0
- package/dist/look-family.js +57 -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-vVI2nwDs.js +253 -0
- package/dist/timber-valley-info.d.ts +3 -0
- package/dist/timber-valley.d.ts +229 -0
- package/dist/timber-valley.js +424 -0
- package/package.json +104 -4
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel, Vec3 } from '@margoengine/core';
|
|
3
|
+
import { BiomeWorld } from '@margoengine/biomes';
|
|
4
|
+
import '@margoengine/biomes/valley';
|
|
5
|
+
import { type FuelMap } from '@margoengine/biomes/fuel';
|
|
6
|
+
import { type Settlements } from '@margoengine/biomes/settlements';
|
|
7
|
+
import { BiomeView, type BiomeViewOptions } from '@margoengine/biomes/view';
|
|
8
|
+
import { PresetScene } from '@margoengine/sky/scenes';
|
|
9
|
+
import { VolumetricClouds } from '@margoengine/sky/volumetric-clouds';
|
|
10
|
+
import { WeatherMachine, type WeatherState } from '@margoengine/weather';
|
|
11
|
+
import { WeatherDrive } from '@margoengine/weather/drive';
|
|
12
|
+
import { FireFront } from '@margoengine/vfx/fire-front';
|
|
13
|
+
import { Shadows } from '@margoengine/shadows';
|
|
14
|
+
import { GTAO } from '@margoengine/post/gtao';
|
|
15
|
+
import { Grade } from '@margoengine/tonemap/grade';
|
|
16
|
+
import type { TAA } from '@margoengine/taa';
|
|
17
|
+
import type { MotionBlur } from '@margoengine/post/motion-blur';
|
|
18
|
+
import { type LookFamilyName, type LookFamilyTargets } from './look-family.js';
|
|
19
|
+
import type { SceneShot } from './index.js';
|
|
20
|
+
/** Settings of {@link attach}. Every one has a default; the defaults are the blowup afternoon of 20 August 1910. */
|
|
21
|
+
export interface TimberValleySettings {
|
|
22
|
+
/** Calendar date, `YYYY-MM-DD`. Default `1910-08-20`. */
|
|
23
|
+
readonly date?: string;
|
|
24
|
+
/** Local solar time, hours. Default 16. */
|
|
25
|
+
readonly hour?: number;
|
|
26
|
+
/** Latitude, degrees north. Default 47.47 (Wallace, Idaho). */
|
|
27
|
+
readonly latitude?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Longitude, degrees east (negative west). With the date and `hour` it places the moon the night sky draws and that
|
|
30
|
+
* lights the scene once the sun has set. Default -115.93 (Wallace, Idaho).
|
|
31
|
+
*/
|
|
32
|
+
readonly longitude?: number;
|
|
33
|
+
/** Look family (`@margoengine/scenes/look-family`). Default `animatedFeature`. */
|
|
34
|
+
readonly look?: LookFamilyName;
|
|
35
|
+
/**
|
|
36
|
+
* `calm` (a clear August day, 2 m/s), `redFlag` (32 C, 15 percent humidity, 9 m/s), `blowup` (the gale of 20 August:
|
|
37
|
+
* 20 m/s gusting, 12 percent humidity) or `smoke` (a day under thick smoke). Default `blowup`.
|
|
38
|
+
*/
|
|
39
|
+
readonly weather?: 'calm' | 'redFlag' | 'blowup' | 'smoke';
|
|
40
|
+
/** Compass direction the wind blows FROM, degrees (0 north, 90 east). Default 225 (the south-west gale). */
|
|
41
|
+
readonly windFrom?: number;
|
|
42
|
+
/** `none`, `running` (burning for `fireTime` seconds) or `burnt` (run until nothing burns, `burnOut`; days of fire time). Default `running`. */
|
|
43
|
+
readonly fire?: 'none' | 'running' | 'burnt';
|
|
44
|
+
/** Seconds the fire has burned when the scene opens, 0 to 21,600. Default 1,800. */
|
|
45
|
+
readonly fireTime?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Live herbaceous fuel moisture of the grass, a fraction of dry weight, 0.3 to 2.5: it sets the share of cured,
|
|
48
|
+
* straw-coloured blades (`herbaceousCuring` of `@margoengine/biomes/fuel`, the load transfer of Scott and Burgan 2005:
|
|
49
|
+
* all living at 1.2 and above, all cured at 0.3). Default 0.3: the summer of 1910 was the driest the northern Rockies
|
|
50
|
+
* had known (Pyne 2001; Koch 1942), and pinegrass is dormant by midsummer (D. G. Stout, A. McLean, B. Brooke and J. W. Hall, Journal of Range
|
|
51
|
+
* Management 33(4), 1980, 286-291, https://doi.org/10.2307/3898075), at the 30 percent of cured herbaceous fuel
|
|
52
|
+
* (NWCG PMS 437, "Live fuel moisture content").
|
|
53
|
+
* A spring valley is near 2.5.
|
|
54
|
+
*/
|
|
55
|
+
readonly grassMoisture?: number;
|
|
56
|
+
/** Town lots along the rail line, 0 to 256. They are fuel and fire obstacles; no building is drawn. Default 48. */
|
|
57
|
+
readonly houses?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Meshes by species key for the forest (`BiomeViewOptions.meshes`): library models drawn in place of the procedural
|
|
60
|
+
* ones (`libraryMesh` of `@margoengine/scenes/library` loads one from glTF). Default none.
|
|
61
|
+
*/
|
|
62
|
+
readonly meshes?: BiomeViewOptions['meshes'];
|
|
63
|
+
/** `film` (2 km of objects, 4,096 shadows, 4 m fire cells) or `preview` (1 km, 2,048, 8 m). Default `film`. */
|
|
64
|
+
readonly quality?: 'film' | 'preview';
|
|
65
|
+
/** Seed of the valley, the forest, the town and the embers. Default 1910. */
|
|
66
|
+
readonly seed?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Restocks the forest on the same valley (KB-BIOMES-STANDSEED1): 1 or more reseeds where the trees stand and their
|
|
69
|
+
* meshes' own randomness (`BiomeViewOptions.standSeed`), keeping the ground, town, cameras and fire. Default 0, the
|
|
70
|
+
* valley's own stand.
|
|
71
|
+
*/
|
|
72
|
+
readonly standSeed?: number;
|
|
73
|
+
/** Aborts loading. */
|
|
74
|
+
readonly signal?: AbortSignal;
|
|
75
|
+
}
|
|
76
|
+
type Filled = Readonly<Required<Omit<TimberValleySettings, 'meshes' | 'signal'>>> & Pick<TimberValleySettings, 'meshes'>;
|
|
77
|
+
/** A named place in the scene: where to stand and where to look, metres. */
|
|
78
|
+
export interface Anchor {
|
|
79
|
+
readonly position: Vec3;
|
|
80
|
+
readonly target: Vec3;
|
|
81
|
+
readonly about: string;
|
|
82
|
+
}
|
|
83
|
+
/** The valley's lines in metres (`[x, z]` points, outlet first) and the town, from {@link layout}. */
|
|
84
|
+
export interface TimberValleyLayout {
|
|
85
|
+
readonly creek: readonly (readonly [number, number])[];
|
|
86
|
+
readonly rail: readonly (readonly [number, number])[];
|
|
87
|
+
readonly axis: readonly (readonly [number, number])[];
|
|
88
|
+
/** The town's lots, streets and exclusions (`layoutSettlements`, grid pattern). */
|
|
89
|
+
readonly town: Settlements;
|
|
90
|
+
/** Every lot as a fire structure (`FireFront` `structures`). */
|
|
91
|
+
readonly structures: readonly {
|
|
92
|
+
readonly at: [number, number];
|
|
93
|
+
readonly radius: number;
|
|
94
|
+
}[];
|
|
95
|
+
/** Where and when the fire starts. */
|
|
96
|
+
readonly ignitions: readonly {
|
|
97
|
+
readonly at: [number, number];
|
|
98
|
+
readonly time: number;
|
|
99
|
+
}[];
|
|
100
|
+
}
|
|
101
|
+
/** One camera key track of a shot, as `tools/shot` cutscene files hold it. */
|
|
102
|
+
export interface ShotTrack {
|
|
103
|
+
readonly type: 'camera';
|
|
104
|
+
readonly id: 'camera';
|
|
105
|
+
readonly path: 'linear';
|
|
106
|
+
readonly keys: readonly {
|
|
107
|
+
time: number;
|
|
108
|
+
position: Vec3;
|
|
109
|
+
target: Vec3;
|
|
110
|
+
fov: number;
|
|
111
|
+
ease?: 'smoothstep';
|
|
112
|
+
}[];
|
|
113
|
+
}
|
|
114
|
+
/** The scene handle from {@link attach}. */
|
|
115
|
+
export interface TimberValleyScene extends Disposable {
|
|
116
|
+
/** The settings in use, every default filled in. */
|
|
117
|
+
readonly settings: Filled;
|
|
118
|
+
/** Ground height at world (x, z), metres. */
|
|
119
|
+
height(x: number, z: number): number;
|
|
120
|
+
readonly anchors: Readonly<Record<string, Anchor>>;
|
|
121
|
+
readonly views: readonly string[];
|
|
122
|
+
/** Puts the engine camera at an anchor (and a field of view, degrees; default 50). */
|
|
123
|
+
view(name: string, fov?: number): void;
|
|
124
|
+
readonly shots: readonly SceneShot[];
|
|
125
|
+
/** Camera tracks per shot name, from each shot's first to its last camera key, for `shotFilesFromScene`. */
|
|
126
|
+
readonly tracks: Readonly<Record<string, readonly ShotTrack[]>>;
|
|
127
|
+
/** Target name to package settings entry (`info.targets`). */
|
|
128
|
+
readonly targets: Readonly<Record<string, string>>;
|
|
129
|
+
/** The valley lines, the town and the fire's starts. */
|
|
130
|
+
readonly layout: TimberValleyLayout;
|
|
131
|
+
/** Applies a look family to every part. */
|
|
132
|
+
applyLook(name: LookFamilyName): void;
|
|
133
|
+
/**
|
|
134
|
+
* Writes per-shot rows: `{weather: {...}, sky: {...}, fire: {...}}`, each through its package's apply function. The sky
|
|
135
|
+
* rows go over the look family in use (`applyFamilySky`): a row left out keeps the family's value, and the sun, the
|
|
136
|
+
* cloud layer and the exposure stay the scene's unless a row names them.
|
|
137
|
+
*/
|
|
138
|
+
applySettings(values: Readonly<Record<string, Readonly<Record<string, unknown>>>>): void;
|
|
139
|
+
/** Moves the scene's own time on (fire, sky): use for film frames instead of wall-clock time. */
|
|
140
|
+
advanceTime(seconds: number): void;
|
|
141
|
+
/** Waits for the forest tiles to stream in around the camera. */
|
|
142
|
+
settle(): Promise<void>;
|
|
143
|
+
readonly parts: {
|
|
144
|
+
readonly world: BiomeWorld;
|
|
145
|
+
readonly view: BiomeView;
|
|
146
|
+
readonly preset: PresetScene;
|
|
147
|
+
/** The colour grade in the preset's Tonemap (its first extension): the look family's and the sky rows' `grade.*`. */
|
|
148
|
+
readonly grade: Grade;
|
|
149
|
+
readonly clouds: VolumetricClouds;
|
|
150
|
+
readonly weather: WeatherMachine;
|
|
151
|
+
readonly drive: WeatherDrive;
|
|
152
|
+
readonly shadows: Shadows;
|
|
153
|
+
readonly occlusion: GTAO;
|
|
154
|
+
readonly fuel: FuelMap;
|
|
155
|
+
readonly fireFront?: FireFront;
|
|
156
|
+
/**
|
|
157
|
+
* Temporal anti-aliasing of the `film` quality (`@margoengine/taa`, its defaults: history weight 0.9, the
|
|
158
|
+
* silhouette history of KB-TAA-EDGE1), reading the post stack's depth, with every swaying scatter of the view in its
|
|
159
|
+
* velocity pass (`BiomeObjects.swaying`, `@margoengine/scatter/velocity`) so swaying leaves keep their history; the
|
|
160
|
+
* flames, smoke, weather and water mark their pixels reactive themselves, and the clouds' march moves its start
|
|
161
|
+
* each frame for it (`temporal: 'auto'`). Undefined at `preview`.
|
|
162
|
+
*/
|
|
163
|
+
readonly taa?: TAA;
|
|
164
|
+
/**
|
|
165
|
+
* Motion blur of the `film` quality (`@margoengine/post/motion-blur`, the reconstruction filter of McGuire et al.
|
|
166
|
+
* 2012) on TAA's resolved frame with TAA's velocity, a 180 degree shutter (`shutter` 0.5) by default. A shot drawn
|
|
167
|
+
* in sub-frames sets `shutter` per sub-frame to its share of the motion since the frame before (the shot tool's
|
|
168
|
+
* `page.shutter` hook, `shutterShare`), so each sub-frame blurs over its own slice of the shutter and the copies
|
|
169
|
+
* join with no steps (KB-LOOK-TV-SUBSTEP1). Undefined at `preview`.
|
|
170
|
+
*/
|
|
171
|
+
readonly motionBlur?: MotionBlur;
|
|
172
|
+
};
|
|
173
|
+
dispose(): void;
|
|
174
|
+
}
|
|
175
|
+
/** The catalogue entry of this scene. */
|
|
176
|
+
export declare const info: import("./index.js").SceneInfo;
|
|
177
|
+
/** Fills defaults and checks every setting. @throws TypeError, RangeError. */
|
|
178
|
+
export declare function check(settings: TimberValleySettings): Filled;
|
|
179
|
+
/** The weather state of a `weather` setting with the wind from `windFrom` (compass, degrees). */
|
|
180
|
+
export declare function weatherState(weather: Filled['weather'], windFrom: number): WeatherState;
|
|
181
|
+
/** The valley's lines and the town, from the same relief the world is built on. CPU only. */
|
|
182
|
+
export declare function layout(world: BiomeWorld, settings?: TimberValleySettings): TimberValleyLayout;
|
|
183
|
+
/** The scene's world on the CPU (heights, climate, biomes), for placing subjects and cameras. */
|
|
184
|
+
export declare function world(settings?: TimberValleySettings): Promise<BiomeWorld>;
|
|
185
|
+
/**
|
|
186
|
+
* What a look family writes in the valley: the sky with its clouds, the preset's Tonemap and its `grade` (the sky rows and
|
|
187
|
+
* the family's tonemap look, so the family's curve, vignette, dither and saturation reach the frame), and the water and
|
|
188
|
+
* fire where the valley has them. Until 2026-11-29 the Tonemap went only to the sky rows, which carry no curve, so every
|
|
189
|
+
* family left the valley on Tonemap's default Neutral curve with no vignette or dither (KB-SCENES-TVTONE1).
|
|
190
|
+
*/
|
|
191
|
+
export declare function lookTargets(parts: {
|
|
192
|
+
readonly preset: Pick<PresetScene, 'sky' | 'tonemap'>;
|
|
193
|
+
readonly grade: Grade;
|
|
194
|
+
readonly clouds: VolumetricClouds;
|
|
195
|
+
readonly water?: LookFamilyTargets['water'];
|
|
196
|
+
readonly fireFront?: FireFront;
|
|
197
|
+
}): LookFamilyTargets;
|
|
198
|
+
/**
|
|
199
|
+
* Builds the scene into `engine`: sky, clouds, weather, the valley and its forest, the town lots, and the fire.
|
|
200
|
+
* @throws TypeError or RangeError for bad settings, before anything is built.
|
|
201
|
+
* @example
|
|
202
|
+
* const scene = await attach(engine, { weather: 'redFlag', fireTime: 600 });
|
|
203
|
+
* scene.view('ridge');
|
|
204
|
+
*/
|
|
205
|
+
export declare function attach(engine: EngineKernel, settings?: TimberValleySettings): Promise<TimberValleyScene>;
|
|
206
|
+
/** The most fire time `fire: 'burnt'` runs while waiting for the fire to go out, seconds: 30 days. */
|
|
207
|
+
export declare const BURN_OUT_LIMIT: number;
|
|
208
|
+
/**
|
|
209
|
+
* Runs a fire until nothing burns and no ember waits (`settle`), for `fire: 'burnt'`, and resolves with its fire time.
|
|
210
|
+
* A surface fire in this valley's timber litter runs on for days (about 2 days of fire time on the 8 m grid): until
|
|
211
|
+
* 2026-11-27 the scene stopped it after one, so the burned valley still burned (KB-VFX-DARKTRAILS1). Throws a coded
|
|
212
|
+
* error, never a picture of a fire still burning, if it has not gone out by {@link BURN_OUT_LIMIT}; `signal` aborts it.
|
|
213
|
+
*/
|
|
214
|
+
export declare function burnOut(fire: {
|
|
215
|
+
settle(maxSeconds: number, signal?: AbortSignal): Promise<number>;
|
|
216
|
+
readonly active: boolean;
|
|
217
|
+
}, signal?: AbortSignal): Promise<number>;
|
|
218
|
+
/**
|
|
219
|
+
* Runs a fire's past `seconds` with its weather: the drive and the front step together in 10 s steps, so the front has
|
|
220
|
+
* the weather's wind and the fuel dried by its humidity and temperature from its first second (stepped alone, a front
|
|
221
|
+
* reads no wind until the drive's first frame and burns its past in still air).
|
|
222
|
+
*/
|
|
223
|
+
export declare function rollFire(drive: {
|
|
224
|
+
update(delta?: number): unknown;
|
|
225
|
+
advanceTime(seconds: number): void;
|
|
226
|
+
}, fire: {
|
|
227
|
+
advanceTime(seconds: number): void;
|
|
228
|
+
}, seconds: number): void;
|
|
229
|
+
export {};
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { t as e } from "./timber-valley-info-vVI2nwDs.js";
|
|
2
|
+
import { applyFamilySky as t, applyLookFamily as n } from "./look-family.js";
|
|
3
|
+
import { t as r } from "./errors-fc4i1pSL.js";
|
|
4
|
+
import { WEATHER_LOOKS as i, WEATHER_SETTINGS as a, applyWeatherSettings as o } from "@margoengine/weather/settings";
|
|
5
|
+
import { applyFireSettings as s } from "@margoengine/vfx/settings";
|
|
6
|
+
import { PresetScene as c, sunScene as l } from "@margoengine/sky/scenes";
|
|
7
|
+
import { degrees as u, sunPath as d } from "@margoengine/sky/sun";
|
|
8
|
+
import { Shadows as f } from "@margoengine/shadows";
|
|
9
|
+
import { GTAO as p } from "@margoengine/post/gtao";
|
|
10
|
+
import { BiomeWorld as m } from "@margoengine/biomes";
|
|
11
|
+
import { pathExclusions as h } from "@margoengine/biomes/splines";
|
|
12
|
+
import { BiomeView as g } from "@margoengine/biomes/view";
|
|
13
|
+
import { VolumetricClouds as _ } from "@margoengine/sky/volumetric-clouds";
|
|
14
|
+
import { WEATHER_PRESETS as v, WeatherMachine as ee } from "@margoengine/weather";
|
|
15
|
+
import { WeatherDrive as y } from "@margoengine/weather/drive";
|
|
16
|
+
import { rockiesValleyWorld as b } from "@margoengine/biomes/presets";
|
|
17
|
+
import { createRelief as x } from "@margoengine/biomes/relief";
|
|
18
|
+
import "@margoengine/biomes/valley";
|
|
19
|
+
import { fuelMap as te, herbaceousCuring as ne } from "@margoengine/biomes/fuel";
|
|
20
|
+
import { layoutSettlements as S } from "@margoengine/biomes/settlements";
|
|
21
|
+
import { FireFront as C } from "@margoengine/vfx/fire-front";
|
|
22
|
+
import { Grade as w } from "@margoengine/tonemap/grade";
|
|
23
|
+
//#region src/timber-valley.ts
|
|
24
|
+
var T = e, E = 4096, D = 2500, re = 1500, O = [-2048, -2048];
|
|
25
|
+
function k(e) {
|
|
26
|
+
if (typeof e != "object" || !e) throw TypeError("timber-valley: pass settings as an object.");
|
|
27
|
+
let { signal: t, ...n } = e, r = {
|
|
28
|
+
...Object.fromEntries(Object.entries(T.settings).map(([e, t]) => [e, t.default])),
|
|
29
|
+
...n
|
|
30
|
+
};
|
|
31
|
+
for (let [e, t] of Object.entries(T.settings)) {
|
|
32
|
+
let n = r[e];
|
|
33
|
+
if (t.range && !(typeof n == "number" && n >= t.range[0] && n <= t.range[1])) throw RangeError(`timber-valley: ${e} is out of range; pass ${t.range[0]} to ${t.range[1]}.`);
|
|
34
|
+
if (t.options && !t.options.includes(n)) throw RangeError(`timber-valley: unknown ${e}; pass ${t.options.join(" or ")}.`);
|
|
35
|
+
}
|
|
36
|
+
if (!Number.isInteger(r.houses)) throw RangeError("timber-valley: houses is not a whole number; pass 0 to 256.");
|
|
37
|
+
if (!Number.isInteger(r.seed) || r.seed < 0) throw RangeError("timber-valley: seed must be a whole number 0 or more.");
|
|
38
|
+
if (!Number.isInteger(r.standSeed)) throw RangeError("timber-valley: standSeed must be a whole number; pass 0 to 4294967295.");
|
|
39
|
+
if (!/^\d{4}-\d{2}-\d{2}$/.test(r.date) || Number.isNaN(Date.parse(r.date))) throw RangeError("timber-valley: date is not a date; pass YYYY-MM-DD.");
|
|
40
|
+
if (r.meshes !== void 0 && (typeof r.meshes != "object" || r.meshes === null)) throw TypeError("timber-valley: meshes must be an object of mesh parts by key.");
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
43
|
+
function A(e) {
|
|
44
|
+
let t = Date.parse(e + "T12:00:00Z"), n = Date.UTC(Number(e.slice(0, 4)), 0, 1, 12);
|
|
45
|
+
return Math.round((t - n) / 864e5) + 1;
|
|
46
|
+
}
|
|
47
|
+
function j(e, t) {
|
|
48
|
+
let n = (t + 180) * Math.PI / 180, r = Math.atan2(Math.sin(n), -Math.cos(n)), a = e === "calm" ? {
|
|
49
|
+
wind: 2,
|
|
50
|
+
gust: .15,
|
|
51
|
+
cloud: .2,
|
|
52
|
+
humidity: .35,
|
|
53
|
+
temperature: 27
|
|
54
|
+
} : e === "redFlag" ? (({ storm: e, ...t }) => t)(i.redFlag) : e === "blowup" ? {
|
|
55
|
+
wind: 20,
|
|
56
|
+
gust: .8,
|
|
57
|
+
humidity: .12,
|
|
58
|
+
temperature: 30,
|
|
59
|
+
cloud: .15
|
|
60
|
+
} : {
|
|
61
|
+
wind: 6,
|
|
62
|
+
gust: .3,
|
|
63
|
+
smoke: i.wildfireSmoke.smoke,
|
|
64
|
+
cloud: .3,
|
|
65
|
+
humidity: .3,
|
|
66
|
+
temperature: 22
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
...v.clear,
|
|
70
|
+
...a,
|
|
71
|
+
windDirection: r
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function M(e, t = {}) {
|
|
75
|
+
let n = k(t), r = x({
|
|
76
|
+
seed: n.seed,
|
|
77
|
+
origin: O,
|
|
78
|
+
size: [E, E],
|
|
79
|
+
...b.relief
|
|
80
|
+
}).mountainValley, i = (e) => {
|
|
81
|
+
let t = [];
|
|
82
|
+
if (e) for (let n = 0; n + 1 < e.length; n += 2) t.push([e[n] / 1e3, e[n + 1] / 1e3]);
|
|
83
|
+
return t;
|
|
84
|
+
}, a = i(r.axis), o = i(r.rail), s = i(r.creek), c = (e) => a[Math.min(a.length - 1, Math.round(e / 16))], l = (e) => o[Math.min(o.length - 1, Math.round(e / 16))] ?? c(e), u = (e) => {
|
|
85
|
+
let t = c(e), n = l(e), r = n[0] - t[0], i = n[1] - t[1], a = Math.hypot(r, i) || 1;
|
|
86
|
+
return [Math.round(n[0] + r / a * 40), Math.round(n[1] + i / a * 40)];
|
|
87
|
+
}, d = (e) => {
|
|
88
|
+
let t = c(e - 64), n = c(e + 64), r = Math.hypot(n[0] - t[0], n[1] - t[1]) || 1;
|
|
89
|
+
return [(n[0] - t[0]) / r, (n[1] - t[1]) / r];
|
|
90
|
+
}, f = {
|
|
91
|
+
points: o,
|
|
92
|
+
width: 10,
|
|
93
|
+
edge: 2
|
|
94
|
+
}, p = {
|
|
95
|
+
points: s,
|
|
96
|
+
width: 14,
|
|
97
|
+
edge: 2
|
|
98
|
+
}, m = n.houses > 0 ? S(e, {
|
|
99
|
+
seed: n.seed,
|
|
100
|
+
sites: [u(700), u(2600)],
|
|
101
|
+
villages: 2,
|
|
102
|
+
spacing: 400,
|
|
103
|
+
houses: Math.ceil(n.houses / 2),
|
|
104
|
+
pattern: "grid",
|
|
105
|
+
grid: {
|
|
106
|
+
toward: d(700),
|
|
107
|
+
block: [64, 32],
|
|
108
|
+
lot: 12,
|
|
109
|
+
street: 10
|
|
110
|
+
},
|
|
111
|
+
siteGrade: .2,
|
|
112
|
+
avoid: h([f, p])
|
|
113
|
+
}) : {
|
|
114
|
+
villages: [],
|
|
115
|
+
roads: [],
|
|
116
|
+
lanes: [],
|
|
117
|
+
paths: [],
|
|
118
|
+
exclusions: []
|
|
119
|
+
}, g = m.villages.flatMap((e) => e.houses.map((e) => ({
|
|
120
|
+
at: [e.centre[0], e.centre[1]],
|
|
121
|
+
radius: Math.max(e.size[0], e.size[1]) / 2
|
|
122
|
+
}))), _ = c(250), v = [{
|
|
123
|
+
at: [_[0] + 60, _[1] + 380],
|
|
124
|
+
time: 0
|
|
125
|
+
}];
|
|
126
|
+
return {
|
|
127
|
+
creek: s,
|
|
128
|
+
rail: o,
|
|
129
|
+
axis: a,
|
|
130
|
+
town: {
|
|
131
|
+
...m,
|
|
132
|
+
exclusions: [...m.exclusions, ...h([f, p])]
|
|
133
|
+
},
|
|
134
|
+
structures: g,
|
|
135
|
+
ignitions: v
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
async function N(e = {}) {
|
|
139
|
+
let t = k(e);
|
|
140
|
+
return m.create({
|
|
141
|
+
seed: t.seed,
|
|
142
|
+
origin: O,
|
|
143
|
+
size: [E, E],
|
|
144
|
+
climate: b.climate,
|
|
145
|
+
height: { relief: b.relief },
|
|
146
|
+
biomes: b.biomes,
|
|
147
|
+
...e.signal ? { signal: e.signal } : {}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function P(e) {
|
|
151
|
+
let { preset: t, grade: n, clouds: r, water: i, fireFront: a } = e;
|
|
152
|
+
return {
|
|
153
|
+
sky: {
|
|
154
|
+
sky: t.sky,
|
|
155
|
+
clouds: r,
|
|
156
|
+
tonemap: t.tonemap,
|
|
157
|
+
grade: n
|
|
158
|
+
},
|
|
159
|
+
tonemap: {
|
|
160
|
+
tonemap: t.tonemap,
|
|
161
|
+
grade: n
|
|
162
|
+
},
|
|
163
|
+
...i ? { water: i } : {},
|
|
164
|
+
...a ? {
|
|
165
|
+
fire: a,
|
|
166
|
+
smoke: a
|
|
167
|
+
} : {}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function F(e, r = {}) {
|
|
171
|
+
let i = k(r), a = i.quality === "film", m = [], h = (e) => {
|
|
172
|
+
for (let e of m.reverse()) e();
|
|
173
|
+
throw e;
|
|
174
|
+
}, v = await N(r);
|
|
175
|
+
m.push(() => v.dispose());
|
|
176
|
+
try {
|
|
177
|
+
let h = M(v, i), x = (e, t) => v.heightAt(e, t), S = d({
|
|
178
|
+
latitude: u(i.latitude),
|
|
179
|
+
dayOfYear: A(i.date),
|
|
180
|
+
hour: i.hour
|
|
181
|
+
}), k = c.attach(e, {
|
|
182
|
+
...l(S.azimuth.degrees, S.elevation.degrees),
|
|
183
|
+
fog: 3.912 / 4e4
|
|
184
|
+
});
|
|
185
|
+
if (k.sky.options.night) {
|
|
186
|
+
let { moonPosition: e } = await import("@margoengine/sky/astro"), t = Date.parse(i.date + "T00:00:00Z") + (i.hour - i.longitude / 15) * 36e5, n = e(new Date(t), {
|
|
187
|
+
latitude: u(i.latitude),
|
|
188
|
+
longitude: u(i.longitude)
|
|
189
|
+
});
|
|
190
|
+
k.sky.options.night = {
|
|
191
|
+
moonDirection: [...n.direction],
|
|
192
|
+
moonPhase: Math.max(-1, Math.min(1, 2 * n.illumination - 1)),
|
|
193
|
+
moonLitBySun: !0
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
m.push(() => k.dispose());
|
|
197
|
+
let N = new w();
|
|
198
|
+
k.tonemap.options.extensions = [N];
|
|
199
|
+
let F = new p({
|
|
200
|
+
radius: 2,
|
|
201
|
+
slices: a ? 3 : 2,
|
|
202
|
+
steps: a ? 8 : 6
|
|
203
|
+
});
|
|
204
|
+
k.post.addEffect(F, 0);
|
|
205
|
+
let I = f.attach(e, {
|
|
206
|
+
resolution: a ? 4096 : 2048,
|
|
207
|
+
distance: 900,
|
|
208
|
+
lambda: .8,
|
|
209
|
+
lightSize: .02,
|
|
210
|
+
normalBias: .2,
|
|
211
|
+
casterMargin: 300
|
|
212
|
+
});
|
|
213
|
+
m.push(() => I.dispose());
|
|
214
|
+
let B = {};
|
|
215
|
+
n(i.look, { biomes: B });
|
|
216
|
+
let V = await g.attach(e, v, {
|
|
217
|
+
...B,
|
|
218
|
+
sky: k.sky,
|
|
219
|
+
shadows: I,
|
|
220
|
+
water: { rivers: "auto" },
|
|
221
|
+
clipmap: { anchor: "camera" },
|
|
222
|
+
exclusions: h.town.exclusions,
|
|
223
|
+
grass: { cured: ne(i.grassMoisture) },
|
|
224
|
+
...i.standSeed > 0 ? { standSeed: i.standSeed } : {},
|
|
225
|
+
radius: a ? 2e3 : 1e3,
|
|
226
|
+
...i.meshes ? { meshes: i.meshes } : {},
|
|
227
|
+
...r.signal ? { signal: r.signal } : {}
|
|
228
|
+
});
|
|
229
|
+
m.push(() => V.dispose());
|
|
230
|
+
let H = b.relief.base, U = _.attach(e, {
|
|
231
|
+
sky: k.sky,
|
|
232
|
+
type: "cumulus",
|
|
233
|
+
coverage: .2,
|
|
234
|
+
bottom: H + D,
|
|
235
|
+
top: H + D + re
|
|
236
|
+
});
|
|
237
|
+
m.push(() => U.dispose());
|
|
238
|
+
let W, G;
|
|
239
|
+
if (a) {
|
|
240
|
+
let [{ TAA: t }, { ScatterVelocity: n }, { MotionBlur: r }] = await Promise.all([
|
|
241
|
+
import("@margoengine/taa"),
|
|
242
|
+
import("@margoengine/scatter/velocity"),
|
|
243
|
+
import("@margoengine/post/motion-blur")
|
|
244
|
+
]), i = t.attach(e, { depth: () => k.post.depthTexture });
|
|
245
|
+
W = i, m.push(() => i.dispose());
|
|
246
|
+
let a = new r({
|
|
247
|
+
velocity: () => i.velocity,
|
|
248
|
+
shutter: .5
|
|
249
|
+
});
|
|
250
|
+
k.post.addEffect(a), G = a, m.push(() => {
|
|
251
|
+
k.post.removeEffect(a), a.dispose();
|
|
252
|
+
});
|
|
253
|
+
for (let e of V.objects?.swaying ?? []) {
|
|
254
|
+
let t = new n(e), r = i.add(t);
|
|
255
|
+
m.push(() => {
|
|
256
|
+
r(), t.dispose();
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
let K = te(v, {
|
|
261
|
+
step: a ? 8 : 16,
|
|
262
|
+
bare: h.town.exclusions
|
|
263
|
+
}), q = new ee(j(i.weather, i.windFrom), { seed: i.seed });
|
|
264
|
+
m.push(() => q.dispose());
|
|
265
|
+
let J;
|
|
266
|
+
i.fire !== "none" && (J = C.attach(e, {
|
|
267
|
+
ground: x,
|
|
268
|
+
size: [E, E],
|
|
269
|
+
origin: O,
|
|
270
|
+
cell: a ? 4 : 8,
|
|
271
|
+
fuel: (e, t) => K.at(e, t),
|
|
272
|
+
structures: h.structures,
|
|
273
|
+
ignitions: h.ignitions,
|
|
274
|
+
seed: i.seed,
|
|
275
|
+
columns: a ? 12 : 6,
|
|
276
|
+
flames: a ? 24 : 12
|
|
277
|
+
}), m.push(() => J?.dispose()));
|
|
278
|
+
let Y = y.attach(e, {
|
|
279
|
+
weather: q,
|
|
280
|
+
listener: e.camera,
|
|
281
|
+
clouds: U,
|
|
282
|
+
...J ? { fires: J } : {}
|
|
283
|
+
});
|
|
284
|
+
m.push(() => Y.dispose?.()), J && (R(Y, J, i.fireTime), i.fire === "burnt" && await L(J, r.signal));
|
|
285
|
+
let X = i.look, Z = (e) => {
|
|
286
|
+
X = e, n(e, P({
|
|
287
|
+
preset: k,
|
|
288
|
+
grade: N,
|
|
289
|
+
clouds: U,
|
|
290
|
+
water: V.water,
|
|
291
|
+
fireFront: J
|
|
292
|
+
}));
|
|
293
|
+
};
|
|
294
|
+
Z(i.look);
|
|
295
|
+
let Q = ie(h, x), $ = {};
|
|
296
|
+
for (let e of T.shots ?? []) {
|
|
297
|
+
let t = Q[e.camera[0]], n = Q[e.camera[e.camera.length - 1]];
|
|
298
|
+
$[e.name] = [{
|
|
299
|
+
type: "camera",
|
|
300
|
+
id: "camera",
|
|
301
|
+
path: "linear",
|
|
302
|
+
keys: [{
|
|
303
|
+
time: 0,
|
|
304
|
+
position: [...t.position],
|
|
305
|
+
target: [...t.target],
|
|
306
|
+
fov: 45
|
|
307
|
+
}, {
|
|
308
|
+
time: e.seconds,
|
|
309
|
+
position: [...n.position],
|
|
310
|
+
target: [...n.target],
|
|
311
|
+
fov: 45,
|
|
312
|
+
ease: "smoothstep"
|
|
313
|
+
}]
|
|
314
|
+
}];
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
settings: i,
|
|
318
|
+
height: x,
|
|
319
|
+
anchors: Q,
|
|
320
|
+
views: T.views,
|
|
321
|
+
view(t, n = 50) {
|
|
322
|
+
let r = Q[t];
|
|
323
|
+
if (!r) throw RangeError(`timber-valley: no anchor ${t}; pass one of ${Object.keys(Q).join(", ")}.`);
|
|
324
|
+
e.camera.position = [...r.position], e.camera.target = [...r.target], e.camera.fov = n;
|
|
325
|
+
},
|
|
326
|
+
shots: T.shots ?? [],
|
|
327
|
+
tracks: $,
|
|
328
|
+
targets: T.targets ?? {},
|
|
329
|
+
layout: h,
|
|
330
|
+
applyLook: Z,
|
|
331
|
+
applySettings(e) {
|
|
332
|
+
for (let [n, r] of Object.entries(e)) if (n === "weather") o(q, {
|
|
333
|
+
...z(q),
|
|
334
|
+
...r
|
|
335
|
+
});
|
|
336
|
+
else if (n === "sky") t(X, {
|
|
337
|
+
sky: k.sky,
|
|
338
|
+
clouds: U,
|
|
339
|
+
tonemap: k.tonemap,
|
|
340
|
+
grade: N
|
|
341
|
+
}, r);
|
|
342
|
+
else if (n === "fire") J && s(J, r);
|
|
343
|
+
else throw RangeError(`timber-valley: no settings target ${n}; pass weather, sky or fire.`);
|
|
344
|
+
},
|
|
345
|
+
advanceTime(e) {
|
|
346
|
+
Y.advanceTime(e), k.sky.advanceTime?.(e), J?.advanceTime(e);
|
|
347
|
+
},
|
|
348
|
+
settle: () => V.whenIdle(),
|
|
349
|
+
parts: {
|
|
350
|
+
world: v,
|
|
351
|
+
view: V,
|
|
352
|
+
preset: k,
|
|
353
|
+
grade: N,
|
|
354
|
+
clouds: U,
|
|
355
|
+
weather: q,
|
|
356
|
+
drive: Y,
|
|
357
|
+
shadows: I,
|
|
358
|
+
occlusion: F,
|
|
359
|
+
fuel: K,
|
|
360
|
+
fireFront: J,
|
|
361
|
+
taa: W,
|
|
362
|
+
motionBlur: G
|
|
363
|
+
},
|
|
364
|
+
dispose() {
|
|
365
|
+
for (let e of m.reverse()) e();
|
|
366
|
+
m.length = 0;
|
|
367
|
+
},
|
|
368
|
+
[Symbol.dispose]() {
|
|
369
|
+
this.dispose();
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
} catch (e) {
|
|
373
|
+
return h(e);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
var I = 2592e3;
|
|
377
|
+
async function L(e, t) {
|
|
378
|
+
let n = await e.settle(I, t);
|
|
379
|
+
if (e.active) throw r("state", `timber-valley fire 'burnt': the fire still burns after ${I} s of fire time; use fire 'running'`);
|
|
380
|
+
return n;
|
|
381
|
+
}
|
|
382
|
+
function R(e, t, n) {
|
|
383
|
+
e.update(0);
|
|
384
|
+
for (let r = 0; r < n; r += 10) {
|
|
385
|
+
let i = Math.min(10, n - r);
|
|
386
|
+
e.advanceTime(i), t.advanceTime(i);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function z(e) {
|
|
390
|
+
let t = e.state, n = {};
|
|
391
|
+
for (let e of a) e.name in t && (n[e.name] = t[e.name]);
|
|
392
|
+
return n;
|
|
393
|
+
}
|
|
394
|
+
function ie(e, t) {
|
|
395
|
+
let n = (t) => e.axis[Math.max(0, Math.min(e.axis.length - 1, Math.round(t / 16)))], r = (t) => e.rail[Math.max(0, Math.min(e.rail.length - 1, Math.round(t / 16)))] ?? n(t), i = (t) => e.creek[Math.max(0, Math.min(e.creek.length - 1, Math.round(t / 16)))], a = (e, n, r = 0, i = 0) => [
|
|
396
|
+
e[0] + r,
|
|
397
|
+
Math.max(t(e[0] + r, e[1] + i), 0) + n,
|
|
398
|
+
e[1] + i
|
|
399
|
+
], o = e.ignitions[0].at, s = e.structures[0]?.at ?? r(700), c = (e, t, n) => ({
|
|
400
|
+
position: e,
|
|
401
|
+
target: t,
|
|
402
|
+
about: n
|
|
403
|
+
});
|
|
404
|
+
return {
|
|
405
|
+
"aerial-west": c(a(n(0), 260), a(n(1400), 60), "high over the valley mouth, looking up the valley"),
|
|
406
|
+
"aerial-east": c(a(n(900), 220), a(n(2400), 40), "over the town, looking up the valley"),
|
|
407
|
+
town: c(a(s, 1.7, -40, 0), a(s, 2, 60, 0), "eye level by the town lots, looking up the street"),
|
|
408
|
+
"town-up": c(a(s, 1.7, 40, 0), a(s, 30, 160, 300), "the lots, turning toward the south ridge"),
|
|
409
|
+
rail: c(a(r(400), 1.2), a(r(800), 1.5), "on the rail grade, looking up the line"),
|
|
410
|
+
"rail-far": c(a(r(600), 1.2), a(r(1e3), 1.5), "up the rail grade"),
|
|
411
|
+
creek: c(a(i(1200), 1, 0, 6), a(i(1500), .5), "on the creek bank"),
|
|
412
|
+
"creek-up": c(a(i(1300), 1, 0, 6), a(i(1600), .5), "up the creek"),
|
|
413
|
+
ridge: c(a(n(1200), 600, 0, -900), a(n(900), 300, 0, 900), "the north ridge, across the valley to the south wall"),
|
|
414
|
+
"ridge-pan": c(a(n(1300), 600, 0, -900), a(n(500), 300, 0, 600), "the north ridge, panning toward the fire"),
|
|
415
|
+
"fire-line": c(a(o, 80, 500, -200), a(o, 40, 0, -100), "side on to the front on the south wall"),
|
|
416
|
+
"fire-line-near": c(a(o, 60, 400, -100), a(o, 40, 0, -150), "closer on the front"),
|
|
417
|
+
blowup: c(a(s, 3, 120, -40), a(o, 200, 0, -200), "from the valley floor by the town toward the fire"),
|
|
418
|
+
"blowup-push": c(a(s, 3, 40, -20), a(o, 250, 0, -250), "pushing in toward the fire"),
|
|
419
|
+
aftermath: c(a(n(500), 40), a(n(500), 250, 0, 700), "the burned south wall from the floor"),
|
|
420
|
+
"aftermath-crane": c(a(n(500), 260), a(n(700), 120, 0, 700), "craned up over the burned walls")
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
//#endregion
|
|
424
|
+
export { I as BURN_OUT_LIMIT, F as attach, L as burnOut, k as check, T as info, M as layout, P as lookTargets, R as rollFire, j as weatherState, N as world };
|