quake2ts 0.0.572 → 0.0.574
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.map +1 -1
- package/packages/client/dist/cjs/index.cjs +2 -2
- package/packages/client/dist/cjs/index.cjs.map +1 -1
- package/packages/client/dist/esm/index.js +2 -2
- package/packages/client/dist/esm/index.js.map +1 -1
- package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/engine/dist/browser/index.global.js +16 -16
- package/packages/engine/dist/browser/index.global.js.map +1 -1
- package/packages/engine/dist/cjs/index.cjs +123 -14
- package/packages/engine/dist/cjs/index.cjs.map +1 -1
- package/packages/engine/dist/esm/index.js +122 -14
- package/packages/engine/dist/esm/index.js.map +1 -1
- package/packages/engine/dist/tsconfig.tsbuildinfo +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/engine/dist/types/render/instancing.d.ts +12 -0
- package/packages/engine/dist/types/render/instancing.d.ts.map +1 -0
- package/packages/engine/dist/types/render/renderer.d.ts +4 -0
- package/packages/engine/dist/types/render/renderer.d.ts.map +1 -1
- package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/test-utils/dist/index.cjs +133 -0
- package/packages/test-utils/dist/index.cjs.map +1 -1
- package/packages/test-utils/dist/index.d.cts +84 -2
- package/packages/test-utils/dist/index.d.ts +84 -2
- package/packages/test-utils/dist/index.js +126 -0
- package/packages/test-utils/dist/index.js.map +1 -1
- package/packages/tools/dist/browser/index.global.js +2 -1
- package/packages/tools/dist/browser/index.global.js.map +1 -1
- package/packages/tools/dist/cjs/index.cjs +175 -2
- package/packages/tools/dist/cjs/index.cjs.map +1 -1
- package/packages/tools/dist/esm/index.js +170 -1
- package/packages/tools/dist/esm/index.js.map +1 -1
- package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
- package/packages/tools/dist/types/index.d.ts +1 -0
- package/packages/tools/dist/types/index.d.ts.map +1 -1
- package/packages/tools/dist/types/modelExport.d.ts +19 -0
- package/packages/tools/dist/types/modelExport.d.ts.map +1 -0
|
@@ -1893,9 +1893,116 @@ function calculatePakChecksum(buffer) {
|
|
|
1893
1893
|
return crc32(new Uint8Array(buffer));
|
|
1894
1894
|
}
|
|
1895
1895
|
|
|
1896
|
-
// src/assets/
|
|
1896
|
+
// src/assets/streamingPak.ts
|
|
1897
|
+
var PAK_MAGIC2 = "PACK";
|
|
1897
1898
|
var HEADER_SIZE2 = 12;
|
|
1898
1899
|
var DIRECTORY_ENTRY_SIZE2 = 64;
|
|
1900
|
+
function normalizePath2(path) {
|
|
1901
|
+
return path.replace(/\\/g, "/").replace(/^\/+/, "").toLowerCase();
|
|
1902
|
+
}
|
|
1903
|
+
var StreamingPakArchive = class {
|
|
1904
|
+
constructor(source) {
|
|
1905
|
+
this.source = source;
|
|
1906
|
+
this.entries = null;
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Read directory asynchronously.
|
|
1910
|
+
* Caches the result so subsequent calls are fast.
|
|
1911
|
+
*/
|
|
1912
|
+
async readDirectory() {
|
|
1913
|
+
if (this.entries) {
|
|
1914
|
+
return Array.from(this.entries.values());
|
|
1915
|
+
}
|
|
1916
|
+
const headerBuffer = await this.readChunk(0, HEADER_SIZE2);
|
|
1917
|
+
const headerView = new DataView(headerBuffer);
|
|
1918
|
+
const magic = String.fromCharCode(
|
|
1919
|
+
headerView.getUint8(0),
|
|
1920
|
+
headerView.getUint8(1),
|
|
1921
|
+
headerView.getUint8(2),
|
|
1922
|
+
headerView.getUint8(3)
|
|
1923
|
+
);
|
|
1924
|
+
if (magic !== PAK_MAGIC2) {
|
|
1925
|
+
throw new PakParseError(`Invalid PAK header magic: ${magic}`);
|
|
1926
|
+
}
|
|
1927
|
+
const dirOffset = headerView.getInt32(4, true);
|
|
1928
|
+
const dirLength = headerView.getInt32(8, true);
|
|
1929
|
+
if (dirOffset < HEADER_SIZE2) {
|
|
1930
|
+
throw new PakParseError(`Invalid directory offset: ${dirOffset}`);
|
|
1931
|
+
}
|
|
1932
|
+
if (dirLength < 0 || dirLength % DIRECTORY_ENTRY_SIZE2 !== 0) {
|
|
1933
|
+
throw new PakParseError(`Invalid directory length: ${dirLength}`);
|
|
1934
|
+
}
|
|
1935
|
+
const dirBuffer = await this.readChunk(dirOffset, dirLength);
|
|
1936
|
+
const dirView = new DataView(dirBuffer);
|
|
1937
|
+
const entryCount = dirLength / DIRECTORY_ENTRY_SIZE2;
|
|
1938
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1939
|
+
for (let i = 0; i < entryCount; i++) {
|
|
1940
|
+
const offset = i * DIRECTORY_ENTRY_SIZE2;
|
|
1941
|
+
const rawName = this.readCString(dirView, offset, 56);
|
|
1942
|
+
const normalized = normalizePath2(rawName);
|
|
1943
|
+
const fileOffset = dirView.getInt32(offset + 56, true);
|
|
1944
|
+
const fileLength = dirView.getInt32(offset + 60, true);
|
|
1945
|
+
if (fileOffset < 0 || fileLength < 0 || fileOffset + fileLength > this.source.size) {
|
|
1946
|
+
}
|
|
1947
|
+
if (normalized) {
|
|
1948
|
+
entries.set(normalized, { name: normalized, offset: fileOffset, length: fileLength });
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
this.entries = entries;
|
|
1952
|
+
return Array.from(entries.values());
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Stream file contents on demand.
|
|
1956
|
+
* Returns a ReadableStream of Uint8Array.
|
|
1957
|
+
*/
|
|
1958
|
+
async readFile(path) {
|
|
1959
|
+
const entry = await this.getEntry(path);
|
|
1960
|
+
if (!entry) {
|
|
1961
|
+
throw new PakParseError(`File not found in PAK: ${path}`);
|
|
1962
|
+
}
|
|
1963
|
+
const blob = this.source.slice(entry.offset, entry.offset + entry.length);
|
|
1964
|
+
return blob.stream();
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Get file as a Blob without loading entire file into memory.
|
|
1968
|
+
*/
|
|
1969
|
+
async getFileBlob(path) {
|
|
1970
|
+
const entry = await this.getEntry(path);
|
|
1971
|
+
if (!entry) {
|
|
1972
|
+
throw new PakParseError(`File not found in PAK: ${path}`);
|
|
1973
|
+
}
|
|
1974
|
+
return this.source.slice(entry.offset, entry.offset + entry.length);
|
|
1975
|
+
}
|
|
1976
|
+
async getEntry(path) {
|
|
1977
|
+
if (!this.entries) {
|
|
1978
|
+
await this.readDirectory();
|
|
1979
|
+
}
|
|
1980
|
+
return this.entries.get(normalizePath2(path));
|
|
1981
|
+
}
|
|
1982
|
+
async readChunk(offset, length2) {
|
|
1983
|
+
const slice = this.source.slice(offset, offset + length2);
|
|
1984
|
+
if ("arrayBuffer" in slice) {
|
|
1985
|
+
return await slice.arrayBuffer();
|
|
1986
|
+
} else {
|
|
1987
|
+
return new Response(slice).arrayBuffer();
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
readCString(view, offset, maxLength) {
|
|
1991
|
+
const codes = [];
|
|
1992
|
+
for (let i = 0; i < maxLength; i += 1) {
|
|
1993
|
+
const code = view.getUint8(offset + i);
|
|
1994
|
+
if (code === 0) {
|
|
1995
|
+
break;
|
|
1996
|
+
}
|
|
1997
|
+
codes.push(code);
|
|
1998
|
+
}
|
|
1999
|
+
return String.fromCharCode(...codes);
|
|
2000
|
+
}
|
|
2001
|
+
};
|
|
2002
|
+
|
|
2003
|
+
// src/assets/pakWriter.ts
|
|
2004
|
+
var HEADER_SIZE3 = 12;
|
|
2005
|
+
var DIRECTORY_ENTRY_SIZE3 = 64;
|
|
1899
2006
|
var PakWriter = class _PakWriter {
|
|
1900
2007
|
constructor() {
|
|
1901
2008
|
this.entries = /* @__PURE__ */ new Map();
|
|
@@ -1928,18 +2035,18 @@ var PakWriter = class _PakWriter {
|
|
|
1928
2035
|
for (const data of this.entries.values()) {
|
|
1929
2036
|
fileDataSize += data.byteLength;
|
|
1930
2037
|
}
|
|
1931
|
-
const directorySize = this.entries.size *
|
|
1932
|
-
const totalSize =
|
|
2038
|
+
const directorySize = this.entries.size * DIRECTORY_ENTRY_SIZE3;
|
|
2039
|
+
const totalSize = HEADER_SIZE3 + fileDataSize + directorySize;
|
|
1933
2040
|
const buffer = new Uint8Array(totalSize);
|
|
1934
2041
|
const view = new DataView(buffer.buffer);
|
|
1935
2042
|
view.setUint8(0, "P".charCodeAt(0));
|
|
1936
2043
|
view.setUint8(1, "A".charCodeAt(0));
|
|
1937
2044
|
view.setUint8(2, "C".charCodeAt(0));
|
|
1938
2045
|
view.setUint8(3, "K".charCodeAt(0));
|
|
1939
|
-
const dirOffset =
|
|
2046
|
+
const dirOffset = HEADER_SIZE3 + fileDataSize;
|
|
1940
2047
|
view.setInt32(4, dirOffset, true);
|
|
1941
2048
|
view.setInt32(8, directorySize, true);
|
|
1942
|
-
let currentOffset =
|
|
2049
|
+
let currentOffset = HEADER_SIZE3;
|
|
1943
2050
|
const fileOffsets = /* @__PURE__ */ new Map();
|
|
1944
2051
|
const sortedKeys = Array.from(this.entries.keys()).sort();
|
|
1945
2052
|
for (const name of sortedKeys) {
|
|
@@ -1965,7 +2072,7 @@ var PakWriter = class _PakWriter {
|
|
|
1965
2072
|
}
|
|
1966
2073
|
view.setInt32(dirEntryOffset + 56, fileOffsets.get(name), true);
|
|
1967
2074
|
view.setInt32(dirEntryOffset + 60, data.byteLength, true);
|
|
1968
|
-
dirEntryOffset +=
|
|
2075
|
+
dirEntryOffset += DIRECTORY_ENTRY_SIZE3;
|
|
1969
2076
|
}
|
|
1970
2077
|
return buffer;
|
|
1971
2078
|
}
|
|
@@ -2597,7 +2704,7 @@ function wireFileInput(input, handler) {
|
|
|
2597
2704
|
var BSP_MAGIC = "IBSP";
|
|
2598
2705
|
var BSP_VERSION = 38;
|
|
2599
2706
|
var HEADER_LUMPS = 19;
|
|
2600
|
-
var
|
|
2707
|
+
var HEADER_SIZE4 = 4 + 4 + HEADER_LUMPS * 8;
|
|
2601
2708
|
var BspParseError = class extends Error {
|
|
2602
2709
|
};
|
|
2603
2710
|
var BspLoader = class {
|
|
@@ -2612,7 +2719,7 @@ var BspLoader = class {
|
|
|
2612
2719
|
}
|
|
2613
2720
|
};
|
|
2614
2721
|
function parseBsp(buffer) {
|
|
2615
|
-
if (buffer.byteLength <
|
|
2722
|
+
if (buffer.byteLength < HEADER_SIZE4) {
|
|
2616
2723
|
throw new BspParseError("BSP too small to contain header");
|
|
2617
2724
|
}
|
|
2618
2725
|
const view = new DataView(buffer);
|
|
@@ -3065,7 +3172,7 @@ function createFaceLightmap(face, lightMaps, info) {
|
|
|
3065
3172
|
// src/assets/md2.ts
|
|
3066
3173
|
var MD2_MAGIC = 844121161;
|
|
3067
3174
|
var MD2_VERSION = 8;
|
|
3068
|
-
var
|
|
3175
|
+
var HEADER_SIZE5 = 17 * 4;
|
|
3069
3176
|
var MD2_NORMALS = [
|
|
3070
3177
|
{ x: -0.525731, y: 0, z: 0.850651 },
|
|
3071
3178
|
{ x: -0.442863, y: 0.238856, z: 0.864188 },
|
|
@@ -3263,12 +3370,12 @@ function readCString2(view, offset, maxLength) {
|
|
|
3263
3370
|
}
|
|
3264
3371
|
function validateSection(buffer, offset, length2, label) {
|
|
3265
3372
|
if (length2 === 0) return;
|
|
3266
|
-
if (offset <
|
|
3373
|
+
if (offset < HEADER_SIZE5 || offset + length2 > buffer.byteLength) {
|
|
3267
3374
|
throw new Md2ParseError(`${label} section is out of bounds`);
|
|
3268
3375
|
}
|
|
3269
3376
|
}
|
|
3270
3377
|
function parseHeader(buffer) {
|
|
3271
|
-
if (buffer.byteLength <
|
|
3378
|
+
if (buffer.byteLength < HEADER_SIZE5) {
|
|
3272
3379
|
throw new Md2ParseError("MD2 buffer too small to contain header");
|
|
3273
3380
|
}
|
|
3274
3381
|
const view = new DataView(buffer);
|
|
@@ -3705,7 +3812,7 @@ var Md3Loader = class {
|
|
|
3705
3812
|
var IDSPRITEHEADER = 844317769;
|
|
3706
3813
|
var SPRITE_VERSION = 2;
|
|
3707
3814
|
var MAX_SKINNAME = 64;
|
|
3708
|
-
var
|
|
3815
|
+
var HEADER_SIZE6 = 12;
|
|
3709
3816
|
var SpriteParseError = class extends Error {
|
|
3710
3817
|
};
|
|
3711
3818
|
function readCString3(view, offset, maxLength) {
|
|
@@ -3718,7 +3825,7 @@ function readCString3(view, offset, maxLength) {
|
|
|
3718
3825
|
return String.fromCharCode(...chars);
|
|
3719
3826
|
}
|
|
3720
3827
|
function parseSprite(buffer) {
|
|
3721
|
-
if (buffer.byteLength <
|
|
3828
|
+
if (buffer.byteLength < HEADER_SIZE6) {
|
|
3722
3829
|
throw new SpriteParseError("Sprite buffer too small to contain header");
|
|
3723
3830
|
}
|
|
3724
3831
|
const view = new DataView(buffer);
|
|
@@ -3733,7 +3840,7 @@ function parseSprite(buffer) {
|
|
|
3733
3840
|
}
|
|
3734
3841
|
const frames = [];
|
|
3735
3842
|
const frameSize = 16 + MAX_SKINNAME;
|
|
3736
|
-
let offset =
|
|
3843
|
+
let offset = HEADER_SIZE6;
|
|
3737
3844
|
for (let i = 0; i < numFrames; i += 1) {
|
|
3738
3845
|
if (offset + frameSize > buffer.byteLength) {
|
|
3739
3846
|
throw new SpriteParseError("Sprite frame data exceeds buffer length");
|
|
@@ -17902,6 +18009,7 @@ export {
|
|
|
17902
18009
|
SoundRegistry,
|
|
17903
18010
|
SpriteLoader,
|
|
17904
18011
|
SpriteParseError,
|
|
18012
|
+
StreamingPakArchive,
|
|
17905
18013
|
Texture2D,
|
|
17906
18014
|
TextureCache,
|
|
17907
18015
|
TextureCubeMap,
|