@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.
- package/LICENSE +201 -201
- package/NOTICE +4 -4
- package/README.md +2241 -1642
- package/dist/{base-C9upJytz.js → base-LGs65K7K.js} +174 -123
- package/dist/base.d.ts +104 -2
- package/dist/base.js +1 -1
- package/dist/blown-sand.js +3 -3
- package/dist/clouds.d.ts +12 -4
- package/dist/clouds.js +35 -18
- package/dist/compat-BFjXAQuu.js +14 -0
- package/dist/debris.d.ts +43 -0
- package/dist/debris.js +33 -1
- package/dist/dust-current.d.ts +66 -0
- package/dist/dust-current.js +92 -0
- package/dist/fire-front.d.ts +72 -1
- package/dist/fire-front.js +309 -69
- package/dist/fire.d.ts +24 -3
- package/dist/fire.js +114 -93
- package/dist/flame.d.ts +171 -3
- package/dist/flame.js +343 -131
- package/dist/flocking-shaders.d.ts +48 -0
- package/dist/flocking-sim.d.ts +623 -0
- package/dist/flocking.d.ts +145 -0
- package/dist/flocking.js +1846 -0
- package/dist/gunfire.d.ts +52 -6
- package/dist/gunfire.js +108 -98
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/json.js +2 -0
- package/dist/lit-Dx2tNwP-.js +152 -0
- package/dist/lit.d.ts +8 -1
- package/dist/lit.js +1 -105
- package/dist/mesh.d.ts +2 -0
- package/dist/mesh.js +92 -69
- package/dist/over-life.js +16 -15
- package/dist/reactive-mask-B8xbyzlk.js +69 -0
- package/dist/ribbons.d.ts +4 -2
- package/dist/ribbons.js +87 -73
- package/dist/settings.js +1 -1
- package/dist/shader.d.ts +5 -0
- package/dist/shared/fog.d.ts +33 -33
- package/dist/shared/pass.d.ts +53 -53
- package/dist/shared/settings.d.ts +89 -89
- package/dist/smoke.d.ts +72 -4
- package/dist/smoke.js +280 -56
- 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).
|
|
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
|
-
*
|
|
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.
|
|
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
|
|
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="
|
|
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,
|
|
16
|
-
import { Smoke as
|
|
17
|
-
import { schedule as
|
|
18
|
-
import { snowNight as
|
|
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
|
|
21
|
-
function
|
|
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) =>
|
|
27
|
+
return e.intensity * Math.max(...n.map((e) => b(e.map((e, n) => e * t[n]))));
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
],
|
|
43
|
-
if (
|
|
44
|
-
if (
|
|
45
|
-
if (!(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
B[0] - z[0],
|
|
67
|
+
B[1] - z[1],
|
|
68
|
+
B[2] - z[2]
|
|
58
69
|
],
|
|
59
70
|
end: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
B[0] + z[0],
|
|
72
|
+
B[1] + z[1],
|
|
73
|
+
B[2] + z[2]
|
|
63
74
|
],
|
|
64
|
-
range:
|
|
65
|
-
intensity:
|
|
66
|
-
color: [...
|
|
67
|
-
samples:
|
|
68
|
-
radius:
|
|
69
|
-
castShadow:
|
|
70
|
-
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) /
|
|
84
|
+
radius: Math.max(e.radius ?? 0, Math.sqrt(((e.intensity ?? 0) / M || 0) * V) || 0)
|
|
74
85
|
})) : []);
|
|
75
|
-
let
|
|
76
|
-
if (
|
|
77
|
-
if (
|
|
78
|
-
let
|
|
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
|
-
...
|
|
92
|
+
...T.wind ? { wind: T.wind } : {},
|
|
82
93
|
position: [...n],
|
|
83
|
-
...
|
|
84
|
-
softness: Math.max(
|
|
85
|
-
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:
|
|
103
|
+
schedule: _,
|
|
93
104
|
overLife: u
|
|
94
105
|
});
|
|
95
|
-
|
|
96
|
-
position:
|
|
97
|
-
length:
|
|
98
|
-
footprint: [
|
|
99
|
-
yaw: Math.atan2(-
|
|
100
|
-
lightPower:
|
|
101
|
-
|
|
102
|
-
...
|
|
103
|
-
...
|
|
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
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
],
|
|
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:
|
|
112
|
-
embers:
|
|
113
|
-
steam:
|
|
124
|
+
flames: K,
|
|
125
|
+
embers: Y,
|
|
126
|
+
steam: X
|
|
114
127
|
});
|
|
115
|
-
let
|
|
116
|
-
if (
|
|
117
|
-
if (
|
|
118
|
-
let t =
|
|
119
|
-
this.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
126
|
-
P + t,
|
|
127
|
-
F
|
|
128
|
-
],
|
|
129
|
-
heat: r
|
|
144
|
+
position: this.smokeAt,
|
|
145
|
+
heat: n
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
148
|
+
if (W && E === void 0) {
|
|
149
|
+
if (U) {
|
|
134
150
|
let e = "fire";
|
|
135
|
-
for (let t = 2;
|
|
136
|
-
this.target = this.group =
|
|
137
|
-
} else this.target =
|
|
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
|
-
|
|
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
|
|
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 {
|
|
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
|
-
*
|
|
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. */
|