Stories: GEV scenes as stories on the live globe

A Stories button (top right) opens Explore: a feed of GEV scenes over
GEV's own Cesium globe, with a pin per story. Explore opens at country
level over the first story and, while idle, flies on from story to story
for a minute. A picked story is framed in the middle of the view; a pin
plays its story on a second click. The Story page plays the scene through
SceneDirector with a timeline, chapters, key moments, sources and
background, then Close (or Back) puts the person's camera, clock, layers,
style and AUTHORING selection back. Open in GEV hands the scene to the
Scenes panel at its current shot.

Stories lists the scenes GEV ships with a camera path (while they are in
the project), the scenes saved with SAVE TO STORIES in AUTHORING, and the
person's other scenes as drafts. The person's own stories live in the
project on this device, so they have no Share; a link to a story that is
not here opens Explore and says so. Each shipped story's
context comes from what GEV knows: what it shows, the place each shot goes,
and each layer's data sources as DATA_SOURCES.md lists them; the Nepal
story carries the event pack's facts and CC BY-NC sources. Card images are
a captured THUMBNAIL or drawn from the keyless Esri World Imagery.

AUTHORING has no scene picker: it starts with no scene, NEW SCENE (or
CAPTURE SHOT) makes one, and Stories' Open in GEV selects one. Before SAVE
TO STORIES it offers topic tags and THUMBNAIL. A scene's stories flag,
storyThumb and storyTags are saved with the project and kept through
export and import.

Only the closed state loads with the page; the screens, styles, story data
and controller load on first open. Stories keeps its place in the query
(one history entry per screen) and holds the share link's hash writes
while open. Keyboard input and voice tools stay with Stories while it is
open. Explore's pins move on every drawn frame without asking for frames;
the idle tour and tile settling are bounded.

All strings are translated in the 13 locales.
This commit is contained in:
Manjunath committed 2026-11-16 20:12:10 +05:30
1 parent da81cf743b
commit 5418438339
77 files changed
+14975 -260

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
const STORIES_PARAMS = ['stories', 'story'];
const wantsStories = () => {
const params = new URLSearchParams(location.search);
return STORIES_PARAMS.some((p) => params.has(p));
};
/**
* Stories, loaded on first use. The controller, the story catalog, the
* screens and their styles are separate chunks, fetched when the person
* opens Stories, follows a Stories link or
* steps into Stories with Back or Forward. Until then the store holds this
* shell, whose calls load the controller and then run.
*
* @param {{viewer: import('cesium').Viewer,
* director: import('../scenes/director.js').SceneDirector,
* store: ReturnType<typeof import('../ui/stores/stories.js').useStoriesStore>,
* onLoadFailed?: () => void,
* loadModules?: () => Promise<[object, object]>}} options `onLoadFailed`
* tells the person a click did nothing because Stories could not load;
* `available` is false where Stories is not offered (an inline embed:
* its URL and history are the host page's);
* `loadModules` fetches the controller, catalog and Stories' styles
* (tests replace it).
*/
export function bootStories({
viewer,
director,
store,
onLoadFailed,
available = true,
loadModules = () =>
Promise.all([
import('./controller.js'),
import('./catalog.js'),
// Stories' screen styles, in place before the screens show, and the
// screens themselves, so opening does not wait on a second fetch.
import('../ui/styles/stories.css'),
import('../ui/views/stories/ExploreScreen.vue'),
import('../ui/views/stories/StoryScreen.vue'),
]),
}) {
store.available = available;
if (!available) {
const off = {
open: async () => {},
openStory: async () => {},
backToExplore: async () => {},
close: () => {},
reframe: () => {},
kind: null,
load: async () => null,
destroy: () => {},
};
store.connect(off, []);
return off;
}
let real = null;
let loading = null;
let destroyed = false;
function load() {
loading ??= loadModules().then(
([{ createStoriesController }, { listStories }]) => {
if (destroyed) return null;
removeEventListener('popstate', onPopState);
real = createStoriesController({
viewer,
director,
store,
});
store.connect(real, listStories());
return real;
},
);
// A failed fetch (offline, or a deploy replaced the chunk) is reported
// once, whatever asked (a click, a link, Back or Forward), and not kept:
// the next attempt tries again.
loading.catch((error) => {
loading = null;
console.warn('Stories could not load', error);
onLoadFailed?.();
});
return loading;
}
// The controller reads a Stories link on creation and opens it.
const onPopState = () => {
if (wantsStories()) load();
};
addEventListener('popstate', onPopState);
if (wantsStories()) load();
const later =
(name) =>
(...args) =>
load().then(
(c) => c?.[name](...args),
() => {}, // reported by load()
);
const shell = {
open: later('open'),
openStory: later('openStory'),
backToExplore: later('backToExplore'),
close: () => real?.close(),
reframe: () => real?.reframe(),
get kind() {
return real?.kind ?? null;
},
/** Resolves to the controller once it has loaded. */
load,
destroy() {
if (destroyed) return;
destroyed = true;
removeEventListener('popstate', onPopState);
real?.destroy();
},
};
store.connect(shell, []);
return shell;
}