SPZ loader
Decode compressed splats without changing the application shape.
SPZLoader reads Niantic Spatial SPZ files, handles their compressed attribute streams, and returns the same Mesh Arrow table shape as the other loaders.gl Gaussian splat formats.
The SPZ path
Probe the file. Decompress its streams. Return typed splat columns.
SPZ keeps the file small by compressing independent attribute streams. The loader hides that storage detail while preserving the decoded fields and format metadata needed by applications.
Input
SPZ v4 binary data with `NGSP` magic
Codec
Native probe or injected ZSTD implementation
Decode
Positions, color, opacity, scale, rotation, and SH
Output
Mesh Arrow table plus SPZ loader metadata
SPZLoader parses Niantic Spatial .spz Gaussian splat files and returns a native Apache Arrow Table.
Detailed guide
Compression and output details
The reference below covers runtime codec selection, supported SPZ versions, decoded fields, metadata, and loader options.
| Property | Value |
|---|---|
| File format | SPZ |
| Extensions | .spz |
| Worker | ❌ No |
| Input type | ArrayBuffer |
| Output shape | arrow |
Usage
SPZ version 4 uses ZSTD-compressed attribute streams. Async SPZ parsing first probes the lightweight
native decompression entrypoint, which has no codec imports, before lazily loading the
codec-backed fallback. Native Zstandard support is not yet widely available, so inject
zstd-codec through loader options for broad runtime compatibility; when provided, it takes
precedence over the native path.
// Install zstd-codec for broad runtime compatibility.
// npm install @loaders.gl/core @loaders.gl/splats zstd-codec
import {load} from '@loaders.gl/core';
import {SPZLoader} from '@loaders.gl/splats/spz';
import {ZstdCodec} from 'zstd-codec';
const table = await load(url, SPZLoader, {
modules: {'zstd-codec': ZstdCodec}
});
The parser-bearing subpath can also be imported directly:
import {SPZLoaderWithParser} from '@loaders.gl/splats/spz/bundled';
Format support
SPZLoader supports SPZ version 4 files that start with the NGSP magic value and use the plaintext 32-byte header, table of contents, and independent ZSTD-compressed attribute streams.
The loader decodes:
- 24-bit fixed-point positions
- 8-bit alpha values into linear opacity
- 8-bit color values into SH DC coefficients
- 8-bit log-encoded scales into linear scale standard deviations
- smallest-three quaternion rotations into
rot_0,rot_1,rot_2,rot_3 - 8-bit spherical harmonic rest coefficients for SPZ degrees 1 through 4
Legacy SPZ versions 1 through 3 use a gzip-compressed single-stream layout and are not supported.
Output
The loader returns a native Apache Arrow Table with the existing Gaussian splat columns:
POSITIONf_dc_0,f_dc_1,f_dc_2opacityscale_0,scale_1,scale_2rot_0,rot_1,rot_2,rot_3f_rest_*when spherical harmonics are present
Schema metadata includes loaders_gl.semantic_type = gaussian-splats and loaders_gl.gaussian_splats.source_format = spz.
Arrow schema metadata stores the SPZ header, antialiased, and extensionByteLength as JSON under loaders_gl.gaussian_splats.loader_data. When plaintext extension records are present, loaders_gl.gaussian_splats.extension_bytes contains their base64 encoding.
Options
| Option | Type | Default | Description |
|---|---|---|---|
splats.shape | 'arrow' | 'arrow' | Returns a native Arrow table. |
modules | object | {} | Include {'zstd-codec': ZstdCodec} for broad SPZ version 4 runtime compatibility. |