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
|
@@ -62,6 +62,7 @@ __export(index_exports, {
|
|
|
62
62
|
MD2_VERTEX_SHADER: () => MD2_VERTEX_SHADER,
|
|
63
63
|
MD3_FRAGMENT_SHADER: () => MD3_FRAGMENT_SHADER,
|
|
64
64
|
MD3_VERTEX_SHADER: () => MD3_VERTEX_SHADER,
|
|
65
|
+
MapAnalyzer: () => MapAnalyzer,
|
|
65
66
|
Md2Loader: () => Md2Loader,
|
|
66
67
|
Md2MeshBuffers: () => Md2MeshBuffers,
|
|
67
68
|
Md2ParseError: () => Md2ParseError,
|
|
@@ -1784,6 +1785,9 @@ var AudioApi = class {
|
|
|
1784
1785
|
stop_entity_sounds(entnum) {
|
|
1785
1786
|
this.system.stopEntitySounds(entnum);
|
|
1786
1787
|
}
|
|
1788
|
+
setPlaybackRate(rate) {
|
|
1789
|
+
this.system.setPlaybackRate(rate);
|
|
1790
|
+
}
|
|
1787
1791
|
set_listener(listener) {
|
|
1788
1792
|
this.system.setListener(listener);
|
|
1789
1793
|
}
|
|
@@ -4606,6 +4610,7 @@ function spatializeOrigin(origin, listener, masterVolume, attenuation, isListene
|
|
|
4606
4610
|
var AudioSystem = class {
|
|
4607
4611
|
constructor(options) {
|
|
4608
4612
|
this.activeSources = /* @__PURE__ */ new Map();
|
|
4613
|
+
this.playbackRate = 1;
|
|
4609
4614
|
this.contextController = options.context;
|
|
4610
4615
|
this.registry = options.registry;
|
|
4611
4616
|
this.playerEntity = options.playerEntity;
|
|
@@ -4627,6 +4632,15 @@ var AudioSystem = class {
|
|
|
4627
4632
|
setSfxVolume(volume) {
|
|
4628
4633
|
this.sfxVolume = volume;
|
|
4629
4634
|
}
|
|
4635
|
+
setPlaybackRate(rate) {
|
|
4636
|
+
this.playbackRate = rate;
|
|
4637
|
+
for (const active of this.activeSources.values()) {
|
|
4638
|
+
if (active.source.playbackRate) {
|
|
4639
|
+
active.source.playbackRate.value = rate;
|
|
4640
|
+
}
|
|
4641
|
+
this.updateSourceGain(active);
|
|
4642
|
+
}
|
|
4643
|
+
}
|
|
4630
4644
|
async ensureRunning() {
|
|
4631
4645
|
await this.contextController.resume();
|
|
4632
4646
|
}
|
|
@@ -4649,6 +4663,9 @@ var AudioSystem = class {
|
|
|
4649
4663
|
const source = ctx.createBufferSource();
|
|
4650
4664
|
source.buffer = buffer;
|
|
4651
4665
|
source.loop = request.looping ?? false;
|
|
4666
|
+
if (source.playbackRate) {
|
|
4667
|
+
source.playbackRate.value = this.playbackRate;
|
|
4668
|
+
}
|
|
4652
4669
|
const origin = request.origin ?? this.listener.origin;
|
|
4653
4670
|
const gain = ctx.createGain();
|
|
4654
4671
|
const panner = this.createPanner(ctx, request.attenuation);
|
|
@@ -4660,7 +4677,8 @@ var AudioSystem = class {
|
|
|
4660
4677
|
const spatial = spatializeOrigin(origin, this.listener, request.volume, request.attenuation, isListenerSound);
|
|
4661
4678
|
const attenuationScale = request.volume === 0 ? 0 : Math.max(spatial.left, spatial.right) / Math.max(1, request.volume);
|
|
4662
4679
|
const gainValue = attenuationScale * (request.volume / 255) * this.masterVolume * this.sfxVolume;
|
|
4663
|
-
|
|
4680
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4681
|
+
gain.gain.value = gainValue * occlusionScale * playbackRateMute;
|
|
4664
4682
|
const startTimeSec = ctx.currentTime + (request.timeOffsetMs ?? 0) / 1e3;
|
|
4665
4683
|
const endTimeMs = (request.looping ? Number.POSITIVE_INFINITY : buffer.duration * 1e3) + startTimeSec * 1e3;
|
|
4666
4684
|
source.connect(panner);
|
|
@@ -4808,9 +4826,15 @@ var AudioSystem = class {
|
|
|
4808
4826
|
filter.frequency.value = clamp(cutoffHz, 10, 2e4);
|
|
4809
4827
|
return filter;
|
|
4810
4828
|
}
|
|
4829
|
+
updateSourceGain(active) {
|
|
4830
|
+
const occlusionScale = active.occlusion?.scale ?? 1;
|
|
4831
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4832
|
+
active.gain.gain.value = active.baseGain * occlusionScale * playbackRateMute;
|
|
4833
|
+
}
|
|
4811
4834
|
applyOcclusion(active, occlusion) {
|
|
4812
4835
|
const scale = clamp01(occlusion?.gainScale ?? 1);
|
|
4813
|
-
|
|
4836
|
+
const playbackRateMute = Math.abs(this.playbackRate - 1) < 1e-3 ? 1 : 0;
|
|
4837
|
+
active.gain.gain.value = active.baseGain * scale * playbackRateMute;
|
|
4814
4838
|
if (active.occlusion?.filter) {
|
|
4815
4839
|
const cutoff = occlusion?.lowpassHz ?? 2e4;
|
|
4816
4840
|
active.occlusion.filter.frequency.value = clamp(cutoff, 10, 2e4);
|
|
@@ -13600,6 +13624,67 @@ var AssetPreviewGenerator = class {
|
|
|
13600
13624
|
}
|
|
13601
13625
|
};
|
|
13602
13626
|
|
|
13627
|
+
// src/assets/mapStatistics.ts
|
|
13628
|
+
var MapAnalyzer = class {
|
|
13629
|
+
constructor(loader) {
|
|
13630
|
+
this.loader = loader;
|
|
13631
|
+
}
|
|
13632
|
+
async getMapStatistics(mapName) {
|
|
13633
|
+
const map = await this.loader.load(mapName);
|
|
13634
|
+
const lightmapCount = map.faces.filter((f) => f.lightOffset !== -1).length;
|
|
13635
|
+
const worldModel = map.models[0];
|
|
13636
|
+
const bounds = worldModel ? {
|
|
13637
|
+
mins: worldModel.mins,
|
|
13638
|
+
maxs: worldModel.maxs
|
|
13639
|
+
} : {
|
|
13640
|
+
mins: [0, 0, 0],
|
|
13641
|
+
maxs: [0, 0, 0]
|
|
13642
|
+
};
|
|
13643
|
+
return {
|
|
13644
|
+
entityCount: map.entities.entities.length,
|
|
13645
|
+
surfaceCount: map.faces.length,
|
|
13646
|
+
lightmapCount,
|
|
13647
|
+
vertexCount: map.vertices.length,
|
|
13648
|
+
bounds
|
|
13649
|
+
};
|
|
13650
|
+
}
|
|
13651
|
+
async getUsedTextures(mapName) {
|
|
13652
|
+
const map = await this.loader.load(mapName);
|
|
13653
|
+
const textures = /* @__PURE__ */ new Set();
|
|
13654
|
+
for (const info of map.texInfo) {
|
|
13655
|
+
if (info.texture) {
|
|
13656
|
+
textures.add(info.texture);
|
|
13657
|
+
}
|
|
13658
|
+
}
|
|
13659
|
+
return Array.from(textures).sort();
|
|
13660
|
+
}
|
|
13661
|
+
async getUsedModels(mapName) {
|
|
13662
|
+
const map = await this.loader.load(mapName);
|
|
13663
|
+
const models = /* @__PURE__ */ new Set();
|
|
13664
|
+
for (const ent of map.entities.entities) {
|
|
13665
|
+
if (ent.properties["model"] && !ent.properties["model"].startsWith("*")) {
|
|
13666
|
+
models.add(ent.properties["model"]);
|
|
13667
|
+
}
|
|
13668
|
+
}
|
|
13669
|
+
return Array.from(models).sort();
|
|
13670
|
+
}
|
|
13671
|
+
async getUsedSounds(mapName) {
|
|
13672
|
+
const map = await this.loader.load(mapName);
|
|
13673
|
+
const sounds = /* @__PURE__ */ new Set();
|
|
13674
|
+
for (const ent of map.entities.entities) {
|
|
13675
|
+
if (ent.properties["noise"]) {
|
|
13676
|
+
sounds.add(ent.properties["noise"]);
|
|
13677
|
+
}
|
|
13678
|
+
for (const [key, value] of Object.entries(ent.properties)) {
|
|
13679
|
+
if ((key === "noise" || key.endsWith("_sound") || key === "sound") && typeof value === "string") {
|
|
13680
|
+
sounds.add(value);
|
|
13681
|
+
}
|
|
13682
|
+
}
|
|
13683
|
+
}
|
|
13684
|
+
return Array.from(sounds).sort();
|
|
13685
|
+
}
|
|
13686
|
+
};
|
|
13687
|
+
|
|
13603
13688
|
// src/index.ts
|
|
13604
13689
|
function createEngine(imports) {
|
|
13605
13690
|
return {
|
|
@@ -13657,6 +13742,7 @@ function createEngine(imports) {
|
|
|
13657
13742
|
MD2_VERTEX_SHADER,
|
|
13658
13743
|
MD3_FRAGMENT_SHADER,
|
|
13659
13744
|
MD3_VERTEX_SHADER,
|
|
13745
|
+
MapAnalyzer,
|
|
13660
13746
|
Md2Loader,
|
|
13661
13747
|
Md2MeshBuffers,
|
|
13662
13748
|
Md2ParseError,
|