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 |
| STL | parseStl(buffer: ArrayBuffer) | binary + ASCII; no color data in the format |
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 |
ink | Illustration-style outlines — silhouette + crease edges only, oriented glyph per contour direction |
mode is a scene option, not a mesh prop — every mesh in a scene renders
through the same mode:
{/* Replace placeholder paths with paths to your own assets. */}<GlyphScene mode="solid"><GlyphMesh src="/cottage.glb" /></GlyphScene><GlyphScene mode="voxel"><GlyphMesh src="/tree.vox" /></GlyphScene><GlyphScene mode="wireframe"><GlyphMesh geometry="cuboctahedron" /></GlyphScene><GlyphScene mode="ink"><GlyphMesh src="/cottage.glb" /></GlyphScene>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 through the scene’s mode like any other mesh — solid by
default.
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.