
r3f-animation
Animate React Three Fiber objects with useFrame, damping, and GLTF clips. Use for procedural motion, animation transitions, or demand-loop animation; use physics guidance for collision-driven movement.
- Installs
- 2K
- Last 24h
- +10
- Trending rank
- #8736
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/enzed/r3f-skills --skill r3f-animation- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads r3f-animation automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
React Three Fiber animation
Check installed Fiber, Drei, and React versions first. These examples target Fiber 9 / React 19. Keep the project's animation library when it already meets the task.
Choose an owner
- Use
useFrameand refs for continuous transforms/uniforms; React state describes discrete goals such as selected, open, or active. - Use Drei
useAnimationsfor authored GLTF clips. Read clip playback for independent animated instances and cleanup. - Use the project's spring/tween library for coordinated transitions; check its React peer dependencies before adding it. Do not introduce a state manager merely to animate a mesh.
- Let Rapier own simulated body transforms. Animate kinematic targets through physics APIs rather than fighting the simulation with mesh positions.
Damping that can return to idle
Mount below Canvas; this also works with frameloop="demand". Click the box to change its target.
import { useEffect, useRef, useState } from 'react'
import { useFrame, useThree } from '@react-three/fiber'
import { MathUtils, type Mesh } from 'three'
export default function Example() {
const mesh = useRef<Mesh>(null)
const [active, setActive] = useState(false)
const invalidate = useThree((state) => state.invalidate)
const target = active ? 1 : -1
useEffect(() => { invalidate() }, [target, invalidate])
useFrame((_, delta) => {
if (!mesh.current) return
// Cap a visual transition's resume jump, not a physics simulation step.
const x = MathUtils.damp(mesh.current.position.x, target, 6, Math.min(delta, 0.1))
const moving = Math.abs(x - target) > 0.001
mesh.current.position.x = moving ? x : target
if (moving) invalidate()
})
return (
<mesh ref={mesh} name="moving-box" onClick={() => setActive((value) => !value)}>
<boxGeometry />
<meshStandardMaterial color={active ? 'orange' : 'coral'} />
</mesh>
)
}
Timing and performance
deltais seconds. Integrate velocity asposition += velocity * delta; useMathUtils.dampor lerp with1 - exp(-lambda * delta)for exponential smoothing. A fixed lerp fraction depends on refresh rate;delta * speedcan overshoot.- Reuse vectors/quaternions; avoid allocating them in every frame. Use quaternion interpolation for orientation instead of independently lerping Euler angles across wrap boundaries.
- Use one timeline/clock owner. Fiber 9 still supplies
state.clock; do not replace Fiber internals because Three.js deprecated new standaloneClockinstances. For independent Three.js timing, consultTimerin the installed release. - On demand, external animation systems need invalidation while active. Invalidate before starting a synchronous animation and arrange the start on the next frame if the first frame would otherwise jump.
- Read fast external state directly in the frame callback when supported (e.g. a store's
getState()); subscribe React only to UI-relevant changes. Clean up external subscriptions. - Do not claim a normal React re-render stops animation. Profile actual work and subscription frequency before memoizing components.
- Hiding an object does not stop its frame callback or mixer. Pause expensive animation explicitly when appropriate; respect reduced-motion preferences for decorative motion.
- Repeated oscillations and shader motion can derive phase from elapsed time; simulations needing reproducibility require a fixed-step design, not arbitrary delta clamping.
Verify
Compare motion at different frame rates, background/resume behavior, and repeated target changes. On demand, confirm the object wakes, reaches its goal, and stops requesting frames. For clips, test two instances playing different actions.
Sources
FAQ
What does the r3f-animation skill do?
Animate React Three Fiber objects with useFrame, damping, and GLTF clips. Use for procedural motion, animation transitions, or demand-loop animation; use physics guidance for collision-driven movement.
How do I install r3f-animation?
Run npx skills add https://github.com/enzed/r3f-skills --skill r3f-animation in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/r3f-animation/ (personal) or .claude/skills/r3f-animation/ (project).
Which AI agents can use r3f-animation?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is r3f-animation safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains r3f-animation?
It is published by enzed in enzed/r3f-skills. It has 2,046 recorded installs.
More from enzed/r3f-skills
r3f-interaction
enzed/r3f-skills
Implement React Three Fiber pointer events, picking, dragging, keyboard input, and camera controls. Use for scene interaction and event propagation, rather than animation or physics simulation itself.
r3f-fundamentals
enzed/r3f-skills
Set up React Three Fiber scenes, Canvas, typed JSX, hooks, and resource ownership. Use for scene architecture and render-loop setup, rather than detailed materials or effects.
r3f-postprocessing
enzed/r3f-skills
Configure React Three Fiber postprocessing, bloom, selection effects, ambient occlusion, and depth of field. Use for composer pipelines and screen-space effects, rather than mesh material shaders.
r3f-materials
enzed/r3f-skills
Choose and configure React Three Fiber surface materials, PBR, transparency, and transmission. Use for mesh appearance and material cost; use shader guidance for custom GLSL or TSL code.
r3f-geometry
enzed/r3f-skills
Build React Three Fiber geometry, custom buffers, instanced meshes, points, and lines. Use for shape construction and geometry draw-call optimization, rather than material appearance.
r3f-shaders
enzed/r3f-skills
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.
Popular frontend & design skills
setup-matt-pocock-skills
mattpocock/skills
Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.
frontend-design
anthropics/skills
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.
hyperframes-animation
heygen-com/hyperframes
All animation knowledge for HyperFrames — atomic motion rules, multi-phase scene blueprints, scene transitions, broader motion-design techniques, AND the seven runtime adapters (GSAP default, plus Lottie, Three.js, Anime.js, CSS keyframes, Web Animations API, TypeGPU). Use for any motion or animation task: pick 2-4 rules and compose, or load a blueprint, or look up runtime-specific API (e.g. GSAP eases / Lottie player / Three.js mixer). Also covers auditing an existing composition's choreography (animation map) and 24 named text-animation effects. HyperFrames-native: single paused timeline, seek-safe, deterministic.
prototype
mattpocock/skills
Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
hyperframes-core
heygen-com/hyperframes
The HyperFrames composition contract — build one renderable project. Use for composition structure, the data- timing attributes, class="clip", tracks, sub-compositions, variables, framework-owned media playback, deterministic-render rules, and validation. Read before writing composition HTML.
vercel-react-best-practices
vercel-labs/agent-skills
React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.