bundle.gs3d.ply

3D Gaussian Splatting PLY reader and writer.

The 3DGS PLY layout (as produced by inria-graphdeco/gaussian-splatting, 3DGRUT, gsplat, and most other trainers) stores one vertex per Gaussian with the following float32 properties:

x, y, z – centre position nx, ny, nz – (optional) ignored on read, written as zeros f_dc_0, f_dc_1, f_dc_2 – spherical-harmonics DC term (RGB) f_rest_0 .. f_rest_44 – SH degrees 1..3 (3 channels * 15 coefficients) opacity – logit-space opacity scale_0, scale_1, scale_2 – log-space anisotropic scale rot_0, rot_1, rot_2, rot_3 – wxyz quaternion (not normalised)

This module reads/writes that format using a numpy structured array. The in-memory container is GaussianCloudArrays, a plain dataclass that exists only to wrap the buffer and provide convenience accessors. It is deliberately not a bundle.core.data.Data subclass — it owns non-JSON-serialisable arrays.

Numpy is an optional dependency. Importing this module without numpy installed will raise a helpful ImportError only at call time.

Attributes

log

Classes

GaussianCloudArrays

In-memory Gaussian splat cloud backed by a numpy structured array.

Functions

sh_rest_count(sh_degree) → int

Number of f_rest_* coefficients for a given SH degree.

property_names(sh_degree) → list[str]

Ordered PLY property names for a given SH degree.

read_ply_header(path) → bundle.gs3d.data.GaussianCloud

Read just the PLY header and return a GaussianCloud record.

read_ply(path) → GaussianCloudArrays

Read a 3DGS PLY file fully into a GaussianCloudArrays.

write_ply(path, arrays) → bundle.gs3d.data.GaussianCloud

Write a GaussianCloudArrays to disk in the 3DGS PLY format.

Module Contents

bundle.gs3d.ply.log
bundle.gs3d.ply.sh_rest_count(sh_degree: int) → int[source]

Number of f_rest_* coefficients for a given SH degree.

SH degree N has (N+1)**2 coefficients per channel; the DC term accounts for one of them. Three RGB channels gives the total below.

bundle.gs3d.ply.property_names(sh_degree: int) → list[str][source]

Ordered PLY property names for a given SH degree.

class bundle.gs3d.ply.GaussianCloudArrays[source]

In-memory Gaussian splat cloud backed by a numpy structured array.

This is intentionally not a Data subclass: it owns numpy buffers that should never be JSON-serialised. Use write_ply() to persist.

data

Structured array with one record per Gaussian. The dtype is built from property_names() for the requested SH degree.

sh_degree

SH degree the array was allocated for.

data: numpy.ndarray
sh_degree: int = 3
classmethod empty(count: int, sh_degree: int = 3) → GaussianCloudArrays[source]

Allocate an uninitialised cloud of count Gaussians.

property positions: GaussianCloudArrays.positions.np

View into (N, 3) xyz positions.

bbox() → tuple[tuple[float, float, float], tuple[float, float, float]][source]

Axis-aligned bounding box (min_xyz, max_xyz).

to_metadata(path: pathlib.Path) → bundle.gs3d.data.GaussianCloud[source]

Build a GaussianCloud metadata record for path.

async bundle.gs3d.ply.read_ply_header(path: pathlib.Path) → bundle.gs3d.data.GaussianCloud[source]

Read just the PLY header and return a GaussianCloud record.

This avoids loading the (potentially huge) vertex payload — useful for bundle gs3d info and other tools that only need metadata.

async bundle.gs3d.ply.read_ply(path: pathlib.Path) → GaussianCloudArrays[source]

Read a 3DGS PLY file fully into a GaussianCloudArrays.

Only binary little-endian PLYs are supported (the universal 3DGS format).

async bundle.gs3d.ply.write_ply(path: pathlib.Path, arrays: GaussianCloudArrays) → bundle.gs3d.data.GaussianCloud[source]

Write a GaussianCloudArrays to disk in the 3DGS PLY format.

Returns the populated GaussianCloud metadata record.