@adatechnology/game-weapons-three 0.19.0 → 0.19.2
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 +476 -138
- package/dist/index.global.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -112,28 +112,28 @@ var GameWeaponsThree = (() => {
|
|
|
112
112
|
// ../game-contracts/dist/index.js
|
|
113
113
|
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
114
114
|
var NEAREST = 0.3;
|
|
115
|
-
function sideOnImpulse(tnt,
|
|
115
|
+
function sideOnImpulse(tnt, distance4) {
|
|
116
116
|
if (!(tnt > 0)) return 0;
|
|
117
117
|
const w3 = Math.cbrt(tnt);
|
|
118
|
-
const z = Math.max(
|
|
118
|
+
const z = Math.max(distance4, NEAREST) / w3;
|
|
119
119
|
const scaled2 = 0.067 * Math.sqrt(1 + (z / 0.23) ** 4) / (z * z * Math.cbrt(1 + (z / 1.55) ** 3));
|
|
120
120
|
return scaled2 * w3 * 100;
|
|
121
121
|
}
|
|
122
122
|
var ATMOSPHERE = 101325;
|
|
123
|
-
function sideOnOverpressure(tnt,
|
|
123
|
+
function sideOnOverpressure(tnt, distance4) {
|
|
124
124
|
if (!(tnt > 0)) return 0;
|
|
125
|
-
const z = Math.max(
|
|
125
|
+
const z = Math.max(distance4, NEAREST) / Math.cbrt(tnt);
|
|
126
126
|
const ratio = 808 * (1 + (z / 4.5) ** 2) / (Math.sqrt(1 + (z / 0.048) ** 2) * Math.sqrt(1 + (z / 0.32) ** 2) * Math.sqrt(1 + (z / 1.35) ** 2));
|
|
127
127
|
return ratio * ATMOSPHERE;
|
|
128
128
|
}
|
|
129
|
-
function bodyImpulse(tnt,
|
|
129
|
+
function bodyImpulse(tnt, distance4) {
|
|
130
130
|
if (!(tnt > 0)) return 0;
|
|
131
|
-
const z = Math.max(
|
|
132
|
-
return sideOnImpulse(tnt,
|
|
131
|
+
const z = Math.max(distance4, NEAREST) / Math.cbrt(tnt);
|
|
132
|
+
return sideOnImpulse(tnt, distance4) * (2 + 4 / (1 + z * z));
|
|
133
133
|
}
|
|
134
|
-
function blastBodySpeed(tnt,
|
|
134
|
+
function blastBodySpeed(tnt, distance4, mass, reach = 1, options = {}) {
|
|
135
135
|
const area3 = options.bodyArea ?? DEFAULT_BLAST_IMPULSE.bodyArea;
|
|
136
|
-
return bodyImpulse(tnt,
|
|
136
|
+
return bodyImpulse(tnt, distance4) * area3 * Math.max(0, reach) / Math.max(mass, 1);
|
|
137
137
|
}
|
|
138
138
|
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
139
139
|
var DEFAULT_IGNITION_RULES = {
|
|
@@ -4469,13 +4469,18 @@ var GameWeaponsThree = (() => {
|
|
|
4469
4469
|
tnt: 0.045,
|
|
4470
4470
|
destructionLevel: 2,
|
|
4471
4471
|
noise: 450,
|
|
4472
|
+
armRange: [
|
|
4473
|
+
14,
|
|
4474
|
+
27
|
|
4475
|
+
],
|
|
4472
4476
|
triggers: [
|
|
4473
4477
|
"impact"
|
|
4474
4478
|
],
|
|
4475
4479
|
sources: [
|
|
4476
4480
|
"arsenal",
|
|
4477
4481
|
"lab",
|
|
4478
|
-
"gallery"
|
|
4482
|
+
"gallery",
|
|
4483
|
+
"reference"
|
|
4479
4484
|
]
|
|
4480
4485
|
},
|
|
4481
4486
|
{
|
|
@@ -4694,11 +4699,16 @@ var GameWeaponsThree = (() => {
|
|
|
4694
4699
|
tnt: 0.045,
|
|
4695
4700
|
destructionLevel: 2,
|
|
4696
4701
|
noise: 450,
|
|
4702
|
+
armRange: [
|
|
4703
|
+
10,
|
|
4704
|
+
40
|
|
4705
|
+
],
|
|
4697
4706
|
triggers: [
|
|
4698
4707
|
"impact"
|
|
4699
4708
|
],
|
|
4700
4709
|
sources: [
|
|
4701
4710
|
"lab",
|
|
4711
|
+
"reference",
|
|
4702
4712
|
"derived"
|
|
4703
4713
|
]
|
|
4704
4714
|
},
|
|
@@ -14612,6 +14622,7 @@ var GameWeaponsThree = (() => {
|
|
|
14612
14622
|
const problems = [];
|
|
14613
14623
|
const [low, high] = explosive.fuseRange ?? [1, 1];
|
|
14614
14624
|
if (!(low > 0 && high >= low)) problems.push(`explosive "${explosive.id}" has a fuse range of ${low} to ${high} s`);
|
|
14625
|
+
if (explosive.armRange && !(explosive.armRange[0] > 0 && explosive.armRange[1] >= explosive.armRange[0])) problems.push(`explosive "${explosive.id}" arms between ${explosive.armRange[0]} and ${explosive.armRange[1]} m`);
|
|
14615
14626
|
if (explosive.fuseLength !== void 0 && !(explosive.fuseLength > 0)) problems.push(`explosive "${explosive.id}" has a fuse length of ${explosive.fuseLength} m`);
|
|
14616
14627
|
if (explosive.burnRate !== void 0 && !(explosive.burnRate > 0)) problems.push(`explosive "${explosive.id}" has a burn rate of ${explosive.burnRate} s/m`);
|
|
14617
14628
|
if (explosive.burnTolerance !== void 0 && !(explosive.burnTolerance >= 0 && explosive.burnTolerance < 1)) problems.push(`explosive "${explosive.id}" has a burn tolerance of ${explosive.burnTolerance}`);
|
|
@@ -15227,7 +15238,12 @@ var GameWeaponsThree = (() => {
|
|
|
15227
15238
|
energy: explosive.energy,
|
|
15228
15239
|
injuryRadius: explosive.injuryRadius
|
|
15229
15240
|
});
|
|
15230
|
-
var
|
|
15241
|
+
var sampleArmDistance = (action, explosive, random) => {
|
|
15242
|
+
const range3 = explosive?.armRange;
|
|
15243
|
+
if (!range3) return action.minArmDistance;
|
|
15244
|
+
return range3[0] + (range3[1] - range3[0]) * random();
|
|
15245
|
+
};
|
|
15246
|
+
var launcherUses = ({ action, explosive, origin, direction, armDistance }) => {
|
|
15231
15247
|
const velocity = [direction[0] * action.speed, direction[1] * action.speed, direction[2] * action.speed];
|
|
15232
15248
|
const projectile = {
|
|
15233
15249
|
kind: "throw",
|
|
@@ -15238,7 +15254,7 @@ var GameWeaponsThree = (() => {
|
|
|
15238
15254
|
origin,
|
|
15239
15255
|
explosive: action.projectile,
|
|
15240
15256
|
trigger: "impact",
|
|
15241
|
-
armDistance: action.minArmDistance,
|
|
15257
|
+
armDistance: armDistance ?? action.minArmDistance,
|
|
15242
15258
|
...explosive ? { injuryRadius: explosive.injuryRadius } : {}
|
|
15243
15259
|
};
|
|
15244
15260
|
if (action.backblast <= 0) return [projectile];
|
|
@@ -16415,7 +16431,7 @@ var GameWeaponsThree = (() => {
|
|
|
16415
16431
|
this._ammo -= 1;
|
|
16416
16432
|
this._heat = Math.min(this.rules.heat.cap, this._heat + heatPerRound({ action: a, caliber: null, energy: 0, barrelMass: this.barrelMass, rules: this.rules.heat }));
|
|
16417
16433
|
this.emit({ type: "shot", shots: 0, rounds: 1, mode: this.mode, at: t });
|
|
16418
|
-
return result("ok", { uses: launcherUses(a, this.explosive, origin, dir), recoil: [a.recoil[0], a.recoil[1]], noise: a.noise ?? 0, rounds: 1, roundTimes: [t - start] });
|
|
16434
|
+
return result("ok", { uses: launcherUses({ action: a, explosive: this.explosive, origin, direction: dir, armDistance: sampleArmDistance(a, this.explosive, this.fuseRng) }), recoil: [a.recoil[0], a.recoil[1]], noise: a.noise ?? 0, rounds: 1, roundTimes: [t - start] });
|
|
16419
16435
|
}
|
|
16420
16436
|
fireMelee(a, origin, dir, start, end3) {
|
|
16421
16437
|
const t0 = Math.max(start, this.readyAt);
|
|
@@ -18285,18 +18301,18 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
18285
18301
|
return { ...p.parameters };
|
|
18286
18302
|
}
|
|
18287
18303
|
function toGeometry(THREE, source, options = {}) {
|
|
18288
|
-
const
|
|
18304
|
+
const copy2 = options.copy !== false;
|
|
18289
18305
|
const primitive = isPrimitive(source) ? source : null;
|
|
18290
18306
|
const ThreeClass = primitive && primitive.type !== "BufferGeometry" ? THREE[primitive.type] : void 0;
|
|
18291
18307
|
const geometry = ThreeClass ? Reflect.construct(THREE.BufferGeometry, [], ThreeClass) : new THREE.BufferGeometry();
|
|
18292
18308
|
if (primitive && ThreeClass) {
|
|
18293
18309
|
Object.assign(geometry, { type: primitive.type, parameters: threeParameters(THREE, primitive) });
|
|
18294
18310
|
}
|
|
18295
|
-
const attribute = (array, size) =>
|
|
18311
|
+
const attribute = (array, size) => copy2 ? new THREE.Float32BufferAttribute(array, size) : new THREE.BufferAttribute(array, size);
|
|
18296
18312
|
const index = source.indices;
|
|
18297
18313
|
const setIndex = () => {
|
|
18298
18314
|
if (!index) return;
|
|
18299
|
-
geometry.setIndex(
|
|
18315
|
+
geometry.setIndex(copy2 ? index instanceof Uint32Array ? new THREE.Uint32BufferAttribute(index, 1) : new THREE.Uint16BufferAttribute(index, 1) : new THREE.BufferAttribute(index, 1));
|
|
18300
18316
|
};
|
|
18301
18317
|
const type = primitive?.type ?? "BufferGeometry";
|
|
18302
18318
|
if (INDEX_FIRST.has(type)) setIndex();
|
|
@@ -22389,7 +22405,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22389
22405
|
for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
|
|
22390
22406
|
return sum2;
|
|
22391
22407
|
};
|
|
22392
|
-
var
|
|
22408
|
+
var REBAR_COVER = 0.03;
|
|
22409
|
+
var COVER = REBAR_COVER;
|
|
22393
22410
|
var MAX_BARS_PER_DIRECTION = 24;
|
|
22394
22411
|
var MAX_MEMBER_BARS_PER_SIDE = 6;
|
|
22395
22412
|
var STEEL_DENSITY = 7850;
|
|
@@ -22532,11 +22549,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22532
22549
|
const KM = options.massFactor ?? FLEXURE_DEFAULTS.massFactor;
|
|
22533
22550
|
return mass > 0 ? (KL * impulse) ** 2 / (2 * KM * mass) : 0;
|
|
22534
22551
|
};
|
|
22535
|
-
var blastImpulse = (tnt,
|
|
22552
|
+
var blastImpulse = (tnt, distance4, options = {}) => {
|
|
22536
22553
|
if (tnt <= 0) return 0;
|
|
22537
22554
|
const o = { ...FLEXURE_DEFAULTS, ...definedOf(options) };
|
|
22538
22555
|
const cube = Math.cbrt(tnt);
|
|
22539
|
-
const r = Math.max(
|
|
22556
|
+
const r = Math.max(distance4, o.nearScaled * cube);
|
|
22540
22557
|
return (o.reflection + o.reflectionNear / (r / cube)) * (o.impulse * cube * cube / r);
|
|
22541
22558
|
};
|
|
22542
22559
|
var slendernessFactor = (h, t, options = {}) => {
|
|
@@ -24625,6 +24642,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24625
24642
|
var PANEL_PI = 6e6;
|
|
24626
24643
|
var PANEL_POINTS = [[0, 0], [-0.3, 0], [0.3, 0], [0, -0.3], [0, 0.3]];
|
|
24627
24644
|
var PANEL_POINTS_LOADED = 4;
|
|
24645
|
+
var MEMBER_BAND = 0.1;
|
|
24646
|
+
var MEMBER_CRATER_CALIBRES = 3.4;
|
|
24647
|
+
var MEMBER_BARED_MAX = 24;
|
|
24648
|
+
var MEMBER_CUT_LOSS = 0.9;
|
|
24628
24649
|
var BLAST_EDGE_WEAR = 0.6;
|
|
24629
24650
|
var RESIDUAL_CAPACITY = 0.15;
|
|
24630
24651
|
var SEVER_BAND = 0.1;
|
|
@@ -26031,6 +26052,57 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26031
26052
|
const lp = toLocal(p.pos, p.q, objectPoint);
|
|
26032
26053
|
return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
|
|
26033
26054
|
};
|
|
26055
|
+
const wearMember = (o, p, entry2, d, E, caliber, penMm, src) => {
|
|
26056
|
+
var _a, _b;
|
|
26057
|
+
if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
|
|
26058
|
+
const along = p.dims.indexOf(Math.max(...p.dims));
|
|
26059
|
+
const lp = toLocal(p.pos, p.q, objLocal(o, entry2));
|
|
26060
|
+
const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
|
|
26061
|
+
let depth = Infinity;
|
|
26062
|
+
for (let a = 0; a < 3; a++) if (a !== along && Math.abs(ld[a]) > 1e-3) depth = Math.min(depth, p.dims[a] / Math.abs(ld[a]));
|
|
26063
|
+
if (!Number.isFinite(depth)) return true;
|
|
26064
|
+
const into = (penMm ?? E / Math.max(p.mat.penetration, 1e-6)) / 1e3;
|
|
26065
|
+
const h = Math.min(into, depth);
|
|
26066
|
+
const r = Math.min(MEMBER_CRATER_CALIBRES * caliber / 1e3, h);
|
|
26067
|
+
const volume = Math.PI / 3 * r * r * h;
|
|
26068
|
+
const section = p.dims.reduce((product2, size, a) => a === along ? product2 : product2 * size, 1);
|
|
26069
|
+
const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
|
|
26070
|
+
const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
|
|
26071
|
+
const height = p.dims[along] / bands;
|
|
26072
|
+
const worn = (_a = p.rt).bands ?? (_a.bands = {});
|
|
26073
|
+
const before = worn[band] ?? 0;
|
|
26074
|
+
const after2 = Math.min(1, before + volume / (section * height));
|
|
26075
|
+
worn[band] = after2;
|
|
26076
|
+
markDamaged(p);
|
|
26077
|
+
const bandCenter = -p.dims[along] / 2 + (band + 0.5) * height;
|
|
26078
|
+
if (h > REBAR_COVER && after2 < MEMBER_CUT_LOSS) {
|
|
26079
|
+
const bared = (_b = p.rt).bared ?? (_b.bared = []);
|
|
26080
|
+
const center = [lp[0], lp[1], lp[2]];
|
|
26081
|
+
const size = [p.dims[0], p.dims[1], p.dims[2]];
|
|
26082
|
+
for (let a = 0; a < 3; a++) if (Math.abs(ld[a]) < 0.5) size[a] = 2 * r;
|
|
26083
|
+
if (bared.length < MEMBER_BARED_MAX && !bared.some((box5) => box5.center.every((x, a) => Math.abs(x - center[a]) < box5.size[a] / 4))) {
|
|
26084
|
+
bared.push({ center, size });
|
|
26085
|
+
exposeRebar(o, p, src);
|
|
26086
|
+
}
|
|
26087
|
+
}
|
|
26088
|
+
if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) return true;
|
|
26089
|
+
const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
|
|
26090
|
+
const standing = Math.abs(axisUp[1]) > 0.7;
|
|
26091
|
+
const upward = axisUp[1] >= 0 ? 1 : -1;
|
|
26092
|
+
const grid = gridOf(p);
|
|
26093
|
+
const gone = p.rt.chips ?? {};
|
|
26094
|
+
const out = [];
|
|
26095
|
+
for (let i = 0; i < grid.length; i++) {
|
|
26096
|
+
if (gone[i] === -1) continue;
|
|
26097
|
+
const at4 = grid[i].center[along];
|
|
26098
|
+
const inBand = Math.abs(at4 - bandCenter) <= height / 2 + 1e-6;
|
|
26099
|
+
const above2 = standing && (at4 - bandCenter) * upward > height / 2;
|
|
26100
|
+
if (inBand || above2) out.push(i);
|
|
26101
|
+
}
|
|
26102
|
+
if (out.length > 0) knockOutUnits(o, p, entry2, E, out, src);
|
|
26103
|
+
giveAtCut(o, p, src);
|
|
26104
|
+
return true;
|
|
26105
|
+
};
|
|
26034
26106
|
const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
|
|
26035
26107
|
var _a, _b, _c;
|
|
26036
26108
|
if (!p.spec.units || !p.staged || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
|
|
@@ -26172,6 +26244,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26172
26244
|
else {
|
|
26173
26245
|
bars = [];
|
|
26174
26246
|
for (const cell of p.st.chipped ?? []) bars.push(...clipBarsToBox(all, u, v, cell.center, cell.size));
|
|
26247
|
+
for (const box5 of p.rt.bared ?? []) bars.push(...clipBarsToBox(all, u, v, box5.center, box5.size));
|
|
26175
26248
|
const op = p.st.opening;
|
|
26176
26249
|
if (op) {
|
|
26177
26250
|
const lc = toLocal(p.pos, p.q, op.center);
|
|
@@ -26710,7 +26783,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
26710
26783
|
const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
|
|
26711
26784
|
const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src);
|
|
26712
26785
|
if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
|
|
26713
|
-
chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
|
|
26786
|
+
if (!wearMember(o, p, entry2, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
|
|
26714
26787
|
return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
|
|
26715
26788
|
};
|
|
26716
26789
|
const melee = (o, p, kind, E, point, n, d, contactR, src) => {
|
|
@@ -27627,14 +27700,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27627
27700
|
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true);
|
|
27628
27701
|
return r ? { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance } : null;
|
|
27629
27702
|
},
|
|
27630
|
-
sweepBox(box5, direction,
|
|
27703
|
+
sweepBox(box5, direction, distance4, options2 = {}) {
|
|
27631
27704
|
const d = vec.normalize(direction);
|
|
27632
27705
|
const ignored = options2.ignore === void 0 ? void 0 : objects.get(options2.ignore);
|
|
27633
27706
|
const hosted = options2.ignore === void 0 || ignored ? void 0 : impls.get(options2.ignore);
|
|
27634
27707
|
const ignore = ignored ? new Set(ignored.parts.map((p) => `${ignored.id}\0${p.spec.id}`)) : hosted ? new Set(hosted.impl.describe().parts.map((p) => `${hosted.impl.id}\0${p.id}`)) : void 0;
|
|
27635
27708
|
let best = null;
|
|
27636
27709
|
for (const origin of sweepOrigins(box5, d, options2.spacing ?? 0.2)) {
|
|
27637
|
-
const r = raycastInternal(origin, d,
|
|
27710
|
+
const r = raycastInternal(origin, d, distance4 + SWEEP_BACK, ignore);
|
|
27638
27711
|
if (!r || best && r.distance >= best.distance) continue;
|
|
27639
27712
|
best = { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: Math.max(0, r.distance - SWEEP_BACK) };
|
|
27640
27713
|
}
|
|
@@ -37707,7 +37780,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37707
37780
|
house.updateMatrixWorld();
|
|
37708
37781
|
return house.localToWorld(localCenter.clone());
|
|
37709
37782
|
};
|
|
37710
|
-
const
|
|
37783
|
+
const distance4 = (focus) => center().distanceTo(focus instanceof THREE.Vector3 ? focus : new THREE.Vector3(focus.x, focus.y, focus.z));
|
|
37711
37784
|
markGroups(r, root, parts);
|
|
37712
37785
|
const structure = assembleStructure(r0, root), destruction = createHouseDestruction(root, house, structure, parts, colliders, water);
|
|
37713
37786
|
h.destruction = destruction;
|
|
@@ -37803,7 +37876,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37803
37876
|
shared3.vegMaterials.setActors(focus ? [{ x: focus.x, y: focus.y, z: focus.z, radius: 0.9 }] : []);
|
|
37804
37877
|
}
|
|
37805
37878
|
if (focus && cfg.lod !== false) {
|
|
37806
|
-
const L = Object.assign({ interior: 45, hide: 220 }, cfg.lod), d =
|
|
37879
|
+
const L = Object.assign({ interior: 45, hide: 220 }, cfg.lod), d = distance4(focus), at4 = h.lodCurrent;
|
|
37807
37880
|
let n = d > L.hide ? 2 : d > L.interior ? 1 : 0;
|
|
37808
37881
|
if (n < at4) n = d < (at4 === 2 ? L.hide : L.interior) * 0.92 ? n : at4;
|
|
37809
37882
|
applyLod(Math.max(n, h.lodMin));
|
|
@@ -37873,7 +37946,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37873
37946
|
return h.lodCurrent;
|
|
37874
37947
|
},
|
|
37875
37948
|
center,
|
|
37876
|
-
distance:
|
|
37949
|
+
distance: distance4,
|
|
37877
37950
|
// damage: the game calls it when a shot/fire hits a part; the SDK subtracts hp and notifies cfg.onDamage(part, point, type). Draws no damage (stage 3).
|
|
37878
37951
|
damage: fire,
|
|
37879
37952
|
colliderDamage,
|
|
@@ -46481,7 +46554,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46481
46554
|
return { id: options.id, samples };
|
|
46482
46555
|
}
|
|
46483
46556
|
|
|
46484
|
-
// ../game-audio/dist/chunk-
|
|
46557
|
+
// ../game-audio/dist/chunk-LZDF5XMZ.js
|
|
46485
46558
|
var DISTANCE_CURVES = {
|
|
46486
46559
|
/** The game's `sfx`: `vol / (1 + d² × 0.004)`, cutoff `/ (1 + d × 0.01)`, silent below 0.01 (jogo L62091–62092, L62101). */
|
|
46487
46560
|
game_sfx: { model: "inverse_square", k: 4e-3, cutoffK: 0.01, minGain: 0.01 },
|
|
@@ -46496,22 +46569,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46496
46569
|
/** The game's animal calls: `max(0, 1 − d / 70) × 0.25`, silent at or below 0.005 (jogo L66627–66628). */
|
|
46497
46570
|
animals: { model: "linear", range: 70, scale: 0.25, minGain: 5e-3 }
|
|
46498
46571
|
};
|
|
46499
|
-
function falloffGain(falloff, volume,
|
|
46572
|
+
function falloffGain(falloff, volume, distance22) {
|
|
46500
46573
|
if (!falloff || falloff.model === "none") return volume;
|
|
46501
46574
|
if (falloff.model === "linear") {
|
|
46502
|
-
const level2 = Math.max(0, 1 -
|
|
46575
|
+
const level2 = Math.max(0, 1 - distance22 / falloff.range) * volume;
|
|
46503
46576
|
return falloff.scale === void 0 ? level2 : level2 * falloff.scale;
|
|
46504
46577
|
}
|
|
46505
|
-
const level = volume / (1 +
|
|
46578
|
+
const level = volume / (1 + distance22 * distance22 * falloff.k);
|
|
46506
46579
|
return falloff.scale === void 0 ? level : falloff.scale * level;
|
|
46507
46580
|
}
|
|
46508
46581
|
function isSilent(falloff, gain) {
|
|
46509
46582
|
if (!falloff || falloff.model === "none" || falloff.minGain === void 0) return false;
|
|
46510
46583
|
return falloff.model === "linear" ? gain <= falloff.minGain : gain < falloff.minGain;
|
|
46511
46584
|
}
|
|
46512
|
-
function cutoffDivisor(falloff,
|
|
46585
|
+
function cutoffDivisor(falloff, distance22) {
|
|
46513
46586
|
if (!falloff || falloff.model !== "inverse_square" || falloff.cutoffK === void 0) return 1;
|
|
46514
|
-
return 1 +
|
|
46587
|
+
return 1 + distance22 * falloff.cutoffK;
|
|
46515
46588
|
}
|
|
46516
46589
|
var game_sfx_default = {
|
|
46517
46590
|
sources: ["jogo:L62089-62107"],
|
|
@@ -46875,8 +46948,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46875
46948
|
const rightZ = -Math.sin(listener.yaw);
|
|
46876
46949
|
const dx = position[0] - listener.position[0];
|
|
46877
46950
|
const dz = position[2] - listener.position[2];
|
|
46878
|
-
const
|
|
46879
|
-
const pan = (dx * rightX + dz * rightZ) / Math.max(
|
|
46951
|
+
const distance22 = Math.hypot(dx, dz) || 1;
|
|
46952
|
+
const pan = (dx * rightX + dz * rightZ) / Math.max(distance22, PAN_MIN_DISTANCE);
|
|
46880
46953
|
return pan < -PAN_LIMIT ? -PAN_LIMIT : pan > PAN_LIMIT ? PAN_LIMIT : pan;
|
|
46881
46954
|
}
|
|
46882
46955
|
var FNV_OFFSET = 2166136261;
|
|
@@ -47061,10 +47134,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47061
47134
|
var layerEnd = (layer3) => layer3.at + layer3.duration + layer3.tail;
|
|
47062
47135
|
function planSound(recipe2, input = {}) {
|
|
47063
47136
|
const listener = input.listener ?? DEFAULT_LISTENER;
|
|
47064
|
-
const
|
|
47137
|
+
const distance22 = input.distance ?? (input.position ? listenerDistance(listener, input.position, input.distanceMode) : 0);
|
|
47065
47138
|
const occlusion = Math.min(1, Math.max(0, input.occlusion ?? 0));
|
|
47066
47139
|
const order = recipe2.order ?? "layered";
|
|
47067
|
-
const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1,
|
|
47140
|
+
const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1, distance22);
|
|
47068
47141
|
const level = occlusion > 0 ? falloffLevel * (1 - OCCLUSION_GAIN * occlusion) : falloffLevel;
|
|
47069
47142
|
const silent = isSilent(recipe2.falloff, falloffLevel);
|
|
47070
47143
|
const base = {
|
|
@@ -47074,7 +47147,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47074
47147
|
...recipe2.group === void 0 ? {} : { group: recipe2.group },
|
|
47075
47148
|
priority: recipe2.priority ?? busPriority(recipe2.bus),
|
|
47076
47149
|
level,
|
|
47077
|
-
distance:
|
|
47150
|
+
distance: distance22,
|
|
47078
47151
|
...recipe2.pan ? { pan: input.position ? panFor(listener, input.position) : 0 } : {}
|
|
47079
47152
|
};
|
|
47080
47153
|
if (silent) return recipe2.keepSilent ? { ...base, silent: true, length: 0, layers: [] } : null;
|
|
@@ -47085,7 +47158,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47085
47158
|
...recipe2.tail === void 0 ? {} : { tail: recipe2.tail },
|
|
47086
47159
|
noiseSeconds: input.noiseSeconds ?? DEFAULT_NOISE_SECONDS
|
|
47087
47160
|
};
|
|
47088
|
-
const divisor = cutoffDivisor(recipe2.falloff,
|
|
47161
|
+
const divisor = cutoffDivisor(recipe2.falloff, distance22) / (1 - OCCLUSION_CUTOFF * occlusion);
|
|
47089
47162
|
const layers = recipe2.layers.flatMap((layer3) => planLayer(layer3, scope2, defaults, order !== "layered", level)).map((layer3) => muffle(layer3, divisor));
|
|
47090
47163
|
return { ...base, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
|
|
47091
47164
|
}
|
|
@@ -47188,6 +47261,255 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47188
47261
|
function unlockContext(context) {
|
|
47189
47262
|
if (context.state === "suspended" && typeof context.close === "function") void context.resume();
|
|
47190
47263
|
}
|
|
47264
|
+
var TRANSMISSION_LOSS = {
|
|
47265
|
+
open: { lossDb: 0, thickness: 1 },
|
|
47266
|
+
brick: { lossDb: 42, thickness: 0.12 },
|
|
47267
|
+
concrete: { lossDb: 48, thickness: 0.1 },
|
|
47268
|
+
stone: { lossDb: 52, thickness: 0.2 },
|
|
47269
|
+
mortar: { lossDb: 32, thickness: 0.02 },
|
|
47270
|
+
plaster: { lossDb: 30, thickness: 0.05 },
|
|
47271
|
+
drywall: { lossDb: 33, thickness: 0.1 },
|
|
47272
|
+
ceramic: { lossDb: 32, thickness: 0.01 },
|
|
47273
|
+
soil: { lossDb: 55, thickness: 0.5 },
|
|
47274
|
+
wood_soft: { lossDb: 22, thickness: 0.04 },
|
|
47275
|
+
wood_hard: { lossDb: 24, thickness: 0.04 },
|
|
47276
|
+
plywood: { lossDb: 20, thickness: 0.018 },
|
|
47277
|
+
mdf: { lossDb: 21, thickness: 0.018 },
|
|
47278
|
+
glass: { lossDb: 27, thickness: 4e-3 },
|
|
47279
|
+
tempered_glass: { lossDb: 30, thickness: 6e-3 },
|
|
47280
|
+
steel: { lossDb: 28, thickness: 2e-3 },
|
|
47281
|
+
cast_iron: { lossDb: 42, thickness: 0.01 },
|
|
47282
|
+
aluminium: { lossDb: 24, thickness: 2e-3 },
|
|
47283
|
+
copper: { lossDb: 28, thickness: 2e-3 },
|
|
47284
|
+
plastic: { lossDb: 12, thickness: 3e-3 },
|
|
47285
|
+
rubber: { lossDb: 15, thickness: 5e-3 },
|
|
47286
|
+
leather: { lossDb: 5, thickness: 3e-3 },
|
|
47287
|
+
fabric: { lossDb: 3, thickness: 5e-3 },
|
|
47288
|
+
paper: { lossDb: 1, thickness: 1e-3 },
|
|
47289
|
+
foam: { lossDb: 4, thickness: 0.05 },
|
|
47290
|
+
foliage: { lossDb: 6, thickness: 0.5 },
|
|
47291
|
+
// mass-law estimates from the density of each (a wall of kg/m² the brick's or the concrete's, less the porosity of the soft ones)
|
|
47292
|
+
green_wood: { lossDb: 18, thickness: 0.05 },
|
|
47293
|
+
cactus: { lossDb: 8, thickness: 0.2 },
|
|
47294
|
+
flesh_fruit: { lossDb: 6, thickness: 0.1 },
|
|
47295
|
+
wax: { lossDb: 6, thickness: 0.01 },
|
|
47296
|
+
asphalt: { lossDb: 45, thickness: 0.1 },
|
|
47297
|
+
sand: { lossDb: 50, thickness: 0.3 },
|
|
47298
|
+
gravel: { lossDb: 48, thickness: 0.3 },
|
|
47299
|
+
turf: { lossDb: 25, thickness: 0.1 },
|
|
47300
|
+
mud: { lossDb: 48, thickness: 0.2 },
|
|
47301
|
+
clay: { lossDb: 50, thickness: 0.2 },
|
|
47302
|
+
snow: { lossDb: 30, thickness: 0.3 },
|
|
47303
|
+
cobble: { lossDb: 46, thickness: 0.1 },
|
|
47304
|
+
paver: { lossDb: 43, thickness: 0.06 }
|
|
47305
|
+
};
|
|
47306
|
+
var OCCLUSION_DEFAULTS = {
|
|
47307
|
+
unknownLossDb: 30,
|
|
47308
|
+
maxLossDb: 50,
|
|
47309
|
+
openCutoff: 2e4,
|
|
47310
|
+
minCutoff: 250,
|
|
47311
|
+
cutoffDbPerDecade: 30,
|
|
47312
|
+
interval: 0.15,
|
|
47313
|
+
budget: 3,
|
|
47314
|
+
smoothing: 0.08,
|
|
47315
|
+
audibleLevel: 2e-3
|
|
47316
|
+
};
|
|
47317
|
+
var MASS_LAW_DB_PER_DOUBLING = 6.02;
|
|
47318
|
+
function hitLossDb(hit, setup = {}) {
|
|
47319
|
+
if (hit.lossDb !== void 0) return Math.max(0, hit.lossDb);
|
|
47320
|
+
const entry2 = hit.material === void 0 ? void 0 : setup.materials?.[hit.material] ?? TRANSMISSION_LOSS[hit.material];
|
|
47321
|
+
if (!entry2) return Math.max(0, setup.unknownLossDb ?? OCCLUSION_DEFAULTS.unknownLossDb);
|
|
47322
|
+
if (hit.thickness === void 0 || entry2.thickness <= 0) return entry2.lossDb;
|
|
47323
|
+
if (hit.thickness <= 0) return 0;
|
|
47324
|
+
return Math.max(0, entry2.lossDb + MASS_LAW_DB_PER_DOUBLING * Math.log2(hit.thickness / entry2.thickness));
|
|
47325
|
+
}
|
|
47326
|
+
function totalLossDb(hits, setup = {}) {
|
|
47327
|
+
let total = 0;
|
|
47328
|
+
for (const hit of hits) total += hitLossDb(hit, setup);
|
|
47329
|
+
return Math.min(total, setup.maxLossDb ?? OCCLUSION_DEFAULTS.maxLossDb);
|
|
47330
|
+
}
|
|
47331
|
+
function occlusionState(lossDb, setup = {}) {
|
|
47332
|
+
const open = setup.openCutoff ?? OCCLUSION_DEFAULTS.openCutoff;
|
|
47333
|
+
const floor2 = Math.min(open, setup.minCutoff ?? OCCLUSION_DEFAULTS.minCutoff);
|
|
47334
|
+
const perDecade = setup.cutoffDbPerDecade ?? OCCLUSION_DEFAULTS.cutoffDbPerDecade;
|
|
47335
|
+
const loss = Math.max(0, lossDb);
|
|
47336
|
+
return { lossDb: loss, gain: 10 ** (-loss / 20), cutoff: Math.max(floor2, open / 10 ** (loss / perDecade)) };
|
|
47337
|
+
}
|
|
47338
|
+
var NEIGHBOUR_RADIUS = 2;
|
|
47339
|
+
var REMEMBERED = 64;
|
|
47340
|
+
var MOVED = 0.05;
|
|
47341
|
+
var CHANGED_DB = 0.5;
|
|
47342
|
+
var distance3 = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
47343
|
+
var copy = (point) => [point[0], point[1], point[2]];
|
|
47344
|
+
var keyOf = (point) => point.map((value) => Math.round(value * 4)).join(",");
|
|
47345
|
+
function createOcclusionTracker(setup) {
|
|
47346
|
+
const entries2 = /* @__PURE__ */ new Map();
|
|
47347
|
+
let served = 0;
|
|
47348
|
+
let spent = 0;
|
|
47349
|
+
const remembered = /* @__PURE__ */ new Map();
|
|
47350
|
+
const interval = setup.interval ?? OCCLUSION_DEFAULTS.interval;
|
|
47351
|
+
const budget = Math.max(1, setup.budget ?? OCCLUSION_DEFAULTS.budget);
|
|
47352
|
+
const audibleLevel = setup.audibleLevel ?? OCCLUSION_DEFAULTS.audibleLevel;
|
|
47353
|
+
const measure = (source, listener) => {
|
|
47354
|
+
const state = occlusionState(totalLossDb(setup.query(source, listener), setup), setup);
|
|
47355
|
+
const key2 = keyOf(source);
|
|
47356
|
+
remembered.delete(key2);
|
|
47357
|
+
remembered.set(key2, state);
|
|
47358
|
+
if (remembered.size > REMEMBERED) remembered.delete(remembered.keys().next().value);
|
|
47359
|
+
return state;
|
|
47360
|
+
};
|
|
47361
|
+
const guess = (source) => {
|
|
47362
|
+
let nearest;
|
|
47363
|
+
let nearestDistance = NEIGHBOUR_RADIUS;
|
|
47364
|
+
for (const voice2 of entries2.values()) {
|
|
47365
|
+
if (voice2.pending) continue;
|
|
47366
|
+
const apart = distance3(voice2.source, source);
|
|
47367
|
+
if (apart <= nearestDistance) [nearest, nearestDistance] = [voice2, apart];
|
|
47368
|
+
}
|
|
47369
|
+
return nearest?.state ?? remembered.get(keyOf(source)) ?? occlusionState(0, setup);
|
|
47370
|
+
};
|
|
47371
|
+
return {
|
|
47372
|
+
add({ id, source, level, listener, now }) {
|
|
47373
|
+
const from = copy(source);
|
|
47374
|
+
const at4 = copy(listener);
|
|
47375
|
+
if (spent >= budget) {
|
|
47376
|
+
const provisional = guess(from);
|
|
47377
|
+
entries2.set(id, { source: from, level, state: provisional, pending: true, checkedAt: now, checkedFrom: at4, served: served++ });
|
|
47378
|
+
return provisional;
|
|
47379
|
+
}
|
|
47380
|
+
spent++;
|
|
47381
|
+
const state = measure(from, at4);
|
|
47382
|
+
entries2.set(id, { source: from, level, state, pending: false, checkedAt: now, checkedFrom: at4, served: served++ });
|
|
47383
|
+
return state;
|
|
47384
|
+
},
|
|
47385
|
+
remove: (id) => void entries2.delete(id),
|
|
47386
|
+
has: (id) => entries2.has(id),
|
|
47387
|
+
state: (id) => entries2.get(id)?.state,
|
|
47388
|
+
update(listener, now) {
|
|
47389
|
+
spent = 0;
|
|
47390
|
+
const at4 = copy(listener);
|
|
47391
|
+
const changes = [];
|
|
47392
|
+
let queries = 0;
|
|
47393
|
+
for (const [id, voice2] of entries2) {
|
|
47394
|
+
if (!voice2.pending || queries >= budget) continue;
|
|
47395
|
+
queries++;
|
|
47396
|
+
const state = measure(voice2.source, at4);
|
|
47397
|
+
voice2.pending = false;
|
|
47398
|
+
voice2.checkedAt = now;
|
|
47399
|
+
voice2.checkedFrom = at4;
|
|
47400
|
+
voice2.served = served++;
|
|
47401
|
+
if (Math.abs(state.lossDb - voice2.state.lossDb) < CHANGED_DB) continue;
|
|
47402
|
+
voice2.state = state;
|
|
47403
|
+
changes.push({ id, state });
|
|
47404
|
+
}
|
|
47405
|
+
const due = [];
|
|
47406
|
+
for (const entry2 of entries2) {
|
|
47407
|
+
const [, voice2] = entry2;
|
|
47408
|
+
if (voice2.pending || now - voice2.checkedAt < interval || voice2.level < audibleLevel) continue;
|
|
47409
|
+
due.push(entry2);
|
|
47410
|
+
}
|
|
47411
|
+
due.sort((a, b) => a[1].checkedAt - b[1].checkedAt || a[1].served - b[1].served);
|
|
47412
|
+
for (const [id, voice2] of due) {
|
|
47413
|
+
if (distance3(voice2.checkedFrom, at4) < MOVED) {
|
|
47414
|
+
voice2.checkedAt = now;
|
|
47415
|
+
continue;
|
|
47416
|
+
}
|
|
47417
|
+
if (queries >= budget) break;
|
|
47418
|
+
queries++;
|
|
47419
|
+
const state = measure(voice2.source, at4);
|
|
47420
|
+
voice2.checkedAt = now;
|
|
47421
|
+
voice2.checkedFrom = at4;
|
|
47422
|
+
voice2.served = served++;
|
|
47423
|
+
if (Math.abs(state.lossDb - voice2.state.lossDb) < CHANGED_DB) continue;
|
|
47424
|
+
voice2.state = state;
|
|
47425
|
+
changes.push({ id, state });
|
|
47426
|
+
}
|
|
47427
|
+
return changes;
|
|
47428
|
+
},
|
|
47429
|
+
get size() {
|
|
47430
|
+
return entries2.size;
|
|
47431
|
+
}
|
|
47432
|
+
};
|
|
47433
|
+
}
|
|
47434
|
+
var RELEASE_GRACE = 0.1;
|
|
47435
|
+
function createEngineOcclusion(setup, context) {
|
|
47436
|
+
const tracker = createOcclusionTracker(setup);
|
|
47437
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
47438
|
+
const smoothing = Math.max(5e-3, setup.smoothing ?? OCCLUSION_DEFAULTS.smoothing);
|
|
47439
|
+
const pairTo = (audio, destination, state) => {
|
|
47440
|
+
const filter = audio.createBiquadFilter();
|
|
47441
|
+
filter.type = "lowpass";
|
|
47442
|
+
filter.frequency.value = state.cutoff;
|
|
47443
|
+
const gain = audio.createGain();
|
|
47444
|
+
gain.gain.value = state.gain;
|
|
47445
|
+
filter.connect(gain);
|
|
47446
|
+
gain.connect(destination);
|
|
47447
|
+
return { filter, gain };
|
|
47448
|
+
};
|
|
47449
|
+
const move2 = (param2, value, now) => {
|
|
47450
|
+
param2.cancelScheduledValues(now);
|
|
47451
|
+
param2.setValueAtTime(param2.value, now);
|
|
47452
|
+
param2.setTargetAtTime(value, now, smoothing / 3);
|
|
47453
|
+
};
|
|
47454
|
+
const apply = (pair, state, now) => {
|
|
47455
|
+
move2(pair.gain.gain, state.gain, now);
|
|
47456
|
+
move2(pair.filter.frequency, state.cutoff, now);
|
|
47457
|
+
};
|
|
47458
|
+
const drop = (id) => {
|
|
47459
|
+
const voice2 = nodes.get(id);
|
|
47460
|
+
if (!voice2) return;
|
|
47461
|
+
for (const pair of [voice2.dry, voice2.wet]) {
|
|
47462
|
+
pair?.filter.disconnect();
|
|
47463
|
+
pair?.gain.disconnect();
|
|
47464
|
+
}
|
|
47465
|
+
nodes.delete(id);
|
|
47466
|
+
};
|
|
47467
|
+
const prune = (alive) => {
|
|
47468
|
+
const now = context()?.currentTime ?? 0;
|
|
47469
|
+
for (const [id, voice2] of [...nodes]) {
|
|
47470
|
+
if (voice2.releasedAt === void 0) {
|
|
47471
|
+
if (alive(id)) continue;
|
|
47472
|
+
voice2.releasedAt = now;
|
|
47473
|
+
tracker.remove(id);
|
|
47474
|
+
} else if (now - voice2.releasedAt > RELEASE_GRACE) drop(id);
|
|
47475
|
+
}
|
|
47476
|
+
};
|
|
47477
|
+
return {
|
|
47478
|
+
attach({ id, source, level, listener }, destination, wet) {
|
|
47479
|
+
const audio = context();
|
|
47480
|
+
const state = tracker.add({ id, source, level, listener, now: audio.currentTime });
|
|
47481
|
+
const dry = pairTo(audio, destination, state);
|
|
47482
|
+
const wetPair = wet ? pairTo(audio, wet, state) : void 0;
|
|
47483
|
+
nodes.set(id, { dry, ...wetPair ? { wet: wetPair } : {} });
|
|
47484
|
+
return { input: dry.filter, ...wetPair ? { wet: wetPair.filter } : {} };
|
|
47485
|
+
},
|
|
47486
|
+
update(listener, alive) {
|
|
47487
|
+
const audio = context();
|
|
47488
|
+
if (!audio) return;
|
|
47489
|
+
prune(alive);
|
|
47490
|
+
const now = audio.currentTime;
|
|
47491
|
+
for (const { id, state } of tracker.update(listener, now)) {
|
|
47492
|
+
const voice2 = nodes.get(id);
|
|
47493
|
+
if (!voice2) continue;
|
|
47494
|
+
apply(voice2.dry, state, now);
|
|
47495
|
+
if (voice2.wet) apply(voice2.wet, state, now);
|
|
47496
|
+
}
|
|
47497
|
+
},
|
|
47498
|
+
prune,
|
|
47499
|
+
voices() {
|
|
47500
|
+
return [...nodes].flatMap(([id, voice2]) => {
|
|
47501
|
+
const state = voice2.releasedAt === void 0 ? tracker.state(id) : void 0;
|
|
47502
|
+
return state ? [{ id, lossDb: state.lossDb, gain: state.gain, cutoff: state.cutoff }] : [];
|
|
47503
|
+
});
|
|
47504
|
+
},
|
|
47505
|
+
clear() {
|
|
47506
|
+
for (const id of [...nodes.keys()]) {
|
|
47507
|
+
tracker.remove(id);
|
|
47508
|
+
drop(id);
|
|
47509
|
+
}
|
|
47510
|
+
}
|
|
47511
|
+
};
|
|
47512
|
+
}
|
|
47191
47513
|
var LOOP_START_ABOVE = 2e-3;
|
|
47192
47514
|
var LOOP_SMOOTHING = { volume: 0.15, frequency: 0.08 };
|
|
47193
47515
|
function createLoopState(recipe2, open = false) {
|
|
@@ -47402,11 +47724,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47402
47724
|
if (!action) return;
|
|
47403
47725
|
nodes ?? (nodes = create4(context, 0));
|
|
47404
47726
|
const listener = placed && position ? host.listener?.() : void 0;
|
|
47405
|
-
const
|
|
47406
|
-
const level = listener ? falloffGain(loopRecipe.falloff, action.volume,
|
|
47727
|
+
const distance22 = listener && position ? listenerDistance(listener, position, host.distance) : 0;
|
|
47728
|
+
const level = listener ? falloffGain(loopRecipe.falloff, action.volume, distance22) : action.volume;
|
|
47407
47729
|
nodes.gain.gain.setTargetAtTime(level, context.currentTime, smoothing.volume);
|
|
47408
47730
|
if (action.frequency !== void 0 && nodes.frequency) nodes.frequency.setTargetAtTime(action.frequency, context.currentTime, smoothing.frequency);
|
|
47409
|
-
if (cutoff !== void 0 && nodes.cutoff) nodes.cutoff.setTargetAtTime(cutoff / cutoffDivisor(loopRecipe.falloff,
|
|
47731
|
+
if (cutoff !== void 0 && nodes.cutoff) nodes.cutoff.setTargetAtTime(cutoff / cutoffDivisor(loopRecipe.falloff, distance22), context.currentTime, smoothing.frequency);
|
|
47410
47732
|
if (listener && position && nodes.panner) nodes.panner.pan.setTargetAtTime(panFor(listener, position), context.currentTime, smoothing.frequency);
|
|
47411
47733
|
},
|
|
47412
47734
|
stop: entry2.stop
|
|
@@ -47425,16 +47747,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47425
47747
|
const drawn = Math.min(count - 2, Math.floor(random() * (count - 1)));
|
|
47426
47748
|
return drawn >= last ? drawn + 1 : drawn;
|
|
47427
47749
|
}
|
|
47428
|
-
function farMixAt(crossover,
|
|
47429
|
-
if (crossover.to <= crossover.from) return
|
|
47430
|
-
const t = (
|
|
47750
|
+
function farMixAt(crossover, distance22) {
|
|
47751
|
+
if (crossover.to <= crossover.from) return distance22 >= crossover.to ? 1 : 0;
|
|
47752
|
+
const t = (distance22 - crossover.from) / (crossover.to - crossover.from);
|
|
47431
47753
|
return t <= 0 ? 0 : t >= 1 ? 1 : t;
|
|
47432
47754
|
}
|
|
47433
47755
|
function crossGains(farMix) {
|
|
47434
47756
|
return { close: Math.cos(farMix * Math.PI / 2), far: Math.sin(farMix * Math.PI / 2) };
|
|
47435
47757
|
}
|
|
47436
|
-
function sampleCutoff(cutoffK,
|
|
47437
|
-
const byDistance = cutoffK > 0 ? OPEN_CUTOFF / (1 +
|
|
47758
|
+
function sampleCutoff(cutoffK, distance22, occlusion = 0) {
|
|
47759
|
+
const byDistance = cutoffK > 0 ? OPEN_CUTOFF / (1 + distance22 * cutoffK) : OPEN_CUTOFF;
|
|
47438
47760
|
const occluded = occlusion > 0 ? byDistance / (1 + occlusion * 9) : byDistance;
|
|
47439
47761
|
return Math.max(80, Math.min(OPEN_CUTOFF, occluded));
|
|
47440
47762
|
}
|
|
@@ -47452,10 +47774,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47452
47774
|
function planSample(sound3, input) {
|
|
47453
47775
|
if (sound3.close.length === 0) throw new Error(`sample sound ${sound3.id} has no close take`);
|
|
47454
47776
|
const listener = input.listener ?? DEFAULT_LISTENER;
|
|
47455
|
-
const
|
|
47777
|
+
const distance22 = input.distance ?? (input.position ? listenerDistance(listener, input.position, input.distanceMode) : 0);
|
|
47456
47778
|
const falloff = sound3.falloff ?? DEFAULT_SAMPLE_FALLOFF;
|
|
47457
47779
|
const occlusion = Math.max(0, Math.min(1, input.occlusion ?? 0));
|
|
47458
|
-
const level = falloffGain(falloff, (input.volume ?? 1) * (sound3.gain ?? 1),
|
|
47780
|
+
const level = falloffGain(falloff, (input.volume ?? 1) * (sound3.gain ?? 1), distance22) * (1 - 0.45 * occlusion);
|
|
47459
47781
|
if (isSilent(falloff, level) || level <= 0) return null;
|
|
47460
47782
|
const pitch = sound3.pitch ?? DEFAULT_SAMPLE_PITCH;
|
|
47461
47783
|
const rate = pitch > 0 ? 1 + (input.random() * 2 - 1) * pitch : 1;
|
|
@@ -47463,7 +47785,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47463
47785
|
const tier = tierFor(sound3, input.intensity);
|
|
47464
47786
|
const close = tier?.close.length ? tier.close : sound3.close;
|
|
47465
47787
|
const far = tier?.far?.length ? tier.far : sound3.far ?? [];
|
|
47466
|
-
const farMix = far.length > 0 ? farMixAt(sound3.crossover ?? DEFAULT_CROSSOVER,
|
|
47788
|
+
const farMix = far.length > 0 ? farMixAt(sound3.crossover ?? DEFAULT_CROSSOVER, distance22) : 0;
|
|
47467
47789
|
const gains = crossGains(farMix);
|
|
47468
47790
|
const layers = [];
|
|
47469
47791
|
const take = (role, refs, gain, at4) => {
|
|
@@ -47493,9 +47815,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47493
47815
|
id: sound3.id,
|
|
47494
47816
|
bus: sound3.bus,
|
|
47495
47817
|
level,
|
|
47496
|
-
distance:
|
|
47818
|
+
distance: distance22,
|
|
47497
47819
|
...pan === void 0 ? {} : { pan },
|
|
47498
|
-
cutoff: sampleCutoff(sound3.cutoffK ?? DEFAULT_SAMPLE_CUTOFF_K,
|
|
47820
|
+
cutoff: sampleCutoff(sound3.cutoffK ?? DEFAULT_SAMPLE_CUTOFF_K, distance22, occlusion),
|
|
47499
47821
|
rate,
|
|
47500
47822
|
environment,
|
|
47501
47823
|
...tier ? { tier: tier.name } : {},
|
|
@@ -48390,6 +48712,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48390
48712
|
chokes.set(id, list2);
|
|
48391
48713
|
return list2;
|
|
48392
48714
|
};
|
|
48715
|
+
const occlusionSetup = typeof options.occlusion === "object" ? options.occlusion : void 0;
|
|
48716
|
+
const pointOcclusion = typeof options.occlusion === "function" ? options.occlusion : void 0;
|
|
48717
|
+
const occluders = occlusionSetup ? createEngineOcclusion(occlusionSetup, () => context) : null;
|
|
48718
|
+
const routed = (id, position, level, destination, wet) => {
|
|
48719
|
+
if (!occluders || id === void 0 || !position) return void 0;
|
|
48720
|
+
return occluders.attach({ id, source: position, level, listener: listener.position }, destination, wet);
|
|
48721
|
+
};
|
|
48722
|
+
const sampleRoute = (voiceId, sample, playOptions, level, bus) => {
|
|
48723
|
+
const at4 = playOptions.occlusion === void 0 && sample.falloff?.model !== "none" ? playOptions.position : void 0;
|
|
48724
|
+
return routed(voiceId, at4, level, sampleOutput(bus))?.input ?? sampleOutput(bus);
|
|
48725
|
+
};
|
|
48393
48726
|
const watchers = /* @__PURE__ */ new Set();
|
|
48394
48727
|
const announce = (event) => {
|
|
48395
48728
|
options.onVoiceStart?.(event);
|
|
@@ -48446,6 +48779,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48446
48779
|
const elapsed = context.currentTime - lastTime;
|
|
48447
48780
|
lastTime = context.currentTime;
|
|
48448
48781
|
if (elapsed > 0) for (const id of voices.advance(elapsed)) active.delete(id);
|
|
48782
|
+
occluders?.prune((id) => active.has(id));
|
|
48449
48783
|
};
|
|
48450
48784
|
const inputFor = (recipe2, playOptions, random) => ({
|
|
48451
48785
|
random,
|
|
@@ -48456,16 +48790,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48456
48790
|
...playOptions.distance === void 0 ? {} : { distance: playOptions.distance },
|
|
48457
48791
|
...playOptions.position ? { position: playOptions.position } : {},
|
|
48458
48792
|
...playOptions.params ? { params: playOptions.params } : {},
|
|
48459
|
-
...
|
|
48793
|
+
...pointOcclusion && playOptions.position && recipe2.falloff?.model !== "none" ? { occlusion: pointOcclusion(playOptions.position) } : {}
|
|
48460
48794
|
});
|
|
48461
48795
|
const startQueue = options.deferredStart ? createStartQueue(options.deferredStart) : null;
|
|
48462
|
-
const build = (plan, store, delay, requestedAt, fallbackOf) => {
|
|
48796
|
+
const build = (plan, store, delay, requestedAt, fallbackOf, route) => {
|
|
48463
48797
|
const audio = context;
|
|
48464
48798
|
const time = audio.currentTime + delay;
|
|
48465
48799
|
const realized = realize(plan, {
|
|
48466
48800
|
context: audio,
|
|
48467
|
-
output: outputFor(plan.bus),
|
|
48468
|
-
...chain?.wet ? { wet: chain
|
|
48801
|
+
output: route?.input ?? outputFor(plan.bus),
|
|
48802
|
+
...route?.wet ?? chain?.wet ? { wet: route?.wet ?? chain?.wet } : {},
|
|
48469
48803
|
noise: () => noiseBuffer(store, audio, mix3.noise.seconds),
|
|
48470
48804
|
time
|
|
48471
48805
|
});
|
|
@@ -48484,7 +48818,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48484
48818
|
});
|
|
48485
48819
|
return realized;
|
|
48486
48820
|
};
|
|
48487
|
-
const deferVoice = (plan, store, voiceId, delay, fallbackOf) => {
|
|
48821
|
+
const deferVoice = (plan, store, voiceId, delay, fallbackOf, route) => {
|
|
48488
48822
|
const requestedAt = context?.currentTime ?? 0;
|
|
48489
48823
|
let built2 = null;
|
|
48490
48824
|
let cancelled = false;
|
|
@@ -48499,7 +48833,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48499
48833
|
};
|
|
48500
48834
|
startQueue.push({
|
|
48501
48835
|
run() {
|
|
48502
|
-
if (!cancelled && context) built2 = build(plan, store, delay, requestedAt, fallbackOf);
|
|
48836
|
+
if (!cancelled && context) built2 = build(plan, store, delay, requestedAt, fallbackOf, route);
|
|
48503
48837
|
},
|
|
48504
48838
|
drop() {
|
|
48505
48839
|
if (voiceId === void 0) return;
|
|
@@ -48509,8 +48843,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48509
48843
|
});
|
|
48510
48844
|
return pending;
|
|
48511
48845
|
};
|
|
48512
|
-
const start = (plan, store, voiceId, delay = 0, fallbackOf, urgent = false) => {
|
|
48513
|
-
const
|
|
48846
|
+
const start = (plan, store, voiceId, delay = 0, fallbackOf, urgent = false, position) => {
|
|
48847
|
+
const route = routed(voiceId, position, plan.level, outputFor(plan.bus), chain?.wet);
|
|
48848
|
+
const realized = startQueue && !urgent ? deferVoice(plan, store, voiceId, delay, fallbackOf, route) : build(plan, store, delay, context?.currentTime ?? 0, fallbackOf, route);
|
|
48514
48849
|
if (voiceId === void 0) return null;
|
|
48515
48850
|
voices.setLength(voiceId, plan.length + delay);
|
|
48516
48851
|
active.set(voiceId, realized);
|
|
@@ -48525,8 +48860,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48525
48860
|
}
|
|
48526
48861
|
};
|
|
48527
48862
|
};
|
|
48528
|
-
const admit = (recipe2, gain,
|
|
48529
|
-
const decision = voices.request({ ...recipe2.group ? { group: recipe2.group } : {}, priority: recipe2.priority ?? busPriority(recipe2.bus), gain, distance:
|
|
48863
|
+
const admit = (recipe2, gain, distance22) => {
|
|
48864
|
+
const decision = voices.request({ ...recipe2.group ? { group: recipe2.group } : {}, priority: recipe2.priority ?? busPriority(recipe2.bus), gain, distance: distance22, length: 0 });
|
|
48530
48865
|
if (!decision.accepted) return null;
|
|
48531
48866
|
for (const id of decision.evicted) {
|
|
48532
48867
|
active.get(id)?.stop();
|
|
@@ -48556,7 +48891,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48556
48891
|
...playOptions.intensity === void 0 ? {} : { intensity: playOptions.intensity },
|
|
48557
48892
|
...playOptions.distance === void 0 ? {} : { distance: playOptions.distance },
|
|
48558
48893
|
...playOptions.position ? { position: playOptions.position } : {},
|
|
48559
|
-
...playOptions.occlusion !== void 0 ? { occlusion: playOptions.occlusion } :
|
|
48894
|
+
...playOptions.occlusion !== void 0 ? { occlusion: playOptions.occlusion } : pointOcclusion && playOptions.position ? { occlusion: pointOcclusion(playOptions.position) } : {}
|
|
48560
48895
|
});
|
|
48561
48896
|
const playSample = (sample, playOptions, random, store) => {
|
|
48562
48897
|
if (busSettings.get(sample.bus)?.muted) return null;
|
|
@@ -48576,7 +48911,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48576
48911
|
const requestedAt = audio.currentTime;
|
|
48577
48912
|
const time = requestedAt + (playOptions.delay ?? 0);
|
|
48578
48913
|
const chokeList = sample.choke ? choked(sample.id) : void 0;
|
|
48579
|
-
const realized = realizeSample(plan, { context: audio, output:
|
|
48914
|
+
const realized = realizeSample(plan, { context: audio, output: sampleRoute(voiceId, sample, playOptions, plan.level, plan.bus), buffer: (url2) => sampleStore.buffer(url2), time });
|
|
48580
48915
|
const sampleBank = registry.bankOf(plan.id);
|
|
48581
48916
|
announce({
|
|
48582
48917
|
id: plan.id,
|
|
@@ -48625,19 +48960,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48625
48960
|
const random = seeded ?? streamRandom;
|
|
48626
48961
|
const recipe2 = registry.sound(id);
|
|
48627
48962
|
if (!recipe2 || busSettings.get(recipe2.bus)?.muted) return null;
|
|
48628
|
-
const
|
|
48629
|
-
const level = falloffGain(recipe2.falloff, playOptions.volume ?? 1,
|
|
48963
|
+
const distance22 = playOptions.distance ?? (playOptions.position ? listenerDistance(listener, playOptions.position, options.distance) : 0);
|
|
48964
|
+
const level = falloffGain(recipe2.falloff, playOptions.volume ?? 1, distance22);
|
|
48630
48965
|
const silent = isSilent(recipe2.falloff, level);
|
|
48631
48966
|
if (silent && !recipe2.keepSilent) return null;
|
|
48632
48967
|
const audio = ready();
|
|
48633
48968
|
if (!audio) return null;
|
|
48634
48969
|
unlockContext(audio);
|
|
48635
48970
|
advance();
|
|
48636
|
-
const voiceId = silent ? void 0 : admit(recipe2, level,
|
|
48971
|
+
const voiceId = silent ? void 0 : admit(recipe2, level, distance22);
|
|
48637
48972
|
if (voiceId === null) return null;
|
|
48638
48973
|
if (!silent && usesNoise(recipe2)) prepareNoise(store, audio, mix3.noise.seconds);
|
|
48639
48974
|
const plan = planSound(recipe2, inputFor(recipe2, playOptions, random));
|
|
48640
|
-
return plan ? start(retunePlan(plan, rate), store, voiceId, playOptions.delay, fallbackOf, playOptions.urgent) : null;
|
|
48975
|
+
return plan ? start(retunePlan(plan, rate), store, voiceId, playOptions.delay, fallbackOf, playOptions.urgent, recipe2.falloff?.model === "none" ? void 0 : playOptions.position) : null;
|
|
48641
48976
|
};
|
|
48642
48977
|
const randomFor = (playOptions) => {
|
|
48643
48978
|
if (playOptions.channel === void 0) return engineRandom;
|
|
@@ -48746,7 +49081,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48746
49081
|
},
|
|
48747
49082
|
setListener(next) {
|
|
48748
49083
|
listener = next;
|
|
49084
|
+
occluders?.update(next.position, (id) => active.has(id));
|
|
48749
49085
|
},
|
|
49086
|
+
occludedVoices: () => occluders?.voices() ?? [],
|
|
48750
49087
|
setBus(id, setting) {
|
|
48751
49088
|
busSettings.set(id, { ...busSettings.get(id), ...setting });
|
|
48752
49089
|
if (!context) return;
|
|
@@ -48808,6 +49145,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48808
49145
|
startQueue?.clear();
|
|
48809
49146
|
for (const id of active.keys()) voices.release(id);
|
|
48810
49147
|
for (const loop of [...loops]) loop.stop();
|
|
49148
|
+
occluders?.clear();
|
|
48811
49149
|
active.clear();
|
|
48812
49150
|
void context?.close();
|
|
48813
49151
|
context = null;
|
|
@@ -50295,9 +50633,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
50295
50633
|
const referenceEnergy = options.referenceEnergy?.[soundClass] ?? CLASS_REFERENCE_ENERGY[soundClass] ?? energyJ;
|
|
50296
50634
|
const k = energyPosition(energyJ, curve);
|
|
50297
50635
|
const referenceK = energyPosition(referenceEnergy, curve);
|
|
50298
|
-
const
|
|
50299
|
-
const attenuation = (input.volume ?? 1) / (1 +
|
|
50300
|
-
const muffling = 1 / (1 +
|
|
50636
|
+
const distance4 = Math.max(0, input.distance ?? 0);
|
|
50637
|
+
const attenuation = (input.volume ?? 1) / (1 + distance4 * distance4 * distanceCurve.gainFalloff);
|
|
50638
|
+
const muffling = 1 / (1 + distance4 * distanceCurve.cutoffFalloff);
|
|
50301
50639
|
const suppressor = input.suppressed ? { ...DEFAULT_SUPPRESSOR, ...options.suppressor } : { gain: 1, cutoff: 1, crack: 1, body: 1 };
|
|
50302
50640
|
const indoors = input.indoors ? { ...DEFAULT_INDOORS, ...options.indoors } : { duration: 1, cutoff: 1 };
|
|
50303
50641
|
const gain = classGain * attenuation * (linear(curve.gain, k) / linear(curve.gain, referenceK)) * suppressor.gain;
|
|
@@ -51084,15 +51422,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
51084
51422
|
const take = Math.max(0, Math.floor(input.take ?? 0)) % GUNSHOT_TAKES;
|
|
51085
51423
|
const jitter = TAKE_JITTER[take] ?? TAKE_JITTER[0];
|
|
51086
51424
|
const pitch = input.pitch ?? 1;
|
|
51087
|
-
const
|
|
51425
|
+
const distance4 = Math.max(0, input.distance ?? 0);
|
|
51088
51426
|
const reference = options.reference ?? 4;
|
|
51089
51427
|
const exponent = options.exponent ?? 0.8;
|
|
51090
|
-
const level = (input.volume ?? 1) * Math.pow(reference / Math.max(
|
|
51091
|
-
const delay =
|
|
51092
|
-
const closeMix = 1 - smoothstep((
|
|
51428
|
+
const level = (input.volume ?? 1) * Math.pow(reference / Math.max(distance4, reference), exponent) * (1 - 0.5 * clamp01(input.occlusion ?? 0));
|
|
51429
|
+
const delay = distance4 / SPEED_OF_SOUND;
|
|
51430
|
+
const closeMix = 1 - smoothstep((distance4 - (options.farFrom ?? 25)) / ((options.farTo ?? 80) - (options.farFrom ?? 25)));
|
|
51093
51431
|
const occlusion = clamp01(input.occlusion ?? 0);
|
|
51094
|
-
const air = (1 - 0.6 * occlusion) / (1 +
|
|
51095
|
-
const highs = Math.exp(-
|
|
51432
|
+
const air = (1 - 0.6 * occlusion) / (1 + distance4 / 250);
|
|
51433
|
+
const highs = Math.exp(-distance4 / 60) * (1 - 0.8 * occlusion);
|
|
51096
51434
|
const space = input.space ?? "outdoor";
|
|
51097
51435
|
const supersonic = (input.caliber?.muzzleSpeed ?? 0) > SUPERSONIC_MS;
|
|
51098
51436
|
const shell = input.caliber?.kind === "slug" ? gunshot_profiles_default.shells.slug : input.caliber?.kind === "birdshot" ? gunshot_profiles_default.shells.birdshot : void 0;
|
|
@@ -51123,7 +51461,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
51123
51461
|
const bodyGain = profile.body.gain * (shell && "bodyGain" in shell ? shell.bodyGain : 1) * (suppressed ? sup.bodyGain : 1);
|
|
51124
51462
|
push({ group: "close", part: "body", at: delay, kind: "tone", frequency: profile.body.from * jitter.body * lower, to: profile.body.to * lower, gain: bodyGain * near * loud, seconds: profile.body.seconds * jitter.seconds * longer });
|
|
51125
51463
|
const mech = gunshot_profiles_default.mech[input.category ?? ""];
|
|
51126
|
-
if (mech && mech.gain > 0 &&
|
|
51464
|
+
if (mech && mech.gain > 0 && distance4 < 15) push({ group: "mech", part: "action", at: delay + mech.at, kind: "noise", filter: "bandpass", frequency: mech.frequency * pitch, q: 3, gain: mech.gain * (suppressed ? sup.mechGain : 1) * near, seconds: 0.05 });
|
|
51127
51465
|
}
|
|
51128
51466
|
const far = level * (1 - closeMix);
|
|
51129
51467
|
if (far > 0) {
|
|
@@ -52101,9 +52439,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52101
52439
|
burst2({ at: at4, seconds: 0.05, gain, filter: "highpass", frequency, q: 2 });
|
|
52102
52440
|
tone({ at: at4, seconds: 0.04, gain: gain * 0.6, frequency: frequency * 0.6, type: "square" });
|
|
52103
52441
|
};
|
|
52104
|
-
const play = (soundClass, classVolume = 1,
|
|
52442
|
+
const play = (soundClass, classVolume = 1, distance4 = 0, at4 = 0) => {
|
|
52105
52443
|
const [cutoff, gain, seconds] = classes[soundClass] ?? FALLBACK_SOUND_CLASS;
|
|
52106
|
-
channel.play(classBurst, { volume: classVolume, distance:
|
|
52444
|
+
channel.play(classBurst, { volume: classVolume, distance: distance4, params: { cutoff, gain, seconds }, ...at4 ? { delay: at4 } : {} });
|
|
52107
52445
|
};
|
|
52108
52446
|
const sceneTone2 = (entry2) => {
|
|
52109
52447
|
channel.play(SCENE_TONE_IDS[entry2.wave], { params: { f: entry2.f, f2: entry2.f2 ?? entry2.f, d: entry2.d, vol: entry2.vol }, ...entry2.at ? { delay: entry2.at } : {} });
|
|
@@ -52217,8 +52555,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52217
52555
|
const id = mechanicalSoundOf(event);
|
|
52218
52556
|
if (id) mechanical(id);
|
|
52219
52557
|
},
|
|
52220
|
-
play(soundClass, classVolume,
|
|
52221
|
-
play(soundClass, classVolume,
|
|
52558
|
+
play(soundClass, classVolume, distance4) {
|
|
52559
|
+
play(soundClass, classVolume, distance4);
|
|
52222
52560
|
},
|
|
52223
52561
|
reloadStart(category) {
|
|
52224
52562
|
metal2(0, 1500, 0.35);
|
|
@@ -52258,8 +52596,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52258
52596
|
}
|
|
52259
52597
|
burst2({ seconds: 0.09, gain: 0.35 * (input.speed === void 0 ? 1 : Math.min(1, Math.max(0.3, input.speed / 2.5))) * ((input.bounce ?? 0) === 0 ? 1 : 0.5), filter: "lowpass", frequency: 380 });
|
|
52260
52598
|
},
|
|
52261
|
-
launch(kind, volume2 = 1,
|
|
52262
|
-
const level = Math.min(1, volume2 / (1 +
|
|
52599
|
+
launch(kind, volume2 = 1, distance4 = 0) {
|
|
52600
|
+
const level = Math.min(1, volume2 / (1 + distance4 / LAUNCH_HALF_AT));
|
|
52263
52601
|
const id = LAUNCH_SOUND_IDS[kind];
|
|
52264
52602
|
if (hostReady(id)) {
|
|
52265
52603
|
channel.play(id, { volume: level });
|
|
@@ -63117,11 +63455,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
63117
63455
|
while (fire.acc >= 1) {
|
|
63118
63456
|
fire.acc -= 1;
|
|
63119
63457
|
const angle = random.next() * Math.PI * 2;
|
|
63120
|
-
const
|
|
63458
|
+
const distance4 = Math.sqrt(random.next()) * radius;
|
|
63121
63459
|
addPuff(core, random, {
|
|
63122
|
-
x: fire.x + Math.cos(angle) *
|
|
63460
|
+
x: fire.x + Math.cos(angle) * distance4,
|
|
63123
63461
|
y: fire.y + 0.05,
|
|
63124
|
-
z: fire.z + Math.sin(angle) *
|
|
63462
|
+
z: fire.z + Math.sin(angle) * distance4,
|
|
63125
63463
|
vx: random.between(-0.2, 0.2),
|
|
63126
63464
|
vy: random.between(0.6, 1.4),
|
|
63127
63465
|
vz: random.between(-0.2, 0.2),
|
|
@@ -64384,8 +64722,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64384
64722
|
const x = positions2[o];
|
|
64385
64723
|
const z = positions2[o + 2];
|
|
64386
64724
|
if (splash && random.next() < SPLASH_CHANCE) {
|
|
64387
|
-
const
|
|
64388
|
-
if (
|
|
64725
|
+
const distance4 = Math.hypot(x - camera2[0], z - camera2[2]);
|
|
64726
|
+
if (distance4 < reach) {
|
|
64389
64727
|
if (random.next() < SPRITE_CHANCE) {
|
|
64390
64728
|
this.engine.spawn("normal", { p: [x, ground + 0.01, z], dir: UP9, cone: 0.6, sp: [0.6, 1.3], life: [0.18, 0.3], size: 0.035, c0: 12110044, a: 0.6, g: 9.8, fi: 0 });
|
|
64391
64729
|
}
|
|
@@ -65269,9 +65607,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
65269
65607
|
let best;
|
|
65270
65608
|
let bestDistance = 9;
|
|
65271
65609
|
for (const block of blocks) {
|
|
65272
|
-
const
|
|
65273
|
-
if (
|
|
65274
|
-
bestDistance =
|
|
65610
|
+
const distance4 = Math.hypot(block.x - x, block.y - y);
|
|
65611
|
+
if (distance4 < bestDistance) {
|
|
65612
|
+
bestDistance = distance4;
|
|
65275
65613
|
best = block;
|
|
65276
65614
|
}
|
|
65277
65615
|
}
|
|
@@ -65639,14 +65977,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
65639
65977
|
if (!walk) return;
|
|
65640
65978
|
const dx = walk.toX - walker.x;
|
|
65641
65979
|
const dz = walk.toZ - walker.z;
|
|
65642
|
-
const
|
|
65643
|
-
if (
|
|
65980
|
+
const distance4 = Math.hypot(dx, dz);
|
|
65981
|
+
if (distance4 <= ARRIVAL_DISTANCE) {
|
|
65644
65982
|
walker.walk = void 0;
|
|
65645
65983
|
return;
|
|
65646
65984
|
}
|
|
65647
|
-
const step = Math.min(
|
|
65648
|
-
walker.x += dx /
|
|
65649
|
-
walker.z += dz /
|
|
65985
|
+
const step = Math.min(distance4, walk.speed * dt);
|
|
65986
|
+
walker.x += dx / distance4 * step;
|
|
65987
|
+
walker.z += dz / distance4 * step;
|
|
65650
65988
|
walker.facing = Math.atan2(dx, dz);
|
|
65651
65989
|
walker.bob = Math.abs(Math.cos(elapsed * walk.speed * STRIDE_FACTOR + phases[index + 1])) * BOB_AMPLITUDE;
|
|
65652
65990
|
});
|
|
@@ -66437,8 +66775,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66437
66775
|
} else pool.glow.intensity = 0;
|
|
66438
66776
|
}
|
|
66439
66777
|
var LOD_GAME = { edges: [15, 40, 80], scales: [1, 0.5, 0.2, 0.1], radiusFactor: 1 };
|
|
66440
|
-
function lodScale(bands,
|
|
66441
|
-
const effective =
|
|
66778
|
+
function lodScale(bands, distance4, visualRadius) {
|
|
66779
|
+
const effective = distance4 - visualRadius * bands.radiusFactor;
|
|
66442
66780
|
if (effective < bands.edges[0]) return bands.scales[0];
|
|
66443
66781
|
if (effective < bands.edges[1]) return bands.scales[1];
|
|
66444
66782
|
if (effective < bands.edges[2]) return bands.scales[2];
|
|
@@ -66495,10 +66833,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66495
66833
|
const count = Math.round(6 + radius * 7);
|
|
66496
66834
|
for (let index = 0; index < count; index++) {
|
|
66497
66835
|
const angle = index / count * Math.PI * 2 + random.between(-0.15, 0.15);
|
|
66498
|
-
const
|
|
66836
|
+
const distance4 = radius * random.between(0.95, 1.3);
|
|
66499
66837
|
const size = random.between(0.12, 0.26) * Math.min(1.6, 0.6 + radius * 0.4);
|
|
66500
|
-
const px = x + Math.cos(angle) *
|
|
66501
|
-
const pz = z + Math.sin(angle) *
|
|
66838
|
+
const px = x + Math.cos(angle) * distance4;
|
|
66839
|
+
const pz = z + Math.sin(angle) * distance4;
|
|
66502
66840
|
const plate3 = random.next() < 0.6;
|
|
66503
66841
|
const color2 = RIM_COLORS[random.next() < 0.5 ? 0 : 1];
|
|
66504
66842
|
const tiltX = random.between(-0.5, 0.5);
|
|
@@ -66583,11 +66921,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66583
66921
|
if (puff3.ring || puff3.t > PUSH_AGE_LIMIT) continue;
|
|
66584
66922
|
const dx = puff3.x - shock.x;
|
|
66585
66923
|
const dz = puff3.z - shock.z;
|
|
66586
|
-
const
|
|
66587
|
-
if (Math.abs(
|
|
66924
|
+
const distance4 = Math.hypot(dx, dz) + 1e-3;
|
|
66925
|
+
if (Math.abs(distance4 - reach) < PUSH_BAND && puff3.y < PUSH_CEILING) {
|
|
66588
66926
|
const strength = 4 * dt * (1 - age);
|
|
66589
|
-
puff3.vx += dx /
|
|
66590
|
-
puff3.vz += dz /
|
|
66927
|
+
puff3.vx += dx / distance4 * strength * 6;
|
|
66928
|
+
puff3.vz += dz / distance4 * strength * 6;
|
|
66591
66929
|
}
|
|
66592
66930
|
}
|
|
66593
66931
|
}
|
|
@@ -66629,13 +66967,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66629
66967
|
addGlow(core, { x, y: y + size * 0.4, z, s: size * 1.4, s1: size * 3.2, i: flash2.intensity || DEFAULT_FLASH_INTENSITY, life: 0.22, color: [1, 0.92, 0.75], curve: 2.5 });
|
|
66630
66968
|
if (!blinding) addGlow(core, { x, y: y + size * 0.5, z, s: size * 2.2, s1: size * 3.6, i: 2.2, life: def.fuel ? 1.4 : 0.6, color: [1, 0.45, 0.15], curve: 1.6 });
|
|
66631
66969
|
if (core.reducedMotion) return;
|
|
66632
|
-
const
|
|
66970
|
+
const distance4 = context.cameraDistance;
|
|
66633
66971
|
const screen2 = core.screen;
|
|
66634
|
-
if (
|
|
66635
|
-
screen2.flash = Math.max(screen2.flash, (blinding ? 1 : 0.32) * (1 -
|
|
66972
|
+
if (distance4 < 15) {
|
|
66973
|
+
screen2.flash = Math.max(screen2.flash, (blinding ? 1 : 0.32) * (1 - distance4 / 15));
|
|
66636
66974
|
screen2.flashDecay = blinding ? 0.55 : 7;
|
|
66637
66975
|
}
|
|
66638
|
-
if (blinding &&
|
|
66976
|
+
if (blinding && distance4 < 40) {
|
|
66639
66977
|
screen2.flash = Math.max(screen2.flash, 1);
|
|
66640
66978
|
screen2.flashDecay = 0.5;
|
|
66641
66979
|
}
|
|
@@ -68379,7 +68717,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68379
68717
|
get lit() {
|
|
68380
68718
|
return this.lights.filter((light) => light.intensity > 0).length;
|
|
68381
68719
|
}
|
|
68382
|
-
flash(point, color2, intensity, duration,
|
|
68720
|
+
flash(point, color2, intensity, duration, distance4, force, steady) {
|
|
68383
68721
|
const { level } = this.context.quality;
|
|
68384
68722
|
if (level >= 1 && !force) return;
|
|
68385
68723
|
if (level >= 2 && force !== "boom") return;
|
|
@@ -68388,7 +68726,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68388
68726
|
light.y = point[1];
|
|
68389
68727
|
light.z = point[2];
|
|
68390
68728
|
light.color = color2;
|
|
68391
|
-
light.distance =
|
|
68729
|
+
light.distance = distance4 || DEFAULT_LIGHT_DISTANCE;
|
|
68392
68730
|
light.peak = intensity;
|
|
68393
68731
|
light.duration = duration;
|
|
68394
68732
|
light.t = 0;
|
|
@@ -68742,9 +69080,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68742
69080
|
const dx = puff3.x - point[0];
|
|
68743
69081
|
const dy = puff3.y - point[1];
|
|
68744
69082
|
const dz = puff3.z - point[2];
|
|
68745
|
-
const
|
|
68746
|
-
if (
|
|
68747
|
-
const strength = speed * (1 -
|
|
69083
|
+
const distance4 = Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
69084
|
+
if (distance4 >= radius) continue;
|
|
69085
|
+
const strength = speed * (1 - distance4 / radius) / (distance4 + 1e-3);
|
|
68748
69086
|
puff3.vx += dx * strength;
|
|
68749
69087
|
puff3.vy += dy * strength;
|
|
68750
69088
|
puff3.vz += dz * strength;
|
|
@@ -69274,10 +69612,10 @@ void main(){
|
|
|
69274
69612
|
context.fillRect(0, 0, size, size);
|
|
69275
69613
|
for (let speck = 0; speck < 420; speck++) {
|
|
69276
69614
|
const angle = random.next() * FULL_TURN;
|
|
69277
|
-
const
|
|
69615
|
+
const distance4 = Math.sqrt(random.next()) * center * 0.8;
|
|
69278
69616
|
context.fillStyle = random.next() < 0.5 ? "rgba(40,30,22,.5)" : "rgba(160,132,96,.5)";
|
|
69279
69617
|
context.beginPath();
|
|
69280
|
-
context.arc(center + Math.cos(angle) *
|
|
69618
|
+
context.arc(center + Math.cos(angle) * distance4, center + Math.sin(angle) * distance4, 1 + random.next() * 3.5, 0, 7);
|
|
69281
69619
|
context.fill();
|
|
69282
69620
|
}
|
|
69283
69621
|
}
|
|
@@ -70423,8 +70761,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
70423
70761
|
1.6,
|
|
70424
70762
|
(progress, dt) => {
|
|
70425
70763
|
const flight = progress * 1.6;
|
|
70426
|
-
const
|
|
70427
|
-
rocket.position.copy(muzzle2).addScaledVector(forward,
|
|
70764
|
+
const distance4 = 1.2 * flight + (flight > 0.25 ? 9 * (flight - 0.25) ** 2 : 0);
|
|
70765
|
+
rocket.position.copy(muzzle2).addScaledVector(forward, distance4);
|
|
70428
70766
|
rocket.rotation.x += 0.25 * dt * 60;
|
|
70429
70767
|
light?.position.copy(rocket.position);
|
|
70430
70768
|
flame?.update({ position: [rocket.position.x, rocket.position.y, rocket.position.z] });
|
|
@@ -70716,9 +71054,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
70716
71054
|
const dropMagazine = (up) => {
|
|
70717
71055
|
if (!parts.mag || !world.layers.magazines) return;
|
|
70718
71056
|
root.updateWorldMatrix(true, true);
|
|
70719
|
-
const
|
|
70720
|
-
parts.mag.matrixWorld.decompose(
|
|
70721
|
-
particles.spawn(
|
|
71057
|
+
const copy2 = parts.mag.clone(true);
|
|
71058
|
+
parts.mag.matrixWorld.decompose(copy2.position, copy2.quaternion, copy2.scale);
|
|
71059
|
+
particles.spawn(copy2, toWorld2(session, vector2(up ? -0.25 : 0.05, up ? 0.9 : -0.3, 0.18)), { kind: "magazine", life: 25, radius: 0.014, bounce: 0.15, spin: vector2(1.5, 0.5, 2.5), onRest: (object2) => object2.rotation.set(0, object2.rotation.y, PI17 / 2) });
|
|
70722
71060
|
};
|
|
70723
71061
|
const stuckCase = () => {
|
|
70724
71062
|
if (!session.cartridge || !parts.eject) return;
|
|
@@ -71318,7 +71656,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71318
71656
|
const kit = modelKit(THREE);
|
|
71319
71657
|
const random = createRng(options.seed ?? 1);
|
|
71320
71658
|
const layers = options.layers ?? createLayers();
|
|
71321
|
-
const
|
|
71659
|
+
const distance4 = () => options.soundDistance?.() ?? 0;
|
|
71322
71660
|
const particles = createParticles(THREE, scene, groundAt, options.particleLimit);
|
|
71323
71661
|
const spawnParticle = particles.spawn.bind(particles);
|
|
71324
71662
|
particles.spawn = (object2, velocity, particleOptions) => {
|
|
@@ -71658,19 +71996,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71658
71996
|
else if (tool2.suppressed !== void 0) current.suppressed = tool2.suppressed;
|
|
71659
71997
|
else current.suppressed = hasSuppressor(tool2.attachments ? fittedOf2(tool2.attachments) : current.def.fitted ?? []);
|
|
71660
71998
|
if (tool2.underbarrelActive && current.model.parts.uglMuzzle) {
|
|
71661
|
-
audio?.launch("grenade", LAUNCH_VOLUME,
|
|
71999
|
+
audio?.launch("grenade", LAUNCH_VOLUME, distance4());
|
|
71662
72000
|
return;
|
|
71663
72001
|
}
|
|
71664
72002
|
const action = current.def.action;
|
|
71665
72003
|
if (action.kind === "launcher") {
|
|
71666
72004
|
const isRocket = current.model.parts.family === "rocket";
|
|
71667
72005
|
if (isRocket) launchRocket(heavy(current), options.flyRocket !== false);
|
|
71668
|
-
audio?.launch(isRocket ? "rocket" : "grenade", LAUNCH_VOLUME,
|
|
72006
|
+
audio?.launch(isRocket ? "rocket" : "grenade", LAUNCH_VOLUME, distance4());
|
|
71669
72007
|
}
|
|
71670
72008
|
if (action.kind !== "firearm") return;
|
|
71671
72009
|
const caliber = caliberOf(arsenal, current.def);
|
|
71672
72010
|
if (!caliber) return;
|
|
71673
|
-
audio?.shot(muzzleEnergy(caliber) * (caliber.pellets ?? 1), current.def.category, { caliber, distance:
|
|
72011
|
+
audio?.shot(muzzleEnergy(caliber) * (caliber.pellets ?? 1), current.def.category, { caliber, distance: distance4(), space: options.soundSpace?.() ?? "outdoor", ...current.suppressed ? { suppressed: true } : {} });
|
|
71674
72012
|
};
|
|
71675
72013
|
return {
|
|
71676
72014
|
equip,
|
|
@@ -73841,17 +74179,17 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73841
74179
|
for (const spawned of room.spawned()) {
|
|
73842
74180
|
const position = spawned.root.getWorldPosition(new (T2()).Vector3());
|
|
73843
74181
|
const at4 = [position.x, position.y, position.z];
|
|
73844
|
-
const
|
|
74182
|
+
const distance4 = dist([at4[0], 0, at4[2]], [origin[0], 0, origin[2]]);
|
|
73845
74183
|
if (spawned.itemId.startsWith("zombie_") || spawned.itemId.startsWith("person_")) {
|
|
73846
74184
|
const state = room.world.state(spawned.objectId);
|
|
73847
74185
|
const alive = state?.body?.alive ?? true;
|
|
73848
74186
|
const raw = state?.body?.vitality;
|
|
73849
74187
|
if (raw !== void 0) fullVitality.set(spawned.objectId, Math.max(fullVitality.get(spawned.objectId) ?? 0, raw));
|
|
73850
74188
|
const vitality = raw === void 0 ? void 0 : Math.max(0, raw) / Math.max(1e-9, fullVitality.get(spawned.objectId) ?? raw);
|
|
73851
|
-
found.push({ kind: "person", id: spawned.objectId, itemId: spawned.itemId, distance:
|
|
74189
|
+
found.push({ kind: "person", id: spawned.objectId, itemId: spawned.itemId, distance: distance4, alive, ...vitality === void 0 ? {} : { vitality } });
|
|
73852
74190
|
} else if (REPORTED_OBJECTS.includes(spawned.itemId)) {
|
|
73853
74191
|
const parts = room.world.state(spawned.objectId)?.parts ?? [];
|
|
73854
|
-
found.push({ kind: "object", id: spawned.objectId, itemId: spawned.itemId, distance:
|
|
74192
|
+
found.push({ kind: "object", id: spawned.objectId, itemId: spawned.itemId, distance: distance4, broken: parts.filter((part) => part.status === "broken").length, marks: parts.filter((part) => part.burning).length });
|
|
73855
74193
|
}
|
|
73856
74194
|
}
|
|
73857
74195
|
if (wallParts.size > 0) {
|
|
@@ -73872,16 +74210,16 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73872
74210
|
const whoIs = (itemId) => itemId.startsWith("zombie_") ? text.things.zombie : text.things.survivor;
|
|
73873
74211
|
const aftermath = (point) => {
|
|
73874
74212
|
for (const w of witnesses()) {
|
|
73875
|
-
const
|
|
74213
|
+
const distance4 = num2(w.distance, 1);
|
|
73876
74214
|
if (w.kind === "person") {
|
|
73877
74215
|
const verdict = w.alive === false ? text.verdicts.dead : w.vitality !== void 0 && w.vitality < 0.999 ? fillText2(text.verdicts.hurt, { vitality: num2(w.vitality * 100, 0) }) : text.verdicts.unhurt;
|
|
73878
|
-
say(fillText2(log.aftermath_person, { who: whoIs(w.itemId), distance:
|
|
74216
|
+
say(fillText2(log.aftermath_person, { who: whoIs(w.itemId), distance: distance4, verdict }), { phase: "aftermath", kind: w.kind, objectId: w.id, distance: w.distance, alive: w.alive, vitality: w.vitality, point });
|
|
73879
74217
|
} else if (w.kind === "wall") {
|
|
73880
74218
|
const verdict = (w.pieces ?? 1) > 1 ? fillText2(text.verdicts.wall_pieces, { pieces: w.pieces ?? 0, n: w.marks ?? 0 }) : (w.broken ?? 0) > 0 ? fillText2(text.verdicts.wall_broken, { n: w.broken ?? 0 }) : (w.marks ?? 0) > 0 ? fillText2(text.verdicts.wall_cracked, { n: w.marks ?? 0 }) : text.verdicts.wall_intact;
|
|
73881
74219
|
say(fillText2(log.aftermath_wall, { verdict }), { phase: "aftermath", kind: w.kind, objectId: w.id, broken: w.broken, marks: w.marks, pieces: w.pieces });
|
|
73882
74220
|
} else {
|
|
73883
74221
|
const verdict = (w.broken ?? 0) > 0 ? fillText2(text.verdicts.lost_parts, { n: w.broken ?? 0 }) : (w.marks ?? 0) > 0 ? text.verdicts.burning : text.verdicts.standing;
|
|
73884
|
-
say(fillText2(log.aftermath_object, { what: text.things[w.itemId] ?? w.itemId, distance:
|
|
74222
|
+
say(fillText2(log.aftermath_object, { what: text.things[w.itemId] ?? w.itemId, distance: distance4, verdict }), { phase: "aftermath", kind: w.kind, objectId: w.id, distance: w.distance, broken: w.broken });
|
|
73885
74223
|
}
|
|
73886
74224
|
}
|
|
73887
74225
|
};
|
|
@@ -74180,7 +74518,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74180
74518
|
{ kind: "chair", item: "dining_chair" }
|
|
74181
74519
|
];
|
|
74182
74520
|
var PUSH_READ_AT = 0.8;
|
|
74183
|
-
var
|
|
74521
|
+
var MOVED2 = 0.15;
|
|
74184
74522
|
var SHELTERED = 0.5;
|
|
74185
74523
|
var SHELTERED_MOST = 1;
|
|
74186
74524
|
var CHEST = 1.1;
|
|
@@ -74191,7 +74529,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74191
74529
|
var GROUND_FRICTION2 = 7;
|
|
74192
74530
|
var PERSON_SLACK = 0.4;
|
|
74193
74531
|
var flat = (a, b) => Math.hypot(a[0] - b[0], a[2] - b[2]);
|
|
74194
|
-
var bearing = (centre,
|
|
74532
|
+
var bearing = (centre, distance4, degrees) => [centre[0] + Math.sin(degrees * Math.PI / 180) * distance4, 0, centre[2] + Math.cos(degrees * Math.PI / 180) * distance4];
|
|
74195
74533
|
var PUSH_LAYOUT = {
|
|
74196
74534
|
can: [[2.5, -52], [5, 12], [8, 78]],
|
|
74197
74535
|
bottle: [[2.5, 26], [5, -62], [8, -78]],
|
|
@@ -74224,7 +74562,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74224
74562
|
} catch {
|
|
74225
74563
|
}
|
|
74226
74564
|
};
|
|
74227
|
-
for (const { kind, item } of PUSH_KINDS) PUSH_LAYOUT[kind].forEach(([
|
|
74565
|
+
for (const { kind, item } of PUSH_KINDS) PUSH_LAYOUT[kind].forEach(([distance4, degrees]) => lay(kind, item, bearing(centre, distance4, degrees)));
|
|
74228
74566
|
if (mode === "grenade") {
|
|
74229
74567
|
lay("zombie", "zombie_walker", bearing(centre, 3.4, -130));
|
|
74230
74568
|
lay("survivor", "person_police_officer", bearing(centre, 7.5, 78));
|
|
@@ -74287,10 +74625,10 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74287
74625
|
const rows = placed.map((body) => {
|
|
74288
74626
|
const from = origin.get(body.objectId) ?? body.from;
|
|
74289
74627
|
const now = start(body);
|
|
74290
|
-
const
|
|
74291
|
-
const away = Math.max(1e-6,
|
|
74628
|
+
const distance4 = flat(from, blast.point);
|
|
74629
|
+
const away = Math.max(1e-6, distance4);
|
|
74292
74630
|
const outward = ((now[0] - from[0]) * (from[0] - blast.point[0]) + (now[2] - from[2]) * (from[2] - blast.point[2])) / away;
|
|
74293
|
-
return { ...body, distance:
|
|
74631
|
+
return { ...body, distance: distance4, outward, moved: flat(now, from), cover: cover.get(body.objectId) ?? 1 };
|
|
74294
74632
|
});
|
|
74295
74633
|
const torn = (row) => (PUSH_KINDS.some((entry2) => entry2.kind === row.kind) || HEAVY_ITEMS.includes(row.kind)) && partsOf(row.objectId) < (partsBefore.get(row.objectId) ?? 0);
|
|
74296
74634
|
const inReach = rows.filter((row) => row.distance < blast.radius * 0.85 && !torn(row));
|
|
@@ -74302,7 +74640,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74302
74640
|
const most = Math.max(SHELTERED_MOST, row.cover * Math.max(0, ...open));
|
|
74303
74641
|
expect(row.outward < most, fillText2(text.push_sheltered, { what: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), cover: (row.cover * 100).toFixed(0), moved: Math.max(0, row.outward).toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward, cover: row.cover, most } });
|
|
74304
74642
|
}
|
|
74305
|
-
const movedAway = reached.filter((row) => row.outward >=
|
|
74643
|
+
const movedAway = reached.filter((row) => row.outward >= MOVED2);
|
|
74306
74644
|
const least = reached.length === 0 ? 0 : Math.min(...reached.map((row) => row.outward));
|
|
74307
74645
|
expect(reached.length > 0 && movedAway.length === reached.length, fillText2(text.push_outward, { moved: movedAway.length, n: reached.length, least: least.toFixed(2) }), { rows: reached.map((row) => ({ kind: row.kind, distance: row.distance, outward: row.outward })), torn: rows.filter(torn).map((row) => row.objectId) });
|
|
74308
74646
|
for (const { kind } of PUSH_KINDS) {
|
|
@@ -74320,7 +74658,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74320
74658
|
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 } });
|
|
74321
74659
|
}
|
|
74322
74660
|
const table = rows.find((row) => HEAVY_ITEMS.includes(row.kind) && row.distance < blast.radius * 0.85);
|
|
74323
|
-
if (table) expect(table.moved >=
|
|
74661
|
+
if (table) expect(table.moved >= MOVED2, fillText2(text.push_heavy, { what: things[table.itemId] ?? table.itemId, moved: table.moved.toFixed(2) }), { table });
|
|
74324
74662
|
}
|
|
74325
74663
|
};
|
|
74326
74664
|
}
|