MCPcopy
hub / github.com/sparkjsdev/spark / getSplatFileType

Function getSplatFileType

src/SplatLoader.ts:403–434  ·  view source on GitHub ↗
(
  fileBytes: Uint8Array,
)

Source from the content-addressed store, hash-verified

401}
402
403export function getSplatFileType(
404 fileBytes: Uint8Array,
405): SplatFileType | undefined {
406 const view = new DataView(fileBytes.buffer);
407 const magic = view.getUint32(0, true);
408 if ((magic & 0x00ffffff) === 0x00796c70) {
409 return SplatFileType.PLY;
410 }
411 if ((magic & 0x00ffffff) === 0x00088b1f) {
412 // Gzipped file, unpack beginning to check magic number
413 const header = decompressPartialGzip(fileBytes, 4);
414 const gView = new DataView(header.buffer);
415 if (gView.getUint32(0, true) === 0x5053474e) {
416 return SplatFileType.SPZ;
417 }
418 // Unknown Gzipped file type
419 return undefined;
420 }
421 if (magic === 0x04034b50) {
422 // PKZip file
423 if (tryPcSogsZip(fileBytes)) {
424 return SplatFileType.PCSOGSZIP;
425 }
426 // Unknown PKZip file type
427 return undefined;
428 }
429 if (magic === 0x30444152) {
430 return SplatFileType.RAD;
431 }
432 // Unknown file type
433 return undefined;
434}
435
436// Returns the lowercased file extension from a path or URL
437export function getFileExtension(pathOrUrl: string): string {

Callers 3

transcodeSpzFunction · 0.90
constructorMethod · 0.90
unpackSplatsFunction · 0.85

Calls 2

decompressPartialGzipFunction · 0.90
tryPcSogsZipFunction · 0.85

Tested by

no test coverage detected