feat(atlas): a regions view, and visited regions that stand out

A traveller who visited only Alberta saw all of Canada colored on the zoomed-out globe. A new layer switch, Regions instead of countries, keeps the coarse regions of every country with a visited region on screen at every zoom: the engine loads and holds them (setPinnedRegions), the renderer draws them at full strength with faint inner borders, and the country itself only tints faintly beneath them once they are drawn. The switch is remembered per device, on the desktop layers dialog and the phone sheet, in all 28 languages.

Also without the switch, a country with visited regions now steps far back once its regions fade in (to about a fifth instead of two thirds), so the regions really visited stand out from the rest of the country.
This commit is contained in:
Maurice
2026-11-29 11:53:46 +01:00
parent 00675c59b0
commit 14443a17be
43 changed files with 257 additions and 31 deletions
@@ -518,6 +518,29 @@ describe('GlobeEngine regions in view', () => {
expect(s.worldKey).toBe('l2');
});
it('FE-ATLAS2-ENGINE-114: pinned countries load and draw their coarse regions on the whole globe', async () => {
const ctx = await start({ initial: { lon: 2, lat: 46, zoom: 1 } });
await boot(ctx);
ctx.engine.setPinnedRegions(['FR']);
frames(1);
await flush();
expect(fetched(ctx, 'regions/FR.r0.json')).toBe(1);
expect(ctx.renderer.touchRegion.mock.calls.map(([k]) => k)).toContain('FR:r0');
ctx.worker.answer();
await flush();
const inUse = ctx.renderer.setRegion.mock.calls[0][2];
expect(inUse?.has('FR:r0')).toBe(true);
frames(1);
const pinned = lastDraw(ctx.renderer);
expect(pinned.regionAlpha).toBe(0);
expect(pinned.regionKeys).toEqual(['FR:r0']);
expect(pinned.pinnedRegions?.has('FR')).toBe(true);
ctx.engine.setPinnedRegions([]);
frames(1);
expect(lastDraw(ctx.renderer).regionKeys).toEqual([]);
});
it('FE-ATLAS2-ENGINE-021: the view is scanned at most every 0.2 s and a loaded region is not fetched twice', async () => {
const ctx = await start({ initial: { lon: 2, lat: 46, zoom: 6 } });
await boot(ctx);
@@ -150,6 +150,8 @@ export class GlobeEngine {
private regionFailedAt = new Map<string, number>();
private regionScanAt = -1;
private inViewRegionKeys: ReadonlySet<string> = new Set();
/** Countries whose regions show at every zoom, not only once zoomed in (the regions view). */
private pinned: ReadonlySet<string> = new Set();
private prefetchQueue: string[] = [];
private prefetchTimer = 0;
private nextRegionId = FIRST_REGION_ID;
@@ -252,6 +254,22 @@ export class GlobeEngine {
}
}
/**
* Shows these countries' regions at every zoom instead of only once zoomed
* in, so a country with a few visited regions reads as those regions rather
* than as a whole visited country. An empty list goes back to the usual fade.
*/
setPinnedRegions(a2s: readonly string[]): void {
this.pinned = new Set(a2s);
this.kick();
}
/** The region layers that must stay on the GPU: those in view and the pinned countries' coarse ones. */
private regionsInUse(): ReadonlySet<string> {
if (!this.pinned.size) return this.inViewRegionKeys;
return new Set([...this.inViewRegionKeys, ...[...this.pinned].map((a2) => `${a2}:r0`)]);
}
async loadRegionIndex(a2: string): Promise<RegionIndex | null> {
const have = this.regionIndex.get(a2);
if (have) return have;
@@ -281,7 +299,7 @@ export class GlobeEngine {
const topo = (await this.opts.fetchJson(idx.files[lod])) as Topology;
const layer = await this.build(topo, 'regions', MAX_EDGE[lod], base);
if (!this.alive) return;
this.renderer.setRegion(key, layer, this.inViewRegionKeys);
this.renderer.setRegion(key, layer, this.regionsInUse());
this.onRegionLoaded?.(a2);
this.kick();
} catch {
@@ -736,6 +754,12 @@ export class GlobeEngine {
if (fine) void this.loadRegion(a2, 'r1');
}
}
// The pinned countries' coarse regions, wherever the camera is.
for (const a2 of this.pinned) {
if (!this.manifest?.regions[a2]) continue;
this.renderer.touchRegion(`${a2}:r0`);
void this.loadRegion(a2, 'r0');
}
this.regionKeys = this.collectRegionKeys();
const time = this.now();
@@ -768,6 +792,7 @@ export class GlobeEngine {
selected: this.selected,
ink,
regionAlpha: this.regionAlpha,
pinnedRegions: this.pinned,
theme: this.theme,
arcs: this.arcs,
arcProgress,
@@ -791,9 +816,13 @@ export class GlobeEngine {
};
private collectRegionKeys(): string[] {
if (this.regionAlpha <= 0) return [];
const fine = this.cam.zoom >= REGION_FINE_ZOOM;
const out: string[] = [];
// Pinned countries draw their regions before the zoom brings the rest in.
for (const a2 of this.pinned) {
if (this.regionAlpha <= 0 && this.renderer.hasRegion(`${a2}:r0`)) out.push(`${a2}:r0`);
}
if (this.regionAlpha <= 0) return out;
const fine = this.cam.zoom >= REGION_FINE_ZOOM;
for (const a2 of this.regionIndex.keys()) {
const k1 = `${a2}:r1`;
const k0 = `${a2}:r0`;
@@ -448,6 +448,17 @@ describe('GlobeRenderer region layers', () => {
expect(DARK.regionBorder[3]).toBe(0.5);
});
it('FE-ATLAS2-RENDER-049: a pinned country draws its regions in full while zoomed out, with faint inner borders', () => {
const { fake, r } = setup();
r.setRegion('DE:r0', layer(4, 1, 5));
r.draw(state({ regionAlpha: 0, regionKeys: ['DE:r0'], pinnedRegions: new Set(['DE']) }));
const [region] = fillDraws(fake, 12);
expect(region.values.u_mode).toBe(2);
expect(region.values.u_layerAlpha).toBe(1);
const [borders] = lineDraws(fake, 5);
expect((borders.values.u_color as number[])[3]).toBeCloseTo(DARK.regionBorder[3] * 0.45);
});
it('FE-ATLAS2-RENDER-029: does not draw regions faded out below the threshold', () => {
const { fake, r } = setup();
r.setRegion('DE', layer(4, 1, 5));
@@ -49,6 +49,8 @@ export interface DrawState {
selected: number;
ink: { id: number; lon: number; lat: number; radius: number } | null;
regionAlpha: number;
/** Countries whose regions show at full strength at every zoom (the regions view). */
pinnedRegions?: ReadonlySet<string>;
theme: GlobeTheme;
arcs: ArcLayer[];
arcProgress: number;
@@ -199,7 +201,7 @@ export class GlobeRenderer {
return vao;
}
/** rgba: colour + fill strength. fx: hatch, reveal order (0..255), outline, spare. */
/** rgba: colour + fill strength. fx: hatch, reveal order (0..255), regions loaded, visited regions. */
setStatus(
id: number,
rgba: [number, number, number, number],
@@ -454,7 +456,10 @@ export class GlobeRenderer {
gl.bindVertexArray(this.ocean.vao);
gl.drawElements(gl.TRIANGLES, this.ocean.count, gl.UNSIGNED_INT, 0);
}
const regionsOn = s.regionAlpha > 0.001 && s.regionKeys.some((k) => this.regions.has(k));
// A pinned country's regions show whatever the zoom; the rest fade in with it.
const pinnedKey = (k: string) => !!s.pinnedRegions?.has(k.slice(0, k.indexOf(':')));
const fillAlpha = (k: string) => (pinnedKey(k) ? 1 : s.regionAlpha);
const regionsOn = s.regionKeys.some((k) => this.regions.has(k) && fillAlpha(k) > 0.001);
if (this.world) {
gl.uniform1i(p.u.u_mode, 0);
gl.uniform1f(p.u.u_dimBase, 1);
@@ -464,10 +469,10 @@ export class GlobeRenderer {
}
if (regionsOn) {
gl.uniform1i(p.u.u_mode, 2);
gl.uniform1f(p.u.u_layerAlpha, s.regionAlpha);
for (const k of s.regionKeys) {
const r = this.regions.get(k);
if (!r) continue;
gl.uniform1f(p.u.u_layerAlpha, fillAlpha(k));
gl.bindVertexArray(r.fill.vao);
gl.drawElements(gl.TRIANGLES, r.fill.count, gl.UNSIGNED_INT, 0);
}
@@ -490,11 +495,13 @@ export class GlobeRenderer {
gl.drawArraysInstanced(gl.TRIANGLES, 0, 6, g.count);
};
if (regionsOn) {
const c = [...th.regionBorder];
c[3] *= s.regionAlpha;
for (const k of s.regionKeys) {
const r = this.regions.get(k);
if (r) lines(r.borders, c, 0.7);
if (!r) continue;
// Zoomed out, a pinned country's inner borders stay faint, so it does not turn into a web.
const c = [...th.regionBorder];
c[3] *= pinnedKey(k) ? Math.max(s.regionAlpha, 0.45) : s.regionAlpha;
lines(r.borders, c, 0.7);
}
}
if (this.world) {
@@ -84,7 +84,7 @@ in float v_shade;
in vec2 v_ll;
flat in int v_fid;
uniform sampler2D u_status; // rgb colour, a strength
uniform sampler2D u_fx; // r hatch, g reveal order, b outline flag
uniform sampler2D u_fx; // r hatch, g reveal order, b regions loaded, a visited regions
uniform int u_mode; // 0 land, 1 ocean, 2 region layer
uniform vec3 u_land;
uniform vec3 u_ocean;
@@ -136,8 +136,9 @@ void main() {
float d = acos(clamp(dot(p1, p2), -1.0, 1.0));
a *= 1.0 - smoothstep(u_inkR - 0.01, u_inkR, d);
}
// A country whose regions are on screen steps back so its regions read.
if (u_mode == 0 && fx.b > 0.5) a *= 1.0 - 0.32 * u_regionFade;
// A country whose regions are on screen steps back so its regions read; one with
// visited regions (fx.a) steps far back, so the regions really visited stand out.
if (u_mode == 0 && fx.b > 0.5) a *= 1.0 - (fx.a > 0.5 ? 0.82 : 0.32) * u_regionFade;
vec3 base = u_land * (u_mode == 2 ? 1.0 : u_dimBase);
vec3 col = mix(base, st.rgb, a);
if (fx.r > 0.5) {
@@ -9,16 +9,20 @@ describe('MAtlasLayersSheet', () => {
expect(screen.queryByRole('dialog')).toBeNull();
});
it('FE-ATLAS2-MOBILE-221: without flights or plugins only the planned switch stands there, and it flips', () => {
const s = buildGlobeState({ showPlanned: true });
it('FE-ATLAS2-MOBILE-221: without flights or plugins the planned and the regions switch stand there, and they flip', () => {
const s = buildGlobeState({ showPlanned: true, regionView: false });
render(<MAtlasLayersSheet s={s} open onClose={vi.fn()} />);
expect(screen.getByRole('dialog', { name: 'atlas.globe.layers' })).toBeInTheDocument();
const switches = screen.getAllByRole('switch');
expect(switches).toHaveLength(1);
expect(switches).toHaveLength(2);
expect(switches[0]).toHaveAccessibleName('atlas.showPlanned');
expect(switches[0]).toHaveAttribute('aria-checked', 'true');
fireEvent.click(switches[0] as HTMLElement);
expect(s.setShowPlanned).toHaveBeenCalledWith(false);
expect(switches[1]).toHaveAccessibleName('atlas.regionView');
expect(switches[1]).toHaveAttribute('aria-checked', 'false');
fireEvent.click(switches[1] as HTMLElement);
expect(s.setRegionView).toHaveBeenCalledWith(true);
});
it('FE-ATLAS2-MOBILE-222: flights with routes add their switch, an empty flight list does not', () => {
@@ -1,4 +1,4 @@
import { CalendarClock, Plane, Puzzle, X } from 'lucide-react';
import { CalendarClock, MapPinned, Plane, Puzzle, X } from 'lucide-react';
import React from 'react';
import type { GlobeColorMode } from '../../../pages/atlas/atlasGlobePaint';
import type { AtlasGlobeState } from '../../../pages/atlas/useAtlasGlobe';
@@ -35,6 +35,13 @@ export default function MAtlasLayersSheet({
on: s.showPlanned,
toggle: () => s.setShowPlanned(!s.showPlanned),
},
{
key: 'regions',
Icon: MapPinned,
label: s.t('atlas.regionView'),
on: s.regionView,
toggle: () => s.setRegionView(!s.regionView),
},
...(s.flights?.routes.length
? [
{
@@ -181,6 +181,15 @@ describe('GlobeLayersDialog', () => {
expect(screen.queryByRole('button', { name: 'atlas.globe.flights' })).not.toBeInTheDocument();
});
it('FE-ATLAS2-VIEWB-105: the regions switch turns the regions view on and off', () => {
const setRegionView = vi.fn();
render(<GlobeLayersDialog s={viewState({ regionView: true, setRegionView })} onClose={vi.fn()} />);
const sw = screen.getByRole('button', { name: 'atlas.regionView' });
expect(sw).toHaveAttribute('aria-pressed', 'true');
fireEvent.click(sw);
expect(setRegionView).toHaveBeenCalledWith(false);
});
it('FE-ATLAS2-VIEWB-101: with flights there is a flights switch', () => {
const setShowFlights = vi.fn();
render(
@@ -198,6 +198,7 @@ export function GlobeLayersDialog({ s, onClose }: { s: AtlasGlobeState; onClose:
>
<div className="flex flex-col gap-2">
{row(s.t('atlas.showPlanned'), s.showPlanned, () => s.setShowPlanned(!s.showPlanned))}
{row(s.t('atlas.regionView'), s.regionView, () => s.setRegionView(!s.regionView))}
{!!s.flights?.routes.length &&
row(s.t('atlas.globe.flights'), s.showFlights, () => s.setShowFlights(!s.showFlights))}
{s.pluginLayers.map((l) => {
@@ -11,6 +11,7 @@ import {
paintGlobe,
PLUGIN_TONES,
regionProgress,
regionViewCountries,
type GlobePaintInput,
} from './atlasGlobePaint';
import { countryColor, type AtlasCountry, type AtlasData, type BucketItem } from './atlasModel';
@@ -456,3 +457,39 @@ describe('regionProgress', () => {
});
});
});
describe('the regions view', () => {
const FR = mc('FR', 'FRA');
const DE = mc('DE', 'DEU');
it('FE-ATLAS2-PAINT-031: counts a country by its regions only when one of them is visited', () => {
expect(
regionViewCountries({
FR: [region('FR-IDF', 'Ile-de-France')],
DE: [region('DE-BY', 'Bavaria', 'planned')],
CA: [region('CA-AB', 'Alberta', 'planned'), region('CA-BC', 'British Columbia', 'visited')],
})
).toEqual(['FR', 'CA']);
});
it('FE-ATLAS2-PAINT-032: a visited country with visited regions steps far back once zoomed in, others do not', () => {
const { engine, at } = fakeEngine({ countries: [FR, DE], loadedRegions: ['FR:r0'] });
const data = buildAtlasData({ countries: [country('FR'), country('DE')] });
paintGlobe(engine, input({ data, regions: { FR: [region('FR-IDF', 'Ile-de-France')] } }));
expect(at(0)?.fx?.[3]).toBe(255);
expect(at(0)?.color[3]).toBe(235);
expect(at(1)?.fx?.[3]).toBe(0);
});
it('FE-ATLAS2-PAINT-033: in the regions view the country only tints faintly beneath its drawn regions', () => {
const regions = { FR: [region('FR-IDF', 'Ile-de-France')] };
const data = buildAtlasData({ countries: [country('FR')] });
const drawn = fakeEngine({ countries: [FR], loadedRegions: ['FR:r0'] });
paintGlobe(drawn.engine, input({ data, regions, regionView: true }));
expect(drawn.at(0)?.color[3]).toBe(40);
// Until its regions are on the GPU the country keeps its full colour, so it never goes blank.
const waiting = fakeEngine({ countries: [FR] });
paintGlobe(waiting.engine, input({ data, regions, regionView: true }));
expect(waiting.at(0)?.color[3]).toBe(235);
});
});
+20 -3
View File
@@ -36,6 +36,16 @@ export interface GlobePaintInput {
gaps?: boolean;
/** Country tints from plugin layers (atlasLayerProvider), by ISO A2, as hex. */
pluginTint?: Map<string, string>;
/** The regions view: a country with visited regions shows those, not itself, at every zoom. */
regionView?: boolean;
}
/** How faintly a country shows under its own visited regions in the regions view (of 255). */
const UNDER_REGIONS = 40;
/** The countries the regions view draws as their regions: those with at least one visited region. */
export function regionViewCountries(regions: Record<string, AtlasRegionRow[]>): string[] {
return Object.keys(regions).filter((a2) => regions[a2].some((r) => (r.status ?? 'visited') === 'visited'));
}
/** The plugin tones, the same palette the classic Atlas and the plugin map markers use. */
@@ -135,6 +145,10 @@ export function paintGlobe(engine: GlobeEngine, input: GlobePaintInput): void {
input.bucket.filter((b) => !b.region_code && b.country_code).map((b) => b.country_code as string)
);
const wishRegions = wishlistRegionCodes(input.bucket);
// Countries with visited regions: zoomed in, the rest of the country steps far back so those
// regions stand out (the spare fx channel tells the shader); in the regions view, also zoomed out.
const withVisitedRegions = new Set(regionViewCountries(input.regions));
const byRegions = input.regionView ? withVisitedRegions : new Set<string>();
m.countries.forEach((c, i) => {
const a2 = c.a2;
@@ -144,7 +158,8 @@ export function paintGlobe(engine: GlobeEngine, input: GlobePaintInput): void {
const status = row ? countryStatus(row) : null;
const year = row?.firstVisit ? Number(row.firstVisit.slice(0, 4)) : null;
const inYear = input.year === null || (year !== null && year <= input.year);
const fx: [number, number, number, number] = [0, reveal, hasRegions ? 255 : 0, 0];
const marked = !!a2 && withVisitedRegions.has(a2);
const fx: [number, number, number, number] = [0, reveal, hasRegions ? 255 : 0, marked ? 255 : 0];
if (status === 'visited' && inYear) {
const hex =
input.colorMode === 'status'
@@ -152,13 +167,15 @@ export function paintGlobe(engine: GlobeEngine, input: GlobePaintInput): void {
: input.colorMode === 'year' && year
? yearColor(year, firstYear, lastYear)
: countryColor(c.a3);
r.setStatus(i, [...rgbToBytes(hexToRgb(hex)), 235], fx);
// In the regions view, once its regions are drawn, the country only shows faintly beneath them.
const strength = hasRegions && a2 && byRegions.has(a2) ? UNDER_REGIONS : 235;
r.setStatus(i, [...rgbToBytes(hexToRgb(hex)), strength], fx);
} else if (status && status !== 'visited' && input.showPlanned) {
r.setStatus(i, [...rgbToBytes(hexToRgb(PLANNED)), 95], fx);
} else if (a2 && input.pluginTint?.has(a2)) {
r.setStatus(i, [...rgbToBytes(hexToRgb(input.pluginTint.get(a2) as string)), 90], fx);
} else if (a2 && wishCountries.has(a2)) {
r.setStatus(i, [...rgbToBytes(hexToRgb(WISH)), 0], [255, reveal, fx[2], 0]);
r.setStatus(i, [...rgbToBytes(hexToRgb(WISH)), 0], [255, reveal, fx[2], fx[3]]);
} else {
r.setStatus(i, [0, 0, 0, 0], fx);
}
@@ -131,6 +131,7 @@ function fakeEngine() {
idOf: vi.fn<(hit: GlobeHit) => number>(() => 600),
startInk: vi.fn<(id: number, lon: number, lat: number) => void>(),
zoomBy: vi.fn<(factor: number) => void>(),
setPinnedRegions: vi.fn<(a2s: readonly string[]) => void>(),
};
}
@@ -800,6 +801,24 @@ describe('useAtlasGlobe: switches', () => {
expect(window.localStorage.getItem('trek_atlas_show_planned')).toBe('1');
});
it('FE-ATLAS2-HOOK-077: the regions view is remembered and hands the engine the countries with visited regions', async () => {
const { result, engine } = await mountLoaded();
expect(result.current.regionView).toBe(false);
act(() =>
result.current.setRegions({
CA: [{ code: 'CA-AB', name: 'Alberta', placeCount: 1, status: 'visited' }],
DE: [{ code: 'DE-BY', name: 'Bavaria', placeCount: 0, status: 'planned' }],
})
);
expect(engine.setPinnedRegions).toHaveBeenLastCalledWith([]);
act(() => result.current.setRegionView(true));
expect(window.localStorage.getItem('trek_atlas_region_view')).toBe('1');
expect(engine.setPinnedRegions).toHaveBeenLastCalledWith(['CA']);
act(() => result.current.setRegionView(false));
expect(window.localStorage.getItem('trek_atlas_region_view')).toBe('0');
expect(engine.setPinnedRegions).toHaveBeenLastCalledWith([]);
});
it('FE-ATLAS2-HOOK-049: blocked storage starts with planned hidden and the switch still works', async () => {
const getItem = vi.spyOn(Storage.prototype, 'getItem').mockImplementation(() => {
throw new Error('blocked');
+41 -12
View File
@@ -18,7 +18,7 @@ import { useAuthStore } from '../../store/authStore';
import { useSettingsStore } from '../../store/settingsStore';
import { useServerPing } from '../../sync/useServerPing';
import { getApiErrorMessage } from '../../types';
import { PLUGIN_TONES, paintGlobe, regionProgress, type GlobeColorMode } from './atlasGlobePaint';
import { PLUGIN_TONES, paintGlobe, regionProgress, regionViewCountries, type GlobeColorMode } from './atlasGlobePaint';
import { countryStatus, type AtlasData, type BucketItem, type CountryDetail } from './atlasModel';
import { useAtlasBucket } from './useAtlasBucket';
import type { AtlasConfirmAction, VisitedRegionMap } from './useAtlasCountryActions';
@@ -31,18 +31,27 @@ function foldSearch(s: string): string {
}
const SHOW_PLANNED_KEY = 'trek_atlas_show_planned';
const REGION_VIEW_KEY = 'trek_atlas_region_view';
/** Tries of the first read after the first one fails (1, 2, 4, 8, 16 s apart). */
const LOAD_RETRIES = 5;
/** Whether planned countries show: what this device chose before, off until then (#1048). */
function readShowPlanned(): boolean {
/** A layer switch as this device left it (planned countries #1048, the regions view), off until then. */
function readFlag(key: string): boolean {
try {
return window.localStorage.getItem(SHOW_PLANNED_KEY) === '1';
return window.localStorage.getItem(key) === '1';
} catch {
return false;
}
}
function writeFlag(key: string, on: boolean): void {
try {
window.localStorage.setItem(key, on ? '1' : '0');
} catch {
// Storage blocked: the switch still works for this visit.
}
}
export type AtlasHubTab = 'overview' | 'badges' | 'wishlist' | 'dawarich' | 'tours' | 'travellers';
type GlobeSelection =
@@ -84,14 +93,16 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
const [manifest, setManifest] = useState<AtlasMeshManifest | null>(null);
const [selection, setSelection] = useState<GlobeSelection | null>(null);
const [hover, setHover] = useState<GlobeHover | null>(null);
const [showPlanned, setShowPlannedState] = useState(readShowPlanned);
const [showPlanned, setShowPlannedState] = useState(() => readFlag(SHOW_PLANNED_KEY));
const setShowPlanned = useCallback((on: boolean) => {
setShowPlannedState(on);
try {
window.localStorage.setItem(SHOW_PLANNED_KEY, on ? '1' : '0');
} catch {
// Storage blocked: the switch still works for this visit.
}
writeFlag(SHOW_PLANNED_KEY, on);
}, []);
// The regions view: a country with visited regions shows those regions at every zoom.
const [regionView, setRegionViewState] = useState(() => readFlag(REGION_VIEW_KEY));
const setRegionView = useCallback((on: boolean) => {
setRegionViewState(on);
writeFlag(REGION_VIEW_KEY, on);
}, []);
const [colorMode, setColorMode] = useState<GlobeColorMode>('country');
const [year, setYear] = useState<number | null>(null);
@@ -208,8 +219,19 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
const [compareCodes, setCompareCodes] = useState<string[] | null>(null);
const [gapsOn, setGapsOn] = useState(false);
const paintInput = useMemo(
() => ({ data, regions, bucket, showPlanned, colorMode, year, compare: compareCodes, gaps: gapsOn, pluginTint }),
[data, regions, bucket, showPlanned, colorMode, year, compareCodes, gapsOn, pluginTint]
() => ({
data,
regions,
bucket,
showPlanned,
colorMode,
year,
compare: compareCodes,
gaps: gapsOn,
pluginTint,
regionView,
}),
[data, regions, bucket, showPlanned, colorMode, year, compareCodes, gapsOn, pluginTint, regionView]
);
const paint = useCallback((engine: GlobeEngine) => paintGlobe(engine, paintInput), [paintInput]);
const paintKey = useMemo(() => [paintInput, regionTick], [paintInput, regionTick]);
@@ -227,6 +249,11 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
}, []);
const engine = useCallback((): GlobeEngine | null => globeRef.current?.engine ?? null, [globeRef]);
// Which countries the engine keeps their regions up for; the manifest marks the engine as ready.
const pinnedCountries = useMemo(() => (regionView ? regionViewCountries(regions) : []), [regionView, regions]);
useEffect(() => {
engine()?.setPinnedRegions(pinnedCountries);
}, [engine, pinnedCountries, manifest]);
// Once the globe and the data are there, fetch in the background the regions
// of the countries this user is most likely to zoom into: the visited ones
@@ -661,6 +688,8 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
placeLang,
showPlanned,
setShowPlanned,
regionView,
setRegionView,
flights,
showFlights,
setShowFlights,