react-three-fiber-3d
Skill2 starsChanged 4 months agoMITView on GitHub
Build performant 3D web experiences with React Three Fiber (R3F), drei, and Three.js — scenes, models, materials, lighting, camera controls, and post-processing, integrated cleanly into a Next.js/React app. Use whenever the user mentions "3D", "Three.js", "React Three Fiber", "R3F", "WebGL", 3D product viewers, 3D hero sections, GLTF/GLB models, or wants an immersive/interactive 3D web experience. Always check performance implications (draw calls, bundle size, mobile fallback) as part of this skill.
- Installs packages
In this repository22 other files it gives its agents.
- accessibility-a11ySkill
- design-system-tailwindSkill
- motion-design-toolkitSkill
- nextjs-architectureSkill
- react-component-engineeringSkill
- responsive-mobile-firstSkill
- auth-authorizationSkill
- database-schema-designSkill
- form-validation-error-handlingSkill
- mern-stack-architectureSkill
- rest-api-integrationSkill
- state-managementSkill
- landing-page-conversionSkill
- payment-gateway-integrationSkill
- saas-dashboard-adminSkill
- startup-mvp-developmentSkill
- ux-research-flow-designSkill
- visual-design-languageSkill
- ai-assisted-frontend-workflowSkill
- deployment-vercel-productionSkill
- performance-seo-optimizationSkill
- project-architecture-clean-codeSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Limit real-time shadows: prefer baked lighting or a single shadow-casting light.
- Very specific: line 44
Frameloop: use frameloop="demand" on the Canvas for static/product-viewer scenes that only need to re-render on interaction, not always …
- Distinctive: line 56
No loading state / fallback while the model streams in
- Distinctive: line 57
No reduced-motion / low-power fallback
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
React Three Fiber (R3F) 3D Experience Skill
Guides building production 3D web experiences that are performant, SSR-safe (Next.js), and don't tank Core Web Vitals or mobile framerate.
Setup essentials
npm i three @react-three/fiber @react-three/drei
npm i -D @types/threeR3F components are client-only — the Canvas and everything inside it must live in a "use client" boundary. In Next.js, dynamically import the whole 3D scene with ssr: false to avoid hydration mismatches:
const Scene = dynamic(() => import('@/components/three/Scene'), { ssr: false });Baseline scene structure
<Canvas camera={{ position: [0, 1.5, 5], fov: 45 }} dpr={[1, 2]} gl={{ antialias: true, powerPreference: 'high-performance' }}>
<Suspense fallback={<Loader />}>
<Environment preset="city" />
<ambientLight intensity={0.4} />
<directionalLight position={[5, 5, 5]} intensity={1} castShadow />
<Model url="/models/product.glb" />
<OrbitControls enableZoom={false} enablePan={false} />
</Suspense>
</Canvas>dpr={[1, 2]}caps device pixel ratio — never let it run uncapped on high-DPI mobile screens (kills framerate).- Wrap async assets (
useGLTF,useTexture) in<Suspense>with a real loading UI, not a blank canvas.
Loading models
- Compress with
gltf-transform/Draco before shipping (useGLTF.preload, use-dracovariants). - Load via
useGLTF(url)(drei) — neveruseLoader(GLTFLoader, url)directly unless you need custom loader config. - Preload critical models:
useGLTF.preload('/models/product.glb')outside the component.
Performance rules (check every time)
- Instance repeated geometry (
<Instances>/InstancedMesh) instead of mapping many<mesh>— one draw call vs. hundreds. - Dispose properly: R3F auto-disposes on unmount for most cases, but custom geometries/materials created imperatively need manual
.dispose(). - Limit real-time shadows: prefer baked lighting or a single shadow-casting light;
castShadowon many lights is expensive. - Frameloop: use
frameloop="demand"on the Canvas for static/product-viewer scenes that only need to re-render on interaction, notalways(60fps loop) when nothing is animating. - Mobile fallback: for low-end devices, detect via a capability check (WebGL2 support,
navigator.hardwareConcurrency) and serve a static image/video poster instead of the full 3D scene — never assume every visitor can run a heavy scene smoothly. - Bundle size: three.js is large — dynamically import the 3D module so it doesn't block the initial page load/LCP for content that isn't 3D.
Reference files (load when relevant)
references/animation-and-interaction.md— useFrame patterns, GSAP/R3F integration, scroll-linked 3D, drei helpers (Html, Text3D, Scroll)references/postprocessing-and-materials.md— @react-three/postprocessing effects, custom shaders/materials, physically-based lighting recipes
Anti-patterns to flag
- Rendering
<Canvas>without SSR guard in a Next.js Server Component tree - Uncompressed multi-MB GLTF models shipped directly
frameloop="always"on a scene with no continuous animation- No loading state / fallback while the model streams in
- No reduced-motion / low-power fallback
Example prompt this skill should trigger on
"Add an interactive 3D product viewer to the hero section of our Next.js landing page."
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

