threejs
Original:🇺🇸 English
Translated
Builds 3D web experiences with Three.js, WebGPU rendering, TSL shaders, and React Three Fiber. Covers scene setup, asset optimization, performance tuning, and React 19 integration. Use when creating 3D scenes, setting up WebGPU rendering, writing TSL shaders, optimizing draw calls, or integrating Three.js with React and Next.js.
1installs
Sourceoakoss/agent-skills
Added on
NPX Install
npx skill4agent add oakoss/agent-skills threejsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Three.js
Overview
Guides building high-performance 3D web experiences with Three.js, WebGPU-first rendering, TSL (Three Shader Language), and React Three Fiber. Covers scene architecture, asset compression, draw call budgets, and React 19 / Next.js integration patterns.
When to use: Creating 3D scenes, WebGPU rendering setup, TSL shader authoring, asset optimization (Draco/KTX2), React Three Fiber composition, Next.js streaming for 3D content, loading GLTF models, setting up lighting and shadows, animation playback and blending.
When NOT to use: 2D canvas animations (use Canvas API), simple SVG graphics, server-side rendering without client hydration, projects targeting pre-2022 hardware exclusively.
Quick Reference
| Pattern | API / Approach | Key Points |
|---|---|---|
| WebGPU renderer | | Must |
| R3F canvas | | Wrap in |
| Frame updates | | Mutate refs directly; never use |
| TSL shaders | | Node-based; compiles to WGSL or GLSL |
| Instancing | | Single draw call for repeated geometry |
| Batched mesh | | Different geometries sharing one material |
| Draco compression | | Up to 90% geometry size reduction |
| KTX2 textures | Basis Universal via | Stays compressed in VRAM |
| LOD | | Swap detail levels by camera distance |
| On-demand render | | Only render when scene state changes |
| Cleanup | | Geometries, materials, and textures |
| Compute shaders | | GPU-side physics, particles, flocking |
| Lighting | | Enable |
| GLTF loading | | Draco for geometry compression; traverse for shadows |
| Animation | | Update with |
| Crossfade | | Weight-based blending between walk/run/idle |
| Environment maps | | Set |
| Raycasting | | Mouse/touch picking; use |
| Morph targets | | Facial animation, blend shapes from GLTF |
Common Mistakes
| Mistake | Correct Pattern |
|---|---|
Allocating | Pre-allocate outside the loop to avoid GC pressure every frame |
Using | Use R3F's |
Not awaiting | Always |
Loading assets without | Wrap |
| Using high-poly models for background or distant elements | Use LOD (Level of Detail) or Impostors to reduce draw calls |
Using | Mutate refs directly via |
Speed tied to frame rate ( | Multiply by |
Not using | Always pass delta time to |
| Forgetting to dispose loaded GLTF models | Traverse and dispose geometries, materials, and textures on removal |
| Shadow map enabled on renderer but not on the light | Set both |
Large | Keep ratio small to avoid z-fighting; set |
Delegation
- Asset and scene graph exploration: Use agent
Explore - Multi-file scene refactoring and optimization passes: Use agent
Task - 3D architecture and rendering pipeline planning: Use agent
Plan
References
- Scene, lighting, and model loading
- Animation system and blending
- Performance and asset optimization
- WebGPU and TSL shader patterns
- React Three Fiber patterns and Next.js integration