GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizlang/ply

3D Gaussian splats in the PLY files of 3DGS (binary, little endian, float properties), as a 3D model (gizai's Idol) makes them and a renderer (gizlang/meshdraw Stage.splats) or a model reads them. A splat is a row of WIDTH floats: x, y, z, the log scales, the rotation (w, x, y, z), the opacity before its sigmoid, the base color's spherical harmonic (f_dc) and, when it has them, the higher degrees' (f_rest).

gizlang
import * as Ply from "gizlang/ply";

Functions

read

gizlang
function read(data: bytes): Gaussians throws string

The splats of a 3DGS PLY file; any property it does not use is skipped.

Effects: fail, alloc.

write

gizlang
function write(s: Gaussians, comments: Vec<string>): bytes

S as a 3DGS PLY file (read reads it back): x, y, z, zero normals, f_dc, f_rest, opacity, scale and rot properties, each a float, with COMMENTS in its header.

Effects: fail, alloc.

comments

gizlang
function comments(data: bytes): Vec<string> throws string

The comments of a PLY file's header, each without its "comment ".

Effects: fail, alloc.

Constants

SPLAT

gizlang
const SPLAT: i64 = 14

The floats of a splat without higher degrees of color.