@margoengine/vfx 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 (104) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +4 -0
  3. package/README.md +2240 -2
  4. package/dist/base-LGs65K7K.js +709 -0
  5. package/dist/base.d.ts +869 -0
  6. package/dist/base.js +1 -0
  7. package/dist/blown-sand.d.ts +218 -0
  8. package/dist/blown-sand.js +700 -0
  9. package/dist/clouds.d.ts +237 -0
  10. package/dist/clouds.js +583 -0
  11. package/dist/compat-BFjXAQuu.js +14 -0
  12. package/dist/compat-CVSEj1Bp.js +217 -0
  13. package/dist/compat.d.ts +59 -0
  14. package/dist/curves.d.ts +11 -0
  15. package/dist/curves.js +59 -0
  16. package/dist/debris.d.ts +154 -0
  17. package/dist/debris.js +290 -0
  18. package/dist/depth-collide.d.ts +7 -0
  19. package/dist/depth-collide.js +96 -0
  20. package/dist/dust-current.d.ts +66 -0
  21. package/dist/dust-current.js +92 -0
  22. package/dist/emitter.d.ts +10 -0
  23. package/dist/emitter.js +125 -0
  24. package/dist/events.d.ts +9 -0
  25. package/dist/events.js +131 -0
  26. package/dist/extra-CgGjbojB.js +4 -0
  27. package/dist/extra.d.ts +2 -0
  28. package/dist/fields.d.ts +11 -0
  29. package/dist/fields.js +95 -0
  30. package/dist/fire-front.d.ts +610 -0
  31. package/dist/fire-front.js +1080 -0
  32. package/dist/fire.d.ts +140 -0
  33. package/dist/fire.js +194 -0
  34. package/dist/flame-ramp-VoBKpYnM.js +75 -0
  35. package/dist/flame-ramp.d.ts +61 -0
  36. package/dist/flame.d.ts +428 -0
  37. package/dist/flame.js +817 -0
  38. package/dist/flipbook.d.ts +7 -0
  39. package/dist/flipbook.js +23 -0
  40. package/dist/flocking-shaders.d.ts +48 -0
  41. package/dist/flocking-sim.d.ts +623 -0
  42. package/dist/flocking.d.ts +145 -0
  43. package/dist/flocking.js +1846 -0
  44. package/dist/fog-B-kBv7g0.js +32 -0
  45. package/dist/frame-BuvMFBPp.js +4 -0
  46. package/dist/frame.d.ts +7 -0
  47. package/dist/gunfire.d.ts +742 -0
  48. package/dist/gunfire.js +1214 -0
  49. package/dist/hash-Btsp6fGK.js +7 -0
  50. package/dist/hash.d.ts +2 -0
  51. package/dist/index.d.ts +17 -0
  52. package/dist/index.js +60 -0
  53. package/dist/json.d.ts +53 -0
  54. package/dist/json.js +239 -0
  55. package/dist/lit-Dx2tNwP-.js +152 -0
  56. package/dist/lit.d.ts +18 -0
  57. package/dist/lit.js +1 -0
  58. package/dist/mesh.d.ts +16 -0
  59. package/dist/mesh.js +248 -0
  60. package/dist/node-system.d.ts +315 -0
  61. package/dist/node-system.js +384 -0
  62. package/dist/nodes.d.ts +14 -0
  63. package/dist/nodes.js +293 -0
  64. package/dist/obstacles.d.ts +3 -0
  65. package/dist/obstacles.js +25 -0
  66. package/dist/over-life.d.ts +14 -0
  67. package/dist/over-life.js +94 -0
  68. package/dist/reactive-mask-B8xbyzlk.js +69 -0
  69. package/dist/require-webgpu--tUXPsmA.js +7 -0
  70. package/dist/ribbons.d.ts +22 -0
  71. package/dist/ribbons.js +165 -0
  72. package/dist/schedule.d.ts +29 -0
  73. package/dist/schedule.js +47 -0
  74. package/dist/settings.d.ts +362 -0
  75. package/dist/settings.js +707 -0
  76. package/dist/shader.d.ts +49 -0
  77. package/dist/shadows.d.ts +26 -0
  78. package/dist/shadows.js +182 -0
  79. package/dist/shapes.d.ts +34 -0
  80. package/dist/shapes.js +81 -0
  81. package/dist/shared/fog.d.ts +33 -0
  82. package/dist/shared/pass.d.ts +53 -0
  83. package/dist/shared/settings.d.ts +89 -0
  84. package/dist/skinned.d.ts +11 -0
  85. package/dist/skinned.js +104 -0
  86. package/dist/smoke.d.ts +283 -0
  87. package/dist/smoke.js +504 -0
  88. package/dist/soft.d.ts +17 -0
  89. package/dist/soft.js +55 -0
  90. package/dist/solid.d.ts +168 -0
  91. package/dist/solid.js +403 -0
  92. package/dist/sort.d.ts +3 -0
  93. package/dist/sort.js +58 -0
  94. package/dist/space.d.ts +14 -0
  95. package/dist/space.js +88 -0
  96. package/dist/stretch.d.ts +7 -0
  97. package/dist/stretch.js +40 -0
  98. package/dist/texture.d.ts +8 -0
  99. package/dist/texture.js +45 -0
  100. package/dist/view-RKprOPAy.js +30 -0
  101. package/dist/view-rect-DkeiiUtw.js +13 -0
  102. package/dist/wrap.d.ts +3 -0
  103. package/dist/wrap.js +5 -0
  104. package/package.json +198 -4
