@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.global.js
CHANGED
|
@@ -44,12 +44,14 @@ var GameVfx = (() => {
|
|
|
44
44
|
OrderedPool: () => OrderedPool,
|
|
45
45
|
PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
|
|
46
46
|
PROFILES: () => PROFILES,
|
|
47
|
+
PUFF_CUTS: () => PUFF_CUTS,
|
|
47
48
|
PUFF_REACH: () => PUFF_REACH,
|
|
48
49
|
RAIN_CAPACITY: () => RAIN_CAPACITY,
|
|
49
50
|
RainField: () => RainField,
|
|
50
51
|
SCRAPE_LIMIT: () => SCRAPE_LIMIT,
|
|
51
52
|
SMOKE_COLORS: () => SMOKE_COLORS,
|
|
52
53
|
SPRITE_KINDS: () => SPRITE_KINDS,
|
|
54
|
+
SPRITE_NO_CUT: () => NO_CUT,
|
|
53
55
|
SpriteKindPool: () => SpriteKindPool,
|
|
54
56
|
SpriteKindSystem: () => SpriteKindSystem,
|
|
55
57
|
VFX_LAYERS: () => VFX_LAYERS,
|
|
@@ -1773,8 +1775,9 @@ var GameVfx = (() => {
|
|
|
1773
1775
|
}
|
|
1774
1776
|
|
|
1775
1777
|
// src/pools/puff-cuts.ts
|
|
1778
|
+
var PUFF_CUTS = 3;
|
|
1776
1779
|
var PUFF_REACH = 1.28;
|
|
1777
|
-
var PROBES = [
|
|
1780
|
+
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)];
|
|
1778
1781
|
var PROBES_PER_SECOND = 60;
|
|
1779
1782
|
var FRAMES_PER_PROBE = 3;
|
|
1780
1783
|
var GROUND_FACING = 0.7;
|
|
@@ -1793,41 +1796,44 @@ var GameVfx = (() => {
|
|
|
1793
1796
|
return new KeptCut();
|
|
1794
1797
|
}
|
|
1795
1798
|
function clearCuts(puff3) {
|
|
1796
|
-
puff3.cuts[
|
|
1797
|
-
puff3.cuts[1].on = false;
|
|
1799
|
+
for (let i = 0; i < PUFF_CUTS; i++) puff3.cuts[i].on = false;
|
|
1798
1800
|
}
|
|
1799
|
-
var
|
|
1800
|
-
|
|
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();
|
|
1801
|
+
var WAY = new Float64Array(3);
|
|
1802
|
+
var PASSED = 0.02;
|
|
1807
1803
|
function probe(confiner, puff3, way) {
|
|
1808
|
-
const reach = puff3.size * PUFF_REACH;
|
|
1804
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1809
1805
|
if (!(reach > 0)) return false;
|
|
1810
1806
|
PROBE.x0 = puff3.x;
|
|
1811
1807
|
PROBE.y0 = puff3.y;
|
|
1812
1808
|
PROBE.z0 = puff3.z;
|
|
1813
|
-
PROBE.x1 = puff3.x + way
|
|
1814
|
-
PROBE.y1 = puff3.y + way
|
|
1815
|
-
PROBE.z1 = puff3.z + way
|
|
1809
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1810
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1811
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1812
|
+
PROBE.pad = 0;
|
|
1813
|
+
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1814
|
+
}
|
|
1815
|
+
function probeAgain(confiner, puff3, way) {
|
|
1816
|
+
const reach = puff3.size * (puff3.reachOfSize ?? PUFF_REACH);
|
|
1817
|
+
if (!(reach > 0)) return false;
|
|
1818
|
+
PROBE.x0 = puff3.x - way[0] * PASSED;
|
|
1819
|
+
PROBE.y0 = puff3.y - way[1] * PASSED;
|
|
1820
|
+
PROBE.z0 = puff3.z - way[2] * PASSED;
|
|
1821
|
+
PROBE.x1 = puff3.x + way[0] * reach;
|
|
1822
|
+
PROBE.y1 = puff3.y + way[1] * reach;
|
|
1823
|
+
PROBE.z1 = puff3.z + way[2] * reach;
|
|
1816
1824
|
PROBE.pad = 0;
|
|
1817
1825
|
return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
|
|
1818
1826
|
}
|
|
1819
1827
|
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;
|
|
1828
|
+
var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d - PASSED;
|
|
1821
1829
|
var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
|
|
1822
1830
|
function cutFor(puff3, face) {
|
|
1823
|
-
const
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
if (
|
|
1828
|
-
|
|
1829
|
-
const farther = isFartherFrom(puff3, first, second) ? first : second;
|
|
1830
|
-
return isFartherFrom(puff3, farther, face) ? farther : void 0;
|
|
1831
|
+
const cuts = puff3.cuts;
|
|
1832
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (sameWall(cuts[i], face)) return cuts[i];
|
|
1833
|
+
for (let i = 0; i < PUFF_CUTS; i++) if (!cuts[i].on) return cuts[i];
|
|
1834
|
+
let farthest = cuts[0];
|
|
1835
|
+
for (let i = 1; i < PUFF_CUTS; i++) if (isFartherFrom(puff3, cuts[i], farthest)) farthest = cuts[i];
|
|
1836
|
+
return isFartherFrom(puff3, farthest, face) ? farthest : void 0;
|
|
1831
1837
|
}
|
|
1832
1838
|
function cutAtFace(puff3, face) {
|
|
1833
1839
|
if (face.ny > GROUND_FACING) return;
|
|
@@ -1850,28 +1856,35 @@ var GameVfx = (() => {
|
|
|
1850
1856
|
function backward(puff3) {
|
|
1851
1857
|
const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
|
|
1852
1858
|
if (!(speed > 0)) return null;
|
|
1853
|
-
WAY
|
|
1854
|
-
WAY
|
|
1855
|
-
WAY
|
|
1859
|
+
WAY[0] = -puff3.vx / speed;
|
|
1860
|
+
WAY[1] = -puff3.vy / speed;
|
|
1861
|
+
WAY[2] = -puff3.vz / speed;
|
|
1856
1862
|
return WAY;
|
|
1857
1863
|
}
|
|
1858
1864
|
function along(cut, sign) {
|
|
1859
|
-
WAY
|
|
1860
|
-
WAY
|
|
1861
|
-
WAY
|
|
1865
|
+
WAY[0] = sign * cut.nx;
|
|
1866
|
+
WAY[1] = sign * cut.ny;
|
|
1867
|
+
WAY[2] = sign * cut.nz;
|
|
1862
1868
|
return WAY;
|
|
1863
1869
|
}
|
|
1864
1870
|
function dropPassed(confiner, puff3) {
|
|
1865
|
-
for (let i = 0; i <
|
|
1871
|
+
for (let i = 0; i < PUFF_CUTS; i++) {
|
|
1866
1872
|
const cut = puff3.cuts[i];
|
|
1867
1873
|
if (!cut.on || !isBehind(puff3, cut)) continue;
|
|
1868
1874
|
cut.on = false;
|
|
1875
|
+
const nx = cut.nx;
|
|
1876
|
+
const ny = cut.ny;
|
|
1877
|
+
const nz = cut.nz;
|
|
1869
1878
|
cutAt(confiner, puff3, along(cut, 1));
|
|
1879
|
+
WAY[0] = -nx;
|
|
1880
|
+
WAY[1] = -ny;
|
|
1881
|
+
WAY[2] = -nz;
|
|
1882
|
+
cutAt(confiner, puff3, WAY);
|
|
1870
1883
|
}
|
|
1871
1884
|
}
|
|
1872
1885
|
function keep(confiner, puff3, cut) {
|
|
1873
1886
|
if (!cut.on) return;
|
|
1874
|
-
if (!
|
|
1887
|
+
if (!probeAgain(confiner, puff3, along(cut, -1))) {
|
|
1875
1888
|
cut.on = false;
|
|
1876
1889
|
return;
|
|
1877
1890
|
}
|
|
@@ -1887,12 +1900,12 @@ var GameVfx = (() => {
|
|
|
1887
1900
|
return;
|
|
1888
1901
|
}
|
|
1889
1902
|
if (turn % FRAMES_PER_PROBE !== 0) return;
|
|
1890
|
-
const slot = turn / FRAMES_PER_PROBE % (PROBES.length +
|
|
1891
|
-
if (slot <
|
|
1892
|
-
else if (slot ===
|
|
1903
|
+
const slot = (turn / FRAMES_PER_PROBE | 0) % (PROBES.length + PUFF_CUTS + 1);
|
|
1904
|
+
if (slot < PUFF_CUTS) keep(confiner, puff3, puff3.cuts[slot]);
|
|
1905
|
+
else if (slot === PUFF_CUTS) {
|
|
1893
1906
|
const back = backward(puff3);
|
|
1894
1907
|
if (back) cutAt(confiner, puff3, back);
|
|
1895
|
-
} else cutAt(confiner, puff3, PROBES[slot -
|
|
1908
|
+
} else cutAt(confiner, puff3, PROBES[slot - PUFF_CUTS - 1]);
|
|
1896
1909
|
}
|
|
1897
1910
|
|
|
1898
1911
|
// src/pools/puffs.ts
|
|
@@ -1936,7 +1949,7 @@ var GameVfx = (() => {
|
|
|
1936
1949
|
heat: 0,
|
|
1937
1950
|
size: 0,
|
|
1938
1951
|
source: void 0,
|
|
1939
|
-
cuts: [createCut(), createCut()]
|
|
1952
|
+
cuts: [createCut(), createCut(), createCut()]
|
|
1940
1953
|
}));
|
|
1941
1954
|
}
|
|
1942
1955
|
function spawnPuff(pool, random, init) {
|
|
@@ -1988,7 +2001,9 @@ var GameVfx = (() => {
|
|
|
1988
2001
|
puff3.z = ring2.z + Math.sin(puff3.ph) * radius + wind.z * ringTime * 0.6;
|
|
1989
2002
|
puff3.y = centerY + minorRadius * Math.sin(theta);
|
|
1990
2003
|
}
|
|
1991
|
-
function moveFree(puff3, dt,
|
|
2004
|
+
function moveFree(puff3, dt, wind) {
|
|
2005
|
+
const age = puff3.age;
|
|
2006
|
+
const heat = puff3.heat;
|
|
1992
2007
|
const damping = Math.exp(-puff3.drag * dt);
|
|
1993
2008
|
puff3.vx *= damping;
|
|
1994
2009
|
puff3.vy *= damping;
|
|
@@ -2013,13 +2028,13 @@ var GameVfx = (() => {
|
|
|
2013
2028
|
pool.compact(ageOrKeep2, dt);
|
|
2014
2029
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
2015
2030
|
for (const puff3 of pool.items) {
|
|
2016
|
-
|
|
2017
|
-
|
|
2031
|
+
puff3.age = puff3.t / puff3.life;
|
|
2032
|
+
puff3.heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
2018
2033
|
MOVE.x0 = puff3.x;
|
|
2019
2034
|
MOVE.y0 = puff3.y;
|
|
2020
2035
|
MOVE.z0 = puff3.z;
|
|
2021
2036
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
2022
|
-
else moveFree(puff3, dt,
|
|
2037
|
+
else moveFree(puff3, dt, wind);
|
|
2023
2038
|
const carried = confining && CARRIED_KINDS[puff3.kind];
|
|
2024
2039
|
if (carried && confine(confiner, puff3, dt)) {
|
|
2025
2040
|
const out = confiner.out;
|
|
@@ -2031,8 +2046,6 @@ var GameVfx = (() => {
|
|
|
2031
2046
|
}
|
|
2032
2047
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
2033
2048
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
2034
|
-
puff3.age = age;
|
|
2035
|
-
puff3.heat = heat;
|
|
2036
2049
|
if (carried) lookForWalls(confiner, puff3);
|
|
2037
2050
|
else clearCuts(puff3);
|
|
2038
2051
|
}
|
|
@@ -4406,8 +4419,36 @@ var GameVfx = (() => {
|
|
|
4406
4419
|
loop: 2,
|
|
4407
4420
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4408
4421
|
};
|
|
4422
|
+
var GLASS_PIECE = 11061464;
|
|
4423
|
+
var GLASS_DUST = 12572386;
|
|
4424
|
+
var HIT = [0, 0, 0];
|
|
4425
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4426
|
+
id: "vehicle_glass_chip",
|
|
4427
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4428
|
+
team: "vehicles",
|
|
4429
|
+
budget: { particles: 16, debris: 6 },
|
|
4430
|
+
loop: 2,
|
|
4431
|
+
timeline: [
|
|
4432
|
+
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 }),
|
|
4433
|
+
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 }),
|
|
4434
|
+
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 }))
|
|
4435
|
+
]
|
|
4436
|
+
};
|
|
4437
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4438
|
+
id: "vehicle_glass_shatter",
|
|
4439
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4440
|
+
team: "vehicles",
|
|
4441
|
+
budget: { particles: 40, debris: 0 },
|
|
4442
|
+
loop: 2,
|
|
4443
|
+
timeline: [
|
|
4444
|
+
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 }),
|
|
4445
|
+
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 })
|
|
4446
|
+
]
|
|
4447
|
+
};
|
|
4409
4448
|
var VEHICLE_EFFECTS = [
|
|
4410
4449
|
BODYWORK_IMPACT,
|
|
4450
|
+
VEHICLE_GLASS_CHIP,
|
|
4451
|
+
VEHICLE_GLASS_SHATTER,
|
|
4411
4452
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4412
4453
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4413
4454
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -5928,6 +5969,112 @@ var GameVfx = (() => {
|
|
|
5928
5969
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5929
5970
|
}
|
|
5930
5971
|
|
|
5972
|
+
// src/pools/chunk-motion.ts
|
|
5973
|
+
var RESTITUTION = -0.32;
|
|
5974
|
+
var GROUND_FRICTION = 0.5;
|
|
5975
|
+
var REST_SPEED = 0.6;
|
|
5976
|
+
var REST_SLIDE = 0.5;
|
|
5977
|
+
var TRAIL_SECONDS = 1.8;
|
|
5978
|
+
var TRAIL_STEP = 0.025;
|
|
5979
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5980
|
+
var TOP_FACING = 0.7;
|
|
5981
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5982
|
+
function bounce(core, chunk, floor2) {
|
|
5983
|
+
chunk.y = floor2;
|
|
5984
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5985
|
+
chunk.splat = true;
|
|
5986
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5987
|
+
}
|
|
5988
|
+
chunk.vy *= RESTITUTION;
|
|
5989
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5990
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5991
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5992
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5993
|
+
chunk.az *= GROUND_FRICTION;
|
|
5994
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5995
|
+
chunk.rest = true;
|
|
5996
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5997
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5998
|
+
}
|
|
5999
|
+
}
|
|
6000
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
6001
|
+
function hitFace(chunk, out) {
|
|
6002
|
+
chunk.x = out.x;
|
|
6003
|
+
chunk.y = out.y;
|
|
6004
|
+
chunk.z = out.z;
|
|
6005
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
6006
|
+
if (into >= 0) return;
|
|
6007
|
+
const tx = chunk.vx - into * out.nx;
|
|
6008
|
+
const ty = chunk.vy - into * out.ny;
|
|
6009
|
+
const tz = chunk.vz - into * out.nz;
|
|
6010
|
+
const back = into * RESTITUTION;
|
|
6011
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
6012
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
6013
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
6014
|
+
chunk.ax *= GROUND_FRICTION;
|
|
6015
|
+
chunk.ay *= GROUND_FRICTION;
|
|
6016
|
+
chunk.az *= GROUND_FRICTION;
|
|
6017
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
6018
|
+
chunk.rest = true;
|
|
6019
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6020
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6021
|
+
}
|
|
6022
|
+
}
|
|
6023
|
+
function leaveTrail(core, chunk, dt) {
|
|
6024
|
+
chunk.trail -= dt;
|
|
6025
|
+
if (chunk.trail > 0) return;
|
|
6026
|
+
chunk.trail = TRAIL_STEP;
|
|
6027
|
+
const random = chunk.rng;
|
|
6028
|
+
addSpark(core, {
|
|
6029
|
+
x: chunk.x,
|
|
6030
|
+
y: chunk.y,
|
|
6031
|
+
z: chunk.z,
|
|
6032
|
+
vx: chunk.vx * 0.15,
|
|
6033
|
+
vy: chunk.vy * 0.15,
|
|
6034
|
+
vz: chunk.vz * 0.15,
|
|
6035
|
+
life: random.between(0.25, 0.45),
|
|
6036
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
6037
|
+
st: 0.05,
|
|
6038
|
+
kind: 0,
|
|
6039
|
+
g: 0,
|
|
6040
|
+
drag: 1,
|
|
6041
|
+
source: chunk.source
|
|
6042
|
+
});
|
|
6043
|
+
if (random.next() < 0.25) {
|
|
6044
|
+
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 });
|
|
6045
|
+
}
|
|
6046
|
+
}
|
|
6047
|
+
function updateChunks(core, dt) {
|
|
6048
|
+
const confiner = core.confiner;
|
|
6049
|
+
const confining = !confiner.empty;
|
|
6050
|
+
const chunks = core.chunks.items;
|
|
6051
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
6052
|
+
const chunk = chunks[index];
|
|
6053
|
+
chunk.t += dt;
|
|
6054
|
+
if (chunk.rest) continue;
|
|
6055
|
+
MOVE2.x0 = chunk.x;
|
|
6056
|
+
MOVE2.y0 = chunk.y;
|
|
6057
|
+
MOVE2.z0 = chunk.z;
|
|
6058
|
+
chunk.vy -= core.gravity * dt;
|
|
6059
|
+
chunk.x += chunk.vx * dt;
|
|
6060
|
+
chunk.y += chunk.vy * dt;
|
|
6061
|
+
chunk.z += chunk.vz * dt;
|
|
6062
|
+
chunk.rx += chunk.ax * dt;
|
|
6063
|
+
chunk.ry += chunk.ay * dt;
|
|
6064
|
+
chunk.rz += chunk.az * dt;
|
|
6065
|
+
if (confining) {
|
|
6066
|
+
MOVE2.x1 = chunk.x;
|
|
6067
|
+
MOVE2.y1 = chunk.y;
|
|
6068
|
+
MOVE2.z1 = chunk.z;
|
|
6069
|
+
MOVE2.pad = chunkPad(chunk);
|
|
6070
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
6071
|
+
}
|
|
6072
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6073
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6074
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6075
|
+
}
|
|
6076
|
+
}
|
|
6077
|
+
|
|
5931
6078
|
// src/pools/rings.ts
|
|
5932
6079
|
function createRingPool(capacity) {
|
|
5933
6080
|
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 }));
|
|
@@ -6062,6 +6209,18 @@ var GameVfx = (() => {
|
|
|
6062
6209
|
puff3.z = out.z;
|
|
6063
6210
|
slideInto(out, puff3);
|
|
6064
6211
|
}
|
|
6212
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6213
|
+
const confiner = core.confiner;
|
|
6214
|
+
if (confiner.empty) return;
|
|
6215
|
+
BIRTH.x0 = ox;
|
|
6216
|
+
BIRTH.y0 = oy;
|
|
6217
|
+
BIRTH.z0 = oz;
|
|
6218
|
+
BIRTH.x1 = chunk.x;
|
|
6219
|
+
BIRTH.y1 = chunk.y;
|
|
6220
|
+
BIRTH.z1 = chunk.z;
|
|
6221
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6222
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6223
|
+
}
|
|
6065
6224
|
function composeFireballs(context) {
|
|
6066
6225
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
6067
6226
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -6246,7 +6405,7 @@ var GameVfx = (() => {
|
|
|
6246
6405
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6247
6406
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6248
6407
|
const hot = random.next() < chunks.hot;
|
|
6249
|
-
addChunk(core, random, {
|
|
6408
|
+
const chunk = addChunk(core, random, {
|
|
6250
6409
|
x: x + d.x * 0.2,
|
|
6251
6410
|
y: y + 0.2,
|
|
6252
6411
|
z: z + d.z * 0.2,
|
|
@@ -6260,10 +6419,11 @@ var GameVfx = (() => {
|
|
|
6260
6419
|
plate,
|
|
6261
6420
|
hot
|
|
6262
6421
|
});
|
|
6422
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6263
6423
|
}
|
|
6264
6424
|
}
|
|
6265
6425
|
function composeRimDebris(context) {
|
|
6266
|
-
const { core, random, x, z } = context;
|
|
6426
|
+
const { core, random, x, y, z } = context;
|
|
6267
6427
|
const radius = context.def.mark.crater ?? 0;
|
|
6268
6428
|
if (!core.layers.shrapnel) return;
|
|
6269
6429
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6274,7 +6434,7 @@ var GameVfx = (() => {
|
|
|
6274
6434
|
const s = random.between(0.12, 0.28);
|
|
6275
6435
|
const vy2 = random.between(4, 10);
|
|
6276
6436
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6277
|
-
addChunk(core, random, {
|
|
6437
|
+
const chunk = addChunk(core, random, {
|
|
6278
6438
|
x: x + Math.cos(angle) * 0.3,
|
|
6279
6439
|
y: 0.1,
|
|
6280
6440
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6287,6 +6447,7 @@ var GameVfx = (() => {
|
|
|
6287
6447
|
color,
|
|
6288
6448
|
plate: true
|
|
6289
6449
|
});
|
|
6450
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6290
6451
|
}
|
|
6291
6452
|
}
|
|
6292
6453
|
function composeMushroom(context, spec) {
|
|
@@ -6418,73 +6579,6 @@ var GameVfx = (() => {
|
|
|
6418
6579
|
return scale;
|
|
6419
6580
|
}
|
|
6420
6581
|
|
|
6421
|
-
// src/pools/chunk-motion.ts
|
|
6422
|
-
var RESTITUTION = -0.32;
|
|
6423
|
-
var GROUND_FRICTION = 0.5;
|
|
6424
|
-
var REST_SPEED = 0.6;
|
|
6425
|
-
var REST_SLIDE = 0.5;
|
|
6426
|
-
var TRAIL_SECONDS = 1.8;
|
|
6427
|
-
var TRAIL_STEP = 0.025;
|
|
6428
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6429
|
-
function bounce(core, chunk, floor2) {
|
|
6430
|
-
chunk.y = floor2;
|
|
6431
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6432
|
-
chunk.splat = true;
|
|
6433
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6434
|
-
}
|
|
6435
|
-
chunk.vy *= RESTITUTION;
|
|
6436
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6437
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6438
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6439
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6440
|
-
chunk.az *= GROUND_FRICTION;
|
|
6441
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6442
|
-
chunk.rest = true;
|
|
6443
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6444
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6445
|
-
}
|
|
6446
|
-
}
|
|
6447
|
-
function leaveTrail(core, chunk, dt) {
|
|
6448
|
-
chunk.trail -= dt;
|
|
6449
|
-
if (chunk.trail > 0) return;
|
|
6450
|
-
chunk.trail = TRAIL_STEP;
|
|
6451
|
-
const random = chunk.rng;
|
|
6452
|
-
addSpark(core, {
|
|
6453
|
-
x: chunk.x,
|
|
6454
|
-
y: chunk.y,
|
|
6455
|
-
z: chunk.z,
|
|
6456
|
-
vx: chunk.vx * 0.15,
|
|
6457
|
-
vy: chunk.vy * 0.15,
|
|
6458
|
-
vz: chunk.vz * 0.15,
|
|
6459
|
-
life: random.between(0.25, 0.45),
|
|
6460
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6461
|
-
st: 0.05,
|
|
6462
|
-
kind: 0,
|
|
6463
|
-
g: 0,
|
|
6464
|
-
drag: 1,
|
|
6465
|
-
source: chunk.source
|
|
6466
|
-
});
|
|
6467
|
-
if (random.next() < 0.25) {
|
|
6468
|
-
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 });
|
|
6469
|
-
}
|
|
6470
|
-
}
|
|
6471
|
-
function updateChunks(core, dt) {
|
|
6472
|
-
for (const chunk of core.chunks.items) {
|
|
6473
|
-
chunk.t += dt;
|
|
6474
|
-
if (chunk.rest) continue;
|
|
6475
|
-
chunk.vy -= core.gravity * dt;
|
|
6476
|
-
chunk.x += chunk.vx * dt;
|
|
6477
|
-
chunk.y += chunk.vy * dt;
|
|
6478
|
-
chunk.z += chunk.vz * dt;
|
|
6479
|
-
chunk.rx += chunk.ax * dt;
|
|
6480
|
-
chunk.ry += chunk.ay * dt;
|
|
6481
|
-
chunk.rz += chunk.az * dt;
|
|
6482
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6483
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6484
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6485
|
-
}
|
|
6486
|
-
}
|
|
6487
|
-
|
|
6488
6582
|
// src/screen.ts
|
|
6489
6583
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6490
6584
|
var INITIAL_FLASH_DECAY = 6;
|
|
@@ -6512,6 +6606,23 @@ var GameVfx = (() => {
|
|
|
6512
6606
|
var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
6513
6607
|
var GROUND_RESAMPLE = 0.1;
|
|
6514
6608
|
var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
|
|
6609
|
+
var SPRITE_REACH = 1;
|
|
6610
|
+
var NO_CUT = -1e9;
|
|
6611
|
+
var SpriteCutView = class {
|
|
6612
|
+
constructor() {
|
|
6613
|
+
__publicField(this, "x", 0.5);
|
|
6614
|
+
__publicField(this, "y", 0.5);
|
|
6615
|
+
__publicField(this, "z", 0.5);
|
|
6616
|
+
__publicField(this, "vx", 0.5);
|
|
6617
|
+
__publicField(this, "vy", 0.5);
|
|
6618
|
+
__publicField(this, "vz", 0.5);
|
|
6619
|
+
__publicField(this, "t", 0.5);
|
|
6620
|
+
__publicField(this, "size", 0.5);
|
|
6621
|
+
__publicField(this, "reachOfSize", SPRITE_REACH);
|
|
6622
|
+
__publicField(this, "cuts", [createCut(), createCut(), createCut()]);
|
|
6623
|
+
}
|
|
6624
|
+
};
|
|
6625
|
+
var VIEW = new SpriteCutView();
|
|
6515
6626
|
var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
|
|
6516
6627
|
var lerp4 = (a, b, t) => a + (b - a) * t;
|
|
6517
6628
|
function rgb(hex) {
|
|
@@ -6540,6 +6651,14 @@ var GameVfx = (() => {
|
|
|
6540
6651
|
__publicField(this, "color");
|
|
6541
6652
|
__publicField(this, "alpha");
|
|
6542
6653
|
__publicField(this, "size");
|
|
6654
|
+
/**
|
|
6655
|
+
* 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
|
|
6656
|
+
* (`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
|
|
6657
|
+
* shows nothing on the wall's other side, as a puff's ball does (`Puff.cuts`).
|
|
6658
|
+
*/
|
|
6659
|
+
__publicField(this, "cutA");
|
|
6660
|
+
__publicField(this, "cutB");
|
|
6661
|
+
__publicField(this, "cutC");
|
|
6543
6662
|
__publicField(this, "next", 0);
|
|
6544
6663
|
__publicField(this, "high", 0);
|
|
6545
6664
|
__publicField(this, "velocity");
|
|
@@ -6566,6 +6685,10 @@ var GameVfx = (() => {
|
|
|
6566
6685
|
this.color = new Float32Array(n * 3);
|
|
6567
6686
|
this.alpha = new Float32Array(n);
|
|
6568
6687
|
this.size = new Float32Array(n);
|
|
6688
|
+
this.cutA = new Float32Array(n * 4);
|
|
6689
|
+
this.cutB = new Float32Array(n * 4);
|
|
6690
|
+
this.cutC = new Float32Array(n * 4);
|
|
6691
|
+
for (let i = 0; i < n; i++) this.uncut(i);
|
|
6569
6692
|
this.velocity = new Float32Array(n * 3);
|
|
6570
6693
|
this.age = new Float32Array(n);
|
|
6571
6694
|
this.life = new Float32Array(n);
|
|
@@ -6614,6 +6737,51 @@ var GameVfx = (() => {
|
|
|
6614
6737
|
this.ground[i * 3] = Number.NaN;
|
|
6615
6738
|
this.size[i] = this.size0[i];
|
|
6616
6739
|
this.alpha[i] = 0;
|
|
6740
|
+
this.uncut(i);
|
|
6741
|
+
}
|
|
6742
|
+
/** Sprite `i` cut at no wall. */
|
|
6743
|
+
uncut(i) {
|
|
6744
|
+
this.cutA.fill(0, i * 4, i * 4 + 3);
|
|
6745
|
+
this.cutA[i * 4 + 3] = NO_CUT;
|
|
6746
|
+
this.cutB.fill(0, i * 4, i * 4 + 3);
|
|
6747
|
+
this.cutB[i * 4 + 3] = NO_CUT;
|
|
6748
|
+
this.cutC.fill(0, i * 4, i * 4 + 3);
|
|
6749
|
+
this.cutC[i * 4 + 3] = NO_CUT;
|
|
6750
|
+
}
|
|
6751
|
+
/**
|
|
6752
|
+
* 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`.
|
|
6753
|
+
* The sprite's faces go into the reused `VIEW` and come back out: no object a sprite.
|
|
6754
|
+
*/
|
|
6755
|
+
cutAtWalls(i, confiner, met) {
|
|
6756
|
+
const o = i * 4;
|
|
6757
|
+
const i3 = i * 3;
|
|
6758
|
+
VIEW.x = this.position[i3];
|
|
6759
|
+
VIEW.y = this.position[i3 + 1];
|
|
6760
|
+
VIEW.z = this.position[i3 + 2];
|
|
6761
|
+
VIEW.vx = this.velocity[i3];
|
|
6762
|
+
VIEW.vy = this.velocity[i3 + 1];
|
|
6763
|
+
VIEW.vz = this.velocity[i3 + 2];
|
|
6764
|
+
VIEW.t = this.age[i];
|
|
6765
|
+
VIEW.size = this.size[i];
|
|
6766
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6767
|
+
const cut = VIEW.cuts[k];
|
|
6768
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6769
|
+
cut.on = faces[o + 3] !== NO_CUT;
|
|
6770
|
+
cut.nx = faces[o];
|
|
6771
|
+
cut.ny = faces[o + 1];
|
|
6772
|
+
cut.nz = faces[o + 2];
|
|
6773
|
+
cut.d = faces[o + 3];
|
|
6774
|
+
}
|
|
6775
|
+
if (met) cutFrom(VIEW, met);
|
|
6776
|
+
lookForWalls(confiner, VIEW);
|
|
6777
|
+
for (let k = 0; k < PUFF_CUTS; k++) {
|
|
6778
|
+
const cut = VIEW.cuts[k];
|
|
6779
|
+
const faces = k === 0 ? this.cutA : k === 1 ? this.cutB : this.cutC;
|
|
6780
|
+
faces[o] = cut.on ? cut.nx : 0;
|
|
6781
|
+
faces[o + 1] = cut.on ? cut.ny : 0;
|
|
6782
|
+
faces[o + 2] = cut.on ? cut.nz : 0;
|
|
6783
|
+
faces[o + 3] = cut.on ? cut.d : NO_CUT;
|
|
6784
|
+
}
|
|
6617
6785
|
}
|
|
6618
6786
|
ownerIndex(name) {
|
|
6619
6787
|
let index = this.owners.indexOf(name);
|
|
@@ -6704,7 +6872,9 @@ var GameVfx = (() => {
|
|
|
6704
6872
|
let y = this.position[i3 + 1] + vy2 * dt;
|
|
6705
6873
|
let z = this.position[i3 + 2] + vz2 * dt;
|
|
6706
6874
|
const confiner = host.confiner;
|
|
6707
|
-
|
|
6875
|
+
const confining = def.carried && confiner !== void 0 && !confiner.empty;
|
|
6876
|
+
let met = false;
|
|
6877
|
+
if (confining) {
|
|
6708
6878
|
STEP.x0 = this.position[i3];
|
|
6709
6879
|
STEP.y0 = this.position[i3 + 1];
|
|
6710
6880
|
STEP.z0 = this.position[i3 + 2];
|
|
@@ -6713,6 +6883,7 @@ var GameVfx = (() => {
|
|
|
6713
6883
|
STEP.z1 = z;
|
|
6714
6884
|
STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
|
|
6715
6885
|
if (confiner.confineMove(STEP, dt)) {
|
|
6886
|
+
met = true;
|
|
6716
6887
|
const out = confiner.out;
|
|
6717
6888
|
x = out.x;
|
|
6718
6889
|
y = out.y;
|
|
@@ -6761,6 +6932,8 @@ var GameVfx = (() => {
|
|
|
6761
6932
|
this.position[i3 + 1] = y;
|
|
6762
6933
|
this.position[i3 + 2] = z;
|
|
6763
6934
|
this.size[i] = this.size0[i] * lerp4(1, def.grow, t);
|
|
6935
|
+
if (confining) this.cutAtWalls(i, confiner, met ? confiner.out : null);
|
|
6936
|
+
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);
|
|
6764
6937
|
this.color[i3] = lerp4(this.rgbStart[i3], this.rgbEnd[i3], t);
|
|
6765
6938
|
this.color[i3 + 1] = lerp4(this.rgbStart[i3 + 1], this.rgbEnd[i3 + 1], t);
|
|
6766
6939
|
this.color[i3 + 2] = lerp4(this.rgbStart[i3 + 2], this.rgbEnd[i3 + 2], t);
|