astraeus 0.8.0 → 0.8.1

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +21 -5
  3. package/data/ephemerides/planets/planets.json +1 -1
  4. package/package.json +1 -1
  5. package/src/api/errors.d.ts +2 -0
  6. package/src/api/viewerHandle.d.ts +8 -2
  7. package/src/api/viewerHandle.js +1 -0
  8. package/src/api/viewerLink.d.ts +1 -0
  9. package/src/api/viewerLink.js +8 -2
  10. package/src/api/viewerSelection.d.ts +6 -1
  11. package/src/api/viewerSelection.js +15 -0
  12. package/src/api/views.d.ts +3 -1
  13. package/src/api/views.js +5 -1
  14. package/src/app/App.js +24 -4
  15. package/src/app/App.node.js +24 -4
  16. package/src/app/AstraeusScene.d.ts +2 -0
  17. package/src/app/sceneCamera.d.ts +2 -0
  18. package/src/app/sceneCamera.js +2 -1
  19. package/src/app/viewerPort.d.ts +2 -0
  20. package/src/app/views.d.ts +2 -0
  21. package/src/core/astronomyAdapter.d.ts +1 -1
  22. package/src/core/astronomyAdapter.js +3 -3
  23. package/src/core/bodies/index.js +13 -12
  24. package/src/core/bodies/jupiter.js +1 -1
  25. package/src/core/bodies/mars.js +1 -1
  26. package/src/core/bodies/mercury.js +1 -1
  27. package/src/core/bodies/outerPlanets.d.ts +2 -3
  28. package/src/core/bodies/outerPlanets.js +4 -13
  29. package/src/core/bodies/planetMoons.d.ts +0 -2
  30. package/src/core/bodies/planetMoons.js +1 -18
  31. package/src/core/bodies/planetRecords.d.ts +8 -2
  32. package/src/core/bodies/planetRecords.js +13 -5
  33. package/src/core/bodies/planetTrajectory.d.ts +21 -4
  34. package/src/core/bodies/planetTrajectory.js +28 -4
  35. package/src/core/bodies/venus.js +1 -1
  36. package/src/core/planetModels.d.ts +1 -1
  37. package/src/core/planetModels.js +1 -1
  38. package/src/core/planetSeries.d.ts +2 -2
  39. package/src/core/planetSeries.js +1 -1
  40. package/src/shell/AstraeusShell.d.ts +13 -1
  41. package/src/shell/AstraeusShell.js +33 -3
  42. package/src/shell/AstraeusShell.node.js +33 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astraeus",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "A 3D solar system engine for the browser: place bodies and recorded paths in a scene, mount it, and get time controls, camera, scale choice and body info. Planet positions and the main pictures included.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,6 +56,8 @@ export type SceneErrorCode =
56
56
  | "bad-camera"
57
57
  /** A scene view is malformed, repeated, or not one of the scene's views. */
58
58
  | "bad-view"
59
+ /** `setSelected` was given something other than an id of an object the showing view shows, or `undefined`. */
60
+ | "bad-selection"
59
61
  /** A look (`setLook`) is unknown or out of its range. */
60
62
  | "bad-look"
61
63
  /** An input field was given under a name it no longer has; the message names the old field and its replacement. */
