@adatechnology/game-vfx 0.5.0 → 0.7.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/README.md +11 -0
- package/dist/index.d.ts +94 -2
- package/dist/index.global.js +378 -114
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +378 -114
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/dist/index.global.js
CHANGED
|
@@ -32,6 +32,7 @@ var GameVfx = (() => {
|
|
|
32
32
|
EffectCamera: () => EffectCamera,
|
|
33
33
|
EffectInstance: () => EffectInstance,
|
|
34
34
|
EffectRunner: () => EffectRunner,
|
|
35
|
+
Enclosures: () => Enclosures,
|
|
35
36
|
GAME_EFFECTS: () => GAME_EFFECTS,
|
|
36
37
|
LOD_GAME: () => LOD_GAME,
|
|
37
38
|
LOD_LAB: () => LOD_LAB,
|
|
@@ -72,6 +73,7 @@ var GameVfx = (() => {
|
|
|
72
73
|
patchExplosions: () => patchExplosions,
|
|
73
74
|
patchSpriteKinds: () => patchSpriteKinds,
|
|
74
75
|
resolveStrings: () => resolveStrings,
|
|
76
|
+
slideAlong: () => slideAlong,
|
|
75
77
|
streamFor: () => streamFor,
|
|
76
78
|
updateScreen: () => updateScreen,
|
|
77
79
|
workshopGround: () => workshopGround
|
|
@@ -1395,12 +1397,262 @@ var GameVfx = (() => {
|
|
|
1395
1397
|
}
|
|
1396
1398
|
}
|
|
1397
1399
|
|
|
1400
|
+
// src/random.ts
|
|
1401
|
+
var LEHMER_MULTIPLIER = 16807;
|
|
1402
|
+
var LEHMER_MODULUS = 2147483647;
|
|
1403
|
+
var LCG_MULTIPLIER = 1664525;
|
|
1404
|
+
var LCG_INCREMENT = 1013904223;
|
|
1405
|
+
var LCG_RANGE = 4294967296;
|
|
1406
|
+
var HASH_MIX = 2654435761;
|
|
1407
|
+
function normalizeLehmerSeed(seed) {
|
|
1408
|
+
const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
|
|
1409
|
+
return whole === 0 ? 1 : whole;
|
|
1410
|
+
}
|
|
1411
|
+
function lehmer(seed) {
|
|
1412
|
+
let state = normalizeLehmerSeed(seed);
|
|
1413
|
+
const next = () => {
|
|
1414
|
+
state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
|
|
1415
|
+
return (state - 1) / (LEHMER_MODULUS - 1);
|
|
1416
|
+
};
|
|
1417
|
+
return {
|
|
1418
|
+
next,
|
|
1419
|
+
between: (min2, max2) => min2 + (max2 - min2) * next(),
|
|
1420
|
+
direction(out) {
|
|
1421
|
+
const up = next() * 2 - 1;
|
|
1422
|
+
const angle = next() * Math.PI * 2;
|
|
1423
|
+
const ring2 = Math.sqrt(1 - up * up);
|
|
1424
|
+
out.x = ring2 * Math.cos(angle);
|
|
1425
|
+
out.y = up;
|
|
1426
|
+
out.z = ring2 * Math.sin(angle);
|
|
1427
|
+
return out;
|
|
1428
|
+
},
|
|
1429
|
+
get state() {
|
|
1430
|
+
return state;
|
|
1431
|
+
}
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
function lcg(seed) {
|
|
1435
|
+
let state = seed >>> 0;
|
|
1436
|
+
const next = () => {
|
|
1437
|
+
state = Math.imul(state, LCG_MULTIPLIER) + LCG_INCREMENT >>> 0;
|
|
1438
|
+
return state / LCG_RANGE;
|
|
1439
|
+
};
|
|
1440
|
+
return {
|
|
1441
|
+
next,
|
|
1442
|
+
between: (min2, max2) => min2 + (max2 - min2) * next(),
|
|
1443
|
+
direction(out) {
|
|
1444
|
+
const up = next() * 2 - 1;
|
|
1445
|
+
const angle = next() * Math.PI * 2;
|
|
1446
|
+
const ring2 = Math.sqrt(1 - up * up);
|
|
1447
|
+
out.x = ring2 * Math.cos(angle);
|
|
1448
|
+
out.y = up;
|
|
1449
|
+
out.z = ring2 * Math.sin(angle);
|
|
1450
|
+
return out;
|
|
1451
|
+
},
|
|
1452
|
+
get state() {
|
|
1453
|
+
return state;
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
function mixEventSeed(eventSeed) {
|
|
1458
|
+
let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
|
|
1459
|
+
mixed ^= mixed >>> 13;
|
|
1460
|
+
mixed = Math.imul(mixed, 3266489909);
|
|
1461
|
+
mixed ^= mixed >>> 16;
|
|
1462
|
+
return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
|
|
1463
|
+
}
|
|
1464
|
+
function streamFor(eventSeed) {
|
|
1465
|
+
return lehmer(mixEventSeed(eventSeed));
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
// src/enclosures.ts
|
|
1469
|
+
var SKIN = 5e-3;
|
|
1470
|
+
var MAX_PAD = 0.45;
|
|
1471
|
+
function rotation(q) {
|
|
1472
|
+
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
1473
|
+
const n = Math.hypot(x, y, z, w) || 1;
|
|
1474
|
+
const qx = x / n;
|
|
1475
|
+
const qy = y / n;
|
|
1476
|
+
const qz = z / n;
|
|
1477
|
+
const qw = w / n;
|
|
1478
|
+
return new Float64Array([
|
|
1479
|
+
1 - 2 * (qy * qy + qz * qz),
|
|
1480
|
+
2 * (qx * qy - qz * qw),
|
|
1481
|
+
2 * (qx * qz + qy * qw),
|
|
1482
|
+
2 * (qx * qy + qz * qw),
|
|
1483
|
+
1 - 2 * (qx * qx + qz * qz),
|
|
1484
|
+
2 * (qy * qz - qx * qw),
|
|
1485
|
+
2 * (qx * qz - qy * qw),
|
|
1486
|
+
2 * (qy * qz + qx * qw),
|
|
1487
|
+
1 - 2 * (qx * qx + qy * qy)
|
|
1488
|
+
]);
|
|
1489
|
+
}
|
|
1490
|
+
var Enclosures = class {
|
|
1491
|
+
constructor(seed = 20973) {
|
|
1492
|
+
__publicField(this, "spaces", /* @__PURE__ */ new Map());
|
|
1493
|
+
__publicField(this, "list", []);
|
|
1494
|
+
__publicField(this, "random");
|
|
1495
|
+
__publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1496
|
+
__publicField(this, "l0", new Float64Array(3));
|
|
1497
|
+
__publicField(this, "l1", new Float64Array(3));
|
|
1498
|
+
__publicField(this, "q", new Float64Array(3));
|
|
1499
|
+
this.random = lehmer(seed);
|
|
1500
|
+
}
|
|
1501
|
+
get empty() {
|
|
1502
|
+
return this.list.length === 0;
|
|
1503
|
+
}
|
|
1504
|
+
get size() {
|
|
1505
|
+
return this.list.length;
|
|
1506
|
+
}
|
|
1507
|
+
/** Declares, moves or (with `null`) ends the space `id`. */
|
|
1508
|
+
set(id, enclosure) {
|
|
1509
|
+
if (!enclosure) {
|
|
1510
|
+
if (this.spaces.delete(id)) this.list = [...this.spaces.values()];
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
const [hx, hy, hz] = enclosure.halfSize;
|
|
1514
|
+
const space = {
|
|
1515
|
+
cx: enclosure.center[0],
|
|
1516
|
+
cy: enclosure.center[1],
|
|
1517
|
+
cz: enclosure.center[2],
|
|
1518
|
+
hx: Math.abs(hx),
|
|
1519
|
+
hy: Math.abs(hy),
|
|
1520
|
+
hz: Math.abs(hz),
|
|
1521
|
+
r: rotation(enclosure.orientation),
|
|
1522
|
+
radius: Math.hypot(hx, hy, hz),
|
|
1523
|
+
openings: enclosure.openings ?? [],
|
|
1524
|
+
leak: Math.max(0, enclosure.leak ?? 0)
|
|
1525
|
+
};
|
|
1526
|
+
const old = this.spaces.get(id);
|
|
1527
|
+
this.spaces.set(id, space);
|
|
1528
|
+
const at3 = old ? this.list.indexOf(old) : -1;
|
|
1529
|
+
if (at3 >= 0) this.list[at3] = space;
|
|
1530
|
+
else this.list.push(space);
|
|
1531
|
+
}
|
|
1532
|
+
get(id) {
|
|
1533
|
+
const s = this.spaces.get(id);
|
|
1534
|
+
if (!s) return void 0;
|
|
1535
|
+
return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak };
|
|
1536
|
+
}
|
|
1537
|
+
ids() {
|
|
1538
|
+
return [...this.spaces.keys()];
|
|
1539
|
+
}
|
|
1540
|
+
clear() {
|
|
1541
|
+
this.spaces.clear();
|
|
1542
|
+
this.list = [];
|
|
1543
|
+
}
|
|
1544
|
+
/** Whether a point is inside any space (on the inside of its walls). */
|
|
1545
|
+
inside(x, y, z) {
|
|
1546
|
+
for (const s of this.list) {
|
|
1547
|
+
this.toLocal(s, x, y, z, this.l0);
|
|
1548
|
+
if (Math.abs(this.l0[0]) <= s.hx && Math.abs(this.l0[1]) <= s.hy && Math.abs(this.l0[2]) <= s.hz) return true;
|
|
1549
|
+
}
|
|
1550
|
+
return false;
|
|
1551
|
+
}
|
|
1552
|
+
toLocal(s, x, y, z, out) {
|
|
1553
|
+
const dx = x - s.cx;
|
|
1554
|
+
const dy = y - s.cy;
|
|
1555
|
+
const dz = z - s.cz;
|
|
1556
|
+
const r = s.r;
|
|
1557
|
+
out[0] = r[0] * dx + r[3] * dy + r[6] * dz;
|
|
1558
|
+
out[1] = r[1] * dx + r[4] * dy + r[7] * dz;
|
|
1559
|
+
out[2] = r[2] * dx + r[5] * dy + r[8] * dz;
|
|
1560
|
+
}
|
|
1561
|
+
/** Passes at `rate` per second. */
|
|
1562
|
+
chance(rate, dt) {
|
|
1563
|
+
return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1564
|
+
}
|
|
1565
|
+
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1566
|
+
through(s, q, dt) {
|
|
1567
|
+
for (const o of s.openings) {
|
|
1568
|
+
if (Math.abs(q[0] - o.center[0]) > o.halfSize[0] || Math.abs(q[1] - o.center[1]) > o.halfSize[1] || Math.abs(q[2] - o.center[2]) > o.halfSize[2]) continue;
|
|
1569
|
+
if (o.rate === void 0 || this.chance(o.rate, dt)) return true;
|
|
1570
|
+
}
|
|
1571
|
+
return this.chance(s.leak, dt);
|
|
1572
|
+
}
|
|
1573
|
+
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1574
|
+
const list = this.list;
|
|
1575
|
+
if (list.length === 0) return false;
|
|
1576
|
+
const p = Math.min(Math.max(0, pad), MAX_PAD);
|
|
1577
|
+
const l0 = this.l0;
|
|
1578
|
+
const l1 = this.l1;
|
|
1579
|
+
const q = this.q;
|
|
1580
|
+
for (const s of list) {
|
|
1581
|
+
const reach = s.radius + p + 0.05;
|
|
1582
|
+
const dx = x1 - s.cx;
|
|
1583
|
+
const dy = y1 - s.cy;
|
|
1584
|
+
const dz = z1 - s.cz;
|
|
1585
|
+
if (dx * dx + dy * dy + dz * dz > reach * reach) {
|
|
1586
|
+
const ex = x0 - s.cx;
|
|
1587
|
+
const ey = y0 - s.cy;
|
|
1588
|
+
const ez = z0 - s.cz;
|
|
1589
|
+
if (ex * ex + ey * ey + ez * ez > reach * reach) continue;
|
|
1590
|
+
}
|
|
1591
|
+
this.toLocal(s, x0, y0, z0, l0);
|
|
1592
|
+
this.toLocal(s, x1, y1, z1, l1);
|
|
1593
|
+
const h = [s.hx, s.hy, s.hz];
|
|
1594
|
+
const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
|
|
1595
|
+
let axis2 = 0;
|
|
1596
|
+
let sign = 1;
|
|
1597
|
+
if (in0) {
|
|
1598
|
+
if (Math.abs(l1[0]) <= s.hx && Math.abs(l1[1]) <= s.hy && Math.abs(l1[2]) <= s.hz) continue;
|
|
1599
|
+
for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
|
|
1600
|
+
if (this.through(s, q, dt)) continue;
|
|
1601
|
+
let worst = -Infinity;
|
|
1602
|
+
for (let a = 0; a < 3; a++) {
|
|
1603
|
+
const over = Math.abs(l1[a]) - h[a];
|
|
1604
|
+
if (over > worst) {
|
|
1605
|
+
worst = over;
|
|
1606
|
+
axis2 = a;
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
sign = l1[axis2] < 0 ? -1 : 1;
|
|
1610
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN, Math.max(-(h[a] - SKIN), l1[a]));
|
|
1611
|
+
sign = -sign;
|
|
1612
|
+
} else {
|
|
1613
|
+
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
1614
|
+
const bound = padded0 ? 0 : p;
|
|
1615
|
+
if (!(Math.abs(l1[0]) <= s.hx + bound && Math.abs(l1[1]) <= s.hy + bound && Math.abs(l1[2]) <= s.hz + bound)) continue;
|
|
1616
|
+
for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
|
|
1617
|
+
if (this.through(s, q, dt)) continue;
|
|
1618
|
+
let worst = -Infinity;
|
|
1619
|
+
for (let a = 0; a < 3; a++) {
|
|
1620
|
+
const over = Math.abs(l0[a]) - (h[a] + bound);
|
|
1621
|
+
if (over > worst) {
|
|
1622
|
+
worst = over;
|
|
1623
|
+
axis2 = a;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1627
|
+
l1[axis2] = sign * (h[axis2] + bound + SKIN);
|
|
1628
|
+
}
|
|
1629
|
+
const r = s.r;
|
|
1630
|
+
const out = this.out;
|
|
1631
|
+
out.x = s.cx + r[0] * l1[0] + r[1] * l1[1] + r[2] * l1[2];
|
|
1632
|
+
out.y = s.cy + r[3] * l1[0] + r[4] * l1[1] + r[5] * l1[2];
|
|
1633
|
+
out.z = s.cz + r[6] * l1[0] + r[7] * l1[1] + r[8] * l1[2];
|
|
1634
|
+
out.nx = r[axis2] * sign;
|
|
1635
|
+
out.ny = r[3 + axis2] * sign;
|
|
1636
|
+
out.nz = r[6 + axis2] * sign;
|
|
1637
|
+
return true;
|
|
1638
|
+
}
|
|
1639
|
+
return false;
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
function slideAlong(out, vx2, vy2, vz2) {
|
|
1643
|
+
const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
|
|
1644
|
+
if (into >= 0) return [vx2, vy2, vz2];
|
|
1645
|
+
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1398
1648
|
// src/pools/puffs.ts
|
|
1399
1649
|
var FLOOR_FRACTION = 0.4;
|
|
1400
1650
|
var FLOOR_BOUNCE = -0.2;
|
|
1401
1651
|
var ARRIVAL_FRAME = 30;
|
|
1402
1652
|
var ARRIVAL_BASE = 0.3;
|
|
1403
1653
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1654
|
+
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1655
|
+
var PAD_OF_SIZE = 0.35;
|
|
1404
1656
|
function createPuffPool(capacity) {
|
|
1405
1657
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1406
1658
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1495,13 +1747,24 @@ var GameVfx = (() => {
|
|
|
1495
1747
|
if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
|
|
1496
1748
|
}
|
|
1497
1749
|
}
|
|
1498
|
-
function updatePuffs(pool, dt, wind) {
|
|
1750
|
+
function updatePuffs(pool, dt, wind, confiner) {
|
|
1499
1751
|
pool.compact(ageOrKeep2, dt);
|
|
1752
|
+
const confining = confiner !== void 0 && !confiner.empty;
|
|
1500
1753
|
for (const puff3 of pool.items) {
|
|
1501
1754
|
const age = puff3.t / puff3.life;
|
|
1502
1755
|
const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
1756
|
+
const x0 = puff3.x;
|
|
1757
|
+
const y0 = puff3.y;
|
|
1758
|
+
const z0 = puff3.z;
|
|
1503
1759
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1504
1760
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1761
|
+
if (confining && CARRIED_KINDS[puff3.kind] && confiner.confine(x0, y0, z0, puff3.x, puff3.y, puff3.z, puff3.size * PAD_OF_SIZE, dt)) {
|
|
1762
|
+
const out = confiner.out;
|
|
1763
|
+
puff3.x = out.x;
|
|
1764
|
+
puff3.y = out.y;
|
|
1765
|
+
puff3.z = out.z;
|
|
1766
|
+
[puff3.vx, puff3.vy, puff3.vz] = slideAlong(out, puff3.vx, puff3.vy, puff3.vz);
|
|
1767
|
+
}
|
|
1505
1768
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1506
1769
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1507
1770
|
puff3.age = age;
|
|
@@ -2055,10 +2318,10 @@ var GameVfx = (() => {
|
|
|
2055
2318
|
};
|
|
2056
2319
|
|
|
2057
2320
|
// src/effects/props.ts
|
|
2058
|
-
function localToWorld(translation,
|
|
2321
|
+
function localToWorld(translation, rotation2, local2) {
|
|
2059
2322
|
const [x, y, z] = local2;
|
|
2060
|
-
const [a, c, e] = [Math.cos(
|
|
2061
|
-
const [b, d, f] = [Math.sin(
|
|
2323
|
+
const [a, c, e] = [Math.cos(rotation2[0]), Math.cos(rotation2[1]), Math.cos(rotation2[2])];
|
|
2324
|
+
const [b, d, f] = [Math.sin(rotation2[0]), Math.sin(rotation2[1]), Math.sin(rotation2[2])];
|
|
2062
2325
|
const [ae, af, be, bf] = [a * e, a * f, b * e, b * f];
|
|
2063
2326
|
return [
|
|
2064
2327
|
c * e * x + -c * f * y + d * z + translation[0],
|
|
@@ -2418,22 +2681,22 @@ var GameVfx = (() => {
|
|
|
2418
2681
|
};
|
|
2419
2682
|
|
|
2420
2683
|
// src/effects/vector-math.ts
|
|
2421
|
-
function normalized(
|
|
2422
|
-
const length = Math.sqrt(
|
|
2684
|
+
function normalized(vector2) {
|
|
2685
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
2423
2686
|
const inverse = 1 / length;
|
|
2424
|
-
return [
|
|
2687
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
2425
2688
|
}
|
|
2426
|
-
function plus(
|
|
2427
|
-
return [
|
|
2689
|
+
function plus(vector2, x, y, z) {
|
|
2690
|
+
return [vector2[0] + x, vector2[1] + y, vector2[2] + z];
|
|
2428
2691
|
}
|
|
2429
|
-
function scaledBy(
|
|
2430
|
-
return [
|
|
2692
|
+
function scaledBy(vector2, factor) {
|
|
2693
|
+
return [vector2[0] * factor, vector2[1] * factor, vector2[2] * factor];
|
|
2431
2694
|
}
|
|
2432
|
-
function plusScaled(
|
|
2433
|
-
return [
|
|
2695
|
+
function plusScaled(vector2, direction, factor) {
|
|
2696
|
+
return [vector2[0] + direction[0] * factor, vector2[1] + direction[1] * factor, vector2[2] + direction[2] * factor];
|
|
2434
2697
|
}
|
|
2435
|
-
function negated(
|
|
2436
|
-
return [-
|
|
2698
|
+
function negated(vector2) {
|
|
2699
|
+
return [-vector2[0], -vector2[1], -vector2[2]];
|
|
2437
2700
|
}
|
|
2438
2701
|
|
|
2439
2702
|
// src/effects/destruction/door-stages.ts
|
|
@@ -3802,10 +4065,35 @@ var GameVfx = (() => {
|
|
|
3802
4065
|
aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
|
|
3803
4066
|
];
|
|
3804
4067
|
|
|
4068
|
+
// src/effects/particles/single-particles.ts
|
|
4069
|
+
var vector = [variable("vx"), variable("vy"), variable("vz")];
|
|
4070
|
+
var range = (name) => [variable(name), variable(name)];
|
|
4071
|
+
var singleParticle = (id, system) => ({
|
|
4072
|
+
id,
|
|
4073
|
+
pageId: `particle:${id}`,
|
|
4074
|
+
team: "world",
|
|
4075
|
+
budget: { particles: 1, lights: 0 },
|
|
4076
|
+
loop: 1e-3,
|
|
4077
|
+
timeline: [
|
|
4078
|
+
spawn(system, {
|
|
4079
|
+
p: [0, 0, 0],
|
|
4080
|
+
v: vector,
|
|
4081
|
+
life: range("life"),
|
|
4082
|
+
size: range("size"),
|
|
4083
|
+
grow: variable("grow"),
|
|
4084
|
+
c0: variable("color"),
|
|
4085
|
+
a: variable("alpha"),
|
|
4086
|
+
g: variable("gravity"),
|
|
4087
|
+
drag: variable("drag")
|
|
4088
|
+
})
|
|
4089
|
+
]
|
|
4090
|
+
});
|
|
4091
|
+
var SINGLE_PARTICLE_EFFECTS = [singleParticle("particle_puff", "normal"), singleParticle("particle_glow", "add"), singleParticle("particle_streak", "streak")];
|
|
4092
|
+
|
|
3805
4093
|
// src/effects/catalog.ts
|
|
3806
4094
|
var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
|
|
3807
4095
|
var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
|
|
3808
|
-
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
4096
|
+
var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS, ...SINGLE_PARTICLE_EFFECTS].map((effect) => [effect.id, effect])) };
|
|
3809
4097
|
function patchEffects(base, changes) {
|
|
3810
4098
|
const result = { ...base };
|
|
3811
4099
|
for (const [id, change] of Object.entries(changes)) {
|
|
@@ -3815,74 +4103,6 @@ var GameVfx = (() => {
|
|
|
3815
4103
|
return result;
|
|
3816
4104
|
}
|
|
3817
4105
|
|
|
3818
|
-
// src/random.ts
|
|
3819
|
-
var LEHMER_MULTIPLIER = 16807;
|
|
3820
|
-
var LEHMER_MODULUS = 2147483647;
|
|
3821
|
-
var LCG_MULTIPLIER = 1664525;
|
|
3822
|
-
var LCG_INCREMENT = 1013904223;
|
|
3823
|
-
var LCG_RANGE = 4294967296;
|
|
3824
|
-
var HASH_MIX = 2654435761;
|
|
3825
|
-
function normalizeLehmerSeed(seed) {
|
|
3826
|
-
const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
|
|
3827
|
-
return whole === 0 ? 1 : whole;
|
|
3828
|
-
}
|
|
3829
|
-
function lehmer(seed) {
|
|
3830
|
-
let state = normalizeLehmerSeed(seed);
|
|
3831
|
-
const next = () => {
|
|
3832
|
-
state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
|
|
3833
|
-
return (state - 1) / (LEHMER_MODULUS - 1);
|
|
3834
|
-
};
|
|
3835
|
-
return {
|
|
3836
|
-
next,
|
|
3837
|
-
between: (min2, max2) => min2 + (max2 - min2) * next(),
|
|
3838
|
-
direction(out) {
|
|
3839
|
-
const up = next() * 2 - 1;
|
|
3840
|
-
const angle = next() * Math.PI * 2;
|
|
3841
|
-
const ring2 = Math.sqrt(1 - up * up);
|
|
3842
|
-
out.x = ring2 * Math.cos(angle);
|
|
3843
|
-
out.y = up;
|
|
3844
|
-
out.z = ring2 * Math.sin(angle);
|
|
3845
|
-
return out;
|
|
3846
|
-
},
|
|
3847
|
-
get state() {
|
|
3848
|
-
return state;
|
|
3849
|
-
}
|
|
3850
|
-
};
|
|
3851
|
-
}
|
|
3852
|
-
function lcg(seed) {
|
|
3853
|
-
let state = seed >>> 0;
|
|
3854
|
-
const next = () => {
|
|
3855
|
-
state = Math.imul(state, LCG_MULTIPLIER) + LCG_INCREMENT >>> 0;
|
|
3856
|
-
return state / LCG_RANGE;
|
|
3857
|
-
};
|
|
3858
|
-
return {
|
|
3859
|
-
next,
|
|
3860
|
-
between: (min2, max2) => min2 + (max2 - min2) * next(),
|
|
3861
|
-
direction(out) {
|
|
3862
|
-
const up = next() * 2 - 1;
|
|
3863
|
-
const angle = next() * Math.PI * 2;
|
|
3864
|
-
const ring2 = Math.sqrt(1 - up * up);
|
|
3865
|
-
out.x = ring2 * Math.cos(angle);
|
|
3866
|
-
out.y = up;
|
|
3867
|
-
out.z = ring2 * Math.sin(angle);
|
|
3868
|
-
return out;
|
|
3869
|
-
},
|
|
3870
|
-
get state() {
|
|
3871
|
-
return state;
|
|
3872
|
-
}
|
|
3873
|
-
};
|
|
3874
|
-
}
|
|
3875
|
-
function mixEventSeed(eventSeed) {
|
|
3876
|
-
let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
|
|
3877
|
-
mixed ^= mixed >>> 13;
|
|
3878
|
-
mixed = Math.imul(mixed, 3266489909);
|
|
3879
|
-
mixed ^= mixed >>> 16;
|
|
3880
|
-
return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
|
|
3881
|
-
}
|
|
3882
|
-
function streamFor(eventSeed) {
|
|
3883
|
-
return lehmer(mixEventSeed(eventSeed));
|
|
3884
|
-
}
|
|
3885
|
-
|
|
3886
4106
|
// src/effects/builders/impact-table.ts
|
|
3887
4107
|
var TABLE = {
|
|
3888
4108
|
concrete: { dust: 9078138, chip: 7236195, spark: 2 },
|
|
@@ -4582,8 +4802,8 @@ var GameVfx = (() => {
|
|
|
4582
4802
|
var UP12 = [0, 1, 0];
|
|
4583
4803
|
var ZERO = [0, 0, 0];
|
|
4584
4804
|
var FULL_TURN_DRAWN = 6.283;
|
|
4585
|
-
function scaledSizes(
|
|
4586
|
-
return [
|
|
4805
|
+
function scaledSizes(range2, factor) {
|
|
4806
|
+
return [range2[0] * Math.sqrt(factor), range2[1] * Math.sqrt(factor)];
|
|
4587
4807
|
}
|
|
4588
4808
|
function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
|
|
4589
4809
|
const wind = options.wind ?? ZERO;
|
|
@@ -5233,8 +5453,8 @@ var GameVfx = (() => {
|
|
|
5233
5453
|
function addScorch(store, random, x, z, radius) {
|
|
5234
5454
|
const variant = Math.floor(random.next() * SCORCH_VARIANTS);
|
|
5235
5455
|
const lift = 0.03 + nextLift(store) * 1e-3;
|
|
5236
|
-
const
|
|
5237
|
-
store.add({ kind: "scorch", x, z, radius, variant, lift, rotation });
|
|
5456
|
+
const rotation2 = random.next() * 6;
|
|
5457
|
+
store.add({ kind: "scorch", x, z, radius, variant, lift, rotation: rotation2 });
|
|
5238
5458
|
}
|
|
5239
5459
|
function addRimRocks(store, ground, random, x, z, radius) {
|
|
5240
5460
|
const count = Math.round(6 + radius * 7);
|
|
@@ -5263,8 +5483,8 @@ var GameVfx = (() => {
|
|
|
5263
5483
|
function addCrater(store, ground, random, spec) {
|
|
5264
5484
|
ground?.dent(random, spec.x, spec.z, spec.radius, spec.depth);
|
|
5265
5485
|
if (!spec.marks) return;
|
|
5266
|
-
const
|
|
5267
|
-
store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation });
|
|
5486
|
+
const rotation2 = random.next() * 6;
|
|
5487
|
+
store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation: rotation2 });
|
|
5268
5488
|
addRimRocks(store, ground, random, spec.x, spec.z, spec.radius);
|
|
5269
5489
|
}
|
|
5270
5490
|
function addBloodSplat(store, ground, random, spec) {
|
|
@@ -5832,6 +6052,7 @@ var GameVfx = (() => {
|
|
|
5832
6052
|
}
|
|
5833
6053
|
|
|
5834
6054
|
// src/sprites/kind-pool.ts
|
|
6055
|
+
var PAD_OF_SIZE2 = 0.35;
|
|
5835
6056
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
5836
6057
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
5837
6058
|
function rgb(hex) {
|
|
@@ -5992,9 +6213,20 @@ var GameVfx = (() => {
|
|
|
5992
6213
|
vy2 *= k;
|
|
5993
6214
|
vz2 *= k;
|
|
5994
6215
|
}
|
|
5995
|
-
|
|
6216
|
+
let x = this.position[i3] + vx2 * dt;
|
|
5996
6217
|
let y = this.position[i3 + 1] + vy2 * dt;
|
|
5997
|
-
|
|
6218
|
+
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6219
|
+
const confiner = host.confiner;
|
|
6220
|
+
if (def.carried && confiner && !confiner.empty) {
|
|
6221
|
+
const pad = this.size0[i] * lerp4(1, def.grow, t) * PAD_OF_SIZE2;
|
|
6222
|
+
if (confiner.confine(this.position[i3], this.position[i3 + 1], this.position[i3 + 2], x, y, z, pad, dt)) {
|
|
6223
|
+
const out = confiner.out;
|
|
6224
|
+
x = out.x;
|
|
6225
|
+
y = out.y;
|
|
6226
|
+
z = out.z;
|
|
6227
|
+
[vx2, vy2, vz2] = slideAlong(out, vx2, vy2, vz2);
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
5998
6230
|
if (def.ground !== "none") {
|
|
5999
6231
|
const own = this.floor[i];
|
|
6000
6232
|
const gy = Number.isNaN(own) ? host.groundAt(x, z) + 5e-3 : own;
|
|
@@ -6082,7 +6314,8 @@ var GameVfx = (() => {
|
|
|
6082
6314
|
alpha: 0.35,
|
|
6083
6315
|
fadeIn: 0.15,
|
|
6084
6316
|
cone: 0.6,
|
|
6085
|
-
ground: "none"
|
|
6317
|
+
ground: "none",
|
|
6318
|
+
carried: true
|
|
6086
6319
|
},
|
|
6087
6320
|
sparks: {
|
|
6088
6321
|
id: "sparks",
|
|
@@ -6126,7 +6359,8 @@ var GameVfx = (() => {
|
|
|
6126
6359
|
alpha: 0.4,
|
|
6127
6360
|
fadeIn: 0.1,
|
|
6128
6361
|
cone: 0.4,
|
|
6129
|
-
ground: "none"
|
|
6362
|
+
ground: "none",
|
|
6363
|
+
carried: true
|
|
6130
6364
|
},
|
|
6131
6365
|
shards: {
|
|
6132
6366
|
id: "shards",
|
|
@@ -6284,7 +6518,8 @@ var GameVfx = (() => {
|
|
|
6284
6518
|
fadeIn: 0.1,
|
|
6285
6519
|
cone: 0.5,
|
|
6286
6520
|
ground: "stop",
|
|
6287
|
-
flutter: 0.6
|
|
6521
|
+
flutter: 0.6,
|
|
6522
|
+
carried: true
|
|
6288
6523
|
},
|
|
6289
6524
|
steam: {
|
|
6290
6525
|
id: "steam",
|
|
@@ -6306,7 +6541,8 @@ var GameVfx = (() => {
|
|
|
6306
6541
|
alpha: 0.35,
|
|
6307
6542
|
fadeIn: 0.15,
|
|
6308
6543
|
cone: 0.6,
|
|
6309
|
-
ground: "none"
|
|
6544
|
+
ground: "none",
|
|
6545
|
+
carried: true
|
|
6310
6546
|
},
|
|
6311
6547
|
flash: {
|
|
6312
6548
|
id: "flash",
|
|
@@ -6451,7 +6687,8 @@ var GameVfx = (() => {
|
|
|
6451
6687
|
const host = {
|
|
6452
6688
|
groundAt: this.options.groundAt,
|
|
6453
6689
|
gravity: this.options.gravity,
|
|
6454
|
-
land: (owner, x, y, z, color, tag) => this.listeners.get(owner)?.(x, y, z, color, tag)
|
|
6690
|
+
land: (owner, x, y, z, color, tag) => this.listeners.get(owner)?.(x, y, z, color, tag),
|
|
6691
|
+
...this.options.confiner ? { confiner: this.options.confiner } : {}
|
|
6455
6692
|
};
|
|
6456
6693
|
if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
|
|
6457
6694
|
if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
|
|
@@ -6466,9 +6703,9 @@ var GameVfx = (() => {
|
|
|
6466
6703
|
var TWO_PI_ROUNDED = 6.2832;
|
|
6467
6704
|
var WIDE_CONE = 3.1;
|
|
6468
6705
|
var UP13 = [0, 1, 0];
|
|
6469
|
-
function drawRange(random,
|
|
6470
|
-
if (Array.isArray(
|
|
6471
|
-
return
|
|
6706
|
+
function drawRange(random, range2) {
|
|
6707
|
+
if (Array.isArray(range2)) return random.between(range2[0], range2[1]);
|
|
6708
|
+
return range2 || 0;
|
|
6472
6709
|
}
|
|
6473
6710
|
function randomUnit(random, out) {
|
|
6474
6711
|
const up = random.next() * 2 - 1;
|
|
@@ -6663,8 +6900,8 @@ var GameVfx = (() => {
|
|
|
6663
6900
|
* Takes away the marks inside a box: world `center`, `half` extents along the axes of the world `rotation` (a quaternion, x y z w; none means the
|
|
6664
6901
|
* world axes). The surface they were on is gone (a brick came out of a wall with its bullet holes). Returns how many went.
|
|
6665
6902
|
*/
|
|
6666
|
-
clearInside(center, half,
|
|
6667
|
-
const qx = -
|
|
6903
|
+
clearInside(center, half, rotation2 = [0, 0, 0, 1]) {
|
|
6904
|
+
const qx = -rotation2[0], qy = -rotation2[1], qz = -rotation2[2], qw = rotation2[3];
|
|
6668
6905
|
let gone = 0;
|
|
6669
6906
|
for (const decal2 of this.decals) {
|
|
6670
6907
|
if (!decal2.on) continue;
|
|
@@ -6789,10 +7026,14 @@ var GameVfx = (() => {
|
|
|
6789
7026
|
var DEFAULT_FADE_IN = 0.1;
|
|
6790
7027
|
var FLOATS_PER_VECTOR = 3;
|
|
6791
7028
|
var BYTE_MAX2 = 255;
|
|
7029
|
+
var CARRIED_GRAVITY = 3;
|
|
7030
|
+
var PAD_OF_SIZE3 = 0.35;
|
|
6792
7031
|
var SpritePool = class {
|
|
6793
|
-
|
|
7032
|
+
/** `carried`: the normal-blend pool (smoke, dust, steam), whose light sprites go round the closed spaces; the additive one (flames, sparks) does not. */
|
|
7033
|
+
constructor(capacity, context, carried = false) {
|
|
6794
7034
|
__publicField(this, "capacity", capacity);
|
|
6795
7035
|
__publicField(this, "context", context);
|
|
7036
|
+
__publicField(this, "carried", carried);
|
|
6796
7037
|
__publicField(this, "count", 0);
|
|
6797
7038
|
__publicField(this, "position");
|
|
6798
7039
|
__publicField(this, "velocity");
|
|
@@ -6893,6 +7134,7 @@ var GameVfx = (() => {
|
|
|
6893
7134
|
}
|
|
6894
7135
|
update(dt, leaveDecal) {
|
|
6895
7136
|
const { position, velocity } = this;
|
|
7137
|
+
const confiner = this.context.confiner;
|
|
6896
7138
|
for (let index = this.count - 1; index >= 0; index--) {
|
|
6897
7139
|
this.life[index] -= dt;
|
|
6898
7140
|
if (this.life[index] <= 0) {
|
|
@@ -6906,9 +7148,25 @@ var GameVfx = (() => {
|
|
|
6906
7148
|
velocity[offset] *= factor;
|
|
6907
7149
|
velocity[offset + 1] *= factor;
|
|
6908
7150
|
velocity[offset + 2] *= factor;
|
|
7151
|
+
const x0 = position[offset];
|
|
7152
|
+
const y0 = position[offset + 1];
|
|
7153
|
+
const z0 = position[offset + 2];
|
|
6909
7154
|
position[offset] += velocity[offset] * dt;
|
|
6910
7155
|
position[offset + 1] += velocity[offset + 1] * dt;
|
|
6911
7156
|
position[offset + 2] += velocity[offset + 2] * dt;
|
|
7157
|
+
if (this.carried && confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
|
|
7158
|
+
const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
|
|
7159
|
+
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
|
|
7160
|
+
const out = confiner.out;
|
|
7161
|
+
position[offset] = out.x;
|
|
7162
|
+
position[offset + 1] = out.y;
|
|
7163
|
+
position[offset + 2] = out.z;
|
|
7164
|
+
const [vx2, vy2, vz2] = slideAlong(out, velocity[offset], velocity[offset + 1], velocity[offset + 2]);
|
|
7165
|
+
velocity[offset] = vx2;
|
|
7166
|
+
velocity[offset + 1] = vy2;
|
|
7167
|
+
velocity[offset + 2] = vz2;
|
|
7168
|
+
}
|
|
7169
|
+
}
|
|
6912
7170
|
const mode = this.groundMode[index];
|
|
6913
7171
|
if (mode) {
|
|
6914
7172
|
const groundHeight = this.context.groundAt(position[offset], position[offset + 2]);
|
|
@@ -7193,9 +7451,9 @@ var GameVfx = (() => {
|
|
|
7193
7451
|
__publicField(this, "placement");
|
|
7194
7452
|
__publicField(this, "accumulators", /* @__PURE__ */ new Map());
|
|
7195
7453
|
const profile = options.profile ?? PROFILES.high;
|
|
7196
|
-
this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace };
|
|
7454
|
+
this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace, ...options.confiner ? { confiner: options.confiner } : {} };
|
|
7197
7455
|
this.add = new SpritePool(profile.sprites.add, this.context);
|
|
7198
|
-
this.normal = new SpritePool(profile.sprites.normal, this.context);
|
|
7456
|
+
this.normal = new SpritePool(profile.sprites.normal, this.context, true);
|
|
7199
7457
|
this.streaks = new StreakPool(profile.streaks, this.context);
|
|
7200
7458
|
this.debris = new DebrisPool(this.context);
|
|
7201
7459
|
this.decals = new DecalPool(this.context);
|
|
@@ -7231,13 +7489,13 @@ var GameVfx = (() => {
|
|
|
7231
7489
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7232
7490
|
}
|
|
7233
7491
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7234
|
-
turn(
|
|
7492
|
+
turn(vector2) {
|
|
7235
7493
|
const placement = this.placement;
|
|
7236
|
-
if (!placement) return
|
|
7237
|
-
if (placement.orientation) return rotate(placement.orientation,
|
|
7494
|
+
if (!placement) return vector2;
|
|
7495
|
+
if (placement.orientation) return rotate(placement.orientation, vector2);
|
|
7238
7496
|
const cos2 = Math.cos(placement.yaw);
|
|
7239
7497
|
const sin2 = Math.sin(placement.yaw);
|
|
7240
|
-
return [cos2 *
|
|
7498
|
+
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
7241
7499
|
}
|
|
7242
7500
|
placed(options) {
|
|
7243
7501
|
if (!this.placement) return options;
|
|
@@ -7387,12 +7645,14 @@ var GameVfx = (() => {
|
|
|
7387
7645
|
const groundAt = options.groundAt ?? (ground ? (x, z) => ground.heightAt(x, z) : () => 0);
|
|
7388
7646
|
const handles = { next: 0, events: 0 };
|
|
7389
7647
|
const low = options.profile === "low";
|
|
7648
|
+
const enclosures = new Enclosures(20973 + (options.seed ?? 0));
|
|
7390
7649
|
const spriteSystem = new SpriteKindSystem({
|
|
7391
7650
|
capacity: options.sprites?.capacity ?? (low ? 1250 : 2500),
|
|
7392
7651
|
density: options.sprites?.density ?? (low ? 0.6 : 1),
|
|
7393
7652
|
seed: 2654435761 + (options.seed ?? 0),
|
|
7394
7653
|
groundAt,
|
|
7395
7654
|
gravity: options.gravity ?? DEFAULT_GRAVITY,
|
|
7655
|
+
confiner: enclosures,
|
|
7396
7656
|
...options.sprites?.kinds ? { kinds: options.sprites.kinds } : {}
|
|
7397
7657
|
});
|
|
7398
7658
|
const core = {
|
|
@@ -7442,7 +7702,7 @@ var GameVfx = (() => {
|
|
|
7442
7702
|
return [camera2.x, camera2.y, camera2.z];
|
|
7443
7703
|
}, forward: (local2) => [local2[0] ?? 0, local2[1] ?? 0, local2[2] ?? 0] };
|
|
7444
7704
|
function workshop() {
|
|
7445
|
-
return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt }));
|
|
7705
|
+
return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt, confiner: enclosures }));
|
|
7446
7706
|
}
|
|
7447
7707
|
function effectPlayer() {
|
|
7448
7708
|
return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
|
|
@@ -7501,6 +7761,10 @@ var GameVfx = (() => {
|
|
|
7501
7761
|
puff3.vz += dz * strength;
|
|
7502
7762
|
}
|
|
7503
7763
|
},
|
|
7764
|
+
enclose(id, enclosure) {
|
|
7765
|
+
enclosures.set(id, enclosure);
|
|
7766
|
+
},
|
|
7767
|
+
enclosures: () => enclosures,
|
|
7504
7768
|
stop(handle) {
|
|
7505
7769
|
player?.stop(handle);
|
|
7506
7770
|
const fires = core.fires;
|
|
@@ -7528,7 +7792,7 @@ var GameVfx = (() => {
|
|
|
7528
7792
|
core.clock.time += dt;
|
|
7529
7793
|
core.schedule.update(core.clock.time);
|
|
7530
7794
|
updateRings(core.rings, dt);
|
|
7531
|
-
updatePuffs(core.puffs, dt, wind);
|
|
7795
|
+
updatePuffs(core.puffs, dt, wind, enclosures);
|
|
7532
7796
|
updateSparks(core.sparks, { dt, groundAt });
|
|
7533
7797
|
updateGlows(core.glows, dt);
|
|
7534
7798
|
updateShocks(core.shocks, core.puffs.items, dt);
|
|
@@ -8440,10 +8704,10 @@ var GameVfx = (() => {
|
|
|
8440
8704
|
function subtract(a, b) {
|
|
8441
8705
|
return [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
8442
8706
|
}
|
|
8443
|
-
function unit(
|
|
8444
|
-
const length = Math.sqrt(
|
|
8707
|
+
function unit(vector2) {
|
|
8708
|
+
const length = Math.sqrt(vector2[0] * vector2[0] + vector2[1] * vector2[1] + vector2[2] * vector2[2]) || 1;
|
|
8445
8709
|
const inverse = 1 / length;
|
|
8446
|
-
return [
|
|
8710
|
+
return [vector2[0] * inverse, vector2[1] * inverse, vector2[2] * inverse];
|
|
8447
8711
|
}
|
|
8448
8712
|
function crossProduct(a, b) {
|
|
8449
8713
|
return [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|