astraeus 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +176 -0
- package/README.md +185 -37
- package/package.json +5 -4
- package/src/api/AstraeusScene.d.ts +21 -5
- package/src/api/AstraeusScene.js +34 -10
- package/src/api/AstraeusScene.node.js +34 -10
- package/src/api/assembleScene.d.ts +36 -0
- package/src/api/assembleScene.js +175 -0
- package/src/api/bodySetChecks.d.ts +10 -0
- package/src/api/bodySetChecks.js +117 -0
- package/src/api/bodySetInput.d.ts +81 -0
- package/src/api/bodySetInput.js +1 -0
- package/src/api/containingBlock.d.ts +6 -0
- package/src/api/containingBlock.js +16 -0
- package/src/api/data.d.ts +17 -5
- package/src/api/data.js +28 -10
- package/src/api/definitionOf.d.ts +16 -0
- package/src/api/definitionOf.js +20 -0
- package/src/api/errors.d.ts +61 -1
- package/src/api/frozenCopy.d.ts +6 -0
- package/src/api/frozenCopy.js +26 -0
- package/src/api/group.d.ts +8 -2
- package/src/api/group.js +24 -5
- package/src/api/index.d.ts +18 -7
- package/src/api/index.js +2 -2
- package/src/api/index.node.js +2 -2
- package/src/api/listeners.d.ts +5 -0
- package/src/api/listeners.js +25 -0
- package/src/api/look.d.ts +47 -0
- package/src/api/look.js +1 -0
- package/src/api/lookInput.d.ts +3 -0
- package/src/api/lookInput.js +41 -0
- package/src/api/moonPanelInput.d.ts +60 -0
- package/src/api/moonPanelInput.js +1 -0
- package/src/api/mount.d.ts +9 -19
- package/src/api/mount.js +27 -13
- package/src/api/mount.node.js +27 -13
- package/src/api/pathProvenance.js +1 -1
- package/src/api/pickerInput.d.ts +25 -0
- package/src/api/pickerInput.js +1 -0
- package/src/api/planBodies.d.ts +72 -0
- package/src/api/planBodies.js +300 -0
- package/src/api/planBodySets.d.ts +68 -0
- package/src/api/planBodySets.js +234 -0
- package/src/api/planCamera.d.ts +83 -0
- package/src/api/planCamera.js +184 -0
- package/src/api/planGroups.d.ts +36 -0
- package/src/api/planGroups.js +103 -0
- package/src/api/planMoonPanel.d.ts +19 -0
- package/src/api/planMoonPanel.js +104 -0
- package/src/api/planPaths.d.ts +40 -0
- package/src/api/planPaths.js +212 -0
- package/src/api/planPicker.d.ts +12 -0
- package/src/api/planPicker.js +40 -0
- package/src/api/planPlaces.d.ts +16 -0
- package/src/api/planPlaces.js +99 -0
- package/src/api/planStory.d.ts +26 -0
- package/src/api/planStory.js +66 -0
- package/src/api/planTimeline.d.ts +27 -0
- package/src/api/planTimeline.js +68 -0
- package/src/api/planViews.d.ts +25 -0
- package/src/api/planViews.js +35 -0
- package/src/api/prepared.js +4 -1
- package/src/api/renamedInputs.d.ts +15 -0
- package/src/api/renamedInputs.js +39 -0
- package/src/api/scene.d.ts +162 -68
- package/src/api/scene.js +247 -793
- package/src/api/sceneFreeze.d.ts +4 -0
- package/src/api/sceneFreeze.js +10 -0
- package/src/api/sceneReads.d.ts +171 -0
- package/src/api/sceneReads.js +6 -0
- package/src/api/story.d.ts +49 -19
- package/src/api/story.js +54 -22
- package/src/api/sunOrbit.js +9 -11
- package/src/api/time.d.ts +2 -1
- package/src/api/time.js +2 -1
- package/src/api/viewerCamera.d.ts +22 -0
- package/src/api/viewerCamera.js +84 -0
- package/src/api/viewerClock.d.ts +30 -0
- package/src/api/viewerClock.js +85 -0
- package/src/api/viewerFirstDraw.d.ts +14 -0
- package/src/api/viewerFirstDraw.js +26 -0
- package/src/api/viewerHandle.d.ts +79 -0
- package/src/api/viewerHandle.js +31 -0
- package/src/api/viewerLink.d.ts +87 -15
- package/src/api/viewerLink.js +111 -75
- package/src/api/viewerLooks.d.ts +19 -0
- package/src/api/viewerLooks.js +37 -0
- package/src/api/viewerPicker.d.ts +22 -0
- package/src/api/viewerPicker.js +49 -0
- package/src/api/viewerSelection.d.ts +25 -0
- package/src/api/viewerSelection.js +31 -0
- package/src/api/viewerViews.d.ts +10 -0
- package/src/api/viewerViews.js +18 -0
- package/src/api/viewerZones.d.ts +20 -0
- package/src/api/viewerZones.js +47 -0
- package/src/api/views.d.ts +4 -5
- package/src/api/views.js +7 -5
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +191 -82
- package/src/app/App.node.js +191 -82
- package/src/app/AstraeusScene.d.ts +16 -2
- package/src/app/AstraeusScene.js +4 -4
- package/src/app/BodyView.d.ts +4 -1
- package/src/app/BodyView.js +2 -2
- package/src/app/CameraController.d.ts +6 -0
- package/src/app/DeveloperSettings.d.ts +1 -4
- package/src/app/DeveloperSettings.js +6 -10
- package/src/app/FeatureMarkers.d.ts +4 -3
- package/src/app/FeatureMarkers.js +8 -13
- package/src/app/FrameRateSection.js +2 -1
- package/src/app/OrbitSetView.js +1 -1
- package/src/app/SettingControls.d.ts +11 -3
- package/src/app/SettingControls.js +10 -2
- package/src/app/SkyView.d.ts +3 -10
- package/src/app/SkyView.js +6 -28
- package/src/app/address.d.ts +16 -0
- package/src/app/address.js +31 -0
- package/src/app/bodyDraw.d.ts +10 -7
- package/src/app/bodyDraw.js +12 -32
- package/src/app/bodyMetrics.js +2 -2
- package/src/app/bodySet.d.ts +4 -20
- package/src/app/bodySet.js +5 -16
- package/src/app/debugReadout.js +1 -1
- package/src/app/displaySwitches.d.ts +4 -0
- package/src/app/displaySwitches.js +6 -0
- package/src/app/experienceDefinition.d.ts +11 -23
- package/src/app/listSwitch.d.ts +8 -14
- package/src/app/listSwitch.js +3 -10
- package/src/app/liveLook.d.ts +39 -0
- package/src/app/liveLook.js +66 -0
- package/src/app/look.d.ts +36 -0
- package/src/app/look.js +61 -0
- package/src/app/mission.d.ts +1 -1
- package/src/app/mission.js +1 -1
- package/src/app/openClock.d.ts +3 -2
- package/src/app/openClock.js +3 -3
- package/src/app/sceneCamera.js +9 -0
- package/src/app/sceneFrame.d.ts +4 -4
- package/src/app/sceneFrame.js +13 -8
- package/src/app/sceneHooks.js +3 -2
- package/src/app/style.css +114 -139
- package/src/app/trackedMetrics.d.ts +10 -3
- package/src/app/trackedMetrics.js +22 -11
- package/src/app/viewLink.d.ts +10 -32
- package/src/app/viewLink.js +10 -49
- package/src/app/viewerPort.d.ts +50 -0
- package/src/app/views.d.ts +1 -0
- package/src/assets/bodies/galileanMoons.js +1 -2
- package/src/assets/bodies/io.js +2 -2
- package/src/assets/bodies/listedMoons.d.ts +1 -1
- package/src/assets/bodies/listedMoons.js +2 -3
- package/src/assets/bodies/planetSystemMaps.js +2 -3
- package/src/assets/bodies/venus.js +2 -6
- package/src/assets/catalogue.js +1 -2
- package/src/assets/licence.d.ts +3 -3
- package/src/assets/licence.js +3 -3
- package/src/assets/pictures.d.ts +15 -12
- package/src/assets/pictures.js +24 -20
- package/src/assets/sky.d.ts +6 -5
- package/src/assets/sky.js +6 -9
- package/src/assets/visual.d.ts +4 -0
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +1 -6
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/moonSystem.d.ts +1 -1
- package/src/core/bodies/moonSystem.js +102 -55
- package/src/core/bodies/outerPlanetRingData.js +2 -2
- package/src/core/bodies/planetTrajectory.js +1 -1
- package/src/core/bodySetFamilies.d.ts +20 -0
- package/src/core/bodySetFamilies.js +14 -0
- package/src/core/chebyshevEphemeris.js +1 -1
- package/src/core/elementsBody.d.ts +8 -4
- package/src/core/elementsBody.js +32 -11
- package/src/core/elementsGroup.d.ts +27 -0
- package/src/core/elementsGroup.js +85 -0
- package/src/core/events.d.ts +2 -0
- package/src/core/events.js +2 -0
- package/src/core/illumination.js +1 -1
- package/src/core/listedOrbitGroup.d.ts +2 -0
- package/src/core/listedOrbitGroup.js +11 -7
- package/src/core/moonListText.d.ts +6 -0
- package/src/core/moonListText.js +19 -0
- package/src/core/moonTrajectory.js +1 -1
- package/src/core/pacing.d.ts +38 -3
- package/src/core/pacing.js +55 -4
- package/src/core/planetModels.js +2 -2
- package/src/core/planetSeries.d.ts +8 -0
- package/src/core/planetSeries.js +16 -2
- package/src/core/pointGroup.js +1 -1
- package/src/core/provenance.d.ts +2 -1
- package/src/core/provenance.js +2 -2
- package/src/core/referenceCenters.js +5 -5
- package/src/core/sampledTrajectory.js +1 -1
- package/src/core/scalePolicy.d.ts +1 -0
- package/src/core/startView.d.ts +19 -0
- package/src/core/startView.js +28 -0
- package/src/core/state.d.ts +6 -2
- package/src/core/state.js +3 -3
- package/src/core/storyPanels.d.ts +63 -0
- package/src/core/storyPanels.js +111 -0
- package/src/core/sunCentredSources.d.ts +4 -0
- package/src/core/sunCentredSources.js +9 -2
- package/src/core/timeInput.d.ts +4 -0
- package/src/core/timeInput.js +4 -0
- package/src/shell/AstraeusShell.d.ts +5 -1
- package/src/shell/AstraeusShell.js +20 -11
- package/src/shell/AstraeusShell.node.js +20 -11
- package/src/shell/Collapsible.d.ts +4 -3
- package/src/shell/Collapsible.js +5 -5
- package/src/shell/ControlsDrawer.d.ts +1 -1
- package/src/shell/ControlsDrawer.js +3 -1
- package/src/shell/DisplaySwitches.js +2 -1
- package/src/shell/InfoPanel.d.ts +3 -1
- package/src/shell/InfoPanel.js +5 -4
- package/src/shell/MoonFamilyPanel.js +1 -1
- package/src/shell/ObjectControls.d.ts +3 -1
- package/src/shell/ObjectControls.js +2 -2
- package/src/shell/Sources.d.ts +5 -3
- package/src/shell/Sources.js +5 -5
- package/src/shell/StoryPanelView.d.ts +4 -3
- package/src/shell/StoryPanelView.js +8 -6
- package/src/shell/SwitchControl.d.ts +5 -11
- package/src/shell/SwitchControl.js +2 -20
- package/src/shell/TimelineBar.css +81 -81
- package/src/shell/TimelineBar.d.ts +5 -2
- package/src/shell/TimelineBar.js +9 -8
- package/src/shell/TimelineBar.node.js +9 -8
- package/src/shell/TopBar.css +22 -22
- package/src/shell/TopBar.d.ts +5 -1
- package/src/shell/TopBar.js +2 -2
- package/src/shell/TopBar.node.js +2 -2
- package/src/shell/bootLoader.d.ts +4 -10
- package/src/shell/bootLoader.js +6 -52
- package/src/shell/embedded.css +18 -18
- package/src/shell/experience.d.ts +1 -1
- package/src/shell/moonFamilies.d.ts +2 -6
- package/src/shell/moonFamilies.js +2 -18
- package/src/shell/phone.css +58 -58
- package/src/shell/storyPanels.d.ts +2 -53
- package/src/shell/storyPanels.js +1 -106
- package/src/shell/style.css +153 -134
- package/src/shell/useDrawers.d.ts +3 -2
- package/src/shell/useDrawers.js +4 -3
- package/src/shell/viewerKeys.d.ts +8 -0
- package/src/shell/viewerKeys.js +16 -0
- package/src/synthetic/syntheticDefinition.js +20 -24
- package/src/synthetic/syntheticJourneyScene.js +3 -3
- package/src/synthetic/syntheticProbeDefinition.js +2 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +0 -3
- package/src/synthetic/syntheticViewsDefinition.js +10 -16
- package/data/moons/jupiter.json +0 -3333
- package/data/moons/neptune.json +0 -555
- package/data/moons/pluto.json +0 -205
- package/data/moons/saturn.json +0 -8267
- package/data/moons/uranus.json +0 -887
- package/src/app/addressNavigation.d.ts +0 -17
- package/src/app/addressNavigation.js +0 -16
- package/src/assets/bodies/jupiterMoonCatalogue.d.ts +0 -3
- package/src/assets/bodies/jupiterMoonCatalogue.js +0 -4
- package/src/assets/bodies/outerPlanetCatalogues.d.ts +0 -7
- package/src/assets/bodies/outerPlanetCatalogues.js +0 -8
- package/src/assets/bodies/swiftTuttle.d.ts +0 -12
- package/src/assets/bodies/swiftTuttle.js +0 -13
- package/src/assets/moonCatalogue.d.ts +0 -49
- package/src/assets/moonCatalogue.js +0 -80
- package/src/core/bodies/outerPlanetData.d.ts +0 -4
- package/src/core/bodies/outerPlanetData.js +0 -13
- package/src/core/bodies/swiftTuttle.d.ts +0 -46
- package/src/core/bodies/swiftTuttle.js +0 -106
|
@@ -2,6 +2,7 @@ import { moonOrientationFromOrbit } from "../bodyOrientation.js";
|
|
|
2
2
|
import { ChebyshevEphemeris, parseEphemerisIndex } from "../chebyshevEphemeris.js";
|
|
3
3
|
import { iauOrientation } from "../iauRotation.js";
|
|
4
4
|
import { periodAboutBalanceS } from "../orbitPeriod.js";
|
|
5
|
+
import { NotLoadedError } from "../planetSeries.js";
|
|
5
6
|
import { createProvenance } from "../provenance.js";
|
|
6
7
|
import { assertUtcUnixMs, createState } from "../state.js";
|
|
7
8
|
/** The span the committed fits cover (T-096, T-114: 2010-01-01 to 2030-01-01 TDB, chunked per calendar year; the same for every system). */
|
|
@@ -52,7 +53,16 @@ const HISTORY_MARGIN = 1.05;
|
|
|
52
53
|
const DECODE_SLICE_MS = 8;
|
|
53
54
|
/** Half the time step (s) the orbit-derived tidal-lock orientation looks along the orbit, as Io's mean-element orientation did. */
|
|
54
55
|
const ORIENTATION_STEP_S = 1800;
|
|
56
|
+
/** Reads a `file:` address with Node's own module (found at run time, so a browser bundle never resolves it); Node's `fetch` does not serve `file:`. */
|
|
57
|
+
async function readFileUrl(url) {
|
|
58
|
+
const nodeFs = globalThis.process?.getBuiltinModule?.("node:fs/promises");
|
|
59
|
+
if (nodeFs === undefined)
|
|
60
|
+
throw new Error(`moon fit chunk ${url}: this runtime cannot read a file: address`);
|
|
61
|
+
return new Uint8Array(await nodeFs.readFile(new URL(url)));
|
|
62
|
+
}
|
|
55
63
|
const fetchBytesOf = async (url) => {
|
|
64
|
+
if (url.startsWith("file:"))
|
|
65
|
+
return readFileUrl(url);
|
|
56
66
|
const response = await fetch(url);
|
|
57
67
|
if (!response.ok)
|
|
58
68
|
throw new Error(`moon fit chunk ${url}: HTTP ${response.status}`);
|
|
@@ -61,11 +71,16 @@ const fetchBytesOf = async (url) => {
|
|
|
61
71
|
export function createMoonSystem(config) {
|
|
62
72
|
let installed = null;
|
|
63
73
|
let loadIndex = config.loadIndex;
|
|
64
|
-
|
|
74
|
+
/** The set built from the index, shared by every request (the index is read once); `held` is true when a set was handed in whole by `install`. */
|
|
75
|
+
let building = null;
|
|
76
|
+
let held = false;
|
|
77
|
+
/** Chunk paths already decoded into the set, and those being fetched now (shared by every request, so a path is fetched once). */
|
|
78
|
+
let added = new Set();
|
|
79
|
+
let fetching = new Map();
|
|
65
80
|
const tidalLockNote = `The orientation is an approximate tidal lock keeping the near side towards ${config.centreLabel}, with no libration.`;
|
|
66
81
|
const ephemeris = () => {
|
|
67
82
|
if (installed === null)
|
|
68
|
-
throw new
|
|
83
|
+
throw new NotLoadedError(`${config.centreLabel}'s moon fits are not loaded: await the system's load before mounting a scene with its moons`);
|
|
69
84
|
return installed;
|
|
70
85
|
};
|
|
71
86
|
const decodeInto = async (target, items, bytes) => {
|
|
@@ -78,6 +93,88 @@ export function createMoonSystem(config) {
|
|
|
78
93
|
}
|
|
79
94
|
}
|
|
80
95
|
};
|
|
96
|
+
const reset = () => { building = null; added = new Set(); fetching = new Map(); };
|
|
97
|
+
const indexSet = () => {
|
|
98
|
+
building ??= (async () => {
|
|
99
|
+
if (loadIndex === undefined)
|
|
100
|
+
throw new Error(`${config.centreLabel}'s moon positions are not provided: pass the astraeus-data-${config.centre} package to mount (data: [...]), or call provideIndex`);
|
|
101
|
+
return new ChebyshevEphemeris(parseEphemerisIndex(await loadIndex()));
|
|
102
|
+
})();
|
|
103
|
+
const own = building;
|
|
104
|
+
own.catch(() => { if (building === own)
|
|
105
|
+
building = null; });
|
|
106
|
+
return own;
|
|
107
|
+
};
|
|
108
|
+
/** Fetches and decodes the chunks of `items` the set does not hold and no request is already fetching; resolves when all of them are in. */
|
|
109
|
+
const ensureChunks = async (set, items, request) => {
|
|
110
|
+
const fetchBytes = request.fetchBytes ?? fetchBytesOf;
|
|
111
|
+
const waiting = [];
|
|
112
|
+
const mine = [];
|
|
113
|
+
for (const item of items) {
|
|
114
|
+
const inFlight = fetching.get(item.path);
|
|
115
|
+
if (inFlight !== undefined)
|
|
116
|
+
waiting.push(inFlight);
|
|
117
|
+
else if (!added.has(item.path) && !mine.some(({ path }) => path === item.path))
|
|
118
|
+
mine.push(item);
|
|
119
|
+
}
|
|
120
|
+
if (mine.length > 0) {
|
|
121
|
+
const batch = (async () => {
|
|
122
|
+
await decodeInto(set, mine, await Promise.all(mine.map(({ path }) => fetchBytes(request.chunkUrls[path]))));
|
|
123
|
+
for (const { path } of mine)
|
|
124
|
+
added.add(path);
|
|
125
|
+
})();
|
|
126
|
+
for (const { path } of mine)
|
|
127
|
+
fetching.set(path, batch);
|
|
128
|
+
const done = () => { for (const { path } of mine)
|
|
129
|
+
if (fetching.get(path) === batch)
|
|
130
|
+
fetching.delete(path); };
|
|
131
|
+
batch.then(done, done);
|
|
132
|
+
waiting.push(batch);
|
|
133
|
+
}
|
|
134
|
+
await Promise.all(waiting);
|
|
135
|
+
};
|
|
136
|
+
/** The chunks before the window the bodies' orbit lines need (about one period back, shipped ones only). */
|
|
137
|
+
const historyChunks = (set, request, history) => {
|
|
138
|
+
const start = request.window.startUtcMs;
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const body of history.bodies) {
|
|
141
|
+
const lookback = Math.min(history.maxMs, HISTORY_MARGIN * osculatingPeriodMs(set, body, start));
|
|
142
|
+
const from = Math.floor(Math.max(start - lookback, set.boundsOf(body).startUtcMs));
|
|
143
|
+
for (const chunk of set.chunksFor([body], from, start))
|
|
144
|
+
if (request.chunkUrls[chunk.path] !== undefined)
|
|
145
|
+
out.push(chunk);
|
|
146
|
+
}
|
|
147
|
+
return out;
|
|
148
|
+
};
|
|
149
|
+
/** A moon's orbit ring is centred on the clock, so at the window's last instant it reads ahead of it: the year after the window, where the build ships it (never required). */
|
|
150
|
+
const afterChunks = (set, request) => {
|
|
151
|
+
const end = request.window.endUtcMs;
|
|
152
|
+
const out = [];
|
|
153
|
+
for (const body of request.bodies) {
|
|
154
|
+
const limit = set.boundsOf(body).endUtcMs;
|
|
155
|
+
if (limit <= end)
|
|
156
|
+
continue;
|
|
157
|
+
for (const chunk of set.chunksFor([body], end, Math.min(limit, end + AFTER_WINDOW_MS)))
|
|
158
|
+
if (request.chunkUrls[chunk.path] !== undefined)
|
|
159
|
+
out.push(chunk);
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
162
|
+
};
|
|
163
|
+
const loadRequest = async (request) => {
|
|
164
|
+
if (held) {
|
|
165
|
+
assertWithinSpan(installed, request);
|
|
166
|
+
return installed;
|
|
167
|
+
}
|
|
168
|
+
const set = await indexSet();
|
|
169
|
+
assertWithinSpan(set, request);
|
|
170
|
+
await ensureChunks(set, chunksNeeded(set, request), request);
|
|
171
|
+
if (request.history !== undefined)
|
|
172
|
+
await ensureChunks(set, historyChunks(set, request, request.history), request);
|
|
173
|
+
await ensureChunks(set, afterChunks(set, request), request);
|
|
174
|
+
if (!held)
|
|
175
|
+
installed = set;
|
|
176
|
+
return set;
|
|
177
|
+
};
|
|
81
178
|
const osculatingPeriodMs = (set, body, timeUtcMs) => {
|
|
82
179
|
const state = set.stateOf(body, timeUtcMs);
|
|
83
180
|
const partner = config.balancePoint === undefined ? state : set.stateOf(config.balancePoint.body, timeUtcMs);
|
|
@@ -118,60 +215,10 @@ export function createMoonSystem(config) {
|
|
|
118
215
|
},
|
|
119
216
|
install(set) {
|
|
120
217
|
installed = set;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
load(request) {
|
|
124
|
-
if (installed !== null) {
|
|
125
|
-
try {
|
|
126
|
-
assertWithinSpan(installed, request);
|
|
127
|
-
}
|
|
128
|
-
catch (error) {
|
|
129
|
-
return Promise.reject(error);
|
|
130
|
-
}
|
|
131
|
-
return Promise.resolve(installed);
|
|
132
|
-
}
|
|
133
|
-
loading ??= (async () => {
|
|
134
|
-
if (loadIndex === undefined)
|
|
135
|
-
throw new Error(`${config.centreLabel}'s moon positions are not provided: pass the astraeus-data-${config.centre} package to mount (data: [...]), or call provideIndex`);
|
|
136
|
-
const set = new ChebyshevEphemeris(parseEphemerisIndex(await loadIndex()));
|
|
137
|
-
assertWithinSpan(set, request);
|
|
138
|
-
const needed = chunksNeeded(set, request);
|
|
139
|
-
const fetchBytes = request.fetchBytes ?? fetchBytesOf;
|
|
140
|
-
await decodeInto(set, needed, await Promise.all(needed.map(({ path }) => fetchBytes(request.chunkUrls[path]))));
|
|
141
|
-
if (request.history !== undefined) {
|
|
142
|
-
const loaded = new Set(needed.map(({ path }) => path));
|
|
143
|
-
const start = request.window.startUtcMs;
|
|
144
|
-
const extra = [];
|
|
145
|
-
for (const body of request.history.bodies) {
|
|
146
|
-
const lookback = Math.min(request.history.maxMs, HISTORY_MARGIN * osculatingPeriodMs(set, body, start));
|
|
147
|
-
const from = Math.floor(Math.max(start - lookback, set.boundsOf(body).startUtcMs));
|
|
148
|
-
for (const chunk of set.chunksFor([body], from, start)) {
|
|
149
|
-
if (loaded.has(chunk.path) || request.chunkUrls[chunk.path] === undefined)
|
|
150
|
-
continue;
|
|
151
|
-
loaded.add(chunk.path);
|
|
152
|
-
extra.push(chunk);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
await decodeInto(set, extra, await Promise.all(extra.map(({ path }) => fetchBytes(request.chunkUrls[path]))));
|
|
156
|
-
}
|
|
157
|
-
// A moon's orbit ring is centred on the clock, so at the window's last instant it reads ahead of it: also load the year after the window where the build ships it (never required).
|
|
158
|
-
const end = request.window.endUtcMs;
|
|
159
|
-
const after = [];
|
|
160
|
-
for (const body of request.bodies) {
|
|
161
|
-
const limit = set.boundsOf(body).endUtcMs;
|
|
162
|
-
if (limit <= end)
|
|
163
|
-
continue;
|
|
164
|
-
for (const chunk of set.chunksFor([body], end, Math.min(limit, end + AFTER_WINDOW_MS))) {
|
|
165
|
-
if (!needed.some(({ path }) => path === chunk.path) && request.chunkUrls[chunk.path] !== undefined && !after.some(({ path }) => path === chunk.path))
|
|
166
|
-
after.push(chunk);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
await decodeInto(set, after, await Promise.all(after.map(({ path }) => fetchBytes(request.chunkUrls[path]))));
|
|
170
|
-
installed = set;
|
|
171
|
-
return set;
|
|
172
|
-
})();
|
|
173
|
-
return loading;
|
|
218
|
+
held = set !== null;
|
|
219
|
+
reset();
|
|
174
220
|
},
|
|
221
|
+
load: (request) => loadRequest(request),
|
|
175
222
|
osculatingPeriodMs,
|
|
176
223
|
trajectory,
|
|
177
224
|
binding: (body, rotation) => Object.freeze({ body, create: (adapter) => trajectory(body, adapter, rotation) }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Saturn's, Uranus's and Neptune's ring bands as they are read (data/rings/<planet>.json, O-033 T-118). Raw JSON in its own file,
|
|
3
|
-
*
|
|
2
|
+
* Saturn's, Uranus's and Neptune's ring bands as they are read (data/rings/<planet>.json, O-033 T-118). Raw JSON in its own file, so a planet that carries its rings in the catalogue (O-048 T-205) reads
|
|
3
|
+
* only its rings (the moon lists live in the planets' data packages, O-059 T-270).
|
|
4
4
|
*/
|
|
5
5
|
import neptuneRings from "../../../data/rings/neptune.json" with { type: "json" };
|
|
6
6
|
import saturnRings from "../../../data/rings/saturn.json" with { type: "json" };
|
|
@@ -22,7 +22,7 @@ export function createPlanetSunTrajectory(planet, rotation, adapter, offsetKm) {
|
|
|
22
22
|
body: planet,
|
|
23
23
|
center: "sun",
|
|
24
24
|
timeUtcMs,
|
|
25
|
-
|
|
25
|
+
plane: EQJ,
|
|
26
26
|
positionKm: position,
|
|
27
27
|
orientation: iauOrientation(rotation, adapter.daysSinceJ2000Tt(timeUtcMs)),
|
|
28
28
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Shader uniform arrays hold at most this many families. */
|
|
2
|
+
export declare const MAX_BODY_SET_FAMILIES = 16;
|
|
3
|
+
export interface BodySetFamily {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
/** Default orbit colour, #rrggbb; the live settings may change it. */
|
|
7
|
+
readonly color: string;
|
|
8
|
+
/** Orbit brightness multiplier of the family before the live look changes it; absent: 1. */
|
|
9
|
+
readonly brightness?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Default orbit colours, in family order: the Okabe and Ito colour-blind-safe set (Okabe and Ito 2008, "Color Universal Design"), without
|
|
13
|
+
* its black and its dark blue (both vanish on the night sky), preceded by the cream of the existing orbit lines and followed by a neutral grey.
|
|
14
|
+
*/
|
|
15
|
+
export declare const DEFAULT_FAMILY_PALETTE: readonly string[];
|
|
16
|
+
/** Families in data order with the default palette's colours, cycling past its end. */
|
|
17
|
+
export declare function familiesWithPalette(families: readonly {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
}[], palette?: readonly string[]): readonly BodySetFamily[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The families of a body set and the colours they take: pure data and one helper, shared by the viewer's body sets and the scene builder.
|
|
2
|
+
/** Shader uniform arrays hold at most this many families. */
|
|
3
|
+
export const MAX_BODY_SET_FAMILIES = 16;
|
|
4
|
+
/**
|
|
5
|
+
* Default orbit colours, in family order: the Okabe and Ito colour-blind-safe set (Okabe and Ito 2008, "Color Universal Design"), without
|
|
6
|
+
* its black and its dark blue (both vanish on the night sky), preceded by the cream of the existing orbit lines and followed by a neutral grey.
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_FAMILY_PALETTE = Object.freeze(["#f0e6da", "#f0e442", "#e69f00", "#56b4e9", "#cc79a7", "#009e73", "#d55e00", "#bbbbbb"]);
|
|
9
|
+
/** Families in data order with the default palette's colours, cycling past its end. */
|
|
10
|
+
export function familiesWithPalette(families, palette = DEFAULT_FAMILY_PALETTE) {
|
|
11
|
+
if (families.length > MAX_BODY_SET_FAMILIES)
|
|
12
|
+
throw new RangeError(`a body set holds at most ${MAX_BODY_SET_FAMILIES} families, got ${families.length}`);
|
|
13
|
+
return Object.freeze(families.map((family, index) => Object.freeze({ id: family.id, label: family.label, color: palette[index % palette.length] })));
|
|
14
|
+
}
|
|
@@ -333,7 +333,7 @@ export class ChebyshevEphemeris {
|
|
|
333
333
|
velocity[axis] -= centreVelocity[axis];
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
|
-
return createState({ body: bodyId, center: this.index.centre, timeUtcMs,
|
|
336
|
+
return createState({ body: bodyId, center: this.index.centre, timeUtcMs, plane: EQJ, positionKm: position, velocityKmS: velocity, orientation: null });
|
|
337
337
|
}
|
|
338
338
|
/** The ordinary Trajectory for one body, valid inside `boundsOf(body)`, in the set's one centre. */
|
|
339
339
|
trajectory(bodyId) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BodyId, CelestialBodyDefinition, StateSourceBinding } from "./body.js";
|
|
2
|
+
import type { TimeInput } from "./timeInput.js";
|
|
2
3
|
import { type EccentricSampling } from "./sunCentredSources.js";
|
|
3
4
|
import type { Trajectory } from "./trajectory.js";
|
|
4
5
|
/** Default look of the marker that stands for a body on a published orbit; a record's own `marker` replaces either value. */
|
|
@@ -13,6 +14,7 @@ export declare const APPROXIMATE_LIMIT_FRACTION = 0.01;
|
|
|
13
14
|
export declare const INDICATIVE_LIMIT_FRACTION = 0.05;
|
|
14
15
|
/** The classification a largest error fraction earns, or null when it earns neither (the body should not be drawn from its elements alone). */
|
|
15
16
|
export declare function classifyPositionError(maxFraction: number): AccuracyClassification | null;
|
|
17
|
+
/** The time scale an elements solution is expressed in: "TDB", "TT" or "UTC". */
|
|
16
18
|
export type ElementsTimeScale = "TDB" | "TT" | "UTC";
|
|
17
19
|
/** The class a position comparison earns: `"approximate"` or `"indicative"` (see `classifyPositionError`). */
|
|
18
20
|
export type AccuracyClassification = "approximate" | "indicative";
|
|
@@ -47,7 +49,7 @@ export interface ElementsBodyRecord {
|
|
|
47
49
|
readonly ttMinusUtcSeconds?: number;
|
|
48
50
|
};
|
|
49
51
|
/** The plane the elements are given in. */
|
|
50
|
-
readonly
|
|
52
|
+
readonly plane: "ecliptic-j2000";
|
|
51
53
|
readonly source: ElementsSource;
|
|
52
54
|
readonly radius?: {
|
|
53
55
|
readonly km: number;
|
|
@@ -56,9 +58,11 @@ export interface ElementsBodyRecord {
|
|
|
56
58
|
readonly accuracy: {
|
|
57
59
|
readonly classification: AccuracyClassification;
|
|
58
60
|
readonly statement: string;
|
|
59
|
-
/** The dates the position was compared with an independent ephemeris: what the claim covers. */
|
|
60
|
-
readonly
|
|
61
|
-
|
|
61
|
+
/** The dates the position was compared with an independent ephemeris: what the claim covers. A record is usually JSON, so ISO text such as `2030-01-01T00:00:00Z` is the usual form; a Date or Unix milliseconds also read. */
|
|
62
|
+
readonly valid: {
|
|
63
|
+
readonly start: TimeInput;
|
|
64
|
+
readonly end: TimeInput;
|
|
65
|
+
};
|
|
62
66
|
/** Further limits to show beside the generic two-body ones. */
|
|
63
67
|
readonly limitations: readonly string[];
|
|
64
68
|
};
|
package/src/core/elementsBody.js
CHANGED
|
@@ -31,7 +31,21 @@ export class ElementsBodyError extends TypeError {
|
|
|
31
31
|
function fail(path, problem) {
|
|
32
32
|
throw new ElementsBodyError(`body record ${path} ${problem}`);
|
|
33
33
|
}
|
|
34
|
-
const { record, text, finite
|
|
34
|
+
const { record, text, finite } = fieldReaders(fail);
|
|
35
|
+
/** A moment a record gives: ISO text (kept as written), a Date or Unix milliseconds (both returned as ISO text); anything else is refused naming the field. */
|
|
36
|
+
function moment(parent, key, path) {
|
|
37
|
+
const value = parent[key];
|
|
38
|
+
if (typeof value === "string") {
|
|
39
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/.test(value) || !Number.isFinite(Date.parse(value))) {
|
|
40
|
+
fail(`${path}.${key}`, `must be an ISO-8601 UTC time like 2030-01-01T00:00:00Z, got "${value}"`);
|
|
41
|
+
}
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
const ms = value instanceof Date ? value.getTime() : value;
|
|
45
|
+
if (typeof ms !== "number" || !Number.isFinite(ms))
|
|
46
|
+
fail(`${path}.${key}`, `is required and must be an ISO-8601 UTC time like 2030-01-01T00:00:00Z, a Date or Unix milliseconds, got ${String(value)}`);
|
|
47
|
+
return new Date(ms).toISOString();
|
|
48
|
+
}
|
|
35
49
|
/** The five orbit-shape elements and the one placement along the orbit (exactly one of mean anomaly and perihelion time). */
|
|
36
50
|
function parseOrbitElements(raw, here) {
|
|
37
51
|
const semiMajorAxisAu = finite(raw, "semiMajorAxisAu", here);
|
|
@@ -86,14 +100,19 @@ function parseAccuracy(raw, here) {
|
|
|
86
100
|
const classification = raw.classification;
|
|
87
101
|
if (classification !== "approximate" && classification !== "indicative")
|
|
88
102
|
fail(`${here}.classification`, `must be "approximate" or "indicative", got ${String(classification)}`);
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
103
|
+
for (const [old, use] of [["validFromUtc", "valid.start"], ["validToUtc", "valid.end"]]) {
|
|
104
|
+
if (Object.hasOwn(raw, old))
|
|
105
|
+
fail(`${here}.${old}`, `is now \`${use}\` inside \`valid: { start, end }\` (the old name is not accepted)`);
|
|
106
|
+
}
|
|
107
|
+
const valid = record(raw.valid, `${here}.valid`);
|
|
108
|
+
const start = moment(valid, "start", `${here}.valid`);
|
|
109
|
+
const end = moment(valid, "end", `${here}.valid`);
|
|
110
|
+
if (Date.parse(end) <= Date.parse(start))
|
|
111
|
+
fail(`${here}.valid.end`, "must be after accuracy.valid.start");
|
|
93
112
|
const limitations = raw.limitations ?? [];
|
|
94
113
|
if (!Array.isArray(limitations) || limitations.some((item) => typeof item !== "string" || item.trim().length === 0))
|
|
95
114
|
fail(`${here}.limitations`, "must be a list of non-empty text");
|
|
96
|
-
return { classification, statement: text(raw, "statement", here),
|
|
115
|
+
return { classification, statement: text(raw, "statement", here), valid: { start, end }, limitations: [...limitations] };
|
|
97
116
|
}
|
|
98
117
|
function parseMarker(raw, here) {
|
|
99
118
|
const color = raw.color === undefined ? DEFAULT_ELEMENTS_MARKER_COLOUR : text(raw, "color", here);
|
|
@@ -113,13 +132,15 @@ export function parseElementsBodyRecord(input, path = "body") {
|
|
|
113
132
|
const label = text(root, "label", path);
|
|
114
133
|
const elements = parseOrbitElements(record(root.elements, `${path}.elements`), `${path}.elements`);
|
|
115
134
|
const epoch = parseEpoch(record(root.epoch, `${path}.epoch`), `${path}.epoch`);
|
|
116
|
-
if (root
|
|
117
|
-
fail(`${path}.frame`, `
|
|
135
|
+
if (Object.hasOwn(root, "frame"))
|
|
136
|
+
fail(`${path}.frame`, "is now `plane` (the old name is not accepted)");
|
|
137
|
+
if (root.plane !== "ecliptic-j2000")
|
|
138
|
+
fail(`${path}.plane`, `must be "ecliptic-j2000", got ${String(root.plane)}`);
|
|
118
139
|
const source = parseSource(record(root.source, `${path}.source`), `${path}.source`);
|
|
119
140
|
const radius = root.radius === undefined ? undefined : parseRadius(record(root.radius, `${path}.radius`), `${path}.radius`);
|
|
120
141
|
const accuracy = parseAccuracy(record(root.accuracy, `${path}.accuracy`), `${path}.accuracy`);
|
|
121
142
|
const marker = parseMarker(root.marker === undefined ? {} : record(root.marker, `${path}.marker`), `${path}.marker`);
|
|
122
|
-
return { id, label, elements, epoch,
|
|
143
|
+
return { id, label, elements, epoch, plane: "ecliptic-j2000", source, ...(radius === undefined ? {} : { radius }), accuracy, marker };
|
|
123
144
|
}
|
|
124
145
|
/** The epoch of a record in UTC milliseconds. */
|
|
125
146
|
export function epochUtcMsOf(epoch) {
|
|
@@ -151,7 +172,7 @@ export function buildElementsBody(input, centre) {
|
|
|
151
172
|
const create = () => createTwoBodyTrajectory({
|
|
152
173
|
body: body.id,
|
|
153
174
|
center: centre.id,
|
|
154
|
-
plane: body.
|
|
175
|
+
plane: body.plane,
|
|
155
176
|
epochUtcMs,
|
|
156
177
|
elements: {
|
|
157
178
|
semiMajorAxisKm,
|
|
@@ -187,7 +208,7 @@ export function buildElementsBody(input, centre) {
|
|
|
187
208
|
accuracyClass: body.accuracy.classification,
|
|
188
209
|
maxErrorFraction: body.accuracy.classification === "approximate" ? APPROXIMATE_LIMIT_FRACTION : INDICATIVE_LIMIT_FRACTION,
|
|
189
210
|
}),
|
|
190
|
-
validUtc: Object.freeze({ startUtcMs: Date.parse(body.accuracy.
|
|
211
|
+
validUtc: Object.freeze({ startUtcMs: Date.parse(body.accuracy.valid.start), endUtcMs: Date.parse(body.accuracy.valid.end) }),
|
|
191
212
|
orientationLimitations: Object.freeze([
|
|
192
213
|
`Unperturbed two-body motion about the Sun from osculating elements at JD ${body.epoch.jd} ${body.epoch.timeScale}: no planetary perturbations and no non-gravitational forces.`,
|
|
193
214
|
...body.accuracy.limitations,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Made-up members on two-body motion as a point group with the `EphemerisGroup` shape: each member has its own elements and moment, and the group
|
|
3
|
+
* answers the same questions a curve-fit group does (batch fill, one state, a position at any time, how far back the data reach), so a body set
|
|
4
|
+
* draws them with no change. Motion is unperturbed two-body about the centre; the centre's gravity comes from the adapter.
|
|
5
|
+
*/
|
|
6
|
+
import type { BodyId, CenterId } from "./body.js";
|
|
7
|
+
import type { EphemerisGroup } from "./ephemerisGroup.js";
|
|
8
|
+
import { type ElementPlane, type OrbitElements } from "./orbitGroup.js";
|
|
9
|
+
import type { Provenance } from "./provenance.js";
|
|
10
|
+
import type { TimeBounds } from "./trajectory.js";
|
|
11
|
+
import type { TwoBodyAdapter } from "./twoBodyAdapter.js";
|
|
12
|
+
/** One member: its id, its elements (km, degrees) and the moment they hold. */
|
|
13
|
+
export interface ElementsGroupMember {
|
|
14
|
+
readonly id: BodyId;
|
|
15
|
+
readonly elements: OrbitElements;
|
|
16
|
+
readonly epochUtcMs: number;
|
|
17
|
+
/** The plane the elements are given in. */
|
|
18
|
+
readonly plane: ElementPlane;
|
|
19
|
+
}
|
|
20
|
+
export interface ElementsGroupInput {
|
|
21
|
+
readonly id: BodyId;
|
|
22
|
+
readonly center: CenterId;
|
|
23
|
+
readonly members: readonly ElementsGroupMember[];
|
|
24
|
+
readonly bounds: TimeBounds;
|
|
25
|
+
readonly provenance: Provenance;
|
|
26
|
+
}
|
|
27
|
+
export declare function createElementsGroup(input: ElementsGroupInput, adapter: TwoBodyAdapter): EphemerisGroup;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { memberStatesOf, propagatedPositionOf } from "./orbitGroup.js";
|
|
2
|
+
import { assertFillBuffer, assertMemberIndex, assertWithinBounds, GroupElementsError, memberState } from "./pointGroup.js";
|
|
3
|
+
import { assertUtcUnixMs, EQJ, createState } from "./state.js";
|
|
4
|
+
const RADIANS = Math.PI / 180;
|
|
5
|
+
/** Half the step of the centred difference that gives a member's velocity, ms. */
|
|
6
|
+
const VELOCITY_HALF_STEP_MS = 500;
|
|
7
|
+
function classical(elements, id) {
|
|
8
|
+
for (const key of ["semiMajorAxisKm", "eccentricity", "inclinationDeg", "raanDeg", "argumentOfPeriapsisDeg", "trueAnomalyDeg"]) {
|
|
9
|
+
if (!Number.isFinite(elements[key]))
|
|
10
|
+
throw new GroupElementsError(`member "${id}" ${key} must be finite`);
|
|
11
|
+
}
|
|
12
|
+
const { semiMajorAxisKm, eccentricity } = elements;
|
|
13
|
+
if (!(semiMajorAxisKm > 0) || !(eccentricity >= 0 && eccentricity < 1))
|
|
14
|
+
throw new GroupElementsError(`member "${id}" needs a bound orbit: a positive semi-major axis and an eccentricity from 0 to below 1`);
|
|
15
|
+
if (!(elements.inclinationDeg >= 0 && elements.inclinationDeg <= 180))
|
|
16
|
+
throw new GroupElementsError(`member "${id}" inclination must be from 0 to 180 degrees`);
|
|
17
|
+
return {
|
|
18
|
+
semiMajorAxisKm,
|
|
19
|
+
eccentricity,
|
|
20
|
+
inclinationRad: elements.inclinationDeg * RADIANS,
|
|
21
|
+
raanRad: elements.raanDeg * RADIANS,
|
|
22
|
+
argumentOfPeriapsisRad: elements.argumentOfPeriapsisDeg * RADIANS,
|
|
23
|
+
trueAnomalyRad: elements.trueAnomalyDeg * RADIANS,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function createElementsGroup(input, adapter) {
|
|
27
|
+
const { id, center, bounds, provenance } = input;
|
|
28
|
+
const members = Object.freeze(input.members.map((member) => member.id));
|
|
29
|
+
if (members.length === 0)
|
|
30
|
+
throw new RangeError(`group "${id}" lists no members`);
|
|
31
|
+
if (new Set(members).size !== members.length)
|
|
32
|
+
throw new RangeError(`group "${id}" lists a member twice`);
|
|
33
|
+
if (!(bounds.endUtcMs >= bounds.startUtcMs))
|
|
34
|
+
throw new RangeError(`group "${id}" bounds end before they start`);
|
|
35
|
+
input.members.forEach((member) => assertUtcUnixMs(member.epochUtcMs));
|
|
36
|
+
// One state per member at its own moment: the shared placement takes each member's elements in turn.
|
|
37
|
+
const states = input.members.map((member) => memberStatesOf([classical(member.elements, member.id)], member.plane, center, adapter));
|
|
38
|
+
const count = members.length;
|
|
39
|
+
const one = new Float64Array(3);
|
|
40
|
+
const at = (index, timeUtcMs, out, offset) => {
|
|
41
|
+
assertMemberIndex(count, index);
|
|
42
|
+
assertUtcUnixMs(timeUtcMs);
|
|
43
|
+
out.set(propagatedPositionOf(states[index], 0, (timeUtcMs - input.members[index].epochUtcMs) / 1000, center, adapter), offset);
|
|
44
|
+
};
|
|
45
|
+
const group = {
|
|
46
|
+
id,
|
|
47
|
+
count,
|
|
48
|
+
center,
|
|
49
|
+
frame: EQJ,
|
|
50
|
+
bounds,
|
|
51
|
+
provenance,
|
|
52
|
+
members,
|
|
53
|
+
fillPositionsKm(timeUtcMs, out) {
|
|
54
|
+
assertWithinBounds(bounds, timeUtcMs);
|
|
55
|
+
assertFillBuffer(count, out);
|
|
56
|
+
for (let index = 0; index < count; index += 1)
|
|
57
|
+
at(index, timeUtcMs, out, 3 * index);
|
|
58
|
+
},
|
|
59
|
+
stateAt(index, timeUtcMs) {
|
|
60
|
+
assertWithinBounds(bounds, timeUtcMs);
|
|
61
|
+
at(index, timeUtcMs, one, 0);
|
|
62
|
+
return memberState(group, index, timeUtcMs, one);
|
|
63
|
+
},
|
|
64
|
+
memberPositionKmInto(index, timeUtcMs, out, offset) {
|
|
65
|
+
at(index, timeUtcMs, out, offset);
|
|
66
|
+
},
|
|
67
|
+
// Two-body motion needs no loaded data: it reaches back as far as asked.
|
|
68
|
+
memberLoadedFromUtcMs(index) {
|
|
69
|
+
assertMemberIndex(count, index);
|
|
70
|
+
return -Infinity;
|
|
71
|
+
},
|
|
72
|
+
memberStateAt(index, timeUtcMs) {
|
|
73
|
+
assertWithinBounds(bounds, timeUtcMs);
|
|
74
|
+
const here = new Float64Array(3);
|
|
75
|
+
const before = new Float64Array(3);
|
|
76
|
+
const after = new Float64Array(3);
|
|
77
|
+
at(index, timeUtcMs, here, 0);
|
|
78
|
+
at(index, timeUtcMs - VELOCITY_HALF_STEP_MS, before, 0);
|
|
79
|
+
at(index, timeUtcMs + VELOCITY_HALF_STEP_MS, after, 0);
|
|
80
|
+
const velocityKmS = Float64Array.from([0, 1, 2].map((k) => (after[k] - before[k]) / (2 * VELOCITY_HALF_STEP_MS / 1000)));
|
|
81
|
+
return createState({ body: members[index], center, timeUtcMs, plane: EQJ, positionKm: here, velocityKmS, orientation: null });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
return Object.freeze(group);
|
|
85
|
+
}
|
package/src/core/events.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface TimelineEvent {
|
|
|
6
6
|
readonly type?: string;
|
|
7
7
|
/** The id of an object in the scene the event is about; Go to frames it. */
|
|
8
8
|
readonly object?: string;
|
|
9
|
+
/** Half-width of the event's own zone, in simulated milliseconds: the zone is `timeUtcMs ± withinMs`. Absent: the event has no zone of its own (a pacing rule may still give it one). */
|
|
10
|
+
readonly withinMs?: number;
|
|
9
11
|
}
|
|
10
12
|
/** Validates and returns a frozen copy: times sorted ascending (ties allowed), ids unique. */
|
|
11
13
|
export declare function createEvents(input: readonly TimelineEvent[]): readonly TimelineEvent[];
|
package/src/core/events.js
CHANGED
|
@@ -11,6 +11,8 @@ export function createEvents(input) {
|
|
|
11
11
|
throw new RangeError(`duplicate event id "${event.id}"`);
|
|
12
12
|
if (event.timeUtcMs < previousMs)
|
|
13
13
|
throw new RangeError("events must be sorted by time");
|
|
14
|
+
if (event.withinMs !== undefined && !(Number.isFinite(event.withinMs) && event.withinMs > 0))
|
|
15
|
+
throw new RangeError(`event "${event.id}" withinMs must be positive and finite`);
|
|
14
16
|
ids.add(event.id);
|
|
15
17
|
previousMs = event.timeUtcMs;
|
|
16
18
|
}
|
package/src/core/illumination.js
CHANGED
|
@@ -10,7 +10,7 @@ function unit(vector, label) {
|
|
|
10
10
|
function validateSameCenter(a, b) {
|
|
11
11
|
if (a.timeUtcMs !== b.timeUtcMs)
|
|
12
12
|
throw new RangeError("illumination geometry requires identical timestamps");
|
|
13
|
-
if (a.
|
|
13
|
+
if (a.plane !== b.plane)
|
|
14
14
|
throw new RangeError("illumination geometry requires identical frames");
|
|
15
15
|
if (a.center !== b.center)
|
|
16
16
|
throw new RangeError("illumination geometry requires positions with the same center");
|
|
@@ -57,6 +57,8 @@ export declare function eccentricAnomalyRad(meanAnomalyRad: number, e: number):
|
|
|
57
57
|
export declare function trueAnomalyFromMeanRad(meanAnomalyRad: number, e: number): number;
|
|
58
58
|
/** Mean anomaly (radians, 0 to 2π) of a body with the given position and velocity about a centre of gravitational parameter `mu`. */
|
|
59
59
|
export declare function meanAnomalyFromStateRad(r: ArrayLike<number>, v: ArrayLike<number>, mu: number): number;
|
|
60
|
+
/** The provenance a group's own card carries: always illustrative, since the position along each orbit is a drawing choice; the source's type stays in the accuracy line. */
|
|
61
|
+
export declare function listedGroupProvenance(source: Provenance, concentrated: boolean): Provenance;
|
|
60
62
|
/**
|
|
61
63
|
* A group drawn from a list of measured orbits: each member has its own elements, record time and source record id. Only the
|
|
62
64
|
* position along each orbit is chosen here (see ListedPhase); every member then moves on its own ellipse by two-body motion.
|
|
@@ -147,6 +147,15 @@ function assignMeanAnomaliesDeg(count, phase, referenceDeg) {
|
|
|
147
147
|
const PHASE_NOTE = "Each orbit's shape and orientation come from its record, but the records give no position along the orbit: "
|
|
148
148
|
+ "that position is an even spread of mean anomaly at the reference time, a drawing choice (illustrative), advanced by unperturbed two-body motion about the centre.";
|
|
149
149
|
const CONCENTRATION_NOTE = "A stated share of the dots is placed near the reference body's position along the orbit: a model, not a measurement. No orbit is added.";
|
|
150
|
+
/** The provenance a group's own card carries: always illustrative, since the position along each orbit is a drawing choice; the source's type stays in the accuracy line. */
|
|
151
|
+
export function listedGroupProvenance(source, concentrated) {
|
|
152
|
+
return createProvenance({
|
|
153
|
+
sourceType: "illustrative",
|
|
154
|
+
sources: source.sources,
|
|
155
|
+
accuracy: `${source.accuracy} Orbit elements are as listed (${source.sourceType}); the position along each orbit is illustrative.`.trim(),
|
|
156
|
+
notes: `${source.notes} ${PHASE_NOTE}${concentrated ? ` ${CONCENTRATION_NOTE}` : ""}`.trim(),
|
|
157
|
+
});
|
|
158
|
+
}
|
|
150
159
|
/**
|
|
151
160
|
* A group drawn from a list of measured orbits: each member has its own elements, record time and source record id. Only the
|
|
152
161
|
* position along each orbit is chosen here (see ListedPhase); every member then moves on its own ellipse by two-body motion.
|
|
@@ -171,12 +180,7 @@ export function createListedOrbitGroup(input, adapter) {
|
|
|
171
180
|
trueAnomalyRad: trueAnomalyFromMeanRad(anomaliesDeg[member] * RADIANS, elements.eccentricity),
|
|
172
181
|
})), input.plane, center, adapter);
|
|
173
182
|
const recordIds = input.members.map((member) => member.recordId);
|
|
174
|
-
const provenance =
|
|
175
|
-
sourceType: "illustrative",
|
|
176
|
-
sources: input.provenance.sources,
|
|
177
|
-
accuracy: `${input.provenance.accuracy} Orbit elements are as listed (${input.provenance.sourceType}); the position along each orbit is illustrative.`.trim(),
|
|
178
|
-
notes: `${input.provenance.notes} ${PHASE_NOTE}${concentration === undefined ? "" : ` ${CONCENTRATION_NOTE}`}`.trim(),
|
|
179
|
-
});
|
|
183
|
+
const provenance = listedGroupProvenance(input.provenance, concentration !== undefined);
|
|
180
184
|
let kepler = null;
|
|
181
185
|
const group = {
|
|
182
186
|
id: input.id,
|
|
@@ -206,7 +210,7 @@ export function createListedOrbitGroup(input, adapter) {
|
|
|
206
210
|
assertUtcUnixMs(timeUtcMs);
|
|
207
211
|
assertWithinBounds(bounds, timeUtcMs);
|
|
208
212
|
const position = propagatedPositionOf(states, index, (timeUtcMs - referenceUtcMs) / 1000, center, adapter);
|
|
209
|
-
return createState({ body: `${input.id}:${recordIds[index]}`, center, timeUtcMs,
|
|
213
|
+
return createState({ body: `${input.id}:${recordIds[index]}`, center, timeUtcMs, plane: EQJ, positionKm: position, orientation: null });
|
|
210
214
|
},
|
|
211
215
|
recordIdAt(index) {
|
|
212
216
|
assertMemberIndex(count, index);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A family's heading count: "5 moons", "1 moon". */
|
|
2
|
+
export declare function moonCountText(count: number): string;
|
|
3
|
+
/** A date from the data (YYYY-MM-DD, or an ISO timestamp) as "18 October 2026"; the text itself when it is not a date. */
|
|
4
|
+
export declare function moonListDateText(date: string): string;
|
|
5
|
+
/** "115 moons in the JPL Horizons list of 18 October 2026": the count is the moons the list holds, the source and date come from the data. */
|
|
6
|
+
export declare function moonListSummary(count: number, source?: string, date?: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// The words of a moon list's count line, shared by the moon panel and `Scene.moonPanel` (no display code here, so the api can use it without loading the panel).
|
|
2
|
+
/** A family's heading count: "5 moons", "1 moon". */
|
|
3
|
+
export function moonCountText(count) {
|
|
4
|
+
return count === 1 ? "1 moon" : `${count} moons`;
|
|
5
|
+
}
|
|
6
|
+
/** A date from the data (YYYY-MM-DD, or an ISO timestamp) as "18 October 2026"; the text itself when it is not a date. */
|
|
7
|
+
export function moonListDateText(date) {
|
|
8
|
+
const parsed = /^\d{4}-\d{2}-\d{2}/.test(date) ? new Date(`${date.slice(0, 10)}T00:00:00Z`) : new Date(Number.NaN);
|
|
9
|
+
return Number.isNaN(parsed.getTime()) ? date : parsed.toLocaleDateString("en-GB", { day: "numeric", month: "long", year: "numeric", timeZone: "UTC" });
|
|
10
|
+
}
|
|
11
|
+
/** "115 moons in the JPL Horizons list of 18 October 2026": the count is the moons the list holds, the source and date come from the data. */
|
|
12
|
+
export function moonListSummary(count, source, date) {
|
|
13
|
+
const head = moonCountText(count);
|
|
14
|
+
if (source !== undefined && date !== undefined)
|
|
15
|
+
return `${head} in the ${source} list of ${moonListDateText(date)}`;
|
|
16
|
+
if (date !== undefined)
|
|
17
|
+
return `${head}, list of ${moonListDateText(date)}`;
|
|
18
|
+
return head;
|
|
19
|
+
}
|