ISS live telemetry, STATION and LIVE sections, Tiangong model, drawn through the renderer's draw port

Builds on the ISS 3D model (PR #1690) and brings it onto main's renderer
seam: the station models are items of a `models` draw set, posed by
heading, pitch and roll from the station's flight axes
(`headingPitchRollOfAxes`), with the camera, canvas and clicks read from
the renderer's ports; no satellites file reaches Cesium. The joint drivers
write column-major matrices into node poses the model part keeps, for a
renderer that can pose nodes; until the draw contract has that member the
models draw rigid.

- ISS joints take their angles from NASA's ISSLive telemetry, relayed by
  the server behind ISS_TELEMETRY_ENABLED.
- STATION and LIVE sections of Context replace the floating command panel
  and player; both collapse like the Radio section.
- Cockpit rides the ISS from mounts on its model; the LIVE page in the
  Cockpit briefing.
- Tiangong as a second station model, with computed joints.
- Installations: a label-box click selects the site.
This commit is contained in:
Denis Groshev committed 2026-11-16 18:39:39 +01:00
1 parent fd3ca679ec
commit 9cc077964f
103 files changed
+12033 -1775

No files matched your search

+46 -1
View File
@@ -1,6 +1,6 @@
import { followedOf } from '../data/followed.js';
import { readEntityRecord } from '../data/entityRecords.js';
import { nextTick } from 'vue';
import { nextTick, watch } from 'vue';
import { resolveImageryHost } from '../layers/weather/imageryHost.js';
import { ShellFacade } from './shellFacade.js';
import { AircraftDisplay } from './aircraftDisplay.js';
@@ -25,6 +25,7 @@ import { CctvControls } from './cctv.js';
import { StreetLevelControls } from './streetLevelControls.js';
import { createWildlifeSightingCard } from './wildlifeSightingCard.js';
import { RadioControls } from './radio.js';
import { LiveControls } from './liveControls.js';
import { LocalSdrControls } from './localSdrControls.js';
import { LocationNavigation } from './locationNavigation.js';
import { bindCameraOrientationControls } from './cameraOrientationControls.js';
@@ -62,6 +63,8 @@ import { applyLocaleChoice } from './localePicker.js';
import { PanelNavigation } from './panelNavigation.js';
import { applicationPinia, createUiRuntime } from './vueRuntime.js';
import { useContextStore } from './stores/context.js';
import { useLiveStore } from './stores/live.js';
import { useStationStore } from './stores/station.js';
import { useMissionReplayStore } from './stores/missionReplay.js';
import { useCelestialRingStore } from './stores/celestialRing.js';
import { icrfToFixedAxes } from '../sky/icrf.js';
@@ -994,6 +997,7 @@ export class StyleManager extends ShellFacade {
militaryInstallationsLayer,
militaryAwarenessLayer,
rocketLaunchesLayer,
satellitesLayer,
} = this.services;
const contextStore = useContextStore(applicationPinia());
this._contextControls = new ContextControls({
@@ -1050,6 +1054,39 @@ export class StyleManager extends ShellFacade {
rocketLaunchesLayer?.subscribeReplayOverlay?.((view) =>
missionReplayStore.publish(view),
);
// The STATION section: the selected space station's moving parts, as
// the satellites layer presents them; its controls reach the layer.
const stationStore = useStationStore(applicationPinia());
this._stationPanelUnsubscribe?.();
if (this._stationOwner) stationStore.detach(this._stationOwner);
this._stationOwner = null;
stationStore.publish(null);
if (satellitesLayer?.getStationActions)
this._stationOwner = stationStore.connect(
satellitesLayer.getStationActions(),
);
this._stationPanelUnsubscribe = satellitesLayer?.subscribeStationPanel?.(
(view) => stationStore.publish(view),
);
// The LIVE section: streams attached to whatever the tracking layers
// select, in the platform's own player, started as soon as one is chosen.
this._liveControls?.destroy();
const liveStore = useLiveStore(applicationPinia());
this._liveControls = new LiveControls({
store: liveStore,
actions: {
getLayer: (layerId) =>
this._dataManager?.layers?.get(layerId)?.module ?? null,
scheduleLayout: () => this._scheduleRightPanelLayout(),
},
});
// The Cockpit briefing offers its LIVE page while a stream is on offer.
this._liveOfferedUnwatch?.();
this._liveOfferedUnwatch = watch(
() => liveStore.view !== null,
(offered) => this.cockpitView?.setBriefLiveOffered?.(offered),
{ immediate: true },
);
}
/** Wire the independent Radio companion controls. */
@@ -1907,6 +1944,14 @@ export class StyleManager extends ShellFacade {
this.services?.streetLevelLayer?.attachNavigation?.(null);
this._streetLevelControls?.destroy();
this._radioControls?.destroy();
this._liveControls?.destroy();
this._liveOfferedUnwatch?.();
this._liveOfferedUnwatch = null;
this._stationPanelUnsubscribe?.();
this._stationPanelUnsubscribe = null;
if (this._stationOwner)
useStationStore(applicationPinia()).detach(this._stationOwner);
this._stationOwner = null;
this._localSdrControls?.destroy();
this._awarenessPanelUnsubscribe?.();
this._awarenessPanelUnsubscribe = null;
+42
View File
@@ -46,6 +46,48 @@ export const COCKPIT_BRIEF_PAGES = [
},
];
/**
* The fourth page, LIVE: the ridden subject's live video, the LIVE section
* of Context in the card. Offered only while a stream is on offer (the
* `gev-live` store's view is not null); the automatic cycle never turns to it.
*/
export const COCKPIT_LIVE_BRIEF_PAGE = Object.freeze({
id: 'live',
kickerKey: msg('LIVE VIDEO'),
subtitleKey: msg('STREAM ATTACHED TO THE SUBJECT'),
// Attribution stays English; the page itself credits the stream's owner.
source: 'YOUTUBE EMBEDDED PLAYER · MUTED',
});
/**
* The pages on offer: the three fixed ones, and LIVE after them while the
* ridden subject has a stream.
* @param {boolean} liveOffered
* @returns {readonly object[]}
*/
export function cockpitBriefPages(liveOffered) {
return liveOffered
? [...COCKPIT_BRIEF_PAGES, COCKPIT_LIVE_BRIEF_PAGE]
: COCKPIT_BRIEF_PAGES;
}
/**
* Where the automatic cycle goes from the page at `index`: the next page
* that is not LIVE (video is never started by the cycle), wrapping; null
* while LIVE is the shown page, where the cycle waits as it does under the
* pointer.
* @param {readonly object[]} pages
* @param {number} index
* @returns {number|null}
*/
export function briefCycleTarget(pages, index) {
if (pages[index]?.id === 'live') return null;
const count = pages.length;
let next = (index + 1) % count;
if (pages[next]?.id === 'live') next = (next + 1) % count;
return next;
}
// The cycle toggle's tooltip, as literal keys for the extractor.
export const CYCLE_HELP_KEYS = Object.freeze({
on: msg(
+31 -4
View File
@@ -9,8 +9,9 @@ import {
formatCockpitWindDirection,
} from './cockpitPresentation.js';
import {
COCKPIT_BRIEF_PAGES,
CYCLE_HELP_KEYS,
briefCycleTarget,
cockpitBriefPages,
createBriefState,
newsWindowFooter,
} from './cockpitBriefPages.js';
@@ -48,11 +49,17 @@ export function publishBriefView() {
});
}
/** The pages on offer now: three, or four with LIVE while a stream is. */
function briefPages() {
return cockpitBriefPages(this.briefLiveOffered === true);
}
export function showBriefPage(index, { manual = false } = {}) {
if (this.destroyed) return;
const count = COCKPIT_BRIEF_PAGES.length;
const pages = briefPages.call(this);
const count = pages.length;
this.briefPageIndex = ((Number(index) % count) + count) % count;
const page = COCKPIT_BRIEF_PAGES[this.briefPageIndex];
const page = pages[this.briefPageIndex];
Object.assign(this.brief, {
pageIndex: this.briefPageIndex,
pageId: page.id,
@@ -101,6 +108,20 @@ export function relocalizeBrief() {
this.renderRegionalBriefStatus(this.brief.news.state, this.lastSubjectInfo);
}
/**
* Offer or withdraw the LIVE page, as the ridden subject's stream comes and
* goes. A LIVE page shown as its stream goes falls back to Live Signals;
* otherwise the shown page stays and its position counts the pages anew.
*/
export function setBriefLiveOffered(offered) {
if (this.destroyed) return;
const next = offered === true;
if (next === this.briefLiveOffered) return;
this.briefLiveOffered = next;
const count = cockpitBriefPages(next).length;
this.showBriefPage(this.briefPageIndex < count ? this.briefPageIndex : 0);
}
export function setBriefAutoRotate(enabled) {
if (this.destroyed) return;
this.briefAutoRotateEnabled = Boolean(enabled);
@@ -129,7 +150,13 @@ export function startBriefRotation({ reset = false } = {}) {
this.signalStream?.contains(document.activeElement) === true;
const isInteracting = hasPointer || hasFocus;
if (!isInteracting) {
this.showBriefPage(this.briefPageIndex + 1);
// The cycle never turns to the LIVE page, and waits while it is shown:
// video starts and stops on request only.
const target = briefCycleTarget(
briefPages.call(this),
this.briefPageIndex,
);
if (target !== null) this.showBriefPage(target);
}
this.startBriefRotation();
}, COCKPIT_BRIEF_ROTATE_MS);
+191 -4
View File
@@ -8,18 +8,24 @@ import { fileURLToPath } from 'node:url';
import { createPinia } from 'pinia';
import { createApp, nextTick } from 'vue';
import { setLocale } from '../i18n/index.js';
import { createBriefState } from './cockpitBriefPages.js';
import {
briefCycleTarget,
cockpitBriefPages,
createBriefState,
} from './cockpitBriefPages.js';
import {
maybeRefreshRegionalBrief,
publishBriefView,
renderRegionalBrief,
renderRegionalBriefStatus,
setBriefAutoRotate,
setBriefLiveOffered,
showBriefPage,
updateLocalPosition,
} from './cockpitBriefing.js';
import { setSignalCollapsed } from './cockpitLayout.js';
import { useCockpitStore } from './stores/cockpit.js';
import { useLiveStore } from './stores/live.js';
import CockpitBriefing from './views/panels/CockpitBriefing.vue';
function fixture(t) {
@@ -35,9 +41,11 @@ function fixture(t) {
destroyed: false,
briefPageIndex: 0,
briefAutoRotateEnabled: false,
briefLiveOffered: false,
brief: createBriefState(),
publishBrief: (view) => store.publishBrief(view),
publishBriefView,
showBriefPage,
scheduleContextLayout() {},
startBriefRotation() {},
stopBriefRotation() {},
@@ -49,11 +57,49 @@ function fixture(t) {
[...document.querySelectorAll('[data-cockpit-brief-page]')]
.filter((page) => !page.hidden)
.map((page) => page.dataset.cockpitBriefPage);
// The tabs on offer: the LIVE tab is in the markup but hidden without a stream.
const current = () =>
[...document.querySelectorAll('[data-cockpit-brief-index]')].map((tab) =>
tab.getAttribute('aria-current'),
[...document.querySelectorAll('[data-cockpit-brief-index]')]
.filter((tab) => !tab.hidden)
.map((tab) => tab.getAttribute('aria-current'));
// A stream on offer for the ridden subject, as LiveControls publishes it;
// the briefing then offers its LIVE page.
const liveStore = useLiveStore(pinia);
const liveActed = [];
liveStore.connect({
cycleLive: (direction) => liveActed.push(['cycle', direction]),
playLive: () => liveActed.push(['play']),
stopLive: () => liveActed.push(['stop']),
retryLive: () => liveActed.push(['retry']),
});
const offerLive = async (view) => {
liveStore.publish(
view && {
label: 'ISS (ZARYA)',
streams: [
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
{ id: 'iss-crew', title: 'Live video and audio', owner: 'NASA' },
],
index: 0,
count: 2,
current: {
id: 'iss-exterior',
title: 'Exterior cameras',
owner: 'NASA',
ownerUrl: 'https://www.youtube.com/@NASA',
note: 'NASA video, via YouTube',
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
},
state: 'idle',
reason: null,
...view,
},
);
return { $, text, owner, visiblePages, current };
setBriefLiveOffered.call(owner, view !== null);
await nextTick();
await nextTick();
};
return { $, text, owner, visiblePages, current, offerLive, liveActed };
}
const INFO = { latitude: 30.25, longitude: -97.75 };
@@ -111,6 +157,147 @@ test('pages, the cycle toggle and the source follow the controller', async (t) =
assert.match(auto.title, /^Stop automatic page cycling/);
});
test('without a stream the briefing keeps its three pages and hides the LIVE tab', async (t) => {
const { $, text, owner, visiblePages } = fixture(t);
const liveTab = $('[data-cockpit-brief-index="3"]');
assert.equal(liveTab.hidden, true);
assert.equal(liveTab.textContent, 'LIVE');
assert.equal(liveTab.getAttribute('aria-label'), 'Show Live Video');
assert.equal(
$('[data-cockpit-brief-page="live"]').querySelector('*'),
null,
'no page body without a stream',
);
// Next from Local wraps to Live Signals, past the page not on offer.
showBriefPage.call(owner, 3);
await nextTick();
assert.deepEqual(visiblePages(), ['signals']);
assert.equal(text('#cockpit-brief-position'), '1 / 3');
});
test('with a stream the LIVE page is the fourth, reached by the arrows and its tab', async (t) => {
const { $, text, owner, visiblePages, current, offerLive } = fixture(t);
await offerLive({});
assert.equal(text('#cockpit-brief-position'), '1 / 4');
const liveTab = $('[data-cockpit-brief-index="3"]');
assert.equal(liveTab.hidden, false);
assert.deepEqual(current(), ['true', 'false', 'false', 'false']);
showBriefPage.call(owner, 2);
showBriefPage.call(owner, owner.briefPageIndex + 1);
await nextTick();
assert.deepEqual(visiblePages(), ['live']);
assert.deepEqual(current(), ['false', 'false', 'false', 'true']);
assert.equal(text('#cockpit-brief-kicker'), 'LIVE VIDEO');
assert.equal(
text('#cockpit-brief-subtitle'),
'STREAM ATTACHED TO THE SUBJECT',
);
assert.equal(text('#cockpit-brief-position'), '4 / 4');
assert.equal(
text('#cockpit-brief-source'),
'YOUTUBE EMBEDDED PLAYER · MUTED',
);
assert.equal($('#cockpit-signal-stream').dataset.briefPage, 'live');
// The page shows what the LIVE section shows, with the player's own screen.
const page = $('[data-cockpit-brief-page="live"]');
assert.equal(
page.querySelector('.cockpit-live-subject strong').textContent,
'ISS (ZARYA)',
);
assert.equal(text('#cockpit-live-stream-title'), 'Exterior cameras · 1/2');
assert.ok($('#cockpit-live-player-host'));
assert.ok($('#cockpit-live-previous'));
assert.ok($('#cockpit-live-next'));
assert.equal(text('#cockpit-live-badge-text'), 'OFF');
assert.equal(text('#cockpit-live-status'), 'Starting…');
assert.equal(
$('#cockpit-live-watch-link').getAttribute('href'),
'https://www.youtube.com/watch?v=ROboUHfPUrU',
);
// Next from LIVE wraps to Live Signals.
showBriefPage.call(owner, owner.briefPageIndex + 1);
await nextTick();
assert.deepEqual(visiblePages(), ['signals']);
assert.equal(text('#cockpit-brief-position'), '1 / 4');
});
test('the LIVE page asks for the stream as soon as it is offered, and its controls reach LiveControls', async (t) => {
const { $, owner, offerLive, liveActed } = fixture(t);
await offerLive({});
assert.deepEqual(
liveActed,
[['play']],
'the player starts on selection, whichever page is shown',
);
showBriefPage.call(owner, 3);
await offerLive({ state: 'playing' });
const page = $('[data-cockpit-brief-page="live"]');
assert.equal($('#cockpit-live-badge-text').textContent, 'ON AIR');
assert.equal(
page.querySelector('.live-dot').classList.contains('on-air'),
true,
);
assert.equal(
page.querySelector('.live-screen').classList.contains('active'),
true,
);
assert.equal($('#cockpit-live-status').textContent, 'Live');
$('#cockpit-live-next').click();
$('#cockpit-live-previous').click();
assert.deepEqual(liveActed, [['play'], ['cycle', 1], ['cycle', -1]]);
await offerLive({ state: 'offline', reason: 'timeout' });
const card = page.querySelector('.live-card');
assert.equal(card.classList.contains('offline'), true);
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
$('#cockpit-live-retry').click();
assert.deepEqual(liveActed.at(-1), ['retry']);
await offerLive({ state: 'unavailable', reason: 'error-150' });
assert.equal($('#cockpit-live-retry'), null);
assert.equal(
$('#cockpit-live-status').textContent,
'This stream cannot play here',
);
});
test('the stream going while LIVE is shown falls back to Live Signals with three pages', async (t) => {
const { $, text, owner, visiblePages, offerLive } = fixture(t);
await offerLive({});
showBriefPage.call(owner, 3);
await nextTick();
assert.deepEqual(visiblePages(), ['live']);
await offerLive(null);
assert.deepEqual(visiblePages(), ['signals']);
assert.equal(text('#cockpit-brief-position'), '1 / 3');
assert.equal($('[data-cockpit-brief-index="3"]').hidden, true);
// Going on another page, the page stays and only the count changes.
showBriefPage.call(owner, 1);
await offerLive({});
assert.deepEqual(visiblePages(), ['news']);
assert.equal(text('#cockpit-brief-position'), '2 / 4');
// Offering what is already offered changes nothing.
const views = [];
owner.publishBrief = (view) => views.push(view);
setBriefLiveOffered.call(owner, true);
assert.equal(views.length, 0);
});
test('the automatic cycle never turns to the LIVE page and waits while it is shown', () => {
const three = cockpitBriefPages(false);
assert.deepEqual(
[0, 1, 2].map((index) => briefCycleTarget(three, index)),
[1, 2, 0],
);
const four = cockpitBriefPages(true);
assert.equal(four.length, 4);
assert.equal(four[3].id, 'live');
assert.deepEqual(
[0, 1, 2].map((index) => briefCycleTarget(four, index)),
[1, 2, 0],
'Local goes back to Live Signals, past LIVE',
);
assert.equal(briefCycleTarget(four, 3), null, 'shown by hand, LIVE stays');
});
test('regional news and local conditions render what the region returned', async (t) => {
const { $, text, owner } = fixture(t);
renderRegionalBriefStatus.call(owner, 'loading', INFO);
+32
View File
@@ -26,10 +26,12 @@ import {
import { update } from './cockpitCamera.js';
import {
beginOrbital,
orbitalViewSignal,
endOrbital,
resetOrbitalLook,
jumpToSensorSwath,
onOrbitalWheel,
stepOrbitalMount,
stepOrbitalZoom,
turnOrbitalLook,
updateOrbital,
@@ -77,6 +79,7 @@ import {
publishBriefView,
showBriefPage,
setBriefAutoRotate,
setBriefLiveOffered,
startBriefRotation,
stopBriefRotation,
updateLocalPosition,
@@ -271,6 +274,8 @@ export class CockpitViewController {
this.signalSignatures = new Map();
this.briefPageIndex = 0;
this.briefAutoRotateEnabled = false;
/** Whether the briefing offers its LIVE page (the subject has a stream). */
this.briefLiveOffered = false;
// Cockpit's views render what these receive.
this.publishPresence = publish.presence ?? (() => {});
this.publishBrief = publish.brief ?? (() => {});
@@ -401,6 +406,10 @@ export class CockpitViewController {
else if (target?.closest?.('#cockpit-orbital-zoom-out'))
this.stepOrbitalZoom(-1);
else if (target?.closest?.('#cockpit-orbital-nadir')) this.orbitalNadir();
else if (target?.closest?.('#cockpit-orbital-view-next'))
this.nextOrbitalView();
else if (target?.closest?.('#cockpit-orbital-view-previous'))
this.previousOrbitalView();
else if (target?.closest?.('#cockpit-orbital-sensor'))
this.jumpToSensorSwath();
});
@@ -454,6 +463,26 @@ export class CockpitViewController {
beginOrbital() {
return beginOrbital.call(this);
}
orbitalViewSignal(info) {
return orbitalViewSignal.call(this, info);
}
/**
* The station view's right arrow: step to the station's next view.
* @returns {boolean} True when the view changed.
*/
nextOrbitalView() {
return stepOrbitalMount.call(this, 1);
}
/**
* The station view's left arrow: step back to the view before.
* @returns {boolean} True when the view changed.
*/
previousOrbitalView() {
return stepOrbitalMount.call(this, -1);
}
endOrbital() {
return endOrbital.call(this);
}
@@ -711,6 +740,9 @@ export class CockpitViewController {
setBriefAutoRotate(enabled) {
return setBriefAutoRotate.call(this, enabled);
}
setBriefLiveOffered(offered) {
return setBriefLiveOffered.call(this, offered);
}
startBriefRotation(options) {
return startBriefRotation.call(this, options);
}
+36 -6
View File
@@ -115,8 +115,19 @@ function sitePosition(site) {
: null;
}
/** The mapped site a canvas position shows, through the layer's picks. */
/**
* The mapped site a canvas position shows: through the layer's own lookup
* where it has one (`findAt`: the dot, the site entity or the label box the
* overlay paints, which is what a click lands on from orbit), else through
* its pick ids.
*/
function siteAt(controller, position) {
try {
const found = sitesLayer(controller)?.findAt?.(position) ?? null;
if (found) return found;
} catch {
// Fall through to the pick ids.
}
let picked = null;
try {
picked = findQuery(controller.viewer)?.pick(position.x, position.y) ?? null;
@@ -297,15 +308,26 @@ export function routeSceneClick() {
* held from its last record). Also rebuilds
* the orbital Live Signals rows on their own clock.
* @param {object} state The orbital session.
* @param {{direction: object, up: object, right: object}} nadir This
* frame's nadir frame.
* @param {{x: number, y: number, z: number}} position The satellite, ECEF.
* @param {{direction: object, up: object, right: object}} nadir The frame
* the look turns about this frame: the nadir one, or a station view's.
* @param {{x: number, y: number, z: number}} position Where the camera is,
* ECEF: the satellite, or the station view's point on it.
* @param {number} nowMs
* @param {{direction: object, up: object, right: object}|null} [trueNadir]
* The nadir frame when `nadir` is a station view's: the rows still word
* their angles from straight down.
* @returns {boolean} True when it placed `state.lookView` itself.
*/
export function updateOrbitalFocus(state, nadir, position, nowMs) {
export function updateOrbitalFocus(
state,
nadir,
position,
nowMs,
trueNadir = null,
) {
state.focusFrame = {
nadir,
trueNadir,
position: { x: position.x, y: position.y, z: position.z },
};
// After a satellite switch the first frame on the new satellite (the hop
@@ -459,13 +481,21 @@ export function orbitalSitesInReach(info) {
});
state.listedSites = remembered;
const focusKey = state.focus?.key ?? null;
const positions = new Map(candidates.map((c) => [c.key, c.position]));
// Reach is measured about the frame the look turns in; the angle shown
// is always from straight down, also from a station view.
const shownOffNadir = (key, offNadirDeg) => {
if (!frame.trueNadir) return offNadirDeg;
const look = focusLook(frame.trueNadir, frame.position, positions.get(key));
return Number.isFinite(look?.offNadirDeg) ? look.offNadirDeg : offNadirDeg;
};
return {
entries: pointsInReach(candidates, {
nadir: frame.nadir,
satellite: frame.position,
}).map(({ key, offNadirDeg }) => ({
site: byId.get(key),
offNadirDeg,
offNadirDeg: shownOffNadir(key, offNadirDeg),
focused: key === focusKey,
})),
};
+436 -63
View File
@@ -39,10 +39,34 @@ const FRAME_MS = 16;
/** Satellites the layer knows, by NORAD id: the ridden one and its neighbours. */
const SATELLITES = Object.freeze({
25544: { name: 'ISS (ZARYA)', lat: 30, lon: -97, alt: 420_000, cls: 'stations' },
49260: { name: 'LANDSAT 9', lat: 31.5, lon: -95, alt: 705_000, cls: 'imaging' },
40697: { name: 'SENTINEL-2A', lat: 26, lon: -99, alt: 786_000, cls: 'imaging' },
99001: { name: 'DEB FRAGMENT', lat: 30.2, lon: -97.1, alt: 430_000, cls: 'debris' },
25544: {
name: 'ISS (ZARYA)',
lat: 30,
lon: -97,
alt: 420_000,
cls: 'stations',
},
49260: {
name: 'LANDSAT 9',
lat: 31.5,
lon: -95,
alt: 705_000,
cls: 'imaging',
},
40697: {
name: 'SENTINEL-2A',
lat: 26,
lon: -99,
alt: 786_000,
cls: 'imaging',
},
99001: {
name: 'DEB FRAGMENT',
lat: 30.2,
lon: -97.1,
alt: 430_000,
cls: 'debris',
},
});
/** Mapped sites as the installations layer keeps them. */
@@ -56,6 +80,8 @@ const SITES = Object.freeze({
lon: -96.5,
memberNames: ['North Field'],
at: { x: 100, y: 100 },
// Where the overlay paints its label box: nothing picks there.
labelAt: { x: 140, y: 70 },
},
bravo: {
id: 'osm:military:way/202',
@@ -100,7 +126,11 @@ function installationsLayer() {
withPosition(record) {
return {
...record,
position: Cesium.Cartesian3.fromDegrees(record.longitude, record.latitude, 0),
position: Cesium.Cartesian3.fromDegrees(
record.longitude,
record.latitude,
0,
),
};
},
// As the layer's own: loaded installations within `rangeM` of
@@ -117,7 +147,10 @@ function installationsLayer() {
from,
Cesium.Cartographic.fromDegrees(record.longitude, record.latitude),
);
return { ...layer.withPosition(record), distanceM: geodesic.surfaceDistance };
return {
...layer.withPosition(record),
distanceM: geodesic.surfaceDistance,
};
})
.filter((record) => record.distanceM <= rangeM)
.sort((a, b) => a.distanceM - b.distanceM)
@@ -133,6 +166,17 @@ function installationsLayer() {
const id = hit?.meta?.installationId ?? null;
return id ? layer.getById(id) : null;
},
// As the layer's: the label box the overlay paints, where no primitive
// picks (the dot is left to the pick ids here).
findAt(position) {
const site = Object.values(SITES).find(
(s) =>
s.labelAt &&
s.labelAt.x === position?.x &&
s.labelAt.y === position?.y,
);
return site ? layer.getById(site.id) : null;
},
};
return layer;
}
@@ -190,7 +234,11 @@ function satellitesLayer(viewer) {
},
// As the layer's: the nearest shown satellites, bounded, with the
// asked-for ids and classes left out.
getNearestPositions(center, maxCount = 8, { excludeIds = [], excludeClasses = [] } = {}) {
getNearestPositions(
center,
maxCount = 8,
{ excludeIds = [], excludeClasses = [] } = {},
) {
layer.calls.push(['nearest']);
const skip = new Set(excludeIds.map(String));
return layer
@@ -214,7 +262,9 @@ function satellitesLayer(viewer) {
if (!positions.has(id)) return false;
layer.calls.push(['track', id]);
layer.tracked = id;
followEntity(viewer, { position: { getValue: () => layer.position(id) } });
followEntity(viewer, {
position: { getValue: () => layer.position(id) },
});
return true;
},
setCockpitSubject(noradId) {
@@ -234,7 +284,11 @@ function fixture(t, { reducedMotion = false } = {}) {
const host = document.body.appendChild(document.createElement('div'));
const pinia = createPinia();
const app = createApp(
defineComponent(() => () => [h(ContextView), h(IntelHudView), h(CockpitView)]),
defineComponent(() => () => [
h(ContextView),
h(IntelHudView),
h(CockpitView),
]),
).use(pinia);
app.mount(host);
useHudStore(pinia);
@@ -276,7 +330,10 @@ function fixture(t, { reducedMotion = false } = {}) {
handler.stockDouble = ({ position }) => {
handler.stockDoubleClicks += 1;
const picked = picks.get(`${position.x},${position.y}`);
followEntity(viewer, picked ? { position: { getValue: () => null } } : null);
followEntity(
viewer,
picked ? { position: { getValue: () => null } } : null,
);
};
// The viewer's stock handler holds them, so the scene's input has them to
// hold off.
@@ -374,7 +431,11 @@ function fixture(t, { reducedMotion = false } = {}) {
globalThis.matchMedia = previousMatchMedia;
performance.now = originalNow;
Date.now = originalDateNow;
document.body.classList.remove('cockpit-mode', 'cockpit-bridge', 'cockpit-orbit');
document.body.classList.remove(
'cockpit-mode',
'cockpit-bridge',
'cockpit-orbit',
);
});
const frame = () => {
@@ -454,7 +515,10 @@ function missDeg(shot, key) {
/** The camera's angle from nadir, degrees. */
function offNadir(shot) {
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
const toCentre = Cesium.Cartesian3.negate(
shot.destination,
new Cesium.Cartesian3(),
);
return angleDeg(shot.direction, toCentre);
}
@@ -465,7 +529,10 @@ function siteOffNadir(shot, key) {
shot.destination,
new Cesium.Cartesian3(),
);
const toCentre = Cesium.Cartesian3.negate(shot.destination, new Cesium.Cartesian3());
const toCentre = Cesium.Cartesian3.negate(
shot.destination,
new Cesium.Cartesian3(),
);
return angleDeg(line, toCentre);
}
@@ -520,7 +587,9 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
assert.ok(shown.length <= 5, 'five rows at most');
assert.equal(shown[0].title, 'TRACK ACQUIRED', 'the track row stays first');
// Two site rows, nearest to nadir first, then the satellites (debris out).
const sitesShown = shown.filter((row) => row.target?.layerId === 'military-installations');
const sitesShown = shown.filter(
(row) => row.target?.layerId === 'military-installations',
);
assert.deepEqual(
sitesShown.map((row) => row.target.id).sort(),
[SITES.alpha.id, SITES.bravo.id].sort(),
@@ -529,16 +598,33 @@ test('in orbit Live Signals lists the sites getNearby finds and the nearest sate
assert.match(row.detail, /^(BASE|AIRFIELD) · OFF-NADIR \d+\.\d°$/);
assert.match(row.className, /nearby actionable/);
}
const satellitesShown = shown.filter((row) => row.target?.layerId === 'satellites');
assert.deepEqual(satellitesShown.map((row) => row.title), ['LANDSAT 9', 'SENTINEL-2A']);
assert.match(satellitesShown[0].detail, /^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/);
const satellitesShown = shown.filter(
(row) => row.target?.layerId === 'satellites',
);
assert.deepEqual(
satellitesShown.map((row) => row.title),
['LANDSAT 9', 'SENTINEL-2A'],
);
assert.match(
satellitesShown[0].detail,
/^SATELLITE · (AHEAD|[LR] \d{3}°) · [\d,.]+\s+KM$/,
);
// Each row names its own action.
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Keep the camera on Camp Alpha');
assert.equal(satelliteRow(scene, 49260).getAttribute('aria-label'), 'Ride LANDSAT 9');
assert.equal(
siteRow(scene, 'alpha').getAttribute('aria-label'),
'Keep the camera on Camp Alpha',
);
assert.equal(
satelliteRow(scene, 49260).getAttribute('aria-label'),
'Ride LANDSAT 9',
);
// Rebuilt on the clock, rows keep their keys and times.
const before = shown.map((row) => [row.key, row.time]);
await refreshRows(scene);
assert.deepEqual(rows(scene).map((row) => [row.key, row.time]), before);
assert.deepEqual(
rows(scene).map((row) => [row.key, row.time]),
before,
);
});
test('a site row turns the camera onto it, holds it, and reads its off-nadir angle', async (t) => {
@@ -550,11 +636,17 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
// The first frames turn part of the way: no jump onto the site.
assert.ok(missDeg(scene.frame(), 'alpha') > 5, 'still turning');
const largest = run(scene, LAND_FRAMES);
assert.ok(largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
assert.ok(
largest > 0.1 && largest < MAX_TURN_PER_FRAME_DEG,
`turned ${largest}° in a frame`,
);
for (let i = 0; i < 20; i += 1) {
scene.satellites.move(0.002, 0.002);
const shot = scene.frame();
assert.ok(missDeg(shot, 'alpha') < 1e-5, `frame ${i}: ${missDeg(shot, 'alpha')}°`);
assert.ok(
missDeg(shot, 'alpha') < 1e-5,
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
);
}
for (let i = 0; i < 8; i += 1) scene.frame();
await settle();
@@ -564,14 +656,20 @@ test('a site row turns the camera onto it, holds it, and reads its off-nadir ang
`OFF-NADIR ${siteOffNadir(shot, 'alpha').toFixed(1)}°`,
);
assert.equal($('#cockpit-orbital-focus').textContent, 'FOCUS · Camp Alpha');
assert.equal($('#cockpit-orbital-look-readout').getAttribute('aria-live'), 'off');
assert.equal(
$('#cockpit-orbital-look-readout').getAttribute('aria-live'),
'off',
);
assert.equal(store.orbital.footprintKm, null);
assert.match($('.cockpit-orbital-swath').textContent, /^SWATH ≈ [\d.]+ KM$/);
// The held site's row reads as the subject does, first among the sites.
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
assert.match(held.className, /^track actionable$/);
assert.match(held.detail, /^FOCUS · BASE · OFF-NADIR/);
assert.equal(siteRow(scene, 'alpha').getAttribute('aria-label'), 'Release the camera from Camp Alpha');
assert.equal(
siteRow(scene, 'alpha').getAttribute('aria-label'),
'Release the camera from Camp Alpha',
);
});
test('another site row switches the focus; the held site row ends it', async (t) => {
@@ -586,7 +684,10 @@ test('another site row switches the focus; the held site row ends it', async (t)
assert.ok(largest < MAX_TURN_PER_FRAME_DEG, `turned ${largest}° in a frame`);
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5);
await settle();
assert.match(rows(scene).find((row) => row.target?.id === SITES.alpha.id).className, /^nearby/);
assert.match(
rows(scene).find((row) => row.target?.id === SITES.alpha.id).className,
/^nearby/,
);
siteRow(scene, 'bravo').click();
assert.equal(cockpit.orbital.focus, null);
const back = run(scene, LAND_FRAMES, { drift: 0 });
@@ -603,7 +704,11 @@ test('a click on a site marker focuses it through the layer; a click elsewhere e
run(scene, LAND_FRAMES);
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
scene.click(SITES.alpha.at);
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id, 'kept on a second click');
assert.equal(
cockpit.orbital.focus.key,
SITES.alpha.id,
'kept on a second click',
);
const focused = offNadir(scene.shots.at(-1));
scene.click(EMPTY_GROUND);
assert.equal(cockpit.orbital.focus, null);
@@ -626,13 +731,21 @@ test('a click a tool owns is left alone', async (t) => {
const lease = claimPointer('draw');
t.after(() => releasePointer(lease));
scene.click(SITES.alpha.at);
assert.equal(scene.cockpit.orbital.focus ?? null, null, 'no focus while drawing');
assert.equal(
scene.cockpit.orbital.focus ?? null,
null,
'no focus while drawing',
);
releasePointer(lease);
scene.click(SITES.alpha.at);
const again = claimPointer('draw');
t.after(() => releasePointer(again));
scene.click(EMPTY_GROUND);
assert.equal(scene.cockpit.orbital.focus.key, SITES.alpha.id, 'kept while drawing');
assert.equal(
scene.cockpit.orbital.focus.key,
SITES.alpha.id,
'kept while drawing',
);
});
test('a double-click on a site focuses it and keeps the orbital view', async (t) => {
@@ -647,7 +760,11 @@ test('a double-click on a site focuses it and keeps the orbital view', async (t)
scene.doubleClick(SITES.bravo.at);
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
scene.doubleClick(SITES.far.at);
assert.equal(handler.stockDoubleClicks, 0, 'beyond reach: not focused, not tracked');
assert.equal(
handler.stockDoubleClicks,
0,
'beyond reach: not focused, not tracked',
);
scene.frame();
assert.equal(cockpit.active, true);
scene.doubleClick(EMPTY_GROUND);
@@ -689,8 +806,15 @@ test('turning the layer off ends the focus and says why; a reload around the sit
assert.ok(status, 'a status row says why no site is listed');
assert.equal(status.detail, 'ENABLE MAPPED INSTALLATIONS FOR SITE PINGS');
assert.equal(status.className, 'warning');
assert.ok(!rows(scene).some((row) => row.target?.layerId === 'military-installations'));
assert.equal(rows(scene).filter((row) => row.target?.layerId === 'satellites').length, 2);
assert.ok(
!rows(scene).some(
(row) => row.target?.layerId === 'military-installations',
),
);
assert.equal(
rows(scene).filter((row) => row.target?.layerId === 'satellites').length,
2,
);
scene.sites.enabled = true;
await refreshRows(scene);
assert.ok(!rows(scene).some((row) => row.title === 'SITES STANDBY'));
@@ -701,7 +825,11 @@ test('turning the layer off ends the focus and says why; a reload around the sit
const loaded = scene.sites.records;
scene.sites.records = loaded.filter((r) => r.id !== SITES.bravo.id);
run(scene, 10);
assert.equal(scene.cockpit.orbital.focus.key, SITES.bravo.id, 'kept through a reload');
assert.equal(
scene.cockpit.orbital.focus.key,
SITES.bravo.id,
'kept through a reload',
);
assert.ok(missDeg(scene.shots.at(-1), 'bravo') < 1e-5, 'still centred');
scene.sites.records = loaded;
// A row the list shows works even if the layer just dropped its site.
@@ -714,7 +842,10 @@ test('turning the layer off ends the focus and says why; a reload around the sit
test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) => {
const scene = await inOrbit(t);
const { cockpit, satellites, viewer, modeEvents } = scene;
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'no history yet');
assert.ok(
!rows(scene).some((row) => row.title.startsWith('RETURN')),
'no history yet',
);
siteRow(scene, 'alpha').click();
run(scene, 5);
const before = Cesium.Cartesian3.clone(scene.shots.at(-1).destination);
@@ -724,21 +855,36 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
satelliteRow(scene, 49260).click();
const newTrack = cockpit.signalItems.filter((item) => item.key === 'track');
assert.equal(newTrack.length, 1);
assert.ok(newTrack[0].timestamp > firstTrack.timestamp, 'the new ride’s own time');
assert.deepEqual(satellites.calls.slice(-2), [['track', 49260], ['subject', 49260]]);
assert.ok(
newTrack[0].timestamp > firstTrack.timestamp,
'the new ride’s own time',
);
assert.deepEqual(satellites.calls.slice(-2), [
['track', 49260],
['subject', 49260],
]);
assert.equal(followedOf(viewer), null, 'the Cockpit keeps the camera');
assert.equal(cockpit.subjectId, 49260);
assert.equal(cockpit.orbital.focus, null, 'the focus is reset');
assert.equal(modeEvents.at(-1)?.active, true);
await settle();
const shown = rows(scene);
assert.deepEqual([shown[0].title, shown[0].detail], ['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW']);
assert.deepEqual(
[shown[0].title, shown[0].detail],
['TRACK ACQUIRED', 'LANDSAT 9 · NADIR VIEW'],
);
assert.equal(shown.filter((row) => row.title === 'TRACK ACQUIRED').length, 1);
const back = shown.find((row) => row.title === 'RETURN · ISS (ZARYA)');
assert.ok(back, 'a RETURN row while there is history');
assert.equal(back.detail, 'PREVIOUS SATELLITE');
assert.equal(satelliteRow(scene, 25544).getAttribute('aria-label'), 'Return to ISS (ZARYA)');
assert.ok(!shown.some((row) => row.title === 'ISS (ZARYA)'), 'listed once, as RETURN');
assert.equal(
satelliteRow(scene, 25544).getAttribute('aria-label'),
'Return to ISS (ZARYA)',
);
assert.ok(
!shown.some((row) => row.title === 'ISS (ZARYA)'),
'listed once, as RETURN',
);
// The camera hops along the way, never in one jump.
const target = satellites.position(49260);
@@ -748,11 +894,20 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) {
const shot = scene.frame();
assert.equal(cockpit.active, true, `still in orbit at frame ${i}`);
largestStep = Math.max(largestStep, Cesium.Cartesian3.distance(previous, shot.destination));
largestStep = Math.max(
largestStep,
Cesium.Cartesian3.distance(previous, shot.destination),
);
previous = shot.destination;
}
assert.ok(largestStep < hopM * 0.1, `largest step ${largestStep} m of ${hopM} m`);
assert.ok(Cesium.Cartesian3.distance(previous, target) < 1, 'landed on the satellite');
assert.ok(
largestStep < hopM * 0.1,
`largest step ${largestStep} m of ${hopM} m`,
);
assert.ok(
Cesium.Cartesian3.distance(previous, target) < 1,
'landed on the satellite',
);
run(scene, LAND_FRAMES, { drift: 0 });
assert.ok(offNadir(scene.shots.at(-1)) < 1e-6, 'looking at nadir');
@@ -768,10 +923,16 @@ test('a satellite row rides it, staying in orbit; RETURN goes back', async (t) =
satelliteRow(scene, 25544).click();
assert.equal(cockpit.subjectId, 25544);
await settle();
assert.ok(!rows(scene).some((row) => row.title.startsWith('RETURN')), 'back at the start');
assert.ok(
!rows(scene).some((row) => row.title.startsWith('RETURN')),
'back at the start',
);
scene.frame();
assert.equal(cockpit.active, true);
assert.ok(!satellites.calls.some(([, id]) => id === 99001), 'debris never offered');
assert.ok(
!satellites.calls.some(([, id]) => id === 99001),
'debris never offered',
);
});
test('while the camera hops, no stale rows; on landing, rows measured from the new satellite', async (t) => {
@@ -790,15 +951,32 @@ test('while the camera hops, no stale rows; on landing, rows measured from the n
scene.refreshCard();
await settle();
assert.ok(cockpit.orbital.hop, 'still hopping');
assert.deepEqual(rows(scene).map((row) => row.title), ['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)']);
assert.deepEqual(
rows(scene).map((row) => row.title),
['TRACK ACQUIRED', 'RETURN · ISS (ZARYA)'],
);
// Landed: the first frame on the satellite rebuilds them at once.
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1) scene.frame();
for (let i = 0; i < Math.ceil(ORBITAL_HOP_MS / FRAME_MS) + 2; i += 1)
scene.frame();
await settle();
shown = rows(scene);
assert.ok(shown.some((row) => row.target?.layerId === 'military-installations'), 'sites back');
const satellitesShown = shown.filter((row) => row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites');
assert.ok(!satellitesShown.some((row) => row.title === 'LANDSAT 9'), 'never the ridden one');
assert.equal(satellitesShown.filter((row) => row.target.id === '25544').length, 1, 'ISS only as RETURN');
assert.ok(
shown.some((row) => row.target?.layerId === 'military-installations'),
'sites back',
);
const satellitesShown = shown.filter(
(row) =>
row.title !== 'TRACK ACQUIRED' && row.target?.layerId === 'satellites',
);
assert.ok(
!satellitesShown.some((row) => row.title === 'LANDSAT 9'),
'never the ridden one',
);
assert.equal(
satellitesShown.filter((row) => row.target.id === '25544').length,
1,
'ISS only as RETURN',
);
});
test('RETURN to a satellite that left the catalogue offers the one before it', async (t) => {
@@ -815,7 +993,10 @@ test('RETURN to a satellite that left the catalogue offers the one before it', a
satelliteRow(scene, 49260).click();
assert.equal(cockpit.subjectId, 40697, 'still on the same satellite');
await settle();
assert.ok(rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'), 'the one before');
assert.ok(
rows(scene).some((row) => row.title === 'RETURN · ISS (ZARYA)'),
'the one before',
);
satelliteRow(scene, 25544).click();
assert.equal(cockpit.subjectId, 25544);
});
@@ -827,7 +1008,11 @@ test('with Installations off no site is offered, by row, list or click', async (
sites.enabled = false;
await refreshRows(scene);
assert.ok(rows(scene).some((row) => row.title === 'SITES STANDBY'));
assert.equal(cockpit.orbital.listedSites.size, 0, 'nothing kept to focus from');
assert.equal(
cockpit.orbital.listedSites.size,
0,
'nothing kept to focus from',
);
assert.equal(cockpit.toggleOrbitalFocus(SITES.alpha.id), false);
scene.click(SITES.alpha.at);
assert.equal(cockpit.orbital.focus ?? null, null);
@@ -842,7 +1027,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
scene.frame();
assert.equal(cockpit.orbital.focusReleasing, true);
const view = { ...cockpit.orbital.lookView };
assert.ok(Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1, 'still turned');
assert.ok(
Math.abs(view.pitchDeg) > 1 || Math.abs(view.yawDeg) > 1,
'still turned',
);
cockpit.onKeyDown({
key: 'ArrowUp',
target: document.body,
@@ -855,7 +1043,10 @@ test('an arrow during the ease back from a focus turns on the arrows’ clock',
Math.abs(cockpit.orbital.lookTarget.yawDeg - view.yawDeg) < 1e-6,
'across kept',
);
assert.ok(cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg, 'tilted on up');
assert.ok(
cockpit.orbital.lookTarget.pitchDeg > view.pitchDeg,
'tilted on up',
);
});
test('leaving orbit leaves no orbital rows to act on', async (t) => {
@@ -870,7 +1061,10 @@ test('leaving orbit leaves no orbital rows to act on', async (t) => {
assert.equal(scene.cockpit.toggleOrbitalFocus(SITES.bravo.id), false);
assert.equal(scene.cockpit.onOrbitalClick(SITES.bravo.at), false);
assert.equal(scene.cockpit.rideOrbitalSatellite(49260), false);
assert.equal(scene.cockpit.handleOrbitalSignalClick('satellites', '49260'), false);
assert.equal(
scene.cockpit.handleOrbitalSignalClick('satellites', '49260'),
false,
);
});
test('NADIR and Home end a focus; an arrow takes the view over where it is', async (t) => {
@@ -913,7 +1107,12 @@ test('reduced motion cuts onto the site, back, and between satellites', async (t
assert.ok(offNadir(scene.frame()) < 1e-6, 'back at once');
satelliteRow(scene, 49260).click();
const shot = scene.frame();
assert.ok(Cesium.Cartesian3.distance(shot.destination, scene.satellites.position(49260)) < 1);
assert.ok(
Cesium.Cartesian3.distance(
shot.destination,
scene.satellites.position(49260),
) < 1,
);
});
test('stopping the Cockpit leaves both clicks to the renderer', async (t) => {
@@ -944,11 +1143,21 @@ test('the focused site keeps its row after nearer sites push it down', async (t)
sources: [],
});
await refreshRows(scene);
const sitesShown = rows(scene).filter((row) => row.target?.layerId === 'military-installations');
const sitesShown = rows(scene).filter(
(row) => row.target?.layerId === 'military-installations',
);
assert.equal(sitesShown.length, 2);
assert.equal(sitesShown[0].target.id, SITES.alpha.id, 'the focused site is kept, first');
assert.equal(
sitesShown[0].target.id,
SITES.alpha.id,
'the focused site is kept, first',
);
siteRow(scene, 'alpha').click();
assert.equal(scene.cockpit.orbital.focus, null, 'its row still ends the focus');
assert.equal(
scene.cockpit.orbital.focus,
null,
'its row still ends the focus',
);
});
test('a site the layer drops in a reload keeps its row, and its row still focuses it', async (t) => {
@@ -959,13 +1168,24 @@ test('a site the layer drops in a reload keeps its row, and its row still focuse
// The thinned view reloads without Camp Alpha for a moment.
scene.sites.records = loaded.filter((r) => r.id !== SITES.alpha.id);
await refreshRows(scene);
assert.deepEqual(rows(scene).map((row) => row.key), before, 'the rows hold still');
assert.deepEqual(
rows(scene).map((row) => row.key),
before,
'the rows hold still',
);
siteRow(scene, 'alpha').click();
assert.equal(scene.cockpit.orbital.focus?.key, SITES.alpha.id, 'focused from its row');
assert.equal(
scene.cockpit.orbital.focus?.key,
SITES.alpha.id,
'focused from its row',
);
siteRow(scene, 'alpha').click();
// Gone for good: after a while it leaves the rows.
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
assert.ok(!rows(scene).some((row) => row.target?.id === SITES.alpha.id), 'forgotten later');
assert.ok(
!rows(scene).some((row) => row.target?.id === SITES.alpha.id),
'forgotten later',
);
});
test('shown rows keep their places while they still qualify', async (t) => {
@@ -990,12 +1210,165 @@ test('shown rows keep their places while they still qualify', async (t) => {
const sitesAfter = rows(scene)
.filter((row) => row.target?.layerId === 'military-installations')
.map((row) => row.target.id);
assert.deepEqual(sitesAfter, sitesBefore, 'no row moves while its site is in reach');
assert.deepEqual(
sitesAfter,
sitesBefore,
'no row moves while its site is in reach',
);
// Once a shown site leaves the list, the nearer one takes its slot.
scene.sites.records = scene.sites.records.filter((r) => r.id !== SITES.bravo.id);
scene.sites.records = scene.sites.records.filter(
(r) => r.id !== SITES.bravo.id,
);
for (let i = 0; i < 12; i += 1) await refreshRows(scene);
assert.ok(
rows(scene).some((row) => row.target?.id === 'osm:military:way/999'),
'the nearer site fills the freed slot',
);
});
/**
* A view from the station: its camera 20 m above the satellite, looking 65°
* below level toward the north, as the satellites layer gives it. Camp Alpha,
* about 120 km to the north-east of a satellite 420 km up, is some 74°
* below level from it: within the view's reach.
*/
function stationMount(scene) {
const position = scene.satellites.position(25544);
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
const axis = (x, y, z) =>
Cesium.Cartesian3.normalize(
Cesium.Matrix4.multiplyByPointAsVector(
enu,
new Cesium.Cartesian3(x, y, z),
new Cesium.Cartesian3(),
),
new Cesium.Cartesian3(),
);
const down = (65 * Math.PI) / 180;
const direction = axis(0, Math.cos(down), -Math.sin(down));
const up = axis(0, Math.sin(down), Math.cos(down));
return {
position: Cesium.Cartesian3.add(
position,
Cesium.Cartesian3.multiplyByScalar(
axis(0, 0, 1),
20,
new Cesium.Cartesian3(),
),
new Cesium.Cartesian3(),
),
direction,
up,
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
key: 'zarya',
label: 'ZARYA',
noradId: 25544,
card: null,
views: [
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: null },
],
};
}
test('from a station view, a site row turns the camera onto it from the view’s own point and holds it', async (t) => {
const scene = await inOrbit(t);
const { cockpit, satellites } = scene;
satellites.getCockpitMount = () => stationMount(scene);
scene.frame();
await refreshRows(scene);
const mount = stationMount(scene);
// Camp Alpha lies below and to the north-east, within 45° of the view.
assert.ok(missDeg(scene.shots.at(-1), 'alpha') > 5, 'not centred yet');
siteRow(scene, 'alpha').click();
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
run(scene, LAND_FRAMES, { drift: 0 });
for (let i = 0; i < 10; i += 1) {
const shot = scene.frame();
// From the view's camera point on the station, not the satellite's.
assert.ok(
Cesium.Cartesian3.distance(
shot.destination,
stationMount(scene).position,
) < 1e-6,
);
assert.ok(
missDeg(shot, 'alpha') < 1e-4,
`frame ${i}: ${missDeg(shot, 'alpha')}°`,
);
}
// The same site from straight down would be off the view's direction.
assert.ok(angleDeg(mount.direction, scene.shots.at(-1).direction) > 1);
// Its row still words the angle from straight down, not from the view.
await refreshRows(scene);
const held = rows(scene).find((row) => row.target?.id === SITES.alpha.id);
const fromNadir = siteOffNadir(scene.shots.at(-1), 'alpha');
const shown = Number(/OFF-NADIR ([\d.]+)°/.exec(held.detail)[1]);
assert.ok(Math.abs(shown - fromNadir) < 0.2, `${shown}° vs ${fromNadir}°`);
// Switching views ends the focus: the new view looks its own way.
cockpit.nextOrbitalView();
assert.ok(!cockpit.orbital.focus);
});
test('from a station view, a site beyond 45° of where the view looks is not focused', async (t) => {
const scene = await inOrbit(t);
const { cockpit, satellites } = scene;
// The view looks south; Camp Alpha is to the north-east, behind it.
satellites.getCockpitMount = () => {
const mount = stationMount(scene);
const flip = (v) => Cesium.Cartesian3.negate(v, new Cesium.Cartesian3());
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(
scene.satellites.position(25544),
);
const south = Cesium.Cartesian3.normalize(
Cesium.Matrix4.multiplyByPointAsVector(
enu,
new Cesium.Cartesian3(0, -0.87, -0.5),
new Cesium.Cartesian3(),
),
new Cesium.Cartesian3(),
);
const up = Cesium.Cartesian3.normalize(
Cesium.Matrix4.multiplyByPointAsVector(
enu,
new Cesium.Cartesian3(0, -0.5, 0.87),
new Cesium.Cartesian3(),
),
new Cesium.Cartesian3(),
);
return {
...mount,
direction: south,
up,
right: Cesium.Cartesian3.cross(south, up, new Cesium.Cartesian3()),
unused: flip,
};
};
scene.frame();
await refreshRows(scene);
const row = siteRow(scene, 'alpha');
if (row) row.click();
else cockpit.toggleOrbitalFocus?.(SITES.alpha.id);
assert.ok(!cockpit.orbital.focus);
});
test("a click on a site's label box focuses it, as one on its dot does", async (t) => {
const scene = await inOrbit(t);
const { cockpit, handler, sites } = scene;
// No dot is drawn at the label's place: the layer's own lookup is what
// finds the site there, through the label box the overlay paints.
assert.equal(sites.findByPick(null), null, 'no draw item at the label');
assert.equal(sites.findAt(SITES.alpha.labelAt)?.id, SITES.alpha.id);
scene.click(SITES.alpha.labelAt);
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
assert.equal(handler.stockClicks, 1, 'Cesium still gets the click');
run(scene, LAND_FRAMES);
assert.ok(missDeg(scene.shots.at(-1), 'alpha') < 1e-5);
// The label of the focused site again keeps it; another site's dot
// switches.
scene.click(SITES.alpha.labelAt);
assert.equal(cockpit.orbital.focus.key, SITES.alpha.id);
scene.click(SITES.bravo.at);
assert.equal(cockpit.orbital.focus.key, SITES.bravo.id);
});
+1 -1
View File
@@ -159,7 +159,7 @@ export function switchOrbitalSatellite(noradId) {
'track',
'track',
t('TRACK ACQUIRED'),
t('{label} · NADIR VIEW', { label: info.name }),
this.orbitalViewSignal(info),
);
this.updateOrbitalHud(info);
this.refreshOrbitalSignals?.();
+165 -26
View File
@@ -1,5 +1,6 @@
/** The orbital (satellite) view of the Cockpit controller: camera, zoom, look and HUD. */
import { isFollowing } from '../data/followed.js';
import { clone } from '../geo/vector.js';
import { cameraOf, canvasOf, findGlobe } from '../render/rendererOf.js';
import { formatNumber, msg, t } from '../i18n/index.js';
import {
@@ -34,6 +35,10 @@ import {
import { cockpitUiUpdateDue } from '../cockpitMath.js';
import { createPlaceTracker, nearPlaceRadiusKm } from '../data/placeBelow.js';
import { isPointerFree } from '../data/inputOwnership.js';
import {
issNextMountView,
issPreviousMountView,
} from '../layers/satellites/issMounts.js';
import { zoomableSwathKm } from '../layers/satellites/sensors.js';
import {
easeOrbitalLook,
@@ -41,7 +46,10 @@ import {
releaseOrbitalFocus,
updateOrbitalFocus,
} from './cockpitOrbitalFocus.js';
import { orbitalEyePosition } from './cockpitOrbitalSatellites.js';
import {
orbitalEyePosition,
switchOrbitalSatellite,
} from './cockpitOrbitalSatellites.js';
import {
COCKPIT_CONTEXT_UPDATE_MS,
COCKPIT_HUD_UPDATE_MS,
@@ -84,6 +92,15 @@ export function beginOrbital() {
// A zoom step in flight: the magnification it started from and when.
transition: null,
previousUp: null,
// The station's view shown (its key and name) and the views on offer;
// null and none for any other satellite. The key is kept while the
// model is away, so the same view comes back with it.
mountKey: null,
mount: null,
mountViews: [],
// A view of a module with no catalog entry (the Cupola) carries the
// card shown in place of the entry it rides; null otherwise.
mountCard: null,
altitudeM: null,
verticalFov: null,
lastBriefMs: 0,
@@ -270,8 +287,49 @@ export function updateOrbital(nowMs) {
);
if (!position) return;
const state = this.orbital;
// The station is ridden from a point on its 3D model, looking along it,
// in place of the straight-down picture (the satellites layer says where).
const mount =
this.services.satellitesLayer?.getCockpitMount?.(state.mountKey) ?? null;
if (mount?.key) state.mountKey = mount.key;
state.mountViews = mount?.views ?? [];
state.mountCard = mount?.card ?? null;
// Each view belongs to an entry of its own (Nauka, the ISS, Poisk, the
// docked vehicle). The Cockpit rides that entry, so the readout, the TLE
// and the signals describe the module the view is from, not the one first
// selected. The switch lands on the next frame; one that fails is not
// retried until the view changes.
if (
mount?.noradId !== null &&
mount?.noradId !== undefined &&
String(mount.noradId) !== String(this.subjectId) &&
state.mountSwitchFailed !== mount.key
) {
if (switchOrbitalSatellite.call(this, mount.noradId)) return;
state.mountSwitchFailed = mount.key;
}
// The model can load after entry, and the picture then changes under the
// TRACK ACQUIRED line that named it: say which it is now.
const riding = mount !== null;
const changed = state.riding !== undefined && state.riding !== riding;
state.riding = riding;
if (changed) {
this.signalItems = (this.signalItems ?? []).filter(
(item) => item.key !== 'track',
);
this.signalSignatures?.delete('track');
this.pushCockpitSignal(
'track',
'track',
t('TRACK ACQUIRED'),
this.orbitalViewSignal(info),
);
}
state.mount = mount ? mount.label || '' : null;
// On the satellite, or on the way to it after Previous/Next.
const eye = orbitalEyePosition(state, position, nowMs);
const eye = mount
? clone(mount.position)
: orbitalEyePosition(state, position, nowMs);
// Track-up: the ground track at the top, so the picture scrolls along it.
// A geostationary satellite has no track and stays north-up.
const nadir = nadirOrientation(eye, {
@@ -291,15 +349,28 @@ export function updateOrbital(nowMs) {
this.lastSubjectInfo = info;
goToZoom.call(this, maxZoom);
}
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js).
if (!updateOrbitalFocus.call(this, state, nadir, eye, nowMs))
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js),
// in the frame the arrows turn: from a station view, its own, from its
// camera point on the station. The same ±45° reach holds about it.
if (
!updateOrbitalFocus.call(
this,
state,
mount ?? nadir,
eye,
nowMs,
mount ? nadir : null,
)
)
state.lookView = easeOrbitalLook(
state,
nowMs - (state.lookLastMs || nowMs),
{ immediate: prefersReducedMotion() },
);
state.lookLastMs = nowMs;
const view = offNadirOrientation(nadir, {
// The arrows tilt the view about its own frame: the nadir one, or the
// mount's.
const view = offNadirOrientation(mount ?? nadir, {
northDeg: state.lookView.pitchDeg,
eastDeg: state.lookView.yawDeg,
});
@@ -470,9 +541,19 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
northDeg: state.lookView?.pitchDeg ?? 0,
eastDeg: state.lookView?.yawDeg ?? 0,
});
// Riding the station from a mount on its model: the view's name, and no
// ground readings, which describe the nadir picture.
const mount = state.mount ?? null;
// A module with no catalog entry of its own shows its own card: its name,
// what it is and a few facts, in place of the entry's identity and TLE.
const card = mount !== null ? (state.mountCard ?? null) : null;
this.publishOrbital({
name: info.name,
classLabel: info.classLabel || '',
name: card ? card.name : info.name,
mount,
facts: card ? card.facts.map((fact) => t(fact)) : null,
// How many views the station offers: the arrows show with two or more.
mountViews: mount === null ? 0 : (state.mountViews?.length ?? 0),
classLabel: card ? t(card.classLabel) : info.classLabel || '',
altitudeM: info.altitudeM,
velocityMps: Number.isFinite(info.velocityMps) ? info.velocityMps : null,
latitude: info.latitude,
@@ -480,12 +561,12 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
zoom: state.zoom,
zoomSteps: ORBITAL_ZOOM_LADDER.filter((step) => step <= maxZoom),
maxZoom,
footprintKm: offset ? null : footprintKm,
footprintKm: offset || mount !== null ? null : footprintKm,
// The imaging sensor's swath, drawn to scale; null without one. The
// SENSOR step's zoom is null when the swath lies outside 1x..maxZoom.
// Looking past the limb there is no ground for it to cover: no sensor.
sensor:
swathKm === null || !seesEarth
swathKm === null || !seesEarth || mount !== null
? null
: {
label: info.sensor?.label ?? null,
@@ -503,18 +584,22 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
transition: { ...transition },
look: {
offset,
readout: focus
? wordFocusOffNadir(focus)
: offset
? wordOffNadir(state.lookTarget, { trackUp })
: '',
// From a mount the tilt is about the mount's frame, not the nadir.
readout:
mount !== null
? ''
: focus
? wordFocusOffNadir(focus)
: offset
? wordOffNadir(state.lookTarget, { trackUp })
: '',
// The mapped point the view is held on, or null.
focus: focus ? { key: focus.key, label: focus.label } : null,
// Off nadir, the ground width at the view's centre, approximated from
// the nadir footprint (`offNadirSwathScale`); 1 and null at nadir.
swathScale,
swathKm:
offset && seesEarth && Number.isFinite(footprintKm)
mount === null && offset && seesEarth && Number.isFinite(footprintKm)
? footprintKm * swathScale
: null,
},
@@ -523,23 +608,45 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
trackUp,
northDeg: trackUp ? (360 - info.groundTrackDeg) % 360 : 0,
place: state.place,
noradId: info.noradId ?? null,
cosparId: info.cosparId ?? null,
tle: info.tle ?? null,
noradId: card ? null : (info.noradId ?? null),
cosparId: card ? null : (info.cosparId ?? null),
tle: card ? null : (info.tle ?? null),
// Read on the HUD's cadence, so the age stays current without a timer.
// The gap between the TLE's epoch and the time the satellite is shown
// at (the world clock's), either side: SGP4 drifts both ways.
tleAgeMs: Number.isFinite(info.tle?.epochMs)
? Math.abs(
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
info.tle.epochMs,
)
: null,
owner: info.owner ?? null,
operator: info.operator ?? null,
tleAgeMs:
!card && Number.isFinite(info.tle?.epochMs)
? Math.abs(
(Number.isFinite(info.atMs) ? info.atMs : Date.now()) -
info.tle.epochMs,
)
: null,
owner: card ? null : (info.owner ?? null),
operator: card ? t(card.operator) : (info.operator ?? null),
});
}
/**
* The TRACK ACQUIRED line for a satellite subject: which picture it gets.
* The station is ridden from a mount on its 3D model (once that is loaded);
* every other satellite looks straight down.
* @param {object} info Satellite subject.
* @returns {string}
*/
export function orbitalViewSignal(info) {
// A running session knows; on entry, before its first frame, the layer does.
const riding =
this.orbital?.riding ??
Boolean(
this.services.satellitesLayer?.getCockpitMount?.(
this.orbital?.mountKey ?? null,
),
);
return riding
? t('{label} · STATION VIEW', { label: info.name })
: t('{label} · NADIR VIEW', { label: info.name });
}
/**
* Present the orbital view on entry and after a language switch: the HUD,
* the local page and a regional brief for the sub-satellite point.
@@ -556,6 +663,38 @@ export function updateOrbitalHud(info, nowMs = performance.now()) {
updateOrbitalContext.call(this, info, nowMs, true);
}
/**
* The station view's arrows: move to its next view (from Nauka, from Zarya,
* from Poisk, from the Cupola, from Kibo, from a docked vehicle) or the one
* before, wrapping round, looking the way that view looks.
* @param {number} [direction] 1 for the next view, -1 for the one before.
* @returns {boolean} True when the view changed.
*/
export function stepOrbitalMount(direction = 1) {
if (!this.active || this.subjectKind !== 'satellite' || !this.orbital)
return false;
const state = this.orbital;
const step = direction < 0 ? issPreviousMountView : issNextMountView;
const next =
state.mount === null ? null : step(state.mountViews, state.mountKey);
if (!next) return false;
state.mountKey = next.key;
state.mount = next.label || '';
state.mountCard = next.card ?? null;
state.mountSwitchFailed = null;
// A ground focus was aimed from the old view: it ends with it.
if (state.focus) {
state.focus = null;
state.focusReleasing = false;
this.refreshOrbitalSignals?.();
}
// Each view has its own way of looking: the look goes back to it.
state.lookTarget = { ...NADIR_LOOK };
state.lookView = { ...NADIR_LOOK };
presentNow.call(this);
return true;
}
/** Re-apply the field of view and publish after a zoom or look change. */
function presentNow() {
const state = this.orbital;
+532
View File
@@ -1466,3 +1466,535 @@ test('back to nadir from past the limb, the sensor waits for the view', async (t
await settle();
assert.ok(store.orbital.sensor, 'back on the Earth');
});
/** A mount on the station: 20 m from the satellite's position, looking along the track. */
function stationMount() {
const centre = satellitePosition();
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(centre);
const axis = (x, y, z) =>
Cesium.Matrix4.multiplyByPointAsVector(
enu,
new Cesium.Cartesian3(x, y, z),
new Cesium.Cartesian3(),
);
const direction = axis(0, 1, 0);
const up = axis(0, 0, 1);
return {
position: Cesium.Cartesian3.add(
centre,
Cesium.Cartesian3.multiplyByScalar(up, 20, new Cesium.Cartesian3()),
new Cesium.Cartesian3(),
),
direction,
up,
right: Cesium.Cartesian3.cross(direction, up, new Cesium.Cartesian3()),
label: 'ZARYA',
};
}
test('the station is ridden from its mount: the camera sits there and looks along it', async (t) => {
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
const mount = stationMount();
satellites.getCockpitMount = () => mount;
clock.advance(16);
cockpit.update();
await settle();
const shot = shots.at(-1);
assert.ok(
Cesium.Cartesian3.equalsEpsilon(shot.destination, mount.position, 1e-9),
'the camera is at the mount, not at the satellite',
);
near(
angleDeg(shot.direction, mount.direction),
0,
'looks along the mount',
1e-9,
);
near(angleDeg(shot.up, mount.up), 0, 'the mount is upright', 1e-9);
// The HUD names the view and drops what describes the nadir picture.
assert.equal(store.orbital.mount, 'ZARYA');
assert.equal(store.orbital.footprintKm, null);
assert.equal(store.orbital.sensor, null);
assert.equal(
$('.cockpit-orbital-kicker').textContent,
'STATION VIEW · ZARYA',
);
assert.equal($('.cockpit-orbital-reticle'), null);
assert.equal($('.cockpit-orbital-north'), null);
assert.match($('.cockpit-help').textContent, /ARROWS LOOK/);
assert.match($('.cockpit-help').textContent, /HOME RESET/);
assert.doesNotMatch($('.cockpit-help').textContent, /NADIR/);
// The arrows turn the view about the mount's own frame, and Home returns.
press(cockpit, 'ArrowRight');
clock.advance(16);
cockpit.update();
await settle();
const turned = shots.at(-1);
near(angleDeg(turned.direction, mount.direction), 5, 'one step is 5°', 1e-6);
assert.ok(
Cesium.Cartesian3.dot(turned.direction, mount.right) > 0,
'right turns toward the mount’s right',
);
assert.ok(
Cesium.Cartesian3.equalsEpsilon(turned.destination, mount.position, 1e-9),
);
assert.equal($('#cockpit-orbital-nadir').textContent, 'RESET');
assert.equal($('#cockpit-orbital-look-readout').textContent, '');
press(cockpit, 'Home');
clock.advance(16);
cockpit.update();
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'Home', 1e-9);
});
test('without a mount the same satellite keeps the nadir picture, and gets it back', async (t) => {
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
const position = satellitePosition();
const toCentre = Cesium.Cartesian3.negate(
Cesium.Cartesian3.normalize(position, new Cesium.Cartesian3()),
new Cesium.Cartesian3(),
);
const signals = [];
cockpit.pushCockpitSignal = (key, kind, title, detail) =>
signals.push(detail);
// The model has not loaded yet: straight down, as for any satellite.
satellites.getCockpitMount = () => null;
clock.advance(16);
cockpit.update();
await settle();
assert.deepEqual(signals, [], 'nothing changed: nothing to say');
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir', 1e-9);
assert.equal(store.orbital.mount, null);
assert.equal(
$('.cockpit-orbital-kicker').textContent,
'ORBITAL VIEW · NADIR',
);
assert.ok($('.cockpit-orbital-reticle'));
// It loads: the view moves to the mount. It goes again: back to nadir.
const mount = stationMount();
satellites.getCockpitMount = () => mount;
clock.advance(1000);
cockpit.update();
await settle();
assert.equal(store.orbital.mount, 'ZARYA');
near(angleDeg(shots.at(-1).direction, mount.direction), 0, 'mount', 1e-9);
// The TRACK ACQUIRED line follows the picture, once per change.
cockpit.update();
assert.deepEqual(signals, ['ISS (ZARYA) · STATION VIEW']);
satellites.getCockpitMount = () => null;
clock.advance(1000);
cockpit.update();
await settle();
assert.deepEqual(signals, [
'ISS (ZARYA) · STATION VIEW',
'ISS (ZARYA) · NADIR VIEW',
]);
assert.equal(store.orbital.mount, null);
near(angleDeg(shots.at(-1).direction, toCentre), 0, 'nadir again', 1e-9);
assert.ok(
Cesium.Cartesian3.equalsEpsilon(shots.at(-1).destination, position, 1e-6),
);
});
/** The station's views as the satellites layer offers them, by key. */
function stationViews({ docked = true } = {}) {
const views = [
{ key: 'nauka', label: 'NAUKA' },
{ key: 'zarya', label: 'ZARYA' },
...(docked ? [{ key: 'docked', label: 'PROGRESS-MS 34' }] : []),
];
const base = stationMount();
// Each view sits a different distance above the satellite's position.
const heights = { nauka: 10, zarya: 20, docked: 30 };
const asked = [];
return {
asked,
views,
heightOf(shot) {
return Math.round(
Cesium.Cartesian3.distance(shot.destination, satellitePosition()),
);
},
getCockpitMount(key) {
asked.push(key);
const view = views.find((entry) => entry.key === key) ?? views[0];
return {
...base,
position: Cesium.Cartesian3.add(
satellitePosition(),
Cesium.Cartesian3.multiplyByScalar(
base.up,
heights[view.key],
new Cesium.Cartesian3(),
),
new Cesium.Cartesian3(),
),
key: view.key,
label: view.label,
views,
};
},
};
}
test('the station opens on its first view and the arrows step through the rest', async (t) => {
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
const station = stationViews();
satellites.getCockpitMount = station.getCockpitMount;
const frame = async () => {
clock.advance(16);
cockpit.update();
await settle();
};
await frame();
// Nothing was chosen: the layer is asked for its first view, Nauka's,
// though the entry ridden is ISS (ZARYA).
assert.equal(station.asked[0], null);
assert.equal(store.orbital.mount, 'NAUKA');
assert.equal(store.orbital.mountViews, 3);
assert.equal(station.heightOf(shots.at(-1)), 10);
assert.equal(
$('.cockpit-orbital-kicker').textContent,
'STATION VIEW · NAUKA',
);
assert.equal(
$('#cockpit-orbital-view-next').getAttribute('aria-label'),
'Next station view',
);
assert.equal(
$('#cockpit-orbital-view-previous').getAttribute('aria-label'),
'Previous station view',
);
assert.equal($('#cockpit-orbital-view-name').textContent, 'NAUKA');
// A look off to one side is dropped by the step: each view looks its own way.
press(cockpit, 'ArrowRight');
await frame();
assert.equal(store.orbital.look.offset, true);
// The button, as a click anywhere inside it.
$('#cockpit-orbital-view-next').dispatchEvent(
new Event('click', { bubbles: true }),
);
await settle();
assert.equal(store.orbital.mount, 'ZARYA', 'named at once, before a frame');
await frame();
assert.equal(station.asked.at(-1), 'zarya');
assert.equal(station.heightOf(shots.at(-1)), 20);
assert.equal(store.orbital.look.offset, false);
near(
angleDeg(shots.at(-1).direction, stationMount().direction),
0,
'reset',
1e-9,
);
assert.equal(
$('.cockpit-orbital-kicker').textContent,
'STATION VIEW · ZARYA',
);
assert.equal(cockpit.nextOrbitalView(), true);
await frame();
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
assert.equal(station.heightOf(shots.at(-1)), 30);
// Round again to the first.
assert.equal(cockpit.nextOrbitalView(), true);
await frame();
assert.equal(store.orbital.mount, 'NAUKA');
assert.equal(station.heightOf(shots.at(-1)), 10);
});
test('the chosen view is kept while the model is away, and one view has no arrows', async (t) => {
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
const station = stationViews({ docked: false });
satellites.getCockpitMount = station.getCockpitMount;
// A second per frame: the HUD republishes on its own cadence.
const frame = async () => {
clock.advance(1000);
cockpit.update();
await settle();
};
await frame();
assert.equal(store.orbital.mountViews, 2);
cockpit.nextOrbitalView();
await frame();
assert.equal(store.orbital.mount, 'ZARYA');
// The model goes: nadir, no control, nothing to step.
satellites.getCockpitMount = () => null;
await frame();
assert.equal(store.orbital.mount, null);
assert.equal(store.orbital.mountViews, 0);
assert.equal($('#cockpit-orbital-view-next'), null);
assert.equal($('#cockpit-orbital-view-previous'), null);
assert.equal(cockpit.nextOrbitalView(), false);
// It comes back: the same view is asked for again.
satellites.getCockpitMount = station.getCockpitMount;
await frame();
assert.equal(station.asked.at(-1), 'zarya');
assert.equal(store.orbital.mount, 'ZARYA');
// A station offering a single view shows no control.
station.views.length = 1;
await frame();
assert.equal(store.orbital.mount, 'NAUKA', 'the view on offer');
assert.equal(store.orbital.mountViews, 1);
assert.equal($('#cockpit-orbital-view-next'), null);
assert.equal($('#cockpit-orbital-view-previous'), null);
assert.equal(cockpit.nextOrbitalView(), false);
});
test('the view arrows do nothing outside a station view', async (t) => {
const { cockpit, clock } = await orbitAt(t);
clock.advance(16);
cockpit.update();
assert.equal(cockpit.nextOrbitalView(), false);
assert.equal(cockpit.previousOrbitalView(), false);
cockpit.exit();
assert.equal(cockpit.nextOrbitalView(), false);
assert.equal(cockpit.previousOrbitalView(), false);
});
test('each station view rides its own entry, so the card describes that module', async (t) => {
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
// The layer, as it behaves: tracking another entry makes it the subject.
const names = {
25544: 'ISS (ZARYA)',
49044: 'ISS (NAUKA)',
36086: 'POISK',
68837: 'PROGRESS-MS 34',
};
let subject = { ...ISS, noradId: 68837, id: '68837', name: names[68837] };
const tracked = [];
satellites.getCockpitSubject = () => ({ ...subject });
satellites.trackById = (noradId) => {
tracked.push(Number(noradId));
const id = Number(noradId);
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
return true;
};
cockpit.subjectId = 68837;
const base = stationMount();
const views = [
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
{ key: 'poisk', label: 'POISK', noradId: 36086 },
{ key: 'docked', label: 'PROGRESS-MS 34', noradId: 68837 },
];
satellites.getCockpitMount = (key) => {
const view = views.find((entry) => entry.key === key) ?? views[0];
return { ...base, ...view, views };
};
const frame = async () => {
clock.advance(1000);
cockpit.update();
await settle();
};
// Entered on the Progress; the view opens on Nauka and rides Nauka.
await frame();
await frame();
assert.deepEqual(tracked, [49044]);
assert.equal(cockpit.subjectId, 49044);
assert.equal(store.orbital.name, 'ISS (NAUKA)');
assert.equal($('.cockpit-orbital-name').textContent, 'ISS (NAUKA)');
assert.equal(store.orbital.mount, 'NAUKA');
// Each step rides the next view's entry.
for (const [noradId, name] of [
[25544, 'ISS (ZARYA)'],
[36086, 'POISK'],
[68837, 'PROGRESS-MS 34'],
[49044, 'ISS (NAUKA)'],
]) {
assert.equal(cockpit.nextOrbitalView(), true);
await frame();
await frame();
assert.equal(cockpit.subjectId, noradId);
assert.equal(store.orbital.name, name);
assert.equal($('.cockpit-orbital-name').textContent, name);
}
assert.deepEqual(tracked, [49044, 25544, 36086, 68837, 49044]);
});
test('a view with no entry, or one that cannot be ridden, keeps the subject', async (t) => {
const { cockpit, satellites, store, clock } = await orbitAt(t);
const base = stationMount();
let views = [
{ key: 'nauka', label: 'NAUKA', noradId: null },
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
];
satellites.getCockpitMount = (key) => {
const view = views.find((entry) => entry.key === key) ?? views[0];
return { ...base, ...view, views };
};
let asked = 0;
satellites.trackById = () => {
asked += 1;
return false;
};
const frame = async () => {
clock.advance(1000);
cockpit.update();
await settle();
};
// No entry for Nauka: the ISS stays the subject, and nothing is tracked.
await frame();
assert.equal(asked, 0);
assert.equal(cockpit.subjectId, 25544);
assert.equal(store.orbital.mount, 'NAUKA');
// An entry the layer will not track: asked once, not every frame.
views = [
{ key: 'nauka', label: 'NAUKA', noradId: 49044 },
{ key: 'zarya', label: 'ZARYA', noradId: 25544 },
];
await frame();
await frame();
await frame();
assert.equal(asked, 1);
assert.equal(cockpit.subjectId, 25544);
assert.equal(document.body.classList.contains('cockpit-orbit'), true);
});
const CUPOLA_CARD = Object.freeze({
name: 'CUPOLA',
classLabel: 'OBSERVATION MODULE · ISS',
operator: 'European Space Agency (ESA)',
facts: ['7 WINDOWS', 'LAUNCHED 8 FEB 2010 · STS-130'],
});
test('a view with a card of its own shows it in place of the entry’s identity', async (t) => {
const { $, cockpit, satellites, store, clock } = await orbitAt(t);
const base = stationMount();
const views = [
{ key: 'zarya', label: 'ZARYA', noradId: 25544, card: null },
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
];
satellites.getCockpitMount = (key) => {
const view = views.find((entry) => entry.key === key) ?? views[0];
return { ...base, ...view, views };
};
const frame = async () => {
clock.advance(1000);
cockpit.update();
await settle();
};
await frame();
assert.equal(store.orbital.name, 'ISS (ZARYA)');
assert.equal(store.orbital.noradId, 25544);
assert.equal(store.orbital.facts, null);
cockpit.nextOrbitalView();
await frame();
// Same entry ridden (nothing to switch), the Cupola's own card shown.
assert.equal(cockpit.subjectId, 25544);
assert.equal(store.orbital.mount, 'CUPOLA');
assert.equal(store.orbital.name, 'CUPOLA');
assert.equal($('.cockpit-orbital-name').textContent, 'CUPOLA');
assert.equal(store.orbital.classLabel, 'OBSERVATION MODULE · ISS');
assert.equal(store.orbital.operator, 'European Space Agency (ESA)');
assert.equal(store.orbital.noradId, null);
assert.equal(store.orbital.tle, null);
assert.equal(store.orbital.owner, null);
assert.equal(
$('.cockpit-orbital-ident-text').textContent,
'7 WINDOWS · LAUNCHED 8 FEB 2010 · STS-130',
);
assert.equal($('#cockpit-orbital-tle-toggle'), null);
// Altitude, velocity and the sub-satellite point are the station's still.
assert.ok($('.cockpit-orbital-altitude').textContent.length > 0);
// Back round to Zarya: the entry's own card again.
cockpit.nextOrbitalView();
await frame();
assert.equal(store.orbital.name, 'ISS (ZARYA)');
assert.equal(store.orbital.noradId, 25544);
assert.equal(store.orbital.facts, null);
});
test('leaving a station view selects Nauka; leaving any other keeps the satellite', async (t) => {
const { cockpit, satellites, clock } = await orbitAt(t);
const names = { 25544: 'ISS (ZARYA)', 49044: 'ISS (NAUKA)' };
let subject = { ...ISS };
const tracked = [];
satellites.getCockpitSubject = () => ({ ...subject });
satellites.trackById = (noradId) => {
const id = Number(noradId);
tracked.push(id);
subject = { ...ISS, noradId: id, id: String(id), name: names[id] };
return true;
};
const base = stationMount();
const views = [
{ key: 'nauka', label: 'NAUKA', noradId: 49044, card: null },
{ key: 'cupola', label: 'CUPOLA', noradId: 25544, card: CUPOLA_CARD },
];
satellites.getCockpitMount = (key) => {
const view = views.find((entry) => entry.key === key) ?? views[0];
return { ...base, ...view, views };
};
const frame = async () => {
clock.advance(1000);
cockpit.update();
await settle();
};
await frame();
await frame();
// On the Cupola, riding the ISS's entry, when the Cockpit is left.
cockpit.nextOrbitalView();
await frame();
await frame();
assert.equal(cockpit.subjectId, 25544);
satellites.calls.length = 0;
tracked.length = 0;
assert.equal(cockpit.exit(), true);
assert.deepEqual(tracked, [49044], 'Nauka is selected');
assert.deepEqual(satellites.calls, [
['subject', null],
['refocus', 49044],
]);
});
test('leaving the plain orbital view refocuses the satellite ridden', async (t) => {
const { cockpit, satellites } = await orbitAt(t);
const tracked = [];
satellites.trackById = (noradId) => {
tracked.push(noradId);
return true;
};
satellites.calls.length = 0;
assert.equal(cockpit.exit(), true);
assert.deepEqual(tracked, []);
assert.deepEqual(satellites.calls, [
['subject', null],
['refocus', 25544],
]);
});
test('the left arrow steps back through the views, wrapping round', async (t) => {
const { $, cockpit, satellites, shots, store, clock } = await orbitAt(t);
const station = stationViews();
satellites.getCockpitMount = station.getCockpitMount;
const frame = async () => {
clock.advance(16);
cockpit.update();
await settle();
};
await frame();
assert.equal(store.orbital.mount, 'NAUKA');
// From the first view back to the last.
$('#cockpit-orbital-view-previous').dispatchEvent(
new Event('click', { bubbles: true }),
);
await settle();
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
await frame();
// The camera is at the docked vehicle's view (30 m up in this stand-in).
assert.equal(station.heightOf(shots.at(-1)), 30);
assert.equal(cockpit.previousOrbitalView(), true);
await frame();
assert.equal(store.orbital.mount, 'ZARYA');
assert.equal(cockpit.nextOrbitalView(), true);
await frame();
assert.equal(store.orbital.mount, 'PROGRESS-MS 34');
});
+23 -3
View File
@@ -675,7 +675,7 @@ export function enter({ kind = null } = {}) {
'track',
'track',
t('TRACK ACQUIRED'),
t('{label} · NADIR VIEW', { label: info.name }),
this.orbitalViewSignal(info),
);
} else if (vessel) {
this.pushCockpitSignal(
@@ -734,6 +734,14 @@ export function exit({ restoreTracking = true } = {}) {
const vesselSubject = this.subjectKind === 'vessel' ? this.subjectId : null;
const satelliteSubject =
this.subjectKind === 'satellite' ? this.subjectId : null;
// Leaving a view from the station selects Nauka, whichever view or entry
// it ended on: the station's first view, and the one it opens on.
const station = this.orbital;
const stationHome =
satelliteSubject !== null && station && station.mount != null
? (station.mountViews?.find((view) => view.key === 'nauka')?.noradId ??
null)
: null;
this.active = false;
this.subjectKind = null;
this.subjectProvider = null;
@@ -805,8 +813,20 @@ export function exit({ restoreTracking = true } = {}) {
// Back to the selected vessel's map view, through the layer's own focus.
this.services.aisLiveVesselsLayer?.focusSelectedVessel?.();
} else if (restoreTracking && satelliteSubject !== null) {
// Back to the satellite's follow camera, through the layer's own refocus.
this.services.satellitesLayer?.refocusTrackedById?.(satelliteSubject);
// Back to the satellite's follow camera, through the layer's own refocus;
// from the station, on Nauka.
const layer = this.services.satellitesLayer;
let subject = satelliteSubject;
if (stationHome !== null && String(stationHome) !== String(subject)) {
let tracked = false;
try {
tracked = Boolean(layer?.trackById?.(stationHome, { origin: 'user' }));
} catch {
tracked = false;
}
if (tracked) subject = stationHome;
}
layer?.refocusTrackedById?.(subject);
}
this.syncEntry();
// Back to whichever entry was used: the Contacts button or the readout's.
+319
View File
@@ -0,0 +1,319 @@
import {
LIVE_STREAMS,
liveStreamsFor,
youtubeWatchUrl,
} from '../data/liveStreams.js';
import { createYouTubeLivePlayer } from '../data/youtubeLivePlayer.js';
import { useLiveStore } from './stores/live.js';
import { applicationPinia } from './vueRuntime.js';
/** The element the LIVE section in Context keeps for the player. */
export const LIVE_PLAYER_HOST_ID = 'live-player-host';
/**
* The element the Cockpit briefing's LIVE page keeps for the player; the one
* used while the Cockpit is on, since the right rail is hidden there.
*/
export const COCKPIT_LIVE_PLAYER_HOST_ID = 'cockpit-live-player-host';
/**
* A layer's selected subject can be judged again as it settles (a satellite
* is docked to the station once both orbits have been compared): the keys
* are read again this often while something is selected.
*/
export const LIVE_SUBJECT_REFRESH_MS = 2000;
/**
* Own the live video: which object is selected (the tracking layers'
* `gev:awareness-subject-selected`), which streams the list attaches to it,
* and the one player. The views (the LIVE section in Context and the Cockpit
* briefing's LIVE page) render what this publishes and ask for the stream to
* start (`playLive`) as soon as one is chosen; the player is built into
* whichever view is shown, the section's outside the Cockpit and the page's
* inside it, and built again in the other when the Cockpit is entered or
* left (an embedded player cannot change parents without reloading). It goes
* when the selection changes or clears.
*/
export class LiveControls {
/**
* @param {{store?: object, actions: {getLayer: (layerId: string) => object|null,
* scheduleLayout?: () => void}, documentRef?: Document, globalRef?: object,
* createPlayer?: typeof createYouTubeLivePlayer,
* streams?: readonly object[], refreshMs?: number}} options
*/
constructor({
store = useLiveStore(applicationPinia()),
actions,
documentRef = globalThis.document,
globalRef = globalThis,
createPlayer = createYouTubeLivePlayer,
streams = LIVE_STREAMS,
refreshMs = LIVE_SUBJECT_REFRESH_MS,
}) {
this.store = store;
this.actions = actions;
this.documentRef = documentRef;
this.globalRef = globalRef;
this.createPlayer = createPlayer;
this.streams = streams;
this.refreshMs = refreshMs;
this.destroyed = false;
/** The selected object: its layer, id and label; null for none. */
this.subject = null;
/** The streams on offer for it, and the chosen one's id. */
this.offered = [];
this.currentId = null;
/** The player, the element and stream it was built for, and its state. */
this.player = null;
this.playerHost = null;
this.playerStreamId = null;
this.playback = { state: 'idle', reason: null };
/** Whether the Cockpit is on, which decides the host the player goes in. */
this.cockpitActive =
documentRef?.body?.classList?.contains?.('cockpit-mode') === true;
this.timer = null;
this.listeners = new AbortController();
const { signal } = this.listeners;
const target = globalRef.addEventListener ? globalRef : null;
target?.addEventListener(
'gev:awareness-subject-selected',
(event) => this._onSelected(event.detail),
{ signal },
);
target?.addEventListener(
'gev:awareness-subject-cleared',
(event) => this._onCleared(event.detail),
{ signal },
);
target?.addEventListener(
'gev:cockpit-mode-changed',
(event) => this._onCockpitMode(event.detail?.active === true),
{ signal },
);
this.owner = store.connect({
cycleLive: (direction) => this.cycle(direction),
playLive: () => this.play(),
stopLive: () => this.stop(),
retryLive: () => this.play({ restart: true }),
});
store.publish(null);
}
_onSelected(detail) {
if (this.destroyed || !detail?.layerId || detail.id == null) return;
const same =
this.subject &&
this.subject.layerId === detail.layerId &&
String(this.subject.id) === String(detail.id);
this.subject = {
layerId: detail.layerId,
id: detail.id,
label: String(detail.label ?? detail.id),
};
if (!same) this.stop();
this._refresh();
this._arm();
}
_onCleared(detail) {
if (this.destroyed || !this.subject) return;
if (detail?.layerId && detail.layerId !== this.subject.layerId) return;
this.subject = null;
this.stop();
this._disarm();
this._refresh();
}
/**
* The Cockpit went on or off: the view shown changed, so a player that is
* loading or playing is built again in the host now shown. With no such
* host in the page the player goes, and the view starts it again once its
* screen is there.
*/
_onCockpitMode(active) {
if (this.destroyed || active === this.cockpitActive) return;
this.cockpitActive = active;
if (this.player === null) return;
const host = this._host();
if (host && host === this.playerHost) return;
if (!this.play({ restart: true })) this.stop();
}
/** The element the player belongs in now: the Cockpit page's, or the section's. */
_host() {
const id = this.cockpitActive
? COCKPIT_LIVE_PLAYER_HOST_ID
: LIVE_PLAYER_HOST_ID;
return this.documentRef?.getElementById?.(id) ?? null;
}
/** Read the selected subject's keys again on a timer, while one is selected. */
_arm() {
this._disarm();
if (!this.subject || !(this.refreshMs > 0)) return;
this.timer = this.globalRef.setInterval(
() => this._refresh(),
this.refreshMs,
);
this.timer?.unref?.();
}
_disarm() {
if (this.timer !== null) this.globalRef.clearInterval(this.timer);
this.timer = null;
}
/** The keys the selected subject is known by, from its layer. */
_subjectKeys() {
if (!this.subject) return [];
const { layerId, id } = this.subject;
const keys = [`${layerId}:${id}`];
let layer = null;
try {
layer = this.actions.getLayer?.(layerId) ?? null;
} catch {
layer = null;
}
try {
for (const key of layer?.getLiveSubjectKeys?.() ?? [])
if (typeof key === 'string') keys.push(key);
} catch {
// A layer that cannot say keeps its plain key.
}
return keys;
}
/** Work out the streams on offer and publish. */
_refresh() {
if (this.destroyed) return;
const offered = liveStreamsFor(this._subjectKeys(), this.streams);
const changed =
offered.length !== this.offered.length ||
offered.some((stream, index) => stream.id !== this.offered[index]?.id);
this.offered = offered;
if (!offered.some((stream) => stream.id === this.currentId)) {
// The chosen stream went with the selection: nothing plays on.
if (this.player) this.stop();
this.currentId = offered[0]?.id ?? null;
}
this._publish();
if (changed) this.actions.scheduleLayout?.();
}
_publish() {
if (this.destroyed) return;
if (!this.subject || !this.offered.length) {
this.store.publish(null);
return;
}
const index = Math.max(
0,
this.offered.findIndex((stream) => stream.id === this.currentId),
);
const current = this.offered[index];
this.store.publish({
label: this.subject.label,
streams: this.offered.map((stream) => ({
id: stream.id,
title: stream.title,
owner: stream.owner,
})),
index,
count: this.offered.length,
current: {
id: current.id,
title: current.title,
owner: current.owner,
ownerUrl: current.ownerUrl,
note: current.note,
watchUrl: youtubeWatchUrl(current.videoId),
},
state: this.playback.state,
reason: this.playback.reason,
});
}
/**
* Step to the next (+1) or previous (-1) stream on offer, wrapping. A
* playing stream hands over to the new one.
* @returns {boolean} True when the stream changed.
*/
cycle(direction = 1) {
if (this.offered.length < 2) return false;
const index = this.offered.findIndex((s) => s.id === this.currentId);
const next =
(Math.max(index, 0) + (direction < 0 ? -1 : 1) + this.offered.length) %
this.offered.length;
this.currentId = this.offered[next].id;
const wasPlaying = this.player !== null;
this.stop();
if (wasPlaying) this.play();
else this._publish();
return true;
}
/**
* Start the chosen stream in the host now shown: the one call that loads
* the player. A player already loading or playing that stream in that host
* is left alone, so the views may ask whenever they see nothing playing;
* `restart` (Try again) builds a fresh one regardless.
* @returns {boolean} True when a player is loading or playing afterwards.
*/
play({ restart = false } = {}) {
if (this.destroyed) return false;
const stream = this.offered.find((s) => s.id === this.currentId);
const host = this._host();
if (!stream || !host) return false;
const running =
this.playback.state === 'loading' || this.playback.state === 'playing';
if (
!restart &&
this.player &&
running &&
this.playerHost === host &&
this.playerStreamId === stream.id
)
return true;
this.stop();
this.playback = { state: 'loading', reason: null };
this.playerHost = host;
this.playerStreamId = stream.id;
this.player = this.createPlayer({
host,
videoId: stream.videoId,
documentRef: this.documentRef,
globalRef: this.globalRef,
onChange: ({ state, reason }) => {
if (this.destroyed) return;
this.playback = { state, reason };
this._publish();
},
});
this._publish();
return true;
}
/** Remove the player; the screen goes dark. */
stop() {
const had = this.player !== null;
this.player?.destroy();
this.player = null;
this.playerHost = null;
this.playerStreamId = null;
if (had || this.playback.state !== 'idle') {
this.playback = { state: 'idle', reason: null };
this._publish();
}
return had;
}
destroy() {
if (this.destroyed) return;
this.stop();
this.destroyed = true;
this._disarm();
this.listeners.abort();
this.store.detach(this.owner);
this.store.publish(null);
}
}
+368
View File
@@ -0,0 +1,368 @@
// src/ui/liveControls.test.mjs — LiveControls owns the live video: the
// selected object's streams, the one player, which screen it is built into,
// and when it goes.
import test from 'node:test';
import assert from 'node:assert/strict';
import {
COCKPIT_LIVE_PLAYER_HOST_ID,
LIVE_PLAYER_HOST_ID,
LiveControls,
} from './liveControls.js';
import { createOwners } from './stores/owners.js';
const STREAMS = Object.freeze([
{
id: 'one',
platform: 'youtube',
videoId: 'AAAAAAAAAAA',
title: 'First',
owner: 'Owner',
ownerUrl: 'https://www.youtube.com/@owner',
subjects: ['station:test'],
note: 'note',
},
{
id: 'two',
platform: 'youtube',
videoId: 'BBBBBBBBBBB',
title: 'Second',
owner: 'Owner',
ownerUrl: 'https://www.youtube.com/@owner',
subjects: ['station:test'],
note: 'note',
},
{
id: 'other',
platform: 'youtube',
videoId: 'CCCCCCCCCCC',
title: 'Elsewhere',
owner: 'Owner',
ownerUrl: 'https://www.youtube.com/@owner',
subjects: ['station:other'],
note: 'note',
},
]);
function fixture({
withHost = true,
withCockpitHost = true,
cockpitMode = false,
} = {}) {
const globalRef = new EventTarget();
const intervals = [];
globalRef.setInterval = (callback, ms) => {
const id = intervals.length + 1;
intervals.push({ id, callback, ms, cleared: false });
return id;
};
globalRef.clearInterval = (id) => {
const timer = intervals.find((entry) => entry.id === id);
if (timer) timer.cleared = true;
};
const host = { id: LIVE_PLAYER_HOST_ID };
const cockpitHost = { id: COCKPIT_LIVE_PLAYER_HOST_ID };
const documentRef = {
getElementById: (id) => {
if (id === LIVE_PLAYER_HOST_ID) return withHost ? host : null;
if (id === COCKPIT_LIVE_PLAYER_HOST_ID)
return withCockpitHost ? cockpitHost : null;
return null;
},
body: {
classList: { contains: (name) => cockpitMode && name === 'cockpit-mode' },
},
};
const published = [];
const store = {
...createOwners(),
publish: (view) => published.push(view),
};
let keys = [];
const layer = { getLiveSubjectKeys: () => keys };
const layouts = [];
const players = [];
const createPlayer = (options) => {
const player = {
options,
destroyed: 0,
destroy: () => (player.destroyed += 1),
};
players.push(player);
return player;
};
const controls = new LiveControls({
store,
actions: {
getLayer: (layerId) => (layerId === 'satellites' ? layer : null),
scheduleLayout: () => layouts.push(1),
},
documentRef,
globalRef,
createPlayer,
streams: STREAMS,
refreshMs: 2000,
});
const dispatch = (type, detail) =>
globalRef.dispatchEvent(new CustomEvent(type, { detail }));
const select = (detail) =>
dispatch('gev:awareness-subject-selected', {
layerId: 'satellites',
id: 25544,
label: 'ISS (ZARYA)',
...detail,
});
const view = () => published.at(-1);
const running = () => intervals.filter((timer) => !timer.cleared);
return {
controls,
store,
published,
view,
dispatch,
select,
setKeys: (next) => (keys = next),
players,
layouts,
intervals,
running,
host,
cockpitHost,
};
}
test('nothing selected publishes no section; a selection with streams publishes them', () => {
const f = fixture();
assert.equal(f.view(), null);
f.setKeys(['station:test']);
f.select();
const view = f.view();
assert.equal(view.label, 'ISS (ZARYA)');
assert.equal(view.count, 2);
assert.equal(view.index, 0);
assert.deepEqual(
view.streams.map((stream) => stream.id),
['one', 'two'],
);
assert.equal(view.current.id, 'one');
assert.equal(
view.current.watchUrl,
'https://www.youtube.com/watch?v=AAAAAAAAAAA',
);
assert.equal(view.state, 'idle');
assert.equal(
f.layouts.length,
1,
'the rail is laid out once the section appears',
);
assert.equal(f.running().length, 1, 'the subject is re-read on a timer');
assert.equal(f.running()[0].ms, 2000);
});
test('a selection no stream names keeps the section away; the plain key counts too', () => {
const f = fixture();
f.select();
assert.equal(f.view(), null);
assert.equal(f.layouts.length, 0);
// A stream attached to a layer's own `<layer>:<id>` key needs no layer help.
const g = fixture();
g.setKeys([]);
g.select({ layerId: 'satellites', id: 'x' });
assert.equal(g.view(), null);
});
test('the layer is asked again on the timer: an entry that settles as docked gains the streams', () => {
const f = fixture();
f.select();
assert.equal(f.view(), null);
f.setKeys(['station:test']);
f.running()[0].callback();
assert.equal(f.view()?.count, 2);
assert.equal(f.layouts.length, 1);
// Unchanged keys do not lay out again.
f.running()[0].callback();
assert.equal(f.layouts.length, 1);
});
test('playLive builds the player for the chosen stream in the section, once; Try again builds it anew', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
assert.equal(
f.players.length,
0,
'the views ask; selection alone builds nothing',
);
assert.equal(f.store.act('playLive'), true);
assert.equal(f.players.length, 1);
assert.equal(f.players[0].options.videoId, 'AAAAAAAAAAA');
assert.equal(f.players[0].options.host, f.host);
assert.equal(f.view().state, 'loading');
// Asked again while loading or playing, the same player stays.
assert.equal(f.store.act('playLive'), true);
f.players[0].options.onChange({ state: 'playing', reason: null });
assert.equal(f.store.act('playLive'), true);
assert.equal(f.players.length, 1, 'no second player for the same stream');
assert.equal(f.players[0].destroyed, 0);
assert.equal(f.view().state, 'playing');
f.players[0].options.onChange({ state: 'offline', reason: 'ended' });
assert.equal(f.view().state, 'offline');
assert.equal(f.view().reason, 'ended');
assert.equal(f.store.act('stopLive'), true);
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.view().state, 'idle');
// Try again builds a fresh player.
assert.equal(f.store.act('retryLive'), true);
assert.equal(f.players.length, 2);
});
test('Play without the host element in the page, or without a selection, does nothing', () => {
const noHost = fixture({ withHost: false });
noHost.setKeys(['station:test']);
noHost.select();
assert.equal(noHost.store.act('playLive'), false);
assert.equal(noHost.players.length, 0);
const idle = fixture();
assert.equal(idle.store.act('playLive'), false);
});
test('the arrows step through the streams, wrapping, and a playing stream hands over', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
assert.equal(f.store.act('cycleLive', 1), true);
assert.equal(f.view().current.id, 'two');
assert.equal(f.store.act('cycleLive', 1), true);
assert.equal(f.view().current.id, 'one', 'wraps forward');
assert.equal(f.store.act('cycleLive', -1), true);
assert.equal(f.view().current.id, 'two', 'wraps backward');
assert.equal(f.players.length, 0, 'stepping while idle loads nothing');
f.store.act('playLive');
f.store.act('cycleLive', 1);
assert.equal(f.players.length, 2);
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.players[1].options.videoId, 'AAAAAAAAAAA');
assert.equal(f.view().state, 'loading');
});
test('with one stream there is nothing to cycle', () => {
const f = fixture();
f.setKeys(['station:other']);
f.select();
assert.equal(f.view().count, 1);
assert.equal(f.store.act('cycleLive', 1), false);
assert.equal(f.view().current.id, 'other');
});
test('a new selection stops the stream; the same entry selected again keeps it', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.store.act('playLive');
f.select({ origin: 'pick' });
assert.equal(f.players[0].destroyed, 0, 'the same subject plays on');
f.setKeys(['station:other']);
f.select({ id: 99999, label: 'OTHER' });
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.view().label, 'OTHER');
assert.equal(f.view().current.id, 'other');
assert.equal(f.view().state, 'idle');
});
test('clearing the selection takes the section down; another layer clearing does not', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.store.act('playLive');
f.dispatch('gev:awareness-subject-cleared', { layerId: 'flights' });
assert.equal(f.view().count, 2, 'another layer clearing is not ours');
f.dispatch('gev:awareness-subject-cleared', { layerId: 'satellites' });
assert.equal(f.view(), null);
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.running().length, 0, 'the timer stops with the selection');
});
test("entering the Cockpit builds the player again in the briefing page's screen, and leaving it in the section's", () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.store.act('playLive');
f.players[0].options.onChange({ state: 'playing', reason: null });
f.dispatch('gev:cockpit-mode-changed', { active: true });
assert.equal(f.players[0].destroyed, 1, 'the rail is hidden in the Cockpit');
assert.equal(f.players.length, 2);
assert.equal(f.players[1].options.host, f.cockpitHost);
assert.equal(f.players[1].options.videoId, 'AAAAAAAAAAA');
assert.equal(f.view().state, 'loading', 'a fresh player starts again');
// The same state again changes nothing.
f.dispatch('gev:cockpit-mode-changed', { active: true });
assert.equal(f.players.length, 2);
// playLive from the hidden section's view finds the Cockpit's screen too.
assert.equal(f.store.act('playLive'), true);
assert.equal(f.players.length, 2);
f.dispatch('gev:cockpit-mode-changed', { active: false });
assert.equal(f.players[1].destroyed, 1);
assert.equal(f.players.length, 3);
assert.equal(f.players[2].options.host, f.host);
});
test('the Cockpit going on or off with nothing playing builds nothing', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.dispatch('gev:cockpit-mode-changed', { active: true });
f.dispatch('gev:cockpit-mode-changed', { active: false });
assert.equal(f.players.length, 0);
assert.equal(f.view().state, 'idle');
});
test("entering the Cockpit without the page's screen in the page removes the player", () => {
const f = fixture({ withCockpitHost: false });
f.setKeys(['station:test']);
f.select();
f.store.act('playLive');
f.dispatch('gev:cockpit-mode-changed', { active: true });
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.players.length, 1);
assert.equal(
f.view().state,
'idle',
'the view starts it once its screen is there',
);
assert.equal(f.store.act('playLive'), false, 'still no screen');
});
test("constructed with the Cockpit already on, playLive uses the page's screen", () => {
const f = fixture({ cockpitMode: true });
f.setKeys(['station:test']);
f.select();
assert.equal(f.store.act('playLive'), true);
assert.equal(f.players[0].options.host, f.cockpitHost);
});
test('the chosen stream going from the list stops it and picks the first that remains', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.store.act('cycleLive', 1);
f.store.act('playLive');
f.setKeys(['station:other']);
f.running()[0].callback();
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.view().current.id, 'other');
assert.equal(f.view().state, 'idle');
});
test('destroy stops the stream, detaches the actions and publishes nothing', () => {
const f = fixture();
f.setKeys(['station:test']);
f.select();
f.store.act('playLive');
f.controls.destroy();
assert.equal(f.players[0].destroyed, 1);
assert.equal(f.view(), null);
assert.equal(f.store.act('playLive'), undefined, 'no owner answers');
assert.equal(f.running().length, 0);
const before = f.published.length;
f.select();
assert.equal(f.published.length, before, 'events after destroy are ignored');
});
+240
View File
@@ -0,0 +1,240 @@
// src/ui/livePanel.test.mjs — the LIVE panel renders what LiveControls
// publishes, over happy-dom; it starts the stream as soon as one is chosen,
// collapsed or not, and its controls reach the store's owner.
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { createApp, nextTick } from 'vue';
import { useLiveStore } from './stores/live.js';
import { usePanelChromeStore } from './stores/panelChrome.js';
import LivePanel from './views/panels/LivePanel.vue';
const settle = async () => {
await nextTick();
await nextTick();
};
function fixture(t) {
document.body.replaceChildren();
const host = document.body.appendChild(document.createElement('div'));
const pinia = createPinia();
const app = createApp(LivePanel).use(pinia);
app.mount(host);
t.after(() => app.unmount());
const store = useLiveStore(pinia);
const acted = [];
store.connect({
cycleLive: (direction) => acted.push(['cycle', direction]),
playLive: () => acted.push(['play']),
stopLive: () => acted.push(['stop']),
retryLive: () => acted.push(['retry']),
});
const chrome = usePanelChromeStore(pinia);
const token = chrome.connect({ toggle() {}, pin() {} });
const setOpen = async (open) => {
chrome.publish(token, 'live-panel', { collapsed: !open });
await settle();
};
const $ = (id) => document.getElementById(id);
const publish = async (view) => {
store.publish(
view && {
label: 'ISS (ZARYA)',
streams: [
{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' },
{
id: 'iss-crew',
title: 'Live video and space-to-ground audio',
owner: 'NASA',
},
],
index: 0,
count: 2,
current: {
id: 'iss-exterior',
title: 'Exterior cameras',
owner: 'NASA',
ownerUrl: 'https://www.youtube.com/@NASA',
note: 'NASA video, via YouTube',
watchUrl: 'https://www.youtube.com/watch?v=ROboUHfPUrU',
},
state: 'idle',
reason: null,
...view,
},
);
await settle();
};
return { $, publish, acted, setOpen };
}
test('without a view the section is hidden and shows OFF', (t) => {
const { $, acted } = fixture(t);
assert.equal($('live-panel').hidden, true);
assert.equal($('live-badge-text').textContent, 'OFF');
assert.equal(
$('live-player-host'),
null,
'no screen until a stream is offered',
);
assert.deepEqual(acted, [], 'nothing to start');
});
test('a view shows the subject and the stream, and starts it at once, with the section collapsed', async (t) => {
const { $, publish, acted } = fixture(t);
await publish({});
const panel = $('live-panel');
assert.equal(panel.hidden, false);
assert.equal(panel.querySelector('.live-subject').textContent, 'ISS (ZARYA)');
assert.equal($('live-stream-title').textContent, 'Exterior cameras · 1/2');
assert.ok($('live-previous-btn'));
assert.ok($('live-next-btn'));
assert.ok($('live-player-host'), 'the screen is in the page for the player');
assert.equal(
$('live-watch-link').getAttribute('href'),
'https://www.youtube.com/watch?v=ROboUHfPUrU',
);
assert.equal($('live-watch-link').getAttribute('rel'), 'noopener noreferrer');
assert.deepEqual(acted, [['play']], 'the stream starts on selection');
// Loading and playing change nothing further.
await publish({ state: 'loading' });
await publish({ state: 'playing' });
assert.deepEqual(acted, [['play']]);
});
test('a different stream chosen while idle starts too', async (t) => {
const { publish, acted } = fixture(t);
await publish({});
assert.deepEqual(acted, [['play']]);
await publish({
current: {
id: 'iss-crew',
title: 'Live video and space-to-ground audio',
owner: 'NASA',
ownerUrl: 'https://www.youtube.com/@NASA',
note: '',
watchUrl: 'https://www.youtube.com/watch?v=M3HKLzjvKPc',
},
index: 1,
});
assert.deepEqual(acted, [['play'], ['play']]);
});
test('collapsing or opening the section neither stops nor restarts the stream', async (t) => {
const { $, publish, acted, setOpen } = fixture(t);
await setOpen(true);
await publish({ state: 'playing' });
assert.deepEqual(acted, [], 'already playing: nothing to start');
await setOpen(false);
assert.deepEqual(acted, [], 'the +/- only hides the body');
assert.ok($('live-player-host'), 'the player keeps its element');
await setOpen(true);
assert.deepEqual(acted, []);
});
test('while playing the badge says ON AIR with the blinking dot, and there is no card', async (t) => {
const { $, publish } = fixture(t);
await publish({ state: 'playing' });
const panel = $('live-panel');
assert.equal(panel.classList.contains('live-on-air'), true);
assert.equal($('live-badge-text').textContent, 'ON AIR');
assert.equal(
panel.querySelector('.live-dot').classList.contains('on-air'),
true,
);
assert.equal(
panel.querySelector('.live-screen').classList.contains('active'),
true,
);
assert.equal(panel.querySelector('.live-card'), null);
assert.equal($('live-status').textContent, 'Live');
});
test('starting shows the waiting dot', async (t) => {
const { $, publish } = fixture(t);
await publish({ state: 'loading' });
assert.equal($('live-badge-text').textContent, 'OFF');
assert.equal(
$('live-panel').querySelector('.live-dot').classList.contains('waiting'),
true,
);
assert.equal($('live-status').textContent, 'Starting…');
});
test('an offline stream shows the fallback card with Try again, and is not restarted by itself', async (t) => {
const { $, publish, acted } = fixture(t);
await publish({ state: 'offline', reason: 'timeout' });
const card = $('live-panel').querySelector('.live-card');
assert.equal(card.classList.contains('offline'), true);
assert.equal(card.querySelector('strong').textContent, 'Stream is offline');
assert.equal($('live-status').textContent, 'Stream is offline');
assert.deepEqual(acted, [], 'offline is left to Try again');
$('live-retry-btn').click();
assert.deepEqual(acted, [['retry']]);
});
test('a stream that cannot be embedded says so, without Try again', async (t) => {
const { $, publish, acted } = fixture(t);
await publish({ state: 'unavailable', reason: 'error-150' });
const card = $('live-panel').querySelector('.live-card');
assert.equal(card.classList.contains('unavailable'), true);
assert.equal(
card.querySelector('strong').textContent,
'This stream cannot play here',
);
assert.equal($('live-retry-btn'), null);
assert.equal($('live-status').textContent, 'This stream cannot play here');
assert.deepEqual(acted, []);
});
test('the arrows step through the streams', async (t) => {
const { $, publish, acted } = fixture(t);
await publish({ state: 'playing' });
$('live-next-btn').click();
$('live-previous-btn').click();
assert.deepEqual(acted, [
['cycle', 1],
['cycle', -1],
]);
});
test('with one stream there are no arrows and no counter', async (t) => {
const { $, publish } = fixture(t);
await publish({
count: 1,
streams: [{ id: 'iss-exterior', title: 'Exterior cameras', owner: 'NASA' }],
});
assert.equal($('live-previous-btn'), null);
assert.equal($('live-next-btn'), null);
assert.equal($('live-stream-title').textContent, 'Exterior cameras');
});
test('publishing null hides the section again', async (t) => {
const { $, publish } = fixture(t);
await publish({});
await publish(null);
assert.equal($('live-panel').hidden, true);
});
test('a language change keeps the same screen element and neither stops nor restarts the stream', async (t) => {
// The player is built into #live-player-host by LiveControls, outside Vue.
// A locale change re-renders the panel's words; the screen must be the
// same element afterwards, with nothing asked of the owner, or the stream
// would be torn down and rebuilt with every language switch.
const { getLocale, setLocale } = await import('../i18n/index.js');
const originalLocale = getLocale();
t.after(() => setLocale(originalLocale));
const { $, publish, acted } = fixture(t);
await publish({ state: 'playing' });
const screen = $('live-player-host');
assert.ok(screen, 'the screen is in the page while a stream is offered');
const marker = screen.appendChild(document.createElement('span'));
const askedBefore = acted.length;
setLocale(originalLocale === 'fr' ? 'es' : 'fr');
await settle();
assert.equal($('live-player-host'), screen, 'the same screen element');
assert.equal(marker.parentNode, screen, 'what LiveControls put in it stays');
assert.equal(acted.length, askedBefore, 'no play, stop or retry asked');
assert.equal($('live-panel').hidden, false);
});
+58
View File
@@ -0,0 +1,58 @@
import { storeToRefs } from 'pinia';
import { computed, nextTick, watch } from 'vue';
import { t } from '../i18n/index.js';
import { useLiveStore } from './stores/live.js';
/**
* What the LIVE section in Context and the Cockpit briefing's LIVE page
* share: the live store's view, its state read as words, and the rule that
* starts the stream. Each view calls this from its setup and renders the
* result; the controls call LiveControls through `act`.
*/
export function useLiveScreen() {
const store = useLiveStore();
const { act } = store;
const { view } = storeToRefs(store);
const playing = computed(() => view.value?.state === 'playing');
const loading = computed(() => view.value?.state === 'loading');
const offline = computed(() => view.value?.state === 'offline');
const unavailable = computed(() => view.value?.state === 'unavailable');
const badgeText = computed(() => (playing.value ? t('ON AIR') : t('OFF')));
const statusText = computed(() => {
switch (view.value?.state) {
case 'playing':
return t('Live');
case 'offline':
return t('Stream is offline');
case 'unavailable':
return t('This stream cannot play here');
default:
return t('Starting…');
}
});
// Start the stream as soon as one is chosen and nothing plays, once the
// screen is in the page (the player is built into it). Which screen is
// LiveControls' choice, and asking from both views starts nothing twice.
// A stream that went offline or cannot play stays as it is until Try again.
watch(
[() => view.value?.current?.id ?? null, () => view.value?.state ?? null],
async ([streamId, state]) => {
if (!streamId || state !== 'idle') return;
await nextTick();
act('playLive');
},
{ immediate: true, flush: 'post' },
);
return {
view,
act,
playing,
loading,
offline,
unavailable,
badgeText,
statusText,
};
}
+215
View File
@@ -0,0 +1,215 @@
// src/ui/stationPanel.test.mjs — the STATION panel renders what the
// satellites layer publishes, over happy-dom; its controls reach the owner.
import '../testSupport/registerDom.mjs';
import test from 'node:test';
import assert from 'node:assert/strict';
import { createPinia } from 'pinia';
import { createApp, nextTick } from 'vue';
import { useStationStore } from './stores/station.js';
import StationPanel from './views/panels/StationPanel.vue';
function fixture(t) {
document.body.replaceChildren();
const host = document.body.appendChild(document.createElement('div'));
const pinia = createPinia();
const app = createApp(StationPanel).use(pinia);
app.mount(host);
t.after(() => app.unmount());
const store = useStationStore(pinia);
const acted = [];
store.connect({
setStationMode: (mode) => acted.push(['mode', mode]),
chooseStation: (group, choice) => acted.push(['choose', group, choice]),
slideStation: (slider, value) => acted.push(['slide', slider, value]),
resumeStationArm: (group) => acted.push(['resume', group]),
zoomStation: () => acted.push(['zoom']),
});
const $ = (id) => document.getElementById(id);
const publish = async (view) => {
store.publish(
view && {
key: 'iss',
title: 'ISS',
subject: 'ISS (ZARYA)',
mode: 'automatic',
telemetry: { state: 'live', poseAgeMs: 4200, liveUntilMs: null },
sunlit: true,
note: 'Computed, not live telemetry.',
groups: [
{
id: 'sun',
label: 'Sun position',
note: null,
kind: 'choices',
choices: [
{ id: 'follow', label: 'Follow the Sun', active: true },
{ id: 'ahead', label: 'Ahead', active: false },
],
},
{
id: 'arm',
label: 'Canadarm2 (degrees)',
note: null,
kind: 'sliders',
resume: 'Resume sway',
sliders: [
{
id: 'shoulder',
label: 'Shoulder roll',
min: -120,
max: 120,
value: 15,
},
],
},
],
zoom: { offered: false, label: 'Zoom to the ISS' },
...view,
},
);
await nextTick();
};
const telemetryText = () => $('station-telemetry').textContent.trim();
return { $, publish, acted, telemetryText };
}
test('without a view the section is hidden', (t) => {
const { $ } = fixture(t);
assert.equal($('station-panel').hidden, true);
assert.equal($('station-badge').textContent, '');
});
test('Automatic shows the subject, the live telemetry age, the Sun line and the note', async (t) => {
const { $, publish, telemetryText } = fixture(t);
await publish({});
const panel = $('station-panel');
assert.equal(panel.hidden, false);
assert.equal($('station-badge').textContent, 'ISS');
assert.equal(
panel.querySelector('.station-subject').textContent,
'ISS (ZARYA)',
);
assert.equal($('station-automatic-btn').getAttribute('aria-checked'), 'true');
assert.equal(
$('station-automatic-btn').classList.contains('is-active'),
true,
);
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'false');
assert.equal(telemetryText(), 'Telemetry · updated 4 s ago');
assert.equal($('station-telemetry').dataset.tone, 'live');
assert.equal($('station-sun').textContent, 'Now: in sunlight');
assert.equal(
panel.querySelectorAll('.station-group').length,
0,
'no controls in Automatic',
);
assert.equal($('station-zoom-btn'), null);
});
test('the status line words each telemetry state, with ages in seconds or minutes', async (t) => {
const { $, publish, telemetryText } = fixture(t);
await publish({
telemetry: { state: 'live', poseAgeMs: 95_000, liveUntilMs: null },
});
assert.equal(telemetryText(), 'Telemetry · updated 2 min ago');
await publish({
telemetry: { state: 'no-signal', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(telemetryText(), 'No signal · computed values');
assert.equal($('station-telemetry').dataset.tone, 'waiting');
await publish({
telemetry: {
state: 'no-signal',
poseAgeMs: 30_000,
liveUntilMs: Date.UTC(2026, 10, 13, 12, 0),
},
});
assert.match(telemetryText(), /^No signal since \S.* · computed values$/);
await publish({
telemetry: { state: 'unavailable', poseAgeMs: 50_000, liveUntilMs: null },
});
assert.equal(
telemetryText(),
'Telemetry unavailable · last update 50 s ago · computed values',
);
assert.equal($('station-telemetry').dataset.tone, 'off');
await publish({
telemetry: { state: 'unavailable', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(telemetryText(), 'Telemetry unavailable · computed values');
await publish({
telemetry: { state: 'disabled', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(
telemetryText(),
'Telemetry not enabled on this server · computed values',
);
// A station with no feed at all (Tiangong).
await publish({
telemetry: { state: 'none', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(telemetryText(), 'No public telemetry · computed values');
assert.equal($('station-telemetry').dataset.tone, 'off');
await publish({
telemetry: { state: 'pending', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(telemetryText(), 'Connecting to telemetry…');
assert.equal($('station-telemetry').dataset.tone, 'waiting');
await publish({
telemetry: { state: 'idle', poseAgeMs: null, liveUntilMs: null },
});
assert.equal(telemetryText(), 'Telemetry reads while the model is on screen');
assert.equal($('station-telemetry').dataset.tone, 'off');
await publish({ sunlit: false });
assert.equal($('station-sun').textContent, "Now: in the Earth's shadow");
});
test('Manual shows the groups with the active choice, the sliders and the resume button', async (t) => {
const { $, publish, telemetryText, acted } = fixture(t);
await publish({ mode: 'manual', sunlit: null });
const panel = $('station-panel');
assert.equal(panel.classList.contains('station-manual'), true);
assert.equal($('station-manual-btn').getAttribute('aria-checked'), 'true');
assert.equal(telemetryText(), 'Manual · telemetry paused');
assert.equal($('station-telemetry').dataset.tone, 'manual');
assert.equal($('station-sun'), null);
assert.equal(panel.querySelectorAll('.station-group').length, 2);
const follow = panel.querySelector('[data-station-choice="sun:follow"]');
const ahead = panel.querySelector('[data-station-choice="sun:ahead"]');
assert.equal(follow.getAttribute('aria-pressed'), 'true');
assert.equal(follow.classList.contains('is-active'), true);
assert.equal(ahead.getAttribute('aria-pressed'), 'false');
ahead.click();
const slider = $('station-slider-shoulder');
assert.ok(slider, 'the slider is in the page');
assert.equal(
panel.querySelector('.station-slider output').textContent,
'15°',
);
panel.querySelector('[data-station-resume="arm"]').click();
assert.deepEqual(acted, [
['choose', 'sun', 'ahead'],
['resume', 'arm'],
]);
});
test('the mode buttons and the zoom button call the owner', async (t) => {
const { $, publish, acted } = fixture(t);
await publish({ zoom: { offered: true, label: 'Zoom to the ISS' } });
$('station-manual-btn').click();
$('station-automatic-btn').click();
assert.equal($('station-zoom-btn').textContent, 'Zoom to the ISS');
$('station-zoom-btn').click();
assert.deepEqual(acted, [
['mode', 'manual'],
['mode', 'automatic'],
['zoom'],
]);
});
test('publishing null hides the section again', async (t) => {
const { $, publish } = fixture(t);
await publish({});
await publish(null);
assert.equal($('station-panel').hidden, true);
});
+23
View File
@@ -0,0 +1,23 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
import { createOwners } from './owners.js';
/**
* The LIVE section in Context as its view renders it: the streams on offer
* for the selected object, the one chosen and the player's state.
* LiveControls presents it (`gev-live` store) and answers the section's
* controls through act(): `cycleLive`, `playLive`, `stopLive`, `retryLive`.
*/
export const useLiveStore = defineStore('gev-live', () => {
/** The presented section; null while nothing selected has a stream. */
const view = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = next && markRaw(next);
}
const { connect, detach, act } = createOwners();
return { view, publish, connect, detach, act };
});
+25
View File
@@ -0,0 +1,25 @@
import { defineStore } from 'pinia';
import { markRaw, shallowRef } from 'vue';
import { createOwners } from './owners.js';
/**
* The STATION section in Context as its view renders it: the selected
* station's controls (Automatic or Manual, the moving parts by hand), where
* its joint angles come from right now, and a zoom to it. The satellites
* layer's station panel presents it (`gev-station` store) and answers its
* controls through act(): `setStationMode`, `chooseStation`, `slideStation`,
* `resumeStationArm`, `zoomStation`.
*/
export const useStationStore = defineStore('gev-station', () => {
/** The presented section; null while no station is selected. */
const view = shallowRef(null);
/** @param {?object} next A fresh presentation; every publish re-renders. */
function publish(next) {
view.value = next && markRaw(next);
}
const { connect, detach, act } = createOwners();
return { view, publish, connect, detach, act };
});
+55
View File
@@ -1952,6 +1952,61 @@ html:not([lang='en']) .cockpit-brief-tabs button {
color: #fff;
outline: none;
}
/* The LIVE tab is in the markup whether or not a stream is on offer. */
.cockpit-brief-tabs button[hidden] {
display: none;
}
/* The briefing's LIVE page: the LIVE section's parts (live.css) in the
card's measure. */
.cockpit-live-subject {
display: flex;
align-items: center;
justify-content: space-between;
gap: 6px;
color: #fff;
font-size: 9px;
letter-spacing: 0.1em;
}
.cockpit-live-subject strong {
overflow: hidden;
font-weight: 500;
text-overflow: ellipsis;
white-space: nowrap;
}
.cockpit-live-subject .live-badge {
flex: none;
font-size: 7px;
}
.cockpit-live-pick {
display: flex;
align-items: center;
gap: 5px;
margin: 5px 0 6px;
}
.cockpit-live-pick .live-stream-title {
font-size: 8px;
}
.cockpit-live-pick .live-step .material-symbols-outlined {
font-size: 14px;
}
.cockpit-live-status {
margin: 5px 0 0;
color: rgba(244, 251, 255, 0.7);
font-size: 7px;
letter-spacing: 0.1em;
text-transform: uppercase;
}
.cockpit-live-credit {
margin: 4px 0 0;
color: rgba(182, 226, 241, 0.72);
font: 600 7px/1.2 var(--font-mono);
letter-spacing: 0.08em;
text-transform: uppercase;
}
.cockpit-live-credit a {
color: inherit;
}
.cockpit-signal-window[data-layout-mode='rail-right-constrained'] {
gap: 5px;
}
+15
View File
@@ -482,6 +482,21 @@
color: #fff;
outline: none;
}
/* A station view's arrows either side of its name. */
.cockpit-orbital-views .cockpit-orbital-look-readout {
flex: 1;
text-align: center;
}
.cockpit-orbital-view-step {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 1px 4px;
line-height: 1;
}
.cockpit-orbital-view-step .material-symbols-outlined {
font-size: 18px;
}
/* The Cockpit HUD in orbit (#cockpit-hud[data-subject='satellite']): the
orbital readout names the satellite, so the topline keeps only the
-150
View File
@@ -1,150 +0,0 @@
/* NASA's ISS live video while the ISS is selected (src/layers/satellites/issLive.js).
The project's floating video window: the Québec CCTV player's `qci-` look
(quebecCctvOverlay.css), draggable by its header. Only its starting place
and the iframe's details are set here: bottom right, above the timeline,
300 px wide so it clears the right rail. */
.qci-panel.iss-live-panel {
top: auto;
right: 16px;
bottom: 96px;
width: min(300px, calc(100vw - 32px));
}
.iss-live-title {
display: inline-flex;
align-items: center;
gap: 6px;
min-width: 0;
}
.iss-live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: #ff4444;
box-shadow: 0 0 6px #ff4444;
}
.iss-live-panel .qci-live {
border: 0;
margin-bottom: 8px;
}
/* The ISS command panel (src/layers/satellites/issCommand.js): the same
floating window, bottom left, collapsed to its header until opened. */
.qci-panel.iss-command-panel {
top: auto;
right: auto;
left: 16px;
bottom: 96px;
width: min(250px, calc(100vw - 32px));
}
.iss-command-title {
min-width: 0;
letter-spacing: 0.06em;
}
.iss-command-body {
max-height: calc(100vh - 230px);
overflow-y: auto;
padding: 8px 10px 10px;
}
.iss-command-body[hidden],
.iss-command-manual[hidden],
.iss-command-panel .qci-note[hidden] {
display: none;
}
.iss-command-modes {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
margin-bottom: 8px;
}
.iss-command-mode,
.iss-command-button {
padding: 5px 7px;
border: 1px solid #2a5d78;
border-radius: 5px;
background: #12283a;
color: inherit;
font: inherit;
cursor: pointer;
}
.iss-command-mode.is-active,
.iss-command-button.is-active {
border-color: #3eabbc;
background: #1b4a5c;
}
.iss-command-mode:focus-visible,
.iss-command-button:focus-visible,
.iss-command-slider input:focus-visible {
outline: 2px solid #7fe3f3;
outline-offset: 1px;
}
.iss-command-panel .qci-note {
margin: 6px 0 0;
padding: 0;
}
.iss-command-group {
margin-top: 10px;
}
.iss-command-label {
margin-bottom: 4px;
font-weight: 600;
}
.iss-command-row {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.iss-command-sliders {
flex-direction: column;
flex-wrap: nowrap;
}
.iss-command-slider {
display: flex;
align-items: center;
gap: 6px;
}
.iss-command-slider span {
flex: 0 0 96px;
}
.iss-command-slider input {
flex: 1;
min-width: 0;
}
.iss-command-zoom {
display: block;
width: 100%;
margin-bottom: 8px;
text-align: center;
}
.iss-command-zoom[hidden] {
display: none;
}
.iss-command-status {
margin: 0 0 4px;
font-weight: 600;
}
.iss-command-status[hidden],
.iss-command-status:empty {
display: none;
}
+202
View File
@@ -0,0 +1,202 @@
/* The LIVE section inside Context: a live stream in the platform's player. */
#live-panel[hidden] {
display: none !important;
}
/* A section inside Context, laid out as the Radio section is: its +/-
hides and shows the body, and it goes with the Context panel. */
#live-panel {
position: relative;
width: 100%;
min-height: 0;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid rgba(65, 220, 231, 0.16);
}
.live-panel-inner {
position: relative;
display: flex;
min-height: 0;
flex-direction: column;
gap: 8px;
padding: 10px;
border: 1px solid rgba(65, 220, 231, 0.18);
border-radius: 8px;
background: rgba(2, 15, 20, 0.42);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
#live-panel .panel-header {
margin-bottom: 0;
}
#right-context-rail #global-context-panel:not(.collapsed) #live-panel {
flex: 0 0 auto;
}
#live-panel.collapsed .live-panel-inner > :not(.panel-header),
#global-context-panel.collapsed #live-panel {
display: none !important;
}
.live-badge {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 10px;
letter-spacing: 0.12em;
}
.live-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.28);
box-shadow: none;
flex: none;
}
.live-dot.waiting {
background: #ffb547;
}
.live-dot.on-air {
background: #ff3b3b;
box-shadow: 0 0 6px rgba(255, 59, 59, 0.9);
animation: live-blink 1.2s ease-in-out infinite;
}
@keyframes live-blink {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.25;
}
}
@media (prefers-reduced-motion: reduce) {
.live-dot.on-air {
animation: none;
}
}
.live-subject {
font-size: 11px;
letter-spacing: 0.08em;
opacity: 0.85;
margin: 2px 0 6px;
}
.live-pick {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 8px;
}
.live-stream-title {
flex: 1;
text-align: center;
font-size: 11px;
font-weight: 700;
letter-spacing: 0.06em;
}
.live-stream-title small {
font-weight: 400;
opacity: 0.7;
}
.live-step {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 1px 4px;
border: 1px solid rgba(255, 255, 255, 0.25);
border-radius: 2px;
background: rgba(0, 7, 12, 0.6);
color: inherit;
cursor: pointer;
line-height: 1;
}
.live-step .material-symbols-outlined {
font-size: 18px;
}
.live-step:hover,
.live-step:focus-visible {
border-color: var(--cockpit-accent, #00dcff);
outline: none;
}
/* The screen keeps a 16:9 box whether a player is in it or not. */
.live-screen {
position: relative;
width: 100%;
aspect-ratio: 16 / 9;
background: #000;
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 2px;
overflow: hidden;
}
.live-player-host,
.live-player-host iframe {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
border: 0;
}
.live-screen:not(.active) .live-player-host {
display: none;
}
.live-card {
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 8px;
padding: 12px;
text-align: center;
font-size: 11px;
letter-spacing: 0.08em;
background:
radial-gradient(
circle at 50% 40%,
rgba(0, 220, 255, 0.08),
transparent 60%
),
#050a0f;
}
.live-card-dot {
width: 10px;
height: 10px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
}
.live-card.offline .live-card-dot {
background: #ff3b3b;
opacity: 0.6;
}
.live-card button {
padding: 3px 10px;
border: 1px solid rgba(255, 255, 255, 0.35);
border-radius: 2px;
background: rgba(0, 7, 12, 0.7);
color: #f4fbff;
font: inherit;
letter-spacing: 0.12em;
cursor: pointer;
}
.live-card button:hover,
.live-card button:focus-visible {
border-color: var(--cockpit-accent, #00dcff);
outline: none;
}
.live-status {
margin: 6px 0 0;
font-size: 11px;
opacity: 0.85;
}
.live-credit,
.live-privacy {
margin: 6px 0 0;
font-size: 10px;
opacity: 0.75;
}
.live-credit a {
color: inherit;
}
+147
View File
@@ -0,0 +1,147 @@
/* The STATION section inside Context: a space station's moving parts. */
#station-panel[hidden] {
display: none !important;
}
/* A section inside Context, laid out as the Radio section is: its +/-
hides and shows the body, and it goes with the Context panel. */
#station-panel {
position: relative;
width: 100%;
min-height: 0;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid rgba(65, 220, 231, 0.16);
}
.station-panel-inner {
position: relative;
display: flex;
min-height: 0;
flex-direction: column;
gap: 8px;
padding: 10px;
border: 1px solid rgba(65, 220, 231, 0.18);
border-radius: 8px;
background: rgba(2, 15, 20, 0.42);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
#station-panel .panel-header {
margin-bottom: 0;
}
#right-context-rail #global-context-panel:not(.collapsed) #station-panel {
flex: 0 0 auto;
}
#station-panel.collapsed .station-panel-inner > :not(.panel-header),
#global-context-panel.collapsed #station-panel {
display: none !important;
}
.station-badge {
font-size: 10px;
letter-spacing: 0.12em;
}
.station-subject {
font-size: 11px;
letter-spacing: 0.08em;
opacity: 0.85;
margin: 2px 0 8px;
}
.station-modes {
display: flex;
gap: 6px;
margin-bottom: 8px;
}
.station-mode,
.station-button {
padding: 3px 10px;
border: 1px solid rgba(255, 255, 255, 0.3);
border-radius: 2px;
background: rgba(0, 7, 12, 0.6);
color: #f4fbff;
font: inherit;
font-size: 10px;
letter-spacing: 0.12em;
cursor: pointer;
}
.station-mode {
flex: 1;
font-weight: 700;
}
.station-mode.is-active,
.station-button.is-active {
border-color: var(--cockpit-accent, #00dcff);
color: var(--cockpit-accent, #00dcff);
}
.station-mode:focus-visible,
.station-button:focus-visible {
outline: 1px solid var(--cockpit-accent, #00dcff);
outline-offset: 1px;
}
.station-telemetry {
display: flex;
align-items: center;
gap: 8px;
margin: 0 0 6px;
font-size: 11px;
letter-spacing: 0.04em;
}
.station-telemetry-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.3);
flex: none;
}
.station-telemetry[data-tone='live'] .station-telemetry-dot {
background: #3bff7a;
box-shadow: 0 0 6px rgba(59, 255, 122, 0.8);
}
.station-telemetry[data-tone='waiting'] .station-telemetry-dot {
background: #ffb547;
}
.station-telemetry[data-tone='manual'] .station-telemetry-dot {
background: var(--cockpit-accent, #00dcff);
}
.station-note {
margin: 0 0 6px;
font-size: 10px;
opacity: 0.75;
}
.station-group {
margin: 8px 0 0;
padding-top: 8px;
border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.station-label {
font-size: 10px;
letter-spacing: 0.12em;
opacity: 0.85;
margin-bottom: 4px;
}
.station-row {
display: flex;
flex-wrap: wrap;
gap: 4px;
}
.station-sliders {
display: grid;
gap: 4px;
}
.station-slider {
display: grid;
grid-template-columns: 7em 1fr 3.5em;
align-items: center;
gap: 6px;
font-size: 10px;
}
.station-slider output {
text-align: right;
font-variant-numeric: tabular-nums;
}
.station-zoom {
margin-top: 8px;
width: 100%;
}
+12 -3
View File
@@ -23,8 +23,14 @@ import CockpitUtilityControls from './panels/CockpitUtilityControls.vue';
// does, they show the state they start in. The controller also publishes
// which surfaces are shown and the utility strip's measured layout; the
// layout pass stays with it, and the controls keep its listeners.
const { presence, instruments, route, vision, utilityLayout } =
storeToRefs(useCockpitStore());
const {
presence,
instruments,
route,
vision,
utilityLayout,
orbital: orbitalView,
} = storeToRefs(useCockpitStore());
const active = computed(() => Boolean(presence.value?.active));
// A vessel subject swaps the aviation readouts for bridge ones.
const bridge = computed(() => presence.value?.subjectKind === 'vessel');
@@ -34,6 +40,9 @@ const orbital = computed(() => presence.value?.subjectKind === 'satellite');
// window view whose readouts, labels and texts the provider words.
const generic = computed(() => presence.value?.subjectGeneric === true);
const labels = computed(() => presence.value?.subjectLabels ?? null);
// The station is ridden from a mount on its 3D model: the arrows look about
// it and Home returns to it, where the nadir picture tilts and returns to nadir.
const stationView = computed(() => (orbitalView.value?.mount ?? null) !== null);
const subject = computed(() =>
generic.value
? presence.value.subjectKind
@@ -314,7 +323,7 @@ const tickStyle = (tick) =>
<CockpitRadar />
</div>
<CockpitUtilityControls />
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></div>
<div class="cockpit-help"><bdi>{{ t('ESC EXIT') }}</bdi><template v-if="looks"> <span>·</span> <bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-if="orbital"> <span>·</span> <bdi>{{ t('+/− ZOOM') }}</bdi> <span>·</span> <template v-if="stationView"><bdi>{{ t('ARROWS LOOK') }}</bdi> <span>·</span> <bdi>{{ t('HOME RESET') }}</bdi></template><template v-else><bdi>{{ t('ARROWS TILT') }}</bdi> <span>·</span> <bdi>{{ t('HOME NADIR') }}</bdi></template></template></div>
</section>
<nav id="view-switcher" :aria-label="t('View switcher')">
+4
View File
@@ -12,7 +12,9 @@ import AwarenessPanel from './panels/AwarenessPanel.vue';
import BhoteKoshiPanel from './panels/BhoteKoshiPanel.vue';
import MissionDetail from './panels/MissionDetail.vue';
import MissionRoster from './panels/MissionRoster.vue';
import LivePanel from './panels/LivePanel.vue';
import RadioPanel from './panels/RadioPanel.vue';
import StationPanel from './panels/StationPanel.vue';
import UiButton from '../kit/UiButton.vue';
import { cockpitEntryFace } from '../cockpitPresentation.js';
@@ -79,6 +81,8 @@ const sceneRuntime = computed(() => scenePanel.value?.runtime ?? '');
<MissionDetail />
</div>
</section>
<StationPanel />
<LivePanel />
<RadioPanel />
</div>
</RailPanel>
+11 -1
View File
@@ -4,6 +4,8 @@ import { computed, useTemplateRef } from 'vue';
import { t } from '../../../i18n/index.js';
import { createBriefState } from '../../cockpitBriefPages.js';
import { useCockpitStore } from '../../stores/cockpit.js';
import { useLiveStore } from '../../stores/live.js';
import CockpitLivePage from './CockpitLivePage.vue';
import CockpitRoute from './CockpitRoute.vue';
import CockpitSignalList from './CockpitSignalList.vue';
import UiButton from '../../kit/UiButton.vue';
@@ -11,8 +13,11 @@ import UiButton from '../../kit/UiButton.vue';
// The Cockpit briefing card. The Cockpit controller presents its pages,
// cycle toggle, regional news and local conditions; until it does, the card
// shows the state it starts in. The controls keep the controller's
// listeners. The route card and the signal rows render themselves.
// listeners. The route card, the signal rows and the LIVE page render
// themselves; the LIVE page and its tab are there only while the subject has
// a stream (the live store's view), which the controller is told of.
const { presence, brief } = storeToRefs(useCockpitStore());
const { view: live } = storeToRefs(useLiveStore());
const initial = createBriefState();
const b = computed(() => brief.value ?? initial);
// The card's collapse, which its toggle and data-collapsed show.
@@ -79,6 +84,9 @@ function leaveSignals() {
</div>
<a class="cockpit-weather-credit" href="https://open-meteo.com/" target="_blank" rel="noopener">{{ t('Weather data by Open-Meteo.com') }}</a>
</section>
<section data-cockpit-brief-page="live" :aria-label="t('Live video')" :hidden="b.pageId !== 'live'">
<CockpitLivePage v-if="live" />
</section>
</div>
<footer class="cockpit-signal-footer">
<span id="cockpit-brief-source">{{ b.source }}</span>
@@ -86,6 +94,8 @@ function leaveSignals() {
<button type="button" data-cockpit-brief-index="0" :aria-label="t('Show Live Signals')" :aria-current="String(b.pageIndex === 0)">{{ t('SIG') }}</button>
<button type="button" data-cockpit-brief-index="1" :aria-label="t('Show Regional News')" :aria-current="brief ? String(b.pageIndex === 1) : undefined">{{ t('NEWS') }}</button>
<button type="button" data-cockpit-brief-index="2" :aria-label="t('Show Local Info')" :aria-current="brief ? String(b.pageIndex === 2) : undefined">{{ t('LOCAL') }}</button>
<!-- Always in the markup (the controller binds the tabs once); hidden without a stream. -->
<button type="button" data-cockpit-brief-index="3" :hidden="!live" :aria-label="t('Show Live Video')" :aria-current="brief ? String(b.pageIndex === 3) : undefined">{{ t('LIVE') }}</button>
</nav>
</footer>
</aside>
+46
View File
@@ -0,0 +1,46 @@
<script setup>
import { t } from '../../../i18n/index.js';
import { useLiveScreen } from '../../liveScreen.js';
// The Cockpit briefing's LIVE page: the LIVE section of Context, in the
// card's measure, for the ridden subject's streams. The briefing renders it
// only while a stream is on offer. LiveControls builds the player into
// `#cockpit-live-player-host` while the Cockpit is on (the right rail, and
// the section's screen with it, is hidden there), and the page's controls
// call LiveControls through the live store, as the section's do.
const {
view,
act,
playing,
loading,
offline,
unavailable,
badgeText,
statusText,
} = useLiveScreen();
</script>
<template>
<template v-if="view">
<div class="cockpit-live-subject">
<strong>{{ view.label }}</strong>
<span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="cockpit-live-badge-text">{{ badgeText }}</span></span>
</div>
<div class="cockpit-live-pick" role="group" :aria-label="t('Stream')">
<button v-if="view.count > 1" id="cockpit-live-previous" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_left</span></button>
<span id="cockpit-live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
<button v-if="view.count > 1" id="cockpit-live-next" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_right</span></button>
</div>
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
<div class="live-screen" :class="{ active: playing || loading }">
<div id="cockpit-live-player-host" class="live-player-host"></div>
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
<span class="live-card-dot" aria-hidden="true"></span>
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
<button v-if="offline" id="cockpit-live-retry" type="button" @click="act('retryLive')">{{ t('Try again') }}</button>
</div>
</div>
<p id="cockpit-live-status" class="cockpit-live-status" role="status" aria-live="polite">{{ statusText }}</p>
<p class="cockpit-live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="cockpit-live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
</template>
</template>
+18 -4
View File
@@ -220,6 +220,8 @@ const shownMark = computed(() =>
const identParts = computed(() => {
const o = orbital.value;
if (!o) return [];
// A module with no catalog entry (the Cupola) shows its facts instead.
if (Array.isArray(o.facts) && o.facts.length) return [...o.facts];
const parts = [];
if (o.noradId !== null && o.noradId !== undefined && o.noradId !== '')
parts.push(t('NORAD {id}', { id: String(o.noradId) }));
@@ -250,6 +252,11 @@ watch(
// The off-nadir tilt; an untilted view shows no readout or reset.
const look = computed(() => orbital.value?.look || { offset: false });
// Riding the station from a mount on its 3D model: the view's name, or null
// for the straight-down picture every other satellite has.
const mount = computed(() => orbital.value?.mount ?? null);
// The station offers several views; with two or more, the arrows step through them.
const mountViews = computed(() => orbital.value?.mountViews ?? 0);
// A ground focus names its target in a polite live region; the angle,
// which changes every update, is left out of it.
const focusText = computed(() => {
@@ -270,7 +277,8 @@ const lensStyle = computed(() => {
<section id="cockpit-orbital" class="cockpit-orbital" :class="{ 'cockpit-orbital-focusing': transition.active }" :style="lensStyle" :aria-label="t('Orbital view')" :hidden="!orbital">
<template v-if="orbital">
<div class="cockpit-orbital-lens" aria-hidden="true"></div>
<div class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
<!-- The nadir reticle and its north pointer; a view from the station has no ground point at its centre. -->
<div v-if="mount === null" class="cockpit-orbital-reticle" :class="{ 'cockpit-orbital-reticle-lock': transition.lockTick }" aria-hidden="true">
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tl"></span>
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-tr"></span>
<span class="cockpit-orbital-bracket cockpit-orbital-bracket-bl"></span>
@@ -287,7 +295,7 @@ const lensStyle = computed(() => {
<!-- Under the vision selector: where the ground track is. -->
<p v-if="placeText" id="cockpit-orbital-over" class="cockpit-orbital-over"><span>{{ t('CURRENTLY OVER') }}</span> <strong>{{ placeText }}</strong></p>
<div class="cockpit-orbital-readout">
<p class="cockpit-orbital-kicker">{{ look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
<p class="cockpit-orbital-kicker">{{ mount !== null ? t('STATION VIEW · {name}', { name: mount }) : look.offset ? t('ORBITAL VIEW · OFF-NADIR') : t('ORBITAL VIEW · NADIR') }}</p>
<div class="cockpit-orbital-title">
<span v-if="shownMark?.kind === 'flag'" class="cockpit-orbital-flag" role="img" :aria-label="shownMark.label" :title="shownMark.label" :style="shownMark.style"></span>
<span v-else-if="shownMark?.kind === 'badge'" class="cockpit-orbital-owner-badge" :title="shownMark.title">{{ shownMark.label }}</span>
@@ -315,11 +323,17 @@ const lensStyle = computed(() => {
<dd class="cockpit-orbital-subpoint">{{ subPointText }}</dd>
</div>
</dl>
<p class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
<p v-if="mount === null" class="cockpit-orbital-north">{{ trackUp ? t('TRACK UP') : t('NORTH UP') }}</p>
<!-- A station view: which one it is, and the step to the next. -->
<div v-if="mount !== null && mountViews > 1" class="cockpit-orbital-look cockpit-orbital-views">
<button id="cockpit-orbital-view-previous" type="button" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Previous station view')" :title="t('Previous station view')"><span class="material-symbols-outlined" aria-hidden="true">chevron_left</span></button>
<span id="cockpit-orbital-view-name" class="cockpit-orbital-look-readout" aria-live="polite">{{ mount }}</span>
<button id="cockpit-orbital-view-next" type="button" class="cockpit-orbital-nadir cockpit-orbital-view-step" :aria-label="t('Next station view')" :title="t('Next station view')"><span class="material-symbols-outlined" aria-hidden="true">chevron_right</span></button>
</div>
<!-- Shown only while the view is tilted off nadir: where it looks and the way back. -->
<div v-if="look.offset" class="cockpit-orbital-look">
<span id="cockpit-orbital-look-readout" class="cockpit-orbital-look-readout" :aria-live="look.focus ? 'off' : 'polite'">{{ look.readout }}</span>
<button id="cockpit-orbital-nadir" ref="nadirButton" type="button" class="cockpit-orbital-nadir" :aria-label="t('Return the view to nadir')" :title="t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ t('NADIR') }}</button>
<button id="cockpit-orbital-nadir" ref="nadirButton" type="button" class="cockpit-orbital-nadir" :aria-label="mount !== null ? t('Return to the default view') : t('Return the view to nadir')" :title="mount !== null ? t('Return to the default view') : t('Return to nadir (Home or 0)')" aria-keyshortcuts="Home 0">{{ mount !== null ? t('RESET') : t('NADIR') }}</button>
</div>
<p id="cockpit-orbital-focus" class="cockpit-orbital-focus" aria-live="polite">{{ focusText }}</p>
</div>
+57
View File
@@ -0,0 +1,57 @@
<script setup>
import { computed } from 'vue';
import { t } from '../../../i18n/index.js';
import RailPanel from '../../rail/RailPanel.vue';
import { vClassToggle } from '../../rail/classToggle.js';
import { useLiveScreen } from '../../liveScreen.js';
// The LIVE section inside Context: the live streams attached to the selected
// object (LiveControls publishes them), one at a time in the platform's own
// player. It is there only while the selection has a stream, and the stream
// starts as soon as one is chosen (useLiveScreen). The section starts
// collapsed; its +/- hides and shows the body, and the player plays on,
// muted, underneath. Its controls call LiveControls through the store.
const PANEL_ID = 'live-panel';
const {
view,
act,
playing,
loading,
offline,
unavailable,
badgeText,
statusText,
} = useLiveScreen();
const liveWords = computed(() => ({
expandLabel: t('Expand Live section'),
collapseLabel: t('Collapse Live section'),
expandTitle: t('Expand Live'),
collapseTitle: t('Collapse Live'),
}));
</script>
<template>
<RailPanel :id="PANEL_ID" tag="section" start-collapsed :hidden="!view" v-class-toggle="{ 'live-on-air': playing }" :aria-label="t('Live streams for the selected object')" :title="t('LIVE')" :toggle-words="liveWords" :glow="false" scroll>
<template #badge><span class="live-badge"><span class="live-dot" :class="{ 'on-air': playing, waiting: loading }" aria-hidden="true"></span><span id="live-badge-text">{{ badgeText }}</span></span></template>
<template v-if="view">
<div class="live-subject">{{ view.label }}</div>
<div class="live-pick" role="group" :aria-label="t('Stream')">
<button v-if="view.count > 1" id="live-previous-btn" type="button" class="live-step" @click="act('cycleLive', -1)" :aria-label="t('Previous stream')" :title="t('Previous stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_left</span></button>
<span id="live-stream-title" class="live-stream-title" aria-live="polite">{{ t(view.current.title) }}<small v-if="view.count > 1"> · {{ view.index + 1 }}/{{ view.count }}</small></span>
<button v-if="view.count > 1" id="live-next-btn" type="button" class="live-step" @click="act('cycleLive', 1)" :aria-label="t('Next stream')" :title="t('Next stream')"><span class="material-symbols-outlined" aria-hidden="true">chevron_right</span></button>
</div>
<!-- The player's element stays put across re-renders: LiveControls mounts the player in it. -->
<div class="live-screen" :class="{ active: playing || loading }">
<div id="live-player-host" class="live-player-host"></div>
<div v-if="offline || unavailable" class="live-card" :class="{ offline, unavailable }">
<span class="live-card-dot" aria-hidden="true"></span>
<strong>{{ offline ? t('Stream is offline') : t('This stream cannot play here') }}</strong>
<button v-if="offline" id="live-retry-btn" type="button" @click="act('retryLive')">{{ t('Try again') }}</button>
</div>
</div>
<p id="live-status" class="live-status" role="status" aria-live="polite">{{ statusText }}</p>
<p class="live-credit"><a :href="view.current.ownerUrl" target="_blank" rel="noopener noreferrer">{{ view.current.owner }}</a> · <a id="live-watch-link" :href="view.current.watchUrl" target="_blank" rel="noopener noreferrer">{{ t('Open on YouTube') }}</a></p>
<p class="live-privacy">{{ t('Video plays from YouTube, which sees your IP address.') }}</p>
</template>
</RailPanel>
</template>
+108
View File
@@ -0,0 +1,108 @@
<script setup>
import { storeToRefs } from 'pinia';
import { computed } from 'vue';
import { formatNumber, t } from '../../../i18n/index.js';
import RailPanel from '../../rail/RailPanel.vue';
import { vClassToggle } from '../../rail/classToggle.js';
import UiSlider from '../../kit/UiSlider.js';
import { useStationStore } from '../../stores/station.js';
// The STATION section inside Context: the selected space station's moving
// parts. Automatic leaves them to their rules (NASA's telemetry where the
// server relays it, computed from the Sun otherwise); Manual hands them to
// the person. The satellites layer publishes the view; its controls call
// the layer through the store. It is there only while a station is selected.
const store = useStationStore();
const { act } = store;
const { view } = storeToRefs(store);
const manual = computed(() => view.value?.mode === 'manual');
/** A duration as the status line words it. */
const ago = (ms) => {
if (!Number.isFinite(ms)) return '';
const seconds = Math.max(0, Math.round(ms / 1000));
return seconds < 90
? t('{seconds} s', { seconds: formatNumber(seconds) })
: t('{minutes} min', { minutes: formatNumber(Math.round(seconds / 60)) });
};
const clock = (ms) =>
Number.isFinite(ms)
? new Date(ms).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
: '';
const telemetry = computed(() => view.value?.telemetry ?? null);
const telemetryText = computed(() => {
const status = telemetry.value;
if (!status) return '';
if (manual.value) return t('Manual · telemetry paused');
switch (status.state) {
case 'live':
return t('Telemetry · updated {ago} ago', { ago: ago(status.poseAgeMs) });
case 'no-signal':
return Number.isFinite(status.liveUntilMs)
? t('No signal since {time} · computed values', { time: clock(status.liveUntilMs) })
: t('No signal · computed values');
case 'unavailable':
return Number.isFinite(status.poseAgeMs)
? t('Telemetry unavailable · last update {ago} ago · computed values', { ago: ago(status.poseAgeMs) })
: t('Telemetry unavailable · computed values');
case 'disabled':
return t('Telemetry not enabled on this server · computed values');
case 'none':
return t('No public telemetry · computed values');
case 'idle':
return t('Telemetry reads while the model is on screen');
default:
return t('Connecting to telemetry…');
}
});
const telemetryTone = computed(() => {
if (manual.value) return 'manual';
const state = telemetry.value?.state;
return state === 'live' ? 'live' : state === 'no-signal' ? 'waiting' : state === 'pending' ? 'waiting' : 'off';
});
const sunText = computed(() => {
const sunlit = view.value?.sunlit;
if (sunlit === null || sunlit === undefined) return '';
return sunlit ? t('Now: in sunlight') : t("Now: in the Earth's shadow");
});
const stationWords = computed(() => ({
expandLabel: t('Expand Station section'),
collapseLabel: t('Collapse Station section'),
expandTitle: t('Expand Station'),
collapseTitle: t('Collapse Station'),
}));
</script>
<template>
<RailPanel id="station-panel" tag="section" start-collapsed :hidden="!view" v-class-toggle="{ 'station-manual': manual }" :aria-label="t('Controls for the selected space station')" :title="t('STATION')" :toggle-words="stationWords" :glow="false" scroll>
<template #badge><span id="station-badge" class="station-badge">{{ view ? view.title : '' }}</span></template>
<template v-if="view">
<div class="station-subject">{{ view.subject }}</div>
<div class="station-modes" role="radiogroup" :aria-label="t('Mode')">
<button id="station-automatic-btn" type="button" role="radio" class="station-mode" :aria-checked="String(!manual)" v-class-toggle="{ 'is-active': !manual }" @click="act('setStationMode', 'automatic')">{{ t('Automatic') }}</button>
<button id="station-manual-btn" type="button" role="radio" class="station-mode" :aria-checked="String(manual)" v-class-toggle="{ 'is-active': manual }" @click="act('setStationMode', 'manual')">{{ t('Manual') }}</button>
</div>
<p id="station-telemetry" class="station-telemetry" :data-tone="telemetryTone" role="status" aria-live="polite"><span class="station-telemetry-dot" aria-hidden="true"></span>{{ telemetryText }}</p>
<p v-if="!manual && sunText" id="station-sun" class="station-note">{{ sunText }}</p>
<p v-if="!manual && view.note" class="station-note">{{ t(view.note) }}</p>
<template v-if="manual">
<div v-for="group in view.groups" :key="group.id" class="station-group">
<div class="station-label">{{ t(group.label) }}</div>
<div v-if="group.kind === 'choices'" class="station-row" role="group" :aria-label="t(group.label)">
<button v-for="choice in group.choices" :key="choice.id" type="button" class="station-button" :data-station-choice="`${group.id}:${choice.id}`" v-class-toggle="{ 'is-active': choice.active }" :aria-pressed="String(choice.active)" @click="act('chooseStation', group.id, choice.id)">{{ t(choice.label) }}</button>
</div>
<div v-else class="station-sliders">
<label v-for="slider in group.sliders" :key="slider.id" class="station-slider">
<span>{{ t(slider.label) }}</span>
<UiSlider :id="`station-slider-${slider.id}`" :min="slider.min" :max="slider.max" :model-value="slider.value" :aria-label="t(slider.label)" @update:model-value="act('slideStation', slider.id, $event)" />
<output class="gev-slider-value">{{ formatNumber(slider.value) }}°</output>
</label>
<button v-if="group.resume" type="button" class="station-button" :data-station-resume="group.id" @click="act('resumeStationArm', group.id)">{{ t(group.resume) }}</button>
</div>
<p v-if="group.note" class="station-note">{{ t(group.note) }}</p>
</div>
</template>
<button v-if="view.zoom.offered" id="station-zoom-btn" type="button" class="station-button station-zoom" @click="act('zoomStation')">{{ t(view.zoom.label) }}</button>
</template>
</RailPanel>
</template>