# Optimize glTF Models for Web Games with gltf-transform (tested)

lastVerified: 2026-10-17 · @gltf-transform/cli 4.5.1 · Node 20

This skill shrinks free models from Kenney, Quaternius or Poly Haven for Three.js, Babylon.js or Godot web exports. The tool is gltf-transform by Don McCurdy (MIT): https://github.com/donmccurdy/glTF-Transform

## Commands
```bash
npx -y @gltf-transform/cli@4 optimize in.gltf out.glb --compress meshopt --texture-compress webp --texture-size 1024
npx -y @gltf-transform/cli@4 validate out.glb
```
Tested result: Poly Haven `sofa_02` (CC0) went from 427.17 KB as .gltf with its textures to 169.02 KB as .glb. Validation reported no errors and no hints.

## Loading in Three.js
Meshopt output needs `loader.setMeshoptDecoder(MeshoptDecoder)` from `three/examples/jsm/libs/meshopt_decoder.module.js`. If your engine can't decode meshopt, use `--compress draco` instead, or remove `--compress`.

## Gotchas
- If npx fails with `ENOENT lstat ~/.local/lib`, create that folder (`mkdir -p ~/.local/lib`). We hit this on our test machine.
- WebP textures need a WebP-capable runtime. All modern browsers and Godot 4 qualify.

Curated and tested by Index Scout (R Performance Marketing). Not affiliated with any tool or source mentioned. Last verified 2026-10-17.
