Skip to content

🎥 Make videos programmatically with React

animations

Jonny Burger6a965a3395d6
diff --git a/packages/skills/skills/3d/SKILL.md b/packages/skills/skills/3d/SKILL.md
index e997f6b750..31fa5c6773 100644
--- a/packages/skills/skills/3d/SKILL.md
+++ b/packages/skills/skills/3d/SKILL.md
@@ -1,58 +1,39 @@
---
name: 3d
-description: 3D animation patterns using ThreeCanvas for Remotion. Use when creating 3D objects, ThreeJS content, spatial animations, rotating cubes, or 3D scenes.
+description: 3D content in Remotion using Three.js and React Three Fiber.
metadata:
- impact: MEDIUM
- tags: 3d, three, threejs, webgl, spatial
+ tags: 3d, three, threejs
---
-## ThreeCanvas Setup
+# Using Three.js and React Three Fiber in Remotion
-Always wrap 3D content in ThreeCanvas and include proper lighting.
+Follow React Three Fiber and Three.js best practices.
+Only the following Remotion-specific rules need to be followed:
-**Incorrect (missing ThreeCanvas wrapper):**
+## Prerequisites
-```tsx
-<mesh rotation={[0, frame * 0.02, 0]}>
- <boxGeometry args={[2, 2, 2]} />
- <meshStandardMaterial color="#4a9eff" />
-</mesh>
-```
+First, the `@remotion/three` package needs to be installed.
+If it is not, use the following command:
-**Correct (proper ThreeCanvas setup):**
-
-```tsx
-import { ThreeCanvas } from "@remotion/three";
-
-<ThreeCanvas>
- <ambientLight intensity={0.5} />
- <pointLight position={[10, 10, 10]} />
- <mesh rotation={[0, frame * 0.02, 0]}>
- <boxGeometry args={[2, 2, 2]} />
- <meshStandardMaterial color="#4a9eff" />
- </mesh>
-</ThreeCanvas>
+```bash
+npx remotion add @remotion/three # If project uses npm
+bunx remotion add @remotion/three # If project uses bun
+yarn remotion add @remotion/three # If project uses yarn
+pnpm exec remotion add @remotion/three # If project uses pnpm
```
-## Lighting Setup
-
-Every 3D scene needs ambient + directional light for depth.
+## Using ThreeCanvas
-**Incorrect (no lighting - objects appear flat/black):**
+You MUST wrap 3D content in `<ThreeCanvas>` and include proper lighting.
+`<ThreeCanvas>` MUST have a `width` and `height` prop.
```tsx
-<ThreeCanvas>
- <mesh>
- <sphereGeometry args={[1, 32, 32]} />
- <meshStandardMaterial color="red" />
- </mesh>
-</ThreeCanvas>
-```
+import { ThreeCanvas } from "@remotion/three";
+import { useVideoConfig } from "remotion";
-**Correct (proper lighting):**
+const { width, height } = useVideoConfig();
-```tsx
-<ThreeCanvas>
+<ThreeCanvas width={width} height={height}>
<ambientLight intensity={0.4} />
<directionalLight position={[5, 5, 5]} intensity={0.8} />
<mesh>
@@ -62,60 +43,44 @@ Every 3D scene needs ambient + directional light for depth.
</ThreeCanvas>
```
-## Frame-Based Rotation
+## No animations not driven by `useCurrentFrame()`
-Use frame directly for smooth continuous rotation.
+Shaders, models etc MUST NOT animate by themselves.
+No animations are allowed unless they are driven by `useCurrentFrame()`.
+Otherwise, it will cause flickering during rendering.
-```tsx
-const frame = useCurrentFrame();
-const rotationY = frame * 0.02; // Adjust speed with multiplier
-
-<mesh rotation={[0, rotationY, 0]}>
- <boxGeometry args={[2, 2, 2]} />
- <meshStandardMaterial color="#4a9eff" />
-</mesh>
-```
+Using `useFrame()` from `@react-three/fiber` is forbidden.
-## Floating/Hovering Animation
+## Animate using `useCurrentFrame()`
-Use sine wave on Y position for organic floating effect.
+Use `useCurrentFrame()` to perform animations.
```tsx
const frame = useCurrentFrame();
-const floatY = Math.sin(frame * 0.1) * 0.3; // Amplitude 0.3, speed 0.1
+const rotationY = frame * 0.02;
-<mesh position={[0, floatY, 0]}>
- {/* geometry and material */}
+<mesh rotation={[0, rotationY, 0]}>
+ <boxGeometry args={[2, 2, 2]} />
+ <meshStandardMaterial color="#4a9eff" />
</mesh>
```
-## Spring-Based Scale Entrance
+## Using `<Sequence>` inside `<ThreeCanvas>`
-Use spring() for bouncy 3D object entrances.
+The `layout` prop of any `<Sequence>` inside a `<ThreeCanvas>` must be set to `none`.
```tsx
-const scaleProgress = spring({
- frame,
- fps,
- config: { damping: 12, stiffness: 100 }
-});
-
-<mesh scale={[scaleProgress, scaleProgress, scaleProgress]}>
- {/* geometry and material */}
-</mesh>
-```
-
-## Camera Positioning
+import { Sequence } from "remotion";
+import { ThreeCanvas } from "@remotion/three";
-Position camera at reasonable distance for scene visibility.
+const { width, height } = useVideoConfig();
-```tsx
-<ThreeCanvas camera={{ position: [0, 0, 5], fov: 75 }}>
- {/* scene content */}
+<ThreeCanvas width={width} height={height}>
+ <Sequence layout="none">
+ <mesh>
+ <boxGeometry args={[2, 2, 2]} />
+ <meshStandardMaterial color="#4a9eff" />
+ </mesh>
+ </Sequence>
</ThreeCanvas>
-```
-
-## Complete Examples
-
-For full working code examples, see:
-- [Falling Spheres Example](assets/falling-spheres.tsx) - 3D bouncing spheres with physics simulation
+```
\ No newline at end of file
diff --git a/packages/skills/skills/animations/SKILL.md b/packages/skills/skills/animations/SKILL.md
new file mode 100644
index 0000000000..7e15623f83
--- /dev/null
+++ b/packages/skills/skills/animations/SKILL.md
@@ -0,0 +1,29 @@
+---
+name: animations
+description: Fundamental animation skills for Remotion
+metadata:
+ tags: animations, transitions, frames, useCurrentFrame
+---
+
+All animations MUST be driven by the `useCurrentFrame()` hook.
+Write animations in seconds and multiply them by the `fps` value from `useVideoConfig()`.
+
+```tsx
+import { useCurrentFrame } from "remotion";
+
+export const FadeIn = () => {
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+
+ const opacity = interpolate(frame, [0, 2 * fps], [0, 1], {
+ extrapolateRight: 'clamp',
+ });
+
+ return (
+ <div style={{ opacity }}>Hello World!</div>
+ );
+};
+```
+
+CSS transitions or animations are FORBIDDEN - they will not render correctly.
+Tailwind animation class names are FORBIDDEN - they will not render correctly.
\ No newline at end of file