DM-01 · Blog · REV 2026.11
Building a 3D Globe Hero with React Three Fiber
2026-07-02 · 1 min read
How I built the interactive globe on this site: instanced particles, great-circle arcs, and keeping it at 60 fps on mobile.
The goal
A hero section that reacts to scroll and mouse movement without tanking performance — the globe you see on this site's landing page.
Instancing everything
Rendering 2,500 individual meshes would mean 2,500 draw calls. Instead, the dot field uses a single Points geometry, and the arcs share materials. The whole scene renders in a handful of draw calls.
const positions = useMemo(() => {
const arr = new Float32Array(COUNT * 3);
for (let i = 0; i < COUNT; i++) {
// Fibonacci sphere distribution avoids pole clustering
const y = 1 - (i / (COUNT - 1)) * 2;
const r = Math.sqrt(1 - y * y);
const theta = GOLDEN_ANGLE * i;
arr.set([Math.cos(theta) * r, y, Math.sin(theta) * r], i * 3);
}
return arr;
}, []);Scroll-linked rotation
Framer Motion's useScroll produces a normalized progress value stored in a ref. The globe's useFrame loop lerps rotation toward that target each frame — never setting rotation directly from the scroll handler. That single change removes all the jitter you get when scroll events and the render loop fight each other.
// Hero.tsx — scroll progress drives opacity; Globe reads scrollProgressRef in useFrame
const { scrollYProgress } = useScroll({ target: sectionRef, offset: ["start start", "end start"] });
const contentOpacity = useTransform(scrollYProgress, [0, 0.45, 0.7], [1, 0.6, 0]);Respecting reduced motion
If prefers-reduced-motion is set, the globe renders a single static frame. Accessibility settings are a contract, not a suggestion.
#three.js #react-three-fiber #webgl #performance