Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/asset-compression.md
Open on GitHub

What 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.glb using 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.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set86

The whole set →
runtime-verifier The runtime-verifier subagent for Claude Code verifies acceptance criteria through real CLI, service, browser, or filesystem boundaries without modifying code. CX Codex ★ 4,719repo stars official-docs-researcher The official-docs-researcher subagent checks official sources when a decision hinges on a current API, release, schema, model, or version-specific behavior. CX Codex ★ 4,719repo stars change-implementer change-implementer — a subagent that carries one pre-approved change through to the end: edits the code, runs it for real, and reports what it observed. CX Codex ★ 4,719repo stars tsl-why-use tsl-why-use — a rule that pushes the coding agent to build custom Three.js materials from TSL nodes rather than patching shaders through onBeforeCompile. CX Codex +1 ★ 4,719repo stars perf-never-set-state-in-useframe perf-never-set-state-in-useframe — a react-three-fiber rule that bans setState inside useFrame and pushes you to mutate a ref instead, so animation stops triggering a React render every frame. CX Codex +1 ★ 4,719repo stars frame-delta-time frame-delta-time — a rule that makes every animated movement multiply by delta, so speed stops depending on the display's refresh rate. CX Codex +1 ★ 4,719repo stars draw-call-optimization The draw-call-optimization rule for Claude Code guides Three.js optimization, reducing draw calls to below 100 per frame through instancing, batching, and geometry merging. CX Codex +1 ★ 4,719repo stars object-pooling object-pooling — a rule that pushes the agent to reuse bullets, particles and NPCs from a pool instead of building and discarding meshes every frame. CX Codex +1 ★ 4,719repo stars

Project sponsors

Companies that keep this analytics open