@margoengine/vfx 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +2240 -2
- package/dist/base-LGs65K7K.js +709 -0
- package/dist/base.d.ts +869 -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 +237 -0
- package/dist/clouds.js +583 -0
- package/dist/compat-BFjXAQuu.js +14 -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 +154 -0
- package/dist/debris.js +290 -0
- package/dist/depth-collide.d.ts +7 -0
- package/dist/depth-collide.js +96 -0
- package/dist/dust-current.d.ts +66 -0
- package/dist/dust-current.js +92 -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 +610 -0
- package/dist/fire-front.js +1080 -0
- package/dist/fire.d.ts +140 -0
- package/dist/fire.js +194 -0
- package/dist/flame-ramp-VoBKpYnM.js +75 -0
- package/dist/flame-ramp.d.ts +61 -0
- package/dist/flame.d.ts +428 -0
- package/dist/flame.js +817 -0
- package/dist/flipbook.d.ts +7 -0
- package/dist/flipbook.js +23 -0
- 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/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 +742 -0
- package/dist/gunfire.js +1214 -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 +239 -0
- package/dist/lit-Dx2tNwP-.js +152 -0
- package/dist/lit.d.ts +18 -0
- package/dist/lit.js +1 -0
- package/dist/mesh.d.ts +16 -0
- package/dist/mesh.js +248 -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 +94 -0
- package/dist/reactive-mask-B8xbyzlk.js +69 -0
- package/dist/require-webgpu--tUXPsmA.js +7 -0
- package/dist/ribbons.d.ts +22 -0
- package/dist/ribbons.js +165 -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 +49 -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 +283 -0
- package/dist/smoke.js +504 -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 +198 -4
package/dist/flame.d.ts
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
3
|
+
import type { Engine, EnginePlugin, FrameGraph } from '@margoengine/core/extension';
|
|
4
|
+
import type { Clustered, PointLight } from '@margoengine/clustered';
|
|
5
|
+
import type { LightGroups } from '@margoengine/clustered/groups';
|
|
6
|
+
import { type FogLike } from './shared/fog.js';
|
|
7
|
+
import type { VFXWind } from '@margoengine/vfx/base';
|
|
8
|
+
import { type FlameRampOptions } from './flame-ramp.js';
|
|
9
|
+
export { blackbodyChromaticity, blackbodyColor, blackbodyLuminanceRatio, blackbodyLuminousEfficacy, flameRamp, FLAME_PEAK, type FlameRampOptions, type FlameStop, } from './flame-ramp.js';
|
|
10
|
+
type Vec3 = readonly [number, number, number];
|
|
11
|
+
/** The rise speed of a flame over sqrt(g L) (Quintiere 1989's scaling, with the constant of a flame's mean rise). */
|
|
12
|
+
export declare const FLAME_FROUDE = 0.5;
|
|
13
|
+
/** The flame length of the Cabin Hearth's fire, metres: the length the hearth kit's flames rise to. */
|
|
14
|
+
export declare const HEARTH_FLAME_LENGTH = 0.25;
|
|
15
|
+
/**
|
|
16
|
+
* Byram's flame length of a fireline, metres: 0.0775 I^0.46 for a fireline intensity I in kW/m (Byram 1959).
|
|
17
|
+
* @throws RangeError for an intensity that is not a finite number of 0 or more.
|
|
18
|
+
* @example byramFlameLength(10000); // 5.4 m
|
|
19
|
+
*/
|
|
20
|
+
export declare function byramFlameLength(intensity: number): number;
|
|
21
|
+
/** The fireline intensity, kW/m, whose Byram flame length is `length` metres (the inverse of {@link byramFlameLength}). */
|
|
22
|
+
export declare function byramIntensity(length: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* Heskestad's mean flame height, metres, of a fire releasing `heat` watts over a source `diameter` metres across:
|
|
25
|
+
* 0.235 Q^(2/5) - 1.02 D with Q in kW, never below 0 (Heskestad 1983).
|
|
26
|
+
* @throws RangeError for a heat or diameter that is not a finite number of 0 or more.
|
|
27
|
+
* @example heskestadFlameLength(20e6, 4); // 8.3 m: a house fire through a roof breach 4 m across
|
|
28
|
+
*/
|
|
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;
|
|
85
|
+
/** Cetegen and Ahmed 1993's puffing constant: a pool fire D metres across puffs at 1.5 D^(-1/2) Hz. */
|
|
86
|
+
export declare const PUFFING_CONSTANT = 1.5;
|
|
87
|
+
/**
|
|
88
|
+
* The puffing frequency, Hz, of a fire `diameter` metres across: 1.5 D^(-1/2) (Cetegen and Ahmed 1993).
|
|
89
|
+
* @throws RangeError for a diameter that is not a finite number above 0.
|
|
90
|
+
* @example puffingFrequency(4); // 0.75 Hz
|
|
91
|
+
*/
|
|
92
|
+
export declare function puffingFrequency(diameter: number): number;
|
|
93
|
+
/**
|
|
94
|
+
* The source diameter, metres, that sets the puffing of a footprint `[x, z]` metres: the diameter of a circle of the same
|
|
95
|
+
* area for a compact fire, never more than twice its narrower side, so a long line of fire puffs as its depth does.
|
|
96
|
+
*/
|
|
97
|
+
export declare function puffingDiameter(footprint: readonly [number, number]): number;
|
|
98
|
+
/**
|
|
99
|
+
* The flame's light over its peak radiance times its silhouette (flame length by width): a source of radiance Lr and
|
|
100
|
+
* area A has intensity Lr A, so a wall it lights is never brighter than the flame (the flame fills about half of that
|
|
101
|
+
* rectangle, at about its peak radiance).
|
|
102
|
+
*/
|
|
103
|
+
export declare const FLAME_LIGHT_FILL = 0.5;
|
|
104
|
+
/**
|
|
105
|
+
* The share of a fire's heat release that leaves as radiation (the radiative fraction chi_r): about 0.3 for wood,
|
|
106
|
+
* cellulosic packing and most sooty fuels in free burn (Tewarson, "Generation of Heat and Gaseous, Liquid, and Solid
|
|
107
|
+
* Products in Fires", SFPE Handbook of Fire Protection Engineering, 5th ed., 2016; Koseki, "Combustion properties of
|
|
108
|
+
* large liquid pool fires", Fire Technology 25(3), 241-255, 1989; McCaffrey, "Purely Buoyant Diffusion Flames: Some
|
|
109
|
+
* Experimental Results", NBSIR 79-1910, 1979).
|
|
110
|
+
*/
|
|
111
|
+
export declare const FLAME_RADIANT_FRACTION = 0.3;
|
|
112
|
+
/**
|
|
113
|
+
* The luminous flux of a fire, lumens: the radiated share of its heat release (`radiantFraction` of `heat` watts) times
|
|
114
|
+
* the luminous efficacy of blackbody radiation at the temperature it radiates at (`kelvin`, Planck's law through the
|
|
115
|
+
* photopic curve). A candle (about 80 W, chi_r about 0.2, 1,850 K soot) gives about 12 lm, the one candela it was
|
|
116
|
+
* named for; a 1 MW wood fire at 1,760 K about 150,000 lm.
|
|
117
|
+
* @throws RangeError for a heat or fraction out of range, or a temperature outside 500 to 40,000 K.
|
|
118
|
+
* @example flameLuminousFlux(1e6, 1760); // about 150,000 lm
|
|
119
|
+
*/
|
|
120
|
+
export declare function flameLuminousFlux(heat: number, kelvin: number, radiantFraction?: number): number;
|
|
121
|
+
/** The heat release, watts, of a flame `length` metres tall over a source `diameter` across (Heskestad 1983 turned round). */
|
|
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;
|
|
152
|
+
/** A flame's hot plume ({@link Flame.plume}): the shape `HeatHaze` of `@margoengine/post/heat-haze` reads. */
|
|
153
|
+
export interface FlamePlume {
|
|
154
|
+
/** Centre of the footprint on the fuel, world units. */
|
|
155
|
+
readonly position: readonly [number, number, number];
|
|
156
|
+
/** Flame length now, metres (0 when out). */
|
|
157
|
+
readonly length: number;
|
|
158
|
+
/** Footprint `[x, z]` before `yaw`, metres, as drawn. */
|
|
159
|
+
readonly footprint: readonly [number, number];
|
|
160
|
+
/** Turn of the footprint about +y, radians. */
|
|
161
|
+
readonly yaw: number;
|
|
162
|
+
/** Lean in the wind, `[x, z]` world metres across per metre up. */
|
|
163
|
+
readonly lean: readonly [number, number];
|
|
164
|
+
/** The flame's clock, seconds. */
|
|
165
|
+
readonly time: number;
|
|
166
|
+
}
|
|
167
|
+
/** `Flame.attach` settings. `position` is required, and one of `length`, `intensity` or `heat`. */
|
|
168
|
+
export interface FlameOptions extends FlameRampOptions {
|
|
169
|
+
/** Centre of the footprint on the fuel, world units. */
|
|
170
|
+
position: Vec3;
|
|
171
|
+
/** The flame length, metres, 0 to 1,000 (0 puts the flames out). Wins over `intensity` and `heat`. */
|
|
172
|
+
length?: number;
|
|
173
|
+
/** A fireline's intensity, kW/m: the length is Byram's (Byram 1959). */
|
|
174
|
+
intensity?: number;
|
|
175
|
+
/** A fire's heat release, watts: the length is Heskestad's over the footprint's diameter (Heskestad 1983). */
|
|
176
|
+
heat?: number;
|
|
177
|
+
/** Footprint `[x, z]` before `yaw`, metres, 0 or more. Default `[0.5 length, 0.5 length]`. */
|
|
178
|
+
footprint?: readonly [number, number];
|
|
179
|
+
/** Turn of the footprint about +y, radians (its x side runs along `[cos yaw, 0, -sin yaw]`). Default 0. */
|
|
180
|
+
yaw?: number;
|
|
181
|
+
/** The wind at the flames, `[x, z]` m/s or `{sample(x, y, z, t)}`: the flames lean atan(U / w) at their rise speed w. Default none. */
|
|
182
|
+
wind?: VFXWind;
|
|
183
|
+
/**
|
|
184
|
+
* The slope of the ground under the flame, `[dy/dx, dy/dz]` in world axes, each -10 to 10: the flame stands on that
|
|
185
|
+
* plane through `position` (its base follows the ground across a long footprint instead of being cut by the slope),
|
|
186
|
+
* and the glow lights it. Default [0, 0] (level ground).
|
|
187
|
+
*/
|
|
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>;
|
|
197
|
+
/**
|
|
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
|
|
199
|
+
* smoky air within `glowRadius` flame lengths glows with the light it scatters (Sun et al. 2005), and the ground plane
|
|
200
|
+
* (`slope`) is lit by it. Without `depth`, surfaces standing in that light (trees) take the light of the ground
|
|
201
|
+
* behind them. 0 turns it off. Default 1.
|
|
202
|
+
*/
|
|
203
|
+
glow?: number;
|
|
204
|
+
/** Scattering coefficient of the air around the flames, per metre, 0 to 1 (a light haze 0.0005, smoke-filled air at a wildfire about 0.003 to 0.01, a clear night 0.0001). Default 0.0005. */
|
|
205
|
+
haze?: number;
|
|
206
|
+
/** Reflectance of the ground the glow lights, 0 to 1 (forest litter about 0.15). Default 0.15; 0 when `lights` is given (the point lights light the scene). */
|
|
207
|
+
groundAlbedo?: number;
|
|
208
|
+
/** How far the glow reaches, flame lengths, 0.5 to 10. Default 3. */
|
|
209
|
+
glowRadius?: number;
|
|
210
|
+
/** Opacity of the flame zone, 0 to 1. Default 1. */
|
|
211
|
+
opacity?: number;
|
|
212
|
+
/** Puffing and light flicker as a multiple of the physical (Cetegen and Ahmed 1993), 0 to 3; 0 holds the flames steady. Default 1. */
|
|
213
|
+
flicker?: number;
|
|
214
|
+
/** Size of the flame tongues as a multiple of the default (0.22 of the flame length across), 0.25 to 4. Default 1. */
|
|
215
|
+
tongues?: number;
|
|
216
|
+
/**
|
|
217
|
+
* A crown fire: the spacing of the burning trees, metres, 0 to 1,000. Each tree torches as its own tapering column
|
|
218
|
+
* (Van Wagner 1977; Alexander and Cruz 2011 put crown flames at one to two and a half times the stand height): its
|
|
219
|
+
* base reaches down into its crown by up to 0.3 flame lengths, its top runs from 0.6 to 1.4 flame lengths, so the
|
|
220
|
+
* fire's foot and crest are ragged as in a torching stand. 0 is a surface fire (one zone over the footprint). Default 0.
|
|
221
|
+
*/
|
|
222
|
+
crowns?: number;
|
|
223
|
+
/**
|
|
224
|
+
* Where the flame's light goes: a `LightGroups` (the flame takes a group of its own, `flame`, `flame 2`, ...) or a
|
|
225
|
+
* `Clustered` (the flame then owns its whole list), attached to the same scene; it lights the meshes added to that
|
|
226
|
+
* `Clustered` (`clustered.add(mesh)`) and smoke whose `lit.lights` is it. Point lights over the footprint at a
|
|
227
|
+
* third of the flame's height, as bright as its silhouette at its peak radiance ({@link FLAME_LIGHT_FILL}), flickering with the puffing
|
|
228
|
+
* of the tongues above each. Read at attach. Default: no light.
|
|
229
|
+
*/
|
|
230
|
+
lights?: Clustered | LightGroups;
|
|
231
|
+
/** Scales the light, 0 or more. Default 1. */
|
|
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;
|
|
256
|
+
/** Fog over the flames (`Fog` of `@margoengine/environment` or any `FogLike`). Default none. */
|
|
257
|
+
fog?: FogLike | null;
|
|
258
|
+
/**
|
|
259
|
+
* The scene depth (`DepthTexture` of `@margoengine/post/depth`): the march stops at surfaces inside the volume (a house
|
|
260
|
+
* in its own flames, logs, the ground), and the camera may stand inside the flames. Read at attach. Default: the box is
|
|
261
|
+
* depth-tested against the scene, which draws nothing from inside it.
|
|
262
|
+
*/
|
|
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;
|
|
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;
|
|
298
|
+
/**
|
|
299
|
+
* A flame of any size, from a campfire to a house fire or a burning forest crown: one ray-marched volume over its
|
|
300
|
+
* footprint, sized by a flame length, an intensity (Byram 1959) or a heat release (Heskestad 1983). Tall tapering
|
|
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
|
|
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
|
|
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`
|
|
305
|
+
* the flame lights the ground, smoke and anything near with point lights that flicker with its puffing. Every option
|
|
306
|
+
* is read each frame and written into one uniform, so a fire that grows, moves, leans or changes its look makes no GPU
|
|
307
|
+
* object after its first frame; a length of 0 puts the flames out. `applyFlameSettings` takes it as a target (the flame
|
|
308
|
+
* rows). WebGPU and the WebGL2 compatibility layer.
|
|
309
|
+
* @throws TypeError for a missing position or size; RangeError for an option out of range.
|
|
310
|
+
* A plugin of the scene it is attached to: disposing that scene disposes the flame.
|
|
311
|
+
*/
|
|
312
|
+
export declare class Flame implements EnginePlugin {
|
|
313
|
+
readonly name: string;
|
|
314
|
+
private readonly seed;
|
|
315
|
+
/** Read every frame; see {@link FlameOptions}. */
|
|
316
|
+
readonly options: FlameOptions;
|
|
317
|
+
/** The light's points (empty without `lights`; one with `castShadow`), their intensities as of the last frame. */
|
|
318
|
+
readonly lights: readonly PointLight[];
|
|
319
|
+
private engine?;
|
|
320
|
+
private disposed;
|
|
321
|
+
private clock;
|
|
322
|
+
private current;
|
|
323
|
+
private look;
|
|
324
|
+
private readonly key;
|
|
325
|
+
private readonly values;
|
|
326
|
+
private readonly view;
|
|
327
|
+
private readonly heat;
|
|
328
|
+
private readonly fogData;
|
|
329
|
+
private readonly target?;
|
|
330
|
+
private readonly group?;
|
|
331
|
+
private readonly steady;
|
|
332
|
+
/** The scene depth's samples as of this view's colour pass. */
|
|
333
|
+
private samples;
|
|
334
|
+
private uniform?;
|
|
335
|
+
private fogBuffer?;
|
|
336
|
+
private owned;
|
|
337
|
+
private softRuntime?;
|
|
338
|
+
private readonly groups;
|
|
339
|
+
private readonly attachment;
|
|
340
|
+
private readonly depthAttachment;
|
|
341
|
+
private readonly reactiveAttachments;
|
|
342
|
+
private constructor();
|
|
343
|
+
/** The flame length now, metres: `length`, else Byram's of `intensity`, else Heskestad's of `heat`. */
|
|
344
|
+
private length;
|
|
345
|
+
private check;
|
|
346
|
+
/** The look values now: the flame rows where `setFlameLook` set them, else the options. */
|
|
347
|
+
private lookOf;
|
|
348
|
+
/** Rewrites the temperature table when a number it depends on changed (no allocation otherwise). */
|
|
349
|
+
private write;
|
|
350
|
+
/**
|
|
351
|
+
* Writes the flame rows that `applyFlameSettings` resolved (`flames.core`, `edge`, `peak`, `flicker`, `tongues`,
|
|
352
|
+
* `size`, `radiance`, `opacity`, `ramp`, `edgeColor`); the flame keeps them while its length, footprint or wind change.
|
|
353
|
+
* The ember rows do nothing here (a `Flame` has no embers).
|
|
354
|
+
*/
|
|
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;
|
|
368
|
+
/**
|
|
369
|
+
* The hot plume over the flame as of its last frame, for `HeatHaze` of `@margoengine/post/heat-haze` (the shimmer of
|
|
370
|
+
* the scene behind the fire): the base, the length now, the footprint as drawn (`flames.size` included), the yaw, the
|
|
371
|
+
* lean in the wind (world metres across per metre up) and the flame's clock, so a seeked flame shimmers as a played
|
|
372
|
+
* one. One object, rewritten on each read.
|
|
373
|
+
*/
|
|
374
|
+
get plume(): FlamePlume;
|
|
375
|
+
/** The length now, metres (0 when out). */
|
|
376
|
+
get flameLength(): number;
|
|
377
|
+
/** Seconds on the flame's clock: the sum of its frame deltas. */
|
|
378
|
+
get time(): number;
|
|
379
|
+
/** The puffing frequency now, Hz: {@link puffingFrequency} of the footprint's {@link puffingDiameter}. */
|
|
380
|
+
get puffing(): number;
|
|
381
|
+
setup(engine: Engine): void;
|
|
382
|
+
registerPasses(graph: FrameGraph): void;
|
|
383
|
+
/** The wind's lean of the flames, `[dx, dz]` per metre of height, at their rise speed `rise`. */
|
|
384
|
+
private lean;
|
|
385
|
+
/**
|
|
386
|
+
* Moves the flame's clock by `delta` seconds (0 or less moves nothing): the CPU part of its frame update, which a
|
|
387
|
+
* seek from `@margoengine/cutscene/seek` replays. Everything a frame then draws (the puffing, the flicker of the light,
|
|
388
|
+
* the dither shift, the wind it samples) is worked from this clock, so a flame seeked to T draws what a continuous run
|
|
389
|
+
* draws at T (GAP-FILM-TIME).
|
|
390
|
+
*/
|
|
391
|
+
advanceTime(delta: number): void;
|
|
392
|
+
/**
|
|
393
|
+
* Back to time 0, as a fresh flame with the same options (GAP-FILM-RESET): the puffing, the light's flicker and the
|
|
394
|
+
* dither start again, so the same frames after it draw what a fresh flame draws.
|
|
395
|
+
*/
|
|
396
|
+
resetTime(): void;
|
|
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;
|
|
403
|
+
/**
|
|
404
|
+
* The ground plane and the glow: the slope in the footprint's axes, the glow sources' intensity (the light's total, as
|
|
405
|
+
* {@link FLAME_LIGHT_FILL}, over as many sources as its points), the haze and the glow box around the flame box.
|
|
406
|
+
*/
|
|
407
|
+
private glow;
|
|
408
|
+
/** Places the light's points over the footprint and sets each one's flicker from the puffing of the tongues above it. */
|
|
409
|
+
private light;
|
|
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;
|
|
413
|
+
/** Sets the flame length, metres (see {@link FlameOptions.length}); the volume answers from the next frame. */
|
|
414
|
+
setLength(length: number): this;
|
|
415
|
+
/** Sets the wind at the flames (see {@link FlameOptions.wind}); undefined removes it. */
|
|
416
|
+
setWind(wind: VFXWind | undefined): this;
|
|
417
|
+
/** The light's points at their steady intensities (the mean the flicker swings about), as of the last frame. */
|
|
418
|
+
get steadyIntensities(): readonly number[];
|
|
419
|
+
/** Flames at `options.position`; see {@link FlameOptions}. */
|
|
420
|
+
static attach(engine: EngineKernel, options: FlameOptions): Flame;
|
|
421
|
+
private release;
|
|
422
|
+
onDeviceRestored(engine: Engine): void;
|
|
423
|
+
/** Removes the flames and their light (a group the flame made goes with it). */
|
|
424
|
+
dispose(): void;
|
|
425
|
+
[Symbol.dispose](): void;
|
|
426
|
+
}
|
|
427
|
+
/** The embers of a hearth kit scaled to a fire of flame length `length` over `footprint` (for `Fire.attach({flameLength})`). */
|
|
428
|
+
export declare function scaleHearthEmbers<T extends Record<string, unknown>>(embers: T, length: number, footprint: readonly [number, number]): T;
|