Loading...
Loading...
Programmatic GLB/glTF 3D model compression library with a multi-phase pipeline, skinned-model awareness, and custom glTF-Transform transforms. Use when integrating compression into application code, building custom pipelines, or using individual transforms.
npx skill4agent add kjanat/glb-compressor glb-compressor-libraryimport { compress, init, PRESETS } from 'glb-compressor';
await init(); // Pre-warm WASM (optional, called automatically)
const glbBytes = await Bun.file('model.glb').bytes();
const result = await compress(glbBytes, { preset: 'aggressive' });
await Bun.write('out.glb', result.buffer);import { ... } from 'glb-compressor'; // Library API
import { ... } from 'glb-compressor/server'; // Server (guarded by import.meta.main)
import { ... } from 'glb-compressor/cli'; // CLI entry"bun""node"init(): Promise<void>compress()compress(input, options?): Promise<CompressResult>| Param | Type | Description |
|---|---|---|
| | Raw GLB file bytes |
| | |
| | Additional simplification in |
| | Progress callback (used by SSE) |
| | Suppress console output |
CompressResultinterface CompressResult {
buffer: Uint8Array; // Compressed GLB binary
method: string; // 'gltfpack' | 'meshopt'
originalSize?: number; // Input byte count
}getHasGltfpack(): booleangltfpack| File | Purpose |
|---|---|
| api.md | Full API surface: types, constants, utilities |
| transforms.md | Custom glTF-Transform transforms for a-la-carte use |
| Task | Files to Read |
|---|---|
| Basic compression | This file only |
| Custom pipeline / advanced | This file + transforms.md |
| Full type reference | This file + api.md |
type CompressPreset = 'default' | 'balanced' | 'aggressive' | 'max';| Preset | Skinned behavior | Static behavior |
|---|---|---|
| | |
| + animation quant ( | Same + |
| + stronger quant ( | Same + |
| + supercompression ( | Same |
cli/server/mod.ts