arupbiswas09/claude_skills/r3f
Claude Code and agent skill by arupbiswas09/claude_skills
- community
Checking that the SKILL.md file is still in the repository.
React Three Fiber skill for declarative 3D in React. USE when building React apps with Three.js, using @react-three/fiber, drei, zustand with 3D, or the user mentions R3F, react-three, Canvas component, useFrame, useThree. Even if they just say 'React 3D' or 'declarative Three.js'. For vanilla Three.js, see threejs skill. For WebGPU/TSL, see webgpu-threejs-tsl skill.
Install
npx vskill@latest install arupbiswas09/claude_skills/r3fSKILL.md
The same SKILL.md was published earlier as arupbiswas09/claude_skills/r3f.
React Three Fiber (R3F) Skill
Declarative Three.js in React via @react-three/fiber. Everything is a component. Drei provides batteries-included helpers. Zustand handles state without re-render hell.
Reference Files
references/patterns.md— component architecture, scroll animations, HTML overlays, instancing, post-processingreferences/recipes.md— product configurator, 3D portfolio, data viz, adaptive quality
Quick Start
Installation
Canvas Setup
Key <Canvas> props:
shadows— enables shadow maps globallydpr={[1, 2]}— clamps device pixel ratio (saves GPU on retina)performance={{ min: 0.5 }}— allows adaptive DPR to drop to 50%frameloop="demand"— only render wheninvalidate()is called (static scenes)flat— disables tone mapping (for UI-heavy scenes)
Core Hooks
useFrame — The Render Loop
GOLDEN RULE: NEVER call setState inside useFrame. Mutate refs instead.
Every setState triggers a React re-render. At 60fps that's 60 re-renders/second = death.
useFrame callback args:
state— full R3F state:clock,camera,mouse,viewport,scene,gl,sizedelta— time since last frame in seconds (use for frame-rate-independent movement)
Priority: useFrame(cb, priority) — lower runs first. Default is 0.
useThree — Access Fiber State
Always use a selector to avoid re-renders on every frame:
Common selectors: camera, gl, scene, viewport, size, mouse, clock.
useLoader
Prefer drei's useTexture or useGLTF — they handle caching and preloading.
Drei Essentials
Drei (@react-three/drei) is the standard helper library. Import only what you use.
Controls
Environment & Lighting
Loading 3D Models
For editable models, use useGLTF + clone or gltfjsx to generate typed components.
HTML Overlays
Text
Other Must-Know Drei Components
| Component | Use Case | |
|---|---|---|
Float | Gentle floating animation | |
MeshReflectorMaterial | Reflective floors | |
ContactShadows | Soft ground shadows (cheaper than shadow maps) | |
Sparkles | Particle sparkle effect | |
useProgress | Loading progress for Suspense | |
Preload | Preload all useLoader assets | |
AdaptiveDpr | Auto-adjust DPR based on performance | |
AdaptiveEvents | Throttle pointer events under load | |
BakeShadows | Bake shadows once (static scenes) | |
PerformanceMonitor | Track FPS and trigger quality changes | |
ScrollControls | Scroll-driven 3D animations | |
PresentationControls | Drag-to-rotate for product views | |
MeshTransmissionMaterial | Glass/refractive materials | |
Center | Auto-center geometry |
Zustand for 3D State
Zustand is the recommended state manager for R3F. It lives outside React's render cycle.
Store Setup
Selective Subscriptions (Prevent Re-renders)
Reading State in useFrame (Zero Re-renders)
Transient Subscriptions
Performance Rules
1. Never setState in useFrame
Already said it. Saying it again. Mutate refs.
2. Memoize Geometry and Materials
Note: R3F auto-caches declarative <boxGeometry /> with same args, so this mainly matters for complex/custom geometries.
3. React.memo for Static Components
4. Instancing for Repeated Objects
Use <instancedMesh> for hundreds+ of similar objects. See references/patterns.md.
5. Adaptive Quality
6. frameloop="demand" for Static Scenes
Mobile Configuration
Device Detection & Quality Tiers
Required CSS
Common Patterns Quick Reference
Events
R3F events are raycasted — they hit the first mesh and propagate. Always stopPropagation() if needed.
Suspense for Loading
Disposing Resources
R3F auto-disposes geometries, materials, and textures when components unmount. For manual control: <mesh dispose={null}> to prevent auto-dispose (shared resources).
TypeScript
Package Versions (as of 2025)
| Package | Version | Notes | |
|---|---|---|---|
@react-three/fiber | 8.x | Stable, React 18+ | |
@react-three/drei | 9.x | Helpers | |
@react-three/postprocessing | 2.x | Effects | |
three | 0.160+ | Keep in sync with R3F peer dep | |
zustand | 4.x / 5.x | State management |
Always check R3F changelog when upgrading Three.js — breaking changes in Three often need R3F patches.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/r3f/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/arupbiswas09/claude_skills/r3f)