( fileBytes: Uint8Array, )
| 401 | } |
| 402 | |
| 403 | export 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 |
| 437 | export function getFileExtension(pathOrUrl: string): string { |
no test coverage detected