Loading Meshes
glyphcss ships parsers for four mesh formats. All return a Polygon[] that
the rasterizer consumes:
| Format | Parser | Notes |
|---|---|---|
| Wavefront OBJ | parseObj(source: string) | + optional MTL for vertex colors |
| glTF / GLB | parseGltf(buffer: ArrayBuffer) | embedded textures supported |
MagicaVoxel .vox | parseVox(buffer: ArrayBuffer) | natural fit for voxel render mode |
Or use the format-detecting wrapper:
import { loadMesh } from "glyphcss";
// Replace "/cottage.glb" with the path to your own file.const { polygons, dispose } = await loadMesh("/cottage.glb");The URL
/cottage.glbis a placeholder — substitute the path to your own asset. For runnable examples that don’t require a file, see Creating Shapes.
Choosing a render mode
Section titled “Choosing a render mode”| Mode | When |
|---|---|
wireframe | Geometric meshes, lattices, anything that should look like line art |
solid | Smooth-shaded surfaces — Lambert shading mapped to a glyph ramp ( .:-=+*#%@) |
voxel | VOX models — one glyph per voxel face, depth-sorted |
{/* Replace placeholder paths with paths to your own assets. */}<GlyphMesh src="/cottage.glb" mode="solid" /><GlyphMesh src="/tree.vox" mode="voxel" /><GlyphMesh geometry="cuboctahedron" mode="wireframe" />Built-in geometries
Section titled “Built-in geometries”For the common case of “I just want a rotating shape”, glyphcss ships generators:
<GlyphMesh geometry="cuboctahedron" /><GlyphMesh geometry="icosahedron" /><GlyphMesh geometry="cube" />These render as wireframe by default with the Prime Radiant–style inner lattice (for cuboctahedron) or plain edge-only (for icosahedron / cube).
Procedural meshes
Section titled “Procedural meshes”For shapes that don’t come from a file, build Polygon[] arrays directly
in JavaScript. The @glyphcss/core package ships generators for all the Platonic
solids plus utility shapes (rings, planes, axes gizmos).
See the full walkthrough — with copy-paste examples for every helper and a parametric wavy-plane example — in Creating Shapes.