astraeus 0.5.1 → 0.7.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +31 -8
  3. package/data/moons/jupiter.json +351 -115
  4. package/data/moons/neptune.json +54 -16
  5. package/data/moons/pluto.json +21 -5
  6. package/data/moons/saturn.json +882 -292
  7. package/data/moons/uranus.json +90 -28
  8. package/package.json +1 -1
  9. package/src/api/AstraeusScene.d.ts +4 -2
  10. package/src/api/AstraeusScene.js +13 -10
  11. package/src/api/AstraeusScene.node.js +13 -10
  12. package/src/api/bodies.d.ts +6 -1
  13. package/src/api/bodies.js +15 -2
  14. package/src/api/data.d.ts +2 -1
  15. package/src/api/data.js +4 -13
  16. package/src/api/errors.d.ts +1 -1
  17. package/src/api/index.d.ts +2 -1
  18. package/src/api/index.js +1 -1
  19. package/src/api/index.node.js +1 -1
  20. package/src/api/mount.d.ts +5 -1
  21. package/src/api/mount.js +2 -0
  22. package/src/api/mount.node.js +2 -0
  23. package/src/api/pathProvenance.d.ts +15 -6
  24. package/src/api/pathProvenance.js +23 -11
  25. package/src/api/scene.d.ts +18 -1
  26. package/src/api/scene.js +110 -15
  27. package/src/api/sphereOfInfluence.d.ts +20 -0
  28. package/src/api/sphereOfInfluence.js +48 -0
  29. package/src/api/viewerLink.d.ts +7 -1
  30. package/src/api/viewerLink.js +13 -2
  31. package/src/api/views.d.ts +42 -0
  32. package/src/api/views.js +80 -0
  33. package/src/app/App.js +32 -5
  34. package/src/app/App.node.js +32 -5
  35. package/src/app/AstraeusScene.d.ts +3 -0
  36. package/src/app/CameraController.d.ts +6 -0
  37. package/src/app/CameraController.js +3 -1
  38. package/src/app/PathView.d.ts +3 -2
  39. package/src/app/PathView.js +5 -5
  40. package/src/app/StoryMarkers.d.ts +4 -1
  41. package/src/app/StoryMarkers.js +3 -2
  42. package/src/app/TrackedBodyView.d.ts +1 -1
  43. package/src/app/TrackedBodyView.js +20 -11
  44. package/src/app/experienceDefinition.d.ts +3 -0
  45. package/src/app/mission.d.ts +15 -2
  46. package/src/app/mission.js +15 -0
  47. package/src/app/sceneCamera.d.ts +2 -0
  48. package/src/app/sceneCamera.js +14 -0
  49. package/src/app/sceneFrame.d.ts +2 -0
  50. package/src/app/sceneFrame.js +42 -6
  51. package/src/app/sceneHooks.js +1 -1
  52. package/src/app/viewHiding.d.ts +13 -0
  53. package/src/app/viewHiding.js +37 -0
  54. package/src/app/viewerPort.d.ts +6 -0
  55. package/src/app/views.d.ts +31 -0
  56. package/src/app/views.js +2 -0
  57. package/src/assets/bodies/listedMoons.d.ts +4 -0
  58. package/src/assets/bodies/listedMoons.js +7 -0
  59. package/src/assets/catalogue.d.ts +3 -0
  60. package/src/assets/catalogue.js +8 -0
  61. package/src/assets/moonCatalogue.d.ts +3 -1
  62. package/src/assets/moonCatalogue.js +1 -0
  63. package/src/core/bodies/jupiterMoons.d.ts +1 -1
  64. package/src/core/bodies/listedMoonBodies.d.ts +18 -0
  65. package/src/core/bodies/listedMoonBodies.js +36 -0
  66. package/src/core/bodies/listedMoons.d.ts +18 -0
  67. package/src/core/bodies/listedMoons.js +483 -0
  68. package/src/core/bodies/moonSystem.d.ts +3 -2
  69. package/src/core/bodies/moonSystem.js +1 -1
  70. package/src/shell/AstraeusShell.d.ts +12 -2
  71. package/src/shell/AstraeusShell.js +42 -4
  72. package/src/shell/AstraeusShell.node.js +42 -4
  73. package/src/shell/DisplaySwitches.d.ts +18 -1
  74. package/src/shell/DisplaySwitches.js +18 -5
  75. package/src/shell/TimelineBar.css +18 -0
  76. package/src/shell/TimelineBar.js +29 -4
  77. package/src/shell/TimelineBar.node.js +29 -4
  78. package/src/shell/TopBar.d.ts +4 -2
  79. package/src/shell/TopBar.js +3 -3
  80. package/src/shell/TopBar.node.js +3 -3
  81. package/src/shell/timelineModel.d.ts +13 -0
  82. package/src/shell/timelineModel.js +25 -0
  83. package/src/shell/viewCamera.d.ts +4 -0
  84. package/src/shell/viewCamera.js +13 -0
  85. package/src/synthetic/syntheticJourneyScene.d.ts +2 -1
  86. package/src/synthetic/syntheticJourneyScene.js +29 -14
  87. package/src/synthetic/syntheticViewsDefinition.d.ts +6 -0
  88. package/src/synthetic/syntheticViewsDefinition.js +44 -0
