Globe
Also called interactive globe, 3D globe, dotted globe, or rotating earth
A 3D Earth drawn in dots that turns on its own and can be dragged, with markers and arcs for cities, offices, or network routes.
import { useEffect, useRef } from 'react';
import { useInView, useReducedMotion } from 'motion/react';
type Place = { lat: number; lng: number };
const RAD = Math.PI / 180;
const TILT = 20 * RAD; // north pole tipped toward the viewer
const SPIN = 12 * RAD; // per second
// `land`: evenly spaced points sampled from a world mask. `cities`: markers.
export function Globe({ land, cities }: { land: Place[]; cities: Place[] }) {
const ref = useRef<HTMLCanvasElement>(null);
const inView = useInView(ref);
const reduceMotion = useReducedMotion();
const view = useRef({ yaw: 0, dragX: null as number | null });
useEffect(() => {
if (!inView) return; // no frames while off screen
const canvas = ref.current!;
const ctx = canvas.getContext('2d')!;
const size = canvas.clientWidth;
const dpr = window.devicePixelRatio || 1;
canvas.width = canvas.height = size * dpr;
ctx.scale(dpr, dpr);
const r = size / 2 - 6;
const c = size / 2;
// Orthographic projection: spin, then tilt. depth <= 0 is the far side.
const draw = (places: Place[], radius: number) => {
for (const { lat, lng } of places) {
const [phi, lambda] = [lat * RAD, lng * RAD + view.current.yaw];
const x = Math.cos(phi) * Math.sin(lambda);
const y = Math.sin(phi);
const z = Math.cos(phi) * Math.cos(lambda);
const depth = y * Math.sin(TILT) + z * Math.cos(TILT);
if (depth <= 0) continue;
ctx.globalAlpha = 0.15 + depth * 0.85; // fade toward the rim
ctx.beginPath();
const up = y * Math.cos(TILT) - z * Math.sin(TILT);
ctx.arc(c + x * r, c - up * r, radius, 0, 2 * Math.PI);
ctx.fill();
}
};
let frame = 0;
let last = performance.now();
const tick = (now: number) => {
if (!reduceMotion && view.current.dragX === null)
view.current.yaw += (SPIN * (now - last)) / 1000;
last = now;
ctx.clearRect(0, 0, size, size);
ctx.fillStyle = getComputedStyle(canvas).color;
draw(land, 1);
ctx.fillStyle = '#3b82f6';
draw(cities, 3.5);
frame = requestAnimationFrame(tick);
};
frame = requestAnimationFrame(tick);
return () => cancelAnimationFrame(frame);
}, [land, cities, inView, reduceMotion]);
return (
<canvas
ref={ref}
role='img'
aria-label='Globe marking our data center cities'
onPointerDown={(e) => {
e.currentTarget.setPointerCapture(e.pointerId);
view.current.dragX = e.clientX;
}}
onPointerMove={(e) => {
if (view.current.dragX === null) return;
view.current.yaw += (e.clientX - view.current.dragX) * 0.006;
view.current.dragX = e.clientX;
}}
onPointerUp={() => (view.current.dragX = null)}
className='aspect-square w-full max-w-sm cursor-grab touch-none text-neutral-500 active:cursor-grabbing'
/>
);
}Add an interactive globe to the "Global edge network" section: a 360px canvas that draws land as about 3,000 evenly spaced 2px dots with an orthographic projection, tilted 20° toward the north and turning 12° per second. Fade dots toward the rim, mark 10 data center cities with blue dots and a ping ring, and connect pairs with great-circle arcs that lift off the surface, each sending a bright pulse every few seconds. Let people drag to spin it with momentum, scale the canvas for devicePixelRatio, pause the loop off screen, and stop the automatic spin when prefers-reduced-motion is set.
Paste into Layerwise or any AI coding tool.
Globe explained
An interactive globe draws the Earth as a sphere of dots that slowly turns. Markers and glowing arcs show places and the links between them: offices, customers, data centers, or the path a request takes. People can usually grab it and spin it.
You can build one without a 3D library. Start from a list of land points, sampled from a world map mask on an even grid, and project each with an orthographic projection: rotate it by the current spin and tilt, keep the points that face the viewer (z > 0), and draw them on a <canvas>. Fading dots toward the rim sells the roundness. WebGL libraries such as cobe and globe.gl help when you need tens of thousands of points or real lighting.
Arcs between two cities follow the great circle between them and lift off the surface in the middle, so they stay visible as they cross the rim. Keep the spin slow, about 10 to 20° per second, pause the loop off screen, and stop the automatic spin under prefers-reduced-motion. Screen readers see a canvas as one image, so give it role="img" and a label, or list the locations in text.
Often confused with
- Dotted map
- A dotted map lays the world out flat and stays still. A globe wraps the dots around a sphere that turns.
Related terms
All termsIcon cloud
A 3D sphere of icons that turns on its own and can be dragged, with front icons large and solid and back icons small and faded.
Animated beam
Curved lines that connect icons, with a glowing pulse traveling along each one to show data moving from apps into a hub and on to a user.
Drag gesture
Moving an element by pressing on it and sliding the pointer or finger, usually within set bounds and with a glide after release.
Momentum
The glide an element keeps after a throw or flick, slowing down gradually like an object sliding across a smooth table.
Build it with Layerwise
Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.