refactor(layers): W1 timestamps without JulianDate

Flights and military keep their fix history in plain milliseconds
(timeMs, whole ms as the Date the JulianDate came from held) and read
"now" from the app clock: the render-delay time, bracketing,
extrapolation, the warm-up check and the trail seed are number
arithmetic (motion.js, tracking.js, snapshotRenderer.js), as is the turn
rate and the forward synthetic fix in data/motionModel.js, which no
longer imports Cesium. The JulianDate scratch fields in state.js and the
unused JulianDate.now() in queries.js go. Launches (mission frame, panel,
selection), the tracked satellite's SGP4 epoch and the celestial ring's
sun and moon read the app clock; where a Cesium property still takes a
JulianDate it is built from the app clock's now (as JulianDate.now did
from Date.now). Wall-clock throttles and feed receipt stamps stay on
Date.now; property reads at viewer.clock.currentTime (render, frozen at
boot) move with the render code in the *a tasks.

Tests that built JulianDate history fixtures now build ms ones with the
same instants (motionModel.test, flights.test, militaryFlights.test); new
tests show the military delayed position and the tracked satellite follow
the app clock (both fail on the previous code).
This commit is contained in:
German Khokhlov committed 2026-10-16 15:01:46 +04:00
1 parent f1a2df5cfe
commit c33ee31efc
21 files changed
+155 -130

No files matched your search

+11 -5
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import { appClock } from '../../time/clock.js';
import { satelliteClassLabel } from '../../data/satelliteClass.js';
import {
ISS_NORAD,
@@ -130,7 +131,7 @@ export function createTracking({ state: layerState, services, parts, source }) {
* Get the tracked satellite's geodetic position, propagated at most once per
* rendered frame (WS-D2). All tracked-satellite consumers (entity position
* callback → camera, host model, point primitive, getTrackedInfo) share this
* single `new Date()` epoch per frame, so they can never diverge by the old
* single app-clock epoch per frame, so they can never diverge by the old
* 200ms throttle. The matching ECEF position is left in
* `_trackedFrameCartesian`. SGP4 for one satellite per frame is cheap.
* @returns {{ longitude: number, latitude: number, altitude: number }|null}
@@ -150,9 +151,11 @@ export function createTracking({ state: layerState, services, parts, source }) {
) {
const pos = parts.orbits.propagatePosition(
sat.satrec,
layerState._trackedFrameNowForTest
? new Date(layerState._trackedFrameNowForTest())
: new Date(),
new Date(
layerState._trackedFrameNowForTest
? layerState._trackedFrameNowForTest()
: appClock.now(),
),
);
if (!pos) return layerState._trackedFrameGeo; // propagation hiccup — keep last good sample
layerState._trackedFrameGeo = pos;
@@ -422,7 +425,10 @@ export function createTracking({ state: layerState, services, parts, source }) {
// Comfortable tracking landing: ~726 km back for LEO (user-validated
// "slightly zoomed out" framing — no stutter, label reads cleanly), scaled
// up for MEO/GEO so the camera doesn't land on top of a high-orbit dot.
const initialPos = parts.orbits.propagatePosition(sat.satrec, new Date());
const initialPos = parts.orbits.propagatePosition(
sat.satrec,
new Date(appClock.now()),
);
const viewScale =
initialPos && initialPos.altitude > HIGH_ORBIT_ALTITUDE_M
? TRACK_VIEW_FROM_HIGH_SCALE