[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EHVTEHSF17G0Z6NBNEAVEM":3,"skill-same:01M7EHVTEHSF17G0Z6NBNEAVEM":67},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":28,"commitSha":29,"skillDirectory":30,"forksCount":13,"repositoryHtmlUrl":31,"repositoryHomepageUrl":6,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7EHVTEHSF17G0Z6NBNEAVEM","threejs-agents-model-optimizer",null,"Use when optimizing 3D models for web delivery: reducing file size, compressing meshes, optimizing textures, or generating LOD. Provides a complete GLTF optimization pipeline using Draco, KTX2, mesh simplification, and gltf-transform. Keywords: optimize model, reduce file size, Draco compression, KTX2, gltf-transform, mesh simplification, LOD, GLTF optimize, bundle size, model too big, slow loading, compress 3D model.","mhyahya854\u002FAI-Second-Brain_Universal-Rules","mhyahya854","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F194078115?v=4","01M7EGSP2M9T858SDHJMXQ257Y","01M7EGSP3N6HN6879SVDPMD4DZ",0,"MIT","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: threejs-agents-model-optimizer\ndescription: >\n  Use when optimizing 3D models for web delivery: reducing file size,\n  compressing meshes, optimizing textures, or generating LOD. Provides\n  a complete GLTF optimization pipeline using Draco, KTX2, mesh\n  simplification, and gltf-transform.\n  Keywords: optimize model, reduce file size, Draco compression, KTX2, gltf-transform, mesh simplification, LOD, GLTF optimize, bundle size, model too big, slow loading, compress 3D model.\nlicense: MIT\ncompatibility: \"Designed for Claude Code. Requires Three.js r160+.\"\nmetadata:\n  author: OpenAEC-Foundation\n  version: \"1.0\"\n---\n\n# threejs-agents-model-optimizer\n\n## Quick Reference\n\n### Optimization Pipeline Overview\n\n```\nINPUT (.glb\u002F.gltf)\n  |\n  v\n[1. ASSESS] ── polygon count, texture sizes, file size, draw calls\n  |\n  v\n[2. MESH OPTIMIZE] ── dedup, flatten, join, weld, simplify\n  |\n  v\n[3. TEXTURE OPTIMIZE] ── resize, KTX2 compress, atlas\n  |\n  v\n[4. COMPRESS] ── Draco mesh compression, quantize attributes\n  |\n  v\n[5. VALIDATE] ── visual diff, file size check, runtime test\n  |\n  v\nOUTPUT (optimized .glb)\n```\n\n### Target File Size Budgets\n\n| Platform | Max File Size | Max Polygons | Max Texture Size |\n|----------|--------------|--------------|------------------|\n| Mobile web | 2 MB | 50K triangles | 1024x1024 |\n| Desktop web | 5 MB | 200K triangles | 2048x2048 |\n| Desktop app | 20 MB | 500K triangles | 4096x4096 |\n| Hero asset (single) | 1 MB | 30K triangles | 1024x1024 |\n\n### Tool Selection\n\n| Tool | Best For | Install |\n|------|----------|---------|\n| `gltf-transform` | Full pipeline, scriptable, Node.js API | `npm i @gltf-transform\u002Fcli` |\n| `gltfpack` | Fast one-shot compression | `npm i -g gltfpack` |\n| Blender | Manual mesh editing, UV repacking | Blender 3.6+ |\n\n### Critical Warnings\n\n**NEVER** skip the assessment step -- optimizing blindly wastes time and can produce worse results than the original.\n\n**NEVER** apply Draco compression AND meshopt compression to the same file -- they are mutually exclusive. Choose ONE.\n\n**NEVER** use KTX2 UASTC for diffuse color maps on mobile -- UASTC textures are 8-16 bytes\u002Ftexel in VRAM. ALWAYS use ETC1S for color maps on mobile targets.\n\n**NEVER** simplify meshes below 10% of original without visual validation -- aggressive simplification destroys silhouettes and UV mapping.\n\n**ALWAYS** validate optimized models visually before shipping -- automated metrics cannot catch all visual artifacts.\n\n**ALWAYS** keep the original unoptimized model in version control -- optimization is lossy and irreversible.\n\n---\n\n## Step 1: Assessment\n\nBefore optimizing, ALWAYS gather these metrics:\n\n```bash\n# Using gltf-transform CLI\nnpx gltf-transform inspect model.glb\n\n# Key output to check:\n# - Mesh count and total triangle count\n# - Texture count, dimensions, and format\n# - Total file size (uncompressed)\n# - Accessor count (indicates potential deduplication)\n# - Animation track count\n```\n\n### Assessment Decision Tree\n\n```\nFile size > target budget?\n├── YES: Textures > 50% of file size?\n│   ├── YES → Start with texture optimization (Step 3)\n│   └── NO → Start with mesh optimization (Step 2)\n└── NO: Draw calls > 50?\n    ├── YES → Merge meshes (join\u002Fflatten)\n    └── NO → Only apply compression (Step 4)\n```\n\n### Polygon Count Guidelines\n\n| Asset Type | Target Triangles | Notes |\n|------------|-----------------|-------|\n| Background prop | 100-500 | Minimal detail |\n| Mid-ground object | 1K-5K | Visible but not hero |\n| Hero\u002Ffocus object | 10K-50K | High detail, close-up |\n| Character | 15K-30K | With LOD chain |\n| Full scene | 100K-300K | All objects combined |\n| Architectural (BIM) | 200K-500K | Simplified from CAD |\n\n---\n\n## Step 2: Mesh Optimization\n\n### gltf-transform Mesh Pipeline\n\nALWAYS run these operations in this order:\n\n```bash\n# 1. Remove duplicate accessors and unused data\nnpx gltf-transform dedup input.glb deduped.glb\n\n# 2. Flatten node hierarchy (removes empty nodes)\nnpx gltf-transform flatten deduped.glb flat.glb\n\n# 3. Join meshes sharing the same material\nnpx gltf-transform join flat.glb joined.glb\n\n# 4. Weld vertices (merge vertices within tolerance)\nnpx gltf-transform weld joined.glb welded.glb --tolerance 0.0001\n\n# 5. Simplify mesh (reduce triangle count)\nnpx gltf-transform simplify welded.glb simplified.glb \\\n  --ratio 0.5 \\\n  --error 0.001\n\n# 6. Remove unused resources\nnpx gltf-transform prune simplified.glb output.glb\n```\n\n### Combined Pipeline (Single Command)\n\n```bash\nnpx gltf-transform optimize input.glb output.glb \\\n  --compress draco \\\n  --texture-compress ktx2\n```\n\n### Mesh Simplification Settings\n\n| Quality Level | Ratio | Error Tolerance | Use Case |\n|--------------|-------|-----------------|----------|\n| Minimal | 0.75 | 0.0005 | Subtle reduction, preserves detail |\n| Moderate | 0.50 | 0.001 | Balanced quality\u002Fsize |\n| Aggressive | 0.25 | 0.005 | LOD1\u002FLOD2 generation |\n| Extreme | 0.10 | 0.01 | LOD3, distant objects only |\n\n### Weld Settings\n\n| Tolerance | Effect |\n|-----------|--------|\n| 0.0001 | Conservative -- merges only nearly-identical vertices |\n| 0.001 | Standard -- good for most models |\n| 0.01 | Aggressive -- may cause visible seams on hard edges |\n\n---\n\n## Step 3: Texture Optimization\n\n### Texture Decision Tree\n\n```\nTexture type?\n├── Color\u002FDiffuse (baseColorTexture)\n│   ├── Mobile → ETC1S (KTX2), max 1024px\n│   └── Desktop → UASTC (KTX2), max 2048px\n├── Normal map\n│   └── ALWAYS UASTC (KTX2) — ETC1S causes visible artifacts on normals\n├── ORM (occlusion\u002Froughness\u002Fmetallic)\n│   └── ETC1S (KTX2) — perceptual quality less critical\n├── Emissive\n│   └── ETC1S (KTX2) — unless HDR, then keep as-is\n└── HDR environment\n    └── Keep as .hdr or .exr — do NOT KTX2 compress\n```\n\n### KTX2 Compression Commands\n\n```bash\n# ETC1S: smaller file, lower quality (color maps, ORM)\nnpx gltf-transform ktx2 input.glb output.glb \\\n  --slots \"baseColorTexture,emissiveTexture,occlusionTexture\" \\\n  --filter \"baseColorTexture=etc1s\" \\\n  --quality 128\n\n# UASTC: larger file, higher quality (normal maps)\nnpx gltf-transform ktx2 input.glb output.glb \\\n  --slots \"normalTexture\" \\\n  --filter \"normalTexture=uastc\"\n```\n\n### KTX2: ETC1S vs UASTC\n\n| Property | ETC1S | UASTC |\n|----------|-------|-------|\n| File size | Very small (6-8x smaller) | Moderate (2-4x smaller) |\n| VRAM usage | Small | Large (8-16 bytes\u002Ftexel) |\n| Quality | Good for color | Near-lossless |\n| Decode speed | Fast | Requires transcoding |\n| Best for | Color maps, ORM, emissive | Normal maps, detail textures |\n\n### Texture Resize\n\n```bash\n# Resize all textures to max 1024x1024\nnpx gltf-transform resize input.glb output.glb --width 1024 --height 1024\n\n# Resize only textures larger than 2048px\nnpx gltf-transform resize input.glb output.glb --width 2048 --height 2048\n```\n\n---\n\n## Step 4: Mesh Compression\n\n### Draco Compression\n\n```bash\n# Default Draco compression\nnpx gltf-transform draco input.glb output.glb\n\n# Draco with quality settings\nnpx gltf-transform draco input.glb output.glb \\\n  --quantize-position 14 \\\n  --quantize-normal 10 \\\n  --quantize-texcoord 12 \\\n  --quantize-color 8\n```\n\n### Draco Quantization Bits\n\n| Attribute | Default | High Quality | Aggressive |\n|-----------|---------|-------------|------------|\n| Position | 14 bits | 16 bits | 11 bits |\n| Normal | 10 bits | 12 bits | 8 bits |\n| TexCoord | 12 bits | 14 bits | 10 bits |\n| Color | 8 bits | 10 bits | 6 bits |\n\nHigher bits = better quality, larger file. 14-bit position is sufficient for most models.\n\n### Quantize Without Draco\n\n```bash\n# Quantize attributes (reduces file size without Draco dependency)\nnpx gltf-transform quantize input.glb output.glb\n```\n\n### Loading Draco-Compressed Models in Three.js\n\n```javascript\nimport { GLTFLoader } from 'three\u002Faddons\u002Floaders\u002FGLTFLoader.js';\nimport { DRACOLoader } from 'three\u002Faddons\u002Floaders\u002FDRACOLoader.js';\n\nconst dracoLoader = new DRACOLoader();\n\u002F\u002F ALWAYS set the decoder path — Draco uses WASM\ndracoLoader.setDecoderPath('https:\u002F\u002Fwww.gstatic.com\u002Fdraco\u002Fversioned\u002Fdecoders\u002F1.5.6\u002F');\ndracoLoader.preload();\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setDRACOLoader(dracoLoader);\n\ngltfLoader.load('model-draco.glb', (gltf) => {\n  scene.add(gltf.scene);\n});\n\n\u002F\u002F ALWAYS dispose when done\ndracoLoader.dispose();\n```\n\n### Loading KTX2-Compressed Textures\n\n```javascript\nimport { KTX2Loader } from 'three\u002Faddons\u002Floaders\u002FKTX2Loader.js';\n\nconst ktx2Loader = new KTX2Loader();\n\u002F\u002F ALWAYS set the transcoder path — KTX2 uses WASM basis_transcoder\nktx2Loader.setTranscoderPath('https:\u002F\u002Fcdn.jsdelivr.net\u002Fnpm\u002Fthree@0.160.0\u002Fexamples\u002Fjsm\u002Flibs\u002Fbasis\u002F');\nktx2Loader.detectSupport(renderer);\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setKTX2Loader(ktx2Loader);\n```\n\n---\n\n## Step 5: Validation\n\n### Validation Checklist\n\nAfter optimization, ALWAYS verify:\n\n1. **File size** -- meets target budget from Step 1\n2. **Visual quality** -- load in Three.js viewer, compare to original\n3. **Bounding box** -- same dimensions as original (no scale errors)\n4. **Materials** -- all textures load, no missing maps\n5. **Animations** -- all clips play correctly (if applicable)\n6. **Performance** -- measure draw calls, frame time\n\n```bash\n# Compare file sizes\nls -la original.glb optimized.glb\n\n# Validate GLTF structure\nnpx gltf-transform inspect optimized.glb\n\n# Check for errors\nnpx gltf-transform validate optimized.glb\n```\n\n---\n\n## LOD Generation\n\n### LOD Chain Strategy\n\n| LOD Level | Screen Coverage | Triangle Ratio | Distance |\n|-----------|----------------|----------------|----------|\n| LOD0 | >30% screen | 1.0 (full) | Near |\n| LOD1 | 10-30% screen | 0.5 | Medium |\n| LOD2 | 3-10% screen | 0.25 | Far |\n| LOD3 | \u003C3% screen | 0.10 | Very far |\n\n### Generating LODs with gltf-transform\n\n```bash\n# Generate LOD chain\nnpx gltf-transform simplify model.glb lod0.glb --ratio 1.0\nnpx gltf-transform simplify model.glb lod1.glb --ratio 0.5 --error 0.001\nnpx gltf-transform simplify model.glb lod2.glb --ratio 0.25 --error 0.005\nnpx gltf-transform simplify model.glb lod3.glb --ratio 0.10 --error 0.01\n```\n\n### Three.js LOD Implementation\n\n```javascript\nimport * as THREE from 'three';\n\nconst lod = new THREE.LOD();\n\n\u002F\u002F ALWAYS add LODs from highest to lowest detail\nlod.addLevel(meshLOD0, 0);    \u002F\u002F distance 0 = closest\nlod.addLevel(meshLOD1, 10);   \u002F\u002F switch at 10 units\nlod.addLevel(meshLOD2, 30);   \u002F\u002F switch at 30 units\nlod.addLevel(meshLOD3, 80);   \u002F\u002F switch at 80 units\n\nscene.add(lod);\n\n\u002F\u002F In render loop — ALWAYS call update for LOD switching\nlod.update(camera);\n```\n\n---\n\n## gltfpack Alternative\n\nFor quick one-shot optimization without a pipeline:\n\n```bash\n# Install\nnpm install -g gltfpack\n\n# Optimize with meshopt compression\ngltfpack -i input.glb -o output.glb -cc -tc\n\n# Flags:\n# -cc  mesh compression (meshopt)\n# -tc  texture compression (KTX2\u002FBasisU)\n# -si N  simplify to ratio (0.0-1.0)\n# -tp  texture power-of-two resize\n```\n\n**NEVER** mix gltfpack meshopt output with gltf-transform Draco -- the compression formats are incompatible.\n\n### Loading Meshopt-Compressed Models\n\n```javascript\nimport { MeshoptDecoder } from 'three\u002Faddons\u002Flibs\u002Fmeshopt_decoder.module.js';\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setMeshoptDecoder(MeshoptDecoder);\n```\n\n---\n\n## Blender Export Optimization\n\nWhen exporting from Blender to glTF:\n\n| Setting | Recommended Value | Why |\n|---------|-------------------|-----|\n| Format | glTF Binary (.glb) | Single file, smaller |\n| Apply Modifiers | ON | Bakes procedural geometry |\n| Compression | OFF | Compress with gltf-transform after |\n| Textures | Include | Embedded in .glb |\n| Limit to | Selected Objects | Avoid exporting hidden\u002Funused |\n| +Y Up | ON | Three.js convention |\n\n**NEVER** enable Draco in Blender's exporter -- Blender's Draco implementation is outdated. ALWAYS compress with gltf-transform or gltfpack after export.\n\n---\n\n## Node.js Scripting with gltf-transform API\n\n```javascript\nimport { NodeIO } from '@gltf-transform\u002Fcore';\nimport { dedup, flatten, join, weld, simplify,\n         textureCompress, draco, prune, quantize } from '@gltf-transform\u002Ffunctions';\nimport draco3d from 'draco3dgltf';\nimport sharp from 'sharp';\n\nconst io = new NodeIO()\n  .registerExtensions(KHRONOS_EXTENSIONS)\n  .registerDependencies({\n    'draco3d.decoder': await draco3d.createDecoderModule(),\n    'draco3d.encoder': await draco3d.createEncoderModule(),\n  });\n\nconst document = await io.read('input.glb');\n\n\u002F\u002F ALWAYS run transforms in dependency order\nawait document.transform(\n  dedup(),\n  flatten(),\n  join(),\n  weld({ tolerance: 0.0001 }),\n  simplify({ ratio: 0.5, error: 0.001 }),\n  textureCompress({ targetFormat: 'ktx2' }),\n  draco(),\n  prune(),\n  quantize(),\n);\n\nawait io.write('output.glb', document);\n```\n\n---\n\n## Reference Links\n\n- [references\u002Fmethods.md](references\u002Fmethods.md) -- gltf-transform API and Three.js loader methods\n- [references\u002Fexamples.md](references\u002Fexamples.md) -- Complete optimization pipeline examples\n- [references\u002Fanti-patterns.md](references\u002Fanti-patterns.md) -- Common optimization mistakes\n\n### Official Sources\n\n- https:\u002F\u002Fgltf-transform.dev\u002F\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FGLTFLoader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FDRACOLoader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FKTX2Loader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#api\u002Fen\u002Fobjects\u002FLOD\n- https:\u002F\u002Fgithub.com\u002Fzeux\u002Fmeshoptimizer\n","# threejs-agents-model-optimizer\n\n## Quick Reference\n\n### Optimization Pipeline Overview\n\n```\nINPUT (.glb\u002F.gltf)\n  |\n  v\n[1. ASSESS] ── polygon count, texture sizes, file size, draw calls\n  |\n  v\n[2. MESH OPTIMIZE] ── dedup, flatten, join, weld, simplify\n  |\n  v\n[3. TEXTURE OPTIMIZE] ── resize, KTX2 compress, atlas\n  |\n  v\n[4. COMPRESS] ── Draco mesh compression, quantize attributes\n  |\n  v\n[5. VALIDATE] ── visual diff, file size check, runtime test\n  |\n  v\nOUTPUT (optimized .glb)\n```\n\n### Target File Size Budgets\n\n| Platform | Max File Size | Max Polygons | Max Texture Size |\n|----------|--------------|--------------|------------------|\n| Mobile web | 2 MB | 50K triangles | 1024x1024 |\n| Desktop web | 5 MB | 200K triangles | 2048x2048 |\n| Desktop app | 20 MB | 500K triangles | 4096x4096 |\n| Hero asset (single) | 1 MB | 30K triangles | 1024x1024 |\n\n### Tool Selection\n\n| Tool | Best For | Install |\n|------|----------|---------|\n| `gltf-transform` | Full pipeline, scriptable, Node.js API | `npm i @gltf-transform\u002Fcli` |\n| `gltfpack` | Fast one-shot compression | `npm i -g gltfpack` |\n| Blender | Manual mesh editing, UV repacking | Blender 3.6+ |\n\n### Critical Warnings\n\n**NEVER** skip the assessment step -- optimizing blindly wastes time and can produce worse results than the original.\n\n**NEVER** apply Draco compression AND meshopt compression to the same file -- they are mutually exclusive. Choose ONE.\n\n**NEVER** use KTX2 UASTC for diffuse color maps on mobile -- UASTC textures are 8-16 bytes\u002Ftexel in VRAM. ALWAYS use ETC1S for color maps on mobile targets.\n\n**NEVER** simplify meshes below 10% of original without visual validation -- aggressive simplification destroys silhouettes and UV mapping.\n\n**ALWAYS** validate optimized models visually before shipping -- automated metrics cannot catch all visual artifacts.\n\n**ALWAYS** keep the original unoptimized model in version control -- optimization is lossy and irreversible.\n\n---\n\n## Step 1: Assessment\n\nBefore optimizing, ALWAYS gather these metrics:\n\n```bash\n# Using gltf-transform CLI\nnpx gltf-transform inspect model.glb\n\n# Key output to check:\n# - Mesh count and total triangle count\n# - Texture count, dimensions, and format\n# - Total file size (uncompressed)\n# - Accessor count (indicates potential deduplication)\n# - Animation track count\n```\n\n### Assessment Decision Tree\n\n```\nFile size > target budget?\n├── YES: Textures > 50% of file size?\n│   ├── YES → Start with texture optimization (Step 3)\n│   └── NO → Start with mesh optimization (Step 2)\n└── NO: Draw calls > 50?\n    ├── YES → Merge meshes (join\u002Fflatten)\n    └── NO → Only apply compression (Step 4)\n```\n\n### Polygon Count Guidelines\n\n| Asset Type | Target Triangles | Notes |\n|------------|-----------------|-------|\n| Background prop | 100-500 | Minimal detail |\n| Mid-ground object | 1K-5K | Visible but not hero |\n| Hero\u002Ffocus object | 10K-50K | High detail, close-up |\n| Character | 15K-30K | With LOD chain |\n| Full scene | 100K-300K | All objects combined |\n| Architectural (BIM) | 200K-500K | Simplified from CAD |\n\n---\n\n## Step 2: Mesh Optimization\n\n### gltf-transform Mesh Pipeline\n\nALWAYS run these operations in this order:\n\n```bash\n# 1. Remove duplicate accessors and unused data\nnpx gltf-transform dedup input.glb deduped.glb\n\n# 2. Flatten node hierarchy (removes empty nodes)\nnpx gltf-transform flatten deduped.glb flat.glb\n\n# 3. Join meshes sharing the same material\nnpx gltf-transform join flat.glb joined.glb\n\n# 4. Weld vertices (merge vertices within tolerance)\nnpx gltf-transform weld joined.glb welded.glb --tolerance 0.0001\n\n# 5. Simplify mesh (reduce triangle count)\nnpx gltf-transform simplify welded.glb simplified.glb \\\n  --ratio 0.5 \\\n  --error 0.001\n\n# 6. Remove unused resources\nnpx gltf-transform prune simplified.glb output.glb\n```\n\n### Combined Pipeline (Single Command)\n\n```bash\nnpx gltf-transform optimize input.glb output.glb \\\n  --compress draco \\\n  --texture-compress ktx2\n```\n\n### Mesh Simplification Settings\n\n| Quality Level | Ratio | Error Tolerance | Use Case |\n|--------------|-------|-----------------|----------|\n| Minimal | 0.75 | 0.0005 | Subtle reduction, preserves detail |\n| Moderate | 0.50 | 0.001 | Balanced quality\u002Fsize |\n| Aggressive | 0.25 | 0.005 | LOD1\u002FLOD2 generation |\n| Extreme | 0.10 | 0.01 | LOD3, distant objects only |\n\n### Weld Settings\n\n| Tolerance | Effect |\n|-----------|--------|\n| 0.0001 | Conservative -- merges only nearly-identical vertices |\n| 0.001 | Standard -- good for most models |\n| 0.01 | Aggressive -- may cause visible seams on hard edges |\n\n---\n\n## Step 3: Texture Optimization\n\n### Texture Decision Tree\n\n```\nTexture type?\n├── Color\u002FDiffuse (baseColorTexture)\n│   ├── Mobile → ETC1S (KTX2), max 1024px\n│   └── Desktop → UASTC (KTX2), max 2048px\n├── Normal map\n│   └── ALWAYS UASTC (KTX2) — ETC1S causes visible artifacts on normals\n├── ORM (occlusion\u002Froughness\u002Fmetallic)\n│   └── ETC1S (KTX2) — perceptual quality less critical\n├── Emissive\n│   └── ETC1S (KTX2) — unless HDR, then keep as-is\n└── HDR environment\n    └── Keep as .hdr or .exr — do NOT KTX2 compress\n```\n\n### KTX2 Compression Commands\n\n```bash\n# ETC1S: smaller file, lower quality (color maps, ORM)\nnpx gltf-transform ktx2 input.glb output.glb \\\n  --slots \"baseColorTexture,emissiveTexture,occlusionTexture\" \\\n  --filter \"baseColorTexture=etc1s\" \\\n  --quality 128\n\n# UASTC: larger file, higher quality (normal maps)\nnpx gltf-transform ktx2 input.glb output.glb \\\n  --slots \"normalTexture\" \\\n  --filter \"normalTexture=uastc\"\n```\n\n### KTX2: ETC1S vs UASTC\n\n| Property | ETC1S | UASTC |\n|----------|-------|-------|\n| File size | Very small (6-8x smaller) | Moderate (2-4x smaller) |\n| VRAM usage | Small | Large (8-16 bytes\u002Ftexel) |\n| Quality | Good for color | Near-lossless |\n| Decode speed | Fast | Requires transcoding |\n| Best for | Color maps, ORM, emissive | Normal maps, detail textures |\n\n### Texture Resize\n\n```bash\n# Resize all textures to max 1024x1024\nnpx gltf-transform resize input.glb output.glb --width 1024 --height 1024\n\n# Resize only textures larger than 2048px\nnpx gltf-transform resize input.glb output.glb --width 2048 --height 2048\n```\n\n---\n\n## Step 4: Mesh Compression\n\n### Draco Compression\n\n```bash\n# Default Draco compression\nnpx gltf-transform draco input.glb output.glb\n\n# Draco with quality settings\nnpx gltf-transform draco input.glb output.glb \\\n  --quantize-position 14 \\\n  --quantize-normal 10 \\\n  --quantize-texcoord 12 \\\n  --quantize-color 8\n```\n\n### Draco Quantization Bits\n\n| Attribute | Default | High Quality | Aggressive |\n|-----------|---------|-------------|------------|\n| Position | 14 bits | 16 bits | 11 bits |\n| Normal | 10 bits | 12 bits | 8 bits |\n| TexCoord | 12 bits | 14 bits | 10 bits |\n| Color | 8 bits | 10 bits | 6 bits |\n\nHigher bits = better quality, larger file. 14-bit position is sufficient for most models.\n\n### Quantize Without Draco\n\n```bash\n# Quantize attributes (reduces file size without Draco dependency)\nnpx gltf-transform quantize input.glb output.glb\n```\n\n### Loading Draco-Compressed Models in Three.js\n\n```javascript\nimport { GLTFLoader } from 'three\u002Faddons\u002Floaders\u002FGLTFLoader.js';\nimport { DRACOLoader } from 'three\u002Faddons\u002Floaders\u002FDRACOLoader.js';\n\nconst dracoLoader = new DRACOLoader();\n\u002F\u002F ALWAYS set the decoder path — Draco uses WASM\ndracoLoader.setDecoderPath('https:\u002F\u002Fwww.gstatic.com\u002Fdraco\u002Fversioned\u002Fdecoders\u002F1.5.6\u002F');\ndracoLoader.preload();\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setDRACOLoader(dracoLoader);\n\ngltfLoader.load('model-draco.glb', (gltf) => {\n  scene.add(gltf.scene);\n});\n\n\u002F\u002F ALWAYS dispose when done\ndracoLoader.dispose();\n```\n\n### Loading KTX2-Compressed Textures\n\n```javascript\nimport { KTX2Loader } from 'three\u002Faddons\u002Floaders\u002FKTX2Loader.js';\n\nconst ktx2Loader = new KTX2Loader();\n\u002F\u002F ALWAYS set the transcoder path — KTX2 uses WASM basis_transcoder\nktx2Loader.setTranscoderPath('https:\u002F\u002Fcdn.jsdelivr.net\u002Fnpm\u002Fthree@0.160.0\u002Fexamples\u002Fjsm\u002Flibs\u002Fbasis\u002F');\nktx2Loader.detectSupport(renderer);\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setKTX2Loader(ktx2Loader);\n```\n\n---\n\n## Step 5: Validation\n\n### Validation Checklist\n\nAfter optimization, ALWAYS verify:\n\n1. **File size** -- meets target budget from Step 1\n2. **Visual quality** -- load in Three.js viewer, compare to original\n3. **Bounding box** -- same dimensions as original (no scale errors)\n4. **Materials** -- all textures load, no missing maps\n5. **Animations** -- all clips play correctly (if applicable)\n6. **Performance** -- measure draw calls, frame time\n\n```bash\n# Compare file sizes\nls -la original.glb optimized.glb\n\n# Validate GLTF structure\nnpx gltf-transform inspect optimized.glb\n\n# Check for errors\nnpx gltf-transform validate optimized.glb\n```\n\n---\n\n## LOD Generation\n\n### LOD Chain Strategy\n\n| LOD Level | Screen Coverage | Triangle Ratio | Distance |\n|-----------|----------------|----------------|----------|\n| LOD0 | >30% screen | 1.0 (full) | Near |\n| LOD1 | 10-30% screen | 0.5 | Medium |\n| LOD2 | 3-10% screen | 0.25 | Far |\n| LOD3 | \u003C3% screen | 0.10 | Very far |\n\n### Generating LODs with gltf-transform\n\n```bash\n# Generate LOD chain\nnpx gltf-transform simplify model.glb lod0.glb --ratio 1.0\nnpx gltf-transform simplify model.glb lod1.glb --ratio 0.5 --error 0.001\nnpx gltf-transform simplify model.glb lod2.glb --ratio 0.25 --error 0.005\nnpx gltf-transform simplify model.glb lod3.glb --ratio 0.10 --error 0.01\n```\n\n### Three.js LOD Implementation\n\n```javascript\nimport * as THREE from 'three';\n\nconst lod = new THREE.LOD();\n\n\u002F\u002F ALWAYS add LODs from highest to lowest detail\nlod.addLevel(meshLOD0, 0);    \u002F\u002F distance 0 = closest\nlod.addLevel(meshLOD1, 10);   \u002F\u002F switch at 10 units\nlod.addLevel(meshLOD2, 30);   \u002F\u002F switch at 30 units\nlod.addLevel(meshLOD3, 80);   \u002F\u002F switch at 80 units\n\nscene.add(lod);\n\n\u002F\u002F In render loop — ALWAYS call update for LOD switching\nlod.update(camera);\n```\n\n---\n\n## gltfpack Alternative\n\nFor quick one-shot optimization without a pipeline:\n\n```bash\n# Install\nnpm install -g gltfpack\n\n# Optimize with meshopt compression\ngltfpack -i input.glb -o output.glb -cc -tc\n\n# Flags:\n# -cc  mesh compression (meshopt)\n# -tc  texture compression (KTX2\u002FBasisU)\n# -si N  simplify to ratio (0.0-1.0)\n# -tp  texture power-of-two resize\n```\n\n**NEVER** mix gltfpack meshopt output with gltf-transform Draco -- the compression formats are incompatible.\n\n### Loading Meshopt-Compressed Models\n\n```javascript\nimport { MeshoptDecoder } from 'three\u002Faddons\u002Flibs\u002Fmeshopt_decoder.module.js';\n\nconst gltfLoader = new GLTFLoader();\ngltfLoader.setMeshoptDecoder(MeshoptDecoder);\n```\n\n---\n\n## Blender Export Optimization\n\nWhen exporting from Blender to glTF:\n\n| Setting | Recommended Value | Why |\n|---------|-------------------|-----|\n| Format | glTF Binary (.glb) | Single file, smaller |\n| Apply Modifiers | ON | Bakes procedural geometry |\n| Compression | OFF | Compress with gltf-transform after |\n| Textures | Include | Embedded in .glb |\n| Limit to | Selected Objects | Avoid exporting hidden\u002Funused |\n| +Y Up | ON | Three.js convention |\n\n**NEVER** enable Draco in Blender's exporter -- Blender's Draco implementation is outdated. ALWAYS compress with gltf-transform or gltfpack after export.\n\n---\n\n## Node.js Scripting with gltf-transform API\n\n```javascript\nimport { NodeIO } from '@gltf-transform\u002Fcore';\nimport { dedup, flatten, join, weld, simplify,\n         textureCompress, draco, prune, quantize } from '@gltf-transform\u002Ffunctions';\nimport draco3d from 'draco3dgltf';\nimport sharp from 'sharp';\n\nconst io = new NodeIO()\n  .registerExtensions(KHRONOS_EXTENSIONS)\n  .registerDependencies({\n    'draco3d.decoder': await draco3d.createDecoderModule(),\n    'draco3d.encoder': await draco3d.createEncoderModule(),\n  });\n\nconst document = await io.read('input.glb');\n\n\u002F\u002F ALWAYS run transforms in dependency order\nawait document.transform(\n  dedup(),\n  flatten(),\n  join(),\n  weld({ tolerance: 0.0001 }),\n  simplify({ ratio: 0.5, error: 0.001 }),\n  textureCompress({ targetFormat: 'ktx2' }),\n  draco(),\n  prune(),\n  quantize(),\n);\n\nawait io.write('output.glb', document);\n```\n\n---\n\n## Reference Links\n\n- [references\u002Fmethods.md](references\u002Fmethods.md) -- gltf-transform API and Three.js loader methods\n- [references\u002Fexamples.md](references\u002Fexamples.md) -- Complete optimization pipeline examples\n- [references\u002Fanti-patterns.md](references\u002Fanti-patterns.md) -- Common optimization mistakes\n\n### Official Sources\n\n- https:\u002F\u002Fgltf-transform.dev\u002F\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FGLTFLoader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FDRACOLoader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#examples\u002Fen\u002Floaders\u002FKTX2Loader\n- https:\u002F\u002Fthreejs.org\u002Fdocs\u002F#api\u002Fen\u002Fobjects\u002FLOD\n- https:\u002F\u002Fgithub.com\u002Fzeux\u002Fmeshoptimizer\n",{"name":5,"license":14,"metadata":23,"description":26,"compatibility":27},{"author":24,"version":25},"OpenAEC-Foundation","1.0","Use when optimizing 3D models for web delivery: reducing file size, compressing meshes, optimizing textures, or generating LOD. Provides a complete GLTF optimization pipeline using Draco, KTX2, mesh simplification, and gltf-transform. Keywords: optimize model, reduce file size, Draco compression, KTX2, gltf-transform, mesh simplification, LOD, GLTF optimize, bundle size, model too big, slow loading, compress 3D model.\n","Designed for Claude Code. Requires Three.js r160+.","main","4c174e06a831864e98c30f630a7aa6c04738b094","skills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules","https:\u002F\u002Fgithub.com\u002Fmhyahya854","2026-11-06 02:03:37",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add mhyahya854\u002FAI-Second-Brain_Universal-Rules --skill threejs-agents-model-optimizer",{"tool":40,"command":41},"bunx","bunx skills add mhyahya854\u002FAI-Second-Brain_Universal-Rules --skill threejs-agents-model-optimizer",{"tool":43,"command":44},"pnpm","pnpm dlx skills add mhyahya854\u002FAI-Second-Brain_Universal-Rules --skill threejs-agents-model-optimizer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002FSKILL.md",true,[48,53,59,63],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":13,"sourceHtmlUrl":52},".gitkeep","OTHER","其他","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002F.gitkeep",{"path":54,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fanti-patterns.md","REFERENCE","参考文档",8753,"https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002Freferences\u002Fanti-patterns.md",{"path":60,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fexamples.md",8303,"https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002Freferences\u002Fexamples.md",{"path":64,"resourceType":55,"resourceTypeDesc":56,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fmethods.md",6973,"https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002FImpertio-Studio\u002FThree.js-Claude-Skill-Package\u002Fthreejs-agents-model-optimizer\u002Freferences\u002Fmethods.md",[68,76,84,92,99,106],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":72,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":18},"01M7EX4T721AAH60R0239P8WBZ","frontend-slides","Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT\u002FPPTX to web, or create slides for a talk\u002Fpitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fzarazhangrui\u002Ffrontend-slides\u002Ffrontend-slides\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fzarazhangrui\u002Ffrontend-slides\u002Ffrontend-slides\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":80,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M7EX495RSHTTCEJVX7C83FA3","design-dna","Extract, define, and apply design DNA across three dimensions: design system (tokens), design style (qualitative feel), and visual effects (Canvas, WebGL, 3D, particles, shaders, scroll effects, etc.). Use this skill when: (1) a user wants to see the full 3-dimension design structure\u002Fschema, (2) a user provides images, screenshots, or URLs of reference designs and wants them analyzed into a structured JSON profile covering all three dimensions, (3) a user has a Design DNA JSON and content and wants a design generated from it, or (4) any combination of these phases. Triggers on \"design DNA\", \"extract design style\", \"analyze design\", \"design tokens from reference\", \"generate design from JSON\", \"design system from screenshot\", \"design profile\", \"style guide JSON\", \"visual effects analysis\", \"design with effects\", \"3d design analysis\".","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fzanwei\u002Fdesign-dna\u002Fdesign-dna\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fzanwei\u002Fdesign-dna\u002Fdesign-dna\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":88,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":18},"01M7EX45RF2XZKRC3KDJDTT1PH","wireframe","Generate JSON wireframe with HTML preview","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fyhassy\u002Fwireframe-skill\u002Fwireframe-skill\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fyhassy\u002Fwireframe-skill\u002Fwireframe-skill\u002FSKILL.md",[],[],{"skillNo":93,"name":94,"nameZh":6,"description":95,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":18},"01M7EWZEM3MHD48AYSYFR2C9JP","social-publishing","Schedule and publish social media posts across 13 platforms (X, LinkedIn, Instagram, Facebook Pages, TikTok, Discord, Telegram, YouTube, Reddit, WordPress, Pinterest) via the SocialClaw API. Use when the user wants to publish, schedule, or manage social media content programmatically. Requires SOCIALCLAW_API_KEY.","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fwshobson\u002Fagents\u002Fsocial-publishing\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":18},"01M7EWKDEK9840C728VXT78EQ9","hermes-tweet","Install and operate Hermes Tweet, a Hermes Agent plugin for X\u002FTwitter research, timeline reading, tweet analysis, and approval-gated private or state-changing operations. Use this skill when installing Hermes Tweet, researching X\u002FTwitter accounts, monitoring launch signals, investigating mentions, auditing giveaways, or preparing gated X operations. Use proactively when a Hermes Agent workflow needs current X\u002FTwitter context. Requires XQUIK_API_KEY for read and action tools.","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fwshobson\u002Fagents\u002Fhermes-tweet\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":18},"01M7EWASXP3NZWW95CJPT2CRWN","refactoring-ui","Audit and fix visual hierarchy, spacing, color, and depth in web UIs. Use when the user mentions \"my UI looks off\" (or amateur\u002Funprofessional), \"fix the design\", \"Tailwind styling\", \"color palette\", \"visual hierarchy\", \"design system\", \"spacing scale\", or \"component styling\". Also trigger when building consistent design tokens, creating dark mode themes, improving data-visualization clarity, or polishing UI details before launch. Covers grayscale-first workflow, constrained design scales, shadows, and component styling. For typeface selection, see web-typography. For usability audits, see ux-heuristics.","https:\u002F\u002Fgithub.com\u002Fmhyahya854\u002FAI-Second-Brain_Universal-Rules\u002Fblob\u002Fmain\u002Fskills\u002F_intake\u002Fgithub\u002Fwondelai\u002Fskills\u002Frefactoring-ui\u002FSKILL.md",[],[]]