{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"reel-wall","type":"registry:component","title":"Reel Wall","description":"Curved video wall for Remotion. A ring of vertical clips turns past in the dark: it eases in from rest on twos, then keeps turning at an even speed.","dependencies":["remotion"],"docs":"Needs a Remotion project. If a frame renders black, the component is drawing on a transparent layer: put a background behind it, e.g. <AbsoluteFill style={{ background: \"#faf9f6\" }}><Component /></AbsoluteFill>.","files":[{"path":"components/kuchi/reel-wall.tsx","type":"registry:component","target":"components/kuchi/reel-wall.tsx","content":"/*! Portions Copyright (c) 2026 Sri Nath (snap-cn). MIT License. See THIRD_PARTY_LICENSES. */\n\"use client\";\r\n\r\nimport type { CSSProperties } from \"react\";\r\nimport {\r\n  Easing,\r\n  Freeze,\r\n  getRemotionEnvironment,\r\n  interpolate,\r\n  OffthreadVideo,\r\n  staticFile,\r\n  useCurrentFrame,\r\n  useVideoConfig,\r\n} from \"remotion\";\r\n\r\n/**\r\n * A \"reel wall\": a curved wall of vertical clips turns past in the dark. It\r\n * eases in from rest, then keeps turning at an even speed for as long as the\r\n * composition runs.\r\n *\r\n * Replicated from a 24fps reference, fitted on its own frames. The wall is a\r\n * CSS 3D ring: every card is a plane `RING_R` in front of the ring's axis,\r\n * viewed through a `perspective` of `PERSPECTIVE` (median edge error 0.64px\r\n * against the recording). Lengths are reference pixels (`REF_W` wide) and scale\r\n * with the frame; the timeline is in 24fps frames.\r\n *\r\n * The wall moves \"on twos\": it holds every picture for two frames, like the\r\n * reference, which is part of its look. The opening fade runs on every frame.\r\n *\r\n * Like `announce-title` it paints a cinematic world rather than a surface — a\r\n * dark stage under clips — so it takes no `theme`/`mode`; its colours are props.\r\n */\r\n\r\nexport interface ReelWallProps {\r\n  /**\r\n   * Clips for the wall, left to right; they repeat around the ring. Video URLs\r\n   * play muted. Absolute URLs or paths under `public/`.\r\n   */\r\n  videos?: string[];\r\n  /** The page behind the wall. */\r\n  background?: string;\r\n  /** A card before its clip has a frame to show. */\r\n  cardColor?: string;\r\n  speed?: number;\r\n  className?: string;\r\n}\r\n\r\n/** Creator-style clips, 12s each, compressed. Absolute, because a root-relative\r\n *  default becomes `staticFile()` in a render and 404s in the project this file\r\n *  was just copied into. Ceiling: a clip shorter than the composition stops on\r\n *  its last frame — pass clips at least as long as the scene runs. */\r\nconst DEFAULT_VIDEOS = [1, 2, 3, 4, 5, 6].map(\r\n  (n) => `https://kuchi-media.kalarislabs.com/components/clips/clip-${n}.mp4`,\r\n);\r\n\r\n// ─── Geometry, in reference pixels ────────────────────────────────────────────\r\nexport const REF_W = 716;\r\nconst REF_H = 398;\r\n/** The card, its ring and the lens. */\r\nexport const CARD = { w: 201.92, h: 349.09 } as const;\r\nexport const RING_R = 1837.36;\r\nexport const PERSPECTIVE = 446.54;\r\n/** Angle between neighbouring cards, radians. */\r\nexport const PITCH = 0.1328;\r\n/** Perspective origin, from the top-left of the frame. */\r\nexport const ORIGIN = { x: 356.76, y: 197.99 } as const;\r\n\r\n// ─── Timeline (24fps frames) ──────────────────────────────────────────────────\r\n/** Where the fitted ease hands over to an even turn, in 12fps steps. */\r\nconst CRUISE_AT = 52;\r\n/** The ease-in, radians over 12fps steps: a cubic-bezier fitted to 53 measured\r\n *  steps (0.31px RMS). Valid up to `CRUISE_AT`; past it the bezier overshoots. */\r\nconst easeIn = (step: number) =>\r\n  interpolate(step, [0, 67.8], [-0.0497, -0.2656], {\r\n    extrapolateLeft: \"clamp\",\r\n    extrapolateRight: \"clamp\",\r\n    easing: Easing.bezier(0.344, 0.0049, 0.7833, 1.3384),\r\n  });\r\n/** Turn per step once cruising: the ease's own speed where it hands over. */\r\nconst CRUISE = easeIn(CRUISE_AT) - easeIn(CRUISE_AT - 1);\r\n\r\n/** The wall's turn at a 12fps step: the fitted ease-in, then an even turn. */\r\nexport const wallTurn = (step: number) =>\r\n  step <= CRUISE_AT\r\n    ? easeIn(step)\r\n    : easeIn(CRUISE_AT) + (step - CRUISE_AT) * CRUISE;\r\n\r\n/** The opening fade-in: a black veil that clears in 9 frames. */\r\nexport const veil = (f: number) =>\r\n  f >= 9 ? 0 : 0.142 * (1 - Math.max(f, 0) / 9) ** 3.7;\r\n\r\n/** Hold every picture for two frames: 0, 1, 1, 3, 3, 5, … */\r\nconst onTwos = (f: number) => (f < 1 ? 0 : Math.floor((f - 1) / 2) * 2 + 1);\r\n\r\nfunction resolveSrc(src: string): string {\r\n  const isLocal = src.startsWith(\"/\") && !src.startsWith(\"//\");\r\n  if (!isLocal || getRemotionEnvironment().isPlayer) return src;\r\n  // A value that already came out of staticFile() carries the static base.\r\n  const base = staticFile(\"_\").slice(0, -2);\r\n  if (base && src.startsWith(`${base}/`)) return src;\r\n  try {\r\n    return staticFile(src.replace(/^\\/+/, \"\"));\r\n  } catch {\r\n    return src;\r\n  }\r\n}\r\n\r\nconst cover: CSSProperties = {\r\n  width: \"100%\",\r\n  height: \"100%\",\r\n  // Preflight's `img { max-width: 100% }` collapses a box sized by its parent.\r\n  maxWidth: \"none\",\r\n  objectFit: \"cover\",\r\n  display: \"block\",\r\n};\r\n\r\nexport function ReelWall({\r\n  videos = DEFAULT_VIDEOS,\r\n  background = \"#0e0e0e\",\r\n  cardColor = \"#1a1a1a\",\r\n  speed = 1,\r\n  className,\r\n}: ReelWallProps) {\r\n  const { width, height, fps } = useVideoConfig();\r\n  const frame = useCurrentFrame() * ((speed * 24) / fps);\r\n  const u = width / REF_W;\r\n  // The reference frame is a hair wider than 16:9; centre it vertically.\r\n  const dy = (height - REF_H * u) / 2;\r\n\r\n  const held = onTwos(Math.floor(frame));\r\n  const theta = wallTurn((held + 1) / 2);\r\n  // Only the cards within reach of the lens; the rest are behind the frame.\r\n  const first = Math.floor((-theta - 0.6) / PITCH);\r\n  const n = videos.length;\r\n\r\n  return (\r\n    <div\r\n      className={className}\r\n      style={{\r\n        position: \"absolute\",\r\n        inset: 0,\r\n        overflow: \"hidden\",\r\n        backgroundColor: background,\r\n      }}\r\n    >\r\n      <div\r\n        style={{\r\n          position: \"absolute\",\r\n          left: 0,\r\n          top: dy,\r\n          width,\r\n          height: REF_H * u,\r\n          perspective: PERSPECTIVE * u,\r\n          perspectiveOrigin: `${ORIGIN.x * u}px ${ORIGIN.y * u}px`,\r\n        }}\r\n      >\r\n        {/* The page: lit from the middle, falling to black at the sides. */}\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            background:\r\n              \"radial-gradient(ellipse 60% 75% at 50% 50%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.45) 70%, rgba(0,0,0,0.92) 100%)\",\r\n          }}\r\n        />\r\n        {Array.from({ length: 10 }, (_, i) => first + i).map((k) => {\r\n          const src = n ? videos[((k % n) + n) % n] : undefined;\r\n          return (\r\n            <div\r\n              key={k}\r\n              style={{\r\n                position: \"absolute\",\r\n                left: (ORIGIN.x - CARD.w / 2) * u,\r\n                top: (ORIGIN.y - CARD.h / 2) * u,\r\n                width: CARD.w * u,\r\n                height: CARD.h * u,\r\n                overflow: \"hidden\",\r\n                backgroundColor: cardColor,\r\n                transform: `translateZ(${-RING_R * u}px) rotateY(${theta + k * PITCH}rad) translateZ(${RING_R * u}px)`,\r\n              }}\r\n            >\r\n              {src && (\r\n                // The clips hold on twos with the wall.\r\n                <Freeze frame={held}>\r\n                  <OffthreadVideo src={resolveSrc(src)} muted style={cover} />\r\n                </Freeze>\r\n              )}\r\n            </div>\r\n          );\r\n        })}\r\n      </div>\r\n\r\n      {veil(frame) > 0 && (\r\n        <div\r\n          style={{\r\n            position: \"absolute\",\r\n            inset: 0,\r\n            background: \"#000\",\r\n            opacity: veil(frame),\r\n          }}\r\n        />\r\n      )}\r\n    </div>\r\n  );\r\n}\r\n"}]}