quake2ts 0.0.405 → 0.0.408
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/package.json +1 -1
- package/packages/client/dist/browser/index.global.js +16 -16
- package/packages/client/dist/browser/index.global.js.map +1 -1
- package/packages/client/dist/cjs/index.cjs +23 -3
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +23 -3
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/client/dist/types/index.d.ts.map +1 -1
- package/packages/client/dist/types/ui/demo-controls.d.ts +2 -1
- package/packages/client/dist/types/ui/demo-controls.d.ts.map +1 -1
- package/packages/engine/dist/browser/index.global.js +14 -14
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +88 -2
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +87 -2
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/types/assets/mapStatistics.d.ts +20 -0
- package/packages/engine/dist/types/assets/mapStatistics.d.ts.map +1 -0
- package/packages/engine/dist/types/audio/api.d.ts +1 -0
- package/packages/engine/dist/types/audio/api.d.ts.map +1 -1
- package/packages/engine/dist/types/audio/context.d.ts +1 -0
- package/packages/engine/dist/types/audio/context.d.ts.map +1 -1
- package/packages/engine/dist/types/audio/system.d.ts +3 -0
- package/packages/engine/dist/types/audio/system.d.ts.map +1 -1
- package/packages/engine/dist/types/index.d.ts +1 -0
- package/packages/engine/dist/types/index.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
|
@@ -1583,6 +1583,9 @@ var AudioApi = class {
|
|
|
1583
1583
|
stop_entity_sounds(entnum) {
|
|
1584
1584
|
this.system.stopEntitySounds(entnum);
|
|
1585
1585
|
}
|
|
1586
|
+
setPlaybackRate(rate) {
|
|
1587
|
+
this.system.setPlaybackRate(rate);
|
|
1588
|
+
}
|
|
1586
1589
|
set_listener(listener) {
|
|
1587
1590
|
this.system.setListener(listener);
|
|
1588
1591
|
}
|
|
@@ -4405,6 +4408,7 @@ function spatializeOrigin(origin, listener, masterVolume, attenuation, isListene
|
|
|
4405
4408
|
var AudioSystem = class {
|
|
4406
4409
|
constructor(options) {
|
|
4407
4410
|
this.activeSources = /* @__PURE__ */ new Map();
|
|
4411
|
+
this.playbackRate = 1;
|
|
4408
4412
|
this.contextController = options.context;
|
|
4409
4413
|
this.registry = options.registry;
|
|
4410
4414
|
this.playerEntity = options.playerEntity;
|
|
@@ -4426,6 +4430,15 @@ var AudioSystem = class {
|
|
|
4426
4430
|
setSfxVolume(volume) {
|
|
4427
4431
|
this.sfxVolume = volume;
|
|
4428
4432
|
}
|
|
4433
|
+
setPlaybackRate(rate) {
|
|
4434
|
+
this.playbackRate = rate;
|
|
4435
|
+
for (const active of this.activeSources.values()) {
|
|
4436
|
+
if (active.source.playbackRate) {
|
|
4437
|
+
active.source.playbackRate.value = rate;
|
|
4438
|
+
}
|
|
4439
|
+
this.updateSourceGain(active);
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4429
4442
|
async ensureRunning() {
|
|
4430
4443
|
await this.contextController.resume();
|
|
4431
4444
|
}
|
|
@@ -4448,6 +4461,9 @@ var AudioSystem = class {
|
|
|
4448
4461
|
const source = ctx.createBufferSource();
|
|
4449
4462
|
source.buffer = buffer;
|
|
4450
4463
|
source.loop = request.looping ?? false;
|
|
4464
|
+
if (source.playbackRate) {
|
|
4465
|
+
source.playbackRate.value = this.playbackRate;
|
|
4466
|
+
}
|
|
4451
4467
|
const origin = request.origin ?? this.listener.origin;
|
|
4452
4468
|
const gain = ctx.createGain();
|
|
4453
4469
|
const panner = this.createPanner(ctx, request.attenuation);
|
|
@@ -4459,7 +4475,8 @@ var AudioSystem = class {
|
|
|
4459
4475
|
const spatial = spatializeOrigin(origin, this.listener, request.volume, request.attenuation, isListenerSound);
|
|
4460
4476
|
const attenuationScale = request.volume === 0 ? 0 : Math.max(spatial.left, spatial.right) / Math.max(1, request.volume);
|
|
4461
4477
|
const gainValue = attenuationScale * (request.volume / 255) * this.masterVolume * this.sfxVolume;
|
|
4462
|
-
|
|
4478
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4479
|
+
gain.gain.value = gainValue * occlusionScale * playbackRateMute;
|
|
4463
4480
|
const startTimeSec = ctx.currentTime + (request.timeOffsetMs ?? 0) / 1e3;
|
|
4464
4481
|
const endTimeMs = (request.looping ? Number.POSITIVE_INFINITY : buffer.duration * 1e3) + startTimeSec * 1e3;
|
|
4465
4482
|
source.connect(panner);
|
|
@@ -4607,9 +4624,15 @@ var AudioSystem = class {
|
|
|
4607
4624
|
filter.frequency.value = clamp(cutoffHz, 10, 2e4);
|
|
4608
4625
|
return filter;
|
|
4609
4626
|
}
|
|
4627
|
+
updateSourceGain(active) {
|
|
4628
|
+
const occlusionScale = active.occlusion?.scale ?? 1;
|
|
4629
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4630
|
+
active.gain.gain.value = active.baseGain * occlusionScale * playbackRateMute;
|
|
4631
|
+
}
|
|
4610
4632
|
applyOcclusion(active, occlusion) {
|
|
4611
4633
|
const scale = clamp01(occlusion?.gainScale ?? 1);
|
|
4612
|
-
|
|
4634
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4635
|
+
active.gain.gain.value = active.baseGain * scale * playbackRateMute;
|
|
4613
4636
|
if (active.occlusion?.filter) {
|
|
4614
4637
|
const cutoff = occlusion?.lowpassHz ?? 2e4;
|
|
4615
4638
|
active.occlusion.filter.frequency.value = clamp(cutoff, 10, 2e4);
|
|
@@ -13399,6 +13422,67 @@ var AssetPreviewGenerator = class {
|
|
|
13399
13422
|
}
|
|
13400
13423
|
};
|
|
13401
13424
|
|
|
13425
|
+
// src/assets/mapStatistics.ts
|
|
13426
|
+
var MapAnalyzer = class {
|
|
13427
|
+
constructor(loader) {
|
|
13428
|
+
this.loader = loader;
|
|
13429
|
+
}
|
|
13430
|
+
async getMapStatistics(mapName) {
|
|
13431
|
+
const map = await this.loader.load(mapName);
|
|
13432
|
+
const lightmapCount = map.faces.filter((f) => f.lightOffset !== -1).length;
|
|
13433
|
+
const worldModel = map.models[0];
|
|
13434
|
+
const bounds = worldModel ? {
|
|
13435
|
+
mins: worldModel.mins,
|
|
13436
|
+
maxs: worldModel.maxs
|
|
13437
|
+
} : {
|
|
13438
|
+
mins: [0, 0, 0],
|
|
13439
|
+
maxs: [0, 0, 0]
|
|
13440
|
+
};
|
|
13441
|
+
return {
|
|
13442
|
+
entityCount: map.entities.entities.length,
|
|
13443
|
+
surfaceCount: map.faces.length,
|
|
13444
|
+
lightmapCount,
|
|
13445
|
+
vertexCount: map.vertices.length,
|
|
13446
|
+
bounds
|
|
13447
|
+
};
|
|
13448
|
+
}
|
|
13449
|
+
async getUsedTextures(mapName) {
|
|
13450
|
+
const map = await this.loader.load(mapName);
|
|
13451
|
+
const textures = /* @__PURE__ */ new Set();
|
|
13452
|
+
for (const info of map.texInfo) {
|
|
13453
|
+
if (info.texture) {
|
|
13454
|
+
textures.add(info.texture);
|
|
13455
|
+
}
|
|
13456
|
+
}
|
|
13457
|
+
return Array.from(textures).sort();
|
|
13458
|
+
}
|
|
13459
|
+
async getUsedModels(mapName) {
|
|
13460
|
+
const map = await this.loader.load(mapName);
|
|
13461
|
+
const models = /* @__PURE__ */ new Set();
|
|
13462
|
+
for (const ent of map.entities.entities) {
|
|
13463
|
+
if (ent.properties["model"] && !ent.properties["model"].startsWith("*")) {
|
|
13464
|
+
models.add(ent.properties["model"]);
|
|
13465
|
+
}
|
|
13466
|
+
}
|
|
13467
|
+
return Array.from(models).sort();
|
|
13468
|
+
}
|
|
13469
|
+
async getUsedSounds(mapName) {
|
|
13470
|
+
const map = await this.loader.load(mapName);
|
|
13471
|
+
const sounds = /* @__PURE__ */ new Set();
|
|
13472
|
+
for (const ent of map.entities.entities) {
|
|
13473
|
+
if (ent.properties["noise"]) {
|
|
13474
|
+
sounds.add(ent.properties["noise"]);
|
|
13475
|
+
}
|
|
13476
|
+
for (const [key, value] of Object.entries(ent.properties)) {
|
|
13477
|
+
if ((key === "noise" || key.endsWith("_sound") || key === "sound") && typeof value === "string") {
|
|
13478
|
+
sounds.add(value);
|
|
13479
|
+
}
|
|
13480
|
+
}
|
|
13481
|
+
}
|
|
13482
|
+
return Array.from(sounds).sort();
|
|
13483
|
+
}
|
|
13484
|
+
};
|
|
13485
|
+
|
|
13402
13486
|
// src/index.ts
|
|
13403
13487
|
function createEngine(imports) {
|
|
13404
13488
|
return {
|
|
@@ -13455,6 +13539,7 @@ export {
|
|
|
13455
13539
|
MD2_VERTEX_SHADER,
|
|
13456
13540
|
MD3_FRAGMENT_SHADER,
|
|
13457
13541
|
MD3_VERTEX_SHADER,
|
|
13542
|
+
MapAnalyzer,
|
|
13458
13543
|
Md2Loader,
|
|
13459
13544
|
Md2MeshBuffers,
|
|
13460
13545
|
Md2ParseError,
|