SPZ writing, exporting, & viewer. Creates a new npm run to-spz which runs scripts/to-spz.js to convert any Gsplat input file to compress .spz. Also includes a configurable viewer examples/viewer that can load splats via drag-n-drop, from url query param, the URL text list, can edit sets of SplatMesh, and export composite .SPZ with some filters. Refactored some loading code from worker.ts to loader files so they can be called from Nodejs. Created api transcodeSpz with options to combine multiple source Gsplat files into one without losing coding quality along the way.

This commit is contained in:
Andreas Sundquist
2025-05-26 13:46:16 -07:00
committed by Diego Marcos Segura
parent b4257bcd64
commit 156bbf400e
19 changed files with 2605 additions and 508 deletions
+8 -3
View File
@@ -45,6 +45,8 @@ export type SplatMeshOptions = {
// auto-detected (.splat, .ksplat). (default: undefined auto-detects other
// formats from file contents)
fileType?: SplatFileType;
// File name to use for type detection. (default: undefined)
fileName?: string;
// Use an existing PackedSplats object as the source instead of loading from
// a file. Can be used to share a collection of Gsplats among multiple SplatMeshes
// (default: undefined creates a new empty PackedSplats or decoded from a
@@ -224,12 +226,14 @@ export class SplatMesh extends SplatGenerator {
}
async asyncInitialize(options: SplatMeshOptions) {
const { url, fileBytes, fileType, maxSplats, constructSplats } = options;
const { url, fileBytes, fileType, fileName, maxSplats, constructSplats } =
options;
if (url || fileBytes || constructSplats) {
const packedSplatsOptions = {
url,
fileBytes,
fileType,
fileName,
maxSplats,
construct: constructSplats,
};
@@ -295,7 +299,8 @@ export class SplatMesh extends SplatGenerator {
this.packedSplats.dispose();
}
constructGenerator({ transform, viewToObject, recolor }: SplatMeshContext) {
constructGenerator(context: SplatMeshContext) {
const { transform, viewToObject, recolor } = context;
const generator = dynoBlock(
{ index: "int" },
{ gsplat: Gsplat },
@@ -354,7 +359,7 @@ export class SplatMesh extends SplatGenerator {
}
// Transform from object to world-space
gsplat = transform.modify(gsplat);
gsplat = transform.applyGsplat(gsplat);
// Apply any global recoloring and opacity
const recolorRgba = mul(recolor, splitGsplat(gsplat).outputs.rgba);