@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.global.js
CHANGED
|
@@ -42,6 +42,7 @@ var GameVfx = (() => {
|
|
|
42
42
|
MATERIAL_EVENT_EFFECTS: () => MATERIAL_EVENT_EFFECTS,
|
|
43
43
|
MeshPool: () => MeshPool,
|
|
44
44
|
OrderedPool: () => OrderedPool,
|
|
45
|
+
PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
|
|
45
46
|
PROFILES: () => PROFILES,
|
|
46
47
|
RAIN_CAPACITY: () => RAIN_CAPACITY,
|
|
47
48
|
RainField: () => RainField,
|
|
@@ -91,6 +92,7 @@ var GameVfx = (() => {
|
|
|
91
92
|
resolveWaterBlast: () => resolveWaterBlast,
|
|
92
93
|
resolveWaterShotProfile: () => resolveWaterShotProfile,
|
|
93
94
|
slideAlong: () => slideAlong,
|
|
95
|
+
slideInto: () => slideInto,
|
|
94
96
|
streamFor: () => streamFor,
|
|
95
97
|
updateScreen: () => updateScreen,
|
|
96
98
|
waterShotClassOf: () => waterShotClassOf,
|
|
@@ -1521,6 +1523,8 @@ var GameVfx = (() => {
|
|
|
1521
1523
|
__publicField(this, "l0", new Float64Array(3));
|
|
1522
1524
|
__publicField(this, "l1", new Float64Array(3));
|
|
1523
1525
|
__publicField(this, "q", new Float64Array(3));
|
|
1526
|
+
__publicField(this, "h", new Float64Array(3));
|
|
1527
|
+
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1524
1528
|
this.random = lehmer(seed);
|
|
1525
1529
|
}
|
|
1526
1530
|
get empty() {
|
|
@@ -1596,9 +1600,21 @@ var GameVfx = (() => {
|
|
|
1596
1600
|
return this.chance(s.leak, dt);
|
|
1597
1601
|
}
|
|
1598
1602
|
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1603
|
+
const move = this.move;
|
|
1604
|
+
move.x0 = x0;
|
|
1605
|
+
move.y0 = y0;
|
|
1606
|
+
move.z0 = z0;
|
|
1607
|
+
move.x1 = x1;
|
|
1608
|
+
move.y1 = y1;
|
|
1609
|
+
move.z1 = z1;
|
|
1610
|
+
move.pad = pad;
|
|
1611
|
+
return this.confineMove(move, dt);
|
|
1612
|
+
}
|
|
1613
|
+
confineMove(move, dt) {
|
|
1599
1614
|
const list = this.list;
|
|
1600
1615
|
if (list.length === 0) return false;
|
|
1601
|
-
const
|
|
1616
|
+
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
1617
|
+
const p = Math.min(Math.max(0, move.pad), MAX_PAD);
|
|
1602
1618
|
const l0 = this.l0;
|
|
1603
1619
|
const l1 = this.l1;
|
|
1604
1620
|
const q = this.q;
|
|
@@ -1615,7 +1631,10 @@ var GameVfx = (() => {
|
|
|
1615
1631
|
}
|
|
1616
1632
|
this.toLocal(s, x0, y0, z0, l0);
|
|
1617
1633
|
this.toLocal(s, x1, y1, z1, l1);
|
|
1618
|
-
const h =
|
|
1634
|
+
const h = this.h;
|
|
1635
|
+
h[0] = s.hx;
|
|
1636
|
+
h[1] = s.hy;
|
|
1637
|
+
h[2] = s.hz;
|
|
1619
1638
|
const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
|
|
1620
1639
|
let axis2 = 0;
|
|
1621
1640
|
let sign = 1;
|
|
@@ -1664,6 +1683,13 @@ var GameVfx = (() => {
|
|
|
1664
1683
|
return false;
|
|
1665
1684
|
}
|
|
1666
1685
|
};
|
|
1686
|
+
function slideInto(out, velocity) {
|
|
1687
|
+
const into = velocity.vx * out.nx + velocity.vy * out.ny + velocity.vz * out.nz;
|
|
1688
|
+
if (into >= 0) return;
|
|
1689
|
+
velocity.vx -= into * out.nx;
|
|
1690
|
+
velocity.vy -= into * out.ny;
|
|
1691
|
+
velocity.vz -= into * out.nz;
|
|
1692
|
+
}
|
|
1667
1693
|
function slideAlong(out, vx2, vy2, vz2) {
|
|
1668
1694
|
const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
|
|
1669
1695
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
@@ -1678,6 +1704,7 @@ var GameVfx = (() => {
|
|
|
1678
1704
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1679
1705
|
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1680
1706
|
var PAD_OF_SIZE = 0.35;
|
|
1707
|
+
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
1681
1708
|
function createPuffPool(capacity) {
|
|
1682
1709
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1683
1710
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1774,23 +1801,30 @@ var GameVfx = (() => {
|
|
|
1774
1801
|
if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
|
|
1775
1802
|
}
|
|
1776
1803
|
}
|
|
1804
|
+
function confine(confiner, puff3, dt) {
|
|
1805
|
+
MOVE.x1 = puff3.x;
|
|
1806
|
+
MOVE.y1 = puff3.y;
|
|
1807
|
+
MOVE.z1 = puff3.z;
|
|
1808
|
+
MOVE.pad = puff3.size * PAD_OF_SIZE;
|
|
1809
|
+
return confiner.confineMove(MOVE, dt);
|
|
1810
|
+
}
|
|
1777
1811
|
function updatePuffs(pool, dt, wind, confiner) {
|
|
1778
1812
|
pool.compact(ageOrKeep2, dt);
|
|
1779
1813
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
1780
1814
|
for (const puff3 of pool.items) {
|
|
1781
1815
|
const age = puff3.t / puff3.life;
|
|
1782
1816
|
const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1817
|
+
MOVE.x0 = puff3.x;
|
|
1818
|
+
MOVE.y0 = puff3.y;
|
|
1819
|
+
MOVE.z0 = puff3.z;
|
|
1786
1820
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1787
1821
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1788
|
-
if (confining && CARRIED_KINDS[puff3.kind] &&
|
|
1822
|
+
if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
|
|
1789
1823
|
const out = confiner.out;
|
|
1790
1824
|
puff3.x = out.x;
|
|
1791
1825
|
puff3.y = out.y;
|
|
1792
1826
|
puff3.z = out.z;
|
|
1793
|
-
|
|
1827
|
+
slideInto(out, puff3);
|
|
1794
1828
|
}
|
|
1795
1829
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1796
1830
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
@@ -1893,6 +1927,7 @@ var GameVfx = (() => {
|
|
|
1893
1927
|
y: 0,
|
|
1894
1928
|
z: 0,
|
|
1895
1929
|
r: 0.6,
|
|
1930
|
+
h: 0,
|
|
1896
1931
|
r0: 0.6,
|
|
1897
1932
|
grow: 0,
|
|
1898
1933
|
life: 6,
|
|
@@ -1918,6 +1953,7 @@ var GameVfx = (() => {
|
|
|
1918
1953
|
fire.y = init.y ?? 0;
|
|
1919
1954
|
fire.z = init.z ?? 0;
|
|
1920
1955
|
fire.r = init.r ?? 0.6;
|
|
1956
|
+
fire.h = init.h ?? 0;
|
|
1921
1957
|
fire.r0 = init.startRadius ?? fire.r;
|
|
1922
1958
|
fire.grow = init.grow ?? 0;
|
|
1923
1959
|
fire.life = init.life ?? 6;
|
|
@@ -1942,19 +1978,23 @@ var GameVfx = (() => {
|
|
|
1942
1978
|
core.trace?.fire?.(fire);
|
|
1943
1979
|
return fire;
|
|
1944
1980
|
}
|
|
1981
|
+
var FLAMES_PER_HEIGHT = 1.5;
|
|
1982
|
+
var SMOKE_PER_HEIGHT = 2;
|
|
1945
1983
|
function positionOf(follow) {
|
|
1946
1984
|
return "position" in follow ? follow.position : follow;
|
|
1947
1985
|
}
|
|
1986
|
+
var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
|
|
1987
|
+
var isBody = (follow) => "radius" in follow && "height" in follow;
|
|
1948
1988
|
function emitFlames(core, fire, radius, dt) {
|
|
1949
1989
|
const random = fire.rng;
|
|
1950
|
-
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
|
|
1990
|
+
fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
1951
1991
|
while (fire.acc >= 1) {
|
|
1952
1992
|
fire.acc -= 1;
|
|
1953
1993
|
const angle = random.next() * Math.PI * 2;
|
|
1954
1994
|
const distance = Math.sqrt(random.next()) * radius;
|
|
1955
1995
|
addPuff(core, random, {
|
|
1956
1996
|
x: fire.x + Math.cos(angle) * distance,
|
|
1957
|
-
y: fire.y + 0.05,
|
|
1997
|
+
y: fire.y + 0.05 + heightOf(fire),
|
|
1958
1998
|
z: fire.z + Math.sin(angle) * distance,
|
|
1959
1999
|
vx: random.between(-0.2, 0.2),
|
|
1960
2000
|
vy: random.between(0.6, 1.4),
|
|
@@ -1976,12 +2016,12 @@ var GameVfx = (() => {
|
|
|
1976
2016
|
}
|
|
1977
2017
|
function emitSmoke(core, fire, radius, dt) {
|
|
1978
2018
|
const random = fire.rng;
|
|
1979
|
-
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
|
|
2019
|
+
fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
|
|
1980
2020
|
while (fire.smokeAcc >= 1 && core.layers.smoke) {
|
|
1981
2021
|
fire.smokeAcc -= 1;
|
|
1982
2022
|
addPuff(core, random, {
|
|
1983
2023
|
x: fire.x + random.between(-radius, radius) * 0.5,
|
|
1984
|
-
y: fire.y + 0.6 + radius * 0.3,
|
|
2024
|
+
y: fire.y + fire.h + 0.6 + radius * 0.3,
|
|
1985
2025
|
z: fire.z + random.between(-radius, radius) * 0.5,
|
|
1986
2026
|
vy: random.between(0.8, 1.5),
|
|
1987
2027
|
s0: 0.25,
|
|
@@ -2003,7 +2043,7 @@ var GameVfx = (() => {
|
|
|
2003
2043
|
if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
|
|
2004
2044
|
addSpark(core, {
|
|
2005
2045
|
x: fire.x + random.between(-radius, radius) * 0.6,
|
|
2006
|
-
y: fire.y + 0.4,
|
|
2046
|
+
y: fire.y + 0.4 + heightOf(fire),
|
|
2007
2047
|
z: fire.z + random.between(-radius, radius) * 0.6,
|
|
2008
2048
|
vx: random.between(-0.4, 0.4),
|
|
2009
2049
|
vy: random.between(1.5, 3.2),
|
|
@@ -2027,6 +2067,10 @@ var GameVfx = (() => {
|
|
|
2027
2067
|
fire.x = point.x + fire.fx;
|
|
2028
2068
|
fire.y = point.y + fire.fy;
|
|
2029
2069
|
fire.z = point.z + fire.fz;
|
|
2070
|
+
if (isBody(fire.follow)) {
|
|
2071
|
+
fire.r = fire.follow.radius;
|
|
2072
|
+
fire.h = fire.follow.height;
|
|
2073
|
+
}
|
|
2030
2074
|
}
|
|
2031
2075
|
const radius = fire.grow ? lerp(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
|
|
2032
2076
|
fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
|
|
@@ -2101,6 +2145,7 @@ var GameVfx = (() => {
|
|
|
2101
2145
|
var QUALITY = { $: "quality" };
|
|
2102
2146
|
var FRESH = { $: "fresh" };
|
|
2103
2147
|
var DIRECTION = { $: "direction" };
|
|
2148
|
+
var NORMAL = { $: "normal" };
|
|
2104
2149
|
var CAMERA_POSITION = { $: "cameraPosition" };
|
|
2105
2150
|
|
|
2106
2151
|
// src/effects/steps.ts
|
|
@@ -2656,7 +2701,7 @@ var GameVfx = (() => {
|
|
|
2656
2701
|
var TIP2 = [-0.8, 1.38, 3.4 - 0.78];
|
|
2657
2702
|
var PORT2 = [-0.76, 1.4, 3.32];
|
|
2658
2703
|
var FORWARD3 = [0, 0, -1];
|
|
2659
|
-
var
|
|
2704
|
+
var NORMAL2 = [0, 0, 1];
|
|
2660
2705
|
var WALL_Z2 = -4.45;
|
|
2661
2706
|
var SHOTS = [[0, 0.45, 0.9], [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0], [0]];
|
|
2662
2707
|
var SHOT_TIME = pick(pick(SHOTS, PARAM), INDEX);
|
|
@@ -2681,8 +2726,8 @@ var GameVfx = (() => {
|
|
|
2681
2726
|
set("target", [add(-0.8, rnd(-0.4, 0.4)), add(1.4, rnd(-0.3, 0.3)), WALL_Z2]),
|
|
2682
2727
|
when(
|
|
2683
2728
|
eq(PARAM, SHOTGUN),
|
|
2684
|
-
[repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2],
|
|
2685
|
-
[call2("impact", "concrete", variable("target"),
|
|
2729
|
+
[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))],
|
|
2730
|
+
[call2("impact", "concrete", variable("target"), NORMAL2, ite(eq(PARAM, BARRETT), 2, 1))]
|
|
2686
2731
|
),
|
|
2687
2732
|
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 })])
|
|
2688
2733
|
)
|
|
@@ -3240,6 +3285,8 @@ var GameVfx = (() => {
|
|
|
3240
3285
|
__publicField(this, "puddles", WORKSHOP_PUDDLES);
|
|
3241
3286
|
/** Replaces the puddle test (a game knows its own wet spots). */
|
|
3242
3287
|
__publicField(this, "puddleAt");
|
|
3288
|
+
/** 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. */
|
|
3289
|
+
__publicField(this, "coverTopAt");
|
|
3243
3290
|
}
|
|
3244
3291
|
/** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
|
|
3245
3292
|
init(count, wind) {
|
|
@@ -3285,6 +3332,13 @@ var GameVfx = (() => {
|
|
|
3285
3332
|
positions[o + 3] += slant;
|
|
3286
3333
|
positions[o + 1] -= fall;
|
|
3287
3334
|
positions[o + 4] -= fall;
|
|
3335
|
+
if (this.coverTopAt) {
|
|
3336
|
+
const top = this.coverTopAt(positions[o], positions[o + 2]);
|
|
3337
|
+
if (top !== void 0 && positions[o + 4] < top) {
|
|
3338
|
+
this.restart(o);
|
|
3339
|
+
continue;
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3288
3342
|
const ground = context.groundAt(positions[o], positions[o + 2]);
|
|
3289
3343
|
if (positions[o + 4] < ground) {
|
|
3290
3344
|
const x = positions[o];
|
|
@@ -3300,10 +3354,7 @@ var GameVfx = (() => {
|
|
|
3300
3354
|
}
|
|
3301
3355
|
}
|
|
3302
3356
|
}
|
|
3303
|
-
|
|
3304
|
-
const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
|
|
3305
|
-
const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
|
|
3306
|
-
this.set(o, nx, ny, nz);
|
|
3357
|
+
this.restart(o);
|
|
3307
3358
|
}
|
|
3308
3359
|
}
|
|
3309
3360
|
}
|
|
@@ -3311,6 +3362,13 @@ var GameVfx = (() => {
|
|
|
3311
3362
|
clear() {
|
|
3312
3363
|
this.on = false;
|
|
3313
3364
|
}
|
|
3365
|
+
restart(offset) {
|
|
3366
|
+
const { random } = this.engine;
|
|
3367
|
+
const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
|
|
3368
|
+
const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
|
|
3369
|
+
const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
|
|
3370
|
+
this.set(offset, nx, ny, nz);
|
|
3371
|
+
}
|
|
3314
3372
|
set(offset, x, y, z) {
|
|
3315
3373
|
const positions = this.positions;
|
|
3316
3374
|
positions[offset] = x;
|
|
@@ -3797,6 +3855,8 @@ var GameVfx = (() => {
|
|
|
3797
3855
|
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3798
3856
|
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3799
3857
|
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3858
|
+
var PIECES_DRAWN_VARIABLE = "piecesDrawn";
|
|
3859
|
+
var standIns = (...steps) => when(not(variable(PIECES_DRAWN_VARIABLE)), steps);
|
|
3800
3860
|
var FAMILIES = {
|
|
3801
3861
|
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3802
3862
|
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
@@ -3843,7 +3903,7 @@ var GameVfx = (() => {
|
|
|
3843
3903
|
...sparks(look, 14),
|
|
3844
3904
|
...glints(look, 20),
|
|
3845
3905
|
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 }),
|
|
3846
|
-
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 })),
|
|
3906
|
+
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 }))),
|
|
3847
3907
|
repeat(
|
|
3848
3908
|
scaled(Math.round(60 * look.cloud)),
|
|
3849
3909
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
@@ -3875,8 +3935,10 @@ var GameVfx = (() => {
|
|
|
3875
3935
|
timeline: [
|
|
3876
3936
|
screen({ add: { shake: 0.45 } }),
|
|
3877
3937
|
...sparks(look, 20),
|
|
3878
|
-
|
|
3879
|
-
|
|
3938
|
+
standIns(
|
|
3939
|
+
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 })),
|
|
3940
|
+
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 }))
|
|
3941
|
+
),
|
|
3880
3942
|
repeat(
|
|
3881
3943
|
scaled(Math.round(70 * look.cloud)),
|
|
3882
3944
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
@@ -3916,7 +3978,6 @@ var GameVfx = (() => {
|
|
|
3916
3978
|
];
|
|
3917
3979
|
|
|
3918
3980
|
// src/effects/events.ts
|
|
3919
|
-
var FACING5 = [0, 0, 1];
|
|
3920
3981
|
var ORIGIN2 = [0, 0, 0];
|
|
3921
3982
|
var FORWARD4 = [0, 0, -1];
|
|
3922
3983
|
var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
|
|
@@ -3926,7 +3987,7 @@ var GameVfx = (() => {
|
|
|
3926
3987
|
team: "weapons",
|
|
3927
3988
|
budget: { particles: 40, decals: 1 },
|
|
3928
3989
|
loop: 2,
|
|
3929
|
-
timeline: [call2("impact", material, ORIGIN2,
|
|
3990
|
+
timeline: [call2("impact", material, ORIGIN2, NORMAL, 1, 0)]
|
|
3930
3991
|
});
|
|
3931
3992
|
var muzzleEffect = (weapon) => ({
|
|
3932
3993
|
id: `muzzle_${weapon}`,
|
|
@@ -4132,13 +4193,25 @@ var GameVfx = (() => {
|
|
|
4132
4193
|
|
|
4133
4194
|
// src/effects/vehicles/game-effects.ts
|
|
4134
4195
|
var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
|
|
4196
|
+
var BODYWORK_IMPACT = {
|
|
4197
|
+
id: "impact_bodywork",
|
|
4198
|
+
pageId: "vehicle:impact_bodywork",
|
|
4199
|
+
team: "vehicles",
|
|
4200
|
+
budget: { particles: 80, debris: 20, lights: 1 },
|
|
4201
|
+
loop: 2,
|
|
4202
|
+
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4203
|
+
};
|
|
4135
4204
|
var VEHICLE_EFFECTS = [
|
|
4205
|
+
BODYWORK_IMPACT,
|
|
4136
4206
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4137
4207
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4138
4208
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
4139
4209
|
aliasOf(ENGINE_SMOKE, "vehicle_exhaust", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 0 }, loop: 0.5 }),
|
|
4140
|
-
/**
|
|
4141
|
-
|
|
4210
|
+
/**
|
|
4211
|
+
* 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
|
|
4212
|
+
* 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.
|
|
4213
|
+
*/
|
|
4214
|
+
aliasOf(FUEL_LEAK_ONLY, "vehicle_leak", { anchor: TANK, timeline: [] }),
|
|
4142
4215
|
/** 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. */
|
|
4143
4216
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
4144
4217
|
];
|
|
@@ -4876,6 +4949,48 @@ var GameVfx = (() => {
|
|
|
4876
4949
|
}
|
|
4877
4950
|
}
|
|
4878
4951
|
|
|
4952
|
+
// src/effects/builders/bodywork.ts
|
|
4953
|
+
var PISTOL_BORE = 9e-3;
|
|
4954
|
+
var BARE_STEEL = 11778236;
|
|
4955
|
+
var DEFAULT_PAINT = 9147290;
|
|
4956
|
+
var DEFAULT_DIRECTION = [0, 0, -1];
|
|
4957
|
+
var MAX_SCALE = 3;
|
|
4958
|
+
var MIN_SCALE = 0.6;
|
|
4959
|
+
function reflected(direction, normal) {
|
|
4960
|
+
const along = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
4961
|
+
const out = [direction[0] - 2 * along * normal[0], direction[1] - 2 * along * normal[1], direction[2] - 2 * along * normal[2]];
|
|
4962
|
+
const length = Math.hypot(out[0], out[1], out[2]);
|
|
4963
|
+
if (length < 1e-6 || Math.abs(along) > 0.98) return normal;
|
|
4964
|
+
return [out[0] / length, out[1] / length, out[2] / length];
|
|
4965
|
+
}
|
|
4966
|
+
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
4967
|
+
function bodyworkHitOf(values) {
|
|
4968
|
+
const raw = Array.isArray(values.direction) ? values.direction : [];
|
|
4969
|
+
const direction = raw.length === 3 && raw.every((entry) => typeof entry === "number" && Number.isFinite(entry)) ? [raw[0], raw[1], raw[2]] : DEFAULT_DIRECTION;
|
|
4970
|
+
return { direction, bore: numberOr(values.bore, PISTOL_BORE), paint: numberOr(values.paint, DEFAULT_PAINT), metal: numberOr(values.metal, BARE_STEEL) };
|
|
4971
|
+
}
|
|
4972
|
+
function bodyworkScale(bore) {
|
|
4973
|
+
return Math.min(MAX_SCALE, Math.max(MIN_SCALE, bore / PISTOL_BORE));
|
|
4974
|
+
}
|
|
4975
|
+
function bodyworkImpact(engine, point, normal, hit) {
|
|
4976
|
+
const scale = bodyworkScale(hit.bore);
|
|
4977
|
+
const off = reflected(hit.direction, normal);
|
|
4978
|
+
if (engine.quality < 2) {
|
|
4979
|
+
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 });
|
|
4980
|
+
engine.burst("add", 2, { p: plusScaled(point, normal, 0.01), size: [0.06 * scale, 0.12 * scale], life: 0.05, c0: 16770736, fi: 0 });
|
|
4981
|
+
engine.flash([plusScaled(point, normal, 0.15), 16760432, 1.6 * scale, 0.05, 4]);
|
|
4982
|
+
}
|
|
4983
|
+
const flakes = engine.scaled(Math.round(5 * scale));
|
|
4984
|
+
for (let index = 0; index < flakes; index++) {
|
|
4985
|
+
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 });
|
|
4986
|
+
}
|
|
4987
|
+
const slivers = engine.scaled(Math.round(2 * scale));
|
|
4988
|
+
for (let index = 0; index < slivers; index++) {
|
|
4989
|
+
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 });
|
|
4990
|
+
}
|
|
4991
|
+
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 });
|
|
4992
|
+
}
|
|
4993
|
+
|
|
4879
4994
|
// src/effects/builders/fire.ts
|
|
4880
4995
|
var UP12 = [0, 1, 0];
|
|
4881
4996
|
var ZERO = [0, 0, 0];
|
|
@@ -5030,11 +5145,12 @@ var GameVfx = (() => {
|
|
|
5030
5145
|
casing: ({ engine }, [port, type]) => casing(engine, port, type),
|
|
5031
5146
|
chips: ({ engine }, [point, direction, count, spread]) => chips(engine, point, direction, count, spread),
|
|
5032
5147
|
spark_at: ({ engine }, [point, direction, count, spread]) => sparkAt(engine, point, direction, count, spread),
|
|
5033
|
-
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count)
|
|
5148
|
+
rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count),
|
|
5149
|
+
bodywork_impact: ({ engine }, [point, normal, direction, bore, paint, metal]) => bodyworkImpact(engine, point, normal, bodyworkHitOf({ direction, bore, paint, metal }))
|
|
5034
5150
|
};
|
|
5035
5151
|
|
|
5036
5152
|
// src/effects/instance.ts
|
|
5037
|
-
var
|
|
5153
|
+
var DEFAULT_DIRECTION2 = [0, 0, -1];
|
|
5038
5154
|
var DEFAULT_NORMAL = [0, 1, 0];
|
|
5039
5155
|
var SCREEN_FIELDS = {
|
|
5040
5156
|
shake: "shake",
|
|
@@ -5103,7 +5219,7 @@ var GameVfx = (() => {
|
|
|
5103
5219
|
return instance().fresh;
|
|
5104
5220
|
},
|
|
5105
5221
|
get direction() {
|
|
5106
|
-
return instance().setup.direction ??
|
|
5222
|
+
return instance().setup.direction ?? DEFAULT_DIRECTION2;
|
|
5107
5223
|
},
|
|
5108
5224
|
get normal() {
|
|
5109
5225
|
return instance().setup.normal ?? DEFAULT_NORMAL;
|
|
@@ -6900,6 +7016,71 @@ var GameVfx = (() => {
|
|
|
6900
7016
|
return out;
|
|
6901
7017
|
}
|
|
6902
7018
|
|
|
7019
|
+
// src/workshop/debris-contact.ts
|
|
7020
|
+
var CELL = 0.12;
|
|
7021
|
+
var OBSTACLE_BOUNCE = 0.3;
|
|
7022
|
+
var radiusOf = (piece) => Math.max(piece.sx, piece.sz) * 0.5;
|
|
7023
|
+
var thicknessOf = (piece) => Math.min(piece.sx, piece.sy, piece.sz);
|
|
7024
|
+
var cellKey = (i, k) => (i + 4096) * 8192 + (k + 4096);
|
|
7025
|
+
var RestingGrid = class {
|
|
7026
|
+
constructor() {
|
|
7027
|
+
__publicField(this, "cells", /* @__PURE__ */ new Map());
|
|
7028
|
+
}
|
|
7029
|
+
clear() {
|
|
7030
|
+
for (const list of this.cells.values()) list.length = 0;
|
|
7031
|
+
}
|
|
7032
|
+
rebuild(pieces) {
|
|
7033
|
+
this.clear();
|
|
7034
|
+
for (const piece of pieces) {
|
|
7035
|
+
if (!piece.on || !piece.rest) continue;
|
|
7036
|
+
const key = cellKey(Math.floor(piece.x / CELL), Math.floor(piece.z / CELL));
|
|
7037
|
+
const list = this.cells.get(key);
|
|
7038
|
+
if (list) list.push(piece);
|
|
7039
|
+
else this.cells.set(key, [piece]);
|
|
7040
|
+
}
|
|
7041
|
+
}
|
|
7042
|
+
/** 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. */
|
|
7043
|
+
supportUnder(piece) {
|
|
7044
|
+
const i = Math.floor(piece.x / CELL);
|
|
7045
|
+
const k = Math.floor(piece.z / CELL);
|
|
7046
|
+
const reach = radiusOf(piece);
|
|
7047
|
+
let top = -Infinity;
|
|
7048
|
+
for (let di = -1; di <= 1; di++) {
|
|
7049
|
+
for (let dk = -1; dk <= 1; dk++) {
|
|
7050
|
+
for (const other of this.cells.get(cellKey(i + di, k + dk)) ?? []) {
|
|
7051
|
+
if (other === piece) continue;
|
|
7052
|
+
if (Math.hypot(other.x - piece.x, other.z - piece.z) > reach + radiusOf(other)) continue;
|
|
7053
|
+
const otherTop = other.y + thicknessOf(other) * 0.5;
|
|
7054
|
+
if (otherTop <= piece.y + thicknessOf(piece) * 0.5) top = Math.max(top, otherTop + thicknessOf(piece) * 0.5);
|
|
7055
|
+
}
|
|
7056
|
+
}
|
|
7057
|
+
}
|
|
7058
|
+
return top;
|
|
7059
|
+
}
|
|
7060
|
+
};
|
|
7061
|
+
function pushOutOfObstacles(piece, obstacles) {
|
|
7062
|
+
let moved = false;
|
|
7063
|
+
for (const body of obstacles) {
|
|
7064
|
+
if (piece.y < body.bottom || piece.y > body.top) continue;
|
|
7065
|
+
const dx = piece.x - body.x;
|
|
7066
|
+
const dz = piece.z - body.z;
|
|
7067
|
+
const distance = Math.hypot(dx, dz);
|
|
7068
|
+
const reach = body.radius + radiusOf(piece);
|
|
7069
|
+
if (distance >= reach) continue;
|
|
7070
|
+
const nx = distance > 1e-6 ? dx / distance : 1;
|
|
7071
|
+
const nz = distance > 1e-6 ? dz / distance : 0;
|
|
7072
|
+
piece.x = body.x + nx * reach;
|
|
7073
|
+
piece.z = body.z + nz * reach;
|
|
7074
|
+
const into = piece.vx * nx + piece.vz * nz;
|
|
7075
|
+
if (into < 0) {
|
|
7076
|
+
piece.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
|
|
7077
|
+
piece.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
|
|
7078
|
+
}
|
|
7079
|
+
moved = true;
|
|
7080
|
+
}
|
|
7081
|
+
return moved;
|
|
7082
|
+
}
|
|
7083
|
+
|
|
6903
7084
|
// src/workshop/debris.ts
|
|
6904
7085
|
var CAPACITY = 500;
|
|
6905
7086
|
var GRAVITY2 = 9.8;
|
|
@@ -6921,6 +7102,7 @@ var GameVfx = (() => {
|
|
|
6921
7102
|
__publicField(this, "count", 0);
|
|
6922
7103
|
__publicField(this, "next", 0);
|
|
6923
7104
|
__publicField(this, "direction", { x: 0, y: 0, z: 0 });
|
|
7105
|
+
__publicField(this, "resting", new RestingGrid());
|
|
6924
7106
|
}
|
|
6925
7107
|
spawn(options) {
|
|
6926
7108
|
const random = this.context.random;
|
|
@@ -6958,14 +7140,21 @@ var GameVfx = (() => {
|
|
|
6958
7140
|
}
|
|
6959
7141
|
update(dt) {
|
|
6960
7142
|
this.count = 0;
|
|
7143
|
+
const contacts = this.context.debrisContacts;
|
|
7144
|
+
const obstacles = contacts?.obstacles() ?? [];
|
|
7145
|
+
let moving = false;
|
|
6961
7146
|
for (const piece of this.pieces) {
|
|
6962
7147
|
if (!piece.on) continue;
|
|
6963
|
-
this.count++;
|
|
6964
7148
|
piece.life -= dt;
|
|
6965
|
-
if (piece.life <= 0)
|
|
6966
|
-
|
|
6967
|
-
|
|
6968
|
-
|
|
7149
|
+
if (piece.life <= 0) piece.on = false;
|
|
7150
|
+
else if (!piece.rest) moving = true;
|
|
7151
|
+
}
|
|
7152
|
+
if (moving && contacts) this.resting.rebuild(this.pieces);
|
|
7153
|
+
else this.resting.clear();
|
|
7154
|
+
for (const piece of this.pieces) {
|
|
7155
|
+
if (!piece.on) continue;
|
|
7156
|
+
this.count++;
|
|
7157
|
+
if (obstacles.length > 0 && pushOutOfObstacles(piece, obstacles)) piece.rest = false;
|
|
6969
7158
|
if (!piece.rest) this.move(piece, dt);
|
|
6970
7159
|
}
|
|
6971
7160
|
}
|
|
@@ -6981,7 +7170,7 @@ var GameVfx = (() => {
|
|
|
6981
7170
|
piece.rx += piece.ax * dt;
|
|
6982
7171
|
piece.ry += piece.ay * dt;
|
|
6983
7172
|
piece.rz += piece.az * dt;
|
|
6984
|
-
const groundHeight = this.context.groundAt(piece.x, piece.z) + Math.min(piece.sx, piece.sy, piece.sz) * 0.5;
|
|
7173
|
+
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));
|
|
6985
7174
|
if (piece.y >= groundHeight) return;
|
|
6986
7175
|
piece.y = groundHeight;
|
|
6987
7176
|
piece.vy *= -piece.bounce;
|
|
@@ -7657,6 +7846,14 @@ var GameVfx = (() => {
|
|
|
7657
7846
|
this.decals = new DecalPool(this.context);
|
|
7658
7847
|
this.lights = new FlashLightPool(this.context);
|
|
7659
7848
|
}
|
|
7849
|
+
/**
|
|
7850
|
+
* 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
|
|
7851
|
+
* upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
|
|
7852
|
+
*/
|
|
7853
|
+
setDebrisContacts(obstacles) {
|
|
7854
|
+
if (obstacles) this.context.debrisContacts = { obstacles };
|
|
7855
|
+
else delete this.context.debrisContacts;
|
|
7856
|
+
}
|
|
7660
7857
|
get random() {
|
|
7661
7858
|
return this.context.random;
|
|
7662
7859
|
}
|
|
@@ -7747,7 +7944,9 @@ var GameVfx = (() => {
|
|
|
7747
7944
|
if (this.placement) {
|
|
7748
7945
|
const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
|
|
7749
7946
|
const options = recipe[5];
|
|
7750
|
-
|
|
7947
|
+
const normal = options?.n ? this.turn(options.n) : void 0;
|
|
7948
|
+
const onFloor = !normal;
|
|
7949
|
+
args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
|
|
7751
7950
|
}
|
|
7752
7951
|
this.context.trace?.("decal", args);
|
|
7753
7952
|
this.decals.add(args[0], args[1], args[2], args[3], args[4], args[5]);
|
|
@@ -7929,6 +8128,21 @@ var GameVfx = (() => {
|
|
|
7929
8128
|
return {
|
|
7930
8129
|
hostGroundAt: options.groundAt,
|
|
7931
8130
|
play(id, point, playOptions = {}) {
|
|
8131
|
+
if (id === "volumetric_fire") {
|
|
8132
|
+
const values = playOptions.values;
|
|
8133
|
+
const handle = ++handles.next;
|
|
8134
|
+
addFire(core, streamOf(playOptions.seed), {
|
|
8135
|
+
x: point[0],
|
|
8136
|
+
y: point[1],
|
|
8137
|
+
z: point[2],
|
|
8138
|
+
r: values?.radius ?? 0.55,
|
|
8139
|
+
life: values?.life ?? 24,
|
|
8140
|
+
...values?.rate !== void 0 ? { rate: values.rate } : {},
|
|
8141
|
+
...values?.smoke !== void 0 ? { smoke: values.smoke } : {},
|
|
8142
|
+
...values?.smokeColor !== void 0 ? { color: hexToLinearRgb(values.smokeColor) } : {}
|
|
8143
|
+
}, handle);
|
|
8144
|
+
return handle;
|
|
8145
|
+
}
|
|
7932
8146
|
if (!(id in effects)) return null;
|
|
7933
8147
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7934
8148
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
@@ -7945,7 +8159,7 @@ var GameVfx = (() => {
|
|
|
7945
8159
|
sprites: () => spriteSystem,
|
|
7946
8160
|
workshop,
|
|
7947
8161
|
peekWorkshop: () => engine,
|
|
7948
|
-
effectIds: () => Object.keys(effects),
|
|
8162
|
+
effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
|
|
7949
8163
|
explosion(id, point, explosionOptions = {}) {
|
|
7950
8164
|
const base = definitionOf(id);
|
|
7951
8165
|
if (!base) return null;
|
|
@@ -7960,10 +8174,11 @@ var GameVfx = (() => {
|
|
|
7960
8174
|
},
|
|
7961
8175
|
fire(fireOptions) {
|
|
7962
8176
|
const handle = ++handles.next;
|
|
7963
|
-
const { point, offset, seed, radius, smokeColor, ...rest } = fireOptions;
|
|
8177
|
+
const { point, offset, seed, radius, height, smokeColor, ...rest } = fireOptions;
|
|
7964
8178
|
addFire(core, streamOf(seed), {
|
|
7965
8179
|
...rest,
|
|
7966
8180
|
r: radius,
|
|
8181
|
+
...height !== void 0 ? { h: height } : {},
|
|
7967
8182
|
x: point[0],
|
|
7968
8183
|
y: point[1],
|
|
7969
8184
|
z: point[2],
|