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
STLparseStl(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.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
inkIllustration-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>

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.

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.