"use client"; import { useEffect, useRef } from "react"; // The home page's moving parts: the WebGL particle field, smooth scroll, reveals, the custom cursor and // the section dots. The libraries load after the page renders so the copy is readable without them. export function HomeMotion({ sections }: { sections: string[] }) { const canvasRef = useRef(null); useEffect(() => { let cancelled = false; let stop: (() => void) | null = null; (async () => { const root = document.querySelector(".xp"); try { const [{ gsap }, { ScrollTrigger }, { default: Lenis }, { startMotion }] = await Promise.all([ import("gsap"), import("gsap/ScrollTrigger"), import("lenis"), import("./start-motion"), ]); if (cancelled || !root) return; const motion = startMotion(root, { gsap, ScrollTrigger, Lenis }); stop = motion.stop; // The glyph shapes are drawn in Geist Mono, so build the field once fonts are in const [{ createParticleField }] = await Promise.all([ import("./particle-field"), Promise.race([document.fonts?.ready, new Promise((r) => setTimeout(r, 1500))]), ]); if (cancelled || !canvasRef.current) return; const mono = getComputedStyle(document.documentElement).getPropertyValue("--font-mono").trim() || "monospace"; motion.setField(createParticleField(canvasRef.current, mono)); } catch (e) { console.error("Home page motion failed to start:", e); root?.classList.remove("xp-wait"); } })(); return () => { cancelled = true; stop?.(); }; }, []); return ( <>
); }