@margoengine/vfx 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 +1642 -3
- package/dist/base-C9upJytz.js +658 -0
- package/dist/base.d.ts +767 -0
- package/dist/base.js +1 -0
- package/dist/blown-sand.d.ts +218 -0
- package/dist/blown-sand.js +700 -0
- package/dist/clouds.d.ts +229 -0
- package/dist/clouds.js +566 -0
- package/dist/compat-CVSEj1Bp.js +217 -0
- package/dist/compat.d.ts +59 -0
- package/dist/curves.d.ts +11 -0
- package/dist/curves.js +59 -0
- package/dist/debris.d.ts +111 -0
- package/dist/debris.js +258 -0
- package/dist/depth-collide.d.ts +7 -0
- package/dist/depth-collide.js +96 -0
- package/dist/emitter.d.ts +10 -0
- package/dist/emitter.js +125 -0
- package/dist/events.d.ts +9 -0
- package/dist/events.js +131 -0
- package/dist/extra-CgGjbojB.js +4 -0
- package/dist/extra.d.ts +2 -0
- package/dist/fields.d.ts +11 -0
- package/dist/fields.js +95 -0
- package/dist/fire-front.d.ts +539 -0
- package/dist/fire-front.js +840 -0
- package/dist/fire.d.ts +119 -0
- package/dist/fire.js +173 -0
- package/dist/flame-ramp-VoBKpYnM.js +75 -0
- package/dist/flame-ramp.d.ts +61 -0
- package/dist/flame.d.ts +260 -0
- package/dist/flame.js +605 -0
- package/dist/flipbook.d.ts +7 -0
- package/dist/flipbook.js +23 -0
- package/dist/fog-B-kBv7g0.js +32 -0
- package/dist/frame-BuvMFBPp.js +4 -0
- package/dist/frame.d.ts +7 -0
- package/dist/gunfire.d.ts +696 -0
- package/dist/gunfire.js +1204 -0
- package/dist/hash-Btsp6fGK.js +7 -0
- package/dist/hash.d.ts +2 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +60 -0
- package/dist/json.d.ts +53 -0
- package/dist/json.js +237 -0
- package/dist/lit.d.ts +11 -0
- package/dist/lit.js +105 -0
- package/dist/mesh.d.ts +14 -0
- package/dist/mesh.js +225 -0
- package/dist/node-system.d.ts +315 -0
- package/dist/node-system.js +384 -0
- package/dist/nodes.d.ts +14 -0
- package/dist/nodes.js +293 -0
- package/dist/obstacles.d.ts +3 -0
- package/dist/obstacles.js +25 -0
- package/dist/over-life.d.ts +14 -0
- package/dist/over-life.js +93 -0
- package/dist/require-webgpu--tUXPsmA.js +7 -0
- package/dist/ribbons.d.ts +20 -0
- package/dist/ribbons.js +151 -0
- package/dist/schedule.d.ts +29 -0
- package/dist/schedule.js +47 -0
- package/dist/settings.d.ts +362 -0
- package/dist/settings.js +707 -0
- package/dist/shader.d.ts +44 -0
- package/dist/shadows.d.ts +26 -0
- package/dist/shadows.js +182 -0
- package/dist/shapes.d.ts +34 -0
- package/dist/shapes.js +81 -0
- package/dist/shared/fog.d.ts +33 -0
- package/dist/shared/pass.d.ts +53 -0
- package/dist/shared/settings.d.ts +89 -0
- package/dist/skinned.d.ts +11 -0
- package/dist/skinned.js +104 -0
- package/dist/smoke.d.ts +215 -0
- package/dist/smoke.js +280 -0
- package/dist/soft.d.ts +17 -0
- package/dist/soft.js +55 -0
- package/dist/solid.d.ts +168 -0
- package/dist/solid.js +403 -0
- package/dist/sort.d.ts +3 -0
- package/dist/sort.js +58 -0
- package/dist/space.d.ts +14 -0
- package/dist/space.js +88 -0
- package/dist/stretch.d.ts +7 -0
- package/dist/stretch.js +40 -0
- package/dist/texture.d.ts +8 -0
- package/dist/texture.js +45 -0
- package/dist/view-RKprOPAy.js +30 -0
- package/dist/view-rect-DkeiiUtw.js +13 -0
- package/dist/wrap.d.ts +3 -0
- package/dist/wrap.js +5 -0
- package/package.json +192 -6
package/dist/fields.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { MargoError as e } from "@margoengine/math/errors";
|
|
2
|
+
//#region src/fields.ts
|
|
3
|
+
var t = 16, n = 2097152, r = "f.gravityDelta.xyz+curlNoise(p.positionLife.xyz)", i = (e) => `
|
|
4
|
+
struct Fields {count:vec4u,center:vec4f,half:vec4f,attractors:array<vec4f,32>}
|
|
5
|
+
@group(0) @binding(19) var<uniform> fields:Fields;
|
|
6
|
+
${e ? "@group(0) @binding(20) var<storage,read> fieldCells:array<vec4f>;\nfn fieldCell(c:vec3u)->vec3f {let n=fields.count.yzw;return fieldCells[c.x+n.x*(c.y+n.y*c.z)].xyz;}" : ""}
|
|
7
|
+
fn fieldForce(x:vec3f)->vec3f {
|
|
8
|
+
var a=vec3f(0);
|
|
9
|
+
for(var k=0u;k<fields.count.x;k++){let d=fields.attractors[k*2].xyz-x;let s=fields.attractors[k*2+1].x;let q=dot(d,d)+s*s;a+=d*fields.attractors[k*2].w*inverseSqrt(q*q*q);}
|
|
10
|
+
${e ? "let local=(x-fields.center.xyz)/fields.half.xyz;\n if(all(abs(local)<=vec3f(1))){\n let n=fields.count.yzw;let g=clamp((local*0.5+0.5)*vec3f(n)-0.5,vec3f(0),vec3f(n-1u));let i=min(vec3u(g),n-1u);let j=min(i+1u,n-1u);let t=g-vec3f(i);\n let x0=mix(mix(fieldCell(i),fieldCell(vec3u(j.x,i.y,i.z)),t.x),mix(fieldCell(vec3u(i.x,j.y,i.z)),fieldCell(vec3u(j.x,j.y,i.z)),t.x),t.y);\n let x1=mix(mix(fieldCell(vec3u(i.x,i.y,j.z)),fieldCell(vec3u(j.x,i.y,j.z)),t.x),mix(fieldCell(vec3u(i.x,j.y,j.z)),fieldCell(j),t.x),t.y);\n a+=mix(x0,x1,t.z)*fields.half.w;\n }" : ""}
|
|
11
|
+
return a;
|
|
12
|
+
}
|
|
13
|
+
`, a = (e, t, n) => {
|
|
14
|
+
if (!Array.isArray(e) || e.length !== t || !e.every((e) => typeof e == "number" && Number.isFinite(e))) throw TypeError(`VFX fields ${n} needs ${t} finite numbers`);
|
|
15
|
+
return e;
|
|
16
|
+
}, o = {
|
|
17
|
+
validate(e) {
|
|
18
|
+
if (!e || typeof e != "object") throw TypeError("VFX fields must be an object; pass {attractors} or {field}");
|
|
19
|
+
let t = e.attractors ?? [];
|
|
20
|
+
if (!Array.isArray(t) || t.length > 16) throw RangeError("VFX fields attractors must be an array of at most 16");
|
|
21
|
+
t.forEach((e, t) => {
|
|
22
|
+
if (a(e?.position, 3, `attractors[${t}].position`), typeof e.strength != "number" || !Number.isFinite(e.strength)) throw TypeError(`VFX fields attractors[${t}].strength needs a finite number (negative pushes)`);
|
|
23
|
+
if (e.radius !== void 0 && !(e.radius > 0 && Number.isFinite(e.radius))) throw RangeError(`VFX fields attractors[${t}].radius must be above 0; pass e.g. 0.5`);
|
|
24
|
+
});
|
|
25
|
+
let r = e.field;
|
|
26
|
+
if (r !== void 0) {
|
|
27
|
+
let [e, t, i] = a(r?.size, 3, "field.size");
|
|
28
|
+
if (![
|
|
29
|
+
e,
|
|
30
|
+
t,
|
|
31
|
+
i
|
|
32
|
+
].every((e) => Number.isInteger(e) && e >= 1) || e * t * i > 2097152) throw RangeError(`VFX fields field.size needs whole cell counts, at most ${n} cells in all`);
|
|
33
|
+
if (!(r.data instanceof Float32Array) || r.data.length !== e * t * i * 3 || !r.data.every(Number.isFinite)) throw RangeError("VFX fields field.data needs a Float32Array of finite xyz vectors, 3 per cell");
|
|
34
|
+
if (a(r.center ?? [
|
|
35
|
+
0,
|
|
36
|
+
0,
|
|
37
|
+
0
|
|
38
|
+
], 3, "field.center"), !a(r.halfSize, 3, "field.halfSize").every((e) => e > 0)) throw RangeError("VFX fields field.halfSize must be above 0 on every axis");
|
|
39
|
+
if (r.strength !== void 0 && !Number.isFinite(r.strength)) throw TypeError("VFX fields field.strength needs a finite number");
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
simulation(t, n) {
|
|
43
|
+
if (t.split(r).length !== 2) throw new e("unsupported", "VFX fields need the simulation shader they were written for; update the edit");
|
|
44
|
+
return t.replace("fn update(", i(!!n.field) + "fn update(").replace(r, r + "+fieldForce(p.positionLife.xyz)");
|
|
45
|
+
},
|
|
46
|
+
create(e, t, n) {
|
|
47
|
+
let { device: r, options: i } = e, a = r.createBuffer({
|
|
48
|
+
size: 560,
|
|
49
|
+
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST
|
|
50
|
+
});
|
|
51
|
+
n.push(a);
|
|
52
|
+
let o = [{
|
|
53
|
+
binding: 19,
|
|
54
|
+
resource: { buffer: a }
|
|
55
|
+
}], s = t.field, c = s ? [...s.size] : [
|
|
56
|
+
0,
|
|
57
|
+
0,
|
|
58
|
+
0
|
|
59
|
+
];
|
|
60
|
+
if (s) {
|
|
61
|
+
let e = new Float32Array(s.data.length / 3 * 4);
|
|
62
|
+
for (let t = 0; t < s.data.length / 3; t++) e.set(s.data.subarray(t * 3, t * 3 + 3), t * 4);
|
|
63
|
+
let t = r.createBuffer({
|
|
64
|
+
size: e.byteLength,
|
|
65
|
+
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST
|
|
66
|
+
});
|
|
67
|
+
n.push(t), r.queue.writeBuffer(t, 0, e), o.push({
|
|
68
|
+
binding: 20,
|
|
69
|
+
resource: { buffer: t }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
let l = /* @__PURE__ */ new Float32Array(140), u = new Uint32Array(l.buffer);
|
|
73
|
+
return {
|
|
74
|
+
compute: o,
|
|
75
|
+
write(e) {
|
|
76
|
+
let t = i.fields;
|
|
77
|
+
if (!t || !!t.field != !!s || s && t.field.data !== s.data) throw TypeError("VFX fields and their field cells are fixed at attach; change attractors and strengths in place");
|
|
78
|
+
let n = t.attractors ?? [];
|
|
79
|
+
l.fill(0), u[0] = n.length, u[1] = c[0], u[2] = c[1], u[3] = c[2], t.field && (l.set(t.field.center ?? [
|
|
80
|
+
0,
|
|
81
|
+
0,
|
|
82
|
+
0
|
|
83
|
+
], 4), l.set(t.field.halfSize, 8), l[11] = t.field.strength ?? 1), n.forEach((e, t) => {
|
|
84
|
+
l.set([
|
|
85
|
+
...e.position,
|
|
86
|
+
e.strength,
|
|
87
|
+
e.radius ?? .5
|
|
88
|
+
], 12 + t * 8);
|
|
89
|
+
}), e.device.queue.writeBuffer(a, 0, l);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { t as MAX_ATTRACTORS, n as MAX_FIELD_CELLS, o as fields };
|
|
@@ -0,0 +1,539 @@
|
|
|
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
|
+
private disposed;
|
|
370
|
+
private readonly step;
|
|
371
|
+
private readonly seg;
|
|
372
|
+
private acc;
|
|
373
|
+
private random;
|
|
374
|
+
private readonly fuels;
|
|
375
|
+
private readonly cellFuel;
|
|
376
|
+
private readonly stateOf;
|
|
377
|
+
private readonly arrival;
|
|
378
|
+
private readonly burnout;
|
|
379
|
+
private readonly intensity;
|
|
380
|
+
private readonly exposure;
|
|
381
|
+
private readonly slopeX;
|
|
382
|
+
private readonly slopeZ;
|
|
383
|
+
private readonly crownOf;
|
|
384
|
+
/** 1 where an active crown fire ran into the cell from a neighbour (Scott and Reinhardt 2001's conditional crown fire). */
|
|
385
|
+
private readonly fed;
|
|
386
|
+
/** Per-cell stands from `options.canopy` (base height, bulk density, height), or undefined to read the fuel's. */
|
|
387
|
+
private readonly stands?;
|
|
388
|
+
private fm10?;
|
|
389
|
+
private readonly rows;
|
|
390
|
+
private burning;
|
|
391
|
+
private pending;
|
|
392
|
+
private readonly travel;
|
|
393
|
+
private beds;
|
|
394
|
+
private bedKey;
|
|
395
|
+
private dirty;
|
|
396
|
+
private readonly columns;
|
|
397
|
+
private readonly segs;
|
|
398
|
+
private readonly flameAcc;
|
|
399
|
+
private readonly structureOf;
|
|
400
|
+
private readonly frontFlames;
|
|
401
|
+
private readonly houseFlames;
|
|
402
|
+
private readonly emberPool;
|
|
403
|
+
/** Each ember effect's kit values (rate, size, intensity, velocity), as built. */
|
|
404
|
+
private readonly emberBase;
|
|
405
|
+
private lightGroups?;
|
|
406
|
+
private readonly frontKeys;
|
|
407
|
+
private readonly houseKeys;
|
|
408
|
+
private readonly midflame;
|
|
409
|
+
private born;
|
|
410
|
+
private smokeReady;
|
|
411
|
+
/** True when the columns' radius follows their segments (no `smoke.radius` given). */
|
|
412
|
+
private smokeRadius;
|
|
413
|
+
private constructor();
|
|
414
|
+
/** A fire with no engine: the same model stepped by `advanceTime`, for tests, bakes and tools. */
|
|
415
|
+
static create(options?: FireFrontOptions): FireFront;
|
|
416
|
+
/** Adds the fire to an engine: it steps with each frame, makes the burn texture and the smoke columns. */
|
|
417
|
+
static attach(engine: EngineKernel, options?: FireFrontOptions): FireFront;
|
|
418
|
+
private checkLive;
|
|
419
|
+
private register;
|
|
420
|
+
private resolve;
|
|
421
|
+
private fill;
|
|
422
|
+
private cellAt;
|
|
423
|
+
/** The state of the cell at world `(x, z)`: `UNBURNT`, `BURNING`, `BURNT`, `NO_FUEL`, or -1 outside the grid. */
|
|
424
|
+
state(x: number, z: number): number;
|
|
425
|
+
/** The fire time the cell at `(x, z)` caught, or -1 where it has not. */
|
|
426
|
+
arrivalTime(x: number, z: number): number;
|
|
427
|
+
/** 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. */
|
|
428
|
+
crownFraction(x: number, z: number): number;
|
|
429
|
+
/** The burning cells whose crowns burn now (crown fraction above 0). */
|
|
430
|
+
get crowningCells(): number;
|
|
431
|
+
/** The stand over cell `i`, or undefined for none (or crown fire off). */
|
|
432
|
+
private canopyAt;
|
|
433
|
+
/** The burning cells now. */
|
|
434
|
+
get burningCells(): number;
|
|
435
|
+
/** The smoke columns along the front, hottest segment first once `ready` has resolved. */
|
|
436
|
+
get smokeColumns(): readonly Smoke[];
|
|
437
|
+
/**
|
|
438
|
+
* The fine smoke (PM2.5) the front gives off now, grams per second: the fuel it burns (the heat it releases over the
|
|
439
|
+
* heat of combustion, 18,622 kJ/kg) times `smokeYield` (15 g/kg, Akagi et al. 2011). `WeatherDrive` raises the
|
|
440
|
+
* weather's `smoke` from it.
|
|
441
|
+
*/
|
|
442
|
+
get smokeEmission(): number;
|
|
443
|
+
/**
|
|
444
|
+
* The flames' radiant power now, watts: the share of the front's heat release it radiates, {@link RADIANT_SHARE} (the
|
|
445
|
+
* `RADIANT_FRACTION` of `@margoengine/vfx/smoke` its smoke columns glow with), over the convective 0.7 of the heat it
|
|
446
|
+
* releases. `WeatherDrive` lights the smoke haze from below with it (KB-WEATHER-FIREHAZE1). 0 while nothing burns.
|
|
447
|
+
*/
|
|
448
|
+
get radiantPower(): number;
|
|
449
|
+
/** True while a cell burns or an ignition waits. */
|
|
450
|
+
get active(): boolean;
|
|
451
|
+
private queue;
|
|
452
|
+
/** Lights a fire at `(x, z)` at `time` seconds of fire time (default now). */
|
|
453
|
+
ignite(x: number, z: number, radius?: number, time?: number): this;
|
|
454
|
+
private bedsFor;
|
|
455
|
+
private light;
|
|
456
|
+
private lightArea;
|
|
457
|
+
/** The 10 m wind `[x, z]` at world `(x, z)` this step. */
|
|
458
|
+
private windAt;
|
|
459
|
+
/** Steps the fire by `delta` seconds in fixed steps of `options.step`; the remainder waits for the next call. */
|
|
460
|
+
advanceTime(delta: number): void;
|
|
461
|
+
/**
|
|
462
|
+
* Back to fire time 0, as a fresh fire with the same options (GAP-FILM-RESET): every cell unburnt again, the
|
|
463
|
+
* `ignitions` of the options queued again (ones added with `ignite` are dropped), the ember and spotting random
|
|
464
|
+
* stream restarted from `seed`, the counters cleared and the burn texture rewritten. Its smoke columns, flame volumes
|
|
465
|
+
* and ember effects go back to idle and to their own start, so the same frames after it draw the same fire.
|
|
466
|
+
*/
|
|
467
|
+
resetTime(): void;
|
|
468
|
+
/** Same as {@link advanceTime}, so `seek` can replay a fire. */
|
|
469
|
+
update(delta: number): void;
|
|
470
|
+
/**
|
|
471
|
+
* Steps the fire until nothing burns and no ignition waits, then resolves with the fire time. Yields to the event
|
|
472
|
+
* loop every 4,096 steps; `signal` aborts it.
|
|
473
|
+
* @param maxSeconds The most fire time to simulate. Default 86,400.
|
|
474
|
+
*/
|
|
475
|
+
settle(maxSeconds?: number, signal?: AbortSignal): Promise<number>;
|
|
476
|
+
private advance;
|
|
477
|
+
/** Flame exposure of structure cells near a burning cell: within 1.5 flame lengths they heat up and ignite. */
|
|
478
|
+
private exposeStructures;
|
|
479
|
+
private throwEmbers;
|
|
480
|
+
/** The burning segments of the front: heat-weighted centre and convective heat in watts, hottest first. */
|
|
481
|
+
segments(): FireSegment[];
|
|
482
|
+
/**
|
|
483
|
+
* The flames to draw now, hottest first: one per stretch of the front (the cells burning within one `segment`), its
|
|
484
|
+
* length Byram's 0.0775 I^0.46 of the heat-weighted fireline intensity there (Byram 1959), and one per burning
|
|
485
|
+
* building, its length Heskestad's 0.235 Q^(2/5) - 1.02 D of the building's heat release over its vent (Heskestad
|
|
486
|
+
* 1983; the vent is `structureVent` of the floor). The flame volumes of an attached front are placed from this.
|
|
487
|
+
*/
|
|
488
|
+
flames(): FireFlame[];
|
|
489
|
+
/** Flame volumes along the front, placed on its hottest stretches (empty until `ready` has resolved). */
|
|
490
|
+
get flameVolumes(): readonly Flame[];
|
|
491
|
+
/** The ember effects over the front's flame volumes, one each in the same order (empty with `flameEmbers: false` or until `ready` has resolved). */
|
|
492
|
+
get flameEmbers(): readonly VFX[];
|
|
493
|
+
/** Flame volumes on burning buildings (empty until `ready` has resolved). */
|
|
494
|
+
get buildingFlameVolumes(): readonly Flame[];
|
|
495
|
+
/** Writes the changed cells into the burn texture and moves the smoke columns. */
|
|
496
|
+
private publish;
|
|
497
|
+
/** The cell states read back as a copy of the burn texture's four channels per cell (row z, column x). */
|
|
498
|
+
read(): Float32Array;
|
|
499
|
+
/** Sets the 10 m wind `[x, z]` (what a `WeatherDrive` writes); undefined gives it back to the default calm. */
|
|
500
|
+
setWind(wind: Vec2 | undefined): this;
|
|
501
|
+
/** Engine plugin hooks. */
|
|
502
|
+
setup(engine: Engine): void;
|
|
503
|
+
/** Resolves once the smoke columns exist (`columns` above 0 and an attached engine); never rejects before attach. */
|
|
504
|
+
get ready(): Promise<void>;
|
|
505
|
+
private makeColumns;
|
|
506
|
+
private makeFlames;
|
|
507
|
+
/** One ember effect per front flame volume: the hearth kit's embers scaled to {@link EMBER_LENGTH}, idle until placed. */
|
|
508
|
+
private makeEmbers;
|
|
509
|
+
/**
|
|
510
|
+
* Writes the flame rows `applyFlameSettings` resolved (a look family's flames, a shot's keyed radiance) onto every flame
|
|
511
|
+
* volume of the front and its buildings, and onto those the front makes later, so a FireFront is a target of
|
|
512
|
+
* `applyFlameSettings` as a `Flame` is.
|
|
513
|
+
*/
|
|
514
|
+
setFlameLook(values: Readonly<Record<string, unknown>>): this;
|
|
515
|
+
private flameLook?;
|
|
516
|
+
/**
|
|
517
|
+
* Keeps the smoke look `applySmokeSettings` resolved (a look family's smoke, a shot's keyed opacity) and writes it onto
|
|
518
|
+
* every smoke column now and onto those the front makes later, so a FireFront is a target of `applySmokeSettings` as a
|
|
519
|
+
* `Smoke` is. `write` leaves each column's heat and radius alone: the front sets them from its segments each step.
|
|
520
|
+
*/
|
|
521
|
+
setSmokeLook(write: (column: Smoke) => void): this;
|
|
522
|
+
private smokeLook?;
|
|
523
|
+
/** Puts each flame volume on its stretch of the front or its building, keeping a volume with the stretch it had. */
|
|
524
|
+
private syncFlames;
|
|
525
|
+
private place;
|
|
526
|
+
/**
|
|
527
|
+
* Puts each ember effect over its flame volume: born over the footprint (its box turned to the world axes) a third of
|
|
528
|
+
* the flame length up, at the kit's rate times sqrt(L / EMBER_LENGTH) times the stretch's length in flame lengths (1
|
|
529
|
+
* to 4), its launch speed times sqrt(L / EMBER_LENGTH) (Sardoy et al. 2007: embers loft with the plume, whose
|
|
530
|
+
* 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
|
|
531
|
+
* brightness.
|
|
532
|
+
*/
|
|
533
|
+
private placeEmbers;
|
|
534
|
+
onPreUpdate(delta: number): void;
|
|
535
|
+
/** Stops the fire and frees the burn texture; the smoke columns stay attached to the engine until it disposes. */
|
|
536
|
+
dispose(): void;
|
|
537
|
+
[Symbol.dispose](): void;
|
|
538
|
+
}
|
|
539
|
+
export {};
|