The 3D Gaussian splat file scalar; a loaded Splat is the .ply path.
The format is the standard 3DGS PLY: each vertex is one gaussian with its
centre x/y/z, its colour as spherical-harmonic coefficients
(f_dc_0..f_dc_2 for degree zero), opacity as a logit, log
scale_0..scale_2 and the rot_0..rot_3 quaternion.
HARMONIC_DEGREE_ZERO = 0.28209479177387814
module-attribute
The degree-zero spherical harmonic: a gaussian's colour is 0.5 + this × f_dc.
Splat
Bases: FileScalar
A 3D Gaussian splat model as a PLY file; a loaded value is its file Path.
Analysis-only: the reconstruction output cg.ui.SplatViewer renders, produced by
a recipe and never captured, so it has no platform mirror and no place in a schema.
Source code in capturegraph-lib/capturegraph/types/scalars/geometry/splat.py
| class Splat(FileScalar, name="edu.cornell.splat.3dgs", extensions=("ply",)):
"""A 3D Gaussian splat model as a PLY file; a loaded value is its file ``Path``.
Analysis-only: the reconstruction output ``cg.ui.SplatViewer`` renders, produced by
a recipe and never captured, so it has no platform mirror and no place in a schema.
"""
__slots__ = ()
analysis_only = True
def centers(self) -> "tuple[np.ndarray, np.ndarray]":
"""Every gaussian's centre and colour as ``(positions, colors)``.
N×3 ``float32`` metres and N×3 ``uint8``, the colour being the degree-zero
harmonic; what seeds another splat.
Raises:
ValueError: If ``self`` is not a binary little-endian PLY of gaussians.
"""
import numpy as np
from capturegraph.types.scalars.geometry.support.ply import vertex_columns
columns = vertex_columns(self)
positions = np.stack([columns["x"], columns["y"], columns["z"]], axis=1).astype(np.float32)
harmonics = np.stack([columns[f"f_dc_{index}"] for index in range(3)], axis=1)
colors = np.clip((0.5 + HARMONIC_DEGREE_ZERO * harmonics) * 255.0, 0, 255)
return positions, colors.astype(np.uint8)
|
centers()
Every gaussian's centre and colour as (positions, colors).
N×3 float32 metres and N×3 uint8, the colour being the degree-zero
harmonic; what seeds another splat.
Raises:
| Type |
Description |
ValueError
|
If self is not a binary little-endian PLY of gaussians.
|
Source code in capturegraph-lib/capturegraph/types/scalars/geometry/splat.py
| def centers(self) -> "tuple[np.ndarray, np.ndarray]":
"""Every gaussian's centre and colour as ``(positions, colors)``.
N×3 ``float32`` metres and N×3 ``uint8``, the colour being the degree-zero
harmonic; what seeds another splat.
Raises:
ValueError: If ``self`` is not a binary little-endian PLY of gaussians.
"""
import numpy as np
from capturegraph.types.scalars.geometry.support.ply import vertex_columns
columns = vertex_columns(self)
positions = np.stack([columns["x"], columns["y"], columns["z"]], axis=1).astype(np.float32)
harmonics = np.stack([columns[f"f_dc_{index}"] for index in range(3)], axis=1)
colors = np.clip((0.5 + HARMONIC_DEGREE_ZERO * harmonics) * 255.0, 0, 255)
return positions, colors.astype(np.uint8)
|