asset-compression — Claude Code rule: what it does, how to install
Guides your AI coding agent through 3D asset compression for Three.js. Covers Draco, Meshopt, KTX2 textures, and LOD implementation.
MIT ★ 4,719 updated 2026-10-24
.claude/rules/asset-compression.mdWhat asset-compression does
This rule equips agents with best practices for web 3D asset delivery. It outlines CLI commands for gltf-transform to achieve 90-95% geometry reduction via Draco or Meshopt, picking decompression trade-offs based on runtime needs.
Textures receive dedicated focus because raw PNG files uncompress entirely into VRAM: a 200KB PNG consumes over 20MB of GPU memory. The instructions guide conversions to KTX2 using UASTC for high-detail maps and ETC1S for background surfaces, along with UV remapping for atlases and THREE.LOD setups that yield 30-40% frame rate gains.
Client-side runtime requires proper transcoder setups pointing to /draco/ and /basis/ folders, while asset preparation depends on gltf-transform.
What it helps with
- compress GLB models via Draco or Meshopt algorithms
- eliminate GPU memory bloat by converting textures to KTX2
- configure loader paths for DRACOLoader and KTX2Loader
- implement THREE.LOD levels on complex meshes
Example prompts for the agent
- Optimize
model.glbusing gltf-transform with draco compression and ktx2 textures - Set up DRACOLoader and KTX2Loader paths for our Three.js scene loader
- Implement a THREE.LOD structure for this heavy mesh
How to install asset-compression
Manually: put the files in place
.claude/rules/asset-compression.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/asset-compression.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/asset-compression.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/asset-compression.mdManually: put the files in place
.clinerules/asset-compression.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about asset-compression
How to install asset-compression in Claude Code?
Place the rule file at .claude/rules/asset-compression.md in your project repository.
What does asset-compression do?
It guides code assistants in optimizing 3D assets using Draco/Meshopt geometry reduction, KTX2 GPU textures, texture atlasing, and LODs.
When should UASTC be chosen over ETC1S?
UASTC delivers higher visual fidelity for normal maps and hero assets, whereas ETC1S creates smaller files ideal for background and environment maps.
Source text
asset-compression.md · MIT
# Asset Compression
> Source: [100 Three.js Tips - Utsubo](https://www.utsubo.com/blog/threejs-best-practices-100-tips)
Proper asset compression is critical for web performance. Unoptimized assets are the #1 cause of slow 3D web experiences.
## Geometry Compression
### Draco Compression
Achieves 90-95% size reduction with Web Worker decompression.
```bash
gltf-transform draco model.glb compressed.glb --method edgebreaker
```
### Meshopt (Alternative to Draco)
Similar compression ratios with faster decompression. Consider Meshopt when decompression speed is critical.
### Setup Decoder Paths
```javascript
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/draco/');
```
## Texture Compression
### Why KTX2?
PNG/JPEG decompress fully in GPU memory:
- 200KB PNG = 20MB+ VRAM
KTX2 stays compressed in GPU memory, dramatically reducing VRAM usage.
### UASTC vs ETC1S
| Format | Quality | Size | Use Case |
|--------|---------|------|----------|
| UASTC | Higher | Larger | Normal maps, hero textures |
| ETC1S | Lower | Smaller | Environment textures, backgrounds |
### KTX2 Setup
```javascript
import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';
const ktx2Loader = new KTX2Loader();
ktx2Loader.setTranscoderPath('/basis/');
```
## CLI Optimization
### gltf-transform (Recommended)
```bash
gltf-transform optimize model.glb output.glb \
--texture-compress ktx2 \
--compress draco
```
### Visual Comparison Tool
Use [Shopify's gltf-compressor](https://github.com/Shopify/gltf-compressor) for interactive side-by-side compression preview (keyboard shortcut "C").
## Texture Atlasing
Combine multiple textures into atlases to reduce texture binds:
```javascript
// Update UV coordinates to reference atlas regions
mesh.geometry.attributes.uv.array = atlasUVs;
mesh.geometry.attributes.uv.needsUpdate = true;
```
## Level of Detail (LOD)
Can improve frame rates by 30-40%.
```javascript
const lod = new THREE.LOD();
lod.addLevel(highPolyMesh, 0);
lod.addLevel(mediumPolyMesh, 50);
lod.addLevel(lowPolyMesh, 100);
scene.add(lod);
```
## Summary Checklist
- [ ] Compress geometry with Draco or Meshopt
- [ ] Convert textures to KTX2
- [ ] Use UASTC for quality-critical textures
- [ ] Use ETC1S for secondary textures
- [ ] Atlas textures where possible
- [ ] Implement LOD for complex models
- [ ] Set up decoder paths correctly
© zebbern · MIT · zebbern/claude-code-guide