import { useEffect, useRef } from "react"; // Identical ellipses, evenly spaced tilts (45° apart) const ORBITALS = [ { icon: "📷", label: "Image", tilt: 0, rx: 130, ry: 45, duration: 10, phase: 0 }, { icon: "🎤", label: "Audio", tilt: 45, rx: 130, ry: 45, duration: 13, phase: 0 }, { icon: "💬", label: "Text", tilt: 90, rx: 130, ry: 45, duration: 11, phase: 0 }, { icon: "🎬", label: "Video", tilt: 135, rx: 130, ry: 45, duration: 15, phase: 0 }, ]; // Precompute tilt radians const ORBITAL_DATA = ORBITALS.map((o) => ({ ...o, tiltRad: (o.tilt * Math.PI) / 180, })); export default function OrbitalHero() { const itemRefs = useRef([]); useEffect(() => { let frame; const start = performance.now(); function tick() { const time = (performance.now() - start) / 1000; for (let i = 0; i < ORBITAL_DATA.length; i++) { const o = ORBITAL_DATA[i]; const el = itemRefs.current[i]; if (!el) continue; const angle = ((time / o.duration) * Math.PI * 2) + o.phase; const ex = o.rx * Math.cos(angle); const ey = o.ry * Math.sin(angle); const x = ex * Math.cos(o.tiltRad) - ey * Math.sin(o.tiltRad); const y = ex * Math.sin(o.tiltRad) + ey * Math.cos(o.tiltRad); const z = Math.sin(angle); el.style.left = `calc(50% + ${x}px)`; el.style.top = `calc(50% + ${y}px)`; el.style.zIndex = z > 0 ? 20 : 1; el.style.opacity = 0.5 + z * 0.5; } frame = requestAnimationFrame(tick); } frame = requestAnimationFrame(tick); return () => cancelAnimationFrame(frame); }, []); return (