@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/gunfire.d.ts
CHANGED
|
@@ -167,20 +167,61 @@ export interface WaterLevel {
|
|
|
167
167
|
height: number;
|
|
168
168
|
} | undefined;
|
|
169
169
|
}
|
|
170
|
-
/**
|
|
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
|
+
*/
|
|
171
175
|
export declare const OAK: Readonly<{
|
|
172
176
|
density: 680;
|
|
173
|
-
strength:
|
|
177
|
+
strength: number;
|
|
178
|
+
inertia: number;
|
|
174
179
|
}>;
|
|
175
|
-
/** The wood a shot meets
|
|
180
|
+
/** The wood a shot meets. Default {@link OAK}. */
|
|
176
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. */
|
|
177
183
|
density?: number;
|
|
184
|
+
/** Resistance at rest, Pa, 1e5 to 1e9. Default oak's 20.45 MPa. */
|
|
178
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
|
+
};
|
|
179
220
|
}
|
|
180
221
|
/**
|
|
181
222
|
* How deep a ball of `radius` m and `mass` kg striking wood at `speed` m/s (the part of its velocity into the
|
|
182
|
-
* surface) goes, metres, by Poncelet's law: (m / (2 B A)) ln(1 + B v^2 / R),
|
|
183
|
-
*
|
|
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.
|
|
184
225
|
*/
|
|
185
226
|
export declare function woodPenetration(speed: number, radius: number, mass: number, wood?: Wood): number;
|
|
186
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. */
|
|
@@ -246,11 +287,14 @@ export interface ShotPathOptions {
|
|
|
246
287
|
maxTime?: number;
|
|
247
288
|
/** Air drag on (Hoerner's sphere). Default true. */
|
|
248
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;
|
|
249
292
|
}
|
|
250
293
|
/**
|
|
251
294
|
* Flies a round shot from `from` along `direction` at `speed` m/s under gravity and the sphere drag of
|
|
252
295
|
* {@link sphereDrag} on its velocity relative to the `wind` (fourth-order Runge-Kutta, 2 ms steps), through any
|
|
253
|
-
* `targets`: at a ship's side it glances off when
|
|
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
|
|
254
298
|
* goes on at Poncelet's exit speed when the side is thinner than its reach, and else lodges; inside, it meets the far
|
|
255
299
|
* side the same way. It ends at the water (`water`, or the plane `seaLevel`), lodged, or after `maxTime` seconds.
|
|
256
300
|
* The ships are where their `matrix()` puts them at the shot.
|
|
@@ -373,6 +417,8 @@ export interface BatteryOptions {
|
|
|
373
417
|
grain?: number;
|
|
374
418
|
/** Ships the shots can strike (their poses read at each shot; not the battery's own ship). Read at a shot. Default none. */
|
|
375
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;
|
|
376
422
|
/** Splinters a strike throws, a multiple of the hole's timber in hand-sized pieces, 0..10. Default 1. */
|
|
377
423
|
splinters?: number;
|
|
378
424
|
}
|
package/dist/gunfire.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 t=(engine,version="
|
|
3
|
+
const t=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
|
|
4
4
|
import { r as e } from "./flame-ramp-VoBKpYnM.js";
|
|
5
5
|
import { engineRuntime as __margoRuntime } from "@margoengine/core/extension";
|
|
6
6
|
import { finiteVector as n } from "@margoengine/math/validate";
|
|
@@ -131,17 +131,19 @@ function T(e) {
|
|
|
131
131
|
}
|
|
132
132
|
var E = (e, t) => Math.cbrt(3 * e / (4 * Math.PI * t)), D = Object.freeze({
|
|
133
133
|
density: 680,
|
|
134
|
-
strength:
|
|
134
|
+
strength: 20451765,
|
|
135
|
+
inertia: 409.0353
|
|
135
136
|
}), O = (e = {}) => ({
|
|
136
|
-
|
|
137
|
-
strength: g(e.strength ?? D.strength, "wood strength", 1e5, 1e9)
|
|
137
|
+
name: "timber",
|
|
138
|
+
strength: g(e.strength ?? D.strength, "wood strength", 1e5, 1e9),
|
|
139
|
+
inertia: g(e.inertia ?? (e.density === void 0 ? D.inertia : .5 * g(e.density, "wood density", 100, 2e3)), "wood inertia", 50, 1e3)
|
|
138
140
|
});
|
|
139
141
|
function k(e, t, n, r) {
|
|
140
|
-
let i = O(r), a = g(e, "strike speed", 0, 3e3), o = Math.PI * g(t, "shot radius", 1e-4, 10) ** 2, s = g(n, "shot mass", 0, 2e3, !0), c =
|
|
142
|
+
let i = O(r), a = g(e, "strike speed", 0, 3e3), o = Math.PI * g(t, "shot radius", 1e-4, 10) ** 2, s = g(n, "shot mass", 0, 2e3, !0), c = i.inertia;
|
|
141
143
|
return s / (2 * c * o) * Math.log(1 + c * a * a / i.strength);
|
|
142
144
|
}
|
|
143
145
|
function A(e, t, n, r, i) {
|
|
144
|
-
let a = O(i), o = g(e, "strike speed", 0, 3e3), s = Math.PI * g(t, "shot radius", 1e-4, 10) ** 2, c = g(n, "shot mass", 0, 2e3, !0), l = g(r, "thickness", 0, 100), u = a.strength /
|
|
146
|
+
let a = O(i), o = g(e, "strike speed", 0, 3e3), s = Math.PI * g(t, "shot radius", 1e-4, 10) ** 2, c = g(n, "shot mass", 0, 2e3, !0), l = g(r, "thickness", 0, 100), u = a.strength / a.inertia, d = (u + o * o) * Math.exp(-2 * a.inertia * s * l / c) - u;
|
|
145
147
|
return d > 0 ? Math.sqrt(d) : 0;
|
|
146
148
|
}
|
|
147
149
|
var j = .8, M = .3, N = 6e-5, P = (e) => typeof e.matrix == "function" ? e.matrix() : e, F = (e, t) => {
|
|
@@ -181,7 +183,7 @@ var j = .8, M = .3, N = 6e-5, P = (e) => typeof e.matrix == "function" ? e.matri
|
|
|
181
183
|
t[0] / (e.a * e.a),
|
|
182
184
|
0,
|
|
183
185
|
t[2] / (e.b * e.b)
|
|
184
|
-
], r =
|
|
186
|
+
], r = q(e.m, n), i = Math.hypot(r[0], r[1], r[2]) || 1;
|
|
185
187
|
return [
|
|
186
188
|
r[0] / i,
|
|
187
189
|
r[1] / i,
|
|
@@ -192,15 +194,18 @@ function R(e, t, r, i = {}, a = {}) {
|
|
|
192
194
|
n(e, 3, "Gunfire shot position"), n(t, 3, "Gunfire shot direction"), g(r, "shot speed", 0, 3e3);
|
|
193
195
|
let o = g(i.mass ?? 14.5, "shot mass", 0, 2e3, !0), s = g(i.density ?? 7200, "shot density", 500, 25e3), c = E(o, s), l = Math.PI * c * c, u = Math.hypot(t[0], t[1], t[2]);
|
|
194
196
|
if (!(u > 0)) throw RangeError("Gunfire shot direction must not be zero");
|
|
195
|
-
let f = a.seaLevel ?? 0, p = g(a.maxTime ?? 30, "maxTime", 0, 600), h = a.drag ?? !0, _ = a.fireTime ?? 0, v = a.wind, y = (a.targets ?? []).map(I), b = y.map((t) => L(t, F(t.m, e))), x = [], S =
|
|
197
|
+
let f = a.seaLevel ?? 0, p = g(a.maxTime ?? 30, "maxTime", 0, 600), h = a.drag ?? !0, _ = a.fireTime ?? 0, v = a.wind, y = (a.targets ?? []).map(I), b = y.map((t) => L(t, F(t.m, e))), x = [], S = a.ballistics, C = {
|
|
198
|
+
mass: o,
|
|
199
|
+
diameter: 2 * c
|
|
200
|
+
}, w = (e, t) => a.water?.sample(e, t)?.height ?? f, D = [
|
|
196
201
|
e[0],
|
|
197
202
|
e[1],
|
|
198
203
|
e[2],
|
|
199
204
|
t[0] / u * r,
|
|
200
205
|
t[1] / u * r,
|
|
201
206
|
t[2] / u * r
|
|
202
|
-
],
|
|
203
|
-
let [n, r] =
|
|
207
|
+
], O = (e, t) => {
|
|
208
|
+
let [n, r] = J(v, [
|
|
204
209
|
e[0],
|
|
205
210
|
e[1],
|
|
206
211
|
e[2]
|
|
@@ -213,7 +218,7 @@ function R(e, t, r, i = {}, a = {}) {
|
|
|
213
218
|
-9.81 - u * a,
|
|
214
219
|
-u * s
|
|
215
220
|
];
|
|
216
|
-
},
|
|
221
|
+
}, P = .002, R = 0, z = (e, t, n, r) => {
|
|
217
222
|
let i = y[e], a = 0, s = 1;
|
|
218
223
|
for (let e = 0; e < 30; e++) {
|
|
219
224
|
let e = (a + s) / 2, o = [
|
|
@@ -231,10 +236,10 @@ function R(e, t, r, i = {}, a = {}) {
|
|
|
231
236
|
u[3],
|
|
232
237
|
u[4],
|
|
233
238
|
u[5]
|
|
234
|
-
], p = F(i.m, d), m = ee(i, p), h = Math.abs(f[0] * m[0] + f[1] * m[1] + f[2] * m[2]), g =
|
|
239
|
+
], p = F(i.m, d), m = ee(i, p), h = Math.abs(f[0] * m[0] + f[1] * m[1] + f[2] * m[2]), g = Math.min(S ? 1e3 : 3e3, h), v = S ? S.penetration(i.wood, C, g).depth : k(g, c, o, i.wood), w = {
|
|
235
240
|
target: e,
|
|
236
241
|
kind: "lodged",
|
|
237
|
-
time: _ +
|
|
242
|
+
time: _ + R + s * P,
|
|
238
243
|
position: d,
|
|
239
244
|
local: p,
|
|
240
245
|
normal: m,
|
|
@@ -244,61 +249,65 @@ function R(e, t, r, i = {}, a = {}) {
|
|
|
244
249
|
0,
|
|
245
250
|
0
|
|
246
251
|
],
|
|
247
|
-
depth:
|
|
252
|
+
depth: v,
|
|
248
253
|
hole: c * 1.1,
|
|
249
254
|
splinters: 0
|
|
250
255
|
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
x.push(w);
|
|
257
|
+
let T = [
|
|
258
|
+
f[0] + h * m[0],
|
|
259
|
+
f[1] + h * m[1],
|
|
260
|
+
f[2] + h * m[2]
|
|
261
|
+
], E = Math.hypot(T[0], T[1], T[2]), O = Math.hypot(E, h), I = !r && v < c, z = j, B = M * h;
|
|
262
|
+
if (S && !r && h > 0) {
|
|
263
|
+
let e = S.ricochet(i.wood, C, Math.min(1e3, O), Math.asin(Math.min(1, h / O)), 0);
|
|
264
|
+
I = e.kind === "ricochet" && e.depth < i.thickness, I && (z = E > 0 ? e.speed * Math.cos(e.angle) / E : 0, B = e.speed * Math.sin(e.angle), w.depth = e.depth);
|
|
265
|
+
}
|
|
266
|
+
if (I) {
|
|
267
|
+
w.kind = "ricochet", w.hole = 0, w.after = [
|
|
268
|
+
z * T[0] + B * m[0],
|
|
269
|
+
z * T[1] + B * m[1],
|
|
270
|
+
z * T[2] + B * m[2]
|
|
271
|
+
], w.splinters = Math.round(l * w.depth / N);
|
|
272
|
+
for (let e = 0; e < 3; e++) D[e] = d[e] + m[e] * c * .01, D[e + 3] = w.after[e];
|
|
263
273
|
return "on";
|
|
264
274
|
}
|
|
265
|
-
let
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
f[0] *
|
|
271
|
-
f[1] *
|
|
272
|
-
f[2] *
|
|
275
|
+
let V = S ? S.residualSpeed(i.wood, C, g, i.thickness) : A(g, c, o, i.thickness, i.wood);
|
|
276
|
+
if (w.splinters = Math.round(l * Math.min(v, i.thickness) / N), V <= 0) return "lodged";
|
|
277
|
+
w.kind = r ? "exit" : "through";
|
|
278
|
+
let H = V / h;
|
|
279
|
+
w.after = [
|
|
280
|
+
f[0] * H,
|
|
281
|
+
f[1] * H,
|
|
282
|
+
f[2] * H
|
|
273
283
|
];
|
|
274
|
-
let
|
|
275
|
-
for (let e = 0; e < 3; e++) C[e] = d[e] + f[e] / T * (r ? c * .01 : i.thickness + c * .01), C[e + 3] = v.after[e];
|
|
284
|
+
for (let e = 0; e < 3; e++) D[e] = d[e] + f[e] / (O || 1) * (r ? c * .01 : i.thickness + c * .01), D[e + 3] = w.after[e];
|
|
276
285
|
return b[e] = !r, "on";
|
|
277
286
|
};
|
|
278
|
-
for (;
|
|
279
|
-
let e =
|
|
287
|
+
for (; R < p;) {
|
|
288
|
+
let e = O(D, R), t = O(D.map((t, n) => t + .5 * P * e[n]), R + P / 2), n = O(D.map((e, n) => e + .5 * P * t[n]), R + P / 2), r = O(D.map((e, t) => e + P * n[t]), R + P), i = D.map((i, a) => i + P / 6 * (e[a] + 2 * t[a] + 2 * n[a] + r[a])), a = !1;
|
|
280
289
|
for (let e = 0; e < y.length && !a; e++) if (L(y[e], F(y[e].m, [
|
|
281
290
|
i[0],
|
|
282
291
|
i[1],
|
|
283
292
|
i[2]
|
|
284
293
|
])) !== b[e]) {
|
|
285
|
-
if (
|
|
294
|
+
if (z(e, D, i, b[e]) === "lodged") return { hits: x };
|
|
286
295
|
a = !0;
|
|
287
296
|
}
|
|
288
297
|
if (a) {
|
|
289
|
-
|
|
298
|
+
R += P;
|
|
290
299
|
continue;
|
|
291
300
|
}
|
|
292
|
-
let o = b.some(Boolean), l =
|
|
301
|
+
let o = b.some(Boolean), l = D[1] - w(D[0], D[2]), u = i[1] - w(i[0], i[2]);
|
|
293
302
|
if (!o && u <= 0 && l > 0) {
|
|
294
|
-
let e = l / (l - u), t =
|
|
303
|
+
let e = l / (l - u), t = D.map((t, n) => t + (i[n] - t) * e);
|
|
295
304
|
return {
|
|
296
305
|
hits: x,
|
|
297
306
|
impact: {
|
|
298
|
-
time: _ +
|
|
307
|
+
time: _ + R + e * P,
|
|
299
308
|
position: [
|
|
300
309
|
t[0],
|
|
301
|
-
|
|
310
|
+
w(t[0], t[2]),
|
|
302
311
|
t[2]
|
|
303
312
|
],
|
|
304
313
|
velocity: [
|
|
@@ -311,18 +320,18 @@ function R(e, t, r, i = {}, a = {}) {
|
|
|
311
320
|
}
|
|
312
321
|
};
|
|
313
322
|
}
|
|
314
|
-
for (let e = 0; e < 6; e++)
|
|
315
|
-
|
|
323
|
+
for (let e = 0; e < 6; e++) D[e] = i[e];
|
|
324
|
+
R += P;
|
|
316
325
|
}
|
|
317
326
|
return { hits: x };
|
|
318
327
|
}
|
|
319
|
-
function
|
|
328
|
+
function z(e, t, n, r = {}, i = {}) {
|
|
320
329
|
return R(e, t, n, r, i).impact;
|
|
321
330
|
}
|
|
322
|
-
var
|
|
323
|
-
function
|
|
331
|
+
var B = .01, V = 1750, H = .02;
|
|
332
|
+
function U(e, t = .003, n = 490) {
|
|
324
333
|
g(e, "charge", 0, 1e4);
|
|
325
|
-
let r = g(t, "grain", 5e-4, .02), i = g(n, "grain speed", 0, 3e3), a = Math.PI / 6 * r ** 3 *
|
|
334
|
+
let r = g(t, "grain", 5e-4, .02), i = g(n, "grain speed", 0, 3e3), a = Math.PI / 6 * r ** 3 * V, o = r / (2 * B), s = .5 * d * Math.PI * (r / 2) ** 2 / a, c = [1], l = i, u = 0, f = 0, p = (e) => -s * T(e / m) * e * e;
|
|
326
335
|
for (let e = 1; e < 32; e++) {
|
|
327
336
|
let t = o * e / 31;
|
|
328
337
|
for (; f < t - 1e-12;) {
|
|
@@ -332,14 +341,14 @@ function H(e, t = .003, n = 490) {
|
|
|
332
341
|
c.push(i > 0 ? Math.max(0, l / i) : 0);
|
|
333
342
|
}
|
|
334
343
|
return {
|
|
335
|
-
count: e *
|
|
344
|
+
count: e * H / a,
|
|
336
345
|
burnTime: o,
|
|
337
|
-
stopping: 4 / 3 * r *
|
|
346
|
+
stopping: 4 / 3 * r * V / (d * .47),
|
|
338
347
|
reach: u,
|
|
339
348
|
speeds: c
|
|
340
349
|
};
|
|
341
350
|
}
|
|
342
|
-
function
|
|
351
|
+
function W(e) {
|
|
343
352
|
g(e, "soot", 0, 1);
|
|
344
353
|
let t = 8.7 * e, n = 3 * (1 - e), r = (.25 * t + .97 * n) / Math.max(1e-9, t + n);
|
|
345
354
|
return [
|
|
@@ -348,22 +357,22 @@ function U(e) {
|
|
|
348
357
|
r * .96
|
|
349
358
|
];
|
|
350
359
|
}
|
|
351
|
-
var
|
|
360
|
+
var G = 0, K = (e, t) => [
|
|
352
361
|
e[0] * t[0] + e[4] * t[1] + e[8] * t[2] + e[12],
|
|
353
362
|
e[1] * t[0] + e[5] * t[1] + e[9] * t[2] + e[13],
|
|
354
363
|
e[2] * t[0] + e[6] * t[1] + e[10] * t[2] + e[14]
|
|
355
|
-
],
|
|
364
|
+
], q = (e, t) => [
|
|
356
365
|
e[0] * t[0] + e[4] * t[1] + e[8] * t[2],
|
|
357
366
|
e[1] * t[0] + e[5] * t[1] + e[9] * t[2],
|
|
358
367
|
e[2] * t[0] + e[6] * t[1] + e[10] * t[2]
|
|
359
|
-
],
|
|
368
|
+
], J = (e, t, n) => {
|
|
360
369
|
if (!e) return [0, 0];
|
|
361
370
|
if ("sample" in e) {
|
|
362
371
|
let r = e.sample(t[0], t[1], t[2], n);
|
|
363
372
|
return [r[0], r[2]];
|
|
364
373
|
}
|
|
365
374
|
return [e[0], e[1]];
|
|
366
|
-
},
|
|
375
|
+
}, te = [
|
|
367
376
|
1,
|
|
368
377
|
0,
|
|
369
378
|
0,
|
|
@@ -380,9 +389,9 @@ var W = 0, G = (e, t) => [
|
|
|
380
389
|
0,
|
|
381
390
|
0,
|
|
382
391
|
1
|
|
383
|
-
],
|
|
392
|
+
], ne = class e {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
384
393
|
constructor(e, n) {
|
|
385
|
-
if (this.name = "vfx-gunfire:" +
|
|
394
|
+
if (this.name = "vfx-gunfire:" + G++, this.flashes = [], this.lights = [], this.fired = [], this.sparks = [], this.pendingHits = [], this.hitCursor = 0, this.disposed = !1, this.clock = 0, this.cursor = 0, this.banks = [], this.drift = [0, 0], this.puffs = /* @__PURE__ */ new Map(), this.point = {
|
|
386
395
|
along: 0,
|
|
387
396
|
rise: 0,
|
|
388
397
|
radius: 0,
|
|
@@ -587,7 +596,7 @@ var W = 0, G = (e, t) => [
|
|
|
587
596
|
resetTime() {
|
|
588
597
|
if (this.disposed) return;
|
|
589
598
|
this.clock = this.cursor = this.hitCursor = 0, this.lastDelta = 1 / 30, this.drift[0] = this.drift[1] = 0, this.queue.length = 0, this.queue.push(...this.options.shots ?? []), this.queue.sort((e, t) => e.time - t.time || e.gun - t.gun), this.fired.length = 0, this.pendingHits.length = 0, this.puffs.clear(), this.point.along = this.point.rise = this.point.radius = this.point.speed = 0;
|
|
590
|
-
for (let e of this.banks) e.shot = e.puff = null, e.cloud.options.opacity = 0, e.cloud.matrix.set(
|
|
599
|
+
for (let e of this.banks) e.shot = e.puff = null, e.cloud.options.opacity = 0, e.cloud.matrix.set(te);
|
|
591
600
|
this.clouds.resetTime();
|
|
592
601
|
for (let e of [
|
|
593
602
|
...this.flashes,
|
|
@@ -600,7 +609,7 @@ var W = 0, G = (e, t) => [
|
|
|
600
609
|
for (let t of this.options.targets ?? []) {
|
|
601
610
|
if (!t.mask || e.has(t.mask)) continue;
|
|
602
611
|
e.add(t.mask);
|
|
603
|
-
let n =
|
|
612
|
+
let n = $(t.mask).data;
|
|
604
613
|
for (let e = 2; e < n.length; e += 4) n[e] = 0;
|
|
605
614
|
t.mask.update();
|
|
606
615
|
}
|
|
@@ -639,7 +648,7 @@ var W = 0, G = (e, t) => [
|
|
|
639
648
|
}), this.puffs.size > 64 && this.puffs.clear(), this.puffs.set(a, o)), o;
|
|
640
649
|
}
|
|
641
650
|
worldDirection(e) {
|
|
642
|
-
let t = this.options.ship ?
|
|
651
|
+
let t = this.options.ship ? q(this.options.ship.matrix(), e.direction) : [
|
|
643
652
|
e.direction[0],
|
|
644
653
|
e.direction[1],
|
|
645
654
|
e.direction[2]
|
|
@@ -652,7 +661,7 @@ var W = 0, G = (e, t) => [
|
|
|
652
661
|
}
|
|
653
662
|
wind() {
|
|
654
663
|
let e = this.options.wind ?? this.flashes[0]?.options.wind, t = this.options.guns[0].position;
|
|
655
|
-
return
|
|
664
|
+
return J(e, this.options.ship ? K(this.options.ship.matrix(), t) : t, this.clock);
|
|
656
665
|
}
|
|
657
666
|
impacts() {
|
|
658
667
|
return this.fired.flatMap((e) => e.impact ? [e.impact] : []);
|
|
@@ -674,7 +683,7 @@ var W = 0, G = (e, t) => [
|
|
|
674
683
|
this.drift[0] += n[0] * t, this.drift[1] += n[1] * t, this.clock += t, this.checkLive();
|
|
675
684
|
let r = this.options;
|
|
676
685
|
for (; this.cursor < this.queue.length && this.queue[this.cursor].time <= this.clock;) {
|
|
677
|
-
let e = this.queue[this.cursor++], t = r.guns[e.gun], i = r.ship?.matrix(), a = i ?
|
|
686
|
+
let e = this.queue[this.cursor++], t = r.guns[e.gun], i = r.ship?.matrix(), a = i ? K(i, t.position) : [
|
|
678
687
|
t.position[0],
|
|
679
688
|
t.position[1],
|
|
680
689
|
t.position[2]
|
|
@@ -690,7 +699,8 @@ var W = 0, G = (e, t) => [
|
|
|
690
699
|
seaLevel: r.seaLevel ?? 0,
|
|
691
700
|
...r.water ? { water: r.water } : {},
|
|
692
701
|
...l ? { wind: l } : {},
|
|
693
|
-
...r.targets?.length ? { targets: r.targets } : {}
|
|
702
|
+
...r.targets?.length ? { targets: r.targets } : {},
|
|
703
|
+
...r.ballistics ? { ballistics: r.ballistics } : {}
|
|
694
704
|
});
|
|
695
705
|
u.impact && (c.impact = u.impact), c.hits = u.hits;
|
|
696
706
|
for (let e of u.hits) {
|
|
@@ -715,7 +725,7 @@ var W = 0, G = (e, t) => [
|
|
|
715
725
|
o[1] * m * 4,
|
|
716
726
|
o[2] * m * 4
|
|
717
727
|
], p.spread = m * 1.5, p.size = m * 1.6, f.burst(24);
|
|
718
|
-
let h = t.muzzleVelocity ?? 490, g =
|
|
728
|
+
let h = t.muzzleVelocity ?? 490, g = U(t.charge ?? 4.5, r.grain ?? .003, h), _ = this.sparks[e.gun], v = _.options;
|
|
719
729
|
v.position = [
|
|
720
730
|
a[0] + o[0] * m * .5,
|
|
721
731
|
a[1] + o[1] * m * .5,
|
|
@@ -768,7 +778,7 @@ var W = 0, G = (e, t) => [
|
|
|
768
778
|
let a = Math.round(Math.min(2048, e.splinters * (t.splinters ?? 1)));
|
|
769
779
|
a > 0 && this.splinters.burst(a, i);
|
|
770
780
|
let o = t.targets?.[e.target];
|
|
771
|
-
o?.mask && e.hole > 0 &&
|
|
781
|
+
o?.mask && e.hole > 0 && ce(o.mask, e.local, e.hole, o);
|
|
772
782
|
}
|
|
773
783
|
place() {
|
|
774
784
|
let e = this.options, t = this.clock, n = (e.shutter ?? .5) * this.lastDelta, r = e.flashDuration ?? .04, i = e.flashRadiance ?? 40, a = /* @__PURE__ */ new Map();
|
|
@@ -788,7 +798,7 @@ var W = 0, G = (e, t) => [
|
|
|
788
798
|
}
|
|
789
799
|
}
|
|
790
800
|
this.target && this.target.setLights(this.lights);
|
|
791
|
-
let o = (e.extinction ?? 3) * 1e3, s = e.smokeLife ?? 600, c = Math.hypot(...this.wind()), l = e.smokeColor ??
|
|
801
|
+
let o = (e.extinction ?? 3) * 1e3, s = e.smokeLife ?? 600, c = Math.hypot(...this.wind()), l = e.smokeColor ?? W(0), u = this.point, d = 0, f = 0;
|
|
792
802
|
for (let n of this.banks) {
|
|
793
803
|
let r = n.shot, i = n.cloud;
|
|
794
804
|
if (!r || !n.puff) {
|
|
@@ -835,7 +845,7 @@ var W = 0, G = (e, t) => [
|
|
|
835
845
|
let p = e.clouds ?? {};
|
|
836
846
|
for (let e of Object.keys(p)) this.clouds.options[e] = p[e];
|
|
837
847
|
}
|
|
838
|
-
static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("
|
|
848
|
+
static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
839
849
|
if (!n || typeof n != "object") throw TypeError("Invalid Battery options; pass {guns: [{position, direction}]}");
|
|
840
850
|
return new e(t, n);
|
|
841
851
|
}
|
|
@@ -851,18 +861,18 @@ var W = 0, G = (e, t) => [
|
|
|
851
861
|
this.dispose();
|
|
852
862
|
}
|
|
853
863
|
};
|
|
854
|
-
function
|
|
864
|
+
function Y(e, t) {
|
|
855
865
|
return g(e, "vent area", 0, 1e4), g(t, "vent height", 0, 100), .09 * e * Math.sqrt(t);
|
|
856
866
|
}
|
|
857
|
-
function
|
|
867
|
+
function X(e, t, n) {
|
|
858
868
|
return g(e, "burning rate", 0, 1e5), g(t, "vent width", 0, 100, !0), g(n, "vent height", 0, 100), Math.max(0, 12.8 * Math.cbrt((e / t) ** 2) - n);
|
|
859
869
|
}
|
|
860
|
-
var
|
|
870
|
+
var Z = 16e6, Q = 24, re = 1.5, ie = .5, $ = (e) => {
|
|
861
871
|
let t = e?.source;
|
|
862
872
|
if (!t || !(t.data instanceof Uint8Array || t.data instanceof Uint8ClampedArray) || !Number.isInteger(t.width) || !Number.isInteger(t.height) || t.data.length !== t.width * t.height * 4 || typeof e.update != "function") throw TypeError("Gunfire hull mask needs a Texture of raw RGBA8 data: new Texture(hullMaskImage(), {colorSpace: \"linear\"})");
|
|
863
873
|
return t;
|
|
864
874
|
};
|
|
865
|
-
function
|
|
875
|
+
function ae(e = 256, t = 64) {
|
|
866
876
|
if (!Number.isInteger(e) || !Number.isInteger(t) || e < 4 || t < 2 || e > 4096 || t > 4096 || e % 2) throw RangeError("hullMaskImage needs an even whole width 4..4096 and a whole height 2..4096");
|
|
867
877
|
let n = new Uint8Array(e * t * 4);
|
|
868
878
|
for (let e = 3; e < n.length; e += 4) n[e] = 255;
|
|
@@ -872,7 +882,7 @@ function oe(e = 256, t = 64) {
|
|
|
872
882
|
height: t
|
|
873
883
|
};
|
|
874
884
|
}
|
|
875
|
-
function
|
|
885
|
+
function oe(e, t = {}) {
|
|
876
886
|
if (!e || e.length % 3) throw TypeError("hullMaskUVs needs x, y, z for each vertex");
|
|
877
887
|
let n = g(t.length ?? 50, "hull length", 1, 500), r = g(t.deck ?? 6, "hull deck", 0, 50), i = g(t.draft ?? 5, "hull draft", 0, 50), a = new Float32Array(e.length / 3 * 2);
|
|
878
888
|
for (let t = 0, o = 0; t < e.length; t += 3, o += 2) {
|
|
@@ -881,19 +891,19 @@ function se(e, t = {}) {
|
|
|
881
891
|
}
|
|
882
892
|
return a;
|
|
883
893
|
}
|
|
884
|
-
var
|
|
894
|
+
var se = (e, t, n, r, i) => {
|
|
885
895
|
let a = e.width / 2;
|
|
886
896
|
return [Math.min(1, Math.max(0, t[2] / n + .5)) * a + (t[0] >= 0 ? a : 0), (t[1] + i) / (r + i || 1) * e.height];
|
|
887
897
|
};
|
|
888
|
-
function
|
|
889
|
-
let i =
|
|
898
|
+
function ce(e, t, n, r) {
|
|
899
|
+
let i = $(e), a = r.length ?? 50, o = r.height ?? 6, s = r.draft ?? 5, [c, l] = se(i, t, a, o, s), u = i.width / 2 / a, d = i.height / (o + s || 1), f = t[0] >= 0 ? i.width / 2 : 0;
|
|
890
900
|
for (let e = Math.floor(l - n * d - 1); e <= Math.ceil(l + n * d + 1); e++) for (let t = Math.floor(c - n * u - 1); t <= Math.ceil(c + n * u + 1); t++) e < 0 || e >= i.height || t < f || t >= f + i.width / 2 || ((t + .5 - c) / u) ** 2 + ((e + .5 - l) / d) ** 2 > n * n || (i.data[(e * i.width + t) * 4 + 2] = 255);
|
|
891
901
|
let p = Math.min(f + i.width / 2 - 1, Math.max(f, Math.floor(c))), m = Math.min(i.height - 1, Math.max(0, Math.floor(l)));
|
|
892
902
|
i.data[(m * i.width + p) * 4 + 2] = 255, e.update();
|
|
893
903
|
}
|
|
894
|
-
var
|
|
895
|
-
function
|
|
896
|
-
let r = g(e, "mast height", 1, 120), i = g(t, "seconds", 0, 1e7), a = g(n, "deck", 0, 50), o = Math.acos(Math.max(-1, Math.min(1, -a / r))), s = 3 * u / (2 * r), c =
|
|
904
|
+
var le = .02;
|
|
905
|
+
function ue(e, t, n = 6) {
|
|
906
|
+
let r = g(e, "mast height", 1, 120), i = g(t, "seconds", 0, 1e7), a = g(n, "deck", 0, 50), o = Math.acos(Math.max(-1, Math.min(1, -a / r))), s = 3 * u / (2 * r), c = le, l = 0, d = 0;
|
|
897
907
|
for (; d < i;) {
|
|
898
908
|
let e = Math.min(.001, i - d), t = s * Math.sin(c), n = s * Math.sin(c + .5 * e * l), r = s * Math.sin(c + .5 * e * (l + .5 * e * t)), a = s * Math.sin(c + e * (l + .5 * e * n));
|
|
899
909
|
if (c += e * l + e * e / 6 * (t + n + r), l += e / 6 * (t + 2 * n + 2 * r + a), d += e, c >= o) return {
|
|
@@ -908,9 +918,9 @@ function $(e, t, n = 6) {
|
|
|
908
918
|
down: !1
|
|
909
919
|
};
|
|
910
920
|
}
|
|
911
|
-
var de = class e {coreRequirement=__margoCoreRequirement("
|
|
921
|
+
var de = class e {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
|
|
912
922
|
constructor(e, n) {
|
|
913
|
-
this.name = "vfx-hull-fire:" +
|
|
923
|
+
this.name = "vfx-hull-fire:" + G++, this.flameVolumes = [], this.smokeColumns = [], this.disposed = !1, this.clock = 0, this.options = n, this.checkLive();
|
|
914
924
|
let r = g(n.flames ?? 10, "flames", 0, 64), i = g(n.columns ?? 2, "columns", 0, 16);
|
|
915
925
|
if (!Number.isInteger(r) || !Number.isInteger(i)) throw RangeError("HullFire flames and columns must be whole numbers");
|
|
916
926
|
t(e).use(this);
|
|
@@ -923,7 +933,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
923
933
|
position: a,
|
|
924
934
|
heat: 0,
|
|
925
935
|
radius: 3,
|
|
926
|
-
color:
|
|
936
|
+
color: W(n.soot ?? .35),
|
|
927
937
|
opacity: n.opacity ?? .7,
|
|
928
938
|
rate: 18,
|
|
929
939
|
lifetime: 240,
|
|
@@ -944,7 +954,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
944
954
|
if (!e || typeof e != "object" || !e.ship) throw TypeError("HullFire needs {ship}: a Floater or a world matrix");
|
|
945
955
|
if (typeof e.ship.matrix != "function" && e.ship.length !== 16) throw TypeError("HullFire ship must have matrix() (a Floater) or be 16 numbers");
|
|
946
956
|
let t = e.hull ?? {};
|
|
947
|
-
g(t.length ?? 50, "hull length", 1, 500), g(t.beam ?? 13, "hull beam", .5, 100), g(t.deck ?? 6, "hull deck", 0, 50), g(e.spread ?? .03, "spread", 0, 10), g(e.burnTime ?? 2400, "burnTime", 1, 1e6), g(e.deckHeat ?? 25e4, "deckHeat", 0, 5e6), g(e.soot ?? .35, "soot", 0, 1), g(e.opacity ?? .7, "opacity", 0, 1), g(e.ignition?.time ?? 0, "ignition time", 0, 1e7), g(t.draft ?? 5, "hull draft", 0, 50), g(e.charRate ?? .5, "charRate", 0, 5), g(e.mastFall ?? 600, "mastFall", 0, 1e6), e.mask &&
|
|
957
|
+
g(t.length ?? 50, "hull length", 1, 500), g(t.beam ?? 13, "hull beam", .5, 100), g(t.deck ?? 6, "hull deck", 0, 50), g(e.spread ?? .03, "spread", 0, 10), g(e.burnTime ?? 2400, "burnTime", 1, 1e6), g(e.deckHeat ?? 25e4, "deckHeat", 0, 5e6), g(e.soot ?? .35, "soot", 0, 1), g(e.opacity ?? .7, "opacity", 0, 1), g(e.ignition?.time ?? 0, "ignition time", 0, 1e7), g(t.draft ?? 5, "hull draft", 0, 50), g(e.charRate ?? .5, "charRate", 0, 5), g(e.mastFall ?? 600, "mastFall", 0, 1e6), e.mask && $(e.mask);
|
|
948
958
|
for (let t of e.masts ?? []) {
|
|
949
959
|
n(t.position, 3, "HullFire mast position"), g(t.height, "mast height", 1, 120), t.falls && n(t.falls, 3, "HullFire mast falls"), t.fallAt !== void 0 && g(t.fallAt, "mast fallAt", 0, 1e7);
|
|
950
960
|
for (let e of t.yards ?? []) g(e.at, "yard at", 0, t.height), g(e.length, "yard length", .1, 100);
|
|
@@ -957,7 +967,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
957
967
|
return typeof e.matrix == "function" ? e.matrix() : e;
|
|
958
968
|
}
|
|
959
969
|
toWorld(e) {
|
|
960
|
-
return
|
|
970
|
+
return K(this.matrix(), e);
|
|
961
971
|
}
|
|
962
972
|
burning(e) {
|
|
963
973
|
let t = this.options, n = t.ignition?.time ?? 0, r = t.ignition?.at?.[2] ?? 0, i = t.spread ?? .03, a = i > 0 ? Math.abs(e - r) / i : Math.abs(e - r) < 1e-9 ? 0 : Infinity, o = this.clock - n - a;
|
|
@@ -980,10 +990,10 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
980
990
|
}
|
|
981
991
|
charDepth(e) {
|
|
982
992
|
n(e, 3, "HullFire char point");
|
|
983
|
-
let t = this.options, r = (t.charRate ?? .5) / 60, i = t.hull?.deck ?? 6, a = e[1] >= i -
|
|
993
|
+
let t = this.options, r = (t.charRate ?? .5) / 60, i = t.hull?.deck ?? 6, a = e[1] >= i - re ? this.exposure(e[2]) : 0;
|
|
984
994
|
for (let n of t.ports ?? []) {
|
|
985
995
|
if (Math.sign(n.position[0] || 1) !== Math.sign(e[0] || 1)) continue;
|
|
986
|
-
let [t, r] = n.size ?? [.8, .7], i = n.position[1] - r / 2, o = n.position[1] + r / 2 + Y(
|
|
996
|
+
let [t, r] = n.size ?? [.8, .7], i = n.position[1] - r / 2, o = n.position[1] + r / 2 + X(Y(t * r, r), t, r), s = Math.max(0, e[1] - i);
|
|
987
997
|
e[1] < i || e[1] > o || Math.abs(e[2] - n.position[2]) > t / 2 + .12 * s || (a = Math.max(a, this.exposure(n.position[2])));
|
|
988
998
|
}
|
|
989
999
|
return r * a;
|
|
@@ -991,7 +1001,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
991
1001
|
paint() {
|
|
992
1002
|
let e = this.options.mask;
|
|
993
1003
|
if (!e) return;
|
|
994
|
-
let t =
|
|
1004
|
+
let t = $(e), n = this.options.hull ?? {}, r = n.length ?? 50, i = n.deck ?? 6, a = n.draft ?? 5, o = t.width / 2, s = [
|
|
995
1005
|
0,
|
|
996
1006
|
0,
|
|
997
1007
|
0
|
|
@@ -1001,7 +1011,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1001
1011
|
let u = this.burning(s[2]);
|
|
1002
1012
|
for (let n = 0; n < t.height; n++) {
|
|
1003
1013
|
s[1] = (n + .5) / t.height * (i + a) - a;
|
|
1004
|
-
let r = this.charDepth(s), o = Math.round(255 * (1 - Math.exp(-r /
|
|
1014
|
+
let r = this.charDepth(s), o = Math.round(255 * (1 - Math.exp(-r / ie))), d = r > 0 ? Math.round(255 * u) : 0, f = (n * t.width + e) * 4;
|
|
1005
1015
|
(c[f] !== o || c[f + 1] !== d) && (c[f] = o, c[f + 1] = d, l = !0);
|
|
1006
1016
|
}
|
|
1007
1017
|
}
|
|
@@ -1015,7 +1025,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1015
1025
|
rigging() {
|
|
1016
1026
|
let e = this.options, t = this.matrix(), n = [];
|
|
1017
1027
|
return (e.masts ?? []).forEach((e, r) => {
|
|
1018
|
-
let i = this.mastFallTime(r), a = this.clock > i ?
|
|
1028
|
+
let i = this.mastFallTime(r), a = this.clock > i ? ue(e.height, this.clock - i, Math.min(50, Math.max(0, e.position[1]))).angle : 0, o = e.falls ?? [
|
|
1019
1029
|
1,
|
|
1020
1030
|
0,
|
|
1021
1031
|
0
|
|
@@ -1092,8 +1102,8 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1092
1102
|
return this.flames().reduce((e, t) => e + t.heat, 0);
|
|
1093
1103
|
}
|
|
1094
1104
|
flames() {
|
|
1095
|
-
let e = this.options, t = e.hull ?? {}, n = t.length ?? 50, r = t.beam ?? 13, i = t.deck ?? 6, a = e.deckHeat ?? 25e4, o = [], s = n /
|
|
1096
|
-
for (let e = 0; e <
|
|
1105
|
+
let e = this.options, t = e.hull ?? {}, n = t.length ?? 50, r = t.beam ?? 13, i = t.deck ?? 6, a = e.deckHeat ?? 25e4, o = [], s = n / Q;
|
|
1106
|
+
for (let e = 0; e < Q; e++) {
|
|
1097
1107
|
let t = -n / 2 + (e + .5) * s, c = this.burning(t);
|
|
1098
1108
|
if (c <= 0) continue;
|
|
1099
1109
|
let l = a * s * r * .8 * c, u = Math.sqrt(4 * s * r * .8 / Math.PI), d = Math.max(0, .235 * (l / 1e3) ** .4 - 1.02 * u);
|
|
@@ -1112,7 +1122,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1112
1122
|
for (let t of e.ports ?? []) {
|
|
1113
1123
|
let e = this.burning(t.position[2]);
|
|
1114
1124
|
if (e <= 0) continue;
|
|
1115
|
-
let [n, r] = t.size ?? [.8, .7], i =
|
|
1125
|
+
let [n, r] = t.size ?? [.8, .7], i = Y(n * r, r) * e, a = X(i, n, r), s = t.normal ?? [
|
|
1116
1126
|
Math.sign(t.position[0]) || 1,
|
|
1117
1127
|
0,
|
|
1118
1128
|
0
|
|
@@ -1126,7 +1136,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1126
1136
|
position: this.toWorld(c),
|
|
1127
1137
|
length: a + r,
|
|
1128
1138
|
footprint: [n, .6 * n],
|
|
1129
|
-
heat: i *
|
|
1139
|
+
heat: i * Z
|
|
1130
1140
|
});
|
|
1131
1141
|
}
|
|
1132
1142
|
return o;
|
|
@@ -1168,7 +1178,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1168
1178
|
let i = this.smokeColumns;
|
|
1169
1179
|
if (i.length === 0) return;
|
|
1170
1180
|
t.reduce((e, t) => e + t.heat, 0);
|
|
1171
|
-
let a = e.hull?.length ?? 50, o = e.hull?.deck ?? 6, s =
|
|
1181
|
+
let a = e.hull?.length ?? 50, o = e.hull?.deck ?? 6, s = W(e.soot ?? .35);
|
|
1172
1182
|
i.forEach((n, r) => {
|
|
1173
1183
|
let c = -a / 2 + (r + .5) * a / i.length, l = -a / 2 + r * a / i.length, u = r === i.length - 1 ? Infinity : l + a / i.length, d = t.filter((e) => {
|
|
1174
1184
|
let t = this.localZ(e.position);
|
|
@@ -1185,7 +1195,7 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1185
1195
|
let t = this.matrix(), n = t[8], r = t[9], i = t[10], a = n * n + r * r + i * i;
|
|
1186
1196
|
return ((e[0] - t[12]) * n + (e[1] - t[13]) * r + (e[2] - t[14]) * i) / (a || 1);
|
|
1187
1197
|
}
|
|
1188
|
-
static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("
|
|
1198
|
+
static attach(t, n) {__margoAssertCore(t,__margoCoreRequirement("1.0.0",import.meta.url));
|
|
1189
1199
|
if (!n || typeof n != "object") throw TypeError("Invalid HullFire options; pass {ship}");
|
|
1190
1200
|
return new e(t, n);
|
|
1191
1201
|
}
|
|
@@ -1201,4 +1211,4 @@ var de = class e {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url
|
|
|
1201
1211
|
}
|
|
1202
1212
|
};
|
|
1203
1213
|
//#endregion
|
|
1204
|
-
export { h as BLACK_POWDER,
|
|
1214
|
+
export { h as BLACK_POWDER, ne as Battery, y as FLASH_ALPHA, v as FLASH_DURATION, V as GRAIN_DENSITY, Z as HULL_FUEL_HEAT, de as HullFire, D as OAK, B as POWDER_BURN_RATE, C as PowderPuff, H as UNBURNT_FRACTION, x as flashExposure, ae as hullMaskImage, oe as hullMaskUVs, ue as mastTopple, b as muzzleFlash, U as powderGrains, _ as powderProducts, z as shotFlight, R as shotPath, W as smokeColor, w as smokeDispersion, T as sphereDrag, Y as ventBurningRate, X as ventFlameHeight, A as woodExitSpeed, k as woodPenetration };
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type { VFXOverLife } from './over-life.js';
|
|
|
6
6
|
export type { VFXSpace } from './space.js';
|
|
7
7
|
export type { BurstSpawn } from './base.js';
|
|
8
8
|
export { VFX_TICK_RATE } from './base.js';
|
|
9
|
-
export type { VFXOptions, VFXWind, VFXObstacle, VFXTexture, VFXCurves, VFXEmitter, ParticleAtlas, VFXFeatures, FogLike, VFXRibbons, VFXMeshParticles, VFXEvents, VFXLit, VFXLightSource, VFXDepthCollide, VFXStretch, VFXFields, VFXAttractor, VFXVectorField, VFXSkinned, VFXSkinnedPrimitive, VFXFlipbook, VFXShadows, VFXParticleLight, VFXNodes, VFXNode, VFXNodeSample, } from './base.js';
|
|
9
|
+
export type { VFXOptions, VFXWind, VFXObstacle, VFXTexture, VFXCurves, VFXEmitter, ParticleAtlas, VFXFeatures, FogLike, VFXRibbons, VFXMeshParticles, VFXEvents, VFXLit, VFXLightSource, VFXLamps, VFXDepthCollide, VFXStretch, VFXFields, VFXAttractor, VFXVectorField, VFXSkinned, VFXSkinnedPrimitive, VFXFlipbook, VFXShadows, VFXParticleLight, VFXNodes, VFXNode, VFXNodeSample, } from './base.js';
|
|
10
10
|
/**
|
|
11
11
|
* GPU particles with every optional feature (obstacles, wrap, sort, texture, curves, emitter, soft, ribbons, mesh, events, lit, depthCollide, stretch, fields, skinned, flipbook, shadows, nodes). Effects that use none of them load
|
|
12
12
|
* less with `VFX` from `@margoengine/vfx/base`, adding only the feature entries they use.
|