@adatechnology/game-vfx 0.17.0 → 0.19.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 -0
- package/dist/index.d.ts +128 -90
- package/dist/index.global.js +295 -40
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +295 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -44,6 +44,7 @@ var GameVfx = (() => {
|
|
|
44
44
|
OrderedPool: () => OrderedPool,
|
|
45
45
|
PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
|
|
46
46
|
PROFILES: () => PROFILES,
|
|
47
|
+
PUFF_REACH: () => PUFF_REACH,
|
|
47
48
|
RAIN_CAPACITY: () => RAIN_CAPACITY,
|
|
48
49
|
RainField: () => RainField,
|
|
49
50
|
SCRAPE_LIMIT: () => SCRAPE_LIMIT,
|
|
@@ -1203,11 +1204,11 @@ var GameVfx = (() => {
|
|
|
1203
1204
|
this.spare.push(record);
|
|
1204
1205
|
}
|
|
1205
1206
|
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
1206
|
-
compact(
|
|
1207
|
+
compact(keep2, context) {
|
|
1207
1208
|
let write = 0;
|
|
1208
1209
|
for (let read = 0; read < this.items.length; read++) {
|
|
1209
1210
|
const record = this.items[read];
|
|
1210
|
-
if (
|
|
1211
|
+
if (keep2(record, context)) {
|
|
1211
1212
|
this.items[write++] = record;
|
|
1212
1213
|
continue;
|
|
1213
1214
|
}
|
|
@@ -1492,9 +1493,74 @@ var GameVfx = (() => {
|
|
|
1492
1493
|
return lehmer(mixEventSeed(eventSeed));
|
|
1493
1494
|
}
|
|
1494
1495
|
|
|
1495
|
-
// src/
|
|
1496
|
-
var SKIN = 5e-3;
|
|
1496
|
+
// src/solids.ts
|
|
1497
1497
|
var MAX_PAD = 0.45;
|
|
1498
|
+
var SKIN = 5e-3;
|
|
1499
|
+
var Solids = class {
|
|
1500
|
+
constructor() {
|
|
1501
|
+
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1502
|
+
__publicField(this, "list", []);
|
|
1503
|
+
// fractions from the start: the fields hold fractions, and a field that held a whole number first boxes each fraction written to it
|
|
1504
|
+
__publicField(this, "hit", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1505
|
+
}
|
|
1506
|
+
get empty() {
|
|
1507
|
+
return this.list.length === 0;
|
|
1508
|
+
}
|
|
1509
|
+
/** Declares or (with `null`) ends the solids `id` answers for. */
|
|
1510
|
+
set(id, query2) {
|
|
1511
|
+
if (query2) this.queries.set(id, query2);
|
|
1512
|
+
else this.queries.delete(id);
|
|
1513
|
+
this.list = [...this.queries.values()];
|
|
1514
|
+
}
|
|
1515
|
+
clear() {
|
|
1516
|
+
this.queries.clear();
|
|
1517
|
+
this.list = [];
|
|
1518
|
+
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Stops a step that goes into a solid: `out` gets the nearest hit, put back the step's `pad` metres (at most `MAX_PAD`) off the surface (never behind where the step began) and
|
|
1521
|
+
* the surface's normal. Answers whether the step was stopped.
|
|
1522
|
+
*/
|
|
1523
|
+
stop(move, out) {
|
|
1524
|
+
const dx = move.x1 - move.x0;
|
|
1525
|
+
const dy = move.y1 - move.y0;
|
|
1526
|
+
const dz = move.z1 - move.z0;
|
|
1527
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1528
|
+
if (!(length > 0)) return false;
|
|
1529
|
+
let nearest = Infinity;
|
|
1530
|
+
const list = this.list;
|
|
1531
|
+
for (let index = 0; index < list.length; index++) {
|
|
1532
|
+
if (!list[index](move, this.hit)) continue;
|
|
1533
|
+
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1534
|
+
if (reached >= nearest) continue;
|
|
1535
|
+
nearest = reached;
|
|
1536
|
+
out.x = this.hit.x;
|
|
1537
|
+
out.y = this.hit.y;
|
|
1538
|
+
out.z = this.hit.z;
|
|
1539
|
+
out.nx = this.hit.nx;
|
|
1540
|
+
out.ny = this.hit.ny;
|
|
1541
|
+
out.nz = this.hit.nz;
|
|
1542
|
+
}
|
|
1543
|
+
if (nearest === Infinity) return false;
|
|
1544
|
+
const hitX2 = out.x;
|
|
1545
|
+
const hitY2 = out.y;
|
|
1546
|
+
const hitZ = out.z;
|
|
1547
|
+
out.d = out.nx * hitX2 + out.ny * hitY2 + out.nz * hitZ;
|
|
1548
|
+
const back = Math.min(Math.min(Math.max(move.pad, 0), MAX_PAD) + SKIN, Math.max(nearest, 0));
|
|
1549
|
+
out.x -= dx / length * back;
|
|
1550
|
+
out.y -= dy / length * back;
|
|
1551
|
+
out.z -= dz / length * back;
|
|
1552
|
+
const off = (out.x - hitX2) * out.nx + (out.y - hitY2) * out.ny + (out.z - hitZ) * out.nz;
|
|
1553
|
+
if (off < SKIN) {
|
|
1554
|
+
out.x += out.nx * (SKIN - off);
|
|
1555
|
+
out.y += out.ny * (SKIN - off);
|
|
1556
|
+
out.z += out.nz * (SKIN - off);
|
|
1557
|
+
}
|
|
1558
|
+
return true;
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
|
|
1562
|
+
// src/enclosures.ts
|
|
1563
|
+
var SKIN2 = 5e-3;
|
|
1498
1564
|
function rotation(q) {
|
|
1499
1565
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
1500
1566
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -1519,16 +1585,21 @@ var GameVfx = (() => {
|
|
|
1519
1585
|
__publicField(this, "spaces", /* @__PURE__ */ new Map());
|
|
1520
1586
|
__publicField(this, "list", []);
|
|
1521
1587
|
__publicField(this, "random");
|
|
1522
|
-
__publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1588
|
+
__publicField(this, "out", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1523
1589
|
__publicField(this, "l0", new Float64Array(3));
|
|
1524
1590
|
__publicField(this, "l1", new Float64Array(3));
|
|
1525
1591
|
__publicField(this, "q", new Float64Array(3));
|
|
1526
1592
|
__publicField(this, "h", new Float64Array(3));
|
|
1527
1593
|
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1594
|
+
__publicField(this, "solids", new Solids());
|
|
1528
1595
|
this.random = lehmer(seed);
|
|
1529
1596
|
}
|
|
1530
1597
|
get empty() {
|
|
1531
|
-
return this.list.length === 0;
|
|
1598
|
+
return this.list.length === 0 && this.solids.empty;
|
|
1599
|
+
}
|
|
1600
|
+
/** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
|
|
1601
|
+
solid(id, query2) {
|
|
1602
|
+
this.solids.set(id, query2);
|
|
1532
1603
|
}
|
|
1533
1604
|
get size() {
|
|
1534
1605
|
return this.list.length;
|
|
@@ -1589,7 +1660,7 @@ var GameVfx = (() => {
|
|
|
1589
1660
|
}
|
|
1590
1661
|
/** Passes at `rate` per second. */
|
|
1591
1662
|
chance(rate, dt) {
|
|
1592
|
-
return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1663
|
+
return rate > 0 && dt > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1593
1664
|
}
|
|
1594
1665
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1595
1666
|
through(s, q, dt) {
|
|
@@ -1611,6 +1682,10 @@ var GameVfx = (() => {
|
|
|
1611
1682
|
return this.confineMove(move, dt);
|
|
1612
1683
|
}
|
|
1613
1684
|
confineMove(move, dt) {
|
|
1685
|
+
if (this.confineSpaces(move, dt)) return true;
|
|
1686
|
+
return !this.solids.empty && this.solids.stop(move, this.out);
|
|
1687
|
+
}
|
|
1688
|
+
confineSpaces(move, dt) {
|
|
1614
1689
|
const list = this.list;
|
|
1615
1690
|
if (list.length === 0) return false;
|
|
1616
1691
|
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
@@ -1651,7 +1726,7 @@ var GameVfx = (() => {
|
|
|
1651
1726
|
}
|
|
1652
1727
|
}
|
|
1653
1728
|
sign = l1[axis2] < 0 ? -1 : 1;
|
|
1654
|
-
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] -
|
|
1729
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
|
|
1655
1730
|
sign = -sign;
|
|
1656
1731
|
} else {
|
|
1657
1732
|
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
@@ -1668,7 +1743,7 @@ var GameVfx = (() => {
|
|
|
1668
1743
|
}
|
|
1669
1744
|
}
|
|
1670
1745
|
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1671
|
-
l1[axis2] = sign * (h[axis2] + bound +
|
|
1746
|
+
l1[axis2] = sign * (h[axis2] + bound + SKIN2);
|
|
1672
1747
|
}
|
|
1673
1748
|
const r = s.r;
|
|
1674
1749
|
const out = this.out;
|
|
@@ -1678,6 +1753,7 @@ var GameVfx = (() => {
|
|
|
1678
1753
|
out.nx = r[axis2] * sign;
|
|
1679
1754
|
out.ny = r[3 + axis2] * sign;
|
|
1680
1755
|
out.nz = r[6 + axis2] * sign;
|
|
1756
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -h[axis2] : h[axis2]);
|
|
1681
1757
|
return true;
|
|
1682
1758
|
}
|
|
1683
1759
|
return false;
|
|
@@ -1696,6 +1772,129 @@ var GameVfx = (() => {
|
|
|
1696
1772
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
1697
1773
|
}
|
|
1698
1774
|
|
|
1775
|
+
// src/pools/puff-cuts.ts
|
|
1776
|
+
var PUFF_REACH = 1.28;
|
|
1777
|
+
var PROBES = [{ x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }, { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }, { x: 0, y: 1, z: 0 }];
|
|
1778
|
+
var PROBES_PER_SECOND = 60;
|
|
1779
|
+
var FRAMES_PER_PROBE = 3;
|
|
1780
|
+
var GROUND_FACING = 0.7;
|
|
1781
|
+
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 };
|
|
1783
|
+
var KeptCut = class {
|
|
1784
|
+
constructor() {
|
|
1785
|
+
__publicField(this, "on", false);
|
|
1786
|
+
__publicField(this, "nx", 0.5);
|
|
1787
|
+
__publicField(this, "ny", 0.5);
|
|
1788
|
+
__publicField(this, "nz", 0.5);
|
|
1789
|
+
__publicField(this, "d", 0.5);
|
|
1790
|
+
}
|
|
1791
|
+
};
|
|
1792
|
+
function createCut() {
|
|
1793
|
+
return new KeptCut();
|
|
1794
|
+
}
|
|
1795
|
+
function clearCuts(puff3) {
|
|
1796
|
+
puff3.cuts[0].on = false;
|
|
1797
|
+
puff3.cuts[1].on = false;
|
|
1798
|
+
}
|
|
1799
|
+
var WrittenWay = class {
|
|
1800
|
+
constructor() {
|
|
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();
|
|
1807
|
+
function probe(confiner, puff3, way) {
|
|
1808
|
+
const reach = puff3.size * PUFF_REACH;
|
|
1809
|
+
if (!(reach > 0)) return false;
|
|
1810
|
+
PROBE.x0 = puff3.x;
|
|
1811
|
+
PROBE.y0 = puff3.y;
|
|
1812
|
+
PROBE.z0 = puff3.z;
|
|
1813
|
+
PROBE.x1 = puff3.x + way.x * reach;
|
|
1814
|
+
PROBE.y1 = puff3.y + way.y * reach;
|
|
1815
|
+
PROBE.z1 = puff3.z + way.z * reach;
|
|
1816
|
+
PROBE.pad = 0;
|
|
1817
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1818
|
+
}
|
|
1819
|
+
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;
|
|
1821
|
+
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1822
|
+
function cutFor(puff3, face) {
|
|
1823
|
+
const first = puff3.cuts[0];
|
|
1824
|
+
const second = puff3.cuts[1];
|
|
1825
|
+
if (sameWall(first, face)) return first;
|
|
1826
|
+
if (sameWall(second, face)) return second;
|
|
1827
|
+
if (!first.on) return first;
|
|
1828
|
+
if (!second.on) return second;
|
|
1829
|
+
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1830
|
+
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1831
|
+
}
|
|
1832
|
+
function cutAtFace(puff3, face) {
|
|
1833
|
+
if (face.ny > GROUND_FACING) return;
|
|
1834
|
+
const cut = cutFor(puff3, face);
|
|
1835
|
+
if (!cut) return;
|
|
1836
|
+
cut.on = true;
|
|
1837
|
+
cut.nx = face.nx;
|
|
1838
|
+
cut.ny = face.ny;
|
|
1839
|
+
cut.nz = face.nz;
|
|
1840
|
+
cut.d = face.d;
|
|
1841
|
+
}
|
|
1842
|
+
function cutFrom(puff3, out) {
|
|
1843
|
+
cutAtFace(puff3, out);
|
|
1844
|
+
}
|
|
1845
|
+
function cutAt(confiner, puff3, way) {
|
|
1846
|
+
if (!probe(confiner, puff3, way)) return false;
|
|
1847
|
+
cutAtFace(puff3, confiner.out);
|
|
1848
|
+
return true;
|
|
1849
|
+
}
|
|
1850
|
+
function backward(puff3) {
|
|
1851
|
+
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1852
|
+
if (!(speed > 0)) return null;
|
|
1853
|
+
WAY.x = -puff3.vx / speed;
|
|
1854
|
+
WAY.y = -puff3.vy / speed;
|
|
1855
|
+
WAY.z = -puff3.vz / speed;
|
|
1856
|
+
return WAY;
|
|
1857
|
+
}
|
|
1858
|
+
function along(cut, sign) {
|
|
1859
|
+
WAY.x = sign * cut.nx;
|
|
1860
|
+
WAY.y = sign * cut.ny;
|
|
1861
|
+
WAY.z = sign * cut.nz;
|
|
1862
|
+
return WAY;
|
|
1863
|
+
}
|
|
1864
|
+
function dropPassed(confiner, puff3) {
|
|
1865
|
+
for (let i = 0; i < 2; i++) {
|
|
1866
|
+
const cut = puff3.cuts[i];
|
|
1867
|
+
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1868
|
+
cut.on = false;
|
|
1869
|
+
cutAt(confiner, puff3, along(cut, 1));
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
function keep(confiner, puff3, cut) {
|
|
1873
|
+
if (!cut.on) return;
|
|
1874
|
+
if (!probe(confiner, puff3, along(cut, -1))) {
|
|
1875
|
+
cut.on = false;
|
|
1876
|
+
return;
|
|
1877
|
+
}
|
|
1878
|
+
cut.d = confiner.out.d;
|
|
1879
|
+
}
|
|
1880
|
+
function lookForWalls(confiner, puff3) {
|
|
1881
|
+
dropPassed(confiner, puff3);
|
|
1882
|
+
const turn = Math.round(puff3.t * PROBES_PER_SECOND);
|
|
1883
|
+
if (turn <= 1) {
|
|
1884
|
+
const back = backward(puff3);
|
|
1885
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1886
|
+
for (let i = 0; i < PROBES.length; i++) cutAt(confiner, puff3, PROBES[i]);
|
|
1887
|
+
return;
|
|
1888
|
+
}
|
|
1889
|
+
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1890
|
+
const slot = turn / FRAMES_PER_PROBE % (PROBES.length + 3);
|
|
1891
|
+
if (slot < 2) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1892
|
+
else if (slot === 2) {
|
|
1893
|
+
const back = backward(puff3);
|
|
1894
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1895
|
+
} else cutAt(confiner, puff3, PROBES[slot - 3]);
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1699
1898
|
// src/pools/puffs.ts
|
|
1700
1899
|
var FLOOR_FRACTION = 0.4;
|
|
1701
1900
|
var FLOOR_BOUNCE = -0.2;
|
|
@@ -1736,7 +1935,8 @@ var GameVfx = (() => {
|
|
|
1736
1935
|
age: 0,
|
|
1737
1936
|
heat: 0,
|
|
1738
1937
|
size: 0,
|
|
1739
|
-
source: void 0
|
|
1938
|
+
source: void 0,
|
|
1939
|
+
cuts: [createCut(), createCut()]
|
|
1740
1940
|
}));
|
|
1741
1941
|
}
|
|
1742
1942
|
function spawnPuff(pool, random, init) {
|
|
@@ -1770,6 +1970,7 @@ var GameVfx = (() => {
|
|
|
1770
1970
|
puff3.heat = 0;
|
|
1771
1971
|
puff3.size = 0;
|
|
1772
1972
|
puff3.source = init.source;
|
|
1973
|
+
clearCuts(puff3);
|
|
1773
1974
|
return puff3;
|
|
1774
1975
|
}
|
|
1775
1976
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1819,17 +2020,21 @@ var GameVfx = (() => {
|
|
|
1819
2020
|
MOVE.z0 = puff3.z;
|
|
1820
2021
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1821
2022
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1822
|
-
|
|
2023
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
2024
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
1823
2025
|
const out = confiner.out;
|
|
1824
2026
|
puff3.x = out.x;
|
|
1825
2027
|
puff3.y = out.y;
|
|
1826
2028
|
puff3.z = out.z;
|
|
1827
2029
|
slideInto(out, puff3);
|
|
2030
|
+
cutFrom(puff3, out);
|
|
1828
2031
|
}
|
|
1829
2032
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1830
2033
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1831
2034
|
puff3.age = age;
|
|
1832
2035
|
puff3.heat = heat;
|
|
2036
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
2037
|
+
else clearCuts(puff3);
|
|
1833
2038
|
}
|
|
1834
2039
|
}
|
|
1835
2040
|
|
|
@@ -4957,10 +5162,10 @@ var GameVfx = (() => {
|
|
|
4957
5162
|
var MAX_SCALE = 3;
|
|
4958
5163
|
var MIN_SCALE = 0.6;
|
|
4959
5164
|
function reflected(direction, normal) {
|
|
4960
|
-
const
|
|
4961
|
-
const out = [direction[0] - 2 *
|
|
5165
|
+
const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
5166
|
+
const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
|
|
4962
5167
|
const length = Math.hypot(out[0], out[1], out[2]);
|
|
4963
|
-
if (length < 1e-6 || Math.abs(
|
|
5168
|
+
if (length < 1e-6 || Math.abs(along2) > 0.98) return normal;
|
|
4964
5169
|
return [out[0] / length, out[1] / length, out[2] / length];
|
|
4965
5170
|
}
|
|
4966
5171
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -5839,6 +6044,24 @@ var GameVfx = (() => {
|
|
|
5839
6044
|
screen2.flashDecay = 0.5;
|
|
5840
6045
|
}
|
|
5841
6046
|
}
|
|
6047
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
6048
|
+
function bornFrom(core, puff3, ox, oy, oz) {
|
|
6049
|
+
const confiner = core.confiner;
|
|
6050
|
+
if (confiner.empty) return;
|
|
6051
|
+
BIRTH.x0 = ox;
|
|
6052
|
+
BIRTH.y0 = oy;
|
|
6053
|
+
BIRTH.z0 = oz;
|
|
6054
|
+
BIRTH.x1 = puff3.x;
|
|
6055
|
+
BIRTH.y1 = puff3.y;
|
|
6056
|
+
BIRTH.z1 = puff3.z;
|
|
6057
|
+
BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
|
|
6058
|
+
if (!confiner.confineMove(BIRTH, 0)) return;
|
|
6059
|
+
const out = confiner.out;
|
|
6060
|
+
puff3.x = out.x;
|
|
6061
|
+
puff3.y = out.y;
|
|
6062
|
+
puff3.z = out.z;
|
|
6063
|
+
slideInto(out, puff3);
|
|
6064
|
+
}
|
|
5842
6065
|
function composeFireballs(context) {
|
|
5843
6066
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5844
6067
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5855,7 +6078,7 @@ var GameVfx = (() => {
|
|
|
5855
6078
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life);
|
|
5856
6079
|
const h0 = random.between(1.05, 1.35) * heat;
|
|
5857
6080
|
const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
|
|
5858
|
-
addPuff(core, random, {
|
|
6081
|
+
const fireball = addPuff(core, random, {
|
|
5859
6082
|
x: x + d.x * size * 0.15,
|
|
5860
6083
|
y: y + size * 0.25 + d.y * size * 0.1,
|
|
5861
6084
|
z: z + d.z * size * 0.15,
|
|
@@ -5874,6 +6097,7 @@ var GameVfx = (() => {
|
|
|
5874
6097
|
color: context.smokeColor,
|
|
5875
6098
|
kind: 0
|
|
5876
6099
|
});
|
|
6100
|
+
bornFrom(core, fireball, x, y, z);
|
|
5877
6101
|
}
|
|
5878
6102
|
}
|
|
5879
6103
|
function composeSmoke(context) {
|
|
@@ -5887,7 +6111,7 @@ var GameVfx = (() => {
|
|
|
5887
6111
|
const s1 = size * random.between(0.55, 0.85);
|
|
5888
6112
|
const sg = size * random.between(0.18, 0.3);
|
|
5889
6113
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
|
|
5890
|
-
addPuff(core, random, {
|
|
6114
|
+
const smoke = addPuff(core, random, {
|
|
5891
6115
|
x: x + d.x * size * 0.6,
|
|
5892
6116
|
y: y + size * 0.4 + d.y * size * 0.5,
|
|
5893
6117
|
z: z + d.z * size * 0.6,
|
|
@@ -5906,6 +6130,7 @@ var GameVfx = (() => {
|
|
|
5906
6130
|
color: context.smokeColor,
|
|
5907
6131
|
kind: def.smoke.kind ?? 0
|
|
5908
6132
|
});
|
|
6133
|
+
bornFrom(core, smoke, x, y, z);
|
|
5909
6134
|
}
|
|
5910
6135
|
}
|
|
5911
6136
|
function composeShock(context) {
|
|
@@ -5917,7 +6142,7 @@ var GameVfx = (() => {
|
|
|
5917
6142
|
spawnShock(core.shocks, spec);
|
|
5918
6143
|
}
|
|
5919
6144
|
function composeDust(context) {
|
|
5920
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
6145
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
5921
6146
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
5922
6147
|
const count = Math.round(def.dust.count * scale);
|
|
5923
6148
|
const color = hexToLinearRgb(def.dust.color);
|
|
@@ -5930,7 +6155,7 @@ var GameVfx = (() => {
|
|
|
5930
6155
|
const s1 = size * random.between(0.5, 0.8);
|
|
5931
6156
|
const sg = size * random.between(0.2, 0.35);
|
|
5932
6157
|
const life = random.between(2.2, 4);
|
|
5933
|
-
addPuff(core, random, {
|
|
6158
|
+
const dust = addPuff(core, random, {
|
|
5934
6159
|
x: x + Math.cos(angle) * 0.3,
|
|
5935
6160
|
y: 0.15,
|
|
5936
6161
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -5947,6 +6172,7 @@ var GameVfx = (() => {
|
|
|
5947
6172
|
color,
|
|
5948
6173
|
kind: 1
|
|
5949
6174
|
});
|
|
6175
|
+
bornFrom(core, dust, x, y, z);
|
|
5950
6176
|
}
|
|
5951
6177
|
}
|
|
5952
6178
|
function coneAngle(context) {
|
|
@@ -6283,6 +6509,9 @@ var GameVfx = (() => {
|
|
|
6283
6509
|
|
|
6284
6510
|
// src/sprites/kind-pool.ts
|
|
6285
6511
|
var PAD_OF_SIZE2 = 0.35;
|
|
6512
|
+
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6513
|
+
var GROUND_RESAMPLE = 0.1;
|
|
6514
|
+
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6286
6515
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6287
6516
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6288
6517
|
function rgb(hex) {
|
|
@@ -6330,6 +6559,8 @@ var GameVfx = (() => {
|
|
|
6330
6559
|
__publicField(this, "bounced");
|
|
6331
6560
|
__publicField(this, "floor");
|
|
6332
6561
|
__publicField(this, "riseMul");
|
|
6562
|
+
/** The ground under each sprite as last asked (`GROUND_RESAMPLE`): x and z where it was asked, and its height. NaN x: not asked yet. */
|
|
6563
|
+
__publicField(this, "ground");
|
|
6333
6564
|
const n = Math.max(1, capacity);
|
|
6334
6565
|
this.position = new Float32Array(n * 3);
|
|
6335
6566
|
this.color = new Float32Array(n * 3);
|
|
@@ -6352,6 +6583,7 @@ var GameVfx = (() => {
|
|
|
6352
6583
|
this.bounced = new Uint8Array(n);
|
|
6353
6584
|
this.floor = new Float32Array(n);
|
|
6354
6585
|
this.riseMul = new Float32Array(n);
|
|
6586
|
+
this.ground = new Float32Array(n * 3);
|
|
6355
6587
|
}
|
|
6356
6588
|
spawn(kind, p, v, random, options) {
|
|
6357
6589
|
if (this.capacity <= 0) return;
|
|
@@ -6379,6 +6611,7 @@ var GameVfx = (() => {
|
|
|
6379
6611
|
this.bounced[i] = 0;
|
|
6380
6612
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
6381
6613
|
this.riseMul[i] = options?.rise ?? 1;
|
|
6614
|
+
this.ground[i * 3] = Number.NaN;
|
|
6382
6615
|
this.size[i] = this.size0[i];
|
|
6383
6616
|
this.alpha[i] = 0;
|
|
6384
6617
|
}
|
|
@@ -6472,18 +6705,36 @@ var GameVfx = (() => {
|
|
|
6472
6705
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6473
6706
|
const confiner = host.confiner;
|
|
6474
6707
|
if (def.carried && confiner && !confiner.empty) {
|
|
6475
|
-
|
|
6476
|
-
|
|
6708
|
+
STEP.x0 = this.position[i3];
|
|
6709
|
+
STEP.y0 = this.position[i3 + 1];
|
|
6710
|
+
STEP.z0 = this.position[i3 + 2];
|
|
6711
|
+
STEP.x1 = x;
|
|
6712
|
+
STEP.y1 = y;
|
|
6713
|
+
STEP.z1 = z;
|
|
6714
|
+
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6715
|
+
if (confiner.confineMove(STEP, dt)) {
|
|
6477
6716
|
const out = confiner.out;
|
|
6478
6717
|
x = out.x;
|
|
6479
6718
|
y = out.y;
|
|
6480
6719
|
z = out.z;
|
|
6481
|
-
|
|
6720
|
+
VELOCITY.vx = vx2;
|
|
6721
|
+
VELOCITY.vy = vy2;
|
|
6722
|
+
VELOCITY.vz = vz2;
|
|
6723
|
+
slideInto(out, VELOCITY);
|
|
6724
|
+
vx2 = VELOCITY.vx;
|
|
6725
|
+
vy2 = VELOCITY.vy;
|
|
6726
|
+
vz2 = VELOCITY.vz;
|
|
6482
6727
|
}
|
|
6483
6728
|
}
|
|
6484
6729
|
if (def.ground !== "none") {
|
|
6485
6730
|
const own = this.floor[i];
|
|
6486
|
-
const
|
|
6731
|
+
const ground = this.ground;
|
|
6732
|
+
if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
|
|
6733
|
+
ground[i3] = x;
|
|
6734
|
+
ground[i3 + 1] = z;
|
|
6735
|
+
ground[i3 + 2] = host.groundAt(x, z);
|
|
6736
|
+
}
|
|
6737
|
+
const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
|
|
6487
6738
|
if (y < gy) {
|
|
6488
6739
|
if (def.ground === "land") {
|
|
6489
6740
|
const tag = this.tag[i];
|
|
@@ -7355,10 +7606,10 @@ var GameVfx = (() => {
|
|
|
7355
7606
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
7356
7607
|
particle.vy -= particle.gravity * dt;
|
|
7357
7608
|
if (particle.drag) {
|
|
7358
|
-
const
|
|
7359
|
-
particle.vx *=
|
|
7360
|
-
particle.vy *=
|
|
7361
|
-
particle.vz *=
|
|
7609
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
7610
|
+
particle.vx *= keep2;
|
|
7611
|
+
particle.vy *= keep2;
|
|
7612
|
+
particle.vz *= keep2;
|
|
7362
7613
|
}
|
|
7363
7614
|
if (particle.carried) this.ride(particle, dt);
|
|
7364
7615
|
else {
|
|
@@ -8066,6 +8317,7 @@ var GameVfx = (() => {
|
|
|
8066
8317
|
});
|
|
8067
8318
|
const core = {
|
|
8068
8319
|
profile,
|
|
8320
|
+
confiner: enclosures,
|
|
8069
8321
|
puffs: createPuffPool(profile.puffs),
|
|
8070
8322
|
sparks: createSparkPool(profile.sparks),
|
|
8071
8323
|
glows: createGlowPool(profile.glows),
|
|
@@ -8206,6 +8458,9 @@ var GameVfx = (() => {
|
|
|
8206
8458
|
enclose(id, enclosure) {
|
|
8207
8459
|
enclosures.set(id, enclosure);
|
|
8208
8460
|
},
|
|
8461
|
+
solid(id, query2) {
|
|
8462
|
+
enclosures.solid(id, query2);
|
|
8463
|
+
},
|
|
8209
8464
|
enclosures: () => enclosures,
|
|
8210
8465
|
stop(handle) {
|
|
8211
8466
|
player?.stop(handle);
|
|
@@ -8213,10 +8468,10 @@ var GameVfx = (() => {
|
|
|
8213
8468
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
8214
8469
|
},
|
|
8215
8470
|
clearSource(source) {
|
|
8216
|
-
const
|
|
8471
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
8217
8472
|
const drop = (pool) => {
|
|
8218
8473
|
const before = pool.count;
|
|
8219
|
-
pool.compact(
|
|
8474
|
+
pool.compact(keep2, source);
|
|
8220
8475
|
return before - pool.count;
|
|
8221
8476
|
};
|
|
8222
8477
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -9390,10 +9645,10 @@ var GameVfx = (() => {
|
|
|
9390
9645
|
function moveDrop(drop, context) {
|
|
9391
9646
|
const { dt } = context;
|
|
9392
9647
|
drop.age += dt;
|
|
9393
|
-
const
|
|
9394
|
-
drop.vx *=
|
|
9395
|
-
drop.vz *=
|
|
9396
|
-
drop.vy = drop.vy *
|
|
9648
|
+
const keep2 = Math.exp(-DROP_DRAG * dt);
|
|
9649
|
+
drop.vx *= keep2;
|
|
9650
|
+
drop.vz *= keep2;
|
|
9651
|
+
drop.vy = drop.vy * keep2 - WATER_GRAVITY * dt;
|
|
9397
9652
|
drop.x += drop.vx * dt;
|
|
9398
9653
|
drop.y += drop.vy * dt;
|
|
9399
9654
|
drop.z += drop.vz * dt;
|
|
@@ -9453,10 +9708,10 @@ var GameVfx = (() => {
|
|
|
9453
9708
|
}
|
|
9454
9709
|
function ageMist(mist, dt) {
|
|
9455
9710
|
mist.age += dt;
|
|
9456
|
-
const
|
|
9457
|
-
mist.vx *=
|
|
9458
|
-
mist.vy = mist.vy *
|
|
9459
|
-
mist.vz *=
|
|
9711
|
+
const keep2 = Math.exp(-MIST_DRAG * dt);
|
|
9712
|
+
mist.vx *= keep2;
|
|
9713
|
+
mist.vy = mist.vy * keep2 - 0.15 * dt;
|
|
9714
|
+
mist.vz *= keep2;
|
|
9460
9715
|
mist.x += mist.vx * dt;
|
|
9461
9716
|
mist.y += mist.vy * dt;
|
|
9462
9717
|
mist.z += mist.vz * dt;
|
|
@@ -9829,10 +10084,10 @@ var GameVfx = (() => {
|
|
|
9829
10084
|
const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
|
|
9830
10085
|
const [ex, ey, ez] = plan.trailEnd;
|
|
9831
10086
|
for (let index = 0; index < count; index++) {
|
|
9832
|
-
const
|
|
9833
|
-
const jitter = 0.01 + 0.02 *
|
|
9834
|
-
const at3 = [point[0] + (ex - point[0]) *
|
|
9835
|
-
addBubble(context, at3, point[1],
|
|
10087
|
+
const along2 = random.next() ** 1.6;
|
|
10088
|
+
const jitter = 0.01 + 0.02 * along2;
|
|
10089
|
+
const at3 = [point[0] + (ex - point[0]) * along2 + random.between(-jitter, jitter), point[1] + (ey - point[1]) * along2, point[2] + (ez - point[2]) * along2 + random.between(-jitter, jitter)];
|
|
10090
|
+
addBubble(context, at3, point[1], along2 * 0.05, random.between(3e-3, 0.01));
|
|
9836
10091
|
}
|
|
9837
10092
|
}
|
|
9838
10093
|
function spawnBlast(context, point, level, plan) {
|