astraeus 0.7.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.
- package/CHANGELOG.md +189 -0
- package/README.md +202 -38
- package/data/ephemerides/planets/planets.json +1 -1
- 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 +63 -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 +85 -0
- package/src/api/viewerHandle.js +32 -0
- package/src/api/viewerLink.d.ts +88 -15
- package/src/api/viewerLink.js +117 -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 +30 -0
- package/src/api/viewerSelection.js +46 -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 +7 -6
- package/src/api/views.js +12 -6
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +211 -82
- package/src/app/App.node.js +211 -82
- package/src/app/AstraeusScene.d.ts +18 -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.d.ts +2 -0
- package/src/app/sceneCamera.js +11 -1
- 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 +52 -0
- package/src/app/views.d.ts +3 -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/astronomyAdapter.d.ts +1 -1
- package/src/core/astronomyAdapter.js +3 -3
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +14 -18
- package/src/core/bodies/jupiter.js +1 -1
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/mars.js +1 -1
- package/src/core/bodies/mercury.js +1 -1
- 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/outerPlanets.d.ts +2 -3
- package/src/core/bodies/outerPlanets.js +4 -13
- package/src/core/bodies/planetMoons.d.ts +0 -2
- package/src/core/bodies/planetMoons.js +1 -18
- package/src/core/bodies/planetRecords.d.ts +8 -2
- package/src/core/bodies/planetRecords.js +13 -5
- package/src/core/bodies/planetTrajectory.d.ts +21 -4
- package/src/core/bodies/planetTrajectory.js +29 -5
- package/src/core/bodies/venus.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.d.ts +1 -1
- package/src/core/planetModels.js +3 -3
- package/src/core/planetSeries.d.ts +10 -2
- package/src/core/planetSeries.js +17 -3
- 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 +18 -2
- package/src/shell/AstraeusShell.js +53 -14
- package/src/shell/AstraeusShell.node.js +53 -14
- 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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Provenance } from "../core/provenance.js";
|
|
2
|
+
import type { BodyRef } from "./bodies.js";
|
|
3
|
+
import type { CardFactInput } from "./scene.js";
|
|
4
|
+
import type { TimeInput } from "./time.js";
|
|
5
|
+
/** One family of a body set: members that share an orbit colour and a place in the moon panel. */
|
|
6
|
+
export interface BodySetFamilyInput {
|
|
7
|
+
/** The family's id; distinct within the set. */
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
/** Orbit colour as a CSS hex colour; default: the palette in family order. */
|
|
11
|
+
readonly color?: string;
|
|
12
|
+
/** Orbit brightness multiplier, above 0; default 1 (the Developer drawer's family gain). */
|
|
13
|
+
readonly brightness?: number;
|
|
14
|
+
}
|
|
15
|
+
/** The elements of a made-up member on two-body motion about the set's centre. Angles in degrees, length in km. */
|
|
16
|
+
export interface BodySetElementsInput {
|
|
17
|
+
readonly semiMajorAxisKm: number;
|
|
18
|
+
/** At least 0 and below 1: a bound orbit. */
|
|
19
|
+
readonly eccentricity: number;
|
|
20
|
+
readonly inclinationDeg: number;
|
|
21
|
+
readonly raanDeg: number;
|
|
22
|
+
readonly argumentOfPeriapsisDeg: number;
|
|
23
|
+
readonly trueAnomalyDeg: number;
|
|
24
|
+
/** The moment the elements hold; the scene's opening time when absent. */
|
|
25
|
+
readonly time?: TimeInput;
|
|
26
|
+
/** The plane the angles are given in: "ecliptic-j2000" or "EQJ" (default). */
|
|
27
|
+
readonly plane?: "ecliptic-j2000" | "EQJ";
|
|
28
|
+
}
|
|
29
|
+
/** One member of a body set: a dot that is selectable, with an info card. */
|
|
30
|
+
export interface BodySetMemberInput {
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/** The id of one of the set's families. */
|
|
33
|
+
readonly family: string;
|
|
34
|
+
/** Required with `elements`; a listed moon defaults to its own. */
|
|
35
|
+
readonly label?: string;
|
|
36
|
+
/** Required with `elements`; a listed moon defaults to its own. */
|
|
37
|
+
readonly radiusKm?: number;
|
|
38
|
+
/** Absent: `id` is a listed moon of the centre (positions come through `data`); present: a made-up member on two-body motion. All members of a set are one kind or the other. */
|
|
39
|
+
readonly elements?: BodySetElementsInput;
|
|
40
|
+
/** Info card words, as on `addBody`. */
|
|
41
|
+
readonly description?: string;
|
|
42
|
+
readonly facts?: readonly CardFactInput[];
|
|
43
|
+
/** Where this member's position comes from; default: the set's. */
|
|
44
|
+
readonly provenance?: Provenance;
|
|
45
|
+
readonly knownLimitations?: readonly string[];
|
|
46
|
+
/** Whether the Object menu offers it; default false, so a long list does not bury the menu. */
|
|
47
|
+
readonly listed?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** A body added with `addBody` that belongs to one of the set's families. */
|
|
50
|
+
export interface BodySetBodyInput {
|
|
51
|
+
readonly id: BodyRef | string;
|
|
52
|
+
readonly family: string;
|
|
53
|
+
}
|
|
54
|
+
/** A member or body the centre circles with: orbit lines are drawn about the balance point. */
|
|
55
|
+
export interface BodySetBalanceInput {
|
|
56
|
+
readonly body: BodyRef | string;
|
|
57
|
+
readonly gmKm3S2: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Many small bodies about one centre, each selectable, drawn as one batch: dots with a pixel floor, a ball at true size close up, names on hover, tap or near zoom,
|
|
61
|
+
* and one batch of orbit lines coloured by family.
|
|
62
|
+
*/
|
|
63
|
+
export interface BodySetInput {
|
|
64
|
+
/** The set's id; not shared with any body, path, group or member. */
|
|
65
|
+
readonly id: string;
|
|
66
|
+
/** The body the members circle; the scene's centre (its first body) when absent. It must be in the scene. */
|
|
67
|
+
readonly center?: BodyRef | string;
|
|
68
|
+
/** One to sixteen families, in order. */
|
|
69
|
+
readonly families: readonly BodySetFamilyInput[];
|
|
70
|
+
readonly members: readonly BodySetMemberInput[];
|
|
71
|
+
/** Bodies added with `addBody` that belong to a family: their orbit lines take its colour, and one with no `orbit` of its own gets its line in this batch. */
|
|
72
|
+
readonly bodies?: readonly BodySetBodyInput[];
|
|
73
|
+
/** Where the positions come from, shown for the set. */
|
|
74
|
+
readonly provenance: Provenance;
|
|
75
|
+
/** Gravity of the centre, km^3/s^2, sizing each orbit line to one lap. Default: the centre's moon system, else its catalogue record; neither throws `bad-body-set`. */
|
|
76
|
+
readonly centerGmKm3S2?: number;
|
|
77
|
+
/** A member or body the centre circles with. Default: the centre's moon system's own when that body is in the set, else none. */
|
|
78
|
+
readonly balancePoint?: BodySetBalanceInput;
|
|
79
|
+
/** How far before the window's start to load positions, ms, so an orbit line can reach back. Default 0. Passed to the moon loader for every moon of the centre the scene holds. */
|
|
80
|
+
readonly orbitHistoryMs?: number;
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes `element` a containing block for the viewer: the viewer's root is `position: absolute; inset: 0`, so it fills this element only when the element is
|
|
3
|
+
* positioned. A static element becomes `relative` and a visible overflow becomes `hidden`; a position or overflow the host already chose is left alone.
|
|
4
|
+
* Called by `mount` and by `AstraeusScene` for their own element, next to the `isolation` they set (O-055 T-256).
|
|
5
|
+
*/
|
|
6
|
+
export declare function makeContainingBlock(element: HTMLElement): () => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Makes `element` a containing block for the viewer: the viewer's root is `position: absolute; inset: 0`, so it fills this element only when the element is
|
|
3
|
+
* positioned. A static element becomes `relative` and a visible overflow becomes `hidden`; a position or overflow the host already chose is left alone.
|
|
4
|
+
* Called by `mount` and by `AstraeusScene` for their own element, next to the `isolation` they set (O-055 T-256).
|
|
5
|
+
*/
|
|
6
|
+
export function makeContainingBlock(element) {
|
|
7
|
+
const { position, overflow } = element.style;
|
|
8
|
+
const style = getComputedStyle(element);
|
|
9
|
+
// An empty value is a page with no style engine behind it (a test DOM): the same as the initial `static` and `visible`.
|
|
10
|
+
if (style.position === "static" || style.position === "")
|
|
11
|
+
element.style.position = "relative";
|
|
12
|
+
if (style.overflow === "visible" || style.overflow === "")
|
|
13
|
+
element.style.overflow = "hidden";
|
|
14
|
+
// Puts back the inline values the host had, so unmounting leaves the element as it was handed over (O-055 C-144).
|
|
15
|
+
return () => { element.style.position = position; element.style.overflow = overflow; };
|
|
16
|
+
}
|
package/src/api/data.d.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { BodyId } from "../core/body.js";
|
|
2
2
|
import type { TimeBounds } from "../core/trajectory.js";
|
|
3
3
|
import { type BodyCatalogue } from "../assets/catalogue.js";
|
|
4
|
+
import type { BodySetLoad } from "./planBodySets.js";
|
|
4
5
|
import { type Pictures } from "../assets/pictures.js";
|
|
6
|
+
/** A moon-position index as a data package reads it from its JSON file: `format`, `id` and the list of `bodies` with their fits. The engine checks all of it when it loads (`bad-data` if it does not fit), so every field is optional here. */
|
|
7
|
+
export interface MoonIndex {
|
|
8
|
+
readonly format?: string;
|
|
9
|
+
readonly id?: string;
|
|
10
|
+
readonly bodies?: readonly object[];
|
|
11
|
+
}
|
|
5
12
|
/** Moon positions a data package (`astraeus-data-<planet>`) hands to the engine: where its index is read from and the URL of every chunk file it ships. */
|
|
6
13
|
export interface MoonPositions {
|
|
7
14
|
/** The planet the moons circle: `jupiter`, `saturn`, `uranus`, `neptune`, `mars` or `pluto`. */
|
|
8
|
-
readonly
|
|
9
|
-
readonly loadIndex: () => Promise<
|
|
15
|
+
readonly center: BodyId;
|
|
16
|
+
readonly loadIndex: () => Promise<MoonIndex>;
|
|
10
17
|
/** Chunk files by path relative to the index (`<moon>/<year>.bin`) to the URL they are served at. */
|
|
11
18
|
readonly chunkUrls: Readonly<Record<string, string>>;
|
|
12
19
|
}
|
|
13
|
-
/** What `mount` needs from a data package: what it provides, and optionally pictures
|
|
20
|
+
/** What `mount` needs from a data package: what it provides, and optionally pictures for the viewer, moon positions to hand to the engine, and a load step. */
|
|
14
21
|
export interface DataSource {
|
|
15
22
|
readonly name: string;
|
|
16
23
|
readonly provides: readonly BodyId[];
|
|
@@ -19,7 +26,12 @@ export interface DataSource {
|
|
|
19
26
|
readonly prepare?: () => Promise<void>;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
|
-
*
|
|
29
|
+
* The faults of a data source that need no loading, thrown by `check`, `load` and `mount` alike (one function, so the three cannot differ): a picture that fails the rights rule or carries an old
|
|
30
|
+
* name (`bad-data`, `renamed`), moon positions carrying an old name or naming a planet with no moon system. Nothing is read or loaded here; a scene with no data passes.
|
|
31
|
+
*/
|
|
32
|
+
export declare function checkDataSources(data: readonly DataSource[]): void;
|
|
33
|
+
/**
|
|
34
|
+
* Checks the rights of the packages' pictures (the viewer draws them from its definition, `assembleScene` carries them there), hands the moon positions to the engine and loads the chunks the scene's window needs for the moons it holds.
|
|
23
35
|
* Nothing is looked up behind the caller's back: a package that was not passed in contributes nothing.
|
|
24
36
|
*/
|
|
25
|
-
export declare function installData(data: readonly DataSource[], sceneBodies: readonly BodyId[], window: TimeBounds, catalogue?: BodyCatalogue): Promise<void>;
|
|
37
|
+
export declare function installData(data: readonly DataSource[], sceneBodies: readonly BodyId[], window: TimeBounds, catalogue?: BodyCatalogue, sets?: BodySetLoad): Promise<void>;
|
package/src/api/data.js
CHANGED
|
@@ -2,25 +2,43 @@ import { MOON_SYSTEMS } from "../core/bodies/listedMoonBodies.js";
|
|
|
2
2
|
import { MoonOutOfSpanError } from "../core/bodies/moonSystem.js";
|
|
3
3
|
import { catalogue as builtInCatalogue } from "../assets/catalogue.js";
|
|
4
4
|
import { SceneError } from "./errors.js";
|
|
5
|
-
import {
|
|
5
|
+
import { rejectRenamed } from "./renamedInputs.js";
|
|
6
|
+
import { picturesProblem } from "../assets/pictures.js";
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* The faults of a data source that need no loading, thrown by `check`, `load` and `mount` alike (one function, so the three cannot differ): a picture that fails the rights rule or carries an old
|
|
9
|
+
* name (`bad-data`, `renamed`), moon positions carrying an old name or naming a planet with no moon system. Nothing is read or loaded here; a scene with no data passes.
|
|
10
|
+
*/
|
|
11
|
+
export function checkDataSources(data) {
|
|
12
|
+
for (const source of data) {
|
|
13
|
+
const problem = source.pictures === undefined ? null : picturesProblem(source.pictures);
|
|
14
|
+
if (problem !== null)
|
|
15
|
+
throw new SceneError("bad-data", `${source.name}: ${problem}`);
|
|
16
|
+
for (const [name, texture] of Object.entries(source.pictures ?? {}))
|
|
17
|
+
rejectRenamed("TextureRefDesktop", texture.desktop, `${source.name}: pictures.${name}.desktop`);
|
|
18
|
+
const positions = source.moonPositions;
|
|
19
|
+
if (positions === undefined)
|
|
20
|
+
continue;
|
|
21
|
+
rejectRenamed("MoonPositions", positions, `${source.name}: moonPositions`);
|
|
22
|
+
if (MOON_SYSTEMS[positions.center] === undefined)
|
|
23
|
+
throw new SceneError("bad-data", `${source.name}: no moon system for "${positions.center}"`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks the rights of the packages' pictures (the viewer draws them from its definition, `assembleScene` carries them there), hands the moon positions to the engine and loads the chunks the scene's window needs for the moons it holds.
|
|
8
28
|
* Nothing is looked up behind the caller's back: a package that was not passed in contributes nothing.
|
|
9
29
|
*/
|
|
10
|
-
export async function installData(data, sceneBodies, window, catalogue = builtInCatalogue) {
|
|
30
|
+
export async function installData(data, sceneBodies, window, catalogue = builtInCatalogue, sets) {
|
|
31
|
+
checkDataSources(data);
|
|
11
32
|
for (const source of data) {
|
|
12
|
-
if (source.pictures !== undefined)
|
|
13
|
-
registerPictures(source.pictures);
|
|
14
33
|
const positions = source.moonPositions;
|
|
15
34
|
if (positions === undefined)
|
|
16
35
|
continue;
|
|
17
|
-
const system = MOON_SYSTEMS[positions.
|
|
18
|
-
if (system === undefined)
|
|
19
|
-
throw new RangeError(`${source.name}: no moon system for "${positions.centre}"`);
|
|
36
|
+
const system = MOON_SYSTEMS[positions.center];
|
|
20
37
|
system.provideIndex(positions.loadIndex);
|
|
21
|
-
const moons = sceneBodies.filter((id) => catalogue.has(id) && catalogue.get(id).definition.parentId === positions.
|
|
38
|
+
const moons = [...sceneBodies.filter((id) => catalogue.has(id) && catalogue.get(id).definition.parentId === positions.center), ...(sets?.moons ?? []).filter((moon) => moon.parent === positions.center).map(({ id }) => id)];
|
|
39
|
+
const maxMs = sets?.historyMs.get(positions.center) ?? 0;
|
|
22
40
|
if (moons.length > 0)
|
|
23
|
-
await system.load({ window, bodies: moons, chunkUrls: positions.chunkUrls }).catch(outOfSpan(source.name));
|
|
41
|
+
await system.load({ window, bodies: moons, chunkUrls: positions.chunkUrls, ...(maxMs > 0 ? { history: { bodies: moons, maxMs } } : {}) }).catch(outOfSpan(source.name));
|
|
24
42
|
}
|
|
25
43
|
for (const source of data)
|
|
26
44
|
await source.prepare?.();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExperienceDefinition } from "../app/experienceDefinition.js";
|
|
2
|
+
import type { DataSource } from "./data.js";
|
|
3
|
+
/**
|
|
4
|
+
* The engine's own route to what a scene builds: the app's plug-in contract (`ExperienceDefinition`). Not exported from the root, so a host cannot reach it (API-01).
|
|
5
|
+
* `Scene`'s constructor registers how its state becomes a definition; `mount`, `load`, `check` and the engine's tests ask here.
|
|
6
|
+
*/
|
|
7
|
+
type Build = (data: readonly DataSource[]) => ExperienceDefinition;
|
|
8
|
+
/** Called once by the `Scene` constructor. A test may register again to stand in for the build; the earlier builder comes back so it can wrap it. */
|
|
9
|
+
export declare function registerDefinition(scene: object, build: Build): Build | undefined;
|
|
10
|
+
/** The definition the scene builds with `data`. Throws what `mount` throws: an empty scene, or a body whose data package `data` lacks. */
|
|
11
|
+
export declare function definitionOf(scene: object, data?: readonly DataSource[]): ExperienceDefinition;
|
|
12
|
+
/** The data packages the scene's bodies need that `data` does not provide. */
|
|
13
|
+
export declare function missingDataOf(scene: object, data?: readonly DataSource[]): readonly string[];
|
|
14
|
+
/** Called once by the `Scene` constructor. */
|
|
15
|
+
export declare function registerMissingData(scene: object, find: (data: readonly DataSource[]) => readonly string[]): void;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const builders = new WeakMap();
|
|
2
|
+
/** Called once by the `Scene` constructor. A test may register again to stand in for the build; the earlier builder comes back so it can wrap it. */
|
|
3
|
+
export function registerDefinition(scene, build) {
|
|
4
|
+
const before = builders.get(scene);
|
|
5
|
+
builders.set(scene, build);
|
|
6
|
+
return before;
|
|
7
|
+
}
|
|
8
|
+
/** The definition the scene builds with `data`. Throws what `mount` throws: an empty scene, or a body whose data package `data` lacks. */
|
|
9
|
+
export function definitionOf(scene, data = []) {
|
|
10
|
+
return builders.get(scene)(data); // a non-Scene fails here with the engine's own TypeError; only `Scene` is registered
|
|
11
|
+
}
|
|
12
|
+
/** The data packages the scene's bodies need that `data` does not provide. */
|
|
13
|
+
export function missingDataOf(scene, data = []) {
|
|
14
|
+
return missing.get(scene)(data);
|
|
15
|
+
}
|
|
16
|
+
const missing = new WeakMap();
|
|
17
|
+
/** Called once by the `Scene` constructor. */
|
|
18
|
+
export function registerMissingData(scene, find) {
|
|
19
|
+
missing.set(scene, find);
|
|
20
|
+
}
|
package/src/api/errors.d.ts
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
/** Why a scene call was refused; `code` is stable so a caller can branch on it. */
|
|
2
|
-
export type SceneErrorCode =
|
|
2
|
+
export type SceneErrorCode =
|
|
3
|
+
/** A body or path id is not in the catalogue or the scene. */
|
|
4
|
+
"unknown-body"
|
|
5
|
+
/** An id is already used in the scene, so the new body, path, group, orbit line, activity, event or story panel cannot take it. */
|
|
6
|
+
| "duplicate-id"
|
|
7
|
+
/** A moment is not a valid time, or lies outside the span it must fall in. */
|
|
8
|
+
| "bad-time"
|
|
9
|
+
/** A path (`addTrajectory`) is malformed: its id, provider, bounds, plane, spans or line stretches. */
|
|
10
|
+
| "bad-trajectory"
|
|
11
|
+
/** A data package passed to the viewer is malformed, for example moon positions that name a planet without a moon system. */
|
|
12
|
+
| "bad-data"
|
|
13
|
+
/** The scale is not one of the engine's scales, or does not suit this scene. */
|
|
14
|
+
| "bad-scale"
|
|
15
|
+
/** Position data a body needs was not given to the viewer: pass its data package. */
|
|
16
|
+
| "missing-data"
|
|
17
|
+
/** The viewer is not drawn yet, or has been unmounted: a handle call before `ready` or after `unmount`. */
|
|
18
|
+
| "not-mounted"
|
|
19
|
+
/** The timeline reaches outside the years a body's data package covers. */
|
|
20
|
+
| "out-of-span"
|
|
21
|
+
/** The scene was edited after a viewer took it; build a new scene instead. */
|
|
22
|
+
| "scene-mounted"
|
|
23
|
+
/** The scene has no bodies to show. */
|
|
24
|
+
| "empty-scene"
|
|
25
|
+
/** An orbital-elements record, or the element to mount into, is malformed. */
|
|
26
|
+
| "bad-element"
|
|
27
|
+
/** An orbit line was asked for a body whose data give no closed orbit, or about a body not in the scene. */
|
|
28
|
+
| "no-orbit"
|
|
29
|
+
/** A path anchor is malformed, repeated or outside the path. */
|
|
30
|
+
| "bad-anchor"
|
|
31
|
+
/** A readout is of an unknown kind, or lacks or misnames the body or activity it measures. */
|
|
32
|
+
| "bad-readout"
|
|
33
|
+
/** An event is malformed or names an object that is not in the scene. */
|
|
34
|
+
| "bad-event"
|
|
35
|
+
/** The story panels are malformed. */
|
|
36
|
+
| "bad-panels"
|
|
37
|
+
/** The timeline, its pacing or its speeds are malformed, or a call needs pacing the scene lacks. */
|
|
38
|
+
| "bad-timeline"
|
|
39
|
+
/** A display switch is unknown or malformed. */
|
|
40
|
+
| "bad-switch"
|
|
41
|
+
/** An option of `addBody` is malformed. */
|
|
42
|
+
| "bad-body"
|
|
43
|
+
/** A point group is malformed or refers to a body that is not in the scene. */
|
|
44
|
+
| "bad-group"
|
|
45
|
+
/** A body set (`addBodySet`) is malformed, or names a centre, moon, body or balance point the scene cannot draw it with. */
|
|
46
|
+
| "bad-body-set"
|
|
47
|
+
/** The moon panel (`setMoonPanel`) is malformed, or names a moon the scene does not hold. */
|
|
48
|
+
| "bad-moon-panel"
|
|
49
|
+
/** The picker (`setPicker`, `setPick`) is malformed, or a pick names an option it does not have. */
|
|
50
|
+
| "bad-picker"
|
|
51
|
+
/** A body's places (`addPlaces`) are malformed, or name a body the scene does not hold. */
|
|
52
|
+
| "bad-places"
|
|
53
|
+
/** An activity curve is malformed. */
|
|
54
|
+
| "bad-activity"
|
|
55
|
+
/** A camera call or pose is malformed, or names an object the view cannot show. */
|
|
56
|
+
| "bad-camera"
|
|
57
|
+
/** A scene view is malformed, repeated, or not one of the scene's views. */
|
|
58
|
+
| "bad-view"
|
|
59
|
+
/** `setSelected` was given something other than an id of an object the showing view shows, or `undefined`. */
|
|
60
|
+
| "bad-selection"
|
|
61
|
+
/** A look (`setLook`) is unknown or out of its range. */
|
|
62
|
+
| "bad-look"
|
|
63
|
+
/** An input field was given under a name it no longer has; the message names the old field and its replacement. */
|
|
64
|
+
| "renamed";
|
|
3
65
|
/** The one error the public API throws for bad input; the message names the offending value. */
|
|
4
66
|
export declare class SceneError extends RangeError {
|
|
5
67
|
readonly code: SceneErrorCode;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A deep, frozen copy of what a caller handed a `Scene` call (API-04): plain objects, lists, number arrays and dates are copied. Anything that behaves rather than holds data is kept as it is: functions,
|
|
3
|
+
* class instances (built-in bodies, providers) and plain objects with a method (a `stateAt` provider, which may keep state of its own). A later edit of the caller's object, or the same object
|
|
4
|
+
* used for another scene, then changes nothing here.
|
|
5
|
+
*/
|
|
6
|
+
export declare function frozenCopy<T>(value: T): T;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Whether `value` is a plain object (an object literal or one with no prototype), the only objects a copy walks into. */
|
|
2
|
+
function isPlain(value) {
|
|
3
|
+
const proto = Object.getPrototypeOf(value);
|
|
4
|
+
return proto === Object.prototype || proto === null;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A deep, frozen copy of what a caller handed a `Scene` call (API-04): plain objects, lists, number arrays and dates are copied. Anything that behaves rather than holds data is kept as it is: functions,
|
|
8
|
+
* class instances (built-in bodies, providers) and plain objects with a method (a `stateAt` provider, which may keep state of its own). A later edit of the caller's object, or the same object
|
|
9
|
+
* used for another scene, then changes nothing here.
|
|
10
|
+
*/
|
|
11
|
+
export function frozenCopy(value) {
|
|
12
|
+
if (typeof value !== "object" || value === null)
|
|
13
|
+
return value;
|
|
14
|
+
if (value instanceof Date)
|
|
15
|
+
return Object.freeze(new Date(value.getTime()));
|
|
16
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView))
|
|
17
|
+
return value.slice();
|
|
18
|
+
if (Array.isArray(value))
|
|
19
|
+
return Object.freeze(value.map(frozenCopy));
|
|
20
|
+
if (!isPlain(value))
|
|
21
|
+
return value;
|
|
22
|
+
const entries = Object.entries(value);
|
|
23
|
+
if (entries.some(([, item]) => typeof item === "function"))
|
|
24
|
+
return value;
|
|
25
|
+
return Object.freeze(Object.fromEntries(entries.map(([key, item]) => [key, frozenCopy(item)])));
|
|
26
|
+
}
|
package/src/api/group.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export interface GroupInput {
|
|
|
46
46
|
readonly label?: string;
|
|
47
47
|
/** The body the orbits circle; the scene's centre (its first body) when absent. It must be in the scene. */
|
|
48
48
|
readonly center?: BodyId;
|
|
49
|
-
/** The plane the elements are given in: "ecliptic-j2000"
|
|
50
|
-
readonly plane
|
|
49
|
+
/** The plane the elements are given in: "ecliptic-j2000" or "EQJ" (the equator of J2000). Required: a group that does not say throws `bad-group`. */
|
|
50
|
+
readonly plane: "ecliptic-j2000" | "EQJ";
|
|
51
51
|
/** The dots' colour as a CSS hex colour such as "#9de3a8"; default "#9de3a8". */
|
|
52
52
|
readonly color?: string;
|
|
53
53
|
/** Dot size in screen pixels; default 2.5. */
|
|
@@ -85,5 +85,11 @@ export interface PlannedGroup {
|
|
|
85
85
|
}
|
|
86
86
|
/** Checks what can be checked before the scene is complete; the centre, the clump body and the id clash with other things are checked at build. */
|
|
87
87
|
export declare function planGroup(input: GroupInput, catalogue?: BodyCatalogue): PlannedGroup;
|
|
88
|
+
/** The provenance a group's card shows (`Scene.groups`): the engine's illustrative statement over the caller's source. */
|
|
89
|
+
export declare function groupCardProvenance(input: GroupInput): Provenance;
|
|
90
|
+
/** The words on a group's card: the caller's, else a sentence stating the count. */
|
|
91
|
+
export declare function groupDescription(input: GroupInput, count: number): string;
|
|
92
|
+
/** The known limits on a group's card: the caller's, then the engine's own about placement, the clump and motion. */
|
|
93
|
+
export declare function groupLimitations(input: GroupInput, catalogue: BodyCatalogue): readonly string[];
|
|
88
94
|
/** Builds the draw layer: the listed-orbit group and its one shell item. `center` and `openUtcMs` come from the finished scene; a group error from the engine is renamed `bad-group`. */
|
|
89
95
|
export declare function buildGroupLayer(plan: PlannedGroup, catalogue: BodyCatalogue, center: BodyId, openUtcMs: number, window: TimeBounds): GroupLayer;
|
package/src/api/group.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
2
|
-
import { createListedOrbitGroup } from "../core/listedOrbitGroup.js";
|
|
2
|
+
import { createListedOrbitGroup, listedGroupProvenance } from "../core/listedOrbitGroup.js";
|
|
3
3
|
import { createProvenance } from "../core/provenance.js";
|
|
4
4
|
import { createOrbTwoBodyAdapter } from "../core/twoBodyAdapter.js";
|
|
5
5
|
import { catalogue as builtInCatalogue } from "../assets/catalogue.js";
|
|
@@ -13,6 +13,8 @@ export function planGroup(input, catalogue = builtInCatalogue) {
|
|
|
13
13
|
const id = input?.id;
|
|
14
14
|
if (typeof id !== "string" || id === "")
|
|
15
15
|
throw bad(id, "the group needs a non-empty id");
|
|
16
|
+
if (input.plane !== "ecliptic-j2000" && input.plane !== "EQJ")
|
|
17
|
+
throw bad(id, `plane must be "ecliptic-j2000" or "EQJ", got ${input.plane === undefined ? "nothing" : JSON.stringify(input.plane)}; say which plane the elements are given in`);
|
|
16
18
|
checkOrbits(id, input.orbits);
|
|
17
19
|
checkLook(id, input);
|
|
18
20
|
if (input.clump !== undefined)
|
|
@@ -72,6 +74,23 @@ const PLACEMENT_LIMIT = "The position of each dot along its orbit is illustrativ
|
|
|
72
74
|
const MOTION_LIMIT = "Motion is unperturbed two-body motion about the centre.";
|
|
73
75
|
const CLUMP_LIMIT = (catalogue, near, fraction) => `${Math.round(fraction * 100)}% of the dots are drawn near ${catalogue.get(near).definition.label}'s position along its orbit. That clump is a model, not a measurement.`;
|
|
74
76
|
const AS_SUPPLIED = createProvenance({ sourceType: "illustrative", sources: ["Supplied by the caller"], accuracy: "As supplied; the engine makes no claim.", notes: "The orbits were passed to addGroup." });
|
|
77
|
+
/** The provenance the caller gave a group, else the "as supplied" notice. */
|
|
78
|
+
function groupSource(input) {
|
|
79
|
+
return input.provenance ?? AS_SUPPLIED;
|
|
80
|
+
}
|
|
81
|
+
/** The provenance a group's card shows (`Scene.groups`): the engine's illustrative statement over the caller's source. */
|
|
82
|
+
export function groupCardProvenance(input) {
|
|
83
|
+
return listedGroupProvenance(groupSource(input), input.clump !== undefined);
|
|
84
|
+
}
|
|
85
|
+
/** The words on a group's card: the caller's, else a sentence stating the count. */
|
|
86
|
+
export function groupDescription(input, count) {
|
|
87
|
+
return input.description ?? `${count} listed orbit${count === 1 ? "" : "s"}, each drawn as one dot. One item stands for the whole group; its focus point is the centroid of the dots.`;
|
|
88
|
+
}
|
|
89
|
+
/** The known limits on a group's card: the caller's, then the engine's own about placement, the clump and motion. */
|
|
90
|
+
export function groupLimitations(input, catalogue) {
|
|
91
|
+
const clump = input.clump;
|
|
92
|
+
return [...(input.knownLimitations ?? []), PLACEMENT_LIMIT, ...(clump === undefined ? [] : [CLUMP_LIMIT(catalogue, clump.near, clump.fraction)]), MOTION_LIMIT];
|
|
93
|
+
}
|
|
75
94
|
/** Builds the draw layer: the listed-orbit group and its one shell item. `center` and `openUtcMs` come from the finished scene; a group error from the engine is renamed `bad-group`. */
|
|
76
95
|
export function buildGroupLayer(plan, catalogue, center, openUtcMs, window) {
|
|
77
96
|
const { id, input } = plan;
|
|
@@ -86,7 +105,7 @@ export function buildGroupLayer(plan, catalogue, center, openUtcMs, window) {
|
|
|
86
105
|
const group = createListedOrbitGroup({
|
|
87
106
|
id,
|
|
88
107
|
center,
|
|
89
|
-
plane: input.plane
|
|
108
|
+
plane: input.plane,
|
|
90
109
|
members,
|
|
91
110
|
phase: {
|
|
92
111
|
referenceUtcMs,
|
|
@@ -94,7 +113,7 @@ export function buildGroupLayer(plan, catalogue, center, openUtcMs, window) {
|
|
|
94
113
|
...(clump === undefined ? {} : { concentration: { around: catalogue.get(clump.near).source.create(createOrbAstronomyAdapter()), fraction: clump.fraction, widthDeg: clump.widthDeg } }),
|
|
95
114
|
},
|
|
96
115
|
bounds: window,
|
|
97
|
-
provenance: input
|
|
116
|
+
provenance: groupSource(input),
|
|
98
117
|
}, createOrbTwoBodyAdapter());
|
|
99
118
|
const color = input.color ?? GROUP_COLOR;
|
|
100
119
|
return {
|
|
@@ -108,8 +127,8 @@ export function buildGroupLayer(plan, catalogue, center, openUtcMs, window) {
|
|
|
108
127
|
label: plan.label,
|
|
109
128
|
color,
|
|
110
129
|
labelPriority: 80,
|
|
111
|
-
description: input
|
|
112
|
-
knownLimitations:
|
|
130
|
+
description: groupDescription(input, group.count),
|
|
131
|
+
knownLimitations: groupLimitations(input, catalogue),
|
|
113
132
|
},
|
|
114
133
|
};
|
|
115
134
|
}
|
package/src/api/index.d.ts
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
export { Scene, SceneCamera, type AddBodyOptions, type AnchorInput, type ReadoutInput, type DataSource, type MoonPositions, type FollowView, type GroupInput, type GroupOrbitInput, type GroupClumpInput, type GroupReadoutInput, type ActivityInput, type ActivitySampleInput, type ActivitySourceInput, type ElementsBodyRecord, type TimeInput, type TrajectoryInput, type TrajectorySampleInput } from "./scene.js";
|
|
2
|
-
export {
|
|
1
|
+
export { Scene, type SceneCamera, type AddBodyOptions, type CardFactInput, type OrbitLapInput, type BodyReadoutKind, type AnchorInput, type ReadoutInput, type DataSource, type SceneLoadOptions, type SceneBodyRead, type SceneActivityRead, type ScenePathRead, type SceneGroupRead, type SceneBodySetRead, type SceneMoonPanelRead, type ScenePlacesRead, type SceneEventRead, type ScenePanelRead, type SceneViewRead, type SceneViewsRead, type SceneTimelineRead, type MoonPositions, type MoonIndex, type FollowView, type GroupInput, type GroupOrbitInput, type GroupClumpInput, type GroupReadoutInput, type ActivityInput, type ActivitySampleInput, type ActivitySourceInput, type ElementsBodyRecord, type TimeInput, type TrajectoryInput, type TrajectorySampleInput, type TrajectoryBase } from "./scene.js";
|
|
2
|
+
export type { MoonPanelInput, MoonPanelFamilyInput, MoonPanelMoonInput, PlacesInput, PlaceInput, PlaceCategoryInput } from "./moonPanelInput.js";
|
|
3
|
+
export type { PickerInput, PickerOptionInput, PickChange } from "./pickerInput.js";
|
|
4
|
+
export type { BodySetInput, BodySetFamilyInput, BodySetMemberInput, BodySetElementsInput, BodySetBodyInput, BodySetBalanceInput } from "./bodySetInput.js";
|
|
5
|
+
export { type EventInput, type AddEventsOptions, type TimelineInput, type PacingInput, type StoryPanelAt, type StoryPanelInput, type StoryPanelPlaybackInput } from "./story.js";
|
|
3
6
|
export { type SwitchesInput } from "./switches.js";
|
|
7
|
+
export { type LookInput, type LookRead, type SunGlowLook } from "./look.js";
|
|
4
8
|
export { type ViewsOptions, type ViewInput, type ViewCameraInput } from "./views.js";
|
|
5
9
|
export { mount, type MountOptions, type MountedScene } from "./mount.js";
|
|
10
|
+
export { type ViewerHandle } from "./viewerHandle.js";
|
|
6
11
|
export { AstraeusScene, type AstraeusSceneProps } from "./AstraeusScene.js";
|
|
7
|
-
export { type
|
|
12
|
+
export { type SelectionChange } from "./viewerSelection.js";
|
|
13
|
+
export { type ViewerChange, type EventZoneChange, type CameraPose, type CameraTarget } from "./viewerLink.js";
|
|
8
14
|
export { SceneError, type SceneErrorCode } from "./errors.js";
|
|
9
15
|
export { sun, mercury, venus, earth, moon, mars, jupiter, saturn, uranus, neptune, pluto, io, europa, ganymede, callisto, mimas, enceladus, tethys, dione, rhea, titan, iapetus, triton, charon, phobos, deimos, listedMoons, type BodyRef } from "./bodies.js";
|
|
10
|
-
export { trueScale, readableScale, solarSystemScale, type ScalePolicy } from "../core/scalePolicy.js";
|
|
11
|
-
export type { State } from "../core/state.js";
|
|
16
|
+
export { trueScale, readableScale, solarSystemScale, type ScalePolicy, type SolarSystemScalePolicy } from "../core/scalePolicy.js";
|
|
17
|
+
export type { State, CenteredPosition, FrameId, Quaternion } from "../core/state.js";
|
|
12
18
|
export type { Provenance, ProvenanceSourceType } from "../core/provenance.js";
|
|
13
19
|
export type { Pictures } from "../assets/pictures.js";
|
|
14
|
-
export type { AssetLicence, TextureRef } from "../assets/licence.js";
|
|
15
|
-
export { APPROXIMATE_LIMIT_FRACTION, INDICATIVE_LIMIT_FRACTION, classifyPositionError, parseElementsBodyRecord, type AccuracyClassification } from "../core/elementsBody.js";
|
|
20
|
+
export type { AssetLicence, TextureRef, LocalOnlyDeclaration, PublicReplacement } from "../assets/licence.js";
|
|
21
|
+
export { APPROXIMATE_LIMIT_FRACTION, INDICATIVE_LIMIT_FRACTION, classifyPositionError, parseElementsBodyRecord, type AccuracyClassification, type ElementsSource, type ElementsTimeScale } from "../core/elementsBody.js";
|
|
22
|
+
export type { BodyId, CenterId } from "../core/body.js";
|
|
23
|
+
export type { DisplaySwitchId, DisplaySwitchPlace } from "../app/displaySwitches.js";
|
|
24
|
+
export type { ViewPlace } from "../app/views.js";
|
|
25
|
+
export type { ViewerChangeCause } from "../app/viewerPort.js";
|
|
26
|
+
export type { LineStretchInput } from "./pathProvenance.js";
|
package/src/api/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The engine's public API
|
|
2
|
-
export { Scene
|
|
1
|
+
// The engine's public API: everything not exported here is internal.
|
|
2
|
+
export { Scene } from "./scene.js";
|
|
3
3
|
export { mount } from "./mount.js";
|
|
4
4
|
export { AstraeusScene } from "./AstraeusScene.js";
|
|
5
5
|
export { SceneError } from "./errors.js";
|
package/src/api/index.node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The engine's public API
|
|
2
|
-
export { Scene
|
|
1
|
+
// The engine's public API: everything not exported here is internal.
|
|
2
|
+
export { Scene } from "./scene.js";
|
|
3
3
|
export { mount } from "./mount.node.js";
|
|
4
4
|
export { AstraeusScene } from "./AstraeusScene.node.js";
|
|
5
5
|
export { SceneError } from "./errors.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calls every listener with `value`, over a copy of the set (a listener that stops itself or adds one during the call changes the next call, not this one).
|
|
3
|
+
* A listener that throws is reported to the page after its turn and never stops the listeners after it.
|
|
4
|
+
*/
|
|
5
|
+
export declare function callListeners<T>(listeners: ReadonlySet<(value: T) => void>, value: T): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Reports a host listener's throw to the page: `reportError` (a window `error` event) when the page has it, else rethrown on a timer so it still surfaces and nothing else is stopped. */
|
|
2
|
+
function reportToPage(error) {
|
|
3
|
+
const report = globalThis.reportError;
|
|
4
|
+
if (typeof report === "function")
|
|
5
|
+
report.call(globalThis, error);
|
|
6
|
+
else
|
|
7
|
+
setTimeout(() => { throw error; }, 0);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Calls every listener with `value`, over a copy of the set (a listener that stops itself or adds one during the call changes the next call, not this one).
|
|
11
|
+
* A listener that throws is reported to the page after its turn and never stops the listeners after it.
|
|
12
|
+
*/
|
|
13
|
+
export function callListeners(listeners, value) {
|
|
14
|
+
const failures = [];
|
|
15
|
+
for (const listener of [...listeners]) {
|
|
16
|
+
try {
|
|
17
|
+
listener(value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
failures.push(error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
for (const error of failures)
|
|
24
|
+
reportToPage(error);
|
|
25
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/** The Sun's glow: the halo drawn round it. Every field is optional and keeps the Sun record's own value when absent. Has no effect in a scene without the Sun. */
|
|
2
|
+
export interface SunGlowLook {
|
|
3
|
+
/** Least width of the glow on screen, in pixels, 0 to 400. Default 72. */
|
|
4
|
+
readonly sizePx?: number;
|
|
5
|
+
/** Strength of the glow, 0 to 2. Default 1. */
|
|
6
|
+
readonly brightness?: number;
|
|
7
|
+
/** The glow is at least this many times the Sun's projected diameter, 1 to 6, so close up it frames the disc. Default 2.5. */
|
|
8
|
+
readonly scale?: number;
|
|
9
|
+
}
|
|
10
|
+
/** The looks a scene may set with `Scene.setLook`: presentation settings that change how the scene is drawn, never where anything is. Each is optional and keeps its default when absent. */
|
|
11
|
+
export interface LookInput {
|
|
12
|
+
/** Brightness of the catalogue stars, 0 to 2; 1 is the baseline star curve and 0 hides them in effect. Default 1. */
|
|
13
|
+
readonly starBrightness?: number;
|
|
14
|
+
/** Whether the Milky Way picture is drawn behind the stars (needs the `milky-way` picture in the viewer's `pictures`). Default off, unless `setSwitches` starts the Milky Way switch on. */
|
|
15
|
+
readonly milkyWay?: boolean;
|
|
16
|
+
/** Brightness of the Milky Way picture, 0 to 2; 1 is the baseline strength. Default 1. */
|
|
17
|
+
readonly milkyWayBrightness?: number;
|
|
18
|
+
/** False hides the whole sky (stars and Milky Way), for a comparison. Default true. */
|
|
19
|
+
readonly skyVisible?: boolean;
|
|
20
|
+
/** The Sun's glow. Default: the Sun record's own. */
|
|
21
|
+
readonly sunGlow?: SunGlowLook;
|
|
22
|
+
/** A sphere whose drawn radius is under this many screen pixels is drawn as a marker dot instead, 0 to 100; 0 never swaps. Default 3. */
|
|
23
|
+
readonly markerSwapRadiusPx?: number;
|
|
24
|
+
/** The narrowest body, in screen pixels across, that still shows its surface feature markers, 0 to 2000. Default 60. */
|
|
25
|
+
readonly featureMinBodyPx?: number;
|
|
26
|
+
/** How long the host's loading cover fades out at the first drawn frame, in seconds, 0 to 3. Default 0.6 (a value saved from the Developer drawer stands in its place). */
|
|
27
|
+
readonly loadFadeSeconds?: number;
|
|
28
|
+
/** Whether bodies with a larger desktop picture use it on a wide screen (default false: the phone-sized picture everywhere). Read when the viewer is built: a later `setLook` neither swaps pictures nor changes what `look` reads. */
|
|
29
|
+
readonly desktopPictures?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** The looks a running viewer shows, every one filled in (`ViewerHandle.look`): the scene's `setLook`, the page address and the Developer drawer laid over the defaults. `sunGlow` is absent in a scene without the Sun. */
|
|
32
|
+
export interface LookRead {
|
|
33
|
+
readonly starBrightness: number;
|
|
34
|
+
readonly milkyWay: boolean;
|
|
35
|
+
readonly milkyWayBrightness: number;
|
|
36
|
+
readonly skyVisible: boolean;
|
|
37
|
+
readonly sunGlow?: {
|
|
38
|
+
readonly sizePx: number;
|
|
39
|
+
readonly brightness: number;
|
|
40
|
+
readonly scale: number;
|
|
41
|
+
};
|
|
42
|
+
readonly markerSwapRadiusPx: number;
|
|
43
|
+
readonly featureMinBodyPx: number;
|
|
44
|
+
readonly loadFadeSeconds: number;
|
|
45
|
+
/** Whether wide screens use the larger desktop pictures: the value the viewer was built with (the scene's look, or the page address); `setLook` does not change it. */
|
|
46
|
+
readonly desktopPictures: boolean;
|
|
47
|
+
}
|
package/src/api/look.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { LookInput } from "./look.js";
|
|
2
|
+
/** Checks a `setLook` argument: an object of known looks, each a finite number in its range or a boolean as its field says. Returns a frozen copy (the scene keeps no reference to the caller's object). */
|
|
3
|
+
export declare function checkedLook(input: LookInput): LookInput;
|