@@ -32,11 +32,17 @@ export interface ViewerHandle {
32
32
  * `cause` is `playback` (the clock ran), `visitor` (timeline or view choice) or `host` (`setTime`, `setView`); overlapping zones report separately. A zone already active when the viewer opens reports `entered` once, with the first report after `ready` (within a tenth of a second), so a listener added right after `await ready` hears it. The engine moves nothing in response: a host composes its own behaviour, for example `setCamera`. No callbacks arrive after `unmount`. A listener that throws is reported to the page (`reportError`) and does not stop the listeners after it.
33
33
  */
34
34
  onEventZone(listener: (change: EventZoneChange) => void): () => void;
35
- /** The id of the object whose information the viewer has open (the one the object menu, a click or a view switch chose); undefined until `ready` has resolved, after `unmount`, and when nothing is selected. Read only: the host cannot select. */
35
+ /** The id of the object whose information the viewer has open (the one the object menu, a click or a view switch chose); undefined until `ready` has resolved, after `unmount`, and when nothing is selected. Set it with `setSelected`. */
36
36
  readonly selected: string | undefined;
37
+ /**
38
+ * Selects the object with this id, or clears the selection with `undefined`; `selected` reads it at once and `onSelect` hears it with `cause: "host"` (nothing is reported when the selection is already that).
39
+ * The object must be one the showing view shows: an unknown or hidden id, an empty or non-string id throws `bad-selection`; before `ready` or after `unmount`, `not-mounted`. Like the object menu it opens the object's card, but the camera stays where it is (`setCamera` points the camera); a clear closes the card.
40
+ * Like every host call it is the last word: made straight after `await ready`, before the first frame, or inside an `onChange` report of a view switch, it holds; a later view switch that no longer shows the object drops it as it drops a visitor's choice.
41
+ */
42
+ setSelected(id: string | undefined): void;
37
43
  /**
38
44
  * Calls `listener({ object?, timeUtcMs, cause })` when the selected object changes: `object` is the new id, absent when the selection was dropped (a view switch that no longer shows it, with nothing to take its place).
39
- * `cause` is `visitor` (the object menu, a click, or a time, speed or view the visitor chose), `host` (a drop caused by the host's own `setTime`, `setRate`, `setPlaying` or `setView`) or `playback` (a drop caused by the clock running); a drop takes the cause `onChange` reported for the move that caused it. The selection the viewer opens with is read from `selected`, not reported. The engine moves nothing in response.
45
+ * `cause` is `visitor` (the object menu, a click, or a time, speed or view the visitor chose), `host` (`setSelected`, or a drop caused by the host's own `setTime`, `setRate`, `setPlaying` or `setView`) or `playback` (a drop caused by the clock running); a drop takes the cause `onChange` reported for the move that caused it. The selection the viewer opens with is read from `selected`, not reported. The engine moves nothing in response.
40
46
  * No callbacks arrive after `unmount`. A listener that throws is reported to the page (`reportError`) and does not stop the listeners after it. Returns the function that stops it.
41
47
  */
42
48
  onSelect(listener: (change: SelectionChange) => void): () => void;
@@ -19,6 +19,7 @@ export function viewerHandleOf(link) {
19
19
  setSwitch: (id, on) => link.setSwitch(id, on),
20
20
  setView: (id) => link.setView(id),
21
21
  setCamera: (target) => link.setCamera(target),
22
+ setSelected: (id) => link.setSelected(id),
22
23
  setTime: (time) => link.setTime(time),
23
24
  setRate: (rate) => link.setRate(rate),
24
25
  setPlaying: (playing) => link.setPlaying(playing),
@@ -101,6 +101,7 @@ export declare class ViewerLink implements ViewerPort {
101
101
  setLook(look: LookInput): void;
102
102
  setScale(id: string): void;
103
103
  setSwitch(id: string, on: boolean): void;
104
+ setSelected(id: string | undefined): void;
104
105
  onChange(listener: (change: ViewerChange) => void): () => void;
105
106
  onEventZone(listener: (change: EventZoneChange) => void): () => void;
106
107
  setPick(value: string): void;
@@ -40,6 +40,8 @@ export class ViewerLink {
40
40
  /** What last moved the clock or the view, as published; a selection dropped by time or the view names it. */
41
41
  #mover = "playback";
42
42
  #closed = false;
43
+ /** How many publishes have started, so one can tell that a listener's host call published inside another. */
44
+ #publishes = 0;
43
45
  attach(control) {
44
46
  this.#control = control;
45
47
  this.#clock.reset(control.read());
@@ -108,6 +110,7 @@ export class ViewerLink {
108
110
  setLook(look) { this.#looks.setLook(look); this.#afterHost(); }
109
111
  setScale(id) { this.#looks.setScale(id); this.#afterHost(); }
110
112
  setSwitch(id, on) { this.#looks.setSwitch(id, on); this.#afterHost(); }
113
+ setSelected(id) { this.#selection.setSelected(id); this.#afterHost(); }
111
114
  onChange(listener) { return this.#clock.onChange(listener); }
112
115
  onEventZone(listener) { return this.#zones.onEventZone(listener); }
113
116
  setPick(value) { this.#picker.setPick(value); }
@@ -120,10 +123,13 @@ export class ViewerLink {
120
123
  onSelect(listener) { return this.#selection.onSelect(listener); }
121
124
  onCameraChange(listener) { return this.#camera.onCameraChange(listener); }
122
125
  publish(state, cause) {
126
+ const serial = ++this.#publishes;
123
127
  if (this.#clock.publish(state, cause))
124
128
  this.#mover = cause;
125
- this.#zones.publish(state, cause);
126
- this.#selection.publish(state, cause);
129
+ // An `onChange` listener that made a host call published inside the call above, with a newer reading: the rest of this publish goes by that reading, not the older one it was handed.
130
+ const now = this.#publishes === serial ? state : this.#control?.read() ?? state;
131
+ this.#zones.publish(now, cause);
132
+ this.#selection.publish(now, cause);
127
133
  this.#camera.publish();
128
134
  }
129
135
  /** The selection changed. A drop by time or the view names whatever last moved them (`onChange` names the same), so the cause is never a second opinion. */
@@ -6,7 +6,7 @@ export interface SelectionChange {
6
6
  readonly object?: string;
7
7
  /** The viewer's time at the report, Unix milliseconds UTC. */
8
8
  readonly timeUtcMs: number;
9
- /** `visitor`: the object menu, a click, or a clock or view change the visitor made; `host`: a host call (`setTime`, `setRate`, `setPlaying`, `setView`) moved the clock or view and the selection followed; `playback`: the clock running moved it. */
9
+ /** `visitor`: the object menu, a click, or a clock or view change the visitor made; `host`: a host call (`setSelected`, or `setTime`, `setRate`, `setPlaying`, `setView`) moved the clock or view and the selection followed; `playback`: the clock running moved it. */
10
10
  readonly cause: ViewerChangeCause;
11
11
  }
12
12
  /** The host link's selection: the selected object read and the `onSelect` callbacks. */
@@ -19,6 +19,11 @@ export declare class ViewerSelection {
19
19
  clearListeners(): void;
20
20
  /** The id of the selected object; undefined before the viewer is drawn, after it is gone and when nothing is selected. */
21
21
  get selected(): string | undefined;
22
+ /**
23
+ * Selects an object the showing view shows, or clears the selection with `undefined`; the caller then publishes it as a host change (`onSelect` with `cause: "host"`; nothing is reported when the selection is already that).
24
+ * Any other id (unknown, hidden by the showing view, empty) or a non-string throws `bad-selection`; before the viewer is drawn or after it is gone, `not-mounted`.
25
+ */
26
+ setSelected(id: unknown): void;
22
27
  /** Calls `listener` when the selected object changes; returns the function that stops it. */
23
28
  onSelect(listener: (change: SelectionChange) => void): () => void;
24
29
  publish(state: ViewerState, cause: ViewerChangeCause): void;
@@ -1,3 +1,4 @@
1
+ import { SceneError } from "./errors.js";
1
2
  import { callListeners } from "./listeners.js";
2
3
  /** The host link's selection: the selected object read and the `onSelect` callbacks. */
3
4
  export class ViewerSelection {
@@ -17,6 +18,20 @@ export class ViewerSelection {
17
18
  clearListeners() { this.#listeners.clear(); }
18
19
  /** The id of the selected object; undefined before the viewer is drawn, after it is gone and when nothing is selected. */
19
20
  get selected() { return this.access.control()?.read().selected; }
21
+ /**
22
+ * Selects an object the showing view shows, or clears the selection with `undefined`; the caller then publishes it as a host change (`onSelect` with `cause: "host"`; nothing is reported when the selection is already that).
23
+ * Any other id (unknown, hidden by the showing view, empty) or a non-string throws `bad-selection`; before the viewer is drawn or after it is gone, `not-mounted`.
24
+ */
25
+ setSelected(id) {
26
+ const control = this.access.open("setSelected");
27
+ if (id !== undefined) {
28
+ const shown = control.cameraTargets();
29
+ if (typeof id !== "string" || !shown.includes(id)) {
30
+ throw new SceneError("bad-selection", `setSelected: ${typeof id === "string" ? `"${id}"` : String(id)} is not an object the showing view shows (${shown.join(", ")}); give one of them, or undefined to clear`);
31
+ }
32
+ }
33
+ control.setSelected(id);
34
+ }
20
35
  /** Calls `listener` when the selected object changes; returns the function that stops it. */
21
36
  onSelect(listener) {
22
37
  this.#listeners.add(listener);
@@ -1,9 +1,11 @@
1
1
  import { type ViewPlace, type ViewSettings } from "../app/views.js";
2
- /** What a view's camera does when what it follows or focuses on is not in the view: `"stay"` (default) keeps the pose and stops following, `"start"` takes the scene's start, `{ follow: id }` / `{ focus: id }` takes that framing (the object must be in the view). */
2
+ /** What a view's camera does when what it follows or focuses on is not in the view: `"stay"` (default) keeps the pose and stops following, `"start"` takes the scene's start, `{ follow: id }` / `{ focus: id }` takes that framing (the object must be in the view). `always: true` on a framing applies it on every switch to the view, not only when the switch takes away what the camera follows or focuses on. */
3
3
  export type ViewCameraInput = "stay" | "start" | {
4
4
  readonly follow: string;
5
+ readonly always?: true;
5
6
  } | {
6
7
  readonly focus: string;
8
+ readonly always?: true;
7
9
  };
8
10
  /** One named view. `objects` are `addBody`, `addGroup` or `addTrajectory` ids, `events` are `addEvents` ids and `panels` are `addStoryPanels` ids. */
9
11
  export interface ViewInput {
package/src/api/views.js CHANGED
@@ -46,9 +46,13 @@ function cameraOf(view) {
46
46
  const follow = camera?.follow;
47
47
  const focus = camera?.focus;
48
48
  const target = follow ?? focus;
49
+ const always = camera?.always;
50
+ if (always !== undefined && always !== true)
51
+ throw bad(`view "${view.id}" camera always must be true when given, got ${JSON.stringify(always)}`);
49
52
  if (typeof camera !== "object" || camera === null || typeof target !== "string" || target === "" || (follow !== undefined) === (focus !== undefined))
50
53
  throw bad(`view "${view.id}" camera must be "stay", "start", { follow: id } or { focus: id }, got ${JSON.stringify(camera)}`);
51
- return { rule: "start", framing: follow === undefined ? { focus: target } : { follow: target } };
54
+ const keep = always === true ? { always: true } : {};
55
+ return { rule: "start", framing: follow === undefined ? { focus: target, ...keep } : { follow: target, ...keep } };
52
56
  }
53
57
  /**
54
58
  * Resolves the membership once: for each kind, an id no view names shows in every view, and an id some views name shows only in those. Throws `bad-view` for an id the scene does not hold
package/src/app/App.js CHANGED
@@ -312,6 +312,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
312
312
  const viewRef = useRef(viewId);
313
313
  const chooseView = useCallback((id) => {
314
314
  viewRef.current = id;
315
+ controls.current.hostCameraRequest = null; // a host camera call counts from this switch on
315
316
  controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
316
317
  // The showing view's events choose the pacing zones; a paced rate that changes with them eases in rather than jumping.
317
318
  if (controls.current.pace !== undefined) {
@@ -342,7 +343,18 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
342
343
  // The presentation (scale, looks, switches) last told to the host, to find what a visitor changed.
343
344
  const shownKey = useRef(null);
344
345
  // `origin` "move": time or the view moved and the selection followed (a drop or a view rule's framing target); the link names whatever last moved them (a host call, the visitor or playback).
346
+ // The host's `setSelected` not yet applied by the shell (id "" clears); the shell applies it after its own view-switch choices, so the host call is the last word.
347
+ const hostSelect = useRef(null);
348
+ const [selectRequest, setSelectRequest] = useState(null);
349
+ const hostSetSelected = useCallback((id) => {
350
+ hostSelect.current = id ?? "";
351
+ controls.current.selectedObjectId = id ?? ""; // `read()` shows it at once
352
+ setSelectRequest((previous) => ({ id: id ?? "", serial: (previous?.serial ?? 0) + 1 }));
353
+ }, []);
354
+ const hostSelectApplied = useCallback(() => { hostSelect.current = null; }, []);
345
355
  const updateSelectedObject = useCallback((objectId, origin) => {
356
+ if (hostSelect.current !== null)
357
+ return; // a host `setSelected` is waiting for the shell: the shell's older choice must not undo it (the host-call order rule)
346
358
  const changed = controls.current.selectedObjectId !== objectId;
347
359
  controls.current.selectedObjectId = objectId;
348
360
  if (changed && hostAttached.current)
@@ -373,6 +385,12 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
373
385
  }
374
386
  setClockSnapshot(runtime.clock.snapshot());
375
387
  }, [runtime]);
388
+ // A host's time jump is a seek for story panels, as a visitor's is: the shell's note re-bases the crossing check first.
389
+ const storySeekNote = useRef(null);
390
+ const hostSeekTo = useCallback((timeUtcMs) => {
391
+ storySeekNote.current?.(timeUtcMs);
392
+ seekTo(timeUtcMs);
393
+ }, [seekTo]);
376
394
  // A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
377
395
  const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
378
396
  const changeRate = useCallback((rate) => {
@@ -399,7 +417,9 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
399
417
  const readCamera = useCallback(() => {
400
418
  return { ...(controls.current.viewReadout ?? opening) };
401
419
  }, [opening]);
402
- const setCamera = useCallback((request) => { controls.current.cameraRequest = request; }, []);
420
+ // A host camera call is the last word: it is also kept in `hostCameraRequest`, so the opening view (first frame) and a view's own camera rule (shell) yield to it.
421
+ const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = request; }, []);
422
+ const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
403
423
  const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
404
424
  const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
405
425
  const hostSetScale = useCallback((id) => live.current?.setScale(id), []);
@@ -409,9 +429,9 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
409
429
  return undefined;
410
430
  hostAttached.current = true;
411
431
  shownKey.current = null; // the presentation is read afresh after each attach
412
- host.attach({ ...(definition.picker === undefined ? {} : { picker: { id: definition.picker.id, values: definition.picker.options.map((option) => option.value), start: definition.picker.value } }), window: runtime.loopWindow, events: experience.events, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
432
+ host.attach({ ...(definition.picker === undefined ? {} : { picker: { id: definition.picker.id, values: definition.picker.options.map((option) => option.value), start: definition.picker.value } }), window: runtime.loopWindow, events: experience.events, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: hostSeekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, setSelected: hostSetSelected, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
413
433
  return () => { hostAttached.current = false; host.detach(); };
414
- }, [host, runtime, definition, seekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
434
+ }, [host, runtime, definition, hostSeekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, hostSetSelected, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
415
435
  useEffect(() => {
416
436
  if (!developerMode)
417
437
  return undefined;
@@ -569,5 +589,5 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
569
589
  }, onSeek: (timeUtcMs) => {
570
590
  seekTo(timeUtcMs);
571
591
  host?.publish(stateNow(), "visitor");
572
- }, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
592
+ }, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
573
593
  }
@@ -312,6 +312,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
312
312
  const viewRef = useRef(viewId);
313
313
  const chooseView = useCallback((id) => {
314
314
  viewRef.current = id;
315
+ controls.current.hostCameraRequest = null; // a host camera call counts from this switch on
315
316
  controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
316
317
  // The showing view's events choose the pacing zones; a paced rate that changes with them eases in rather than jumping.
317
318
  if (controls.current.pace !== undefined) {
@@ -342,7 +343,18 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
342
343
  // The presentation (scale, looks, switches) last told to the host, to find what a visitor changed.
343
344
  const shownKey = useRef(null);
344
345
  // `origin` "move": time or the view moved and the selection followed (a drop or a view rule's framing target); the link names whatever last moved them (a host call, the visitor or playback).
346
+ // The host's `setSelected` not yet applied by the shell (id "" clears); the shell applies it after its own view-switch choices, so the host call is the last word.
347
+ const hostSelect = useRef(null);
348
+ const [selectRequest, setSelectRequest] = useState(null);
349
+ const hostSetSelected = useCallback((id) => {
350
+ hostSelect.current = id ?? "";
351
+ controls.current.selectedObjectId = id ?? ""; // `read()` shows it at once
352
+ setSelectRequest((previous) => ({ id: id ?? "", serial: (previous?.serial ?? 0) + 1 }));
353
+ }, []);
354
+ const hostSelectApplied = useCallback(() => { hostSelect.current = null; }, []);
345
355
  const updateSelectedObject = useCallback((objectId, origin) => {
356
+ if (hostSelect.current !== null)
357
+ return; // a host `setSelected` is waiting for the shell: the shell's older choice must not undo it (the host-call order rule)
346
358
  const changed = controls.current.selectedObjectId !== objectId;
347
359
  controls.current.selectedObjectId = objectId;
348
360
  if (changed && hostAttached.current)
@@ -373,6 +385,12 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
373
385
  }
374
386
  setClockSnapshot(runtime.clock.snapshot());
375
387
  }, [runtime]);
388
+ // A host's time jump is a seek for story panels, as a visitor's is: the shell's note re-bases the crossing check first.
389
+ const storySeekNote = useRef(null);
390
+ const hostSeekTo = useCallback((timeUtcMs) => {
391
+ storySeekNote.current?.(timeUtcMs);
392
+ seekTo(timeUtcMs);
393
+ }, [seekTo]);
376
394
  // A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
377
395
  const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
378
396
  const changeRate = useCallback((rate) => {
@@ -399,7 +417,9 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
399
417
  const readCamera = useCallback(() => {
400
418
  return { ...(controls.current.viewReadout ?? opening) };
401
419
  }, [opening]);
402
- const setCamera = useCallback((request) => { controls.current.cameraRequest = request; }, []);
420
+ // A host camera call is the last word: it is also kept in `hostCameraRequest`, so the opening view (first frame) and a view's own camera rule (shell) yield to it.
421
+ const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = request; }, []);
422
+ const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
403
423
  const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
404
424
  const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
405
425
  const hostSetScale = useCallback((id) => live.current?.setScale(id), []);
@@ -409,9 +429,9 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
409
429
  return undefined;
410
430
  hostAttached.current = true;
411
431
  shownKey.current = null; // the presentation is read afresh after each attach
412
- host.attach({ ...(definition.picker === undefined ? {} : { picker: { id: definition.picker.id, values: definition.picker.options.map((option) => option.value), start: definition.picker.value } }), window: runtime.loopWindow, events: experience.events, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
432
+ host.attach({ ...(definition.picker === undefined ? {} : { picker: { id: definition.picker.id, values: definition.picker.options.map((option) => option.value), start: definition.picker.value } }), window: runtime.loopWindow, events: experience.events, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: hostSeekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, setSelected: hostSetSelected, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
413
433
  return () => { hostAttached.current = false; host.detach(); };
414
- }, [host, runtime, definition, seekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
434
+ }, [host, runtime, definition, hostSeekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, hostSetSelected, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
415
435
  useEffect(() => {
416
436
  if (!developerMode)
417
437
  return undefined;
@@ -569,5 +589,5 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
569
589
  }, onSeek: (timeUtcMs) => {
570
590
  seekTo(timeUtcMs);
571
591
  host?.publish(stateNow(), "visitor");
572
- }, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
592
+ }, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale, onFirstDraw: host === undefined ? undefined : told }) }) }));
573
593
  }
@@ -75,6 +75,8 @@ export interface SceneRuntime {
75
75
  export interface SceneControls {
76
76
  policy: ScalePolicy;
77
77
  cameraRequest: CameraRequest | null;
78
+ /** The host's last `setCamera`, kept so the opening view and a view's own camera rule cannot discard it. Absent: none. */
79
+ hostCameraRequest?: CameraRequest | null;
78
80
  /** Presentation only: show source-anchor ID labels beside the anchor dots. */
79
81
  showAnchorLabels: boolean;
80
82
  /** Presentation only: draw the Milky Way picture behind the stars (the stars are always drawn while the sky is). */
@@ -10,6 +10,8 @@ import type { StartView } from "./viewLink.js";
10
10
  export interface CameraControls {
11
11
  startView?: StartView;
12
12
  cameraRequest: CameraRequest | null;
13
+ /** The host's last `setCamera`, kept apart from `cameraRequest` so the opening view and a view's own camera rule cannot discard it (the host-call order rule). */
14
+ hostCameraRequest?: CameraRequest | null;
13
15
  }
14
16
  export interface CameraStepInput {
15
17
  readonly camState: OrbitCameraState;
@@ -35,7 +35,8 @@ function openFirstFrame(input) {
35
35
  const view = controls.startView;
36
36
  if (view !== undefined && canFocus(targets, view.focus)) {
37
37
  applyStartView(camState, view);
38
- controls.cameraRequest = null;
38
+ // The opening view replaces any request made before the first frame, except the host's: that one is applied after it.
39
+ controls.cameraRequest = controls.hostCameraRequest ?? null;
39
40
  return false;
40
41
  }
41
42
  if (controls.cameraRequest === null && startsInsideFocus(camState.distance, targets.bodyIdFor(camState.focus) ?? camState.focus, frame, targets.policy, reach)) {
@@ -65,6 +65,8 @@ export interface ViewerControl {
65
65
  cameraTargets(): readonly string[];
66
66
  /** The camera as the viewer's view link writes it; undefined until the scene has drawn its first frame. */
67
67
  readCamera(): StartView | undefined;
68
+ /** Selects the object with this id (one of `cameraTargets()`), or clears the selection (`undefined`); `read()` shows it at once. */
69
+ setSelected(id: string | undefined): void;
68
70
  /** Asks the scene camera for a follow, focus or pose through its own request path (the same one a view's camera rule uses). */
69
71
  setCamera(request: CameraRequest): void;
70
72
  }
@@ -9,8 +9,10 @@ export type ViewCameraRule = {
9
9
  readonly rule: "start";
10
10
  readonly framing?: {
11
11
  readonly follow: string;
12
+ readonly always?: true;
12
13
  } | {
13
14
  readonly focus: string;
15
+ readonly always?: true;
14
16
  };
15
17
  };
16
18
  /** One view, resolved once when the scene is built. The sets hold every id of that kind the view shows (an id no view names is in every view's set); switching only changes which set is read. */
@@ -5,7 +5,7 @@ export interface AstronomyAdapter {
5
5
  earthPositionFromSunKm(timeUtcMs: number): Float64Array;
6
6
  sunPositionFromEarthKm(timeUtcMs: number): Float64Array;
7
7
  earthFixedToEqjMatrix(timeUtcMs: number): Float64Array;
8
- /** Planet position about the Sun in EQJ km (VSOP87A); throws for a planet the adapter has no model for. */
8
+ /** Planet system barycentre about the Sun in EQJ km (the planet series, JPL Horizons); throws for a planet the adapter has no model for. */
9
9
  planetPositionFromSunKm(planet: PlanetId, timeUtcMs: number): Float64Array;
10
10
  /** Days of terrestrial time since J2000 (JD 2451545.0 TT), the epoch the IAU rotation models count from. */
11
11
  daysSinceJ2000Tt(timeUtcMs: number): number;
@@ -61,7 +61,7 @@ export function createOrbAstronomyAdapter() {
61
61
  const model = planetModels()[planet];
62
62
  const ecliptic = model.xyz(new Date(timeUtcMs));
63
63
  if (ecliptic.coordinate_keywords !== "ecliptic rectangular j2000" || ecliptic.unit_keywords !== "au") {
64
- throw new TypeError("Orb VSOP87A result changed its heliocentric ecliptic-J2000 au contract");
64
+ throw new TypeError("the planet series result changed its heliocentric ecliptic-J2000 au contract (JPL Horizons fit)");
65
65
  }
66
66
  const state = makeState({
67
67
  t: instant,
@@ -71,8 +71,8 @@ export function createOrbAstronomyAdapter() {
71
71
  });
72
72
  const eqj = transform(state, { frame: "equatorial-j2000" });
73
73
  if (eqj.center !== "sun")
74
- throw new TypeError("Orb VSOP87A transform changed its center");
75
- return finiteVector(eqj.r, `${planet} VSOP87A`);
74
+ throw new TypeError("Orb ecliptic-to-equatorial transform of the planet series changed its center");
75
+ return finiteVector(eqj.r, `${planet} Horizons planet series`);
76
76
  },
77
77
  daysSinceJ2000Tt(timeUtcMs) {
78
78
  const [jd1, jd2] = instantAt(timeUtcMs).jd2parts("tt");
@@ -1,15 +1,15 @@
1
1
  import { MoonTrajectory } from "../moonTrajectory.js";
2
- import { createPlanetSunTrajectory } from "./planetTrajectory.js";
2
+ import { planetBinding } from "./planetTrajectory.js";
3
3
  import { createEarthSunTrajectory } from "../sunCentredSources.js";
4
4
  import { EARTH } from "./earth.js";
5
5
  import { MOON } from "./moon.js";
6
6
  import { IO, IO_BINDING } from "./io.js";
7
- import { CALLISTO, EUROPA, GANYMEDE, MAPPED_MOON_BINDINGS } from "./jupiterMoons.js";
7
+ import { CALLISTO, EUROPA, GANYMEDE, JUPITER_MOON_SYSTEM, MAPPED_MOON_BINDINGS } from "./jupiterMoons.js";
8
8
  import { JUPITER, JUPITER_ROTATION } from "./jupiter.js";
9
9
  import { MARS, MARS_ROTATION } from "./mars.js";
10
10
  import { MERCURY, MERCURY_ROTATION } from "./mercury.js";
11
- import { NEPTUNE, NEPTUNE_ROTATION, PLUTO, SATURN, SATURN_ROTATION, URANUS, URANUS_ROTATION } from "./outerPlanets.js";
12
- import { PLANET_MOON_BINDINGS, PLANET_MOON_DEFINITIONS, PLUTO_BINDING } from "./planetMoons.js";
11
+ import { NEPTUNE, NEPTUNE_ROTATION, PLUTO, PLUTO_ROTATION, SATURN, SATURN_ROTATION, URANUS, URANUS_ROTATION } from "./outerPlanets.js";
12
+ import { MARS_MOON_SYSTEM, NEPTUNE_MOON_SYSTEM, PLANET_MOON_BINDINGS, PLANET_MOON_DEFINITIONS, PLUTO_MOON_SYSTEM, SATURN_MOON_SYSTEM, URANUS_MOON_SYSTEM } from "./planetMoons.js";
13
13
  import { SUN } from "./sun.js";
14
14
  import { VENUS, VENUS_ROTATION } from "./venus.js";
15
15
  export { EARTH, EARTH_EPHEMERIS } from "./earth.js";
@@ -28,14 +28,15 @@ export const BUILT_IN_BODIES = Object.freeze([SUN, EARTH, MOON, MERCURY, VENUS,
28
28
  export const BUILT_IN_BINDINGS = Object.freeze([
29
29
  Object.freeze({ body: EARTH.id, create: createEarthSunTrajectory }),
30
30
  Object.freeze({ body: MOON.id, create: (adapter) => new MoonTrajectory(adapter) }),
31
- Object.freeze({ body: MERCURY.id, create: (adapter) => createPlanetSunTrajectory("mercury", MERCURY_ROTATION, adapter) }),
32
- Object.freeze({ body: VENUS.id, create: (adapter) => createPlanetSunTrajectory("venus", VENUS_ROTATION, adapter) }),
33
- Object.freeze({ body: MARS.id, create: (adapter) => createPlanetSunTrajectory("mars", MARS_ROTATION, adapter) }),
34
- Object.freeze({ body: JUPITER.id, create: (adapter) => createPlanetSunTrajectory("jupiter", JUPITER_ROTATION, adapter) }),
35
- Object.freeze({ body: SATURN.id, create: (adapter) => createPlanetSunTrajectory("saturn", SATURN_ROTATION, adapter) }),
36
- Object.freeze({ body: URANUS.id, create: (adapter) => createPlanetSunTrajectory("uranus", URANUS_ROTATION, adapter) }),
37
- Object.freeze({ body: NEPTUNE.id, create: (adapter) => createPlanetSunTrajectory("neptune", NEPTUNE_ROTATION, adapter) }),
38
- PLUTO_BINDING,
31
+ // Each planet is its system barycentre plus, with its moon system loaded, its own offset from it (O-063 T-290).
32
+ planetBinding("mercury", MERCURY_ROTATION),
33
+ planetBinding("venus", VENUS_ROTATION),
34
+ planetBinding("mars", MARS_ROTATION, MARS_MOON_SYSTEM),
35
+ planetBinding("jupiter", JUPITER_ROTATION, JUPITER_MOON_SYSTEM),
36
+ planetBinding("saturn", SATURN_ROTATION, SATURN_MOON_SYSTEM),
37
+ planetBinding("uranus", URANUS_ROTATION, URANUS_MOON_SYSTEM),
38
+ planetBinding("neptune", NEPTUNE_ROTATION, NEPTUNE_MOON_SYSTEM),
39
+ planetBinding("pluto", PLUTO_ROTATION, PLUTO_MOON_SYSTEM),
39
40
  IO_BINDING,
40
41
  ...MAPPED_MOON_BINDINGS,
41
42
  ...PLANET_MOON_BINDINGS,
@@ -1,6 +1,6 @@
1
1
  import { createProvenance } from "../provenance.js";
2
2
  import { IAU_REPORT, PLANET_VALIDATED_UTC, planetEphemeris, ROTATION_LIMITATION } from "./planetRecords.js";
3
- export const JUPITER_EPHEMERIS = planetEphemeris("Jupiter", "at most 1269 km (0.33 arcsec) from Horizons", ["The largest sampled difference from the Horizons body centre is about 1.3 thousand km, larger than the inner planets because the series is fitted to the planet as a system."]);
3
+ export const JUPITER_EPHEMERIS = planetEphemeris("Jupiter", "599", "DE441 with the Jupiter satellite ephemeris jup365_merged", "With the Jupiter moon package loaded (it covers 1950 to 2029), within 0.5 km of Horizons' Jupiter on 2 January of each year 1972 to 2029 and 0.22 to 0.24 km at the Voyager 1 and 2 closest approaches (O-063 T-290).", "Until the Jupiter moon package is loaded for the date Jupiter sits at its system barycentre, up to 216 km from its centre (measured 1972 to 2044).");
4
4
  /** Jupiter pole and prime meridian from the IAU 2015 report: degrees, pole per Julian century, W per day, from J2000 TDB. */
5
5
  export const JUPITER_ROTATION = Object.freeze({
6
6
  poleRaDeg: [268.056595, -0.006499],
@@ -1,6 +1,6 @@
1
1
  import { createProvenance } from "../provenance.js";
2
2
  import { IAU_REPORT, PLANET_VALIDATED_UTC, planetEphemeris, ROTATION_LIMITATION } from "./planetRecords.js";
3
- export const MARS_EPHEMERIS = planetEphemeris("Mars", "at most 96 km (0.09 arcsec) from Horizons");
3
+ export const MARS_EPHEMERIS = planetEphemeris("Mars", "499", "DE441 with the Mars satellite ephemeris mar099", "Within 0.6 km of Horizons' Mars on 2 January of each year 1972 to 2044, with or without the Mars moon package (O-063 T-290).", "Until the Mars moon package is loaded (it covers 2010 to 2029) Mars sits at its system barycentre, under a metre from its centre.");
4
4
  /** Mars pole and prime meridian from the IAU 2015 report: degrees, pole per Julian century, W per day, from J2000 TDB. */
5
5
  export const MARS_ROTATION = Object.freeze({
6
6
  poleRaDeg: [317.269202, -0.10927547],
@@ -1,6 +1,6 @@
1
1
  import { createProvenance } from "../provenance.js";
2
2
  import { IAU_REPORT, PLANET_VALIDATED_UTC, planetEphemeris, ROTATION_LIMITATION } from "./planetRecords.js";
3
- export const MERCURY_EPHEMERIS = planetEphemeris("Mercury", "at most 30 km (0.11 arcsec) from Horizons");
3
+ export const MERCURY_EPHEMERIS = planetEphemeris("Mercury", "199", "DE441 (Mercury has no moons: its barycentre, 1, is the planet)", "Within 0.4 km of Horizons' Mercury on 2 January of each year 1972 to 2044 (O-063 T-290); the fit is within 0.62 km of Horizons at independent dates 1950 to 2045.");
4
4
  /** Mercury pole and prime meridian from the IAU 2015 report: degrees, pole per Julian century, W per day, from J2000 TDB. */
5
5
  export const MERCURY_ROTATION = Object.freeze({
6
6
  poleRaDeg: [281.0103, -0.0328],
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Saturn, Uranus, Neptune and Pluto (O-033 T-116): defined once here, placed Sun-centred from the planet curve fits (`data/ephemerides/planets/`,
3
- * T-114: VSOP87A for the first three; Pluto's system barycentre from JPL Horizons), turned by the IAU pole and prime meridian. Their radii and
3
+ * each the system barycentre as JPL Horizons reports the planet, O-063 T-290), turned by the IAU pole and prime meridian. Their radii and
4
4
  * gravitational parameters are the Horizons physical-data headers saved in each system's moon index (`data/ephemerides/<planet>-moons/index.json`).
5
- * Pluto is placed at the system barycentre plus its own offset when its system is loaded: that binding is `PLUTO_BINDING` in `planetMoons.ts`.
5
+ * Each is placed at the system barycentre plus its own offset when its moon system is loaded: that binding is `planetBinding` in `planetTrajectory.ts`.
6
6
  */
7
7
  import type { CelestialBodyDefinition, EphemerisRecord } from "../body.js";
8
8
  import type { IauRotationElements } from "../iauRotation.js";
@@ -14,7 +14,6 @@ export declare const PLUTO_ROTATION: IauRotationElements;
14
14
  export declare const SATURN_EPHEMERIS: EphemerisRecord;
15
15
  export declare const URANUS_EPHEMERIS: EphemerisRecord;
16
16
  export declare const NEPTUNE_EPHEMERIS: EphemerisRecord;
17
- /** Pluto has no VSOP87 series: its barycentre is a curve fit of Horizons states (T-114, T-116), and its own wobble about it comes from its system's fits. */
18
17
  export declare const PLUTO_EPHEMERIS: EphemerisRecord;
19
18
  export declare const SATURN: CelestialBodyDefinition;
20
19
  export declare const URANUS: CelestialBodyDefinition;
@@ -30,19 +30,10 @@ export const SATURN_ROTATION = Object.freeze({ poleRaDeg: [40.589, -0.036], pole
30
30
  export const URANUS_ROTATION = Object.freeze({ poleRaDeg: [257.311, 0], poleDecDeg: [-15.175, 0], primeMeridianDeg: [203.81, -501.1600928], citation: IAU_REPORT });
31
31
  export const NEPTUNE_ROTATION = Object.freeze({ poleRaDeg: [299.36, 0], poleDecDeg: [43.46, 0], primeMeridianDeg: [249.978, 541.1397757], citation: IAU_REPORT });
32
32
  export const PLUTO_ROTATION = Object.freeze({ poleRaDeg: [132.993, 0], poleDecDeg: [-6.163, 0], primeMeridianDeg: [302.695, 56.3625225], citation: IAU_REPORT });
33
- export const SATURN_EPHEMERIS = planetEphemeris("Saturn", "at most 2,256 km (0.32 arcsec) from Horizons", ["The difference from the Horizons body centre is VSOP87A's own model error, not the curve fit's (within 1 km of the series)."]);
34
- export const URANUS_EPHEMERIS = planetEphemeris("Uranus", "at most 19,070 km (1.36 arcsec) from Horizons", ["The difference from the Horizons body centre is VSOP87A's own model error, not the curve fit's (within 1 km of the series)."]);
35
- export const NEPTUNE_EPHEMERIS = planetEphemeris("Neptune", "at most 36,192 km (1.62 arcsec) from Horizons", ["The difference from the Horizons body centre is VSOP87A's own model error, not the curve fit's (within 1 km of the series)."]);
36
- /** Pluto has no VSOP87 series: its barycentre is a curve fit of Horizons states (T-114, T-116), and its own wobble about it comes from its system's fits. */
37
- export const PLUTO_EPHEMERIS = {
38
- provenance: createProvenance({
39
- sourceType: "ephemeris",
40
- sources: ["JPL Horizons API 1.2 (https://ssd.jpl.nasa.gov/api/horizons.api), COMMAND=9 (Pluto system barycentre) CENTER=500@10, VECTORS geometric ICRF km TDB, fetched 2026-10-20, fitted as piecewise Chebyshev series (tools/import/planet-fits.mjs); US Government work, credit NASA/JPL-Caltech Solar System Dynamics"],
41
- accuracy: "The system barycentre reproduces Horizons within 1 km at independent dates 1950 to 2045. Pluto's centre is that point plus its own offset from the system's fits (within a metre 2010 to 2030); with the system not loaded Pluto is drawn at the barycentre, up to about 2,100 km from its centre.",
42
- notes: "Geometric position about the Sun's centre; no light-time or aberration.",
43
- }),
44
- knownLimitations: ["No velocity is modelled for planets, so they have no speed readout.", "Until Pluto's system fits are loaded Pluto sits at the system barycentre, up to about 2,100 km from its centre."],
45
- };
33
+ export const SATURN_EPHEMERIS = planetEphemeris("Saturn", "699", "DE441 with the Saturn satellite ephemeris sat441l", "With the Saturn moon package loaded (it covers 1950 to 2029), within 0.5 km of Horizons' Saturn on 2 January of each year 1972 to 2029 and 0.11 to 0.31 km at the Voyager 1 and 2 closest approaches (O-063 T-290).", "Until the Saturn moon package is loaded for the date Saturn sits at its system barycentre, up to 304 km from its centre (measured 1972 to 2044).");
34
+ export const URANUS_EPHEMERIS = planetEphemeris("Uranus", "799", "DE441 with the Uranus satellite ephemeris ura184_merged, whose system barycentre differs from DE441's barycentre body 7 by up to about 3,400 km away from the 1986 Voyager 2 encounter; the series follows Horizons' Uranus", "With the Uranus moon package loaded (it covers 1950 to 2029), within 0.6 km of Horizons' Uranus on 2 January of each year 1972 to 2029 and 0.20 km at Voyager 2's closest approach (O-063 T-290).", "Until the Uranus moon package is loaded for the date Uranus sits at its system barycentre, up to 45 km from its centre (measured 1972 to 2044).");
35
+ export const NEPTUNE_EPHEMERIS = planetEphemeris("Neptune", "899", "DE441 with the Neptune satellite ephemeris nep098_merged, whose system barycentre differs from DE441's barycentre body 8 by up to about 740 km away from the 1989 Voyager 2 encounter; the series follows Horizons' Neptune", "With the Neptune moon package loaded (it covers 1950 to 2029), within 0.5 km of Horizons' Neptune on 2 January of each year 1972 to 2029 and 0.27 km at Voyager 2's closest approach (O-063 T-290).", "Until the Neptune moon package is loaded for the date Neptune sits at its system barycentre, up to 74 km from its centre (measured 1972 to 2044).");
36
+ export const PLUTO_EPHEMERIS = planetEphemeris("Pluto", "999", "DE441 with the Pluto satellite ephemeris plu060_merged (whose barycentre agrees with DE441's body 9: the fit's bytes are the same as T-116's fit of body 9)", "With the Pluto moon package loaded (it covers 2010 to 2029), within 1.5 km of Horizons' Pluto at the archived dates 2010 to 2030 (tests/planetMoonSystems.test.ts); the barycentre fit is within 0.79 km of Horizons at independent dates 1950 to 2045.", "Until Pluto's moon package is loaded for the date Pluto sits at its system barycentre, up to about 2,100 km from its centre.");
46
37
  export const SATURN = giantPlanet("saturn", "Saturn", { mean: 58232, equatorial: 60268, polar: 54364 }, 37_931_206.234, { radius: "Equat. radius (1 bar) = 60268+-4 km, Polar radius (km) = 54364+-10, Vol. Mean Radius (km) = 58232+-6", gm: "GM (km^3/s^2) = 37931206.234" }, SATURN_EPHEMERIS, [GAS_BAND("Saturn")]);
47
38
  export const URANUS = giantPlanet("uranus", "Uranus", { mean: 25362, equatorial: 25559, polar: 24973 }, 5_793_950.6103, { radius: "Equat. radius (1 bar) = 25559+-4 km, Polar radius (km) = 24973+-20, Vol. Mean Radius (km) = 25362+-12", gm: "GM (km^3/s^2) = 5793950.6103" }, URANUS_EPHEMERIS, [GAS_BAND("Uranus")]);
48
39
  export const NEPTUNE = giantPlanet("neptune", "Neptune", { mean: 24624, equatorial: 24766, polar: 24342 }, 6_835_099.97, { radius: "Equat. radius (1 bar) = 24766+-15 km, Polar radius (km) = 24342+-30, Vol. mean radius (km) = 24624+-21", gm: "GM (km^3/s^2) = 6835099.97" }, NEPTUNE_EPHEMERIS, [GAS_BAND("Neptune")]);
@@ -24,5 +24,3 @@ export declare const CHARON: import("../body.js").CelestialBodyDefinition;
24
24
  /** The mapped moons by system, in the order the moon lists give them. */
25
25
  export declare const PLANET_MOON_DEFINITIONS: readonly import("../body.js").CelestialBodyDefinition[];
26
26
  export declare const PLANET_MOON_BINDINGS: readonly StateSourceBinding[];
27
- /** Pluto: the planet fits give the system barycentre; its own offset is added once its system's fits are loaded. */
28
- export declare const PLUTO_BINDING: StateSourceBinding;
@@ -1,9 +1,8 @@
1
1
  import { iauElementsFromRecord } from "../iauRotation.js";
2
2
  import { recordPeriodDays } from "../siderealPeriod.js";
3
- import { createPlanetSunTrajectory } from "./planetTrajectory.js";
4
3
  import { MARS } from "./mars.js";
5
4
  import { createMoonSystem, HISTORICAL_MOON_FIT_SPAN, moonFitSource } from "./moonSystem.js";
6
- import { NEPTUNE, PLUTO, PLUTO_ROTATION, SATURN, URANUS } from "./outerPlanets.js";
5
+ import { NEPTUNE, PLUTO, SATURN, URANUS } from "./outerPlanets.js";
7
6
  import charonOrbit from "../../../data/orbits/charon.json" with { type: "json" };
8
7
  import dioneOrbit from "../../../data/orbits/dione.json" with { type: "json" };
9
8
  import enceladusOrbit from "../../../data/orbits/enceladus.json" with { type: "json" };
@@ -60,19 +59,3 @@ export const PLANET_MOON_BINDINGS = Object.freeze([
60
59
  NEPTUNE_MOON_SYSTEM.binding(TRITON.id, iauElementsFromRecord(tritonOrbit.rotation)),
61
60
  PLUTO_MOON_SYSTEM.binding(CHARON.id, iauElementsFromRecord(charonOrbit.rotation)),
62
61
  ]);
63
- /**
64
- * Pluto's own offset from the system barycentre at `timeUtcMs`, from its system's centre series, or null while the system is not loaded or the
65
- * time lies outside the loaded chunks (Pluto then stays at the barycentre, which its position record says).
66
- */
67
- function plutoOffsetKm(timeUtcMs) {
68
- if (!PLUTO_MOON_SYSTEM.isLoaded())
69
- return null;
70
- try {
71
- return PLUTO_MOON_SYSTEM.ephemeris().centreOffsetKm(timeUtcMs);
72
- }
73
- catch {
74
- return null;
75
- }
76
- }
77
- /** Pluto: the planet fits give the system barycentre; its own offset is added once its system's fits are loaded. */
78
- export const PLUTO_BINDING = Object.freeze({ body: PLUTO.id, create: (adapter) => createPlanetSunTrajectory("pluto", PLUTO_ROTATION, adapter, plutoOffsetKm) });