mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 08:42:21 +00:00
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:
1 parent
da81cf743b
commit
5418438339
77 files changed
+14975
-260
No files matched your search
@@ -0,0 +1,142 @@
|
||||
// Stories loads its controller, catalog and engine on first use, not with GEV.
|
||||
import '../testSupport/registerDom.mjs';
|
||||
import { registerHooks } from 'node:module';
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createPinia, setActivePinia } from 'pinia';
|
||||
|
||||
// Every module Node loads, to see when the Stories chunk arrives.
|
||||
const loaded = new Set();
|
||||
registerHooks({
|
||||
load(url, context, next) {
|
||||
loaded.add(url);
|
||||
if (url.endsWith('.css'))
|
||||
return {
|
||||
format: 'module',
|
||||
source: 'export default "";',
|
||||
shortCircuit: true,
|
||||
};
|
||||
if (url.endsWith('.webp'))
|
||||
return {
|
||||
format: 'module',
|
||||
source: `export default ${JSON.stringify(url)};`,
|
||||
shortCircuit: true,
|
||||
};
|
||||
return next(url, context);
|
||||
},
|
||||
});
|
||||
const context = new Proxy(
|
||||
{},
|
||||
{ get: (target, name) => target[name] ?? (() => context), set: () => true },
|
||||
);
|
||||
globalThis.HTMLCanvasElement.prototype.getContext = (kind) =>
|
||||
kind === 'webgl' ? null : context;
|
||||
globalThis.requestAnimationFrame = () => 0;
|
||||
globalThis.cancelAnimationFrame = () => {};
|
||||
|
||||
const { bootStories } = await import('./boot.js');
|
||||
const { useStoriesStore } = await import('../ui/stores/stories.js');
|
||||
|
||||
const viewer = {
|
||||
scene: {
|
||||
canvas: document.createElement('canvas'),
|
||||
postRender: { addEventListener: () => () => {} },
|
||||
},
|
||||
camera: {
|
||||
positionWC: new Cesium.Cartesian3(1, 2, 3),
|
||||
positionCartographic: { latitude: 0, longitude: 0, height: 2e6 },
|
||||
heading: 0,
|
||||
pitch: -1,
|
||||
roll: 0,
|
||||
setView() {},
|
||||
flyTo() {},
|
||||
flyToBoundingSphere() {},
|
||||
cancelFlight() {},
|
||||
},
|
||||
clock: { currentTime: Cesium.JulianDate.now(), shouldAnimate: false },
|
||||
};
|
||||
const director = {
|
||||
running: false,
|
||||
stopScene() {},
|
||||
whenIdle: async () => {},
|
||||
listShots: () => [],
|
||||
subscribeSceneClock: () => () => {},
|
||||
seekScene() {},
|
||||
styleManager: { runImmediateNavigation: () => true },
|
||||
};
|
||||
|
||||
test('the shell loads the controller on first open, then steps aside', async () => {
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/');
|
||||
const store = useStoriesStore();
|
||||
const shell = bootStories({ viewer, director, store });
|
||||
assert.equal(store.controller, shell);
|
||||
assert.equal(store.stories.length, 0, 'no catalog until Stories is used');
|
||||
const engineLoaded = () =>
|
||||
[...loaded].some((u) =>
|
||||
/stories\/(controller|catalog|protoEngine)\.js$/.test(u),
|
||||
);
|
||||
assert.equal(engineLoaded(), false, 'GEV starts without the Stories chunk');
|
||||
await shell.open();
|
||||
assert.equal(engineLoaded(), true);
|
||||
assert.notEqual(store.controller, shell);
|
||||
assert.ok(store.stories.length > 0);
|
||||
assert.equal(store.mode, 'explore');
|
||||
shell.destroy();
|
||||
assert.equal(store.mode, 'closed');
|
||||
});
|
||||
|
||||
test('a Stories link loads the controller straight away', async () => {
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/?stories=explore');
|
||||
const store = useStoriesStore();
|
||||
const shell = bootStories({ viewer, director, store });
|
||||
const real = await shell.load();
|
||||
assert.equal(store.controller, real);
|
||||
shell.destroy();
|
||||
history.replaceState(null, '', '/');
|
||||
});
|
||||
|
||||
test('a failed load is reported and the next open tries again', async () => {
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/');
|
||||
const store = useStoriesStore();
|
||||
let failures = 0;
|
||||
let attempts = 0;
|
||||
const shell = bootStories({
|
||||
viewer,
|
||||
director,
|
||||
store,
|
||||
onLoadFailed: () => (failures += 1),
|
||||
// The Stories chunk is unreachable on the first try only.
|
||||
loadModules: () =>
|
||||
++attempts === 1
|
||||
? Promise.reject(new Error('offline'))
|
||||
: Promise.all([import('./controller.js'), import('./catalog.js')]),
|
||||
});
|
||||
await shell.open();
|
||||
assert.equal(failures, 1);
|
||||
assert.equal(store.mode, 'closed');
|
||||
await shell.open();
|
||||
assert.equal(attempts, 2, 'the failure was not kept');
|
||||
assert.equal(store.mode, 'explore');
|
||||
shell.destroy();
|
||||
});
|
||||
|
||||
test('a Stories link that cannot load is reported too', async () => {
|
||||
setActivePinia(createPinia());
|
||||
history.replaceState(null, '', '/?story=worldfx%3Afire-tracker');
|
||||
const store = useStoriesStore();
|
||||
let failures = 0;
|
||||
bootStories({
|
||||
viewer,
|
||||
director,
|
||||
store,
|
||||
onLoadFailed: () => (failures += 1),
|
||||
loadModules: () => Promise.reject(new Error('offline')),
|
||||
});
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
assert.equal(failures, 1);
|
||||
history.replaceState(null, '', '/');
|
||||
});
|
||||
Reference in new issue
Block a user