@@ -1,3 +1,18 @@
1
+ /** The body a path's line is drawn against at `timeUtcMs`: the one named, the covering stretch's, or `fallback` (the scene centre). A shared boundary belongs to the later stretch. */
2
+ export function lineAgainstAt(lineFixedTo, timeUtcMs, fallback) {
3
+ if (lineFixedTo === undefined)
4
+ return fallback;
5
+ if (typeof lineFixedTo === "string")
6
+ return lineFixedTo;
7
+ const last = lineFixedTo[lineFixedTo.length - 1];
8
+ return lineFixedTo.find((stretch) => timeUtcMs >= stretch.startUtcMs && timeUtcMs < stretch.endUtcMs)?.body ?? (last !== undefined && timeUtcMs === last.endUtcMs ? last.body : fallback);
9
+ }
10
+ /** Every body a path's line is drawn against, in order, with the `lineFixedTo` index of each (a plain id is index null). */
11
+ export function lineBodies(lineFixedTo) {
12
+ if (lineFixedTo === undefined)
13
+ return [];
14
+ return typeof lineFixedTo === "string" ? [{ index: null, body: lineFixedTo }] : lineFixedTo.map((stretch, index) => ({ index, body: stretch.body }));
15
+ }
1
16
  /** The segment covering `timeUtcMs`; a shared boundary belongs to the later segment. */
