@adatechnology/game-vfx-three 0.10.2 → 0.10.4
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/index.global.js
CHANGED
|
@@ -57,15 +57,37 @@ var GameVfxThree = (() => {
|
|
|
57
57
|
var DEFERRED_QUEUE_ID = {
|
|
58
58
|
DESTRUCTION_EVENTS: "destruction.events",
|
|
59
59
|
BREACH_PAINT: "floorplan.breach-paint",
|
|
60
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
60
61
|
AUDIO_VOICES: "audio.voices",
|
|
61
|
-
VEHICLE_CREASE: "vehicles.crease"
|
|
62
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
63
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
64
|
+
FLUID_FILM: "fluids.film",
|
|
65
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
66
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
67
|
+
STATIC_BATCH: "render.static-batch",
|
|
68
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
69
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
70
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
71
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
62
72
|
};
|
|
63
73
|
var DEFERRED_PRIORITY = {
|
|
64
74
|
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
65
|
-
|
|
75
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
76
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
77
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
66
78
|
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
67
|
-
[DEFERRED_QUEUE_ID.
|
|
79
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
80
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
81
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
82
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
83
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
84
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
85
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
86
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
87
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
88
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
68
89
|
};
|
|
90
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
69
91
|
var KIT_ORIGIN_KEY = "kitOrigin";
|
|
70
92
|
function markKitOrigin(object, origin) {
|
|
71
93
|
const node = object;
|
|
@@ -109,6 +131,22 @@ var GameVfxThree = (() => {
|
|
|
109
131
|
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
110
132
|
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
111
133
|
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
134
|
+
var WORKER_KIND_ID = {
|
|
135
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
136
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
137
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
138
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
139
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
140
|
+
WORLD_REGION: "world.region"
|
|
141
|
+
};
|
|
142
|
+
var WORKER_KIND_DEFAULTS = {
|
|
143
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
144
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
145
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
146
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
147
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
148
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" }
|
|
149
|
+
};
|
|
112
150
|
|
|
113
151
|
// ../game-vfx/dist/index.js
|
|
114
152
|
var __defProp2 = Object.defineProperty;
|
|
@@ -1252,7 +1290,8 @@ var GameVfxThree = (() => {
|
|
|
1252
1290
|
trail: 0,
|
|
1253
1291
|
glow: null,
|
|
1254
1292
|
rng: placeholder,
|
|
1255
|
-
outColor: [0, 0, 0]
|
|
1293
|
+
outColor: [0, 0, 0],
|
|
1294
|
+
source: void 0
|
|
1256
1295
|
}),
|
|
1257
1296
|
freezeFollowingGlow
|
|
1258
1297
|
);
|
|
@@ -1354,7 +1393,8 @@ var GameVfxThree = (() => {
|
|
|
1354
1393
|
outY: 0,
|
|
1355
1394
|
outZ: 0,
|
|
1356
1395
|
outSize: 0,
|
|
1357
|
-
outIntensity: 0
|
|
1396
|
+
outIntensity: 0,
|
|
1397
|
+
source: void 0
|
|
1358
1398
|
}));
|
|
1359
1399
|
}
|
|
1360
1400
|
function spawnGlow(pool, init) {
|
|
@@ -1374,6 +1414,7 @@ var GameVfxThree = (() => {
|
|
|
1374
1414
|
glow.fx = init.fx ?? 0;
|
|
1375
1415
|
glow.fy = init.fy ?? 0;
|
|
1376
1416
|
glow.fz = init.fz ?? 0;
|
|
1417
|
+
glow.source = init.source;
|
|
1377
1418
|
return glow;
|
|
1378
1419
|
}
|
|
1379
1420
|
function ageOrKeep(glow, dt) {
|
|
@@ -1472,6 +1513,8 @@ var GameVfxThree = (() => {
|
|
|
1472
1513
|
__publicField(this, "l0", new Float64Array(3));
|
|
1473
1514
|
__publicField(this, "l1", new Float64Array(3));
|
|
1474
1515
|
__publicField(this, "q", new Float64Array(3));
|
|
1516
|
+
__publicField(this, "h", new Float64Array(3));
|
|
1517
|
+
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1475
1518
|
this.random = lehmer(seed);
|
|
1476
1519
|
}
|
|
1477
1520
|
get empty() {
|
|
@@ -1547,9 +1590,21 @@ var GameVfxThree = (() => {
|
|
|
1547
1590
|
return this.chance(s.leak, dt);
|
|
1548
1591
|
}
|
|
1549
1592
|
confine(x0, y0, z0, x1, y1, z1, pad, dt) {
|
|
1593
|
+
const move = this.move;
|
|
1594
|
+
move.x0 = x0;
|
|
1595
|
+
move.y0 = y0;
|
|
1596
|
+
move.z0 = z0;
|
|
1597
|
+
move.x1 = x1;
|
|
1598
|
+
move.y1 = y1;
|
|
1599
|
+
move.z1 = z1;
|
|
1600
|
+
move.pad = pad;
|
|
1601
|
+
return this.confineMove(move, dt);
|
|
1602
|
+
}
|
|
1603
|
+
confineMove(move, dt) {
|
|
1550
1604
|
const list = this.list;
|
|
1551
1605
|
if (list.length === 0) return false;
|
|
1552
|
-
const
|
|
1606
|
+
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
1607
|
+
const p = Math.min(Math.max(0, move.pad), MAX_PAD);
|
|
1553
1608
|
const l0 = this.l0;
|
|
1554
1609
|
const l1 = this.l1;
|
|
1555
1610
|
const q = this.q;
|
|
@@ -1566,7 +1621,10 @@ var GameVfxThree = (() => {
|
|
|
1566
1621
|
}
|
|
1567
1622
|
this.toLocal(s, x0, y0, z0, l0);
|
|
1568
1623
|
this.toLocal(s, x1, y1, z1, l1);
|
|
1569
|
-
const h =
|
|
1624
|
+
const h = this.h;
|
|
1625
|
+
h[0] = s.hx;
|
|
1626
|
+
h[1] = s.hy;
|
|
1627
|
+
h[2] = s.hz;
|
|
1570
1628
|
const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
|
|
1571
1629
|
let axis2 = 0;
|
|
1572
1630
|
let sign = 1;
|
|
@@ -1615,6 +1673,13 @@ var GameVfxThree = (() => {
|
|
|
1615
1673
|
return false;
|
|
1616
1674
|
}
|
|
1617
1675
|
};
|
|
1676
|
+
function slideInto(out, velocity) {
|
|
1677
|
+
const into = velocity.vx * out.nx + velocity.vy * out.ny + velocity.vz * out.nz;
|
|
1678
|
+
if (into >= 0) return;
|
|
1679
|
+
velocity.vx -= into * out.nx;
|
|
1680
|
+
velocity.vy -= into * out.ny;
|
|
1681
|
+
velocity.vz -= into * out.nz;
|
|
1682
|
+
}
|
|
1618
1683
|
function slideAlong(out, vx2, vy2, vz2) {
|
|
1619
1684
|
const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
|
|
1620
1685
|
if (into >= 0) return [vx2, vy2, vz2];
|
|
@@ -1627,6 +1692,7 @@ var GameVfxThree = (() => {
|
|
|
1627
1692
|
var GROWTH_CAP_SECONDS = 3.5;
|
|
1628
1693
|
var CARRIED_KINDS = [true, true, false, true, false];
|
|
1629
1694
|
var PAD_OF_SIZE = 0.35;
|
|
1695
|
+
var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
1630
1696
|
function createPuffPool(capacity) {
|
|
1631
1697
|
const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
|
|
1632
1698
|
return new OrderedPool(capacity, () => ({
|
|
@@ -1657,7 +1723,8 @@ var GameVfxThree = (() => {
|
|
|
1657
1723
|
rng: placeholder,
|
|
1658
1724
|
age: 0,
|
|
1659
1725
|
heat: 0,
|
|
1660
|
-
size: 0
|
|
1726
|
+
size: 0,
|
|
1727
|
+
source: void 0
|
|
1661
1728
|
}));
|
|
1662
1729
|
}
|
|
1663
1730
|
function spawnPuff(pool, random, init) {
|
|
@@ -1690,6 +1757,7 @@ var GameVfxThree = (() => {
|
|
|
1690
1757
|
puff3.age = 0;
|
|
1691
1758
|
puff3.heat = 0;
|
|
1692
1759
|
puff3.size = 0;
|
|
1760
|
+
puff3.source = init.source;
|
|
1693
1761
|
return puff3;
|
|
1694
1762
|
}
|
|
1695
1763
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -1721,23 +1789,30 @@ var GameVfxThree = (() => {
|
|
|
1721
1789
|
if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
|
|
1722
1790
|
}
|
|
1723
1791
|
}
|
|
1792
|
+
function confine(confiner, puff3, dt) {
|
|
1793
|
+
MOVE.x1 = puff3.x;
|
|
1794
|
+
MOVE.y1 = puff3.y;
|
|
1795
|
+
MOVE.z1 = puff3.z;
|
|
1796
|
+
MOVE.pad = puff3.size * PAD_OF_SIZE;
|
|
1797
|
+
return confiner.confineMove(MOVE, dt);
|
|
1798
|
+
}
|
|
1724
1799
|
function updatePuffs(pool, dt, wind, confiner) {
|
|
1725
1800
|
pool.compact(ageOrKeep2, dt);
|
|
1726
1801
|
const confining = confiner !== void 0 && !confiner.empty;
|
|
1727
1802
|
for (const puff3 of pool.items) {
|
|
1728
1803
|
const age = puff3.t / puff3.life;
|
|
1729
1804
|
const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1805
|
+
MOVE.x0 = puff3.x;
|
|
1806
|
+
MOVE.y0 = puff3.y;
|
|
1807
|
+
MOVE.z0 = puff3.z;
|
|
1733
1808
|
if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
|
|
1734
1809
|
else moveFree(puff3, dt, age, heat, wind);
|
|
1735
|
-
if (confining && CARRIED_KINDS[puff3.kind] &&
|
|
1810
|
+
if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
|
|
1736
1811
|
const out = confiner.out;
|
|
1737
1812
|
puff3.x = out.x;
|
|
1738
1813
|
puff3.y = out.y;
|
|
1739
1814
|
puff3.z = out.z;
|
|
1740
|
-
|
|
1815
|
+
slideInto(out, puff3);
|
|
1741
1816
|
}
|
|
1742
1817
|
const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
|
|
1743
1818
|
puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
|
|
@@ -1748,7 +1823,7 @@ var GameVfxThree = (() => {
|
|
|
1748
1823
|
var GROUND_LIFT = 0.02;
|
|
1749
1824
|
var BOUNCE_SLIDE = 0.55;
|
|
1750
1825
|
function createSparkPool(capacity) {
|
|
1751
|
-
return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0 }));
|
|
1826
|
+
return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0, source: void 0 }));
|
|
1752
1827
|
}
|
|
1753
1828
|
function spawnSpark(pool, init) {
|
|
1754
1829
|
const spark = pool.acquire();
|
|
@@ -1767,6 +1842,7 @@ var GameVfxThree = (() => {
|
|
|
1767
1842
|
spark.g = init.g ?? 9.8;
|
|
1768
1843
|
spark.bounce = init.bounce ?? 0.35;
|
|
1769
1844
|
spark.age = 0;
|
|
1845
|
+
spark.source = init.source;
|
|
1770
1846
|
return spark;
|
|
1771
1847
|
}
|
|
1772
1848
|
function ageOrKeep3(spark, dt) {
|
|
@@ -1800,22 +1876,26 @@ var GameVfxThree = (() => {
|
|
|
1800
1876
|
function addPuff(core, random, init) {
|
|
1801
1877
|
core.spawned.puffs++;
|
|
1802
1878
|
const puff3 = spawnPuff(core.puffs, random, init);
|
|
1879
|
+
puff3.source = init.source ?? core.source;
|
|
1803
1880
|
core.trace?.puff?.(puff3);
|
|
1804
1881
|
return puff3;
|
|
1805
1882
|
}
|
|
1806
1883
|
function addSpark(core, init) {
|
|
1807
1884
|
core.spawned.sparks++;
|
|
1808
1885
|
const spark = spawnSpark(core.sparks, init);
|
|
1886
|
+
spark.source = init.source ?? core.source;
|
|
1809
1887
|
core.trace?.spark?.(spark);
|
|
1810
1888
|
return spark;
|
|
1811
1889
|
}
|
|
1812
1890
|
function addGlow(core, init) {
|
|
1813
1891
|
const glow = spawnGlow(core.glows, init);
|
|
1892
|
+
glow.source = init.source ?? core.source;
|
|
1814
1893
|
core.trace?.glow?.(glow);
|
|
1815
1894
|
return glow;
|
|
1816
1895
|
}
|
|
1817
1896
|
function addChunk(core, random, init) {
|
|
1818
1897
|
const chunk = spawnChunk(core.chunks, random, init);
|
|
1898
|
+
chunk.source = core.source;
|
|
1819
1899
|
core.spawned.chunks++;
|
|
1820
1900
|
if (chunk.hot && core.layers.shrapnel) {
|
|
1821
1901
|
chunk.glow = addGlow(core, { follow: chunk, s: 0.35 + chunk.sx, i: 2.2, life: random.between(1, 2.2), color: HOT_GLOW_COLOR, curve: 1.5 });
|
|
@@ -1844,7 +1924,8 @@ var GameVfxThree = (() => {
|
|
|
1844
1924
|
fz: 0,
|
|
1845
1925
|
color: SMOKE_COLORS.black,
|
|
1846
1926
|
rng: placeholder,
|
|
1847
|
-
handle: 0
|
|
1927
|
+
handle: 0,
|
|
1928
|
+
source: void 0
|
|
1848
1929
|
}));
|
|
1849
1930
|
}
|
|
1850
1931
|
function spawnFire(pool, random, init, handle) {
|
|
@@ -1869,6 +1950,7 @@ var GameVfxThree = (() => {
|
|
|
1869
1950
|
fire.color = init.color ?? SMOKE_COLORS.black;
|
|
1870
1951
|
fire.rng = random;
|
|
1871
1952
|
fire.handle = handle;
|
|
1953
|
+
fire.source = init.source;
|
|
1872
1954
|
return fire;
|
|
1873
1955
|
}
|
|
1874
1956
|
function addFire(core, random, init, handle) {
|
|
@@ -1903,7 +1985,8 @@ var GameVfxThree = (() => {
|
|
|
1903
1985
|
buoy: 3.2,
|
|
1904
1986
|
color: fire.color,
|
|
1905
1987
|
kind: 0,
|
|
1906
|
-
wind: 0.4
|
|
1988
|
+
wind: 0.4,
|
|
1989
|
+
source: fire.source
|
|
1907
1990
|
});
|
|
1908
1991
|
}
|
|
1909
1992
|
}
|
|
@@ -1926,7 +2009,8 @@ var GameVfxThree = (() => {
|
|
|
1926
2009
|
drag: 0.6,
|
|
1927
2010
|
buoy: 0.55,
|
|
1928
2011
|
color: fire.color,
|
|
1929
|
-
kind: 0
|
|
2012
|
+
kind: 0,
|
|
2013
|
+
source: fire.source
|
|
1930
2014
|
});
|
|
1931
2015
|
}
|
|
1932
2016
|
}
|
|
@@ -1945,7 +2029,8 @@ var GameVfxThree = (() => {
|
|
|
1945
2029
|
st: 0.02,
|
|
1946
2030
|
kind: 4,
|
|
1947
2031
|
g: -0.6,
|
|
1948
|
-
drag: 1.2
|
|
2032
|
+
drag: 1.2,
|
|
2033
|
+
source: fire.source
|
|
1949
2034
|
});
|
|
1950
2035
|
}
|
|
1951
2036
|
function updateFires(core, dt) {
|
|
@@ -3627,6 +3712,8 @@ var GameVfxThree = (() => {
|
|
|
3627
3712
|
var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
|
|
3628
3713
|
var DEBRIS_COLOR_VARIABLE = "debrisColor";
|
|
3629
3714
|
var DUST_COLOR_VARIABLE = "dustColor";
|
|
3715
|
+
var PIECES_DRAWN_VARIABLE = "piecesDrawn";
|
|
3716
|
+
var standIns = (...steps) => when(not(variable(PIECES_DRAWN_VARIABLE)), steps);
|
|
3630
3717
|
var FAMILIES = {
|
|
3631
3718
|
wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
|
|
3632
3719
|
masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
|
|
@@ -3673,7 +3760,7 @@ var GameVfxThree = (() => {
|
|
|
3673
3760
|
...sparks(look, 14),
|
|
3674
3761
|
...glints(look, 20),
|
|
3675
3762
|
burst("normal", Math.round(30 * look.cloud), { p: ORIGIN, box: [1.4, 0.8, 0.2], sp: [0.3, 1.2], drag: 1.5, life: [1.5, 2.6], size: [0.4, 0.7], grow: 3, c0: dustTone(look), c1: 4867648, a: 0.45 }),
|
|
3676
|
-
repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 })),
|
|
3763
|
+
standIns(repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 }))),
|
|
3677
3764
|
repeat(
|
|
3678
3765
|
scaled(Math.round(60 * look.cloud)),
|
|
3679
3766
|
spawn("normal", local("angle", rnd(0, 6.283), {
|
|
@@ -3705,8 +3792,10 @@ var GameVfxThree = (() => {
|
|
|
3705
3792
|
timeline: [
|
|
3706
3793
|
screen({ add: { shake: 0.45 } }),
|
|
3707
3794
|
...sparks(look, 20),
|
|
3708
|
-
|
|
3709
|
-
|
|
3795
|
+
standIns(
|
|
3796
|
+
repeat(6, debris({ p: ORIGIN, box: [2, 0.05, 0.6], v: [rnd(-0.5, 0.5), rnd(-0.5, 0), rnd(0, 0.8)], sp: 0, size: [rnd(0.5, 1.1), look.piece[1] > 0.01 ? 0.25 : 0.03, rnd(0.4, 0.8)], c: debrisTone(look), spin: 3, life: 30, bounce: 0.1 })),
|
|
3797
|
+
repeat(scaled(20), debris({ p: ORIGIN, box: [2.1, 0.1, 0.7], v: [rnd(-1, 1), rnd(-1, 1), rnd(0, 1.5)], sp: 0, size: grow(look.piece, 3.4), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 30 }))
|
|
3798
|
+
),
|
|
3710
3799
|
repeat(
|
|
3711
3800
|
scaled(Math.round(70 * look.cloud)),
|
|
3712
3801
|
spawn("normal", local("angle", rnd(-0.4, 3.5), {
|
|
@@ -5875,10 +5964,11 @@ var GameVfxThree = (() => {
|
|
|
5875
5964
|
st: 0.05,
|
|
5876
5965
|
kind: 0,
|
|
5877
5966
|
g: 0,
|
|
5878
|
-
drag: 1
|
|
5967
|
+
drag: 1,
|
|
5968
|
+
source: chunk.source
|
|
5879
5969
|
});
|
|
5880
5970
|
if (random.next() < 0.25) {
|
|
5881
|
-
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 });
|
|
5971
|
+
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 });
|
|
5882
5972
|
}
|
|
5883
5973
|
}
|
|
5884
5974
|
function updateChunks(core, dt) {
|
|
@@ -5934,10 +6024,11 @@ var GameVfxThree = (() => {
|
|
|
5934
6024
|
};
|
|
5935
6025
|
}
|
|
5936
6026
|
var SpriteKindPool = class {
|
|
5937
|
-
constructor(capacity, defs, owners) {
|
|
6027
|
+
constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
|
|
5938
6028
|
__publicField(this, "capacity", capacity);
|
|
5939
6029
|
__publicField(this, "defs", defs);
|
|
5940
6030
|
__publicField(this, "owners", owners);
|
|
6031
|
+
__publicField(this, "sources", sources);
|
|
5941
6032
|
__publicField(this, "live", 0);
|
|
5942
6033
|
__publicField(this, "drawCount", 0);
|
|
5943
6034
|
__publicField(this, "position");
|
|
@@ -5956,6 +6047,7 @@ var GameVfxThree = (() => {
|
|
|
5956
6047
|
__publicField(this, "alphaMul");
|
|
5957
6048
|
__publicField(this, "tag");
|
|
5958
6049
|
__publicField(this, "owner");
|
|
6050
|
+
__publicField(this, "source");
|
|
5959
6051
|
__publicField(this, "colorHex");
|
|
5960
6052
|
__publicField(this, "rgbStart");
|
|
5961
6053
|
__publicField(this, "rgbEnd");
|
|
@@ -5977,6 +6069,7 @@ var GameVfxThree = (() => {
|
|
|
5977
6069
|
this.alphaMul = new Float32Array(n);
|
|
5978
6070
|
this.tag = new Int32Array(n);
|
|
5979
6071
|
this.owner = new Int32Array(n);
|
|
6072
|
+
this.source = new Int32Array(n);
|
|
5980
6073
|
this.colorHex = new Int32Array(n);
|
|
5981
6074
|
this.rgbStart = new Float32Array(n * 3);
|
|
5982
6075
|
this.rgbEnd = new Float32Array(n * 3);
|
|
@@ -6003,6 +6096,7 @@ var GameVfxThree = (() => {
|
|
|
6003
6096
|
this.alphaMul[i] = options?.alpha ?? 1;
|
|
6004
6097
|
this.tag[i] = options?.tag ?? 0;
|
|
6005
6098
|
this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
|
|
6099
|
+
this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
|
|
6006
6100
|
this.colorHex[i] = options?.color ?? -1;
|
|
6007
6101
|
this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
|
|
6008
6102
|
this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
|
|
@@ -6017,6 +6111,26 @@ var GameVfxThree = (() => {
|
|
|
6017
6111
|
if (index < 0) index = this.owners.push(name) - 1;
|
|
6018
6112
|
return index;
|
|
6019
6113
|
}
|
|
6114
|
+
sourceIndex(name) {
|
|
6115
|
+
let index = this.sources.ids.get(name);
|
|
6116
|
+
if (index === void 0) {
|
|
6117
|
+
index = this.sources.next++;
|
|
6118
|
+
this.sources.ids.set(name, index);
|
|
6119
|
+
}
|
|
6120
|
+
return index;
|
|
6121
|
+
}
|
|
6122
|
+
/** Kills the live sprites made for `source`; returns how many went. */
|
|
6123
|
+
clearSource(source) {
|
|
6124
|
+
const index = this.sources.ids.get(source);
|
|
6125
|
+
if (index === void 0) return 0;
|
|
6126
|
+
let killed = 0;
|
|
6127
|
+
for (let i = 0; i < this.high; i++) {
|
|
6128
|
+
if (!this.alive[i] || this.source[i] !== index) continue;
|
|
6129
|
+
this.kill(i);
|
|
6130
|
+
killed++;
|
|
6131
|
+
}
|
|
6132
|
+
return killed;
|
|
6133
|
+
}
|
|
6020
6134
|
kill(i) {
|
|
6021
6135
|
if (!this.alive[i]) return;
|
|
6022
6136
|
this.alive[i] = 0;
|
|
@@ -6462,14 +6576,15 @@ var GameVfxThree = (() => {
|
|
|
6462
6576
|
__publicField(this, "defs");
|
|
6463
6577
|
__publicField(this, "index", /* @__PURE__ */ new Map());
|
|
6464
6578
|
__publicField(this, "owners", []);
|
|
6579
|
+
__publicField(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
|
|
6465
6580
|
__publicField(this, "listeners", /* @__PURE__ */ new Map());
|
|
6466
6581
|
const kinds = options.kinds ?? SPRITE_KINDS;
|
|
6467
6582
|
this.ids = Object.keys(kinds);
|
|
6468
6583
|
this.defs = this.ids.map((id) => kinds[id]);
|
|
6469
6584
|
this.ids.forEach((id, at3) => this.index.set(id, at3));
|
|
6470
6585
|
const additiveCapacity = Math.floor(options.capacity * 0.4);
|
|
6471
|
-
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
|
|
6472
|
-
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
|
|
6586
|
+
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
|
|
6587
|
+
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
|
|
6473
6588
|
this.random = spriteRandom(options.seed);
|
|
6474
6589
|
}
|
|
6475
6590
|
get capacity() {
|
|
@@ -6543,9 +6658,16 @@ var GameVfxThree = (() => {
|
|
|
6543
6658
|
if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
|
|
6544
6659
|
if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
|
|
6545
6660
|
}
|
|
6661
|
+
/** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
|
|
6662
|
+
clearSource(source) {
|
|
6663
|
+
const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
|
|
6664
|
+
this.sources.ids.delete(source);
|
|
6665
|
+
return killed;
|
|
6666
|
+
}
|
|
6546
6667
|
clear() {
|
|
6547
6668
|
this.additive.clear();
|
|
6548
6669
|
this.normal.clear();
|
|
6670
|
+
this.sources.ids.clear();
|
|
6549
6671
|
}
|
|
6550
6672
|
};
|
|
6551
6673
|
var TWO_PI_ROUNDED = 6.2832;
|
|
@@ -7303,6 +7425,7 @@ var GameVfxThree = (() => {
|
|
|
7303
7425
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
7304
7426
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
7305
7427
|
var LENS_FADE = 0.16;
|
|
7428
|
+
var FLOOR_NORMAL_Y = 0.9;
|
|
7306
7429
|
function rotate2(q, v) {
|
|
7307
7430
|
const [qx, qy, qz, qw] = q;
|
|
7308
7431
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
@@ -7430,7 +7553,9 @@ var GameVfxThree = (() => {
|
|
|
7430
7553
|
if (this.placement) {
|
|
7431
7554
|
const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
|
|
7432
7555
|
const options = recipe[5];
|
|
7433
|
-
|
|
7556
|
+
const normal = options?.n ? this.turn(options.n) : void 0;
|
|
7557
|
+
const onFloor = !normal || normal[1] > FLOOR_NORMAL_Y;
|
|
7558
|
+
args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
|
|
7434
7559
|
}
|
|
7435
7560
|
this.context.trace?.("decal", args);
|
|
7436
7561
|
this.decals.add(args[0], args[1], args[2], args[3], args[4], args[5]);
|
|
@@ -7573,7 +7698,8 @@ var GameVfxThree = (() => {
|
|
|
7573
7698
|
groundAt,
|
|
7574
7699
|
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
7575
7700
|
...options.cratersAt ? { cratersAt: options.cratersAt } : {},
|
|
7576
|
-
emit: (request) => options.onRequest?.(request)
|
|
7701
|
+
emit: (request) => options.onRequest?.(request),
|
|
7702
|
+
source: void 0
|
|
7577
7703
|
};
|
|
7578
7704
|
function definitionOf(id) {
|
|
7579
7705
|
return explosions[id] ?? explosions[aliases[id] ?? ""];
|
|
@@ -7584,7 +7710,13 @@ var GameVfxThree = (() => {
|
|
|
7584
7710
|
return streamFor(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7585
7711
|
}
|
|
7586
7712
|
function detonate(def, point, call3) {
|
|
7587
|
-
|
|
7713
|
+
const outer = core.source;
|
|
7714
|
+
core.source = call3.source;
|
|
7715
|
+
try {
|
|
7716
|
+
composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
|
|
7717
|
+
} finally {
|
|
7718
|
+
core.source = outer;
|
|
7719
|
+
}
|
|
7588
7720
|
}
|
|
7589
7721
|
let engine;
|
|
7590
7722
|
let player;
|
|
@@ -7601,6 +7733,21 @@ var GameVfxThree = (() => {
|
|
|
7601
7733
|
return {
|
|
7602
7734
|
hostGroundAt: options.groundAt,
|
|
7603
7735
|
play(id, point, playOptions = {}) {
|
|
7736
|
+
if (id === "volumetric_fire") {
|
|
7737
|
+
const values = playOptions.values;
|
|
7738
|
+
const handle = ++handles.next;
|
|
7739
|
+
addFire(core, streamOf(playOptions.seed), {
|
|
7740
|
+
x: point[0],
|
|
7741
|
+
y: point[1],
|
|
7742
|
+
z: point[2],
|
|
7743
|
+
r: values?.radius ?? 0.55,
|
|
7744
|
+
life: values?.life ?? 24,
|
|
7745
|
+
...values?.rate !== void 0 ? { rate: values.rate } : {},
|
|
7746
|
+
...values?.smoke !== void 0 ? { smoke: values.smoke } : {},
|
|
7747
|
+
...values?.smokeColor !== void 0 ? { color: hexToLinearRgb(values.smokeColor) } : {}
|
|
7748
|
+
}, handle);
|
|
7749
|
+
return handle;
|
|
7750
|
+
}
|
|
7604
7751
|
if (!(id in effects)) return null;
|
|
7605
7752
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7606
7753
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
@@ -7617,7 +7764,7 @@ var GameVfxThree = (() => {
|
|
|
7617
7764
|
sprites: () => spriteSystem,
|
|
7618
7765
|
workshop,
|
|
7619
7766
|
peekWorkshop: () => engine,
|
|
7620
|
-
effectIds: () => Object.keys(effects),
|
|
7767
|
+
effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
|
|
7621
7768
|
explosion(id, point, explosionOptions = {}) {
|
|
7622
7769
|
const base = definitionOf(id);
|
|
7623
7770
|
if (!base) return null;
|
|
@@ -7625,8 +7772,9 @@ var GameVfxThree = (() => {
|
|
|
7625
7772
|
const handle = ++handles.next;
|
|
7626
7773
|
const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
|
|
7627
7774
|
const random = streamOf(explosionOptions.seed);
|
|
7628
|
-
|
|
7629
|
-
|
|
7775
|
+
const source = explosionOptions.source;
|
|
7776
|
+
if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
|
|
7777
|
+
else detonate(def, point, { direction, random, handle, source });
|
|
7630
7778
|
return handle;
|
|
7631
7779
|
},
|
|
7632
7780
|
fire(fireOptions) {
|
|
@@ -7668,6 +7816,15 @@ var GameVfxThree = (() => {
|
|
|
7668
7816
|
const fires = core.fires;
|
|
7669
7817
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
7670
7818
|
},
|
|
7819
|
+
clearSource(source) {
|
|
7820
|
+
const keep = (record, gone) => record.source !== gone;
|
|
7821
|
+
const drop = (pool) => {
|
|
7822
|
+
const before = pool.count;
|
|
7823
|
+
pool.compact(keep, source);
|
|
7824
|
+
return before - pool.count;
|
|
7825
|
+
};
|
|
7826
|
+
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
7827
|
+
},
|
|
7671
7828
|
setLayer(layer2, on) {
|
|
7672
7829
|
layers[layer2] = on;
|
|
7673
7830
|
},
|
|
@@ -9657,6 +9814,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9657
9814
|
}
|
|
9658
9815
|
};
|
|
9659
9816
|
}
|
|
9817
|
+
var REST_LAYER = 2e-3;
|
|
9818
|
+
var REST_LAYERS = 4;
|
|
9660
9819
|
function debrisLayer(THREE, pool) {
|
|
9661
9820
|
const geometry = new THREE.BoxGeometry(1, 1, 1);
|
|
9662
9821
|
const material2 = new THREE.MeshStandardMaterial({ color: 16777215, roughness: 0.45, metalness: 0.25, flatShading: true });
|
|
@@ -9687,7 +9846,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9687
9846
|
const shrink = Math.min(1, piece.life / FADE_SECONDS2);
|
|
9688
9847
|
euler.set(piece.rx, piece.ry, piece.rz);
|
|
9689
9848
|
quaternion.setFromEuler(euler);
|
|
9690
|
-
|
|
9849
|
+
const lift = piece.rest ? index % REST_LAYERS * REST_LAYER : 0;
|
|
9850
|
+
matrix.compose(position.set(piece.x, piece.y + lift, piece.z), quaternion, scale.set(piece.sx * shrink, piece.sy * shrink, piece.sz * shrink));
|
|
9691
9851
|
mesh2.setMatrixAt(index, matrix);
|
|
9692
9852
|
mesh2.setColorAt(index, colour.setHex(piece.color));
|
|
9693
9853
|
}
|
|
@@ -9809,7 +9969,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9809
9969
|
}
|
|
9810
9970
|
function ringLayer(THREE, pool) {
|
|
9811
9971
|
const geometry = new THREE.RingGeometry(0.86, 1, 40);
|
|
9812
|
-
const material2 = new THREE.MeshBasicMaterial({ color: 16777215, transparent: true, blending: THREE.AdditiveBlending, depthWrite: false, side: THREE.DoubleSide });
|
|
9972
|
+
const material2 = new THREE.MeshBasicMaterial({ color: 16777215, transparent: true, blending: THREE.AdditiveBlending, depthWrite: false, side: THREE.DoubleSide, forceSinglePass: true });
|
|
9813
9973
|
const mesh2 = new THREE.InstancedMesh(geometry, material2, RING_CAPACITY3);
|
|
9814
9974
|
mesh2.frustumCulled = false;
|
|
9815
9975
|
mesh2.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
|