diff --git a/scripts/build-home-countries.mjs b/scripts/build-home-countries.mjs
new file mode 100644
index 0000000000..86514d8f75
--- /dev/null
+++ b/scripts/build-home-countries.mjs
@@ -0,0 +1,101 @@
+#!/usr/bin/env node
+// Writes src/data/homeCountries.js: each time zone's country, and where the
+// opening stops over that country.
+//
+// node scripts/build-home-countries.mjs [path/to/zone.tab]
+//
+// Zones come from tzdata's zone.tab (macOS and most Linux systems ship it at
+// /usr/share/zoneinfo/zone.tab), with the older names ICU still reports for
+// some of them (Asia/Calcutta for Asia/Kolkata): a browser may give either.
+// A country's point is the centroid of its largest part in the Natural Earth
+// countries pack (the contiguous United States, mainland France), or the
+// zone's own place where the pack has no such country.
+import { readFileSync, writeFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { geometryOf } from '../src/data/adminBoundaries.js';
+
+const root = new URL('../', import.meta.url);
+const zoneTab = process.argv[2] ?? '/usr/share/zoneinfo/zone.tab';
+const pack = JSON.parse(
+ readFileSync(
+ new URL('src/data/local_data/natural_earth/countries.json', root),
+ 'utf8',
+ ),
+);
+const out = new URL('src/data/homeCountries.js', root);
+
+const round = (value) => Math.round(value * 10) / 10;
+
+/** ISO 6709 `±DDMM[SS]±DDDMM[SS]` → [lat, lon]. */
+function iso6709(text) {
+ const [, lat, lon] = text.match(/^([+-]\d+)([+-]\d+)$/);
+ const part = (s, degreeDigits) => {
+ const sign = s[0] === '-' ? -1 : 1;
+ const d = s.slice(1);
+ const deg = Number(d.slice(0, degreeDigits));
+ const min = Number(d.slice(degreeDigits, degreeDigits + 2));
+ const sec = Number(d.slice(degreeDigits + 2) || 0);
+ return sign * (deg + min / 60 + sec / 3600);
+ };
+ return [part(lat, 2), part(lon, 3)];
+}
+
+const largest = new Map();
+for (const feature of pack.features) {
+ if (feature.type !== 'Country' || !/^[A-Z]{2}$/.test(feature.iso2)) continue;
+ const geometry = geometryOf({ feature, decimals: pack.meta.decimals });
+ const held = largest.get(feature.iso2);
+ if (!held || geometry.areaKm2 > held.areaKm2)
+ largest.set(feature.iso2, geometry);
+}
+
+const zones = new Map();
+const centres = new Map();
+const icuName = (zone) => {
+ try {
+ return new Intl.DateTimeFormat('en', { timeZone: zone }).resolvedOptions()
+ .timeZone;
+ } catch {
+ return null;
+ }
+};
+for (const line of readFileSync(zoneTab, 'utf8').split('\n')) {
+ if (!line || line.startsWith('#')) continue;
+ const [country, place, zone] = line.split('\t');
+ zones.set(zone, country);
+ const icu = icuName(zone);
+ if (icu && icu !== zone && !zones.has(icu)) zones.set(icu, country);
+ if (centres.has(country)) continue;
+ const label = largest.get(country)?.label;
+ centres.set(
+ country,
+ label ? [round(label.lat), round(label.lon)] : iso6709(place).map(round),
+ );
+}
+
+const sortedEntries = (map) =>
+ [...map].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
+const lines = [
+ '// Generated by scripts/build-home-countries.mjs. Do not edit by hand.',
+ '// Sources: tzdata zone.tab (public domain) and the Natural Earth countries',
+ '// pack in src/data/local_data/natural_earth (public domain).',
+ '',
+ '/** ISO 3166 country → [lat, lon]: the centroid of its largest part. */',
+ 'export const COUNTRY_CENTRES = {',
+ ...sortedEntries(centres).map(
+ ([country, [lat, lon]]) => ` ${country}: [${lat}, ${lon}],`,
+ ),
+ '};',
+ '',
+ '/** Time zone (tzdata and ICU names) → ISO 3166 country. */',
+ 'export const ZONE_COUNTRIES = {',
+ ...sortedEntries(zones).map(
+ ([zone, country]) => ` '${zone}': '${country}',`,
+ ),
+ '};',
+ '',
+];
+writeFileSync(out, lines.join('\n'));
+console.log(
+ `${fileURLToPath(out)}: ${centres.size} countries, ${zones.size} zones`,
+);
diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json
index 0e29f23de1..daaa460c14 100644
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@ -4303,6 +4303,7 @@
"src/render/contract/index.js",
"src/sources/sourceSlot.js",
"src/app/sources.js",
+ "src/app/openingIntro.js",
"src/app/startupChrome.js",
"src/app/stateChannel.js",
"src/app/surfaceServices.js",
diff --git a/src/app/openingIntro.js b/src/app/openingIntro.js
new file mode 100644
index 0000000000..b4d6257cf2
--- /dev/null
+++ b/src/app/openingIntro.js
@@ -0,0 +1,281 @@
+import { cameraOf } from '../render/rendererOf.js';
+
+/**
+ * The opening: once the world has loaded, the loading screen's logo turns
+ * into the globe. The words fade and the logo glides to the centre; the eye's
+ * arcs fly at the viewer; the drawn planet in the pupil gives way to the real
+ * one, drawn the same size behind it; the real one spins and grows, slowing
+ * until it stops, the whole planet in view, over the start view (the
+ * visitor's country). Everything is timed from one clock, in ms.
+ */
+export const OPENING = Object.freeze({
+ /** The words fade and the logo moves to the centre. */
+ centreMs: 450,
+ // The rest is timed from the end of the move.
+ /** The arcs grow and fade. */
+ arcsMs: 700,
+ /** The background clears to the globe. */
+ veilMs: Object.freeze([200, 700]),
+ /** The drawn planet fades into the real one. */
+ pupilMs: Object.freeze([500, 1100]),
+ /** The camera's flight in. */
+ flightStartMs: 300,
+ flightMs: 4200,
+ /** How far the globe turns on the way in, degrees. */
+ spinDeg: 360,
+});
+
+const EARTH_RADIUS_M = 6371000;
+// logo.svg: its viewBox width and the drawn planet's radius, in its units.
+const LOGO_WIDTH = 775;
+const PUPIL_RADIUS = 120.33;
+/** Never start further out than this, metres. */
+const MAX_FAR_HEIGHT_M = 4e8;
+
+/** Openings in progress on this page. */
+let playing = 0;
+
+/**
+ * Whether an opening is playing: the far start shows the globe as a speck,
+ * which the globe-in-view recovery would otherwise turn the camera back to.
+ */
+export function openingPlaying() {
+ return playing > 0;
+}
+
+const clamp01 = (x) => Math.min(1, Math.max(0, x));
+const easeInCubic = (x) => x ** 3;
+const easeOutCubic = (x) => 1 - (1 - x) ** 3;
+const easeInOutCubic = (x) =>
+ x < 0.5 ? 4 * x ** 3 : 1 - (-2 * x + 2) ** 3 / 2;
+const span = (t, [from, to]) => clamp01((t - from) / (to - from));
+
+/**
+ * Where each part of the opening stands `t` ms after it starts.
+ * @param {number} t
+ */
+export function openingStage(t, timing = OPENING) {
+ const move = clamp01(t / timing.centreMs);
+ const after = t - timing.centreMs;
+ const arcs = easeInCubic(clamp01(after / timing.arcsMs));
+ const flight = clamp01((after - timing.flightStartMs) / timing.flightMs);
+ return {
+ /** The words' opacity. */
+ text: 1 - move,
+ /** How far the logo has moved to the centre, 0–1. */
+ centre: easeInOutCubic(move),
+ arcsScale: 1 + 5 * arcs,
+ arcsOpacity: 1 - arcs,
+ /** The loading screen's background opacity. */
+ veil: 1 - span(after, timing.veilMs),
+ pupilOpacity: 1 - span(after, timing.pupilMs),
+ /** The flight's progress, 0–1. */
+ flight,
+ done: flight >= 1,
+ };
+}
+
+/**
+ * The camera `flight` (0–1) of the way in: from `farHeight` over the
+ * equator, a turn of `spinDeg` west to east that slows to a stop over
+ * `target`, closing in on `target.height`.
+ */
+export function openingPose(
+ flight,
+ { target, farHeight, spinDeg = OPENING.spinDeg },
+) {
+ const f = clamp01(flight);
+ const closing = easeInOutCubic(f);
+ const height = Math.exp(
+ Math.log(farHeight) +
+ (Math.log(target.height) - Math.log(farHeight)) * closing,
+ );
+ const lon = target.lon + spinDeg * (1 - easeOutCubic(f));
+ return {
+ lon: ((((lon + 180) % 360) + 360) % 360) - 180,
+ lat: target.lat * closing,
+ height,
+ };
+}
+
+/**
+ * The globe's radius on screen, pixels, from `height` metres straight above
+ * it, through a lens of vertical angle `fovy` on a view `viewportHeight`
+ * pixels tall.
+ */
+export function globeRadiusPx(height, { fovy, viewportHeight }) {
+ const angle = Math.asin(EARTH_RADIUS_M / (EARTH_RADIUS_M + height));
+ return (Math.tan(angle) / Math.tan(fovy / 2)) * (viewportHeight / 2);
+}
+
+/** The height at which the globe's radius on screen is `radiusPx`. */
+export function heightForGlobeRadius(radiusPx, { fovy, viewportHeight }) {
+ const tangent = (radiusPx * Math.tan(fovy / 2)) / (viewportHeight / 2);
+ return EARTH_RADIUS_M / Math.sin(Math.atan(tangent)) - EARTH_RADIUS_M;
+}
+
+/**
+ * Whether the page opens with the opening: not where motion is reduced, not
+ * on a Stories link (Stories opens its own view) and not with `?intro=0`.
+ */
+export function openingWanted(win = globalThis.window) {
+ if (!win) return false;
+ if (win.matchMedia?.('(prefers-reduced-motion: reduce)').matches)
+ return false;
+ const params = new URLSearchParams(win.location?.search ?? '');
+ return !(
+ params.get('intro') === '0' ||
+ params.has('story') ||
+ params.has('stories')
+ );
+}
+
+/**
+ * Play the opening over `loadingScreen`, from where the camera stands (the
+ * start view). Returns null when it does not play; else `done`, which
+ * settles when the camera has stopped, and `cancel()`. A click, a key or the
+ * wheel skips to the start view; any other camera move stops it where it is. The loading
+ * screen is `hidden` once the real globe shows, or at once on a cancel.
+ * @param {{viewer: object, loadingScreen: HTMLElement, win?: Window,
+ * camera?: object}} options `camera` is the viewer's camera port unless given.
+ */
+export function playOpeningIntro({
+ viewer,
+ loadingScreen,
+ win = globalThis.window,
+ camera = null,
+}) {
+ if (!openingWanted(win)) return null;
+ try {
+ camera ??= cameraOf(viewer);
+ } catch {
+ return null;
+ }
+ const target = camera.pose();
+ if (
+ !Number.isFinite(target?.height) ||
+ !Number.isFinite(target.lon) ||
+ !Number.isFinite(target.lat)
+ )
+ return null;
+ const doc = loadingScreen.ownerDocument;
+ const logo = loadingScreen.querySelector('.loader-logo');
+ const svg = logo?.querySelector('svg');
+ const part = (id) => svg?.querySelector(`#${id}`);
+ const arcs = [part('outer_eye'), part('inner_eye')].filter(Boolean);
+ // The drawn planet; the whole logo where it is an
.
+ const pupil = svg
+ ? [part('globe'), part('globe_cage')].filter(Boolean)
+ : [logo].filter(Boolean);
+
+ loadingScreen.classList.add('opening');
+ playing += 1;
+ // The planet looks out of the middle of the eye again.
+ for (const element of pupil) element.style.transform = 'none';
+ const globe = part('globe');
+ const pupilRect = (globe ?? logo)?.getBoundingClientRect();
+ const view = (
+ doc.getElementById('cesiumContainer') ?? doc.documentElement
+ ).getBoundingClientRect();
+ const viewportHeight = view.height || win.innerHeight;
+ const aspect = (view.width || win.innerWidth) / viewportHeight;
+ // Cesium's default lens: 60° across the wider side.
+ const fovy = Number.isFinite(target.fovy)
+ ? target.fovy
+ : aspect > 1
+ ? 2 * Math.atan(Math.tan(Math.PI / 6) / aspect)
+ : Math.PI / 3;
+ const lens = { fovy, viewportHeight };
+ const pupilRadius = pupilRect
+ ? globe
+ ? pupilRect.width / 2
+ : (pupilRect.width * PUPIL_RADIUS) / LOGO_WIDTH
+ : 20;
+ const farHeight = Math.min(
+ MAX_FAR_HEIGHT_M,
+ Math.max(target.height * 2, heightForGlobeRadius(pupilRadius, lens)),
+ );
+ const toCentre = pupilRect
+ ? {
+ x: view.left + view.width / 2 - (pupilRect.left + pupilRect.width / 2),
+ y: view.top + view.height / 2 - (pupilRect.top + pupilRect.height / 2),
+ }
+ : { x: 0, y: 0 };
+ const startRadius = globeRadiusPx(farHeight, lens);
+
+ let driving = false;
+ const place = (pose, heading = 0, pitch = -Math.PI / 2) => {
+ driving = true;
+ try {
+ camera.setView({
+ destination: pose,
+ orientation: { heading, pitch, roll: 0 },
+ });
+ } finally {
+ driving = false;
+ }
+ };
+
+ let resolveDone;
+ const done = new Promise((resolve) => {
+ resolveDone = resolve;
+ });
+ let frame = 0;
+ let finished = false;
+ const hide = () => loadingScreen.classList.add('hidden');
+ const stopCommands = camera.onCommand?.(() => {
+ if (!driving) finish();
+ });
+ const inputs = ['pointerdown', 'wheel', 'keydown', 'touchstart'];
+ // The person's own input skips to the end; another camera move stops it.
+ const onInput = () => finish({ land: true });
+ for (const type of inputs)
+ win.addEventListener(type, onInput, { capture: true, passive: true });
+
+ function finish({ land = false } = {}) {
+ if (finished) return;
+ finished = true;
+ playing -= 1;
+ if (frame) win.cancelAnimationFrame(frame);
+ stopCommands?.();
+ for (const type of inputs)
+ win.removeEventListener(type, onInput, { capture: true });
+ if (land)
+ place(
+ { lon: target.lon, lat: target.lat, height: target.height },
+ target.heading ?? 0,
+ target.pitch ?? -Math.PI / 2,
+ );
+ hide();
+ resolveDone();
+ }
+
+ const start = win.performance.now();
+ const step = () => {
+ frame = 0;
+ if (finished) return;
+ const stage = openingStage(win.performance.now() - start);
+ if (stage.done) {
+ finish({ land: true });
+ return;
+ }
+ const pose = openingPose(stage.flight, { target, farHeight });
+ place(pose);
+ const scale = globeRadiusPx(pose.height, lens) / startRadius;
+ loadingScreen.style.setProperty('--opening-text', stage.text);
+ loadingScreen.style.setProperty('--opening-veil', stage.veil);
+ if (logo)
+ logo.style.transform = `translate(${toCentre.x * stage.centre}px, ${
+ toCentre.y * stage.centre
+ }px) scale(${scale})`;
+ for (const element of arcs) {
+ element.style.transform = `scale(${stage.arcsScale})`;
+ element.style.opacity = stage.arcsOpacity;
+ }
+ for (const element of pupil) element.style.opacity = stage.pupilOpacity;
+ if (stage.pupilOpacity === 0) hide();
+ frame = win.requestAnimationFrame(step);
+ };
+ step();
+ return { done, cancel: () => finish() };
+}
diff --git a/src/app/openingIntro.test.mjs b/src/app/openingIntro.test.mjs
new file mode 100644
index 0000000000..50d80b58cb
--- /dev/null
+++ b/src/app/openingIntro.test.mjs
@@ -0,0 +1,184 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { Window } from 'happy-dom';
+import {
+ OPENING,
+ globeRadiusPx,
+ heightForGlobeRadius,
+ openingPlaying,
+ openingPose,
+ openingStage,
+ openingWanted,
+ playOpeningIntro,
+} from './openingIntro.js';
+
+const LENS = { fovy: Math.PI / 4, viewportHeight: 800 };
+const TARGET = { lon: 10.4, lat: 51.1, height: 23e6, heading: 0, pitch: -1 };
+const LANDED = { lon: TARGET.lon, lat: TARGET.lat, height: TARGET.height };
+const END_MS = OPENING.centreMs + OPENING.flightStartMs + OPENING.flightMs + 1;
+
+test('the arcs fly out and the words fade before the globe arrives', () => {
+ const start = openingStage(0);
+ assert.equal(start.text, 1);
+ assert.equal(start.veil, 1);
+ assert.equal(start.pupilOpacity, 1);
+ assert.equal(start.flight, 0);
+ const centred = openingStage(OPENING.centreMs);
+ assert.equal(centred.text, 0);
+ assert.equal(centred.centre, 1);
+ const arcsGone = openingStage(OPENING.centreMs + OPENING.arcsMs);
+ assert.equal(arcsGone.arcsOpacity, 0);
+ assert.ok(arcsGone.arcsScale > 5);
+ const real = openingStage(OPENING.centreMs + OPENING.pupilMs[1]);
+ assert.equal(real.pupilOpacity, 0);
+ assert.equal(real.veil, 0);
+ assert.ok(real.flight > 0 && real.flight < 1);
+ assert.equal(openingStage(END_MS).done, true);
+});
+
+test('the flight turns west to east, slows and stops over the target', () => {
+ const far = 4e8;
+ const start = openingPose(0, { target: TARGET, farHeight: far });
+ assert.ok(Math.abs(start.height - far) < 1);
+ assert.equal(start.lat, 0);
+ const end = openingPose(1, { target: TARGET, farHeight: far });
+ assert.ok(Math.abs(end.lon - TARGET.lon) < 1e-9);
+ assert.ok(Math.abs(end.lat - TARGET.lat) < 1e-9);
+ assert.ok(Math.abs(end.height - TARGET.height) < 1e-3);
+ // Unwrapped longitude falls all the way (the camera moves west, so the
+ // surface turns east), fastest at first.
+ let previous = Infinity;
+ let previousStep = Infinity;
+ for (let i = 0; i <= 10; i++) {
+ const f = i / 10;
+ const unwrapped = TARGET.lon + OPENING.spinDeg * (1 - (1 - (1 - f) ** 3));
+ assert.ok(unwrapped <= previous);
+ if (i > 0) {
+ const step = previous - unwrapped;
+ assert.ok(step <= previousStep + 1e-9, 'the turn slows');
+ previousStep = step;
+ }
+ previous = unwrapped;
+ const pose = openingPose(f, { target: TARGET, farHeight: far });
+ assert.ok(pose.lon >= -180 && pose.lon < 180);
+ }
+});
+
+test('the far start draws the globe the size of the pupil', () => {
+ for (const radius of [12, 20, 64]) {
+ const height = heightForGlobeRadius(radius, LENS);
+ assert.ok(Math.abs(globeRadiusPx(height, LENS) - radius) < 1e-6);
+ }
+ assert.ok(globeRadiusPx(4e8, LENS) < globeRadiusPx(23e6, LENS));
+});
+
+test('reduced motion, Stories links and ?intro=0 open without it', () => {
+ const win = (search, reduced = false) => ({
+ location: { search },
+ matchMedia: () => ({ matches: reduced }),
+ });
+ assert.equal(openingWanted(win('')), true);
+ assert.equal(openingWanted(win('', true)), false);
+ assert.equal(openingWanted(win('?intro=0')), false);
+ assert.equal(openingWanted(win('?story=abc')), false);
+ assert.equal(openingWanted(win('?stories')), false);
+ assert.equal(openingWanted(win('?intro=1')), true);
+});
+
+// A loading screen and a camera port; the test runs the frames by hand.
+function stage() {
+ const window = new Window({ width: 1280, height: 800 });
+ const doc = window.document;
+ doc.body.innerHTML = `
+
+ `;
+ const screen = doc.getElementById('loading-screen');
+ let now = 0;
+ let frames = [];
+ window.performance.now = () => now;
+ window.requestAnimationFrame = (fn) => frames.push(fn);
+ window.cancelAnimationFrame = () => {
+ frames = [];
+ };
+ window.matchMedia = () => ({ matches: false });
+ const views = [];
+ const commandListeners = new Set();
+ const camera = {
+ pose: () => ({ ...TARGET, fovy: Math.PI / 4 }),
+ setView(spec) {
+ views.push(spec);
+ for (const cb of commandListeners) cb({ kind: 'setView' });
+ },
+ onCommand(cb) {
+ commandListeners.add(cb);
+ return () => commandListeners.delete(cb);
+ },
+ };
+ return {
+ window,
+ screen,
+ views,
+ camera,
+ commandListeners,
+ play: () =>
+ playOpeningIntro({
+ viewer: {},
+ loadingScreen: screen,
+ win: window,
+ camera,
+ }),
+ advance(ms) {
+ now += ms;
+ const run = frames;
+ frames = [];
+ for (const fn of run) fn();
+ },
+ otherMove: () => {
+ for (const cb of [...commandListeners]) cb({ kind: 'flyTo' });
+ },
+ };
+}
+
+test('the opening runs to the start view, then hides the cover', async () => {
+ const s = stage();
+ const opening = s.play();
+ assert.ok(opening);
+ assert.equal(openingPlaying(), true);
+ assert.ok(s.screen.classList.contains('opening'));
+ assert.ok(s.views[0].destination.height > TARGET.height * 2, 'far start');
+ s.advance(OPENING.centreMs + OPENING.pupilMs[1]);
+ assert.ok(s.screen.classList.contains('hidden'));
+ s.advance(OPENING.flightMs);
+ await opening.done;
+ const last = s.views.at(-1);
+ assert.deepEqual(last.destination, LANDED);
+ assert.equal(last.orientation.pitch, TARGET.pitch);
+ assert.equal(openingPlaying(), false);
+ assert.equal(s.commandListeners.size, 0);
+});
+
+test("the person's input skips to the start view", async () => {
+ const s = stage();
+ const opening = s.play();
+ s.advance(2000);
+ s.window.dispatchEvent(new s.window.Event('keydown'));
+ await opening.done;
+ assert.deepEqual(s.views.at(-1).destination, LANDED);
+ assert.ok(s.screen.classList.contains('hidden'));
+ assert.equal(openingPlaying(), false);
+});
+
+test('another camera move stops it where it is', async () => {
+ const s = stage();
+ const opening = s.play();
+ s.advance(2000);
+ const count = s.views.length;
+ s.otherMove();
+ await opening.done;
+ s.advance(1000);
+ assert.equal(s.views.length, count, 'no more frames');
+ assert.ok(s.screen.classList.contains('hidden'));
+});
diff --git a/src/app/startupChrome.js b/src/app/startupChrome.js
index 0cda050f4b..42bf1b0e24 100644
--- a/src/app/startupChrome.js
+++ b/src/app/startupChrome.js
@@ -1,6 +1,9 @@
import { initFirstRunExperience } from '../firstRunExperience.js';
-/** Reveal welcome controls only after restoration and the loading transition. */
+/**
+ * Reveal welcome controls only after restoration and the loading transition.
+ * `playOpening` plays the opening on a bare address (src/app/openingIntro.js).
+ */
export function startApplicationChrome({
loadingScreen,
styleManager,
@@ -8,9 +11,11 @@ export function startApplicationChrome({
signal,
initializeWelcome = initFirstRunExperience,
initializeSettings,
+ playOpening = null,
}) {
let disposed = false;
let firstRun;
+ let opening = null;
let revealTimer;
let resolveDelay;
const minimumDelay = new Promise((resolve) => {
@@ -29,6 +34,14 @@ export function startApplicationChrome({
})
.then(() => {
if (disposed || signal.aborted) return;
+ // A bare address opens with the opening; welcome waits for its end.
+ opening = styleManager.hasShareState
+ ? null
+ : playOpening?.({ viewer: styleManager.viewer, loadingScreen });
+ if (opening) {
+ void opening.done.then(revealFirstRun);
+ return;
+ }
loadingScreen.classList.add('hidden');
loadingScreen.addEventListener('transitionend', revealFirstRun, {
once: true,
@@ -44,6 +57,7 @@ export function startApplicationChrome({
);
return async () => {
disposed = true;
+ opening?.cancel();
clearTimeout(delayTimer);
clearTimeout(revealTimer);
resolveDelay();
diff --git a/src/app/tools.js b/src/app/tools.js
index ce0611a78c..f393caaa2d 100644
--- a/src/app/tools.js
+++ b/src/app/tools.js
@@ -22,6 +22,7 @@ import { initImageryBoxTool } from '../ui/imageryBoxTool.js';
import { createRecentImageryPanel } from '../ui/recentImagery.js';
import { createDataLibrary } from '../library/controller.js';
import { flyToLibraryExtent } from '../library/camera.js';
+import { openingPlaying } from './openingIntro.js';
import { createLibraryBrowser } from '../ui/libraryBrowser.js';
import { useDataLibraryStore } from '../ui/stores/dataLibrary.js';
import { localGeoJsonServices } from './localGeojsonServices.js';
@@ -88,8 +89,9 @@ export function createApplicationTools({
installGlobeInViewRecovery(viewer, {
// The scope mask hides everything outside its keyhole.
keyholeRadius: () => (isScopeMaskEnabled() ? KEYHOLE_OUTER_RADIUS : 0),
- // An authored scene frames its own shots, holds included.
- paused: () => sceneDirector.running,
+ // An authored scene frames its own shots, holds included, and the
+ // opening starts with the globe as a speck.
+ paused: () => sceneDirector.running || openingPlaying(),
}),
);
onSceneDirector?.(sceneDirector);
diff --git a/src/data/homeCountries.js b/src/data/homeCountries.js
new file mode 100644
index 0000000000..949b2da045
--- /dev/null
+++ b/src/data/homeCountries.js
@@ -0,0 +1,695 @@
+// Generated by scripts/build-home-countries.mjs. Do not edit by hand.
+// Sources: tzdata zone.tab (public domain) and the Natural Earth countries
+// pack in src/data/local_data/natural_earth (public domain).
+
+/** ISO 3166 country → [lat, lon]: the centroid of its largest part. */
+export const COUNTRY_CENTRES = {
+ AD: [42.5, 1.6],
+ AE: [23.9, 54.3],
+ AF: [33.8, 66],
+ AG: [17.1, -61.8],
+ AI: [18.2, -63.1],
+ AL: [41.1, 20.1],
+ AM: [40.3, 44.9],
+ AO: [-12.3, 17.6],
+ AQ: [-80.6, 20.8],
+ AR: [-35.2, -65.1],
+ AS: [-14.3, -170.7],
+ AT: [47.6, 14.1],
+ AU: [-25.6, 134.4],
+ AW: [12.5, -70],
+ AX: [60.2, 19.9],
+ AZ: [40.3, 47.7],
+ BA: [44.2, 17.8],
+ BB: [13.2, -59.6],
+ BD: [23.9, 90.2],
+ BE: [50.6, 4.6],
+ BF: [12.3, -1.8],
+ BG: [42.8, 25.2],
+ BH: [26.1, 50.5],
+ BI: [-3.4, 29.9],
+ BJ: [9.6, 2.3],
+ BL: [17.9, -62.8],
+ BM: [32.3, -64.8],
+ BN: [4.5, 114.6],
+ BO: [-16.7, -64.7],
+ BQ: [12.2, -68.3],
+ BR: [-10.8, -53.1],
+ BS: [24.7, -78],
+ BT: [27.4, 90.4],
+ BW: [-22.2, 23.8],
+ BY: [53.5, 28],
+ BZ: [17.2, -88.7],
+ CA: [57.9, -102.4],
+ CC: [-12.2, 96.9],
+ CD: [-2.9, 23.6],
+ CF: [6.6, 20.5],
+ CG: [-0.8, 15.2],
+ CH: [46.8, 8.2],
+ CI: [7.6, -5.6],
+ CK: [-21.2, -159.8],
+ CL: [-35.4, -71.2],
+ CM: [5.7, 12.7],
+ CN: [36.6, 103.8],
+ CO: [3.9, -73.1],
+ CR: [10, -84.2],
+ CU: [21.6, -79],
+ CV: [15.1, -23.6],
+ CW: [12.2, -69],
+ CX: [-10.4, 105.7],
+ CY: [34.9, 33],
+ CZ: [49.7, 15.3],
+ DE: [51.1, 10.4],
+ DJ: [11.8, 42.6],
+ DK: [56.2, 9.4],
+ DM: [15.4, -61.4],
+ DO: [18.9, -70.5],
+ DZ: [28.1, 2.7],
+ EC: [-1.4, -78.4],
+ EE: [58.7, 25.8],
+ EG: [26.5, 29.9],
+ EH: [24.2, -12.2],
+ ER: [15.4, 38.8],
+ ES: [40.4, -3.6],
+ ET: [8.6, 39.6],
+ FI: [64.5, 26.3],
+ FJ: [-17.8, 178],
+ FK: [-51.7, -58.8],
+ FM: [6.9, 158.2],
+ FO: [62.1, -7],
+ FR: [46.6, 2.5],
+ GA: [-0.6, 11.8],
+ GB: [53.9, -2.5],
+ GD: [12.1, -61.7],
+ GE: [42.2, 43.5],
+ GF: [4.9, -52.3],
+ GG: [49.5, -2.6],
+ GH: [8, -1.2],
+ GI: [36.1, -5.3],
+ GL: [74.8, -41.4],
+ GM: [13.4, -15.4],
+ GN: [10.4, -10.9],
+ GP: [16.2, -61.5],
+ GQ: [1.6, 10.5],
+ GR: [39.5, 22.6],
+ GS: [-54.4, -36.7],
+ GT: [15.7, -90.4],
+ GU: [13.4, 144.8],
+ GW: [12.1, -14.9],
+ GY: [4.8, -59],
+ HK: [22.4, 114.2],
+ HN: [14.8, -86.6],
+ HR: [45.2, 16.4],
+ HT: [18.9, -72.7],
+ HU: [47.2, 19.4],
+ ID: [-0.2, 114],
+ IE: [53.2, -8.1],
+ IL: [31.4, 35],
+ IM: [54.2, -4.5],
+ IN: [22.9, 79.6],
+ IO: [-7.3, 72.4],
+ IQ: [33, 43.7],
+ IR: [32.6, 54.3],
+ IS: [65, -18.6],
+ IT: [43.5, 12.2],
+ JE: [49.2, -2.1],
+ JM: [18.2, -77.3],
+ JO: [31.2, 36.8],
+ JP: [36.7, 138],
+ KE: [0.6, 37.8],
+ KG: [41.5, 74.5],
+ KH: [12.7, 104.9],
+ KI: [1.9, -157.4],
+ KM: [-11.7, 43.3],
+ KN: [17.3, -62.8],
+ KP: [40.2, 127.2],
+ KR: [36.5, 127.9],
+ KW: [29.3, 47.6],
+ KY: [19.3, -81.3],
+ KZ: [48.2, 67.3],
+ LA: [18.5, 103.7],
+ LB: [33.9, 35.9],
+ LC: [13.9, -61],
+ LI: [47.1, 9.5],
+ LK: [7.6, 80.7],
+ LR: [6.5, -9.3],
+ LS: [-29.6, 28.2],
+ LT: [55.3, 23.9],
+ LU: [49.8, 6.1],
+ LV: [56.9, 24.9],
+ LY: [27, 18],
+ MA: [29.8, -8.4],
+ MC: [43.7, 7.4],
+ MD: [47.2, 28.5],
+ ME: [42.8, 19.2],
+ MF: [18.1, -63.1],
+ MG: [-19.4, 46.7],
+ MH: [7.1, 171.2],
+ MK: [41.6, 21.7],
+ ML: [17.3, -3.5],
+ MM: [21.2, 96.5],
+ MN: [46.8, 103.1],
+ MO: [22.1, 113.6],
+ MP: [15.2, 145.7],
+ MQ: [14.6, -61.1],
+ MR: [20.3, -10.3],
+ MS: [16.7, -62.2],
+ MT: [35.9, 14.4],
+ MU: [-20.3, 57.6],
+ MV: [4.2, 73.5],
+ MW: [-13.2, 34.3],
+ MX: [23.9, -102.5],
+ MY: [3.6, 114.7],
+ MZ: [-17.3, 35.5],
+ NA: [-22.1, 17.2],
+ NC: [-21.3, 165.5],
+ NE: [17.4, 9.4],
+ NF: [-29, 168],
+ NG: [9.6, 8.1],
+ NI: [12.8, -85],
+ NL: [52.3, 5.6],
+ NO: [64.2, 14],
+ NP: [28.2, 83.9],
+ NR: [-0.5, 166.9],
+ NU: [-19, -169.9],
+ NZ: [-44, 170.5],
+ OM: [20.6, 56.1],
+ PA: [8.5, -80.1],
+ PE: [-9.2, -74.4],
+ PF: [-17.7, -149.4],
+ PG: [-6.6, 144.3],
+ PH: [16, 121.4],
+ PK: [29.9, 69.3],
+ PL: [52.1, 19.4],
+ PM: [47, -56.3],
+ PN: [-24.4, -128.3],
+ PR: [18.2, -66.5],
+ PS: [31.9, 35.3],
+ PT: [39.7, -8],
+ PW: [7.5, 134.6],
+ PY: [-23.2, -58.4],
+ QA: [25.3, 51.2],
+ RE: [-20.9, 55.5],
+ RO: [45.9, 25],
+ RS: [44.2, 20.8],
+ RU: [61.7, 99.1],
+ RW: [-2, 29.9],
+ SA: [24.1, 44.5],
+ SB: [-9.6, 160.2],
+ SC: [-4.7, 55.5],
+ SD: [16, 29.9],
+ SE: [62.8, 16.7],
+ SG: [1.4, 103.8],
+ SH: [-16, -5.7],
+ SI: [46.1, 14.8],
+ SJ: [78, 16],
+ SK: [48.7, 19.5],
+ SL: [8.6, -11.8],
+ SM: [43.9, 12.4],
+ SN: [14.4, -14.5],
+ SO: [4.8, 45.7],
+ SR: [4.1, -55.9],
+ SS: [7.3, 30.3],
+ ST: [0.2, 6.6],
+ SV: [13.7, -88.9],
+ SX: [18, -63.1],
+ SY: [35, 38.5],
+ SZ: [-26.6, 31.5],
+ TC: [21.8, -71.7],
+ TD: [15.3, 18.6],
+ TF: [-49.3, 69.5],
+ TG: [8.5, 1],
+ TH: [15.1, 101],
+ TJ: [38.5, 71],
+ TK: [-9.4, -171.2],
+ TL: [-8.8, 125.9],
+ TM: [39.1, 59.4],
+ TN: [34.1, 9.5],
+ TO: [-21.2, -175.2],
+ TR: [39, 35.4],
+ TT: [10.4, -61.3],
+ TV: [-8.5, 179.2],
+ TW: [23.8, 121],
+ TZ: [-6.3, 34.8],
+ UA: [49.2, 31.3],
+ UG: [1.3, 32.4],
+ UM: [5.9, -162.1],
+ US: [39.5, -99.1],
+ UY: [-32.8, -56],
+ UZ: [41.8, 63.1],
+ VA: [41.9, 12.5],
+ VC: [13.3, -61.2],
+ VE: [7.1, -66.2],
+ VG: [18.4, -64.6],
+ VI: [17.7, -64.8],
+ VN: [16.7, 106.3],
+ VU: [-15.2, 166.9],
+ WF: [-13.3, -176.2],
+ WS: [-13.6, -172.4],
+ YE: [15.9, 47.5],
+ YT: [-12.8, 45.2],
+ ZA: [-29, 25.2],
+ ZM: [-13.5, 27.8],
+ ZW: [-19, 29.9],
+};
+
+/** Time zone (tzdata and ICU names) → ISO 3166 country. */
+export const ZONE_COUNTRIES = {
+ 'Africa/Abidjan': 'CI',
+ 'Africa/Accra': 'GH',
+ 'Africa/Addis_Ababa': 'ET',
+ 'Africa/Algiers': 'DZ',
+ 'Africa/Asmara': 'ER',
+ 'Africa/Asmera': 'ER',
+ 'Africa/Bamako': 'ML',
+ 'Africa/Bangui': 'CF',
+ 'Africa/Banjul': 'GM',
+ 'Africa/Bissau': 'GW',
+ 'Africa/Blantyre': 'MW',
+ 'Africa/Brazzaville': 'CG',
+ 'Africa/Bujumbura': 'BI',
+ 'Africa/Cairo': 'EG',
+ 'Africa/Casablanca': 'MA',
+ 'Africa/Ceuta': 'ES',
+ 'Africa/Conakry': 'GN',
+ 'Africa/Dakar': 'SN',
+ 'Africa/Dar_es_Salaam': 'TZ',
+ 'Africa/Djibouti': 'DJ',
+ 'Africa/Douala': 'CM',
+ 'Africa/El_Aaiun': 'EH',
+ 'Africa/Freetown': 'SL',
+ 'Africa/Gaborone': 'BW',
+ 'Africa/Harare': 'ZW',
+ 'Africa/Johannesburg': 'ZA',
+ 'Africa/Juba': 'SS',
+ 'Africa/Kampala': 'UG',
+ 'Africa/Khartoum': 'SD',
+ 'Africa/Kigali': 'RW',
+ 'Africa/Kinshasa': 'CD',
+ 'Africa/Lagos': 'NG',
+ 'Africa/Libreville': 'GA',
+ 'Africa/Lome': 'TG',
+ 'Africa/Luanda': 'AO',
+ 'Africa/Lubumbashi': 'CD',
+ 'Africa/Lusaka': 'ZM',
+ 'Africa/Malabo': 'GQ',
+ 'Africa/Maputo': 'MZ',
+ 'Africa/Maseru': 'LS',
+ 'Africa/Mbabane': 'SZ',
+ 'Africa/Mogadishu': 'SO',
+ 'Africa/Monrovia': 'LR',
+ 'Africa/Nairobi': 'KE',
+ 'Africa/Ndjamena': 'TD',
+ 'Africa/Niamey': 'NE',
+ 'Africa/Nouakchott': 'MR',
+ 'Africa/Ouagadougou': 'BF',
+ 'Africa/Porto-Novo': 'BJ',
+ 'Africa/Sao_Tome': 'ST',
+ 'Africa/Tripoli': 'LY',
+ 'Africa/Tunis': 'TN',
+ 'Africa/Windhoek': 'NA',
+ 'America/Adak': 'US',
+ 'America/Anchorage': 'US',
+ 'America/Anguilla': 'AI',
+ 'America/Antigua': 'AG',
+ 'America/Araguaina': 'BR',
+ 'America/Argentina/Buenos_Aires': 'AR',
+ 'America/Argentina/Catamarca': 'AR',
+ 'America/Argentina/Cordoba': 'AR',
+ 'America/Argentina/Jujuy': 'AR',
+ 'America/Argentina/La_Rioja': 'AR',
+ 'America/Argentina/Mendoza': 'AR',
+ 'America/Argentina/Rio_Gallegos': 'AR',
+ 'America/Argentina/Salta': 'AR',
+ 'America/Argentina/San_Juan': 'AR',
+ 'America/Argentina/San_Luis': 'AR',
+ 'America/Argentina/Tucuman': 'AR',
+ 'America/Argentina/Ushuaia': 'AR',
+ 'America/Aruba': 'AW',
+ 'America/Asuncion': 'PY',
+ 'America/Atikokan': 'CA',
+ 'America/Bahia': 'BR',
+ 'America/Bahia_Banderas': 'MX',
+ 'America/Barbados': 'BB',
+ 'America/Belem': 'BR',
+ 'America/Belize': 'BZ',
+ 'America/Blanc-Sablon': 'CA',
+ 'America/Boa_Vista': 'BR',
+ 'America/Bogota': 'CO',
+ 'America/Boise': 'US',
+ 'America/Buenos_Aires': 'AR',
+ 'America/Cambridge_Bay': 'CA',
+ 'America/Campo_Grande': 'BR',
+ 'America/Cancun': 'MX',
+ 'America/Caracas': 'VE',
+ 'America/Catamarca': 'AR',
+ 'America/Cayenne': 'GF',
+ 'America/Cayman': 'KY',
+ 'America/Chicago': 'US',
+ 'America/Chihuahua': 'MX',
+ 'America/Ciudad_Juarez': 'MX',
+ 'America/Coral_Harbour': 'CA',
+ 'America/Cordoba': 'AR',
+ 'America/Costa_Rica': 'CR',
+ 'America/Coyhaique': 'CL',
+ 'America/Creston': 'CA',
+ 'America/Cuiaba': 'BR',
+ 'America/Curacao': 'CW',
+ 'America/Danmarkshavn': 'GL',
+ 'America/Dawson': 'CA',
+ 'America/Dawson_Creek': 'CA',
+ 'America/Denver': 'US',
+ 'America/Detroit': 'US',
+ 'America/Dominica': 'DM',
+ 'America/Edmonton': 'CA',
+ 'America/Eirunepe': 'BR',
+ 'America/El_Salvador': 'SV',
+ 'America/Fort_Nelson': 'CA',
+ 'America/Fortaleza': 'BR',
+ 'America/Glace_Bay': 'CA',
+ 'America/Godthab': 'GL',
+ 'America/Goose_Bay': 'CA',
+ 'America/Grand_Turk': 'TC',
+ 'America/Grenada': 'GD',
+ 'America/Guadeloupe': 'GP',
+ 'America/Guatemala': 'GT',
+ 'America/Guayaquil': 'EC',
+ 'America/Guyana': 'GY',
+ 'America/Halifax': 'CA',
+ 'America/Havana': 'CU',
+ 'America/Hermosillo': 'MX',
+ 'America/Indiana/Indianapolis': 'US',
+ 'America/Indiana/Knox': 'US',
+ 'America/Indiana/Marengo': 'US',
+ 'America/Indiana/Petersburg': 'US',
+ 'America/Indiana/Tell_City': 'US',
+ 'America/Indiana/Vevay': 'US',
+ 'America/Indiana/Vincennes': 'US',
+ 'America/Indiana/Winamac': 'US',
+ 'America/Indianapolis': 'US',
+ 'America/Inuvik': 'CA',
+ 'America/Iqaluit': 'CA',
+ 'America/Jamaica': 'JM',
+ 'America/Jujuy': 'AR',
+ 'America/Juneau': 'US',
+ 'America/Kentucky/Louisville': 'US',
+ 'America/Kentucky/Monticello': 'US',
+ 'America/Kralendijk': 'BQ',
+ 'America/La_Paz': 'BO',
+ 'America/Lima': 'PE',
+ 'America/Los_Angeles': 'US',
+ 'America/Louisville': 'US',
+ 'America/Lower_Princes': 'SX',
+ 'America/Maceio': 'BR',
+ 'America/Managua': 'NI',
+ 'America/Manaus': 'BR',
+ 'America/Marigot': 'MF',
+ 'America/Martinique': 'MQ',
+ 'America/Matamoros': 'MX',
+ 'America/Mazatlan': 'MX',
+ 'America/Mendoza': 'AR',
+ 'America/Menominee': 'US',
+ 'America/Merida': 'MX',
+ 'America/Metlakatla': 'US',
+ 'America/Mexico_City': 'MX',
+ 'America/Miquelon': 'PM',
+ 'America/Moncton': 'CA',
+ 'America/Monterrey': 'MX',
+ 'America/Montevideo': 'UY',
+ 'America/Montserrat': 'MS',
+ 'America/Nassau': 'BS',
+ 'America/New_York': 'US',
+ 'America/Nome': 'US',
+ 'America/Noronha': 'BR',
+ 'America/North_Dakota/Beulah': 'US',
+ 'America/North_Dakota/Center': 'US',
+ 'America/North_Dakota/New_Salem': 'US',
+ 'America/Nuuk': 'GL',
+ 'America/Ojinaga': 'MX',
+ 'America/Panama': 'PA',
+ 'America/Paramaribo': 'SR',
+ 'America/Phoenix': 'US',
+ 'America/Port-au-Prince': 'HT',
+ 'America/Port_of_Spain': 'TT',
+ 'America/Porto_Velho': 'BR',
+ 'America/Puerto_Rico': 'PR',
+ 'America/Punta_Arenas': 'CL',
+ 'America/Rankin_Inlet': 'CA',
+ 'America/Recife': 'BR',
+ 'America/Regina': 'CA',
+ 'America/Resolute': 'CA',
+ 'America/Rio_Branco': 'BR',
+ 'America/Santarem': 'BR',
+ 'America/Santiago': 'CL',
+ 'America/Santo_Domingo': 'DO',
+ 'America/Sao_Paulo': 'BR',
+ 'America/Scoresbysund': 'GL',
+ 'America/Sitka': 'US',
+ 'America/St_Barthelemy': 'BL',
+ 'America/St_Johns': 'CA',
+ 'America/St_Kitts': 'KN',
+ 'America/St_Lucia': 'LC',
+ 'America/St_Thomas': 'VI',
+ 'America/St_Vincent': 'VC',
+ 'America/Swift_Current': 'CA',
+ 'America/Tegucigalpa': 'HN',
+ 'America/Thule': 'GL',
+ 'America/Tijuana': 'MX',
+ 'America/Toronto': 'CA',
+ 'America/Tortola': 'VG',
+ 'America/Vancouver': 'CA',
+ 'America/Whitehorse': 'CA',
+ 'America/Winnipeg': 'CA',
+ 'America/Yakutat': 'US',
+ 'Antarctica/Casey': 'AQ',
+ 'Antarctica/Davis': 'AQ',
+ 'Antarctica/DumontDUrville': 'AQ',
+ 'Antarctica/Macquarie': 'AU',
+ 'Antarctica/Mawson': 'AQ',
+ 'Antarctica/McMurdo': 'AQ',
+ 'Antarctica/Palmer': 'AQ',
+ 'Antarctica/Rothera': 'AQ',
+ 'Antarctica/Syowa': 'AQ',
+ 'Antarctica/Troll': 'AQ',
+ 'Antarctica/Vostok': 'AQ',
+ 'Arctic/Longyearbyen': 'SJ',
+ 'Asia/Aden': 'YE',
+ 'Asia/Almaty': 'KZ',
+ 'Asia/Amman': 'JO',
+ 'Asia/Anadyr': 'RU',
+ 'Asia/Aqtau': 'KZ',
+ 'Asia/Aqtobe': 'KZ',
+ 'Asia/Ashgabat': 'TM',
+ 'Asia/Atyrau': 'KZ',
+ 'Asia/Baghdad': 'IQ',
+ 'Asia/Bahrain': 'BH',
+ 'Asia/Baku': 'AZ',
+ 'Asia/Bangkok': 'TH',
+ 'Asia/Barnaul': 'RU',
+ 'Asia/Beirut': 'LB',
+ 'Asia/Bishkek': 'KG',
+ 'Asia/Brunei': 'BN',
+ 'Asia/Calcutta': 'IN',
+ 'Asia/Chita': 'RU',
+ 'Asia/Colombo': 'LK',
+ 'Asia/Damascus': 'SY',
+ 'Asia/Dhaka': 'BD',
+ 'Asia/Dili': 'TL',
+ 'Asia/Dubai': 'AE',
+ 'Asia/Dushanbe': 'TJ',
+ 'Asia/Famagusta': 'CY',
+ 'Asia/Gaza': 'PS',
+ 'Asia/Hebron': 'PS',
+ 'Asia/Ho_Chi_Minh': 'VN',
+ 'Asia/Hong_Kong': 'HK',
+ 'Asia/Hovd': 'MN',
+ 'Asia/Irkutsk': 'RU',
+ 'Asia/Jakarta': 'ID',
+ 'Asia/Jayapura': 'ID',
+ 'Asia/Jerusalem': 'IL',
+ 'Asia/Kabul': 'AF',
+ 'Asia/Kamchatka': 'RU',
+ 'Asia/Karachi': 'PK',
+ 'Asia/Kathmandu': 'NP',
+ 'Asia/Katmandu': 'NP',
+ 'Asia/Khandyga': 'RU',
+ 'Asia/Kolkata': 'IN',
+ 'Asia/Krasnoyarsk': 'RU',
+ 'Asia/Kuala_Lumpur': 'MY',
+ 'Asia/Kuching': 'MY',
+ 'Asia/Kuwait': 'KW',
+ 'Asia/Macau': 'MO',
+ 'Asia/Magadan': 'RU',
+ 'Asia/Makassar': 'ID',
+ 'Asia/Manila': 'PH',
+ 'Asia/Muscat': 'OM',
+ 'Asia/Nicosia': 'CY',
+ 'Asia/Novokuznetsk': 'RU',
+ 'Asia/Novosibirsk': 'RU',
+ 'Asia/Omsk': 'RU',
+ 'Asia/Oral': 'KZ',
+ 'Asia/Phnom_Penh': 'KH',
+ 'Asia/Pontianak': 'ID',
+ 'Asia/Pyongyang': 'KP',
+ 'Asia/Qatar': 'QA',
+ 'Asia/Qostanay': 'KZ',
+ 'Asia/Qyzylorda': 'KZ',
+ 'Asia/Rangoon': 'MM',
+ 'Asia/Riyadh': 'SA',
+ 'Asia/Saigon': 'VN',
+ 'Asia/Sakhalin': 'RU',
+ 'Asia/Samarkand': 'UZ',
+ 'Asia/Seoul': 'KR',
+ 'Asia/Shanghai': 'CN',
+ 'Asia/Singapore': 'SG',
+ 'Asia/Srednekolymsk': 'RU',
+ 'Asia/Taipei': 'TW',
+ 'Asia/Tashkent': 'UZ',
+ 'Asia/Tbilisi': 'GE',
+ 'Asia/Tehran': 'IR',
+ 'Asia/Thimphu': 'BT',
+ 'Asia/Tokyo': 'JP',
+ 'Asia/Tomsk': 'RU',
+ 'Asia/Ulaanbaatar': 'MN',
+ 'Asia/Urumqi': 'CN',
+ 'Asia/Ust-Nera': 'RU',
+ 'Asia/Vientiane': 'LA',
+ 'Asia/Vladivostok': 'RU',
+ 'Asia/Yakutsk': 'RU',
+ 'Asia/Yangon': 'MM',
+ 'Asia/Yekaterinburg': 'RU',
+ 'Asia/Yerevan': 'AM',
+ 'Atlantic/Azores': 'PT',
+ 'Atlantic/Bermuda': 'BM',
+ 'Atlantic/Canary': 'ES',
+ 'Atlantic/Cape_Verde': 'CV',
+ 'Atlantic/Faeroe': 'FO',
+ 'Atlantic/Faroe': 'FO',
+ 'Atlantic/Madeira': 'PT',
+ 'Atlantic/Reykjavik': 'IS',
+ 'Atlantic/South_Georgia': 'GS',
+ 'Atlantic/St_Helena': 'SH',
+ 'Atlantic/Stanley': 'FK',
+ 'Australia/Adelaide': 'AU',
+ 'Australia/Brisbane': 'AU',
+ 'Australia/Broken_Hill': 'AU',
+ 'Australia/Darwin': 'AU',
+ 'Australia/Eucla': 'AU',
+ 'Australia/Hobart': 'AU',
+ 'Australia/Lindeman': 'AU',
+ 'Australia/Lord_Howe': 'AU',
+ 'Australia/Melbourne': 'AU',
+ 'Australia/Perth': 'AU',
+ 'Australia/Sydney': 'AU',
+ 'Europe/Amsterdam': 'NL',
+ 'Europe/Andorra': 'AD',
+ 'Europe/Astrakhan': 'RU',
+ 'Europe/Athens': 'GR',
+ 'Europe/Belgrade': 'RS',
+ 'Europe/Berlin': 'DE',
+ 'Europe/Bratislava': 'SK',
+ 'Europe/Brussels': 'BE',
+ 'Europe/Bucharest': 'RO',
+ 'Europe/Budapest': 'HU',
+ 'Europe/Busingen': 'DE',
+ 'Europe/Chisinau': 'MD',
+ 'Europe/Copenhagen': 'DK',
+ 'Europe/Dublin': 'IE',
+ 'Europe/Gibraltar': 'GI',
+ 'Europe/Guernsey': 'GG',
+ 'Europe/Helsinki': 'FI',
+ 'Europe/Isle_of_Man': 'IM',
+ 'Europe/Istanbul': 'TR',
+ 'Europe/Jersey': 'JE',
+ 'Europe/Kaliningrad': 'RU',
+ 'Europe/Kiev': 'UA',
+ 'Europe/Kirov': 'RU',
+ 'Europe/Kyiv': 'UA',
+ 'Europe/Lisbon': 'PT',
+ 'Europe/Ljubljana': 'SI',
+ 'Europe/London': 'GB',
+ 'Europe/Luxembourg': 'LU',
+ 'Europe/Madrid': 'ES',
+ 'Europe/Malta': 'MT',
+ 'Europe/Mariehamn': 'AX',
+ 'Europe/Minsk': 'BY',
+ 'Europe/Monaco': 'MC',
+ 'Europe/Moscow': 'RU',
+ 'Europe/Oslo': 'NO',
+ 'Europe/Paris': 'FR',
+ 'Europe/Podgorica': 'ME',
+ 'Europe/Prague': 'CZ',
+ 'Europe/Riga': 'LV',
+ 'Europe/Rome': 'IT',
+ 'Europe/Samara': 'RU',
+ 'Europe/San_Marino': 'SM',
+ 'Europe/Sarajevo': 'BA',
+ 'Europe/Saratov': 'RU',
+ 'Europe/Simferopol': 'UA',
+ 'Europe/Skopje': 'MK',
+ 'Europe/Sofia': 'BG',
+ 'Europe/Stockholm': 'SE',
+ 'Europe/Tallinn': 'EE',
+ 'Europe/Tirane': 'AL',
+ 'Europe/Ulyanovsk': 'RU',
+ 'Europe/Vaduz': 'LI',
+ 'Europe/Vatican': 'VA',
+ 'Europe/Vienna': 'AT',
+ 'Europe/Vilnius': 'LT',
+ 'Europe/Volgograd': 'RU',
+ 'Europe/Warsaw': 'PL',
+ 'Europe/Zagreb': 'HR',
+ 'Europe/Zurich': 'CH',
+ 'Indian/Antananarivo': 'MG',
+ 'Indian/Chagos': 'IO',
+ 'Indian/Christmas': 'CX',
+ 'Indian/Cocos': 'CC',
+ 'Indian/Comoro': 'KM',
+ 'Indian/Kerguelen': 'TF',
+ 'Indian/Mahe': 'SC',
+ 'Indian/Maldives': 'MV',
+ 'Indian/Mauritius': 'MU',
+ 'Indian/Mayotte': 'YT',
+ 'Indian/Reunion': 'RE',
+ 'Pacific/Apia': 'WS',
+ 'Pacific/Auckland': 'NZ',
+ 'Pacific/Bougainville': 'PG',
+ 'Pacific/Chatham': 'NZ',
+ 'Pacific/Chuuk': 'FM',
+ 'Pacific/Easter': 'CL',
+ 'Pacific/Efate': 'VU',
+ 'Pacific/Enderbury': 'KI',
+ 'Pacific/Fakaofo': 'TK',
+ 'Pacific/Fiji': 'FJ',
+ 'Pacific/Funafuti': 'TV',
+ 'Pacific/Galapagos': 'EC',
+ 'Pacific/Gambier': 'PF',
+ 'Pacific/Guadalcanal': 'SB',
+ 'Pacific/Guam': 'GU',
+ 'Pacific/Honolulu': 'US',
+ 'Pacific/Kanton': 'KI',
+ 'Pacific/Kiritimati': 'KI',
+ 'Pacific/Kosrae': 'FM',
+ 'Pacific/Kwajalein': 'MH',
+ 'Pacific/Majuro': 'MH',
+ 'Pacific/Marquesas': 'PF',
+ 'Pacific/Midway': 'UM',
+ 'Pacific/Nauru': 'NR',
+ 'Pacific/Niue': 'NU',
+ 'Pacific/Norfolk': 'NF',
+ 'Pacific/Noumea': 'NC',
+ 'Pacific/Pago_Pago': 'AS',
+ 'Pacific/Palau': 'PW',
+ 'Pacific/Pitcairn': 'PN',
+ 'Pacific/Pohnpei': 'FM',
+ 'Pacific/Ponape': 'FM',
+ 'Pacific/Port_Moresby': 'PG',
+ 'Pacific/Rarotonga': 'CK',
+ 'Pacific/Saipan': 'MP',
+ 'Pacific/Tahiti': 'PF',
+ 'Pacific/Tarawa': 'KI',
+ 'Pacific/Tongatapu': 'TO',
+ 'Pacific/Truk': 'FM',
+ 'Pacific/Wake': 'UM',
+ 'Pacific/Wallis': 'WF',
+};
diff --git a/src/homeCountry.js b/src/homeCountry.js
new file mode 100644
index 0000000000..d1e5241f00
--- /dev/null
+++ b/src/homeCountry.js
@@ -0,0 +1,52 @@
+import { COUNTRY_CENTRES, ZONE_COUNTRIES } from './data/homeCountries.js';
+import { START_VIEW } from './camera.js';
+
+/**
+ * The visitor's country, guessed from the browser's time zone and, for a zone
+ * that belongs to no country (UTC), the region of a preferred language
+ * ("en-GB"). Nothing leaves the browser. Null when neither names one.
+ * @param {{timeZone?: string|null, languages?: readonly string[]}} [where]
+ * @returns {string|null} ISO 3166 code, e.g. 'DE'
+ */
+export function homeCountry({
+ timeZone = currentTimeZone(),
+ languages = globalThis.navigator?.languages ?? [],
+} = {}) {
+ const byZone = ZONE_COUNTRIES[timeZone];
+ if (byZone) return byZone;
+ for (const language of languages) {
+ const region = regionOf(language);
+ if (region && COUNTRY_CENTRES[region]) return region;
+ }
+ return null;
+}
+
+/**
+ * The start view over the visitor's country: the planet from `base.height`,
+ * looking straight down on the country's centre. `base` where the country is
+ * unknown.
+ * @param {{timeZone?: string|null, languages?: readonly string[],
+ * base?: {lon: number, lat: number, height: number}}} [where]
+ */
+export function homeCountryView({ base = START_VIEW, ...where } = {}) {
+ const centre = COUNTRY_CENTRES[homeCountry(where)];
+ if (!centre) return base;
+ const [lat, lon] = centre;
+ return Object.freeze({ lon, lat, height: base.height });
+}
+
+function currentTimeZone() {
+ try {
+ return new Intl.DateTimeFormat().resolvedOptions().timeZone ?? null;
+ } catch {
+ return null;
+ }
+}
+
+function regionOf(language) {
+ try {
+ return new Intl.Locale(language).region ?? null;
+ } catch {
+ return null;
+ }
+}
diff --git a/src/homeCountry.test.mjs b/src/homeCountry.test.mjs
new file mode 100644
index 0000000000..4cf74bcedc
--- /dev/null
+++ b/src/homeCountry.test.mjs
@@ -0,0 +1,53 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { homeCountry, homeCountryView } from './homeCountry.js';
+import { START_VIEW } from './camera.js';
+import { COUNTRY_CENTRES, ZONE_COUNTRIES } from './data/homeCountries.js';
+
+test('the time zone names the country, in its tzdata or ICU name', () => {
+ assert.equal(homeCountry({ timeZone: 'Europe/Berlin', languages: [] }), 'DE');
+ assert.equal(homeCountry({ timeZone: 'Asia/Kolkata', languages: [] }), 'IN');
+ assert.equal(homeCountry({ timeZone: 'Asia/Calcutta', languages: [] }), 'IN');
+ assert.equal(homeCountry({ timeZone: 'Europe/Kiev', languages: [] }), 'UA');
+ assert.equal(
+ homeCountry({ timeZone: 'America/Chicago', languages: ['de-DE'] }),
+ 'US',
+ 'the zone outranks the language',
+ );
+});
+
+test("a zone of no country falls back to a language's region", () => {
+ assert.equal(
+ homeCountry({ timeZone: 'UTC', languages: ['fr', 'en-GB'] }),
+ 'GB',
+ );
+ assert.equal(homeCountry({ timeZone: 'Etc/UTC', languages: ['ru'] }), null);
+ assert.equal(homeCountry({ timeZone: null, languages: [] }), null);
+});
+
+test('the start view looks down on the country from the planet height', () => {
+ const view = homeCountryView({ timeZone: 'Asia/Tokyo', languages: [] });
+ assert.deepEqual(
+ [view.lat, view.lon, view.height],
+ [...COUNTRY_CENTRES.JP, START_VIEW.height],
+ );
+ assert.equal(
+ homeCountryView({ timeZone: 'UTC', languages: [] }),
+ START_VIEW,
+ 'unknown: the default start',
+ );
+});
+
+test('every zone has a country with a centre on the globe', () => {
+ for (const [zone, country] of Object.entries(ZONE_COUNTRIES)) {
+ const centre = COUNTRY_CENTRES[country];
+ assert.ok(centre, `${zone} → ${country}`);
+ const [lat, lon] = centre;
+ assert.ok(Math.abs(lat) <= 90 && Math.abs(lon) <= 180, country);
+ }
+ // Countries whose largest part is not where their centroid would be.
+ const [usLat, usLon] = COUNTRY_CENTRES.US;
+ assert.ok(usLat > 30 && usLat < 45 && usLon > -110 && usLon < -85);
+ const [frLat, frLon] = COUNTRY_CENTRES.FR;
+ assert.ok(frLat > 42 && frLat < 50 && frLon > -2 && frLon < 8);
+});
diff --git a/src/standalone/controls.js b/src/standalone/controls.js
index b168c5e1b3..1ecc7682f4 100644
--- a/src/standalone/controls.js
+++ b/src/standalone/controls.js
@@ -1,8 +1,11 @@
import { createApplicationControls } from '../app/controls.js';
import { getStandaloneCatalog } from './catalog.js';
+import { homeCountryView } from '../homeCountry.js';
export function createStandaloneControls(options) {
return createApplicationControls({
catalog: options?.catalog ?? getStandaloneCatalog(),
+ // The planet over the visitor's country; the title's logo goes back here.
+ startView: homeCountryView(),
...options,
});
}
diff --git a/src/standalone/startupChrome.js b/src/standalone/startupChrome.js
index 8eef323461..07183e42d9 100644
--- a/src/standalone/startupChrome.js
+++ b/src/standalone/startupChrome.js
@@ -1,8 +1,10 @@
import { startApplicationChrome } from '../app/startupChrome.js';
+import { playOpeningIntro } from '../app/openingIntro.js';
import { initKeySetup } from '../keySetup.js';
export function startStandaloneChrome(options) {
return startApplicationChrome({
initializeSettings: initKeySetup,
+ playOpening: playOpeningIntro,
...options,
});
}
diff --git a/src/standalone/startupChrome.test.mjs b/src/standalone/startupChrome.test.mjs
index 5f934a72bb..84ba38664f 100644
--- a/src/standalone/startupChrome.test.mjs
+++ b/src/standalone/startupChrome.test.mjs
@@ -10,7 +10,7 @@ const source = readFileSync(
.replace(/^import .*;\n/gm, '')
.replace('export function', 'function');
-function fixture() {
+function fixture({ playOpening, hasShareState = false } = {}) {
const timers = new Map();
const listeners = new Map();
const events = [];
@@ -44,7 +44,10 @@ function fixture() {
addEventListener: (type, listener) => listeners.set(type, listener),
removeEventListener: (type) => listeners.delete(type),
},
+ playOpening,
styleManager: {
+ hasShareState,
+ viewer: 'viewer',
initialRestorePromise: new Promise((resolve) => {
restored = resolve;
}),
@@ -124,3 +127,59 @@ test('shutdown during the cover transition cancels the listener and fallback', a
f.fire(900);
assert.deepEqual(f.events, ['hidden', 'settings:destroy']);
});
+
+function openingStub(events) {
+ let land;
+ const calls = [];
+ const play = (options) => {
+ calls.push(options);
+ events.push('opening');
+ return {
+ done: new Promise((resolve) => {
+ land = resolve;
+ }),
+ cancel: () => events.push('opening:cancel'),
+ };
+ };
+ return { play, calls, land: () => land() };
+}
+
+test('a bare address plays the opening, and welcome waits for its end', async () => {
+ const events = [];
+ const opening = openingStub(events);
+ const f = fixture({ playOpening: opening.play });
+ f.events.push = (value) => events.push(value);
+ f.restored();
+ f.fire(1000);
+ await flush();
+ assert.deepEqual(events, ['opening']);
+ assert.equal(opening.calls[0].viewer, 'viewer');
+ f.fire(900);
+ assert.deepEqual(events, ['opening'], 'no fallback timer while it plays');
+ opening.land();
+ await flush();
+ assert.deepEqual(events, ['opening', 'welcome']);
+ await f.stop();
+ assert.ok(events.includes('opening:cancel'));
+});
+
+test('a shared view opens without the opening', async () => {
+ const events = [];
+ const opening = openingStub(events);
+ const f = fixture({ playOpening: opening.play, hasShareState: true });
+ f.restored();
+ f.fire(1000);
+ await flush();
+ assert.equal(opening.calls.length, 0);
+ assert.deepEqual(f.events, ['hidden']);
+ await f.stop();
+});
+
+test('without an opening to play the cover hides as before', async () => {
+ const f = fixture({ playOpening: () => null });
+ f.restored();
+ f.fire(1000);
+ await flush();
+ assert.deepEqual(f.events, ['hidden']);
+ await f.stop();
+});
diff --git a/src/ui/styles/controls.css b/src/ui/styles/controls.css
index fd9c3788cd..472e21035e 100644
--- a/src/ui/styles/controls.css
+++ b/src/ui/styles/controls.css
@@ -431,6 +431,35 @@ html:not([lang='en']):not(:lang(zh)):not(:lang(ja))
}
}
+/* The opening (src/app/openingIntro.js) sets these each frame. */
+#loading-screen.opening {
+ background: color-mix(
+ in srgb,
+ var(--bg-dark) calc(var(--opening-veil, 1) * 100%),
+ transparent
+ );
+}
+
+#loading-screen.opening .loader-logo {
+ animation: none;
+ will-change: transform;
+}
+
+#loading-screen.opening .loader-logo svg {
+ overflow: visible;
+}
+
+#loading-screen.opening .loader-logo svg > path {
+ transform-box: fill-box;
+ transform-origin: center;
+}
+
+#loading-screen.opening h2,
+#loading-screen.opening .loader-status {
+ animation: none;
+ opacity: var(--opening-text, 1);
+}
+
.loader-content h2 {
font-family: var(--font-mono);
font-size: 18px;