@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
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
+
import type { EngineKernel } from '@margoengine/core';
|
|
3
|
+
import { type Engine, type EnginePlugin } from '@margoengine/core/extension';
|
|
4
|
+
import type { Clustered, PointLight } from '@margoengine/clustered';
|
|
5
|
+
import type { LightGroups } from '@margoengine/clustered/groups';
|
|
6
|
+
import { VFX, type VFXWind } from '@margoengine/vfx/base';
|
|
7
|
+
import { Clouds, type CloudsOptions } from '@margoengine/vfx/clouds';
|
|
8
|
+
import { Flame } from '@margoengine/vfx/flame';
|
|
9
|
+
import { Smoke } from '@margoengine/vfx/smoke';
|
|
10
|
+
type Vec3 = readonly [number, number, number];
|
|
11
|
+
type V3 = [number, number, number];
|
|
12
|
+
/** Service black powder (Noble and Abel 1875): what a kilogram burns to. */
|
|
13
|
+
export declare const BLACK_POWDER: Readonly<{
|
|
14
|
+
/** Mass fractions of the mix: saltpetre, charcoal, sulphur. */
|
|
15
|
+
saltpetre: 0.75;
|
|
16
|
+
charcoal: 0.15;
|
|
17
|
+
sulphur: 0.1;
|
|
18
|
+
/** Share of the mass that leaves as permanent gas (CO2, CO, N2, H2S, H2, CH4). */
|
|
19
|
+
gasFraction: 0.4298;
|
|
20
|
+
/** Share left as solids: K2CO3, K2SO4, K2S. In the air they are the white smoke. */
|
|
21
|
+
solidFraction: 0.5591;
|
|
22
|
+
/** Share left as water vapour. */
|
|
23
|
+
waterFraction: 0.0111;
|
|
24
|
+
/** Permanent gas, cubic metres a kilogram at 0 C and 1 atm (271.3 cm^3/g). */
|
|
25
|
+
gasVolume: 0.2713;
|
|
26
|
+
/** Heat of explosion, joules a kilogram (718.1 cal/g). */
|
|
27
|
+
heat: number;
|
|
28
|
+
/** Explosion temperature, kelvin (about 2,200 C). */
|
|
29
|
+
flameTemperature: 2473;
|
|
30
|
+
}>;
|
|
31
|
+
/** What a charge of black powder burns to, from {@link powderProducts}. */
|
|
32
|
+
export interface PowderProducts {
|
|
33
|
+
/** Permanent gas, kg. */
|
|
34
|
+
gas: number;
|
|
35
|
+
/** Solids, kg: the smoke. */
|
|
36
|
+
smoke: number;
|
|
37
|
+
/** Water vapour, kg. */
|
|
38
|
+
water: number;
|
|
39
|
+
/** Permanent gas at 0 C and 1 atm, m^3. */
|
|
40
|
+
gasVolume: number;
|
|
41
|
+
/** Heat of explosion, joules. */
|
|
42
|
+
heat: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The products of `charge` kilograms of service black powder (Noble and Abel 1875): gas, smoke solids, water, the gas
|
|
46
|
+
* volume at 0 C and the heat. A 32-pounder's 4.5 kg (10 lb) charge leaves 2.5 kg of smoke.
|
|
47
|
+
*/
|
|
48
|
+
export declare function powderProducts(charge: number): PowderProducts;
|
|
49
|
+
/** A gun's muzzle flash, from {@link muzzleFlash}. */
|
|
50
|
+
export interface MuzzleFlash {
|
|
51
|
+
/** Radius of the fireball, metres. */
|
|
52
|
+
radius: number;
|
|
53
|
+
/** Time constant of its fade, seconds. */
|
|
54
|
+
duration: number;
|
|
55
|
+
/** Its colour: the blackbody of the explosion temperature (linear RGB, brightest channel 1). */
|
|
56
|
+
color: [number, number, number];
|
|
57
|
+
}
|
|
58
|
+
/** Default fade of a large gun's secondary flash, seconds (tens of milliseconds, Klingenberg and Heimerl 1992). */
|
|
59
|
+
export declare const FLASH_DURATION = 0.04;
|
|
60
|
+
/** Alpha of a flash billboard: its radiance rides in the intensity divided by this, so it adds light (the flash is
|
|
61
|
+
* glowing gas, not a surface) and a dimmed particle covers only this share of the scene behind it. */
|
|
62
|
+
export declare const FLASH_ALPHA = 0.05;
|
|
63
|
+
/**
|
|
64
|
+
* The flash of `charge` kg of powder: a ball of the charge's gas at its explosion temperature and 1 atm (its permanent
|
|
65
|
+
* gas and water at 0 C times T / 273.15), so a 4.5 kg charge flashes about 1.4 m across in radius; it fades with a time
|
|
66
|
+
* constant of `duration` (default {@link FLASH_DURATION}) in the blackbody colour of 2,473 K.
|
|
67
|
+
*/
|
|
68
|
+
export declare function muzzleFlash(charge: number, duration?: number): MuzzleFlash;
|
|
69
|
+
/**
|
|
70
|
+
* The share of a flash's peak brightness a frame records: the flash e^(-t / duration) averaged over the shutter, open
|
|
71
|
+
* for `shutter` seconds up to the frame `age` seconds after the shot. A flash shorter than a frame is still on the frame
|
|
72
|
+
* that holds it, and the frames of a 360 degree shutter add up to the same light at any frame rate (duration times the
|
|
73
|
+
* peak), as a film camera records it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function flashExposure(age: number, shutter: number, duration?: number): number;
|
|
76
|
+
/** The settings of a {@link powderPuff}. */
|
|
77
|
+
export interface PuffSettings {
|
|
78
|
+
/** Powder charge, kg. */
|
|
79
|
+
charge: number;
|
|
80
|
+
/** Muzzle velocity of the shot, m/s. */
|
|
81
|
+
muzzleVelocity: number;
|
|
82
|
+
/** The barrel's elevation above the horizontal, radians. Default 0. */
|
|
83
|
+
elevation?: number;
|
|
84
|
+
/**
|
|
85
|
+
* The gas's momentum as a multiple of charge x muzzle velocity: the powder gas leaves behind the shot faster than it
|
|
86
|
+
* (the recoil "after-effect", 1.5 for black powder in the gunnery manuals that follow Corner's Theory of the Interior
|
|
87
|
+
* Ballistics of Guns, 1950). Default 1.5.
|
|
88
|
+
*/
|
|
89
|
+
momentum?: number;
|
|
90
|
+
/** Share of the heat of explosion still in the gas as it leaves the muzzle, 0 to 1. Default 0.4. */
|
|
91
|
+
heatFraction?: number;
|
|
92
|
+
/** Radius over distance travelled through the air (Richards 1965, Scorer 1957: about 0.25). Default 0.25. */
|
|
93
|
+
entrainment?: number;
|
|
94
|
+
/** Air stability N^2 = (g / T) dtheta/dz, 1/s^2, 0 or more. Default 0. */
|
|
95
|
+
stability?: number;
|
|
96
|
+
/** Air temperature, kelvin. Default 288.15. */
|
|
97
|
+
airTemperature?: number;
|
|
98
|
+
/** Seconds the table covers. Default 600. */
|
|
99
|
+
duration?: number;
|
|
100
|
+
}
|
|
101
|
+
/** The bank `t` seconds after the shot, relative to the air, from {@link PowderPuff.at}. */
|
|
102
|
+
export interface PuffPoint {
|
|
103
|
+
/** Distance travelled along the barrel's bearing, metres (horizontal). */
|
|
104
|
+
along: number;
|
|
105
|
+
/** Height gained, metres. */
|
|
106
|
+
rise: number;
|
|
107
|
+
/** Radius of the puff, metres. */
|
|
108
|
+
radius: number;
|
|
109
|
+
/** Speed relative to the air, m/s. */
|
|
110
|
+
speed: number;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* A powder-smoke puff as the integral model of an isolated turbulent puff and thermal (Richards 1965; Scorer 1957; MTT
|
|
114
|
+
* 1956): its volume V = 4/3 pi (alpha s)^3 grows with the distance s it has moved through the air, its momentum (per
|
|
115
|
+
* unit air density) keeps the gas's momentum along the barrel and gains its buoyancy B upward, and in stable air its
|
|
116
|
+
* buoyancy falls at N^2 V w. So the bank shoots out of the gun, stops within tens of metres, rises slowly as a warm
|
|
117
|
+
* thermal, levels off in stable air and hangs; the wind carries it as a whole (add the wind's drift). Integrated once
|
|
118
|
+
* with fourth-order Runge-Kutta in time steps that grow from 1 ms, tabulated, so `at(t)` is the same at any frame rate.
|
|
119
|
+
*/
|
|
120
|
+
export declare class PowderPuff {
|
|
121
|
+
/** Puff radius at the muzzle, metres: the flash's ball of gas. */
|
|
122
|
+
readonly startRadius: number;
|
|
123
|
+
/** Momentum at the muzzle per unit air density, m^4/s. */
|
|
124
|
+
readonly momentum: number;
|
|
125
|
+
/** Buoyancy at the muzzle, g' V, m^4/s^2. */
|
|
126
|
+
readonly buoyancy: number;
|
|
127
|
+
/** Seconds the table covers. */
|
|
128
|
+
readonly duration: number;
|
|
129
|
+
private readonly times;
|
|
130
|
+
private readonly table;
|
|
131
|
+
constructor(settings: PuffSettings);
|
|
132
|
+
/** The puff `seconds` after the shot, relative to the air (clamped to the table). */
|
|
133
|
+
at(seconds: number, out?: PuffPoint): PuffPoint;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Richardson's relative dispersion of a cloud `seconds` after it stopped moving of itself, metres (sigma, one axis):
|
|
137
|
+
* sigma^2 = g_R eps t^3 (Batchelor 1952; g_R 0.5, Salazar and Collins 2009), with the sea surface layer's dissipation
|
|
138
|
+
* eps = u*^3 / (0.4 z), u* = sqrt(1.2e-3) U (Large and Pond 1981), at height `height` (default 10 m) in a wind of `wind`
|
|
139
|
+
* m/s. 0 in calm air (the bank then thins by its own growth only).
|
|
140
|
+
*/
|
|
141
|
+
export declare function smokeDispersion(seconds: number, wind: number, height?: number, constant?: number): number;
|
|
142
|
+
/** A sphere's drag coefficient at Mach `mach` (Hoerner 1965 ch. 16): 0.47 subsonic, rising through Mach 0.6 to 1.2, 0.95 to 0.92 beyond. */
|
|
143
|
+
export declare function sphereDrag(mach: number): number;
|
|
144
|
+
/** A round shot: iron by default. */
|
|
145
|
+
export interface RoundShot {
|
|
146
|
+
/** Mass, kg. Default 14.5 (a 32-pounder). */
|
|
147
|
+
mass?: number;
|
|
148
|
+
/** Density, kg/m^3. Default 7,200 (cast iron). */
|
|
149
|
+
density?: number;
|
|
150
|
+
}
|
|
151
|
+
/** Where a shot meets the water, from {@link shotFlight}. */
|
|
152
|
+
export interface ShotImpact {
|
|
153
|
+
/** Film time of the impact, seconds (fire time plus the flight). */
|
|
154
|
+
time: number;
|
|
155
|
+
/** Where it meets the water, world units. */
|
|
156
|
+
position: V3;
|
|
157
|
+
/** Velocity there, m/s. */
|
|
158
|
+
velocity: V3;
|
|
159
|
+
/** Shot radius, metres. */
|
|
160
|
+
radius: number;
|
|
161
|
+
/** Shot density, kg/m^3. */
|
|
162
|
+
density: number;
|
|
163
|
+
}
|
|
164
|
+
/** Anything that gives the water's height at world XZ (a `WaveQuery` of `@margoengine/water/query`). */
|
|
165
|
+
export interface WaterLevel {
|
|
166
|
+
sample(x: number, z: number): {
|
|
167
|
+
height: number;
|
|
168
|
+
} | undefined;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Oak as a ball meets it (Didion 1860, the Metz firings; the `OAK` of `@margoengine/physics/ballistics`): its
|
|
172
|
+
* resistance at rest `strength`, Pa, and the v^2 term `inertia`, kg/m^3. `density` is the timber's own, kg/m^3 (Wood
|
|
173
|
+
* Handbook 2010, table 5-3a).
|
|
174
|
+
*/
|
|
175
|
+
export declare const OAK: Readonly<{
|
|
176
|
+
density: 680;
|
|
177
|
+
strength: number;
|
|
178
|
+
inertia: number;
|
|
179
|
+
}>;
|
|
180
|
+
/** The wood a shot meets. Default {@link OAK}. */
|
|
181
|
+
export interface Wood {
|
|
182
|
+
/** The timber's density, kg/m^3, 100 to 2000. Read only when `inertia` is not given: the v^2 term is then half of it. */
|
|
183
|
+
density?: number;
|
|
184
|
+
/** Resistance at rest, Pa, 1e5 to 1e9. Default oak's 20.45 MPa. */
|
|
185
|
+
strength?: number;
|
|
186
|
+
/** The resistance's v^2 term, kg/m^3, 50 to 1000. Default oak's 409, or half of a `density` you pass. */
|
|
187
|
+
inertia?: number;
|
|
188
|
+
}
|
|
189
|
+
/** A medium as `@margoengine/physics/ballistics` takes it. */
|
|
190
|
+
export interface StrikeMedium {
|
|
191
|
+
name: string;
|
|
192
|
+
strength: number;
|
|
193
|
+
inertia: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The terminal ballistics a strike reads: `import * as ballistics from '@margoengine/physics/ballistics'` is one.
|
|
197
|
+
* With it a strike's depth, exit speed and glance come from that entry (the glance from the timber's own pressure on
|
|
198
|
+
* the ball); without it the depth and exit speed are the same law in closed form and the glance is Margo's rule.
|
|
199
|
+
*/
|
|
200
|
+
export interface StrikeLaw {
|
|
201
|
+
penetration(target: StrikeMedium, shot: {
|
|
202
|
+
mass: number;
|
|
203
|
+
diameter: number;
|
|
204
|
+
}, speed: number): {
|
|
205
|
+
depth: number;
|
|
206
|
+
};
|
|
207
|
+
residualSpeed(target: StrikeMedium, shot: {
|
|
208
|
+
mass: number;
|
|
209
|
+
diameter: number;
|
|
210
|
+
}, speed: number, thickness: number): number;
|
|
211
|
+
ricochet(surface: StrikeMedium, shot: {
|
|
212
|
+
mass: number;
|
|
213
|
+
diameter: number;
|
|
214
|
+
}, speed: number, angle: number, gravity?: number): {
|
|
215
|
+
kind: 'ricochet' | 'buried';
|
|
216
|
+
speed: number;
|
|
217
|
+
angle: number;
|
|
218
|
+
depth: number;
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* How deep a ball of `radius` m and `mass` kg striking wood at `speed` m/s (the part of its velocity into the
|
|
223
|
+
* surface) goes, metres, by Poncelet's law: (m / (2 B A)) ln(1 + B v^2 / R), R the wood's `strength` and B its
|
|
224
|
+
* `inertia`. It is `penetration` of `@margoengine/physics/ballistics` in closed form.
|
|
225
|
+
*/
|
|
226
|
+
export declare function woodPenetration(speed: number, radius: number, mass: number, wood?: Wood): number;
|
|
227
|
+
/** The speed a ball keeps after going through `thickness` m of wood it struck at `speed` (Poncelet's law), 0 if it stops in it. */
|
|
228
|
+
export declare function woodExitSpeed(speed: number, radius: number, mass: number, thickness: number, wood?: Wood): number;
|
|
229
|
+
/** A ship a shot can hit: its hull as an elliptic cylinder in its frame (+X port, +Y up, +Z forward). */
|
|
230
|
+
export interface ShotTarget {
|
|
231
|
+
/** The ship (a `Floater`, its `matrix()` read at the shot) or a fixed world matrix (16 numbers). */
|
|
232
|
+
ship: Carrier | ArrayLike<number>;
|
|
233
|
+
/** Length and beam at the waterline, metres. Default 50 by 13. */
|
|
234
|
+
length?: number;
|
|
235
|
+
beam?: number;
|
|
236
|
+
/** Top of the side above the hull origin (the waterline), and the keel below it, metres. Default 6 and 5. */
|
|
237
|
+
height?: number;
|
|
238
|
+
draft?: number;
|
|
239
|
+
/** The side's timber, metres. Default 0.5 (a ship of the line's side at the gun decks). */
|
|
240
|
+
thickness?: number;
|
|
241
|
+
/** The timber. Default {@link OAK}. */
|
|
242
|
+
wood?: Wood;
|
|
243
|
+
/** A hull mask (see {@link hullMaskImage}) the holes are drawn into, its blue channel. Default none. */
|
|
244
|
+
mask?: HullMask;
|
|
245
|
+
}
|
|
246
|
+
/** A shot's strike on a ship, from {@link shotPath} and `Battery.hits()`. */
|
|
247
|
+
export interface HullHit {
|
|
248
|
+
/** Index into the targets. */
|
|
249
|
+
target: number;
|
|
250
|
+
/** `ricochet`: it glanced off; `through`: it holed the side and went in; `exit`: it left through the far side; `lodged`: it stopped in the timber. */
|
|
251
|
+
kind: 'ricochet' | 'through' | 'exit' | 'lodged';
|
|
252
|
+
/** Film time, seconds. */
|
|
253
|
+
time: number;
|
|
254
|
+
/** World point of the strike, and the hull-local one. */
|
|
255
|
+
position: V3;
|
|
256
|
+
local: V3;
|
|
257
|
+
/** World normal of the side, out of the hull. */
|
|
258
|
+
normal: V3;
|
|
259
|
+
/** The shot's velocity before and after, m/s. */
|
|
260
|
+
velocity: V3;
|
|
261
|
+
after: V3;
|
|
262
|
+
/** How deep the strike would go into the timber, metres (Poncelet). */
|
|
263
|
+
depth: number;
|
|
264
|
+
/** Radius of the hole (0 for a ricochet's gouge), metres. */
|
|
265
|
+
hole: number;
|
|
266
|
+
/** Splinters it throws (before the battery's `splinters` multiple). */
|
|
267
|
+
splinters: number;
|
|
268
|
+
}
|
|
269
|
+
/** What {@link shotPath} returns: the strikes on ships, in order, and where the shot meets the water, if it does. */
|
|
270
|
+
export interface ShotPath {
|
|
271
|
+
hits: HullHit[];
|
|
272
|
+
impact?: ShotImpact;
|
|
273
|
+
}
|
|
274
|
+
/** The flight of {@link shotPath}: the water, the wind, ships and the drag. */
|
|
275
|
+
export interface ShotPathOptions {
|
|
276
|
+
/** Film time of the shot. Default 0. */
|
|
277
|
+
fireTime?: number;
|
|
278
|
+
/** Sea level when there is no `water`. Default 0. */
|
|
279
|
+
seaLevel?: number;
|
|
280
|
+
/** The water's height. Default the plane `seaLevel`. */
|
|
281
|
+
water?: WaterLevel;
|
|
282
|
+
/** The wind, `[x, z]` m/s or a field `{sample(x, y, z, t)}`: the drag acts on the velocity relative to it. Default calm. */
|
|
283
|
+
wind?: VFXWind;
|
|
284
|
+
/** Ships the shot can strike. Default none. */
|
|
285
|
+
targets?: readonly ShotTarget[];
|
|
286
|
+
/** Seconds of flight at most. Default 30. */
|
|
287
|
+
maxTime?: number;
|
|
288
|
+
/** Air drag on (Hoerner's sphere). Default true. */
|
|
289
|
+
drag?: boolean;
|
|
290
|
+
/** The terminal ballistics strikes read, `@margoengine/physics/ballistics` (see {@link StrikeLaw}). Default the closed form and Margo's glance. */
|
|
291
|
+
ballistics?: StrikeLaw;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Flies a round shot from `from` along `direction` at `speed` m/s under gravity and the sphere drag of
|
|
295
|
+
* {@link sphereDrag} on its velocity relative to the `wind` (fourth-order Runge-Kutta, 2 ms steps), through any
|
|
296
|
+
* `targets`: at a ship's side it glances off (with `ballistics`, when the timber's pressure on the ball turns it back
|
|
297
|
+
* out, at the speed and angle that leaves it; without, when Poncelet's law cannot sink it a radius in), holes it and
|
|
298
|
+
* goes on at Poncelet's exit speed when the side is thinner than its reach, and else lodges; inside, it meets the far
|
|
299
|
+
* side the same way. It ends at the water (`water`, or the plane `seaLevel`), lodged, or after `maxTime` seconds.
|
|
300
|
+
* The ships are where their `matrix()` puts them at the shot.
|
|
301
|
+
*/
|
|
302
|
+
export declare function shotPath(from: Vec3, direction: Vec3, speed: number, shot?: RoundShot, options?: ShotPathOptions): ShotPath;
|
|
303
|
+
/**
|
|
304
|
+
* Flies a round shot from `from` along `direction` at `speed` m/s under gravity and the sphere drag of
|
|
305
|
+
* {@link sphereDrag} on its velocity relative to the wind until it meets the water: {@link shotPath}'s impact.
|
|
306
|
+
* Returns the impact, or undefined for a shot still in the air or stopped in a ship.
|
|
307
|
+
*/
|
|
308
|
+
export declare function shotFlight(from: Vec3, direction: Vec3, speed: number, shot?: RoundShot, options?: ShotPathOptions): ShotImpact | undefined;
|
|
309
|
+
/** Black powder's linear burning rate in the open, m/s: of the order of 1 cm/s at one atmosphere (Conkling and Mocella 2019). */
|
|
310
|
+
export declare const POWDER_BURN_RATE = 0.01;
|
|
311
|
+
/** Density of a pressed powder grain, kg/m^3 (1.7 to 1.8 g/cm^3, Conkling and Mocella 2019). */
|
|
312
|
+
export declare const GRAIN_DENSITY = 1750;
|
|
313
|
+
/** Share of a charge that leaves the muzzle as burning grains (Margo's: a few percent of a black-powder charge burns outside the bore). */
|
|
314
|
+
export declare const UNBURNT_FRACTION = 0.02;
|
|
315
|
+
/** The burning grains a shot throws, from {@link powderGrains}. */
|
|
316
|
+
export interface PowderGrains {
|
|
317
|
+
/** Grains, before the battery's `sparks` multiple. */
|
|
318
|
+
count: number;
|
|
319
|
+
/** Seconds a grain burns: d / (2 r). */
|
|
320
|
+
burnTime: number;
|
|
321
|
+
/** Stopping length of a grain's quadratic drag, metres: (4/3) d rho_grain / (rho_air 0.47). */
|
|
322
|
+
stopping: number;
|
|
323
|
+
/** How far one goes before it burns out, metres (the drag of {@link sphereDrag} on its way). */
|
|
324
|
+
reach: number;
|
|
325
|
+
/** Its speed 0, 1/31 ... 1 of the way through its burn, over its start speed: 32 samples (a `VFX` overLife speed curve). */
|
|
326
|
+
speeds: number[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The burning grains of `charge` kg of powder of grains `grain` metres across leaving the muzzle at `speed` m/s
|
|
330
|
+
* (default the shot's 490): {@link UNBURNT_FRACTION} of the charge in grains of {@link GRAIN_DENSITY} that burn at
|
|
331
|
+
* {@link POWDER_BURN_RATE} and slow under the sphere drag of {@link sphereDrag} (RK4, 1 ms steps).
|
|
332
|
+
*/
|
|
333
|
+
export declare function powderGrains(charge: number, grain?: number, speed?: number): PowderGrains;
|
|
334
|
+
/**
|
|
335
|
+
* The colour (linear single-scattering albedo, grey) of a smoke whose particulate is `soot` (0..1) soot by mass and the
|
|
336
|
+
* rest white matter (powder salts, tar mist, steam): soot extinguishes 8.7 m^2/g at albedo 0.25 (Mulholland and Croarkin
|
|
337
|
+
* 2000), white particulate about 3 m^2/g at 0.97. So 0 is white powder smoke, 0.1 already a mid grey, 0.5 nearly black.
|
|
338
|
+
*/
|
|
339
|
+
export declare function smokeColor(soot: number): [number, number, number];
|
|
340
|
+
/** Anything that carries guns or a fire: a `Floater` of `@margoengine/water/ships` (`matrix()` is its world transform). */
|
|
341
|
+
export interface Carrier {
|
|
342
|
+
matrix(out?: Float32Array | number[]): ArrayLike<number>;
|
|
343
|
+
}
|
|
344
|
+
/** One gun of a {@link Battery}. */
|
|
345
|
+
export interface Gun {
|
|
346
|
+
/** The muzzle, world units, or ship-local (+X port, +Y up, +Z forward) when the battery has a `ship`. */
|
|
347
|
+
position: Vec3;
|
|
348
|
+
/** Where the barrel points (world, or ship-local with a `ship`), not zero. */
|
|
349
|
+
direction: Vec3;
|
|
350
|
+
/** Powder charge, kg. Default 4.5 (a 32-pounder's 10 lb). */
|
|
351
|
+
charge?: number;
|
|
352
|
+
/** Muzzle velocity, m/s. Default 490. */
|
|
353
|
+
muzzleVelocity?: number;
|
|
354
|
+
/** The shot. Default a 14.5 kg iron ball. */
|
|
355
|
+
shot?: RoundShot;
|
|
356
|
+
}
|
|
357
|
+
/** When a gun fires. */
|
|
358
|
+
export interface GunShot {
|
|
359
|
+
/** Index into `guns`. */
|
|
360
|
+
gun: number;
|
|
361
|
+
/** Film time, seconds. */
|
|
362
|
+
time: number;
|
|
363
|
+
}
|
|
364
|
+
/** `Battery.attach` settings. Numbers are read every frame unless marked. */
|
|
365
|
+
export interface BatteryOptions {
|
|
366
|
+
/** The guns. Read at attach (their count). Up to 128. */
|
|
367
|
+
guns: readonly Gun[];
|
|
368
|
+
/** When they fire, any order (sorted at attach). More can be added with `fire`. Default none. */
|
|
369
|
+
shots?: readonly GunShot[];
|
|
370
|
+
/** The ship the guns stand on: their positions and directions are in its frame, read at each shot. Default none (world). */
|
|
371
|
+
ship?: Carrier;
|
|
372
|
+
/** The wind, `[x, z]` m/s or `{sample(x, y, z, t)}`. Default none: a `WeatherDrive` writes the weather's wind. */
|
|
373
|
+
wind?: VFXWind;
|
|
374
|
+
/** Where the water is, for the shots' fall: a water height source or a plane. Default the plane y = 0. */
|
|
375
|
+
water?: WaterLevel;
|
|
376
|
+
/** Sea level for the shots when there is no `water`. Default 0. */
|
|
377
|
+
seaLevel?: number;
|
|
378
|
+
/** Air stability N^2, 1/s^2, 0 or more: the banks level off. Read at a shot. Default 1e-4 (a slightly stable marine layer). */
|
|
379
|
+
stability?: number;
|
|
380
|
+
/** Share of the heat of explosion in the gas at the muzzle, 0..1. Read at a shot. Default 0.4. */
|
|
381
|
+
heatFraction?: number;
|
|
382
|
+
/** Puff radius over distance travelled through the air, 0.05..1. Read at a shot. Default 0.25. */
|
|
383
|
+
entrainment?: number;
|
|
384
|
+
/** Flash fade, seconds. Default {@link FLASH_DURATION}. */
|
|
385
|
+
flashDuration?: number;
|
|
386
|
+
/** Flash size as a multiple of the fireball radius. Default 1. */
|
|
387
|
+
flashSize?: number;
|
|
388
|
+
/** Peak radiance of the flash billboards (their HDR intensity). Default 40. */
|
|
389
|
+
flashRadiance?: number;
|
|
390
|
+
/** The light's intensity as a multiple of the flash's own (a sphere of the flash radius at its radiance). Default 1. */
|
|
391
|
+
flashLight?: number;
|
|
392
|
+
/** Shutter open time as a share of the frame (0.5 is a 180 degree shutter), 0..1. Default 0.5. */
|
|
393
|
+
shutter?: number;
|
|
394
|
+
/** Smoke mass extinction, m^2/g (white hygroscopic salt smoke). Default 3. */
|
|
395
|
+
extinction?: number;
|
|
396
|
+
/** Smoke colour, linear RGB. Default `smokeColor(0)`. */
|
|
397
|
+
smokeColor?: Vec3;
|
|
398
|
+
/** Richardson's constant g_R of the air's spreading of a bank, 0..5. Default 0.5. */
|
|
399
|
+
dispersion?: number;
|
|
400
|
+
/** Seconds a bank lives at most. Default 600. */
|
|
401
|
+
smokeLife?: number;
|
|
402
|
+
/** Most banks at once (the oldest is reused). Read at attach. Default 48, at most 512. */
|
|
403
|
+
banks?: number;
|
|
404
|
+
/** Puffs a bank is drawn with. Read at attach. Default 24. */
|
|
405
|
+
puffs?: number;
|
|
406
|
+
/** Lights on the scene: each gun's flash lights it through a group of its own. Read at attach. Default none. */
|
|
407
|
+
lights?: Clustered | LightGroups;
|
|
408
|
+
/** Settings of the banks' `Clouds` (light direction, colour, ambient, texture, depth...). Read every frame. */
|
|
409
|
+
clouds?: Omit<CloudsOptions, 'limit' | 'density'>;
|
|
410
|
+
/** Burning powder grains thrown out with the flash, a multiple of {@link powderGrains}' count, 0..10. Default 1. */
|
|
411
|
+
sparks?: number;
|
|
412
|
+
/** Radiance of a burning grain (its HDR intensity), 0..3,000. Default 30. */
|
|
413
|
+
sparkRadiance?: number;
|
|
414
|
+
/** Drawn width of a burning grain's streak, metres, 0.01..2: its flame and the film's halation round it, far wider than the grain (Margo's). Default 0.3. */
|
|
415
|
+
sparkSize?: number;
|
|
416
|
+
/** Grain size of the powder, metres, 0.0005..0.02. Read at a shot. Default 0.003 (cannon powder). */
|
|
417
|
+
grain?: number;
|
|
418
|
+
/** Ships the shots can strike (their poses read at each shot; not the battery's own ship). Read at a shot. Default none. */
|
|
419
|
+
targets?: readonly ShotTarget[];
|
|
420
|
+
/** The terminal ballistics strikes read, `@margoengine/physics/ballistics` (see {@link StrikeLaw}). Read at a shot. Default the closed form and Margo's glance. */
|
|
421
|
+
ballistics?: StrikeLaw;
|
|
422
|
+
/** Splinters a strike throws, a multiple of the hole's timber in hand-sized pieces, 0..10. Default 1. */
|
|
423
|
+
splinters?: number;
|
|
424
|
+
}
|
|
425
|
+
/** One fired shot, as the battery tracks it. */
|
|
426
|
+
export interface FiredShot {
|
|
427
|
+
gun: number;
|
|
428
|
+
time: number;
|
|
429
|
+
/** World muzzle and barrel direction at the shot. */
|
|
430
|
+
muzzle: V3;
|
|
431
|
+
direction: V3;
|
|
432
|
+
/** The bank's wind drift at the shot, metres (the drift since is the bank's). */
|
|
433
|
+
drift: [number, number];
|
|
434
|
+
/** Where it meets the water, if it does within 30 s. */
|
|
435
|
+
impact?: ShotImpact;
|
|
436
|
+
/** Its strikes on the `targets`, in time order. */
|
|
437
|
+
hits: HullHit[];
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* A battery of muzzle-loading guns: each shot flashes (fireball billboards whose brightness is the flash averaged over
|
|
441
|
+
* the camera's shutter, and a point light of the same radiance), throws out a bank of white powder smoke that grows,
|
|
442
|
+
* stops, rises as a warm thermal, levels off and drifts with the wind, thinning by Richardson's law and the optical
|
|
443
|
+
* depth of its 56% of solids, and flies its round shot to the water (`impacts`, for `ShotSplash` of
|
|
444
|
+
* `@margoengine/water/splash`). Everything is a function of the battery's clock, so a film seek lands it.
|
|
445
|
+
* A plugin of its scene: disposing the scene disposes it.
|
|
446
|
+
*/
|
|
447
|
+
export declare class Battery implements EnginePlugin {
|
|
448
|
+
readonly name: string;
|
|
449
|
+
/** Read every frame (see {@link BatteryOptions}). */
|
|
450
|
+
readonly options: BatteryOptions;
|
|
451
|
+
/** The banks of smoke (`clouds.puffs()` lists them). */
|
|
452
|
+
readonly clouds: Clouds;
|
|
453
|
+
/** Each gun's fireball billboards. */
|
|
454
|
+
readonly flashes: VFX[];
|
|
455
|
+
/** Each gun's light (in the battery's light group), when `lights` was given. */
|
|
456
|
+
readonly lights: PointLight[];
|
|
457
|
+
/** The shots fired so far, in time order. */
|
|
458
|
+
readonly fired: FiredShot[];
|
|
459
|
+
/** Each gun's burning powder grains. */
|
|
460
|
+
readonly sparks: VFX[];
|
|
461
|
+
/** The splinters of strikes on ships. */
|
|
462
|
+
readonly splinters: VFX;
|
|
463
|
+
private readonly pendingHits;
|
|
464
|
+
private hitCursor;
|
|
465
|
+
private engine?;
|
|
466
|
+
private disposed;
|
|
467
|
+
private clock;
|
|
468
|
+
private cursor;
|
|
469
|
+
private readonly queue;
|
|
470
|
+
private readonly banks;
|
|
471
|
+
private readonly drift;
|
|
472
|
+
private readonly group?;
|
|
473
|
+
private readonly target?;
|
|
474
|
+
private readonly puffs;
|
|
475
|
+
private readonly point;
|
|
476
|
+
private lastDelta;
|
|
477
|
+
private constructor();
|
|
478
|
+
private checkGun;
|
|
479
|
+
private checkShot;
|
|
480
|
+
private checkLive;
|
|
481
|
+
/**
|
|
482
|
+
* Back to time 0, as a fresh battery with the same options (GAP-FILM-RESET): the `shots` of the options queued again
|
|
483
|
+
* (ones added with `fire` or `broadside` are dropped), no shot fired, every bank, flash, spark, splinter and light
|
|
484
|
+
* idle, and the holes it drew into the targets' masks (their blue channel) cleared, so the same frames after it draw
|
|
485
|
+
* what a fresh battery draws.
|
|
486
|
+
*/
|
|
487
|
+
resetTime(): void;
|
|
488
|
+
/** Queues gun `gun` to fire at film time `time` (default now). */
|
|
489
|
+
fire(gun: number, time?: number): this;
|
|
490
|
+
/** A broadside: every gun (or the listed ones) fires from `time`, one every `interval` seconds in order. */
|
|
491
|
+
broadside(time: number, interval?: number, guns?: readonly number[]): this;
|
|
492
|
+
/** The puff law of a gun for the battery's air now. */
|
|
493
|
+
puffOf(gun: number): PowderPuff;
|
|
494
|
+
private worldDirection;
|
|
495
|
+
/** The wind the banks drift in now: the battery's own, else the one the weather wrote on its flashes. */
|
|
496
|
+
wind(): [number, number];
|
|
497
|
+
/** Every shot's impact on the water so far, in time order (a `ShotSplash` takes them). */
|
|
498
|
+
impacts(): ShotImpact[];
|
|
499
|
+
/** Seconds on the battery's clock. */
|
|
500
|
+
get time(): number;
|
|
501
|
+
setup(engine: Engine): void;
|
|
502
|
+
onPreUpdate(delta: number): void;
|
|
503
|
+
/**
|
|
504
|
+
* Moves the clock by `delta` seconds and fires every shot due by then (CPU only: a seek replays it): the wind drift
|
|
505
|
+
* adds up here, each due gun's bank is placed and its shot flown, and every flash, light and bank is set for the new
|
|
506
|
+
* time.
|
|
507
|
+
*/
|
|
508
|
+
advanceTime(delta: number): void;
|
|
509
|
+
/** Every strike on the `targets` so far, in time order (the ones whose time has come). */
|
|
510
|
+
hits(): HullHit[];
|
|
511
|
+
private strike;
|
|
512
|
+
/** Sets every flash, light and bank for the clock now. */
|
|
513
|
+
private place;
|
|
514
|
+
/** A battery of guns; see {@link BatteryOptions}. */
|
|
515
|
+
static attach(engine: EngineKernel, options: BatteryOptions): Battery;
|
|
516
|
+
/** Removes the flashes, banks and lights. */
|
|
517
|
+
dispose(): void;
|
|
518
|
+
[Symbol.dispose](): void;
|
|
519
|
+
}
|
|
520
|
+
/** Wood burnt through a ventilation-limited opening, kg/s: 0.09 A sqrt(H) (Kawagoe 1958; Drysdale 2011 ch. 10). */
|
|
521
|
+
export declare function ventBurningRate(area: number, height: number): number;
|
|
522
|
+
/** The flame's height above an opening's top, metres: 12.8 (R / w)^(2/3) - H (Law 1978), 0 when that is negative. */
|
|
523
|
+
export declare function ventFlameHeight(rate: number, width: number, height: number): number;
|
|
524
|
+
/** Heat of combustion of the wood and tar of a hull, J/kg (dry wood about 16 MJ/kg effective; Drysdale 2011 table 1.13). */
|
|
525
|
+
export declare const HULL_FUEL_HEAT = 16000000;
|
|
526
|
+
/** A gun port or other opening into a burning hull, in the hull's frame (+X port, +Y up, +Z forward). */
|
|
527
|
+
export interface HullPort {
|
|
528
|
+
/** Centre of the opening on the hull side, hull-local metres. */
|
|
529
|
+
position: Vec3;
|
|
530
|
+
/** Width and height of the opening, metres. Default 0.8 by 0.7 (a lower-deck gun port). */
|
|
531
|
+
size?: readonly [number, number];
|
|
532
|
+
/** Outward normal, hull-local (default from `position`'s side: +X or -X). */
|
|
533
|
+
normal?: Vec3;
|
|
534
|
+
}
|
|
535
|
+
/** `HullFire.attach` settings. Numbers are read every frame unless marked. */
|
|
536
|
+
export interface HullFireOptions {
|
|
537
|
+
/** The burning ship (a `Floater` of `@margoengine/water/ships`) or a fixed world matrix (16 numbers). */
|
|
538
|
+
ship: Carrier | ArrayLike<number>;
|
|
539
|
+
/** The hull: length, beam, the deck's height above the hull origin and the keel's depth below it, metres. Default 50 by 13, deck 6, draft 5. */
|
|
540
|
+
hull?: {
|
|
541
|
+
length?: number;
|
|
542
|
+
beam?: number;
|
|
543
|
+
deck?: number;
|
|
544
|
+
draft?: number;
|
|
545
|
+
};
|
|
546
|
+
/** Char rate of the hull's timber while fire is over it, mm/min, 0..5. Default 0.5 (hardwood, EN 1995-1-2 table 3.1). */
|
|
547
|
+
charRate?: number;
|
|
548
|
+
/** A hull mask (see {@link hullMaskImage}) the char (red) and the live glow (green) are painted into each frame. Default none. */
|
|
549
|
+
mask?: HullMask;
|
|
550
|
+
/** Masts that fall when the fire has burnt their stays. Read at attach (their count). Default none. */
|
|
551
|
+
masts?: readonly HullMast[];
|
|
552
|
+
/** Seconds after the fire reaches a mast that it falls (its stays and shrouds of tarred hemp gone; Margo's). Default 600. */
|
|
553
|
+
mastFall?: number;
|
|
554
|
+
/** Where the fire starts, hull-local metres, and when (film seconds). Default the waist, at time 0. */
|
|
555
|
+
ignition?: {
|
|
556
|
+
at?: Vec3;
|
|
557
|
+
time?: number;
|
|
558
|
+
};
|
|
559
|
+
/** Spread of the fire along the hull, m/s. Default 0.03 (a ship of the line fully alight within half an hour). */
|
|
560
|
+
spread?: number;
|
|
561
|
+
/** Seconds a stretch of hull burns at full before it dies down to embers. Default 2,400. */
|
|
562
|
+
burnTime?: number;
|
|
563
|
+
/** Heat release of the burning deck, W/m^2. Default 250,000 (planks, tar and rigging; Babrauskas' 100 to 300 kW/m^2 for structural wood). */
|
|
564
|
+
deckHeat?: number;
|
|
565
|
+
/** The openings that flame (gun ports). Default none. */
|
|
566
|
+
ports?: readonly HullPort[];
|
|
567
|
+
/** Soot share of the smoke's particulate, 0..1: wood and tar. Default 0.35. */
|
|
568
|
+
soot?: number;
|
|
569
|
+
/** The wind, `[x, z]` m/s or a field. Default none: a `WeatherDrive` writes it (through the smoke). */
|
|
570
|
+
wind?: VFXWind;
|
|
571
|
+
/** Flame volumes over the deck and the ports. Read at attach. Default 10. */
|
|
572
|
+
flames?: number;
|
|
573
|
+
/** Smoke columns along the hull. Read at attach. Default 2. */
|
|
574
|
+
columns?: number;
|
|
575
|
+
/** Lights the flames light the scene with. Read at attach. Default none. */
|
|
576
|
+
lights?: Clustered | LightGroups;
|
|
577
|
+
/** Smoke puff opacity, 0..1. Default 0.7. */
|
|
578
|
+
opacity?: number;
|
|
579
|
+
}
|
|
580
|
+
/** A flame the hull shows now, from {@link HullFire.flames}. */
|
|
581
|
+
export interface HullFlame {
|
|
582
|
+
kind: 'deck' | 'port';
|
|
583
|
+
/** World position of the flame's base. */
|
|
584
|
+
position: V3;
|
|
585
|
+
/** Flame length, metres. */
|
|
586
|
+
length: number;
|
|
587
|
+
/** Footprint [along, across], metres. */
|
|
588
|
+
footprint: [number, number];
|
|
589
|
+
/** Heat release, watts. */
|
|
590
|
+
heat: number;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* A hull mask: an RGBA8 image over the hull's sides (red the char, green the glow of the fire on it now, blue the shot
|
|
594
|
+
* holes) and the texture drawn from it, re-uploaded when it changes. A materials `Texture` made from
|
|
595
|
+
* {@link hullMaskImage} fits: `new Texture(hullMaskImage(), {colorSpace: 'linear'})`. Its layout is
|
|
596
|
+
* {@link hullMaskUVs}': the left half of the image the starboard side (-X), the right half the port side (+X), stern
|
|
597
|
+
* to bow across each half, keel (row 0) to deck (the top row).
|
|
598
|
+
*/
|
|
599
|
+
export interface HullMask {
|
|
600
|
+
readonly source: {
|
|
601
|
+
data: Uint8Array | Uint8ClampedArray;
|
|
602
|
+
width: number;
|
|
603
|
+
height: number;
|
|
604
|
+
} | object;
|
|
605
|
+
update(): void;
|
|
606
|
+
}
|
|
607
|
+
/** A blank hull mask image, `width` by `height` texels (RGBA8, alpha 255), for a `Texture`. Default 256 by 64. */
|
|
608
|
+
export declare function hullMaskImage(width?: number, height?: number): {
|
|
609
|
+
data: Uint8Array;
|
|
610
|
+
width: number;
|
|
611
|
+
height: number;
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* The UV set a hull mesh reads its {@link HullMask} with, from its hull-local vertex positions (x, y, z per vertex;
|
|
615
|
+
* +X port, +Y up, +Z forward) and the hull's size (as `HullFire`'s `hull`): u = 0.5 (z / L + 0.5) on the starboard side
|
|
616
|
+
* and 0.5 more on the port side, v = (y + draft) / (deck + draft). Give it to the mesh as its second UV set and the
|
|
617
|
+
* mask to a `layered()` layer with `texCoord: 1`.
|
|
618
|
+
*/
|
|
619
|
+
export declare function hullMaskUVs(positions: ArrayLike<number>, hull?: {
|
|
620
|
+
length?: number;
|
|
621
|
+
deck?: number;
|
|
622
|
+
draft?: number;
|
|
623
|
+
}): Float32Array;
|
|
624
|
+
/** A mast on a burning hull, hull-local. */
|
|
625
|
+
export interface HullMast {
|
|
626
|
+
/** Its foot on the deck, hull-local metres. */
|
|
627
|
+
position: Vec3;
|
|
628
|
+
/** Its height above the foot, metres, 1..120. */
|
|
629
|
+
height: number;
|
|
630
|
+
/** Its yards: height up the mast and length, metres. Default none. */
|
|
631
|
+
yards?: readonly {
|
|
632
|
+
at: number;
|
|
633
|
+
length: number;
|
|
634
|
+
}[];
|
|
635
|
+
/** Which way it falls, hull-local and horizontal. Default [1, 0, 0] (to port). */
|
|
636
|
+
falls?: Vec3;
|
|
637
|
+
/** Film time it starts to fall. Default the fire's reach to it plus `mastFall`. */
|
|
638
|
+
fallAt?: number;
|
|
639
|
+
}
|
|
640
|
+
/** A piece of falling rigging, from {@link HullFire.rigging}: a mast (its +Y from the foot) or a yard (its +X along it, centred). */
|
|
641
|
+
export interface RiggingPiece {
|
|
642
|
+
kind: 'mast' | 'yard';
|
|
643
|
+
/** Index into `masts`. */
|
|
644
|
+
mast: number;
|
|
645
|
+
/** World transform of the piece (column-major), for the scene's mast or yard mesh. */
|
|
646
|
+
matrix: Float32Array;
|
|
647
|
+
/** Length, metres. */
|
|
648
|
+
length: number;
|
|
649
|
+
/** Radians the mast has turned from upright. */
|
|
650
|
+
angle: number;
|
|
651
|
+
}
|
|
652
|
+
/** A toppling mast, from {@link mastTopple}. */
|
|
653
|
+
export interface MastTopple {
|
|
654
|
+
/** Radians from upright. */
|
|
655
|
+
angle: number;
|
|
656
|
+
/** Radians a second. */
|
|
657
|
+
rate: number;
|
|
658
|
+
/** True once its top is in the water (it then lies there). */
|
|
659
|
+
down: boolean;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* A uniform mast `height` metres tall toppling on its foot `deck` metres above the water (Varieschi and Kamiya 2003):
|
|
663
|
+
* theta'' = (3 g / 2 L) sin theta from a lean of 0.02 rad, `seconds` after it starts to go (RK4, 1 ms steps), until its
|
|
664
|
+
* top meets the water at cos theta = -deck / L.
|
|
665
|
+
*/
|
|
666
|
+
export declare function mastTopple(height: number, seconds: number, deck?: number): MastTopple;
|
|
667
|
+
/**
|
|
668
|
+
* A burning wooden hull: the fire spreads from its ignition along the deck at `spread` m/s; each stretch burns for
|
|
669
|
+
* `burnTime` and dies down. The open deck releases `deckHeat` per square metre, drawn as `Flame` volumes as tall as
|
|
670
|
+
* Heskestad's flame of that heat; each gun port in a burning stretch is the opening of a ventilation-limited
|
|
671
|
+
* compartment (Kawagoe's 0.09 A sqrt(H) kg/s of wood) and throws a flame Law's 12.8 (R / w)^(2/3) - H above its top; the
|
|
672
|
+
* whole fire feeds `Smoke` columns (0.7 of its heat convected) dark with soot. Every piece rides the ship's
|
|
673
|
+
* `matrix()` each frame, so the fire moves and rolls with a `Floater`. A plugin of its scene.
|
|
674
|
+
*/
|
|
675
|
+
export declare class HullFire implements EnginePlugin {
|
|
676
|
+
readonly name: string;
|
|
677
|
+
/** Read every frame (see {@link HullFireOptions}). */
|
|
678
|
+
readonly options: HullFireOptions;
|
|
679
|
+
/** The flame volumes (a fixed pool). */
|
|
680
|
+
readonly flameVolumes: Flame[];
|
|
681
|
+
/** The smoke columns. */
|
|
682
|
+
readonly smokeColumns: Smoke[];
|
|
683
|
+
private engine?;
|
|
684
|
+
private disposed;
|
|
685
|
+
private clock;
|
|
686
|
+
private constructor();
|
|
687
|
+
private checkLive;
|
|
688
|
+
private matrix;
|
|
689
|
+
private toWorld;
|
|
690
|
+
/** How much of hull section `i` (0 at the stern) burns now, 0..1 (0 before the fire reaches it and after it dies). */
|
|
691
|
+
private burning;
|
|
692
|
+
/** Seconds the fire reaches hull-local z after its ignition (Infinity where it never does). */
|
|
693
|
+
private reach;
|
|
694
|
+
/**
|
|
695
|
+
* Seconds of full burning hull-local z has had by now: the time integral of the growth, full burn and dying down of
|
|
696
|
+
* {@link burning}, in closed form (so a seek lands it).
|
|
697
|
+
*/
|
|
698
|
+
exposure(z: number): number;
|
|
699
|
+
/**
|
|
700
|
+
* How deep the hull's side or deck is charred at hull-local `point`, mm: the char rate (EN 1995-1-2) times the
|
|
701
|
+
* exposure of the flames over it. The deck burns where its section does and chars the side to 1.5 m below the deck
|
|
702
|
+
* edge; a flaming port chars the side over its opening up to Law's flame height, widening as the plume does
|
|
703
|
+
* (MTT 1956's 0.12 per metre).
|
|
704
|
+
*/
|
|
705
|
+
charDepth(point: Vec3): number;
|
|
706
|
+
/** Paints the char and the glow into the mask: every texel's char from {@link charDepth}, and how hard the fire over it burns now. */
|
|
707
|
+
private paint;
|
|
708
|
+
/** When mast `i` starts to fall, film seconds (Infinity if the fire never reaches it). */
|
|
709
|
+
mastFallTime(i: number): number;
|
|
710
|
+
/**
|
|
711
|
+
* The masts and their yards now, as pieces with world transforms: upright until they fall, then toppling on their feet
|
|
712
|
+
* by {@link mastTopple} the way `falls` points until their tops are in the water, where they lie. A function of the
|
|
713
|
+
* clock and the ship's pose, so a seek lands it.
|
|
714
|
+
*/
|
|
715
|
+
rigging(): RiggingPiece[];
|
|
716
|
+
/** Heat release now, watts: the deck plus every flaming port. */
|
|
717
|
+
get heat(): number;
|
|
718
|
+
/** The flames the hull shows now: one a burning deck section (merged into the pool's count) and one per flaming port. */
|
|
719
|
+
flames(): HullFlame[];
|
|
720
|
+
/** Seconds on the fire's clock. */
|
|
721
|
+
get time(): number;
|
|
722
|
+
setup(engine: Engine): void;
|
|
723
|
+
onPreUpdate(delta: number): void;
|
|
724
|
+
/**
|
|
725
|
+
* Back to time 0, as a fresh fire with the same options (GAP-FILM-RESET): its flames and smoke columns go back to their
|
|
726
|
+
* own start and are placed for time 0, and the mask's char and glow are painted for time 0 (none), so the same frames
|
|
727
|
+
* after it draw what a fresh fire draws.
|
|
728
|
+
*/
|
|
729
|
+
resetTime(): void;
|
|
730
|
+
/** Moves the fire's clock by `delta` seconds and sets its flames and smoke for that time and the ship's pose (CPU only). */
|
|
731
|
+
advanceTime(delta: number): void;
|
|
732
|
+
/** The wind at the fire: its own, else the one the weather wrote on its smoke. */
|
|
733
|
+
private windNow;
|
|
734
|
+
private place;
|
|
735
|
+
private localZ;
|
|
736
|
+
/** A burning hull; see {@link HullFireOptions}. */
|
|
737
|
+
static attach(engine: EngineKernel, options: HullFireOptions): HullFire;
|
|
738
|
+
/** Removes the flames and smoke. */
|
|
739
|
+
dispose(): void;
|
|
740
|
+
[Symbol.dispose](): void;
|
|
741
|
+
}
|
|
742
|
+
export {};
|