Keep one world clock that every timed layer reads

Core told time eight ways: Date.now() in most layers, JulianDate.now() for
flights and military, Cesium's clock frozen at page load for the sky, the
weather clock for observed imagery. They now read one clock,
src/time/worldClock.js, exported as ./time.

Live is a mode, not a timestamp: while live the clock is the wall clock,
so every layer draws as before. Away from live only the layers that follow
the clock move with it. The weather products follow it, as they followed
the weather transport; a host opts others in with follow(id).

- The weather clock takes its time from the world clock and drives its
  replay, stepping its frames as before.
- Satellites, launches, flights and military (still 30 s and 15 s behind),
  transit, GNSS, Recent Imagery, street level, the HUD and the celestial
  ring read worldTimeFor(id). Cadences stay on the wall clock.
- Cesium's sky (stars, sun, moon, atmosphere, lighting) draws at the world
  time each frame instead of the moment the page loaded.
- Weather frames and satellites declare coverage() for a host's timeline.
This commit is contained in:
Sameh Khamis committed 2026-11-01 21:47:32 -08:00
1 parent 92bb1d6a89
commit 0c4da3cdb2
43 files changed
+1091 -75

No files matched your search

+1 -1
View File
@@ -105,7 +105,7 @@ export function createLaunchPad({
}
const nowMs = Date.now();
if (nowMs - layerState._lastMissionRingRotationMs >= 1000) {
layerState._missionRingDate.setTime(nowMs);
layerState._missionRingDate.setTime(layerState.orbitNow());
parts.orbitRendering.updateMissionOrbitPrimitiveFrames(
layerState._missionRingDate,
);
+1 -1
View File
@@ -175,7 +175,7 @@ export function createModel({ state: layerState, services, parts, source }) {
* @returns {Array<object>}
*/
function normalizeRocketLaunches(payload, now = new Date()) {
function normalizeRocketLaunches(payload, now = new Date(layerState.now())) {
const launches = Array.isArray(payload) ? payload : payload?.results;
if (!Array.isArray(launches)) return [];
const cutoff = now.getTime() - WINDOW_DAYS * 86400000;
+1 -1
View File
@@ -124,7 +124,7 @@ export function createOrbitRendering({
collection.show = missionOrbitPrimitiveVisible(launch.id);
orbitFrameModelMatrix(
satelliteTrack.gmstAtBake,
new Date(),
new Date(layerState.orbitNow()),
collection.modelMatrix,
);
layerState._viewer.scene.primitives.add(collection);
+2 -2
View File
@@ -394,7 +394,7 @@ export function createRendering({
orbitCurrent.latitude,
orbitCurrent.altitude,
);
const liveTime = new Date();
const liveTime = new Date(layerState.orbitNow());
const liveTelemetry = { speedMps: null };
layerState._satelliteTelemetry.set(launch.id, liveTelemetry);
let liveFrameNumber = -1;
@@ -405,7 +405,7 @@ export function createRendering({
layerState._viewer?.scene?.frameState?.frameNumber ?? -1;
if (frameNumber !== -1 && frameNumber === liveFrameNumber) return;
liveFrameNumber = frameNumber;
const nowMs = Date.now();
const nowMs = layerState.orbitNow();
liveTime.setTime(nowMs);
if (satelliteTrack) {
const propagated =
+9
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import { worldTimeFor } from '../../time/worldClock.js';
export function createState({ services }) {
const { setOverlayEntries, setOverlaySourceVisible, clearOverlaySource } =
@@ -147,6 +148,14 @@ export function createState({ services }) {
state._missionRingDate = new Date(0);
/** 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');
state._missionOrbitPatternRegistered = false;
state._pathDistanceCache = new WeakMap();