@margoengine/vfx 0.1.0 → 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 (46) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +4 -4
  3. package/README.md +2241 -1642
  4. package/dist/{base-C9upJytz.js → base-LGs65K7K.js} +174 -123
  5. package/dist/base.d.ts +104 -2
  6. package/dist/base.js +1 -1
  7. package/dist/blown-sand.js +3 -3
  8. package/dist/clouds.d.ts +12 -4
  9. package/dist/clouds.js +35 -18
  10. package/dist/compat-BFjXAQuu.js +14 -0
  11. package/dist/debris.d.ts +43 -0
  12. package/dist/debris.js +33 -1
  13. package/dist/dust-current.d.ts +66 -0
  14. package/dist/dust-current.js +92 -0
  15. package/dist/fire-front.d.ts +72 -1
  16. package/dist/fire-front.js +309 -69
  17. package/dist/fire.d.ts +24 -3
  18. package/dist/fire.js +114 -93
  19. package/dist/flame.d.ts +171 -3
  20. package/dist/flame.js +343 -131
  21. package/dist/flocking-shaders.d.ts +48 -0
  22. package/dist/flocking-sim.d.ts +623 -0
  23. package/dist/flocking.d.ts +145 -0
  24. package/dist/flocking.js +1846 -0
  25. package/dist/gunfire.d.ts +52 -6
  26. package/dist/gunfire.js +108 -98
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +5 -5
  29. package/dist/json.js +2 -0
  30. package/dist/lit-Dx2tNwP-.js +152 -0
  31. package/dist/lit.d.ts +8 -1
  32. package/dist/lit.js +1 -105
  33. package/dist/mesh.d.ts +2 -0
  34. package/dist/mesh.js +92 -69
  35. package/dist/over-life.js +16 -15
  36. package/dist/reactive-mask-B8xbyzlk.js +69 -0
  37. package/dist/ribbons.d.ts +4 -2
  38. package/dist/ribbons.js +87 -73
  39. package/dist/settings.js +1 -1
  40. package/dist/shader.d.ts +5 -0
  41. package/dist/shared/fog.d.ts +33 -33
  42. package/dist/shared/pass.d.ts +53 -53
  43. package/dist/shared/settings.d.ts +89 -89
  44. package/dist/smoke.d.ts +72 -4
  45. package/dist/smoke.js +280 -56
  46. package/package.json +200 -192
