diff --git a/examples/splat-painter/index.html b/examples/splat-painter/index.html index 0e56cf5c..d36bdf05 100644 --- a/examples/splat-painter/index.html +++ b/examples/splat-painter/index.html @@ -487,7 +487,7 @@ // Now export the PackedSplats to SPZ console.log("Writing splats to SPZ..."); - const { fileBytes: spzBytes } = writeSpz(newPackedSplats, ioOptions.maxSh, ioOptions.fractionalBits); + const { fileBytes: spzBytes } = await writeSpz(newPackedSplats, ioOptions.maxSh, ioOptions.fractionalBits); console.log("Creating download..."); const blob = new Blob([spzBytes], { type: "application/octet-stream" }); diff --git a/src/spz.ts b/src/spz.ts index 03d36e22..299beda8 100644 --- a/src/spz.ts +++ b/src/spz.ts @@ -99,16 +99,18 @@ export function writeSpz( splats: PackedSplats | ExtSplats, maxSh?: number, fractionalBits?: number, -): { fileBytes: Uint8Array }; +): Promise<{ fileBytes: Uint8Array }>; export function writeSpz( splats: PackedSplats | ExtSplats, options?: WriteSpzOptions, -): { fileBytes: Uint8Array }; -export function writeSpz( +): Promise<{ fileBytes: Uint8Array }>; +export async function writeSpz( splats: PackedSplats | ExtSplats, maxShOrOptions?: number | WriteSpzOptions, fractionalBits?: number, ) { + await wasm.initialization; + const options: WriteSpzOptions = typeof maxShOrOptions === "number" ? { maxSh: maxShOrOptions, fractionalBits }