Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

threejs-r3f

БесплатноБез исполняемых скриптовНе проверен

Three.js and React Three Fiber sub-skill - 3D scenes, shaders, postprocessing.

AThevonот AThevon★ 919 звёзд на GitHub

Об этом скилле

Version-sensitive. Every API name, SDK gate and browser-support claim below was verified on 2026-09-08 against primary sources. What against, and when, is in _jutsu/VERSIONS.md. If that date is old, re-verify before acting on a version number.

Three.js & React Three Fiber

3D on the web. Three.js is the engine, R3F is the React renderer. Concise rules here. Deep-dive in references/.

Versions: three r187 (0.187.x) · @react-three/fiber 9.x · @react-three/drei 10.x · @react-three/postprocessing 3.x. R3F 9 is React 19 only - its declared peer range is react / react-dom >=19 <19.4 (drei 10 asks ^19). React 18 projects must stay on R3F 8 + drei 9. Check the installed React major before scaffolding. Renderers: WebGLRenderer is still R3F's default. WebGPURenderer + TSL is shipped (not flagged) and self-falls-back to WebGL 2, but three's docs call it "the new alternative of WebGLRenderer", not the default. Opt in with an async gl callback:

import * as THREE from 'three/webgpu'
<Canvas gl={async (props) => { const r = new THREE.WebGPURenderer(props as any); await r.init(); return r }} />

When to Use What

Need Tool Why
Full 3D scene (models, lights, physics) R3F + drei Declarative, React-friendly, ecosystem
Vanilla 3D (no React) Three.js direct Lighter, no React overhead
Simple 3D transforms on UI CSS transform3d GPU-composited, no WebGL context
2D particles / generative Canvas 2D Simpler API, less GPU overhead
Shader-only visuals (no scene graph) Raw WebGL / ShaderMaterial Maximum control, minimal abstraction

Scene Setup Patterns

import { Canvas } from '@react-three/fiber'
import { Environment, OrbitControls } from '@react-three/drei'
import { Suspense } from 'react'

<Canvas camera={{ position: [0, 2, 5], fov: 45 }} dpr={[1, 2]} gl={{ antialias: true }}>
  <Suspense fallback={null}>
    <Environment preset="studio" />
    <OrbitControls makeDefault />
    <Scene />
  </Suspense>
</Canvas>

Rules:

  • Always wrap scene content in <Suspense> -- loaders (GLTF, textures, HDRI) need it
  • Set dpr={[1, 2]} to clamp pixel ratio (Retina without melting GPUs)
  • Keep the Canvas parent component minimal -- re-renders propagate into the scene

R3F Hooks

Hook Purpose Gotcha
useFrame((state, delta) => {}) Per-frame logic (animation, physics) Never setState inside
useThree() Access gl, scene, camera, size, viewport, pointer Destructure only what you need
useLoader(TextureLoader, url) Load any Three.js resource Wrap parent in Suspense
useGraph(scene) Extract nodes/materials from loaded scene Useful after useGLTF

useFrame Tips

useFrame((state, delta) => {
  // Use delta for framerate-independent animation
  meshRef.current.rotation.y += delta * 0.5
  // Access clock for time-based effects
  material.uniforms.uTime.value = state.clock.elapsedTime
})

state.clock is a THREE.Clock, which three deprecated in r183 in favour of Timer. R3F 9.8 still creates it, so the console shows that deprecation warning in every R3F app; state.clock.elapsedTime keeps working, and the warning is not yours to fix.


Drei Essentials

Component Use Case
Environment HDRI lighting (presets: studio, sunset, city, forest, dawn)
Float Idle floating animation (speed, rotationIntensity, floatIntensity)
Text3D Extruded 3D text (needs JSON font from Facetype.js)
useGLTF Load .glb/.gltf models (returns { nodes, materials, scene })
useGLTF.preload(url) Preload model before component mounts
MeshTransmissionMaterial Glass/crystal/liquid refraction effects
PresentationControls Drag-to-rotate for product showcases
Center Auto-center any group of meshes
Detailed LOD -- swap geometry by camera distance
useTexture Load textures with Suspense support
Instances Declarative instancing for repeated meshes

Postprocessing

import { EffectComposer, Bloom, ChromaticAberration } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'

<EffectComposer>
  <Bloom
    luminanceThreshold={1}
    luminanceSmoothing={0.4}
    intensity={0.6}
  />
  <ChromaticAberration
    blendFunction={BlendFunction.NORMAL}
    offset={[0.002, 0.002]}
  />
</EffectComposer>

Rules:

  • Bloom is selective by default -- lift material color/emissive above 1.0 to make it glow
  • luminanceThreshold={1} = nothing glows unless explicitly emissive
  • Order matters inside EffectComposer
  • Effects are merged into a single pass (performant by design)

Performance Patterns

Pattern When
<Instances> / InstancedMesh 100+ identical meshes (particles, trees, crowds)
<Detailed distances={[0, 50, 100]}> LOD: swap hi/lo models by distance
`disp
Полный SKILL.md на GitHub

Установить threejs-r3f в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/scene-setup.mdreferences/shaders.md

FAQ

Что делает скилл threejs-r3f?

Three.js and React Three Fiber sub-skill - 3D scenes, shaders, postprocessing.

Как установить скилл threejs-r3f?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл threejs-r3f запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить threejs-r3f с