@adatechnology/game-vfx-three 0.11.1 → 0.11.3
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/dist/{chunk-KIZDMENO.js → chunk-JM23474M.js} +31 -10
- package/dist/chunk-JM23474M.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.global.js +369 -107
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-KIZDMENO.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1233,11 +1233,11 @@ var GameVfxThree = (() => {
|
|
|
1233
1233
|
this.spare.push(record);
|
|
1234
1234
|
}
|
|
1235
1235
|
/** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
|
|
1236
|
-
compact(
|
|
1236
|
+
compact(keep2, context) {
|
|
1237
1237
|
let write = 0;
|
|
1238
1238
|
for (let read = 0; read < this.items.length; read++) {
|
|
1239
1239
|
const record = this.items[read];
|
|
1240
|
-
if (
|
|
1240
|
+
if (keep2(record, context)) {
|
|
1241
1241
|
this.items[write++] = record;
|
|
1242
1242
|
continue;
|
|
1243
1243
|
}
|
|
@@ -1487,12 +1487,13 @@ var GameVfxThree = (() => {
|
|
|
1487
1487
|
function streamFor(eventSeed) {
|
|
1488
1488
|
return lehmer(mixEventSeed(eventSeed));
|
|
1489
1489
|
}
|
|
1490
|
+
var MAX_PAD = 0.45;
|
|
1490
1491
|
var SKIN = 5e-3;
|
|
1491
1492
|
var Solids = class {
|
|
1492
1493
|
constructor() {
|
|
1493
1494
|
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1494
1495
|
__publicField(this, "list", []);
|
|
1495
|
-
__publicField(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1496
|
+
__publicField(this, "hit", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1496
1497
|
}
|
|
1497
1498
|
get empty() {
|
|
1498
1499
|
return this.list.length === 0;
|
|
@@ -1508,18 +1509,19 @@ var GameVfxThree = (() => {
|
|
|
1508
1509
|
this.list = [];
|
|
1509
1510
|
}
|
|
1510
1511
|
/**
|
|
1511
|
-
* 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
|
|
1512
|
+
* 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
|
|
1512
1513
|
* the surface's normal. Answers whether the step was stopped.
|
|
1513
1514
|
*/
|
|
1514
|
-
stop(move,
|
|
1515
|
+
stop(move, out) {
|
|
1515
1516
|
const dx = move.x1 - move.x0;
|
|
1516
1517
|
const dy = move.y1 - move.y0;
|
|
1517
1518
|
const dz = move.z1 - move.z0;
|
|
1518
|
-
const length = Math.
|
|
1519
|
+
const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
1519
1520
|
if (!(length > 0)) return false;
|
|
1520
1521
|
let nearest = Infinity;
|
|
1521
|
-
|
|
1522
|
-
|
|
1522
|
+
const list = this.list;
|
|
1523
|
+
for (let index = 0; index < list.length; index++) {
|
|
1524
|
+
if (!list[index](move, this.hit)) continue;
|
|
1523
1525
|
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1524
1526
|
if (reached >= nearest) continue;
|
|
1525
1527
|
nearest = reached;
|
|
@@ -1531,15 +1533,24 @@ var GameVfxThree = (() => {
|
|
|
1531
1533
|
out.nz = this.hit.nz;
|
|
1532
1534
|
}
|
|
1533
1535
|
if (nearest === Infinity) return false;
|
|
1534
|
-
const
|
|
1536
|
+
const hitX2 = out.x;
|
|
1537
|
+
const hitY2 = out.y;
|
|
1538
|
+
const hitZ = out.z;
|
|
1539
|
+
out.d = out.nx * hitX2 + out.ny * hitY2 + out.nz * hitZ;
|
|
1540
|
+
const back = Math.min(Math.min(Math.max(move.pad, 0), MAX_PAD) + SKIN, Math.max(nearest, 0));
|
|
1535
1541
|
out.x -= dx / length * back;
|
|
1536
1542
|
out.y -= dy / length * back;
|
|
1537
1543
|
out.z -= dz / length * back;
|
|
1544
|
+
const off = (out.x - hitX2) * out.nx + (out.y - hitY2) * out.ny + (out.z - hitZ) * out.nz;
|
|
1545
|
+
if (off < SKIN) {
|
|
1546
|
+
out.x += out.nx * (SKIN - off);
|
|
1547
|
+
out.y += out.ny * (SKIN - off);
|
|
1548
|
+
out.z += out.nz * (SKIN - off);
|
|
1549
|
+
}
|
|
1538
1550
|
return true;
|
|
1539
1551
|
}
|
|
1540
1552
|
};
|
|
1541
1553
|
var SKIN2 = 5e-3;
|
|
1542
|
-
var MAX_PAD = 0.45;
|
|
1543
1554
|
function rotation(q) {
|
|
1544
1555
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
1545
1556
|
const n = Math.hypot(x, y, z, w) || 1;
|
|
@@ -1564,7 +1575,7 @@ var GameVfxThree = (() => {
|
|
|
1564
1575
|
__publicField(this, "spaces", /* @__PURE__ */ new Map());
|
|
1565
1576
|
__publicField(this, "list", []);
|
|
1566
1577
|
__publicField(this, "random");
|
|
1567
|
-
__publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1578
|
+
__publicField(this, "out", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
|
|
1568
1579
|
__publicField(this, "l0", new Float64Array(3));
|
|
1569
1580
|
__publicField(this, "l1", new Float64Array(3));
|
|
1570
1581
|
__publicField(this, "q", new Float64Array(3));
|
|
@@ -1639,7 +1650,7 @@ var GameVfxThree = (() => {
|
|
|
1639
1650
|
}
|
|
1640
1651
|
/** Passes at `rate` per second. */
|
|
1641
1652
|
chance(rate, dt) {
|
|
1642
|
-
return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1653
|
+
return rate > 0 && dt > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
|
|
1643
1654
|
}
|
|
1644
1655
|
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
1645
1656
|
through(s, q, dt) {
|
|
@@ -1662,7 +1673,7 @@ var GameVfxThree = (() => {
|
|
|
1662
1673
|
}
|
|
1663
1674
|
confineMove(move, dt) {
|
|
1664
1675
|
if (this.confineSpaces(move, dt)) return true;
|
|
1665
|
-
return !this.solids.empty && this.solids.stop(move,
|
|
1676
|
+
return !this.solids.empty && this.solids.stop(move, this.out);
|
|
1666
1677
|
}
|
|
1667
1678
|
confineSpaces(move, dt) {
|
|
1668
1679
|
const list = this.list;
|
|
@@ -1732,6 +1743,7 @@ var GameVfxThree = (() => {
|
|
|
1732
1743
|
out.nx = r[axis2] * sign;
|
|
1733
1744
|
out.ny = r[3 + axis2] * sign;
|
|
1734
1745
|
out.nz = r[6 + axis2] * sign;
|
|
1746
|
+
out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -h[axis2] : h[axis2]);
|
|
1735
1747
|
return true;
|
|
1736
1748
|
}
|
|
1737
1749
|
return false;
|
|
@@ -1749,6 +1761,127 @@ var GameVfxThree = (() => {
|
|
|
1749
1761
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
1750
1762
|
return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
|
|
1751
1763
|
}
|
|
1764
|
+
var PUFF_REACH = 1.28;
|
|
1765
|
+
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 }];
|
|
1766
|
+
var PROBES_PER_SECOND = 60;
|
|
1767
|
+
var FRAMES_PER_PROBE = 3;
|
|
1768
|
+
var GROUND_FACING = 0.7;
|
|
1769
|
+
var SAME_WALL = 0.9;
|
|
1770
|
+
var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
1771
|
+
var KeptCut = class {
|
|
1772
|
+
constructor() {
|
|
1773
|
+
__publicField(this, "on", false);
|
|
1774
|
+
__publicField(this, "nx", 0.5);
|
|
1775
|
+
__publicField(this, "ny", 0.5);
|
|
1776
|
+
__publicField(this, "nz", 0.5);
|
|
1777
|
+
__publicField(this, "d", 0.5);
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
function createCut() {
|
|
1781
|
+
return new KeptCut();
|
|
1782
|
+
}
|
|
1783
|
+
function clearCuts(puff3) {
|
|
1784
|
+
puff3.cuts[0].on = false;
|
|
1785
|
+
puff3.cuts[1].on = false;
|
|
1786
|
+
}
|
|
1787
|
+
var WrittenWay = class {
|
|
1788
|
+
constructor() {
|
|
1789
|
+
__publicField(this, "x", 0.5);
|
|
1790
|
+
__publicField(this, "y", 0.5);
|
|
1791
|
+
__publicField(this, "z", 0.5);
|
|
1792
|
+
}
|
|
1793
|
+
};
|
|
1794
|
+
var WAY = new WrittenWay();
|
|
1795
|
+
function probe(confiner, puff3, way) {
|
|
1796
|
+
const reach = puff3.size * PUFF_REACH;
|
|
1797
|
+
if (!(reach > 0)) return false;
|
|
1798
|
+
PROBE.x0 = puff3.x;
|
|
1799
|
+
PROBE.y0 = puff3.y;
|
|
1800
|
+
PROBE.z0 = puff3.z;
|
|
1801
|
+
PROBE.x1 = puff3.x + way.x * reach;
|
|
1802
|
+
PROBE.y1 = puff3.y + way.y * reach;
|
|
1803
|
+
PROBE.z1 = puff3.z + way.z * reach;
|
|
1804
|
+
PROBE.pad = 0;
|
|
1805
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1806
|
+
}
|
|
1807
|
+
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;
|
|
1808
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d;
|
|
1809
|
+
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1810
|
+
function cutFor(puff3, face) {
|
|
1811
|
+
const first = puff3.cuts[0];
|
|
1812
|
+
const second = puff3.cuts[1];
|
|
1813
|
+
if (sameWall(first, face)) return first;
|
|
1814
|
+
if (sameWall(second, face)) return second;
|
|
1815
|
+
if (!first.on) return first;
|
|
1816
|
+
if (!second.on) return second;
|
|
1817
|
+
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1818
|
+
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1819
|
+
}
|
|
1820
|
+
function cutAtFace(puff3, face) {
|
|
1821
|
+
if (face.ny > GROUND_FACING) return;
|
|
1822
|
+
const cut = cutFor(puff3, face);
|
|
1823
|
+
if (!cut) return;
|
|
1824
|
+
cut.on = true;
|
|
1825
|
+
cut.nx = face.nx;
|
|
1826
|
+
cut.ny = face.ny;
|
|
1827
|
+
cut.nz = face.nz;
|
|
1828
|
+
cut.d = face.d;
|
|
1829
|
+
}
|
|
1830
|
+
function cutFrom(puff3, out) {
|
|
1831
|
+
cutAtFace(puff3, out);
|
|
1832
|
+
}
|
|
1833
|
+
function cutAt(confiner, puff3, way) {
|
|
1834
|
+
if (!probe(confiner, puff3, way)) return false;
|
|
1835
|
+
cutAtFace(puff3, confiner.out);
|
|
1836
|
+
return true;
|
|
1837
|
+
}
|
|
1838
|
+
function backward(puff3) {
|
|
1839
|
+
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1840
|
+
if (!(speed > 0)) return null;
|
|
1841
|
+
WAY.x = -puff3.vx / speed;
|
|
1842
|
+
WAY.y = -puff3.vy / speed;
|
|
1843
|
+
WAY.z = -puff3.vz / speed;
|
|
1844
|
+
return WAY;
|
|
1845
|
+
}
|
|
1846
|
+
function along(cut, sign) {
|
|
1847
|
+
WAY.x = sign * cut.nx;
|
|
1848
|
+
WAY.y = sign * cut.ny;
|
|
1849
|
+
WAY.z = sign * cut.nz;
|
|
1850
|
+
return WAY;
|
|
1851
|
+
}
|
|
1852
|
+
function dropPassed(confiner, puff3) {
|
|
1853
|
+
for (let i = 0; i < 2; i++) {
|
|
1854
|
+
const cut = puff3.cuts[i];
|
|
1855
|
+
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1856
|
+
cut.on = false;
|
|
1857
|
+
cutAt(confiner, puff3, along(cut, 1));
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
function keep(confiner, puff3, cut) {
|
|
1861
|
+
if (!cut.on) return;
|
|
1862
|
+
if (!probe(confiner, puff3, along(cut, -1))) {
|
|
1863
|
+
cut.on = false;
|
|
1864
|
+
return;
|
|
1865
|
+
}
|
|
1866
|
+
cut.d = confiner.out.d;
|
|
1867
|
+
}
|
|
1868
|
+
function lookForWalls(confiner, puff3) {
|
|
1869
|
+
dropPassed(confiner, puff3);
|
|
1870
|
+
const turn = Math.round(puff3.t * PROBES_PER_SECOND);
|
|
1871
|
+
if (turn <= 1) {
|
|
1872
|
+
const back = backward(puff3);
|
|
1873
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1874
|
+
for (let i = 0; i < PROBES.length; i++) cutAt(confiner, puff3, PROBES[i]);
|
|
1875
|
+
return;
|
|
1876
|
+
}
|
|
1877
|
+
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1878
|
+
const slot = turn / FRAMES_PER_PROBE % (PROBES.length + 3);
|
|
1879
|
+
if (slot < 2) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1880
|
+
else if (slot === 2) {
|
|
1881
|
+
const back = backward(puff3);
|
|
1882
|
+
if (back) cutAt(confiner, puff3, back);
|
|
1883
|
+
} else cutAt(confiner, puff3, PROBES[slot - 3]);
|
|
1884
|
+
}
|
|
1752
1885
|
var FLOOR_FRACTION = 0.4;
|
|
1753
1886
|
var FLOOR_BOUNCE = -0.2;
|
|
1754
1887
|
var ARRIVAL_FRAME = 30;
|
|
@@ -1788,7 +1921,8 @@ var GameVfxThree = (() => {
|
|
|
1788
1921
|
age: 0,
|
|
1789
1922
|
heat: 0,
|
|
1790
1923
|
size: 0,
|
|
1791
|
-
source: void 0
|
|
1924
|
+
source: void 0,
|
|
1925
|
+
cuts: [createCut(), createCut()]
|
|
1792
1926
|
}));
|
|
1793
1927
|
}
|
|
1794
1928
|
function spawnPuff(pool, random, init) {
|
|
@@ -1822,6 +1956,7 @@ var GameVfxThree = (() => {
|
|
|
1822
1956
|
puff3.heat = 0;
|
|
1823
1957
|
puff3.size = 0;
|
|
1824
1958
|
puff3.source = init.source;
|
|
1959
|
+
clearCuts(puff3);
|
|
1825
1960
|
return puff3;
|
|
1826
1961
|
}
|
|
1827
1962
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1871,17 +2006,21 @@ var GameVfxThree = (() => {
|
|
|
1871
2006
|
MOVE.z0 = puff3.z;
|
|
1872
2007
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1873
2008
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1874
|
-
|
|
2009
|
+
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
2010
|
+
if (carried && confine(confiner, puff3, dt)) {
|
|
1875
2011
|
const out = confiner.out;
|
|
1876
2012
|
puff3.x = out.x;
|
|
1877
2013
|
puff3.y = out.y;
|
|
1878
2014
|
puff3.z = out.z;
|
|
1879
2015
|
slideInto(out, puff3);
|
|
2016
|
+
cutFrom(puff3, out);
|
|
1880
2017
|
}
|
|
1881
2018
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1882
2019
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1883
2020
|
puff3.age = age;
|
|
1884
2021
|
puff3.heat = heat;
|
|
2022
|
+
if (carried) lookForWalls(confiner, puff3);
|
|
2023
|
+
else clearCuts(puff3);
|
|
1885
2024
|
}
|
|
1886
2025
|
}
|
|
1887
2026
|
var GROUND_LIFT = 0.02;
|
|
@@ -4139,8 +4278,36 @@ var GameVfxThree = (() => {
|
|
|
4139
4278
|
loop: 2,
|
|
4140
4279
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4141
4280
|
};
|
|
4281
|
+
var GLASS_PIECE = 11061464;
|
|
4282
|
+
var GLASS_DUST = 12572386;
|
|
4283
|
+
var HIT = [0, 0, 0];
|
|
4284
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4285
|
+
id: "vehicle_glass_chip",
|
|
4286
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4287
|
+
team: "vehicles",
|
|
4288
|
+
budget: { particles: 16, debris: 6 },
|
|
4289
|
+
loop: 2,
|
|
4290
|
+
timeline: [
|
|
4291
|
+
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 }),
|
|
4292
|
+
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 }),
|
|
4293
|
+
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 }))
|
|
4294
|
+
]
|
|
4295
|
+
};
|
|
4296
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4297
|
+
id: "vehicle_glass_shatter",
|
|
4298
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4299
|
+
team: "vehicles",
|
|
4300
|
+
budget: { particles: 40, debris: 0 },
|
|
4301
|
+
loop: 2,
|
|
4302
|
+
timeline: [
|
|
4303
|
+
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 }),
|
|
4304
|
+
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 })
|
|
4305
|
+
]
|
|
4306
|
+
};
|
|
4142
4307
|
var VEHICLE_EFFECTS = [
|
|
4143
4308
|
BODYWORK_IMPACT,
|
|
4309
|
+
VEHICLE_GLASS_CHIP,
|
|
4310
|
+
VEHICLE_GLASS_SHATTER,
|
|
4144
4311
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4145
4312
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4146
4313
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -4852,10 +5019,10 @@ var GameVfxThree = (() => {
|
|
|
4852
5019
|
var MAX_SCALE = 3;
|
|
4853
5020
|
var MIN_SCALE = 0.6;
|
|
4854
5021
|
function reflected(direction, normal) {
|
|
4855
|
-
const
|
|
4856
|
-
const out = [direction[0] - 2 *
|
|
5022
|
+
const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
|
|
5023
|
+
const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
|
|
4857
5024
|
const length = Math.hypot(out[0], out[1], out[2]);
|
|
4858
|
-
if (length < 1e-6 || Math.abs(
|
|
5025
|
+
if (length < 1e-6 || Math.abs(along2) > 0.98) return normal;
|
|
4859
5026
|
return [out[0] / length, out[1] / length, out[2] / length];
|
|
4860
5027
|
}
|
|
4861
5028
|
var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
|
|
@@ -5598,6 +5765,110 @@ var GameVfxThree = (() => {
|
|
|
5598
5765
|
function addScrape(store, spec) {
|
|
5599
5766
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5600
5767
|
}
|
|
5768
|
+
var RESTITUTION = -0.32;
|
|
5769
|
+
var GROUND_FRICTION = 0.5;
|
|
5770
|
+
var REST_SPEED = 0.6;
|
|
5771
|
+
var REST_SLIDE = 0.5;
|
|
5772
|
+
var TRAIL_SECONDS = 1.8;
|
|
5773
|
+
var TRAIL_STEP = 0.025;
|
|
5774
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5775
|
+
var TOP_FACING = 0.7;
|
|
5776
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5777
|
+
function bounce(core, chunk, floor2) {
|
|
5778
|
+
chunk.y = floor2;
|
|
5779
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5780
|
+
chunk.splat = true;
|
|
5781
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5782
|
+
}
|
|
5783
|
+
chunk.vy *= RESTITUTION;
|
|
5784
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5785
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5786
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5787
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5788
|
+
chunk.az *= GROUND_FRICTION;
|
|
5789
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5790
|
+
chunk.rest = true;
|
|
5791
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5792
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5793
|
+
}
|
|
5794
|
+
}
|
|
5795
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5796
|
+
function hitFace(chunk, out) {
|
|
5797
|
+
chunk.x = out.x;
|
|
5798
|
+
chunk.y = out.y;
|
|
5799
|
+
chunk.z = out.z;
|
|
5800
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5801
|
+
if (into >= 0) return;
|
|
5802
|
+
const tx = chunk.vx - into * out.nx;
|
|
5803
|
+
const ty = chunk.vy - into * out.ny;
|
|
5804
|
+
const tz = chunk.vz - into * out.nz;
|
|
5805
|
+
const back = into * RESTITUTION;
|
|
5806
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5807
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
5808
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
5809
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5810
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5811
|
+
chunk.az *= GROUND_FRICTION;
|
|
5812
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
5813
|
+
chunk.rest = true;
|
|
5814
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5815
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
function leaveTrail(core, chunk, dt) {
|
|
5819
|
+
chunk.trail -= dt;
|
|
5820
|
+
if (chunk.trail > 0) return;
|
|
5821
|
+
chunk.trail = TRAIL_STEP;
|
|
5822
|
+
const random = chunk.rng;
|
|
5823
|
+
addSpark(core, {
|
|
5824
|
+
x: chunk.x,
|
|
5825
|
+
y: chunk.y,
|
|
5826
|
+
z: chunk.z,
|
|
5827
|
+
vx: chunk.vx * 0.15,
|
|
5828
|
+
vy: chunk.vy * 0.15,
|
|
5829
|
+
vz: chunk.vz * 0.15,
|
|
5830
|
+
life: random.between(0.25, 0.45),
|
|
5831
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
5832
|
+
st: 0.05,
|
|
5833
|
+
kind: 0,
|
|
5834
|
+
g: 0,
|
|
5835
|
+
drag: 1,
|
|
5836
|
+
source: chunk.source
|
|
5837
|
+
});
|
|
5838
|
+
if (random.next() < 0.25) {
|
|
5839
|
+
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 });
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
function updateChunks(core, dt) {
|
|
5843
|
+
const confiner = core.confiner;
|
|
5844
|
+
const confining = !confiner.empty;
|
|
5845
|
+
const chunks = core.chunks.items;
|
|
5846
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
5847
|
+
const chunk = chunks[index];
|
|
5848
|
+
chunk.t += dt;
|
|
5849
|
+
if (chunk.rest) continue;
|
|
5850
|
+
MOVE2.x0 = chunk.x;
|
|
5851
|
+
MOVE2.y0 = chunk.y;
|
|
5852
|
+
MOVE2.z0 = chunk.z;
|
|
5853
|
+
chunk.vy -= core.gravity * dt;
|
|
5854
|
+
chunk.x += chunk.vx * dt;
|
|
5855
|
+
chunk.y += chunk.vy * dt;
|
|
5856
|
+
chunk.z += chunk.vz * dt;
|
|
5857
|
+
chunk.rx += chunk.ax * dt;
|
|
5858
|
+
chunk.ry += chunk.ay * dt;
|
|
5859
|
+
chunk.rz += chunk.az * dt;
|
|
5860
|
+
if (confining) {
|
|
5861
|
+
MOVE2.x1 = chunk.x;
|
|
5862
|
+
MOVE2.y1 = chunk.y;
|
|
5863
|
+
MOVE2.z1 = chunk.z;
|
|
5864
|
+
MOVE2.pad = chunkPad(chunk);
|
|
5865
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
5866
|
+
}
|
|
5867
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
5868
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
5869
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5601
5872
|
function createRingPool(capacity) {
|
|
5602
5873
|
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 }));
|
|
5603
5874
|
}
|
|
@@ -5727,6 +5998,18 @@ var GameVfxThree = (() => {
|
|
|
5727
5998
|
puff3.z = out.z;
|
|
5728
5999
|
slideInto(out, puff3);
|
|
5729
6000
|
}
|
|
6001
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6002
|
+
const confiner = core.confiner;
|
|
6003
|
+
if (confiner.empty) return;
|
|
6004
|
+
BIRTH.x0 = ox;
|
|
6005
|
+
BIRTH.y0 = oy;
|
|
6006
|
+
BIRTH.z0 = oz;
|
|
6007
|
+
BIRTH.x1 = chunk.x;
|
|
6008
|
+
BIRTH.y1 = chunk.y;
|
|
6009
|
+
BIRTH.z1 = chunk.z;
|
|
6010
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6011
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6012
|
+
}
|
|
5730
6013
|
function composeFireballs(context) {
|
|
5731
6014
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5732
6015
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5807,7 +6090,7 @@ var GameVfxThree = (() => {
|
|
|
5807
6090
|
spawnShock(core.shocks, spec);
|
|
5808
6091
|
}
|
|
5809
6092
|
function composeDust(context) {
|
|
5810
|
-
const { core, def, random, x, z, size, scale } = context;
|
|
6093
|
+
const { core, def, random, x, y, z, size, scale } = context;
|
|
5811
6094
|
if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
|
|
5812
6095
|
const count = Math.round(def.dust.count * scale);
|
|
5813
6096
|
const color = hexToLinearRgb(def.dust.color);
|
|
@@ -5837,7 +6120,7 @@ var GameVfxThree = (() => {
|
|
|
5837
6120
|
color,
|
|
5838
6121
|
kind: 1
|
|
5839
6122
|
});
|
|
5840
|
-
bornFrom(core, dust, x,
|
|
6123
|
+
bornFrom(core, dust, x, y, z);
|
|
5841
6124
|
}
|
|
5842
6125
|
}
|
|
5843
6126
|
function coneAngle(context) {
|
|
@@ -5911,7 +6194,7 @@ var GameVfxThree = (() => {
|
|
|
5911
6194
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
5912
6195
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
5913
6196
|
const hot = random.next() < chunks.hot;
|
|
5914
|
-
addChunk(core, random, {
|
|
6197
|
+
const chunk = addChunk(core, random, {
|
|
5915
6198
|
x: x + d.x * 0.2,
|
|
5916
6199
|
y: y + 0.2,
|
|
5917
6200
|
z: z + d.z * 0.2,
|
|
@@ -5925,10 +6208,11 @@ var GameVfxThree = (() => {
|
|
|
5925
6208
|
plate,
|
|
5926
6209
|
hot
|
|
5927
6210
|
});
|
|
6211
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
5928
6212
|
}
|
|
5929
6213
|
}
|
|
5930
6214
|
function composeRimDebris(context) {
|
|
5931
|
-
const { core, random, x, z } = context;
|
|
6215
|
+
const { core, random, x, y, z } = context;
|
|
5932
6216
|
const radius = context.def.mark.crater ?? 0;
|
|
5933
6217
|
if (!core.layers.shrapnel) return;
|
|
5934
6218
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -5939,7 +6223,7 @@ var GameVfxThree = (() => {
|
|
|
5939
6223
|
const s = random.between(0.12, 0.28);
|
|
5940
6224
|
const vy2 = random.between(4, 10);
|
|
5941
6225
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
5942
|
-
addChunk(core, random, {
|
|
6226
|
+
const chunk = addChunk(core, random, {
|
|
5943
6227
|
x: x + Math.cos(angle) * 0.3,
|
|
5944
6228
|
y: 0.1,
|
|
5945
6229
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -5952,6 +6236,7 @@ var GameVfxThree = (() => {
|
|
|
5952
6236
|
color,
|
|
5953
6237
|
plate: true
|
|
5954
6238
|
});
|
|
6239
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
5955
6240
|
}
|
|
5956
6241
|
}
|
|
5957
6242
|
function composeMushroom(context, spec) {
|
|
@@ -6082,71 +6367,6 @@ var GameVfxThree = (() => {
|
|
|
6082
6367
|
emitRequests(context);
|
|
6083
6368
|
return scale;
|
|
6084
6369
|
}
|
|
6085
|
-
var RESTITUTION = -0.32;
|
|
6086
|
-
var GROUND_FRICTION = 0.5;
|
|
6087
|
-
var REST_SPEED = 0.6;
|
|
6088
|
-
var REST_SLIDE = 0.5;
|
|
6089
|
-
var TRAIL_SECONDS = 1.8;
|
|
6090
|
-
var TRAIL_STEP = 0.025;
|
|
6091
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6092
|
-
function bounce(core, chunk, floor2) {
|
|
6093
|
-
chunk.y = floor2;
|
|
6094
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6095
|
-
chunk.splat = true;
|
|
6096
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6097
|
-
}
|
|
6098
|
-
chunk.vy *= RESTITUTION;
|
|
6099
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6100
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6101
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6102
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6103
|
-
chunk.az *= GROUND_FRICTION;
|
|
6104
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6105
|
-
chunk.rest = true;
|
|
6106
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6107
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6108
|
-
}
|
|
6109
|
-
}
|
|
6110
|
-
function leaveTrail(core, chunk, dt) {
|
|
6111
|
-
chunk.trail -= dt;
|
|
6112
|
-
if (chunk.trail > 0) return;
|
|
6113
|
-
chunk.trail = TRAIL_STEP;
|
|
6114
|
-
const random = chunk.rng;
|
|
6115
|
-
addSpark(core, {
|
|
6116
|
-
x: chunk.x,
|
|
6117
|
-
y: chunk.y,
|
|
6118
|
-
z: chunk.z,
|
|
6119
|
-
vx: chunk.vx * 0.15,
|
|
6120
|
-
vy: chunk.vy * 0.15,
|
|
6121
|
-
vz: chunk.vz * 0.15,
|
|
6122
|
-
life: random.between(0.25, 0.45),
|
|
6123
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6124
|
-
st: 0.05,
|
|
6125
|
-
kind: 0,
|
|
6126
|
-
g: 0,
|
|
6127
|
-
drag: 1,
|
|
6128
|
-
source: chunk.source
|
|
6129
|
-
});
|
|
6130
|
-
if (random.next() < 0.25) {
|
|
6131
|
-
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 });
|
|
6132
|
-
}
|
|
6133
|
-
}
|
|
6134
|
-
function updateChunks(core, dt) {
|
|
6135
|
-
for (const chunk of core.chunks.items) {
|
|
6136
|
-
chunk.t += dt;
|
|
6137
|
-
if (chunk.rest) continue;
|
|
6138
|
-
chunk.vy -= core.gravity * dt;
|
|
6139
|
-
chunk.x += chunk.vx * dt;
|
|
6140
|
-
chunk.y += chunk.vy * dt;
|
|
6141
|
-
chunk.z += chunk.vz * dt;
|
|
6142
|
-
chunk.rx += chunk.ax * dt;
|
|
6143
|
-
chunk.ry += chunk.ay * dt;
|
|
6144
|
-
chunk.rz += chunk.az * dt;
|
|
6145
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6146
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6147
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6148
|
-
}
|
|
6149
|
-
}
|
|
6150
6370
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6151
6371
|
var INITIAL_FLASH_DECAY = 6;
|
|
6152
6372
|
function createScreenState() {
|
|
@@ -6168,6 +6388,9 @@ var GameVfxThree = (() => {
|
|
|
6168
6388
|
state.beat *= Math.exp(-DECAY.beat * dt);
|
|
6169
6389
|
}
|
|
6170
6390
|
var PAD_OF_SIZE2 = 0.35;
|
|
6391
|
+
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6392
|
+
var GROUND_RESAMPLE = 0.1;
|
|
6393
|
+
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6171
6394
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6172
6395
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6173
6396
|
function rgb(hex) {
|
|
@@ -6214,6 +6437,7 @@ var GameVfxThree = (() => {
|
|
|
6214
6437
|
__publicField(this, "bounced");
|
|
6215
6438
|
__publicField(this, "floor");
|
|
6216
6439
|
__publicField(this, "riseMul");
|
|
6440
|
+
__publicField(this, "ground");
|
|
6217
6441
|
const n = Math.max(1, capacity);
|
|
6218
6442
|
this.position = new Float32Array(n * 3);
|
|
6219
6443
|
this.color = new Float32Array(n * 3);
|
|
@@ -6236,6 +6460,7 @@ var GameVfxThree = (() => {
|
|
|
6236
6460
|
this.bounced = new Uint8Array(n);
|
|
6237
6461
|
this.floor = new Float32Array(n);
|
|
6238
6462
|
this.riseMul = new Float32Array(n);
|
|
6463
|
+
this.ground = new Float32Array(n * 3);
|
|
6239
6464
|
}
|
|
6240
6465
|
spawn(kind, p, v, random, options) {
|
|
6241
6466
|
if (this.capacity <= 0) return;
|
|
@@ -6263,6 +6488,7 @@ var GameVfxThree = (() => {
|
|
|
6263
6488
|
this.bounced[i] = 0;
|
|
6264
6489
|
this.floor[i] = options?.floor ?? Number.NaN;
|
|
6265
6490
|
this.riseMul[i] = options?.rise ?? 1;
|
|
6491
|
+
this.ground[i * 3] = Number.NaN;
|
|
6266
6492
|
this.size[i] = this.size0[i];
|
|
6267
6493
|
this.alpha[i] = 0;
|
|
6268
6494
|
}
|
|
@@ -6356,18 +6582,36 @@ var GameVfxThree = (() => {
|
|
|
6356
6582
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6357
6583
|
const confiner = host.confiner;
|
|
6358
6584
|
if (def.carried && confiner && !confiner.empty) {
|
|
6359
|
-
|
|
6360
|
-
|
|
6585
|
+
STEP.x0 = this.position[i3];
|
|
6586
|
+
STEP.y0 = this.position[i3 + 1];
|
|
6587
|
+
STEP.z0 = this.position[i3 + 2];
|
|
6588
|
+
STEP.x1 = x;
|
|
6589
|
+
STEP.y1 = y;
|
|
6590
|
+
STEP.z1 = z;
|
|
6591
|
+
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6592
|
+
if (confiner.confineMove(STEP, dt)) {
|
|
6361
6593
|
const out = confiner.out;
|
|
6362
6594
|
x = out.x;
|
|
6363
6595
|
y = out.y;
|
|
6364
6596
|
z = out.z;
|
|
6365
|
-
|
|
6597
|
+
VELOCITY.vx = vx2;
|
|
6598
|
+
VELOCITY.vy = vy2;
|
|
6599
|
+
VELOCITY.vz = vz2;
|
|
6600
|
+
slideInto(out, VELOCITY);
|
|
6601
|
+
vx2 = VELOCITY.vx;
|
|
6602
|
+
vy2 = VELOCITY.vy;
|
|
6603
|
+
vz2 = VELOCITY.vz;
|
|
6366
6604
|
}
|
|
6367
6605
|
}
|
|
6368
6606
|
if (def.ground !== "none") {
|
|
6369
6607
|
const own = this.floor[i];
|
|
6370
|
-
const
|
|
6608
|
+
const ground = this.ground;
|
|
6609
|
+
if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
|
|
6610
|
+
ground[i3] = x;
|
|
6611
|
+
ground[i3 + 1] = z;
|
|
6612
|
+
ground[i3 + 2] = host.groundAt(x, z);
|
|
6613
|
+
}
|
|
6614
|
+
const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
|
|
6371
6615
|
if (y < gy) {
|
|
6372
6616
|
if (def.ground === "land") {
|
|
6373
6617
|
const tag = this.tag[i];
|
|
@@ -7213,10 +7457,10 @@ var GameVfxThree = (() => {
|
|
|
7213
7457
|
if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
|
|
7214
7458
|
particle.vy -= particle.gravity * dt;
|
|
7215
7459
|
if (particle.drag) {
|
|
7216
|
-
const
|
|
7217
|
-
particle.vx *=
|
|
7218
|
-
particle.vy *=
|
|
7219
|
-
particle.vz *=
|
|
7460
|
+
const keep2 = Math.max(0, 1 - particle.drag * dt);
|
|
7461
|
+
particle.vx *= keep2;
|
|
7462
|
+
particle.vy *= keep2;
|
|
7463
|
+
particle.vz *= keep2;
|
|
7220
7464
|
}
|
|
7221
7465
|
if (particle.carried) this.ride(particle, dt);
|
|
7222
7466
|
else {
|
|
@@ -8060,10 +8304,10 @@ var GameVfxThree = (() => {
|
|
|
8060
8304
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
8061
8305
|
},
|
|
8062
8306
|
clearSource(source) {
|
|
8063
|
-
const
|
|
8307
|
+
const keep2 = (record, gone) => record.source !== gone;
|
|
8064
8308
|
const drop = (pool) => {
|
|
8065
8309
|
const before = pool.count;
|
|
8066
|
-
pool.compact(
|
|
8310
|
+
pool.compact(keep2, source);
|
|
8067
8311
|
return before - pool.count;
|
|
8068
8312
|
};
|
|
8069
8313
|
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
@@ -8989,23 +9233,24 @@ float vn(vec3 x){vec3 i=floor(x),f=fract(x);f=f*f*(3.-2.*f);
|
|
|
8989
9233
|
`;
|
|
8990
9234
|
|
|
8991
9235
|
// src/shaders/puff.ts
|
|
9236
|
+
var PUFF_BASE = (PUFF_REACH - 0.5).toFixed(2);
|
|
8992
9237
|
var PUFF_VERTEX = `${GL_NOISE}
|
|
8993
|
-
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
9238
|
+
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;attribute vec4 aK;attribute vec4 aK2;varying vec4 vK;varying vec4 vK2;
|
|
8994
9239
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
8995
9240
|
void main(){
|
|
8996
9241
|
vec3 p=position;
|
|
8997
9242
|
float s=aD.z;
|
|
8998
9243
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
8999
|
-
p
|
|
9244
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
9000
9245
|
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;
|
|
9001
9246
|
vL=p;
|
|
9002
9247
|
vec3 wp=aP.xyz+p*aP.w;
|
|
9003
|
-
vWP=wp;vD=aD;vC=aC;
|
|
9248
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
9004
9249
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
9005
9250
|
}`;
|
|
9006
9251
|
var PUFF_FRAGMENT = `${GL_NOISE}
|
|
9007
9252
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
9008
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
9253
|
+
varying vec4 vK;varying vec4 vK2;varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;
|
|
9009
9254
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
9010
9255
|
vec3 ramp(float h){
|
|
9011
9256
|
vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
|
|
@@ -9015,6 +9260,8 @@ vec3 ramp(float h){
|
|
|
9015
9260
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
9016
9261
|
}
|
|
9017
9262
|
void main(){
|
|
9263
|
+
// cut at the face of a wall within reach (Puff.cuts): smoke flattens on the wall, it does not show through on its other side
|
|
9264
|
+
if(dot(vWP,vK.xyz)<vK.w||dot(vWP,vK2.xyz)<vK2.w)discard;
|
|
9018
9265
|
vec3 N=normalize(cross(dFdx(vWP),dFdy(vWP)));
|
|
9019
9266
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
9020
9267
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
@@ -9043,23 +9290,23 @@ void main(){
|
|
|
9043
9290
|
#include <colorspace_fragment>
|
|
9044
9291
|
}`;
|
|
9045
9292
|
var SOFT_PUFF_VERTEX = `${GL_NOISE}
|
|
9046
|
-
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;
|
|
9293
|
+
attribute vec4 aP;attribute vec4 aD;attribute vec3 aC;attribute vec4 aK;attribute vec4 aK2;varying vec4 vK;varying vec4 vK2;
|
|
9047
9294
|
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
9048
9295
|
void main(){
|
|
9049
9296
|
vec3 p=position;
|
|
9050
9297
|
vec3 q=normalize(position);
|
|
9051
9298
|
float s=aD.z;
|
|
9052
9299
|
float n=vn(p*1.6+vec3(s*11.0,s*7.0,s*3.0));
|
|
9053
|
-
p
|
|
9300
|
+
p*=${PUFF_BASE}+0.5*n;
|
|
9054
9301
|
float a=s*6.2831;float c=cos(a),si=sin(a);p.xz=mat2(c,-si,si,c)*p.xz;q.xz=mat2(c,-si,si,c)*q.xz;
|
|
9055
9302
|
vL=p;vN=q;
|
|
9056
9303
|
vec3 wp=aP.xyz+p*aP.w;
|
|
9057
|
-
vWP=wp;vD=aD;vC=aC;
|
|
9304
|
+
vWP=wp;vD=aD;vC=aC;vK=aK;vK2=aK2;
|
|
9058
9305
|
gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.0);
|
|
9059
9306
|
}`;
|
|
9060
9307
|
var SOFT_PUFF_FRAGMENT = `${GL_NOISE}
|
|
9061
9308
|
uniform vec3 uLight;uniform vec3 uSky;uniform vec3 uGround;uniform vec3 uGlowPos;uniform vec3 uGlowCol;uniform float uGlowI;
|
|
9062
|
-
varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
9309
|
+
varying vec4 vK;varying vec4 vK2;varying vec3 vWP;varying vec3 vL;varying vec4 vD;varying vec3 vC;varying vec3 vN;
|
|
9063
9310
|
vec3 L(vec3 c){return pow(c,vec3(2.2));}
|
|
9064
9311
|
vec3 ramp(float h){
|
|
9065
9312
|
vec3 c0=L(vec3(.36,.07,.03)),c1=L(vec3(.76,.21,.1)),c2=L(vec3(1.,.54,.16)),c3=L(vec3(1.,.83,.42)),c4=L(vec3(1.,.96,.84));
|
|
@@ -9069,6 +9316,8 @@ vec3 ramp(float h){
|
|
|
9069
9316
|
return mix(c3,c4,clamp((h-.8)/.4,0.,1.));
|
|
9070
9317
|
}
|
|
9071
9318
|
void main(){
|
|
9319
|
+
// cut at the face of a wall within reach (Puff.cuts): smoke flattens on the wall, it does not show through on its other side
|
|
9320
|
+
if(dot(vWP,vK.xyz)<vK.w||dot(vWP,vK2.xyz)<vK2.w)discard;
|
|
9072
9321
|
float age=vD.x,heat=vD.y,kind=vD.w;
|
|
9073
9322
|
float n=vn(vL*2.4+vD.z*13.0);
|
|
9074
9323
|
// the sphere's own normal, roughened by the noise: a billowing cloud, never facets
|
|
@@ -9136,6 +9385,13 @@ void main(){
|
|
|
9136
9385
|
function dynamic(THREE, array, size) {
|
|
9137
9386
|
return new THREE.InstancedBufferAttribute(array, size).setUsage(THREE.DynamicDrawUsage);
|
|
9138
9387
|
}
|
|
9388
|
+
var NO_CUT = -1e9;
|
|
9389
|
+
function writeCut(into, n, cut) {
|
|
9390
|
+
into[n * 4] = cut.on ? cut.nx : 0;
|
|
9391
|
+
into[n * 4 + 1] = cut.on ? cut.ny : 0;
|
|
9392
|
+
into[n * 4 + 2] = cut.on ? cut.nz : 0;
|
|
9393
|
+
into[n * 4 + 3] = cut.on ? cut.d : NO_CUT;
|
|
9394
|
+
}
|
|
9139
9395
|
var PUFF_DETAIL = { faceted: 1, soft: 2 };
|
|
9140
9396
|
function createPuffLayer(THREE, pool, uniforms, style = "faceted") {
|
|
9141
9397
|
const capacity = pool.capacity;
|
|
@@ -9144,10 +9400,14 @@ void main(){
|
|
|
9144
9400
|
const a = new Float32Array(capacity * 4);
|
|
9145
9401
|
const d = new Float32Array(capacity * 4);
|
|
9146
9402
|
const c = new Float32Array(capacity * 3);
|
|
9147
|
-
const
|
|
9403
|
+
const k = new Float32Array(capacity * 4);
|
|
9404
|
+
const k2 = new Float32Array(capacity * 4);
|
|
9405
|
+
const attributes = [dynamic(THREE, a, 4), dynamic(THREE, d, 4), dynamic(THREE, c, 3), dynamic(THREE, k, 4), dynamic(THREE, k2, 4)];
|
|
9148
9406
|
geometry.setAttribute("aP", attributes[0]);
|
|
9149
9407
|
geometry.setAttribute("aD", attributes[1]);
|
|
9150
9408
|
geometry.setAttribute("aC", attributes[2]);
|
|
9409
|
+
geometry.setAttribute("aK", attributes[3]);
|
|
9410
|
+
geometry.setAttribute("aK2", attributes[4]);
|
|
9151
9411
|
geometry.instanceCount = 0;
|
|
9152
9412
|
const material2 = style === "faceted" ? new THREE.ShaderMaterial({ uniforms, vertexShader: PUFF_VERTEX, fragmentShader: PUFF_FRAGMENT }) : new THREE.ShaderMaterial({ uniforms, vertexShader: SOFT_PUFF_VERTEX, fragmentShader: SOFT_PUFF_FRAGMENT, transparent: true, depthWrite: false });
|
|
9153
9413
|
const mesh2 = new THREE.Mesh(geometry, material2);
|
|
@@ -9169,6 +9429,8 @@ void main(){
|
|
|
9169
9429
|
c[n * 3] = p.color[0];
|
|
9170
9430
|
c[n * 3 + 1] = p.color[1];
|
|
9171
9431
|
c[n * 3 + 2] = p.color[2];
|
|
9432
|
+
writeCut(k, n, p.cuts[0]);
|
|
9433
|
+
writeCut(k2, n, p.cuts[1]);
|
|
9172
9434
|
n++;
|
|
9173
9435
|
}
|
|
9174
9436
|
geometry.instanceCount = n;
|