import React, {useId} from 'react'; import { Easing, Interactive, interpolate, useCurrentFrame, useVideoConfig, } from 'remotion'; import {ChapterTag} from '../components/ChapterTag'; import {RiseText} from '../components/RiseText'; import {colors, mono, sans, serif} from '../theme'; const clamp = {extrapolateLeft: 'clamp', extrapolateRight: 'clamp'} as const; const GRID = 12; const PITCH = (32 * Math.PI) / 180; const CENTER = {x: 1250, y: 596}; const MIN_H = 0.5; const MAX_H = 3.1; type Rgb = readonly [number, number, number]; const hexToRgb = (hex: string): Rgb => [ parseInt(hex.slice(1, 3), 16), parseInt(hex.slice(3, 5), 16), parseInt(hex.slice(5, 7), 16), ]; const mix = (a: Rgb, b: Rgb, t: number): Rgb => [ a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t, ]; const toCss = (c: Rgb) => `rgb(${Math.round(c[0])}, ${Math.round(c[1])}, ${Math.round(c[2])})`; const CLAY = hexToRgb('#DDD5C6'); const ACCENT = hexToRgb(colors.accent); const INK = hexToRgb(colors.ink); // Fixed world-space light: faces keep their shade while the camera orbits. const SHADE = {top: 1, front: 0.8, side: 0.6}; const Cubes: React.FC = () => { const frame = useCurrentFrame(); const {fps} = useVideoConfig(); const shadowId = `shadow-${useId().replace(/:/g, '')}`; const t = frame / fps; const yaw = interpolate(frame, [0, 210], [24, 62], clamp) * (Math.PI / 180); const scale = interpolate(frame, [0, 210], [56, 63], clamp); const cosY = Math.cos(yaw); const sinY = Math.sin(yaw); const cosP = Math.cos(PITCH); const sinP = Math.sin(PITCH); const project = (x: number, y: number, z: number) => { const cx = x * cosY - z * sinY; const cz = x * sinY + z * cosY; return { x: CENTER.x + cx * scale, y: CENTER.y + (cz * sinP - y * cosP) * scale, }; }; const poly = (points: [number, number, number][]) => points .map(([x, y, z]) => { const p = project(x, y, z); return `${p.x.toFixed(1)},${p.y.toFixed(1)}`; }) .join(' '); const half = GRID / 2; const cubes = []; for (let i = 0; i < GRID; i++) { for (let j = 0; j < GRID; j++) { const x0 = i - half; const z0 = j - half; const cx = x0 + 0.5; const cz = z0 + 0.5; const distance = Math.hypot(cx, cz); const rise = interpolate( frame, [2 + distance * 2.6, 30 + distance * 2.6], [0, 1], { ...clamp, easing: Easing.bezier(0.16, 1, 0.3, 1), }, ); // One wave per bar, phased so the center crests on each downbeat. const wave = 0.5 + 0.5 * Math.sin(Math.PI * 2 * 0.5 * t - distance * 0.78 + 0.55); const height = Math.max(0.02, (MIN_H + (MAX_H - MIN_H) * wave) * rise); const heat = interpolate(wave, [0.55, 1], [0, 1], clamp) ** 1.6; const base = mix(CLAY, ACCENT, heat * rise); cubes.push({ key: `${i}-${j}`, depth: cx * sinY + cz * cosY, x0, z0, height, base, }); } } cubes.sort((a, b) => a.depth - b.depth); return ( ); }; const Spec: React.FC<{ readonly label: string; readonly value: string; readonly start: number; }> = ({label, value, start}) => { const frame = useCurrentFrame(); const enter = interpolate(frame, [start, start + 16], [0, 1], { ...clamp, easing: Easing.bezier(0.16, 1, 0.3, 1), }); return (