Render GLB 3D models to PNG images using headless WebGL
npm install render-glbRender GLB (glTF 2.0 Binary) 3D models to PNG images using headless WebGL.
- Headless rendering - no display required
- Auto-fit camera to model bounds
- Configurable output dimensions
- Cross-platform: macOS, Linux, Windows
- JSON output for scripting
``bash`
npm install -g render-glb
Or use directly with bunx/npx (no install needed):
`bash`
bunx render-glb model.glb output.png
npx render-glb model.glb output.png
`bash
render-glb
Options:
--width N Output image width (default: 1024)
--height N Output image height (default: 1024)
--help, -h Show help message
`
Auto-scaling: The camera automatically adjusts to fit any model size, from millimeter-scale parts to large assemblies.
`bashBasic usage
render-glb model.glb output.png
$3
Returns JSON to stdout:
`json
{
"success": true,
"input": "/path/to/model.glb",
"output": "/path/to/output.png",
"width": 512,
"height": 512,
"size_bytes": 12345,
"render_time_ms": 150
}
`Platform Notes
$3
Works directly, no additional setup needed.$3
Requires xvfb for virtual framebuffer:`bash
Ubuntu/Debian
sudo apt-get install xvfb libgl1-mesa-devRun with xvfb-run
xvfb-run render-glb model.glb output.png
``- three.js - 3D rendering engine
- gl - Headless WebGL
- node-three-gltf - GLB loader for Node.js
- pngjs - PNG encoding
- jsdom - DOM shim for Three.js
MIT