2
17
  export function discrepancyAt(body, timeUtcMs) {
3
18
  const segments = body.positionDiscrepancies ?? [];
@@ -27,6 +27,8 @@ export interface CameraStepInput {
27
27
  }
28
28
  /** Keeps the same relative framing when the visual scale changes (physical state is untouched). */
29
29
  export declare function rescaleCameraForPolicy(camState: OrbitCameraState, sceneCenter: BodyId, factor: number): void;
30
+ /** Where the camera's target is this frame: the held point after a `hold` request, else the focus. */
31
+ export declare function cameraTargetAbsolute(camState: OrbitCameraState, targets: SceneTargets): RenderVector;
30
32
  /**
31
33
  * One frame of camera decisions before the camera is posed: the opening view, a pending request, a change of up, and the zoom limits.
32
34
  * Returns the body (or other id) the camera is focused on.
@@ -9,6 +9,13 @@ export function rescaleCameraForPolicy(camState, sceneCenter, factor) {
9
9
  camState.distance *= factor;
10
10
  for (let i = 0; i < 3; i += 1)
11
11
  camState.transition[i] *= factor;
12
+ if (camState.fixedPoint !== null)
13
+ for (let i = 0; i < 3; i += 1)
14
+ camState.fixedPoint[i] *= factor;
15
+ }
16
+ /** Where the camera's target is this frame: the held point after a `hold` request, else the focus. */
17
+ export function cameraTargetAbsolute(camState, targets) {
18
+ return camState.fixedPoint ?? focusAbsoluteOf(targets, camState.focus);
12
19
  }
13
20
  /** An explicit start view wins over the overview rule: the camera opens exactly there (the zoom limits still apply). */
14
21
  function applyStartView(camState, view) {
@@ -66,6 +73,13 @@ function faceParent(camState, targets, viewUp, body, parent) {
66
73
  }
67
74
  function applyCameraRequest(input, request) {
68
75
  const { camState, targets, frame, catalogue, viewUp } = input;
76
+ if (request.kind === "hold") {
77
+ // The target stops where it is (including any tween still running); angles and distance are untouched. Scene-frame state only: nothing in State changes.
78
+ const now = cameraTargetAbsolute(camState, targets);
79
+ camState.fixedPoint = [now[0] + camState.transition[0], now[1] + camState.transition[1], now[2] + camState.transition[2]];
80
+ camState.transition.fill(0);
81
+ return;
82
+ }
69
83
  const target = request.kind === "overview" ? frame.centre : request.target;
70
84
  const targetBody = targets.bodyIdFor(target);
71
85
  switchFocus(camState, target, focusAbsoluteOf(targets, target));
@@ -142,6 +142,8 @@ export declare function publishOrbitHeadGap(canvas: HTMLCanvasElement, views: re
142
142
  export declare function publishCanvasReadouts(ctx: FrameContext): void;
143
143
  /** Stage 5: places every view about the floating origin and publishes the views' readouts. Returns the hover brightness gain. */
144
144
  export declare function placeViews(ctx: FrameContext, t: number, placed: PlacedScene, setLook: BodySetLook): number;
145
+ /** Stage 5b: shows or hides each drawn group by the current view's hidden ids (bodies, paths, point groups, body sets). One set, read here; nothing is rebuilt. */
146
+ export declare function applyViewVisibility(ctx: FrameContext): void;
145
147
  /** A mounted body's drawn sphere and radius for the feature markers, or null when the body is not drawn as a sphere. */
146
148
  export declare function featureHostOf(assets: readonly BodyAsset[], parts: ReadonlyMap<BodyId, BodyParts>, id: string, policy: ScalePolicy): FeatureHost | null;
147
149
  /** Stage 6: updates the overlay layers (names, story and feature markers) and rebuilds what a tap or hover can pick. */
@@ -5,7 +5,7 @@ import { applyPacing } from "../core/pacing.js";
5
5
  import { poseCamera, resolveCamera } from "./CameraController.js";
6
6
  import { DEFAULT_CAMERA_FAR } from "./experienceDefinition.js";
7
7
  import { DEFAULT_FEATURE_MIN_BODY_PX } from "./FeatureMarkers.js";
8
- import { rescaleCameraForPolicy, stepCameraTarget } from "./sceneCamera.js";
8
+ import { cameraTargetAbsolute, rescaleCameraForPolicy, stepCameraTarget } from "./sceneCamera.js";
9
9
  import { buildFrameReadout, publishBodyData, publishPathData, publishPointsData, publishSceneData, recordFrameStats } from "./sceneDebug.js";
10
10
  import { focusRadius, liveReach } from "./sceneFraming.js";
11
11
  import { bodyScreenReadouts, placeBodies, swapSmallBodiesToMarkers } from "./sceneBodies.js";
@@ -14,7 +14,7 @@ import { bodyAbsolute, placeComposition } from "./sceneLayout.js";
14
14
  import { placeBodyLights } from "./sceneLights.js";
15
15
  import { clampHoverBrightness, HOVER_BRIGHTNESS_DEFAULT, hoverTarget, pickCandidatesOf } from "./scenePicking.js";
16
16
  import { updateSky } from "./sceneSky.js";
17
- import { focusAbsoluteOf, labelPositionOf } from "./sceneTargets.js";
17
+ import { labelPositionOf } from "./sceneTargets.js";
18
18
  import { viewFromAngles } from "./viewLink.js";
19
19
  import { EQUATORIAL_UP } from "./viewUp.js";
20
20
  /** Floating-origin rebase threshold in scaled units (Earth radii). */
@@ -103,7 +103,7 @@ export function stepAndPoseCamera(ctx, t, placed) {
103
103
  const reach = liveReach(runtime.cameraReach, policy, camera.aspect);
104
104
  const focusBody = stepCameraTarget({ camState: orbit, controls, targets, frame, catalogue, reach, fovDeg: camera.fov, viewUp, firstFrame, previousUp: state.lastUp });
105
105
  state.lastUp = viewUp;
106
- resolveCamera(orbit, focusAbsoluteOf(targets, orbit.focus), ctx.origin, ctx.delta, REBASE_THRESHOLD, viewUp);
106
+ resolveCamera(orbit, cameraTargetAbsolute(orbit, targets), ctx.origin, ctx.delta, REBASE_THRESHOLD, viewUp);
107
107
  placeBodies(ctx.assets, placed.composed.states, ctx.bodyRefs, policy, ctx.origin);
108
108
  poseCamera(camera, orbit, focusRadius(focusBody, policy, catalogue), ctx.origin, reach.far ?? DEFAULT_CAMERA_FAR, viewUp);
109
109
  if (firstFrame)
@@ -156,12 +156,46 @@ export function placeViews(ctx, t, placed, setLook) {
156
156
  publishPointsData(canvas, views.groupViews, camera, views.bodySetViews);
157
157
  return hoverGain;
158
158
  }
159
+ /** Stage 5b: shows or hides each drawn group by the current view's hidden ids (bodies, paths, point groups, body sets). One set, read here; nothing is rebuilt. */
160
+ export function applyViewVisibility(ctx) {
161
+ const hidden = ctx.controls.viewHidden?.objects;
162
+ const { views, bodyRefs } = ctx;
163
+ const show = (id, group) => { group.visible = hidden?.has(id) !== true; };
164
+ for (const [id, group] of bodyRefs.groups)
165
+ show(id, group);
166
+ for (const view of views.trackedViews)
167
+ show(view.body.id, view.group);
168
+ for (const view of views.groupViews)
169
+ show(view.id, view.group);
170
+ for (const view of views.sunCentredViews)
171
+ show(view.id, view.group);
172
+ // A line follows the body or set it belongs to (the link the line already carries), so a view never names orbit lines.
173
+ const showOwned = (id, owner, group) => { group.visible = hidden?.has(id) !== true && hidden?.has(owner) !== true; };
174
+ for (const view of views.compositionPaths)
175
+ showOwned(view.id, String(view.layer.source.body), view.group);
176
+ for (const view of views.bodySetViews)
177
+ show(view.id, view.group);
178
+ for (const view of views.orbitSetViews)
179
+ showOwned(view.id, view.layer.id, view.group);
180
+ }
159
181
  /** A mounted body's drawn sphere and radius for the feature markers, or null when the body is not drawn as a sphere. */
160
182
  export function featureHostOf(assets, parts, id, policy) {
161
183
  const sphere = parts.get(id)?.sphere;
162
184
  const asset = assets.find((candidate) => candidate.definition.id === id);
163
185
  return sphere === undefined || asset === undefined ? null : { sphere, radius: drawnRadii(asset.definition, policy).equatorial };
164
186
  }
187
+ /** What the labels and taps see under the current view: the objects and body sets it shows, and the label-hidden ids with the view's own added. Allocates only when a view hides something. */
188
+ function shownUnderView(ctx) {
189
+ const { controls, views } = ctx;
190
+ const hidden = controls.viewHidden?.objects;
191
+ if (hidden === undefined || hidden.size === 0)
192
+ return { objects: controls.labelObjects, bodySetViews: views.bodySetViews, hiddenLabels: controls.hiddenLabels };
193
+ return {
194
+ objects: controls.labelObjects.filter((object) => !hidden.has(object.id)),
195
+ bodySetViews: views.bodySetViews.filter((view) => !hidden.has(view.id)),
196
+ hiddenLabels: new Set([...(controls.hiddenLabels ?? []), ...hidden]),
197
+ };
198
+ }
165
199
  /** Stage 6: updates the overlay layers (names, story and feature markers) and rebuilds what a tap or hover can pick. */
166
200
  export function updateOverlays(ctx, t, step, hoverGain) {
167
201
  const { controls, camera, canvas, size, origin, state, layers } = ctx;
@@ -169,13 +203,14 @@ export function updateOverlays(ctx, t, step, hoverGain) {
169
203
  publishBodyData(canvas, bodyScreens);
170
204
  layers.anchorLabels.current?.update(controls.showAnchorLabels, camera, size.width, size.height);
171
205
  const positionFor = (id) => labelPositionOf(step.targets, id);
172
- layers.sceneLabels.current?.update(positionFor, camera, size.width, size.height, origin, controls.selectedObjectId, controls.hiddenLabels);
173
- state.pickables = pickCandidatesOf({ objects: controls.labelObjects, bodyIdFor: ctx.bodyIdFor, bodyScreens, widthPx: size.width, heightPx: size.height, labelRects: layers.sceneLabels.current?.shownRects, canvas, bodySetViews: ctx.views.bodySetViews });
206
+ const shown = shownUnderView(ctx);
207
+ layers.sceneLabels.current?.update(positionFor, camera, size.width, size.height, origin, controls.selectedObjectId, shown.hiddenLabels);
208
+ state.pickables = pickCandidatesOf({ objects: shown.objects, bodyIdFor: ctx.bodyIdFor, bodyScreens, widthPx: size.width, heightPx: size.height, labelRects: layers.sceneLabels.current?.shownRects, canvas, bodySetViews: shown.bodySetViews });
174
209
  const hover = state.hoverPoint === null ? null : hoverTarget(state.pickables, state.hoverPoint.x, state.hoverPoint.y, "mouse");
175
210
  canvas.style.cursor = hover === null ? "" : "pointer";
176
211
  canvas.dataset.pickHover = hover ?? "";
177
212
  layers.sceneLabels.current?.setHover(hover, hoverGain);
178
- layers.storyMarkers.current?.update(positionFor, camera, size.width, size.height, origin, controls.openStoryPanelId ?? null, t);
213
+ layers.storyMarkers.current?.update(positionFor, camera, size.width, size.height, origin, controls.openStoryPanelId ?? null, t, controls.viewHidden);
179
214
  const featureReadout = layers.featureMarkers.current?.update((id) => featureHostOf(ctx.assets, ctx.bodyRefs.parts, id, controls.policy), camera, camera.fov, size.width, size.height, controls.openFeatureKey ?? null, controls.featureMinBodyPx ?? DEFAULT_FEATURE_MIN_BODY_PX);
180
215
  if (featureReadout !== null && featureReadout !== undefined)
181
216
  canvas.dataset.featureMarkers = JSON.stringify(featureReadout);
@@ -271,6 +306,7 @@ export function runFrame(ctx) {
271
306
  const placed = placeScene(ctx, t);
272
307
  const step = stepAndPoseCamera(ctx, t, placed);
273
308
  publishCanvasReadouts(ctx);
309
+ applyViewVisibility(ctx);
274
310
  const hoverGain = placeViews(ctx, t, placed, setLook);
275
311
  updateOverlays(ctx, t, step, hoverGain);
276
312
  placeLightsAndReadout(ctx, t, placed);
@@ -56,7 +56,7 @@ export function useSceneViews(runtime, gl) {
56
56
  const trackedViews = useMemo(() => runtime.trackedBodies.map((body) => new TrackedBodyView(body)), [runtime.trackedBodies]);
57
57
  const groupViews = useMemo(() => runtime.groups.map((layer) => new PointsView(layer)), [runtime.groups]);
58
58
  const sunCentredViews = useMemo(() => createPathViews(runtime.paths ?? []), [runtime.paths]);
59
- const compositionPaths = useMemo(() => (runtime.composition?.paths ?? []).map((path) => compositionPathView(path, runtime.resolver)), [runtime.composition, runtime.resolver]);
59
+ const compositionPaths = useMemo(() => (runtime.composition?.paths ?? []).map((path) => compositionPathView(path, runtime.resolver, runtime.catalogue)), [runtime.composition, runtime.resolver, runtime.catalogue]);
60
60
  const skyView = useMemo(() => (runtime.sky?.visible ? new SkyView({ starBrightness: runtime.sky.starBrightness, milkyWayBrightness: runtime.sky.milkyWayBrightness, pixelRatio: gl.getPixelRatio(), maxAnisotropy: gl.capabilities.getMaxAnisotropy(), milkyWay: runtime.sky.milkyWay, picture: null }) : null), [runtime.sky, gl]);
61
61
  const bodySetViews = useMemo(() => (runtime.bodySets ?? []).map((layer) => new BodySetView(layer)), [runtime.bodySets]);
62
62
  const orbitSetViews = useMemo(() => (runtime.bodySets ?? []).map((layer) => new OrbitSetView(layer)), [runtime.bodySets]);
@@ -0,0 +1,13 @@
1
+ import type { ExperienceConfig } from "../shell/experience.js";
2
+ import type { ResolvedView, ViewSettings } from "./views.js";
3
+ /** The ids the current view hides: objects (bodies, paths, groups) and story panels. Empty sets: everything shows. */
4
+ export interface ViewHidden {
5
+ readonly objects: ReadonlySet<string>;
6
+ readonly panels: ReadonlySet<string>;
7
+ }
8
+ /** The view with this id, else the opening one; undefined for a scene without views. */
9
+ export declare function viewById(settings: ViewSettings | undefined, id: string): ResolvedView | undefined;
10
+ /** What `view` hides. A scene without views hides nothing. An object that belongs to a hidden one (`partOf`: a body's Sun-orbit line) is hidden with it, so a view never names orbit lines. */
11
+ export declare function hiddenByView(settings: ViewSettings | undefined, view: ResolvedView | undefined, experience?: ExperienceConfig): ViewHidden;
12
+ /** The experience as the view shows it: its objects, timeline events and story panels. The same object when there are no views, so a scene without views is untouched. */
13
+ export declare function experienceInView(experience: ExperienceConfig, settings: ViewSettings | undefined, view: ResolvedView | undefined): ExperienceConfig;
@@ -0,0 +1,37 @@
1
+ /** The view with this id, else the opening one; undefined for a scene without views. */
2
+ export function viewById(settings, id) {
3
+ return settings?.views.find((view) => view.id === id) ?? settings?.views.find((view) => view.id === settings.start);
4
+ }
5
+ /** The ids of `kind` some view shows and `view` does not. An id no view's set holds (the sky, an orbit line) is never the views' to hide. */
6
+ function hiddenIds(settings, view, kind) {
7
+ const hidden = new Set();
8
+ for (const other of settings.views)
9
+ for (const id of other[kind])
10
+ if (!view[kind].has(id))
11
+ hidden.add(id);
12
+ return hidden;
13
+ }
14
+ /** What `view` hides. A scene without views hides nothing. An object that belongs to a hidden one (`partOf`: a body's Sun-orbit line) is hidden with it, so a view never names orbit lines. */
15
+ export function hiddenByView(settings, view, experience) {
16
+ if (settings === undefined || view === undefined)
17
+ return { objects: new Set(), panels: new Set() };
18
+ const objects = new Set(hiddenIds(settings, view, "objects"));
19
+ for (const object of experience?.objects ?? [])
20
+ if (object.partOf !== undefined && objects.has(object.partOf))
21
+ objects.add(object.id);
22
+ return { objects, panels: hiddenIds(settings, view, "panels") };
23
+ }
24
+ /** The experience as the view shows it: its objects, timeline events and story panels. The same object when there are no views, so a scene without views is untouched. */
25
+ export function experienceInView(experience, settings, view) {
26
+ if (settings === undefined || view === undefined)
27
+ return experience;
28
+ const hiddenEvents = hiddenIds(settings, view, "events");
29
+ const { objects, panels } = hiddenByView(settings, view, experience);
30
+ const storySet = experience.storyPanels;
31
+ return {
32
+ ...experience,
33
+ objects: experience.objects.filter((object) => !objects.has(object.id)),
34
+ events: experience.events.filter((event) => !hiddenEvents.has(event.id)),
35
+ ...(storySet === undefined ? {} : { storyPanels: { ...storySet, panels: storySet.panels.filter((panel) => !panels.has(panel.id)) } }),
36
+ };
37
+ }
@@ -7,6 +7,8 @@ export interface ViewerState {
7
7
  readonly playing: boolean;
8
8
  /** Only in a scene with pacing: true while pacing sets the rate, false once a visitor or the host has picked a speed. */
9
9
  readonly auto?: boolean;
10
+ /** Only in a scene with views: the id of the view showing. */
11
+ readonly view?: string;
10
12
  }
11
13
  /** Who moved the clock: the clock running (`playback`), a person at the controls (`visitor`) or the host page (`host`). */
12
14
  export type ViewerChangeCause = "playback" | "visitor" | "host";
@@ -21,6 +23,10 @@ export interface ViewerControl {
21
23
  readonly paced: boolean;
22
24
  /** A number is a chosen speed; `"auto"` gives the rate back to the scene's pacing. */
23
25
  setRate(rate: number | "auto"): void;
26
+ /** The ids of the scene's views, in order; empty without views. */
27
+ readonly views: readonly string[];
28
+ /** Switches to the view with this id (one of `views`), as a visitor's button does. */
29
+ setView(id: string): void;
24
30
  }
25
31
  /** The viewer's side of the host link; the public API supplies the implementation (`ViewerLink`). */
26
32
  export interface ViewerPort {
@@ -0,0 +1,31 @@
1
+ /** Where the view choice shows: a button group in the top bar, or a row in the one switch panel opened from the bar (as for the display switches). */
2
+ export declare const VIEW_PLACES: readonly ["top-bar", "panel"];
3
+ export type ViewPlace = (typeof VIEW_PLACES)[number];
4
+ /** What the camera does when it switches to a view whose members no longer include what it follows or focuses on. `stay`: keep the pose and stop following. `start`: take the view's own framing, else the scene's start. */
5
+ export type ViewCameraRule = {
6
+ readonly rule: "stay";
7
+ } | {
8
+ readonly rule: "start";
9
+ readonly framing?: {
10
+ readonly follow: string;
11
+ } | {
12
+ readonly focus: string;
13
+ };
14
+ };
15
+ /** 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. */
16
+ export interface ResolvedView {
17
+ readonly id: string;
18
+ readonly label: string;
19
+ readonly camera: ViewCameraRule;
20
+ /** Bodies, paths and groups: the ids the menu lists and the scene draws. */
21
+ readonly objects: ReadonlySet<string>;
22
+ readonly events: ReadonlySet<string>;
23
+ readonly panels: ReadonlySet<string>;
24
+ }
25
+ /** The views a scene names: presentation only (no State changes), so a hidden object keeps its state. */
26
+ export interface ViewSettings {
27
+ readonly place: ViewPlace;
28
+ /** Id of the opening view. */
29
+ readonly start: string;
30
+ readonly views: readonly ResolvedView[];
31
+ }
@@ -0,0 +1,2 @@
1
+ /** Where the view choice shows: a button group in the top bar, or a row in the one switch panel opened from the bar (as for the display switches). */
2
+ export const VIEW_PLACES = ["top-bar", "panel"];
@@ -0,0 +1,4 @@
1
+ import type { ListedMoonBody } from "../../core/bodies/listedMoonBodies.js";
2
+ import type { VisualEntry } from "../catalogue.js";
3
+ /** A listed moon's look (O-049 T-211): a grey sphere, or its picture when the picture pack holds one under the moon's id (read when asked for, so a pack registered later still shows). */
4
+ export declare const listedMoonEntry: ({ definition }: ListedMoonBody) => VisualEntry;
@@ -0,0 +1,7 @@
1
+ import { withPicture } from "../pictures.js";
2
+ const LIGHT = Object.freeze({ ambient: 0.08, directional: 1.4 });
3
+ /** A listed moon's look (O-049 T-211): a grey sphere, or its picture when the picture pack holds one under the moon's id (read when asked for, so a pack registered later still shows). */
4
+ export const listedMoonEntry = ({ definition }) => ({
5
+ body: definition.id,
6
+ visual: withPicture(definition.id, { kind: "sphere", material: Object.freeze({ color: "#a8a8a8", roughness: 0.95, metalness: 0 }), light: LIGHT }),
7
+ });
@@ -1,4 +1,5 @@
1
1
  import type { BodyId, CelestialBodyDefinition, StateSourceBinding } from "../core/body.js";
2
+ import type { ListedMoonBody } from "../core/bodies/listedMoonBodies.js";
2
3
  import { type ElementsBodyRecord } from "../core/elementsBody.js";
3
4
  import type { BodyVisual } from "./visual.js";
4
5
  /** Definition, optional state source, and appearance of one body, joined by id. */
@@ -31,6 +32,8 @@ export declare function createCatalogue(definitions: readonly CelestialBodyDefin
31
32
  * already holds, like any other duplicate.
32
33
  */
33
34
  export declare function extendCatalogue(base: BodyCatalogue, records: readonly ElementsBodyRecord[]): BodyCatalogue;
35
+ /** A catalogue that holds everything `base` holds plus the listed moons given (each added to a scene on request; `base` is not changed). */
36
+ export declare function extendCatalogueWithMoons(base: BodyCatalogue, moons: readonly ListedMoonBody[]): BodyCatalogue;
34
37
  /** The id of the catalogue's one root body (the one with no parent), the origin every chain ends at. */
35
38
  export declare function rootBodyId(source?: BodyCatalogue): BodyId;
36
39
  /** Explicit, import-built, no discovery. */
@@ -2,6 +2,7 @@ import { BUILT_IN_BINDINGS, BUILT_IN_BODIES } from "../core/bodies/index.js";
2
2
  import { buildElementsBody } from "../core/elementsBody.js";
3
3
  import { EARTH_ENTRY } from "./bodies/earth.js";
4
4
  import { GALILEAN_ENTRIES } from "./bodies/galileanMoons.js";
5
+ import { listedMoonEntry } from "./bodies/listedMoons.js";
5
6
  import { IO_ENTRY } from "./bodies/io.js";
6
7
  import { JUPITER_ENTRY } from "./bodies/jupiter.js";
7
8
  import { MARS_ENTRY } from "./bodies/mars.js";
@@ -95,6 +96,13 @@ export function extendCatalogue(base, records) {
95
96
  }
96
97
  return createCatalogue([...base.definitions(), ...built.map(({ body }) => body.definition)], [...base.sources(), ...built.map(({ body }) => body.binding)], visuals);
97
98
  }
99
+ /** A catalogue that holds everything `base` holds plus the listed moons given (each added to a scene on request; `base` is not changed). */
100
+ export function extendCatalogueWithMoons(base, moons) {
101
+ if (moons.length === 0)
102
+ return base;
103
+ const visuals = [...base.ids().map((id) => ({ body: id, visual: base.get(id).visual })), ...moons.map(listedMoonEntry)];
104
+ return createCatalogue([...base.definitions(), ...moons.map(({ definition }) => definition)], [...base.sources(), ...moons.map(({ binding }) => binding)], visuals);
105
+ }
98
106
  /** The id of the catalogue's one root body (the one with no parent), the origin every chain ends at. */
99
107
  export function rootBodyId(source = catalogue) {
100
108
  const root = source.definitions().find((definition) => definition.parentId === undefined);
@@ -20,7 +20,9 @@ export interface MoonRecord {
20
20
  /** False for a provisional designation such as "S/2003 J 19" that has no name yet. */
21
21
  readonly named: boolean;
22
22
  readonly discoveryYear?: number;
23
- /** Ids into the catalogue's `sources`: the list, the family, the size and the discovery. */
23
+ /** Sidereal orbit period in days (JPL SSD mean elements); absent when no period is published for the moon. */
24
+ readonly orbitPeriodDays?: number;
25
+ /** Ids into the catalogue's `sources`: the list, the family, the size and the discovery (the period source is in the list but not in the info-panel provenance until a panel shows the period). */
24
26
  readonly sourceIds: readonly string[];
25
27
  }
26
28
  export interface MoonSource {
@@ -43,6 +43,7 @@ export function parseMoonCatalogue(raw) {
43
43
  return Object.freeze({
44
44
  named: moon.named !== false,
45
45
  ...(typeof moon.discoveryYear === "number" ? { discoveryYear: moon.discoveryYear } : {}),
46
+ ...(typeof moon.orbitPeriodDays === "number" && moon.orbitPeriodDays > 0 ? { orbitPeriodDays: moon.orbitPeriodDays } : {}),
46
47
  sourceIds: Object.freeze(sourceIds),
47
48
  id: text(moon.id, `${where}.id`),
48
49
  name: text(moon.name, `${where}.name`),
@@ -20,7 +20,7 @@ export declare const loadJupiterMoons: (load: MoonSystemLoad) => Promise<import(
20
20
  export declare const osculatingPeriodMs: (ephemeris: import("../chebyshevEphemeris.js").ChebyshevEphemeris, body: BodyId, timeUtcMs: number) => number;
21
21
  export declare const FITTED_MOON_TIDAL_LOCK: string;
22
22
  /** What every mapped Jupiter moon's record says about its position, with its own worst figure from T-096. */
23
- export declare const fittedMoonPosition: (label: string, worstM: number, span?: TimeBounds) => ReturnType<typeof import("../provenance.js").createProvenance>;
23
+ export declare const fittedMoonPosition: (label: string, worstM?: number, span?: TimeBounds) => ReturnType<typeof import("../provenance.js").createProvenance>;
24
24
  /** The Galilean moons turn synchronously: their prime meridians are the IAU records saved with their orbits (`data/orbits/`), the one source. */
25
25
  export declare const IO_ROTATION: import("../iauRotation.js").IauRotationElements;
26
26
  export declare const EUROPA: import("../body.js").CelestialBodyDefinition;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The one rule that turns a slim-table entry (`listedMoons.ts`) into a catalogue body (O-049 T-211): its planet's moon system builds the definition and the
3
+ * state source, from the table's mean radius and period. Nothing here names a moon. The result is made only when a scene adds the moon, so a moon nobody adds costs nothing.
4
+ * Detailed moons (`planetMoons.ts`, `jupiterMoons.ts`) are defined by hand and are in the built-in catalogue first, so they win.
5
+ */
6
+ import type { CelestialBodyDefinition, StateSourceBinding } from "../body.js";
7
+ import { type ListedMoon } from "./listedMoons.js";
8
+ import { type MoonSystem } from "./moonSystem.js";
9
+ /** Each planet's moon system by planet id: the loader every moon of that planet shares. */
10
+ export declare const MOON_SYSTEMS: Readonly<Record<string, MoonSystem>>;
11
+ export interface ListedMoonBody {
12
+ readonly definition: CelestialBodyDefinition;
13
+ readonly binding: StateSourceBinding;
14
+ }
15
+ /** The definition and state source of a listed moon: a sphere at its mean radius, positioned from its planet's fits, with the table's period when it has one. */
16
+ export declare function listedMoonBody(moon: ListedMoon): ListedMoonBody;
17
+ /** The body for a moon id, or undefined when the table does not list it. */
18
+ export declare const listedMoonBodyOf: (id: string) => ListedMoonBody | undefined;
@@ -0,0 +1,36 @@
1
+ import { JUPITER_MOON_SYSTEM } from "./jupiterMoons.js";
2
+ import { listedMoon } from "./listedMoons.js";
3
+ import { HISTORICAL_MOON_FIT_SPAN } from "./moonSystem.js";
4
+ import { MARS_MOON_SYSTEM, NEPTUNE_MOON_SYSTEM, PLUTO_MOON_SYSTEM, SATURN_MOON_SYSTEM, URANUS_MOON_SYSTEM } from "./planetMoons.js";
5
+ /** Each planet's moon system by planet id: the loader every moon of that planet shares. */
6
+ export const MOON_SYSTEMS = Object.freeze({
7
+ jupiter: JUPITER_MOON_SYSTEM,
8
+ saturn: SATURN_MOON_SYSTEM,
9
+ uranus: URANUS_MOON_SYSTEM,
10
+ neptune: NEPTUNE_MOON_SYSTEM,
11
+ mars: MARS_MOON_SYSTEM,
12
+ pluto: PLUTO_MOON_SYSTEM,
13
+ });
14
+ const RADIUS_SOURCE = "JPL SSD satellite physical parameters (https://ssd.jpl.nasa.gov/sats/phys_par/), mean radius";
15
+ const PERIOD_SOURCE = "JPL SSD satellite mean elements (https://ssd.jpl.nasa.gov/sats/elem/), sidereal period P";
16
+ /** The definition and state source of a listed moon: a sphere at its mean radius, positioned from its planet's fits, with the table's period when it has one. */
17
+ export function listedMoonBody(moon) {
18
+ const system = MOON_SYSTEMS[moon.parent];
19
+ if (system === undefined)
20
+ throw new RangeError(`${moon.id}: no moon system for "${moon.parent}"`);
21
+ const definition = system.mappedMoon({
22
+ id: moon.id,
23
+ label: moon.label,
24
+ radiusKm: moon.meanRadiusKm,
25
+ ...(moon.orbitPeriodDays === null ? {} : { orbitPeriodDays: moon.orbitPeriodDays }),
26
+ ...(moon.early ? { span: HISTORICAL_MOON_FIT_SPAN } : {}),
27
+ header: `${RADIUS_SOURCE}${moon.orbitPeriodDays === null ? "" : `; ${PERIOD_SOURCE}`}`,
28
+ dimensionsNote: `Mean radius ${moon.meanRadiusKm} km (${RADIUS_SOURCE}); ${moon.label} is drawn as a sphere at that radius. No gravitational parameter is held, and its rotation is not modelled: the sphere is turned to keep one face to ${system.config.centreLabel}.`,
29
+ });
30
+ return Object.freeze({ definition, binding: system.binding(moon.id) });
31
+ }
32
+ /** The body for a moon id, or undefined when the table does not list it. */
33
+ export const listedMoonBodyOf = (id) => {
34
+ const moon = listedMoon(id);
35
+ return moon === undefined ? undefined : listedMoonBody(moon);
36
+ };
@@ -0,0 +1,18 @@
1
+ export interface ListedMoon {
2
+ readonly id: string;
3
+ readonly label: string;
4
+ readonly meanRadiusKm: number;
5
+ readonly parent: string;
6
+ /** Sidereal orbit period, days; null when no period is published. */
7
+ readonly orbitPeriodDays: number | null;
8
+ /** The data package that holds the moon's fit: `astraeus-data-<parent>`. */
9
+ readonly dataPackage: string;
10
+ readonly fitSet: string;
11
+ readonly fitBody: string;
12
+ /** True when the fit starts in 1950 (the main moons); false when it starts in 2010. */
13
+ readonly early: boolean;
14
+ }
15
+ /** The listed moon with this id, or undefined. */
16
+ export declare const listedMoon: (id: string) => ListedMoon | undefined;
17
+ /** Every listed moon, in list order by parent. */
18
+ export declare const listedMoons: () => readonly ListedMoon[];