# Loading Meshes

```ts
import { createGlyphPerspectiveCamera, createGlyphScene, createGlyphOrbitControls } from "glyphcss";
import { loadMesh, recenterPolygons } from "@glyphcss/core";

const host = document.getElementById("scene");
const camera = createGlyphPerspectiveCamera({ rotX: 65, rotY: 0, zoom: 0.3, distance: 0, perspective: 32000, stretch: 1 });
const scene = createGlyphScene(host, { camera, autoSize: true, mode: "solid", colorEncoding: "spans" });
scene.output.style.fontSize = "10px";
scene.output.style.lineHeight = "1";
scene.fit();
const { polygons } = await loadMesh("/gallery/glb/Duck.glb", { solidTextureSamples: false });
scene.add(recenterPolygons(polygons));
createGlyphOrbitControls(scene, { drag: true, wheel: true });
```



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

| 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

```ts
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](/guides/creating-shapes/).
