Production-ready animations, transitions, backgrounds, and scenes for Remotion
TypeScript ai-agentsclaude-codedemo-videomcpmcp-servermodel-context-protocolmotion-designproduct-demoreactremotionshadcnvideo
{
"type": "remotion-element",
"version": 1,
"element": {
"assets": [],
"dependencies": [
{
"name": "@remotion/google-fonts",
"version": null
}
],
"dimensions": null,
"displayName": "Paper Plane",
"initialProps": null,
"slug": "paper-plane",
"sourceCode": "import { loadFont as loadFraunces } from \"@remotion/google-fonts/Fraunces\";\nimport { loadFont as loadManrope } from \"@remotion/google-fonts/Manrope\";\nimport React, { forwardRef, useId, useImperativeHandle, useMemo, useRef, type ComponentProps } from \"react\";\nimport { AbsoluteFill, Easing, Interactive, Sequence, interpolate, useCurrentFrame, useVideoConfig, type InteractiveBaseProps, type InteractiveTransformProps, type InteractivitySchema, type SequenceControls } from \"remotion\";\n\n// Manrope: small labels (500) and the remocn.dev logo (600, the brand asset).\nconst { fontFamily: sans } = loadManrope(\"normal\", {\n weights: [\"500\", \"600\"],\n subsets: [\"latin\"],\n});\nconst { fontFamily: display } = loadFraunces(\"normal\", {\n weights: [\"400\"],\n subsets: [\"latin\"],\n});\n\ninterface PaperPlaneProps {\n /** The three stops the plane flies past. The last one labels the landing. */\n steps?: [string, string, string];\n /** Replaces the remocn.dev logo. The plane lands as a full stop after it. */\n logo?: React.ReactNode;\n /** Shown under the lockup once the plane has landed. */\n url?: string;\n accent?: string;\n /** Playback multiplier. */\n speed?: number;\n theme?: \"light\" | \"dark\";\n}\n\nconst EASE_IO = Easing.bezier(0.65, 0, 0.35, 1);\nconst EASE_OUT = Easing.bezier(0.22, 1, 0.36, 1);\nconst CLAMP = {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n} as const;\n\n/** Frame the plane touches down. */\nconst LAND = 184;\n\nconst PAPER_TEX = `url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' seed='9' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35 0 0 0 0 0.33 0 0 0 0 0.3 0 0 0 0.16 0'/></filter><rect width='240' height='240' filter='url(%23p)'/></svg>\")`;\n\nconst THEMES = {\n light: {\n bg: \"#F5F4F0\",\n fg: \"#121214\",\n muted: \"#8A877F\",\n card: \"#FFFFFF\",\n hair: \"rgba(18,18,20,0.09)\",\n line: \"rgba(18,18,20,0.13)\",\n block: \"rgba(18,18,20,0.05)\",\n trail: \"rgba(18,18,20,0.42)\",\n paper: [255, 255, 255],\n fold: [168, 162, 150],\n edge: \"rgba(18,18,20,0.16)\",\n shadow: \"rgba(60,52,40,0.22)\",\n cardShadow: \"rgba(60,52,40,0.10)\",\n texture: 1,\n grain: 0.035,\n stopInk: \"#1d1c22\",\n },\n dark: {\n bg: \"#0A0A0B\",\n fg: \"#F3F2EF\",\n muted: \"#77767C\",\n card: \"#141416\",\n hair: \"rgba(255,255,255,0.08)\",\n line: \"rgba(255,255,255,0.14)\",\n block: \"rgba(255,255,255,0.06)\",\n trail: \"rgba(255,255,255,0.38)\",\n paper: [246, 245, 242],\n fold: [96, 95, 100],\n edge: \"rgba(255,255,255,0.0)\",\n shadow: \"rgba(0,0,0,0.85)\",\n cardShadow: \"rgba(0,0,0,0.5)\",\n texture: 0,\n grain: 0.06,\n stopInk: \"#F3F2EF\",\n },\n} as const;\n\ntype Palette = (typeof THEMES)[keyof typeof THEMES];\n\n/**\n * gradients.sh ground, screen-fixed, drifting a little against the camera.\n * Light: \"smear\" (#efe8dc · #f2552c #f7b23b #e889b5). Dark: \"rise\" (sunrise\n * from the bottom: #fff1e2 #ff8a3d #a3301a #2a0d0a).\n */\nfunction groundFill(theme: \"light\" | \"dark\", drift: number) {\n if (theme === \"light\") {\n const x = 70 - drift * 18;\n return [\n `radial-gradient(48% 62% at ${x}% 112%, color-mix(in oklab, #f7b23b 54%, transparent) 0%, transparent 72%)`,\n `radial-gradient(42% 58% at ${x + 26}% 104%, color-mix(in oklab, #e889b5 48%, transparent) 0%, transparent 70%)`,\n `radial-gradient(30% 34% at ${x - 6}% 118%, color-mix(in oklab, #f2552c 30%, transparent) 0%, transparent 72%)`,\n `radial-gradient(60% 50% at ${x - 40}% -10%, color-mix(in oklab, #efe8dc 90%, transparent) 0%, transparent 70%)`,\n ].join(\", \");\n }\n const x = 58 - drift * 12;\n return [\n `radial-gradient(58% 40% at ${x}% 112%, #fff1e2 0%, #ff8a3d 22%, color-mix(in oklab, #a3301a 80%, transparent) 46%, color-mix(in oklab, #2a0d0a 70%, transparent) 70%, transparent 92%)`,\n `radial-gradient(110% 46% at ${x + 8}% 104%, color-mix(in oklab, #a3301a 22%, transparent) 0%, transparent 80%)`,\n ].join(\", \");\n}\n\nconst REMOCN_R_PATH =\n \"M 0.01 0.81 C 0.01 1.73, 0.36 2.79, 1.09 4.13 C 4.91 11.04, 13.45 17.16, 21.7 18.9 C 22.94 19.16, 23.18 19.16, 51.39 19.27 C 76.07 19.36, 80.02 19.4, 81.32 19.57 C 89.89 20.69, 96.2 24.68, 99.38 31.01 C 103.19 38.56, 102.53 50.1, 97.91 57.07 C 94.66 61.96, 89.68 64.99, 83.26 66 C 82.81 66.07, 70.18 66.83, 55.2 67.69 C 24.82 69.43, 27.03 69.23, 24.18 70.4 C 19.9 72.15, 14.84 75.7, 10.65 79.89 C 4.86 85.68, 1.3 91.91, 0.25 98.13 C 0.12 98.85, 0.08 103.13, 0.04 116.66 L 0 134.26 9.5 134.26 L 19 134.26 19.05 119.41 C 19.1 103.27, 19.08 103.82, 19.82 101.04 C 21.79 93.65, 27.86 88.75, 36.45 87.63 C 37.23 87.53, 39.41 87.5, 43.57 87.53 C 50.12 87.59, 50.75 87.65, 53.22 88.45 C 56.61 89.56, 59.67 91.86, 62.02 95.07 C 62.52 95.76, 69.35 103.85, 77.2 113.07 C 85.04 122.28, 91.63 130.04, 91.85 130.32 C 92.07 130.59, 92.5 131.34, 92.82 131.97 C 93.52 133.35, 94.11 133.93, 95.06 134.13 C 95.5 134.23, 98.97 134.26, 106.36 134.23 L 117.01 134.19 100.82 113.07 C 91.91 101.45, 84.52 91.78, 84.39 91.57 C 83.36 89.89, 83.66 87.53, 85.09 86 C 85.79 85.25, 86.36 84.94, 88.07 84.38 C 96.18 81.72, 104.15 76.62, 109.97 70.36 C 120.59 58.93, 124.06 44.32, 119.44 30.43 C 114.59 15.81, 101.93 4.02, 87.64 0.83 C 83.93 0.01, 88.09 0.08, 41.85 0.04 L 0.01 0 0.01 0.81 Z\";\n\n// Manrope 600 metrics for the logo lockup (em units).\nconst LOGO_BASELINE = 0.883;\nconst LOGO_EMOCN = 3.147;\nconst LOGO_R = 0.76 * (124.06 / 134.26);\ntype V2 = { x: number; y: number };\ntype V3 = [number, number, number];\n\nfunction Grain({ opacity }: { opacity: number }) {\n const id = `g${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n return (\n <svg\n width=\"100%\"\n height=\"100%\"\n style={{ position: \"absolute\", inset: 0, opacity }}\n aria-hidden\n >\n <filter id={id}>\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.9\"\n numOctaves={2}\n seed={11}\n stitchTiles=\"stitch\"\n />\n <feColorMatrix values=\"0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0\" />\n </filter>\n <rect width=\"100%\" height=\"100%\" filter={`url(#${id})`} />\n </svg>\n );\n}\n\n/* ------------------------------------------------------------------ */\n/* Flight path: centripetal Catmull-Rom, resampled by arc length. */\n/* ------------------------------------------------------------------ */\n\nfunction catmullRom(pts: V2[], per: number): V2[] {\n const ext = [\n { x: 2 * pts[0].x - pts[1].x, y: 2 * pts[0].y - pts[1].y },\n ...pts,\n {\n x: 2 * pts[pts.length - 1].x - pts[pts.length - 2].x,\n y: 2 * pts[pts.length - 1].y - pts[pts.length - 2].y,\n },\n ];\n const out: V2[] = [];\n const knot = (a: V2, b: V2) =>\n Math.hypot(b.x - a.x, b.y - a.y) ** 0.5 || 1e-4;\n for (let i = 0; i < ext.length - 3; i++) {\n const [p0, p1, p2, p3] = [ext[i], ext[i + 1], ext[i + 2], ext[i + 3]];\n const t0 = 0;\n const t1 = t0 + knot(p0, p1);\n const t2 = t1 + knot(p1, p2);\n const t3 = t2 + knot(p2, p3);\n const lerp = (a: V2, b: V2, ta: number, tb: number, t: number) => ({\n x: ((tb - t) / (tb - ta)) * a.x + ((t - ta) / (tb - ta)) * b.x,\n y: ((tb - t) / (tb - ta)) * a.y + ((t - ta) / (tb - ta)) * b.y,\n });\n for (let k = 0; k < per; k++) {\n const t = t1 + ((t2 - t1) * k) / per;\n const a1 = lerp(p0, p1, t0, t1, t);\n const a2 = lerp(p1, p2, t1, t2, t);\n const a3 = lerp(p2, p3, t2, t3, t);\n const b1 = lerp(a1, a2, t0, t2, t);\n const b2 = lerp(a2, a3, t1, t3, t);\n out.push(lerp(b1, b2, t1, t2, t));\n }\n }\n out.push(pts[pts.length - 1]);\n return out;\n}\n\ninterface Track {\n pts: V2[];\n len: number[];\n total: number;\n}\n\nfunction buildTrack(pts: V2[]): Track {\n const dense = catmullRom(pts, 40);\n const len = [0];\n for (let i = 1; i < dense.length; i++) {\n len.push(\n len[i - 1] +\n Math.hypot(dense[i].x - dense[i - 1].x, dense[i].y - dense[i - 1].y),\n );\n }\n return { pts: dense, len, total: len[len.length - 1] };\n}\n\nfunction sampleTrack(tr: Track, s: number) {\n const d = Math.min(tr.total, Math.max(0, s));\n let lo = 0;\n let hi = tr.len.length - 1;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (tr.len[mid] < d) lo = mid;\n else hi = mid;\n }\n const seg = tr.len[hi] - tr.len[lo] || 1;\n const f = (d - tr.len[lo]) / seg;\n const a = tr.pts[lo];\n const b = tr.pts[hi];\n return { x: a.x + (b.x - a.x) * f, y: a.y + (b.y - a.y) * f };\n}\n\nfunction headingAt(tr: Track, s: number) {\n const a = sampleTrack(tr, s - 6);\n const b = sampleTrack(tr, s + 6);\n return Math.atan2(b.y - a.y, b.x - a.x);\n}\n\n/** Glide speed: already airborne at frame 0, eases off into the landing. */\nfunction velocity(t: number) {\n return interpolate(t, [LAND - 36, LAND], [1, 0.14], {\n ...CLAMP,\n easing: Easing.bezier(0.45, 0, 0.55, 1),\n });\n}\n\nfunction buildDistance() {\n const table = [0];\n let sum = 0;\n for (let i = 1; i <= LAND * 2; i++) {\n sum += velocity((i - 0.5) / 2) / 2;\n table.push(sum);\n }\n return table.map((v) => v / sum);\n}\n\n/* ------------------------------------------------------------------ */\n/* The plane: six flat-shaded facets, re-projected every frame. */\n/* ------------------------------------------------------------------ */\n\nconst NOSE: V3 = [1, 0, 0];\nconst TAIL: V3 = [-0.62, 0, 0];\nconst FOLD_L: V3 = [-0.66, -0.2, 0.03];\nconst FOLD_R: V3 = [-0.66, 0.2, 0.03];\nconst TIP_L: V3 = [-0.7, -0.56, 0.14];\nconst TIP_R: V3 = [-0.7, 0.56, 0.14];\nconst KEEL_L: V3 = [-0.6, -0.025, -0.2];\nconst KEEL_R: V3 = [-0.6, 0.025, -0.2];\n\nconst FACETS: V3[][] = [\n [NOSE, TAIL, FOLD_L],\n [NOSE, FOLD_L, TIP_L],\n [NOSE, FOLD_R, TAIL],\n [NOSE, TIP_R, FOLD_R],\n [NOSE, KEEL_L, TAIL],\n [NOSE, TAIL, KEEL_R],\n];\n\nconst LIGHT: V3 = (() => {\n const l: V3 = [-0.45, -0.75, 0.62];\n const m = Math.hypot(...l);\n return [l[0] / m, l[1] / m, l[2] / m];\n})();\n\nfunction cross(a: V3, b: V3): V3 {\n return [\n a[1] * b[2] - a[2] * b[1],\n a[2] * b[0] - a[0] * b[2],\n a[0] * b[1] - a[1] * b[0],\n ];\n}\n\ninterface Facet {\n pts: string;\n shadowPts: string;\n z: number;\n lit: number;\n}\n\nfunction planeFacets(\n heading: number,\n bank: number,\n tilt: number,\n size: number,\n lift: V2,\n): Facet[] {\n const f: V3 = [Math.cos(heading), Math.sin(heading), 0];\n // \"up\" is perpendicular to the path in the screen, tilted toward the viewer\n const up0: V3 = [\n Math.sin(heading) * Math.cos(tilt),\n -Math.cos(heading) * Math.cos(tilt),\n Math.sin(tilt),\n ];\n const side0 = cross(f, up0);\n const up: V3 = [\n up0[0] * Math.cos(bank) + side0[0] * Math.sin(bank),\n up0[1] * Math.cos(bank) + side0[1] * Math.sin(bank),\n up0[2] * Math.cos(bank) + side0[2] * Math.sin(bank),\n ];\n const right = cross(f, up);\n const world = (v: V3): V3 => [\n (v[0] * f[0] + v[1] * right[0] + v[2] * up[0]) * size,\n (v[0] * f[1] + v[1] * right[1] + v[2] * up[1]) * size,\n (v[0] * f[2] + v[1] * right[2] + v[2] * up[2]) * size,\n ];\n return FACETS.map((tri) => {\n const w = tri.map(world);\n const persp = (p: V3) => 1 + p[2] / (size * 9);\n const pts = w\n .map(\n (p) =>\n `${(p[0] * persp(p)).toFixed(2)},${(p[1] * persp(p)).toFixed(2)}`,\n )\n .join(\" \");\n const shadowPts = w\n .map((p) => `${(p[0] + lift.x).toFixed(2)},${(p[1] + lift.y).toFixed(2)}`)\n .join(\" \");\n const e1: V3 = [w[1][0] - w[0][0], w[1][1] - w[0][1], w[1][2] - w[0][2]];\n const e2: V3 = [w[2][0] - w[0][0], w[2][1] - w[0][1], w[2][2] - w[0][2]];\n const n = cross(e1, e2);\n const m = Math.hypot(...n) || 1;\n const dot = Math.abs(\n (n[0] * LIGHT[0] + n[1] * LIGHT[1] + n[2] * LIGHT[2]) / m,\n );\n return {\n pts,\n shadowPts,\n z: (w[0][2] + w[1][2] + w[2][2]) / 3,\n lit: 0.08 + dot ** 1.4 * 0.92,\n };\n }).sort((a, b) => a.z - b.z);\n}\n\nfunction mix(a: readonly number[], b: readonly number[], t: number) {\n return [0, 1, 2].map((i) => a[i] + (b[i] - a[i]) * t);\n}\n\nfunction rgb(c: readonly number[]) {\n return `rgb(${Math.round(c[0])},${Math.round(c[1])},${Math.round(c[2])})`;\n}\n\nfunction hexRgb(hex: string): number[] {\n const h = hex.replace(\"#\", \"\");\n const full =\n h.length === 3\n ? h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n : h;\n const n = Number.parseInt(full.slice(0, 6), 16);\n return [(n >> 16) & 255, (n >> 8) & 255, n & 255];\n}\n\n/* ------------------------------------------------------------------ */\n/* Stops along the way */\n/* ------------------------------------------------------------------ */\n\nfunction StepLabel({\n index,\n text,\n u,\n pal,\n}: {\n index: string;\n text?: string;\n u: number;\n pal: Palette;\n}) {\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n gap: 10 * u,\n fontFamily: sans,\n fontSize: 15 * u,\n fontWeight: 500,\n letterSpacing: \"0.01em\",\n color: pal.muted,\n fontVariantNumeric: \"tabular-nums\",\n }}\n >\n <span>{index}</span>\n <span\n style={{ width: 22 * u, height: Math.max(1, u), background: pal.line }}\n />\n {text && <span style={{ letterSpacing: \"-0.005em\" }}>{text}</span>}\n </div>\n );\n}\n\nfunction BigWord({ text, u, pal }: { text: string; u: number; pal: Palette }) {\n return (\n <div\n style={{\n fontFamily: display,\n fontWeight: 400,\n fontSize: 140 * u,\n lineHeight: 0.95,\n letterSpacing: \"-0.035em\",\n fontVariationSettings: '\"opsz\" 144, \"SOFT\" 50, \"WONK\" 0',\n color: pal.stopInk,\n marginTop: 14 * u,\n whiteSpace: \"nowrap\",\n }}\n >\n {text}\n </div>\n );\n}\n\nfunction WriteCard({\n p,\n t,\n u,\n pal,\n accent,\n}: {\n p: number;\n t: number;\n u: number;\n pal: Palette;\n accent: string;\n}) {\n const widths = [0.86, 0.72, 0.48];\n const lineP = (i: number) =>\n interpolate(p, [i / 3, (i + 1) / 3], [0, 1], { ...CLAMP });\n const active = Math.min(2, Math.floor(p * 3));\n const caretX = widths[active] * lineP(active);\n const blink = p >= 1 ? (Math.floor(t / 15) % 2 === 0 ? 1 : 0.15) : 1;\n return (\n <div\n style={{\n position: \"relative\",\n width: 300 * u,\n height: 176 * u,\n borderRadius: 14 * u,\n background: pal.card,\n boxShadow: `0 0 0 ${Math.max(1, u)}px ${pal.hair}, 0 ${18 * u}px ${40 * u}px -${18 * u}px ${pal.cardShadow}`,\n padding: 26 * u,\n boxSizing: \"border-box\",\n }}\n >\n <div\n style={{\n width: 64 * u,\n height: 8 * u,\n borderRadius: 99,\n background: pal.block,\n marginBottom: 22 * u,\n }}\n />\n {widths.map((w, i) => (\n <div\n key={i}\n style={{\n position: \"relative\",\n height: 10 * u,\n marginBottom: 14 * u,\n }}\n >\n <div\n style={{\n width: `${w * lineP(i) * 100}%`,\n height: \"100%\",\n borderRadius: 99,\n background: pal.line,\n }}\n />\n {i === active && (\n <div\n style={{\n position: \"absolute\",\n left: `calc(${caretX * 100}% + ${4 * u}px)`,\n top: -4 * u,\n width: 2 * u,\n height: 18 * u,\n borderRadius: u,\n background: accent,\n opacity: blink,\n }}\n />\n )}\n </div>\n ))}\n </div>\n );\n}\n\nfunction FilmStrip({\n p,\n u,\n pal,\n accent,\n}: {\n p: number;\n u: number;\n pal: Palette;\n accent: string;\n}) {\n const n = 5;\n return (\n <div style={{ display: \"flex\", flexDirection: \"column\", gap: 14 * u }}>\n <div style={{ display: \"flex\", gap: 10 * u }}>\n {Array.from({ length: n }, (_, i) => {\n const done = interpolate(p, [i / n, (i + 0.8) / n], [0, 1], CLAMP);\n return (\n <div\n key={i}\n style={{\n position: \"relative\",\n width: 78 * u,\n height: 50 * u,\n borderRadius: 8 * u,\n background: pal.card,\n boxShadow: `0 0 0 ${Math.max(1, u)}px ${pal.hair}, 0 ${10 * u}px ${24 * u}px -${12 * u}px ${pal.cardShadow}`,\n overflow: \"hidden\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n background: `linear-gradient(160deg, ${pal.block}, ${pal.line})`,\n clipPath: `inset(0 ${(1 - done) * 100}% 0 0)`,\n }}\n />\n <div\n style={{\n position: \"absolute\",\n left: 9 * u,\n bottom: 9 * u,\n width: 26 * u,\n height: 5 * u,\n borderRadius: 99,\n background: i === 2 ? accent : pal.line,\n opacity: done,\n }}\n />\n </div>\n );\n })}\n </div>\n <div\n style={{\n height: Math.max(1, 1.5 * u),\n background: pal.hair,\n borderRadius: 99,\n position: \"relative\",\n }}\n >\n <div\n style={{\n position: \"absolute\",\n inset: 0,\n right: `${(1 - p) * 100}%`,\n background: pal.fg,\n opacity: 0.55,\n borderRadius: 99,\n }}\n />\n </div>\n </div>\n );\n}\n\n/* ------------------------------------------------------------------ */\n\nfunction PaperPlaneBase({\n steps = [\"Write\", \"Render\", \"Launch\"],\n logo,\n url = \"remocn.dev\",\n accent = \"#3B5BFD\",\n speed = 1,\n theme = \"light\",\n}: PaperPlaneProps) {\n const t = useCurrentFrame() * speed;\n const { width, height } = useVideoConfig();\n const u = height / 720;\n const pal = THEMES[theme];\n const W = width;\n const D = width * 0.92;\n\n // lockup geometry (world space, origin = centre of the first stop)\n const F = 128 * u;\n const dotR = 0.068 * F;\n const lockW = logo ? 4 * F : F * (LOGO_R + 0.04 + LOGO_EMOCN);\n const lockX = 2 * D - (lockW + 0.06 * F + dotR * 2) / 2;\n const lockY = 30 * u;\n const baseY = lockY + 0.36 * F;\n const dotX = lockX + lockW + 0.06 * F + dotR;\n const dotY = baseY - dotR;\n const dot: V2 = { x: dotX, y: dotY };\n\n const track = useMemo(() => {\n const dot: V2 = { x: dotX, y: dotY };\n // the loop sits above-left of the logo, clear of the letters\n const C = { x: 2 * D - 360 * u, y: lockY - 170 * u };\n const R = 88 * u;\n const loop: V2[] = [];\n for (let k = 0; k <= 12; k++) {\n const a = Math.PI / 2 - (k * Math.PI * 2) / 12;\n loop.push({ x: C.x + Math.cos(a) * R, y: C.y + Math.sin(a) * R });\n }\n return buildTrack([\n { x: -0.66 * W, y: 250 * u },\n { x: -0.32 * W, y: 196 * u },\n { x: 0.02 * W, y: 214 * u },\n { x: 0.32 * W, y: 120 * u },\n { x: 0.6 * W, y: -150 * u },\n { x: D - 0.1 * W, y: -252 * u },\n { x: D + 0.17 * W, y: -180 * u },\n { x: D + 0.36 * W, y: 40 * u },\n { x: C.x - 130 * u, y: C.y + R + 8 * u },\n ...loop,\n // skim over the word, drop past its end and hook back into the full stop\n { x: lockX + lockW * 0.4, y: lockY - 150 * u },\n { x: dot.x + 64 * u, y: lockY - 118 * u },\n { x: dot.x + 90 * u, y: dot.y + 2 * u },\n { x: dot.x + 36 * u, y: dot.y + 22 * u },\n dot,\n ]);\n }, [W, D, u, dotX, dotY, lockX, lockY, lockW]);\n const dist = useMemo(buildDistance, []);\n\n const sAt = (time: number) => {\n const x = Math.min(LAND, Math.max(0, time)) * 2;\n const i = Math.floor(x);\n const f = x - i;\n const a = dist[Math.min(i, dist.length - 1)];\n const b = dist[Math.min(i + 1, dist.length - 1)];\n return (a + (b - a) * f) * track.total;\n };\n const s = sAt(t);\n const pos = sampleTrack(track, s);\n const heading = headingAt(track, s);\n\n // bank into the turn, plus a slow rock so the facets keep catching light\n const turn = headingAt(track, s + 30 * u) - headingAt(track, s - 30 * u);\n const wrapped = Math.atan2(Math.sin(turn), Math.cos(turn));\n const bank =\n Math.max(-0.6, Math.min(0.6, wrapped * 0.9)) + Math.sin(t / 13) * 0.22;\n const tilt = 0.95 + Math.sin(t / 21) * 0.08;\n\n // camera: follows the plane with a soft lag, then settles on the lockup\n let lagX = 0;\n let lagY = 0;\n for (let k = 0; k < 6; k++) {\n const p = sampleTrack(track, sAt(t - 6 - k * 3));\n lagX += p.x / 6;\n lagY += p.y / 6;\n }\n const softMax = (a: number, b: number, k: number) =>\n (a + b + Math.sqrt((a - b) ** 2 + k * k)) / 2;\n const settle = interpolate(t, [LAND - 60, LAND + 6], [0, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n const followX = softMax(lagX + 0.08 * W, 0, 180 * u);\n const camX = followX + (2 * D - followX) * settle;\n const camY = lagY * 0.28 * (1 - settle);\n const zoom = 1 + 0.035 * settle;\n\n // landing: the plane folds itself into the accent dot\n const morph = interpolate(t, [LAND - 14, LAND], [0, 1], {\n ...CLAMP,\n easing: Easing.bezier(0.55, 0, 1, 0.45),\n });\n const planeSize = 62 * u * (1 - morph * 0.86);\n const height3d = interpolate(t, [LAND - 40, LAND], [1, 0], {\n ...CLAMP,\n easing: Easing.bezier(0.55, 0, 1, 0.45),\n });\n const lift = { x: 10 * u * height3d + 2 * u, y: 30 * u * height3d + 3 * u };\n const facets = planeFacets(heading, bank, tilt, planeSize, lift);\n const accentRgb = hexRgb(accent);\n const dotIn = interpolate(t, [LAND - 3, LAND + 4], [0, 1], CLAMP);\n const dotPop = interpolate(t, [LAND, LAND + 6, LAND + 16], [1, 1.12, 1], {\n ...CLAMP,\n easing: EASE_IO,\n });\n\n // the dashed trail, oldest part faded\n const trailEnd = Math.max(0, s - planeSize * 0.72);\n const dash = 7 * u;\n const gap = 9 * u;\n const chunks: React.ReactNode[] = [];\n const CH = 140 * u;\n const trailDim = interpolate(t, [LAND - 6, LAND + 30], [1, 0.4], CLAMP);\n for (let c0 = 0; c0 < trailEnd; c0 += CH) {\n const c1 = Math.min(trailEnd, c0 + CH);\n const pts: string[] = [];\n for (let d = c0; d <= c1 + 0.01; d += 6 * u) {\n const p = sampleTrack(track, Math.min(d, c1));\n pts.push(`${p.x.toFixed(1)},${p.y.toFixed(1)}`);\n }\n const behind = trailEnd - c1;\n chunks.push(\n <polyline\n key={c0}\n points={pts.join(\" \")}\n fill=\"none\"\n stroke={pal.trail}\n strokeWidth={1.4 * u}\n strokeLinecap=\"round\"\n strokeDasharray={`${dash} ${gap}`}\n strokeDashoffset={-(c0 % (dash + gap))}\n opacity={interpolate(behind, [0, 1800 * u], [1, 0.3], CLAMP) * trailDim}\n />,\n );\n }\n\n // stop reactions, driven by where the plane is\n const writeP = interpolate(pos.x, [-0.42 * W, 0.42 * W], [0, 1], CLAMP);\n const renderP = interpolate(\n pos.x,\n [D - 0.3 * W, D + 0.36 * W],\n [0, 1],\n CLAMP,\n );\n const enter = (start: number) =>\n interpolate(t, [start, start + 22], [0, 1], { ...CLAMP, easing: EASE_OUT });\n const s1 = enter(-8);\n const s2 = interpolate(camX, [0.35 * D, 0.75 * D], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const s3 = interpolate(camX, [1.3 * D, 1.75 * D], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const wordReveal = interpolate(camX, [1.5 * D, 1.85 * D], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const urlIn = interpolate(t, [LAND + 8, LAND + 28], [0, 1], {\n ...CLAMP,\n easing: EASE_OUT,\n });\n const rise = (p: number) => ({\n opacity: p,\n transform: `translateY(${(1 - p) * 16 * u}px)`,\n });\n\n const shadowBlur = (2 + height3d * 5) * u;\n const svgId = `pp${useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n\n return (\n <AbsoluteFill style={{ background: pal.bg, overflow: \"hidden\" }}>\n {pal.texture > 0 && (\n <AbsoluteFill\n style={{\n backgroundImage: PAPER_TEX,\n backgroundSize: `${240 * u}px ${240 * u}px`,\n backgroundPosition: `${-camX * 0.98}px ${-camY}px`,\n }}\n />\n )}\n <AbsoluteFill\n style={{\n background: `radial-gradient(ellipse 70% 80% at 40% 30%, ${\n theme === \"light\"\n ? \"rgba(255,255,255,0.6)\"\n : \"rgba(255,255,255,0.035)\"\n }, transparent 100%)`,\n }}\n />\n\n <AbsoluteFill\n style={{ backgroundImage: groundFill(theme, camX / (2 * D)) }}\n />\n\n {/* world */}\n <div\n style={{\n position: \"absolute\",\n left: W / 2,\n top: height / 2,\n width: 0,\n height: 0,\n transform: `scale(${zoom}) translate(${-camX}px, ${-camY}px)`,\n }}\n >\n {/* stop 1: write */}\n <div\n style={{\n position: \"absolute\",\n left: -0.36 * W,\n top: -150 * u,\n ...rise(s1),\n }}\n >\n <StepLabel index=\"01\" u={u} pal={pal} />\n <BigWord text={steps[0]} u={u} pal={pal} />\n </div>\n <div\n style={{\n position: \"absolute\",\n left: 0.07 * W,\n top: -110 * u,\n transform: `rotate(-3deg) translateY(${(1 - s1) * 20 * u}px)`,\n opacity: s1,\n }}\n >\n <WriteCard p={writeP} t={t} u={u} pal={pal} accent={accent} />\n </div>\n\n {/* stop 2: render */}\n <div\n style={{\n position: \"absolute\",\n left: D - 0.3 * W,\n top: -150 * u,\n ...rise(s2),\n }}\n >\n <FilmStrip p={renderP} u={u} pal={pal} accent={accent} />\n </div>\n <div\n style={{\n position: \"absolute\",\n left: D - 0.3 * W,\n top: -10 * u,\n ...rise(s2),\n }}\n >\n <StepLabel index=\"02\" u={u} pal={pal} />\n <BigWord text={steps[1]} u={u} pal={pal} />\n </div>\n\n {/* stop 3: launch, the lockup the plane lands in */}\n <div\n style={{\n position: \"absolute\",\n left: lockX,\n width: lockW,\n display: \"flex\",\n justifyContent: \"flex-end\",\n top: baseY - 0.72 * F - 64 * u,\n ...rise(s3),\n }}\n >\n <StepLabel index=\"03\" text={steps[2]} u={u} pal={pal} />\n </div>\n <div\n style={{\n position: \"absolute\",\n left: lockX,\n top: baseY - LOGO_BASELINE * F,\n height: F,\n display: \"flex\",\n alignItems: \"baseline\",\n color: pal.fg,\n fontFamily: sans,\n fontWeight: 600,\n fontSize: F,\n lineHeight: 1,\n letterSpacing: \"-0.025em\",\n }}\n >\n {logo ?? (\n <>\n <svg\n viewBox=\"0 0 124.06 134.26\"\n style={{\n height: \"0.76em\",\n width: \"auto\",\n opacity: s3,\n transform: `translateY(${(1 - s3) * 16 * u}px)`,\n }}\n aria-hidden\n >\n <path fill=\"currentColor\" d={REMOCN_R_PATH} />\n </svg>\n <span\n style={{\n marginLeft: \"0.04em\",\n clipPath: `inset(-20% ${(1 - wordReveal) * 100}% -20% 0)`,\n transform: `translateX(${(1 - wordReveal) * -20 * u}px)`,\n }}\n >\n emocn\n </span>\n </>\n )}\n </div>\n <div\n style={{\n position: \"absolute\",\n left: lockX,\n width: lockW,\n top: baseY + 44 * u,\n textAlign: \"center\",\n fontFamily: sans,\n fontSize: 21 * u,\n fontWeight: 500,\n letterSpacing: \"-0.01em\",\n color: pal.muted,\n ...rise(urlIn),\n }}\n >\n {url}\n </div>\n\n {/* trail + plane */}\n <svg\n style={{\n position: \"absolute\",\n left: 0,\n top: 0,\n overflow: \"visible\",\n }}\n width={1}\n height={1}\n aria-hidden\n >\n <defs>\n <filter id={svgId} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\">\n <feGaussianBlur stdDeviation={shadowBlur} />\n </filter>\n </defs>\n {chunks}\n {morph < 1 && (\n <g transform={`translate(${pos.x} ${pos.y})`}>\n <g filter={`url(#${svgId})`} opacity={1 - morph}>\n {facets.map((fc, i) => (\n <polygon\n key={`s${i}`}\n points={fc.shadowPts}\n fill={pal.shadow}\n opacity={0.22 + (1 - height3d) * 0.3}\n />\n ))}\n </g>\n {facets.map((fc, i) => (\n <polygon\n key={i}\n points={fc.pts}\n fill={rgb(\n mix(mix(pal.fold, pal.paper, fc.lit), accentRgb, morph),\n )}\n stroke={pal.edge}\n strokeWidth={0.6 * u}\n strokeLinejoin=\"round\"\n />\n ))}\n </g>\n )}\n {dotIn > 0 && (\n <circle\n cx={dot.x}\n cy={dot.y}\n r={dotR * dotPop}\n fill={accent}\n opacity={dotIn}\n />\n )}\n </svg>\n </div>\n\n <Grain opacity={pal.grain} />\n </AbsoluteFill>\n );\n}\n\nconst elementSchema = {\n ...Interactive.baseSchema,\n theme: {\n type: \"enum\",\n default: \"light\",\n variants: {\n light: {},\n dark: {},\n },\n description: \"Theme\",\n },\n accent: {\n type: \"color\",\n default: \"#3B5BFD\",\n description: \"Accent\",\n },\n url: {\n type: \"text-content\",\n default: \"remocn.dev\",\n description: \"Url\",\n },\n speed: {\n type: \"number\",\n default: 1,\n min: 0.25,\n max: 4,\n step: 0.25,\n description: \"Speed\",\n hiddenFromList: false,\n },\n ...Interactive.transformSchema,\n} as const satisfies InteractivitySchema;\n\nconst ELEMENT_PROP_KEYS = new Set([\"theme\",\"accent\",\"url\",\"speed\"]);\n\nconst ELEMENT_PROP_DEFAULTS: Record<string, unknown> = {\n theme: \"light\",\n accent: \"#3B5BFD\",\n url: \"remocn.dev\",\n speed: 1,\n};\n\ntype PaperPlaneElementProps = InteractiveBaseProps &\n InteractiveTransformProps &\n ComponentProps<typeof PaperPlaneBase>;\n\nconst PaperPlaneInner = forwardRef<\n HTMLDivElement,\n PaperPlaneElementProps & { readonly controls: SequenceControls | undefined }\n>(({ controls, name, style, ...rest }, ref) => {\n const outlineRef = useRef<HTMLDivElement>(null);\n useImperativeHandle(ref, () => outlineRef.current as HTMLDivElement, []);\n const componentProps: Record<string, unknown> = { ...ELEMENT_PROP_DEFAULTS };\n const sequenceProps: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rest)) {\n if (ELEMENT_PROP_KEYS.has(key)) {\n if (value !== undefined) componentProps[key] = value;\n } else {\n sequenceProps[key] = value;\n }\n }\n return (\n <Sequence\n layout=\"none\"\n {...sequenceProps}\n controls={controls}\n name={name ?? \"<PaperPlane>\"}\n outlineRef={outlineRef}\n >\n <div\n ref={outlineRef}\n style={{\n position: \"relative\",\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n ...style,\n }}\n >\n <PaperPlaneBase\n {...(componentProps as unknown as ComponentProps<typeof PaperPlaneBase>)}\n />\n </div>\n </Sequence>\n );\n});\n\nexport const PaperPlane = Interactive.withSchema({\n Component: PaperPlaneInner,\n componentName: \"<PaperPlane>\",\n componentIdentity: null,\n schema: elementSchema,\n supportsEffects: false,\n});\n",
"durationInFrames": 212,
"installationMode": "component-owned-sequence"
},
"durationInFrames": 212
}