package/dist/fire.d.ts CHANGED
@@ -20,6 +20,12 @@ export interface FireOptions {
20
20
  hearth?: KitHearth;
21
21
  /** Scales the firelight's intensity and the flames' and embers' radiance together, 0 or more. Default 1. */
22
22
  power?: number;
23
+ /**
24
+ * Meters the firelight of a large fire (one with a `flameLength`) on a white card (`FlameOptions.keyDistance`): the
25
+ * distance, metres, at which a white card facing the flames reads 1 in the pre-exposed frame, times `power`. For a
26
+ * scene exposed on what the fire lights; the flames stay as bright. Read at attach. Default none.
27
+ */
28
+ keyDistance?: number;
23
29
  /** Length of the flame line along `axis`, metres, above 0. Default `hearth.light.length` (0.62), or the flame length with `flameLength`. */
24
30
  width?: number;
25
31
  /** Direction the flames run along (the logs), nonzero. Default [1, 0, 0]. */
@@ -32,7 +38,8 @@ export interface FireOptions {
32
38
  lights?: Clustered | LightGroups;
33
39
  /**
34
40
  * The firelight's soft shadows (`LocalShadows` from `@margoengine/clustered/shadows`, attached to the same
35
- * `Clustered` first). Default true.
41
+ * `Clustered` first). With a `flameLength` the flame's light is then one point that takes one shadow slot
42
+ * (`FlameOptions.castShadow`). Default true.
36
43
  */
37
44
  castShadow?: boolean;
38
45
  /** Points on the flame line (`lineLights` samples), 1 to 8. Default 2. */
@@ -45,7 +52,7 @@ export interface FireOptions {
45
52
  /**
46
53
  * The flame length, metres, 0.05 to 1,000: the fire's flames become a `Flame` volume of `@margoengine/vfx/flame` that
47
54
  * long (house fires, burning ships, crowns): tapering tongues that puff at the Cetegen and Ahmed frequency, a
48
- * yellow-white core that cannot blow out, and, with `lights`, the flame's own light, which flickers with the puffing.
55
+ * core at the flame's peak radiance (the frame's tonemap grades it), and, with `lights`, the flame's own light, which flickers with the puffing.
49
56
  * The embers' size, speed and life scale by the square root of the length over the hearth's
50
57
  * ({@link HEARTH_FLAME_LENGTH}). Set it later with `fire.flame.setLength`. Read at attach. Default: the hearth's own
51
58
  * flames (billboards) and firelight.
@@ -59,7 +66,8 @@ export interface FireOptions {
59
66
  * A smoke column over the flames (`Smoke` of `@margoengine/vfx/smoke`, as `fire.smoke`): true stands one on the flame
60
67
  * tips with the fire's convective heat (Heskestad's flame length turned back into a heat release, 70% of it
61
68
  * convective; Heskestad 1983, Drysdale 2011 ch. 4) over the flames' width, lit by the fire's `lights`; an object
62
- * gives it options of its own (colour, opacity, rate, lifetime, ...); false makes none. Read at attach. Default true
69
+ * gives it options of its own (colour, opacity, rate, lifetime, a `ceiling` indoors, ...); false makes none. With
70
+ * `lights` the fire's own lights light the column and its `glow` defaults to 0. Read at attach. Default true
63
71
  * with `flameLength` (a large fire always smokes), false for the hearth's own flames (a wood hearth's thin smoke is
64
72
  * its `steam`).
65
73
  */
@@ -103,10 +111,23 @@ export declare class Fire implements EnginePlugin {
103
111
  private engine?;
104
112
  private readonly stopFlicker?;
105
113
  private disposed;
114
+ /** The smoke's source, on the flame tips: `setLength` moves it. */
115
+ private readonly smokeAt?;
116
+ /** The fuel top's height and the footprint's puffing diameter, for `setLength`. */
117
+ private readonly base;
118
+ private readonly diameter;
106
119
  private constructor();
107
120
  setup(engine: Engine): void;
108
121
  /** Sets the wind of the flames, embers and steam (see {@link FireOptions.wind}); undefined removes it. */
109
122
  setWind(wind: VFXWind | undefined): this;
123
+ /**
124
+ * Sets the flame length, metres, 0.05 to 1,000, of a fire made with a `flameLength`, for a fire that grows and dies
125
+ * (a `burningBed` of `@margoengine/vfx/flame` gives the length over its burn): the flames, the smoke column's heat
126
+ * (Heskestad's height turned round over the footprint, 70% of it convected, as at attach) and its source on the new
127
+ * flame tips. The embers keep the size they were made with. Answers from the next frame.
128
+ * @throws TypeError for a hearth fire (one made without a `flameLength`); RangeError for a length outside 0.05 to 1,000.
129
+ */
130
+ setLength(length: number): this;
110
131
  /** Lights and particles for a fire at `options.position`; see {@link FireOptions}. */
111
132
  static attach(engine: EngineKernel, options: FireOptions): Fire;
112
133
  /**
package/dist/fire.js CHANGED
@@ -1,6 +1,6 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const e=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
3
+ const e=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
4
  import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
5
5
  import { finiteVector as t } from "@margoengine/math/validate";
6
6
  import { MargoError as n } from "@margoengine/math/errors";
@@ -12,129 +12,145 @@ import { shapes as s } from "@margoengine/vfx/shapes";
12
12
  import { soft as c } from "@margoengine/vfx/soft";
13
13
  import { stretch as l } from "@margoengine/vfx/stretch";
14
14
  import { overLife as u } from "@margoengine/vfx/over-life";
15
- import { Flame as d, HEARTH_FLAME_LENGTH as f, puffingDiameter as p, scaleHearthEmbers as m } from "@margoengine/vfx/flame";
16
- import { Smoke as h } from "@margoengine/vfx/smoke";
17
- import { schedule as g } from "@margoengine/vfx/schedule";
18
- import { snowNight as _ } from "@margoengine/sky/scene-kits";
15
+ import { Flame as d, HEARTH_FLAME_LENGTH as f, heskestadHeat as p, puffingDiameter as m, scaleHearthEmbers as h } from "@margoengine/vfx/flame";
16
+ import { Smoke as g } from "@margoengine/vfx/smoke";
17
+ import { schedule as _ } from "@margoengine/vfx/schedule";
18
+ import { snowNight as v } from "@margoengine/sky/scene-kits";
19
19
  //#region src/fire.ts
20
- var v = (e) => .2126 * e[0] + .7152 * e[1] + .0722 * e[2];
21
- function y(e) {
20
+ var y = .7, b = (e) => .2126 * e[0] + .7152 * e[1] + .0722 * e[2];
21
+ function x(e) {
22
22
  let t = e.color.slice(0, 3), n = e.curves.color.length ? e.curves.color.map((e) => e.color) : [[
23
23
  1,
24
24
  1,
25
25
  1
26
26
  ]];
27
- return e.intensity * Math.max(...n.map((e) => v(e.map((e, n) => e * t[n]))));
27
+ return e.intensity * Math.max(...n.map((e) => b(e.map((e, n) => e * t[n]))));
28
28
  }
29
- var b = .08, x = 0, S = class S {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
30
- constructor(e, S) {
31
- this.name = "vfx-fire:" + x++, this.disposed = !1;
32
- let C = S.flameLength;
33
- if (C !== void 0 && !(Number.isFinite(C) && C >= .05 && C <= 1e3)) throw RangeError("Fire flameLength must be a finite length from 0.05 to 1000 (metres)");
34
- let w = S.hearth ?? _().hearth, T = S.width ?? (C === void 0 ? w.light.length : Math.max(w.light.length, C)), E = S.breadth ?? .6 * T, D = C === void 0 ? w : {
35
- ...w,
36
- embers: m(w.embers, C, [T, E]),
37
- emberHeight: w.emberHeight * Math.max(C / f, 1)
38
- }, { light: O } = D, k = S.power ?? 1, A = S.axis ?? [
29
+ function S(e) {
30
+ let t = e.color.slice(0, 3), n = e.curves.color.length ? e.curves.color.map((e) => e.color) : [[
31
+ 1,
32
+ 1,
33
+ 1
34
+ ]];
35
+ return Math.max(...n.flatMap((e) => e.map((e, n) => e * t[n])));
36
+ }
37
+ var C = .08, w = 0, T = class T {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
38
+ constructor(e, T) {
39
+ this.name = "vfx-fire:" + w++, this.disposed = !1;
40
+ let E = T.flameLength;
41
+ if (E !== void 0 && !(Number.isFinite(E) && E >= .05 && E <= 1e3)) throw RangeError("Fire flameLength must be a finite length from 0.05 to 1000 (metres)");
42
+ let D = T.hearth ?? v().hearth, O = T.width ?? (E === void 0 ? D.light.length : Math.max(D.light.length, E)), k = T.breadth ?? .6 * O, A = E === void 0 ? D : {
43
+ ...D,
44
+ embers: h(D.embers, E, [O, k]),
45
+ emberHeight: D.emberHeight * Math.max(E / f, 1)
46
+ }, { light: j } = A, M = T.power ?? 1, N = T.axis ?? [
39
47
  1,
40
48
  0,
41
49
  0
42
- ], j = S.castShadow ?? !0;
43
- if (t(S.position, 3, "Fire position"), t(A, 3, "Fire axis"), S.steam && t(S.steam, 3, "Fire steam point"), !(k >= 0 && Number.isFinite(k))) throw RangeError("Fire power must be a finite number of 0 or more");
44
- if (!(T > 0 && Number.isFinite(T))) throw RangeError("Fire width must be a finite length above 0 (metres)");
45
- if (!(E > 0 && Number.isFinite(E))) throw RangeError("Fire breadth must be a finite length above 0 (metres)");
46
- let M = Math.hypot(A[0], A[1], A[2]);
47
- if (!M) throw RangeError("Fire axis must be nonzero");
48
- let [N, P, F] = S.position, I = A.map((e) => e / M * (T / 2)), L = [
49
- N,
50
- P + O.height,
51
- F
52
- ], R = v(O.color) / (Math.PI * y(D.fire));
53
- this.lights = Object.freeze(C === void 0 ? r({
50
+ ], P = T.castShadow ?? !0;
51
+ if (T.keyDistance !== void 0 && E === void 0) throw TypeError("Fire keyDistance meters a large fire; pass a flameLength with it");
52
+ if (t(T.position, 3, "Fire position"), t(N, 3, "Fire axis"), T.steam && t(T.steam, 3, "Fire steam point"), !(M >= 0 && Number.isFinite(M))) throw RangeError("Fire power must be a finite number of 0 or more");
53
+ if (!(O > 0 && Number.isFinite(O))) throw RangeError("Fire width must be a finite length above 0 (metres)");
54
+ if (!(k > 0 && Number.isFinite(k))) throw RangeError("Fire breadth must be a finite length above 0 (metres)");
55
+ let F = Math.hypot(N[0], N[1], N[2]);
56
+ if (!F) throw RangeError("Fire axis must be nonzero");
57
+ let [I, L, R] = T.position;
58
+ this.base = L, this.diameter = m([O, k]);
59
+ let z = N.map((e) => e / F * (O / 2)), B = [
60
+ I,
61
+ L + j.height,
62
+ R
63
+ ], V = b(j.color) / (Math.PI * x(A.fire));
64
+ this.lights = Object.freeze(E === void 0 ? r({
54
65
  start: [
55
- L[0] - I[0],
56
- L[1] - I[1],
57
- L[2] - I[2]
66
+ B[0] - z[0],
67
+ B[1] - z[1],
68
+ B[2] - z[2]
58
69
  ],
59
70
  end: [
60
- L[0] + I[0],
61
- L[1] + I[1],
62
- L[2] + I[2]
71
+ B[0] + z[0],
72
+ B[1] + z[1],
73
+ B[2] + z[2]
63
74
  ],
64
- range: O.range,
65
- intensity: O.intensity * k,
66
- color: [...O.color],
67
- samples: S.samples ?? (C === void 0 ? 2 : Math.min(8, Math.max(2, Math.ceil(T / (.5 * C))))),
68
- radius: O.radius * T / O.length,
69
- castShadow: j,
70
- flicker: { ...O.flicker }
75
+ range: j.range,
76
+ intensity: j.intensity * M,
77
+ color: [...j.color],
78
+ samples: T.samples ?? (E === void 0 ? 2 : Math.min(8, Math.max(2, Math.ceil(O / (.5 * E))))),
79
+ radius: j.radius * O / j.length,
80
+ castShadow: P,
81
+ flicker: { ...j.flicker }
71
82
  }).map((e) => ({
72
83
  ...e,
73
- radius: Math.max(e.radius ?? 0, Math.sqrt(((e.intensity ?? 0) / k || 0) * R) || 0)
84
+ radius: Math.max(e.radius ?? 0, Math.sqrt(((e.intensity ?? 0) / M || 0) * V) || 0)
74
85
  })) : []);
75
- let z = S.lights, B = z && "names" in z && "clustered" in z ? z : void 0, V = B ? B.clustered : z && "maxLights" in z ? z : void 0;
76
- if (z && !V) throw TypeError("Invalid Fire lights; pass a Clustered from @margoengine/clustered or its LightGroups");
77
- if (C === void 0 && j && V && !V.shadow) throw new n("state", "Fire casts soft shadows through LocalShadows; attach LocalShadows to its Clustered first, or pass castShadow: false");
78
- let H = (t, n, r) => a.attach(e, {
86
+ let H = T.lights, U = H && "names" in H && "clustered" in H ? H : void 0, W = U ? U.clustered : H && "maxLights" in H ? H : void 0;
87
+ if (H && !W) throw TypeError("Invalid Fire lights; pass a Clustered from @margoengine/clustered or its LightGroups");
88
+ if (P && W && !W.shadow) throw new n("state", "Fire casts soft shadows through LocalShadows; attach LocalShadows to its Clustered first, or pass castShadow: false");
89
+ let G = (t, n, r) => a.attach(e, {
79
90
  ...structuredClone(t),
80
91
  intensity: t.intensity * r,
81
- ...S.wind ? { wind: S.wind } : {},
92
+ ...T.wind ? { wind: T.wind } : {},
82
93
  position: [...n],
83
- ...S.depth ? {
84
- softness: Math.max(b, .1 * t.size),
85
- depth: S.depth
94
+ ...T.depth ? {
95
+ softness: Math.max(C, .1 * t.size),
96
+ depth: T.depth
86
97
  } : {}
87
98
  }, {
88
99
  curves: o,
89
100
  emitter: s,
90
101
  soft: c,
91
102
  stretch: l,
92
- schedule: g,
103
+ schedule: _,
93
104
  overLife: u
94
105
  });
95
- C !== void 0 && (this.flame = d.attach(e, {
96
- position: S.position,
97
- length: C,
98
- footprint: [T, E],
99
- yaw: Math.atan2(-A[2], A[0]),
100
- lightPower: k,
101
- ...S.wind ? { wind: S.wind } : {},
102
- ...S.depth ? { depth: S.depth } : {},
103
- ...S.lights ? { lights: S.lights } : {}
106
+ E !== void 0 && (this.flame = d.attach(e, {
107
+ position: T.position,
108
+ length: E,
109
+ footprint: [O, k],
110
+ yaw: Math.atan2(-N[2], N[0]),
111
+ lightPower: M,
112
+ castShadow: P,
113
+ ...T.keyDistance === void 0 ? {} : { keyDistance: T.keyDistance },
114
+ ...T.wind ? { wind: T.wind } : {},
115
+ ...T.depth ? { depth: T.depth } : {},
116
+ ...T.lights ? { lights: T.lights } : {}
104
117
  }));
105
- let U = C === void 0 ? H(D.fire, S.position, k) : void 0, W = S.embers === !1 ? void 0 : H(D.embers, [
106
- N,
107
- P + D.emberHeight,
108
- F
109
- ], k), G = S.steam ? H(D.steam, S.steam, 1) : void 0;
118
+ let K = E === void 0 ? G(A.fire, T.position, M) : void 0, q = A.embers.intensity * S(A.embers), J = this.flame ? q > 0 ? this.flame.peakRadiance * M / q : 0 : M, Y = T.embers === !1 ? void 0 : G(A.embers, [
119
+ I,
120
+ L + A.emberHeight,
121
+ R
122
+ ], J), X = T.steam ? G(A.steam, T.steam, 1) : void 0;
110
123
  this.particles = Object.freeze({
111
- flames: U,
112
- embers: W,
113
- steam: G
124
+ flames: K,
125
+ embers: Y,
126
+ steam: X
114
127
  });
115
- let K = S.smoke ?? C !== void 0;
116
- if (K && typeof K != "boolean" && typeof K != "object") throw TypeError("Invalid Fire smoke; pass true, false or Smoke options");
117
- if (K) {
118
- let t = C ?? f, n = p([T, E]), r = 700 * (Math.max(t + 1.02 * n, 0) / .235) ** 2.5;
119
- this.smoke = h.attach(e, {
120
- radius: n / 2,
121
- ...V ? { lights: V } : {},
122
- ...typeof K == "object" ? K : {},
128
+ let Z = T.smoke ?? E !== void 0;
129
+ if (Z && typeof Z != "boolean" && typeof Z != "object") throw TypeError("Invalid Fire smoke; pass true, false or Smoke options");
130
+ if (Z) {
131
+ let t = E ?? f, n = y * p(t, this.diameter);
132
+ this.smokeAt = [
133
+ I,
134
+ L + t,
135
+ R
136
+ ], this.smoke = g.attach(e, {
137
+ radius: this.diameter / 2,
138
+ ...W ? {
139
+ lights: W,
140
+ glow: 0
141
+ } : {},
142
+ ...typeof Z == "object" ? Z : {},
123
143
  fire: this,
124
- position: [
125
- N,
126
- P + t,
127
- F
128
- ],
129
- heat: r
144
+ position: this.smokeAt,
145
+ heat: n
130
146
  });
131
147
  }
132
- if (V && C === void 0) {
133
- if (B) {
148
+ if (W && E === void 0) {
149
+ if (U) {
134
150
  let e = "fire";
135
- for (let t = 2; B.names.includes(e); t++) e = `fire ${t}`;
136
- this.target = this.group = B.group(e);
137
- } else this.target = V;
151
+ for (let t = 2; U.names.includes(e); t++) e = `fire ${t}`;
152
+ this.target = this.group = U.group(e);
153
+ } else this.target = W;
138
154
  this.stopFlicker = i(e, this.target, this.lights);
139
155
  }
140
156
  }
@@ -149,9 +165,14 @@ var b = .08, x = 0, S = class S {coreRequirement=__margoCoreRequirement("0.1.0",
149
165
  ]) t?.setWind(e);
150
166
  return this.flame?.setWind(e), this;
151
167
  }
152
- static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("0.1.0",import.meta.url));
168
+ setLength(e) {
169
+ if (!this.flame) throw TypeError("Fire setLength sizes a large fire; attach it with a flameLength");
170
+ if (!(Number.isFinite(e) && e >= .05 && e <= 1e3)) throw RangeError("Fire flameLength must be a finite length from 0.05 to 1000 (metres)");
171
+ return this.flame.setLength(e), this.smoke && this.smokeAt && (this.smokeAt[1] = this.base + e, this.smoke.setHeat(y * p(e, this.diameter))), this;
172
+ }
173
+ static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
153
174
  if (!n || typeof n != "object") throw TypeError("Invalid Fire options; pass an object with a position [x, y, z]");
154
- let r = new S(t, n);
175
+ let r = new T(t, n);
155
176
  return e(t).use(r), r;
156
177
  }
157
178
  dispose() {
@@ -170,4 +191,4 @@ var b = .08, x = 0, S = class S {coreRequirement=__margoCoreRequirement("0.1.0",
170
191
  }
171
192
  };
172
193
  //#endregion
173
- export { S as Fire };
194
+ export { T as Fire };
package/dist/flame.d.ts CHANGED
@@ -27,6 +27,61 @@ export declare function byramIntensity(length: number): number;
27
27
  * @example heskestadFlameLength(20e6, 4); // 8.3 m: a house fire through a roof breach 4 m across
28
28
  */
29
29
  export declare function heskestadFlameLength(heat: number, diameter: number): number;
30
+ /** Options of {@link burningBed}: a bed of burning pieces (incendiaries, cordwood, debris) and how they catch. */
31
+ export interface BurningBedOptions {
32
+ /** Mass of fuel that burns, kilograms, above 0. */
33
+ fuel: number;
34
+ /** Area of the bed, square metres, above 0: its diameter is that of a circle of the same area. */
35
+ area: number;
36
+ /** Seconds one piece burns, at a steady rate, above 0. */
37
+ burnTime: number;
38
+ /** Heat of combustion of the fuel, J/kg, above 0. */
39
+ heatOfCombustion: number;
40
+ /** Seconds over which the pieces catch, evenly, 0 or more (0: all at once). Default 0. */
41
+ spread?: number;
42
+ }
43
+ /** A burning bed's heat release and flames over time; see {@link burningBed}. */
44
+ export interface BurningBed {
45
+ /** Seconds from the first piece catching to the last going out: `spread + burnTime`. */
46
+ readonly duration: number;
47
+ /** The bed's diameter, metres: a circle of its area. */
48
+ readonly diameter: number;
49
+ /** The heat release, watts, `t` seconds after the first piece caught; 0 before and after the burn. */
50
+ power(t: number): number;
51
+ /** Heskestad's mean flame height, metres, at `t` ({@link heskestadFlameLength} of {@link power} over the bed). */
52
+ flameLength(t: number): number;
53
+ }
54
+ /**
55
+ * The 4 lb magnesium incendiary bomb (US AN-M50, the British 4 lb Mk IV of the same design): its body of magnesium alloy,
56
+ * 0.567 kg (1.25 lb), burns about ten minutes at 2,300 to 2,500 F (War Department TM 3-330, "Incendiary Bombs", 23
57
+ * March 1942, chapter on the AN-M50; the body's weight from the AN-M50 drawings). Magnesium releases 24.7 MJ/kg burning
58
+ * to MgO (its standard enthalpy of formation, -601.6 kJ/mol, over 24.305 g/mol; NIST-JANAF Thermochemical Tables,
59
+ * 4th ed., M. W. Chase, J. Phys. Chem. Ref. Data Monograph 9, 1998). Its smoke, MgO, is white: `smoke` is the
60
+ * diffuse reflectance of smoked magnesium oxide, 0.97 across the visible (W. E. K. Middleton and C. L. Sanders, "The
61
+ * absolute spectral diffuse reflectance of magnesium oxide", J. Opt. Soc. Am. 41(6), 419-424, 1951,
62
+ * https://doi.org/10.1364/JOSA.41.000419), a `Smoke` colour. The fields of a {@link burningBed} per bomb: multiply
63
+ * `itemMass` by the count for the bed's `fuel`.
64
+ */
65
+ export declare const INCENDIARY_4LB: Readonly<{
66
+ itemMass: 0.567;
67
+ burnTime: 600;
68
+ heatOfCombustion: 24700000;
69
+ smoke: readonly [0.97, 0.97, 0.97];
70
+ }>;
71
+ /**
72
+ * A bed of burning pieces that catch evenly over `spread` seconds and each burn `burnTime` seconds at a steady rate:
73
+ * the heat release is `fuel * heatOfCombustion / burnTime` times the share of pieces alight, rising over the spread,
74
+ * steady while they all burn and falling over the spread as they go out (the sum of the pieces' own top-hat burns), and
75
+ * the flames are Heskestad's over the bed's diameter (Heskestad 1983). A bed too wide for its heat has no flame above
76
+ * it (a length of 0), only its glowing pieces.
77
+ * @throws RangeError for an option outside its range.
78
+ * @example
79
+ * // 20,000 incendiaries over a 30 m crater floor, catching over a minute: about 470 MW for ten minutes.
80
+ * const bed = burningBed({ ...INCENDIARY_4LB, fuel: 20000 * INCENDIARY_4LB.itemMass, area: 700, spread: 60 });
81
+ * bed.duration; // 660 s
82
+ * bed.flameLength(300); // 13.1 m
83
+ */
84
+ export declare function burningBed(options: BurningBedOptions): BurningBed;
30
85
  /** Cetegen and Ahmed 1993's puffing constant: a pool fire D metres across puffs at 1.5 D^(-1/2) Hz. */
31
86
  export declare const PUFFING_CONSTANT = 1.5;
32
87
  /**
@@ -65,6 +120,35 @@ export declare const FLAME_RADIANT_FRACTION = 0.3;
65
120
  export declare function flameLuminousFlux(heat: number, kelvin: number, radiantFraction?: number): number;
66
121
  /** The heat release, watts, of a flame `length` metres tall over a source `diameter` across (Heskestad 1983 turned round). */
67
122
  export declare function heskestadHeat(length: number, diameter: number): number;
123
+ /** `flameCoreRadiance` settings: the fire and how its flame is drawn. */
124
+ export interface FlameRadianceOptions {
125
+ /** The fire's heat release, watts, 0 or more. */
126
+ heat: number;
127
+ /** The flame's surface, square metres, above 0. */
128
+ area: number;
129
+ /** The temperature of the flame's core, kelvin, 800 to 3,000. */
130
+ kelvin: number;
131
+ /** The engine sun intensity of the scene's noon sun of 1,000 W/m^2, above 0. Default pi (as `SmokeOptions.noon`). */
132
+ noon?: number;
133
+ /** The share of the heat release radiated, 0 to 1. Default {@link FLAME_RADIANT_FRACTION}. */
134
+ radiantFraction?: number;
135
+ }
136
+ /**
137
+ * A flame's core radiance in its brightest channel, scene-linear, from its heat release: the radiated share
138
+ * `radiantFraction` of `heat` leaves through the flame's `area` (its surface emissive power, never above the blackbody's
139
+ * sigma T^4 at the core), seen as luminance E eta(T) / pi with the Planck luminous efficacy eta of the core's
140
+ * temperature, and referred to the noon sun as the smoke's glow is (the same radiated share of the same release lights
141
+ * the column): a white card under a sun of 1,000 W/m^2 (SUN_EFFICACY lm/W) shows noon / pi, so a luminance Lv shows Lv
142
+ * noon / (1,000 SUN_EFFICACY). The emissive power this gives matches measured fires: about 55 kW/m^2 for a 1 MW fire
143
+ * one metre across, where Shokri and Beyler's pool-fire correlation, 58 x 10^(-0.00823 D) kW/m^2 (Shokri and Beyler,
144
+ * "Radiation from large pool fires", J. Fire Protection Engineering 1(4), 141-149, 1989), gives 57; and up to a few
145
+ * hundred kW/m^2 in crown fires, as Butler et al. 2004 measured.
146
+ * @throws RangeError for a heat, area, temperature, noon or fraction out of range.
147
+ * @example flameCoreRadiance({ heat: 1e6, area: 5.57, kelvin: 2200 }); // about 2.7 (a sunlit white card is 1)
148
+ */
149
+ export declare function flameCoreRadiance(options: FlameRadianceOptions): number;
150
+ /** The surface of a flame zone `length` tall over a footprint: two faces tapering to a ridge along the longer side, and its base. */
151
+ export declare function flameArea(length: number, footprint: readonly [number, number]): number;
68
152
  /** A flame's hot plume ({@link Flame.plume}): the shape `HeatHaze` of `@margoengine/post/heat-haze` reads. */
69
153
  export interface FlamePlume {
70
154
  /** Centre of the footprint on the fuel, world units. */
@@ -102,6 +186,14 @@ export interface FlameOptions extends FlameRampOptions {
102
186
  * and the glow lights it. Default [0, 0] (level ground).
103
187
  */
104
188
  slope?: readonly [number, number];
189
+ /**
190
+ * The ground's height over the `slope` plane, metres, at {@link FLAME_RELIEF} x {@link FLAME_RELIEF} points evenly
191
+ * over the footprint (row by row along its z axis, each row along its x axis, the first and last points on its edges),
192
+ * each within 1,000 m: the flame stands on the ground between them (bilinear) instead of on the plane, so a long
193
+ * stretch over a rise or a hollow is neither buried in the rise nor floating over the hollow, and its glow and lights
194
+ * follow it (KB-VFX-FLAMELOOK1). Read every frame. Default none (the plane).
195
+ */
196
+ relief?: ArrayLike<number>;
105
197
  /**
106
198
  * The light the flame throws into the air and onto the ground around it, as a multiple of the physical, 0 to 8: the
107
199
  * smoky air within `glowRadius` flame lengths glows with the light it scatters (Sun et al. 2005), and the ground plane
@@ -138,6 +230,29 @@ export interface FlameOptions extends FlameRampOptions {
138
230
  lights?: Clustered | LightGroups;
139
231
  /** Scales the light, 0 or more. Default 1. */
140
232
  lightPower?: number;
233
+ /**
234
+ * The engine sun intensity of the scene's noon sun of 1,000 W/m^2, which the flame's radiance is referred to (as
235
+ * `SmokeOptions.noon`, the sky's `lighting.intensity`): the core's radiance is the heat release's
236
+ * ({@link flameCoreRadiance}), so a fire is the same share of the noon light in any scene. Read every frame. Default pi.
237
+ */
238
+ noon?: number;
239
+ /**
240
+ * Meters the light on a white card: the distance, metres, above 0, at which a white Lambertian card facing the flame
241
+ * reads 1 in the pre-exposed frame (luminous intensity pi d^2, from `E = I / d^2` and `L = E / pi`), before
242
+ * `lightPower` and the flicker. It replaces the silhouette light of {@link FLAME_LIGHT_FILL}, which lights a wall at
243
+ * the flames' displayed brightness times its solid angle: right for a frame exposed on the flames, several stops dark
244
+ * for one exposed on what they light (a tunnel, a room at night). The flames' own radiance is unchanged. Default
245
+ * none: the silhouette light.
246
+ */
247
+ keyDistance?: number;
248
+ /**
249
+ * The light casts soft shadows (`LocalShadows` from `@margoengine/clustered/shadows`, attached to the same
250
+ * `Clustered` first, which also takes the casters): all of it is then one point at the footprint's middle, a third of
251
+ * the flame up, with the source radius as the penumbra's, so it takes one of `LocalShadows`' `maxLights` slots (six
252
+ * cube faces) and walls and piers stop it. Without `lights` it does nothing. Read at attach. Default false: up to four
253
+ * points over the footprint that light through everything.
254
+ */
255
+ castShadow?: boolean;
141
256
  /** Fog over the flames (`Fog` of `@margoengine/environment` or any `FogLike`). Default none. */
142
257
  fog?: FogLike | null;
143
258
  /**
@@ -146,13 +261,47 @@ export interface FlameOptions extends FlameRampOptions {
146
261
  * depth-tested against the scene, which draws nothing from inside it.
147
262
  */
148
263
  depth?: () => GPUTexture | undefined;
264
+ /**
265
+ * Draw the flame's coverage (its opacity along each pixel's ray) into the frame's shared reactive mask, which TAA reads
266
+ * with no option, so the rising, puffing tongues stay crisp instead of smearing into a history they have no motion
267
+ * vectors for. The glow, smooth added light, is left out. Default: on while TAA (or another reader of reactive masks)
268
+ * runs, off otherwise; `true` draws it every frame, `false` never. Changeable between frames.
269
+ */
270
+ reactive?: boolean;
271
+ }
272
+ /** Points a side of a flame's `relief` grid over its footprint (8: 64 heights, two to three flame lengths apart at most on a front's longest stretches). */
273
+ export declare const FLAME_RELIEF = 8;
274
+ /**
275
+ * The ground's height over a flame's plane at a point of its footprint, `(u, v)` each -1 to 1 across it (clamped
276
+ * outside): bilinear between the `relief` grid's points, as the shader reads it. 0 without a relief.
277
+ */
278
+ export declare function flameReliefAt(relief: ArrayLike<number> | undefined, u: number, v: number): number;
279
+ /** The flame coverage mask {@link watchFlameCoverage} returns. */
280
+ export interface FlameCoverage extends Disposable {
281
+ /**
282
+ * This frame's mask (r8unorm, the frame's size): 1 wherever a `Flame` of the engine is drawn with coverage above zero,
283
+ * the flames' own depth test applied, 0 elsewhere; the glow is left out. Undefined when no flame drew in the latest
284
+ * frame. Read after the frame (a shot page's AOVs); borrowed, replaced on resize.
285
+ */
286
+ readonly texture: GPUTexture | undefined;
287
+ /** Stops watching; the mask is freed once no watcher is left. */
288
+ dispose(): void;
149
289
  }
290
+ /**
291
+ * Has every `Flame` of `engine` also draw where it is drawn into a coverage mask, each frame until disposed, for look
292
+ * checks that must tell a flame's own animation from the surfaces around it (KB-LOOK-TV-FLAMEMASK1). A pixel counts as
293
+ * flame only where the flame's drawn coverage is above zero, so no threshold is chosen; smoke, embers and the glow are
294
+ * not flame. Costs one more draw of each lit flame's box a frame while watched.
295
+ * @throws TypeError when `engine` is not an engine (no `use`).
296
+ */
297
+ export declare function watchFlameCoverage(engine: EngineKernel): FlameCoverage;
150
298
  /**
151
299
  * A flame of any size, from a campfire to a house fire or a burning forest crown: one ray-marched volume over its
152
300
  * footprint, sized by a flame length, an intensity (Byram 1959) or a heat release (Heskestad 1983). Tall tapering
153
301
  * tongues rise at the buoyant speed and break up at the tip half the time at the flame length (Zukoski et al. 1985); the
154
302
  * zone puffs at 1.5 D^(-1/2) Hz (Cetegen and Ahmed 1993); the colour runs from the core's temperature to the edge's
155
- * through a camera's shoulder, so the core reads yellow-white and no pixel passes `peak` or turns white. With `lights`
303
+ * up to the core's, whose brightest channel is `peak` times `radiance` (scene-linear; the frame's exposure and display
304
+ * curve map it as they map everything else, so under a tonemap a hot bright core grades yellow-white). With `lights`
156
305
  * the flame lights the ground, smoke and anything near with point lights that flicker with its puffing. Every option
157
306
  * is read each frame and written into one uniform, so a fire that grows, moves, leans or changes its look makes no GPU
158
307
  * object after its first frame; a length of 0 puts the flames out. `applyFlameSettings` takes it as a target (the flame
@@ -165,7 +314,7 @@ export declare class Flame implements EnginePlugin {
165
314
  private readonly seed;
166
315
  /** Read every frame; see {@link FlameOptions}. */
167
316
  readonly options: FlameOptions;
168
- /** The light's points (empty without `lights`), their intensities as of the last frame. */
317
+ /** The light's points (empty without `lights`; one with `castShadow`), their intensities as of the last frame. */
169
318
  readonly lights: readonly PointLight[];
170
319
  private engine?;
171
320
  private disposed;
@@ -180,7 +329,6 @@ export declare class Flame implements EnginePlugin {
180
329
  private readonly target?;
181
330
  private readonly group?;
182
331
  private readonly steady;
183
- private coreFloor;
184
332
  /** The scene depth's samples as of this view's colour pass. */
185
333
  private samples;
186
334
  private uniform?;
@@ -190,6 +338,7 @@ export declare class Flame implements EnginePlugin {
190
338
  private readonly groups;
191
339
  private readonly attachment;
192
340
  private readonly depthAttachment;
341
+ private readonly reactiveAttachments;
193
342
  private constructor();
194
343
  /** The flame length now, metres: `length`, else Byram's of `intensity`, else Heskestad's of `heat`. */
195
344
  private length;
@@ -204,6 +353,18 @@ export declare class Flame implements EnginePlugin {
204
353
  * The ember rows do nothing here (a `Flame` has no embers).
205
354
  */
206
355
  setFlameLook(values: Readonly<Record<string, unknown>>): this;
356
+ /**
357
+ * The brightest the flame shows in any channel, linear: its `peak` times its `radiance` as the look is now times the
358
+ * heat release's core radiance ({@link flameCoreRadiance}; no gas the ray crosses is brighter than the core). A `Fire`'s embers take it as their own brightest radiance.
359
+ */
360
+ get peakRadiance(): number;
361
+ /**
362
+ * The heat release now, watts: `heat`, else the fireline `intensity` along the footprint's x side, else Heskestad's
363
+ * for the flame length over the footprint's diameter (the release a flame that long stands on).
364
+ */
365
+ get heatRelease(): number;
366
+ /** The core's radiance at peak 1 and radiance 1: {@link flameCoreRadiance} of the heat release over the drawn flame. */
367
+ private coreRadiance;
207
368
  /**
208
369
  * The hot plume over the flame as of its last frame, for `HeatHaze` of `@margoengine/post/heat-haze` (the shimmer of
209
370
  * the scene behind the fire): the base, the length now, the footprint as drawn (`flames.size` included), the yaw, the
@@ -234,6 +395,11 @@ export declare class Flame implements EnginePlugin {
234
395
  */
235
396
  resetTime(): void;
236
397
  onPreUpdate(delta: number): void;
398
+ /**
399
+ * The light's mean intensity, all its points together: the card metering of `keyDistance`, else the silhouette at
400
+ * peak radiance; times `lightPower`.
401
+ */
402
+ private lightTotal;
237
403
  /**
238
404
  * The ground plane and the glow: the slope in the footprint's axes, the glow sources' intensity (the light's total, as
239
405
  * {@link FLAME_LIGHT_FILL}, over as many sources as its points), the haze and the glow box around the flame box.
@@ -242,6 +408,8 @@ export declare class Flame implements EnginePlugin {
242
408
  /** Places the light's points over the footprint and sets each one's flicker from the puffing of the tongues above it. */
243
409
  private light;
244
410
  private draw;
411
+ /** One draw of the flame's box into a single r8unorm mask (the reactive mask or the coverage mask). */
412
+ private drawMask;
245
413
  /** Sets the flame length, metres (see {@link FlameOptions.length}); the volume answers from the next frame. */
246
414
  setLength(length: number): this;
247
415
  /** Sets the wind at the flames (see {@link FlameOptions.wind}); undefined removes it. */