@adatechnology/game-vfx 0.19.0 → 0.20.1
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 +24 -2
- package/dist/index.global.js +287 -114
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +287 -114
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1675,8 +1675,9 @@ function slideAlong(out, vx2, vy2, vz2) {
|
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
1677
|
// src/pools/puff-cuts.ts
|
|
1678
|
+
var PUFF_CUTS = 3;
|
|
1678
1679
|
var PUFF_REACH = 1.28;
|
|
1679
|
-
var PROBES = [
|
|
1680
|
+
var PROBES = [Float64Array.of(1, 0, 0), Float64Array.of(-1, 0, 0), Float64Array.of(0, 0, 1), Float64Array.of(0, 0, -1), Float64Array.of(0, 1, 0)];
|
|
1680
1681
|
var PROBES_PER_SECOND = 60;
|
|
1681
1682
|
var FRAMES_PER_PROBE = 3;
|
|
1682
1683
|
var GROUND_FACING = 0.7;
|
|
@@ -1695,41 +1696,44 @@ function createCut() {
|
|
|
1695
1696
|
return new KeptCut();
|
|
1696
1697
|
}
|
|
1697
1698
|
function clearCuts(puff3) {
|
|
1698
|
-
puff3.cuts[
|
|
1699
|
-
puff3.cuts[1].on = false;
|
|
1699
|
+
for (let i = 0; i < PUFF_CUTS; i++) puff3.cuts[i].on = false;
|
|
1700
1700
|
}
|
|
1701
|
-
var
|
|
1702
|
-
|
|
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();
|
|
1701
|
+
var WAY = new Float64Array(3);
|
|
1702
|
+
var PASSED = 0.02;
|
|
1709
1703
|
function probe(confiner, puff3, way) {
|
|
1710
|
-
const reach = puff3.size * PUFF_REACH;
|
|
1704
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1711
1705
|
if (!(reach > 0)) return false;
|
|
1712
1706
|
PROBE.x0 = puff3.x;
|
|
1713
1707
|
PROBE.y0 = puff3.y;
|
|
1714
1708
|
PROBE.z0 = puff3.z;
|
|
1715
|
-
PROBE.x1 = puff3.x + way
|
|
1716
|
-
PROBE.y1 = puff3.y + way
|
|
1717
|
-
PROBE.z1 = puff3.z + way
|
|
1709
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1710
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1711
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1712
|
+
PROBE.pad = 0;
|
|
1713
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1714
|
+
}
|
|
1715
|
+
function probeAgain(confiner, puff3, way) {
|
|
1716
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1717
|
+
if (!(reach > 0)) return false;
|
|
1718
|
+
PROBE.x0 = puff3.x - way[0] * PASSED;
|
|
1719
|
+
PROBE.y0 = puff3.y - way[1] * PASSED;
|
|
1720
|
+
PROBE.z0 = puff3.z - way[2] * PASSED;
|
|
1721
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1722
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1723
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1718
1724
|
PROBE.pad = 0;
|
|
1719
1725
|
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1720
1726
|
}
|
|
1721
1727
|
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;
|
|
1728
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d - PASSED;
|
|
1723
1729
|
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1724
1730
|
function cutFor(puff3, face) {
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
if (
|
|
1730
|
-
|
|
1731
|
-
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1732
|
-
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1731
|
+
const cuts = puff3.cuts;
|
|
1732
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (sameWall(cuts[i], face)) return cuts[i];
|
|
1733
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (!cuts[i].on) return cuts[i];
|
|
1734
|
+
let farthest = cuts[0];
|
|
1735
|
+
for (let i = 1; i < PUFF_CUTS; i++) if (isFartherFrom(puff3, cuts[i], farthest)) farthest = cuts[i];
|
|
1736
|
+
return isFartherFrom(puff3, farthest, face) ? farthest : void 0;
|
|
1733
1737
|
}
|
|
1734
1738
|
function cutAtFace(puff3, face) {
|
|
1735
1739
|
if (face.ny > GROUND_FACING) return;
|
|
@@ -1752,28 +1756,35 @@ function cutAt(confiner, puff3, way) {
|
|
|
1752
1756
|
function backward(puff3) {
|
|
1753
1757
|
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1754
1758
|
if (!(speed > 0)) return null;
|
|
1755
|
-
WAY
|
|
1756
|
-
WAY
|
|
1757
|
-
WAY
|
|
1759
|
+
WAY[0] = -puff3.vx / speed;
|
|
1760
|
+
WAY[1] = -puff3.vy / speed;
|
|
1761
|
+
WAY[2] = -puff3.vz / speed;
|
|
1758
1762
|
return WAY;
|
|
1759
1763
|
}
|
|
1760
1764
|
function along(cut, sign) {
|
|
1761
|
-
WAY
|
|
1762
|
-
WAY
|
|
1763
|
-
WAY
|
|
1765
|
+
WAY[0] = sign * cut.nx;
|
|
1766
|
+
WAY[1] = sign * cut.ny;
|
|
1767
|
+
WAY[2] = sign * cut.nz;
|
|
1764
1768
|
return WAY;
|
|
1765
1769
|
}
|
|
1766
1770
|
function dropPassed(confiner, puff3) {
|
|
1767
|
-
for (let i = 0; i <
|
|
1771
|
+
for (let i = 0; i < PUFF_CUTS; i++) {
|
|
1768
1772
|
const cut = puff3.cuts[i];
|
|
1769
1773
|
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1770
1774
|
cut.on = false;
|
|
1775
|
+
const nx = cut.nx;
|
|
1776
|
+
const ny = cut.ny;
|
|
1777
|
+
const nz = cut.nz;
|
|
1771
1778
|
cutAt(confiner, puff3, along(cut, 1));
|
|
1779
|
+
WAY[0] = -nx;
|
|
1780
|
+
WAY[1] = -ny;
|
|
1781
|
+
WAY[2] = -nz;
|
|
1782
|
+
cutAt(confiner, puff3, WAY);
|
|
1772
1783
|
}
|
|
1773
1784
|
}
|
|
1774
1785
|
function keep(confiner, puff3, cut) {
|
|
1775
1786
|
if (!cut.on) return;
|
|
1776
|
-
if (!
|
|
1787
|
+
if (!probeAgain(confiner, puff3, along(cut, -1))) {
|
|
1777
1788
|
cut.on = false;
|
|
1778
1789
|
return;
|
|
1779
1790
|
}
|
|
@@ -1789,12 +1800,12 @@ function lookForWalls(confiner, puff3) {
|
|
|
1789
1800
|
return;
|
|
1790
1801
|
}
|
|
1791
1802
|
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1792
|
-
const slot = turn / FRAMES_PER_PROBE % (PROBES.length +
|
|
1793
|
-
if (slot <
|
|
1794
|
-
else if (slot ===
|
|
1803
|
+
const slot = (turn / FRAMES_PER_PROBE | 0) % (PROBES.length + PUFF_CUTS + 1);
|
|
1804
|
+
if (slot < PUFF_CUTS) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1805
|
+
else if (slot === PUFF_CUTS) {
|
|
1795
1806
|
const back = backward(puff3);
|
|
1796
1807
|
if (back) cutAt(confiner, puff3, back);
|
|
1797
|
-
} else cutAt(confiner, puff3, PROBES[slot -
|
|
1808
|
+
} else cutAt(confiner, puff3, PROBES[slot - PUFF_CUTS - 1]);
|
|
1798
1809
|
}
|
|
1799
1810
|
|
|
1800
1811
|
// src/pools/puffs.ts
|
|
@@ -1838,7 +1849,7 @@ function createPuffPool(capacity) {
|
|
|
1838
1849
|
heat: 0,
|
|
1839
1850
|
size: 0,
|
|
1840
1851
|
source: void 0,
|
|
1841
|
-
cuts: [createCut(), createCut()]
|
|
1852
|
+
cuts: [createCut(), createCut(), createCut()]
|
|
1842
1853
|
}));
|
|
1843
1854
|
}
|
|
1844
1855
|
function spawnPuff(pool, random, init) {
|
|
@@ -1890,7 +1901,9 @@ function moveOnRing(puff3, ring2, wind) {
|
|
|
1890
1901
|
puff3.z = ring2.z + Math.sin(puff3.ph) * radius + wind.z * ringTime * 0.6;
|
|
1891
1902
|
puff3.y = centerY + minorRadius * Math.sin(theta);
|
|
1892
1903
|
}
|
|
1893
|
-
function moveFree(puff3, dt,
|
|
1904
|
+
function moveFree(puff3, dt, wind) {
|
|
1905
|
+
const age = puff3.age;
|
|
1906
|
+
const heat = puff3.heat;
|
|
1894
1907
|
const damping = Math.exp(-puff3.drag * dt);
|
|
1895
1908
|
puff3.vx *= damping;
|
|
1896
1909
|
puff3.vy *= damping;
|
|
@@ -1915,13 +1928,13 @@ function updatePuffs(pool, dt, wind, confiner) {
|
|
|
1915
1928
|
pool.compact(ageOrKeep2, dt);
|
|
1916
1929
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
1917
1930
|
for (const puff3 of pool.items) {
|
|
1918
|
-
|
|
1919
|
-
|
|
1931
|
+
puff3.age = puff3.t / puff3.life;
|
|
1932
|
+
puff3.heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
1920
1933
|
MOVE.x0 = puff3.x;
|
|
1921
1934
|
MOVE.y0 = puff3.y;
|
|
1922
1935
|
MOVE.z0 = puff3.z;
|
|
1923
1936
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1924
|
-
else moveFree(puff3, dt,
|
|
1937
|
+
else moveFree(puff3, dt, wind);
|
|
1925
1938
|
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
1926
1939
|
if (carried && confine(confiner, puff3, dt)) {
|
|
1927
1940
|
const out = confiner.out;
|
|
@@ -1933,8 +1946,6 @@ function updatePuffs(pool, dt, wind, confiner) {
|
|
|
1933
1946
|
}
|
|
1934
1947
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1935
1948
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
1936
|
-
puff3.age = age;
|
|
1937
|
-
puff3.heat = heat;
|
|
1938
1949
|
if (carried) lookForWalls(confiner, puff3);
|
|
1939
1950
|
else clearCuts(puff3);
|
|
1940
1951
|
}
|
|
@@ -4308,8 +4319,36 @@ var BODYWORK_IMPACT = {
|
|
|
4308
4319
|
loop: 2,
|
|
4309
4320
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4310
4321
|
};
|
|
4322
|
+
var GLASS_PIECE = 11061464;
|
|
4323
|
+
var GLASS_DUST = 12572386;
|
|
4324
|
+
var HIT = [0, 0, 0];
|
|
4325
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4326
|
+
id: "vehicle_glass_chip",
|
|
4327
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4328
|
+
team: "vehicles",
|
|
4329
|
+
budget: { particles: 16, debris: 6 },
|
|
4330
|
+
loop: 2,
|
|
4331
|
+
timeline: [
|
|
4332
|
+
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 }),
|
|
4333
|
+
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 }),
|
|
4334
|
+
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 }))
|
|
4335
|
+
]
|
|
4336
|
+
};
|
|
4337
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4338
|
+
id: "vehicle_glass_shatter",
|
|
4339
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4340
|
+
team: "vehicles",
|
|
4341
|
+
budget: { particles: 40, debris: 0 },
|
|
4342
|
+
loop: 2,
|
|
4343
|
+
timeline: [
|
|
4344
|
+
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 }),
|
|
4345
|
+
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 })
|
|
4346
|
+
]
|
|
4347
|
+
};
|
|
4311
4348
|
var VEHICLE_EFFECTS = [
|
|
4312
4349
|
BODYWORK_IMPACT,
|
|
4350
|
+
VEHICLE_GLASS_CHIP,
|
|
4351
|
+
VEHICLE_GLASS_SHATTER,
|
|
4313
4352
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4314
4353
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4315
4354
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -5830,6 +5869,112 @@ function addScrape(store, spec) {
|
|
|
5830
5869
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5831
5870
|
}
|
|
5832
5871
|
|
|
5872
|
+
// src/pools/chunk-motion.ts
|
|
5873
|
+
var RESTITUTION = -0.32;
|
|
5874
|
+
var GROUND_FRICTION = 0.5;
|
|
5875
|
+
var REST_SPEED = 0.6;
|
|
5876
|
+
var REST_SLIDE = 0.5;
|
|
5877
|
+
var TRAIL_SECONDS = 1.8;
|
|
5878
|
+
var TRAIL_STEP = 0.025;
|
|
5879
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5880
|
+
var TOP_FACING = 0.7;
|
|
5881
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5882
|
+
function bounce(core, chunk, floor2) {
|
|
5883
|
+
chunk.y = floor2;
|
|
5884
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5885
|
+
chunk.splat = true;
|
|
5886
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5887
|
+
}
|
|
5888
|
+
chunk.vy *= RESTITUTION;
|
|
5889
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5890
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5891
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5892
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5893
|
+
chunk.az *= GROUND_FRICTION;
|
|
5894
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5895
|
+
chunk.rest = true;
|
|
5896
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5897
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5898
|
+
}
|
|
5899
|
+
}
|
|
5900
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5901
|
+
function hitFace(chunk, out) {
|
|
5902
|
+
chunk.x = out.x;
|
|
5903
|
+
chunk.y = out.y;
|
|
5904
|
+
chunk.z = out.z;
|
|
5905
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5906
|
+
if (into >= 0) return;
|
|
5907
|
+
const tx = chunk.vx - into * out.nx;
|
|
5908
|
+
const ty = chunk.vy - into * out.ny;
|
|
5909
|
+
const tz = chunk.vz - into * out.nz;
|
|
5910
|
+
const back = into * RESTITUTION;
|
|
5911
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5912
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
5913
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
5914
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5915
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5916
|
+
chunk.az *= GROUND_FRICTION;
|
|
5917
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
5918
|
+
chunk.rest = true;
|
|
5919
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5920
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5921
|
+
}
|
|
5922
|
+
}
|
|
5923
|
+
function leaveTrail(core, chunk, dt) {
|
|
5924
|
+
chunk.trail -= dt;
|
|
5925
|
+
if (chunk.trail > 0) return;
|
|
5926
|
+
chunk.trail = TRAIL_STEP;
|
|
5927
|
+
const random = chunk.rng;
|
|
5928
|
+
addSpark(core, {
|
|
5929
|
+
x: chunk.x,
|
|
5930
|
+
y: chunk.y,
|
|
5931
|
+
z: chunk.z,
|
|
5932
|
+
vx: chunk.vx * 0.15,
|
|
5933
|
+
vy: chunk.vy * 0.15,
|
|
5934
|
+
vz: chunk.vz * 0.15,
|
|
5935
|
+
life: random.between(0.25, 0.45),
|
|
5936
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
5937
|
+
st: 0.05,
|
|
5938
|
+
kind: 0,
|
|
5939
|
+
g: 0,
|
|
5940
|
+
drag: 1,
|
|
5941
|
+
source: chunk.source
|
|
5942
|
+
});
|
|
5943
|
+
if (random.next() < 0.25) {
|
|
5944
|
+
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 });
|
|
5945
|
+
}
|
|
5946
|
+
}
|
|
5947
|
+
function updateChunks(core, dt) {
|
|
5948
|
+
const confiner = core.confiner;
|
|
5949
|
+
const confining = !confiner.empty;
|
|
5950
|
+
const chunks = core.chunks.items;
|
|
5951
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
5952
|
+
const chunk = chunks[index];
|
|
5953
|
+
chunk.t += dt;
|
|
5954
|
+
if (chunk.rest) continue;
|
|
5955
|
+
MOVE2.x0 = chunk.x;
|
|
5956
|
+
MOVE2.y0 = chunk.y;
|
|
5957
|
+
MOVE2.z0 = chunk.z;
|
|
5958
|
+
chunk.vy -= core.gravity * dt;
|
|
5959
|
+
chunk.x += chunk.vx * dt;
|
|
5960
|
+
chunk.y += chunk.vy * dt;
|
|
5961
|
+
chunk.z += chunk.vz * dt;
|
|
5962
|
+
chunk.rx += chunk.ax * dt;
|
|
5963
|
+
chunk.ry += chunk.ay * dt;
|
|
5964
|
+
chunk.rz += chunk.az * dt;
|
|
5965
|
+
if (confining) {
|
|
5966
|
+
MOVE2.x1 = chunk.x;
|
|
5967
|
+
MOVE2.y1 = chunk.y;
|
|
5968
|
+
MOVE2.z1 = chunk.z;
|
|
5969
|
+
MOVE2.pad = chunkPad(chunk);
|
|
5970
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
5971
|
+
}
|
|
5972
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
5973
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
5974
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
5975
|
+
}
|
|
5976
|
+
}
|
|
5977
|
+
|
|
5833
5978
|
// src/pools/rings.ts
|
|
5834
5979
|
function createRingPool(capacity) {
|
|
5835
5980
|
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 }));
|
|
@@ -5964,6 +6109,18 @@ function bornFrom(core, puff3, ox, oy, oz) {
|
|
|
5964
6109
|
puff3.z = out.z;
|
|
5965
6110
|
slideInto(out, puff3);
|
|
5966
6111
|
}
|
|
6112
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6113
|
+
const confiner = core.confiner;
|
|
6114
|
+
if (confiner.empty) return;
|
|
6115
|
+
BIRTH.x0 = ox;
|
|
6116
|
+
BIRTH.y0 = oy;
|
|
6117
|
+
BIRTH.z0 = oz;
|
|
6118
|
+
BIRTH.x1 = chunk.x;
|
|
6119
|
+
BIRTH.y1 = chunk.y;
|
|
6120
|
+
BIRTH.z1 = chunk.z;
|
|
6121
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6122
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6123
|
+
}
|
|
5967
6124
|
function composeFireballs(context) {
|
|
5968
6125
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5969
6126
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -6148,7 +6305,7 @@ function composeDebris(context) {
|
|
|
6148
6305
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6149
6306
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6150
6307
|
const hot = random.next() < chunks.hot;
|
|
6151
|
-
addChunk(core, random, {
|
|
6308
|
+
const chunk = addChunk(core, random, {
|
|
6152
6309
|
x: x + d.x * 0.2,
|
|
6153
6310
|
y: y + 0.2,
|
|
6154
6311
|
z: z + d.z * 0.2,
|
|
@@ -6162,10 +6319,11 @@ function composeDebris(context) {
|
|
|
6162
6319
|
plate,
|
|
6163
6320
|
hot
|
|
6164
6321
|
});
|
|
6322
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6165
6323
|
}
|
|
6166
6324
|
}
|
|
6167
6325
|
function composeRimDebris(context) {
|
|
6168
|
-
const { core, random, x, z } = context;
|
|
6326
|
+
const { core, random, x, y, z } = context;
|
|
6169
6327
|
const radius = context.def.mark.crater ?? 0;
|
|
6170
6328
|
if (!core.layers.shrapnel) return;
|
|
6171
6329
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6176,7 +6334,7 @@ function composeRimDebris(context) {
|
|
|
6176
6334
|
const s = random.between(0.12, 0.28);
|
|
6177
6335
|
const vy2 = random.between(4, 10);
|
|
6178
6336
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6179
|
-
addChunk(core, random, {
|
|
6337
|
+
const chunk = addChunk(core, random, {
|
|
6180
6338
|
x: x + Math.cos(angle) * 0.3,
|
|
6181
6339
|
y: 0.1,
|
|
6182
6340
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6189,6 +6347,7 @@ function composeRimDebris(context) {
|
|
|
6189
6347
|
color,
|
|
6190
6348
|
plate: true
|
|
6191
6349
|
});
|
|
6350
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6192
6351
|
}
|
|
6193
6352
|
}
|
|
6194
6353
|
function composeMushroom(context, spec) {
|
|
@@ -6320,73 +6479,6 @@ function composeExplosion(core, def, call3) {
|
|
|
6320
6479
|
return scale;
|
|
6321
6480
|
}
|
|
6322
6481
|
|
|
6323
|
-
// src/pools/chunk-motion.ts
|
|
6324
|
-
var RESTITUTION = -0.32;
|
|
6325
|
-
var GROUND_FRICTION = 0.5;
|
|
6326
|
-
var REST_SPEED = 0.6;
|
|
6327
|
-
var REST_SLIDE = 0.5;
|
|
6328
|
-
var TRAIL_SECONDS = 1.8;
|
|
6329
|
-
var TRAIL_STEP = 0.025;
|
|
6330
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6331
|
-
function bounce(core, chunk, floor2) {
|
|
6332
|
-
chunk.y = floor2;
|
|
6333
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6334
|
-
chunk.splat = true;
|
|
6335
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6336
|
-
}
|
|
6337
|
-
chunk.vy *= RESTITUTION;
|
|
6338
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6339
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6340
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6341
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6342
|
-
chunk.az *= GROUND_FRICTION;
|
|
6343
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6344
|
-
chunk.rest = true;
|
|
6345
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6346
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6347
|
-
}
|
|
6348
|
-
}
|
|
6349
|
-
function leaveTrail(core, chunk, dt) {
|
|
6350
|
-
chunk.trail -= dt;
|
|
6351
|
-
if (chunk.trail > 0) return;
|
|
6352
|
-
chunk.trail = TRAIL_STEP;
|
|
6353
|
-
const random = chunk.rng;
|
|
6354
|
-
addSpark(core, {
|
|
6355
|
-
x: chunk.x,
|
|
6356
|
-
y: chunk.y,
|
|
6357
|
-
z: chunk.z,
|
|
6358
|
-
vx: chunk.vx * 0.15,
|
|
6359
|
-
vy: chunk.vy * 0.15,
|
|
6360
|
-
vz: chunk.vz * 0.15,
|
|
6361
|
-
life: random.between(0.25, 0.45),
|
|
6362
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6363
|
-
st: 0.05,
|
|
6364
|
-
kind: 0,
|
|
6365
|
-
g: 0,
|
|
6366
|
-
drag: 1,
|
|
6367
|
-
source: chunk.source
|
|
6368
|
-
});
|
|
6369
|
-
if (random.next() < 0.25) {
|
|
6370
|
-
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 });
|
|
6371
|
-
}
|
|
6372
|
-
}
|
|
6373
|
-
function updateChunks(core, dt) {
|
|
6374
|
-
for (const chunk of core.chunks.items) {
|
|
6375
|
-
chunk.t += dt;
|
|
6376
|
-
if (chunk.rest) continue;
|
|
6377
|
-
chunk.vy -= core.gravity * dt;
|
|
6378
|
-
chunk.x += chunk.vx * dt;
|
|
6379
|
-
chunk.y += chunk.vy * dt;
|
|
6380
|
-
chunk.z += chunk.vz * dt;
|
|
6381
|
-
chunk.rx += chunk.ax * dt;
|
|
6382
|
-
chunk.ry += chunk.ay * dt;
|
|
6383
|
-
chunk.rz += chunk.az * dt;
|
|
6384
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6385
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6386
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6387
|
-
}
|
|
6388
|
-
}
|
|
6389
|
-
|
|
6390
6482
|
// src/screen.ts
|
|
6391
6483
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6392
6484
|
var INITIAL_FLASH_DECAY = 6;
|
|
@@ -6414,6 +6506,23 @@ var PAD_OF_SIZE2 = 0.35;
|
|
|
6414
6506
|
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6415
6507
|
var GROUND_RESAMPLE = 0.1;
|
|
6416
6508
|
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6509
|
+
var SPRITE_REACH = 1;
|
|
6510
|
+
var NO_CUT = -1e9;
|
|
6511
|
+
var SpriteCutView = class {
|
|
6512
|
+
constructor() {
|
|
6513
|
+
__publicField(this, "x", 0.5);
|
|
6514
|
+
__publicField(this, "y", 0.5);
|
|
6515
|
+
__publicField(this, "z", 0.5);
|
|
6516
|
+
__publicField(this, "vx", 0.5);
|
|
6517
|
+
__publicField(this, "vy", 0.5);
|
|
6518
|
+
__publicField(this, "vz", 0.5);
|
|
6519
|
+
__publicField(this, "t", 0.5);
|
|
6520
|
+
__publicField(this, "size", 0.5);
|
|
6521
|
+
__publicField(this, "reachOfSize", SPRITE_REACH);
|
|
6522
|
+
__publicField(this, "cuts", [createCut(), createCut(), createCut()]);
|
|
6523
|
+
}
|
|
6524
|
+
};
|
|
6525
|
+
var VIEW = new SpriteCutView();
|
|
6417
6526
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6418
6527
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6419
6528
|
function rgb(hex) {
|
|
@@ -6442,6 +6551,14 @@ var SpriteKindPool = class {
|
|
|
6442
6551
|
__publicField(this, "color");
|
|
6443
6552
|
__publicField(this, "alpha");
|
|
6444
6553
|
__publicField(this, "size");
|
|
6554
|
+
/**
|
|
6555
|
+
* The faces of the walls each carried sprite (smoke, steam, dust) is cut at, three of them (`PUFF_CUTS`: a corner), four numbers a sprite in each: unit normal towards the sprite and offset
|
|
6556
|
+
* (`n · point`), `(0, 0, 0, NO_CUT)` for none. The renderer drops the part of the drawn square behind a face: a puff against a wall flattens on it and
|
|
6557
|
+
* shows nothing on the wall's other side, as a puff's ball does (`Puff.cuts`).
|
|
6558
|
+
*/
|
|
6559
|
+
__publicField(this, "cutA");
|
|
6560
|
+
__publicField(this, "cutB");
|
|
6561
|
+
__publicField(this, "cutC");
|
|
6445
6562
|
__publicField(this, "next", 0);
|
|
6446
6563
|
__publicField(this, "high", 0);
|
|
6447
6564
|
__publicField(this, "velocity");
|
|
@@ -6468,6 +6585,10 @@ var SpriteKindPool = class {
|
|
|
6468
6585
|
this.color = new Float32Array(n * 3);
|
|
6469
6586
|
this.alpha = new Float32Array(n);
|
|
6470
6587
|
this.size = new Float32Array(n);
|
|
6588
|
+
this.cutA = new Float32Array(n * 4);
|
|
6589
|
+
this.cutB = new Float32Array(n * 4);
|
|
6590
|
+
this.cutC = new Float32Array(n * 4);
|
|
6591
|
+
for (let i = 0; i < n; i++) this.uncut(i);
|
|
6471
6592
|
this.velocity = new Float32Array(n * 3);
|
|
6472
6593
|
this.age = new Float32Array(n);
|
|
6473
6594
|
this.life = new Float32Array(n);
|
|
@@ -6516,6 +6637,51 @@ var SpriteKindPool = class {
|
|
|
6516
6637
|
this.ground[i * 3] = Number.NaN;
|
|
6517
6638
|
this.size[i] = this.size0[i];
|
|
6518
6639
|
this.alpha[i] = 0;
|
|
6640
|
+
this.uncut(i);
|
|
6641
|
+
}
|
|
6642
|
+
/** Sprite `i` cut at no wall. */
|
|
6643
|
+
uncut(i) {
|
|
6644
|
+
this.cutA.fill(0, i * 4, i * 4 + 3);
|
|
6645
|
+
this.cutA[i * 4 + 3] = NO_CUT;
|
|
6646
|
+
this.cutB.fill(0, i * 4, i * 4 + 3);
|
|
6647
|
+
this.cutB[i * 4 + 3] = NO_CUT;
|
|
6648
|
+
this.cutC.fill(0, i * 4, i * 4 + 3);
|
|
6649
|
+
this.cutC[i * 4 + 3] = NO_CUT;
|
|
6650
|
+
}
|
|
6651
|
+
/**
|
|
6652
|
+
* Looks for the walls carried sprite `i` reaches (as a puff's ball does: `lookForWalls`), `met` the face its step was just stopped at, and keeps them in `cuts`.
|
|
6653
|
+
* The sprite's faces go into the reused `VIEW` and come back out: no object a sprite.
|
|
6654
|
+
*/
|
|
6655
|
+
cutAtWalls(i, confiner, met) {
|
|
6656
|
+
const o = i * 4;
|
|
6657
|
+
const i3 = i * 3;
|
|
6658
|
+
VIEW.x = this.position[i3];
|
|
6659
|
+
VIEW.y = this.position[i3 + 1];
|
|
6660
|
+
VIEW.z = this.position[i3 + 2];
|
|
6661
|
+
VIEW.vx = this.velocity[i3];
|
|
6662
|
+
VIEW.vy = this.velocity[i3 + 1];
|
|
6663
|
+
VIEW.vz = this.velocity[i3 + 2];
|
|
6664
|
+
VIEW.t = this.age[i];
|
|
6665
|
+
VIEW.size = this.size[i];
|
|
6666
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6667
|
+
const cut = VIEW.cuts[k];
|
|
6668
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6669
|
+
cut.on = faces[o + 3] !== NO_CUT;
|
|
6670
|
+
cut.nx = faces[o];
|
|
6671
|
+
cut.ny = faces[o + 1];
|
|
6672
|
+
cut.nz = faces[o + 2];
|
|
6673
|
+
cut.d = faces[o + 3];
|
|
6674
|
+
}
|
|
6675
|
+
if (met) cutFrom(VIEW, met);
|
|
6676
|
+
lookForWalls(confiner, VIEW);
|
|
6677
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6678
|
+
const cut = VIEW.cuts[k];
|
|
6679
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6680
|
+
faces[o] = cut.on ? cut.nx : 0;
|
|
6681
|
+
faces[o + 1] = cut.on ? cut.ny : 0;
|
|
6682
|
+
faces[o + 2] = cut.on ? cut.nz : 0;
|
|
6683
|
+
faces[o + 3] = cut.on ? cut.d : NO_CUT;
|
|
6684
|
+
}
|
|
6519
6685
|
}
|
|
6520
6686
|
ownerIndex(name) {
|
|
6521
6687
|
let index = this.owners.indexOf(name);
|
|
@@ -6606,7 +6772,9 @@ var SpriteKindPool = class {
|
|
|
6606
6772
|
let y = this.position[i3 + 1] + vy2 * dt;
|
|
6607
6773
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6608
6774
|
const confiner = host.confiner;
|
|
6609
|
-
|
|
6775
|
+
const confining = def.carried && confiner !== void 0 && !confiner.empty;
|
|
6776
|
+
let met = false;
|
|
6777
|
+
if (confining) {
|
|
6610
6778
|
STEP.x0 = this.position[i3];
|
|
6611
6779
|
STEP.y0 = this.position[i3 + 1];
|
|
6612
6780
|
STEP.z0 = this.position[i3 + 2];
|
|
@@ -6615,6 +6783,7 @@ var SpriteKindPool = class {
|
|
|
6615
6783
|
STEP.z1 = z;
|
|
6616
6784
|
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6617
6785
|
if (confiner.confineMove(STEP, dt)) {
|
|
6786
|
+
met = true;
|
|
6618
6787
|
const out = confiner.out;
|
|
6619
6788
|
x = out.x;
|
|
6620
6789
|
y = out.y;
|
|
@@ -6663,6 +6832,8 @@ var SpriteKindPool = class {
|
|
|
6663
6832
|
this.position[i3 + 1] = y;
|
|
6664
6833
|
this.position[i3 + 2] = z;
|
|
6665
6834
|
this.size[i] = this.size0[i] * lerp4(1, def.grow, t);
|
|
6835
|
+
if (confining) this.cutAtWalls(i, confiner, met ? confiner.out : null);
|
|
6836
|
+
else if (def.carried && (this.cutA[i * 4 + 3] !== NO_CUT || this.cutB[i * 4 + 3] !== NO_CUT || this.cutC[i * 4 + 3] !== NO_CUT)) this.uncut(i);
|
|
6666
6837
|
this.color[i3] = lerp4(this.rgbStart[i3], this.rgbEnd[i3], t);
|
|
6667
6838
|
this.color[i3 + 1] = lerp4(this.rgbStart[i3 + 1], this.rgbEnd[i3 + 1], t);
|
|
6668
6839
|
this.color[i3 + 2] = lerp4(this.rgbStart[i3 + 2], this.rgbEnd[i3 + 2], t);
|
|
@@ -10229,12 +10400,14 @@ export {
|
|
|
10229
10400
|
OrderedPool,
|
|
10230
10401
|
PIECES_DRAWN_VARIABLE,
|
|
10231
10402
|
PROFILES,
|
|
10403
|
+
PUFF_CUTS,
|
|
10232
10404
|
PUFF_REACH,
|
|
10233
10405
|
RAIN_CAPACITY,
|
|
10234
10406
|
RainField,
|
|
10235
10407
|
SCRAPE_LIMIT,
|
|
10236
10408
|
SMOKE_COLORS,
|
|
10237
10409
|
SPRITE_KINDS,
|
|
10410
|
+
NO_CUT as SPRITE_NO_CUT,
|
|
10238
10411
|
SpriteKindPool,
|
|
10239
10412
|
SpriteKindSystem,
|
|
10240
10413
|
VFX_LAYERS,
|