@adatechnology/game-vfx 0.18.0 → 0.20.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 +1 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.global.js +361 -112
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +361 -112
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1106,11 +1106,11 @@ var OrderedPool = class {
|
|
|
1106
1106
|
this.spare.push(record);
|
|
1107
1107
|
}
|
|
1108
1108
|
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
1109
|
-
compact(
|
|
1109
|
+
compact(keep2, context) {
|
|
1110
1110
|
let write = 0;
|
|
1111
1111
|
for (let read = 0; read < this.items.length; read++) {
|
|
1112
1112
|
const record = this.items[read];
|
|
1113
|
-
if (
|
|
1113
|
+
if (keep2(record, context)) {
|
|
1114
1114
|
this.items[write++] = record;
|
|
1115
1115
|
continue;
|
|
1116
1116
|
}
|
|
@@ -1396,12 +1396,14 @@ function streamFor(eventSeed) {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
|
|
1398
1398
|
// src/solids.ts
|
|
1399
|
+
var MAX_PAD = 0.45;
|
|
1399
1400
|
var SKIN = 5e-3;
|
|
1400
1401
|
var Solids = class {
|
|
1401
1402
|
constructor() {
|
|
1402
1403
|
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1403
1404
|
__publicField(this, "list", []);
|
|
1404
|
-
|
|
1405
|
+
// fractions from the start: the fields hold fractions, and a field that held a whole number first boxes each fraction written to it
|
|
1406
|
+
__publicField(this, "hit", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1405
1407
|
}
|
|
1406
1408
|
get empty() {
|
|
1407
1409
|
return this.list.length === 0;
|
|
@@ -1417,18 +1419,19 @@ var Solids = class {
|
|
|
1417
1419
|
this.list = [];
|
|
1418
1420
|
}
|
|
1419
1421
|
/**
|
|
1420
|
-
* Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
|
|
1422
|
+
* 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
|
|
1421
1423
|
* the surface's normal. Answers whether the step was stopped.
|
|
1422
1424
|
*/
|
|
1423
|
-
stop(move,
|
|
1425
|
+
stop(move, out) {
|
|
1424
1426
|
const dx = move.x1 - move.x0;
|
|
1425
1427
|
const dy = move.y1 - move.y0;
|
|
1426
1428
|
const dz = move.z1 - move.z0;
|
|
1427
|
-
const length = Math.
|
|
1429
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1428
1430
|
if (!(length > 0)) return false;
|
|
1429
1431
|
let nearest = Infinity;
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
+
const list = this.list;
|
|
1433
|
+
for (let index = 0; index < list.length; index++) {
|
|
1434
|
+
if (!list[index](move, this.hit)) continue;
|
|
1432
1435
|
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1433
1436
|
if (reached >= nearest) continue;
|
|
1434
1437
|
nearest = reached;
|
|
@@ -1440,17 +1443,26 @@ var Solids = class {
|
|
|
1440
1443
|
out.nz = this.hit.nz;
|
|
1441
1444
|
}
|
|
1442
1445
|
if (nearest === Infinity) return false;
|
|
1443
|
-
const
|
|
1446
|
+
const hitX2 = out.x;
|
|
1447
|
+
const hitY2 = out.y;
|
|
1448
|
+
const hitZ = out.z;
|
|
1449
|
+
out.d = out.nx * hitX2 + out.ny * hitY2 + out.nz * hitZ;
|
|
1450
|
+
const back = Math.min(Math.min(Math.max(move.pad, 0), MAX_PAD) + SKIN, Math.max(nearest, 0));
|
|
1444
1451
|
out.x -= dx / length * back;
|
|
1445
1452
|
out.y -= dy / length * back;
|
|
1446
1453
|
out.z -= dz / length * back;
|
|
1454
|
+
const off = (out.x - hitX2) * out.nx + (out.y - hitY2) * out.ny + (out.z - hitZ) * out.nz;
|
|
1455
|
+
if (off < SKIN) {
|
|
1456
|
+
out.x += out.nx * (SKIN - off);
|
|
1457
|
+
out.y += out.ny * (SKIN - off);
|
|
1458
|
+
out.z += out.nz * (SKIN - off);
|
|
1459
|
+
}
|
|
1447
1460
|
return true;
|
|
1448
1461
|
}
|
|
1449
1462
|
};
|
|
1450
1463
|
|
|
1451
1464
|
// src/enclosures.ts
|
|
1452
1465
|
var SKIN2 = 5e-3;
|
|
1453
|
-
var MAX_PAD = 0.45;
|
|
1454
1466
|
function rotation(q) {
|
|
1455
1467
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
1456
1468
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -1475,7 +1487,7 @@ var Enclosures = class {
|
|
|
1475
1487
|
__publicField(this, "spaces", /* @__PURE__ */ new Map());
|
|
1476
1488
|
__publicField(this, "list", []);
|
|
1477
1489
|
__publicField(this, "random");
|
|
1478
|
-
__publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1490
|
+
__publicField(this, "out", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1479
1491
|
__publicField(this, "l0", new Float64Array(3));
|
|
1480
1492
|
__publicField(this, "l1", new Float64Array(3));
|
|
1481
1493
|
__publicField(this, "q", new Float64Array(3));
|
|
@@ -1550,7 +1562,7 @@ var Enclosures = class {
|
|
|
1550
1562
|
}
|
|
1551
1563
|
/** Passes at `rate` per second. */
|
|
1552
1564
|
chance(rate, dt) {
|
|
1553
|
-
return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1565
|
+
return rate > 0 && dt > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1554
1566
|
}
|
|
1555
1567
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1556
1568
|
through(s, q, dt) {
|
|
@@ -1573,7 +1585,7 @@ var Enclosures = class {
|
|
|
1573
1585
|
}
|
|
1574
1586
|
confineMove(move, dt) {
|
|
1575
1587
|
if (this.confineSpaces(move, dt)) return true;
|
|
1576
|
-
return !this.solids.empty && this.solids.stop(move,
|
|
1588
|
+
return !this.solids.empty && this.solids.stop(move, this.out);
|
|
1577
1589
|
}
|
|
1578
1590
|
confineSpaces(move, dt) {
|
|
1579
1591
|
const list = this.list;
|
|
@@ -1643,6 +1655,7 @@ var Enclosures = class {
|
|
|
1643
1655
|
out.nx = r[axis2] * sign;
|
|
1644
1656
|
out.ny = r[3 + axis2] * sign;
|
|
1645
1657
|
out.nz = r[6 + axis2] * sign;
|
|
1658
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -h[axis2] : h[axis2]);
|
|
1646
1659
|
return true;
|
|
1647
1660
|
}
|
|
1648
1661
|
return false;
|
|
@@ -1661,6 +1674,129 @@ function slideAlong(out, vx2, vy2, vz2) {
|
|
|
1661
1674
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
1662
1675
|
}
|
|
1663
1676
|
|
|
1677
|
+
// src/pools/puff-cuts.ts
|
|
1678
|
+
var PUFF_REACH = 1.28;
|
|
1679
|
+
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 }];
|
|
1680
|
+
var PROBES_PER_SECOND = 60;
|
|
1681
|
+
var FRAMES_PER_PROBE = 3;
|
|
1682
|
+
var GROUND_FACING = 0.7;
|
|
1683
|
+
var SAME_WALL = 0.9;
|
|
1684
|
+
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
1685
|
+
var KeptCut = class {
|
|
1686
|
+
constructor() {
|
|
1687
|
+
__publicField(this, "on", false);
|
|
1688
|
+
__publicField(this, "nx", 0.5);
|
|
1689
|
+
__publicField(this, "ny", 0.5);
|
|
1690
|
+
__publicField(this, "nz", 0.5);
|
|
1691
|
+
__publicField(this, "d", 0.5);
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
function createCut() {
|
|
1695
|
+
return new KeptCut();
|
|
1696
|
+
}
|
|
1697
|
+
function clearCuts(puff3) {
|
|
1698
|
+
puff3.cuts[0].on = false;
|
|
1699
|
+
puff3.cuts[1].on = false;
|
|
1700
|
+
}
|
|
1701
|
+
var WrittenWay = class {
|
|
1702
|
+
constructor() {
|
|
1703
|
+
__publicField(this, "x", 0.5);
|
|
1704
|
+
__publicField(this, "y", 0.5);
|
|
1705
|
+
__publicField(this, "z", 0.5);
|
|
1706
|
+
}
|
|
1707
|
+
};
|
|
1708
|
+
var WAY = new WrittenWay();
|
|
1709
|
+
function probe(confiner, puff3, way) {
|
|
1710
|
+
const reach = puff3.size * PUFF_REACH;
|
|
1711
|
+
if (!(reach > 0)) return false;
|
|
1712
|
+
PROBE.x0 = puff3.x;
|
|
1713
|
+
PROBE.y0 = puff3.y;
|
|
1714
|
+
PROBE.z0 = puff3.z;
|
|
1715
|
+
PROBE.x1 = puff3.x + way.x * reach;
|
|
1716
|
+
PROBE.y1 = puff3.y + way.y * reach;
|
|
1717
|
+
PROBE.z1 = puff3.z + way.z * reach;
|
|
1718
|
+
PROBE.pad = 0;
|
|
1719
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1720
|
+
}
|
|
1721
|
+
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;
|
|
1722
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d;
|
|
1723
|
+
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1724
|
+
function cutFor(puff3, face) {
|
|
1725
|
+
const first = puff3.cuts[0];
|
|
1726
|
+
const second = puff3.cuts[1];
|
|
1727
|
+
if (sameWall(first, face)) return first;
|
|
1728
|
+
if (sameWall(second, face)) return second;
|
|
1729
|
+
if (!first.on) return first;
|
|
1730
|
+
if (!second.on) return second;
|
|
1731
|
+
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1732
|
+
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1733
|
+
}
|
|
1734
|
+
function cutAtFace(puff3, face) {
|
|
1735
|
+
if (face.ny > GROUND_FACING) return;
|
|
1736
|
+
const cut = cutFor(puff3, face);
|
|
1737
|
+
if (!cut) return;
|
|
1738
|
+
cut.on = true;
|
|
1739
|
+
cut.nx = face.nx;
|
|
1740
|
+
cut.ny = face.ny;
|
|
1741
|
+
cut.nz = face.nz;
|
|
1742
|
+
cut.d = face.d;
|
|
1743
|
+
}
|
|
1744
|
+
function cutFrom(puff3, out) {
|
|
1745
|
+
cutAtFace(puff3, out);
|
|
1746
|
+
}
|
|
1747
|
+
function cutAt(confiner, puff3, way) {
|
|
1748
|
+
if (!probe(confiner, puff3, way)) return false;
|
|
1749
|
+
cutAtFace(puff3, confiner.out);
|
|
1750
|
+
return true;
|
|
1751
|
+
}
|
|
1752
|
+
function backward(puff3) {
|
|
1753
|
+
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1754
|
+
if (!(speed > 0)) return null;
|
|
1755
|
+
WAY.x = -puff3.vx / speed;
|
|
1756
|
+
WAY.y = -puff3.vy / speed;
|
|
1757
|
+
WAY.z = -puff3.vz / speed;
|
|
1758
|
+
return WAY;
|
|
1759
|
+
}
|
|
1760
|
+
function along(cut, sign) {
|
|
1761
|
+
WAY.x = sign * cut.nx;
|
|
1762
|
+
WAY.y = sign * cut.ny;
|
|
1763
|
+
WAY.z = sign * cut.nz;
|
|
1764
|
+
return WAY;
|
|
1765
|
+
}
|
|
1766
|
+
function dropPassed(confiner, puff3) {
|
|
1767
|
+
for (let i = 0; i < 2; i++) {
|
|
1768
|
+
const cut = puff3.cuts[i];
|
|
1769
|
+
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1770
|
+
cut.on = false;
|
|
1771
|
+
cutAt(confiner, puff3, along(cut, 1));
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
function keep(confiner, puff3, cut) {
|
|
1775
|
+
if (!cut.on) return;
|
|
1776
|
+
if (!probe(confiner, puff3, along(cut, -1))) {
|
|
1777
|
+
cut.on = false;
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
cut.d = confiner.out.d;
|
|
1781
|
+
}
|
|
1782
|
+
function lookForWalls(confiner, puff3) {
|
|
1783
|
+
dropPassed(confiner, puff3);
|
|
1784
|
+
const turn = Math.round(puff3.t * PROBES_PER_SECOND);
|
|
1785
|
+
if (turn <= 1) {
|
|
1786
|
+
const back = backward(puff3);
|
|
1787
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1788
|
+
for (let i = 0; i < PROBES.length; i++) cutAt(confiner, puff3, PROBES[i]);
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1792
|
+
const slot = turn / FRAMES_PER_PROBE % (PROBES.length + 3);
|
|
1793
|
+
if (slot < 2) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1794
|
+
else if (slot === 2) {
|
|
1795
|
+
const back = backward(puff3);
|
|
1796
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1797
|
+
} else cutAt(confiner, puff3, PROBES[slot - 3]);
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1664
1800
|
// src/pools/puffs.ts
|
|
1665
1801
|
var FLOOR_FRACTION = 0.4;
|
|
1666
1802
|
var FLOOR_BOUNCE = -0.2;
|
|
@@ -1701,7 +1837,8 @@ function createPuffPool(capacity) {
|
|
|
1701
1837
|
age: 0,
|
|
1702
1838
|
heat: 0,
|
|
1703
1839
|
size: 0,
|
|
1704
|
-
source: void 0
|
|
1840
|
+
source: void 0,
|
|
1841
|
+
cuts: [createCut(), createCut()]
|
|
1705
1842
|
}));
|
|
1706
1843
|
}
|
|
1707
1844
|
function spawnPuff(pool, random, init) {
|
|
@@ -1735,6 +1872,7 @@ function spawnPuff(pool, random, init) {
|
|
|
1735
1872
|
puff3.heat = 0;
|
|
1736
1873
|
puff3.size = 0;
|
|
1737
1874
|
puff3.source = init.source;
|
|
1875
|
+
clearCuts(puff3);
|
|
1738
1876
|
return puff3;
|
|
1739
1877
|
}
|
|
1740
1878
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1784,17 +1922,21 @@ function updatePuffs(pool, dt, wind, confiner) {
|
|
|
1784
1922
|
MOVE.z0 = puff3.z;
|
|
1785
1923
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1786
1924
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1787
|
-
|
|
1925
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
1926
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
1788
1927
|
const out = confiner.out;
|
|
1789
1928
|
puff3.x = out.x;
|
|
1790
1929
|
puff3.y = out.y;
|
|
1791
1930
|
puff3.z = out.z;
|
|
1792
1931
|
slideInto(out, puff3);
|
|
1932
|
+
cutFrom(puff3, out);
|
|
1793
1933
|
}
|
|
1794
1934
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1795
1935
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1796
1936
|
puff3.age = age;
|
|
1797
1937
|
puff3.heat = heat;
|
|
1938
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
1939
|
+
else clearCuts(puff3);
|
|
1798
1940
|
}
|
|
1799
1941
|
}
|
|
1800
1942
|
|
|
@@ -4166,8 +4308,36 @@ var BODYWORK_IMPACT = {
|
|
|
4166
4308
|
loop: 2,
|
|
4167
4309
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4168
4310
|
};
|
|
4311
|
+
var GLASS_PIECE = 11061464;
|
|
4312
|
+
var GLASS_DUST = 12572386;
|
|
4313
|
+
var HIT = [0, 0, 0];
|
|
4314
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4315
|
+
id: "vehicle_glass_chip",
|
|
4316
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4317
|
+
team: "vehicles",
|
|
4318
|
+
budget: { particles: 16, debris: 6 },
|
|
4319
|
+
loop: 2,
|
|
4320
|
+
timeline: [
|
|
4321
|
+
burst("add", 6, { p: HIT, box: [0.04, 0.04, 0.04], size: [8e-3, 0.02], life: [0.12, 0.3], c0: 16777215, a: 0.9, fi: 0.3 }),
|
|
4322
|
+
burst("normal", 6, { p: HIT, dir: NORMAL, sp: [0.3, 0.9], drag: 3, life: [0.4, 0.8], size: [0.04, 0.08], grow: 2, c0: GLASS_DUST, a: 0.18 }),
|
|
4323
|
+
repeat(6, debris({ p: HIT, box: [0.03, 0.03, 0.03], dir: NORMAL, cone: 0.6, sp: [0.4, 1.4], size: [rnd(2e-3, 4e-3), 2e-3, rnd(2e-3, 4e-3)], c: GLASS_PIECE, spin: 20, life: 6, bounce: 0.2 }))
|
|
4324
|
+
]
|
|
4325
|
+
};
|
|
4326
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4327
|
+
id: "vehicle_glass_shatter",
|
|
4328
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4329
|
+
team: "vehicles",
|
|
4330
|
+
budget: { particles: 40, debris: 0 },
|
|
4331
|
+
loop: 2,
|
|
4332
|
+
timeline: [
|
|
4333
|
+
burst("add", 24, { p: HIT, box: [0.5, 0.3, 0.5], size: [0.01, 0.03], life: [0.15, 0.5], c0: 16777215, a: 0.9, fi: 0.3 }),
|
|
4334
|
+
burst("normal", 10, { p: [0, -0.15, 0], box: [0.5, 0.2, 0.5], sp: [0.1, 0.4], drag: 2, life: [0.6, 1.1], size: [0.08, 0.14], grow: 2.5, c0: GLASS_DUST, a: 0.14 })
|
|
4335
|
+
]
|
|
4336
|
+
};
|
|
4169
4337
|
var VEHICLE_EFFECTS = [
|
|
4170
4338
|
BODYWORK_IMPACT,
|
|
4339
|
+
VEHICLE_GLASS_CHIP,
|
|
4340
|
+
VEHICLE_GLASS_SHATTER,
|
|
4171
4341
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4172
4342
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4173
4343
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -4922,10 +5092,10 @@ var DEFAULT_DIRECTION = [0, 0, -1];
|
|
|
4922
5092
|
var MAX_SCALE = 3;
|
|
4923
5093
|
var MIN_SCALE = 0.6;
|
|
4924
5094
|
function reflected(direction, normal) {
|
|
4925
|
-
const
|
|
4926
|
-
const out = [direction[0] - 2 *
|
|
5095
|
+
const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
5096
|
+
const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
|
|
4927
5097
|
const length = Math.hypot(out[0], out[1], out[2]);
|
|
4928
|
-
if (length < 1e-6 || Math.abs(
|
|
5098
|
+
if (length < 1e-6 || Math.abs(along2) > 0.98) return normal;
|
|
4929
5099
|
return [out[0] / length, out[1] / length, out[2] / length];
|
|
4930
5100
|
}
|
|
4931
5101
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -5688,6 +5858,112 @@ function addScrape(store, spec) {
|
|
|
5688
5858
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5689
5859
|
}
|
|
5690
5860
|
|
|
5861
|
+
// src/pools/chunk-motion.ts
|
|
5862
|
+
var RESTITUTION = -0.32;
|
|
5863
|
+
var GROUND_FRICTION = 0.5;
|
|
5864
|
+
var REST_SPEED = 0.6;
|
|
5865
|
+
var REST_SLIDE = 0.5;
|
|
5866
|
+
var TRAIL_SECONDS = 1.8;
|
|
5867
|
+
var TRAIL_STEP = 0.025;
|
|
5868
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5869
|
+
var TOP_FACING = 0.7;
|
|
5870
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5871
|
+
function bounce(core, chunk, floor2) {
|
|
5872
|
+
chunk.y = floor2;
|
|
5873
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5874
|
+
chunk.splat = true;
|
|
5875
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5876
|
+
}
|
|
5877
|
+
chunk.vy *= RESTITUTION;
|
|
5878
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5879
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5880
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5881
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5882
|
+
chunk.az *= GROUND_FRICTION;
|
|
5883
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5884
|
+
chunk.rest = true;
|
|
5885
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5886
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5890
|
+
function hitFace(chunk, out) {
|
|
5891
|
+
chunk.x = out.x;
|
|
5892
|
+
chunk.y = out.y;
|
|
5893
|
+
chunk.z = out.z;
|
|
5894
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5895
|
+
if (into >= 0) return;
|
|
5896
|
+
const tx = chunk.vx - into * out.nx;
|
|
5897
|
+
const ty = chunk.vy - into * out.ny;
|
|
5898
|
+
const tz = chunk.vz - into * out.nz;
|
|
5899
|
+
const back = into * RESTITUTION;
|
|
5900
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5901
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
5902
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
5903
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5904
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5905
|
+
chunk.az *= GROUND_FRICTION;
|
|
5906
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
5907
|
+
chunk.rest = true;
|
|
5908
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5909
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
function leaveTrail(core, chunk, dt) {
|
|
5913
|
+
chunk.trail -= dt;
|
|
5914
|
+
if (chunk.trail > 0) return;
|
|
5915
|
+
chunk.trail = TRAIL_STEP;
|
|
5916
|
+
const random = chunk.rng;
|
|
5917
|
+
addSpark(core, {
|
|
5918
|
+
x: chunk.x,
|
|
5919
|
+
y: chunk.y,
|
|
5920
|
+
z: chunk.z,
|
|
5921
|
+
vx: chunk.vx * 0.15,
|
|
5922
|
+
vy: chunk.vy * 0.15,
|
|
5923
|
+
vz: chunk.vz * 0.15,
|
|
5924
|
+
life: random.between(0.25, 0.45),
|
|
5925
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
5926
|
+
st: 0.05,
|
|
5927
|
+
kind: 0,
|
|
5928
|
+
g: 0,
|
|
5929
|
+
drag: 1,
|
|
5930
|
+
source: chunk.source
|
|
5931
|
+
});
|
|
5932
|
+
if (random.next() < 0.25) {
|
|
5933
|
+
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
function updateChunks(core, dt) {
|
|
5937
|
+
const confiner = core.confiner;
|
|
5938
|
+
const confining = !confiner.empty;
|
|
5939
|
+
const chunks = core.chunks.items;
|
|
5940
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
5941
|
+
const chunk = chunks[index];
|
|
5942
|
+
chunk.t += dt;
|
|
5943
|
+
if (chunk.rest) continue;
|
|
5944
|
+
MOVE2.x0 = chunk.x;
|
|
5945
|
+
MOVE2.y0 = chunk.y;
|
|
5946
|
+
MOVE2.z0 = chunk.z;
|
|
5947
|
+
chunk.vy -= core.gravity * dt;
|
|
5948
|
+
chunk.x += chunk.vx * dt;
|
|
5949
|
+
chunk.y += chunk.vy * dt;
|
|
5950
|
+
chunk.z += chunk.vz * dt;
|
|
5951
|
+
chunk.rx += chunk.ax * dt;
|
|
5952
|
+
chunk.ry += chunk.ay * dt;
|
|
5953
|
+
chunk.rz += chunk.az * dt;
|
|
5954
|
+
if (confining) {
|
|
5955
|
+
MOVE2.x1 = chunk.x;
|
|
5956
|
+
MOVE2.y1 = chunk.y;
|
|
5957
|
+
MOVE2.z1 = chunk.z;
|
|
5958
|
+
MOVE2.pad = chunkPad(chunk);
|
|
5959
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
5960
|
+
}
|
|
5961
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
5962
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
5963
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
5964
|
+
}
|
|
5965
|
+
}
|
|
5966
|
+
|
|
5691
5967
|
// src/pools/rings.ts
|
|
5692
5968
|
function createRingPool(capacity) {
|
|
5693
5969
|
return new OrderedPool(capacity, () => ({ x: 0, z: 0, y0: 0, rise: 0, rk: 0, R0: 0, R1: 0, r: 0, roll: 0, t: 0, life: 0 }));
|
|
@@ -5822,6 +6098,18 @@ function bornFrom(core, puff3, ox, oy, oz) {
|
|
|
5822
6098
|
puff3.z = out.z;
|
|
5823
6099
|
slideInto(out, puff3);
|
|
5824
6100
|
}
|
|
6101
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6102
|
+
const confiner = core.confiner;
|
|
6103
|
+
if (confiner.empty) return;
|
|
6104
|
+
BIRTH.x0 = ox;
|
|
6105
|
+
BIRTH.y0 = oy;
|
|
6106
|
+
BIRTH.z0 = oz;
|
|
6107
|
+
BIRTH.x1 = chunk.x;
|
|
6108
|
+
BIRTH.y1 = chunk.y;
|
|
6109
|
+
BIRTH.z1 = chunk.z;
|
|
6110
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6111
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6112
|
+
}
|
|
5825
6113
|
function composeFireballs(context) {
|
|
5826
6114
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5827
6115
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5902,7 +6190,7 @@ function composeShock(context) {
|
|
|
5902
6190
|
spawnShock(core.shocks, spec);
|
|
5903
6191
|
}
|
|
5904
6192
|
function composeDust(context) {
|
|
5905
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
6193
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
5906
6194
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
5907
6195
|
const count = Math.round(def.dust.count * scale);
|
|
5908
6196
|
const color = hexToLinearRgb(def.dust.color);
|
|
@@ -5932,7 +6220,7 @@ function composeDust(context) {
|
|
|
5932
6220
|
color,
|
|
5933
6221
|
kind: 1
|
|
5934
6222
|
});
|
|
5935
|
-
bornFrom(core, dust, x,
|
|
6223
|
+
bornFrom(core, dust, x, y, z);
|
|
5936
6224
|
}
|
|
5937
6225
|
}
|
|
5938
6226
|
function coneAngle(context) {
|
|
@@ -6006,7 +6294,7 @@ function composeDebris(context) {
|
|
|
6006
6294
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6007
6295
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6008
6296
|
const hot = random.next() < chunks.hot;
|
|
6009
|
-
addChunk(core, random, {
|
|
6297
|
+
const chunk = addChunk(core, random, {
|
|
6010
6298
|
x: x + d.x * 0.2,
|
|
6011
6299
|
y: y + 0.2,
|
|
6012
6300
|
z: z + d.z * 0.2,
|
|
@@ -6020,10 +6308,11 @@ function composeDebris(context) {
|
|
|
6020
6308
|
plate,
|
|
6021
6309
|
hot
|
|
6022
6310
|
});
|
|
6311
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6023
6312
|
}
|
|
6024
6313
|
}
|
|
6025
6314
|
function composeRimDebris(context) {
|
|
6026
|
-
const { core, random, x, z } = context;
|
|
6315
|
+
const { core, random, x, y, z } = context;
|
|
6027
6316
|
const radius = context.def.mark.crater ?? 0;
|
|
6028
6317
|
if (!core.layers.shrapnel) return;
|
|
6029
6318
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6034,7 +6323,7 @@ function composeRimDebris(context) {
|
|
|
6034
6323
|
const s = random.between(0.12, 0.28);
|
|
6035
6324
|
const vy2 = random.between(4, 10);
|
|
6036
6325
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6037
|
-
addChunk(core, random, {
|
|
6326
|
+
const chunk = addChunk(core, random, {
|
|
6038
6327
|
x: x + Math.cos(angle) * 0.3,
|
|
6039
6328
|
y: 0.1,
|
|
6040
6329
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6047,6 +6336,7 @@ function composeRimDebris(context) {
|
|
|
6047
6336
|
color,
|
|
6048
6337
|
plate: true
|
|
6049
6338
|
});
|
|
6339
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6050
6340
|
}
|
|
6051
6341
|
}
|
|
6052
6342
|
function composeMushroom(context, spec) {
|
|
@@ -6178,73 +6468,6 @@ function composeExplosion(core, def, call3) {
|
|
|
6178
6468
|
return scale;
|
|
6179
6469
|
}
|
|
6180
6470
|
|
|
6181
|
-
// src/pools/chunk-motion.ts
|
|
6182
|
-
var RESTITUTION = -0.32;
|
|
6183
|
-
var GROUND_FRICTION = 0.5;
|
|
6184
|
-
var REST_SPEED = 0.6;
|
|
6185
|
-
var REST_SLIDE = 0.5;
|
|
6186
|
-
var TRAIL_SECONDS = 1.8;
|
|
6187
|
-
var TRAIL_STEP = 0.025;
|
|
6188
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6189
|
-
function bounce(core, chunk, floor2) {
|
|
6190
|
-
chunk.y = floor2;
|
|
6191
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6192
|
-
chunk.splat = true;
|
|
6193
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6194
|
-
}
|
|
6195
|
-
chunk.vy *= RESTITUTION;
|
|
6196
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6197
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6198
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6199
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6200
|
-
chunk.az *= GROUND_FRICTION;
|
|
6201
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6202
|
-
chunk.rest = true;
|
|
6203
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6204
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6205
|
-
}
|
|
6206
|
-
}
|
|
6207
|
-
function leaveTrail(core, chunk, dt) {
|
|
6208
|
-
chunk.trail -= dt;
|
|
6209
|
-
if (chunk.trail > 0) return;
|
|
6210
|
-
chunk.trail = TRAIL_STEP;
|
|
6211
|
-
const random = chunk.rng;
|
|
6212
|
-
addSpark(core, {
|
|
6213
|
-
x: chunk.x,
|
|
6214
|
-
y: chunk.y,
|
|
6215
|
-
z: chunk.z,
|
|
6216
|
-
vx: chunk.vx * 0.15,
|
|
6217
|
-
vy: chunk.vy * 0.15,
|
|
6218
|
-
vz: chunk.vz * 0.15,
|
|
6219
|
-
life: random.between(0.25, 0.45),
|
|
6220
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6221
|
-
st: 0.05,
|
|
6222
|
-
kind: 0,
|
|
6223
|
-
g: 0,
|
|
6224
|
-
drag: 1,
|
|
6225
|
-
source: chunk.source
|
|
6226
|
-
});
|
|
6227
|
-
if (random.next() < 0.25) {
|
|
6228
|
-
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
|
|
6229
|
-
}
|
|
6230
|
-
}
|
|
6231
|
-
function updateChunks(core, dt) {
|
|
6232
|
-
for (const chunk of core.chunks.items) {
|
|
6233
|
-
chunk.t += dt;
|
|
6234
|
-
if (chunk.rest) continue;
|
|
6235
|
-
chunk.vy -= core.gravity * dt;
|
|
6236
|
-
chunk.x += chunk.vx * dt;
|
|
6237
|
-
chunk.y += chunk.vy * dt;
|
|
6238
|
-
chunk.z += chunk.vz * dt;
|
|
6239
|
-
chunk.rx += chunk.ax * dt;
|
|
6240
|
-
chunk.ry += chunk.ay * dt;
|
|
6241
|
-
chunk.rz += chunk.az * dt;
|
|
6242
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6243
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6244
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6245
|
-
}
|
|
6246
|
-
}
|
|
6247
|
-
|
|
6248
6471
|
// src/screen.ts
|
|
6249
6472
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6250
6473
|
var INITIAL_FLASH_DECAY = 6;
|
|
@@ -6269,6 +6492,9 @@ function updateScreen(state, dt) {
|
|
|
6269
6492
|
|
|
6270
6493
|
// src/sprites/kind-pool.ts
|
|
6271
6494
|
var PAD_OF_SIZE2 = 0.35;
|
|
6495
|
+
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6496
|
+
var GROUND_RESAMPLE = 0.1;
|
|
6497
|
+
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6272
6498
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6273
6499
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6274
6500
|
function rgb(hex) {
|
|
@@ -6316,6 +6542,8 @@ var SpriteKindPool = class {
|
|
|
6316
6542
|
__publicField(this, "bounced");
|
|
6317
6543
|
__publicField(this, "floor");
|
|
6318
6544
|
__publicField(this, "riseMul");
|
|
6545
|
+
/** 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. */
|
|
6546
|
+
__publicField(this, "ground");
|
|
6319
6547
|
const n = Math.max(1, capacity);
|
|
6320
6548
|
this.position = new Float32Array(n * 3);
|
|
6321
6549
|
this.color = new Float32Array(n * 3);
|
|
@@ -6338,6 +6566,7 @@ var SpriteKindPool = class {
|
|
|
6338
6566
|
this.bounced = new Uint8Array(n);
|
|
6339
6567
|
this.floor = new Float32Array(n);
|
|
6340
6568
|
this.riseMul = new Float32Array(n);
|
|
6569
|
+
this.ground = new Float32Array(n * 3);
|
|
6341
6570
|
}
|
|
6342
6571
|
spawn(kind, p, v, random, options) {
|
|
6343
6572
|
if (this.capacity <= 0) return;
|
|
@@ -6365,6 +6594,7 @@ var SpriteKindPool = class {
|
|
|
6365
6594
|
this.bounced[i] = 0;
|
|
6366
6595
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
6367
6596
|
this.riseMul[i] = options?.rise ?? 1;
|
|
6597
|
+
this.ground[i * 3] = Number.NaN;
|
|
6368
6598
|
this.size[i] = this.size0[i];
|
|
6369
6599
|
this.alpha[i] = 0;
|
|
6370
6600
|
}
|
|
@@ -6458,18 +6688,36 @@ var SpriteKindPool = class {
|
|
|
6458
6688
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6459
6689
|
const confiner = host.confiner;
|
|
6460
6690
|
if (def.carried && confiner && !confiner.empty) {
|
|
6461
|
-
|
|
6462
|
-
|
|
6691
|
+
STEP.x0 = this.position[i3];
|
|
6692
|
+
STEP.y0 = this.position[i3 + 1];
|
|
6693
|
+
STEP.z0 = this.position[i3 + 2];
|
|
6694
|
+
STEP.x1 = x;
|
|
6695
|
+
STEP.y1 = y;
|
|
6696
|
+
STEP.z1 = z;
|
|
6697
|
+
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6698
|
+
if (confiner.confineMove(STEP, dt)) {
|
|
6463
6699
|
const out = confiner.out;
|
|
6464
6700
|
x = out.x;
|
|
6465
6701
|
y = out.y;
|
|
6466
6702
|
z = out.z;
|
|
6467
|
-
|
|
6703
|
+
VELOCITY.vx = vx2;
|
|
6704
|
+
VELOCITY.vy = vy2;
|
|
6705
|
+
VELOCITY.vz = vz2;
|
|
6706
|
+
slideInto(out, VELOCITY);
|
|
6707
|
+
vx2 = VELOCITY.vx;
|
|
6708
|
+
vy2 = VELOCITY.vy;
|
|
6709
|
+
vz2 = VELOCITY.vz;
|
|
6468
6710
|
}
|
|
6469
6711
|
}
|
|
6470
6712
|
if (def.ground !== "none") {
|
|
6471
6713
|
const own = this.floor[i];
|
|
6472
|
-
const
|
|
6714
|
+
const ground = this.ground;
|
|
6715
|
+
if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
|
|
6716
|
+
ground[i3] = x;
|
|
6717
|
+
ground[i3 + 1] = z;
|
|
6718
|
+
ground[i3 + 2] = host.groundAt(x, z);
|
|
6719
|
+
}
|
|
6720
|
+
const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
|
|
6473
6721
|
if (y < gy) {
|
|
6474
6722
|
if (def.ground === "land") {
|
|
6475
6723
|
const tag = this.tag[i];
|
|
@@ -7341,10 +7589,10 @@ var MeshPool = class {
|
|
|
7341
7589
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
7342
7590
|
particle.vy -= particle.gravity * dt;
|
|
7343
7591
|
if (particle.drag) {
|
|
7344
|
-
const
|
|
7345
|
-
particle.vx *=
|
|
7346
|
-
particle.vy *=
|
|
7347
|
-
particle.vz *=
|
|
7592
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
7593
|
+
particle.vx *= keep2;
|
|
7594
|
+
particle.vy *= keep2;
|
|
7595
|
+
particle.vz *= keep2;
|
|
7348
7596
|
}
|
|
7349
7597
|
if (particle.carried) this.ride(particle, dt);
|
|
7350
7598
|
else {
|
|
@@ -8203,10 +8451,10 @@ function createVfx(options = {}) {
|
|
|
8203
8451
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
8204
8452
|
},
|
|
8205
8453
|
clearSource(source) {
|
|
8206
|
-
const
|
|
8454
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
8207
8455
|
const drop = (pool) => {
|
|
8208
8456
|
const before = pool.count;
|
|
8209
|
-
pool.compact(
|
|
8457
|
+
pool.compact(keep2, source);
|
|
8210
8458
|
return before - pool.count;
|
|
8211
8459
|
};
|
|
8212
8460
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -9380,10 +9628,10 @@ var MIST_DRAG = 1.2;
|
|
|
9380
9628
|
function moveDrop(drop, context) {
|
|
9381
9629
|
const { dt } = context;
|
|
9382
9630
|
drop.age += dt;
|
|
9383
|
-
const
|
|
9384
|
-
drop.vx *=
|
|
9385
|
-
drop.vz *=
|
|
9386
|
-
drop.vy = drop.vy *
|
|
9631
|
+
const keep2 = Math.exp(-DROP_DRAG * dt);
|
|
9632
|
+
drop.vx *= keep2;
|
|
9633
|
+
drop.vz *= keep2;
|
|
9634
|
+
drop.vy = drop.vy * keep2 - WATER_GRAVITY * dt;
|
|
9387
9635
|
drop.x += drop.vx * dt;
|
|
9388
9636
|
drop.y += drop.vy * dt;
|
|
9389
9637
|
drop.z += drop.vz * dt;
|
|
@@ -9443,10 +9691,10 @@ function ageBubble(bubble, dt) {
|
|
|
9443
9691
|
}
|
|
9444
9692
|
function ageMist(mist, dt) {
|
|
9445
9693
|
mist.age += dt;
|
|
9446
|
-
const
|
|
9447
|
-
mist.vx *=
|
|
9448
|
-
mist.vy = mist.vy *
|
|
9449
|
-
mist.vz *=
|
|
9694
|
+
const keep2 = Math.exp(-MIST_DRAG * dt);
|
|
9695
|
+
mist.vx *= keep2;
|
|
9696
|
+
mist.vy = mist.vy * keep2 - 0.15 * dt;
|
|
9697
|
+
mist.vz *= keep2;
|
|
9450
9698
|
mist.x += mist.vx * dt;
|
|
9451
9699
|
mist.y += mist.vy * dt;
|
|
9452
9700
|
mist.z += mist.vz * dt;
|
|
@@ -9819,10 +10067,10 @@ function spawnTrail(context, point, plan) {
|
|
|
9819
10067
|
const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
|
|
9820
10068
|
const [ex, ey, ez] = plan.trailEnd;
|
|
9821
10069
|
for (let index = 0; index < count; index++) {
|
|
9822
|
-
const
|
|
9823
|
-
const jitter = 0.01 + 0.02 *
|
|
9824
|
-
const at3 = [point[0] + (ex - point[0]) *
|
|
9825
|
-
addBubble(context, at3, point[1],
|
|
10070
|
+
const along2 = random.next() ** 1.6;
|
|
10071
|
+
const jitter = 0.01 + 0.02 * along2;
|
|
10072
|
+
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)];
|
|
10073
|
+
addBubble(context, at3, point[1], along2 * 0.05, random.between(3e-3, 0.01));
|
|
9826
10074
|
}
|
|
9827
10075
|
}
|
|
9828
10076
|
function spawnBlast(context, point, level, plan) {
|
|
@@ -10062,6 +10310,7 @@ export {
|
|
|
10062
10310
|
OrderedPool,
|
|
10063
10311
|
PIECES_DRAWN_VARIABLE,
|
|
10064
10312
|
PROFILES,
|
|
10313
|
+
PUFF_REACH,
|
|
10065
10314
|
RAIN_CAPACITY,
|
|
10066
10315
|
RainField,
|
|
10067
10316
|
SCRAPE_LIMIT,
|