@adatechnology/game-weapons-three 0.19.1 → 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 +397 -132
- package/dist/index.global.js.map +1 -1
- package/package.json +3 -3
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 = {
|
|
@@ -18301,18 +18301,18 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
18301
18301
|
return { ...p.parameters };
|
|
18302
18302
|
}
|
|
18303
18303
|
function toGeometry(THREE, source, options = {}) {
|
|
18304
|
-
const
|
|
18304
|
+
const copy2 = options.copy !== false;
|
|
18305
18305
|
const primitive = isPrimitive(source) ? source : null;
|
|
18306
18306
|
const ThreeClass = primitive && primitive.type !== "BufferGeometry" ? THREE[primitive.type] : void 0;
|
|
18307
18307
|
const geometry = ThreeClass ? Reflect.construct(THREE.BufferGeometry, [], ThreeClass) : new THREE.BufferGeometry();
|
|
18308
18308
|
if (primitive && ThreeClass) {
|
|
18309
18309
|
Object.assign(geometry, { type: primitive.type, parameters: threeParameters(THREE, primitive) });
|
|
18310
18310
|
}
|
|
18311
|
-
const attribute = (array, size) =>
|
|
18311
|
+
const attribute = (array, size) => copy2 ? new THREE.Float32BufferAttribute(array, size) : new THREE.BufferAttribute(array, size);
|
|
18312
18312
|
const index = source.indices;
|
|
18313
18313
|
const setIndex = () => {
|
|
18314
18314
|
if (!index) return;
|
|
18315
|
-
geometry.setIndex(
|
|
18315
|
+
geometry.setIndex(copy2 ? index instanceof Uint32Array ? new THREE.Uint32BufferAttribute(index, 1) : new THREE.Uint16BufferAttribute(index, 1) : new THREE.BufferAttribute(index, 1));
|
|
18316
18316
|
};
|
|
18317
18317
|
const type = primitive?.type ?? "BufferGeometry";
|
|
18318
18318
|
if (INDEX_FIRST.has(type)) setIndex();
|
|
@@ -22549,11 +22549,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
22549
22549
|
const KM = options.massFactor ?? FLEXURE_DEFAULTS.massFactor;
|
|
22550
22550
|
return mass > 0 ? (KL * impulse) ** 2 / (2 * KM * mass) : 0;
|
|
22551
22551
|
};
|
|
22552
|
-
var blastImpulse = (tnt,
|
|
22552
|
+
var blastImpulse = (tnt, distance4, options = {}) => {
|
|
22553
22553
|
if (tnt <= 0) return 0;
|
|
22554
22554
|
const o = { ...FLEXURE_DEFAULTS, ...definedOf(options) };
|
|
22555
22555
|
const cube = Math.cbrt(tnt);
|
|
22556
|
-
const r = Math.max(
|
|
22556
|
+
const r = Math.max(distance4, o.nearScaled * cube);
|
|
22557
22557
|
return (o.reflection + o.reflectionNear / (r / cube)) * (o.impulse * cube * cube / r);
|
|
22558
22558
|
};
|
|
22559
22559
|
var slendernessFactor = (h, t, options = {}) => {
|
|
@@ -27700,14 +27700,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
27700
27700
|
const r = raycastInternal(origin, direction, maxDistance, void 0, false, true);
|
|
27701
27701
|
return r ? { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: r.distance } : null;
|
|
27702
27702
|
},
|
|
27703
|
-
sweepBox(box5, direction,
|
|
27703
|
+
sweepBox(box5, direction, distance4, options2 = {}) {
|
|
27704
27704
|
const d = vec.normalize(direction);
|
|
27705
27705
|
const ignored = options2.ignore === void 0 ? void 0 : objects.get(options2.ignore);
|
|
27706
27706
|
const hosted = options2.ignore === void 0 || ignored ? void 0 : impls.get(options2.ignore);
|
|
27707
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;
|
|
27708
27708
|
let best = null;
|
|
27709
27709
|
for (const origin of sweepOrigins(box5, d, options2.spacing ?? 0.2)) {
|
|
27710
|
-
const r = raycastInternal(origin, d,
|
|
27710
|
+
const r = raycastInternal(origin, d, distance4 + SWEEP_BACK, ignore);
|
|
27711
27711
|
if (!r || best && r.distance >= best.distance) continue;
|
|
27712
27712
|
best = { object: r.object, part: r.part, point: r.point, normal: r.normal, distance: Math.max(0, r.distance - SWEEP_BACK) };
|
|
27713
27713
|
}
|
|
@@ -37780,7 +37780,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37780
37780
|
house.updateMatrixWorld();
|
|
37781
37781
|
return house.localToWorld(localCenter.clone());
|
|
37782
37782
|
};
|
|
37783
|
-
const
|
|
37783
|
+
const distance4 = (focus) => center().distanceTo(focus instanceof THREE.Vector3 ? focus : new THREE.Vector3(focus.x, focus.y, focus.z));
|
|
37784
37784
|
markGroups(r, root, parts);
|
|
37785
37785
|
const structure = assembleStructure(r0, root), destruction = createHouseDestruction(root, house, structure, parts, colliders, water);
|
|
37786
37786
|
h.destruction = destruction;
|
|
@@ -37876,7 +37876,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37876
37876
|
shared3.vegMaterials.setActors(focus ? [{ x: focus.x, y: focus.y, z: focus.z, radius: 0.9 }] : []);
|
|
37877
37877
|
}
|
|
37878
37878
|
if (focus && cfg.lod !== false) {
|
|
37879
|
-
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;
|
|
37880
37880
|
let n = d > L.hide ? 2 : d > L.interior ? 1 : 0;
|
|
37881
37881
|
if (n < at4) n = d < (at4 === 2 ? L.hide : L.interior) * 0.92 ? n : at4;
|
|
37882
37882
|
applyLod(Math.max(n, h.lodMin));
|
|
@@ -37946,7 +37946,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
37946
37946
|
return h.lodCurrent;
|
|
37947
37947
|
},
|
|
37948
37948
|
center,
|
|
37949
|
-
distance:
|
|
37949
|
+
distance: distance4,
|
|
37950
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).
|
|
37951
37951
|
damage: fire,
|
|
37952
37952
|
colliderDamage,
|
|
@@ -46554,7 +46554,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46554
46554
|
return { id: options.id, samples };
|
|
46555
46555
|
}
|
|
46556
46556
|
|
|
46557
|
-
// ../game-audio/dist/chunk-
|
|
46557
|
+
// ../game-audio/dist/chunk-LZDF5XMZ.js
|
|
46558
46558
|
var DISTANCE_CURVES = {
|
|
46559
46559
|
/** The game's `sfx`: `vol / (1 + d² × 0.004)`, cutoff `/ (1 + d × 0.01)`, silent below 0.01 (jogo L62091–62092, L62101). */
|
|
46560
46560
|
game_sfx: { model: "inverse_square", k: 4e-3, cutoffK: 0.01, minGain: 0.01 },
|
|
@@ -46569,22 +46569,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46569
46569
|
/** The game's animal calls: `max(0, 1 − d / 70) × 0.25`, silent at or below 0.005 (jogo L66627–66628). */
|
|
46570
46570
|
animals: { model: "linear", range: 70, scale: 0.25, minGain: 5e-3 }
|
|
46571
46571
|
};
|
|
46572
|
-
function falloffGain(falloff, volume,
|
|
46572
|
+
function falloffGain(falloff, volume, distance22) {
|
|
46573
46573
|
if (!falloff || falloff.model === "none") return volume;
|
|
46574
46574
|
if (falloff.model === "linear") {
|
|
46575
|
-
const level2 = Math.max(0, 1 -
|
|
46575
|
+
const level2 = Math.max(0, 1 - distance22 / falloff.range) * volume;
|
|
46576
46576
|
return falloff.scale === void 0 ? level2 : level2 * falloff.scale;
|
|
46577
46577
|
}
|
|
46578
|
-
const level = volume / (1 +
|
|
46578
|
+
const level = volume / (1 + distance22 * distance22 * falloff.k);
|
|
46579
46579
|
return falloff.scale === void 0 ? level : falloff.scale * level;
|
|
46580
46580
|
}
|
|
46581
46581
|
function isSilent(falloff, gain) {
|
|
46582
46582
|
if (!falloff || falloff.model === "none" || falloff.minGain === void 0) return false;
|
|
46583
46583
|
return falloff.model === "linear" ? gain <= falloff.minGain : gain < falloff.minGain;
|
|
46584
46584
|
}
|
|
46585
|
-
function cutoffDivisor(falloff,
|
|
46585
|
+
function cutoffDivisor(falloff, distance22) {
|
|
46586
46586
|
if (!falloff || falloff.model !== "inverse_square" || falloff.cutoffK === void 0) return 1;
|
|
46587
|
-
return 1 +
|
|
46587
|
+
return 1 + distance22 * falloff.cutoffK;
|
|
46588
46588
|
}
|
|
46589
46589
|
var game_sfx_default = {
|
|
46590
46590
|
sources: ["jogo:L62089-62107"],
|
|
@@ -46948,8 +46948,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
46948
46948
|
const rightZ = -Math.sin(listener.yaw);
|
|
46949
46949
|
const dx = position[0] - listener.position[0];
|
|
46950
46950
|
const dz = position[2] - listener.position[2];
|
|
46951
|
-
const
|
|
46952
|
-
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);
|
|
46953
46953
|
return pan < -PAN_LIMIT ? -PAN_LIMIT : pan > PAN_LIMIT ? PAN_LIMIT : pan;
|
|
46954
46954
|
}
|
|
46955
46955
|
var FNV_OFFSET = 2166136261;
|
|
@@ -47134,10 +47134,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47134
47134
|
var layerEnd = (layer3) => layer3.at + layer3.duration + layer3.tail;
|
|
47135
47135
|
function planSound(recipe2, input = {}) {
|
|
47136
47136
|
const listener = input.listener ?? DEFAULT_LISTENER;
|
|
47137
|
-
const
|
|
47137
|
+
const distance22 = input.distance ?? (input.position ? listenerDistance(listener, input.position, input.distanceMode) : 0);
|
|
47138
47138
|
const occlusion = Math.min(1, Math.max(0, input.occlusion ?? 0));
|
|
47139
47139
|
const order = recipe2.order ?? "layered";
|
|
47140
|
-
const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1,
|
|
47140
|
+
const falloffLevel = falloffGain(recipe2.falloff, input.volume ?? 1, distance22);
|
|
47141
47141
|
const level = occlusion > 0 ? falloffLevel * (1 - OCCLUSION_GAIN * occlusion) : falloffLevel;
|
|
47142
47142
|
const silent = isSilent(recipe2.falloff, falloffLevel);
|
|
47143
47143
|
const base = {
|
|
@@ -47147,7 +47147,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47147
47147
|
...recipe2.group === void 0 ? {} : { group: recipe2.group },
|
|
47148
47148
|
priority: recipe2.priority ?? busPriority(recipe2.bus),
|
|
47149
47149
|
level,
|
|
47150
|
-
distance:
|
|
47150
|
+
distance: distance22,
|
|
47151
47151
|
...recipe2.pan ? { pan: input.position ? panFor(listener, input.position) : 0 } : {}
|
|
47152
47152
|
};
|
|
47153
47153
|
if (silent) return recipe2.keepSilent ? { ...base, silent: true, length: 0, layers: [] } : null;
|
|
@@ -47158,7 +47158,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47158
47158
|
...recipe2.tail === void 0 ? {} : { tail: recipe2.tail },
|
|
47159
47159
|
noiseSeconds: input.noiseSeconds ?? DEFAULT_NOISE_SECONDS
|
|
47160
47160
|
};
|
|
47161
|
-
const divisor = cutoffDivisor(recipe2.falloff,
|
|
47161
|
+
const divisor = cutoffDivisor(recipe2.falloff, distance22) / (1 - OCCLUSION_CUTOFF * occlusion);
|
|
47162
47162
|
const layers = recipe2.layers.flatMap((layer3) => planLayer(layer3, scope2, defaults, order !== "layered", level)).map((layer3) => muffle(layer3, divisor));
|
|
47163
47163
|
return { ...base, silent: false, length: Math.max(0, ...layers.map(layerEnd)), layers };
|
|
47164
47164
|
}
|
|
@@ -47261,6 +47261,255 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47261
47261
|
function unlockContext(context) {
|
|
47262
47262
|
if (context.state === "suspended" && typeof context.close === "function") void context.resume();
|
|
47263
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
|
+
}
|
|
47264
47513
|
var LOOP_START_ABOVE = 2e-3;
|
|
47265
47514
|
var LOOP_SMOOTHING = { volume: 0.15, frequency: 0.08 };
|
|
47266
47515
|
function createLoopState(recipe2, open = false) {
|
|
@@ -47475,11 +47724,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47475
47724
|
if (!action) return;
|
|
47476
47725
|
nodes ?? (nodes = create4(context, 0));
|
|
47477
47726
|
const listener = placed && position ? host.listener?.() : void 0;
|
|
47478
|
-
const
|
|
47479
|
-
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;
|
|
47480
47729
|
nodes.gain.gain.setTargetAtTime(level, context.currentTime, smoothing.volume);
|
|
47481
47730
|
if (action.frequency !== void 0 && nodes.frequency) nodes.frequency.setTargetAtTime(action.frequency, context.currentTime, smoothing.frequency);
|
|
47482
|
-
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);
|
|
47483
47732
|
if (listener && position && nodes.panner) nodes.panner.pan.setTargetAtTime(panFor(listener, position), context.currentTime, smoothing.frequency);
|
|
47484
47733
|
},
|
|
47485
47734
|
stop: entry2.stop
|
|
@@ -47498,16 +47747,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47498
47747
|
const drawn = Math.min(count - 2, Math.floor(random() * (count - 1)));
|
|
47499
47748
|
return drawn >= last ? drawn + 1 : drawn;
|
|
47500
47749
|
}
|
|
47501
|
-
function farMixAt(crossover,
|
|
47502
|
-
if (crossover.to <= crossover.from) return
|
|
47503
|
-
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);
|
|
47504
47753
|
return t <= 0 ? 0 : t >= 1 ? 1 : t;
|
|
47505
47754
|
}
|
|
47506
47755
|
function crossGains(farMix) {
|
|
47507
47756
|
return { close: Math.cos(farMix * Math.PI / 2), far: Math.sin(farMix * Math.PI / 2) };
|
|
47508
47757
|
}
|
|
47509
|
-
function sampleCutoff(cutoffK,
|
|
47510
|
-
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;
|
|
47511
47760
|
const occluded = occlusion > 0 ? byDistance / (1 + occlusion * 9) : byDistance;
|
|
47512
47761
|
return Math.max(80, Math.min(OPEN_CUTOFF, occluded));
|
|
47513
47762
|
}
|
|
@@ -47525,10 +47774,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47525
47774
|
function planSample(sound3, input) {
|
|
47526
47775
|
if (sound3.close.length === 0) throw new Error(`sample sound ${sound3.id} has no close take`);
|
|
47527
47776
|
const listener = input.listener ?? DEFAULT_LISTENER;
|
|
47528
|
-
const
|
|
47777
|
+
const distance22 = input.distance ?? (input.position ? listenerDistance(listener, input.position, input.distanceMode) : 0);
|
|
47529
47778
|
const falloff = sound3.falloff ?? DEFAULT_SAMPLE_FALLOFF;
|
|
47530
47779
|
const occlusion = Math.max(0, Math.min(1, input.occlusion ?? 0));
|
|
47531
|
-
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);
|
|
47532
47781
|
if (isSilent(falloff, level) || level <= 0) return null;
|
|
47533
47782
|
const pitch = sound3.pitch ?? DEFAULT_SAMPLE_PITCH;
|
|
47534
47783
|
const rate = pitch > 0 ? 1 + (input.random() * 2 - 1) * pitch : 1;
|
|
@@ -47536,7 +47785,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47536
47785
|
const tier = tierFor(sound3, input.intensity);
|
|
47537
47786
|
const close = tier?.close.length ? tier.close : sound3.close;
|
|
47538
47787
|
const far = tier?.far?.length ? tier.far : sound3.far ?? [];
|
|
47539
|
-
const farMix = far.length > 0 ? farMixAt(sound3.crossover ?? DEFAULT_CROSSOVER,
|
|
47788
|
+
const farMix = far.length > 0 ? farMixAt(sound3.crossover ?? DEFAULT_CROSSOVER, distance22) : 0;
|
|
47540
47789
|
const gains = crossGains(farMix);
|
|
47541
47790
|
const layers = [];
|
|
47542
47791
|
const take = (role, refs, gain, at4) => {
|
|
@@ -47566,9 +47815,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
47566
47815
|
id: sound3.id,
|
|
47567
47816
|
bus: sound3.bus,
|
|
47568
47817
|
level,
|
|
47569
|
-
distance:
|
|
47818
|
+
distance: distance22,
|
|
47570
47819
|
...pan === void 0 ? {} : { pan },
|
|
47571
|
-
cutoff: sampleCutoff(sound3.cutoffK ?? DEFAULT_SAMPLE_CUTOFF_K,
|
|
47820
|
+
cutoff: sampleCutoff(sound3.cutoffK ?? DEFAULT_SAMPLE_CUTOFF_K, distance22, occlusion),
|
|
47572
47821
|
rate,
|
|
47573
47822
|
environment,
|
|
47574
47823
|
...tier ? { tier: tier.name } : {},
|
|
@@ -48463,6 +48712,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48463
48712
|
chokes.set(id, list2);
|
|
48464
48713
|
return list2;
|
|
48465
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
|
+
};
|
|
48466
48726
|
const watchers = /* @__PURE__ */ new Set();
|
|
48467
48727
|
const announce = (event) => {
|
|
48468
48728
|
options.onVoiceStart?.(event);
|
|
@@ -48519,6 +48779,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48519
48779
|
const elapsed = context.currentTime - lastTime;
|
|
48520
48780
|
lastTime = context.currentTime;
|
|
48521
48781
|
if (elapsed > 0) for (const id of voices.advance(elapsed)) active.delete(id);
|
|
48782
|
+
occluders?.prune((id) => active.has(id));
|
|
48522
48783
|
};
|
|
48523
48784
|
const inputFor = (recipe2, playOptions, random) => ({
|
|
48524
48785
|
random,
|
|
@@ -48529,16 +48790,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48529
48790
|
...playOptions.distance === void 0 ? {} : { distance: playOptions.distance },
|
|
48530
48791
|
...playOptions.position ? { position: playOptions.position } : {},
|
|
48531
48792
|
...playOptions.params ? { params: playOptions.params } : {},
|
|
48532
|
-
...
|
|
48793
|
+
...pointOcclusion && playOptions.position && recipe2.falloff?.model !== "none" ? { occlusion: pointOcclusion(playOptions.position) } : {}
|
|
48533
48794
|
});
|
|
48534
48795
|
const startQueue = options.deferredStart ? createStartQueue(options.deferredStart) : null;
|
|
48535
|
-
const build = (plan, store, delay, requestedAt, fallbackOf) => {
|
|
48796
|
+
const build = (plan, store, delay, requestedAt, fallbackOf, route) => {
|
|
48536
48797
|
const audio = context;
|
|
48537
48798
|
const time = audio.currentTime + delay;
|
|
48538
48799
|
const realized = realize(plan, {
|
|
48539
48800
|
context: audio,
|
|
48540
|
-
output: outputFor(plan.bus),
|
|
48541
|
-
...chain?.wet ? { wet: chain
|
|
48801
|
+
output: route?.input ?? outputFor(plan.bus),
|
|
48802
|
+
...route?.wet ?? chain?.wet ? { wet: route?.wet ?? chain?.wet } : {},
|
|
48542
48803
|
noise: () => noiseBuffer(store, audio, mix3.noise.seconds),
|
|
48543
48804
|
time
|
|
48544
48805
|
});
|
|
@@ -48557,7 +48818,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48557
48818
|
});
|
|
48558
48819
|
return realized;
|
|
48559
48820
|
};
|
|
48560
|
-
const deferVoice = (plan, store, voiceId, delay, fallbackOf) => {
|
|
48821
|
+
const deferVoice = (plan, store, voiceId, delay, fallbackOf, route) => {
|
|
48561
48822
|
const requestedAt = context?.currentTime ?? 0;
|
|
48562
48823
|
let built2 = null;
|
|
48563
48824
|
let cancelled = false;
|
|
@@ -48572,7 +48833,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48572
48833
|
};
|
|
48573
48834
|
startQueue.push({
|
|
48574
48835
|
run() {
|
|
48575
|
-
if (!cancelled && context) built2 = build(plan, store, delay, requestedAt, fallbackOf);
|
|
48836
|
+
if (!cancelled && context) built2 = build(plan, store, delay, requestedAt, fallbackOf, route);
|
|
48576
48837
|
},
|
|
48577
48838
|
drop() {
|
|
48578
48839
|
if (voiceId === void 0) return;
|
|
@@ -48582,8 +48843,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48582
48843
|
});
|
|
48583
48844
|
return pending;
|
|
48584
48845
|
};
|
|
48585
|
-
const start = (plan, store, voiceId, delay = 0, fallbackOf, urgent = false) => {
|
|
48586
|
-
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);
|
|
48587
48849
|
if (voiceId === void 0) return null;
|
|
48588
48850
|
voices.setLength(voiceId, plan.length + delay);
|
|
48589
48851
|
active.set(voiceId, realized);
|
|
@@ -48598,8 +48860,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48598
48860
|
}
|
|
48599
48861
|
};
|
|
48600
48862
|
};
|
|
48601
|
-
const admit = (recipe2, gain,
|
|
48602
|
-
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 });
|
|
48603
48865
|
if (!decision.accepted) return null;
|
|
48604
48866
|
for (const id of decision.evicted) {
|
|
48605
48867
|
active.get(id)?.stop();
|
|
@@ -48629,7 +48891,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48629
48891
|
...playOptions.intensity === void 0 ? {} : { intensity: playOptions.intensity },
|
|
48630
48892
|
...playOptions.distance === void 0 ? {} : { distance: playOptions.distance },
|
|
48631
48893
|
...playOptions.position ? { position: playOptions.position } : {},
|
|
48632
|
-
...playOptions.occlusion !== void 0 ? { occlusion: playOptions.occlusion } :
|
|
48894
|
+
...playOptions.occlusion !== void 0 ? { occlusion: playOptions.occlusion } : pointOcclusion && playOptions.position ? { occlusion: pointOcclusion(playOptions.position) } : {}
|
|
48633
48895
|
});
|
|
48634
48896
|
const playSample = (sample, playOptions, random, store) => {
|
|
48635
48897
|
if (busSettings.get(sample.bus)?.muted) return null;
|
|
@@ -48649,7 +48911,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48649
48911
|
const requestedAt = audio.currentTime;
|
|
48650
48912
|
const time = requestedAt + (playOptions.delay ?? 0);
|
|
48651
48913
|
const chokeList = sample.choke ? choked(sample.id) : void 0;
|
|
48652
|
-
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 });
|
|
48653
48915
|
const sampleBank = registry.bankOf(plan.id);
|
|
48654
48916
|
announce({
|
|
48655
48917
|
id: plan.id,
|
|
@@ -48698,19 +48960,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48698
48960
|
const random = seeded ?? streamRandom;
|
|
48699
48961
|
const recipe2 = registry.sound(id);
|
|
48700
48962
|
if (!recipe2 || busSettings.get(recipe2.bus)?.muted) return null;
|
|
48701
|
-
const
|
|
48702
|
-
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);
|
|
48703
48965
|
const silent = isSilent(recipe2.falloff, level);
|
|
48704
48966
|
if (silent && !recipe2.keepSilent) return null;
|
|
48705
48967
|
const audio = ready();
|
|
48706
48968
|
if (!audio) return null;
|
|
48707
48969
|
unlockContext(audio);
|
|
48708
48970
|
advance();
|
|
48709
|
-
const voiceId = silent ? void 0 : admit(recipe2, level,
|
|
48971
|
+
const voiceId = silent ? void 0 : admit(recipe2, level, distance22);
|
|
48710
48972
|
if (voiceId === null) return null;
|
|
48711
48973
|
if (!silent && usesNoise(recipe2)) prepareNoise(store, audio, mix3.noise.seconds);
|
|
48712
48974
|
const plan = planSound(recipe2, inputFor(recipe2, playOptions, random));
|
|
48713
|
-
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;
|
|
48714
48976
|
};
|
|
48715
48977
|
const randomFor = (playOptions) => {
|
|
48716
48978
|
if (playOptions.channel === void 0) return engineRandom;
|
|
@@ -48819,7 +49081,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48819
49081
|
},
|
|
48820
49082
|
setListener(next) {
|
|
48821
49083
|
listener = next;
|
|
49084
|
+
occluders?.update(next.position, (id) => active.has(id));
|
|
48822
49085
|
},
|
|
49086
|
+
occludedVoices: () => occluders?.voices() ?? [],
|
|
48823
49087
|
setBus(id, setting) {
|
|
48824
49088
|
busSettings.set(id, { ...busSettings.get(id), ...setting });
|
|
48825
49089
|
if (!context) return;
|
|
@@ -48881,6 +49145,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
48881
49145
|
startQueue?.clear();
|
|
48882
49146
|
for (const id of active.keys()) voices.release(id);
|
|
48883
49147
|
for (const loop of [...loops]) loop.stop();
|
|
49148
|
+
occluders?.clear();
|
|
48884
49149
|
active.clear();
|
|
48885
49150
|
void context?.close();
|
|
48886
49151
|
context = null;
|
|
@@ -50368,9 +50633,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
50368
50633
|
const referenceEnergy = options.referenceEnergy?.[soundClass] ?? CLASS_REFERENCE_ENERGY[soundClass] ?? energyJ;
|
|
50369
50634
|
const k = energyPosition(energyJ, curve);
|
|
50370
50635
|
const referenceK = energyPosition(referenceEnergy, curve);
|
|
50371
|
-
const
|
|
50372
|
-
const attenuation = (input.volume ?? 1) / (1 +
|
|
50373
|
-
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);
|
|
50374
50639
|
const suppressor = input.suppressed ? { ...DEFAULT_SUPPRESSOR, ...options.suppressor } : { gain: 1, cutoff: 1, crack: 1, body: 1 };
|
|
50375
50640
|
const indoors = input.indoors ? { ...DEFAULT_INDOORS, ...options.indoors } : { duration: 1, cutoff: 1 };
|
|
50376
50641
|
const gain = classGain * attenuation * (linear(curve.gain, k) / linear(curve.gain, referenceK)) * suppressor.gain;
|
|
@@ -51157,15 +51422,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
51157
51422
|
const take = Math.max(0, Math.floor(input.take ?? 0)) % GUNSHOT_TAKES;
|
|
51158
51423
|
const jitter = TAKE_JITTER[take] ?? TAKE_JITTER[0];
|
|
51159
51424
|
const pitch = input.pitch ?? 1;
|
|
51160
|
-
const
|
|
51425
|
+
const distance4 = Math.max(0, input.distance ?? 0);
|
|
51161
51426
|
const reference = options.reference ?? 4;
|
|
51162
51427
|
const exponent = options.exponent ?? 0.8;
|
|
51163
|
-
const level = (input.volume ?? 1) * Math.pow(reference / Math.max(
|
|
51164
|
-
const delay =
|
|
51165
|
-
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)));
|
|
51166
51431
|
const occlusion = clamp01(input.occlusion ?? 0);
|
|
51167
|
-
const air = (1 - 0.6 * occlusion) / (1 +
|
|
51168
|
-
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);
|
|
51169
51434
|
const space = input.space ?? "outdoor";
|
|
51170
51435
|
const supersonic = (input.caliber?.muzzleSpeed ?? 0) > SUPERSONIC_MS;
|
|
51171
51436
|
const shell = input.caliber?.kind === "slug" ? gunshot_profiles_default.shells.slug : input.caliber?.kind === "birdshot" ? gunshot_profiles_default.shells.birdshot : void 0;
|
|
@@ -51196,7 +51461,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
51196
51461
|
const bodyGain = profile.body.gain * (shell && "bodyGain" in shell ? shell.bodyGain : 1) * (suppressed ? sup.bodyGain : 1);
|
|
51197
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 });
|
|
51198
51463
|
const mech = gunshot_profiles_default.mech[input.category ?? ""];
|
|
51199
|
-
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 });
|
|
51200
51465
|
}
|
|
51201
51466
|
const far = level * (1 - closeMix);
|
|
51202
51467
|
if (far > 0) {
|
|
@@ -52174,9 +52439,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52174
52439
|
burst2({ at: at4, seconds: 0.05, gain, filter: "highpass", frequency, q: 2 });
|
|
52175
52440
|
tone({ at: at4, seconds: 0.04, gain: gain * 0.6, frequency: frequency * 0.6, type: "square" });
|
|
52176
52441
|
};
|
|
52177
|
-
const play = (soundClass, classVolume = 1,
|
|
52442
|
+
const play = (soundClass, classVolume = 1, distance4 = 0, at4 = 0) => {
|
|
52178
52443
|
const [cutoff, gain, seconds] = classes[soundClass] ?? FALLBACK_SOUND_CLASS;
|
|
52179
|
-
channel.play(classBurst, { volume: classVolume, distance:
|
|
52444
|
+
channel.play(classBurst, { volume: classVolume, distance: distance4, params: { cutoff, gain, seconds }, ...at4 ? { delay: at4 } : {} });
|
|
52180
52445
|
};
|
|
52181
52446
|
const sceneTone2 = (entry2) => {
|
|
52182
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 } : {} });
|
|
@@ -52290,8 +52555,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52290
52555
|
const id = mechanicalSoundOf(event);
|
|
52291
52556
|
if (id) mechanical(id);
|
|
52292
52557
|
},
|
|
52293
|
-
play(soundClass, classVolume,
|
|
52294
|
-
play(soundClass, classVolume,
|
|
52558
|
+
play(soundClass, classVolume, distance4) {
|
|
52559
|
+
play(soundClass, classVolume, distance4);
|
|
52295
52560
|
},
|
|
52296
52561
|
reloadStart(category) {
|
|
52297
52562
|
metal2(0, 1500, 0.35);
|
|
@@ -52331,8 +52596,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
52331
52596
|
}
|
|
52332
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 });
|
|
52333
52598
|
},
|
|
52334
|
-
launch(kind, volume2 = 1,
|
|
52335
|
-
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));
|
|
52336
52601
|
const id = LAUNCH_SOUND_IDS[kind];
|
|
52337
52602
|
if (hostReady(id)) {
|
|
52338
52603
|
channel.play(id, { volume: level });
|
|
@@ -63190,11 +63455,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
63190
63455
|
while (fire.acc >= 1) {
|
|
63191
63456
|
fire.acc -= 1;
|
|
63192
63457
|
const angle = random.next() * Math.PI * 2;
|
|
63193
|
-
const
|
|
63458
|
+
const distance4 = Math.sqrt(random.next()) * radius;
|
|
63194
63459
|
addPuff(core, random, {
|
|
63195
|
-
x: fire.x + Math.cos(angle) *
|
|
63460
|
+
x: fire.x + Math.cos(angle) * distance4,
|
|
63196
63461
|
y: fire.y + 0.05,
|
|
63197
|
-
z: fire.z + Math.sin(angle) *
|
|
63462
|
+
z: fire.z + Math.sin(angle) * distance4,
|
|
63198
63463
|
vx: random.between(-0.2, 0.2),
|
|
63199
63464
|
vy: random.between(0.6, 1.4),
|
|
63200
63465
|
vz: random.between(-0.2, 0.2),
|
|
@@ -64457,8 +64722,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
64457
64722
|
const x = positions2[o];
|
|
64458
64723
|
const z = positions2[o + 2];
|
|
64459
64724
|
if (splash && random.next() < SPLASH_CHANCE) {
|
|
64460
|
-
const
|
|
64461
|
-
if (
|
|
64725
|
+
const distance4 = Math.hypot(x - camera2[0], z - camera2[2]);
|
|
64726
|
+
if (distance4 < reach) {
|
|
64462
64727
|
if (random.next() < SPRITE_CHANCE) {
|
|
64463
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 });
|
|
64464
64729
|
}
|
|
@@ -65342,9 +65607,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
65342
65607
|
let best;
|
|
65343
65608
|
let bestDistance = 9;
|
|
65344
65609
|
for (const block of blocks) {
|
|
65345
|
-
const
|
|
65346
|
-
if (
|
|
65347
|
-
bestDistance =
|
|
65610
|
+
const distance4 = Math.hypot(block.x - x, block.y - y);
|
|
65611
|
+
if (distance4 < bestDistance) {
|
|
65612
|
+
bestDistance = distance4;
|
|
65348
65613
|
best = block;
|
|
65349
65614
|
}
|
|
65350
65615
|
}
|
|
@@ -65712,14 +65977,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
65712
65977
|
if (!walk) return;
|
|
65713
65978
|
const dx = walk.toX - walker.x;
|
|
65714
65979
|
const dz = walk.toZ - walker.z;
|
|
65715
|
-
const
|
|
65716
|
-
if (
|
|
65980
|
+
const distance4 = Math.hypot(dx, dz);
|
|
65981
|
+
if (distance4 <= ARRIVAL_DISTANCE) {
|
|
65717
65982
|
walker.walk = void 0;
|
|
65718
65983
|
return;
|
|
65719
65984
|
}
|
|
65720
|
-
const step = Math.min(
|
|
65721
|
-
walker.x += dx /
|
|
65722
|
-
walker.z += dz /
|
|
65985
|
+
const step = Math.min(distance4, walk.speed * dt);
|
|
65986
|
+
walker.x += dx / distance4 * step;
|
|
65987
|
+
walker.z += dz / distance4 * step;
|
|
65723
65988
|
walker.facing = Math.atan2(dx, dz);
|
|
65724
65989
|
walker.bob = Math.abs(Math.cos(elapsed * walk.speed * STRIDE_FACTOR + phases[index + 1])) * BOB_AMPLITUDE;
|
|
65725
65990
|
});
|
|
@@ -66510,8 +66775,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66510
66775
|
} else pool.glow.intensity = 0;
|
|
66511
66776
|
}
|
|
66512
66777
|
var LOD_GAME = { edges: [15, 40, 80], scales: [1, 0.5, 0.2, 0.1], radiusFactor: 1 };
|
|
66513
|
-
function lodScale(bands,
|
|
66514
|
-
const effective =
|
|
66778
|
+
function lodScale(bands, distance4, visualRadius) {
|
|
66779
|
+
const effective = distance4 - visualRadius * bands.radiusFactor;
|
|
66515
66780
|
if (effective < bands.edges[0]) return bands.scales[0];
|
|
66516
66781
|
if (effective < bands.edges[1]) return bands.scales[1];
|
|
66517
66782
|
if (effective < bands.edges[2]) return bands.scales[2];
|
|
@@ -66568,10 +66833,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66568
66833
|
const count = Math.round(6 + radius * 7);
|
|
66569
66834
|
for (let index = 0; index < count; index++) {
|
|
66570
66835
|
const angle = index / count * Math.PI * 2 + random.between(-0.15, 0.15);
|
|
66571
|
-
const
|
|
66836
|
+
const distance4 = radius * random.between(0.95, 1.3);
|
|
66572
66837
|
const size = random.between(0.12, 0.26) * Math.min(1.6, 0.6 + radius * 0.4);
|
|
66573
|
-
const px = x + Math.cos(angle) *
|
|
66574
|
-
const pz = z + Math.sin(angle) *
|
|
66838
|
+
const px = x + Math.cos(angle) * distance4;
|
|
66839
|
+
const pz = z + Math.sin(angle) * distance4;
|
|
66575
66840
|
const plate3 = random.next() < 0.6;
|
|
66576
66841
|
const color2 = RIM_COLORS[random.next() < 0.5 ? 0 : 1];
|
|
66577
66842
|
const tiltX = random.between(-0.5, 0.5);
|
|
@@ -66656,11 +66921,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66656
66921
|
if (puff3.ring || puff3.t > PUSH_AGE_LIMIT) continue;
|
|
66657
66922
|
const dx = puff3.x - shock.x;
|
|
66658
66923
|
const dz = puff3.z - shock.z;
|
|
66659
|
-
const
|
|
66660
|
-
if (Math.abs(
|
|
66924
|
+
const distance4 = Math.hypot(dx, dz) + 1e-3;
|
|
66925
|
+
if (Math.abs(distance4 - reach) < PUSH_BAND && puff3.y < PUSH_CEILING) {
|
|
66661
66926
|
const strength = 4 * dt * (1 - age);
|
|
66662
|
-
puff3.vx += dx /
|
|
66663
|
-
puff3.vz += dz /
|
|
66927
|
+
puff3.vx += dx / distance4 * strength * 6;
|
|
66928
|
+
puff3.vz += dz / distance4 * strength * 6;
|
|
66664
66929
|
}
|
|
66665
66930
|
}
|
|
66666
66931
|
}
|
|
@@ -66702,13 +66967,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
66702
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 });
|
|
66703
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 });
|
|
66704
66969
|
if (core.reducedMotion) return;
|
|
66705
|
-
const
|
|
66970
|
+
const distance4 = context.cameraDistance;
|
|
66706
66971
|
const screen2 = core.screen;
|
|
66707
|
-
if (
|
|
66708
|
-
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));
|
|
66709
66974
|
screen2.flashDecay = blinding ? 0.55 : 7;
|
|
66710
66975
|
}
|
|
66711
|
-
if (blinding &&
|
|
66976
|
+
if (blinding && distance4 < 40) {
|
|
66712
66977
|
screen2.flash = Math.max(screen2.flash, 1);
|
|
66713
66978
|
screen2.flashDecay = 0.5;
|
|
66714
66979
|
}
|
|
@@ -68452,7 +68717,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68452
68717
|
get lit() {
|
|
68453
68718
|
return this.lights.filter((light) => light.intensity > 0).length;
|
|
68454
68719
|
}
|
|
68455
|
-
flash(point, color2, intensity, duration,
|
|
68720
|
+
flash(point, color2, intensity, duration, distance4, force, steady) {
|
|
68456
68721
|
const { level } = this.context.quality;
|
|
68457
68722
|
if (level >= 1 && !force) return;
|
|
68458
68723
|
if (level >= 2 && force !== "boom") return;
|
|
@@ -68461,7 +68726,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68461
68726
|
light.y = point[1];
|
|
68462
68727
|
light.z = point[2];
|
|
68463
68728
|
light.color = color2;
|
|
68464
|
-
light.distance =
|
|
68729
|
+
light.distance = distance4 || DEFAULT_LIGHT_DISTANCE;
|
|
68465
68730
|
light.peak = intensity;
|
|
68466
68731
|
light.duration = duration;
|
|
68467
68732
|
light.t = 0;
|
|
@@ -68815,9 +69080,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
68815
69080
|
const dx = puff3.x - point[0];
|
|
68816
69081
|
const dy = puff3.y - point[1];
|
|
68817
69082
|
const dz = puff3.z - point[2];
|
|
68818
|
-
const
|
|
68819
|
-
if (
|
|
68820
|
-
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);
|
|
68821
69086
|
puff3.vx += dx * strength;
|
|
68822
69087
|
puff3.vy += dy * strength;
|
|
68823
69088
|
puff3.vz += dz * strength;
|
|
@@ -69347,10 +69612,10 @@ void main(){
|
|
|
69347
69612
|
context.fillRect(0, 0, size, size);
|
|
69348
69613
|
for (let speck = 0; speck < 420; speck++) {
|
|
69349
69614
|
const angle = random.next() * FULL_TURN;
|
|
69350
|
-
const
|
|
69615
|
+
const distance4 = Math.sqrt(random.next()) * center * 0.8;
|
|
69351
69616
|
context.fillStyle = random.next() < 0.5 ? "rgba(40,30,22,.5)" : "rgba(160,132,96,.5)";
|
|
69352
69617
|
context.beginPath();
|
|
69353
|
-
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);
|
|
69354
69619
|
context.fill();
|
|
69355
69620
|
}
|
|
69356
69621
|
}
|
|
@@ -70496,8 +70761,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
70496
70761
|
1.6,
|
|
70497
70762
|
(progress, dt) => {
|
|
70498
70763
|
const flight = progress * 1.6;
|
|
70499
|
-
const
|
|
70500
|
-
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);
|
|
70501
70766
|
rocket.rotation.x += 0.25 * dt * 60;
|
|
70502
70767
|
light?.position.copy(rocket.position);
|
|
70503
70768
|
flame?.update({ position: [rocket.position.x, rocket.position.y, rocket.position.z] });
|
|
@@ -70789,9 +71054,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
70789
71054
|
const dropMagazine = (up) => {
|
|
70790
71055
|
if (!parts.mag || !world.layers.magazines) return;
|
|
70791
71056
|
root.updateWorldMatrix(true, true);
|
|
70792
|
-
const
|
|
70793
|
-
parts.mag.matrixWorld.decompose(
|
|
70794
|
-
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) });
|
|
70795
71060
|
};
|
|
70796
71061
|
const stuckCase = () => {
|
|
70797
71062
|
if (!session.cartridge || !parts.eject) return;
|
|
@@ -71391,7 +71656,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71391
71656
|
const kit = modelKit(THREE);
|
|
71392
71657
|
const random = createRng(options.seed ?? 1);
|
|
71393
71658
|
const layers = options.layers ?? createLayers();
|
|
71394
|
-
const
|
|
71659
|
+
const distance4 = () => options.soundDistance?.() ?? 0;
|
|
71395
71660
|
const particles = createParticles(THREE, scene, groundAt, options.particleLimit);
|
|
71396
71661
|
const spawnParticle = particles.spawn.bind(particles);
|
|
71397
71662
|
particles.spawn = (object2, velocity, particleOptions) => {
|
|
@@ -71731,19 +71996,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
71731
71996
|
else if (tool2.suppressed !== void 0) current.suppressed = tool2.suppressed;
|
|
71732
71997
|
else current.suppressed = hasSuppressor(tool2.attachments ? fittedOf2(tool2.attachments) : current.def.fitted ?? []);
|
|
71733
71998
|
if (tool2.underbarrelActive && current.model.parts.uglMuzzle) {
|
|
71734
|
-
audio?.launch("grenade", LAUNCH_VOLUME,
|
|
71999
|
+
audio?.launch("grenade", LAUNCH_VOLUME, distance4());
|
|
71735
72000
|
return;
|
|
71736
72001
|
}
|
|
71737
72002
|
const action = current.def.action;
|
|
71738
72003
|
if (action.kind === "launcher") {
|
|
71739
72004
|
const isRocket = current.model.parts.family === "rocket";
|
|
71740
72005
|
if (isRocket) launchRocket(heavy(current), options.flyRocket !== false);
|
|
71741
|
-
audio?.launch(isRocket ? "rocket" : "grenade", LAUNCH_VOLUME,
|
|
72006
|
+
audio?.launch(isRocket ? "rocket" : "grenade", LAUNCH_VOLUME, distance4());
|
|
71742
72007
|
}
|
|
71743
72008
|
if (action.kind !== "firearm") return;
|
|
71744
72009
|
const caliber = caliberOf(arsenal, current.def);
|
|
71745
72010
|
if (!caliber) return;
|
|
71746
|
-
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 } : {} });
|
|
71747
72012
|
};
|
|
71748
72013
|
return {
|
|
71749
72014
|
equip,
|
|
@@ -73914,17 +74179,17 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73914
74179
|
for (const spawned of room.spawned()) {
|
|
73915
74180
|
const position = spawned.root.getWorldPosition(new (T2()).Vector3());
|
|
73916
74181
|
const at4 = [position.x, position.y, position.z];
|
|
73917
|
-
const
|
|
74182
|
+
const distance4 = dist([at4[0], 0, at4[2]], [origin[0], 0, origin[2]]);
|
|
73918
74183
|
if (spawned.itemId.startsWith("zombie_") || spawned.itemId.startsWith("person_")) {
|
|
73919
74184
|
const state = room.world.state(spawned.objectId);
|
|
73920
74185
|
const alive = state?.body?.alive ?? true;
|
|
73921
74186
|
const raw = state?.body?.vitality;
|
|
73922
74187
|
if (raw !== void 0) fullVitality.set(spawned.objectId, Math.max(fullVitality.get(spawned.objectId) ?? 0, raw));
|
|
73923
74188
|
const vitality = raw === void 0 ? void 0 : Math.max(0, raw) / Math.max(1e-9, fullVitality.get(spawned.objectId) ?? raw);
|
|
73924
|
-
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 } });
|
|
73925
74190
|
} else if (REPORTED_OBJECTS.includes(spawned.itemId)) {
|
|
73926
74191
|
const parts = room.world.state(spawned.objectId)?.parts ?? [];
|
|
73927
|
-
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 });
|
|
73928
74193
|
}
|
|
73929
74194
|
}
|
|
73930
74195
|
if (wallParts.size > 0) {
|
|
@@ -73945,16 +74210,16 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
73945
74210
|
const whoIs = (itemId) => itemId.startsWith("zombie_") ? text.things.zombie : text.things.survivor;
|
|
73946
74211
|
const aftermath = (point) => {
|
|
73947
74212
|
for (const w of witnesses()) {
|
|
73948
|
-
const
|
|
74213
|
+
const distance4 = num2(w.distance, 1);
|
|
73949
74214
|
if (w.kind === "person") {
|
|
73950
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;
|
|
73951
|
-
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 });
|
|
73952
74217
|
} else if (w.kind === "wall") {
|
|
73953
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;
|
|
73954
74219
|
say(fillText2(log.aftermath_wall, { verdict }), { phase: "aftermath", kind: w.kind, objectId: w.id, broken: w.broken, marks: w.marks, pieces: w.pieces });
|
|
73955
74220
|
} else {
|
|
73956
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;
|
|
73957
|
-
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 });
|
|
73958
74223
|
}
|
|
73959
74224
|
}
|
|
73960
74225
|
};
|
|
@@ -74253,7 +74518,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74253
74518
|
{ kind: "chair", item: "dining_chair" }
|
|
74254
74519
|
];
|
|
74255
74520
|
var PUSH_READ_AT = 0.8;
|
|
74256
|
-
var
|
|
74521
|
+
var MOVED2 = 0.15;
|
|
74257
74522
|
var SHELTERED = 0.5;
|
|
74258
74523
|
var SHELTERED_MOST = 1;
|
|
74259
74524
|
var CHEST = 1.1;
|
|
@@ -74264,7 +74529,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74264
74529
|
var GROUND_FRICTION2 = 7;
|
|
74265
74530
|
var PERSON_SLACK = 0.4;
|
|
74266
74531
|
var flat = (a, b) => Math.hypot(a[0] - b[0], a[2] - b[2]);
|
|
74267
|
-
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];
|
|
74268
74533
|
var PUSH_LAYOUT = {
|
|
74269
74534
|
can: [[2.5, -52], [5, 12], [8, 78]],
|
|
74270
74535
|
bottle: [[2.5, 26], [5, -62], [8, -78]],
|
|
@@ -74297,7 +74562,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74297
74562
|
} catch {
|
|
74298
74563
|
}
|
|
74299
74564
|
};
|
|
74300
|
-
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)));
|
|
74301
74566
|
if (mode === "grenade") {
|
|
74302
74567
|
lay("zombie", "zombie_walker", bearing(centre, 3.4, -130));
|
|
74303
74568
|
lay("survivor", "person_police_officer", bearing(centre, 7.5, 78));
|
|
@@ -74360,10 +74625,10 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74360
74625
|
const rows = placed.map((body) => {
|
|
74361
74626
|
const from = origin.get(body.objectId) ?? body.from;
|
|
74362
74627
|
const now = start(body);
|
|
74363
|
-
const
|
|
74364
|
-
const away = Math.max(1e-6,
|
|
74628
|
+
const distance4 = flat(from, blast.point);
|
|
74629
|
+
const away = Math.max(1e-6, distance4);
|
|
74365
74630
|
const outward = ((now[0] - from[0]) * (from[0] - blast.point[0]) + (now[2] - from[2]) * (from[2] - blast.point[2])) / away;
|
|
74366
|
-
return { ...body, distance:
|
|
74631
|
+
return { ...body, distance: distance4, outward, moved: flat(now, from), cover: cover.get(body.objectId) ?? 1 };
|
|
74367
74632
|
});
|
|
74368
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);
|
|
74369
74634
|
const inReach = rows.filter((row) => row.distance < blast.radius * 0.85 && !torn(row));
|
|
@@ -74375,7 +74640,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74375
74640
|
const most = Math.max(SHELTERED_MOST, row.cover * Math.max(0, ...open));
|
|
74376
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 } });
|
|
74377
74642
|
}
|
|
74378
|
-
const movedAway = reached.filter((row) => row.outward >=
|
|
74643
|
+
const movedAway = reached.filter((row) => row.outward >= MOVED2);
|
|
74379
74644
|
const least = reached.length === 0 ? 0 : Math.min(...reached.map((row) => row.outward));
|
|
74380
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) });
|
|
74381
74646
|
for (const { kind } of PUSH_KINDS) {
|
|
@@ -74393,7 +74658,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
74393
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 } });
|
|
74394
74659
|
}
|
|
74395
74660
|
const table = rows.find((row) => HEAVY_ITEMS.includes(row.kind) && row.distance < blast.radius * 0.85);
|
|
74396
|
-
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 });
|
|
74397
74662
|
}
|
|
74398
74663
|
};
|
|
74399
74664
|
}
|