# r3f-interaction

Configures pointer events, object picking, dragging, and camera controls in React Three Fiber. Helps avoid input conflicts between 3D scene controls and interactive meshes.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3300 installs · ★ 130
- Author: EnzeD
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/EnzeD/r3f-skills/tree/HEAD/skills/r3f-interaction/SKILL.md
- Updated: 2026-08-31
- HTML: https://affpapa.org/en/nevibecode/skills/r3f-interaction

## What it does

The skill sets interaction rules for React Three Fiber 9 and React 19 projects. It covers raycasting semantics, distinguishing the hit mesh (`event.object`) from the handler owner (`event.eventObject`). It also highlights how `stopPropagation()` halts event delivery to farther hits and ancestors without preventing raycasts that have already run. Canvas deselection relies on `onPointerMissed`.

For scene movement, the guide coordinates Drei helpers such as `OrbitControls`, `CameraControls`, and `TransformControls`. Custom drag interactions need explicit pointer capture via `setPointerCapture` alongside temporary suspension of default camera controls. Storing raw pointer positions in refs avoids unnecessary React re-renders during high-frequency movement.

Mesh pointer handlers do not supply keyboard accessibility on their own, so critical actions must stay in external DOM controls. When reading continuous movement from Drei `KeyboardControls`, poll the getter inside `useFrame`, normalize diagonal vectors, and clear held keys whenever window focus drops.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add EnzeD/r3f-skills --skill r3f-interaction -a claude-code
```

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

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add EnzeD/r3f-skills --skill r3f-interaction -a codex
```

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

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add EnzeD/r3f-skills --skill r3f-interaction -a cursor
```

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

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install EnzeD/r3f-skills r3f-interaction
```

2. **Manually: put the files in place**
- File: `.github/skills/r3f-interaction/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add EnzeD/r3f-skills --skill r3f-interaction -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/EnzeD/r3f-skills --path skills/r3f-interaction
```

### Windsurf (Devin Desktop)

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

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add EnzeD/r3f-skills --skill r3f-interaction -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/EnzeD/r3f-skills/tree/HEAD/skills/r3f-interaction/SKILL.md

## When to use it
- prevent camera rotation conflicts when dragging meshes across the scene
- deselect active objects cleanly through Canvas onPointerMissed
- coordinate pointer capture between OrbitControls and custom transform gizmos
- implement continuous character movement using KeyboardControls in useFrame

## Example prompts
- Set up mesh selection in Canvas with stopPropagation and background deselection
- Implement 3D object dragging while temporarily disabling OrbitControls
- Add keyboard controls with normalized diagonal movement inside useFrame

## Similar
- [threejs-react-three-fiber](https://affpapa.org/en/nevibecode/skills/threejs-react-three-fiber.md) — skill · 1300 installs
- [threejs-r3f](https://affpapa.org/en/nevibecode/skills/threejs-r3f.md) — skill · 1000 installs
- [r3f-best-practices](https://affpapa.org/en/nevibecode/skills/r3f-best-practices.md) — skill · 1500 installs
- [react-three-fiber](https://affpapa.org/en/nevibecode/skills/react-three-fiber.md) — skill · 3800 installs
- [react-three-fiber-game](https://affpapa.org/en/nevibecode/skills/react-three-fiber-game.md) — skill · 39 installs
- [threejs-interaction](https://affpapa.org/en/nevibecode/skills/threejs-interaction.md) — skill · 14300 installs

From the same set: [enzed/r3f-skills](https://affpapa.org/en/nevibecode/by/enzed/r3f-skills.md) — 6 cards

---
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
