@adatechnology/game-weapons-three 0.21.6 → 0.22.0
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-O5SQTNFW.js → chunk-5M3ANYC5.js} +74 -4
- package/dist/chunk-5M3ANYC5.js.map +1 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.global.js +434 -52
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{testing-CyfMbH0P.d.ts → testing-CocgzbYC.d.ts} +4 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +10 -10
- package/dist/chunk-O5SQTNFW.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -79,6 +79,7 @@ var GameWeaponsThree = (() => {
|
|
|
79
79
|
createWeaponProps: () => createWeaponProps,
|
|
80
80
|
createWeaponsTestModule: () => createWeaponsTestModule,
|
|
81
81
|
createWorldEffects: () => createWorldEffects,
|
|
82
|
+
createWorldExplosiveShells: () => createWorldExplosiveShells,
|
|
82
83
|
defaultWeaponProps: () => defaultWeaponProps,
|
|
83
84
|
deriveFrames: () => deriveFrames,
|
|
84
85
|
explosivesTextOf: () => explosivesTextOf,
|
|
@@ -24858,6 +24859,58 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24858
24859
|
if (ductility >= 0.3) return 1;
|
|
24859
24860
|
return (1 + 4 * (0.3 - ductility) / 0.3) * Math.min(25, Math.max(1, (0.02 / Math.max(thickness, 1e-4)) ** 2));
|
|
24860
24861
|
};
|
|
24862
|
+
var SWEEP_BROAD_SLACK = 1e-3;
|
|
24863
|
+
var sweptBounds = (origins, direction, length2) => {
|
|
24864
|
+
if (origins.length === 0 || !Number.isFinite(length2)) return null;
|
|
24865
|
+
const min2 = [Infinity, Infinity, Infinity];
|
|
24866
|
+
const max2 = [-Infinity, -Infinity, -Infinity];
|
|
24867
|
+
for (const origin of origins) {
|
|
24868
|
+
for (let k = 0; k < 3; k++) {
|
|
24869
|
+
const end3 = origin[k] + direction[k] * length2;
|
|
24870
|
+
min2[k] = Math.min(min2[k], origin[k], end3);
|
|
24871
|
+
max2[k] = Math.max(max2[k], origin[k], end3);
|
|
24872
|
+
}
|
|
24873
|
+
}
|
|
24874
|
+
for (let k = 0; k < 3; k++) {
|
|
24875
|
+
if (!Number.isFinite(min2[k]) || !Number.isFinite(max2[k])) return null;
|
|
24876
|
+
min2[k] -= SWEEP_BROAD_SLACK;
|
|
24877
|
+
max2[k] += SWEEP_BROAD_SLACK;
|
|
24878
|
+
}
|
|
24879
|
+
return { min: min2, max: max2 };
|
|
24880
|
+
};
|
|
24881
|
+
var sphereTouchesBounds = (bounds, centre, radius) => {
|
|
24882
|
+
let distanceSquared = 0;
|
|
24883
|
+
for (let k = 0; k < 3; k++) {
|
|
24884
|
+
const below = bounds.min[k] - centre[k];
|
|
24885
|
+
const above2 = centre[k] - bounds.max[k];
|
|
24886
|
+
if (below > 0) distanceSquared += below * below;
|
|
24887
|
+
else if (above2 > 0) distanceSquared += above2 * above2;
|
|
24888
|
+
}
|
|
24889
|
+
return distanceSquared <= radius * radius;
|
|
24890
|
+
};
|
|
24891
|
+
var boundsTouch = (a, b) => a.min[0] <= b.max[0] && a.max[0] >= b.min[0] && a.min[1] <= b.max[1] && a.max[1] >= b.min[1] && a.min[2] <= b.max[2] && a.max[2] >= b.min[2];
|
|
24892
|
+
var boundsInFrame = (bounds, position, rotation2) => {
|
|
24893
|
+
const inverse = quat.conjugate(rotation2);
|
|
24894
|
+
const centre = [(bounds.min[0] + bounds.max[0]) / 2 - position[0], (bounds.min[1] + bounds.max[1]) / 2 - position[1], (bounds.min[2] + bounds.max[2]) / 2 - position[2]];
|
|
24895
|
+
const size = [bounds.max[0] - bounds.min[0], bounds.max[1] - bounds.min[1], bounds.max[2] - bounds.min[2]];
|
|
24896
|
+
return aabbOf({ kind: "box", size }, rotateVec(inverse, centre), inverse);
|
|
24897
|
+
};
|
|
24898
|
+
var rayMissesBounds = (origin, direction, maxDistance, bounds) => {
|
|
24899
|
+
let near = 0;
|
|
24900
|
+
let far = maxDistance;
|
|
24901
|
+
for (let k = 0; k < 3; k++) {
|
|
24902
|
+
if (direction[k] === 0) {
|
|
24903
|
+
if (origin[k] < bounds.min[k] || origin[k] > bounds.max[k]) return true;
|
|
24904
|
+
continue;
|
|
24905
|
+
}
|
|
24906
|
+
const a = (bounds.min[k] - origin[k]) / direction[k];
|
|
24907
|
+
const b = (bounds.max[k] - origin[k]) / direction[k];
|
|
24908
|
+
near = Math.max(near, Math.min(a, b));
|
|
24909
|
+
far = Math.min(far, Math.max(a, b));
|
|
24910
|
+
if (near > far) return true;
|
|
24911
|
+
}
|
|
24912
|
+
return false;
|
|
24913
|
+
};
|
|
24861
24914
|
var THIN_SHEET_DISHING = 5e-3;
|
|
24862
24915
|
var SWEEP_BACK = 0.01;
|
|
24863
24916
|
function sweepOrigins(box5, d, spacing) {
|
|
@@ -25042,6 +25095,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25042
25095
|
const ignitionRules = resolveIgnitionRules(options.ignition);
|
|
25043
25096
|
const breachBlastFactor = options.breach?.blastFactor ?? BREACH_BLAST_FACTOR;
|
|
25044
25097
|
const chipEnergy = options.breach?.chipEnergy ?? CHIP_ENERGY;
|
|
25098
|
+
const broadPhase = options.broadPhase ?? true;
|
|
25045
25099
|
const chainLinkCap = options.chainLinksPerUpdate !== void 0 && options.chainLinksPerUpdate >= 1 ? Math.floor(options.chainLinksPerUpdate) : Infinity;
|
|
25046
25100
|
const rng2 = createRng2(options.seed ?? 1);
|
|
25047
25101
|
const rnd2 = () => rng2.next();
|
|
@@ -25147,6 +25201,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
25147
25201
|
unsup: [],
|
|
25148
25202
|
anyAnchor: false,
|
|
25149
25203
|
order: ++orderCounter,
|
|
25204
|
+
loose: carry?.loose ?? false,
|
|
25150
25205
|
base: { pos: [pos[0], pos[1], pos[2]], rot: [rot[0], rot[1], rot[2], rot[3]] }
|
|
25151
25206
|
};
|
|
25152
25207
|
for (const ps of spec.parts) {
|
|
@@ -26634,28 +26689,109 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26634
26689
|
if (disc < 0) return true;
|
|
26635
26690
|
return -b - Math.sqrt(disc) > maxDist;
|
|
26636
26691
|
};
|
|
26637
|
-
const
|
|
26692
|
+
const worldCentres = /* @__PURE__ */ new WeakMap();
|
|
26693
|
+
const worldCentreOf = (o) => {
|
|
26694
|
+
const p = o.st.position, q = o.st.rotation, c = o.bc;
|
|
26695
|
+
const known = worldCentres.get(o);
|
|
26696
|
+
if (known) {
|
|
26697
|
+
const k = known.key;
|
|
26698
|
+
if (k[0] === p[0] && k[1] === p[1] && k[2] === p[2] && k[3] === q[0] && k[4] === q[1] && k[5] === q[2] && k[6] === q[3] && k[7] === c[0] && k[8] === c[1] && k[9] === c[2]) return known.centre;
|
|
26699
|
+
}
|
|
26700
|
+
const centre = toWorld(p, q, c);
|
|
26701
|
+
worldCentres.set(o, { key: [p[0], p[1], p[2], q[0], q[1], q[2], q[3], c[0], c[1], c[2]], centre });
|
|
26702
|
+
return centre;
|
|
26703
|
+
};
|
|
26704
|
+
const implPartBox = (im, ps) => {
|
|
26705
|
+
const ov = im.poses.get(ps.id);
|
|
26706
|
+
return aabbOf(ps.shape, toWorld(im.position, im.rotation, ov?.pos ?? ps.position), quat.mul(im.rotation, ov?.q ?? quatFromEuler(...ps.rotation ?? [0, 0, 0])));
|
|
26707
|
+
};
|
|
26708
|
+
const implBounds = /* @__PURE__ */ new WeakMap();
|
|
26709
|
+
const implBoundsOf = (im) => {
|
|
26710
|
+
const spec = im.impl.describe();
|
|
26711
|
+
const p = im.position, q = im.rotation;
|
|
26712
|
+
const known = implBounds.get(im);
|
|
26713
|
+
if (known && known.spec === spec) {
|
|
26714
|
+
const k = known.key;
|
|
26715
|
+
if (k[0] === p[0] && k[1] === p[1] && k[2] === p[2] && k[3] === q[0] && k[4] === q[1] && k[5] === q[2] && k[6] === q[3] && k[7] === im.posesVersion) return known.bounds;
|
|
26716
|
+
}
|
|
26717
|
+
const min2 = [Infinity, Infinity, Infinity];
|
|
26718
|
+
const max2 = [-Infinity, -Infinity, -Infinity];
|
|
26719
|
+
for (const ps of spec.parts) {
|
|
26720
|
+
const box5 = implPartBox(im, ps);
|
|
26721
|
+
for (let k = 0; k < 3; k++) {
|
|
26722
|
+
min2[k] = Math.min(min2[k], box5.min[k] - SWEEP_BROAD_SLACK);
|
|
26723
|
+
max2[k] = Math.max(max2[k], box5.max[k] + SWEEP_BROAD_SLACK);
|
|
26724
|
+
}
|
|
26725
|
+
}
|
|
26726
|
+
const bounds = { min: min2, max: max2 };
|
|
26727
|
+
implBounds.set(im, { spec, key: [p[0], p[1], p[2], q[0], q[1], q[2], q[3], im.posesVersion], bounds });
|
|
26728
|
+
return bounds;
|
|
26729
|
+
};
|
|
26730
|
+
const sweepScope = (origins, d, length2, ignore) => {
|
|
26731
|
+
const bounds = sweptBounds(origins, d, length2);
|
|
26732
|
+
if (!bounds) return null;
|
|
26733
|
+
const scoped = [];
|
|
26734
|
+
const parts = /* @__PURE__ */ new Map();
|
|
26735
|
+
for (const o of objects.values()) {
|
|
26736
|
+
if (!sphereTouchesBounds(bounds, worldCentreOf(o), o.br + SWEEP_BROAD_SLACK)) continue;
|
|
26737
|
+
const local2 = boundsInFrame(bounds, o.st.position, o.st.rotation);
|
|
26738
|
+
const near = o.parts.filter((p) => !isLost(p) && !ignore.has(`${o.id}\0${p.spec.id}`) && sphereTouchesBounds(local2, p.pos, p.bound + PART_BOUND_SLACK + SWEEP_BROAD_SLACK));
|
|
26739
|
+
if (near.length === 0) continue;
|
|
26740
|
+
scoped.push(o);
|
|
26741
|
+
parts.set(o, near);
|
|
26742
|
+
}
|
|
26743
|
+
const scopedImpls = [];
|
|
26744
|
+
const implParts2 = /* @__PURE__ */ new Map();
|
|
26745
|
+
for (const im of impls.values()) {
|
|
26746
|
+
if (!boundsTouch(bounds, implBoundsOf(im))) continue;
|
|
26747
|
+
const near = im.impl.describe().parts.filter((ps) => !ignore.has(`${im.impl.id}\0${ps.id}`) && boundsTouch(bounds, implPartBox(im, ps)));
|
|
26748
|
+
if (near.length === 0) continue;
|
|
26749
|
+
scopedImpls.push(im);
|
|
26750
|
+
implParts2.set(im, near);
|
|
26751
|
+
}
|
|
26752
|
+
return { objects: scoped, parts, impls: scopedImpls, implParts: implParts2 };
|
|
26753
|
+
};
|
|
26754
|
+
let sweepCounts = null;
|
|
26755
|
+
let lastSweep = { objectVisits: 0, partVisits: 0, shapeTests: 0, shapeTested: [] };
|
|
26756
|
+
const raycastInternal = (origin, dir, maxDist, ignore, worldOnly = false, precise = false, skip = {}, scope2) => {
|
|
26638
26757
|
const d = vec.normalize(dir);
|
|
26758
|
+
const minRadius = skip.minObjectRadius ?? 0;
|
|
26639
26759
|
let best = null;
|
|
26640
|
-
|
|
26641
|
-
|
|
26760
|
+
const counts = sweepCounts;
|
|
26761
|
+
for (const o of scope2 ? scope2.objects : objects.values()) {
|
|
26762
|
+
if (counts) counts.objectVisits++;
|
|
26763
|
+
if (skip.skipLoose && o.loose || o.br < minRadius) continue;
|
|
26764
|
+
if (raySphereMiss(origin, d, worldCentreOf(o), o.br, best ? Math.min(maxDist, best.distance) : maxDist)) continue;
|
|
26642
26765
|
const qi = quat.conjugate(o.st.rotation);
|
|
26643
26766
|
const lo = rotateVec(qi, vec.sub(origin, o.st.position));
|
|
26644
26767
|
const ld = rotateVec(qi, d);
|
|
26645
|
-
for (const p of o.parts) {
|
|
26768
|
+
for (const p of scope2?.parts.get(o) ?? o.parts) {
|
|
26769
|
+
if (counts) counts.partVisits++;
|
|
26646
26770
|
if (isLost(p) || ignore?.has(`${o.id}\0${p.spec.id}`)) continue;
|
|
26647
26771
|
if (partSphereMiss(lo, ld, p, maxDist)) continue;
|
|
26772
|
+
if (counts) {
|
|
26773
|
+
counts.shapeTests++;
|
|
26774
|
+
counts.shapeTested.add(o.id);
|
|
26775
|
+
}
|
|
26648
26776
|
const r = rayPart(o, p, origin, d);
|
|
26649
26777
|
if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
|
|
26650
|
-
if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
|
|
26778
|
+
if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
26779
|
+
if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
26651
26780
|
if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
|
|
26652
26781
|
if (!best || r.t0 < best.distance) best = { object: o.id, part: p.spec.id, point: vec.madd(origin, d, r.t0), normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
|
|
26653
26782
|
}
|
|
26654
26783
|
}
|
|
26655
|
-
for (const im of worldOnly ? [] : impls.values()) {
|
|
26784
|
+
for (const im of worldOnly ? [] : scope2 ? scope2.impls : impls.values()) {
|
|
26785
|
+
if (counts) counts.objectVisits++;
|
|
26786
|
+
if (!scope2 && broadPhase && rayMissesBounds(origin, d, maxDist, implBoundsOf(im))) continue;
|
|
26656
26787
|
let boxHit = null;
|
|
26657
|
-
for (const ps of im.impl.describe().parts) {
|
|
26788
|
+
for (const ps of scope2?.implParts.get(im) ?? im.impl.describe().parts) {
|
|
26789
|
+
if (counts) counts.partVisits++;
|
|
26658
26790
|
if (ignore?.has(`${im.impl.id}\0${ps.id}`)) continue;
|
|
26791
|
+
if (counts) {
|
|
26792
|
+
counts.shapeTests++;
|
|
26793
|
+
counts.shapeTested.add(im.impl.id);
|
|
26794
|
+
}
|
|
26659
26795
|
const ov = im.poses.get(ps.id);
|
|
26660
26796
|
const r = rayPartRaw(im.position, im.rotation, ps, ov?.q ?? quatFromEuler(...ps.rotation ?? [0, 0, 0]), origin, d, ov?.pos);
|
|
26661
26797
|
if (!r || r.t1 < 0 || r.t0 > maxDist) continue;
|
|
@@ -26863,6 +26999,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26863
26999
|
return covered / length2;
|
|
26864
27000
|
};
|
|
26865
27001
|
const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
|
|
27002
|
+
const fixesTrim = (o, j) => isTrim(o.parts[j.ia]) !== isTrim(o.parts[j.ib]);
|
|
26866
27003
|
const wearJoints = (o, p, amount, near, radius = 0.06, src, split = false, span, blast) => {
|
|
26867
27004
|
if (amount <= 0) return;
|
|
26868
27005
|
const mine = (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open);
|
|
@@ -26871,7 +27008,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26871
27008
|
if (j.st.open) continue;
|
|
26872
27009
|
if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
|
|
26873
27010
|
if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
|
|
26874
|
-
if (blast && (
|
|
27011
|
+
if (blast && fixesTrim(o, j) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
|
|
26875
27012
|
j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
|
|
26876
27013
|
if (j.st.hp <= 0 && blast && span !== void 0 && onFoundation(o, j) && wornShare(o, j, blast.point, span) < JOINT_OPEN_SHARE) j.st.hp = Math.min(j.st.maxHp, 1);
|
|
26877
27014
|
if (j.st.hp <= 0) {
|
|
@@ -26919,6 +27056,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26919
27056
|
const lc = toLocal(p.pos, p.q, op.center);
|
|
26920
27057
|
return Math.hypot(lp[u] - lc[u], lp[v] - lc[v]) <= op.radius;
|
|
26921
27058
|
};
|
|
27059
|
+
const throughAperture = (p, objectPoint) => {
|
|
27060
|
+
const [u, v] = planeAxes(p.thin);
|
|
27061
|
+
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
27062
|
+
return (p.spec.apertures ?? []).some((ap) => {
|
|
27063
|
+
const du = lp[u] - (ap.offset?.[0] ?? 0);
|
|
27064
|
+
const dv = lp[v] - (ap.offset?.[1] ?? 0);
|
|
27065
|
+
if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
|
|
27066
|
+
if (!ap.bars || ap.bars.spacing <= 0) return true;
|
|
27067
|
+
const along = ap.bars.axis === 0 ? du + ap.size[0] / 2 : dv + ap.size[1] / 2;
|
|
27068
|
+
return Math.abs(along - Math.round(along / ap.bars.spacing) * ap.bars.spacing) > ap.bars.width / 2;
|
|
27069
|
+
});
|
|
27070
|
+
};
|
|
26922
27071
|
const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
|
|
26923
27072
|
const localHolesOf = (p) => p.st.holes.map((h) => ({ point: toLocal(p.pos, p.q, h.point), normal: rotateVec(quat.conjugate(p.q), h.normal), diameter: h.diameter }));
|
|
26924
27073
|
const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
|
|
@@ -28025,7 +28174,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28025
28174
|
const path = Math.min(r.t1, L) - t0;
|
|
28026
28175
|
if (path < shelter.minPath) continue;
|
|
28027
28176
|
const mid = vec.madd(point, d, t0 + path / 2);
|
|
28028
|
-
const opening = p.st.opening && insideOpening(o, p, mid);
|
|
28177
|
+
const opening = p.st.opening && insideOpening(o, p, objLocal(o, mid));
|
|
28029
28178
|
if (opening && was & FLAG_OPEN) continue;
|
|
28030
28179
|
if (p.st.stripped && was & FLAG_OPEN) continue;
|
|
28031
28180
|
const resistance = p.mat.hpPerKg * p.mat.density * path * (p.mat.damageScale?.shelter ?? 1);
|
|
@@ -28594,7 +28743,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28594
28743
|
register(impl, opts = {}) {
|
|
28595
28744
|
const id = opts.id ?? impl.id;
|
|
28596
28745
|
if (taken(id)) throw new Error(`object "${id}" already exists`);
|
|
28597
|
-
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map() });
|
|
28746
|
+
impls.set(id, { impl, position: opts.position ?? [0, 0, 0], rotation: opts.rotation ?? [0, 0, 0, 1], poses: /* @__PURE__ */ new Map(), posesVersion: 0 });
|
|
28598
28747
|
return id;
|
|
28599
28748
|
},
|
|
28600
28749
|
setPartPose(objectId, partId, position, rotation2) {
|
|
@@ -28603,6 +28752,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28603
28752
|
if (im) {
|
|
28604
28753
|
im.impl.setPartPose?.(partId, position, rotation2);
|
|
28605
28754
|
im.poses.set(partId, { pos: [position[0], position[1], position[2]], q });
|
|
28755
|
+
im.posesVersion++;
|
|
28606
28756
|
return;
|
|
28607
28757
|
}
|
|
28608
28758
|
const o = getObj(objectId);
|
|
@@ -28658,7 +28808,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28658
28808
|
const inNew = (pid) => moved.has(pid);
|
|
28659
28809
|
const inOld = (pid) => !moved.has(pid);
|
|
28660
28810
|
const pos = o.st.position, rot = o.st.rotation;
|
|
28661
|
-
const fresh = build(sub2(inNew), nid, pos, rot, carryFor(inNew, (a, b) => inNew(a) && inNew(b)));
|
|
28811
|
+
const fresh = build(sub2(inNew), nid, pos, rot, { ...carryFor(inNew, (a, b) => inNew(a) && inNew(b)), loose: true });
|
|
28662
28812
|
const restCarry = carryFor(inOld, (a, b) => !(inNew(a) && inNew(b)));
|
|
28663
28813
|
if (o.st.soil) restCarry.soil = o.st.soil;
|
|
28664
28814
|
if (o.soil?.sets.size) restCarry.soilSets = Object.fromEntries(o.soil.sets);
|
|
@@ -28730,8 +28880,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28730
28880
|
if (!(loss.radius > 0) || !(loss.depth > 0) || !Number.isFinite(loss.x) || !Number.isFinite(loss.z)) return;
|
|
28731
28881
|
pendingLosses.push({ ...loss });
|
|
28732
28882
|
},
|
|
28733
|
-
raycast(origin, direction, maxDistance = Infinity) {
|
|
28734
|
-
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true);
|
|
28883
|
+
raycast(origin, direction, maxDistance = Infinity, options2) {
|
|
28884
|
+
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true, options2);
|
|
28735
28885
|
return r ? { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance } : null;
|
|
28736
28886
|
},
|
|
28737
28887
|
sweepBox(box5, direction, distance4, options2 = {}) {
|
|
@@ -28745,13 +28895,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28745
28895
|
else if (hosted) for (const p of hosted.impl.describe().parts) ignore.add(`${hosted.impl.id}\0${p.id}`);
|
|
28746
28896
|
}
|
|
28747
28897
|
let best = null;
|
|
28748
|
-
|
|
28749
|
-
|
|
28750
|
-
|
|
28751
|
-
|
|
28898
|
+
const origins = sweepOrigins(box5, d, options2.spacing ?? 0.2);
|
|
28899
|
+
const length2 = distance4 + SWEEP_BACK;
|
|
28900
|
+
const scope2 = broadPhase ? sweepScope(origins, d, length2, ignore) ?? void 0 : void 0;
|
|
28901
|
+
const counts = { objectVisits: 0, partVisits: 0, shapeTests: 0, shapeTested: /* @__PURE__ */ new Set() };
|
|
28902
|
+
sweepCounts = counts;
|
|
28903
|
+
try {
|
|
28904
|
+
for (const origin of origins) {
|
|
28905
|
+
const r = raycastInternal(origin, d, length2, ignore.size > 0 ? ignore : void 0, false, false, {}, scope2);
|
|
28906
|
+
if (!r || best && r.distance >= best.distance) continue;
|
|
28907
|
+
best = { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: Math.max(0, r.distance - SWEEP_BACK) };
|
|
28908
|
+
}
|
|
28909
|
+
} finally {
|
|
28910
|
+
sweepCounts = null;
|
|
28911
|
+
lastSweep = { objectVisits: counts.objectVisits, partVisits: counts.partVisits, shapeTests: counts.shapeTests, shapeTested: [...counts.shapeTested] };
|
|
28752
28912
|
}
|
|
28753
28913
|
return best;
|
|
28754
28914
|
},
|
|
28915
|
+
sweepProbe() {
|
|
28916
|
+
return lastSweep;
|
|
28917
|
+
},
|
|
28755
28918
|
shoot(origin, direction, energy, caliber, source, round5) {
|
|
28756
28919
|
const extras = typeof round5 === "number" ? { piercing: round5 } : round5 ?? {};
|
|
28757
28920
|
return withCollapses(run(withBlow("ballistic", () => {
|
|
@@ -28984,7 +29147,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
28984
29147
|
rng: rng2.state(),
|
|
28985
29148
|
counter,
|
|
28986
29149
|
objects: [...objects.values()].map((o) => {
|
|
28987
|
-
const runtime = { parts: {}, joints: {}, collapsed: [...o.collapsed], ...o.unanchored.size ? { unanchored: [...o.unanchored] } : {}, ...o.soil?.sets.size ? { soil: Object.fromEntries(o.soil.sets) } : {}, ...o.wind ? { wind: [o.wind.dyn.x, o.wind.dyn.v, o.wind.dyn.y, o.wind.dyn.w, o.wind.dyn.peak] } : {} };
|
|
29150
|
+
const runtime = { parts: {}, joints: {}, collapsed: [...o.collapsed], ...o.loose ? { loose: true } : {}, ...o.unanchored.size ? { unanchored: [...o.unanchored] } : {}, ...o.soil?.sets.size ? { soil: Object.fromEntries(o.soil.sets) } : {}, ...o.wind ? { wind: [o.wind.dyn.x, o.wind.dyn.v, o.wind.dyn.y, o.wind.dyn.w, o.wind.dyn.peak] } : {} };
|
|
28988
29151
|
for (const p of o.parts) runtime.parts[p.spec.id] = clone(p.rt);
|
|
28989
29152
|
for (const j of o.joints) runtime.joints[j.spec.id] = j.step;
|
|
28990
29153
|
return { id: o.id, spec: clone(o.spec), state: clone(o.st), runtime };
|
|
@@ -29007,7 +29170,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
29007
29170
|
joints: new Map(state.joints.map((st) => [st.id, { st, step: e.runtime?.joints[st.id] ?? 0 }])),
|
|
29008
29171
|
collapsed: e.runtime?.collapsed,
|
|
29009
29172
|
...e.runtime?.unanchored ? { unanchored: e.runtime.unanchored } : {},
|
|
29010
|
-
...e.runtime?.wind ? { wind: e.runtime.wind } : {}
|
|
29173
|
+
...e.runtime?.wind ? { wind: e.runtime.wind } : {},
|
|
29174
|
+
...e.runtime?.loose ? { loose: true } : {}
|
|
29011
29175
|
};
|
|
29012
29176
|
let pos = state.position, rot = state.rotation;
|
|
29013
29177
|
if (state.soil) {
|
|
@@ -30336,6 +30500,42 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30336
30500
|
}
|
|
30337
30501
|
return { ...next, capacities };
|
|
30338
30502
|
}
|
|
30503
|
+
var planeAxes2 = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
|
|
30504
|
+
function toPartFrame(part, point) {
|
|
30505
|
+
const dx = point[0] - part.position[0];
|
|
30506
|
+
const dz = point[2] - part.position[2];
|
|
30507
|
+
const angle = -(part.rotation?.[1] ?? 0);
|
|
30508
|
+
return [dx * Math.cos(angle) + dz * Math.sin(angle), point[1] - part.position[1], -dx * Math.sin(angle) + dz * Math.cos(angle)];
|
|
30509
|
+
}
|
|
30510
|
+
function wallApertures(part, windows) {
|
|
30511
|
+
if (part.shape.kind !== "box") return [];
|
|
30512
|
+
const size = part.shape.size;
|
|
30513
|
+
const thin = size.indexOf(Math.min(...size));
|
|
30514
|
+
if (thin === 1) return [];
|
|
30515
|
+
const [along] = planeAxes2(thin);
|
|
30516
|
+
const turn2 = part.rotation?.[1] ?? 0;
|
|
30517
|
+
const alongU = Math.abs(Math.cos(turn2)) * size[0] + Math.abs(Math.sin(turn2)) * size[2] >= Math.abs(Math.sin(turn2)) * size[0] + Math.abs(Math.cos(turn2)) * size[2];
|
|
30518
|
+
return windows.map((opening2) => {
|
|
30519
|
+
const middle = (opening2.from + opening2.to) / 2;
|
|
30520
|
+
const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
|
|
30521
|
+
const local2 = toPartFrame(part, centre2);
|
|
30522
|
+
return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local2[along], local2[1]] };
|
|
30523
|
+
});
|
|
30524
|
+
}
|
|
30525
|
+
function withWindowApertures(spec, openings) {
|
|
30526
|
+
const byWall = /* @__PURE__ */ new Map();
|
|
30527
|
+
for (const opening2 of openings) if (opening2.kind === "window") byWall.set(opening2.wall, [...byWall.get(opening2.wall) ?? [], opening2]);
|
|
30528
|
+
if (!byWall.size) return spec;
|
|
30529
|
+
return {
|
|
30530
|
+
...spec,
|
|
30531
|
+
parts: spec.parts.map((part) => {
|
|
30532
|
+
const windows = byWall.get(part.id);
|
|
30533
|
+
if (!windows) return part;
|
|
30534
|
+
const apertures = wallApertures(part, windows);
|
|
30535
|
+
return apertures.length ? { ...part, apertures: [...part.apertures ?? [], ...apertures] } : part;
|
|
30536
|
+
})
|
|
30537
|
+
};
|
|
30538
|
+
}
|
|
30339
30539
|
var RAFT_THICKNESS = 0.25;
|
|
30340
30540
|
var PILE_AREA = 9;
|
|
30341
30541
|
var RAFT_MARGIN = 0.15;
|
|
@@ -30434,7 +30634,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
30434
30634
|
const infill = new Set(portico && slabOptions ? kept.filter((part) => part.role === "wall").map((part) => part.id) : []);
|
|
30435
30635
|
const beams = new Set(parts.filter((part) => part.role === "beam" && (part.beamKind === "bond_beam" || part.slab !== void 0)).map((part) => part.id));
|
|
30436
30636
|
const joints = supports.filter((s) => present.has(s.part) && present.has(s.on)).map((s) => ({ id: `${s.part}~${s.on}`, a: s.part, b: s.on, kind: s.joint, bears: s.bears === false || beams.has(s.part) && infill.has(s.on) ? false : "a_on_b" }));
|
|
30437
|
-
const
|
|
30637
|
+
const built2 = { name: options.name ?? "house", parts: specs, joints, tags: ["structure", "house"] };
|
|
30638
|
+
const spec = detail === "coarse" && options.windowApertures !== false ? withWindowApertures(built2, structure.openings) : built2;
|
|
30438
30639
|
return onSoil(withRebar(spec, structure, options, portico, slabOptions !== void 0), structure, options);
|
|
30439
30640
|
}
|
|
30440
30641
|
function withRebar(spec, structure, options, portico, panelled) {
|
|
@@ -32308,7 +32509,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
32308
32509
|
}
|
|
32309
32510
|
var residentialTower = residentialTowerTemplate();
|
|
32310
32511
|
|
|
32311
|
-
// ../game-floorplan-three/dist/chunk-
|
|
32512
|
+
// ../game-floorplan-three/dist/chunk-XOLKY3ZJ.js
|
|
32312
32513
|
var __defProp4 = Object.defineProperty;
|
|
32313
32514
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
32314
32515
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -33364,6 +33565,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33364
33565
|
function installHouseWindows(K, shared3) {
|
|
33365
33566
|
const { EPS: EPS6, Y0, boxC, bx, cursor, pieceRecord, roomAt } = K;
|
|
33366
33567
|
const FRAME_COLORS = { budget: 15856110, mid: 12830924, high: 2829875, commercial: 11844287 };
|
|
33568
|
+
const ALUMINIUM_PROFILE_KG_PER_M = 1.2, SILL_KG_PER_M = 6, STEEL_KG_PER_M3 = 7850, GRILLE_BAR = 0.016;
|
|
33367
33569
|
const SILL_COLORS = { budget: 15131870, mid: 14277076, high: 3816770, commercial: 13225166 };
|
|
33368
33570
|
function windows() {
|
|
33369
33571
|
const R = shared3.ctx.r, cut = shared3.ctx.cut, C = shared3.ctx.colors, structure = R.style, fr = FRAME_COLORS[structure] || FRAME_COLORS.budget, pe_ = SILL_COLORS[structure] || SILL_COLORS.budget;
|
|
@@ -33379,7 +33581,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33379
33581
|
}
|
|
33380
33582
|
const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS6), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
|
|
33381
33583
|
const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt) => alongU ? bx(mat, u0, y0 + y_0, L - tw / 2, u1, y0 + y_1, L + tw / 2, color2) : bx(mat, L - tw / 2, y0 + y_0, u0, L + tw / 2, y0 + y_1, u1, color2);
|
|
33382
|
-
const
|
|
33584
|
+
const outside0 = !roomAt(f, alongU ? j.at : L + 0.4, alongU ? L + 0.4 : j.at) || !roomAt(f, alongU ? j.at : L - 0.4, alongU ? L - 0.4 : j.at);
|
|
33585
|
+
const frameMass = ALUMINIUM_PROFILE_KG_PER_M * (2 * (j.width + (yb - ya)) + j.width + (j.width > 0.9 ? yb - ya : 0)) + (outside0 ? SILL_KG_PER_M * (j.width + 0.1) : 0);
|
|
33586
|
+
const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f, mass: frameMass, aperture: { alongU, a: a + t, b: b - t, y0: y0 + ya + t, y1: y0 + yb - t } });
|
|
33383
33587
|
cursor.pc = frame2;
|
|
33384
33588
|
bar2(a, ya, a + t, yb, "metal", fr);
|
|
33385
33589
|
bar2(b - t, ya, b, yb, "metal", fr);
|
|
@@ -33398,7 +33602,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33398
33602
|
if (alongU) bx("plaster", a - 0.05, y0 + ya - 0.04, L + (outside > 0 ? th / 2 : -th / 2 - 0.08), b + 0.05, y0 + ya, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), pe_);
|
|
33399
33603
|
else bx("plaster", L + (outside > 0 ? th / 2 : -th / 2 - 0.08), y0 + ya - 0.04, a - 0.05, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), y0 + ya, b + 0.05, pe_);
|
|
33400
33604
|
if (R.facade.grilles && !cut) {
|
|
33401
|
-
const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12));
|
|
33605
|
+
const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12)), spacing = (j.width - 0.06) / n;
|
|
33606
|
+
cursor.pc = pieceRecord("window_grille:" + j.id, "steel", null, { floor: f, mass: STEEL_KG_PER_M3 * ((n + 1) * (yb - ya + 0.06) * GRILLE_BAR * GRILLE_BAR + 3 * j.width * 0.025 * 0.024), aperture: { alongU, a: a + 0.03, b: a + 0.03 + n * spacing, y0: y0 + ya - 0.03, y1: y0 + yb + 0.03, bars: { spacing, width: GRILLE_BAR } } });
|
|
33402
33607
|
for (let k = 0; k <= n; k++) {
|
|
33403
33608
|
const u = a + 0.03 + k * (j.width - 0.06) / n;
|
|
33404
33609
|
if (alongU) bx("metal", u - 8e-3, y0 + ya - 0.03, L + go - 8e-3, u + 8e-3, y0 + yb + 0.03, L + go + 8e-3, g);
|
|
@@ -33408,6 +33613,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
33408
33613
|
if (alongU) bx("metal", a, y0 + y, L + go - 0.012, b, y0 + y + 0.025, L + go + 0.012, g);
|
|
33409
33614
|
else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
|
|
33410
33615
|
}
|
|
33616
|
+
cursor.pc = frame2;
|
|
33411
33617
|
}
|
|
33412
33618
|
cursor.pc = null;
|
|
33413
33619
|
}
|
|
@@ -38662,6 +38868,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38662
38868
|
else if (def.kind === "swing" || def.kind === "drawer") tagObject(def.name, [def.outer], "mdf", null, { mass: 6 });
|
|
38663
38869
|
}
|
|
38664
38870
|
}
|
|
38871
|
+
function apertureOf(sp, ap) {
|
|
38872
|
+
if (!ap || sp.shape.kind !== "box") return null;
|
|
38873
|
+
const size = sp.shape.size, depth = ap.alongU ? 2 : 0;
|
|
38874
|
+
if (size[depth] > Math.min(size[ap.alongU ? 0 : 2], size[1])) return null;
|
|
38875
|
+
const out = { size: [ap.b - ap.a, ap.y1 - ap.y0], offset: [(ap.a + ap.b) / 2 - sp.position[ap.alongU ? 0 : 2], (ap.y0 + ap.y1) / 2 - sp.position[1]] };
|
|
38876
|
+
if (ap.bars) out.bars = { axis: 0, spacing: ap.bars.spacing, width: ap.bars.width };
|
|
38877
|
+
return out;
|
|
38878
|
+
}
|
|
38665
38879
|
function assembleStructure(r0, root) {
|
|
38666
38880
|
const E0 = r0.structure || { parts: [], supports: [], levels: [], elevation: 0 }, meshes = /* @__PURE__ */ new Map(), add2 = (id, it) => {
|
|
38667
38881
|
let l = meshes.get(id);
|
|
@@ -38706,7 +38920,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38706
38920
|
if (!b) continue;
|
|
38707
38921
|
const vol = Math.max(1e-6, (b[3] - b[0]) * (b[4] - b[1]) * (b[5] - b[2]));
|
|
38708
38922
|
const p = { id, role: "none", material: pc.mat, aabb: [b[0], b[2], b[3], b[5]], y0: b[1], y1: b[4], floor: pc.floor != null ? pc.floor : floorAtY(b[1] + 0.1), mass: pc.mass != null ? pc.mass : Math.max(0.5, vol * (DENSITY[pc.mat] || 800) * (pc.fill != null ? pc.fill : 0.15)), meshes: meshes.get(id).length, extra: true };
|
|
38709
|
-
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units"]) if (pc[k] != null) p[k] = pc[k];
|
|
38923
|
+
for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units", "aperture"]) if (pc[k] != null) p[k] = pc[k];
|
|
38710
38924
|
parts.push(p);
|
|
38711
38925
|
byId.set(id, p);
|
|
38712
38926
|
}
|
|
@@ -38779,6 +38993,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38779
38993
|
if (!pc0) return sp;
|
|
38780
38994
|
const extra = {};
|
|
38781
38995
|
for (const k of ["contains", "explodes", "thickness", "fill", "tags"]) if (pc0[k] != null && sp[k] == null) extra[k] = pc0[k];
|
|
38996
|
+
const aperture = apertureOf(sp, pc0.aperture);
|
|
38997
|
+
if (aperture) extra.apertures = [aperture];
|
|
38782
38998
|
return Object.keys(extra).length ? { ...sp, ...extra } : sp;
|
|
38783
38999
|
});
|
|
38784
39000
|
spec.parts = spec.parts.map((sp) => {
|
|
@@ -38802,7 +39018,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
38802
39018
|
return sp;
|
|
38803
39019
|
}
|
|
38804
39020
|
});
|
|
38805
|
-
|
|
39021
|
+
const walls = new Set((E0.openings ?? []).map((op) => op.wall));
|
|
39022
|
+
return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest2 }) => rest2)(sp) : sp) }, E0.openings ?? []);
|
|
38806
39023
|
}
|
|
38807
39024
|
};
|
|
38808
39025
|
return structure;
|
|
@@ -39504,9 +39721,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39504
39721
|
dropped.length = 0;
|
|
39505
39722
|
},
|
|
39506
39723
|
flush,
|
|
39507
|
-
/** Takes this house's painting out of the renderer's queue (the house goes away); `claim` puts it back. */
|
|
39724
|
+
/** Takes this house's painting out of the renderer's queue (the house goes away) and frees the unit shapes on the GPU; `claim` puts it back (three.js uploads the shapes again when drawn). */
|
|
39508
39725
|
release() {
|
|
39509
39726
|
paintQueues.delete(queue);
|
|
39727
|
+
unitGeometry.dispose();
|
|
39728
|
+
lumpShape?.dispose();
|
|
39510
39729
|
},
|
|
39511
39730
|
/** The painting of this house alone. */
|
|
39512
39731
|
deferredQueue: () => queue,
|
|
@@ -39773,6 +39992,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39773
39992
|
D.deactivate = () => {
|
|
39774
39993
|
if (off) off();
|
|
39775
39994
|
off = null;
|
|
39995
|
+
if (R && D.id && D.active) R.release?.(D.id);
|
|
39776
39996
|
D.restore();
|
|
39777
39997
|
if (R && D.id && D.active) R.unbind(D.id);
|
|
39778
39998
|
if (D.active && D.world.has(D.id)) D.world.remove(D.id);
|
|
@@ -39855,7 +40075,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
39855
40075
|
D.piece = (id) => D.active ? D.world.part(D.id, id) : null;
|
|
39856
40076
|
D.state = () => D.active ? D.world.state(D.id) : null;
|
|
39857
40077
|
D.reset = () => {
|
|
39858
|
-
if (D.active)
|
|
40078
|
+
if (D.active) {
|
|
40079
|
+
R?.releasePieces?.(D.id);
|
|
40080
|
+
D.world.reset(D.id);
|
|
40081
|
+
}
|
|
39859
40082
|
D.restore();
|
|
39860
40083
|
};
|
|
39861
40084
|
D.strike = (pid, point, type, amount, d) => {
|
|
@@ -47875,7 +48098,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47875
48098
|
var MAGAZINE_DROP_DEFAULTS = defaultsOf(SAMPLE_LEVELS.magazine);
|
|
47876
48099
|
var droppedPartDefaults = (id) => id.startsWith("casing_drop_") ? CASING_DEFAULTS : id.startsWith("mag_drop_") ? MAGAZINE_DROP_DEFAULTS : void 0;
|
|
47877
48100
|
|
|
47878
|
-
// ../game-audio/dist/chunk-
|
|
48101
|
+
// ../game-audio/dist/chunk-ZFNHDQRV.js
|
|
47879
48102
|
var DISTANCE_CURVES = {
|
|
47880
48103
|
/** The game's `sfx`: `vol / (1 + d² × 0.004)`, cutoff `/ (1 + d × 0.01)`, silent below 0.01 (jogo L62091–62092, L62101). */
|
|
47881
48104
|
game_sfx: { model: "inverse_square", k: 4e-3, cutoffK: 0.01, minGain: 0.01 },
|
|
@@ -48635,6 +48858,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48635
48858
|
cutoffDbPerDecade: 30,
|
|
48636
48859
|
interval: 0.15,
|
|
48637
48860
|
budget: 3,
|
|
48861
|
+
budgetMs: 1,
|
|
48638
48862
|
smoothing: 0.08,
|
|
48639
48863
|
audibleLevel: 2e-3
|
|
48640
48864
|
};
|
|
@@ -48661,6 +48885,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48661
48885
|
}
|
|
48662
48886
|
var NEIGHBOUR_RADIUS = 2;
|
|
48663
48887
|
var REMEMBERED = 64;
|
|
48888
|
+
var COST_WEIGHT = 0.5;
|
|
48664
48889
|
var MOVED = 0.05;
|
|
48665
48890
|
var CHANGED_DB = 0.5;
|
|
48666
48891
|
var distance3 = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
@@ -48670,12 +48895,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48670
48895
|
const entries2 = /* @__PURE__ */ new Map();
|
|
48671
48896
|
let served = 0;
|
|
48672
48897
|
let spent = 0;
|
|
48898
|
+
let spentMs = 0;
|
|
48899
|
+
let costMs;
|
|
48673
48900
|
const remembered = /* @__PURE__ */ new Map();
|
|
48674
48901
|
const interval = setup.interval ?? OCCLUSION_DEFAULTS.interval;
|
|
48675
48902
|
const budget = Math.max(1, setup.budget ?? OCCLUSION_DEFAULTS.budget);
|
|
48676
48903
|
const audibleLevel = setup.audibleLevel ?? OCCLUSION_DEFAULTS.audibleLevel;
|
|
48904
|
+
const budgetMs = setup.budgetMs ?? OCCLUSION_DEFAULTS.budgetMs;
|
|
48905
|
+
const clock = setup.clock ?? (() => performance.now());
|
|
48677
48906
|
const measure = (source, listener) => {
|
|
48907
|
+
const started = clock();
|
|
48678
48908
|
const state = occlusionState(totalLossDb(setup.query(source, listener), setup), setup);
|
|
48909
|
+
const cost = clock() - started;
|
|
48910
|
+
spentMs += cost;
|
|
48911
|
+
costMs = costMs === void 0 ? cost : costMs + (cost - costMs) * COST_WEIGHT;
|
|
48679
48912
|
const key2 = keyOf(source);
|
|
48680
48913
|
remembered.delete(key2);
|
|
48681
48914
|
remembered.set(key2, state);
|
|
@@ -48696,7 +48929,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48696
48929
|
add({ id, source, level, listener, now }) {
|
|
48697
48930
|
const from = copy(source);
|
|
48698
48931
|
const at4 = copy(listener);
|
|
48699
|
-
if (spent >= budget) {
|
|
48932
|
+
if (spent >= budget || spentMs >= budgetMs || spentMs + (costMs ?? 0) > budgetMs) {
|
|
48700
48933
|
const provisional = guess(from);
|
|
48701
48934
|
entries2.set(id, { source: from, level, state: provisional, pending: true, checkedAt: now, checkedFrom: at4, served: served++ });
|
|
48702
48935
|
return provisional;
|
|
@@ -48711,18 +48944,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48711
48944
|
state: (id) => entries2.get(id)?.state,
|
|
48712
48945
|
update(listener, now) {
|
|
48713
48946
|
spent = 0;
|
|
48947
|
+
spentMs = 0;
|
|
48714
48948
|
const at4 = copy(listener);
|
|
48715
48949
|
const changes = [];
|
|
48716
48950
|
let queries = 0;
|
|
48951
|
+
const canQuery = () => queries < budget && (queries === 0 || spentMs < budgetMs);
|
|
48717
48952
|
for (const [id, voice2] of entries2) {
|
|
48718
|
-
if (!voice2.pending
|
|
48953
|
+
if (!voice2.pending) continue;
|
|
48954
|
+
if (!canQuery()) break;
|
|
48719
48955
|
queries++;
|
|
48720
48956
|
const state = measure(voice2.source, at4);
|
|
48721
48957
|
voice2.pending = false;
|
|
48722
48958
|
voice2.checkedAt = now;
|
|
48723
48959
|
voice2.checkedFrom = at4;
|
|
48724
48960
|
voice2.served = served++;
|
|
48725
|
-
if (
|
|
48961
|
+
if (state.lossDb === voice2.state.lossDb) continue;
|
|
48726
48962
|
voice2.state = state;
|
|
48727
48963
|
changes.push({ id, state });
|
|
48728
48964
|
}
|
|
@@ -48738,7 +48974,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48738
48974
|
voice2.checkedAt = now;
|
|
48739
48975
|
continue;
|
|
48740
48976
|
}
|
|
48741
|
-
if (
|
|
48977
|
+
if (!canQuery()) break;
|
|
48742
48978
|
queries++;
|
|
48743
48979
|
const state = measure(voice2.source, at4);
|
|
48744
48980
|
voice2.checkedAt = now;
|
|
@@ -50341,6 +50577,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
50341
50577
|
const chosen = (ids ?? registry.sampleIds()).map((id) => registry.sample(id)).filter((sample) => sample !== void 0);
|
|
50342
50578
|
return loadSounds(chosen);
|
|
50343
50579
|
},
|
|
50580
|
+
preload(ids) {
|
|
50581
|
+
const chosen = /* @__PURE__ */ new Map();
|
|
50582
|
+
const seen = /* @__PURE__ */ new Set();
|
|
50583
|
+
const visit = (id) => {
|
|
50584
|
+
if (seen.has(id)) return;
|
|
50585
|
+
seen.add(id);
|
|
50586
|
+
const sample = registry.sample(id);
|
|
50587
|
+
const set2 = registry.set(id);
|
|
50588
|
+
if (sample) chosen.set(sample.id, sample);
|
|
50589
|
+
else if (set2) for (const variant of set2.variants) visit(variant);
|
|
50590
|
+
else wanted.add(id);
|
|
50591
|
+
};
|
|
50592
|
+
for (const id of ids) visit(id);
|
|
50593
|
+
return loadSounds([...chosen.values()]);
|
|
50594
|
+
},
|
|
50344
50595
|
sampleStatus(id) {
|
|
50345
50596
|
const sample = registry.sample(id);
|
|
50346
50597
|
if (!sample) return "none";
|
|
@@ -64241,7 +64492,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64241
64492
|
trail: 0,
|
|
64242
64493
|
glow: null,
|
|
64243
64494
|
rng: placeholder,
|
|
64244
|
-
outColor: [0, 0, 0]
|
|
64495
|
+
outColor: [0, 0, 0],
|
|
64496
|
+
source: void 0
|
|
64245
64497
|
}),
|
|
64246
64498
|
freezeFollowingGlow
|
|
64247
64499
|
);
|
|
@@ -64343,7 +64595,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64343
64595
|
outY: 0,
|
|
64344
64596
|
outZ: 0,
|
|
64345
64597
|
outSize: 0,
|
|
64346
|
-
outIntensity: 0
|
|
64598
|
+
outIntensity: 0,
|
|
64599
|
+
source: void 0
|
|
64347
64600
|
}));
|
|
64348
64601
|
}
|
|
64349
64602
|
function spawnGlow(pool, init) {
|
|
@@ -64363,6 +64616,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64363
64616
|
glow.fx = init.fx ?? 0;
|
|
64364
64617
|
glow.fy = init.fy ?? 0;
|
|
64365
64618
|
glow.fz = init.fz ?? 0;
|
|
64619
|
+
glow.source = init.source;
|
|
64366
64620
|
return glow;
|
|
64367
64621
|
}
|
|
64368
64622
|
function ageOrKeep(glow, dt) {
|
|
@@ -64646,7 +64900,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64646
64900
|
rng: placeholder,
|
|
64647
64901
|
age: 0,
|
|
64648
64902
|
heat: 0,
|
|
64649
|
-
size: 0
|
|
64903
|
+
size: 0,
|
|
64904
|
+
source: void 0
|
|
64650
64905
|
}));
|
|
64651
64906
|
}
|
|
64652
64907
|
function spawnPuff(pool, random, init) {
|
|
@@ -64679,6 +64934,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64679
64934
|
puff3.age = 0;
|
|
64680
64935
|
puff3.heat = 0;
|
|
64681
64936
|
puff3.size = 0;
|
|
64937
|
+
puff3.source = init.source;
|
|
64682
64938
|
return puff3;
|
|
64683
64939
|
}
|
|
64684
64940
|
function ageOrKeep2(puff3, dt) {
|
|
@@ -64737,7 +64993,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64737
64993
|
var GROUND_LIFT = 0.02;
|
|
64738
64994
|
var BOUNCE_SLIDE = 0.55;
|
|
64739
64995
|
function createSparkPool(capacity) {
|
|
64740
|
-
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 }));
|
|
64996
|
+
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 }));
|
|
64741
64997
|
}
|
|
64742
64998
|
function spawnSpark(pool, init) {
|
|
64743
64999
|
const spark = pool.acquire();
|
|
@@ -64756,6 +65012,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64756
65012
|
spark.g = init.g ?? 9.8;
|
|
64757
65013
|
spark.bounce = init.bounce ?? 0.35;
|
|
64758
65014
|
spark.age = 0;
|
|
65015
|
+
spark.source = init.source;
|
|
64759
65016
|
return spark;
|
|
64760
65017
|
}
|
|
64761
65018
|
function ageOrKeep3(spark, dt) {
|
|
@@ -64789,22 +65046,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64789
65046
|
function addPuff(core, random, init) {
|
|
64790
65047
|
core.spawned.puffs++;
|
|
64791
65048
|
const puff3 = spawnPuff(core.puffs, random, init);
|
|
65049
|
+
puff3.source = init.source ?? core.source;
|
|
64792
65050
|
core.trace?.puff?.(puff3);
|
|
64793
65051
|
return puff3;
|
|
64794
65052
|
}
|
|
64795
65053
|
function addSpark(core, init) {
|
|
64796
65054
|
core.spawned.sparks++;
|
|
64797
65055
|
const spark = spawnSpark(core.sparks, init);
|
|
65056
|
+
spark.source = init.source ?? core.source;
|
|
64798
65057
|
core.trace?.spark?.(spark);
|
|
64799
65058
|
return spark;
|
|
64800
65059
|
}
|
|
64801
65060
|
function addGlow(core, init) {
|
|
64802
65061
|
const glow = spawnGlow(core.glows, init);
|
|
65062
|
+
glow.source = init.source ?? core.source;
|
|
64803
65063
|
core.trace?.glow?.(glow);
|
|
64804
65064
|
return glow;
|
|
64805
65065
|
}
|
|
64806
65066
|
function addChunk(core, random, init) {
|
|
64807
65067
|
const chunk = spawnChunk(core.chunks, random, init);
|
|
65068
|
+
chunk.source = core.source;
|
|
64808
65069
|
core.spawned.chunks++;
|
|
64809
65070
|
if (chunk.hot && core.layers.shrapnel) {
|
|
64810
65071
|
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 });
|
|
@@ -64833,7 +65094,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64833
65094
|
fz: 0,
|
|
64834
65095
|
color: SMOKE_COLORS.black,
|
|
64835
65096
|
rng: placeholder,
|
|
64836
|
-
handle: 0
|
|
65097
|
+
handle: 0,
|
|
65098
|
+
source: void 0
|
|
64837
65099
|
}));
|
|
64838
65100
|
}
|
|
64839
65101
|
function spawnFire(pool, random, init, handle) {
|
|
@@ -64858,6 +65120,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64858
65120
|
fire.color = init.color ?? SMOKE_COLORS.black;
|
|
64859
65121
|
fire.rng = random;
|
|
64860
65122
|
fire.handle = handle;
|
|
65123
|
+
fire.source = init.source;
|
|
64861
65124
|
return fire;
|
|
64862
65125
|
}
|
|
64863
65126
|
function addFire(core, random, init, handle) {
|
|
@@ -64892,7 +65155,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64892
65155
|
buoy: 3.2,
|
|
64893
65156
|
color: fire.color,
|
|
64894
65157
|
kind: 0,
|
|
64895
|
-
wind: 0.4
|
|
65158
|
+
wind: 0.4,
|
|
65159
|
+
source: fire.source
|
|
64896
65160
|
});
|
|
64897
65161
|
}
|
|
64898
65162
|
}
|
|
@@ -64915,7 +65179,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64915
65179
|
drag: 0.6,
|
|
64916
65180
|
buoy: 0.55,
|
|
64917
65181
|
color: fire.color,
|
|
64918
|
-
kind: 0
|
|
65182
|
+
kind: 0,
|
|
65183
|
+
source: fire.source
|
|
64919
65184
|
});
|
|
64920
65185
|
}
|
|
64921
65186
|
}
|
|
@@ -64934,7 +65199,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64934
65199
|
st: 0.02,
|
|
64935
65200
|
kind: 4,
|
|
64936
65201
|
g: -0.6,
|
|
64937
|
-
drag: 1.2
|
|
65202
|
+
drag: 1.2,
|
|
65203
|
+
source: fire.source
|
|
64938
65204
|
});
|
|
64939
65205
|
}
|
|
64940
65206
|
function updateFires(core, dt) {
|
|
@@ -68864,10 +69130,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68864
69130
|
st: 0.05,
|
|
68865
69131
|
kind: 0,
|
|
68866
69132
|
g: 0,
|
|
68867
|
-
drag: 1
|
|
69133
|
+
drag: 1,
|
|
69134
|
+
source: chunk.source
|
|
68868
69135
|
});
|
|
68869
69136
|
if (random.next() < 0.25) {
|
|
68870
|
-
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 });
|
|
69137
|
+
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 });
|
|
68871
69138
|
}
|
|
68872
69139
|
}
|
|
68873
69140
|
function updateChunks(core, dt) {
|
|
@@ -68923,10 +69190,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68923
69190
|
};
|
|
68924
69191
|
}
|
|
68925
69192
|
var SpriteKindPool = class {
|
|
68926
|
-
constructor(capacity, defs, owners) {
|
|
69193
|
+
constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
|
|
68927
69194
|
__publicField3(this, "capacity", capacity);
|
|
68928
69195
|
__publicField3(this, "defs", defs);
|
|
68929
69196
|
__publicField3(this, "owners", owners);
|
|
69197
|
+
__publicField3(this, "sources", sources);
|
|
68930
69198
|
__publicField3(this, "live", 0);
|
|
68931
69199
|
__publicField3(this, "drawCount", 0);
|
|
68932
69200
|
__publicField3(this, "position");
|
|
@@ -68945,6 +69213,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68945
69213
|
__publicField3(this, "alphaMul");
|
|
68946
69214
|
__publicField3(this, "tag");
|
|
68947
69215
|
__publicField3(this, "owner");
|
|
69216
|
+
__publicField3(this, "source");
|
|
68948
69217
|
__publicField3(this, "colorHex");
|
|
68949
69218
|
__publicField3(this, "rgbStart");
|
|
68950
69219
|
__publicField3(this, "rgbEnd");
|
|
@@ -68966,6 +69235,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68966
69235
|
this.alphaMul = new Float32Array(n);
|
|
68967
69236
|
this.tag = new Int32Array(n);
|
|
68968
69237
|
this.owner = new Int32Array(n);
|
|
69238
|
+
this.source = new Int32Array(n);
|
|
68969
69239
|
this.colorHex = new Int32Array(n);
|
|
68970
69240
|
this.rgbStart = new Float32Array(n * 3);
|
|
68971
69241
|
this.rgbEnd = new Float32Array(n * 3);
|
|
@@ -68992,6 +69262,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68992
69262
|
this.alphaMul[i] = options?.alpha ?? 1;
|
|
68993
69263
|
this.tag[i] = options?.tag ?? 0;
|
|
68994
69264
|
this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
|
|
69265
|
+
this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
|
|
68995
69266
|
this.colorHex[i] = options?.color ?? -1;
|
|
68996
69267
|
this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
|
|
68997
69268
|
this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
|
|
@@ -69006,6 +69277,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69006
69277
|
if (index < 0) index = this.owners.push(name) - 1;
|
|
69007
69278
|
return index;
|
|
69008
69279
|
}
|
|
69280
|
+
sourceIndex(name) {
|
|
69281
|
+
let index = this.sources.ids.get(name);
|
|
69282
|
+
if (index === void 0) {
|
|
69283
|
+
index = this.sources.next++;
|
|
69284
|
+
this.sources.ids.set(name, index);
|
|
69285
|
+
}
|
|
69286
|
+
return index;
|
|
69287
|
+
}
|
|
69288
|
+
/** Kills the live sprites made for `source`; returns how many went. */
|
|
69289
|
+
clearSource(source) {
|
|
69290
|
+
const index = this.sources.ids.get(source);
|
|
69291
|
+
if (index === void 0) return 0;
|
|
69292
|
+
let killed = 0;
|
|
69293
|
+
for (let i = 0; i < this.high; i++) {
|
|
69294
|
+
if (!this.alive[i] || this.source[i] !== index) continue;
|
|
69295
|
+
this.kill(i);
|
|
69296
|
+
killed++;
|
|
69297
|
+
}
|
|
69298
|
+
return killed;
|
|
69299
|
+
}
|
|
69009
69300
|
kill(i) {
|
|
69010
69301
|
if (!this.alive[i]) return;
|
|
69011
69302
|
this.alive[i] = 0;
|
|
@@ -69451,14 +69742,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69451
69742
|
__publicField3(this, "defs");
|
|
69452
69743
|
__publicField3(this, "index", /* @__PURE__ */ new Map());
|
|
69453
69744
|
__publicField3(this, "owners", []);
|
|
69745
|
+
__publicField3(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
|
|
69454
69746
|
__publicField3(this, "listeners", /* @__PURE__ */ new Map());
|
|
69455
69747
|
const kinds = options.kinds ?? SPRITE_KINDS;
|
|
69456
69748
|
this.ids = Object.keys(kinds);
|
|
69457
69749
|
this.defs = this.ids.map((id) => kinds[id]);
|
|
69458
69750
|
this.ids.forEach((id, at32) => this.index.set(id, at32));
|
|
69459
69751
|
const additiveCapacity = Math.floor(options.capacity * 0.4);
|
|
69460
|
-
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
|
|
69461
|
-
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
|
|
69752
|
+
this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
|
|
69753
|
+
this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
|
|
69462
69754
|
this.random = spriteRandom(options.seed);
|
|
69463
69755
|
}
|
|
69464
69756
|
get capacity() {
|
|
@@ -69532,9 +69824,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
69532
69824
|
if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
|
|
69533
69825
|
if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
|
|
69534
69826
|
}
|
|
69827
|
+
/** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
|
|
69828
|
+
clearSource(source) {
|
|
69829
|
+
const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
|
|
69830
|
+
this.sources.ids.delete(source);
|
|
69831
|
+
return killed;
|
|
69832
|
+
}
|
|
69535
69833
|
clear() {
|
|
69536
69834
|
this.additive.clear();
|
|
69537
69835
|
this.normal.clear();
|
|
69836
|
+
this.sources.ids.clear();
|
|
69538
69837
|
}
|
|
69539
69838
|
};
|
|
69540
69839
|
var TWO_PI_ROUNDED = 6.2832;
|
|
@@ -70562,7 +70861,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70562
70861
|
groundAt,
|
|
70563
70862
|
...options.marklessAt ? { marklessAt: options.marklessAt } : {},
|
|
70564
70863
|
...options.cratersAt ? { cratersAt: options.cratersAt } : {},
|
|
70565
|
-
emit: (request) => options.onRequest?.(request)
|
|
70864
|
+
emit: (request) => options.onRequest?.(request),
|
|
70865
|
+
source: void 0
|
|
70566
70866
|
};
|
|
70567
70867
|
function definitionOf(id) {
|
|
70568
70868
|
return explosions[id] ?? explosions[aliases[id] ?? ""];
|
|
@@ -70573,7 +70873,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70573
70873
|
return streamFor3(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
70574
70874
|
}
|
|
70575
70875
|
function detonate(def, point, call3) {
|
|
70576
|
-
|
|
70876
|
+
const outer = core.source;
|
|
70877
|
+
core.source = call3.source;
|
|
70878
|
+
try {
|
|
70879
|
+
composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
|
|
70880
|
+
} finally {
|
|
70881
|
+
core.source = outer;
|
|
70882
|
+
}
|
|
70577
70883
|
}
|
|
70578
70884
|
let engine;
|
|
70579
70885
|
let player;
|
|
@@ -70614,8 +70920,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70614
70920
|
const handle = ++handles.next;
|
|
70615
70921
|
const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
|
|
70616
70922
|
const random = streamOf(explosionOptions.seed);
|
|
70617
|
-
|
|
70618
|
-
|
|
70923
|
+
const source = explosionOptions.source;
|
|
70924
|
+
if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
|
|
70925
|
+
else detonate(def, point, { direction, random, handle, source });
|
|
70619
70926
|
return handle;
|
|
70620
70927
|
},
|
|
70621
70928
|
fire(fireOptions) {
|
|
@@ -70657,6 +70964,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
70657
70964
|
const fires = core.fires;
|
|
70658
70965
|
for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
|
|
70659
70966
|
},
|
|
70967
|
+
clearSource(source) {
|
|
70968
|
+
const keep = (record, gone) => record.source !== gone;
|
|
70969
|
+
const drop = (pool) => {
|
|
70970
|
+
const before = pool.count;
|
|
70971
|
+
pool.compact(keep, source);
|
|
70972
|
+
return before - pool.count;
|
|
70973
|
+
};
|
|
70974
|
+
return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
|
|
70975
|
+
},
|
|
70660
70976
|
setLayer(layer3, on) {
|
|
70661
70977
|
layers[layer3] = on;
|
|
70662
70978
|
},
|
|
@@ -74874,6 +75190,25 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
74874
75190
|
model.name = `${WORLD_EXPLOSIVE_PREFIX}${defId}_shell`;
|
|
74875
75191
|
return model;
|
|
74876
75192
|
};
|
|
75193
|
+
var createWorldExplosiveShells = (THREE, defId, items) => {
|
|
75194
|
+
const model = worldExplosiveShell(THREE, defId, items);
|
|
75195
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
75196
|
+
const materials = /* @__PURE__ */ new Set();
|
|
75197
|
+
model?.traverse((node) => {
|
|
75198
|
+
const mesh3 = node;
|
|
75199
|
+
if (!mesh3.isMesh) return;
|
|
75200
|
+
geometries.add(mesh3.geometry);
|
|
75201
|
+
for (const material of Array.isArray(mesh3.material) ? mesh3.material : [mesh3.material]) materials.add(material);
|
|
75202
|
+
});
|
|
75203
|
+
markShared(...geometries, ...materials);
|
|
75204
|
+
return {
|
|
75205
|
+
next: () => model?.clone(),
|
|
75206
|
+
dispose() {
|
|
75207
|
+
for (const geometry of geometries) geometry.dispose();
|
|
75208
|
+
for (const material of materials) material.dispose();
|
|
75209
|
+
}
|
|
75210
|
+
};
|
|
75211
|
+
};
|
|
74877
75212
|
var worldExplosiveItem = (def, name, options = {}) => {
|
|
74878
75213
|
const shape = SHAPES3[def.id];
|
|
74879
75214
|
if (!shape) return void 0;
|
|
@@ -75648,6 +75983,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
75648
75983
|
const vessels = /* @__PURE__ */ new Map();
|
|
75649
75984
|
const wallParts = /* @__PURE__ */ new Set();
|
|
75650
75985
|
const shells = [];
|
|
75986
|
+
let shellModel = null;
|
|
75651
75987
|
const T2 = () => host?.THREE;
|
|
75652
75988
|
const now = () => room?.world.time ?? 0;
|
|
75653
75989
|
const say = (message, data = {}) => host?.log(message, { source: EXPLOSIVES_AREA_ID, ...data });
|
|
@@ -75754,7 +76090,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
75754
76090
|
const launchShell = (vessel, point) => {
|
|
75755
76091
|
const config = def.shell;
|
|
75756
76092
|
if (!config || !host) return;
|
|
75757
|
-
const mesh3 =
|
|
76093
|
+
const mesh3 = shellModel?.next();
|
|
75758
76094
|
if (!mesh3) return;
|
|
75759
76095
|
mesh3.position.set(point[0], Math.max(point[1], 0.3), point[2]);
|
|
75760
76096
|
host.scene.add(mesh3);
|
|
@@ -76099,6 +76435,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76099
76435
|
],
|
|
76100
76436
|
attach(lent) {
|
|
76101
76437
|
host = lent;
|
|
76438
|
+
if (def.shell) shellModel = createWorldExplosiveShells(T2(), def.id, options.items);
|
|
76102
76439
|
const offs = [];
|
|
76103
76440
|
if (room) {
|
|
76104
76441
|
offs.push(room.world.on("*", onEvent));
|
|
@@ -76129,6 +76466,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76129
76466
|
for (const vessel of vessels.values()) clearRings(vessel);
|
|
76130
76467
|
vessels.clear();
|
|
76131
76468
|
clearShells();
|
|
76469
|
+
shellModel?.dispose();
|
|
76470
|
+
shellModel = null;
|
|
76132
76471
|
host = null;
|
|
76133
76472
|
};
|
|
76134
76473
|
},
|
|
@@ -76143,6 +76482,38 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76143
76482
|
};
|
|
76144
76483
|
}
|
|
76145
76484
|
|
|
76485
|
+
// src/test-area/torn-body.ts
|
|
76486
|
+
function boxesCentre(boxes) {
|
|
76487
|
+
if (boxes.length === 0) return void 0;
|
|
76488
|
+
const low = [Infinity, Infinity, Infinity];
|
|
76489
|
+
const high = [-Infinity, -Infinity, -Infinity];
|
|
76490
|
+
for (const box5 of boxes) {
|
|
76491
|
+
for (let axis2 = 0; axis2 < 3; axis2++) {
|
|
76492
|
+
low[axis2] = Math.min(low[axis2], box5[axis2]);
|
|
76493
|
+
high[axis2] = Math.max(high[axis2], box5[axis2 + 3]);
|
|
76494
|
+
}
|
|
76495
|
+
}
|
|
76496
|
+
return [(low[0] + high[0]) / 2, (low[1] + high[1]) / 2, (low[2] + high[2]) / 2];
|
|
76497
|
+
}
|
|
76498
|
+
function tornBodyShift(before, after2) {
|
|
76499
|
+
let mass = 0;
|
|
76500
|
+
const from = [0, 0];
|
|
76501
|
+
const to = [0, 0];
|
|
76502
|
+
for (const [key2, first] of before) {
|
|
76503
|
+
const second = after2.get(key2);
|
|
76504
|
+
const start = boxesCentre(first.boxes);
|
|
76505
|
+
const end3 = second ? boxesCentre(second.boxes) : void 0;
|
|
76506
|
+
if (!start || !end3 || first.mass <= 0) continue;
|
|
76507
|
+
mass += first.mass;
|
|
76508
|
+
from[0] += start[0] * first.mass;
|
|
76509
|
+
from[1] += start[2] * first.mass;
|
|
76510
|
+
to[0] += end3[0] * first.mass;
|
|
76511
|
+
to[1] += end3[2] * first.mass;
|
|
76512
|
+
}
|
|
76513
|
+
if (mass === 0) return void 0;
|
|
76514
|
+
return Math.hypot((to[0] - from[0]) / mass, (to[1] - from[1]) / mass);
|
|
76515
|
+
}
|
|
76516
|
+
|
|
76146
76517
|
// src/test-area/explosives-scenarios.ts
|
|
76147
76518
|
var TORCH_WINDOW = [0.7, 1];
|
|
76148
76519
|
var BLAST_WITHIN = 1.6;
|
|
@@ -76217,6 +76588,13 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76217
76588
|
origin.set(body.objectId, body.from);
|
|
76218
76589
|
}
|
|
76219
76590
|
const partsBefore = new Map(placed.map((body) => [body.objectId, partsOf(body.objectId)]));
|
|
76591
|
+
const partPlaces = (objectId, keep = () => true) => (room.world.state(objectId)?.parts ?? []).filter(keep).map((part) => [part, { mass: part.mass, boxes: room.renderer.shownBoxes?.(objectId, part.id) ?? [] }]);
|
|
76592
|
+
const heavyBefore = new Map(placed.filter((body) => HEAVY_ITEMS.includes(body.kind)).map((body) => [body.objectId, new Map(partPlaces(body.objectId))]));
|
|
76593
|
+
const heavyShift = (objectId) => {
|
|
76594
|
+
const before = heavyBefore.get(objectId);
|
|
76595
|
+
if (!before) return void 0;
|
|
76596
|
+
return tornBodyShift(before, new Map(room.world.ids().flatMap((id) => partPlaces(id, (part) => before.has(part)))));
|
|
76597
|
+
};
|
|
76220
76598
|
expect(placed.length > 0, fillText2(text.push_found, { n: placed.length, kinds: [...new Set(placed.map((body) => body.kind))].join(", ") }), { placed: placed.map((body) => body.itemId) });
|
|
76221
76599
|
const aimOf = new Map(
|
|
76222
76600
|
placed.map((body) => {
|
|
@@ -76293,7 +76671,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76293
76671
|
expect(row.outward <= most, fillText2(text.push_person_wave, { who: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), moved: Math.max(0, row.outward).toFixed(2), most: most.toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward, speed, most } });
|
|
76294
76672
|
}
|
|
76295
76673
|
const table = rows.find((row) => HEAVY_ITEMS.includes(row.kind) && row.distance < blast.radius * 0.85);
|
|
76296
|
-
if (table)
|
|
76674
|
+
if (table) {
|
|
76675
|
+
const moved = heavyShift(table.objectId) ?? table.moved;
|
|
76676
|
+
expect(moved >= MOVED2, fillText2(text.push_heavy, { what: things[table.itemId] ?? table.itemId, moved: moved.toFixed(2) }), { table, moved, rootMoved: table.moved });
|
|
76677
|
+
}
|
|
76297
76678
|
}
|
|
76298
76679
|
};
|
|
76299
76680
|
}
|
|
@@ -76392,7 +76773,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
76392
76773
|
{ item: "fridge", at: [-1.65, 0, -10.55] },
|
|
76393
76774
|
{ item: "kitchen_cabinet_base", at: [-0.78, 0, -10.6] },
|
|
76394
76775
|
{ item: "stove", at: [0.72, 0, -10.58] },
|
|
76395
|
-
|
|
76776
|
+
// on open floor in the blast's sight, off the paving along the wall: the slabs a blast leaves fixed beyond the stretch it breaks (since #281) held the table's legs out of its reach
|
|
76777
|
+
{ item: "camp_table", at: [1.82, 0, -8.52], rotationY: Math.PI / 2 }
|
|
76396
76778
|
],
|
|
76397
76779
|
cylinder: [0.02, 0, -10.66],
|
|
76398
76780
|
zombie: { item: "zombie_walker", at: [-1.6, 0, -8.1] },
|