react-three-fiber
Build 3D scenes in React with React Three Fiber (@react-three/fiber), the React renderer for three.js. Use when the user wants 3D in a React or Next.js app, a Canvas with meshes, lights and cameras, animation with useFrame, loading models or textures, pointer events on 3D objects, on-demand rendering and performance work, a v8 to v9 migration, or to fix a React Three Fiber problem such as setState in a render loop or a Next.js server-component error.
- License 许可
- MIT
- 所属仓库
- siddu1004/SFP
- 最近更新
- 2026-11-09
- Stars
- ★ 5
- Forks
- 0
01 前言 Front Matter
- name
- react-three-fiber
- description
- Build 3D scenes in React with React Three Fiber (@react-three/fiber), the React renderer for three.js. Use when the user wants 3D in a React or Next.js app, a Canvas with meshes, lights and cameras, animation with useFrame, loading models or textures, pointer events on 3D objects, on-demand rendering and performance work, a v8 to v9 migration, or to fix a React Three Fiber problem such as setState in a render loop or a Next.js server-component error.
02 资源文件 15
- 参考文档reference/basic-animations.md3.4 KB
- 参考文档reference/canvas.md13.3 KB
- 参考文档reference/events.md8.1 KB
- 参考文档reference/hooks.md15.9 KB
- 参考文档reference/how-it-works.md5.8 KB
- 参考文档reference/installation.md5.4 KB
- 参考文档reference/introduction.md9.4 KB
- 参考文档reference/loading-models.md6.7 KB
- 参考文档reference/loading-textures.md4.2 KB
- 参考文档reference/objects.md8.9 KB
- 参考文档reference/pitfalls.md7.4 KB
- 参考文档reference/scaling-performance.md15.7 KB
- 参考文档reference/testing.md4.0 KB
- 参考文档reference/typescript.md4.5 KB
- 参考文档reference/v9-migration-guide.md8.6 KB
03 SKILL.md 正文
React Three Fiber
React Three Fiber (R3F) renders three.js with React: three.js objects are written as JSX, and hooks give access to the render loop and the scene. The project's own docs are bundled in reference/. Read the file that matches the task instead of all of them.
| Task | Read |
|---|---|
| What it is, a first scene | reference/introduction.md |
| Install for Vite, Next.js, React Native or a CDN | reference/installation.md |
Canvas props: frameloop, dpr, shadows, camera, gl |
reference/canvas.md |
useFrame, useThree, useLoader, useGraph |
reference/hooks.md |
JSX objects, constructor args, attach, props, dispose |
reference/objects.md |
Pointer events, onClick, onPointerOver, event propagation |
reference/events.md |
Animation with useFrame and springs |
reference/basic-animations.md |
| Loading glTF models and textures | reference/loading-models.md, reference/loading-textures.md |
| Why it is fast, how objects map to JSX | reference/how-it-works.md |
| Common mistakes | reference/pitfalls.md |
| Frame rate, instancing, on-demand rendering, level of detail | reference/scaling-performance.md |
| TypeScript types and JSX typing | reference/typescript.md |
| Upgrading from v8 | reference/v9-migration-guide.md |
| Testing | reference/testing.md |
The rules that prevent most problems
These come from the bundled docs; the details and examples are in reference/pitfalls.md and reference/scaling-performance.md.
- Install
threeand@react-three/fiber. R3F must pair with the matching major version of React, like react-dom does: check the version note inreference/installation.mdbefore choosing versions. - Do not call
setStateinuseFrameor in fast events. Mutate refs and use the framedeltainstead, so the animation does not depend on the frame rate. - Do not create objects in a loop. Allocate vectors, colours and materials once and reuse them.
- Load assets with
useLoader, which caches and suspends, rather than calling a loader in render. - Reuse geometries and materials, and use instancing for many copies of the same mesh.
- Render on demand (
frameloop="demand") when nothing animates all the time, and callinvalidate()to draw a frame. - Mount with care. Toggling
visibleis cheaper than mounting and unmounting a heavy component. - In Next.js, add
threetotranspilePackagesinnext.config.js(seereference/installation.md). R3F components use hooks and browser APIs, so keep them in a client component ("use client").
Working method
- Read the file for the task above before writing code, and use the API shown there. R3F changes between major versions.
- Start from the smallest
Canvasthat works, check it renders, then add objects, lights and motion. - For performance problems, measure first (the performance monitoring section in
reference/scaling-performance.md), then apply the matching technique.
04 同仓库更多 Skills
scientific-schematics
Generates scientific diagram drafts using Nano Banana 2 AI with smart iterative refinement. Uses Gemini 3.7 Flash for quality review. Refines when the review requests improvement, with at most two generations. Specialized in neural network architectures, system diagrams, flowcharts, biological pathways, and complex scientific visualizations.
polyhaven-texture-apply
Apply realistic PBR textures from PolyHaven to any Blender object. Supports metals, wood, concrete, fabric, and more. Trigger when asked to texture an object, apply a material from PolyHaven, make something look like metal/wood/marble, or change object surface.
polyhaven-studio-setup
Set up a professional product photography studio in Blender using PolyHaven HDRIs and PBR ground materials. Trigger when asked to create a studio setup, add HDRI lighting, set up product photography, or create a showroom scene.
polyhaven-scene-builder
Build complete product scenes using PolyHaven assets — HDRI environment, textured ground/pedestal, and optional props from the 3D model library. Trigger when asked to build a product scene, create a showcase setup, add a pedestal, or compose a product shot.
polyhaven-material-swap
Cycle through multiple PolyHaven materials on a product and render each variant. Great for showing color/finish options. Trigger when asked to show material variants, swap textures, create color options, show finish comparisons, or render product in different materials.
polyhaven-hdri-showcase
Render the same product across multiple HDRI environments and output a comparison grid. Trigger when asked to compare lighting setups, test different environments, show product in multiple settings, or create an HDRI comparison.