Loading...
Loading...
Use when implementing motion design, timeline animations, visual animation editors, animating Three.js/R3F scenes, creating keyframe animations, or using Theatre.js, @theatre/core, @theatre/studio, @theatre/r3f, theatric, or building animation tooling for the web.
npx skill4agent add noklip-io/agent-skills theatre-js# Core + Studio (development)
npm install @theatre/core@0.7 @theatre/studio@0.7
# React Three Fiber integration
npm install @theatre/r3f@0.7
# React utilities
npm install @theatre/react
# Theatric (simplified controls)
npm install theatricimport * as core from '@theatre/core'
import studio from '@theatre/studio'
// Initialize Studio (dev only)
if (import.meta.env.DEV) {
studio.initialize()
}
// Create project → sheet → object
const project = core.getProject('My Project')
const sheet = project.sheet('Main')
const obj = sheet.object('Box', {
position: { x: 0, y: 0 },
opacity: 1
})
// Read values
console.log(obj.value.position.x)
// Listen to changes
obj.onValuesChange((values) => {
element.style.opacity = values.opacity
element.style.transform = `translate(${values.position.x}px, ${values.position.y}px)`
})
// Play animation
sheet.sequence.play({ iterationCount: Infinity })| Concept | Description |
|---|---|
| Project | Container for all animation data; maps to exported JSON state |
| Sheet | A scene or component; contains objects and one sequence |
| Object | Animatable entity with typed props |
| Sequence | Timeline with keyframes; controls playback |
| Props | Typed values (number, compound, rgba, etc.) |
| Reference | Use When |
|---|---|
| Project setup, sheets, objects, sequences, playback control |
| Defining props, custom types, compound props, constraints |
| Studio UI, keyboard shortcuts, extensions, panels |
| useVal, usePrism, @theatre/react hooks |
| React Three Fiber, editable components, SheetProvider |
| Export state, assets, deployment, tree-shaking |
const obj = sheet.object('Card', {
x: 0,
y: 0,
rotation: 0,
scale: 1,
opacity: 1
})
obj.onValuesChange(({ x, y, rotation, scale, opacity }) => {
element.style.transform = `translate(${x}px, ${y}px) rotate(${rotation}deg) scale(${scale})`
element.style.opacity = opacity
})const seq = sheet.sequence
// Play once
seq.play()
// Play with options
seq.play({
iterationCount: Infinity, // loop forever
range: [0, 2], // play seconds 0-2
rate: 1.5, // 1.5x speed
direction: 'alternate' // ping-pong
})
// Pause and seek
seq.pause()
seq.position = 1.5 // jump to 1.5s
// Await completion
await seq.play({ iterationCount: 1 })
console.log('Animation complete')import { Canvas } from '@react-three/fiber'
import { editable as e, SheetProvider } from '@theatre/r3f'
import { getProject } from '@theatre/core'
import studio from '@theatre/studio'
import extension from '@theatre/r3f/dist/extension'
// Dev setup
if (import.meta.env.DEV) {
studio.initialize()
studio.extend(extension)
}
const sheet = getProject('R3F Demo').sheet('Scene')
function App() {
return (
<Canvas>
<SheetProvider sheet={sheet}>
<e.mesh theatreKey="Cube">
<boxGeometry />
<meshStandardMaterial color="orange" />
</e.mesh>
<e.pointLight theatreKey="Light" position={[10, 10, 10]} />
</SheetProvider>
</Canvas>
)
}import { useControls, types } from 'theatric'
function Component() {
const { color, intensity, position } = useControls({
color: '#ff0000',
intensity: types.number(1, { range: [0, 2] }),
position: { x: 0, y: 0, z: 0 }
})
return <mesh position={[position.x, position.y, position.z]} />
}// ❌ Includes studio in bundle
import studio from '@theatre/studio'
studio.initialize()
// ✅ Dev-only initialization
if (import.meta.env.DEV) {
studio.initialize()
}// ❌ No animations without state
const project = core.getProject('My Project')
// ✅ Load exported state
import state from './state.json'
const project = core.getProject('My Project', { state })// ❌ Same key = same object (shared state)
sheet.object('Box', { x: 0 })
sheet.object('Box', { y: 0 }) // Overwrites!
// ✅ Unique keys per object
sheet.object('Box1', { x: 0 })
sheet.object('Box2', { y: 0 })// ❌ No 3D controls in Studio
studio.initialize()
// ✅ Extend with R3F extension
import extension from '@theatre/r3f/dist/extension'
studio.initialize()
studio.extend(extension)// ❌ Not editable
<e.mesh>
// ✅ Requires theatreKey
<e.mesh theatreKey="MyCube">| Task | Solution |
|---|---|
| Create project | |
| Create sheet | |
| Create object | |
| Listen to values | |
| Read value | |
| Play animation | |
| Pause animation | |
| Seek position | |
| R3F editable | |
| React value hook | |
| Export state | Studio → Project → Export (JSON) |