Loading Meshes
Loading…
Pick a format to load the same way: GLB, OBJ with its MTL, STL, or a MagicaVoxel .vox. Each fits the viewport; Code shows the loader call.
Supported formats
Section titled “Supported formats”| Format | Parser | Notes |
|---|---|---|
| OBJ | parseObj(string) | Optional MTL materials |
| glTF / GLB | parseGltf(ArrayBuffer) | Embedded textures supported |
| VOX | parseVox(ArrayBuffer) | MagicaVoxel palette colors |
| STL | parseStl(ArrayBuffer) | Binary or ASCII; no colors |
These parsers live in @glyphcss/core. loadMesh detects the format and returns polygons plus texture/animation data.
Loading yourself
Section titled “Loading yourself”import { loadMesh } from "glyphcss";const model = await loadMesh("/gallery/glb/apple.glb");const mesh = scene.add(model.polygons);// On teardown:mesh.dispose();model.dispose?.();Use your own asset URL. Recenter with recenterPolygons or the binding’s autoCenter; choose camera zoom for its world-unit size. For built-in and procedural geometry, see creating shapes.