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

Function tryPcSogsZip

src/SplatLoader.ts:604–635  ·  view source on GitHub ↗
(
  input: ArrayBuffer | Uint8Array,
)

Source from the content-addressed store, hash-verified

602}
603
604export function tryPcSogsZip(
605 input: ArrayBuffer | Uint8Array,
606): { name: string; json: PcSogsJson | PcSogsV2Json } | undefined {
607 try {
608 const fileBytes =
609 input instanceof ArrayBuffer ? new Uint8Array(input) : input;
610 let metaFilename: string | null = null;
611
612 const unzipped = unzipSync(fileBytes, {
613 filter: ({ name }) => {
614 const filename = name.split(/[\\/]/).pop() as string;
615 if (filename === "meta.json") {
616 metaFilename = name;
617 return true;
618 }
619 return false;
620 },
621 });
622 if (!metaFilename) {
623 return undefined;
624 }
625
626 // Check for PC SOGS V1 and V2 (aka SOG)
627 const json = tryPcSogs(unzipped[metaFilename]);
628 if (!json) {
629 return undefined;
630 }
631 return { name: metaFilename, json };
632 } catch {
633 return undefined;
634 }
635}
636
637export async function unpackSplats({
638 input,

Callers 2

unpackPcSogsZipFunction · 0.90
getSplatFileTypeFunction · 0.85

Calls 1

tryPcSogsFunction · 0.85

Tested by

no test coverage detected