react-three-fiber-expert
Expert patterns for building 3D web applications with React.
Install
mkdir -p .claude/skills/react-three-fiber-expert && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15729" && unzip -o skill.zip -d .claude/skills/react-three-fiber-expert && rm skill.zipInstalls to .claude/skills/react-three-fiber-expert
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Best practices, hooks, and patterns for React Three Fiber (R3F) and Drei. Use when building 3D web applications, optimizing WebGL performance, or implementing camera controls and scene interactions.Key capabilities
- →Center imported GLTF models using the <Center> component
- →Handle camera controls with <OrbitControls>
- →Apply image-based lighting using <Environment>
- →Implement performant shadow solutions like <ContactShadows>
- →Load 3D models using useGLTF from Drei
- →Animate objects smoothly with useFrame
How it works
React Three Fiber acts as a React renderer for Three.js, allowing 3D objects and scenes to be defined using declarative React components. Drei provides helper components and hooks to simplify common Three.js tasks within R3F.
Inputs & outputs
When to use react-three-fiber-expert
- →Implement OrbitControls in R3F
- →Optimize GLTF model loading
- →Manage WebGL lighting and shadows
About this skill
React Three Fiber (R3F) & Drei Best Practices
1. Core Concepts
React Three Fiber is a React renderer for Three.js.
- Rule of Thumb: If you can do it in Three.js, you can do it in R3F.
new THREE.Mesh()becomes<mesh />. - Properties: Class properties become props:
mesh.position.set(1, 2, 3)-><mesh position={[1, 2, 3]} />.
2. Drei Utilities
Always prefer @react-three/drei helpers over writing manual Three.js logic.
<Center>: Automatically calculates the bounding box of its children and centers them. Extremely useful for aligning imported.glbmodels.bottomprop: Aligns the lowest point of the model toY = 0.
<OrbitControls>: Handles camera orbiting, zooming, and panning.makeDefaultprop: Tells other Drei components (likeTransformControls) that this is the primary camera controller.
<Environment>: Image-based lighting (IBL). Usepreset="city"or pass an HDR file.<ContactShadows>/<SoftShadows>: Pre-built shadow solutions that perform better than manual shadow maps.
3. Loading Models
Use useGLTF from Drei to load models.
import { useGLTF, Center } from '@react-three/drei'
export default function FurnitureModel({ url }) {
const { scene } = useGLTF(url)
return (
<Center bottom>
<primitive object={scene} />
</Center>
)
}
Important: Do NOT mutate scene.position directly if using <Center>. Let Drei handle the layout.
4. Animation and Loops
Do not use setInterval or React useEffect for 60fps animations. Use useFrame.
import { useFrame } from '@react-three/fiber'
import { useRef } from 'react'
function SpinningMesh() {
const meshRef = useRef()
useFrame((state, delta) => {
// Delta is time since last frame. Ensures smooth animation regardless of framerate.
meshRef.current.rotation.y += delta
})
return <mesh ref={meshRef}><boxGeometry /></mesh>
}
5. State Management
R3F works seamlessly with Zustand for global state. Do not pass rapidly changing 3D state (like camera coordinates every frame) through React Context, as it causes massive re-renders. Use Zustand's transient updates (e.g., useStore.getState()) inside useFrame.
6. Performance Optimization
- Instancing: If rendering many identical objects, use
<InstancedMesh>instead of mapping over<mesh>. - Dispose: R3F auto-disposes geometries and materials when unmounted.
- Shadows: Shadows are expensive. Use
castShadowandreceiveShadowonly on meshes that truly need them. - DPR: Cap pixel ratio to save GPU:
<Canvas dpr={[1, 2]}>(default in newer versions).
7. Math & Coordinates
- R3F uses a Right-Handed Y-Up coordinate system (X=right, Y=up, Z=towards viewer).
- For angle manipulation, use Math.PI (e.g.,
rotation={[-Math.PI / 2, 0, 0]}to lay a plane flat on the floor).
When not to use it
- →When building 2D web applications
- →When direct Three.js manipulation is preferred over React components
- →When state management for rapidly changing 3D data is handled by React Context
Limitations
- →Requires understanding of React component lifecycle and state management
- →Performance optimization requires specific techniques like instancing and careful shadow usage
- →Direct mutation of scene.position is not recommended when using <Center>
How it compares
This approach uses React components and hooks to manage Three.js scenes and objects, abstracting away direct imperative Three.js API calls for a more declarative workflow.
Compared to similar skills
react-three-fiber-expert side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| react-three-fiber-expert (this skill) | 0 | 2mo | No flags | Intermediate |
| 3d-web-experience | 35 | 6mo | Review | Intermediate |
| tamagui | 24 | 6mo | Review | Intermediate |
| remotion | 29 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
3d-web-experience
davila7
Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences. Use when: 3D website, three.js, WebGL, react three fiber, 3D experience.
tamagui
tamagui
Universal React UI framework for web and native. Use when building cross-platform apps with Tamagui, creating styled components with `styled()`, configuring design tokens/themes, using Tamagui UI components, or working with animations. Triggers: "tamagui", "styled()", "$token", "XStack/YStack", "useTheme", "@tamagui/*" imports, "createStyledContext", "variants".
remotion
davila7
Best practices and comprehensive guide for Remotion - programmatic video creation in React with animations, compositions, and media handling
rendering-animate-svg
TheOrcDev
Wrap animated SVG elements in a div to enable hardware acceleration. Apply when animating SVG icons or elements, especially in 8-bit retro components with pixel art animations.
frontend-ui-dark-ts
microsoft
Build dark-themed React applications using Tailwind CSS with custom theming, glassmorphism effects, and Framer Motion animations. Use when creating dashboards, admin panels, or data-rich interfaces with a refined dark aesthetic.
remotion-best-practices
ali156666
Best practices for Remotion - Video creation in React