@adatechnology/game-vfx-three 0.11.0 → 0.11.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/dist/{chunk-BLUUVMCE.js → chunk-KIZDMENO.js} +14 -1
- package/dist/chunk-KIZDMENO.js.map +1 -0
- package/dist/index.global.js +104 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-BLUUVMCE.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1488,6 +1488,57 @@ var GameVfxThree = (() => {
|
|
|
1488
1488
|
return lehmer(mixEventSeed(eventSeed));
|
|
1489
1489
|
}
|
|
1490
1490
|
var SKIN = 5e-3;
|
|
1491
|
+
var Solids = class {
|
|
1492
|
+
constructor() {
|
|
1493
|
+
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1494
|
+
__publicField(this, "list", []);
|
|
1495
|
+
__publicField(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1496
|
+
}
|
|
1497
|
+
get empty() {
|
|
1498
|
+
return this.list.length === 0;
|
|
1499
|
+
}
|
|
1500
|
+
/** Declares or (with `null`) ends the solids `id` answers for. */
|
|
1501
|
+
set(id, query2) {
|
|
1502
|
+
if (query2) this.queries.set(id, query2);
|
|
1503
|
+
else this.queries.delete(id);
|
|
1504
|
+
this.list = [...this.queries.values()];
|
|
1505
|
+
}
|
|
1506
|
+
clear() {
|
|
1507
|
+
this.queries.clear();
|
|
1508
|
+
this.list = [];
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
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
|
+
* the surface's normal. Answers whether the step was stopped.
|
|
1513
|
+
*/
|
|
1514
|
+
stop(move, pad, out) {
|
|
1515
|
+
const dx = move.x1 - move.x0;
|
|
1516
|
+
const dy = move.y1 - move.y0;
|
|
1517
|
+
const dz = move.z1 - move.z0;
|
|
1518
|
+
const length = Math.hypot(dx, dy, dz);
|
|
1519
|
+
if (!(length > 0)) return false;
|
|
1520
|
+
let nearest = Infinity;
|
|
1521
|
+
for (const query2 of this.list) {
|
|
1522
|
+
if (!query2(move, this.hit)) continue;
|
|
1523
|
+
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1524
|
+
if (reached >= nearest) continue;
|
|
1525
|
+
nearest = reached;
|
|
1526
|
+
out.x = this.hit.x;
|
|
1527
|
+
out.y = this.hit.y;
|
|
1528
|
+
out.z = this.hit.z;
|
|
1529
|
+
out.nx = this.hit.nx;
|
|
1530
|
+
out.ny = this.hit.ny;
|
|
1531
|
+
out.nz = this.hit.nz;
|
|
1532
|
+
}
|
|
1533
|
+
if (nearest === Infinity) return false;
|
|
1534
|
+
const back = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
|
|
1535
|
+
out.x -= dx / length * back;
|
|
1536
|
+
out.y -= dy / length * back;
|
|
1537
|
+
out.z -= dz / length * back;
|
|
1538
|
+
return true;
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
var SKIN2 = 5e-3;
|
|
1491
1542
|
var MAX_PAD = 0.45;
|
|
1492
1543
|
function rotation(q) {
|
|
1493
1544
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
@@ -1519,10 +1570,15 @@ var GameVfxThree = (() => {
|
|
|
1519
1570
|
__publicField(this, "q", new Float64Array(3));
|
|
1520
1571
|
__publicField(this, "h", new Float64Array(3));
|
|
1521
1572
|
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1573
|
+
__publicField(this, "solids", new Solids());
|
|
1522
1574
|
this.random = lehmer(seed);
|
|
1523
1575
|
}
|
|
1524
1576
|
get empty() {
|
|
1525
|
-
return this.list.length === 0;
|
|
1577
|
+
return this.list.length === 0 && this.solids.empty;
|
|
1578
|
+
}
|
|
1579
|
+
/** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
|
|
1580
|
+
solid(id, query2) {
|
|
1581
|
+
this.solids.set(id, query2);
|
|
1526
1582
|
}
|
|
1527
1583
|
get size() {
|
|
1528
1584
|
return this.list.length;
|
|
@@ -1605,6 +1661,10 @@ var GameVfxThree = (() => {
|
|
|
1605
1661
|
return this.confineMove(move, dt);
|
|
1606
1662
|
}
|
|
1607
1663
|
confineMove(move, dt) {
|
|
1664
|
+
if (this.confineSpaces(move, dt)) return true;
|
|
1665
|
+
return !this.solids.empty && this.solids.stop(move, Math.min(Math.max(0, move.pad), MAX_PAD), this.out);
|
|
1666
|
+
}
|
|
1667
|
+
confineSpaces(move, dt) {
|
|
1608
1668
|
const list = this.list;
|
|
1609
1669
|
if (list.length === 0) return false;
|
|
1610
1670
|
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
@@ -1645,7 +1705,7 @@ var GameVfxThree = (() => {
|
|
|
1645
1705
|
}
|
|
1646
1706
|
}
|
|
1647
1707
|
sign = l1[axis2] < 0 ? -1 : 1;
|
|
1648
|
-
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] -
|
|
1708
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
|
|
1649
1709
|
sign = -sign;
|
|
1650
1710
|
} else {
|
|
1651
1711
|
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
@@ -1662,7 +1722,7 @@ var GameVfxThree = (() => {
|
|
|
1662
1722
|
}
|
|
1663
1723
|
}
|
|
1664
1724
|
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1665
|
-
l1[axis2] = sign * (h[axis2] + bound +
|
|
1725
|
+
l1[axis2] = sign * (h[axis2] + bound + SKIN2);
|
|
1666
1726
|
}
|
|
1667
1727
|
const r = s.r;
|
|
1668
1728
|
const out = this.out;
|
|
@@ -5649,6 +5709,24 @@ var GameVfxThree = (() => {
|
|
|
5649
5709
|
screen2.flashDecay = 0.5;
|
|
5650
5710
|
}
|
|
5651
5711
|
}
|
|
5712
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
5713
|
+
function bornFrom(core, puff3, ox, oy, oz) {
|
|
5714
|
+
const confiner = core.confiner;
|
|
5715
|
+
if (confiner.empty) return;
|
|
5716
|
+
BIRTH.x0 = ox;
|
|
5717
|
+
BIRTH.y0 = oy;
|
|
5718
|
+
BIRTH.z0 = oz;
|
|
5719
|
+
BIRTH.x1 = puff3.x;
|
|
5720
|
+
BIRTH.y1 = puff3.y;
|
|
5721
|
+
BIRTH.z1 = puff3.z;
|
|
5722
|
+
BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
|
|
5723
|
+
if (!confiner.confineMove(BIRTH, 0)) return;
|
|
5724
|
+
const out = confiner.out;
|
|
5725
|
+
puff3.x = out.x;
|
|
5726
|
+
puff3.y = out.y;
|
|
5727
|
+
puff3.z = out.z;
|
|
5728
|
+
slideInto(out, puff3);
|
|
5729
|
+
}
|
|
5652
5730
|
function composeFireballs(context) {
|
|
5653
5731
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5654
5732
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5665,7 +5743,7 @@ var GameVfxThree = (() => {
|
|
|
5665
5743
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life);
|
|
5666
5744
|
const h0 = random.between(1.05, 1.35) * heat;
|
|
5667
5745
|
const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
|
|
5668
|
-
addPuff(core, random, {
|
|
5746
|
+
const fireball = addPuff(core, random, {
|
|
5669
5747
|
x: x + d.x * size * 0.15,
|
|
5670
5748
|
y: y + size * 0.25 + d.y * size * 0.1,
|
|
5671
5749
|
z: z + d.z * size * 0.15,
|
|
@@ -5684,6 +5762,7 @@ var GameVfxThree = (() => {
|
|
|
5684
5762
|
color: context.smokeColor,
|
|
5685
5763
|
kind: 0
|
|
5686
5764
|
});
|
|
5765
|
+
bornFrom(core, fireball, x, y, z);
|
|
5687
5766
|
}
|
|
5688
5767
|
}
|
|
5689
5768
|
function composeSmoke(context) {
|
|
@@ -5697,7 +5776,7 @@ var GameVfxThree = (() => {
|
|
|
5697
5776
|
const s1 = size * random.between(0.55, 0.85);
|
|
5698
5777
|
const sg = size * random.between(0.18, 0.3);
|
|
5699
5778
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
|
|
5700
|
-
addPuff(core, random, {
|
|
5779
|
+
const smoke = addPuff(core, random, {
|
|
5701
5780
|
x: x + d.x * size * 0.6,
|
|
5702
5781
|
y: y + size * 0.4 + d.y * size * 0.5,
|
|
5703
5782
|
z: z + d.z * size * 0.6,
|
|
@@ -5716,6 +5795,7 @@ var GameVfxThree = (() => {
|
|
|
5716
5795
|
color: context.smokeColor,
|
|
5717
5796
|
kind: def.smoke.kind ?? 0
|
|
5718
5797
|
});
|
|
5798
|
+
bornFrom(core, smoke, x, y, z);
|
|
5719
5799
|
}
|
|
5720
5800
|
}
|
|
5721
5801
|
function composeShock(context) {
|
|
@@ -5740,7 +5820,7 @@ var GameVfxThree = (() => {
|
|
|
5740
5820
|
const s1 = size * random.between(0.5, 0.8);
|
|
5741
5821
|
const sg = size * random.between(0.2, 0.35);
|
|
5742
5822
|
const life = random.between(2.2, 4);
|
|
5743
|
-
addPuff(core, random, {
|
|
5823
|
+
const dust = addPuff(core, random, {
|
|
5744
5824
|
x: x + Math.cos(angle) * 0.3,
|
|
5745
5825
|
y: 0.15,
|
|
5746
5826
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -5757,6 +5837,7 @@ var GameVfxThree = (() => {
|
|
|
5757
5837
|
color,
|
|
5758
5838
|
kind: 1
|
|
5759
5839
|
});
|
|
5840
|
+
bornFrom(core, dust, x, 0.15, z);
|
|
5760
5841
|
}
|
|
5761
5842
|
}
|
|
5762
5843
|
function coneAngle(context) {
|
|
@@ -7828,6 +7909,7 @@ var GameVfxThree = (() => {
|
|
|
7828
7909
|
});
|
|
7829
7910
|
const core = {
|
|
7830
7911
|
profile,
|
|
7912
|
+
confiner: enclosures,
|
|
7831
7913
|
puffs: createPuffPool(profile.puffs),
|
|
7832
7914
|
sparks: createSparkPool(profile.sparks),
|
|
7833
7915
|
glows: createGlowPool(profile.glows),
|
|
@@ -7968,6 +8050,9 @@ var GameVfxThree = (() => {
|
|
|
7968
8050
|
enclose(id, enclosure) {
|
|
7969
8051
|
enclosures.set(id, enclosure);
|
|
7970
8052
|
},
|
|
8053
|
+
solid(id, query2) {
|
|
8054
|
+
enclosures.solid(id, query2);
|
|
8055
|
+
},
|
|
7971
8056
|
enclosures: () => enclosures,
|
|
7972
8057
|
stop(handle) {
|
|
7973
8058
|
player?.stop(handle);
|
|
@@ -9752,6 +9837,7 @@ void main(){
|
|
|
9752
9837
|
}
|
|
9753
9838
|
|
|
9754
9839
|
// src/screen-overlay.ts
|
|
9840
|
+
var SHOWN_FIELDS = 6;
|
|
9755
9841
|
var clamp5 = (value, min2, max2) => value < min2 ? min2 : value > max2 ? max2 : value;
|
|
9756
9842
|
function layer(container, name, blend) {
|
|
9757
9843
|
const element = container.ownerDocument.createElement("div");
|
|
@@ -9769,8 +9855,20 @@ void main(){
|
|
|
9769
9855
|
const sides = layer(container, "sides");
|
|
9770
9856
|
const gas = layer(container, "gas");
|
|
9771
9857
|
const elements = [flash2, white, red, sides, gas];
|
|
9858
|
+
const shown = new Float64Array(SHOWN_FIELDS).fill(Number.NaN);
|
|
9859
|
+
const isShown = (state) => {
|
|
9860
|
+
const same = shown[0] === state.flash && shown[1] === state.white && shown[2] === state.red && shown[3] === state.directionLeft && shown[4] === state.directionRight && shown[5] === state.gas;
|
|
9861
|
+
shown[0] = state.flash;
|
|
9862
|
+
shown[1] = state.white;
|
|
9863
|
+
shown[2] = state.red;
|
|
9864
|
+
shown[3] = state.directionLeft;
|
|
9865
|
+
shown[4] = state.directionRight;
|
|
9866
|
+
shown[5] = state.gas;
|
|
9867
|
+
return same;
|
|
9868
|
+
};
|
|
9772
9869
|
return {
|
|
9773
9870
|
update(state) {
|
|
9871
|
+
if (isShown(state)) return;
|
|
9774
9872
|
flash2.style.opacity = clamp5(state.flash, 0, 1).toFixed(3);
|
|
9775
9873
|
white.style.opacity = "1";
|
|
9776
9874
|
white.style.background = `rgba(235,240,255,${clamp5(state.white, 0, 1).toFixed(2)})`;
|