@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.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
|
}
|
|
@@ -1493,12 +1494,14 @@ var GameVfx = (() => {
|
|
|
1493
1494
|
}
|
|
1494
1495
|
|
|
1495
1496
|
// src/solids.ts
|
|
1497
|
+
var MAX_PAD = 0.45;
|
|
1496
1498
|
var SKIN = 5e-3;
|
|
1497
1499
|
var Solids = class {
|
|
1498
1500
|
constructor() {
|
|
1499
1501
|
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1500
1502
|
__publicField(this, "list", []);
|
|
1501
|
-
|
|
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 });
|
|
1502
1505
|
}
|
|
1503
1506
|
get empty() {
|
|
1504
1507
|
return this.list.length === 0;
|
|
@@ -1514,18 +1517,19 @@ var GameVfx = (() => {
|
|
|
1514
1517
|
this.list = [];
|
|
1515
1518
|
}
|
|
1516
1519
|
/**
|
|
1517
|
-
* 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
|
|
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
|
|
1518
1521
|
* the surface's normal. Answers whether the step was stopped.
|
|
1519
1522
|
*/
|
|
1520
|
-
stop(move,
|
|
1523
|
+
stop(move, out) {
|
|
1521
1524
|
const dx = move.x1 - move.x0;
|
|
1522
1525
|
const dy = move.y1 - move.y0;
|
|
1523
1526
|
const dz = move.z1 - move.z0;
|
|
1524
|
-
const length = Math.
|
|
1527
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1525
1528
|
if (!(length > 0)) return false;
|
|
1526
1529
|
let nearest = Infinity;
|
|
1527
|
-
|
|
1528
|
-
|
|
1530
|
+
const list = this.list;
|
|
1531
|
+
for (let index = 0; index < list.length; index++) {
|
|
1532
|
+
if (!list[index](move, this.hit)) continue;
|
|
1529
1533
|
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1530
1534
|
if (reached >= nearest) continue;
|
|
1531
1535
|
nearest = reached;
|
|
@@ -1537,17 +1541,26 @@ var GameVfx = (() => {
|
|
|
1537
1541
|
out.nz = this.hit.nz;
|
|
1538
1542
|
}
|
|
1539
1543
|
if (nearest === Infinity) return false;
|
|
1540
|
-
const
|
|
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));
|
|
1541
1549
|
out.x -= dx / length * back;
|
|
1542
1550
|
out.y -= dy / length * back;
|
|
1543
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
|
+
}
|
|
1544
1558
|
return true;
|
|
1545
1559
|
}
|
|
1546
1560
|
};
|
|
1547
1561
|
|
|
1548
1562
|
// src/enclosures.ts
|
|
1549
1563
|
var SKIN2 = 5e-3;
|
|
1550
|
-
var MAX_PAD = 0.45;
|
|
1551
1564
|
function rotation(q) {
|
|
1552
1565
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
1553
1566
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -1572,7 +1585,7 @@ var GameVfx = (() => {
|
|
|
1572
1585
|
__publicField(this, "spaces", /* @__PURE__ */ new Map());
|
|
1573
1586
|
__publicField(this, "list", []);
|
|
1574
1587
|
__publicField(this, "random");
|
|
1575
|
-
__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 });
|
|
1576
1589
|
__publicField(this, "l0", new Float64Array(3));
|
|
1577
1590
|
__publicField(this, "l1", new Float64Array(3));
|
|
1578
1591
|
__publicField(this, "q", new Float64Array(3));
|
|
@@ -1647,7 +1660,7 @@ var GameVfx = (() => {
|
|
|
1647
1660
|
}
|
|
1648
1661
|
/** Passes at `rate` per second. */
|
|
1649
1662
|
chance(rate, dt) {
|
|
1650
|
-
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);
|
|
1651
1664
|
}
|
|
1652
1665
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1653
1666
|
through(s, q, dt) {
|
|
@@ -1670,7 +1683,7 @@ var GameVfx = (() => {
|
|
|
1670
1683
|
}
|
|
1671
1684
|
confineMove(move, dt) {
|
|
1672
1685
|
if (this.confineSpaces(move, dt)) return true;
|
|
1673
|
-
return !this.solids.empty && this.solids.stop(move,
|
|
1686
|
+
return !this.solids.empty && this.solids.stop(move, this.out);
|
|
1674
1687
|
}
|
|
1675
1688
|
confineSpaces(move, dt) {
|
|
1676
1689
|
const list = this.list;
|
|
@@ -1740,6 +1753,7 @@ var GameVfx = (() => {
|
|
|
1740
1753
|
out.nx = r[axis2] * sign;
|
|
1741
1754
|
out.ny = r[3 + axis2] * sign;
|
|
1742
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]);
|
|
1743
1757
|
return true;
|
|
1744
1758
|
}
|
|
1745
1759
|
return false;
|
|
@@ -1758,6 +1772,129 @@ var GameVfx = (() => {
|
|
|
1758
1772
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
1759
1773
|
}
|
|
1760
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
|
+
|
|
1761
1898
|
// src/pools/puffs.ts
|
|
1762
1899
|
var FLOOR_FRACTION = 0.4;
|
|
1763
1900
|
var FLOOR_BOUNCE = -0.2;
|
|
@@ -1798,7 +1935,8 @@ var GameVfx = (() => {
|
|
|
1798
1935
|
age: 0,
|
|
1799
1936
|
heat: 0,
|
|
1800
1937
|
size: 0,
|
|
1801
|
-
source: void 0
|
|
1938
|
+
source: void 0,
|
|
1939
|
+
cuts: [createCut(), createCut()]
|
|
1802
1940
|
}));
|
|
1803
1941
|
}
|
|
1804
1942
|
function spawnPuff(pool, random, init) {
|
|
@@ -1832,6 +1970,7 @@ var GameVfx = (() => {
|
|
|
1832
1970
|
puff3.heat = 0;
|
|
1833
1971
|
puff3.size = 0;
|
|
1834
1972
|
puff3.source = init.source;
|
|
1973
|
+
clearCuts(puff3);
|
|
1835
1974
|
return puff3;
|
|
1836
1975
|
}
|
|
1837
1976
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1881,17 +2020,21 @@ var GameVfx = (() => {
|
|
|
1881
2020
|
MOVE.z0 = puff3.z;
|
|
1882
2021
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1883
2022
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1884
|
-
|
|
2023
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
2024
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
1885
2025
|
const out = confiner.out;
|
|
1886
2026
|
puff3.x = out.x;
|
|
1887
2027
|
puff3.y = out.y;
|
|
1888
2028
|
puff3.z = out.z;
|
|
1889
2029
|
slideInto(out, puff3);
|
|
2030
|
+
cutFrom(puff3, out);
|
|
1890
2031
|
}
|
|
1891
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);
|
|
1892
2033
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1893
2034
|
puff3.age = age;
|
|
1894
2035
|
puff3.heat = heat;
|
|
2036
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
2037
|
+
else clearCuts(puff3);
|
|
1895
2038
|
}
|
|
1896
2039
|
}
|
|
1897
2040
|
|
|
@@ -4263,8 +4406,36 @@ var GameVfx = (() => {
|
|
|
4263
4406
|
loop: 2,
|
|
4264
4407
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4265
4408
|
};
|
|
4409
|
+
var GLASS_PIECE = 11061464;
|
|
4410
|
+
var GLASS_DUST = 12572386;
|
|
4411
|
+
var HIT = [0, 0, 0];
|
|
4412
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4413
|
+
id: "vehicle_glass_chip",
|
|
4414
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4415
|
+
team: "vehicles",
|
|
4416
|
+
budget: { particles: 16, debris: 6 },
|
|
4417
|
+
loop: 2,
|
|
4418
|
+
timeline: [
|
|
4419
|
+
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 }),
|
|
4420
|
+
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 }),
|
|
4421
|
+
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 }))
|
|
4422
|
+
]
|
|
4423
|
+
};
|
|
4424
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4425
|
+
id: "vehicle_glass_shatter",
|
|
4426
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4427
|
+
team: "vehicles",
|
|
4428
|
+
budget: { particles: 40, debris: 0 },
|
|
4429
|
+
loop: 2,
|
|
4430
|
+
timeline: [
|
|
4431
|
+
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 }),
|
|
4432
|
+
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 })
|
|
4433
|
+
]
|
|
4434
|
+
};
|
|
4266
4435
|
var VEHICLE_EFFECTS = [
|
|
4267
4436
|
BODYWORK_IMPACT,
|
|
4437
|
+
VEHICLE_GLASS_CHIP,
|
|
4438
|
+
VEHICLE_GLASS_SHATTER,
|
|
4268
4439
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4269
4440
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4270
4441
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -5019,10 +5190,10 @@ var GameVfx = (() => {
|
|
|
5019
5190
|
var MAX_SCALE = 3;
|
|
5020
5191
|
var MIN_SCALE = 0.6;
|
|
5021
5192
|
function reflected(direction, normal) {
|
|
5022
|
-
const
|
|
5023
|
-
const out = [direction[0] - 2 *
|
|
5193
|
+
const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
5194
|
+
const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
|
|
5024
5195
|
const length = Math.hypot(out[0], out[1], out[2]);
|
|
5025
|
-
if (length < 1e-6 || Math.abs(
|
|
5196
|
+
if (length < 1e-6 || Math.abs(along2) > 0.98) return normal;
|
|
5026
5197
|
return [out[0] / length, out[1] / length, out[2] / length];
|
|
5027
5198
|
}
|
|
5028
5199
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -5785,6 +5956,112 @@ var GameVfx = (() => {
|
|
|
5785
5956
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5786
5957
|
}
|
|
5787
5958
|
|
|
5959
|
+
// src/pools/chunk-motion.ts
|
|
5960
|
+
var RESTITUTION = -0.32;
|
|
5961
|
+
var GROUND_FRICTION = 0.5;
|
|
5962
|
+
var REST_SPEED = 0.6;
|
|
5963
|
+
var REST_SLIDE = 0.5;
|
|
5964
|
+
var TRAIL_SECONDS = 1.8;
|
|
5965
|
+
var TRAIL_STEP = 0.025;
|
|
5966
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5967
|
+
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 };
|
|
5969
|
+
function bounce(core, chunk, floor2) {
|
|
5970
|
+
chunk.y = floor2;
|
|
5971
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5972
|
+
chunk.splat = true;
|
|
5973
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5974
|
+
}
|
|
5975
|
+
chunk.vy *= RESTITUTION;
|
|
5976
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5977
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5978
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5979
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5980
|
+
chunk.az *= GROUND_FRICTION;
|
|
5981
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5982
|
+
chunk.rest = true;
|
|
5983
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5984
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5985
|
+
}
|
|
5986
|
+
}
|
|
5987
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5988
|
+
function hitFace(chunk, out) {
|
|
5989
|
+
chunk.x = out.x;
|
|
5990
|
+
chunk.y = out.y;
|
|
5991
|
+
chunk.z = out.z;
|
|
5992
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5993
|
+
if (into >= 0) return;
|
|
5994
|
+
const tx = chunk.vx - into * out.nx;
|
|
5995
|
+
const ty = chunk.vy - into * out.ny;
|
|
5996
|
+
const tz = chunk.vz - into * out.nz;
|
|
5997
|
+
const back = into * RESTITUTION;
|
|
5998
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5999
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
6000
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
6001
|
+
chunk.ax *= GROUND_FRICTION;
|
|
6002
|
+
chunk.ay *= GROUND_FRICTION;
|
|
6003
|
+
chunk.az *= GROUND_FRICTION;
|
|
6004
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
6005
|
+
chunk.rest = true;
|
|
6006
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6007
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6008
|
+
}
|
|
6009
|
+
}
|
|
6010
|
+
function leaveTrail(core, chunk, dt) {
|
|
6011
|
+
chunk.trail -= dt;
|
|
6012
|
+
if (chunk.trail > 0) return;
|
|
6013
|
+
chunk.trail = TRAIL_STEP;
|
|
6014
|
+
const random = chunk.rng;
|
|
6015
|
+
addSpark(core, {
|
|
6016
|
+
x: chunk.x,
|
|
6017
|
+
y: chunk.y,
|
|
6018
|
+
z: chunk.z,
|
|
6019
|
+
vx: chunk.vx * 0.15,
|
|
6020
|
+
vy: chunk.vy * 0.15,
|
|
6021
|
+
vz: chunk.vz * 0.15,
|
|
6022
|
+
life: random.between(0.25, 0.45),
|
|
6023
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
6024
|
+
st: 0.05,
|
|
6025
|
+
kind: 0,
|
|
6026
|
+
g: 0,
|
|
6027
|
+
drag: 1,
|
|
6028
|
+
source: chunk.source
|
|
6029
|
+
});
|
|
6030
|
+
if (random.next() < 0.25) {
|
|
6031
|
+
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 });
|
|
6032
|
+
}
|
|
6033
|
+
}
|
|
6034
|
+
function updateChunks(core, dt) {
|
|
6035
|
+
const confiner = core.confiner;
|
|
6036
|
+
const confining = !confiner.empty;
|
|
6037
|
+
const chunks = core.chunks.items;
|
|
6038
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
6039
|
+
const chunk = chunks[index];
|
|
6040
|
+
chunk.t += dt;
|
|
6041
|
+
if (chunk.rest) continue;
|
|
6042
|
+
MOVE2.x0 = chunk.x;
|
|
6043
|
+
MOVE2.y0 = chunk.y;
|
|
6044
|
+
MOVE2.z0 = chunk.z;
|
|
6045
|
+
chunk.vy -= core.gravity * dt;
|
|
6046
|
+
chunk.x += chunk.vx * dt;
|
|
6047
|
+
chunk.y += chunk.vy * dt;
|
|
6048
|
+
chunk.z += chunk.vz * dt;
|
|
6049
|
+
chunk.rx += chunk.ax * dt;
|
|
6050
|
+
chunk.ry += chunk.ay * dt;
|
|
6051
|
+
chunk.rz += chunk.az * dt;
|
|
6052
|
+
if (confining) {
|
|
6053
|
+
MOVE2.x1 = chunk.x;
|
|
6054
|
+
MOVE2.y1 = chunk.y;
|
|
6055
|
+
MOVE2.z1 = chunk.z;
|
|
6056
|
+
MOVE2.pad = chunkPad(chunk);
|
|
6057
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
6058
|
+
}
|
|
6059
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6060
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6061
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
|
|
5788
6065
|
// src/pools/rings.ts
|
|
5789
6066
|
function createRingPool(capacity) {
|
|
5790
6067
|
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 }));
|
|
@@ -5919,6 +6196,18 @@ var GameVfx = (() => {
|
|
|
5919
6196
|
puff3.z = out.z;
|
|
5920
6197
|
slideInto(out, puff3);
|
|
5921
6198
|
}
|
|
6199
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6200
|
+
const confiner = core.confiner;
|
|
6201
|
+
if (confiner.empty) return;
|
|
6202
|
+
BIRTH.x0 = ox;
|
|
6203
|
+
BIRTH.y0 = oy;
|
|
6204
|
+
BIRTH.z0 = oz;
|
|
6205
|
+
BIRTH.x1 = chunk.x;
|
|
6206
|
+
BIRTH.y1 = chunk.y;
|
|
6207
|
+
BIRTH.z1 = chunk.z;
|
|
6208
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6209
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6210
|
+
}
|
|
5922
6211
|
function composeFireballs(context) {
|
|
5923
6212
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5924
6213
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5999,7 +6288,7 @@ var GameVfx = (() => {
|
|
|
5999
6288
|
spawnShock(core.shocks, spec);
|
|
6000
6289
|
}
|
|
6001
6290
|
function composeDust(context) {
|
|
6002
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
6291
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
6003
6292
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
6004
6293
|
const count = Math.round(def.dust.count * scale);
|
|
6005
6294
|
const color = hexToLinearRgb(def.dust.color);
|
|
@@ -6029,7 +6318,7 @@ var GameVfx = (() => {
|
|
|
6029
6318
|
color,
|
|
6030
6319
|
kind: 1
|
|
6031
6320
|
});
|
|
6032
|
-
bornFrom(core, dust, x,
|
|
6321
|
+
bornFrom(core, dust, x, y, z);
|
|
6033
6322
|
}
|
|
6034
6323
|
}
|
|
6035
6324
|
function coneAngle(context) {
|
|
@@ -6103,7 +6392,7 @@ var GameVfx = (() => {
|
|
|
6103
6392
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6104
6393
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6105
6394
|
const hot = random.next() < chunks.hot;
|
|
6106
|
-
addChunk(core, random, {
|
|
6395
|
+
const chunk = addChunk(core, random, {
|
|
6107
6396
|
x: x + d.x * 0.2,
|
|
6108
6397
|
y: y + 0.2,
|
|
6109
6398
|
z: z + d.z * 0.2,
|
|
@@ -6117,10 +6406,11 @@ var GameVfx = (() => {
|
|
|
6117
6406
|
plate,
|
|
6118
6407
|
hot
|
|
6119
6408
|
});
|
|
6409
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6120
6410
|
}
|
|
6121
6411
|
}
|
|
6122
6412
|
function composeRimDebris(context) {
|
|
6123
|
-
const { core, random, x, z } = context;
|
|
6413
|
+
const { core, random, x, y, z } = context;
|
|
6124
6414
|
const radius = context.def.mark.crater ?? 0;
|
|
6125
6415
|
if (!core.layers.shrapnel) return;
|
|
6126
6416
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6131,7 +6421,7 @@ var GameVfx = (() => {
|
|
|
6131
6421
|
const s = random.between(0.12, 0.28);
|
|
6132
6422
|
const vy2 = random.between(4, 10);
|
|
6133
6423
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6134
|
-
addChunk(core, random, {
|
|
6424
|
+
const chunk = addChunk(core, random, {
|
|
6135
6425
|
x: x + Math.cos(angle) * 0.3,
|
|
6136
6426
|
y: 0.1,
|
|
6137
6427
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6144,6 +6434,7 @@ var GameVfx = (() => {
|
|
|
6144
6434
|
color,
|
|
6145
6435
|
plate: true
|
|
6146
6436
|
});
|
|
6437
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6147
6438
|
}
|
|
6148
6439
|
}
|
|
6149
6440
|
function composeMushroom(context, spec) {
|
|
@@ -6275,73 +6566,6 @@ var GameVfx = (() => {
|
|
|
6275
6566
|
return scale;
|
|
6276
6567
|
}
|
|
6277
6568
|
|
|
6278
|
-
// src/pools/chunk-motion.ts
|
|
6279
|
-
var RESTITUTION = -0.32;
|
|
6280
|
-
var GROUND_FRICTION = 0.5;
|
|
6281
|
-
var REST_SPEED = 0.6;
|
|
6282
|
-
var REST_SLIDE = 0.5;
|
|
6283
|
-
var TRAIL_SECONDS = 1.8;
|
|
6284
|
-
var TRAIL_STEP = 0.025;
|
|
6285
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6286
|
-
function bounce(core, chunk, floor2) {
|
|
6287
|
-
chunk.y = floor2;
|
|
6288
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6289
|
-
chunk.splat = true;
|
|
6290
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6291
|
-
}
|
|
6292
|
-
chunk.vy *= RESTITUTION;
|
|
6293
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6294
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6295
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6296
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6297
|
-
chunk.az *= GROUND_FRICTION;
|
|
6298
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6299
|
-
chunk.rest = true;
|
|
6300
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6301
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6302
|
-
}
|
|
6303
|
-
}
|
|
6304
|
-
function leaveTrail(core, chunk, dt) {
|
|
6305
|
-
chunk.trail -= dt;
|
|
6306
|
-
if (chunk.trail > 0) return;
|
|
6307
|
-
chunk.trail = TRAIL_STEP;
|
|
6308
|
-
const random = chunk.rng;
|
|
6309
|
-
addSpark(core, {
|
|
6310
|
-
x: chunk.x,
|
|
6311
|
-
y: chunk.y,
|
|
6312
|
-
z: chunk.z,
|
|
6313
|
-
vx: chunk.vx * 0.15,
|
|
6314
|
-
vy: chunk.vy * 0.15,
|
|
6315
|
-
vz: chunk.vz * 0.15,
|
|
6316
|
-
life: random.between(0.25, 0.45),
|
|
6317
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6318
|
-
st: 0.05,
|
|
6319
|
-
kind: 0,
|
|
6320
|
-
g: 0,
|
|
6321
|
-
drag: 1,
|
|
6322
|
-
source: chunk.source
|
|
6323
|
-
});
|
|
6324
|
-
if (random.next() < 0.25) {
|
|
6325
|
-
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 });
|
|
6326
|
-
}
|
|
6327
|
-
}
|
|
6328
|
-
function updateChunks(core, dt) {
|
|
6329
|
-
for (const chunk of core.chunks.items) {
|
|
6330
|
-
chunk.t += dt;
|
|
6331
|
-
if (chunk.rest) continue;
|
|
6332
|
-
chunk.vy -= core.gravity * dt;
|
|
6333
|
-
chunk.x += chunk.vx * dt;
|
|
6334
|
-
chunk.y += chunk.vy * dt;
|
|
6335
|
-
chunk.z += chunk.vz * dt;
|
|
6336
|
-
chunk.rx += chunk.ax * dt;
|
|
6337
|
-
chunk.ry += chunk.ay * dt;
|
|
6338
|
-
chunk.rz += chunk.az * dt;
|
|
6339
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6340
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6341
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6342
|
-
}
|
|
6343
|
-
}
|
|
6344
|
-
|
|
6345
6569
|
// src/screen.ts
|
|
6346
6570
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6347
6571
|
var INITIAL_FLASH_DECAY = 6;
|
|
@@ -6366,6 +6590,9 @@ var GameVfx = (() => {
|
|
|
6366
6590
|
|
|
6367
6591
|
// src/sprites/kind-pool.ts
|
|
6368
6592
|
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 };
|
|
6594
|
+
var GROUND_RESAMPLE = 0.1;
|
|
6595
|
+
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6369
6596
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6370
6597
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6371
6598
|
function rgb(hex) {
|
|
@@ -6413,6 +6640,8 @@ var GameVfx = (() => {
|
|
|
6413
6640
|
__publicField(this, "bounced");
|
|
6414
6641
|
__publicField(this, "floor");
|
|
6415
6642
|
__publicField(this, "riseMul");
|
|
6643
|
+
/** 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. */
|
|
6644
|
+
__publicField(this, "ground");
|
|
6416
6645
|
const n = Math.max(1, capacity);
|
|
6417
6646
|
this.position = new Float32Array(n * 3);
|
|
6418
6647
|
this.color = new Float32Array(n * 3);
|
|
@@ -6435,6 +6664,7 @@ var GameVfx = (() => {
|
|
|
6435
6664
|
this.bounced = new Uint8Array(n);
|
|
6436
6665
|
this.floor = new Float32Array(n);
|
|
6437
6666
|
this.riseMul = new Float32Array(n);
|
|
6667
|
+
this.ground = new Float32Array(n * 3);
|
|
6438
6668
|
}
|
|
6439
6669
|
spawn(kind, p, v, random, options) {
|
|
6440
6670
|
if (this.capacity <= 0) return;
|
|
@@ -6462,6 +6692,7 @@ var GameVfx = (() => {
|
|
|
6462
6692
|
this.bounced[i] = 0;
|
|
6463
6693
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
6464
6694
|
this.riseMul[i] = options?.rise ?? 1;
|
|
6695
|
+
this.ground[i * 3] = Number.NaN;
|
|
6465
6696
|
this.size[i] = this.size0[i];
|
|
6466
6697
|
this.alpha[i] = 0;
|
|
6467
6698
|
}
|
|
@@ -6555,18 +6786,36 @@ var GameVfx = (() => {
|
|
|
6555
6786
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6556
6787
|
const confiner = host.confiner;
|
|
6557
6788
|
if (def.carried && confiner && !confiner.empty) {
|
|
6558
|
-
|
|
6559
|
-
|
|
6789
|
+
STEP.x0 = this.position[i3];
|
|
6790
|
+
STEP.y0 = this.position[i3 + 1];
|
|
6791
|
+
STEP.z0 = this.position[i3 + 2];
|
|
6792
|
+
STEP.x1 = x;
|
|
6793
|
+
STEP.y1 = y;
|
|
6794
|
+
STEP.z1 = z;
|
|
6795
|
+
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6796
|
+
if (confiner.confineMove(STEP, dt)) {
|
|
6560
6797
|
const out = confiner.out;
|
|
6561
6798
|
x = out.x;
|
|
6562
6799
|
y = out.y;
|
|
6563
6800
|
z = out.z;
|
|
6564
|
-
|
|
6801
|
+
VELOCITY.vx = vx2;
|
|
6802
|
+
VELOCITY.vy = vy2;
|
|
6803
|
+
VELOCITY.vz = vz2;
|
|
6804
|
+
slideInto(out, VELOCITY);
|
|
6805
|
+
vx2 = VELOCITY.vx;
|
|
6806
|
+
vy2 = VELOCITY.vy;
|
|
6807
|
+
vz2 = VELOCITY.vz;
|
|
6565
6808
|
}
|
|
6566
6809
|
}
|
|
6567
6810
|
if (def.ground !== "none") {
|
|
6568
6811
|
const own = this.floor[i];
|
|
6569
|
-
const
|
|
6812
|
+
const ground = this.ground;
|
|
6813
|
+
if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
|
|
6814
|
+
ground[i3] = x;
|
|
6815
|
+
ground[i3 + 1] = z;
|
|
6816
|
+
ground[i3 + 2] = host.groundAt(x, z);
|
|
6817
|
+
}
|
|
6818
|
+
const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
|
|
6570
6819
|
if (y < gy) {
|
|
6571
6820
|
if (def.ground === "land") {
|
|
6572
6821
|
const tag = this.tag[i];
|
|
@@ -7438,10 +7687,10 @@ var GameVfx = (() => {
|
|
|
7438
7687
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
7439
7688
|
particle.vy -= particle.gravity * dt;
|
|
7440
7689
|
if (particle.drag) {
|
|
7441
|
-
const
|
|
7442
|
-
particle.vx *=
|
|
7443
|
-
particle.vy *=
|
|
7444
|
-
particle.vz *=
|
|
7690
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
7691
|
+
particle.vx *= keep2;
|
|
7692
|
+
particle.vy *= keep2;
|
|
7693
|
+
particle.vz *= keep2;
|
|
7445
7694
|
}
|
|
7446
7695
|
if (particle.carried) this.ride(particle, dt);
|
|
7447
7696
|
else {
|
|
@@ -8300,10 +8549,10 @@ var GameVfx = (() => {
|
|
|
8300
8549
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
8301
8550
|
},
|
|
8302
8551
|
clearSource(source) {
|
|
8303
|
-
const
|
|
8552
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
8304
8553
|
const drop = (pool) => {
|
|
8305
8554
|
const before = pool.count;
|
|
8306
|
-
pool.compact(
|
|
8555
|
+
pool.compact(keep2, source);
|
|
8307
8556
|
return before - pool.count;
|
|
8308
8557
|
};
|
|
8309
8558
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -9477,10 +9726,10 @@ var GameVfx = (() => {
|
|
|
9477
9726
|
function moveDrop(drop, context) {
|
|
9478
9727
|
const { dt } = context;
|
|
9479
9728
|
drop.age += dt;
|
|
9480
|
-
const
|
|
9481
|
-
drop.vx *=
|
|
9482
|
-
drop.vz *=
|
|
9483
|
-
drop.vy = drop.vy *
|
|
9729
|
+
const keep2 = Math.exp(-DROP_DRAG * dt);
|
|
9730
|
+
drop.vx *= keep2;
|
|
9731
|
+
drop.vz *= keep2;
|
|
9732
|
+
drop.vy = drop.vy * keep2 - WATER_GRAVITY * dt;
|
|
9484
9733
|
drop.x += drop.vx * dt;
|
|
9485
9734
|
drop.y += drop.vy * dt;
|
|
9486
9735
|
drop.z += drop.vz * dt;
|
|
@@ -9540,10 +9789,10 @@ var GameVfx = (() => {
|
|
|
9540
9789
|
}
|
|
9541
9790
|
function ageMist(mist, dt) {
|
|
9542
9791
|
mist.age += dt;
|
|
9543
|
-
const
|
|
9544
|
-
mist.vx *=
|
|
9545
|
-
mist.vy = mist.vy *
|
|
9546
|
-
mist.vz *=
|
|
9792
|
+
const keep2 = Math.exp(-MIST_DRAG * dt);
|
|
9793
|
+
mist.vx *= keep2;
|
|
9794
|
+
mist.vy = mist.vy * keep2 - 0.15 * dt;
|
|
9795
|
+
mist.vz *= keep2;
|
|
9547
9796
|
mist.x += mist.vx * dt;
|
|
9548
9797
|
mist.y += mist.vy * dt;
|
|
9549
9798
|
mist.z += mist.vz * dt;
|
|
@@ -9916,10 +10165,10 @@ var GameVfx = (() => {
|
|
|
9916
10165
|
const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
|
|
9917
10166
|
const [ex, ey, ez] = plan.trailEnd;
|
|
9918
10167
|
for (let index = 0; index < count; index++) {
|
|
9919
|
-
const
|
|
9920
|
-
const jitter = 0.01 + 0.02 *
|
|
9921
|
-
const at3 = [point[0] + (ex - point[0]) *
|
|
9922
|
-
addBubble(context, at3, point[1],
|
|
10168
|
+
const along2 = random.next() ** 1.6;
|
|
10169
|
+
const jitter = 0.01 + 0.02 * along2;
|
|
10170
|
+
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)];
|
|
10171
|
+
addBubble(context, at3, point[1], along2 * 0.05, random.between(3e-3, 0.01));
|
|
9923
10172
|
}
|
|
9924
10173
|
}
|
|
9925
10174
|
function spawnBlast(context, point, level, plan) {
|