@quake2ts/engine 0.0.869 → 0.0.874
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/browser/index.global.js +67 -43
- package/dist/browser/index.global.js.map +1 -1
- package/dist/cjs/index.cjs +517 -205
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +517 -205
- package/dist/esm/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/render/bsp.d.ts +10 -0
- package/dist/types/render/bsp.d.ts.map +1 -1
- package/dist/types/render/webgpu/frame.d.ts +1 -1
- package/dist/types/render/webgpu/frame.d.ts.map +1 -1
- package/dist/types/render/webgpu/pipelines/bspPipeline.d.ts +6 -1
- package/dist/types/render/webgpu/pipelines/bspPipeline.d.ts.map +1 -1
- package/dist/types/render/webgpu/resources.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,10 @@ export { ATTN_IDLE, ATTN_LOOP_NONE, ATTN_NONE, ATTN_NORM, ATTN_STATIC, MAX_SOUND
|
|
|
3
3
|
import { OggVorbisDecoder } from '@wasm-audio-decoders/ogg-vorbis';
|
|
4
4
|
import { vec3, mat4, quat, vec4, mat3 } from 'gl-matrix';
|
|
5
5
|
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
9
|
+
|
|
6
10
|
// src/loop.ts
|
|
7
11
|
var DEFAULT_FIXED_DELTA_MS = 25;
|
|
8
12
|
var DEFAULT_MAX_SUBSTEPS = 5;
|
|
@@ -17,10 +21,12 @@ var defaultScheduler = (tick) => {
|
|
|
17
21
|
var FixedTimestepLoop = class {
|
|
18
22
|
constructor(callbacks, options = {}) {
|
|
19
23
|
this.callbacks = callbacks;
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
+
__publicField(this, "options");
|
|
25
|
+
__publicField(this, "accumulatorMs", 0);
|
|
26
|
+
__publicField(this, "frame", 0);
|
|
27
|
+
__publicField(this, "lastTimeMs");
|
|
28
|
+
__publicField(this, "running", false);
|
|
29
|
+
__publicField(this, "tick", () => {
|
|
24
30
|
if (!this.running) return;
|
|
25
31
|
const nowMs = this.options.now();
|
|
26
32
|
const elapsed = this.lastTimeMs === void 0 ? 0 : nowMs - this.lastTimeMs;
|
|
@@ -29,7 +35,7 @@ var FixedTimestepLoop = class {
|
|
|
29
35
|
if (this.running) {
|
|
30
36
|
this.options.schedule(this.tick);
|
|
31
37
|
}
|
|
32
|
-
};
|
|
38
|
+
});
|
|
33
39
|
const fixedDeltaMs = options.fixedDeltaMs ?? DEFAULT_FIXED_DELTA_MS;
|
|
34
40
|
const maxSubSteps = options.maxSubSteps ?? DEFAULT_MAX_SUBSTEPS;
|
|
35
41
|
this.options = {
|
|
@@ -82,6 +88,9 @@ var FixedTimestepLoop = class {
|
|
|
82
88
|
// src/commands.ts
|
|
83
89
|
var Command = class {
|
|
84
90
|
constructor(name, callback, description) {
|
|
91
|
+
__publicField(this, "name");
|
|
92
|
+
__publicField(this, "description");
|
|
93
|
+
__publicField(this, "callback");
|
|
85
94
|
this.name = name;
|
|
86
95
|
this.callback = callback;
|
|
87
96
|
this.description = description;
|
|
@@ -92,10 +101,11 @@ var Command = class {
|
|
|
92
101
|
};
|
|
93
102
|
var CommandRegistry = class {
|
|
94
103
|
constructor() {
|
|
95
|
-
this
|
|
96
|
-
this
|
|
97
|
-
this
|
|
98
|
-
this
|
|
104
|
+
__publicField(this, "commands", /* @__PURE__ */ new Map());
|
|
105
|
+
__publicField(this, "history", []);
|
|
106
|
+
__publicField(this, "historyLimit", 64);
|
|
107
|
+
__publicField(this, "autocompleteProviders", []);
|
|
108
|
+
__publicField(this, "onConsoleOutput");
|
|
99
109
|
}
|
|
100
110
|
register(name, callback, description) {
|
|
101
111
|
const command = new Command(name, callback, description);
|
|
@@ -193,7 +203,14 @@ var Cvar = class {
|
|
|
193
203
|
flags = CvarFlags.None,
|
|
194
204
|
onChange
|
|
195
205
|
}) {
|
|
196
|
-
this
|
|
206
|
+
__publicField(this, "name");
|
|
207
|
+
__publicField(this, "defaultValue");
|
|
208
|
+
__publicField(this, "description");
|
|
209
|
+
__publicField(this, "flags");
|
|
210
|
+
__publicField(this, "_value");
|
|
211
|
+
__publicField(this, "latched");
|
|
212
|
+
__publicField(this, "onChange");
|
|
213
|
+
__publicField(this, "modifiedCount", 0);
|
|
197
214
|
this.name = name;
|
|
198
215
|
this.defaultValue = defaultValue;
|
|
199
216
|
this.description = description;
|
|
@@ -269,7 +286,8 @@ var Cvar = class {
|
|
|
269
286
|
};
|
|
270
287
|
var CvarRegistry = class {
|
|
271
288
|
constructor() {
|
|
272
|
-
this
|
|
289
|
+
__publicField(this, "cvars", /* @__PURE__ */ new Map());
|
|
290
|
+
__publicField(this, "onCvarChange");
|
|
273
291
|
}
|
|
274
292
|
register(def) {
|
|
275
293
|
const existing = this.cvars.get(def.name);
|
|
@@ -333,22 +351,27 @@ var EngineHost = class {
|
|
|
333
351
|
constructor(game, client, options = {}) {
|
|
334
352
|
this.game = game;
|
|
335
353
|
this.client = client;
|
|
336
|
-
this
|
|
337
|
-
this
|
|
338
|
-
this
|
|
339
|
-
this
|
|
340
|
-
this
|
|
354
|
+
__publicField(this, "loop");
|
|
355
|
+
__publicField(this, "startTimeMs");
|
|
356
|
+
__publicField(this, "previousFrame");
|
|
357
|
+
__publicField(this, "latestFrame");
|
|
358
|
+
__publicField(this, "started", false);
|
|
359
|
+
__publicField(this, "paused_", false);
|
|
360
|
+
__publicField(this, "latestCommand");
|
|
361
|
+
__publicField(this, "commands", new CommandRegistry());
|
|
362
|
+
__publicField(this, "cvars", new CvarRegistry());
|
|
363
|
+
__publicField(this, "stepSimulation", (step) => {
|
|
341
364
|
this.previousFrame = this.latestFrame;
|
|
342
365
|
this.latestFrame = this.game.frame(step, this.latestCommand);
|
|
343
|
-
};
|
|
344
|
-
this
|
|
366
|
+
});
|
|
367
|
+
__publicField(this, "renderClient", (renderContext) => {
|
|
345
368
|
if (!this.client) return;
|
|
346
369
|
this.latestCommand = this.client.render({
|
|
347
370
|
...renderContext,
|
|
348
371
|
previous: this.previousFrame,
|
|
349
372
|
latest: this.latestFrame
|
|
350
373
|
});
|
|
351
|
-
};
|
|
374
|
+
});
|
|
352
375
|
const now = options.loop?.now?.() ?? Date.now();
|
|
353
376
|
this.startTimeMs = options.startTimeMs ?? options.loop?.startTimeMs ?? now;
|
|
354
377
|
this.loop = new FixedTimestepLoop(
|
|
@@ -411,6 +434,10 @@ var EngineHost = class {
|
|
|
411
434
|
// src/audio/api.ts
|
|
412
435
|
var AudioApi = class {
|
|
413
436
|
constructor(options) {
|
|
437
|
+
__publicField(this, "registry");
|
|
438
|
+
__publicField(this, "system");
|
|
439
|
+
__publicField(this, "music");
|
|
440
|
+
__publicField(this, "client");
|
|
414
441
|
this.registry = options.registry;
|
|
415
442
|
this.system = options.system;
|
|
416
443
|
this.music = options.music;
|
|
@@ -503,7 +530,7 @@ var EngineRuntime = class {
|
|
|
503
530
|
constructor(engine, host) {
|
|
504
531
|
this.engine = engine;
|
|
505
532
|
this.host = host;
|
|
506
|
-
this
|
|
533
|
+
__publicField(this, "started", false);
|
|
507
534
|
}
|
|
508
535
|
start() {
|
|
509
536
|
if (this.started) return;
|
|
@@ -548,15 +575,15 @@ function assertLength(index, value) {
|
|
|
548
575
|
}
|
|
549
576
|
var ConfigStringRegistry = class {
|
|
550
577
|
constructor() {
|
|
551
|
-
this
|
|
552
|
-
this
|
|
553
|
-
this
|
|
554
|
-
this
|
|
555
|
-
this
|
|
556
|
-
this
|
|
557
|
-
this
|
|
558
|
-
this
|
|
559
|
-
this
|
|
578
|
+
__publicField(this, "values", /* @__PURE__ */ new Map());
|
|
579
|
+
__publicField(this, "modelCursor", ConfigStringIndex.Models);
|
|
580
|
+
__publicField(this, "soundCursor", ConfigStringIndex.Sounds);
|
|
581
|
+
__publicField(this, "imageCursor", ConfigStringIndex.Images);
|
|
582
|
+
__publicField(this, "lightCursor", ConfigStringIndex.Lights);
|
|
583
|
+
__publicField(this, "shadowLightCursor", ConfigStringIndex.ShadowLights);
|
|
584
|
+
__publicField(this, "itemCursor", ConfigStringIndex.Items);
|
|
585
|
+
__publicField(this, "playerSkinCursor", ConfigStringIndex.PlayerSkins);
|
|
586
|
+
__publicField(this, "generalCursor", ConfigStringIndex.General);
|
|
560
587
|
}
|
|
561
588
|
set(index, value) {
|
|
562
589
|
assertWithinBounds(index);
|
|
@@ -671,6 +698,9 @@ var PakArchive = class _PakArchive {
|
|
|
671
698
|
constructor(name, buffer, entries, checksum) {
|
|
672
699
|
this.name = name;
|
|
673
700
|
this.buffer = buffer;
|
|
701
|
+
__publicField(this, "entries");
|
|
702
|
+
__publicField(this, "checksum");
|
|
703
|
+
__publicField(this, "size");
|
|
674
704
|
this.entries = new Map(entries.map((entry) => [entry.name, entry]));
|
|
675
705
|
this.checksum = checksum;
|
|
676
706
|
this.size = buffer.byteLength;
|
|
@@ -764,7 +794,7 @@ function normalizePath2(path) {
|
|
|
764
794
|
var StreamingPakArchive = class {
|
|
765
795
|
constructor(source) {
|
|
766
796
|
this.source = source;
|
|
767
|
-
this
|
|
797
|
+
__publicField(this, "entries", null);
|
|
768
798
|
}
|
|
769
799
|
/**
|
|
770
800
|
* Read directory asynchronously.
|
|
@@ -865,7 +895,7 @@ var HEADER_SIZE3 = 12;
|
|
|
865
895
|
var DIRECTORY_ENTRY_SIZE3 = 64;
|
|
866
896
|
var PakWriter = class _PakWriter {
|
|
867
897
|
constructor() {
|
|
868
|
-
this
|
|
898
|
+
__publicField(this, "entries", /* @__PURE__ */ new Map());
|
|
869
899
|
}
|
|
870
900
|
/**
|
|
871
901
|
* Adds a file to the archive.
|
|
@@ -960,10 +990,10 @@ var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
|
|
|
960
990
|
})(ResourceType || {});
|
|
961
991
|
var ResourceLoadTracker = class {
|
|
962
992
|
constructor() {
|
|
963
|
-
this
|
|
964
|
-
this
|
|
965
|
-
this
|
|
966
|
-
this
|
|
993
|
+
__publicField(this, "tracking", false);
|
|
994
|
+
__publicField(this, "entries", []);
|
|
995
|
+
__publicField(this, "currentFrame", 0);
|
|
996
|
+
__publicField(this, "currentTime", 0);
|
|
967
997
|
}
|
|
968
998
|
startTracking() {
|
|
969
999
|
this.tracking = true;
|
|
@@ -1014,9 +1044,9 @@ var ResourceLoadTracker = class {
|
|
|
1014
1044
|
// src/assets/vfs.ts
|
|
1015
1045
|
var VirtualFileSystem = class {
|
|
1016
1046
|
constructor(archives = []) {
|
|
1017
|
-
this
|
|
1047
|
+
__publicField(this, "mounts", []);
|
|
1018
1048
|
// files maps path -> list of sources, sorted by priority (high to low)
|
|
1019
|
-
this
|
|
1049
|
+
__publicField(this, "files", /* @__PURE__ */ new Map());
|
|
1020
1050
|
archives.forEach((archive) => this.mountPak(archive));
|
|
1021
1051
|
}
|
|
1022
1052
|
mountPak(archive, priority = 0) {
|
|
@@ -1264,7 +1294,7 @@ var PakValidationError = class extends Error {
|
|
|
1264
1294
|
};
|
|
1265
1295
|
var PakValidator = class {
|
|
1266
1296
|
constructor(knownPaks = RERELEASE_KNOWN_PAKS) {
|
|
1267
|
-
this
|
|
1297
|
+
__publicField(this, "known", /* @__PURE__ */ new Map());
|
|
1268
1298
|
knownPaks.forEach((pak) => this.known.set(this.normalizePakName(pak.name), pak));
|
|
1269
1299
|
}
|
|
1270
1300
|
validateArchive(archive, nameOverride) {
|
|
@@ -1455,8 +1485,8 @@ var LruCache = class {
|
|
|
1455
1485
|
this._capacity = _capacity;
|
|
1456
1486
|
this._maxMemory = _maxMemory;
|
|
1457
1487
|
this.sizeCalculator = sizeCalculator;
|
|
1458
|
-
this
|
|
1459
|
-
this
|
|
1488
|
+
__publicField(this, "map", /* @__PURE__ */ new Map());
|
|
1489
|
+
__publicField(this, "currentMemoryUsage", 0);
|
|
1460
1490
|
if (_capacity <= 0) {
|
|
1461
1491
|
throw new RangeError("LRU cache capacity must be greater than zero");
|
|
1462
1492
|
}
|
|
@@ -2201,7 +2231,7 @@ var Md2ParseError = class extends Error {
|
|
|
2201
2231
|
var Md2Loader = class {
|
|
2202
2232
|
constructor(vfs) {
|
|
2203
2233
|
this.vfs = vfs;
|
|
2204
|
-
this
|
|
2234
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
2205
2235
|
}
|
|
2206
2236
|
async load(path) {
|
|
2207
2237
|
if (this.cache.has(path)) {
|
|
@@ -2652,7 +2682,7 @@ function parseMd3(buffer) {
|
|
|
2652
2682
|
var Md3Loader = class {
|
|
2653
2683
|
constructor(vfs) {
|
|
2654
2684
|
this.vfs = vfs;
|
|
2655
|
-
this
|
|
2685
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
2656
2686
|
}
|
|
2657
2687
|
async load(path) {
|
|
2658
2688
|
if (this.cache.has(path)) {
|
|
@@ -3017,6 +3047,7 @@ function calculateTextureSize(texture) {
|
|
|
3017
3047
|
}
|
|
3018
3048
|
var TextureCache = class {
|
|
3019
3049
|
constructor(options = {}) {
|
|
3050
|
+
__publicField(this, "cache");
|
|
3020
3051
|
this.cache = new LruCache(
|
|
3021
3052
|
options.capacity ?? 128,
|
|
3022
3053
|
options.maxMemory ?? 256 * 1024 * 1024,
|
|
@@ -3184,8 +3215,10 @@ var AudioRegistryError = class extends Error {
|
|
|
3184
3215
|
var AudioRegistry = class {
|
|
3185
3216
|
constructor(vfs, options = {}) {
|
|
3186
3217
|
this.vfs = vfs;
|
|
3187
|
-
this
|
|
3188
|
-
this
|
|
3218
|
+
__publicField(this, "cache");
|
|
3219
|
+
__publicField(this, "refCounts", /* @__PURE__ */ new Map());
|
|
3220
|
+
__publicField(this, "worker");
|
|
3221
|
+
__publicField(this, "nextRequestId", 0);
|
|
3189
3222
|
this.cache = new LruCache(options.cacheSize ?? 64);
|
|
3190
3223
|
if (options.workerPath) {
|
|
3191
3224
|
this.worker = new Worker(options.workerPath, { type: "module" });
|
|
@@ -3419,7 +3452,7 @@ var AssetDependencyError = class extends Error {
|
|
|
3419
3452
|
};
|
|
3420
3453
|
var AssetDependencyTracker = class {
|
|
3421
3454
|
constructor() {
|
|
3422
|
-
this
|
|
3455
|
+
__publicField(this, "nodes", /* @__PURE__ */ new Map());
|
|
3423
3456
|
}
|
|
3424
3457
|
register(assetKey, dependencies = []) {
|
|
3425
3458
|
const node = this.nodes.get(assetKey) ?? { dependencies: /* @__PURE__ */ new Set(), loaded: false };
|
|
@@ -3472,9 +3505,19 @@ var AssetDependencyTracker = class {
|
|
|
3472
3505
|
var AssetManager = class {
|
|
3473
3506
|
constructor(vfs, options = {}) {
|
|
3474
3507
|
this.vfs = vfs;
|
|
3475
|
-
this
|
|
3476
|
-
this
|
|
3477
|
-
this
|
|
3508
|
+
__publicField(this, "textures");
|
|
3509
|
+
__publicField(this, "audio");
|
|
3510
|
+
__publicField(this, "dependencyTracker");
|
|
3511
|
+
__publicField(this, "resourceTracker");
|
|
3512
|
+
__publicField(this, "md2");
|
|
3513
|
+
__publicField(this, "md3");
|
|
3514
|
+
__publicField(this, "sprite");
|
|
3515
|
+
__publicField(this, "bsp");
|
|
3516
|
+
__publicField(this, "palette");
|
|
3517
|
+
__publicField(this, "maps", /* @__PURE__ */ new Map());
|
|
3518
|
+
__publicField(this, "loadQueue", []);
|
|
3519
|
+
__publicField(this, "activeLoads", 0);
|
|
3520
|
+
__publicField(this, "maxConcurrentLoads");
|
|
3478
3521
|
this.textures = new TextureCache({
|
|
3479
3522
|
capacity: options.textureCacheCapacity ?? 128,
|
|
3480
3523
|
maxMemory: options.textureMemoryLimit
|
|
@@ -3772,6 +3815,7 @@ var AssetManager = class {
|
|
|
3772
3815
|
var AudioContextController = class {
|
|
3773
3816
|
constructor(factory) {
|
|
3774
3817
|
this.factory = factory;
|
|
3818
|
+
__publicField(this, "context");
|
|
3775
3819
|
}
|
|
3776
3820
|
getContext() {
|
|
3777
3821
|
if (!this.context) {
|
|
@@ -3827,7 +3871,7 @@ function createAudioGraph(controller) {
|
|
|
3827
3871
|
var SoundRegistry = class {
|
|
3828
3872
|
constructor(configStrings = new ConfigStringRegistry()) {
|
|
3829
3873
|
this.configStrings = configStrings;
|
|
3830
|
-
this
|
|
3874
|
+
__publicField(this, "buffers", /* @__PURE__ */ new Map());
|
|
3831
3875
|
}
|
|
3832
3876
|
registerName(name) {
|
|
3833
3877
|
return this.configStrings.soundIndex(name);
|
|
@@ -3854,6 +3898,11 @@ var SoundRegistry = class {
|
|
|
3854
3898
|
// src/audio/precache.ts
|
|
3855
3899
|
var SoundPrecache = class {
|
|
3856
3900
|
constructor(options) {
|
|
3901
|
+
__publicField(this, "vfs");
|
|
3902
|
+
__publicField(this, "registry");
|
|
3903
|
+
__publicField(this, "contextController");
|
|
3904
|
+
__publicField(this, "decodeAudio");
|
|
3905
|
+
__publicField(this, "soundRoot");
|
|
3857
3906
|
this.vfs = options.vfs;
|
|
3858
3907
|
this.registry = options.registry;
|
|
3859
3908
|
this.contextController = options.context;
|
|
@@ -3943,8 +3992,9 @@ function pickChannel(channels, entnum, entchannel, context) {
|
|
|
3943
3992
|
// src/audio/reverb.ts
|
|
3944
3993
|
var ReverbSystem = class {
|
|
3945
3994
|
constructor(node) {
|
|
3946
|
-
this
|
|
3947
|
-
this
|
|
3995
|
+
__publicField(this, "activePreset", null);
|
|
3996
|
+
__publicField(this, "node");
|
|
3997
|
+
__publicField(this, "enabled", true);
|
|
3948
3998
|
this.node = node;
|
|
3949
3999
|
this.node.input.gain.value = 0.5;
|
|
3950
4000
|
this.node.output.gain.value = 1;
|
|
@@ -3979,8 +4029,18 @@ var ReverbSystem = class {
|
|
|
3979
4029
|
// src/audio/system.ts
|
|
3980
4030
|
var AudioSystem = class {
|
|
3981
4031
|
constructor(options) {
|
|
3982
|
-
this
|
|
3983
|
-
this
|
|
4032
|
+
__publicField(this, "channels");
|
|
4033
|
+
__publicField(this, "registry");
|
|
4034
|
+
__publicField(this, "contextController");
|
|
4035
|
+
__publicField(this, "graph");
|
|
4036
|
+
__publicField(this, "playerEntity");
|
|
4037
|
+
__publicField(this, "activeSources", /* @__PURE__ */ new Map());
|
|
4038
|
+
__publicField(this, "resolveOcclusion");
|
|
4039
|
+
__publicField(this, "listener");
|
|
4040
|
+
__publicField(this, "sfxVolume");
|
|
4041
|
+
__publicField(this, "masterVolume");
|
|
4042
|
+
__publicField(this, "playbackRate", 1);
|
|
4043
|
+
__publicField(this, "reverb");
|
|
3984
4044
|
this.contextController = options.context;
|
|
3985
4045
|
this.registry = options.registry;
|
|
3986
4046
|
this.playerEntity = options.playerEntity;
|
|
@@ -4229,7 +4289,7 @@ var clamp01 = (value) => clamp(value, 0, 1);
|
|
|
4229
4289
|
var AudioOcclusion = class {
|
|
4230
4290
|
constructor(trace) {
|
|
4231
4291
|
this.trace = trace;
|
|
4232
|
-
this
|
|
4292
|
+
__publicField(this, "resolve", (listener, source, attenuation) => {
|
|
4233
4293
|
const dist = lengthVec3(subtractVec3(source, listener.origin));
|
|
4234
4294
|
const maxDist = calculateMaxAudibleDistance(attenuation);
|
|
4235
4295
|
const clampedDist = Math.min(dist, maxDist);
|
|
@@ -4250,7 +4310,7 @@ var AudioOcclusion = class {
|
|
|
4250
4310
|
};
|
|
4251
4311
|
}
|
|
4252
4312
|
return void 0;
|
|
4253
|
-
};
|
|
4313
|
+
});
|
|
4254
4314
|
}
|
|
4255
4315
|
};
|
|
4256
4316
|
function createOcclusionResolver(trace) {
|
|
@@ -4262,6 +4322,14 @@ function createOcclusionResolver(trace) {
|
|
|
4262
4322
|
var MusicSystem = class {
|
|
4263
4323
|
// Timer handle
|
|
4264
4324
|
constructor(options) {
|
|
4325
|
+
__publicField(this, "createElement");
|
|
4326
|
+
__publicField(this, "resolveSource");
|
|
4327
|
+
__publicField(this, "crossfadeDuration");
|
|
4328
|
+
__publicField(this, "currentElement");
|
|
4329
|
+
__publicField(this, "fadingElement");
|
|
4330
|
+
__publicField(this, "track");
|
|
4331
|
+
__publicField(this, "volume");
|
|
4332
|
+
__publicField(this, "fadeInterval");
|
|
4265
4333
|
this.createElement = options.createElement;
|
|
4266
4334
|
this.resolveSource = options.resolveSource ?? (async (path) => path);
|
|
4267
4335
|
this.volume = options.volume ?? 1;
|
|
@@ -4505,8 +4573,11 @@ function linkProgram(gl, vertexShader, fragmentShader, attributeLocations) {
|
|
|
4505
4573
|
}
|
|
4506
4574
|
var ShaderProgram = class _ShaderProgram {
|
|
4507
4575
|
constructor(gl, program, sourceSize) {
|
|
4508
|
-
this
|
|
4509
|
-
this
|
|
4576
|
+
__publicField(this, "gl");
|
|
4577
|
+
__publicField(this, "program");
|
|
4578
|
+
__publicField(this, "uniformLocations", /* @__PURE__ */ new Map());
|
|
4579
|
+
__publicField(this, "attributeLocations", /* @__PURE__ */ new Map());
|
|
4580
|
+
__publicField(this, "sourceSize");
|
|
4510
4581
|
this.gl = gl;
|
|
4511
4582
|
this.program = program;
|
|
4512
4583
|
this.sourceSize = sourceSize;
|
|
@@ -4553,6 +4624,9 @@ function createProgramFromSources(gl, sources, attributeLocations) {
|
|
|
4553
4624
|
// src/render/resources.ts
|
|
4554
4625
|
var VertexBuffer = class {
|
|
4555
4626
|
constructor(gl, usage = gl.STATIC_DRAW, target) {
|
|
4627
|
+
__publicField(this, "gl");
|
|
4628
|
+
__publicField(this, "buffer");
|
|
4629
|
+
__publicField(this, "target");
|
|
4556
4630
|
this.gl = gl;
|
|
4557
4631
|
this.target = target ?? gl.ARRAY_BUFFER;
|
|
4558
4632
|
const buffer = gl.createBuffer();
|
|
@@ -4585,6 +4659,8 @@ var IndexBuffer = class extends VertexBuffer {
|
|
|
4585
4659
|
};
|
|
4586
4660
|
var VertexArray = class {
|
|
4587
4661
|
constructor(gl) {
|
|
4662
|
+
__publicField(this, "gl");
|
|
4663
|
+
__publicField(this, "vao");
|
|
4588
4664
|
this.gl = gl;
|
|
4589
4665
|
const vao = gl.createVertexArray();
|
|
4590
4666
|
if (!vao) {
|
|
@@ -4621,8 +4697,11 @@ var VertexArray = class {
|
|
|
4621
4697
|
};
|
|
4622
4698
|
var Texture2D = class {
|
|
4623
4699
|
constructor(gl, target = gl.TEXTURE_2D) {
|
|
4624
|
-
this
|
|
4625
|
-
this
|
|
4700
|
+
__publicField(this, "gl");
|
|
4701
|
+
__publicField(this, "texture");
|
|
4702
|
+
__publicField(this, "target");
|
|
4703
|
+
__publicField(this, "width", 0);
|
|
4704
|
+
__publicField(this, "height", 0);
|
|
4626
4705
|
this.gl = gl;
|
|
4627
4706
|
this.target = target;
|
|
4628
4707
|
const texture = gl.createTexture();
|
|
@@ -4665,6 +4744,9 @@ var Texture2D = class {
|
|
|
4665
4744
|
};
|
|
4666
4745
|
var TextureCubeMap = class {
|
|
4667
4746
|
constructor(gl) {
|
|
4747
|
+
__publicField(this, "gl");
|
|
4748
|
+
__publicField(this, "texture");
|
|
4749
|
+
__publicField(this, "target");
|
|
4668
4750
|
this.gl = gl;
|
|
4669
4751
|
this.target = gl.TEXTURE_CUBE_MAP;
|
|
4670
4752
|
const texture = gl.createTexture();
|
|
@@ -4702,6 +4784,8 @@ var TextureCubeMap = class {
|
|
|
4702
4784
|
};
|
|
4703
4785
|
var Framebuffer = class {
|
|
4704
4786
|
constructor(gl) {
|
|
4787
|
+
__publicField(this, "gl");
|
|
4788
|
+
__publicField(this, "framebuffer");
|
|
4705
4789
|
this.gl = gl;
|
|
4706
4790
|
const framebuffer = gl.createFramebuffer();
|
|
4707
4791
|
if (!framebuffer) {
|
|
@@ -5231,7 +5315,7 @@ function gatherVisibleFaces(map, cameraPosition, frustum, portalState) {
|
|
|
5231
5315
|
var MAX_DLIGHTS = 32;
|
|
5232
5316
|
var DynamicLightManager = class {
|
|
5233
5317
|
constructor() {
|
|
5234
|
-
this
|
|
5318
|
+
__publicField(this, "lights", []);
|
|
5235
5319
|
}
|
|
5236
5320
|
/**
|
|
5237
5321
|
* Adds a dynamic light or updates an existing one with the same key.
|
|
@@ -5535,7 +5619,33 @@ function deriveSurfaceRenderState(surfaceFlags = SURF_NONE, timeSeconds = 0) {
|
|
|
5535
5619
|
}
|
|
5536
5620
|
var BspSurfacePipeline = class {
|
|
5537
5621
|
constructor(gl) {
|
|
5538
|
-
this
|
|
5622
|
+
__publicField(this, "gl");
|
|
5623
|
+
__publicField(this, "program");
|
|
5624
|
+
__publicField(this, "uniformMvp");
|
|
5625
|
+
__publicField(this, "uniformTexScroll");
|
|
5626
|
+
__publicField(this, "uniformLmScroll");
|
|
5627
|
+
__publicField(this, "uniformLightStyles");
|
|
5628
|
+
__publicField(this, "uniformStyleLayerMapping");
|
|
5629
|
+
__publicField(this, "uniformAlpha");
|
|
5630
|
+
__publicField(this, "uniformApplyLightmap");
|
|
5631
|
+
__publicField(this, "uniformWarp");
|
|
5632
|
+
__publicField(this, "uniformLightmapOnly");
|
|
5633
|
+
__publicField(this, "uniformDiffuse");
|
|
5634
|
+
__publicField(this, "uniformLightmap");
|
|
5635
|
+
__publicField(this, "uniformRefraction");
|
|
5636
|
+
// New
|
|
5637
|
+
__publicField(this, "uniformHasRefraction");
|
|
5638
|
+
// New
|
|
5639
|
+
__publicField(this, "uniformTime");
|
|
5640
|
+
__publicField(this, "uniformRenderMode");
|
|
5641
|
+
__publicField(this, "uniformSolidColor");
|
|
5642
|
+
__publicField(this, "uniformNumDlights");
|
|
5643
|
+
__publicField(this, "uniformDlights", []);
|
|
5644
|
+
// Lighting controls uniforms
|
|
5645
|
+
__publicField(this, "uniformBrightness");
|
|
5646
|
+
__publicField(this, "uniformGamma");
|
|
5647
|
+
__publicField(this, "uniformFullbright");
|
|
5648
|
+
__publicField(this, "uniformAmbient");
|
|
5539
5649
|
this.gl = gl;
|
|
5540
5650
|
this.program = ShaderProgram.create(
|
|
5541
5651
|
gl,
|
|
@@ -5847,6 +5957,14 @@ void main() {
|
|
|
5847
5957
|
}`;
|
|
5848
5958
|
var SkyboxPipeline = class {
|
|
5849
5959
|
constructor(gl) {
|
|
5960
|
+
__publicField(this, "gl");
|
|
5961
|
+
__publicField(this, "program");
|
|
5962
|
+
__publicField(this, "vao");
|
|
5963
|
+
__publicField(this, "vbo");
|
|
5964
|
+
__publicField(this, "cubemap");
|
|
5965
|
+
__publicField(this, "uniformViewProj");
|
|
5966
|
+
__publicField(this, "uniformScroll");
|
|
5967
|
+
__publicField(this, "uniformSampler");
|
|
5850
5968
|
this.gl = gl;
|
|
5851
5969
|
this.program = ShaderProgram.create(
|
|
5852
5970
|
gl,
|
|
@@ -6118,6 +6236,14 @@ function buildMd2VertexData(model, geometry, blend) {
|
|
|
6118
6236
|
}
|
|
6119
6237
|
var Md2MeshBuffers = class {
|
|
6120
6238
|
constructor(gl, model, blend) {
|
|
6239
|
+
__publicField(this, "gl");
|
|
6240
|
+
__publicField(this, "geometry");
|
|
6241
|
+
__publicField(this, "vertexBuffer");
|
|
6242
|
+
__publicField(this, "indexBuffer");
|
|
6243
|
+
__publicField(this, "vertexArray");
|
|
6244
|
+
__publicField(this, "indexCount");
|
|
6245
|
+
__publicField(this, "wireframeIndexBuffer");
|
|
6246
|
+
__publicField(this, "wireframeIndexCount");
|
|
6121
6247
|
this.gl = gl;
|
|
6122
6248
|
this.geometry = buildMd2Geometry(model);
|
|
6123
6249
|
this.vertexBuffer = new VertexBuffer(gl, gl.STATIC_DRAW);
|
|
@@ -6154,7 +6280,23 @@ var Md2MeshBuffers = class {
|
|
|
6154
6280
|
};
|
|
6155
6281
|
var Md2Pipeline = class {
|
|
6156
6282
|
constructor(gl) {
|
|
6157
|
-
this
|
|
6283
|
+
__publicField(this, "gl");
|
|
6284
|
+
__publicField(this, "program");
|
|
6285
|
+
__publicField(this, "uniformMvp");
|
|
6286
|
+
__publicField(this, "uniformModelMatrix");
|
|
6287
|
+
__publicField(this, "uniformLightDir");
|
|
6288
|
+
__publicField(this, "uniformAmbient");
|
|
6289
|
+
__publicField(this, "uniformTint");
|
|
6290
|
+
__publicField(this, "uniformDiffuse");
|
|
6291
|
+
__publicField(this, "uniformRenderMode");
|
|
6292
|
+
__publicField(this, "uniformSolidColor");
|
|
6293
|
+
__publicField(this, "uniformNumDlights");
|
|
6294
|
+
__publicField(this, "uniformDlights", []);
|
|
6295
|
+
// Lighting controls
|
|
6296
|
+
__publicField(this, "uniformBrightness");
|
|
6297
|
+
__publicField(this, "uniformGamma");
|
|
6298
|
+
__publicField(this, "uniformFullbright");
|
|
6299
|
+
__publicField(this, "uniformGlobalAmbient");
|
|
6158
6300
|
this.gl = gl;
|
|
6159
6301
|
this.program = ShaderProgram.create(
|
|
6160
6302
|
gl,
|
|
@@ -6259,21 +6401,23 @@ var Md2Pipeline = class {
|
|
|
6259
6401
|
};
|
|
6260
6402
|
var Camera = class {
|
|
6261
6403
|
constructor(width, height) {
|
|
6262
|
-
this
|
|
6263
|
-
this
|
|
6404
|
+
__publicField(this, "_position", vec3.create());
|
|
6405
|
+
__publicField(this, "_angles", vec3.create());
|
|
6264
6406
|
// pitch, yaw, roll
|
|
6265
|
-
this
|
|
6266
|
-
this
|
|
6267
|
-
this
|
|
6268
|
-
this
|
|
6269
|
-
this
|
|
6270
|
-
this
|
|
6271
|
-
this
|
|
6272
|
-
this
|
|
6273
|
-
this
|
|
6274
|
-
this
|
|
6275
|
-
this
|
|
6276
|
-
this
|
|
6407
|
+
__publicField(this, "_bobAngles", vec3.create());
|
|
6408
|
+
__publicField(this, "_bobOffset", vec3.create());
|
|
6409
|
+
__publicField(this, "_kickAngles", vec3.create());
|
|
6410
|
+
__publicField(this, "_rollAngle", 0);
|
|
6411
|
+
__publicField(this, "_fov", 90);
|
|
6412
|
+
__publicField(this, "_aspect", 1);
|
|
6413
|
+
__publicField(this, "_near", 0.1);
|
|
6414
|
+
__publicField(this, "_far", 1e3);
|
|
6415
|
+
__publicField(this, "_viewMatrix", mat4.create());
|
|
6416
|
+
__publicField(this, "_projectionMatrix", mat4.create());
|
|
6417
|
+
__publicField(this, "_viewProjectionMatrix", mat4.create());
|
|
6418
|
+
__publicField(this, "_dirty", true);
|
|
6419
|
+
// Event callback
|
|
6420
|
+
__publicField(this, "onCameraMove");
|
|
6277
6421
|
if (width !== void 0 && height !== void 0 && height > 0) {
|
|
6278
6422
|
this._aspect = width / height;
|
|
6279
6423
|
}
|
|
@@ -6715,6 +6859,14 @@ void main() {
|
|
|
6715
6859
|
}`;
|
|
6716
6860
|
var Md3SurfaceMesh = class {
|
|
6717
6861
|
constructor(gl, surface, blend, lighting) {
|
|
6862
|
+
__publicField(this, "gl");
|
|
6863
|
+
__publicField(this, "geometry");
|
|
6864
|
+
__publicField(this, "vertexBuffer");
|
|
6865
|
+
__publicField(this, "indexBuffer");
|
|
6866
|
+
__publicField(this, "vertexArray");
|
|
6867
|
+
__publicField(this, "indexCount");
|
|
6868
|
+
__publicField(this, "wireframeIndexBuffer");
|
|
6869
|
+
__publicField(this, "wireframeIndexCount");
|
|
6718
6870
|
this.gl = gl;
|
|
6719
6871
|
this.geometry = buildMd3SurfaceGeometry(surface);
|
|
6720
6872
|
this.vertexBuffer = new VertexBuffer(gl, gl.STATIC_DRAW);
|
|
@@ -6752,7 +6904,11 @@ var Md3SurfaceMesh = class {
|
|
|
6752
6904
|
};
|
|
6753
6905
|
var Md3ModelMesh = class {
|
|
6754
6906
|
constructor(gl, model, blend, lighting) {
|
|
6755
|
-
this
|
|
6907
|
+
__publicField(this, "surfaces", /* @__PURE__ */ new Map());
|
|
6908
|
+
__publicField(this, "gl");
|
|
6909
|
+
__publicField(this, "model");
|
|
6910
|
+
__publicField(this, "blend");
|
|
6911
|
+
__publicField(this, "lighting");
|
|
6756
6912
|
this.gl = gl;
|
|
6757
6913
|
this.model = model;
|
|
6758
6914
|
this.blend = blend;
|
|
@@ -6778,6 +6934,18 @@ var Md3ModelMesh = class {
|
|
|
6778
6934
|
};
|
|
6779
6935
|
var Md3Pipeline = class {
|
|
6780
6936
|
constructor(gl) {
|
|
6937
|
+
__publicField(this, "gl");
|
|
6938
|
+
__publicField(this, "program");
|
|
6939
|
+
__publicField(this, "uniformMvp");
|
|
6940
|
+
__publicField(this, "uniformTint");
|
|
6941
|
+
__publicField(this, "uniformDiffuse");
|
|
6942
|
+
__publicField(this, "uniformRenderMode");
|
|
6943
|
+
__publicField(this, "uniformSolidColor");
|
|
6944
|
+
// Lighting controls
|
|
6945
|
+
__publicField(this, "uniformBrightness");
|
|
6946
|
+
__publicField(this, "uniformGamma");
|
|
6947
|
+
__publicField(this, "uniformFullbright");
|
|
6948
|
+
__publicField(this, "uniformGlobalAmbient");
|
|
6781
6949
|
this.gl = gl;
|
|
6782
6950
|
this.program = ShaderProgram.create(
|
|
6783
6951
|
gl,
|
|
@@ -6854,6 +7022,29 @@ var Md3Pipeline = class {
|
|
|
6854
7022
|
var DEFAULT_COLOR = [1, 1, 1, 1];
|
|
6855
7023
|
var ParticleSystem = class {
|
|
6856
7024
|
constructor(maxParticles, rng) {
|
|
7025
|
+
__publicField(this, "maxParticles");
|
|
7026
|
+
__publicField(this, "rng");
|
|
7027
|
+
__publicField(this, "alive");
|
|
7028
|
+
__publicField(this, "positionX");
|
|
7029
|
+
__publicField(this, "positionY");
|
|
7030
|
+
__publicField(this, "positionZ");
|
|
7031
|
+
__publicField(this, "velocityX");
|
|
7032
|
+
__publicField(this, "velocityY");
|
|
7033
|
+
__publicField(this, "velocityZ");
|
|
7034
|
+
__publicField(this, "colorR");
|
|
7035
|
+
__publicField(this, "colorG");
|
|
7036
|
+
__publicField(this, "colorB");
|
|
7037
|
+
__publicField(this, "colorA");
|
|
7038
|
+
__publicField(this, "size");
|
|
7039
|
+
__publicField(this, "lifetime");
|
|
7040
|
+
__publicField(this, "remaining");
|
|
7041
|
+
__publicField(this, "gravity");
|
|
7042
|
+
__publicField(this, "damping");
|
|
7043
|
+
__publicField(this, "bounce");
|
|
7044
|
+
__publicField(this, "fade");
|
|
7045
|
+
__publicField(this, "blendMode");
|
|
7046
|
+
// 0 alpha, 1 additive
|
|
7047
|
+
__publicField(this, "textureIndex");
|
|
6857
7048
|
this.maxParticles = maxParticles;
|
|
6858
7049
|
this.rng = rng;
|
|
6859
7050
|
this.alive = new Uint8Array(maxParticles);
|
|
@@ -7072,8 +7263,14 @@ void main() {
|
|
|
7072
7263
|
}`;
|
|
7073
7264
|
var ParticleRenderer = class {
|
|
7074
7265
|
constructor(gl, system) {
|
|
7075
|
-
this
|
|
7076
|
-
this
|
|
7266
|
+
__publicField(this, "gl");
|
|
7267
|
+
__publicField(this, "program");
|
|
7268
|
+
__publicField(this, "system");
|
|
7269
|
+
__publicField(this, "vertexBuffer");
|
|
7270
|
+
__publicField(this, "indexBuffer");
|
|
7271
|
+
__publicField(this, "vertexArray");
|
|
7272
|
+
__publicField(this, "vertexCapacity", 0);
|
|
7273
|
+
__publicField(this, "indexCapacity", 0);
|
|
7077
7274
|
this.gl = gl;
|
|
7078
7275
|
this.system = system;
|
|
7079
7276
|
this.program = ShaderProgram.create(gl, { vertex: PARTICLE_VERTEX_SHADER, fragment: PARTICLE_FRAGMENT_SHADER });
|
|
@@ -7510,6 +7707,12 @@ void main() {
|
|
|
7510
7707
|
`;
|
|
7511
7708
|
var PostProcessPipeline = class {
|
|
7512
7709
|
constructor(gl) {
|
|
7710
|
+
__publicField(this, "gl");
|
|
7711
|
+
__publicField(this, "program");
|
|
7712
|
+
__publicField(this, "vao");
|
|
7713
|
+
__publicField(this, "uTime");
|
|
7714
|
+
__publicField(this, "uStrength");
|
|
7715
|
+
__publicField(this, "uTexture");
|
|
7513
7716
|
this.gl = gl;
|
|
7514
7717
|
this.program = ShaderProgram.create(
|
|
7515
7718
|
gl,
|
|
@@ -7629,8 +7832,17 @@ void main() {
|
|
|
7629
7832
|
`;
|
|
7630
7833
|
var BloomPipeline = class {
|
|
7631
7834
|
constructor(gl) {
|
|
7632
|
-
this
|
|
7633
|
-
this
|
|
7835
|
+
__publicField(this, "gl");
|
|
7836
|
+
__publicField(this, "extractProgram");
|
|
7837
|
+
__publicField(this, "blurProgram");
|
|
7838
|
+
__publicField(this, "compositeProgram");
|
|
7839
|
+
__publicField(this, "vao");
|
|
7840
|
+
__publicField(this, "framebuffer1");
|
|
7841
|
+
__publicField(this, "framebuffer2");
|
|
7842
|
+
__publicField(this, "texture1");
|
|
7843
|
+
__publicField(this, "texture2");
|
|
7844
|
+
__publicField(this, "width", 0);
|
|
7845
|
+
__publicField(this, "height", 0);
|
|
7634
7846
|
this.gl = gl;
|
|
7635
7847
|
this.extractProgram = ShaderProgram.create(gl, { vertex: QUAD_VERTEX_SOURCE, fragment: EXTRACT_FRAGMENT_SOURCE }, { a_position: 0 });
|
|
7636
7848
|
this.blurProgram = ShaderProgram.create(gl, { vertex: QUAD_VERTEX_SOURCE, fragment: BLUR_FRAGMENT_SOURCE }, { a_position: 0 });
|
|
@@ -8056,6 +8268,14 @@ void main() {
|
|
|
8056
8268
|
}`;
|
|
8057
8269
|
var SpriteRenderer = class {
|
|
8058
8270
|
constructor(gl) {
|
|
8271
|
+
__publicField(this, "gl");
|
|
8272
|
+
__publicField(this, "program");
|
|
8273
|
+
__publicField(this, "vao");
|
|
8274
|
+
__publicField(this, "vbo");
|
|
8275
|
+
__publicField(this, "whiteTexture");
|
|
8276
|
+
__publicField(this, "uniformProjection");
|
|
8277
|
+
__publicField(this, "uniformDiffuse");
|
|
8278
|
+
__publicField(this, "uniformTint");
|
|
8059
8279
|
this.gl = gl;
|
|
8060
8280
|
this.program = ShaderProgram.create(
|
|
8061
8281
|
gl,
|
|
@@ -8144,7 +8364,12 @@ void main() {
|
|
|
8144
8364
|
}`;
|
|
8145
8365
|
var CollisionVisRenderer = class {
|
|
8146
8366
|
constructor(gl) {
|
|
8147
|
-
this
|
|
8367
|
+
__publicField(this, "gl");
|
|
8368
|
+
__publicField(this, "program");
|
|
8369
|
+
__publicField(this, "vao");
|
|
8370
|
+
__publicField(this, "vbo");
|
|
8371
|
+
__publicField(this, "vertices", []);
|
|
8372
|
+
__publicField(this, "uniformViewProjection");
|
|
8148
8373
|
this.gl = gl;
|
|
8149
8374
|
this.program = ShaderProgram.create(
|
|
8150
8375
|
gl,
|
|
@@ -8318,17 +8543,20 @@ function calculateEntityLight(map, origin) {
|
|
|
8318
8543
|
// src/render/gpuProfiler.ts
|
|
8319
8544
|
var GpuProfiler = class {
|
|
8320
8545
|
constructor(gl) {
|
|
8321
|
-
this
|
|
8322
|
-
|
|
8323
|
-
this
|
|
8324
|
-
this
|
|
8546
|
+
__publicField(this, "ext");
|
|
8547
|
+
// EXT_disjoint_timer_query_webgl2
|
|
8548
|
+
__publicField(this, "gl");
|
|
8549
|
+
__publicField(this, "activeQueries", []);
|
|
8550
|
+
__publicField(this, "queryPool", []);
|
|
8551
|
+
__publicField(this, "currentQuery", null);
|
|
8552
|
+
__publicField(this, "lastGpuTimeMs", 0);
|
|
8325
8553
|
// CPU-side counters
|
|
8326
|
-
this
|
|
8327
|
-
this
|
|
8554
|
+
__publicField(this, "frameStartTime", 0);
|
|
8555
|
+
__publicField(this, "lastCpuFrameTimeMs", 0);
|
|
8328
8556
|
// Resource Tracking
|
|
8329
|
-
this
|
|
8330
|
-
this
|
|
8331
|
-
this
|
|
8557
|
+
__publicField(this, "textureMemoryBytes", 0);
|
|
8558
|
+
__publicField(this, "bufferMemoryBytes", 0);
|
|
8559
|
+
__publicField(this, "shaderMemoryBytes", 0);
|
|
8332
8560
|
this.gl = gl;
|
|
8333
8561
|
this.ext = gl.getExtension("EXT_disjoint_timer_query_webgl2");
|
|
8334
8562
|
}
|
|
@@ -8542,9 +8770,16 @@ function fromGlVec3(v) {
|
|
|
8542
8770
|
}
|
|
8543
8771
|
var DebugRenderer = class {
|
|
8544
8772
|
constructor(gl) {
|
|
8545
|
-
this
|
|
8546
|
-
this
|
|
8547
|
-
this
|
|
8773
|
+
__publicField(this, "gl");
|
|
8774
|
+
__publicField(this, "shader");
|
|
8775
|
+
__publicField(this, "vao");
|
|
8776
|
+
__publicField(this, "vbo");
|
|
8777
|
+
__publicField(this, "shaderSolid");
|
|
8778
|
+
__publicField(this, "vaoSolid");
|
|
8779
|
+
__publicField(this, "vboSolid");
|
|
8780
|
+
__publicField(this, "vertices", []);
|
|
8781
|
+
__publicField(this, "solidVertices", []);
|
|
8782
|
+
__publicField(this, "labels", []);
|
|
8548
8783
|
this.gl = gl;
|
|
8549
8784
|
this.shader = ShaderProgram.create(gl, { vertex: VS_SOURCE, fragment: FS_SOURCE });
|
|
8550
8785
|
this.vao = new VertexArray(gl);
|
|
@@ -9736,15 +9971,15 @@ var FrameRenderer = class {
|
|
|
9736
9971
|
constructor(context, pipelines) {
|
|
9737
9972
|
this.context = context;
|
|
9738
9973
|
this.pipelines = pipelines;
|
|
9739
|
-
this
|
|
9740
|
-
this
|
|
9974
|
+
__publicField(this, "depthTexture", null);
|
|
9975
|
+
__publicField(this, "copyTexture", null);
|
|
9741
9976
|
// Separate texture for headless output if no context exists
|
|
9742
|
-
this
|
|
9743
|
-
this
|
|
9744
|
-
this
|
|
9745
|
-
this
|
|
9977
|
+
__publicField(this, "headlessTarget", null);
|
|
9978
|
+
__publicField(this, "lastWidth", 0);
|
|
9979
|
+
__publicField(this, "lastHeight", 0);
|
|
9980
|
+
__publicField(this, "lastFrameTime", 0);
|
|
9746
9981
|
// Current frame context (available during frame rendering)
|
|
9747
|
-
this
|
|
9982
|
+
__publicField(this, "currentFrameContext", null);
|
|
9748
9983
|
}
|
|
9749
9984
|
ensureDepthTexture(width, height) {
|
|
9750
9985
|
if (this.depthTexture && this.lastWidth === width && this.lastHeight === height) {
|
|
@@ -9949,7 +10184,9 @@ var FrameRenderer = class {
|
|
|
9949
10184
|
gamma,
|
|
9950
10185
|
fullbright,
|
|
9951
10186
|
ambient,
|
|
9952
|
-
cameraPosition: options.camera.position
|
|
10187
|
+
cameraPosition: options.camera.position,
|
|
10188
|
+
// Workaround for worldPos offset bug: pass surface mins for shader correction
|
|
10189
|
+
surfaceMins: geometry.mins
|
|
9953
10190
|
});
|
|
9954
10191
|
this.pipelines.bsp.draw(pass, geometry, renderMode);
|
|
9955
10192
|
stats.facesDrawn++;
|
|
@@ -10030,6 +10267,9 @@ fn fs_main(in: VSOutput) -> @location(0) vec4f {
|
|
|
10030
10267
|
var GPUBufferResource = class {
|
|
10031
10268
|
constructor(device, descriptor) {
|
|
10032
10269
|
this.device = device;
|
|
10270
|
+
__publicField(this, "buffer");
|
|
10271
|
+
__publicField(this, "size");
|
|
10272
|
+
__publicField(this, "usage");
|
|
10033
10273
|
this.size = Math.ceil(descriptor.size / 4) * 4;
|
|
10034
10274
|
this.usage = descriptor.usage;
|
|
10035
10275
|
this.buffer = device.createBuffer({
|
|
@@ -10115,9 +10355,7 @@ function getBlockSize(format) {
|
|
|
10115
10355
|
case "rgba16float":
|
|
10116
10356
|
case "rgba16sint":
|
|
10117
10357
|
case "rgba16uint":
|
|
10118
|
-
case "rgba32float":
|
|
10119
10358
|
return 8;
|
|
10120
|
-
// wait, rgba16 is 8 bytes. rgba32 is 16 bytes.
|
|
10121
10359
|
case "rgba32float":
|
|
10122
10360
|
case "rgba32sint":
|
|
10123
10361
|
case "rgba32uint":
|
|
@@ -10134,6 +10372,10 @@ function getBlockSize(format) {
|
|
|
10134
10372
|
var _Texture2D = class _Texture2D {
|
|
10135
10373
|
constructor(device, descriptor) {
|
|
10136
10374
|
this.device = device;
|
|
10375
|
+
__publicField(this, "texture");
|
|
10376
|
+
__publicField(this, "width");
|
|
10377
|
+
__publicField(this, "height");
|
|
10378
|
+
__publicField(this, "format");
|
|
10137
10379
|
this.width = descriptor.width;
|
|
10138
10380
|
this.height = descriptor.height;
|
|
10139
10381
|
this.format = descriptor.format;
|
|
@@ -10270,11 +10512,12 @@ var _Texture2D = class _Texture2D {
|
|
|
10270
10512
|
}
|
|
10271
10513
|
};
|
|
10272
10514
|
// Cache pipelines per device and per format
|
|
10273
|
-
_Texture2D
|
|
10274
|
-
_Texture2D
|
|
10515
|
+
__publicField(_Texture2D, "mipmapPipelines", /* @__PURE__ */ new WeakMap());
|
|
10516
|
+
__publicField(_Texture2D, "mipmapSamplers", /* @__PURE__ */ new WeakMap());
|
|
10275
10517
|
var Texture2D2 = _Texture2D;
|
|
10276
10518
|
var Sampler = class {
|
|
10277
10519
|
constructor(device, descriptor) {
|
|
10520
|
+
__publicField(this, "sampler");
|
|
10278
10521
|
this.sampler = device.createSampler({
|
|
10279
10522
|
...descriptor,
|
|
10280
10523
|
label: descriptor.label
|
|
@@ -10294,6 +10537,7 @@ function createLinearSampler(device) {
|
|
|
10294
10537
|
var ShaderModule = class {
|
|
10295
10538
|
constructor(device, descriptor) {
|
|
10296
10539
|
this.device = device;
|
|
10540
|
+
__publicField(this, "module");
|
|
10297
10541
|
this.module = device.createShaderModule({
|
|
10298
10542
|
code: descriptor.code,
|
|
10299
10543
|
label: descriptor.label
|
|
@@ -10306,6 +10550,7 @@ var ShaderModule = class {
|
|
|
10306
10550
|
var RenderPipeline = class {
|
|
10307
10551
|
constructor(device, descriptor) {
|
|
10308
10552
|
this.device = device;
|
|
10553
|
+
__publicField(this, "pipeline");
|
|
10309
10554
|
const layout = descriptor.layout;
|
|
10310
10555
|
this.pipeline = device.createRenderPipeline({
|
|
10311
10556
|
layout,
|
|
@@ -10334,6 +10579,7 @@ var RenderPipeline = class {
|
|
|
10334
10579
|
var BindGroupLayout = class {
|
|
10335
10580
|
constructor(device, descriptor) {
|
|
10336
10581
|
this.device = device;
|
|
10582
|
+
__publicField(this, "layout");
|
|
10337
10583
|
this.layout = device.createBindGroupLayout({
|
|
10338
10584
|
entries: descriptor.entries,
|
|
10339
10585
|
label: descriptor.label
|
|
@@ -10343,6 +10589,7 @@ var BindGroupLayout = class {
|
|
|
10343
10589
|
var BindGroup = class {
|
|
10344
10590
|
constructor(device, layout, entries, label) {
|
|
10345
10591
|
this.device = device;
|
|
10592
|
+
__publicField(this, "bindGroup");
|
|
10346
10593
|
const gpuEntries = entries.map((entry) => {
|
|
10347
10594
|
let resource;
|
|
10348
10595
|
if (entry.resource instanceof GPUBufferResource) {
|
|
@@ -10369,7 +10616,7 @@ var BindGroup = class {
|
|
|
10369
10616
|
var BindGroupBuilder = class {
|
|
10370
10617
|
constructor(label) {
|
|
10371
10618
|
this.label = label;
|
|
10372
|
-
this
|
|
10619
|
+
__publicField(this, "entries", []);
|
|
10373
10620
|
}
|
|
10374
10621
|
addUniformBuffer(binding, visibility) {
|
|
10375
10622
|
this.entries.push({
|
|
@@ -10467,13 +10714,24 @@ var SpriteRenderer2 = class {
|
|
|
10467
10714
|
constructor(device, format) {
|
|
10468
10715
|
this.device = device;
|
|
10469
10716
|
this.format = format;
|
|
10470
|
-
this
|
|
10471
|
-
this
|
|
10472
|
-
this
|
|
10473
|
-
this
|
|
10474
|
-
this
|
|
10475
|
-
this
|
|
10476
|
-
this
|
|
10717
|
+
__publicField(this, "pipelineTextured");
|
|
10718
|
+
__publicField(this, "pipelineSolid");
|
|
10719
|
+
__publicField(this, "vertexBuffer");
|
|
10720
|
+
__publicField(this, "indexBuffer");
|
|
10721
|
+
__publicField(this, "uniformBuffer");
|
|
10722
|
+
__publicField(this, "uniformBindGroup");
|
|
10723
|
+
__publicField(this, "textureBindGroupLayout");
|
|
10724
|
+
__publicField(this, "defaultSampler");
|
|
10725
|
+
__publicField(this, "projectionMatrix");
|
|
10726
|
+
// Batching state
|
|
10727
|
+
__publicField(this, "vertexData");
|
|
10728
|
+
__publicField(this, "currentVertexCount", 0);
|
|
10729
|
+
__publicField(this, "currentIndexCount", 0);
|
|
10730
|
+
__publicField(this, "currentTexture", null);
|
|
10731
|
+
__publicField(this, "drawCommands", []);
|
|
10732
|
+
__publicField(this, "textureBindGroups", /* @__PURE__ */ new Map());
|
|
10733
|
+
__publicField(this, "_activeEncoder", null);
|
|
10734
|
+
__publicField(this, "_activeRenderTarget", null);
|
|
10477
10735
|
const shaderModule = new ShaderModule(device, {
|
|
10478
10736
|
code: SPRITE_SHADER,
|
|
10479
10737
|
label: "sprite-shader"
|
|
@@ -10757,7 +11015,7 @@ var CoordinateSystem = /* @__PURE__ */ ((CoordinateSystem2) => {
|
|
|
10757
11015
|
// src/render/matrix/webgpu.ts
|
|
10758
11016
|
var WebGPUMatrixBuilder = class {
|
|
10759
11017
|
constructor() {
|
|
10760
|
-
this
|
|
11018
|
+
__publicField(this, "coordinateSystem", "webgpu" /* WEBGPU */);
|
|
10761
11019
|
}
|
|
10762
11020
|
buildProjectionMatrix(camera) {
|
|
10763
11021
|
const projection = mat4.create();
|
|
@@ -10865,6 +11123,12 @@ var SkyboxPipeline3 = class {
|
|
|
10865
11123
|
constructor(device, format) {
|
|
10866
11124
|
this.device = device;
|
|
10867
11125
|
this.format = format;
|
|
11126
|
+
__publicField(this, "pipeline");
|
|
11127
|
+
__publicField(this, "vertexBuffer");
|
|
11128
|
+
__publicField(this, "bindGroupHelper");
|
|
11129
|
+
__publicField(this, "uniformBuffer");
|
|
11130
|
+
__publicField(this, "sampler");
|
|
11131
|
+
__publicField(this, "matrixBuilder");
|
|
10868
11132
|
this.matrixBuilder = new WebGPUMatrixBuilder();
|
|
10869
11133
|
const module = device.createShaderModule({
|
|
10870
11134
|
label: "skybox-shader",
|
|
@@ -11020,7 +11284,7 @@ var SkyboxBindGroupHelper = class {
|
|
|
11020
11284
|
this.layout = layout;
|
|
11021
11285
|
this.uniformBuffer = uniformBuffer;
|
|
11022
11286
|
this.sampler = sampler;
|
|
11023
|
-
this
|
|
11287
|
+
__publicField(this, "bindGroupCache", /* @__PURE__ */ new Map());
|
|
11024
11288
|
}
|
|
11025
11289
|
getBindGroup(cubemap) {
|
|
11026
11290
|
if (this.bindGroupCache.has(cubemap)) {
|
|
@@ -11049,7 +11313,7 @@ var SkyboxBindGroupHelper = class {
|
|
|
11049
11313
|
};
|
|
11050
11314
|
|
|
11051
11315
|
// raw-loader:/home/runner/work/quake2/quake2/quake2ts/packages/engine/src/render/webgpu/shaders/bsp.wgsl
|
|
11052
|
-
var bsp_default = "struct DLight {\n position: vec3<f32>,\n intensity: f32,\n color: vec3<f32>,\n padding: f32,\n}\n\nstruct FrameUniforms {\n viewProjection: mat4x4<f32>, // 0-64\n cameraPosition: vec3<f32>, // 64-76\n pad0: f32, // 76-80 (Explicit padding to align next field to 80)\n time: f32, // 80-84\n brightness: f32, // 84-88\n gamma: f32, // 88-92\n ambient: f32, // 92-96\n numDlights: u32, // 96-100\n fullbright: u32, // 100-104\n pad1: vec2<f32>, // 104-112 (Aligns next field to 112)\n pad2: vec4<f32>, // 112-128 (Aligns next field to 128)\n dlights: array<DLight, 32>, // Starts at 128\n}\n\nstruct SurfaceUniforms {\n texScroll: vec2<f32>,\n lightmapScroll: vec2<f32>,\n lightStyleFactors: vec4<f32>,\n styleLayerMapping: vec4<f32>,\n solidColor: vec4<f32>,\n alpha: f32,\n applyLightmap: u32,\n warp: u32,\n lightmapOnly: u32,\n renderMode: u32, // 0: Texture, 1: Solid, 2: Faceted\n
|
|
11316
|
+
var bsp_default = "struct DLight {\n position: vec3<f32>,\n intensity: f32,\n color: vec3<f32>,\n padding: f32,\n}\n\nstruct FrameUniforms {\n viewProjection: mat4x4<f32>, // 0-64\n cameraPosition: vec3<f32>, // 64-76\n pad0: f32, // 76-80 (Explicit padding to align next field to 80)\n time: f32, // 80-84\n brightness: f32, // 84-88\n gamma: f32, // 88-92\n ambient: f32, // 92-96\n numDlights: u32, // 96-100\n fullbright: u32, // 100-104\n pad1: vec2<f32>, // 104-112 (Aligns next field to 112)\n pad2: vec4<f32>, // 112-128 (Aligns next field to 128)\n dlights: array<DLight, 32>, // Starts at 128\n}\n\nstruct SurfaceUniforms {\n texScroll: vec2<f32>,\n lightmapScroll: vec2<f32>,\n lightStyleFactors: vec4<f32>,\n styleLayerMapping: vec4<f32>,\n solidColor: vec4<f32>,\n alpha: f32,\n applyLightmap: u32,\n warp: u32,\n lightmapOnly: u32,\n renderMode: u32, // 0: Texture, 1: Solid, 2: Faceted, 3: WorldPos Debug, 4: Distance Debug\n pad0: vec3<f32>,\n // Workaround for worldPos offset bug: surface mins for correction\n surfaceMins: vec3<f32>,\n pad1: f32,\n}\n\n@group(0) @binding(0) var<uniform> frame: FrameUniforms;\n@group(1) @binding(0) var<uniform> surface: SurfaceUniforms;\n@group(2) @binding(0) var diffuseMap: texture_2d<f32>;\n@group(2) @binding(1) var diffuseSampler: sampler;\n@group(2) @binding(2) var lightmapAtlas: texture_2d<f32>;\n@group(2) @binding(3) var lightmapSampler: sampler;\n\nstruct VertexInput {\n @location(0) position: vec3<f32>,\n @location(1) texCoord: vec2<f32>,\n @location(2) lightmapCoord: vec2<f32>,\n @location(3) lightmapStep: f32,\n}\n\nstruct VertexOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) texCoord: vec2<f32>,\n @location(1) lightmapCoord: vec2<f32>,\n @location(2) lightmapStep: f32,\n @location(3) worldPos: vec3<f32>,\n @location(4) screenPos: vec4<f32>,\n}\n\n@vertex\nfn vertexMain(input: VertexInput) -> VertexOutput {\n var output: VertexOutput;\n\n var pos = input.position;\n var tex = input.texCoord;\n var lm = input.lightmapCoord;\n\n // Vertex Warping\n if (surface.warp != 0u) {\n let amp = 0.125;\n let s = tex.x + sin((tex.y * 0.125 + frame.time) * 1.0) * amp;\n let t = tex.y + sin((tex.x * 0.125 + frame.time) * 1.0) * amp;\n tex = vec2<f32>(s, t);\n }\n\n output.texCoord = tex + surface.texScroll;\n output.lightmapCoord = lm + surface.lightmapScroll;\n output.lightmapStep = input.lightmapStep;\n output.worldPos = pos;\n output.position = frame.viewProjection * vec4<f32>(pos, 1.0);\n output.screenPos = output.position;\n\n return output;\n}\n\n@fragment\nfn fragmentMain(input: VertexOutput) -> @location(0) vec4<f32> {\n var finalColor: vec4<f32>;\n\n if (surface.renderMode == 0u) {\n // TEXTURED MODE\n var base = vec4<f32>(1.0, 1.0, 1.0, 1.0);\n if (surface.lightmapOnly == 0u) {\n base = textureSample(diffuseMap, diffuseSampler, input.texCoord);\n }\n\n var totalLight = vec3<f32>(0.0, 0.0, 0.0);\n\n if (frame.fullbright != 0u) {\n totalLight = vec3<f32>(1.0, 1.0, 1.0);\n } else {\n // Apply Lightmaps\n if (surface.applyLightmap != 0u) {\n var hasLight = false;\n for (var i = 0; i < 4; i++) {\n let layer = surface.styleLayerMapping[i];\n let factor = surface.lightStyleFactors[i];\n\n if (layer >= -0.5) {\n let offset = vec2<f32>(0.0, layer * input.lightmapStep);\n totalLight += textureSample(lightmapAtlas, lightmapSampler, input.lightmapCoord + offset).rgb * factor;\n hasLight = true;\n }\n }\n\n // If lightmap enabled but no active layers, fallback to white?\n // Quake 2 logic usually implies at least one style is active if surfaced has SURF_LIGHT\n // But if we have no lightmap data, we start black.\n if (!hasLight) {\n // Fallback to avoid pitch black if lightmap intended but missing?\n // totalLight = vec3<f32>(1.0, 1.0, 1.0);\n }\n }\n\n // Apply Dynamic Lights\n // Workaround: worldPos appears offset by surface.mins, so we add it back\n let correctedWorldPos = input.worldPos + surface.surfaceMins;\n for (var i = 0u; i < 32u; i++) {\n if (i >= frame.numDlights) {\n break;\n }\n let dlight = frame.dlights[i];\n let dist = distance(correctedWorldPos, dlight.position);\n\n if (dist < dlight.intensity) {\n let contribution = (dlight.intensity - dist) * (1.0 / 255.0);\n totalLight += dlight.color * contribution;\n }\n }\n }\n\n totalLight = max(totalLight, vec3<f32>(frame.ambient));\n totalLight *= frame.brightness;\n base = vec4<f32>(base.rgb * totalLight, base.a);\n\n // Gamma correction\n if (frame.gamma != 1.0) {\n base = vec4<f32>(pow(base.rgb, vec3<f32>(1.0 / frame.gamma)), base.a);\n }\n\n finalColor = vec4<f32>(base.rgb, base.a * surface.alpha);\n\n } else if (surface.renderMode == 3u) {\n // DEBUG: Output corrected worldPos as color (scaled to 0-1 range)\n // Map worldPos components: divide by 256 and take fract to visualize\n // Values 0-255 map to 0-1, values 256-511 wrap back to 0-1, etc.\n // Use correctedWorldPos (input.worldPos + surface.surfaceMins) for accurate debug output\n let debugWorldPos = input.worldPos + surface.surfaceMins;\n let posScaled = abs(debugWorldPos) / 256.0;\n finalColor = vec4<f32>(fract(posScaled.x), fract(posScaled.y), fract(posScaled.z), 1.0);\n } else if (surface.renderMode == 4u) {\n // DEBUG: Output distance to first dlight as grayscale\n // Brighter = closer to light. Scale: 0-500 units maps to 1.0-0.0\n // Use correctedWorldPos (input.worldPos + surface.surfaceMins) for accurate distance calculation\n let debugWorldPos = input.worldPos + surface.surfaceMins;\n var dist = 500.0;\n if (frame.numDlights > 0u) {\n dist = distance(debugWorldPos, frame.dlights[0].position);\n }\n let brightness = clamp(1.0 - dist / 500.0, 0.0, 1.0);\n finalColor = vec4<f32>(brightness, brightness, brightness, 1.0);\n } else {\n // SOLID / WIREFRAME / FACETED\n var color = surface.solidColor.rgb;\n if (surface.renderMode == 2u) {\n // FACETED\n let fdx = dpdx(input.worldPos);\n let fdy = dpdy(input.worldPos);\n let faceNormal = normalize(cross(fdx, fdy));\n let lightDir = normalize(vec3<f32>(0.5, 0.5, 1.0));\n let diff = max(dot(faceNormal, lightDir), 0.2);\n color *= diff;\n }\n finalColor = vec4<f32>(color, surface.solidColor.a * surface.alpha);\n }\n\n // Alpha Test (Simple discard for fence textures if alpha is very low)\n if (finalColor.a < 0.01) {\n discard;\n }\n\n return finalColor;\n}\n";
|
|
11053
11317
|
|
|
11054
11318
|
// src/render/webgpu/pipelines/bspPipeline.ts
|
|
11055
11319
|
var DEFAULT_STYLE_INDICES2 = [0, 255, 255, 255];
|
|
@@ -11092,8 +11356,21 @@ function deriveSurfaceRenderState2(surfaceFlags = SURF_NONE, timeSeconds = 0) {
|
|
|
11092
11356
|
}
|
|
11093
11357
|
var BspSurfacePipeline3 = class {
|
|
11094
11358
|
constructor(device, format, depthFormat) {
|
|
11359
|
+
__publicField(this, "device");
|
|
11360
|
+
__publicField(this, "pipeline");
|
|
11361
|
+
__publicField(this, "pipelineWireframe");
|
|
11362
|
+
__publicField(this, "frameUniformBuffer");
|
|
11363
|
+
__publicField(this, "surfaceUniformBuffer");
|
|
11364
|
+
__publicField(this, "frameBindGroup");
|
|
11365
|
+
__publicField(this, "frameBindGroupLayout");
|
|
11366
|
+
__publicField(this, "surfaceBindGroupLayout");
|
|
11367
|
+
__publicField(this, "textureBindGroupLayout");
|
|
11368
|
+
// Default resources
|
|
11369
|
+
__publicField(this, "defaultWhiteTexture");
|
|
11370
|
+
__publicField(this, "defaultSampler");
|
|
11371
|
+
__publicField(this, "defaultBindGroup");
|
|
11095
11372
|
// Cache for texture bind groups
|
|
11096
|
-
this
|
|
11373
|
+
__publicField(this, "textureBindGroupCache", /* @__PURE__ */ new Map());
|
|
11097
11374
|
this.device = device;
|
|
11098
11375
|
const frameBufferSize = 2048;
|
|
11099
11376
|
const surfaceBufferSize = 256;
|
|
@@ -11247,7 +11524,8 @@ var BspSurfacePipeline3 = class {
|
|
|
11247
11524
|
gamma = 1,
|
|
11248
11525
|
fullbright = false,
|
|
11249
11526
|
ambient = 0,
|
|
11250
|
-
cameraPosition = [0, 0, 0]
|
|
11527
|
+
cameraPosition = [0, 0, 0],
|
|
11528
|
+
surfaceMins = { x: 0, y: 0, z: 0 }
|
|
11251
11529
|
} = options;
|
|
11252
11530
|
const state = deriveSurfaceRenderState2(surfaceFlags, timeSeconds);
|
|
11253
11531
|
const styles = resolveLightStyles2(styleIndices, styleValues);
|
|
@@ -11296,6 +11574,10 @@ var BspSurfacePipeline3 = class {
|
|
|
11296
11574
|
modeInt = 1;
|
|
11297
11575
|
} else if (renderMode.mode === "solid-faceted") {
|
|
11298
11576
|
modeInt = 2;
|
|
11577
|
+
} else if (renderMode.mode === "worldpos-debug") {
|
|
11578
|
+
modeInt = 3;
|
|
11579
|
+
} else if (renderMode.mode === "distance-debug") {
|
|
11580
|
+
modeInt = 4;
|
|
11299
11581
|
}
|
|
11300
11582
|
if (renderMode.color) {
|
|
11301
11583
|
color = [...renderMode.color];
|
|
@@ -11311,6 +11593,9 @@ var BspSurfacePipeline3 = class {
|
|
|
11311
11593
|
surfaceUint[18] = finalWarp ? 1 : 0;
|
|
11312
11594
|
surfaceUint[19] = lightmapOnly ? 1 : 0;
|
|
11313
11595
|
surfaceUint[20] = modeInt;
|
|
11596
|
+
surfaceData[28] = surfaceMins.x;
|
|
11597
|
+
surfaceData[29] = surfaceMins.y;
|
|
11598
|
+
surfaceData[30] = surfaceMins.z;
|
|
11314
11599
|
this.device.queue.writeBuffer(this.surfaceUniformBuffer, 0, surfaceData);
|
|
11315
11600
|
const surfaceBindGroup = this.device.createBindGroup({
|
|
11316
11601
|
layout: this.surfaceBindGroupLayout,
|
|
@@ -11357,12 +11642,17 @@ var WebGPURendererImpl = class {
|
|
|
11357
11642
|
this.context = context;
|
|
11358
11643
|
this.frameRenderer = frameRenderer;
|
|
11359
11644
|
this.pipelines = pipelines;
|
|
11360
|
-
this
|
|
11645
|
+
__publicField(this, "type", "webgpu");
|
|
11361
11646
|
// Texture cache for registered pics
|
|
11362
|
-
this
|
|
11363
|
-
this
|
|
11647
|
+
__publicField(this, "picCache", /* @__PURE__ */ new Map());
|
|
11648
|
+
__publicField(this, "whiteTexture");
|
|
11649
|
+
__publicField(this, "font", null);
|
|
11364
11650
|
// 2D rendering state
|
|
11365
|
-
this
|
|
11651
|
+
__publicField(this, "is2DActive", false);
|
|
11652
|
+
// Stub implementations for required properties
|
|
11653
|
+
__publicField(this, "collisionVis");
|
|
11654
|
+
__publicField(this, "debug");
|
|
11655
|
+
__publicField(this, "particleSystem");
|
|
11366
11656
|
this.whiteTexture = new Texture2D2(context.device, {
|
|
11367
11657
|
width: 1,
|
|
11368
11658
|
height: 1,
|
|
@@ -11672,8 +11962,11 @@ async function createWebGPURenderer(canvas, options) {
|
|
|
11672
11962
|
}
|
|
11673
11963
|
var DemoReader = class {
|
|
11674
11964
|
constructor(buffer) {
|
|
11675
|
-
this
|
|
11676
|
-
this
|
|
11965
|
+
__publicField(this, "buffer");
|
|
11966
|
+
__publicField(this, "view");
|
|
11967
|
+
__publicField(this, "offset");
|
|
11968
|
+
__publicField(this, "messageOffsets", []);
|
|
11969
|
+
__publicField(this, "currentBlock", null);
|
|
11677
11970
|
this.buffer = buffer;
|
|
11678
11971
|
this.view = new DataView(buffer);
|
|
11679
11972
|
this.offset = 0;
|
|
@@ -16014,6 +16307,9 @@ var pako = {
|
|
|
16014
16307
|
var _StreamingBuffer = class _StreamingBuffer {
|
|
16015
16308
|
// From vanilla Q2
|
|
16016
16309
|
constructor(initialCapacity = _StreamingBuffer.INITIAL_SIZE) {
|
|
16310
|
+
__publicField(this, "buffer");
|
|
16311
|
+
__publicField(this, "readOffset");
|
|
16312
|
+
__publicField(this, "writeOffset");
|
|
16017
16313
|
this.buffer = new Uint8Array(initialCapacity);
|
|
16018
16314
|
this.readOffset = 0;
|
|
16019
16315
|
this.writeOffset = 0;
|
|
@@ -16204,9 +16500,9 @@ var _StreamingBuffer = class _StreamingBuffer {
|
|
|
16204
16500
|
this.writeOffset = 0;
|
|
16205
16501
|
}
|
|
16206
16502
|
};
|
|
16207
|
-
_StreamingBuffer
|
|
16503
|
+
__publicField(_StreamingBuffer, "INITIAL_SIZE", 64 * 1024);
|
|
16208
16504
|
// 64KB initial buffer
|
|
16209
|
-
_StreamingBuffer
|
|
16505
|
+
__publicField(_StreamingBuffer, "MAX_STRING_LENGTH", 2048);
|
|
16210
16506
|
var StreamingBuffer = _StreamingBuffer;
|
|
16211
16507
|
|
|
16212
16508
|
// src/demo/state.ts
|
|
@@ -16288,7 +16584,7 @@ var PROTO34_MAP = {
|
|
|
16288
16584
|
};
|
|
16289
16585
|
var Quake2ProtocolHandler = class {
|
|
16290
16586
|
constructor() {
|
|
16291
|
-
this
|
|
16587
|
+
__publicField(this, "protocolVersion", 34);
|
|
16292
16588
|
}
|
|
16293
16589
|
translateCommand(cmd) {
|
|
16294
16590
|
if (PROTO34_MAP[cmd] !== void 0) {
|
|
@@ -16443,7 +16739,7 @@ var Quake2ProtocolHandler = class {
|
|
|
16443
16739
|
var PROTOCOL_VERSION_RERELEASE = 2023;
|
|
16444
16740
|
var RereleaseProtocolHandler = class {
|
|
16445
16741
|
constructor() {
|
|
16446
|
-
this
|
|
16742
|
+
__publicField(this, "protocolVersion", PROTOCOL_VERSION_RERELEASE);
|
|
16447
16743
|
}
|
|
16448
16744
|
translateCommand(cmd) {
|
|
16449
16745
|
return cmd;
|
|
@@ -16600,6 +16896,7 @@ var RereleaseProtocolHandler = class {
|
|
|
16600
16896
|
};
|
|
16601
16897
|
var LegacyProtocolHandler = class {
|
|
16602
16898
|
constructor(version = 0) {
|
|
16899
|
+
__publicField(this, "protocolVersion");
|
|
16603
16900
|
this.protocolVersion = version;
|
|
16604
16901
|
}
|
|
16605
16902
|
translateCommand(cmd) {
|
|
@@ -16751,7 +17048,7 @@ var LegacyProtocolHandler = class {
|
|
|
16751
17048
|
};
|
|
16752
17049
|
var BootstrapProtocolHandler = class {
|
|
16753
17050
|
constructor() {
|
|
16754
|
-
this
|
|
17051
|
+
__publicField(this, "protocolVersion", 0);
|
|
16755
17052
|
}
|
|
16756
17053
|
// We assume standard Q2 opcodes for bootstrap to find serverdata
|
|
16757
17054
|
// but we can also check for legacy serverdata (12 vs 13 vs 7)
|
|
@@ -16869,9 +17166,12 @@ var BinaryStreamAdapter = class extends StreamingBuffer {
|
|
|
16869
17166
|
};
|
|
16870
17167
|
var NetworkMessageParser = class _NetworkMessageParser {
|
|
16871
17168
|
constructor(stream, handler, strictMode = false) {
|
|
16872
|
-
this
|
|
16873
|
-
this
|
|
16874
|
-
this
|
|
17169
|
+
__publicField(this, "stream");
|
|
17170
|
+
__publicField(this, "handler");
|
|
17171
|
+
__publicField(this, "strictMode", false);
|
|
17172
|
+
__publicField(this, "errorCount", 0);
|
|
17173
|
+
__publicField(this, "protocolHandler");
|
|
17174
|
+
__publicField(this, "isDemo", RECORD_CLIENT);
|
|
16875
17175
|
if (stream instanceof BinaryStream) {
|
|
16876
17176
|
this.stream = new BinaryStreamAdapter(stream);
|
|
16877
17177
|
} else {
|
|
@@ -17497,23 +17797,24 @@ var DemoEventType = /* @__PURE__ */ ((DemoEventType2) => {
|
|
|
17497
17797
|
// src/demo/analyzer.ts
|
|
17498
17798
|
var DemoAnalyzer = class {
|
|
17499
17799
|
constructor(buffer) {
|
|
17500
|
-
this
|
|
17501
|
-
this
|
|
17800
|
+
__publicField(this, "buffer");
|
|
17801
|
+
__publicField(this, "events", []);
|
|
17802
|
+
__publicField(this, "summary", {
|
|
17502
17803
|
totalKills: 0,
|
|
17503
17804
|
totalDeaths: 0,
|
|
17504
17805
|
damageDealt: 0,
|
|
17505
17806
|
damageReceived: 0,
|
|
17506
17807
|
weaponUsage: /* @__PURE__ */ new Map()
|
|
17507
|
-
};
|
|
17508
|
-
this
|
|
17509
|
-
this
|
|
17510
|
-
this
|
|
17511
|
-
this
|
|
17512
|
-
this
|
|
17808
|
+
});
|
|
17809
|
+
__publicField(this, "header", null);
|
|
17810
|
+
__publicField(this, "configStrings", /* @__PURE__ */ new Map());
|
|
17811
|
+
__publicField(this, "serverInfo", {});
|
|
17812
|
+
__publicField(this, "statistics", null);
|
|
17813
|
+
__publicField(this, "playerStats", /* @__PURE__ */ new Map());
|
|
17513
17814
|
// By playerNum
|
|
17514
|
-
this
|
|
17815
|
+
__publicField(this, "weaponStats", /* @__PURE__ */ new Map());
|
|
17515
17816
|
// By entity ID
|
|
17516
|
-
this
|
|
17817
|
+
__publicField(this, "activeEntities", /* @__PURE__ */ new Set());
|
|
17517
17818
|
this.buffer = buffer;
|
|
17518
17819
|
}
|
|
17519
17820
|
analyze() {
|
|
@@ -17785,39 +18086,41 @@ var createNoOpHandler = () => ({
|
|
|
17785
18086
|
});
|
|
17786
18087
|
var DemoPlaybackController = class {
|
|
17787
18088
|
constructor() {
|
|
17788
|
-
this
|
|
17789
|
-
this
|
|
18089
|
+
__publicField(this, "reader", null);
|
|
18090
|
+
__publicField(this, "buffer", null);
|
|
17790
18091
|
// Keep reference for analysis
|
|
17791
|
-
this
|
|
17792
|
-
this
|
|
17793
|
-
this
|
|
17794
|
-
this
|
|
18092
|
+
__publicField(this, "state", 0 /* Stopped */);
|
|
18093
|
+
__publicField(this, "playbackSpeed", 1);
|
|
18094
|
+
__publicField(this, "handler");
|
|
18095
|
+
__publicField(this, "callbacks");
|
|
18096
|
+
__publicField(this, "currentProtocolVersion", 0);
|
|
18097
|
+
__publicField(this, "currentFrameIndex", -1);
|
|
17795
18098
|
// -1 means no frames processed yet
|
|
17796
18099
|
// Last parsed frame data for accessors
|
|
17797
|
-
this
|
|
18100
|
+
__publicField(this, "lastFrameData", null);
|
|
17798
18101
|
// Timing
|
|
17799
|
-
this
|
|
17800
|
-
this
|
|
18102
|
+
__publicField(this, "accumulatedTime", 0);
|
|
18103
|
+
__publicField(this, "frameDuration", 100);
|
|
17801
18104
|
// ms (10Hz default)
|
|
17802
18105
|
// Snapshots
|
|
17803
|
-
this
|
|
18106
|
+
__publicField(this, "snapshotInterval", 100);
|
|
17804
18107
|
// frames
|
|
17805
|
-
this
|
|
18108
|
+
__publicField(this, "snapshots", /* @__PURE__ */ new Map());
|
|
17806
18109
|
// Analysis Cache
|
|
17807
|
-
this
|
|
17808
|
-
this
|
|
17809
|
-
this
|
|
17810
|
-
this
|
|
17811
|
-
this
|
|
17812
|
-
this
|
|
17813
|
-
this
|
|
17814
|
-
this
|
|
18110
|
+
__publicField(this, "cachedEvents", null);
|
|
18111
|
+
__publicField(this, "cachedSummary", null);
|
|
18112
|
+
__publicField(this, "cachedHeader", null);
|
|
18113
|
+
__publicField(this, "cachedConfigStrings", null);
|
|
18114
|
+
__publicField(this, "cachedServerInfo", null);
|
|
18115
|
+
__publicField(this, "cachedStatistics", null);
|
|
18116
|
+
__publicField(this, "cachedPlayerStats", null);
|
|
18117
|
+
__publicField(this, "cachedWeaponStats", null);
|
|
17815
18118
|
// Resource Tracking
|
|
17816
|
-
this
|
|
18119
|
+
__publicField(this, "tracker", null);
|
|
17817
18120
|
// Camera State
|
|
17818
|
-
this
|
|
17819
|
-
this
|
|
17820
|
-
this
|
|
18121
|
+
__publicField(this, "cameraMode", 0 /* FirstPerson */);
|
|
18122
|
+
__publicField(this, "thirdPersonDistance", 80);
|
|
18123
|
+
__publicField(this, "thirdPersonOffset", { x: 0, y: 0, z: 0 });
|
|
17821
18124
|
}
|
|
17822
18125
|
setHandler(handler) {
|
|
17823
18126
|
this.handler = handler;
|
|
@@ -18438,11 +18741,12 @@ var DemoPlaybackController = class {
|
|
|
18438
18741
|
var DemoRecorder = class {
|
|
18439
18742
|
// -1 means start of demo
|
|
18440
18743
|
constructor() {
|
|
18441
|
-
this
|
|
18442
|
-
this
|
|
18443
|
-
this
|
|
18444
|
-
this
|
|
18445
|
-
this
|
|
18744
|
+
__publicField(this, "isRecording", false);
|
|
18745
|
+
__publicField(this, "messageBuffer");
|
|
18746
|
+
__publicField(this, "startTime", 0);
|
|
18747
|
+
__publicField(this, "frameCount", 0);
|
|
18748
|
+
__publicField(this, "filename", null);
|
|
18749
|
+
__publicField(this, "lastMessageSize", -1);
|
|
18446
18750
|
this.messageBuffer = new BinaryWriter(1024 * 1024);
|
|
18447
18751
|
}
|
|
18448
18752
|
startRecording(filename, startTime = 0) {
|
|
@@ -18475,6 +18779,8 @@ var DemoRecorder = class {
|
|
|
18475
18779
|
};
|
|
18476
18780
|
var MessageWriter = class {
|
|
18477
18781
|
constructor(writer, protocol = 34) {
|
|
18782
|
+
__publicField(this, "writer");
|
|
18783
|
+
__publicField(this, "protocol");
|
|
18478
18784
|
this.writer = writer || new BinaryWriter(new Uint8Array(64 * 1024));
|
|
18479
18785
|
this.protocol = protocol;
|
|
18480
18786
|
}
|
|
@@ -18834,10 +19140,12 @@ var DemoValidator = class {
|
|
|
18834
19140
|
// src/demo/clipper.ts
|
|
18835
19141
|
var DemoClipper = class {
|
|
18836
19142
|
constructor(buffer) {
|
|
18837
|
-
this
|
|
18838
|
-
this
|
|
18839
|
-
this
|
|
18840
|
-
this
|
|
19143
|
+
__publicField(this, "parser");
|
|
19144
|
+
__publicField(this, "frames", []);
|
|
19145
|
+
__publicField(this, "serverData");
|
|
19146
|
+
__publicField(this, "configStrings", /* @__PURE__ */ new Map());
|
|
19147
|
+
__publicField(this, "baselines", /* @__PURE__ */ new Map());
|
|
19148
|
+
__publicField(this, "currentEntities", /* @__PURE__ */ new Map());
|
|
18841
19149
|
if (buffer) {
|
|
18842
19150
|
const sb = new StreamingBuffer(buffer.byteLength);
|
|
18843
19151
|
sb.append(new Uint8Array(buffer));
|
|
@@ -19552,13 +19860,13 @@ async function captureRenderTarget(device, texture) {
|
|
|
19552
19860
|
// src/render/null/renderer.ts
|
|
19553
19861
|
var NullRenderer = class {
|
|
19554
19862
|
constructor(width = 800, height = 600) {
|
|
19555
|
-
this
|
|
19556
|
-
this
|
|
19557
|
-
this
|
|
19558
|
-
this
|
|
19559
|
-
this
|
|
19560
|
-
this
|
|
19561
|
-
this
|
|
19863
|
+
__publicField(this, "width", 0);
|
|
19864
|
+
__publicField(this, "height", 0);
|
|
19865
|
+
__publicField(this, "collisionVis", null);
|
|
19866
|
+
__publicField(this, "debug", null);
|
|
19867
|
+
__publicField(this, "particleSystem", null);
|
|
19868
|
+
__publicField(this, "frameCount", 0);
|
|
19869
|
+
__publicField(this, "callLog", []);
|
|
19562
19870
|
this.width = width;
|
|
19563
19871
|
this.height = height;
|
|
19564
19872
|
}
|
|
@@ -19671,7 +19979,7 @@ var NullRenderer = class {
|
|
|
19671
19979
|
};
|
|
19672
19980
|
var WebGLMatrixBuilder = class {
|
|
19673
19981
|
constructor() {
|
|
19674
|
-
this
|
|
19982
|
+
__publicField(this, "coordinateSystem", "opengl" /* OPENGL */);
|
|
19675
19983
|
}
|
|
19676
19984
|
buildProjectionMatrix(camera) {
|
|
19677
19985
|
const projection = mat4.create();
|
|
@@ -19737,7 +20045,7 @@ var WebGLMatrixBuilder = class {
|
|
|
19737
20045
|
};
|
|
19738
20046
|
var IdentityMatrixBuilder = class {
|
|
19739
20047
|
constructor() {
|
|
19740
|
-
this
|
|
20048
|
+
__publicField(this, "coordinateSystem", "quake" /* QUAKE */);
|
|
19741
20049
|
}
|
|
19742
20050
|
buildProjectionMatrix(camera) {
|
|
19743
20051
|
const projection = mat4.create();
|
|
@@ -19788,12 +20096,14 @@ function quakeToWebGPU(v) {
|
|
|
19788
20096
|
// src/render/logging/renderer.ts
|
|
19789
20097
|
var LoggingRenderer = class {
|
|
19790
20098
|
constructor(options = {}) {
|
|
19791
|
-
this
|
|
19792
|
-
this
|
|
19793
|
-
this
|
|
19794
|
-
this
|
|
19795
|
-
this
|
|
19796
|
-
this
|
|
20099
|
+
__publicField(this, "width", 0);
|
|
20100
|
+
__publicField(this, "height", 0);
|
|
20101
|
+
__publicField(this, "collisionVis", null);
|
|
20102
|
+
__publicField(this, "debug", null);
|
|
20103
|
+
__publicField(this, "particleSystem", null);
|
|
20104
|
+
__publicField(this, "logs", []);
|
|
20105
|
+
__publicField(this, "builder");
|
|
20106
|
+
__publicField(this, "options");
|
|
19797
20107
|
this.options = {
|
|
19798
20108
|
targetSystem: options.targetSystem ?? "quake" /* QUAKE */,
|
|
19799
20109
|
verbose: options.verbose ?? true,
|
|
@@ -19992,23 +20302,25 @@ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
|
19992
20302
|
})(ConnectionState || {});
|
|
19993
20303
|
var ClientConnection = class {
|
|
19994
20304
|
constructor(options) {
|
|
19995
|
-
this
|
|
19996
|
-
this
|
|
20305
|
+
__publicField(this, "state", 0 /* Disconnected */);
|
|
20306
|
+
__publicField(this, "netchan");
|
|
20307
|
+
__publicField(this, "parser", null);
|
|
20308
|
+
__publicField(this, "options");
|
|
19997
20309
|
// Event listeners
|
|
19998
|
-
this
|
|
20310
|
+
__publicField(this, "listeners", {});
|
|
19999
20311
|
// Game State
|
|
20000
|
-
this
|
|
20001
|
-
this
|
|
20002
|
-
this
|
|
20003
|
-
this
|
|
20004
|
-
this
|
|
20005
|
-
this
|
|
20006
|
-
this
|
|
20007
|
-
this
|
|
20008
|
-
this
|
|
20009
|
-
this
|
|
20010
|
-
this
|
|
20011
|
-
this
|
|
20312
|
+
__publicField(this, "serverProtocol", 0);
|
|
20313
|
+
__publicField(this, "serverCount", 0);
|
|
20314
|
+
__publicField(this, "gameDir", "");
|
|
20315
|
+
__publicField(this, "playerNum", 0);
|
|
20316
|
+
__publicField(this, "levelName", "");
|
|
20317
|
+
__publicField(this, "configStrings", /* @__PURE__ */ new Map());
|
|
20318
|
+
__publicField(this, "baselines", /* @__PURE__ */ new Map());
|
|
20319
|
+
__publicField(this, "entities", /* @__PURE__ */ new Map());
|
|
20320
|
+
__publicField(this, "latestServerFrame", 0);
|
|
20321
|
+
__publicField(this, "frameCRCs", /* @__PURE__ */ new Map());
|
|
20322
|
+
__publicField(this, "currentPacketCRC", 0);
|
|
20323
|
+
__publicField(this, "commandHistory", []);
|
|
20012
20324
|
this.options = options;
|
|
20013
20325
|
this.netchan = options.netchan ?? new NetChan();
|
|
20014
20326
|
}
|