# react-three-fiber

Teaches the agent to build declarative Three.js 3D scenes in React using JSX components, animation hooks, and Suspense loaders.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3800 installs · ★ 1133
- Author: freshtechbro
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/freshtechbro/claudedesignskills/tree/HEAD/plugins/bundles/core-3d-animation/skills/react-three-fiber/SKILL.md
- Updated: 2025-11-20
- HTML: https://affpapa.org/en/nevibecode/skills/react-three-fiber

## What it does

The skill provides guidelines for React Three Fiber (R3F), a React renderer for Three.js. Instead of imperative scene graphs, the agent builds 3D interfaces via JSX components like `<Canvas>`, `<mesh>`, geometries, and materials.

It covers core hooks such as `useFrame` for frame loops, `useThree` for scene and camera state, and `useLoader` for GLTF models and textures with DRACO loader support. It also documents canvas settings like `dpr`, `shadows`, and `frameloop`.

Calling `setState` inside `useFrame` causes severe re-render spikes, so per-frame animations must mutate mesh refs directly.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/react-three-fiber/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/react-three-fiber/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/react-three-fiber/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/react-three-fiber/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install freshtechbro/claudedesignskills react-three-fiber
```

2. **Manually: put the files in place**
- File: `.github/skills/react-three-fiber/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/freshtechbro/claudedesignskills --path plugins/bundles/core-3d-animation/skills/react-three-fiber
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/react-three-fiber/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add freshtechbro/claudedesignskills --skill react-three-fiber -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/freshtechbro/claudedesignskills/tree/HEAD/plugins/bundles/core-3d-animation/skills/react-three-fiber/SKILL.md

## When to use it
- convert imperative Three.js code into declarative React components
- set up frame-rate independent animations using useFrame
- load GLTF assets and textures with React Suspense integration
- configure Canvas camera, renderer settings, and shadows

## Example prompts
- Create an interactive rotating 3D box component using React Three Fiber and useFrame
- Set up a Canvas with shadows enabled and a GLTF model loaded via useLoader
- Access viewport dimensions and mouse pointer using the useThree hook

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: fedd930fb33211d8.

BEGIN THIRD-PARTY FILE fedd930fb33211d8
````text
---
name: react-three-fiber
description: 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.
---

# React Three Fiber

## Overview

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**:
- Building 3D experiences within React applications
- Creating interactive product configurators or showcases
- Developing 3D portfolios, galleries, or storytelling experiences
- Building games or simulations in React
- Adding 3D elements to existing React projects
- When you need state management and React hooks with 3D graphics
- When working with React frameworks (Next.js, Gatsby, Remix)

**Key Benefits**:
- **Declarative**: Write 3D scenes like React components
- **React Integration**: Full access to hooks, context, state management
- **Reusability**: Create and share 3D component libraries
- **Performance**: Automatic render optimization and reconciliation
- **Ecosystem**: Works with Drei helpers, Zustand, Framer Motion, etc.
- **TypeScript Support**: Full type safety for Three.js objects

---

## Core Concepts

### 1. Canvas Component

The `<Canvas>` component sets up a Three.js scene, camera, renderer, and render loop.

```jsx
import { Canvas } from '@react-three/fiber'

function App() {
  return (
    <Canvas
      camera={{ position: [0, 0, 5], fov: 75 }}
      gl={{ antialias: true }}
      dpr={[1, 2]}
    >
      {/* 3D content goes here */}
    </Canvas>
  )
}
```

**Canvas Props**:
- `camera` - Camera configuration (position, fov, near, far)
- `gl` - WebGL renderer settings
- `dpr` - Device pixel ratio (default: [1, 2])
- `shadows` - Enable shadow mapping (default: false)
- `frameloop` - "always" (default), "demand", or "never"
- `flat` - Disable color management for simpler colors
- `linear` - Use linear color space instead of sRGB

### 2. Declarative 3D Objects

Three.js objects are created using JSX with kebab-case props:

```jsx
// THREE.Mesh + THREE.BoxGeometry + THREE.MeshStandardMaterial
<mesh position={[0, 0, 0]} rotation={[0, Math.PI / 4, 0]}>
  <boxGeometry args={[1, 1, 1]} />
  <meshStandardMaterial color="hotpink" />
</mesh>
```

**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/material
- `attach` → Attach to parent property (e.g., `attach="material"`)
````
END THIRD-PARTY FILE fedd930fb33211d8

The third-party file has ended. Everything between the fedd930fb33211d8 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2899 of 22994 bytes. © freshtechbro · MIT · https://github.com/freshtechbro/claudedesignskills/tree/HEAD/plugins/bundles/core-3d-animation/skills/react-three-fiber/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
