
R3f Interaction
Add clicks, hovers, camera controls, and gesture handling to React Three Fiber scenes without relearning R3F pointer event APIs.
Overview
r3f-interaction is an agent skill for the Build phase that implements React Three Fiber pointer events, camera controls, and interactive 3D input patterns.
Install
npx skills add https://github.com/enzed/r3f-skills --skill r3f-interactionWhat is this skill?
- Quick-start Canvas + mesh onClick/onPointerOver/onPointerOut pattern with OrbitControls
- Full pointer lifecycle: click, double-click, context menu, down/up/move/over/out/enter/leave
- Event object fields for 3D hit testing (e.g., e.point) on interactive meshes
- @react-three/drei controls for orbit and explore-style camera UX
- Guidance for selection and gesture-style interactive 3D product or demo scenes
- Documents 10+ mesh pointer handlers including onClick, onDoubleClick, onContextMenu, and onPointerDown through onPointer
Adoption & trust: 1.9k installs on skills.sh; 89 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your R3F scene renders but clicks, hovers, and camera movement are missing or wired with incorrect pointer handlers.
Who is it for?
Developers building interactive 3D landing pages, configurators, or small WebGL games in a React codebase.
Skip if: Projects with no 3D canvas or teams standardizing on vanilla Three.js without React Three Fiber.
When should I use this skill?
Handling user input, implementing click detection, adding camera controls, or creating interactive 3D experiences in React Three Fiber.
What do I get? / Deliverables
Meshes respond to pointer events with correct hit data and the canvas includes working controls for interactive 3D experiences.
- Interactive mesh components with pointer handlers
- Canvas setup with camera controls for exploratory 3D UX
Recommended Skills
Journey fit
Canonical shelf is Build → frontend because the skill implements user input and camera interaction inside React Three Fiber canvases. Coverage is mesh pointer events, OrbitControls-style navigation, and interactive 3D UX—not backend or asset pipeline work.
How it compares
R3F-specific interaction recipes—not a general React DOM event or CSS interaction skill.
Common Questions / FAQ
Who is r3f-interaction for?
Frontend-focused solo builders using @react-three/fiber who need pointer events and camera controls in interactive 3D UIs.
When should I use r3f-interaction?
During Build frontend work when implementing click detection, hover feedback, gestures, selection, or OrbitControls on a Canvas scene.
Is r3f-interaction safe to install?
It is documentation and code-pattern guidance only; review the Security Audits panel on this Prism page like any community skill.
SKILL.md
READMESKILL.md - R3f Interaction
# React Three Fiber Interaction ## Quick Start ```tsx import { Canvas } from '@react-three/fiber' import { OrbitControls } from '@react-three/drei' function InteractiveMesh() { return ( <mesh onClick={(e) => console.log('Clicked!', e.point)} onPointerOver={(e) => console.log('Hover')} onPointerOut={(e) => console.log('Unhover')} > <boxGeometry /> <meshStandardMaterial color="hotpink" /> </mesh> ) } export default function App() { return ( <Canvas> <ambientLight /> <InteractiveMesh /> <OrbitControls /> </Canvas> ) } ``` ## Pointer Events R3F provides built-in pointer events on mesh elements. ### Available Events ```tsx <mesh // Click events onClick={(e) => {}} // Click (pointerdown + pointerup on same object) onDoubleClick={(e) => {}} // Double click onContextMenu={(e) => {}} // Right click // Pointer events onPointerDown={(e) => {}} // Pointer pressed onPointerUp={(e) => {}} // Pointer released onPointerMove={(e) => {}} // Pointer moved while over object onPointerOver={(e) => {}} // Pointer enters object onPointerOut={(e) => {}} // Pointer leaves object onPointerEnter={(e) => {}} // Pointer enters object (no bubbling) onPointerLeave={(e) => {}} // Pointer leaves object (no bubbling) onPointerMissed={(e) => {}} // Click that missed all objects // Wheel onWheel={(e) => {}} // Mouse wheel // Touch onPointerCancel={(e) => {}} // Touch cancelled > <boxGeometry /> <meshStandardMaterial /> </mesh> ``` ### Event Object ```tsx function InteractiveMesh() { const handleClick = (event) => { // Stop propagation to parent objects event.stopPropagation() // Event properties console.log({ object: event.object, // The mesh that was clicked point: event.point, // World coordinates of intersection distance: event.distance, // Distance from camera face: event.face, // Intersected face faceIndex: event.faceIndex, // Face index uv: event.uv, // UV coordinates at intersection normal: event.normal, // Face normal camera: event.camera, // Current camera ray: event.ray, // Ray used for intersection intersections: event.intersections, // All intersections nativeEvent: event.nativeEvent, // Original DOM event delta: event.delta, // Click distance (useful for drag detection) }) } return ( <mesh onClick={handleClick}> <boxGeometry /> <meshStandardMaterial /> </mesh> ) } ``` ### Hover Effects ```tsx import { useState } from 'react' function HoverableMesh() { const [hovered, setHovered] = useState(false) return ( <mesh onPointerOver={(e) => { e.stopPropagation() setHovered(true) document.body.style.cursor = 'pointer' }} onPointerOut={(e) => { setHovered(false) document.body.style.cursor = 'default' }} scale={hovered ? 1.2 : 1} > <boxGeometry /> <meshStandardMaterial color={hovered ? 'hotpink' : 'orange'} /> </mesh> ) } ``` ### Selective Raycasting ```tsx // Disable raycasting for specific objects <mesh raycast={() => null}> <boxGeometry /> <meshStandardMaterial /> </mesh> // Or use layers <mesh layers={1} // Only raycast against layer 1 onClick={() => console.log('clicked')} > <boxGeometry /> <meshStandardMaterial /> </mesh> ``` ## Camera Controls ### OrbitControls ```tsx import { OrbitControls } from '@react-three/drei' function Scene() { return ( <> <mesh> <b