dymokomi/luce-ply
PLY in Luce Base: ascii and binary reading and writing of any elements, meshes and point clouds as luce-geocore GeometrySets, and a parallel fast path for 3D Gaussian splat files.
A library written in luce-base. Latest release 0.1.0.
Install#
luc add dymokomi/luce-plyDocumentation#
luce-ply
PLY in Luce Base: reading and writing ASCII, binary little-endian and binary big-endian files with any elements and properties, as luce-geocore GeometrySets.
from luce_ply.ply import Ply
let geometry = Ply.load("scan.ply")
Ply.save(geometry, "copy.ply") # binary little-endian
Ply.save(geometry, "copy.txt.ply", "ascii")
print(Ply.warnings())
Reading
- The
vertexelement gives the points.x y zare the positions; every other property becomes a point attribute of its name, except these groups:nx ny nzbecomeN,red green blue(ordiffuse_*) becomeCdin 0..1 withalphaasAlpha, andu v,s t,texture_u texture_vortexture_s texture_tbecomeuv. - A
faceelement with avertex_indices(orvertex_index) list makes a mesh. Its other properties become face attributes, and atexcoordlist becomes corneruv. Without faces the points are a point cloud. - Lists on vertices and faces become array attributes.
- Every other element's scalar properties become detail arrays named
element.property. - Integer properties keep their values exactly (
uintas 64-bit). Double positions are stored as f32 offsets from an f64 origin at their center.
Gaussian splats
A 3DGS file (a vertex element with f_dc_0..2, opacity, scale_0..2 and rot_0..3) keeps those raw PLY names as f32 point attributes. Its channel-major f_rest_* become one array attribute, f_rest: per point, coefficient-major RGB items (item i is coefficient i + 1 of red, green and blue), 0, 3, 8 or 15 items. Its all-zero normals are dropped. luce-geocore's Bake GSplats turns these names into the splat conventions (orient, scale, opacity, Cd, sh).
Binary bodies without lists decode in parallel on luce-std's pool, a block of rows at a time: a 1M-splat degree-3 file (248 MB) reads in well under a second.
PlayCanvas compressed PLY (SuperSplat) reads to the same raw names. Writing it is not supported yet.
Writing
The mesh, or else the point cloud, is written as the vertex element (and the faces as face), mapping attributes back as the reader maps them. A cloud with the raw 3DGS names is written in the reference layout (x y z nx ny nz f_dc_* f_rest_* opacity scale_* rot_*, all float), so a 3DGS file read and written comes back byte for byte. ASCII floats use the fewest digits that read back to the same value.
Tests
luc test runs tests/ply: ASCII, binary little- and big-endian fixtures made in the test, a byte-exact 3DGS round trip, the f_rest interleaving against a hand-built file, compressed PLY, and the read and write times of a 1M-splat file.
Dependencies#
| Package | Version |
|---|---|
| dymokomi/luce-geocore | newest |
| dymokomi/luce-std | newest |
Versions#
0.1.0
Browse source · pack · commit 506e98de2158
SHA-256 d1a0dce59cf26ce104ec57e503d5efce7233255fb79435eca6b861fba36d50b5
luce-ply 0.1.0: first release