@adatechnology/game-vfx 0.20.1 → 0.21.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 +6 -2
- package/dist/index.d.ts +24 -7
- package/dist/index.global.js +83 -33
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +83 -33
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1462,6 +1462,13 @@ var Solids = class {
|
|
|
1462
1462
|
};
|
|
1463
1463
|
|
|
1464
1464
|
// src/enclosures.ts
|
|
1465
|
+
function ceilingAt(s, x) {
|
|
1466
|
+
const c = s.ceiling;
|
|
1467
|
+
if (!c) return s.hy;
|
|
1468
|
+
const t = Math.min(1, Math.max(0, (x + s.hx) / (2 * s.hx))) * (c.length - 1);
|
|
1469
|
+
const i = Math.min(c.length - 2, Math.floor(t));
|
|
1470
|
+
return c[i] + (c[i + 1] - c[i]) * (t - i);
|
|
1471
|
+
}
|
|
1465
1472
|
var SKIN2 = 5e-3;
|
|
1466
1473
|
function rotation(q) {
|
|
1467
1474
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
@@ -1491,8 +1498,15 @@ var Enclosures = class {
|
|
|
1491
1498
|
__publicField(this, "l0", new Float64Array(3));
|
|
1492
1499
|
__publicField(this, "l1", new Float64Array(3));
|
|
1493
1500
|
__publicField(this, "q", new Float64Array(3));
|
|
1501
|
+
/** Of the step being tested, per local axis: the walls (`wallLo`, `wallHi`) and how far a particle held inside may go (`lo`, `hi`). */
|
|
1502
|
+
__publicField(this, "wallLo", new Float64Array(3));
|
|
1503
|
+
__publicField(this, "wallHi", new Float64Array(3));
|
|
1504
|
+
__publicField(this, "lo", new Float64Array(3));
|
|
1505
|
+
__publicField(this, "hi", new Float64Array(3));
|
|
1506
|
+
/** The last `through` passed by a plain opening (no rate), not by a gap's or the leak's chance. */
|
|
1507
|
+
__publicField(this, "plain", false);
|
|
1494
1508
|
__publicField(this, "h", new Float64Array(3));
|
|
1495
|
-
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1509
|
+
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: -1 });
|
|
1496
1510
|
__publicField(this, "solids", new Solids());
|
|
1497
1511
|
this.random = lehmer(seed);
|
|
1498
1512
|
}
|
|
@@ -1523,7 +1537,9 @@ var Enclosures = class {
|
|
|
1523
1537
|
r: rotation(enclosure.orientation),
|
|
1524
1538
|
radius: Math.hypot(hx, hy, hz),
|
|
1525
1539
|
openings: enclosure.openings ?? [],
|
|
1526
|
-
leak: Math.max(0, enclosure.leak ?? 0)
|
|
1540
|
+
leak: Math.max(0, enclosure.leak ?? 0),
|
|
1541
|
+
// a roof no higher than the box, and never under its floor
|
|
1542
|
+
ceiling: enclosure.ceiling && enclosure.ceiling.length >= 2 && Math.abs(hx) > 0 ? Float64Array.from(enclosure.ceiling, (y) => Math.min(Math.abs(hy), Math.max(-Math.abs(hy), y))) : null
|
|
1527
1543
|
};
|
|
1528
1544
|
const old = this.spaces.get(id);
|
|
1529
1545
|
this.spaces.set(id, space);
|
|
@@ -1534,7 +1550,7 @@ var Enclosures = class {
|
|
|
1534
1550
|
get(id) {
|
|
1535
1551
|
const s = this.spaces.get(id);
|
|
1536
1552
|
if (!s) return void 0;
|
|
1537
|
-
return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak };
|
|
1553
|
+
return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak, ...s.ceiling ? { ceiling: [...s.ceiling] } : {} };
|
|
1538
1554
|
}
|
|
1539
1555
|
ids() {
|
|
1540
1556
|
return [...this.spaces.keys()];
|
|
@@ -1547,7 +1563,7 @@ var Enclosures = class {
|
|
|
1547
1563
|
inside(x, y, z) {
|
|
1548
1564
|
for (const s of this.list) {
|
|
1549
1565
|
this.toLocal(s, x, y, z, this.l0);
|
|
1550
|
-
if (Math.abs(this.l0[0]) <= s.hx &&
|
|
1566
|
+
if (Math.abs(this.l0[0]) <= s.hx && this.l0[1] >= -s.hy && this.l0[1] <= ceilingAt(s, this.l0[0]) && Math.abs(this.l0[2]) <= s.hz) return true;
|
|
1551
1567
|
}
|
|
1552
1568
|
return false;
|
|
1553
1569
|
}
|
|
@@ -1566,13 +1582,18 @@ var Enclosures = class {
|
|
|
1566
1582
|
}
|
|
1567
1583
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1568
1584
|
through(s, q, dt) {
|
|
1585
|
+
this.plain = false;
|
|
1569
1586
|
for (const o of s.openings) {
|
|
1570
1587
|
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;
|
|
1571
|
-
if (o.rate === void 0
|
|
1588
|
+
if (o.rate === void 0) {
|
|
1589
|
+
this.plain = true;
|
|
1590
|
+
return true;
|
|
1591
|
+
}
|
|
1592
|
+
if (this.chance(o.rate, dt)) return true;
|
|
1572
1593
|
}
|
|
1573
1594
|
return this.chance(s.leak, dt);
|
|
1574
1595
|
}
|
|
1575
|
-
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1596
|
+
confine(x0, y0, z0, x1, y1, z1, pad, dt, inner = -1) {
|
|
1576
1597
|
const move = this.move;
|
|
1577
1598
|
move.x0 = x0;
|
|
1578
1599
|
move.y0 = y0;
|
|
@@ -1581,6 +1602,7 @@ var Enclosures = class {
|
|
|
1581
1602
|
move.y1 = y1;
|
|
1582
1603
|
move.z1 = z1;
|
|
1583
1604
|
move.pad = pad;
|
|
1605
|
+
move.inner = inner;
|
|
1584
1606
|
return this.confineMove(move, dt);
|
|
1585
1607
|
}
|
|
1586
1608
|
confineMove(move, dt) {
|
|
@@ -1592,6 +1614,7 @@ var Enclosures = class {
|
|
|
1592
1614
|
if (list.length === 0) return false;
|
|
1593
1615
|
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
1594
1616
|
const p = Math.min(Math.max(0, move.pad), MAX_PAD);
|
|
1617
|
+
const inner = move.inner < 0 ? p : move.inner;
|
|
1595
1618
|
const l0 = this.l0;
|
|
1596
1619
|
const l1 = this.l1;
|
|
1597
1620
|
const q = this.q;
|
|
@@ -1612,40 +1635,65 @@ var Enclosures = class {
|
|
|
1612
1635
|
h[0] = s.hx;
|
|
1613
1636
|
h[1] = s.hy;
|
|
1614
1637
|
h[2] = s.hz;
|
|
1615
|
-
const
|
|
1638
|
+
const top0 = ceilingAt(s, l0[0]);
|
|
1639
|
+
const top = ceilingAt(s, l1[0]);
|
|
1640
|
+
const in0 = Math.abs(l0[0]) <= s.hx && l0[1] >= -s.hy && l0[1] <= top0 && Math.abs(l0[2]) <= s.hz;
|
|
1616
1641
|
let axis2 = 0;
|
|
1617
1642
|
let sign = 1;
|
|
1643
|
+
let outward = false;
|
|
1644
|
+
let face = 0;
|
|
1618
1645
|
if (in0) {
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1646
|
+
const { wallLo, wallHi, lo, hi } = this;
|
|
1647
|
+
let pressing = false;
|
|
1648
|
+
for (let a = 0; a < 3; a++) {
|
|
1649
|
+
wallLo[a] = -h[a];
|
|
1650
|
+
wallHi[a] = a === 1 ? top : h[a];
|
|
1651
|
+
const off = Math.min(inner, (wallHi[a] - wallLo[a]) * 0.25);
|
|
1652
|
+
lo[a] = wallLo[a] + off;
|
|
1653
|
+
hi[a] = wallHi[a] - off;
|
|
1654
|
+
if (l1[a] > hi[a] || l1[a] < lo[a]) pressing = true;
|
|
1655
|
+
}
|
|
1656
|
+
if (!pressing) continue;
|
|
1622
1657
|
let worst = -Infinity;
|
|
1658
|
+
let gated = false;
|
|
1623
1659
|
for (let a = 0; a < 3; a++) {
|
|
1624
|
-
const over = Math.
|
|
1660
|
+
const over = Math.max(l1[a] - hi[a], lo[a] - l1[a]);
|
|
1661
|
+
q[a] = over > 0 ? l1[a] < lo[a] ? wallLo[a] : wallHi[a] : l1[a];
|
|
1625
1662
|
if (over > worst) {
|
|
1626
1663
|
worst = over;
|
|
1627
1664
|
axis2 = a;
|
|
1628
1665
|
}
|
|
1629
1666
|
}
|
|
1630
|
-
sign = l1[axis2] <
|
|
1631
|
-
|
|
1632
|
-
|
|
1667
|
+
sign = l1[axis2] < lo[axis2] ? -1 : 1;
|
|
1668
|
+
face = sign > 0 ? wallHi[axis2] : -wallLo[axis2];
|
|
1669
|
+
if (this.through(s, q, dt)) {
|
|
1670
|
+
if (this.plain) continue;
|
|
1671
|
+
gated = true;
|
|
1672
|
+
l1[axis2] = sign * (face + SKIN2);
|
|
1673
|
+
} else {
|
|
1674
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(Math.min(hi[a], wallHi[a] - SKIN2), Math.max(Math.max(lo[a], wallLo[a] + SKIN2), l1[a]));
|
|
1675
|
+
sign = -sign;
|
|
1676
|
+
}
|
|
1677
|
+
outward = gated;
|
|
1633
1678
|
} else {
|
|
1634
|
-
const padded0 = Math.abs(l0[0]) <= s.hx + p &&
|
|
1679
|
+
const padded0 = Math.abs(l0[0]) <= s.hx + p && l0[1] >= -s.hy - p && l0[1] <= top0 + p && Math.abs(l0[2]) <= s.hz + p;
|
|
1635
1680
|
const bound = padded0 ? 0 : p;
|
|
1636
|
-
if (!(Math.abs(l1[0]) <= s.hx + bound &&
|
|
1637
|
-
|
|
1681
|
+
if (!(Math.abs(l1[0]) <= s.hx + bound && l1[1] >= -s.hy - bound && l1[1] <= top + bound && Math.abs(l1[2]) <= s.hz + bound)) continue;
|
|
1682
|
+
q[0] = Math.min(h[0], Math.max(-h[0], l1[0]));
|
|
1683
|
+
q[1] = Math.min(top, Math.max(-h[1], l1[1]));
|
|
1684
|
+
q[2] = Math.min(h[2], Math.max(-h[2], l1[2]));
|
|
1638
1685
|
if (this.through(s, q, dt)) continue;
|
|
1639
1686
|
let worst = -Infinity;
|
|
1640
1687
|
for (let a = 0; a < 3; a++) {
|
|
1641
|
-
const over = Math.abs(l0[a]) - (h[a] + bound);
|
|
1688
|
+
const over = a === 1 ? Math.max(l0[1] - (top0 + bound), -l0[1] - (h[1] + bound)) : Math.abs(l0[a]) - (h[a] + bound);
|
|
1642
1689
|
if (over > worst) {
|
|
1643
1690
|
worst = over;
|
|
1644
1691
|
axis2 = a;
|
|
1645
1692
|
}
|
|
1646
1693
|
}
|
|
1647
|
-
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1648
|
-
|
|
1694
|
+
sign = axis2 === 1 ? l0[1] - top0 >= -l0[1] - h[1] ? 1 : -1 : l0[axis2] < 0 ? -1 : 1;
|
|
1695
|
+
face = axis2 === 1 && sign > 0 ? top : h[axis2];
|
|
1696
|
+
l1[axis2] = sign * (face + bound + SKIN2);
|
|
1649
1697
|
}
|
|
1650
1698
|
const r = s.r;
|
|
1651
1699
|
const out = this.out;
|
|
@@ -1655,7 +1703,7 @@ var Enclosures = class {
|
|
|
1655
1703
|
out.nx = r[axis2] * sign;
|
|
1656
1704
|
out.ny = r[3 + axis2] * sign;
|
|
1657
1705
|
out.nz = r[6 + axis2] * sign;
|
|
1658
|
-
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -
|
|
1706
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 && !outward ? -face : face);
|
|
1659
1707
|
return true;
|
|
1660
1708
|
}
|
|
1661
1709
|
return false;
|
|
@@ -1682,7 +1730,7 @@ var PROBES_PER_SECOND = 60;
|
|
|
1682
1730
|
var FRAMES_PER_PROBE = 3;
|
|
1683
1731
|
var GROUND_FACING = 0.7;
|
|
1684
1732
|
var SAME_WALL = 0.9;
|
|
1685
|
-
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
1733
|
+
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5, inner: -0.5 };
|
|
1686
1734
|
var KeptCut = class {
|
|
1687
1735
|
constructor() {
|
|
1688
1736
|
__publicField(this, "on", false);
|
|
@@ -1816,7 +1864,7 @@ var ARRIVAL_BASE = 0.3;
|
|
|
1816
1864
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1817
1865
|
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1818
1866
|
var PAD_OF_SIZE = 0.35;
|
|
1819
|
-
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
1867
|
+
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: 0 };
|
|
1820
1868
|
function createPuffPool(capacity) {
|
|
1821
1869
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1822
1870
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1922,6 +1970,7 @@ function confine(confiner, puff3, dt) {
|
|
|
1922
1970
|
MOVE.y1 = puff3.y;
|
|
1923
1971
|
MOVE.z1 = puff3.z;
|
|
1924
1972
|
MOVE.pad = puff3.size * PAD_OF_SIZE;
|
|
1973
|
+
MOVE.inner = puff3.size * 0.5;
|
|
1925
1974
|
return confiner.confineMove(MOVE, dt);
|
|
1926
1975
|
}
|
|
1927
1976
|
function updatePuffs(pool, dt, wind, confiner) {
|
|
@@ -5878,7 +5927,7 @@ var TRAIL_SECONDS = 1.8;
|
|
|
5878
5927
|
var TRAIL_STEP = 0.025;
|
|
5879
5928
|
var QUARTER_TURN3 = Math.PI / 2;
|
|
5880
5929
|
var TOP_FACING = 0.7;
|
|
5881
|
-
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5930
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5, inner: -0.5 };
|
|
5882
5931
|
function bounce(core, chunk, floor2) {
|
|
5883
5932
|
chunk.y = floor2;
|
|
5884
5933
|
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
@@ -6091,7 +6140,7 @@ function composeFlash(context) {
|
|
|
6091
6140
|
screen2.flashDecay = 0.5;
|
|
6092
6141
|
}
|
|
6093
6142
|
}
|
|
6094
|
-
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
6143
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: -1 };
|
|
6095
6144
|
function bornFrom(core, puff3, ox, oy, oz) {
|
|
6096
6145
|
const confiner = core.confiner;
|
|
6097
6146
|
if (confiner.empty) return;
|
|
@@ -6503,7 +6552,7 @@ function updateScreen(state, dt) {
|
|
|
6503
6552
|
|
|
6504
6553
|
// src/sprites/kind-pool.ts
|
|
6505
6554
|
var PAD_OF_SIZE2 = 0.35;
|
|
6506
|
-
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6555
|
+
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5, inner: 0.5 };
|
|
6507
6556
|
var GROUND_RESAMPLE = 0.1;
|
|
6508
6557
|
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6509
6558
|
var SPRITE_REACH = 1;
|
|
@@ -6782,6 +6831,7 @@ var SpriteKindPool = class {
|
|
|
6782
6831
|
STEP.y1 = y;
|
|
6783
6832
|
STEP.z1 = z;
|
|
6784
6833
|
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6834
|
+
STEP.inner = STEP.pad * (0.5 / PAD_OF_SIZE2);
|
|
6785
6835
|
if (confiner.confineMove(STEP, dt)) {
|
|
6786
6836
|
met = true;
|
|
6787
6837
|
const out = confiner.out;
|
|
@@ -6870,7 +6920,8 @@ var sprite_kinds_default = {
|
|
|
6870
6920
|
fadeIn: 0.12,
|
|
6871
6921
|
cone: 0.7,
|
|
6872
6922
|
ground: "none",
|
|
6873
|
-
flicker: 0.35
|
|
6923
|
+
flicker: 0.35,
|
|
6924
|
+
carried: true
|
|
6874
6925
|
},
|
|
6875
6926
|
smoke: {
|
|
6876
6927
|
id: "smoke",
|
|
@@ -7732,12 +7783,11 @@ var FLOATS_PER_VECTOR = 3;
|
|
|
7732
7783
|
var BYTE_MAX2 = 255;
|
|
7733
7784
|
var CARRIED_GRAVITY = 3;
|
|
7734
7785
|
var PAD_OF_SIZE3 = 0.35;
|
|
7786
|
+
var INNER_OF_SIZE = 0.5;
|
|
7735
7787
|
var SpritePool = class {
|
|
7736
|
-
|
|
7737
|
-
constructor(capacity, context, carried = false) {
|
|
7788
|
+
constructor(capacity, context) {
|
|
7738
7789
|
__publicField(this, "capacity", capacity);
|
|
7739
7790
|
__publicField(this, "context", context);
|
|
7740
|
-
__publicField(this, "carried", carried);
|
|
7741
7791
|
__publicField(this, "count", 0);
|
|
7742
7792
|
__publicField(this, "position");
|
|
7743
7793
|
__publicField(this, "velocity");
|
|
@@ -7858,9 +7908,9 @@ var SpritePool = class {
|
|
|
7858
7908
|
position[offset] += velocity[offset] * dt;
|
|
7859
7909
|
position[offset + 1] += velocity[offset + 1] * dt;
|
|
7860
7910
|
position[offset + 2] += velocity[offset + 2] * dt;
|
|
7861
|
-
if (
|
|
7911
|
+
if (confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
|
|
7862
7912
|
const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
|
|
7863
|
-
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
|
|
7913
|
+
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt, size * INNER_OF_SIZE)) {
|
|
7864
7914
|
const out = confiner.out;
|
|
7865
7915
|
position[offset] = out.x;
|
|
7866
7916
|
position[offset + 1] = out.y;
|
|
@@ -8164,7 +8214,7 @@ var WorkshopEngine = class {
|
|
|
8164
8214
|
const profile = options.profile ?? PROFILES.high;
|
|
8165
8215
|
this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace, ...options.confiner ? { confiner: options.confiner } : {} };
|
|
8166
8216
|
this.add = new SpritePool(profile.sprites.add, this.context);
|
|
8167
|
-
this.normal = new SpritePool(profile.sprites.normal, this.context
|
|
8217
|
+
this.normal = new SpritePool(profile.sprites.normal, this.context);
|
|
8168
8218
|
this.streaks = new StreakPool(profile.streaks, this.context);
|
|
8169
8219
|
this.debris = new DebrisPool(this.context);
|
|
8170
8220
|
this.decals = new DecalPool(this.context);
|