diff --git a/client/src/components/AtlasGlobe/BadgeMedal.tsx b/client/src/components/AtlasGlobe/BadgeMedal.tsx
index f036b28ec..a419b8c9a 100644
--- a/client/src/components/AtlasGlobe/BadgeMedal.tsx
+++ b/client/src/components/AtlasGlobe/BadgeMedal.tsx
@@ -32,8 +32,8 @@ import { TIERS } from './badgeTiers';
const HEX = '46,3 89,27 89,77 46,101 3,77 3,27';
const INNER = '46,12 80,31 80,73 46,92 12,73 12,31';
-const INK = '#e0f2fe'; // theme-lint-disable: medal line art
-const ACCENT = '#7dd3fc'; // theme-lint-disable: medal line art
+const INK = '#f4f4f5'; // theme-lint-disable: medal line art
+const ACCENT = '#d4d4d8'; // theme-lint-disable: medal line art
/**
* One drawn symbol per motif, from the same icon set as the rest of TREK so every
@@ -131,9 +131,9 @@ export default function BadgeMedal({
-
-
-
+
+
+
diff --git a/client/src/components/AtlasGlobe/GlobeEngine.ts b/client/src/components/AtlasGlobe/GlobeEngine.ts
index ae6afb6e7..20204f883 100644
--- a/client/src/components/AtlasGlobe/GlobeEngine.ts
+++ b/client/src/components/AtlasGlobe/GlobeEngine.ts
@@ -10,6 +10,7 @@ import type { Topology } from 'topojson-specification';
import { GlobeRenderer, MAX_FEATURES, type ArcLayer, type GlobeTheme } from './GlobeRenderer';
import {
frameParams,
+ latLimits,
MAX_ZOOM,
MIN_ZOOM,
morphOf,
@@ -486,7 +487,7 @@ export class GlobeEngine {
const dx = p.x - prev.x;
const dy = p.y - prev.y;
this.cam.lon -= dx * kx;
- this.cam.lat = Math.max(-80, Math.min(80, this.cam.lat + dy * k));
+ this.cam.lat = this.clampLat(this.cam.lat + dy * k);
this.vx = dx * kx * 0.85 + this.vx * 0.15;
this.vy = dy * k * 0.85 + this.vy * 0.15;
this.kick();
@@ -564,7 +565,7 @@ export class GlobeEngine {
for (let i = 0; i < 2; i++) {
const f = frameParams(this.cam, this.vp);
const k = 1 / (f.scale * RAD);
- this.cam.lat = Math.max(-80, Math.min(80, a.lat + (a.y - f.originY) * k));
+ this.cam.lat = this.clampLat(a.lat + (a.y - f.originY) * k);
this.cam.lon = a.lon - ((a.x - f.originX) * k) / xSqueeze(f);
}
}
@@ -642,6 +643,12 @@ export class GlobeEngine {
if (!this.raf && this.alive) this.raf = requestAnimationFrame(this.tick);
}
+ /** A latitude for the view's centre, held where the map's edges stay off screen. */
+ private clampLat(lat: number): number {
+ const [south, north] = latLimits(this.cam.zoom, this.vp);
+ return Math.max(south, Math.min(north, lat));
+ }
+
private tick = (): void => {
this.raf = 0;
if (!this.alive) return;
@@ -665,7 +672,7 @@ export class GlobeEngine {
}
if (!this.dragging && !this.fly && (Math.abs(this.vx) > 1e-3 || Math.abs(this.vy) > 1e-3)) {
this.cam.lon -= this.vx;
- this.cam.lat = Math.max(-80, Math.min(80, this.cam.lat + this.vy));
+ this.cam.lat = this.clampLat(this.cam.lat + this.vy);
this.vx *= 0.93;
this.vy *= 0.93;
moving = true;
@@ -683,6 +690,8 @@ export class GlobeEngine {
this.zoomAnchor = null;
}
this.cam.lon = ((this.cam.lon + 540) % 360) - 180;
+ // Zooming into the flat map narrows how far north and south it may look.
+ this.cam.lat = this.clampLat(this.cam.lat);
this.frame = frameParams(this.cam, this.vp);
const want = this.wantedWorld();
diff --git a/client/src/components/AtlasGlobe/GlobeRenderer.ts b/client/src/components/AtlasGlobe/GlobeRenderer.ts
index 7dce07b48..e1f06d278 100644
--- a/client/src/components/AtlasGlobe/GlobeRenderer.ts
+++ b/client/src/components/AtlasGlobe/GlobeRenderer.ts
@@ -404,7 +404,6 @@ export class GlobeRenderer {
gl.uniform1f(this.skyP.u.u_radius, f.scale * s.dpr);
gl.uniform1f(this.skyP.u.u_t, f.t);
gl.uniform1f(this.skyP.u.u_time, s.time);
- gl.uniform2f(this.skyP.u.u_drift, f.centerLon, f.centerLat);
gl.uniform3fv(this.skyP.u.u_space0, th.space0);
gl.uniform3fv(this.skyP.u.u_space1, th.space1);
gl.uniform3fv(this.skyP.u.u_glow, th.glow);
diff --git a/client/src/components/AtlasGlobe/GlobeSky.tsx b/client/src/components/AtlasGlobe/GlobeSky.tsx
index e1be424df..5f3ba75a6 100644
--- a/client/src/components/AtlasGlobe/GlobeSky.tsx
+++ b/client/src/components/AtlasGlobe/GlobeSky.tsx
@@ -1,4 +1,4 @@
-import { forwardRef, useImperativeHandle, useMemo, useRef } from 'react';
+import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
import type { GlobeEngine } from './GlobeEngine';
import { moonPhase, smoothstep } from './globeMath';
@@ -8,16 +8,55 @@ export interface GlobeSkyHandle {
shootingStar: () => void;
}
+/** How long the sky waits between two shooting stars of its own, in ms. */
+const STAR_EVERY_MIN = 40_000;
+const STAR_EVERY_SPREAD = 60_000;
+
/**
- * What hangs in the sky around the globe: the moon in its real phase, and the
- * shooting star that crosses when a country is marked. The moon is placed per
- * frame without React rendering.
+ * What hangs in the sky around the globe: the moon in its real phase, and shooting
+ * stars, now and then on their own and one whenever a country is marked. The
+ * moon is placed per frame without React rendering.
*/
const GlobeSky = forwardRef(function GlobeSky({ dark }, ref) {
const moonRef = useRef(null);
const starHost = useRef(null);
const phase = useMemo(() => moonPhase(new Date()), []);
+ const shootingStar = useCallback(() => {
+ const host = starHost.current;
+ if (!host || !dark || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
+ const el = document.createElement('div');
+ el.className = 'ag-shooting-star';
+ el.style.left = `${host.clientWidth * (0.55 + Math.random() * 0.35)}px`;
+ el.style.top = `${host.clientHeight * (0.05 + Math.random() * 0.25)}px`;
+ host.appendChild(el);
+ el.animate(
+ [
+ { transform: 'rotate(-28deg) translateX(0) scaleX(0.2)', opacity: 0 },
+ { transform: 'rotate(-28deg) translateX(-90px) scaleX(1)', opacity: 1, offset: 0.25 },
+ { transform: 'rotate(-28deg) translateX(-420px) scaleX(0.6)', opacity: 0 },
+ ],
+ { duration: 1100, easing: 'cubic-bezier(.2,.6,.3,1)' }
+ ).onfinish = () => el.remove();
+ }, [dark]);
+
+ // Now and then a shooting star of its own, while the page is in view.
+ useEffect(() => {
+ if (!dark) return;
+ let timer = 0;
+ const next = () => {
+ timer = window.setTimeout(
+ () => {
+ if (document.visibilityState === 'visible') shootingStar();
+ next();
+ },
+ STAR_EVERY_MIN + Math.random() * STAR_EVERY_SPREAD
+ );
+ };
+ next();
+ return () => window.clearTimeout(timer);
+ }, [dark, shootingStar]);
+
useImperativeHandle(
ref,
() => ({
@@ -36,25 +75,9 @@ const GlobeSky = forwardRef(function GlobeSky
moonRef.current.style.transform = `translate3d(${x.toFixed(1)}px, ${y.toFixed(1)}px, 0) translate(-50%, -50%)`;
moonRef.current.style.opacity = String(fade * 0.95);
},
- shootingStar() {
- const host = starHost.current;
- if (!host || !dark || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
- const el = document.createElement('div');
- el.className = 'ag-shooting-star';
- el.style.left = `${host.clientWidth * (0.55 + Math.random() * 0.35)}px`;
- el.style.top = `${host.clientHeight * (0.05 + Math.random() * 0.25)}px`;
- host.appendChild(el);
- el.animate(
- [
- { transform: 'rotate(-28deg) translateX(0) scaleX(0.2)', opacity: 0 },
- { transform: 'rotate(-28deg) translateX(-90px) scaleX(1)', opacity: 1, offset: 0.25 },
- { transform: 'rotate(-28deg) translateX(-420px) scaleX(0.6)', opacity: 0 },
- ],
- { duration: 1100, easing: 'cubic-bezier(.2,.6,.3,1)' }
- ).onfinish = () => el.remove();
- },
+ shootingStar,
}),
- [dark]
+ [dark, shootingStar]
);
// The lit part of the moon: the disc with an ellipse carving the shadow.
@@ -70,19 +93,19 @@ const GlobeSky = forwardRef(function GlobeSky
ref={moonRef}
aria-hidden="true"
className="pointer-events-none absolute start-0 top-0"
- style={{ filter: 'drop-shadow(0 0 14px rgb(220 230 255 / 0.35))' }}
+ style={{ filter: 'drop-shadow(0 0 14px rgb(235 235 237 / 0.35))' }}
>
>
diff --git a/client/src/components/AtlasGlobe/atlasGlobe.css b/client/src/components/AtlasGlobe/atlasGlobe.css
index 680e48951..5186c160b 100644
--- a/client/src/components/AtlasGlobe/atlasGlobe.css
+++ b/client/src/components/AtlasGlobe/atlasGlobe.css
@@ -6,34 +6,34 @@
*/
.atlas-globe {
--ag-glass: linear-gradient(180deg, rgb(255 255 255 / 0.11), rgb(255 255 255 / 0.04));
- --ag-glass-solid: rgb(16 20 34 / 0.9);
+ --ag-glass-solid: rgb(22 22 24 / 0.9);
--ag-edge: rgb(255 255 255 / 0.13);
--ag-edge-hi: rgb(255 255 255 / 0.3);
--ag-hi: inset 0 1px 0 rgb(255 255 255 / 0.22);
--ag-shadow: 0 12px 32px rgb(0 0 0 / 0.38);
- --ag-ink: rgb(238 242 255);
- --ag-muted: rgb(150 160 182);
- --ag-faint: rgb(100 110 132);
- --ag-accent: rgb(125 211 252);
- --ag-mint: rgb(94 234 212);
- --ag-label: rgb(226 232 245 / 0.92);
+ --ag-ink: rgb(244 244 245);
+ --ag-muted: rgb(161 161 170);
+ --ag-faint: rgb(113 113 122);
+ --ag-accent: rgb(244 244 245);
+ --ag-mint: rgb(161 161 170);
+ --ag-label: rgb(235 235 237 / 0.92);
--ag-label-shadow: 0 1px 2px rgb(0 0 0 / 0.85), 0 0 10px rgb(0 0 0 / 0.55);
position: relative;
color: var(--ag-ink);
- background: rgb(3 5 12);
+ background: rgb(4 4 5);
}
html:not(.dark) .ag-btn {
- background: rgb(15 23 42 / 0.04);
+ background: rgb(24 24 27 / 0.04);
}
html:not(.dark) .ag-btn[data-on='1'] {
- background: rgb(37 99 235 / 0.12);
- border-color: rgb(37 99 235 / 0.4);
+ background: rgb(24 24 27 / 0.12);
+ border-color: rgb(24 24 27 / 0.4);
}
html:not(.dark) .ag-bar {
- background: rgb(15 23 42 / 0.08);
+ background: rgb(24 24 27 / 0.08);
}
.ag-glass {
@@ -96,8 +96,8 @@ html:not(.dark) .ag-bar {
}
.ag-btn[data-on='1'] {
- background: rgb(125 211 252 / 0.18);
- border-color: rgb(125 211 252 / 0.5);
+ background: rgb(255 255 255 / 0.16);
+ border-color: rgb(255 255 255 / 0.45);
}
.ag-bar {
@@ -112,7 +112,7 @@ html:not(.dark) .ag-bar {
height: 100%;
border-radius: 99px;
background: linear-gradient(90deg, var(--ag-accent), var(--ag-mint));
- box-shadow: 0 0 12px rgb(125 211 252 / 0.55);
+ box-shadow: 0 0 12px rgb(255 255 255 / 0.35);
transition: width 0.9s cubic-bezier(0.2, 0.9, 0.2, 1);
}
@@ -159,10 +159,10 @@ html:not(.dark) .ag-bar {
radial-gradient(60% 45% at var(--mx, 30%) var(--my, 20%), rgb(255 255 255 / 0.5), rgb(255 255 255 / 0) 60%),
linear-gradient(
115deg,
- rgb(125 211 252 / 0) 30%,
- rgb(167 139 250 / 0.22) 45%,
- rgb(94 234 212 / 0.2) 55%,
- rgb(125 211 252 / 0) 70%
+ rgb(255 255 255 / 0) 30%,
+ rgb(255 255 255 / 0.18) 45%,
+ rgb(255 255 255 / 0.14) 55%,
+ rgb(255 255 255 / 0) 70%
);
mix-blend-mode: screen;
pointer-events: none;
@@ -179,7 +179,7 @@ html:not(.dark) .ag-bar {
border-radius: 99px;
transform-origin: right center;
background: linear-gradient(90deg, rgb(255 255 255 / 0), rgb(255 255 255 / 0.95));
- box-shadow: 0 0 10px rgb(186 230 253 / 0.8);
+ box-shadow: 0 0 10px rgb(255 255 255 / 0.7);
}
@media (prefers-reduced-motion: reduce) {
@@ -294,7 +294,7 @@ html:not(.dark) .ag-bar {
height: 220px;
margin-top: -36px;
border-radius: 999px;
- background: radial-gradient(circle, rgb(125 211 252 / 0.35) 0%, rgb(167 139 250 / 0.18) 40%, transparent 70%);
+ background: radial-gradient(circle, rgb(255 255 255 / 0.3) 0%, rgb(255 255 255 / 0.12) 40%, transparent 70%);
animation: ag-unlock-pulse 1.6s ease-out infinite;
pointer-events: none;
}
diff --git a/client/src/components/AtlasGlobe/globeLabels.ts b/client/src/components/AtlasGlobe/globeLabels.ts
index 63b20f6c4..b52fefba3 100644
--- a/client/src/components/AtlasGlobe/globeLabels.ts
+++ b/client/src/components/AtlasGlobe/globeLabels.ts
@@ -52,7 +52,11 @@ export function placeLabels(
const regionsOn = zoom >= (width < NARROW_WIDTH ? REGION_LABEL_ZOOM_PHONE : REGION_LABEL_ZOOM_WIDE);
const named = regionsOn ? regionCandidates(engine, cands) : new Set();
countryCandidates(engine, cands, named, labelFor, labelRegionsOf);
- cands.sort((a, b) => b.rank - a.rank);
+ // A name on screen keeps its place against a near equal one, so two labels
+ // that overlap while the globe turns do not take turns frame by frame.
+ const shown = new Set(pool.filter((l) => l.key && l.el.style.opacity !== '0').map((l) => l.key));
+ const held = (c: Candidate) => (shown.has(c.key) ? (c.region ? c.rank + 3e5 : c.rank * 1.5) : c.rank);
+ cands.sort((a, b) => held(b) - held(a));
let regionCount = 0;
const placed: Array<[number, number, number, number]> = [];
@@ -69,26 +73,32 @@ export function placeLabels(
if (c.region) regionCount++;
}
- while (pool.length < chosen.length) {
- const el = document.createElement('div');
- el.className = 'atlas-globe-label text-caption';
- host.appendChild(el);
- pool.push({ el, key: '' });
+ // Every name keeps its own element while it shows; an element only takes a
+ // new name once its old one is gone, so no label jumps to another's place.
+ const wanted = new Set(chosen.map((c) => c.key));
+ const byKey = new Map(pool.filter((l) => wanted.has(l.key)).map((l) => [l.key, l]));
+ const free = pool.filter((l) => !wanted.has(l.key));
+ for (const l of free) {
+ if (l.el.style.opacity !== '0') l.el.style.opacity = '0';
}
- pool.forEach((l, i) => {
- const c = chosen[i];
- if (!c) {
- if (l.el.style.opacity !== '0') l.el.style.opacity = '0';
- return;
- }
- if (l.key !== c.key) {
+ for (const c of chosen) {
+ let l = byKey.get(c.key);
+ if (!l) {
+ l = free.pop();
+ if (!l) {
+ const el = document.createElement('div');
+ el.className = 'atlas-globe-label text-caption';
+ host.appendChild(el);
+ l = { el, key: '' };
+ pool.push(l);
+ }
l.key = c.key;
l.el.textContent = c.text;
l.el.dataset.region = c.region ? '1' : '';
}
l.el.style.transform = `translate3d(${c.x.toFixed(1)}px, ${c.y.toFixed(1)}px, 0) translate(-50%, -50%)`;
l.el.style.opacity = String(Math.max(0, Math.min(1, c.fade)));
- });
+ }
}
/**
diff --git a/client/src/components/AtlasGlobe/globeMath.test.ts b/client/src/components/AtlasGlobe/globeMath.test.ts
index 48d635e0b..f6f411949 100644
--- a/client/src/components/AtlasGlobe/globeMath.test.ts
+++ b/client/src/components/AtlasGlobe/globeMath.test.ts
@@ -4,6 +4,7 @@ import {
arcSegments,
frameParams,
interpolateGreatCircle,
+ latLimits,
moonPhase,
MORPH_END,
MORPH_START,
@@ -108,4 +109,33 @@ describe('globeMath', () => {
const fresh = moonPhase(new Date(Date.UTC(2026, 0, 18, 19)));
expect(fresh.lit).toBeLessThan(0.05);
});
+
+ describe('latLimits', () => {
+ it('lets the globe tilt to 80 degrees either way', () => {
+ expect(latLimits(1, VP)).toEqual([-80, 80]);
+ });
+
+ it('keeps the cut edges of the flat map off the screen', () => {
+ const zoom = MORPH_END * 2;
+ const [south, north] = latLimits(zoom, VP);
+ const scale = VP.baseRadius * zoom;
+ // At the northern limit the top of the screen shows exactly the pole, and no further.
+ expect(north + VP.flatY / scale / (Math.PI / 180)).toBeCloseTo(90);
+ expect(south - (VP.height - VP.flatY) / scale / (Math.PI / 180)).toBeCloseTo(-90);
+ });
+
+ it('holds a flat map lower than the screen in the middle', () => {
+ const [south, north] = latLimits(MORPH_END, { ...VP, height: 4000, flatY: 2000 });
+ expect(south).toBeCloseTo(0);
+ expect(north).toBeCloseTo(0);
+ });
+
+ it('narrows the range as the globe unrolls', () => {
+ const half = (MORPH_START + MORPH_END) / 2;
+ const [, mid] = latLimits(half, VP);
+ const [, flat] = latLimits(MORPH_END, VP);
+ expect(mid).toBeLessThan(80);
+ expect(mid).toBeGreaterThan(flat);
+ });
+ });
});
diff --git a/client/src/components/AtlasGlobe/globeMath.ts b/client/src/components/AtlasGlobe/globeMath.ts
index 72450144d..77c195f6d 100644
--- a/client/src/components/AtlasGlobe/globeMath.ts
+++ b/client/src/components/AtlasGlobe/globeMath.ts
@@ -73,6 +73,22 @@ export function frameParams(cam: GlobeCamera, vp: GlobeViewport): FrameParams {
};
}
+/**
+ * How far south and north the view's centre may go, in degrees. On the globe a
+ * fixed 80; as it unrolls into the flat map, as far as keeps the map's cut
+ * edges at the poles off the screen (the middle when the map is lower than the
+ * screen, where nothing hides them).
+ */
+export function latLimits(zoom: number, vp: GlobeViewport): [number, number] {
+ const t = morphOf(zoom);
+ if (t <= 0) return [-80, 80];
+ const scale = vp.baseRadius * zoom;
+ let north = 90 - vp.flatY / scale / RAD;
+ let south = -90 + (vp.height - vp.flatY) / scale / RAD;
+ if (south > north) north = south = (north + south) / 2;
+ return [-80 + (south + 80) * t, 80 + (north - 80) * t];
+}
+
export interface ScreenPoint {
x: number;
y: number;
diff --git a/client/src/components/AtlasGlobe/globeShaders.ts b/client/src/components/AtlasGlobe/globeShaders.ts
index baab85e96..1b55769e6 100644
--- a/client/src/components/AtlasGlobe/globeShaders.ts
+++ b/client/src/components/AtlasGlobe/globeShaders.ts
@@ -3,6 +3,15 @@
* globeMath.ts; a change to one belongs in the other.
*/
+/**
+ * The flat map has edges at the poles, where the sphere was cut open. While the
+ * globe unrolls, land, sea and lines fade into the sky towards them, so the map
+ * ends in a haze instead of a hard rim. Needs u_t.
+ */
+const POLAR = /* glsl */ `
+float polarFade(float lat) { return 1.0 - u_t * smoothstep(1.36, 1.5708, abs(lat)); }
+`;
+
const PROJECT = /* glsl */ `
uniform vec2 u_center; // centre lon, lat in radians
uniform float u_t; // 0 globe .. 1 flat map
@@ -89,6 +98,7 @@ uniform int u_inkId;
uniform vec2 u_inkLL;
uniform float u_inkR;
uniform float u_dpr;
+uniform float u_scale; // device px per radian, as in PROJECT
uniform float u_t;
uniform float u_dimBase;
uniform float u_regionFade;
@@ -99,7 +109,7 @@ uniform vec4 u_hoverTint; // rgb + strength; selection uses 1.8x the strength
out vec4 outColor;
vec4 fetch(sampler2D tex, int id) { return texelFetch(tex, ivec2(id % 256, id / 256), 0); }
-
+${POLAR}
void main() {
if (v_vis < 0.0) discard;
float edge = smoothstep(0.0, 0.004, v_vis);
@@ -112,8 +122,8 @@ void main() {
vec3 col = mix(u_oceanDeep, u_ocean, pow(v_shade, 0.9));
col *= mix(1.0 - u_night * 0.7, 1.0, day);
// A faint glint where the sun stands over the sea.
- col += vec3(0.35, 0.45, 0.6) * pow(max(0.0, sunDot), 40.0) * 0.25 * (1.0 - u_t) * v_shade;
- outColor = vec4(col, edge);
+ col += vec3(0.45) * pow(max(0.0, sunDot), 40.0) * 0.25 * (1.0 - u_t) * v_shade;
+ outColor = vec4(col, edge * polarFade(v_ll.y));
return;
}
vec4 st = fetch(u_status, v_fid);
@@ -131,7 +141,13 @@ void main() {
vec3 base = u_land * (u_mode == 2 ? 1.0 : u_dimBase);
vec3 col = mix(base, st.rgb, a);
if (fx.r > 0.5) {
- float h = step(mod(gl_FragCoord.x + gl_FragCoord.y, 7.0 * u_dpr), 1.6 * u_dpr);
+ // The stripes are slices through the globe itself, so they stay on the land
+ // while it turns; their spacing steps with the zoom to stay about 7 px.
+ vec3 p3 = vec3(cos(v_ll.y) * cos(v_ll.x), cos(v_ll.y) * sin(v_ll.x), sin(v_ll.y));
+ float per = exp2(floor(log2(7.0 * u_dpr / u_scale)));
+ float sl = dot(p3, vec3(0.6, 0.6, 0.53)) / per;
+ float w = max(fwidth(sl), 1e-4);
+ float h = 1.0 - smoothstep(0.115 - w * 0.5, 0.115 + w * 0.5, abs(fract(sl) - 0.115));
col = mix(col, st.rgb, h * 0.9 * reveal);
a = max(a, h * 0.9 * reveal);
}
@@ -140,7 +156,7 @@ void main() {
col *= light;
// Night darkens the land; what you marked keeps most of its colour, like lights on.
col *= mix(nightMul, 1.0, a * 0.75);
- float alpha = edge;
+ float alpha = edge * polarFade(v_ll.y);
if (u_mode == 2) alpha *= u_layerAlpha * max(a, (v_fid == u_hover || v_fid == u_selected) ? 0.25 : 0.0);
outColor = vec4(col, alpha);
}
@@ -176,6 +192,7 @@ out float v_vis;
out float v_across;
out float v_s;
out float v_shade;
+out float v_lat;
vec2 lifted(vec4 p, float h) {
vec2 d = p.xy - u_origin;
vec2 globe = u_origin + d * (1.0 + h);
@@ -199,6 +216,7 @@ void main() {
v_across = a_corner.y * (u_width * 0.5 + 1.0);
v_s = mix(a_s.x, a_s.y, a_corner.x);
v_shade = mix(pa.w, pb.w, a_corner.x);
+ v_lat = mix(a_a.y, a_b.y, a_corner.x);
gl_Position = toClip(s);
}
`;
@@ -209,11 +227,14 @@ in float v_vis;
in float v_across;
in float v_s;
in float v_shade;
+in float v_lat;
uniform vec4 u_color;
uniform float u_width;
+uniform float u_t;
uniform float u_progress; // draws the line up to this share (arcs drawing in)
uniform float u_glow;
out vec4 outColor;
+${POLAR}
void main() {
if (v_vis < 0.0 || v_s > u_progress) discard;
float d = abs(v_across);
@@ -221,7 +242,7 @@ void main() {
float a = core;
if (u_glow > 0.0) a = max(core, exp(-d * d / (u_width * u_width * 1.2)) * u_glow);
float limb = smoothstep(0.0, 0.03, v_vis);
- outColor = vec4(u_color.rgb, u_color.a * a * limb * mix(0.55, 1.0, v_shade));
+ outColor = vec4(u_color.rgb, u_color.a * a * limb * mix(0.55, 1.0, v_shade) * polarFade(v_lat));
}
`;
@@ -244,7 +265,6 @@ uniform vec2 u_globe; // device px of the globe centre
uniform float u_radius; // device px
uniform float u_t;
uniform float u_time;
-uniform vec2 u_drift; // parallax from the camera, radians
uniform vec3 u_space0;
uniform vec3 u_space1;
uniform vec3 u_glow;
@@ -253,6 +273,104 @@ out vec4 outColor;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
+// Three constellations from their stars' real places (a gnomonic view around
+// each figure's middle, north up): the Big Dipper, Orion and Cassiopeia. Each
+// star is x, y in units of the view's height and its magnitude.
+const vec3 CST[20] = vec3[20](
+ vec3(0.1807, 0.0977, 1.8),
+ vec3(0.21, 0.0111, 2.4),
+ vec3(0.0945, -0.0566, 2.4),
+ vec3(0.0403, -0.0038, 3.3),
+ vec3(-0.0494, -0.0169, 1.8),
+ vec3(-0.1232, -0.0213, 2.2),
+ vec3(-0.21, -0.0977, 1.9),
+ vec3(-0.0874, 0.1263, 0.5),
+ vec3(0.0415, 0.1075, 1.6),
+ vec3(-0.0255, -0.0354, 1.8),
+ vec3(-0.0061, -0.0226, 1.7),
+ vec3(0.0121, -0.0072, 2.2),
+ vec3(-0.0557, -0.17, 2.1),
+ vec3(0.0874, -0.1445, 0.1),
+ vec3(-0.0015, 0.17, 3.4),
+ vec3(0.13, -0.0137, 2.3),
+ vec3(0.0514, -0.0792, 2.2),
+ vec3(0.0035, 0.0053, 2.2),
+ vec3(-0.0711, -0.0018, 2.7),
+ vec3(-0.13, 0.0792, 3.4)
+);
+// Their colour: warm for the cool giants (Betelgeuse, Dubhe, Schedar), blue white for the hot ones.
+const vec3 CST_TINT[20] = vec3[20](
+ vec3(1.0, 0.9, 0.78),
+ vec3(0.94, 0.96, 1.0),
+ vec3(0.94, 0.96, 1.0),
+ vec3(0.95, 0.97, 1.0),
+ vec3(0.95, 0.97, 1.0),
+ vec3(0.95, 0.97, 1.0),
+ vec3(0.9, 0.94, 1.0),
+ vec3(1.0, 0.78, 0.6),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.86, 0.92, 1.0),
+ vec3(0.92, 0.95, 1.0),
+ vec3(1.0, 0.97, 0.9),
+ vec3(1.0, 0.88, 0.74),
+ vec3(0.9, 0.94, 1.0),
+ vec3(0.96, 0.97, 1.0),
+ vec3(0.9, 0.94, 1.0)
+);
+const ivec2 CSL[19] = ivec2[19](
+ ivec2(0, 1), ivec2(1, 2), ivec2(2, 3), ivec2(3, 0), ivec2(3, 4), ivec2(4, 5),
+ ivec2(5, 6), ivec2(7, 14), ivec2(14, 8), ivec2(7, 9), ivec2(8, 11), ivec2(9, 10),
+ ivec2(10, 11), ivec2(9, 12), ivec2(11, 13), ivec2(15, 16), ivec2(16, 17), ivec2(17, 18),
+ ivec2(18, 19)
+);
+
+/** Where a constellation's star stands on the screen, in device px. */
+vec2 cstAt(int i) {
+ float h = u_viewport.y;
+ float w = u_viewport.x / h;
+ // px runs downwards from the top, the figures are drawn upwards.
+ vec2 at = i < 7 ? vec2(w - 0.36, 0.2) : i < 15 ? vec2(0.24, 0.74) : vec2(0.2, 0.2);
+ return (at + vec2(CST[i].x, -CST[i].y)) * h;
+}
+
+/** The share of a hairline between two stars at p, with a gap around each star. */
+float cstLine(vec2 p, vec2 a, vec2 b, float gap, float width) {
+ vec2 ba = b - a;
+ float len = length(ba);
+ float h = dot(p - a, ba) / (len * len);
+ float g = gap / len;
+ if (h < g || h > 1.0 - g) return 0.0;
+ float d = length(p - a - ba * h);
+ // The line thins out towards its ends, so it reads as drawn, not as a wire.
+ float ends = smoothstep(g, g + 0.12, h) * smoothstep(1.0 - g, 1.0 - g - 0.12, h);
+ return (1.0 - smoothstep(width * 0.5, width, d)) * ends;
+}
+
+/** The figures: hairlines first, then their stars, sized and tinted by brightness, each with a soft halo. */
+vec3 constellations(vec2 px) {
+ float unit = max(1.0, u_viewport.y / 1000.0);
+ float line = 0.0;
+ for (int i = 0; i < 19; i++) {
+ line = max(line, cstLine(px, cstAt(CSL[i].x), cstAt(CSL[i].y), 6.0 * unit, 1.1 * unit));
+ }
+ vec3 col = vec3(0.86, 0.88, 0.92) * line * 0.11;
+ for (int i = 0; i < 20; i++) {
+ float d = length(px - cstAt(i));
+ // Magnitude 0 is the brightest here, 3.5 the faintest that still shows.
+ float bright = clamp(1.0 - CST[i].z / 4.2, 0.18, 1.0);
+ float r = mix(0.7, 2.1, bright) * unit;
+ float tw = 0.86 + 0.14 * sin(u_time * (0.7 + float(i) * 0.13) + float(i) * 1.7);
+ float core = 1.0 - smoothstep(r * 0.4, r, d);
+ float halo = exp(-d / (r * 2.2)) * 0.35 * bright;
+ col += CST_TINT[i] * (core * bright + halo) * tw;
+ }
+ return col;
+}
+
float stars(vec2 px, float cell, float density, float size) {
vec2 g = floor(px / cell);
vec2 f = fract(px / cell);
@@ -270,14 +388,16 @@ void main() {
float r = length(px - u_globe);
vec3 col = mix(u_space1, u_space0, smoothstep(0.0, max(u_viewport.x, u_viewport.y) * 0.8, r));
float sky = (1.0 - u_t * 0.9) * u_dark;
- // Milky way: a soft band across the sky, drifting with the camera.
- vec2 q = px / u_viewport.y + u_drift * vec2(0.08, 0.05);
+ // Milky way: a soft band across the sky. The stars are endlessly far away, so
+ // they stand still while the Earth turns in front of them.
+ vec2 q = px / u_viewport.y;
float band = exp(-pow((q.y - 0.35 - 0.45 * q.x + 0.25) * 3.2, 2.0));
float dust = hash(floor(px * 0.5)) * 0.5 + 0.5;
- col += vec3(0.20, 0.24, 0.42) * band * 0.10 * sky * dust;
- vec2 sp = px + u_drift * vec2(60.0, 40.0) * u_viewport.y / 900.0;
+ col += vec3(0.27, 0.27, 0.28) * band * 0.10 * sky * dust;
+ vec2 sp = px;
float s = stars(sp, 38.0, 0.20, 1.6) + stars(sp * 1.7 + 13.0, 31.0, 0.12, 1.1) * 0.7 + band * stars(sp * 2.3 + 5.0, 17.0, 0.35, 0.9) * 0.8;
- col += vec3(0.85, 0.9, 1.0) * s * sky;
+ col += vec3(0.93, 0.93, 0.94) * s * sky;
+ col += constellations(px) * sky;
// Atmosphere: a glow hugging the globe, gone once the map lies flat.
float atm = (1.0 - smoothstep(0.0, 0.7, u_t));
float outside = smoothstep(u_radius * 0.985, u_radius * 1.0, r);
diff --git a/client/src/components/AtlasGlobe/globeTheme.ts b/client/src/components/AtlasGlobe/globeTheme.ts
index d8c642ef4..496d37859 100644
--- a/client/src/components/AtlasGlobe/globeTheme.ts
+++ b/client/src/components/AtlasGlobe/globeTheme.ts
@@ -33,17 +33,17 @@ export function globeTheme(dark: boolean): GlobeTheme {
const accent = hexToRgb(readCssColor('--accent', dark ? '#e4e4e7' : '#111827'));
if (dark) {
return {
- land: [0.15, 0.18, 0.27],
- ocean: [0.07, 0.11, 0.22],
- oceanDeep: [0.025, 0.04, 0.09],
- space0: [0.008, 0.012, 0.03],
- space1: [0.04, 0.06, 0.13],
- glow: [0.49, 0.78, 0.99],
- border: [0.03, 0.04, 0.09, 0.9],
- coast: [0.55, 0.75, 1.0, 0.16],
- regionBorder: [0.9, 0.95, 1.0, 0.32],
+ land: [0.19, 0.19, 0.2],
+ ocean: [0.085, 0.085, 0.09],
+ oceanDeep: [0.03, 0.03, 0.032],
+ space0: [0.006, 0.006, 0.007],
+ space1: [0.035, 0.035, 0.038],
+ glow: [0.18, 0.18, 0.185],
+ border: [0.05, 0.05, 0.055, 0.9],
+ coast: [0.85, 0.85, 0.87, 0.14],
+ regionBorder: [0.95, 0.95, 0.95, 0.3],
selection: [1, 1, 1, 0.95],
- arc: [0.88, 0.95, 1.0, 0.95],
+ arc: [0.95, 0.95, 0.95, 0.95],
dark: true,
};
}
diff --git a/client/src/pages/atlas/useAtlasGlobe.ts b/client/src/pages/atlas/useAtlasGlobe.ts
index eff134ddd..3c3b97ec0 100644
--- a/client/src/pages/atlas/useAtlasGlobe.ts
+++ b/client/src/pages/atlas/useAtlasGlobe.ts
@@ -359,7 +359,10 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
// running out from its centre and a shooting star.
const visitedBefore = useRef | null>(null);
useEffect(() => {
- const now = new Set((data?.countries ?? []).filter((c) => countryStatus(c) === 'visited').map((c) => c.code));
+ // Until the Atlas has loaded there is nothing to compare with: the first
+ // answer is what was already visited, not countries visited just now.
+ if (!data) return;
+ const now = new Set(data.countries.filter((c) => countryStatus(c) === 'visited').map((c) => c.code));
const before = visitedBefore.current;
visitedBefore.current = now;
if (!before) return;