# adom-glb2png

Render a GLB file to a PNG via headless three.js. Useful for verifying 3D component models without spinning up a webview + screenshot loop.

## Usage

```
adom-glb2png <glb-path> [--view top|iso|front|side|bottom] [--size N] [--out path]
```

- `--view` — camera direction, defaults to `iso`
- `--size` — output image is square `size × size`, defaults to 800
- `--out`  — output PNG path, defaults to `<basename>.png`

Exit codes: `0` on success, `1` on render error, `2` on bad input.

## How it works

A small Bun-compiled binary that spins up a headless Chromium (via puppeteer) pointing at a tiny three.js viewer page, loads the GLB, frames the camera so the bbox diagonal fills ~70% of the viewport, screenshots, exits.

- Camera near-plane is `0.0001` because most KiCad-pipeline GLBs use meters (a 0402 resistor's bbox diagonal is ~0.0012m).
- Double-render with `requestAnimationFrame` between passes makes the output buffer non-empty reliably under SwiftShader.
- First run downloads Chromium (~150 MB) into `~/.cache/puppeteer/`. Subsequent runs reuse the cache.

## Source

github.com/adom-inc/adom-glb2png