@@ -0,0 +1,610 @@
1
+ /// <reference lib="esnext.disposable" preserve="true" />
2
+ import type { EngineKernel } from '@margoengine/core';
3
+ import { type Engine, type EnginePlugin } from '@margoengine/core/extension';
4
+ import type { Smoke, SmokeOptions } from '@margoengine/vfx/smoke';
5
+ import type { Flame, FlameOptions } from '@margoengine/vfx/flame';
6
+ import type { VFX } from '@margoengine/vfx/base';
7
+ /** One size class of a fuel bed. */
8
+ export interface FuelClass {
9
+ /** Fuel load, tons per acre (Anderson 1982's unit). */
10
+ readonly load: number;
11
+ /** Surface-area-to-volume ratio, 1/ft. */
12
+ readonly sav: number;
13
+ /** Which kind of fuel: dead classes dry with the weather, live ones keep their moisture. */
14
+ readonly live?: boolean;
15
+ /** Dead size class (1, 10 or 100 hours), which sets the moisture it holds beside the 1-hour value. */
16
+ readonly hours?: 1 | 10 | 100;
17
+ }
18
+ /** A fuel bed: its classes, depth and the moisture at which a fire no longer spreads. */
19
+ export interface FuelModel {
20
+ /** A name for lookups and tests. */
21
+ readonly name: string;
22
+ /** Size classes, at least one. */
23
+ readonly classes: readonly FuelClass[];
24
+ /** Fuel bed depth, ft. */
25
+ readonly depth: number;
26
+ /** Moisture of extinction of the dead fuel, as a fraction of dry weight (0.12 is 12 percent). */
27
+ readonly extinction: number;
28
+ /** A building: it burns for `structureBurnTime` seconds and ignites from embers and flame exposure. */
29
+ readonly structure?: boolean;
30
+ /** The stand over the bed, for crown fire ({@link crownBehaviour}); none is a bed with no crowns (grass, brush, slash). */
31
+ readonly canopy?: CanopyFuel;
32
+ }
33
+ /** Anderson 1982's fuel models for grass, brush and timber, by name `FM1` ... `FM13` (loads from table 1 of INT-GTR-122, surface-area-to-volume ratios from table 7 of INT-30 except FM7's live 1,500 1/ft, the standard value of Andrews 2018 table 8a where INT-30 prints 1,550), plus `STRUCTURE`. The timber models FM8, FM9 and FM10 carry a `canopy` for crown fire. */
34
+ export declare const FUEL_MODELS: Readonly<Record<string, FuelModel>>;
35
+ /** The conditions a spread rate is for. */
36
+ export interface FireConditions {
37
+ /** Dead 1-hour fuel moisture, a fraction of dry weight. The 10 and 100 hour classes hold 0.01 and 0.02 more. */
38
+ moisture: number;
39
+ /** Live fuel moisture, a fraction of dry weight (chaparral is 0.6 to 1.2). Default 1. */
40
+ liveMoisture?: number;
41
+ /** Dead 10-hour fuel moisture, a fraction of dry weight. Default `moisture` + 0.01. */
42
+ moisture10?: number;
43
+ /** Dead 100-hour fuel moisture, a fraction of dry weight. Default `moisture` + 0.02. Albini 1976's nomographs hold every dead class at the 1-hour value. */
44
+ moisture100?: number;
45
+ /** Wind at midflame height, m/s. Default 0. */
46
+ wind?: number;
47
+ /** Slope, rise over run along the direction of spread. Default 0. */
48
+ slope?: number;
49
+ }
50
+ /** What a fuel bed does in given conditions; every number is for the head of a fire that spreads straight upwind. */
51
+ export interface FireBehaviour {
52
+ /** Rate of spread of the head, m/s. */
53
+ rate: number;
54
+ /** Rate with no wind and no slope, m/s. */
55
+ rate0: number;
56
+ /** Rothermel's wind factor phi_w. */
57
+ windFactor: number;
58
+ /** Rothermel's slope factor phi_s. */
59
+ slopeFactor: number;
60
+ /** Reaction intensity, kW/m^2. */
61
+ reactionIntensity: number;
62
+ /** Residence time of the flame, seconds (384 / sigma minutes). */
63
+ residence: number;
64
+ /** Byram's fireline intensity at the head, kW/m. */
65
+ firelineIntensity: number;
66
+ /** Byram's flame length at the head, m. */
67
+ flameLength: number;
68
+ /** Head to flank length-to-breadth ratio (Anderson 1983) for the effective wind. */
69
+ lengthToBreadth: number;
70
+ }
71
+ /** A fuel bed's constants for a moisture state: everything of Rothermel's equations that wind and slope do not touch. */
72
+ export interface FuelBed {
73
+ readonly model: FuelModel;
74
+ /** Characteristic surface-area-to-volume ratio, 1/ft. */
75
+ readonly sigma: number;
76
+ /** Packing ratio. */
77
+ readonly beta: number;
78
+ /** Optimum packing ratio. */
79
+ readonly betaOp: number;
80
+ /** Reaction intensity, Btu/ft^2/min. */
81
+ readonly ir: number;
82
+ readonly rate0: number;
83
+ readonly windC: number;
84
+ readonly windB: number;
85
+ readonly windE: number;
86
+ readonly ratio: number;
87
+ readonly residence: number;
88
+ /** Total fuel burned per unit area by the front, kg/m^2 (the mass in the classes that burn). */
89
+ readonly consumed: number;
90
+ }
91
+ /**
92
+ * Precomputes a fuel bed for a moisture state (Rothermel 1972 with Albini 1976's weighting): the characteristic
93
+ * surface-area-to-volume ratio, packing ratio, reaction intensity and the spread rate with no wind and no slope.
94
+ * @throws RangeError for a model with no classes or a non-positive load, depth or surface-area-to-volume ratio, or a
95
+ * moisture outside 0 to 4.
96
+ */
97
+ export declare function fuelBed(model: FuelModel, moisture: number, liveMoisture?: number, moisture10?: number, moisture100?: number): FuelBed;
98
+ /** Rothermel's wind factor for a midflame wind of `wind` m/s (with Andrews 1986's limit 0.9 I_R). */
99
+ export declare function windFactor(bed: FuelBed, wind: number): number;
100
+ /** Rothermel's slope factor for a slope (rise over run). */
101
+ export declare const slopeFactor: (bed: FuelBed, slope: number) => number;
102
+ /**
103
+ * Fire behaviour of a fuel bed at the head of a fire (Rothermel 1972, Albini 1976). Wind and slope are taken to act
104
+ * along the same direction; `FireFront` adds them as vectors.
105
+ * @example fireBehaviour(FUEL_MODELS.FM1, { moisture: 0.08, wind: 2.2352 }).rate * 3600 / 20.1168 // about 79 chains/h
106
+ */
107
+ export declare function fireBehaviour(model: FuelModel, conditions: FireConditions): FireBehaviour;
108
+ /** Richards 1990: spread rate at `angle` radians from the head, for a fire at the focus of its ellipse. */
109
+ export declare function ellipseRate(head: number, lengthToBreadth: number, angle: number): number;
110
+ /** The canopy over a fuel bed: what a crown fire needs (Van Wagner 1977; Scott and Reinhardt 2001). */
111
+ export interface CanopyFuel {
112
+ /** Canopy base height, m: ground to the lowest live crowns and ladder fuel that carry flame upward. */
113
+ readonly baseHeight: number;
114
+ /** Canopy bulk density, kg/m^3: foliage and fine twigs per volume of the crown layer. */
115
+ readonly bulkDensity: number;
116
+ /** Stand height, m (the top of the crown layer). */
117
+ readonly height: number;
118
+ }
119
+ /** What a stand does over a surface fire: whether it crowns, how fast and how hot. */
120
+ export interface CrownBehaviour {
121
+ /** `'surface'` below Van Wagner's critical intensity, `'passive'` torching (crowns burn behind a surface head), `'active'` a running crown fire. */
122
+ type: 'surface' | 'passive' | 'active';
123
+ /** Van Wagner 1977's critical surface intensity for crowning, (0.010 z (460 + 25.9 M))^1.5 kW/m. */
124
+ initiation: number;
125
+ /** Van Wagner 1977's critical spread rate of an active crown fire, 3 / CBD m/min, here m/s. */
126
+ activeRate: number;
127
+ /** Rothermel 1991's crown fire rate, 3.34 times fuel model 10's rate at 0.4 of the 20 ft wind, m/s. */
128
+ crownRate: number;
129
+ /** Crown fraction burned, 0 to 1 (Forestry Canada 1992: 1 - exp(-0.23 (R - R_o)), R in m/min). */
130
+ fraction: number;
131
+ /** Spread rate of the fire, m/s: the surface rate, the passive blend R_s + CFB (R_c - R_s), or the crown rate. */
132
+ rate: number;
133
+ /** Byram's fireline intensity with the crowns burned, kW/m. */
134
+ firelineIntensity: number;
135
+ /** Flame length, m: Thomas 1963's 0.0266 I^(2/3) once crowns burn, else the surface flame. */
136
+ flameLength: number;
137
+ /** Head to flank ratio: Rothermel 1991's 1 + 0.125 U20 (mi/h) for a crown fire, the surface ratio blended by the fraction. */
138
+ lengthToBreadth: number;
139
+ }
140
+ /**
141
+ * Crown fire over a surface fire (Van Wagner 1977; Rothermel 1991; Forestry Canada Fire Danger Group 1992): the stand
142
+ * crowns when the surface fire's intensity reaches Van Wagner's critical value for its canopy base height and foliar
143
+ * moisture; it runs as an active crown fire when Rothermel's crown rate passes 3 / CBD m/min, else it torches
144
+ * (passive) with the crown fraction burned of the Canadian system. A crown fire that runs in from a neighbouring stand
145
+ * (`fed`) goes on as an active crown fire wherever the rate criterion holds, even over a surface fire too weak to start
146
+ * one: Scott and Reinhardt 2001's conditional crown fire.
147
+ * @param surface The surface fire's behaviour at the head ({@link fireBehaviour}).
148
+ * @param canopy The stand.
149
+ * @param foliarMoisture Foliar moisture of the crowns, a fraction of dry weight (1 is 100 percent, Van Wagner's value).
150
+ * @param crownRate Rothermel 1991's crown rate in m/s ({@link crownRate10}).
151
+ * @param wind10 The 10 m open wind, m/s, for the crown fire's shape.
152
+ * @param fed True where an active crown fire runs into this stand from a neighbour. Default false.
153
+ * @example crownBehaviour(fireBehaviour(FUEL_MODELS.FM10, { moisture: 0.05, wind: 7 }), FUEL_MODELS.FM10.canopy!, 1, 1.2, 20).type // 'active'
154
+ */
155
+ export declare function crownBehaviour(surface: FireBehaviour, canopy: CanopyFuel, foliarMoisture: number, crownRate: number, wind10: number, fed?: boolean): CrownBehaviour;
156
+ /**
157
+ * Rothermel 1991's crown fire rate, m/s: 3.34 times the rate of fuel model 10 (Anderson 1982) with its midflame wind
158
+ * at 0.4 of the 20 ft wind (the 10 m wind over 1.15, Turner and Lawson 1978), at the given slope factor.
159
+ * @param conditions The dead and live moistures; `wind` is the 10 m open wind, m/s; `slope` rise over run.
160
+ */
161
+ export declare function crownRate10(conditions: FireConditions): number;
162
+ type Vec2 = readonly [number, number];
163
+ /** The wind as `[x, z]` m/s at 10 m, or a sampler (a `WindField` fits). */
164
+ export type FireWind = Vec2 | {
165
+ sample(x: number, y: number, z: number, t: number): ArrayLike<number>;
166
+ };
167
+ /** Cell states of the burn texture's alpha channel and `FireFront.state`. */
168
+ export declare const UNBURNT = 0, BURNING = 1, BURNT = 2, NO_FUEL = 3;
169
+ /** One ignition: where, when (seconds of fire time) and how big. */
170
+ export interface FireIgnition {
171
+ /** World `[x, z]`. */
172
+ at: Vec2;
173
+ /** Fire time in seconds. Default 0. */
174
+ time?: number;
175
+ /** Radius of the ignited patch in metres. Default one cell. */
176
+ radius?: number;
177
+ }
178
+ /** A building: a footprint that burns as the `STRUCTURE` fuel. */
179
+ export interface FireStructure {
180
+ /** World `[x, z]` of the centre. */
181
+ at: Vec2;
182
+ /** Half the footprint's side, m. Default 6. */
183
+ radius?: number;
184
+ }
185
+ /** What a spread over a segment of the front gives smoke. */
186
+ export interface FireSegment {
187
+ /** World centre of the burning cells, weighted by heat. */
188
+ x: number;
189
+ z: number;
190
+ /** Ground height at the centre. */
191
+ y: number;
192
+ /** Convective heat release of the segment's cells, watts. */
193
+ heat: number;
194
+ /** Burning cells. */
195
+ cells: number;
196
+ /** Flame length of the segment's front, metres (Byram's, or Thomas's where crowns burn): the column starts at its top. */
197
+ flameLength: number;
198
+ }
199
+ /** One flame volume to draw: a stretch of the front or a burning building (see {@link FireFront.flames}). */
200
+ export interface FireFlame {
201
+ /** `'front'`: cells of the front in one segment, flames by Byram's law; `'structure'`: one building, by Heskestad's. */
202
+ kind: 'front' | 'structure';
203
+ /** World centre of the burning cells, weighted by heat. */
204
+ x: number;
205
+ z: number;
206
+ /** Ground height at the centre. */
207
+ y: number;
208
+ /** Convective heat release, watts. */
209
+ heat: number;
210
+ /** Burning cells. */
211
+ cells: number;
212
+ /** Byram's fireline intensity of the front here (heat-weighted mean), kW/m; 0 for a building. */
213
+ intensity: number;
214
+ /** Flame length, metres: Byram's 0.0775 I^0.46 for the front, Heskestad's for a building. */
215
+ flameLength: number;
216
+ /**
217
+ * Size in metres of the burning cells: for the front, `[along, across]` the stretch of fire line (the heat-weighted
218
+ * spread of its cells along their principal axes, at least one cell each), turned by `yaw`; for a building its
219
+ * `[x, z]` box.
220
+ */
221
+ footprint: [number, number];
222
+ /** Turn of `footprint` about the vertical, radians, as `Flame` `yaw`: the stretch's along axis is (cos yaw, -sin yaw) in x, z. 0 for a building. */
223
+ yaw: number;
224
+ /** The building's index in `options.structures`; -1 for the front. */
225
+ structure: number;
226
+ /** Crown fraction burned here, heat-weighted, 0 (a surface fire) to 1 (an active crown fire); 0 for a building. */
227
+ crown: number;
228
+ /** The ground's slope over the stretch, `[dy/dx, dy/dz]` (a central difference of `ground` across its footprint), as `Flame` `slope`. [0, 0] for a building. */
229
+ slope: [number, number];
230
+ /** A key that stays with the same stretch of front or the same building from step to step. */
231
+ readonly key: number;
232
+ }
233
+ /** An ember that landed. */
234
+ export interface FireSpot {
235
+ from: Vec2;
236
+ to: Vec2;
237
+ /** Fire time, seconds. */
238
+ time: number;
239
+ /** True where it started a fire. */
240
+ ignited: boolean;
241
+ }
242
+ /** `FireFront` options; the numbers in the second group are read every step. */
243
+ export interface FireFrontOptions {
244
+ /** Ground height at world `(x, z)`, metres; sets the slope. Default flat at 0. */
245
+ ground?: (x: number, z: number) => number;
246
+ /** World extent `[x, z]`, m. Default [1024, 1024]. */
247
+ size?: Vec2;
248
+ /** World `[x, z]` of the minimum corner. Default centred on the origin. */
249
+ origin?: Vec2;
250
+ /** Cell side, metres, 1 to 100. The grid holds at most 4,194,304 cells. Default 8. */
251
+ cell?: number;
252
+ /** Fuel at a place: a model, an `FM` name, or null for no fuel (road, water, rock). Default FM1. */
253
+ fuel?: FuelModel | string | ((x: number, z: number) => FuelModel | string | null | undefined);
254
+ /** Buildings, burning as the `STRUCTURE` fuel. */
255
+ structures?: readonly FireStructure[];
256
+ /** Ignitions, each at its time. */
257
+ ignitions?: readonly FireIgnition[];
258
+ /** The step of the fire, seconds, 0.05 to 5. Default 0.5. Read at construction. */
259
+ step?: number;
260
+ /** Seed of the embers' random draws. Default 1. Read at construction. */
261
+ seed?: number;
262
+ /** Segment side for the smoke, metres, at least one cell. Default 120. Read at construction. */
263
+ segment?: number;
264
+ /** Smoke columns along the front (they need an engine). 0 for none. Default 12. Read at attach. */
265
+ columns?: number;
266
+ /**
267
+ * Flame volumes along the front (they need an engine): `Flame` effects of `@margoengine/vfx/flame` placed on the
268
+ * hottest segments, each as long as Byram's flame length of that segment's intensity. 0 for none. A fixed pool: the
269
+ * count of GPU objects does not change as the fire moves. Read at attach. Default 16.
270
+ */
271
+ flames?: number;
272
+ /** Flame volumes on burning buildings (they need an engine), one per building, longest first; 0 for none. Read at attach. Default 8. */
273
+ buildingFlames?: number;
274
+ /** Heat-release share of a burning building's floor that flames leave through, 0.01 to 1: sets the vent Heskestad's height is over (a roof breach and its windows). Default 0.1. */
275
+ structureVent?: number;
276
+ /**
277
+ * Options of every flame volume (the ramp, `peak`, `opacity`, `flicker`, `tongues`, `depth`, `fog`, and `lights`: a
278
+ * `LightGroups` or `Clustered` the volumes light the land, smoke and buildings through); the placement is the front's.
279
+ */
280
+ flame?: Omit<FlameOptions, 'position' | 'length' | 'intensity' | 'heat' | 'footprint' | 'wind' | 'slope'>;
281
+ /**
282
+ * Embers over every flame volume of the front (they need an engine): sparks lofted from the flames and carried ahead
283
+ * of the front by the wind, one particle effect per volume (`VFX` of `@margoengine/vfx/base`, the hearth kit's
284
+ * embers of `snowNight` scaled to a flame of 20 m), born over the flame's footprint a third of its
285
+ * length up, their rate and speed following the flame length of the stretch. The flame volume writes its depth, so
286
+ * an ember behind the flames is hidden and one in front draws over them. Read at attach. Default true.
287
+ */
288
+ flameEmbers?: boolean;
289
+ /**
290
+ * Options handed to every smoke column, over the front's defaults: a 300 s life (the column grows into a pall over
291
+ * the valley), 16 puffs a second, slightly stable air (`stability` 1.5e-4, so it levels off at Briggs' final rise of
292
+ * a few hundred metres and spreads), wood smoke [0.24, 0.22, 0.2] at opacity 0.6, the fire's glow from below, and a
293
+ * source radius of the burning ground of its segment (2 to 60 m) unless `radius` is given.
294
+ */
295
+ smoke?: Omit<SmokeOptions, 'position' | 'heat' | 'fire' | 'wind'>;
296
+ /** Called for each ember that lands. */
297
+ onSpot?: (spot: FireSpot) => void;
298
+ /**
299
+ * The stand at a place, for crown fire: a canopy, or null for none. Default the `canopy` of the place's fuel model
300
+ * (FM8, FM9 and FM10 carry one). Read at construction.
301
+ */
302
+ canopy?: (x: number, z: number) => CanopyFuel | null | undefined;
303
+ /** Dead 1-hour fuel moisture, a fraction. A `WeatherDrive` writes it from the weather's humidity, temperature and rain while it is unset. Default 0.06. */
304
+ moisture?: number;
305
+ /** Dead 10-hour fuel moisture, a fraction. A `WeatherDrive` writes it while unset. Default `moisture` + 0.01. */
306
+ moisture10?: number;
307
+ /** Dead 100-hour fuel moisture, a fraction. A `WeatherDrive` writes it while unset. Default `moisture` + 0.02. */
308
+ moisture100?: number;
309
+ /** Live fuel moisture, a fraction. Default 0.9 (late-season chaparral). */
310
+ liveMoisture?: number;
311
+ /** The wind 10 m up: `[x, z]` m/s, or a sampler. A `WeatherDrive` writes it while it is unset. Default [0, 0]. */
312
+ wind?: FireWind;
313
+ /** Midflame wind as a fraction of the 10 m wind (Albini and Baughman 1979). Default 0.4. */
314
+ windReduction?: number;
315
+ /** Embers per second from each 64 m^2 of burning ground (an 8 m cell) per 1,000 kW/m of fireline intensity above 1,000. Default 0.02. */
316
+ spotting?: number;
317
+ /** Spread of the landing distance (lognormal sigma). Default 0.7. */
318
+ spotSpread?: number;
319
+ /** Chance an ember starts a fire in dry fuel. Default 0.3. */
320
+ emberIgnition?: number;
321
+ /** Seconds of flame exposure within a flame length and a half before a structure ignites. Default 90. */
322
+ structureExposure?: number;
323
+ /** Seconds a structure burns. Default 1,800. */
324
+ structureBurnTime?: number;
325
+ /**
326
+ * Crown fire (Van Wagner 1977, Rothermel 1991): where a cell's stand has a canopy, a surface fire past Van Wagner's
327
+ * critical intensity torches the crowns or runs through them, faster, hotter, with longer flames and embers thrown
328
+ * further. False keeps every fire on the ground. Default true.
329
+ */
330
+ crown?: boolean;
331
+ /** Foliar moisture of the crowns, a fraction of dry weight: 1 (100 percent) is Van Wagner's value, 0.8 late-summer drought, 1.3 new growth. Default 1. */
332
+ foliarMoisture?: number;
333
+ /** Fine smoke (PM2.5) a kilogram of fuel gives, grams: 15 is the extratropical forest value of Akagi et al. 2011 (variation 7.5). Default 15. */
334
+ smokeYield?: number;
335
+ }
336
+ /**
337
+ * The share of a fire's heat release it radiates: `RADIANT_FRACTION` of `@margoengine/vfx/smoke` (Drysdale 2011: 0.2 to
338
+ * 0.4; NISTIR 6546: about 0.3), kept here so the front does not load the smoke entry; a test pins the two equal.
339
+ */
340
+ export declare const RADIANT_SHARE = 0.3;
341
+ /**
342
+ * A wildfire front on a grid, stepped in fixed steps (`advanceTime`, or each frame once attached; `settle()` runs it
343
+ * until nothing burns). Spread is Rothermel's, direction by direction as Richards' ellipse, so a fire runs fast
344
+ * upwind of the wind and uphill and creeps back downhill. `burnTexture` (rgba32float, one texel per cell, row z) holds
345
+ * per cell: r the fire time it caught, g the time it burns out, b the fireline intensity in MW/m (kept after burn-out), a the state
346
+ * (0 unburnt, 1 burning, 2 burnt, 3 no fuel); terrain and plants read it for char, ash and blackened stems.
347
+ * @throws TypeError / RangeError for invalid options; MargoError `'disposed'` after `dispose()`.
348
+ * @example
349
+ * const fire = FireFront.attach(engine, { ground: world.heightAt, fuel: 'FM4', ignitions: [{ at: [0, 0] }] });
350
+ */
351
+ export declare class FireFront implements EnginePlugin {
352
+ readonly name: string;
353
+ /** Read every step; see {@link FireFrontOptions}. */
354
+ readonly options: FireFrontOptions;
355
+ /** Cells along x and z. */
356
+ readonly width: number;
357
+ readonly height: number;
358
+ /** World `[x, z]` of the minimum corner and the cell side. */
359
+ readonly origin: Vec2;
360
+ readonly cell: number;
361
+ /** The burn texture (needs a WebGPU engine); undefined without one. */
362
+ texture?: GPUTexture;
363
+ /** Fire time, seconds. */
364
+ time: number;
365
+ /** Embers that landed, and how many of them started a fire. */
366
+ embers: number;
367
+ spots: number;
368
+ private engine?;
369
+ /** advanceTime stepped the fire since the engine's last frame with time in it, not from that frame. */
370
+ private stepped;
371
+ /** How many engine frames in a row found such a step: two or more is a doubled clock. */
372
+ private doubled;
373
+ /** Inside onPreUpdate: the engine's own step. */
374
+ private fromEngine;
375
+ private disposed;
376
+ private readonly step;
377
+ private readonly seg;
378
+ private acc;
379
+ private random;
380
+ private readonly fuels;
381
+ private readonly cellFuel;
382
+ private readonly stateOf;
383
+ private readonly arrival;
384
+ private readonly burnout;
385
+ private readonly intensity;
386
+ private readonly exposure;
387
+ private readonly slopeX;
388
+ private readonly slopeZ;
389
+ private readonly crownOf;
390
+ /** 1 where an active crown fire ran into the cell from a neighbour (Scott and Reinhardt 2001's conditional crown fire). */
391
+ private readonly fed;
392
+ /** Per-cell stands from `options.canopy` (base height, bulk density, height), or undefined to read the fuel's. */
393
+ private readonly stands?;
394
+ private fm10?;
395
+ private readonly rows;
396
+ private burning;
397
+ private pending;
398
+ private readonly travel;
399
+ private readonly carry;
400
+ private carryKey;
401
+ /** Light order of each cell (1, 2, ...): the order `burning` holds them in, so the lazy cells interleave exactly. */
402
+ private readonly seqOf;
403
+ /** The cell lit `seq`-th. */
404
+ private readonly cellOfSeq;
405
+ private seqN;
406
+ /** Steps taken since the front was made or reset; the step in progress inside `advance`. */
407
+ private stepN;
408
+ /** Light order of the cell the step is visiting (-1 before the first: ignitions). */
409
+ private visitSeq;
410
+ private lazyOn;
411
+ private readonly lazy;
412
+ /** Step -> neighbours reached in it, each `seq * 16 + k`; `dueSteps` is a min-heap of the steps. */
413
+ private readonly due;
414
+ private readonly dueSteps;
415
+ /** Step -> lazy cells whose last open neighbour closes in it (they leave at the end of that step). */
416
+ private readonly dying;
417
+ private beds;
418
+ private bedKey;
419
+ private dirty;
420
+ private readonly columns;
421
+ private readonly segs;
422
+ private readonly flameAcc;
423
+ private readonly structureOf;
424
+ private readonly frontFlames;
425
+ private readonly houseFlames;
426
+ private readonly emberPool;
427
+ /** Each ember effect's kit values (rate, size, intensity, velocity), as built. */
428
+ private readonly emberBase;
429
+ private lightGroups?;
430
+ private readonly frontKeys;
431
+ private readonly houseKeys;
432
+ private readonly midflame;
433
+ private born;
434
+ private smokeReady;
435
+ /** True when the columns' radius follows their segments (no `smoke.radius` given). */
436
+ private smokeRadius;
437
+ private constructor();
438
+ /** A fire with no engine: the same model stepped by `advanceTime`, for tests, bakes and tools. */
439
+ static create(options?: FireFrontOptions): FireFront;
440
+ /** Adds the fire to an engine: it steps with each frame, makes the burn texture and the smoke columns. */
441
+ static attach(engine: EngineKernel, options?: FireFrontOptions): FireFront;
442
+ private checkLive;
443
+ private register;
444
+ private resolve;
445
+ private fill;
446
+ private cellAt;
447
+ /** The state of the cell at world `(x, z)`: `UNBURNT`, `BURNING`, `BURNT`, `NO_FUEL`, or -1 outside the grid. */
448
+ state(x: number, z: number): number;
449
+ /** The fire time the cell at `(x, z)` caught, or -1 where it has not. */
450
+ arrivalTime(x: number, z: number): number;
451
+ /** The crown fraction burned of the cell at `(x, z)` when it burned (0 a surface fire, 1 an active crown fire), or 0 outside the grid. */
452
+ crownFraction(x: number, z: number): number;
453
+ /** The burning cells whose crowns burn now (crown fraction above 0). */
454
+ get crowningCells(): number;
455
+ /** The stand over cell `i`, or undefined for none (or crown fire off). */
456
+ private canopyAt;
457
+ /** The burning cells now. */
458
+ get burningCells(): number;
459
+ /** The smoke columns along the front, hottest segment first once `ready` has resolved. */
460
+ get smokeColumns(): readonly Smoke[];
461
+ /**
462
+ * The fine smoke (PM2.5) the front gives off now, grams per second: the fuel it burns (the heat it releases over the
463
+ * heat of combustion, 18,622 kJ/kg) times `smokeYield` (15 g/kg, Akagi et al. 2011). `WeatherDrive` raises the
464
+ * weather's `smoke` from it.
465
+ */
466
+ get smokeEmission(): number;
467
+ /**
468
+ * The flames' radiant power now, watts: the share of the front's heat release it radiates, {@link RADIANT_SHARE} (the
469
+ * `RADIANT_FRACTION` of `@margoengine/vfx/smoke` its smoke columns glow with), over the convective 0.7 of the heat it
470
+ * releases. `WeatherDrive` lights the smoke haze from below with it (KB-WEATHER-FIREHAZE1). 0 while nothing burns.
471
+ */
472
+ get radiantPower(): number;
473
+ /**
474
+ * The engine sun intensity of the scene's noon sun its smoke columns' glow and its flames' radiance are referred to (`SmokeOptions.noon`, `FlameOptions.noon`,
475
+ * KB-VFX-GLOWUNITS1), written on every column now and on those made later. `WeatherDrive` sets it from its sky's
476
+ * `lighting.intensity` each frame. Undefined: the columns' own (`smoke.noon`, default pi).
477
+ */
478
+ get noon(): number | undefined;
479
+ set noon(value: number | undefined);
480
+ private noonValue?;
481
+ private noonOn;
482
+ /**
483
+ * Light of the air round its smoke columns (`SmokeOptions.air`, shares of the noon sun's light, red, green and blue),
484
+ * written on every column now and on those made later. `WeatherDrive` sets it each frame to its fires' light on the
485
+ * smoke pall over this front, so the columns inside the firelit pall take its light, not only their bases' glow
486
+ * (KB-VFX-COLUMNAMBIENT1). Undefined: the columns' own (`smoke.air`, default none).
487
+ */
488
+ get air(): readonly [number, number, number] | undefined;
489
+ set air(value: readonly [number, number, number] | undefined);
490
+ private airValue?;
491
+ /**
492
+ * The reflectance of the smoke pall over this front (`SmokeOptions.airReflectance`, red, green and blue, each 0 to
493
+ * 1), written on every column now and on those made later: the share of the `air`'s light the pall sends back down,
494
+ * so the columns are lit from below by the fire and less from above (KB-VFX-SMOKEFLAT1). `WeatherDrive` sets it each
495
+ * frame to its haze's reflectance. Undefined: the columns' own (`smoke.airReflectance`, default `PALL_REFLECTANCE`).
496
+ */
497
+ get airReflectance(): readonly [number, number, number] | undefined;
498
+ set airReflectance(value: readonly [number, number, number] | undefined);
499
+ private airBackValue?;
500
+ /** True while a cell burns or an ignition waits. */
501
+ get active(): boolean;
502
+ private queue;
503
+ /** Lights a fire at `(x, z)` at `time` seconds of fire time (default now). */
504
+ ignite(x: number, z: number, radius?: number, time?: number): this;
505
+ private bedsFor;
506
+ private light;
507
+ private closeToward;
508
+ private closed;
509
+ /** Takes a cell past its flames, after its visit in step `s`, out of `burning` into a lazy record. */
510
+ private lazify;
511
+ /** A lazy cell's kept travel reaches neighbour `k` in step `s`: what its visit would have done. */
512
+ private reach;
513
+ /** Puts every lazy cell back into `burning`, in light order, with the travel the steps since would have added. */
514
+ private flush;
515
+ /** The next step a lazy cell does anything in (reaches a neighbour or leaves), or Infinity. */
516
+ private nextLazyStep;
517
+ private lightArea;
518
+ /** The 10 m wind `[x, z]` at world `(x, z)` this step. */
519
+ private windAt;
520
+ /** Steps the fire by `delta` seconds in fixed steps of `options.step`; the remainder waits for the next call. */
521
+ advanceTime(delta: number): void;
522
+ /**
523
+ * Back to fire time 0, as a fresh fire with the same options (GAP-FILM-RESET): every cell unburnt again, the
524
+ * `ignitions` of the options queued again (ones added with `ignite` are dropped), the ember and spotting random
525
+ * stream restarted from `seed`, the counters cleared and the burn texture rewritten. Its smoke columns, flame volumes
526
+ * and ember effects go back to idle and to their own start, so the same frames after it draw the same fire.
527
+ */
528
+ resetTime(): void;
529
+ /** Same as {@link advanceTime}, so `seek` can replay a fire. */
530
+ update(delta: number): void;
531
+ /**
532
+ * Steps the fire until nothing burns and no ignition waits, then resolves with the fire time. Yields to the event
533
+ * loop every 4,096 steps; `signal` aborts it. The burn is the one `advanceTime` steps, cell for cell, but a cell past
534
+ * its flames is not visited each step: it waits for the step its kept travel reaches a neighbour, worked out ahead
535
+ * (KB-SCENES-BURNTSLOW1), and steps in which nothing but such cells wait are only counted.
536
+ * @param maxSeconds The most fire time to simulate. Default 86,400.
537
+ */
538
+ settle(maxSeconds?: number, signal?: AbortSignal): Promise<number>;
539
+ private advance;
540
+ private carryOn;
541
+ /** Flame exposure of structure cells near a burning cell: within 1.5 flame lengths they heat up and ignite. */
542
+ private exposeStructures;
543
+ private throwEmbers;
544
+ /** The burning segments of the front: heat-weighted centre and convective heat in watts, hottest first. */
545
+ segments(): FireSegment[];
546
+ /**
547
+ * The flames to draw now, hottest first: one per stretch of the front (the cells burning within one `segment`), its
548
+ * length Byram's 0.0775 I^0.46 of the heat-weighted fireline intensity there (Byram 1959), and one per burning
549
+ * building, its length Heskestad's 0.235 Q^(2/5) - 1.02 D of the building's heat release over its vent (Heskestad
550
+ * 1983; the vent is `structureVent` of the floor). The flame volumes of an attached front are placed from this.
551
+ */
552
+ flames(): FireFlame[];
553
+ /** Flame volumes along the front, placed on its hottest stretches (empty until `ready` has resolved). */
554
+ get flameVolumes(): readonly Flame[];
555
+ /** The ember effects over the front's flame volumes, one each in the same order (empty with `flameEmbers: false` or until `ready` has resolved). */
556
+ get flameEmbers(): readonly VFX[];
557
+ /** Flame volumes on burning buildings (empty until `ready` has resolved). */
558
+ get buildingFlameVolumes(): readonly Flame[];
559
+ /** Writes the changed cells into the burn texture and moves the smoke columns. */
560
+ private publish;
561
+ /** The cell states read back as a copy of the burn texture's four channels per cell (row z, column x). */
562
+ read(): Float32Array;
563
+ /** Sets the 10 m wind `[x, z]` (what a `WeatherDrive` writes); undefined gives it back to the default calm. */
564
+ setWind(wind: Vec2 | undefined): this;
565
+ /** Engine plugin hooks. */
566
+ setup(engine: Engine): void;
567
+ /** Resolves once the smoke columns exist (`columns` above 0 and an attached engine); never rejects before attach. */
568
+ get ready(): Promise<void>;
569
+ private makeColumns;
570
+ private makeFlames;
571
+ /** One ember effect per front flame volume: the hearth kit's embers scaled to {@link EMBER_LENGTH}, idle until placed. */
572
+ private makeEmbers;
573
+ /**
574
+ * Writes the flame rows `applyFlameSettings` resolved (a look family's flames, a shot's keyed radiance) onto every flame
575
+ * volume of the front and its buildings, and onto those the front makes later, so a FireFront is a target of
576
+ * `applyFlameSettings` as a `Flame` is.
577
+ */
578
+ setFlameLook(values: Readonly<Record<string, unknown>>): this;
579
+ private flameLook?;
580
+ /**
581
+ * Keeps the smoke look `applySmokeSettings` resolved (a look family's smoke, a shot's keyed opacity) and writes it onto
582
+ * every smoke column now and onto those the front makes later, so a FireFront is a target of `applySmokeSettings` as a
583
+ * `Smoke` is. `write` leaves each column's heat and radius alone: the front sets them from its segments each step.
584
+ */
585
+ setSmokeLook(write: (column: Smoke) => void): this;
586
+ private smokeLook?;
587
+ /** Puts each flame volume on its stretch of the front or its building, keeping a volume with the stretch it had. */
588
+ private syncFlames;
589
+ private place;
590
+ /**
591
+ * The ground under a stretch of front over its plane (`slope` through its centre) at `Flame` `relief`'s grid of
592
+ * points over its footprint, into `out`: a stretch is up to a few flame lengths long and the ground under it rises
593
+ * and falls by up to 0.7 flame lengths off any one plane (the timber-valley town fire), so on the plane alone the
594
+ * flames were buried in the rises and floated over the hollows, a hard cut along their foot (KB-VFX-FLAMELOOK1).
595
+ */
596
+ private reliefOf;
597
+ /**
598
+ * Puts each ember effect over its flame volume: born over the footprint (its box turned to the world axes) a third of
599
+ * the flame length up, at the kit's rate times sqrt(L / EMBER_LENGTH) times the stretch's length in flame lengths (1
600
+ * to 4), its launch speed times sqrt(L / EMBER_LENGTH) (Sardoy et al. 2007: embers loft with the plume, whose
601
+ * speeds go as sqrt(g L)), carried by the open (10 m) wind above the canopy; none where the volume is out. The ember rows of `applyFlameSettings` scale size, rate and
602
+ * brightness.
603
+ */
604
+ private placeEmbers;
605
+ onPreUpdate(delta: number): void;
606
+ /** Stops the fire and frees the burn texture; the smoke columns stay attached to the engine until it disposes. */
607
+ dispose(): void;
608
+ [Symbol.dispose](): void;
609
+ }
610
+ export {};