Skip to content

Loading Meshes

glyphcss ships parsers for four mesh formats. All return a Polygon[] that the rasterizer consumes:

FormatParserNotes
Wavefront OBJparseObj(source: string)+ optional MTL for vertex colors
glTF / GLBparseGltf(buffer: ArrayBuffer)embedded textures supported
MagicaVoxel .voxparseVox(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.glb is a placeholder — substitute the path to your own asset. For runnable examples that don’t require a file, see Creating Shapes.

ModeWhen
wireframeGeometric meshes, lattices, anything that should look like line art
solidSmooth-shaded surfaces — Lambert shading mapped to a glyph ramp ( .:-=+*#%@)
voxelVOX 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" />

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).

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.