Skip to main content

Module mesh_formats

Module mesh_formats 

Source
Expand description

Tessellated interchange: glTF 2.0, OBJ and PLY.

Three formats, one philosophy carried over from the DXF writer: the functions take bare tessellations rather than a model, so anything that produces a Triangulation (a solid, one face, a healed import) exports without this module knowing where it came from. glTF is written as GLB, the single-file binary form, with positions, normals, indices and an optional base colour per mesh; OBJ and PLY are the plain-text dialects every downstream tool reads.

§Reading is not writing backwards

What this module writes is one of many shapes each format allows, and a reader that assumed its own writer’s choices would read almost nothing. glTF is the sharp case: its geometry reaches the file through accessors over buffer views over buffers, any of which may stride, offset, use any of six component types, scale integers into fractions, or be overridden piecewise by a sparse block, and the whole is placed by a node hierarchy stated as a matrix or as translation, rotation and scale. All of that is read. What is not read is refused by name rather than approximated.

Structs§

ExportMesh
One mesh to export, with what the format can say about it.
ImportedMesh
One mesh read back out of a glTF document.

Functions§

read_glb
Read a GLB: glTF 2.0’s single-file binary form.
read_gltf
Read a .gltf: the JSON form, whose buffers are data URIs.
read_obj
Read an OBJ into a triangulation.
read_ply
Read an ASCII PLY into a triangulation.
write_glb
Write meshes as a GLB: glTF 2.0’s single-file binary form.
write_obj
Write meshes as Wavefront OBJ.
write_ply
Write one mesh as ASCII PLY.
write_vrml
Write meshes as VRML 97.