@adatechnology/game-vfx 0.15.0 → 0.17.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/dist/index.d.ts +71 -4
- package/dist/index.global.js +253 -38
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +253 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1426,6 +1426,8 @@ var Enclosures = class {
|
|
|
1426
1426
|
__publicField(this, "l0", new Float64Array(3));
|
|
1427
1427
|
__publicField(this, "l1", new Float64Array(3));
|
|
1428
1428
|
__publicField(this, "q", new Float64Array(3));
|
|
1429
|
+
__publicField(this, "h", new Float64Array(3));
|
|
1430
|
+
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1429
1431
|
this.random = lehmer(seed);
|
|
1430
1432
|
}
|
|
1431
1433
|
get empty() {
|
|
@@ -1501,9 +1503,21 @@ var Enclosures = class {
|
|
|
1501
1503
|
return this.chance(s.leak, dt);
|
|
1502
1504
|
}
|
|
1503
1505
|
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1506
|
+
const move = this.move;
|
|
1507
|
+
move.x0 = x0;
|
|
1508
|
+
move.y0 = y0;
|
|
1509
|
+
move.z0 = z0;
|
|
1510
|
+
move.x1 = x1;
|
|
1511
|
+
move.y1 = y1;
|
|
1512
|
+
move.z1 = z1;
|
|
1513
|
+
move.pad = pad;
|
|
1514
|
+
return this.confineMove(move, dt);
|
|
1515
|
+
}
|
|
1516
|
+
confineMove(move, dt) {
|
|
1504
1517
|
const list = this.list;
|
|
1505
1518
|
if (list.length === 0) return false;
|
|
1506
|
-
const
|
|
1519
|
+
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
1520
|
+
const p = Math.min(Math.max(0, move.pad), MAX_PAD);
|
|
1507
1521
|
const l0 = this.l0;
|
|
1508
1522
|
const l1 = this.l1;
|
|
1509
1523
|
const q = this.q;
|
|
@@ -1520,7 +1534,10 @@ var Enclosures = class {
|
|
|
1520
1534
|
}
|
|
1521
1535
|
this.toLocal(s, x0, y0, z0, l0);
|
|
1522
1536
|
this.toLocal(s, x1, y1, z1, l1);
|
|
1523
|
-
const h =
|
|
1537
|
+
const h = this.h;
|
|
1538
|
+
h[0] = s.hx;
|
|
1539
|
+
h[1] = s.hy;
|
|
1540
|
+
h[2] = s.hz;
|
|
1524
1541
|
const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
|
|
1525
1542
|
let axis2 = 0;
|
|
1526
1543
|
let sign = 1;
|
|
@@ -1569,6 +1586,13 @@ var Enclosures = class {
|
|
|
1569
1586
|
return false;
|
|
1570
1587
|
}
|
|
1571
1588
|
};
|
|
1589
|
+
function slideInto(out, velocity) {
|
|
1590
|
+
const into = velocity.vx * out.nx + velocity.vy * out.ny + velocity.vz * out.nz;
|
|
1591
|
+
if (into >= 0) return;
|
|
1592
|
+
velocity.vx -= into * out.nx;
|
|
1593
|
+
velocity.vy -= into * out.ny;
|
|
1594
|
+
velocity.vz -= into * out.nz;
|
|
1595
|
+
}
|
|
1572
1596
|
function slideAlong(out, vx2, vy2, vz2) {
|
|
1573
1597
|
const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
|
|
1574
1598
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
@@ -1583,6 +1607,7 @@ var ARRIVAL_BASE = 0.3;
|
|
|
1583
1607
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1584
1608
|
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1585
1609
|
var PAD_OF_SIZE = 0.35;
|
|
1610
|
+
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
1586
1611
|
function createPuffPool(capacity) {
|
|
1587
1612
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1588
1613
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1679,23 +1704,30 @@ function moveFree(puff3, dt, age, heat, wind) {
|
|
|
1679
1704
|
if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
|
|
1680
1705
|
}
|
|
1681
1706
|
}
|
|
1707
|
+
function confine(confiner, puff3, dt) {
|
|
1708
|
+
MOVE.x1 = puff3.x;
|
|
1709
|
+
MOVE.y1 = puff3.y;
|
|
1710
|
+
MOVE.z1 = puff3.z;
|
|
1711
|
+
MOVE.pad = puff3.size * PAD_OF_SIZE;
|
|
1712
|
+
return confiner.confineMove(MOVE, dt);
|
|
1713
|
+
}
|
|
1682
1714
|
function updatePuffs(pool, dt, wind, confiner) {
|
|
1683
1715
|
pool.compact(ageOrKeep2, dt);
|
|
1684
1716
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
1685
1717
|
for (const puff3 of pool.items) {
|
|
1686
1718
|
const age = puff3.t / puff3.life;
|
|
1687
1719
|
const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1720
|
+
MOVE.x0 = puff3.x;
|
|
1721
|
+
MOVE.y0 = puff3.y;
|
|
1722
|
+
MOVE.z0 = puff3.z;
|
|
1691
1723
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1692
1724
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1693
|
-
if (confining && CARRIED_KINDS[puff3.kind] &&
|
|
1725
|
+
if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
|
|
1694
1726
|
const out = confiner.out;
|
|
1695
1727
|
puff3.x = out.x;
|
|
1696
1728
|
puff3.y = out.y;
|
|
1697
1729
|
puff3.z = out.z;
|
|
1698
|
-
|
|
1730
|
+
slideInto(out, puff3);
|
|
1699
1731
|
}
|
|
1700
1732
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1701
1733
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
@@ -1798,6 +1830,7 @@ function createFirePool(capacity, placeholder) {
|
|
|
1798
1830
|
y: 0,
|
|
1799
1831
|
z: 0,
|
|
1800
1832
|
r: 0.6,
|
|
1833
|
+
h: 0,
|
|
1801
1834
|
r0: 0.6,
|
|
1802
1835
|
grow: 0,
|
|
1803
1836
|
life: 6,
|
|
@@ -1823,6 +1856,7 @@ function spawnFire(pool, random, init, handle) {
|
|
|
1823
1856
|
fire.y = init.y ?? 0;
|
|
1824
1857
|
fire.z = init.z ?? 0;
|
|
1825
1858
|
fire.r = init.r ?? 0.6;
|
|
1859
|
+
fire.h = init.h ?? 0;
|
|
1826
1860
|
fire.r0 = init.startRadius ?? fire.r;
|
|
1827
1861
|
fire.grow = init.grow ?? 0;
|
|
1828
1862
|
fire.life = init.life ?? 6;
|
|
@@ -1847,19 +1881,23 @@ function addFire(core, random, init, handle) {
|
|
|
1847
1881
|
core.trace?.fire?.(fire);
|
|
1848
1882
|
return fire;
|
|
1849
1883
|
}
|
|
1884
|
+
var FLAMES_PER_HEIGHT = 1.5;
|
|
1885
|
+
var SMOKE_PER_HEIGHT = 2;
|
|
1850
1886
|
function positionOf(follow) {
|
|
1851
1887
|
return "position" in follow ? follow.position : follow;
|
|
1852
1888
|
}
|
|
1889
|
+
var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
|
|
1890
|
+
var isBody = (follow) => "radius" in follow && "height" in follow;
|
|
1853
1891
|
function emitFlames(core, fire, radius, dt) {
|
|
1854
1892
|
const random = fire.rng;
|
|
1855
|
-
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
|
|
1893
|
+
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
1856
1894
|
while (fire.acc >= 1) {
|
|
1857
1895
|
fire.acc -= 1;
|
|
1858
1896
|
const angle = random.next() * Math.PI * 2;
|
|
1859
1897
|
const distance = Math.sqrt(random.next()) * radius;
|
|
1860
1898
|
addPuff(core, random, {
|
|
1861
1899
|
x: fire.x + Math.cos(angle) * distance,
|
|
1862
|
-
y: fire.y + 0.05,
|
|
1900
|
+
y: fire.y + 0.05 + heightOf(fire),
|
|
1863
1901
|
z: fire.z + Math.sin(angle) * distance,
|
|
1864
1902
|
vx: random.between(-0.2, 0.2),
|
|
1865
1903
|
vy: random.between(0.6, 1.4),
|
|
@@ -1881,12 +1919,12 @@ function emitFlames(core, fire, radius, dt) {
|
|
|
1881
1919
|
}
|
|
1882
1920
|
function emitSmoke(core, fire, radius, dt) {
|
|
1883
1921
|
const random = fire.rng;
|
|
1884
|
-
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
|
|
1922
|
+
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
1885
1923
|
while (fire.smokeAcc >= 1 && core.layers.smoke) {
|
|
1886
1924
|
fire.smokeAcc -= 1;
|
|
1887
1925
|
addPuff(core, random, {
|
|
1888
1926
|
x: fire.x + random.between(-radius, radius) * 0.5,
|
|
1889
|
-
y: fire.y + 0.6 + radius * 0.3,
|
|
1927
|
+
y: fire.y + fire.h + 0.6 + radius * 0.3,
|
|
1890
1928
|
z: fire.z + random.between(-radius, radius) * 0.5,
|
|
1891
1929
|
vy: random.between(0.8, 1.5),
|
|
1892
1930
|
s0: 0.25,
|
|
@@ -1908,7 +1946,7 @@ function emitEmber(core, fire, radius, dt) {
|
|
|
1908
1946
|
if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
|
|
1909
1947
|
addSpark(core, {
|
|
1910
1948
|
x: fire.x + random.between(-radius, radius) * 0.6,
|
|
1911
|
-
y: fire.y + 0.4,
|
|
1949
|
+
y: fire.y + 0.4 + heightOf(fire),
|
|
1912
1950
|
z: fire.z + random.between(-radius, radius) * 0.6,
|
|
1913
1951
|
vx: random.between(-0.4, 0.4),
|
|
1914
1952
|
vy: random.between(1.5, 3.2),
|
|
@@ -1932,6 +1970,10 @@ function updateFires(core, dt) {
|
|
|
1932
1970
|
fire.x = point.x + fire.fx;
|
|
1933
1971
|
fire.y = point.y + fire.fy;
|
|
1934
1972
|
fire.z = point.z + fire.fz;
|
|
1973
|
+
if (isBody(fire.follow)) {
|
|
1974
|
+
fire.r = fire.follow.radius;
|
|
1975
|
+
fire.h = fire.follow.height;
|
|
1976
|
+
}
|
|
1935
1977
|
}
|
|
1936
1978
|
const radius = fire.grow ? lerp(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
|
|
1937
1979
|
fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
|
|
@@ -2006,6 +2048,7 @@ var INDEX = { $: "index" };
|
|
|
2006
2048
|
var QUALITY = { $: "quality" };
|
|
2007
2049
|
var FRESH = { $: "fresh" };
|
|
2008
2050
|
var DIRECTION = { $: "direction" };
|
|
2051
|
+
var NORMAL = { $: "normal" };
|
|
2009
2052
|
var CAMERA_POSITION = { $: "cameraPosition" };
|
|
2010
2053
|
|
|
2011
2054
|
// src/effects/steps.ts
|
|
@@ -2561,7 +2604,7 @@ var WEAPONS = ["glock", "ak", "r870", "barrett"];
|
|
|
2561
2604
|
var TIP2 = [-0.8, 1.38, 3.4 - 0.78];
|
|
2562
2605
|
var PORT2 = [-0.76, 1.4, 3.32];
|
|
2563
2606
|
var FORWARD3 = [0, 0, -1];
|
|
2564
|
-
var
|
|
2607
|
+
var NORMAL2 = [0, 0, 1];
|
|
2565
2608
|
var WALL_Z2 = -4.45;
|
|
2566
2609
|
var SHOTS = [[0, 0.45, 0.9], [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0], [0]];
|
|
2567
2610
|
var SHOT_TIME = pick(pick(SHOTS, PARAM), INDEX);
|
|
@@ -2586,8 +2629,8 @@ var MUZZLE_FLASH = {
|
|
|
2586
2629
|
set("target", [add(-0.8, rnd(-0.4, 0.4)), add(1.4, rnd(-0.3, 0.3)), WALL_Z2]),
|
|
2587
2630
|
when(
|
|
2588
2631
|
eq(PARAM, SHOTGUN),
|
|
2589
|
-
[repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2],
|
|
2590
|
-
[call2("impact", "concrete", variable("target"),
|
|
2632
|
+
[repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL2, 0.35))],
|
|
2633
|
+
[call2("impact", "concrete", variable("target"), NORMAL2, ite(eq(PARAM, BARRETT), 2, 1))]
|
|
2591
2634
|
),
|
|
2592
2635
|
when(and(eq(PARAM, AK), eq(mod(round(mul(SHOT_TIME, 10)), 3), 0)), [spawn("streak", { p: TIP2, dir: FORWARD3, cone: 0, sp: 90, life: 0.09, len: 0.025, c0: 16752704, a: 1 })])
|
|
2593
2636
|
)
|
|
@@ -3145,6 +3188,8 @@ var RainField = class {
|
|
|
3145
3188
|
__publicField(this, "puddles", WORKSHOP_PUDDLES);
|
|
3146
3189
|
/** Replaces the puddle test (a game knows its own wet spots). */
|
|
3147
3190
|
__publicField(this, "puddleAt");
|
|
3191
|
+
/** Top (world y) of the roof or slab over (x, z), `undefined` for open sky: a streak that falls under it is gone, with no splash and no ring. Unset: nothing is roofed. */
|
|
3192
|
+
__publicField(this, "coverTopAt");
|
|
3148
3193
|
}
|
|
3149
3194
|
/** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
|
|
3150
3195
|
init(count, wind) {
|
|
@@ -3190,6 +3235,13 @@ var RainField = class {
|
|
|
3190
3235
|
positions[o + 3] += slant;
|
|
3191
3236
|
positions[o + 1] -= fall;
|
|
3192
3237
|
positions[o + 4] -= fall;
|
|
3238
|
+
if (this.coverTopAt) {
|
|
3239
|
+
const top = this.coverTopAt(positions[o], positions[o + 2]);
|
|
3240
|
+
if (top !== void 0 && positions[o + 4] < top) {
|
|
3241
|
+
this.restart(o);
|
|
3242
|
+
continue;
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3193
3245
|
const ground = context.groundAt(positions[o], positions[o + 2]);
|
|
3194
3246
|
if (positions[o + 4] < ground) {
|
|
3195
3247
|
const x = positions[o];
|
|
@@ -3205,10 +3257,7 @@ var RainField = class {
|
|
|
3205
3257
|
}
|
|
3206
3258
|
}
|
|
3207
3259
|
}
|
|
3208
|
-
|
|
3209
|
-
const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
|
|
3210
|
-
const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
|
|
3211
|
-
this.set(o, nx, ny, nz);
|
|
3260
|
+
this.restart(o);
|
|
3212
3261
|
}
|
|
3213
3262
|
}
|
|
3214
3263
|
}
|
|
@@ -3216,6 +3265,13 @@ var RainField = class {
|
|
|
3216
3265
|
clear() {
|
|
3217
3266
|
this.on = false;
|
|
3218
3267
|
}
|
|
3268
|
+
restart(offset) {
|
|
3269
|
+
const { random } = this.engine;
|
|
3270
|
+
const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
|
|
3271
|
+
const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
|
|
3272
|
+
const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
|
|
3273
|
+
this.set(offset, nx, ny, nz);
|
|
3274
|
+
}
|
|
3219
3275
|
set(offset, x, y, z) {
|
|
3220
3276
|
const positions = this.positions;
|
|
3221
3277
|
positions[offset] = x;
|
|
@@ -3702,6 +3758,8 @@ var COUGH_AND_BREATH = {
|
|
|
3702
3758
|
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3703
3759
|
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3704
3760
|
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3761
|
+
var PIECES_DRAWN_VARIABLE = "piecesDrawn";
|
|
3762
|
+
var standIns = (...steps) => when(not(variable(PIECES_DRAWN_VARIABLE)), steps);
|
|
3705
3763
|
var FAMILIES = {
|
|
3706
3764
|
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3707
3765
|
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
@@ -3748,7 +3806,7 @@ function breachDust(family) {
|
|
|
3748
3806
|
...sparks(look, 14),
|
|
3749
3807
|
...glints(look, 20),
|
|
3750
3808
|
burst("normal", Math.round(30 * look.cloud), { p: ORIGIN, box: [1.4, 0.8, 0.2], sp: [0.3, 1.2], drag: 1.5, life: [1.5, 2.6], size: [0.4, 0.7], grow: 3, c0: dustTone(look), c1: 4867648, a: 0.45 }),
|
|
3751
|
-
repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 })),
|
|
3809
|
+
standIns(repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 }))),
|
|
3752
3810
|
repeat(
|
|
3753
3811
|
scaled(Math.round(60 * look.cloud)),
|
|
3754
3812
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
@@ -3780,8 +3838,10 @@ function collapseDust(family) {
|
|
|
3780
3838
|
timeline: [
|
|
3781
3839
|
screen({ add: { shake: 0.45 } }),
|
|
3782
3840
|
...sparks(look, 20),
|
|
3783
|
-
|
|
3784
|
-
|
|
3841
|
+
standIns(
|
|
3842
|
+
repeat(6, debris({ p: ORIGIN, box: [2, 0.05, 0.6], v: [rnd(-0.5, 0.5), rnd(-0.5, 0), rnd(0, 0.8)], sp: 0, size: [rnd(0.5, 1.1), look.piece[1] > 0.01 ? 0.25 : 0.03, rnd(0.4, 0.8)], c: debrisTone(look), spin: 3, life: 30, bounce: 0.1 })),
|
|
3843
|
+
repeat(scaled(20), debris({ p: ORIGIN, box: [2.1, 0.1, 0.7], v: [rnd(-1, 1), rnd(-1, 1), rnd(0, 1.5)], sp: 0, size: grow(look.piece, 3.4), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 30 }))
|
|
3844
|
+
),
|
|
3785
3845
|
repeat(
|
|
3786
3846
|
scaled(Math.round(70 * look.cloud)),
|
|
3787
3847
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
@@ -3821,7 +3881,6 @@ var MATERIAL_EVENT_EFFECTS = [
|
|
|
3821
3881
|
];
|
|
3822
3882
|
|
|
3823
3883
|
// src/effects/events.ts
|
|
3824
|
-
var FACING5 = [0, 0, 1];
|
|
3825
3884
|
var ORIGIN2 = [0, 0, 0];
|
|
3826
3885
|
var FORWARD4 = [0, 0, -1];
|
|
3827
3886
|
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
@@ -3831,7 +3890,7 @@ var impactEffect = (material) => ({
|
|
|
3831
3890
|
team: "weapons",
|
|
3832
3891
|
budget: { particles: 40, decals: 1 },
|
|
3833
3892
|
loop: 2,
|
|
3834
|
-
timeline: [call2("impact", material, ORIGIN2,
|
|
3893
|
+
timeline: [call2("impact", material, ORIGIN2, NORMAL, 1, 0)]
|
|
3835
3894
|
});
|
|
3836
3895
|
var muzzleEffect = (weapon) => ({
|
|
3837
3896
|
id: `muzzle_${weapon}`,
|
|
@@ -4037,13 +4096,25 @@ var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
|
|
|
4037
4096
|
|
|
4038
4097
|
// src/effects/vehicles/game-effects.ts
|
|
4039
4098
|
var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
|
|
4099
|
+
var BODYWORK_IMPACT = {
|
|
4100
|
+
id: "impact_bodywork",
|
|
4101
|
+
pageId: "vehicle:impact_bodywork",
|
|
4102
|
+
team: "vehicles",
|
|
4103
|
+
budget: { particles: 80, debris: 20, lights: 1 },
|
|
4104
|
+
loop: 2,
|
|
4105
|
+
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4106
|
+
};
|
|
4040
4107
|
var VEHICLE_EFFECTS = [
|
|
4108
|
+
BODYWORK_IMPACT,
|
|
4041
4109
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4042
4110
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4043
4111
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
4044
4112
|
aliasOf(ENGINE_SMOKE, "vehicle_exhaust", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 0 }, loop: 0.5 }),
|
|
4045
|
-
/**
|
|
4046
|
-
|
|
4113
|
+
/**
|
|
4114
|
+
* A hole in a tank: the page's drips, falling from the point it is played at (the hole). No pool of its own: the pool is the liquid that came out, laid by the
|
|
4115
|
+
* host's fluid world as it leaks (it grows with the volume and spreads by the liquid's own kind), not a drawing of a size the page chose.
|
|
4116
|
+
*/
|
|
4117
|
+
aliasOf(FUEL_LEAK_ONLY, "vehicle_leak", { anchor: TANK, timeline: [] }),
|
|
4047
4118
|
/** The leak caught fire (an incendiary or tracer round, a spark, a fire near): the page's whole sequence, the fire running along the pool to the tank and the blast. */
|
|
4048
4119
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
4049
4120
|
];
|
|
@@ -4781,6 +4852,48 @@ function resolve(value, context) {
|
|
|
4781
4852
|
}
|
|
4782
4853
|
}
|
|
4783
4854
|
|
|
4855
|
+
// src/effects/builders/bodywork.ts
|
|
4856
|
+
var PISTOL_BORE = 9e-3;
|
|
4857
|
+
var BARE_STEEL = 11778236;
|
|
4858
|
+
var DEFAULT_PAINT = 9147290;
|
|
4859
|
+
var DEFAULT_DIRECTION = [0, 0, -1];
|
|
4860
|
+
var MAX_SCALE = 3;
|
|
4861
|
+
var MIN_SCALE = 0.6;
|
|
4862
|
+
function reflected(direction, normal) {
|
|
4863
|
+
const along = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
4864
|
+
const out = [direction[0] - 2 * along * normal[0], direction[1] - 2 * along * normal[1], direction[2] - 2 * along * normal[2]];
|
|
4865
|
+
const length = Math.hypot(out[0], out[1], out[2]);
|
|
4866
|
+
if (length < 1e-6 || Math.abs(along) > 0.98) return normal;
|
|
4867
|
+
return [out[0] / length, out[1] / length, out[2] / length];
|
|
4868
|
+
}
|
|
4869
|
+
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
4870
|
+
function bodyworkHitOf(values) {
|
|
4871
|
+
const raw = Array.isArray(values.direction) ? values.direction : [];
|
|
4872
|
+
const direction = raw.length === 3 && raw.every((entry) => typeof entry === "number" && Number.isFinite(entry)) ? [raw[0], raw[1], raw[2]] : DEFAULT_DIRECTION;
|
|
4873
|
+
return { direction, bore: numberOr(values.bore, PISTOL_BORE), paint: numberOr(values.paint, DEFAULT_PAINT), metal: numberOr(values.metal, BARE_STEEL) };
|
|
4874
|
+
}
|
|
4875
|
+
function bodyworkScale(bore) {
|
|
4876
|
+
return Math.min(MAX_SCALE, Math.max(MIN_SCALE, bore / PISTOL_BORE));
|
|
4877
|
+
}
|
|
4878
|
+
function bodyworkImpact(engine, point, normal, hit) {
|
|
4879
|
+
const scale = bodyworkScale(hit.bore);
|
|
4880
|
+
const off = reflected(hit.direction, normal);
|
|
4881
|
+
if (engine.quality < 2) {
|
|
4882
|
+
engine.burst("streak", Math.round(14 * scale), { p: point, dir: off, cone: 0.75, sp: [4, 12], life: [0.08, 0.3], len: 0.03, c0: 16774352, c1: 16738840, g: 9.8, gnd: 2 });
|
|
4883
|
+
engine.burst("add", 2, { p: plusScaled(point, normal, 0.01), size: [0.06 * scale, 0.12 * scale], life: 0.05, c0: 16770736, fi: 0 });
|
|
4884
|
+
engine.flash([plusScaled(point, normal, 0.15), 16760432, 1.6 * scale, 0.05, 4]);
|
|
4885
|
+
}
|
|
4886
|
+
const flakes = engine.scaled(Math.round(5 * scale));
|
|
4887
|
+
for (let index = 0; index < flakes; index++) {
|
|
4888
|
+
engine.debrisPiece({ p: point, dir: normal, cone: 0.9, sp: [1.2, 3.5], size: [8e-3 * scale, 12e-4, 6e-3 * scale], k: [0.5, 1.4], c: hit.paint, life: 6, bounce: 0.2 });
|
|
4889
|
+
}
|
|
4890
|
+
const slivers = engine.scaled(Math.round(2 * scale));
|
|
4891
|
+
for (let index = 0; index < slivers; index++) {
|
|
4892
|
+
engine.debrisPiece({ p: point, dir: off, cone: 0.6, sp: [2.5, 6], size: [25e-4, 15e-4, 0.01 * scale], k: [0.6, 1.3], c: hit.metal, life: 6, bounce: 0.35 });
|
|
4893
|
+
}
|
|
4894
|
+
engine.burst("normal", Math.round(6 * scale), { p: point, dir: normal, cone: 0.7, sp: [0.4, 1.4], drag: 2.5, life: [0.4, 0.9], size: [0.03, 0.07], grow: 3, c0: hit.paint, a: 0.45, g: -0.05 });
|
|
4895
|
+
}
|
|
4896
|
+
|
|
4784
4897
|
// src/effects/builders/fire.ts
|
|
4785
4898
|
var UP12 = [0, 1, 0];
|
|
4786
4899
|
var ZERO = [0, 0, 0];
|
|
@@ -4935,11 +5048,12 @@ var MACROS = {
|
|
|
4935
5048
|
casing: ({ engine }, [port, type]) => casing(engine, port, type),
|
|
4936
5049
|
chips: ({ engine }, [point, direction, count, spread]) => chips(engine, point, direction, count, spread),
|
|
4937
5050
|
spark_at: ({ engine }, [point, direction, count, spread]) => sparkAt(engine, point, direction, count, spread),
|
|
4938
|
-
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count)
|
|
5051
|
+
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count),
|
|
5052
|
+
bodywork_impact: ({ engine }, [point, normal, direction, bore, paint, metal]) => bodyworkImpact(engine, point, normal, bodyworkHitOf({ direction, bore, paint, metal }))
|
|
4939
5053
|
};
|
|
4940
5054
|
|
|
4941
5055
|
// src/effects/instance.ts
|
|
4942
|
-
var
|
|
5056
|
+
var DEFAULT_DIRECTION2 = [0, 0, -1];
|
|
4943
5057
|
var DEFAULT_NORMAL = [0, 1, 0];
|
|
4944
5058
|
var SCREEN_FIELDS = {
|
|
4945
5059
|
shake: "shake",
|
|
@@ -5008,7 +5122,7 @@ var EffectInstance = class {
|
|
|
5008
5122
|
return instance().fresh;
|
|
5009
5123
|
},
|
|
5010
5124
|
get direction() {
|
|
5011
|
-
return instance().setup.direction ??
|
|
5125
|
+
return instance().setup.direction ?? DEFAULT_DIRECTION2;
|
|
5012
5126
|
},
|
|
5013
5127
|
get normal() {
|
|
5014
5128
|
return instance().setup.normal ?? DEFAULT_NORMAL;
|
|
@@ -6805,6 +6919,71 @@ function coneDirection(random, direction, cone, out) {
|
|
|
6805
6919
|
return out;
|
|
6806
6920
|
}
|
|
6807
6921
|
|
|
6922
|
+
// src/workshop/debris-contact.ts
|
|
6923
|
+
var CELL = 0.12;
|
|
6924
|
+
var OBSTACLE_BOUNCE = 0.3;
|
|
6925
|
+
var radiusOf = (piece) => Math.max(piece.sx, piece.sz) * 0.5;
|
|
6926
|
+
var thicknessOf = (piece) => Math.min(piece.sx, piece.sy, piece.sz);
|
|
6927
|
+
var cellKey = (i, k) => (i + 4096) * 8192 + (k + 4096);
|
|
6928
|
+
var RestingGrid = class {
|
|
6929
|
+
constructor() {
|
|
6930
|
+
__publicField(this, "cells", /* @__PURE__ */ new Map());
|
|
6931
|
+
}
|
|
6932
|
+
clear() {
|
|
6933
|
+
for (const list of this.cells.values()) list.length = 0;
|
|
6934
|
+
}
|
|
6935
|
+
rebuild(pieces) {
|
|
6936
|
+
this.clear();
|
|
6937
|
+
for (const piece of pieces) {
|
|
6938
|
+
if (!piece.on || !piece.rest) continue;
|
|
6939
|
+
const key = cellKey(Math.floor(piece.x / CELL), Math.floor(piece.z / CELL));
|
|
6940
|
+
const list = this.cells.get(key);
|
|
6941
|
+
if (list) list.push(piece);
|
|
6942
|
+
else this.cells.set(key, [piece]);
|
|
6943
|
+
}
|
|
6944
|
+
}
|
|
6945
|
+
/** The height a piece at `piece`'s place lands at on the pieces under it (the top of the highest one it overlaps), or `-Infinity` over none. */
|
|
6946
|
+
supportUnder(piece) {
|
|
6947
|
+
const i = Math.floor(piece.x / CELL);
|
|
6948
|
+
const k = Math.floor(piece.z / CELL);
|
|
6949
|
+
const reach = radiusOf(piece);
|
|
6950
|
+
let top = -Infinity;
|
|
6951
|
+
for (let di = -1; di <= 1; di++) {
|
|
6952
|
+
for (let dk = -1; dk <= 1; dk++) {
|
|
6953
|
+
for (const other of this.cells.get(cellKey(i + di, k + dk)) ?? []) {
|
|
6954
|
+
if (other === piece) continue;
|
|
6955
|
+
if (Math.hypot(other.x - piece.x, other.z - piece.z) > reach + radiusOf(other)) continue;
|
|
6956
|
+
const otherTop = other.y + thicknessOf(other) * 0.5;
|
|
6957
|
+
if (otherTop <= piece.y + thicknessOf(piece) * 0.5) top = Math.max(top, otherTop + thicknessOf(piece) * 0.5);
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
}
|
|
6961
|
+
return top;
|
|
6962
|
+
}
|
|
6963
|
+
};
|
|
6964
|
+
function pushOutOfObstacles(piece, obstacles) {
|
|
6965
|
+
let moved = false;
|
|
6966
|
+
for (const body of obstacles) {
|
|
6967
|
+
if (piece.y < body.bottom || piece.y > body.top) continue;
|
|
6968
|
+
const dx = piece.x - body.x;
|
|
6969
|
+
const dz = piece.z - body.z;
|
|
6970
|
+
const distance = Math.hypot(dx, dz);
|
|
6971
|
+
const reach = body.radius + radiusOf(piece);
|
|
6972
|
+
if (distance >= reach) continue;
|
|
6973
|
+
const nx = distance > 1e-6 ? dx / distance : 1;
|
|
6974
|
+
const nz = distance > 1e-6 ? dz / distance : 0;
|
|
6975
|
+
piece.x = body.x + nx * reach;
|
|
6976
|
+
piece.z = body.z + nz * reach;
|
|
6977
|
+
const into = piece.vx * nx + piece.vz * nz;
|
|
6978
|
+
if (into < 0) {
|
|
6979
|
+
piece.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
|
|
6980
|
+
piece.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
|
|
6981
|
+
}
|
|
6982
|
+
moved = true;
|
|
6983
|
+
}
|
|
6984
|
+
return moved;
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6808
6987
|
// src/workshop/debris.ts
|
|
6809
6988
|
var CAPACITY = 500;
|
|
6810
6989
|
var GRAVITY2 = 9.8;
|
|
@@ -6826,6 +7005,7 @@ var DebrisPool = class {
|
|
|
6826
7005
|
__publicField(this, "count", 0);
|
|
6827
7006
|
__publicField(this, "next", 0);
|
|
6828
7007
|
__publicField(this, "direction", { x: 0, y: 0, z: 0 });
|
|
7008
|
+
__publicField(this, "resting", new RestingGrid());
|
|
6829
7009
|
}
|
|
6830
7010
|
spawn(options) {
|
|
6831
7011
|
const random = this.context.random;
|
|
@@ -6863,14 +7043,21 @@ var DebrisPool = class {
|
|
|
6863
7043
|
}
|
|
6864
7044
|
update(dt) {
|
|
6865
7045
|
this.count = 0;
|
|
7046
|
+
const contacts = this.context.debrisContacts;
|
|
7047
|
+
const obstacles = contacts?.obstacles() ?? [];
|
|
7048
|
+
let moving = false;
|
|
6866
7049
|
for (const piece of this.pieces) {
|
|
6867
7050
|
if (!piece.on) continue;
|
|
6868
|
-
this.count++;
|
|
6869
7051
|
piece.life -= dt;
|
|
6870
|
-
if (piece.life <= 0)
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
7052
|
+
if (piece.life <= 0) piece.on = false;
|
|
7053
|
+
else if (!piece.rest) moving = true;
|
|
7054
|
+
}
|
|
7055
|
+
if (moving && contacts) this.resting.rebuild(this.pieces);
|
|
7056
|
+
else this.resting.clear();
|
|
7057
|
+
for (const piece of this.pieces) {
|
|
7058
|
+
if (!piece.on) continue;
|
|
7059
|
+
this.count++;
|
|
7060
|
+
if (obstacles.length > 0 && pushOutOfObstacles(piece, obstacles)) piece.rest = false;
|
|
6874
7061
|
if (!piece.rest) this.move(piece, dt);
|
|
6875
7062
|
}
|
|
6876
7063
|
}
|
|
@@ -6886,7 +7073,7 @@ var DebrisPool = class {
|
|
|
6886
7073
|
piece.rx += piece.ax * dt;
|
|
6887
7074
|
piece.ry += piece.ay * dt;
|
|
6888
7075
|
piece.rz += piece.az * dt;
|
|
6889
|
-
const groundHeight = this.context.groundAt(piece.x, piece.z) + Math.min(piece.sx, piece.sy, piece.sz) * 0.5;
|
|
7076
|
+
const groundHeight = Math.max(this.context.groundAt(piece.x, piece.z) + Math.min(piece.sx, piece.sy, piece.sz) * 0.5, this.resting.supportUnder(piece));
|
|
6890
7077
|
if (piece.y >= groundHeight) return;
|
|
6891
7078
|
piece.y = groundHeight;
|
|
6892
7079
|
piece.vy *= -piece.bounce;
|
|
@@ -7562,6 +7749,14 @@ var WorkshopEngine = class {
|
|
|
7562
7749
|
this.decals = new DecalPool(this.context);
|
|
7563
7750
|
this.lights = new FlashLightPool(this.context);
|
|
7564
7751
|
}
|
|
7752
|
+
/**
|
|
7753
|
+
* Turns on the touch of the debris pieces (a game's world; the Workshop page's recording has none): they pile on the pieces at rest under them, and the
|
|
7754
|
+
* upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
|
|
7755
|
+
*/
|
|
7756
|
+
setDebrisContacts(obstacles) {
|
|
7757
|
+
if (obstacles) this.context.debrisContacts = { obstacles };
|
|
7758
|
+
else delete this.context.debrisContacts;
|
|
7759
|
+
}
|
|
7565
7760
|
get random() {
|
|
7566
7761
|
return this.context.random;
|
|
7567
7762
|
}
|
|
@@ -7652,7 +7847,9 @@ var WorkshopEngine = class {
|
|
|
7652
7847
|
if (this.placement) {
|
|
7653
7848
|
const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
|
|
7654
7849
|
const options = recipe[5];
|
|
7655
|
-
|
|
7850
|
+
const normal = options?.n ? this.turn(options.n) : void 0;
|
|
7851
|
+
const onFloor = !normal;
|
|
7852
|
+
args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
|
|
7656
7853
|
}
|
|
7657
7854
|
this.context.trace?.("decal", args);
|
|
7658
7855
|
this.decals.add(args[0], args[1], args[2], args[3], args[4], args[5]);
|
|
@@ -7834,6 +8031,21 @@ function createVfx(options = {}) {
|
|
|
7834
8031
|
return {
|
|
7835
8032
|
hostGroundAt: options.groundAt,
|
|
7836
8033
|
play(id, point, playOptions = {}) {
|
|
8034
|
+
if (id === "volumetric_fire") {
|
|
8035
|
+
const values = playOptions.values;
|
|
8036
|
+
const handle = ++handles.next;
|
|
8037
|
+
addFire(core, streamOf(playOptions.seed), {
|
|
8038
|
+
x: point[0],
|
|
8039
|
+
y: point[1],
|
|
8040
|
+
z: point[2],
|
|
8041
|
+
r: values?.radius ?? 0.55,
|
|
8042
|
+
life: values?.life ?? 24,
|
|
8043
|
+
...values?.rate !== void 0 ? { rate: values.rate } : {},
|
|
8044
|
+
...values?.smoke !== void 0 ? { smoke: values.smoke } : {},
|
|
8045
|
+
...values?.smokeColor !== void 0 ? { color: hexToLinearRgb(values.smokeColor) } : {}
|
|
8046
|
+
}, handle);
|
|
8047
|
+
return handle;
|
|
8048
|
+
}
|
|
7837
8049
|
if (!(id in effects)) return null;
|
|
7838
8050
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7839
8051
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
@@ -7850,7 +8062,7 @@ function createVfx(options = {}) {
|
|
|
7850
8062
|
sprites: () => spriteSystem,
|
|
7851
8063
|
workshop,
|
|
7852
8064
|
peekWorkshop: () => engine,
|
|
7853
|
-
effectIds: () => Object.keys(effects),
|
|
8065
|
+
effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
|
|
7854
8066
|
explosion(id, point, explosionOptions = {}) {
|
|
7855
8067
|
const base = definitionOf(id);
|
|
7856
8068
|
if (!base) return null;
|
|
@@ -7865,10 +8077,11 @@ function createVfx(options = {}) {
|
|
|
7865
8077
|
},
|
|
7866
8078
|
fire(fireOptions) {
|
|
7867
8079
|
const handle = ++handles.next;
|
|
7868
|
-
const { point, offset, seed, radius, smokeColor, ...rest } = fireOptions;
|
|
8080
|
+
const { point, offset, seed, radius, height, smokeColor, ...rest } = fireOptions;
|
|
7869
8081
|
addFire(core, streamOf(seed), {
|
|
7870
8082
|
...rest,
|
|
7871
8083
|
r: radius,
|
|
8084
|
+
...height !== void 0 ? { h: height } : {},
|
|
7872
8085
|
x: point[0],
|
|
7873
8086
|
y: point[1],
|
|
7874
8087
|
z: point[2],
|
|
@@ -9760,6 +9973,7 @@ export {
|
|
|
9760
9973
|
MATERIAL_EVENT_EFFECTS,
|
|
9761
9974
|
MeshPool,
|
|
9762
9975
|
OrderedPool,
|
|
9976
|
+
PIECES_DRAWN_VARIABLE,
|
|
9763
9977
|
PROFILES,
|
|
9764
9978
|
RAIN_CAPACITY,
|
|
9765
9979
|
RainField,
|
|
@@ -9809,6 +10023,7 @@ export {
|
|
|
9809
10023
|
resolveWaterBlast,
|
|
9810
10024
|
resolveWaterShotProfile,
|
|
9811
10025
|
slideAlong,
|
|
10026
|
+
slideInto,
|
|
9812
10027
|
streamFor,
|
|
9813
10028
|
updateScreen,
|
|
9814
10029
|
waterShotClassOf,
|