threejs-performance

Diagnose and optimize Three.js and React Three Fiber rendering performance issues.

706|130|Updated Oct 31, 2025
One-click install
npx skills add https://github.com/staruhub/ClaudeSkills --skill threejs-performance
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: threejs-performance
Source: https://github.com/staruhub/ClaudeSkills/tree/main/skills/Geek-skills-threejs-performance
Command: npx skills add https://github.com/staruhub/ClaudeSkills --skill threejs-performance

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Three.js and React Three Fiber projects often suffer from frame drops, memory leaks, slow asset loading, and excessive draw calls, and developers lack a systematic way to diagnose and fix these bottlenecks.

Core Features & Use Cases

  • Diagnostic Decision Tree: Maps symptoms like frame drops, memory growth, and slow loading to concrete checks using renderer.info metrics.
  • Optimization Playbooks: Covers draw call reduction with InstancedMesh and BatchedMesh, Draco/KTX2 asset compression pipelines, GPU memory disposal rules, shader optimization, and lighting budgets.
  • WebGPU Migration Guidance: Explains when and how to migrate to WebGPURenderer, write TSL shaders, and use compute shaders for million-scale particle systems.
  • Use Case: A React Three Fiber scene stutters on mobile. The skill identifies setState calls inside useFrame, switches to ref-based animation, enables frameloop="demand", and compresses the GLB assets with gltf-transform.

Quick Start

Use the threejs-performance skill to diagnose why my React Three Fiber scene drops frames on mobile and fix the draw call and memory issues.

Frequently Asked Questions about threejs-performance

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce draw calls in Three.js?

Use InstancedMesh for many identical geometries like trees, BatchedMesh for different geometries sharing a material, and mergeGeometries for static objects. Keep draw calls under 100 per frame and monitor them with renderer.info.render.calls.

How to fix memory leaks in Three.js applications?

Three.js does not automatically release GPU resources, so you must call geometry.dispose(), dispose every texture attached to each material, and call material.dispose() when removing objects. For GLTF ImageBitmap textures, also call texture.source.data.close().

Should I use Draco or Meshopt for GLTF compression?

Draco achieves higher compression ratios but decodes slower, while Meshopt decodes faster and pairs well with gzip for CDN delivery. Use gltf-transform optimize with KTX2 texture compression for a complete pipeline.

Why does my React Three Fiber app re-render every frame?

Calling setState inside useFrame triggers a React re-render on every frame, destroying performance. Mutate refs directly inside useFrame and reserve state updates for interaction events only.

When should I migrate from WebGL to WebGPU in Three.js?

Migrate when draw-call-heavy scenes drop frames, when you need compute shaders for particle physics beyond roughly 50,000 CPU particles, or when complex post-processing chains stall. WebGPURenderer requires await renderer.init() and falls back to WebGL automatically.

What are the limitations of this Three.js optimization approach?

It does not cover general React performance issues like memoization or bundle size, Three.js beginner tutorials, or 3D art asset creation. Optimization without measurement is discouraged; install monitoring like stats-gl before changing code.