@adatechnology/game-vfx 0.20.0 → 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 +48 -9
- package/dist/index.global.js +219 -77
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +219 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -44,12 +44,14 @@ var GameVfx = (() => {
|
|
|
44
44
|
OrderedPool: () => OrderedPool,
|
|
45
45
|
PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
|
|
46
46
|
PROFILES: () => PROFILES,
|
|
47
|
+
PUFF_CUTS: () => PUFF_CUTS,
|
|
47
48
|
PUFF_REACH: () => PUFF_REACH,
|
|
48
49
|
RAIN_CAPACITY: () => RAIN_CAPACITY,
|
|
49
50
|
RainField: () => RainField,
|
|
50
51
|
SCRAPE_LIMIT: () => SCRAPE_LIMIT,
|
|
51
52
|
SMOKE_COLORS: () => SMOKE_COLORS,
|
|
52
53
|
SPRITE_KINDS: () => SPRITE_KINDS,
|
|
54
|
+
SPRITE_NO_CUT: () => NO_CUT,
|
|
53
55
|
SpriteKindPool: () => SpriteKindPool,
|
|
54
56
|
SpriteKindSystem: () => SpriteKindSystem,
|
|
55
57
|
VFX_LAYERS: () => VFX_LAYERS,
|
|
@@ -1560,6 +1562,13 @@ var GameVfx = (() => {
|
|
|
1560
1562
|
};
|
|
1561
1563
|
|
|
1562
1564
|
// src/enclosures.ts
|
|
1565
|
+
function ceilingAt(s, x) {
|
|
1566
|
+
const c = s.ceiling;
|
|
1567
|
+
if (!c) return s.hy;
|
|
1568
|
+
const t = Math.min(1, Math.max(0, (x + s.hx) / (2 * s.hx))) * (c.length - 1);
|
|
1569
|
+
const i = Math.min(c.length - 2, Math.floor(t));
|
|
1570
|
+
return c[i] + (c[i + 1] - c[i]) * (t - i);
|
|
1571
|
+
}
|
|
1563
1572
|
var SKIN2 = 5e-3;
|
|
1564
1573
|
function rotation(q) {
|
|
1565
1574
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
@@ -1589,8 +1598,15 @@ var GameVfx = (() => {
|
|
|
1589
1598
|
__publicField(this, "l0", new Float64Array(3));
|
|
1590
1599
|
__publicField(this, "l1", new Float64Array(3));
|
|
1591
1600
|
__publicField(this, "q", new Float64Array(3));
|
|
1601
|
+
/** Of the step being tested, per local axis: the walls (`wallLo`, `wallHi`) and how far a particle held inside may go (`lo`, `hi`). */
|
|
1602
|
+
__publicField(this, "wallLo", new Float64Array(3));
|
|
1603
|
+
__publicField(this, "wallHi", new Float64Array(3));
|
|
1604
|
+
__publicField(this, "lo", new Float64Array(3));
|
|
1605
|
+
__publicField(this, "hi", new Float64Array(3));
|
|
1606
|
+
/** The last `through` passed by a plain opening (no rate), not by a gap's or the leak's chance. */
|
|
1607
|
+
__publicField(this, "plain", false);
|
|
1592
1608
|
__publicField(this, "h", new Float64Array(3));
|
|
1593
|
-
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1609
|
+
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: -1 });
|
|
1594
1610
|
__publicField(this, "solids", new Solids());
|
|
1595
1611
|
this.random = lehmer(seed);
|
|
1596
1612
|
}
|
|
@@ -1621,7 +1637,9 @@ var GameVfx = (() => {
|
|
|
1621
1637
|
r: rotation(enclosure.orientation),
|
|
1622
1638
|
radius: Math.hypot(hx, hy, hz),
|
|
1623
1639
|
openings: enclosure.openings ?? [],
|
|
1624
|
-
leak: Math.max(0, enclosure.leak ?? 0)
|
|
1640
|
+
leak: Math.max(0, enclosure.leak ?? 0),
|
|
1641
|
+
// a roof no higher than the box, and never under its floor
|
|
1642
|
+
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
|
|
1625
1643
|
};
|
|
1626
1644
|
const old = this.spaces.get(id);
|
|
1627
1645
|
this.spaces.set(id, space);
|
|
@@ -1632,7 +1650,7 @@ var GameVfx = (() => {
|
|
|
1632
1650
|
get(id) {
|
|
1633
1651
|
const s = this.spaces.get(id);
|
|
1634
1652
|
if (!s) return void 0;
|
|
1635
|
-
return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak };
|
|
1653
|
+
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] } : {} };
|
|
1636
1654
|
}
|
|
1637
1655
|
ids() {
|
|
1638
1656
|
return [...this.spaces.keys()];
|
|
@@ -1645,7 +1663,7 @@ var GameVfx = (() => {
|
|
|
1645
1663
|
inside(x, y, z) {
|
|
1646
1664
|
for (const s of this.list) {
|
|
1647
1665
|
this.toLocal(s, x, y, z, this.l0);
|
|
1648
|
-
if (Math.abs(this.l0[0]) <= s.hx &&
|
|
1666
|
+
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;
|
|
1649
1667
|
}
|
|
1650
1668
|
return false;
|
|
1651
1669
|
}
|
|
@@ -1664,13 +1682,18 @@ var GameVfx = (() => {
|
|
|
1664
1682
|
}
|
|
1665
1683
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1666
1684
|
through(s, q, dt) {
|
|
1685
|
+
this.plain = false;
|
|
1667
1686
|
for (const o of s.openings) {
|
|
1668
1687
|
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;
|
|
1669
|
-
if (o.rate === void 0
|
|
1688
|
+
if (o.rate === void 0) {
|
|
1689
|
+
this.plain = true;
|
|
1690
|
+
return true;
|
|
1691
|
+
}
|
|
1692
|
+
if (this.chance(o.rate, dt)) return true;
|
|
1670
1693
|
}
|
|
1671
1694
|
return this.chance(s.leak, dt);
|
|
1672
1695
|
}
|
|
1673
|
-
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1696
|
+
confine(x0, y0, z0, x1, y1, z1, pad, dt, inner = -1) {
|
|
1674
1697
|
const move = this.move;
|
|
1675
1698
|
move.x0 = x0;
|
|
1676
1699
|
move.y0 = y0;
|
|
@@ -1679,6 +1702,7 @@ var GameVfx = (() => {
|
|
|
1679
1702
|
move.y1 = y1;
|
|
1680
1703
|
move.z1 = z1;
|
|
1681
1704
|
move.pad = pad;
|
|
1705
|
+
move.inner = inner;
|
|
1682
1706
|
return this.confineMove(move, dt);
|
|
1683
1707
|
}
|
|
1684
1708
|
confineMove(move, dt) {
|
|
@@ -1690,6 +1714,7 @@ var GameVfx = (() => {
|
|
|
1690
1714
|
if (list.length === 0) return false;
|
|
1691
1715
|
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
1692
1716
|
const p = Math.min(Math.max(0, move.pad), MAX_PAD);
|
|
1717
|
+
const inner = move.inner < 0 ? p : move.inner;
|
|
1693
1718
|
const l0 = this.l0;
|
|
1694
1719
|
const l1 = this.l1;
|
|
1695
1720
|
const q = this.q;
|
|
@@ -1710,40 +1735,65 @@ var GameVfx = (() => {
|
|
|
1710
1735
|
h[0] = s.hx;
|
|
1711
1736
|
h[1] = s.hy;
|
|
1712
1737
|
h[2] = s.hz;
|
|
1713
|
-
const
|
|
1738
|
+
const top0 = ceilingAt(s, l0[0]);
|
|
1739
|
+
const top = ceilingAt(s, l1[0]);
|
|
1740
|
+
const in0 = Math.abs(l0[0]) <= s.hx && l0[1] >= -s.hy && l0[1] <= top0 && Math.abs(l0[2]) <= s.hz;
|
|
1714
1741
|
let axis2 = 0;
|
|
1715
1742
|
let sign = 1;
|
|
1743
|
+
let outward = false;
|
|
1744
|
+
let face = 0;
|
|
1716
1745
|
if (in0) {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1746
|
+
const { wallLo, wallHi, lo, hi } = this;
|
|
1747
|
+
let pressing = false;
|
|
1748
|
+
for (let a = 0; a < 3; a++) {
|
|
1749
|
+
wallLo[a] = -h[a];
|
|
1750
|
+
wallHi[a] = a === 1 ? top : h[a];
|
|
1751
|
+
const off = Math.min(inner, (wallHi[a] - wallLo[a]) * 0.25);
|
|
1752
|
+
lo[a] = wallLo[a] + off;
|
|
1753
|
+
hi[a] = wallHi[a] - off;
|
|
1754
|
+
if (l1[a] > hi[a] || l1[a] < lo[a]) pressing = true;
|
|
1755
|
+
}
|
|
1756
|
+
if (!pressing) continue;
|
|
1720
1757
|
let worst = -Infinity;
|
|
1758
|
+
let gated = false;
|
|
1721
1759
|
for (let a = 0; a < 3; a++) {
|
|
1722
|
-
const over = Math.
|
|
1760
|
+
const over = Math.max(l1[a] - hi[a], lo[a] - l1[a]);
|
|
1761
|
+
q[a] = over > 0 ? l1[a] < lo[a] ? wallLo[a] : wallHi[a] : l1[a];
|
|
1723
1762
|
if (over > worst) {
|
|
1724
1763
|
worst = over;
|
|
1725
1764
|
axis2 = a;
|
|
1726
1765
|
}
|
|
1727
1766
|
}
|
|
1728
|
-
sign = l1[axis2] <
|
|
1729
|
-
|
|
1730
|
-
|
|
1767
|
+
sign = l1[axis2] < lo[axis2] ? -1 : 1;
|
|
1768
|
+
face = sign > 0 ? wallHi[axis2] : -wallLo[axis2];
|
|
1769
|
+
if (this.through(s, q, dt)) {
|
|
1770
|
+
if (this.plain) continue;
|
|
1771
|
+
gated = true;
|
|
1772
|
+
l1[axis2] = sign * (face + SKIN2);
|
|
1773
|
+
} else {
|
|
1774
|
+
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]));
|
|
1775
|
+
sign = -sign;
|
|
1776
|
+
}
|
|
1777
|
+
outward = gated;
|
|
1731
1778
|
} else {
|
|
1732
|
-
const padded0 = Math.abs(l0[0]) <= s.hx + p &&
|
|
1779
|
+
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;
|
|
1733
1780
|
const bound = padded0 ? 0 : p;
|
|
1734
|
-
if (!(Math.abs(l1[0]) <= s.hx + bound &&
|
|
1735
|
-
|
|
1781
|
+
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;
|
|
1782
|
+
q[0] = Math.min(h[0], Math.max(-h[0], l1[0]));
|
|
1783
|
+
q[1] = Math.min(top, Math.max(-h[1], l1[1]));
|
|
1784
|
+
q[2] = Math.min(h[2], Math.max(-h[2], l1[2]));
|
|
1736
1785
|
if (this.through(s, q, dt)) continue;
|
|
1737
1786
|
let worst = -Infinity;
|
|
1738
1787
|
for (let a = 0; a < 3; a++) {
|
|
1739
|
-
const over = Math.abs(l0[a]) - (h[a] + bound);
|
|
1788
|
+
const over = a === 1 ? Math.max(l0[1] - (top0 + bound), -l0[1] - (h[1] + bound)) : Math.abs(l0[a]) - (h[a] + bound);
|
|
1740
1789
|
if (over > worst) {
|
|
1741
1790
|
worst = over;
|
|
1742
1791
|
axis2 = a;
|
|
1743
1792
|
}
|
|
1744
1793
|
}
|
|
1745
|
-
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1746
|
-
|
|
1794
|
+
sign = axis2 === 1 ? l0[1] - top0 >= -l0[1] - h[1] ? 1 : -1 : l0[axis2] < 0 ? -1 : 1;
|
|
1795
|
+
face = axis2 === 1 && sign > 0 ? top : h[axis2];
|
|
1796
|
+
l1[axis2] = sign * (face + bound + SKIN2);
|
|
1747
1797
|
}
|
|
1748
1798
|
const r = s.r;
|
|
1749
1799
|
const out = this.out;
|
|
@@ -1753,7 +1803,7 @@ var GameVfx = (() => {
|
|
|
1753
1803
|
out.nx = r[axis2] * sign;
|
|
1754
1804
|
out.ny = r[3 + axis2] * sign;
|
|
1755
1805
|
out.nz = r[6 + axis2] * sign;
|
|
1756
|
-
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -
|
|
1806
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 && !outward ? -face : face);
|
|
1757
1807
|
return true;
|
|
1758
1808
|
}
|
|
1759
1809
|
return false;
|
|
@@ -1773,13 +1823,14 @@ var GameVfx = (() => {
|
|
|
1773
1823
|
}
|
|
1774
1824
|
|
|
1775
1825
|
// src/pools/puff-cuts.ts
|
|
1826
|
+
var PUFF_CUTS = 3;
|
|
1776
1827
|
var PUFF_REACH = 1.28;
|
|
1777
|
-
var PROBES = [
|
|
1828
|
+
var PROBES = [Float64Array.of(1, 0, 0), Float64Array.of(-1, 0, 0), Float64Array.of(0, 0, 1), Float64Array.of(0, 0, -1), Float64Array.of(0, 1, 0)];
|
|
1778
1829
|
var PROBES_PER_SECOND = 60;
|
|
1779
1830
|
var FRAMES_PER_PROBE = 3;
|
|
1780
1831
|
var GROUND_FACING = 0.7;
|
|
1781
1832
|
var SAME_WALL = 0.9;
|
|
1782
|
-
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
1833
|
+
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 };
|
|
1783
1834
|
var KeptCut = class {
|
|
1784
1835
|
constructor() {
|
|
1785
1836
|
__publicField(this, "on", false);
|
|
@@ -1793,41 +1844,44 @@ var GameVfx = (() => {
|
|
|
1793
1844
|
return new KeptCut();
|
|
1794
1845
|
}
|
|
1795
1846
|
function clearCuts(puff3) {
|
|
1796
|
-
puff3.cuts[
|
|
1797
|
-
puff3.cuts[1].on = false;
|
|
1847
|
+
for (let i = 0; i < PUFF_CUTS; i++) puff3.cuts[i].on = false;
|
|
1798
1848
|
}
|
|
1799
|
-
var
|
|
1800
|
-
|
|
1801
|
-
__publicField(this, "x", 0.5);
|
|
1802
|
-
__publicField(this, "y", 0.5);
|
|
1803
|
-
__publicField(this, "z", 0.5);
|
|
1804
|
-
}
|
|
1805
|
-
};
|
|
1806
|
-
var WAY = new WrittenWay();
|
|
1849
|
+
var WAY = new Float64Array(3);
|
|
1850
|
+
var PASSED = 0.02;
|
|
1807
1851
|
function probe(confiner, puff3, way) {
|
|
1808
|
-
const reach = puff3.size * PUFF_REACH;
|
|
1852
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1809
1853
|
if (!(reach > 0)) return false;
|
|
1810
1854
|
PROBE.x0 = puff3.x;
|
|
1811
1855
|
PROBE.y0 = puff3.y;
|
|
1812
1856
|
PROBE.z0 = puff3.z;
|
|
1813
|
-
PROBE.x1 = puff3.x + way
|
|
1814
|
-
PROBE.y1 = puff3.y + way
|
|
1815
|
-
PROBE.z1 = puff3.z + way
|
|
1857
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1858
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1859
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1860
|
+
PROBE.pad = 0;
|
|
1861
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1862
|
+
}
|
|
1863
|
+
function probeAgain(confiner, puff3, way) {
|
|
1864
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1865
|
+
if (!(reach > 0)) return false;
|
|
1866
|
+
PROBE.x0 = puff3.x - way[0] * PASSED;
|
|
1867
|
+
PROBE.y0 = puff3.y - way[1] * PASSED;
|
|
1868
|
+
PROBE.z0 = puff3.z - way[2] * PASSED;
|
|
1869
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1870
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1871
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1816
1872
|
PROBE.pad = 0;
|
|
1817
1873
|
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1818
1874
|
}
|
|
1819
1875
|
var isFartherFrom = (puff3, a, b) => a.nx * puff3.x + a.ny * puff3.y + a.nz * puff3.z - a.d > b.nx * puff3.x + b.ny * puff3.y + b.nz * puff3.z - b.d;
|
|
1820
|
-
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d;
|
|
1876
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d - PASSED;
|
|
1821
1877
|
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1822
1878
|
function cutFor(puff3, face) {
|
|
1823
|
-
const
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (
|
|
1828
|
-
|
|
1829
|
-
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1830
|
-
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1879
|
+
const cuts = puff3.cuts;
|
|
1880
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (sameWall(cuts[i], face)) return cuts[i];
|
|
1881
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (!cuts[i].on) return cuts[i];
|
|
1882
|
+
let farthest = cuts[0];
|
|
1883
|
+
for (let i = 1; i < PUFF_CUTS; i++) if (isFartherFrom(puff3, cuts[i], farthest)) farthest = cuts[i];
|
|
1884
|
+
return isFartherFrom(puff3, farthest, face) ? farthest : void 0;
|
|
1831
1885
|
}
|
|
1832
1886
|
function cutAtFace(puff3, face) {
|
|
1833
1887
|
if (face.ny > GROUND_FACING) return;
|
|
@@ -1850,28 +1904,35 @@ var GameVfx = (() => {
|
|
|
1850
1904
|
function backward(puff3) {
|
|
1851
1905
|
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1852
1906
|
if (!(speed > 0)) return null;
|
|
1853
|
-
WAY
|
|
1854
|
-
WAY
|
|
1855
|
-
WAY
|
|
1907
|
+
WAY[0] = -puff3.vx / speed;
|
|
1908
|
+
WAY[1] = -puff3.vy / speed;
|
|
1909
|
+
WAY[2] = -puff3.vz / speed;
|
|
1856
1910
|
return WAY;
|
|
1857
1911
|
}
|
|
1858
1912
|
function along(cut, sign) {
|
|
1859
|
-
WAY
|
|
1860
|
-
WAY
|
|
1861
|
-
WAY
|
|
1913
|
+
WAY[0] = sign * cut.nx;
|
|
1914
|
+
WAY[1] = sign * cut.ny;
|
|
1915
|
+
WAY[2] = sign * cut.nz;
|
|
1862
1916
|
return WAY;
|
|
1863
1917
|
}
|
|
1864
1918
|
function dropPassed(confiner, puff3) {
|
|
1865
|
-
for (let i = 0; i <
|
|
1919
|
+
for (let i = 0; i < PUFF_CUTS; i++) {
|
|
1866
1920
|
const cut = puff3.cuts[i];
|
|
1867
1921
|
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1868
1922
|
cut.on = false;
|
|
1923
|
+
const nx = cut.nx;
|
|
1924
|
+
const ny = cut.ny;
|
|
1925
|
+
const nz = cut.nz;
|
|
1869
1926
|
cutAt(confiner, puff3, along(cut, 1));
|
|
1927
|
+
WAY[0] = -nx;
|
|
1928
|
+
WAY[1] = -ny;
|
|
1929
|
+
WAY[2] = -nz;
|
|
1930
|
+
cutAt(confiner, puff3, WAY);
|
|
1870
1931
|
}
|
|
1871
1932
|
}
|
|
1872
1933
|
function keep(confiner, puff3, cut) {
|
|
1873
1934
|
if (!cut.on) return;
|
|
1874
|
-
if (!
|
|
1935
|
+
if (!probeAgain(confiner, puff3, along(cut, -1))) {
|
|
1875
1936
|
cut.on = false;
|
|
1876
1937
|
return;
|
|
1877
1938
|
}
|
|
@@ -1887,12 +1948,12 @@ var GameVfx = (() => {
|
|
|
1887
1948
|
return;
|
|
1888
1949
|
}
|
|
1889
1950
|
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1890
|
-
const slot = turn / FRAMES_PER_PROBE % (PROBES.length +
|
|
1891
|
-
if (slot <
|
|
1892
|
-
else if (slot ===
|
|
1951
|
+
const slot = (turn / FRAMES_PER_PROBE | 0) % (PROBES.length + PUFF_CUTS + 1);
|
|
1952
|
+
if (slot < PUFF_CUTS) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1953
|
+
else if (slot === PUFF_CUTS) {
|
|
1893
1954
|
const back = backward(puff3);
|
|
1894
1955
|
if (back) cutAt(confiner, puff3, back);
|
|
1895
|
-
} else cutAt(confiner, puff3, PROBES[slot -
|
|
1956
|
+
} else cutAt(confiner, puff3, PROBES[slot - PUFF_CUTS - 1]);
|
|
1896
1957
|
}
|
|
1897
1958
|
|
|
1898
1959
|
// src/pools/puffs.ts
|
|
@@ -1903,7 +1964,7 @@ var GameVfx = (() => {
|
|
|
1903
1964
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1904
1965
|
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1905
1966
|
var PAD_OF_SIZE = 0.35;
|
|
1906
|
-
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
1967
|
+
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: 0 };
|
|
1907
1968
|
function createPuffPool(capacity) {
|
|
1908
1969
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1909
1970
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1936,7 +1997,7 @@ var GameVfx = (() => {
|
|
|
1936
1997
|
heat: 0,
|
|
1937
1998
|
size: 0,
|
|
1938
1999
|
source: void 0,
|
|
1939
|
-
cuts: [createCut(), createCut()]
|
|
2000
|
+
cuts: [createCut(), createCut(), createCut()]
|
|
1940
2001
|
}));
|
|
1941
2002
|
}
|
|
1942
2003
|
function spawnPuff(pool, random, init) {
|
|
@@ -1988,7 +2049,9 @@ var GameVfx = (() => {
|
|
|
1988
2049
|
puff3.z = ring2.z + Math.sin(puff3.ph) * radius + wind.z * ringTime * 0.6;
|
|
1989
2050
|
puff3.y = centerY + minorRadius * Math.sin(theta);
|
|
1990
2051
|
}
|
|
1991
|
-
function moveFree(puff3, dt,
|
|
2052
|
+
function moveFree(puff3, dt, wind) {
|
|
2053
|
+
const age = puff3.age;
|
|
2054
|
+
const heat = puff3.heat;
|
|
1992
2055
|
const damping = Math.exp(-puff3.drag * dt);
|
|
1993
2056
|
puff3.vx *= damping;
|
|
1994
2057
|
puff3.vy *= damping;
|
|
@@ -2007,19 +2070,20 @@ var GameVfx = (() => {
|
|
|
2007
2070
|
MOVE.y1 = puff3.y;
|
|
2008
2071
|
MOVE.z1 = puff3.z;
|
|
2009
2072
|
MOVE.pad = puff3.size * PAD_OF_SIZE;
|
|
2073
|
+
MOVE.inner = puff3.size * 0.5;
|
|
2010
2074
|
return confiner.confineMove(MOVE, dt);
|
|
2011
2075
|
}
|
|
2012
2076
|
function updatePuffs(pool, dt, wind, confiner) {
|
|
2013
2077
|
pool.compact(ageOrKeep2, dt);
|
|
2014
2078
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
2015
2079
|
for (const puff3 of pool.items) {
|
|
2016
|
-
|
|
2017
|
-
|
|
2080
|
+
puff3.age = puff3.t / puff3.life;
|
|
2081
|
+
puff3.heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
2018
2082
|
MOVE.x0 = puff3.x;
|
|
2019
2083
|
MOVE.y0 = puff3.y;
|
|
2020
2084
|
MOVE.z0 = puff3.z;
|
|
2021
2085
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
2022
|
-
else moveFree(puff3, dt,
|
|
2086
|
+
else moveFree(puff3, dt, wind);
|
|
2023
2087
|
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
2024
2088
|
if (carried && confine(confiner, puff3, dt)) {
|
|
2025
2089
|
const out = confiner.out;
|
|
@@ -2031,8 +2095,6 @@ var GameVfx = (() => {
|
|
|
2031
2095
|
}
|
|
2032
2096
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
2033
2097
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
2034
|
-
puff3.age = age;
|
|
2035
|
-
puff3.heat = heat;
|
|
2036
2098
|
if (carried) lookForWalls(confiner, puff3);
|
|
2037
2099
|
else clearCuts(puff3);
|
|
2038
2100
|
}
|
|
@@ -5965,7 +6027,7 @@ var GameVfx = (() => {
|
|
|
5965
6027
|
var TRAIL_STEP = 0.025;
|
|
5966
6028
|
var QUARTER_TURN3 = Math.PI / 2;
|
|
5967
6029
|
var TOP_FACING = 0.7;
|
|
5968
|
-
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6030
|
+
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 };
|
|
5969
6031
|
function bounce(core, chunk, floor2) {
|
|
5970
6032
|
chunk.y = floor2;
|
|
5971
6033
|
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
@@ -6178,7 +6240,7 @@ var GameVfx = (() => {
|
|
|
6178
6240
|
screen2.flashDecay = 0.5;
|
|
6179
6241
|
}
|
|
6180
6242
|
}
|
|
6181
|
-
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
6243
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0, inner: -1 };
|
|
6182
6244
|
function bornFrom(core, puff3, ox, oy, oz) {
|
|
6183
6245
|
const confiner = core.confiner;
|
|
6184
6246
|
if (confiner.empty) return;
|
|
@@ -6590,9 +6652,26 @@ var GameVfx = (() => {
|
|
|
6590
6652
|
|
|
6591
6653
|
// src/sprites/kind-pool.ts
|
|
6592
6654
|
var PAD_OF_SIZE2 = 0.35;
|
|
6593
|
-
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6655
|
+
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 };
|
|
6594
6656
|
var GROUND_RESAMPLE = 0.1;
|
|
6595
6657
|
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6658
|
+
var SPRITE_REACH = 1;
|
|
6659
|
+
var NO_CUT = -1e9;
|
|
6660
|
+
var SpriteCutView = class {
|
|
6661
|
+
constructor() {
|
|
6662
|
+
__publicField(this, "x", 0.5);
|
|
6663
|
+
__publicField(this, "y", 0.5);
|
|
6664
|
+
__publicField(this, "z", 0.5);
|
|
6665
|
+
__publicField(this, "vx", 0.5);
|
|
6666
|
+
__publicField(this, "vy", 0.5);
|
|
6667
|
+
__publicField(this, "vz", 0.5);
|
|
6668
|
+
__publicField(this, "t", 0.5);
|
|
6669
|
+
__publicField(this, "size", 0.5);
|
|
6670
|
+
__publicField(this, "reachOfSize", SPRITE_REACH);
|
|
6671
|
+
__publicField(this, "cuts", [createCut(), createCut(), createCut()]);
|
|
6672
|
+
}
|
|
6673
|
+
};
|
|
6674
|
+
var VIEW = new SpriteCutView();
|
|
6596
6675
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6597
6676
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6598
6677
|
function rgb(hex) {
|
|
@@ -6621,6 +6700,14 @@ var GameVfx = (() => {
|
|
|
6621
6700
|
__publicField(this, "color");
|
|
6622
6701
|
__publicField(this, "alpha");
|
|
6623
6702
|
__publicField(this, "size");
|
|
6703
|
+
/**
|
|
6704
|
+
* The faces of the walls each carried sprite (smoke, steam, dust) is cut at, three of them (`PUFF_CUTS`: a corner), four numbers a sprite in each: unit normal towards the sprite and offset
|
|
6705
|
+
* (`n · point`), `(0, 0, 0, NO_CUT)` for none. The renderer drops the part of the drawn square behind a face: a puff against a wall flattens on it and
|
|
6706
|
+
* shows nothing on the wall's other side, as a puff's ball does (`Puff.cuts`).
|
|
6707
|
+
*/
|
|
6708
|
+
__publicField(this, "cutA");
|
|
6709
|
+
__publicField(this, "cutB");
|
|
6710
|
+
__publicField(this, "cutC");
|
|
6624
6711
|
__publicField(this, "next", 0);
|
|
6625
6712
|
__publicField(this, "high", 0);
|
|
6626
6713
|
__publicField(this, "velocity");
|
|
@@ -6647,6 +6734,10 @@ var GameVfx = (() => {
|
|
|
6647
6734
|
this.color = new Float32Array(n * 3);
|
|
6648
6735
|
this.alpha = new Float32Array(n);
|
|
6649
6736
|
this.size = new Float32Array(n);
|
|
6737
|
+
this.cutA = new Float32Array(n * 4);
|
|
6738
|
+
this.cutB = new Float32Array(n * 4);
|
|
6739
|
+
this.cutC = new Float32Array(n * 4);
|
|
6740
|
+
for (let i = 0; i < n; i++) this.uncut(i);
|
|
6650
6741
|
this.velocity = new Float32Array(n * 3);
|
|
6651
6742
|
this.age = new Float32Array(n);
|
|
6652
6743
|
this.life = new Float32Array(n);
|
|
@@ -6695,6 +6786,51 @@ var GameVfx = (() => {
|
|
|
6695
6786
|
this.ground[i * 3] = Number.NaN;
|
|
6696
6787
|
this.size[i] = this.size0[i];
|
|
6697
6788
|
this.alpha[i] = 0;
|
|
6789
|
+
this.uncut(i);
|
|
6790
|
+
}
|
|
6791
|
+
/** Sprite `i` cut at no wall. */
|
|
6792
|
+
uncut(i) {
|
|
6793
|
+
this.cutA.fill(0, i * 4, i * 4 + 3);
|
|
6794
|
+
this.cutA[i * 4 + 3] = NO_CUT;
|
|
6795
|
+
this.cutB.fill(0, i * 4, i * 4 + 3);
|
|
6796
|
+
this.cutB[i * 4 + 3] = NO_CUT;
|
|
6797
|
+
this.cutC.fill(0, i * 4, i * 4 + 3);
|
|
6798
|
+
this.cutC[i * 4 + 3] = NO_CUT;
|
|
6799
|
+
}
|
|
6800
|
+
/**
|
|
6801
|
+
* Looks for the walls carried sprite `i` reaches (as a puff's ball does: `lookForWalls`), `met` the face its step was just stopped at, and keeps them in `cuts`.
|
|
6802
|
+
* The sprite's faces go into the reused `VIEW` and come back out: no object a sprite.
|
|
6803
|
+
*/
|
|
6804
|
+
cutAtWalls(i, confiner, met) {
|
|
6805
|
+
const o = i * 4;
|
|
6806
|
+
const i3 = i * 3;
|
|
6807
|
+
VIEW.x = this.position[i3];
|
|
6808
|
+
VIEW.y = this.position[i3 + 1];
|
|
6809
|
+
VIEW.z = this.position[i3 + 2];
|
|
6810
|
+
VIEW.vx = this.velocity[i3];
|
|
6811
|
+
VIEW.vy = this.velocity[i3 + 1];
|
|
6812
|
+
VIEW.vz = this.velocity[i3 + 2];
|
|
6813
|
+
VIEW.t = this.age[i];
|
|
6814
|
+
VIEW.size = this.size[i];
|
|
6815
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6816
|
+
const cut = VIEW.cuts[k];
|
|
6817
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6818
|
+
cut.on = faces[o + 3] !== NO_CUT;
|
|
6819
|
+
cut.nx = faces[o];
|
|
6820
|
+
cut.ny = faces[o + 1];
|
|
6821
|
+
cut.nz = faces[o + 2];
|
|
6822
|
+
cut.d = faces[o + 3];
|
|
6823
|
+
}
|
|
6824
|
+
if (met) cutFrom(VIEW, met);
|
|
6825
|
+
lookForWalls(confiner, VIEW);
|
|
6826
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6827
|
+
const cut = VIEW.cuts[k];
|
|
6828
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6829
|
+
faces[o] = cut.on ? cut.nx : 0;
|
|
6830
|
+
faces[o + 1] = cut.on ? cut.ny : 0;
|
|
6831
|
+
faces[o + 2] = cut.on ? cut.nz : 0;
|
|
6832
|
+
faces[o + 3] = cut.on ? cut.d : NO_CUT;
|
|
6833
|
+
}
|
|
6698
6834
|
}
|
|
6699
6835
|
ownerIndex(name) {
|
|
6700
6836
|
let index = this.owners.indexOf(name);
|
|
@@ -6785,7 +6921,9 @@ var GameVfx = (() => {
|
|
|
6785
6921
|
let y = this.position[i3 + 1] + vy2 * dt;
|
|
6786
6922
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6787
6923
|
const confiner = host.confiner;
|
|
6788
|
-
|
|
6924
|
+
const confining = def.carried && confiner !== void 0 && !confiner.empty;
|
|
6925
|
+
let met = false;
|
|
6926
|
+
if (confining) {
|
|
6789
6927
|
STEP.x0 = this.position[i3];
|
|
6790
6928
|
STEP.y0 = this.position[i3 + 1];
|
|
6791
6929
|
STEP.z0 = this.position[i3 + 2];
|
|
@@ -6793,7 +6931,9 @@ var GameVfx = (() => {
|
|
|
6793
6931
|
STEP.y1 = y;
|
|
6794
6932
|
STEP.z1 = z;
|
|
6795
6933
|
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6934
|
+
STEP.inner = STEP.pad * (0.5 / PAD_OF_SIZE2);
|
|
6796
6935
|
if (confiner.confineMove(STEP, dt)) {
|
|
6936
|
+
met = true;
|
|
6797
6937
|
const out = confiner.out;
|
|
6798
6938
|
x = out.x;
|
|
6799
6939
|
y = out.y;
|
|
@@ -6842,6 +6982,8 @@ var GameVfx = (() => {
|
|
|
6842
6982
|
this.position[i3 + 1] = y;
|
|
6843
6983
|
this.position[i3 + 2] = z;
|
|
6844
6984
|
this.size[i] = this.size0[i] * lerp4(1, def.grow, t);
|
|
6985
|
+
if (confining) this.cutAtWalls(i, confiner, met ? confiner.out : null);
|
|
6986
|
+
else if (def.carried && (this.cutA[i * 4 + 3] !== NO_CUT || this.cutB[i * 4 + 3] !== NO_CUT || this.cutC[i * 4 + 3] !== NO_CUT)) this.uncut(i);
|
|
6845
6987
|
this.color[i3] = lerp4(this.rgbStart[i3], this.rgbEnd[i3], t);
|
|
6846
6988
|
this.color[i3 + 1] = lerp4(this.rgbStart[i3 + 1], this.rgbEnd[i3 + 1], t);
|
|
6847
6989
|
this.color[i3 + 2] = lerp4(this.rgbStart[i3 + 2], this.rgbEnd[i3 + 2], t);
|
|
@@ -6878,7 +7020,8 @@ var GameVfx = (() => {
|
|
|
6878
7020
|
fadeIn: 0.12,
|
|
6879
7021
|
cone: 0.7,
|
|
6880
7022
|
ground: "none",
|
|
6881
|
-
flicker: 0.35
|
|
7023
|
+
flicker: 0.35,
|
|
7024
|
+
carried: true
|
|
6882
7025
|
},
|
|
6883
7026
|
smoke: {
|
|
6884
7027
|
id: "smoke",
|
|
@@ -7740,12 +7883,11 @@ var GameVfx = (() => {
|
|
|
7740
7883
|
var BYTE_MAX2 = 255;
|
|
7741
7884
|
var CARRIED_GRAVITY = 3;
|
|
7742
7885
|
var PAD_OF_SIZE3 = 0.35;
|
|
7886
|
+
var INNER_OF_SIZE = 0.5;
|
|
7743
7887
|
var SpritePool = class {
|
|
7744
|
-
|
|
7745
|
-
constructor(capacity, context, carried = false) {
|
|
7888
|
+
constructor(capacity, context) {
|
|
7746
7889
|
__publicField(this, "capacity", capacity);
|
|
7747
7890
|
__publicField(this, "context", context);
|
|
7748
|
-
__publicField(this, "carried", carried);
|
|
7749
7891
|
__publicField(this, "count", 0);
|
|
7750
7892
|
__publicField(this, "position");
|
|
7751
7893
|
__publicField(this, "velocity");
|
|
@@ -7866,9 +8008,9 @@ var GameVfx = (() => {
|
|
|
7866
8008
|
position[offset] += velocity[offset] * dt;
|
|
7867
8009
|
position[offset + 1] += velocity[offset + 1] * dt;
|
|
7868
8010
|
position[offset + 2] += velocity[offset + 2] * dt;
|
|
7869
|
-
if (
|
|
8011
|
+
if (confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
|
|
7870
8012
|
const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
|
|
7871
|
-
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
|
|
8013
|
+
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt, size * INNER_OF_SIZE)) {
|
|
7872
8014
|
const out = confiner.out;
|
|
7873
8015
|
position[offset] = out.x;
|
|
7874
8016
|
position[offset + 1] = out.y;
|
|
@@ -8172,7 +8314,7 @@ var GameVfx = (() => {
|
|
|
8172
8314
|
const profile = options.profile ?? PROFILES.high;
|
|
8173
8315
|
this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace, ...options.confiner ? { confiner: options.confiner } : {} };
|
|
8174
8316
|
this.add = new SpritePool(profile.sprites.add, this.context);
|
|
8175
|
-
this.normal = new SpritePool(profile.sprites.normal, this.context
|
|
8317
|
+
this.normal = new SpritePool(profile.sprites.normal, this.context);
|
|
8176
8318
|
this.streaks = new StreakPool(profile.streaks, this.context);
|
|
8177
8319
|
this.debris = new DebrisPool(this.context);
|
|
8178
8320
|
this.decals = new DecalPool(this.context);
|