Files
substrata/scripts
CatoandClaude Opus 5.5 177f286e4f feat(atlas): the world view is a globe (#120)
* feat(atlas): the world view is a globe

George (2026-09-26): 'instead of an ugly map with randomly different
colored countries, we can have an actual globe.'

- Orthographic globe on Canvas 2D with d3-geo (already the map stack):
  lit sphere, atmosphere, limb shade, crisp borders drawn as one mesh.
  Drag with inertia, wheel/pinch zoom, keyboard turn/zoom/open; a click
  turns the country to face the reader. Idle turn only with nothing
  picked, never under prefers-reduced-motion. Drawn only when moving.
- Lazy: next/dynamic, no SSR; the canvas box is held so nothing shifts.
- Facing a country uses its mainland (largest pieces to 75% of area) and
  spherical centroid/distance, so Russia, the US and Fiji (antimeridian)
  and France (Guiana) frame right; flights take the short great circle.
- Colour only for a quantity: the default view and presence-only
  resources (uranium, quartz, neon, boron) are plain land with a 'no
  quantity to shade' note; withheld stays hatched; accent for selection.
- Antarctica drawn as unlisted land (a globe needs a south pole).
- Split by job: globe-geo, -motion, -pick, -paint, -loop, -input.
- Tests (mutation-checked): focus/zoom for ru/us/fj/fr/no, date-line
  flight, drag, coast, picking incl. far side, share bins, neutral
  layers, hatched withheld.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* perf(atlas): the globe paints only what moves and what faces you

- While a finger is down or the globe is turning, paint a coarse copy of
  the world (every third arc vertex, thinned in the topology so borders
  stay shared); the frame after it stops is full detail.
- Cull every country and border line whose cap is beyond the horizon
  (half the world at rest, most of it zoomed in); tested so nothing with
  a vertex on screen is ever culled.
- Atmosphere, lit sphere and limb shade do not turn with the Earth:
  render them once per disc and blit, instead of three full-disc
  gradients a frame. precision(0): 50m needs no adaptive resampling.
- Drop d3-zoom/-selection/-transition (the flat map's), and guard
  setPointerCapture for untrusted pointers.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* perf(atlas): paint the globe from unit vectors, not d3's stream

d3's projection stream spends several sin/cos per vertex per frame
(rotate, clip, project). Every vertex is now a unit vector packed once
at load, and a frame is three dot products per vertex against the view's
basis — the same orthographic projection (tested against d3), ~35x less
geometry work per frame. Vertices behind the globe are pulled onto the
limb for fills; lines break there. Picking stays on d3.

Also: a country is framed at 60% of the disc, not 72%, so it keeps its
neighbours in view.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 01:14:48 -07:00
..