r3f-animation
Animate React Three Fiber objects with useFrame, damping, and GLTF clips. Use for procedural motion, animation transitions, or…
Implement custom GLSL or TSL materials in React Three Fiber, including uniforms and vertex deformation. Use for shader code and shader debugging, rather than ordinary PBR settings or composer effects.
$ npx -y skills add enzed/r3f-skills --skill r3f-shaders --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/r3f-shadersContext preview
The summary Claude sees to decide when to auto-load this skill.
Implement custom GLSL or TSL materials in React Three Fiber, including uniforms and vertex deformation. Use for shader code and shader debugging, rather than ordinary PBR settings or composer effects.
name: r3f-shaders description: Implement custom GLSL or TSL materials in React Three Fiber, including uniforms and vertex deformation. Use for shader code and shader debugging, rather than ordinary PBR settings or composer effects.
Inspect installed Fiber, Drei, Three.js, and renderer versions first. The example uses Fiber 9 / React 19 and WebGL. Preserve an existing project's versions.
Mount beneath Canvas. Keep the material class and `extend` call outside render; the local component avoids global JSX augmentation.
import { useRef } from 'react'
import { extend, useFrame } from '@react-three/fiber'
import { shaderMaterial } from '@react-three/drei'
import { Color } from 'three'
const WaveMaterial = shaderMaterial(
{ uTime: 0, uColor: new Color('coral') },
`uniform float uTime;
varying vec2 vUv;
void main() {
vUv = uv;
vec3 p = position;
p.z += sin(p.x * 4.0 + uTime) * 0.15;
gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
}`,
`uniform vec3 uColor;
varying vec2 vUv;
void main() {
gl_FragColor = vec4(uColor * (0.4 + 0.6 * vUv.y), 1.0);
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,
)
const Wave = extend(WaveMaterial)
export default function Example() {
const material = useRef<InstanceType<typeof WaveMaterial>>(null)
useFrame((_, delta) => {
if (material.current) material.current.uTime += delta
})
return (
<mesh>
<planeGeometry args={[3, 3, 32, 32]} />
<Wave ref={material} key={WaveMaterial.key} />
</mesh>
)
}Use `onBeforeCompile` only when retaining a built-in material's lighting is useful. Shader chunk names are version-sensitive: inspect the installed source, and render-test after a Three.js update.
Set the callback before first compilation. When a configuration changes generated GLSL, provide a matching `customProgramCacheKey` and trigger recompilation; keep animated values in uniforms. Do not assume `.clone()` or serialization preserves callbacks. Prefer node materials when the task already targets WebGPU.
Focused guidance for building React Three Fiber scenes with current, compatible APIs. Each skill keeps decisions, pitfalls, and one checked example in SKILL.md; substantial optional recipes live in that skill's references/ directory.
Animate React Three Fiber objects with useFrame, damping, and GLTF clips. Use for procedural motion, animation transitions, or…
Set up React Three Fiber scenes, Canvas, typed JSX, hooks, and resource ownership. Use for scene architecture and render-loop…
Build React Three Fiber geometry, custom buffers, instanced meshes, points, and lines. Use for shape construction and geometry…
Implement React Three Fiber pointer events, picking, dragging, keyboard input, and camera controls. Use for scene interaction and…
Light React Three Fiber scenes with direct lights, environment maps, and shadows. Use for light placement, image-based lighting,…
Load and reuse 3D assets in React Three Fiber with useGLTF, useLoader, Suspense, and preloading. Use for model loading, decoder…