mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
Merge main through #1634 into the renderer seam
Brings in the CCTV opening camera, the Iceland, Giroc HLS, Taiwan, Quebec, Ottawa and world camera packs, the world clock and timeline, the zoom-out limit and registered-only layer state, ported onto the renderer contract: the sky follows the world time through the frame port's setTime in preUpdate, the Quebec overlay reads the eye, projects and redraws through the camera, query and frame ports, launches hide pending missions through their draw records, and mission orbit rings turn on the scene clock.
This commit is contained in:
commit
2b60531c3c
170 files changed
+44096
-319
No files matched your search
Vendored
+1
-1
@@ -29,7 +29,7 @@ export function createControls({ state: layerState, services, parts, source }) {
|
||||
*/
|
||||
getAnalystRecords(maxCount = Infinity) {
|
||||
if (!layerState._enabled) return [];
|
||||
const now = Date.now();
|
||||
const now = layerState.now();
|
||||
const text = (v) => (typeof v === 'string' && v.trim() ? v.trim() : null);
|
||||
const result = [];
|
||||
for (const launch of layerState._launches || []) {
|
||||
|
||||
@@ -225,6 +225,7 @@ export function createIngestion({
|
||||
}
|
||||
layerState._focusAfterActiveLookup = false;
|
||||
parts.panel.renderMissionPanel();
|
||||
layerState.coverageChanged();
|
||||
layerState._entryCameraView = null;
|
||||
} catch (error) {
|
||||
if (layerState._enabled && token === layerState._lifecycleToken) {
|
||||
|
||||
@@ -74,7 +74,9 @@ export function createLaunchPad({
|
||||
}
|
||||
const nowMs = Date.now();
|
||||
if (nowMs - layerState._lastMissionRingRotationMs >= 1000) {
|
||||
parts.orbitRendering.updateMissionOrbitPrimitiveFrames(nowMs);
|
||||
parts.orbitRendering.updateMissionOrbitPrimitiveFrames(
|
||||
layerState.orbitNow(),
|
||||
);
|
||||
layerState._lastMissionRingRotationMs = nowMs;
|
||||
}
|
||||
const launch = layerState._launches.find(
|
||||
|
||||
@@ -2,6 +2,7 @@ import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { canvasOf, findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
import { followOnDoubleClick } from '../../data/stockFollow.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
|
||||
const HOVER_PICK_INTERVAL_MS = 120;
|
||||
|
||||
@@ -155,6 +156,21 @@ export function createLifecycle({
|
||||
}) {
|
||||
const { holdContinuousRender, releaseContinuousRender } = services.render;
|
||||
let hover = null;
|
||||
// While on, the launches loaded span the time from the first to the last,
|
||||
// each one a mark. Registered once; off, the layer has no time to show, and
|
||||
// each step tells the clock once it has settled.
|
||||
worldClock.register({
|
||||
id: 'rocket-launches',
|
||||
coverage: () => {
|
||||
if (!layerState._enabled) return null;
|
||||
const marks = layerState._launches
|
||||
.map((launch) => Date.parse(launch.launchTime))
|
||||
.filter(Number.isFinite)
|
||||
.sort((a, b) => a - b);
|
||||
if (!marks.length) return null;
|
||||
return { start: marks[0], end: marks.at(-1), marks };
|
||||
},
|
||||
});
|
||||
|
||||
const methods = {
|
||||
init(viewer) {
|
||||
@@ -233,6 +249,7 @@ export function createLifecycle({
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
layerState.coverageChanged();
|
||||
},
|
||||
|
||||
async _enableBody() {
|
||||
@@ -300,6 +317,7 @@ export function createLifecycle({
|
||||
parts.overlays.clearMissionOverlaySources();
|
||||
await parts.ingestion.restoreSatelliteDependency();
|
||||
parts.panel.renderMissionPanel();
|
||||
layerState.coverageChanged();
|
||||
},
|
||||
|
||||
async destroy(viewer) {
|
||||
|
||||
@@ -113,6 +113,9 @@ export function createOrbitRendering({
|
||||
return Boolean(
|
||||
layerState._enabled &&
|
||||
parts.rendering.missionsShown() &&
|
||||
!layerState.launchHidden(
|
||||
layerState._missionOverlayRecords.get(launchId)?.launch,
|
||||
) &&
|
||||
(!layerState._selectedLaunchId ||
|
||||
layerState._selectedLaunchId === launchId),
|
||||
);
|
||||
|
||||
@@ -404,8 +404,11 @@ export function createOverlays({ state: layerState, services, parts, source }) {
|
||||
false,
|
||||
);
|
||||
layerState._selectedMissionOverlayTimeText = null;
|
||||
const records = [...layerState._missionOverlayRecords.values()].filter(
|
||||
(record) => !layerState.launchHidden(record.launch),
|
||||
);
|
||||
const entries = selectRocketMissionMarkerOverlayCohort(
|
||||
Array.from(layerState._missionOverlayRecords.values(), (record) => {
|
||||
records.map((record) => {
|
||||
const entry = createRocketMissionMarkerOverlayEntry(
|
||||
record.launch,
|
||||
record.anchorPosition,
|
||||
|
||||
@@ -142,7 +142,9 @@ export function createRendering({
|
||||
sites: draw.points({ id: setIds.sites, show: false }),
|
||||
markers: draw.points({ id: setIds.markers, show: false }),
|
||||
reticles: draw.icons({ id: setIds.reticles, show: false }),
|
||||
orbits: draw.lines({ id: setIds.orbits }),
|
||||
// Their inertial rings turn at the frame's time, the world time the
|
||||
// sky is drawn at, so away from live they sit under the payload.
|
||||
orbits: draw.lines({ id: setIds.orbits, motionClock: { kind: 'scene' } }),
|
||||
pad: draw.shapes({ id: setIds.pad }),
|
||||
};
|
||||
layerState._missionSets = sets;
|
||||
@@ -265,6 +267,25 @@ export function createRendering({
|
||||
return layerState._replayTracks.get(launchId)?.projectedOrbitPath ?? null;
|
||||
}
|
||||
|
||||
// Away from live, a launch shows from its lift-off on, so scrubbing the
|
||||
// world time forward brings the launches up in the order they flew. The
|
||||
// selected mission stays, whenever it flies.
|
||||
function syncPendingLaunches() {
|
||||
const pending = new Set();
|
||||
for (const { launch } of layerState._missionOverlayRecords.values()) {
|
||||
if (layerState.launchHidden(launch)) pending.add(launch.id);
|
||||
}
|
||||
const previous = layerState._pendingLaunchIds;
|
||||
if (
|
||||
pending.size === previous.size &&
|
||||
[...pending].every((id) => previous.has(id))
|
||||
)
|
||||
return;
|
||||
layerState._pendingLaunchIds = pending;
|
||||
parts.overlays.syncMissionOverlayEntries();
|
||||
parts.orbitRendering.syncMissionOrbitPrimitiveVisibility();
|
||||
}
|
||||
|
||||
function updateMissionFrame() {
|
||||
if (followSampled) followSampled = false;
|
||||
else frameNumber += 1;
|
||||
@@ -272,25 +293,34 @@ export function createRendering({
|
||||
parts.overlays.hideReplayVehicleOverlay();
|
||||
return;
|
||||
}
|
||||
syncPendingLaunches();
|
||||
parts.panel.updateMissionTelemetry();
|
||||
const eye = findCamera(layerState._viewer)?.pose().position;
|
||||
const occluder = eye ? horizonFrom(eye) : null;
|
||||
parts.overlays.updateReplayVehicleOverlay(occluder);
|
||||
parts.overlays.refreshSelectedMissionOverlayText();
|
||||
for (const record of records.values()) {
|
||||
if (!record.isolated || !record.position) continue;
|
||||
if (!record.isolated) continue;
|
||||
// Away from live, a launch shows from its lift-off on.
|
||||
const pending = layerState._pendingLaunchIds.has(record.launchId);
|
||||
if (!record.position) {
|
||||
record.graphicShow = !pending;
|
||||
refresh(record);
|
||||
continue;
|
||||
}
|
||||
const live = typeof record.position === 'function';
|
||||
const position = live ? record.position() : record.position;
|
||||
let horizonVisible = Boolean(
|
||||
position && occluder?.isPointVisible(position),
|
||||
);
|
||||
let horizonVisible =
|
||||
!pending && Boolean(position && occluder?.isPointVisible(position));
|
||||
if (record.id.startsWith('rocket-launch:')) {
|
||||
horizonVisible = parts.overlays.missionAnchorVisible(
|
||||
eye,
|
||||
position,
|
||||
record.launchId,
|
||||
layerState._selectedLaunchId,
|
||||
);
|
||||
horizonVisible =
|
||||
!pending &&
|
||||
parts.overlays.missionAnchorVisible(
|
||||
eye,
|
||||
position,
|
||||
record.launchId,
|
||||
layerState._selectedLaunchId,
|
||||
);
|
||||
// The selection's isolation stays its own; horizon state is kept
|
||||
// apart, so a rear-side anchor is judged again as the camera moves.
|
||||
}
|
||||
@@ -643,7 +673,7 @@ export function createRendering({
|
||||
orbitCurrent.latitude,
|
||||
orbitCurrent.altitude,
|
||||
);
|
||||
const liveTime = new Date();
|
||||
const liveTime = new Date(layerState.orbitNow());
|
||||
const liveTelemetry = {
|
||||
speedMps: null,
|
||||
// Where the payload draws now, for the mission panel.
|
||||
@@ -661,7 +691,7 @@ export function createRendering({
|
||||
const updateLiveState = () => {
|
||||
if (frameNumber !== 0 && frameNumber === liveFrameNumber) return;
|
||||
liveFrameNumber = frameNumber;
|
||||
const nowMs = Date.now();
|
||||
const nowMs = layerState.orbitNow();
|
||||
liveTime.setTime(nowMs);
|
||||
if (satelliteTrack) {
|
||||
const propagated =
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { worldClock, worldTimeFor } from '../../time/worldClock.js';
|
||||
|
||||
export function createState({ services }) {
|
||||
const { setOverlayEntries, setOverlaySourceVisible, clearOverlaySource } =
|
||||
services.overlays;
|
||||
@@ -147,6 +149,38 @@ export function createState({ services }) {
|
||||
|
||||
state._missionOrbitPrimitives = new Map();
|
||||
|
||||
/** The time the launch window ends at, in epoch ms. */
|
||||
|
||||
state.now = worldTimeFor('rocket-launches');
|
||||
|
||||
/** A launched mission's satellite flies on the satellites layer's time. */
|
||||
|
||||
state.orbitNow = worldTimeFor('satellites');
|
||||
|
||||
/** The launches loaded changed, and with them the time they cover. */
|
||||
|
||||
state.coverageChanged = () => worldClock.coverageChanged();
|
||||
|
||||
/**
|
||||
* Whether a launch has yet to lift off at the world time. While live none
|
||||
* has, so the layer shows every launch in its window as it always did.
|
||||
*/
|
||||
|
||||
state.launchPending = (launch) => {
|
||||
if (worldClock.isLive()) return false;
|
||||
const launchMs = Date.parse(launch?.launchTime);
|
||||
return Number.isFinite(launchMs) && launchMs > state.now();
|
||||
};
|
||||
|
||||
/** Whether a launch is hidden for lifting off after the world time. */
|
||||
|
||||
state.launchHidden = (launch) =>
|
||||
launch?.id !== state._selectedLaunchId && state.launchPending(launch);
|
||||
|
||||
/** The launches hidden at the last frame, by id, to spot a change. */
|
||||
|
||||
state._pendingLaunchIds = new Set();
|
||||
|
||||
state._pathDistanceCache = new WeakMap();
|
||||
state._sourceController = new AbortController();
|
||||
return state;
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
// Away from live, a launch shows from its lift-off on, so scrubbing the world
|
||||
// time brings the launches up in the order they flew.
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import { createState } from './state.js';
|
||||
import { createRendering } from './rendering.js';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
const noop = () => {};
|
||||
const LAUNCH_MS = Date.UTC(2026, 9, 20, 12);
|
||||
|
||||
function scene(t) {
|
||||
t.after(() => worldClock.goLive());
|
||||
const state = createState({
|
||||
services: {
|
||||
overlays: {
|
||||
setOverlayEntries: noop,
|
||||
setOverlaySourceVisible: noop,
|
||||
clearOverlaySource: noop,
|
||||
},
|
||||
},
|
||||
});
|
||||
const launch = {
|
||||
id: 'ceres-1',
|
||||
name: 'Ceres-1',
|
||||
lon: 0,
|
||||
lat: 0,
|
||||
launchTime: new Date(LAUNCH_MS).toISOString(),
|
||||
status: 'Launch Successful',
|
||||
recoveryStages: [],
|
||||
trajectory: [
|
||||
{ latitude: 0, longitude: 0 },
|
||||
{ latitude: 1, longitude: 1 },
|
||||
],
|
||||
};
|
||||
const viewer = { scene: {} };
|
||||
const { draw, unbind } = bindFakeDraw(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ position: { x: 2e7, y: 0, z: 0 } }),
|
||||
on: () => () => {},
|
||||
},
|
||||
});
|
||||
t.after(unbind);
|
||||
state._enabled = true;
|
||||
state._viewer = viewer;
|
||||
const syncs = { labels: 0, orbits: 0 };
|
||||
const parts = {
|
||||
model: { missionMarkerColor: () => [1, 1, 1, 1] },
|
||||
policyHelpers: { launchStatusAllowsOrbit: () => false },
|
||||
paths: { surfaceSafePath: (positions) => positions },
|
||||
panel: { updateMissionTelemetry: noop },
|
||||
overlays: {
|
||||
missionHoverReticleImage: () => ({}),
|
||||
hideReplayVehicleOverlay: noop,
|
||||
updateReplayVehicleOverlay: noop,
|
||||
refreshSelectedMissionOverlayText: noop,
|
||||
missionAnchorVisible: () => true,
|
||||
syncMissionOverlayEntries: () => syncs.labels++,
|
||||
},
|
||||
orbitRendering: {
|
||||
syncMissionOrbitPrimitiveVisibility: () => syncs.orbits++,
|
||||
},
|
||||
};
|
||||
const services = {
|
||||
geometry: { getKeyholeGeometry: noop },
|
||||
satellites: {},
|
||||
};
|
||||
parts.selection = createSelection({ state, services, parts });
|
||||
const rendering = createRendering({ state, services, parts });
|
||||
rendering.attach(viewer);
|
||||
rendering.showMissions(true);
|
||||
rendering.addLaunchEntity(launch, null);
|
||||
rendering.flushLaunchEntities();
|
||||
// The drawn item by id, across the mission sets.
|
||||
const item = (id) => {
|
||||
for (const record of draw.sets.values())
|
||||
if (!record.disposed && record.items.has(id)) return record.items.get(id);
|
||||
return null;
|
||||
};
|
||||
assert.ok(item(`rocket-launch:${launch.id}`), 'the marker is drawn');
|
||||
assert.ok(item(`rocket-trajectory:${launch.id}:0`), 'the path is drawn');
|
||||
const shown = () => {
|
||||
rendering.updateMissionFrame();
|
||||
return {
|
||||
marker: item(`rocket-launch:${launch.id}`).show,
|
||||
path: item(`rocket-trajectory:${launch.id}:0`).show,
|
||||
};
|
||||
};
|
||||
return { state, rendering, launch, syncs, shown, draw };
|
||||
}
|
||||
|
||||
test('live shows every launch in the window, lifted off or not', (t) => {
|
||||
const { state, launch, shown } = scene(t);
|
||||
assert.equal(state.launchPending(launch), false);
|
||||
assert.deepEqual(shown(), { marker: true, path: true });
|
||||
});
|
||||
|
||||
test('away from live a launch shows from its lift-off on', (t) => {
|
||||
const { state, launch, syncs, shown } = scene(t);
|
||||
worldClock.seek(LAUNCH_MS - 60_000);
|
||||
assert.equal(state.launchPending(launch), true);
|
||||
assert.deepEqual(shown(), { marker: false, path: false });
|
||||
assert.deepEqual(syncs, { labels: 1, orbits: 1 }, 'its label and orbit go');
|
||||
shown();
|
||||
assert.deepEqual(syncs, { labels: 1, orbits: 1 }, 'once, not each frame');
|
||||
|
||||
worldClock.seek(LAUNCH_MS);
|
||||
assert.equal(state.launchPending(launch), false);
|
||||
assert.deepEqual(shown(), { marker: true, path: true });
|
||||
assert.deepEqual(syncs, { labels: 2, orbits: 2 });
|
||||
});
|
||||
|
||||
test('the selected mission stays whenever it flies', (t) => {
|
||||
const { state, rendering, launch, shown } = scene(t);
|
||||
state._selectedLaunchId = launch.id;
|
||||
rendering.isolateMission(launch.id);
|
||||
worldClock.seek(LAUNCH_MS - 60_000);
|
||||
assert.deepEqual(shown(), { marker: true, path: true });
|
||||
});
|
||||
|
||||
test('the live orbit rings turn at the frame time, not the wall clock', (t) => {
|
||||
const { draw } = scene(t);
|
||||
const orbits = [...draw.sets.values()].find((record) =>
|
||||
record.spec.id.endsWith(':orbits'),
|
||||
);
|
||||
assert.deepEqual(orbits.spec.motionClock, { kind: 'scene' });
|
||||
});
|
||||
Reference in new issue
Block a user