🎥 Make videos programmatically with React
Add code examples gallery with 3D, shapes, and Lottie support
ASchwadf01d3d0494ac
diff --git a/bun.lock b/bun.lockindex 792414223c..19d5f54574 100644--- a/bun.lock+++ b/bun.lock@@ -1419,14 +1419,18 @@"@radix-ui/react-select": "^2.2.6","@radix-ui/react-slot": "^1.2.4","@radix-ui/react-tooltip": "^1.2.8",+ "@react-three/fiber": "^9.4.2",+ "@remotion/animated-emoji": "workspace:*","@remotion/bundler": "workspace:*","@remotion/cli": "workspace:*","@remotion/google-fonts": "workspace:*","@remotion/lambda": "workspace:*",+ "@remotion/lottie": "workspace:*","@remotion/paths": "workspace:*","@remotion/player": "workspace:*","@remotion/shapes": "workspace:*","@remotion/tailwind-v4": "workspace:*",+ "@remotion/three": "workspace:*","ai": "^5.0.104","class-variance-authority": "^0.7.1","clsx": "^2.1.1",@@ -1438,6 +1442,7 @@"react-dom": "19.0.0","remotion": "workspace:*","tailwind-merge": "^3.4.0",+ "three": "^0.181.2","zod": "^4.1.13",},"devDependencies": {@@ -1449,6 +1454,7 @@"@types/node": "20.12.14","@types/react": "19.0.0","@types/react-dom": "19.0.0",+ "@types/three": "^0.181.0","@types/web": "0.0.166","@typescript-eslint/eslint-plugin": "8.46.0","@typescript-eslint/parser": "8.46.0",@@ -2698,6 +2704,8 @@"@csstools/utilities": ["@csstools/[email protected]", "", { "peerDependencies": { "postcss": "8.5.1" } }, "sha512-5VdOr0Z71u+Yp3ozOx8T11N703wIFGVRgOWbOZMKgglPJsWA54MRIoMNVMa7shUToIhx5J8vX4sOZgD2XiihiQ=="],+ "@dimforge/rapier3d-compat": ["@dimforge/[email protected]", "", {}, "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow=="],+"@discoveryjs/json-ext": ["@discoveryjs/[email protected]", "", {}, "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw=="],"@docsearch/css": ["@docsearch/[email protected]", "", {}, "sha512-cQbnVbq0rrBwNAKegIac/t6a8nWoUAn8frnkLFW6YARaRmAQr5/Eoe6Ln2fqkUCZ40KpdrKbpSAmgrkviOxuWA=="],@@ -9162,6 +9170,10 @@"template-code-generation/@radix-ui/react-slot": ["@radix-ui/[email protected]", "", { "dependencies": { "@radix-ui/react-compose-refs": "1.1.2" }, "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-Jl+bCv8HxKnlTLVrcDE8zTMJ09R9/ukw4qBs/oZClOfoQk/cOTbDn+NceXfV7j09YPVQUryJPHurafcSg6EVKA=="],+ "template-code-generation/@react-three/fiber": ["@react-three/[email protected]", "", { "dependencies": { "@babel/runtime": "^7.17.8", "@types/react-reconciler": "^0.32.0", "@types/webxr": "*", "base64-js": "^1.5.1", "buffer": "^6.0.3", "its-fine": "^2.0.0", "react-reconciler": "^0.31.0", "react-use-measure": "^2.1.7", "scheduler": "^0.25.0", "suspend-react": "^0.1.3", "use-sync-external-store": "^1.4.0", "zustand": "^5.0.3" }, "peerDependencies": { "expo": ">=43.0", "expo-asset": ">=8.4", "expo-file-system": ">=11.0", "expo-gl": ">=11.0", "react": "^19.0.0", "react-dom": "^19.0.0", "react-native": ">=0.78", "three": ">=0.156" }, "optionalPeers": ["expo", "expo-asset", "expo-file-system", "expo-gl", "react-dom", "react-native"] }, "sha512-H4B4+FDNHpvIb4FmphH4ubxOfX5bxmfOw0+3pkQwR9u9wFiyMS7wUDkNn0m4RqQuiLWeia9jfN1eBvtyAVGEog=="],++ "template-code-generation/@types/three": ["@types/[email protected]", "", { "dependencies": { "@dimforge/rapier3d-compat": "~0.12.0", "@tweenjs/tween.js": "~23.1.3", "@types/stats.js": "*", "@types/webxr": "*", "@webgpu/types": "*", "fflate": "~0.8.2", "meshoptimizer": "~0.22.0" } }, "sha512-MLF1ks8yRM2k71D7RprFpDb9DOX0p22DbdPqT/uAkc6AtQXjxWCVDjCy23G9t1o8HcQPk7woD2NIyiaWcWPYmA=="],+"template-code-generation/@typescript-eslint/eslint-plugin": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/type-utils": "8.46.0", "@typescript-eslint/utils": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "graphemer": "^1.4.0", "ignore": "^7.0.0", "natural-compare": "^1.4.0", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "@typescript-eslint/parser": "^8.46.0", "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hA8gxBq4ukonVXPy0OKhiaUh/68D0E88GSmtC1iAEnGaieuDi38LhS7jdCHRLi6ErJBNDGCzvh5EnzdPwUc0DA=="],"template-code-generation/@typescript-eslint/parser": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/scope-manager": "8.46.0", "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0", "debug": "^4.3.4" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-n1H6IcDhmmUEG7TNVSspGmiHHutt7iVKtZwRppD7e04wha5MrkV1h3pti9xQLcCMt6YWsncpoT0HMjkH1FNwWQ=="],@@ -9176,6 +9188,8 @@"template-code-generation/tailwindcss": ["[email protected]", "", {}, "sha512-ImmZF0Lon5RrQpsEAKGxRvHwCvMgSC4XVlFRqmbzTEDb/3wvin9zfEZrMwgsa3yqBbPqahYcVI6lulM2S7IZAA=="],+ "template-code-generation/three": ["[email protected]", "", {}, "sha512-k/CjiZ80bYss6Qs7/ex1TBlPD11whT9oKfT8oTGiHa34W4JRd1NiH/Tr1DbHWQ2/vMUypxksLnF2CfmlmM5XFQ=="],+"template-code-generation/typescript-eslint": ["[email protected]", "", { "dependencies": { "@typescript-eslint/eslint-plugin": "8.46.0", "@typescript-eslint/parser": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-6+ZrB6y2bT2DX3K+Qd9vn7OFOJR+xSLDj+Aw/N3zBwUt27uTw2sw2TE2+UcY1RiyBZkaGbTkVg9SSdPNUG6aUw=="],"template-code-generation/zod": ["[email protected]", "", {}, "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig=="],@@ -11142,6 +11156,8 @@"template-code-generation/@radix-ui/react-slot/@radix-ui/react-compose-refs": ["@radix-ui/[email protected]", "", { "peerDependencies": { "@types/react": "19.0.0", "react": "19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg=="],+ "template-code-generation/@types/three/meshoptimizer": ["[email protected]", "", {}, "sha512-IebiK79sqIy+E4EgOr+CAw+Ke8hAspXKzBd0JdgEmPHiAwmvEj2S4h1rfvo+o/BnfEYd/jAOg5IeeIjzlzSnDg=="],+"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/scope-manager": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/visitor-keys": "8.46.0" } }, "sha512-lWETPa9XGcBes4jqAMYD9fW0j4n6hrPtTJwWDmtqgFO/4HF4jmdH/Q6wggTw5qIT5TXjKzbt7GsZUBnWoO3dqw=="],"template-code-generation/@typescript-eslint/eslint-plugin/@typescript-eslint/type-utils": ["@typescript-eslint/[email protected]", "", { "dependencies": { "@typescript-eslint/types": "8.46.0", "@typescript-eslint/typescript-estree": "8.46.0", "@typescript-eslint/utils": "8.46.0", "debug": "^4.3.4", "ts-api-utils": "^2.1.0" }, "peerDependencies": { "eslint": "^8.57.0 || ^9.0.0", "typescript": ">=4.8.4 <6.0.0" } }, "sha512-hy+lvYV1lZpVs2jRaEYvgCblZxUoJiPyCemwbQZ+NGulWkQRy0HRPYAoef/CNSzaLt+MLvMptZsHXHlkEilaeg=="],diff --git a/packages/template-code-generation/README.md b/packages/template-code-generation/README.mdindex 609a7a3f41..9a9ee2ab0b 100644--- a/packages/template-code-generation/README.md+++ b/packages/template-code-generation/README.md@@ -2,6 +2,14 @@AI-powered code generation template for Remotion.+## Adding examples and capabilities++When adding new capabilities to the assistant, we have to first create some examples to let the system know what we can do. So first we add the example to the template, tweak it a bit more to get it right with our taste and then add it as an example potentially to the system prompt of the assistant.++## Model Selection++GPT5.1 Low reasoning seems to be a good middle ground between generation speed and output quality.+## Usage```bashdiff --git a/packages/template-code-generation/package.json b/packages/template-code-generation/package.jsonindex 5b22bc4484..8bf8fe70f4 100644--- a/packages/template-code-generation/package.json+++ b/packages/template-code-generation/package.json@@ -24,14 +24,18 @@"@radix-ui/react-select": "^2.2.6","@radix-ui/react-slot": "^1.2.4","@radix-ui/react-tooltip": "^1.2.8",+ "@react-three/fiber": "^9.4.2",+ "@remotion/animated-emoji": "workspace:*","@remotion/bundler": "workspace:*","@remotion/cli": "workspace:*","@remotion/google-fonts": "workspace:*","@remotion/lambda": "workspace:*",+ "@remotion/lottie": "workspace:*","@remotion/paths": "workspace:*","@remotion/player": "workspace:*","@remotion/shapes": "workspace:*","@remotion/tailwind-v4": "workspace:*",+ "@remotion/three": "workspace:*","ai": "^5.0.104","class-variance-authority": "^0.7.1","clsx": "^2.1.1",@@ -43,6 +47,7 @@"react-dom": "19.0.0","remotion": "workspace:*","tailwind-merge": "^3.4.0",+ "three": "^0.181.2","zod": "^4.1.13"},"devDependencies": {@@ -54,6 +59,7 @@"@types/node": "20.12.14","@types/react": "19.0.0","@types/react-dom": "19.0.0",+ "@types/three": "^0.181.0","@types/web": "0.0.166","@typescript-eslint/eslint-plugin": "8.46.0","@typescript-eslint/parser": "8.46.0",diff --git a/packages/template-code-generation/src/app/code-examples/page.tsx b/packages/template-code-generation/src/app/code-examples/page.tsxnew file mode 100644index 0000000000..7f9d9b83bf--- /dev/null+++ b/packages/template-code-generation/src/app/code-examples/page.tsx@@ -0,0 +1,179 @@+"use client";++import { useState, useCallback, useMemo, Suspense, useEffect, useRef } from "react";+import Link from "next/link";+import { useSearchParams, useRouter } from "next/navigation";+import { ArrowLeft, PanelLeftClose, PanelLeft } from "lucide-react";+import { examples, getExampleById } from "../../templates";+import { useAnimationState } from "../../hooks/useAnimationState";+import { CodeEditor } from "../../components/CodeEditor";+import { AnimationPlayer } from "../../components/AnimationPlayer";+import { Logo } from "../../components/Logo";++function DemoPageContent() {+ const searchParams = useSearchParams();+ const router = useRouter();++ // Derive selected example directly from URL (single source of truth)+ const selectedExample = useMemo(() => {+ const exampleId = searchParams.get("example");+ if (exampleId) {+ return getExampleById(exampleId) ?? examples[0]!;+ }+ return examples[0]!;+ }, [searchParams]);++ const [sidebarOpen, setSidebarOpen] = useState(true);+ const selectedButtonRef = useRef<HTMLButtonElement>(null);++ const { code, Component, error, isCompiling, setCode, compileCode } =+ useAnimationState(selectedExample.code);++ // Auto-scroll to selected example+ useEffect(() => {+ if (selectedButtonRef.current) {+ selectedButtonRef.current.scrollIntoView({+ behavior: "smooth",+ block: "nearest",+ });+ }+ }, [selectedExample.id]);++ const handleExampleSelect = useCallback(+ (exampleId: string) => {+ const example = getExampleById(exampleId);+ if (example) {+ setCode(example.code);+ compileCode(example.code);+ router.replace(`/code-examples?example=${exampleId}`, { scroll: false });+ }+ },+ [setCode, compileCode, router],+ );++ const handleCodeChange = useCallback(+ (newCode: string) => {+ setCode(newCode);+ compileCode(newCode);+ },+ [setCode, compileCode],+ );++ const categories = [...new Set(examples.map((e) => e.category))];++ return (+ <div className="h-screen w-screen bg-[#0a0a0a] flex flex-col">+ {/* Header with logo */}+ <header className="flex items-center gap-6 py-8 px-12 shrink-0">+ <div className="flex flex-col gap-2">+ <Logo asLink />+ <Link+ href="/"+ className="flex items-center gap-1.5 text-xs text-[#666] hover:text-white transition-colors"+ >+ <ArrowLeft className="w-3 h-3" />+ Back to Home+ </Link>+ </div>+ <div className="h-10 w-px bg-[#333]" />+ <h1 className="text-sm font-medium text-[#888]">Example Gallery</h1>+ </header>++ {/* Main content with sidebar */}+ <div className="flex-1 flex overflow-hidden px-12">+ {/* Sidebar */}+ <div+ className={`border-r border-[#222] flex flex-col shrink-0 transition-all duration-300 overflow-hidden ${+ sidebarOpen ? "w-64 mr-8" : "w-0 border-r-0"+ }`}+ >+ <div+ className={`flex-1 overflow-y-auto pr-4 w-64 ${sidebarOpen ? "opacity-100" : "opacity-0 pointer-events-none"}`}+ >+ {categories.map((category) => (+ <div key={category} className="mb-6">+ <h3 className="text-xs font-semibold text-[#666] uppercase tracking-wider mb-3">+ {category}+ </h3>+ <div className="space-y-2">+ {examples+ .filter((e) => e.category === category)+ .map((example) => (+ <button+ key={example.id}+ ref={selectedExample.id === example.id ? selectedButtonRef : null}+ onClick={() => handleExampleSelect(example.id)}+ className={`w-full text-left p-3 rounded-lg border transition-all ${+ selectedExample.id === example.id+ ? "border-[#6366f1] bg-[#6366f1]/10 text-white"+ : "border-[#222] bg-[#111] text-gray-400 hover:border-[#333] hover:bg-[#1a1a1a]"+ }`}+ >+ <div className="font-medium text-sm">{example.name}</div>+ <div className="text-xs text-[#666] mt-1 line-clamp-2">+ {example.description}+ </div>+ </button>+ ))}+ </div>+ </div>+ ))}+ </div>+ </div>++ {/* Main content */}+ <div className="flex-1 flex flex-col min-w-0 pb-8">+ <div className="mb-4 flex items-center gap-4">+ <button+ onClick={() => setSidebarOpen(!sidebarOpen)}+ className="p-2 rounded-lg border border-[#222] bg-[#111] text-[#888] hover:text-white hover:border-[#333] transition-colors"+ title={sidebarOpen ? "Hide sidebar" : "Show sidebar"}+ >+ {sidebarOpen ? (+ <PanelLeftClose className="w-4 h-4" />+ ) : (+ <PanelLeft className="w-4 h-4" />+ )}+ </button>+ <div>+ <h2 className="text-lg font-semibold text-white">+ {selectedExample.name}+ </h2>+ <p className="text-sm text-[#666]">{selectedExample.description}</p>+ </div>+ </div>++ <div className="flex-1 flex gap-8 overflow-hidden">+ <CodeEditor+ code={code}+ onChange={handleCodeChange}+ isStreaming={false}+ streamPhase="idle"+ />+ <AnimationPlayer+ Component={Component}+ durationInFrames={selectedExample.durationInFrames}+ fps={selectedExample.fps}+ isCompiling={isCompiling}+ error={error}+ />+ </div>+ </div>+ </div>+ </div>+ );+}++export default function DemoPage() {+ return (+ <Suspense+ fallback={+ <div className="h-screen w-screen bg-[#0a0a0a] flex items-center justify-center">+ <div className="w-8 h-8 border-2 border-[#333] border-t-[#6366f1] rounded-full animate-spin" />+ </div>+ }+ >+ <DemoPageContent />+ </Suspense>+ );+}diff --git a/packages/template-code-generation/src/app/page.tsx b/packages/template-code-generation/src/app/page.tsxindex d86c0a74b1..95c868ffee 100644--- a/packages/template-code-generation/src/app/page.tsx+++ b/packages/template-code-generation/src/app/page.tsx@@ -3,8 +3,10 @@import { useState } from "react";import type { NextPage } from "next";import { useRouter } from "next/navigation";+import Link from "next/link";import {ArrowUp,+ SquareArrowOutUpRight,Loader2,Type,MessageCircle,@@ -110,7 +112,7 @@ const Home: NextPage = () => {</div><div className="flex flex-wrap items-center justify-center mt-6 gap-2">- <span className="text-[#666] text-xs mr-1">Try</span>+ <span className="text-[#666] text-xs mr-1">Prompt examples</span>{examplePrompts.map((example) => {const Icon = iconMap[example.icon];return (@@ -130,6 +132,16 @@ const Home: NextPage = () => {);})}</div>++ <div className="flex justify-center mt-4">+ <Link+ href="/code-examples"+ className="text-[#555] hover:text-[#888] text-xs transition-colors flex items-center gap-1"+ >+ View Code examples+ <SquareArrowOutUpRight className="w-3 h-3" />+ </Link>+ </div></form></div></PageLayout>diff --git a/packages/template-code-generation/src/hooks/useCodeCompiler.ts b/packages/template-code-generation/src/hooks/useCodeCompiler.tsindex 6c31b1b546..c61887ceb4 100644--- a/packages/template-code-generation/src/hooks/useCodeCompiler.ts+++ b/packages/template-code-generation/src/hooks/useCodeCompiler.ts@@ -11,6 +11,10 @@ import {spring,Sequence,} from "remotion";+import * as RemotionShapes from "@remotion/shapes";+import { Lottie } from "@remotion/lottie";+import { ThreeCanvas } from "@remotion/three";+import * as THREE from "three";export interface CompilationResult {Component: React.FC | null;@@ -54,6 +58,10 @@ export function useCodeCompiler() {const createComponent = new Function("React","Remotion",+ "RemotionShapes",+ "Lottie",+ "ThreeCanvas",+ "THREE","AbsoluteFill","interpolate","useCurrentFrame",@@ -66,6 +74,10 @@ export function useCodeCompiler() {const Component = createComponent(React,Remotion,+ RemotionShapes,+ Lottie,+ ThreeCanvas,+ THREE,AbsoluteFill,interpolate,useCurrentFrame,diff --git a/packages/template-code-generation/src/templates/index.ts b/packages/template-code-generation/src/templates/index.tsindex 1466de56a5..e0cd6b5f9a 100644--- a/packages/template-code-generation/src/templates/index.ts+++ b/packages/template-code-generation/src/templates/index.ts@@ -5,7 +5,7 @@ export interface RemotionExample {code: string;durationInFrames: number;fps: number;- category: "Text" | "Charts" | "Other";+ category: "Text" | "Charts" | "Shapes" | "Animation" | "3D" | "Other";}export const examples: RemotionExample[] = [@@ -86,20 +86,24 @@ export const examples: RemotionExample[] = [const messages = [{ text: "Hey! How are you?", isMe: false, delay: 0 },- { text: "I'm good! Working on Remotion", isMe: true, delay: 30 },- { text: "That's awesome! Show me!", isMe: false, delay: 60 },- { text: "Check this out!", isMe: true, delay: 90 },+ { text: "I'm good! Working on Remotion", isMe: true, delay: 45 },+ { text: "That's awesome! Show me!", isMe: false, delay: 90 },+ { text: "Check this out!", isMe: true, delay: 135 },];+ const visibleMessages = messages.filter((msg) => frame >= msg.delay);+ const messageHeight = 100;+return (<Remotion.AbsoluteFillstyle={{backgroundColor: "#0a0a0a",- padding: 40,- justifyContent: "center",+ padding: 60,+ justifyContent: "flex-end",+ paddingBottom: 80,}}>- <div style={{ maxWidth: 500, margin: "0 auto" }}>+ <div style={{ width: "100%", position: "relative" }}>{messages.map((msg, i) => {const progress = Remotion.spring({frame: frame - msg.delay,@@ -109,26 +113,31 @@ export const examples: RemotionExample[] = [if (frame < msg.delay) return null;+ const messagesAfter = messages.filter((m, idx) => idx > i && frame >= m.delay).length;+ const yOffset = messagesAfter * messageHeight;++ const xOffset = msg.isMe ? (1 - progress) * 100 : (1 - progress) * -100;+return (<divkey={i}style={{display: "flex",justifyContent: msg.isMe ? "flex-end" : "flex-start",- marginBottom: 12,+ marginBottom: 24,opacity: progress,- transform: \`translateY(\${(1 - progress) * 30}px) scale(\${0.8 + progress * 0.2})\`,+ transform: \`translateX(\${xOffset}px) translateY(\${-yOffset}px) scale(\${0.8 + progress * 0.2})\`,}}><divstyle={{backgroundColor: msg.isMe ? "#25D366" : "#2a2a2a",color: "#fff",- padding: "12px 18px",- borderRadius: 18,- fontSize: 24,+ padding: "20px 28px",+ borderRadius: 24,+ fontSize: 42,fontFamily: "system-ui, sans-serif",- maxWidth: 300,+ maxWidth: "70%",}}>{msg.text}@@ -195,6 +204,7 @@ export const examples: RemotionExample[] = [textAlign: "center",opacity: Remotion.interpolate(staggeredProgress, [0, 0.2], [0, 1]),transform: \`translateY(\${(1 - staggeredProgress) * 20}px)\`,+ minWidth: 200,}}><div@@ -203,6 +213,7 @@ export const examples: RemotionExample[] = [fontWeight: "bold",color: metric.color,fontFamily: "system-ui, sans-serif",+ fontVariantNumeric: "tabular-nums",}}>{metric.prefix || ""}{value.toLocaleString()}{metric.suffix || ""}@@ -227,7 +238,7 @@ export const examples: RemotionExample[] = [{id: "histogram",name: "Histogram",- description: "Animated bar chart with data visualization",+ description: "Animated bar chart using @remotion/shapes",category: "Charts",durationInFrames: 120,fps: 30,@@ -244,6 +255,7 @@ export const examples: RemotionExample[] = [];const maxValue = Math.max(...data.map(d => d.value));+ const barWidth = 80;return (<Remotion.AbsoluteFill@@ -273,24 +285,24 @@ export const examples: RemotionExample[] = [config: { damping: 15, stiffness: 100 },});- const height = (item.value / maxValue) * 300 * progress;+ const height = Math.max(1, (item.value / maxValue) * 300 * progress);return (- <div key={i} style={{ textAlign: "center" }}>- <div- style={{- width: 80,- height,- backgroundColor: item.color,- borderRadius: "8px 8px 0 0",- display: "flex",- justifyContent: "center",- alignItems: "flex-start",- paddingTop: 10,- }}- >+ <div key={i} style={{ textAlign: "center", position: "relative" }}>+ <div style={{ position: "relative", height, width: barWidth }}>+ <RemotionShapes.Rect+ width={barWidth}+ height={height}+ fill={item.color}+ cornerRadius={12}+ style={{ filter: \`drop-shadow(0 0 8px \${item.color}50)\` }}+ /><spanstyle={{+ position: "absolute",+ top: 10,+ left: "50%",+ transform: "translateX(-50%)",color: "#fff",fontSize: 18,fontWeight: "bold",@@ -403,6 +415,451 @@ export const examples: RemotionExample[] = [</Remotion.AbsoluteFill>);`,},+ {+ id: "animated-shapes",+ name: "Animated Shapes",+ description: "Bouncing and rotating SVG shapes with spring animations",+ category: "Shapes",+ durationInFrames: 180,+ fps: 30,+ code: `+ const frame = Remotion.useCurrentFrame();+ const { fps, width, height } = Remotion.useVideoConfig();++ const shapes = [+ { type: "circle", color: "#6366f1", delay: 0 },+ { type: "triangle", color: "#10b981", delay: 15 },+ { type: "rect", color: "#f59e0b", delay: 30 },+ { type: "star", color: "#ec4899", delay: 45 },+ ];++ return (+ <Remotion.AbsoluteFill+ style={{+ backgroundColor: "#0f0f0f",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <div+ style={{+ display: "flex",+ gap: 80,+ alignItems: "center",+ }}+ >+ {shapes.map((shape, i) => {+ const entrance = Remotion.spring({+ frame: frame - shape.delay,+ fps,+ config: { damping: 12, stiffness: 200 },+ });++ const rotation = Remotion.interpolate(+ frame,+ [0, 180],+ [0, 360],+ { extrapolateRight: "clamp" }+ );++ const bounce = Math.sin((frame - shape.delay) * 0.1) * 10;++ const scale = entrance;+ const opacity = entrance;++ const shapeProps = {+ fill: shape.color,+ stroke: "#fff",+ strokeWidth: 2,+ };++ return (+ <div+ key={i}+ style={{+ opacity,+ transform: \`scale(\${scale}) translateY(\${bounce}px) rotate(\${shape.type === "star" ? rotation : 0}deg)\`,+ }}+ >+ {shape.type === "circle" && (+ <RemotionShapes.Circle radius={60} {...shapeProps} />+ )}+ {shape.type === "triangle" && (+ <RemotionShapes.Triangle length={120} direction="up" {...shapeProps} />+ )}+ {shape.type === "rect" && (+ <RemotionShapes.Rect width={100} height={100} cornerRadius={12} {...shapeProps} />+ )}+ {shape.type === "star" && (+ <RemotionShapes.Star points={5} innerRadius={40} outerRadius={70} {...shapeProps} />+ )}+ </div>+ );+ })}+ </div>+ </Remotion.AbsoluteFill>+ );`,+ },+ {+ id: "morphing-hexagons",+ name: "Morphing Hexagons",+ description:+ "Mesmerizing hexagon grid with pulsing and color-shifting effects",+ category: "Shapes",+ durationInFrames: 240,+ fps: 30,+ code: `+ const frame = Remotion.useCurrentFrame();+ const { fps, width, height } = Remotion.useVideoConfig();++ const hexSize = 50;+ const cols = 7;+ const rows = 5;++ const hexagons = [];+ for (let row = 0; row < rows; row++) {+ for (let col = 0; col < cols; col++) {+ const offsetX = row % 2 === 0 ? 0 : hexSize * 0.866;+ hexagons.push({+ x: col * hexSize * 1.732 + offsetX,+ y: row * hexSize * 1.5,+ delay: (row + col) * 3,+ });+ }+ }++ const gridWidth = (cols - 1) * hexSize * 1.732 + hexSize;+ const gridHeight = (rows - 1) * hexSize * 1.5 + hexSize * 2;++ return (+ <Remotion.AbsoluteFill+ style={{+ backgroundColor: "#0a0a0f",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <svg+ width={gridWidth + 100}+ height={gridHeight + 100}+ viewBox={\`-50 -50 \${gridWidth + 100} \${gridHeight + 100}\`}+ >+ <defs>+ <filter id="glow">+ <feGaussianBlur stdDeviation="3" result="coloredBlur" />+ <feMerge>+ <feMergeNode in="coloredBlur" />+ <feMergeNode in="SourceGraphic" />+ </feMerge>+ </filter>+ </defs>+ {hexagons.map((hex, i) => {+ const wave = Math.sin((frame - hex.delay) * 0.08);+ const pulse = Remotion.interpolate(wave, [-1, 1], [0.6, 1]);++ const hue = Remotion.interpolate(+ (frame + hex.delay * 2) % 240,+ [0, 120, 240],+ [280, 200, 280]+ );++ const opacity = Remotion.interpolate(wave, [-1, 1], [0.3, 0.9]);++ const scale = Remotion.interpolate(wave, [-1, 1], [0.7, 1]);++ const entrance = Remotion.spring({+ frame: frame - hex.delay,+ fps,+ config: { damping: 15, stiffness: 120 },+ });++ const points = [];+ for (let j = 0; j < 6; j++) {+ const angle = (Math.PI / 3) * j - Math.PI / 6;+ const px = hex.x + hexSize * scale * entrance * Math.cos(angle);+ const py = hex.y + hexSize * scale * entrance * Math.sin(angle);+ points.push(\`\${px},\${py}\`);+ }++ return (+ <polygon+ key={i}+ points={points.join(" ")}+ fill="none"+ stroke={\`hsl(\${hue}, 80%, 60%)\`}+ strokeWidth={2 * pulse}+ opacity={opacity * entrance}+ filter="url(#glow)"+ />+ );+ })}+ </svg>+ </Remotion.AbsoluteFill>+ );`,+ },+ {+ id: "spiral-dots",+ name: "Spiral Dots",+ description: "Hypnotic spiral of dots with rainbow colors and rotation",+ category: "Shapes",+ durationInFrames: 300,+ fps: 30,+ code: `+ const frame = Remotion.useCurrentFrame();+ const { fps } = Remotion.useVideoConfig();++ const numDots = 120;+ const maxRadius = 280;++ const globalRotation = Remotion.interpolate(frame, [0, 300], [0, Math.PI * 4]);++ const entrance = Remotion.spring({+ frame,+ fps,+ config: { damping: 20, stiffness: 80 },+ });++ return (+ <Remotion.AbsoluteFill+ style={{+ backgroundColor: "#050510",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <svg width={600} height={600} viewBox="-300 -300 600 600">+ <defs>+ <filter id="dotGlow">+ <feGaussianBlur stdDeviation="2" result="blur" />+ <feMerge>+ <feMergeNode in="blur" />+ <feMergeNode in="SourceGraphic" />+ </feMerge>+ </filter>+ </defs>+ {Array.from({ length: numDots }).map((_, i) => {+ const t = i / numDots;+ const spiralAngle = t * Math.PI * 8 + globalRotation;+ const radius = t * maxRadius * entrance;++ const x = Math.cos(spiralAngle) * radius;+ const y = Math.sin(spiralAngle) * radius;++ const hue = (t * 360 + frame * 2) % 360;++ const pulse = Math.sin(frame * 0.1 + i * 0.2) * 0.5 + 1;+ const dotSize = (3 + t * 8) * pulse;++ const opacity = Remotion.interpolate(t, [0, 0.1, 1], [0, 1, 0.8]) * entrance;++ return (+ <circle+ key={i}+ cx={x}+ cy={y}+ r={dotSize}+ fill={\`hsl(\${hue}, 90%, 60%)\`}+ opacity={opacity}+ filter="url(#dotGlow)"+ />+ );+ })}+ </svg>+ </Remotion.AbsoluteFill>+ );`,+ },+ {+ id: "lottie-animation",+ name: "Lottie Fish Loader",+ description: "Glowing fish loader animation from LottieFiles",+ category: "Animation",+ durationInFrames: 180,+ fps: 60,+ code: `+ const frame = Remotion.useCurrentFrame();+ const { fps, durationInFrames } = Remotion.useVideoConfig();+ const [animationData, setAnimationData] = React.useState(null);++ React.useEffect(() => {+ fetch("https://assets-v2.lottiefiles.com/a/73ecc94a-4ccb-4018-a710-835b9eaffeaf/OwGeQT8PCr.json")+ .then((res) => res.json())+ .then((data) => setAnimationData(data))+ .catch((err) => console.error("Failed to load Lottie:", err));+ }, []);++ const entrance = Remotion.spring({+ frame,+ fps,+ config: { damping: 15, stiffness: 100 },+ });++ const scale = Remotion.interpolate(entrance, [0, 1], [0.5, 1]);+ const opacity = Remotion.interpolate(entrance, [0, 1], [0, 1]);++ if (!animationData) {+ return (+ <Remotion.AbsoluteFill+ style={{+ backgroundColor: "#000000",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <div style={{ color: "#94a3b8", fontSize: 24, fontFamily: "system-ui" }}>+ Loading animation...+ </div>+ </Remotion.AbsoluteFill>+ );+ }++ return (+ <Remotion.AbsoluteFill+ style={{+ backgroundColor: "#000000",+ justifyContent: "center",+ alignItems: "center",+ }}+ >+ <div+ style={{+ transform: \`scale(\${scale})\`,+ opacity,+ }}+ >+ <Lottie+ animationData={animationData}+ style={{ width: 400, height: 400 }}+ />+ </div>+ <div+ style={{+ position: "absolute",+ bottom: 60,+ color: "#e2e8f0",+ fontSize: 24,+ fontFamily: "system-ui",+ opacity,+ textAlign: "center",+ }}+ >+ <div style={{ fontWeight: "bold", marginBottom: 4 }}>Glowing Fish Loader</div>+ <div style={{ fontSize: 16, color: "#94a3b8" }}>by Mau Ali on LottieFiles</div>+ </div>+ </Remotion.AbsoluteFill>+ );`,+ },+ {+ id: "falling-spheres",+ name: "Golden Bouncing Spheres",+ description: "Glowing golden spheres with physics and orbiting camera",+ category: "3D",+ durationInFrames: 450,+ fps: 60,+ code: `+ const frame = Remotion.useCurrentFrame();+ const { width, height, fps, durationInFrames } = Remotion.useVideoConfig();++ const spheres = [+ { x: -1.5, z: -0.5, delay: 0, radius: 0.4, restitution: 0.75 },+ { x: 0, z: 0, delay: 20, radius: 0.5, restitution: 0.75 },+ { x: 1.5, z: 0.5, delay: 40, radius: 0.35, restitution: 0.75 },+ { x: -0.8, z: 1, delay: 60, radius: 0.45, restitution: 0.75 },+ { x: 0.8, z: -1, delay: 80, radius: 0.38, restitution: 0.75 },+ ];++ const gravity = 12;+ const groundY = -2;++ // Realistic bounce physics simulation+ const simulateBounce = (f, delay, radius, restitution) => {+ const elapsed = Math.max(0, f - delay);+ const t = elapsed / fps;+ const startY = 6;+ const surfaceY = groundY + radius;++ // Calculate time to first impact+ const firstImpactTime = Math.sqrt(2 * (startY - surfaceY) / gravity);++ if (t <= firstImpactTime) {+ const y = startY - 0.5 * gravity * t * t;+ return { y, squash: 1 };+ }++ // After first impact, simulate bounces+ let currentVelocity = gravity * firstImpactTime;+ let bounceStartTime = firstImpactTime;++ for (let bounce = 0; bounce < 20; bounce++) {+ currentVelocity *= restitution;++ if (currentVelocity < 0.5) {+ return { y: surfaceY, squash: 1 };+ }++ const bounceDuration = 2 * currentVelocity / gravity;+ const timeInBounce = t - bounceStartTime;++ if (timeInBounce <= bounceDuration) {+ const y = surfaceY + currentVelocity * timeInBounce - 0.5 * gravity * timeInBounce * timeInBounce;+ const impactProximity = Math.abs(y - surfaceY);+ const squash = impactProximity < 0.08 ? 0.65 + (impactProximity / 0.08) * 0.35 : 1;+ return { y: Math.max(surfaceY, y), squash };+ }++ bounceStartTime += bounceDuration;+ }++ return { y: surfaceY, squash: 1 };+ };++ return (+ <Remotion.AbsoluteFill style={{ backgroundColor: "#000000" }}>+ <ThreeCanvas+ width={width}+ height={height}+ camera={{ position: [0, 3, 8], fov: 40 }}+ >+ {/* Minimal ambient for dark scene */}+ <ambientLight intensity={0.05} />++ {/* Ground plane - dark reflective surface */}+ <mesh rotation={[-Math.PI / 2, 0, 0]} position={[0, groundY, 0]}>+ <planeGeometry args={[20, 20]} />+ <meshStandardMaterial color="#0a0a0a" metalness={0.9} roughness={0.3} />+ </mesh>++ {/* Bouncing golden spheres with point lights */}+ {spheres.map((sphere, i) => {+ const { y, squash } = simulateBounce(frame, sphere.delay, sphere.radius, sphere.restitution);+ const stretch = 1 / squash;++ return (+ <group key={i} position={[sphere.x, y, sphere.z]}>+ {/* Point light emanating from sphere */}+ <pointLight+ color="#ffd700"+ intensity={0.8}+ distance={4}+ decay={2}+ />+ {/* Golden sphere */}+ <mesh scale={[1, squash, stretch]}>+ <sphereGeometry args={[sphere.radius, 32, 32]} />+ <meshStandardMaterial+ color="#ffd700"+ emissive="#cc7a00"+ emissiveIntensity={0.15}+ metalness={0.4}+ roughness={0.6}+ />+ </mesh>+ </group>+ );+ })}+ </ThreeCanvas>+ </Remotion.AbsoluteFill>+ );`,+ },];export function getExampleById(id: string): RemotionExample | undefined {