npx skills add ...
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber
Build declarative 3D scenes with React Three Fiber (R3F) - a React renderer for Three.js. Use when building interactive 3D experiences in React applications with component-based architecture, state management, and reusable abstractions. Ideal for product configurators, portfolios, games, data visualization, and immersive web experiences.
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber
React Three Fiber (R3F) is a React renderer for Three.js that brings declarative, component-based 3D development to React applications. Instead of imperatively creating and managing Three.js objects, you build 3D scenes using JSX components that map directly to Three.js objects.
When to Use This Skill:
Key Benefits:
The <Canvas> component sets up a Three.js scene, camera, renderer, and render loop.
Canvas Props:
camera - Camera configuration (position, fov, near, far)gl - WebGL renderer settingsdpr - Device pixel ratio (default: [1, 2])shadows - Enable shadow mapping (default: false)frameloop - "always" (default), "demand", or "never"flat - Disable color management for simpler colorslinear - Use linear color space instead of sRGBThree.js objects are created using JSX with kebab-case props:
Prop Mapping:
position → object.position.set(x, y, z)rotation → object.rotation.set(x, y, z)scale → object.scale.set(x, y, z)args → Constructor arguments for geometry/materialattach → Attach to parent property (e.g., attach="material")Shorthand Notation:
Execute code on every frame (animation loop):
useFrame Parameters:
state - Scene state (camera, scene, gl, clock, etc.)delta - Time since last frame (for frame-rate independence)xrFrame - XR frame data (for VR/AR)Important: Never use setState inside useFrame - it causes unnecessary re-renders!
Access scene state and methods:
Available State:
camera - Default camerascene - Three.js scenegl - WebGL renderersize - Canvas dimensionsviewport - Viewport dimensions in 3D unitsclock - Three.js clockpointer - Normalized mouse coordinatesinvalidate() - Manually trigger rendersetSize() - Manually resize canvasLoad assets with automatic caching and Suspense integration:
Loading Multiple Assets:
Loader Extensions:
Pre-loading:
Drei is the essential helper library for R3F, providing ready-to-use components:
Use <instancedMesh> for rendering many identical objects:
Objects outside the camera view are automatically culled.
Use useThree selectors to avoid unnecessary re-renders:
✅ Solution: Mutate refs directly
✅ Solution: Use arrays or useMemo
✅ Solution: Use useLoader (automatic caching)
✅ Solution: Use visibility prop
✅ Solution: Use hooks inside Canvas children
✅ Solution: R3F handles disposal automatically, but be careful with manual Three.js objects
Break scenes into reusable components:
Always wrap async operations in Suspense:
Monitor re-renders and optimize components causing performance issues.
references/api_reference.md - Complete R3F & Drei API documentationreferences/hooks_guide.md - Detailed hooks usage and patternsreferences/drei_helpers.md - Comprehensive Drei library guidescripts/component_generator.py - Generate R3F component boilerplatescripts/scene_setup.py - Initialize R3F scene with common patternsassets/starter_r3f/ - Complete R3F + Vite starter templateassets/examples/ - Real-world R3F component examples