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
|
@@ -4,7 +4,7 @@ import { createCenteredPosition, createState, EQJ } from "./state.js";
|
|
|
4
4
|
function sameEpochAndFrame(a, b) {
|
|
5
5
|
if (a.timeUtcMs !== b.timeUtcMs)
|
|
6
6
|
throw new RangeError("center composition requires identical timestamps");
|
|
7
|
-
if (a.
|
|
7
|
+
if (a.plane !== b.plane)
|
|
8
8
|
throw new RangeError("center composition requires identical frames");
|
|
9
9
|
}
|
|
10
10
|
export function composeCenteredPositions(bodyFromOrigin, originFromCenter) {
|
|
@@ -16,7 +16,7 @@ export function composeCenteredPositions(bodyFromOrigin, originFromCenter) {
|
|
|
16
16
|
body: bodyFromOrigin.body,
|
|
17
17
|
center: originFromCenter.center,
|
|
18
18
|
timeUtcMs: bodyFromOrigin.timeUtcMs,
|
|
19
|
-
|
|
19
|
+
plane: bodyFromOrigin.plane,
|
|
20
20
|
positionKm: [
|
|
21
21
|
bodyFromOrigin.positionKm[0] + originFromCenter.positionKm[0],
|
|
22
22
|
bodyFromOrigin.positionKm[1] + originFromCenter.positionKm[1],
|
|
@@ -30,7 +30,7 @@ export function inverseCenteredPosition(position) {
|
|
|
30
30
|
body: position.center,
|
|
31
31
|
center: position.body,
|
|
32
32
|
timeUtcMs: position.timeUtcMs,
|
|
33
|
-
|
|
33
|
+
plane: position.plane,
|
|
34
34
|
positionKm: [-position.positionKm[0], -position.positionKm[1], -position.positionKm[2]],
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -39,7 +39,7 @@ export function earthStateAt(adapter, timeUtcMs) {
|
|
|
39
39
|
body: "earth",
|
|
40
40
|
center: "sun",
|
|
41
41
|
timeUtcMs,
|
|
42
|
-
|
|
42
|
+
plane: EQJ,
|
|
43
43
|
positionKm: adapter.earthPositionFromSunKm(timeUtcMs),
|
|
44
44
|
orientation: earthOrientationFromEcefToEqj(adapter.earthFixedToEqjMatrix(timeUtcMs)),
|
|
45
45
|
});
|
|
@@ -49,7 +49,7 @@ export function sunPositionFromEarthAt(adapter, timeUtcMs) {
|
|
|
49
49
|
body: "sun",
|
|
50
50
|
center: "earth",
|
|
51
51
|
timeUtcMs,
|
|
52
|
-
|
|
52
|
+
plane: EQJ,
|
|
53
53
|
positionKm: adapter.sunPositionFromEarthKm(timeUtcMs),
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -36,6 +36,7 @@ export interface SolarSystemScaleOptions {
|
|
|
36
36
|
readonly exaggeration: Readonly<Record<BodyId, number>>;
|
|
37
37
|
readonly defaultExaggeration: number;
|
|
38
38
|
}
|
|
39
|
+
/** The scale policy `solarSystemScale` is: a `ScalePolicy` with a per-body radius exaggeration. */
|
|
39
40
|
export interface SolarSystemScalePolicy extends ScalePolicy {
|
|
40
41
|
readonly id: "solar-system";
|
|
41
42
|
/** The enlargement applied to a body (the default when it has no declared factor). */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A camera view as a short text: `?view=<focus>,<azimuthDeg>,<elevationDeg>,<distance>`, with the scale (`scale=`), up direction (`up=`)
|
|
3
|
+
* and time (`t=`, ISO UTC) beside it. Azimuth and elevation are the scene camera's own angles about the up direction in force;
|
|
4
|
+
* distance is the scene camera's own (scaled units, camera to focus). Pure text handling: no body is named here.
|
|
5
|
+
*/
|
|
6
|
+
export interface StartView {
|
|
7
|
+
/** The focus target's id (a body, group or path the scene knows). */
|
|
8
|
+
readonly focus: string;
|
|
9
|
+
/** Degrees, 0 up to 360, about the up direction. */
|
|
10
|
+
readonly azimuthDeg: number;
|
|
11
|
+
/** Degrees above the orbit plane, within ±89. */
|
|
12
|
+
readonly elevationDeg: number;
|
|
13
|
+
/** Camera-to-focus distance in scaled units; positive. */
|
|
14
|
+
readonly distance: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const MAX_ELEVATION_DEG = 89;
|
|
17
|
+
export declare const wrapAzimuth: (deg: number) => number;
|
|
18
|
+
/** Checks a view's fields, naming the offending one (`where` is its path, e.g. `look.startView`). Returns the view with the azimuth wrapped. */
|
|
19
|
+
export declare function validateStartView(raw: unknown, where?: string): StartView;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const MAX_ELEVATION_DEG = 89;
|
|
2
|
+
export const wrapAzimuth = (deg) => ((deg % 360) + 360) % 360;
|
|
3
|
+
/** Checks a view's fields, naming the offending one (`where` is its path, e.g. `look.startView`). Returns the view with the azimuth wrapped. */
|
|
4
|
+
export function validateStartView(raw, where = "startView") {
|
|
5
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
6
|
+
throw new RangeError(`${where} must be an object with focus, azimuthDeg, elevationDeg and distance`);
|
|
7
|
+
const record = raw;
|
|
8
|
+
for (const key of Object.keys(record)) {
|
|
9
|
+
if (!["focus", "azimuthDeg", "elevationDeg", "distance"].includes(key))
|
|
10
|
+
throw new RangeError(`${where}.${key} is not a view field`);
|
|
11
|
+
}
|
|
12
|
+
if (typeof record.focus !== "string" || record.focus === "")
|
|
13
|
+
throw new RangeError(`${where}.focus must be a non-empty id, got ${String(record.focus)}`);
|
|
14
|
+
const number = (key) => {
|
|
15
|
+
const value = record[key];
|
|
16
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
17
|
+
throw new RangeError(`${where}.${key} must be a finite number, got ${String(value)}`);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
const azimuthDeg = number("azimuthDeg");
|
|
21
|
+
const elevationDeg = number("elevationDeg");
|
|
22
|
+
const distance = number("distance");
|
|
23
|
+
if (Math.abs(elevationDeg) > MAX_ELEVATION_DEG)
|
|
24
|
+
throw new RangeError(`${where}.elevationDeg must be within ±${MAX_ELEVATION_DEG}, got ${elevationDeg}`);
|
|
25
|
+
if (!(distance > 0))
|
|
26
|
+
throw new RangeError(`${where}.distance must be positive, got ${distance}`);
|
|
27
|
+
return { focus: record.focus, azimuthDeg: wrapAzimuth(azimuthDeg), elevationDeg, distance };
|
|
28
|
+
}
|
package/src/core/state.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { type BodyId, type CenterId } from "./body.js";
|
|
2
2
|
export declare const EQJ: "EQJ";
|
|
3
|
+
/** The reference frame of a state: `"EQJ"`, equatorial J2000. */
|
|
3
4
|
export type FrameId = typeof EQJ;
|
|
5
|
+
/** A rotation as a unit quaternion `[x, y, z, w]`. */
|
|
4
6
|
export type Quaternion = readonly [x: number, y: number, z: number, w: number];
|
|
7
|
+
/** Where a body is, in km relative to a centre, with the velocity when known (a `State` without its orientation). */
|
|
5
8
|
export interface CenteredPosition {
|
|
6
9
|
readonly body: BodyId;
|
|
7
10
|
readonly center: CenterId;
|
|
8
11
|
readonly timeUtcMs: number;
|
|
9
|
-
|
|
12
|
+
/** The plane the position is measured in: `"EQJ"`, equatorial J2000. */
|
|
13
|
+
readonly plane: FrameId;
|
|
10
14
|
readonly positionKm: Float64Array;
|
|
11
15
|
readonly velocityKmS?: Float64Array;
|
|
12
16
|
}
|
|
@@ -19,7 +23,7 @@ export interface StateInput {
|
|
|
19
23
|
readonly body: BodyId;
|
|
20
24
|
readonly center: CenterId;
|
|
21
25
|
readonly timeUtcMs: number;
|
|
22
|
-
readonly
|
|
26
|
+
readonly plane?: FrameId;
|
|
23
27
|
readonly positionKm: ArrayLike<number>;
|
|
24
28
|
readonly velocityKmS?: ArrayLike<number>;
|
|
25
29
|
readonly orientation: Quaternion | null;
|
package/src/core/state.js
CHANGED
|
@@ -42,14 +42,14 @@ export function createCenteredPosition(input) {
|
|
|
42
42
|
&& (positionKm.some((component) => component !== 0) || velocityKmS?.some((component) => component !== 0))) {
|
|
43
43
|
throw new RangeError("a body can be positioned relative to itself only at exactly zero");
|
|
44
44
|
}
|
|
45
|
-
const
|
|
46
|
-
if (
|
|
45
|
+
const plane = input.plane ?? EQJ;
|
|
46
|
+
if (plane !== EQJ)
|
|
47
47
|
throw new RangeError("this spike's scientific states use the EQJ frame only");
|
|
48
48
|
return Object.freeze({
|
|
49
49
|
body: input.body,
|
|
50
50
|
center: input.center,
|
|
51
51
|
timeUtcMs: input.timeUtcMs,
|
|
52
|
-
|
|
52
|
+
plane,
|
|
53
53
|
positionKm,
|
|
54
54
|
...(velocityKmS === undefined ? {} : { velocityKmS }),
|
|
55
55
|
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type Provenance } from "./provenance.js";
|
|
2
|
+
import type { TimeBounds } from "./trajectory.js";
|
|
3
|
+
/** One short story panel, resolved to a UTC time. */
|
|
4
|
+
export interface StoryPanel {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly timeUtcMs: number;
|
|
7
|
+
readonly title: string;
|
|
8
|
+
/** Paragraphs, in order. */
|
|
9
|
+
readonly body: readonly string[];
|
|
10
|
+
/** Short paragraphs of exact figures and measured-versus-reconstructed notes, shown in the folded section above the sources. Empty when the panel has none. */
|
|
11
|
+
readonly details: readonly string[];
|
|
12
|
+
/** Where the panel's facts come from and how far to trust them (PROV-01): its `sourceType` is the badge word; `sources` is never empty and `accuracy` is always stated. */
|
|
13
|
+
readonly provenance: Provenance;
|
|
14
|
+
/** A shell object this panel is about; the scene draws a marker on it that reopens the panel. */
|
|
15
|
+
readonly objectId?: string;
|
|
16
|
+
}
|
|
17
|
+
/** The panels an experience offers, with the defaults of the two settings that govern them. */
|
|
18
|
+
export interface StoryPanelSet {
|
|
19
|
+
readonly panels: readonly StoryPanel[];
|
|
20
|
+
/** How long playback holds when a panel opens by itself, in seconds (0 never pauses). */
|
|
21
|
+
readonly pauseSeconds: number;
|
|
22
|
+
/** Whether panels open by themselves as forward playback reaches them. */
|
|
23
|
+
readonly autoOpen: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const DEFAULT_PANEL_PAUSE_SECONDS = 6;
|
|
26
|
+
export declare const MAX_PANEL_PAUSE_SECONDS = 20;
|
|
27
|
+
/** The two playback settings of a scene's story panels. */
|
|
28
|
+
export type PanelPlayback = Pick<StoryPanelSet, "pauseSeconds" | "autoOpen">;
|
|
29
|
+
export declare const DEFAULT_PANEL_PLAYBACK: PanelPlayback;
|
|
30
|
+
/** A panel whose own shape is sound and whose moment is converted. What it names (an event, an anchor, an object) is left for `resolveStoryPanels`, because those may be added later. */
|
|
31
|
+
export interface CheckedPanel extends Omit<StoryPanel, "timeUtcMs" | "objectId"> {
|
|
32
|
+
readonly at: {
|
|
33
|
+
readonly timeUtcMs: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly event: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly anchor: string;
|
|
38
|
+
};
|
|
39
|
+
readonly object?: string;
|
|
40
|
+
}
|
|
41
|
+
/** What a story's settings may point a panel's time at, besides a plain UTC time. */
|
|
42
|
+
export interface PanelLookup {
|
|
43
|
+
readonly events: readonly {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly timeUtcMs: number;
|
|
46
|
+
}[];
|
|
47
|
+
/** Source anchors by id, when the experience has them. */
|
|
48
|
+
readonly anchors?: ReadonlyMap<string, number>;
|
|
49
|
+
/** Ids a panel's `object` may name. Absent: any id is accepted. */
|
|
50
|
+
readonly objectIds?: readonly string[];
|
|
51
|
+
/** When given, every panel must fall inside it. */
|
|
52
|
+
readonly window?: TimeBounds;
|
|
53
|
+
}
|
|
54
|
+
/** A panel's settings entry is wrong; the message names the panel and the field. */
|
|
55
|
+
export declare class StoryPanelError extends Error {
|
|
56
|
+
constructor(panel: string, field: string, problem: string);
|
|
57
|
+
}
|
|
58
|
+
/** Checks the shape of one panel, the `index`th of the list it came in. Nothing here looks at the scene: links are `resolveStoryPanels`' job. */
|
|
59
|
+
export declare function checkStoryPanel(raw: unknown, index: number): CheckedPanel;
|
|
60
|
+
/** Checks the two playback settings; a setting left out takes its default, so the result is the whole setting. */
|
|
61
|
+
export declare function checkPanelPlayback(raw: unknown): PanelPlayback;
|
|
62
|
+
/** Resolves each checked panel's time and links against the scene as built. Panels come back sorted by time. */
|
|
63
|
+
export declare function resolveStoryPanels(panels: readonly CheckedPanel[], playback: PanelPlayback, lookup: PanelLookup): StoryPanelSet;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { createProvenance, PROVENANCE_SOURCE_TYPES } from "./provenance.js";
|
|
2
|
+
import { timeInputMs } from "./timeInput.js";
|
|
3
|
+
export const DEFAULT_PANEL_PAUSE_SECONDS = 6;
|
|
4
|
+
export const MAX_PANEL_PAUSE_SECONDS = 20;
|
|
5
|
+
export const DEFAULT_PANEL_PLAYBACK = Object.freeze({ pauseSeconds: DEFAULT_PANEL_PAUSE_SECONDS, autoOpen: true });
|
|
6
|
+
/** A panel's settings entry is wrong; the message names the panel and the field. */
|
|
7
|
+
export class StoryPanelError extends Error {
|
|
8
|
+
constructor(panel, field, problem) {
|
|
9
|
+
super(`story panel ${panel}: ${field} ${problem}`);
|
|
10
|
+
this.name = "StoryPanelError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
14
|
+
function text(panel, field, value) {
|
|
15
|
+
if (typeof value !== "string" || value.trim() === "")
|
|
16
|
+
throw new StoryPanelError(panel, field, "must be non-empty text");
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
function lines(panel, field, value) {
|
|
20
|
+
const list = typeof value === "string" ? [value] : value;
|
|
21
|
+
if (!Array.isArray(list) || list.length === 0)
|
|
22
|
+
throw new StoryPanelError(panel, field, "must be one or more non-empty lines");
|
|
23
|
+
return list.map((line, index) => text(panel, `${field}[${index}]`, line));
|
|
24
|
+
}
|
|
25
|
+
function atOf(panel, at) {
|
|
26
|
+
if (!isRecord(at))
|
|
27
|
+
throw new StoryPanelError(panel, "at", "must name a time: { time }, { event } or { anchor }");
|
|
28
|
+
const keys = ["time", "event", "anchor"].filter((key) => at[key] !== undefined);
|
|
29
|
+
if (keys.length !== 1)
|
|
30
|
+
throw new StoryPanelError(panel, "at", "must give exactly one of time, event or anchor");
|
|
31
|
+
if (keys[0] === "event")
|
|
32
|
+
return { event: text(panel, "at.event", at.event) };
|
|
33
|
+
if (keys[0] === "anchor")
|
|
34
|
+
return { anchor: text(panel, "at.anchor", at.anchor) };
|
|
35
|
+
const timeUtcMs = timeInputMs(at.time);
|
|
36
|
+
if (!Number.isFinite(timeUtcMs))
|
|
37
|
+
throw new StoryPanelError(panel, "at.time", `must be a valid moment (ISO text, a Date or Unix milliseconds), got ${JSON.stringify(at.time)}`);
|
|
38
|
+
return { timeUtcMs };
|
|
39
|
+
}
|
|
40
|
+
function provenanceOf(panel, value) {
|
|
41
|
+
if (!isRecord(value))
|
|
42
|
+
throw new StoryPanelError(panel, "provenance", "must be an object: { sourceType, sources, accuracy, notes }");
|
|
43
|
+
if (!PROVENANCE_SOURCE_TYPES.includes(value.sourceType))
|
|
44
|
+
throw new StoryPanelError(panel, "provenance.sourceType", `must be one of ${PROVENANCE_SOURCE_TYPES.join(", ")}, got ${JSON.stringify(value.sourceType)}`);
|
|
45
|
+
if (!Array.isArray(value.sources))
|
|
46
|
+
throw new StoryPanelError(panel, "provenance.sources", "must be one or more non-empty lines");
|
|
47
|
+
lines(panel, "provenance.sources", value.sources);
|
|
48
|
+
text(panel, "provenance.accuracy", value.accuracy);
|
|
49
|
+
if (typeof value.notes !== "string")
|
|
50
|
+
throw new StoryPanelError(panel, "provenance.notes", "must be text");
|
|
51
|
+
return createProvenance(value);
|
|
52
|
+
}
|
|
53
|
+
/** Checks the shape of one panel, the `index`th of the list it came in. Nothing here looks at the scene: links are `resolveStoryPanels`' job. */
|
|
54
|
+
export function checkStoryPanel(raw, index) {
|
|
55
|
+
if (!isRecord(raw))
|
|
56
|
+
throw new StoryPanelError(`#${index + 1}`, "entry", "must be an object");
|
|
57
|
+
const id = text(`#${index + 1}`, "id", raw.id);
|
|
58
|
+
const object = raw.object === undefined ? undefined : text(id, "object", raw.object);
|
|
59
|
+
return {
|
|
60
|
+
id,
|
|
61
|
+
at: atOf(id, raw.at),
|
|
62
|
+
title: text(id, "title", raw.title),
|
|
63
|
+
body: lines(id, "body", raw.body),
|
|
64
|
+
details: raw.details === undefined ? [] : lines(id, "details", raw.details),
|
|
65
|
+
provenance: provenanceOf(id, raw.provenance),
|
|
66
|
+
...(object === undefined ? {} : { object }),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Checks the two playback settings; a setting left out takes its default, so the result is the whole setting. */
|
|
70
|
+
export function checkPanelPlayback(raw) {
|
|
71
|
+
if (!isRecord(raw))
|
|
72
|
+
throw new StoryPanelError("settings", "playback", "must be an object: { pauseSeconds?, autoOpen? }");
|
|
73
|
+
const pauseSeconds = raw.pauseSeconds ?? DEFAULT_PANEL_PLAYBACK.pauseSeconds;
|
|
74
|
+
if (typeof pauseSeconds !== "number" || !Number.isFinite(pauseSeconds) || pauseSeconds < 0 || pauseSeconds > MAX_PANEL_PAUSE_SECONDS) {
|
|
75
|
+
throw new StoryPanelError("settings", "pauseSeconds", `must be between 0 and ${MAX_PANEL_PAUSE_SECONDS}, got ${JSON.stringify(pauseSeconds)}`);
|
|
76
|
+
}
|
|
77
|
+
const autoOpen = raw.autoOpen ?? DEFAULT_PANEL_PLAYBACK.autoOpen;
|
|
78
|
+
if (typeof autoOpen !== "boolean")
|
|
79
|
+
throw new StoryPanelError("settings", "autoOpen", "must be true or false");
|
|
80
|
+
return { pauseSeconds, autoOpen };
|
|
81
|
+
}
|
|
82
|
+
function timeOf({ id, at }, lookup) {
|
|
83
|
+
if ("timeUtcMs" in at)
|
|
84
|
+
return at.timeUtcMs;
|
|
85
|
+
if ("event" in at) {
|
|
86
|
+
const event = lookup.events.find((candidate) => candidate.id === at.event);
|
|
87
|
+
if (event === undefined)
|
|
88
|
+
throw new StoryPanelError(id, "at.event", `names "${at.event}", which the experience's events lack`);
|
|
89
|
+
return event.timeUtcMs;
|
|
90
|
+
}
|
|
91
|
+
const anchor = lookup.anchors?.get(at.anchor);
|
|
92
|
+
if (anchor === undefined)
|
|
93
|
+
throw new StoryPanelError(id, "at.anchor", `names "${at.anchor}", which the experience's anchors lack`);
|
|
94
|
+
return anchor;
|
|
95
|
+
}
|
|
96
|
+
function resolvePanel(panel, lookup) {
|
|
97
|
+
const { id, title, body, details, provenance, object } = panel;
|
|
98
|
+
const timeUtcMs = timeOf(panel, lookup);
|
|
99
|
+
if (lookup.window !== undefined && (timeUtcMs < lookup.window.startUtcMs || timeUtcMs > lookup.window.endUtcMs)) {
|
|
100
|
+
throw new StoryPanelError(id, "at", "falls outside the timeline window");
|
|
101
|
+
}
|
|
102
|
+
if (object !== undefined && lookup.objectIds !== undefined && !lookup.objectIds.includes(object)) {
|
|
103
|
+
throw new StoryPanelError(id, "object", `names "${object}", which the experience lacks`);
|
|
104
|
+
}
|
|
105
|
+
return { id, timeUtcMs, title, body, details, provenance, ...(object === undefined ? {} : { objectId: object }) };
|
|
106
|
+
}
|
|
107
|
+
/** Resolves each checked panel's time and links against the scene as built. Panels come back sorted by time. */
|
|
108
|
+
export function resolveStoryPanels(panels, playback, lookup) {
|
|
109
|
+
const resolved = panels.map((panel) => resolvePanel(panel, lookup));
|
|
110
|
+
return { panels: resolved.sort((a, b) => a.timeUtcMs - b.timeUtcMs), ...playback };
|
|
111
|
+
}
|
|
@@ -53,6 +53,10 @@ export declare function samplePositionsKm(source: Trajectory, timesUtcMs: readon
|
|
|
53
53
|
* its end inclusive: 3 × count values. This is all a path is; no orbit maths lives here.
|
|
54
54
|
*/
|
|
55
55
|
export declare function samplePathKm(source: Trajectory, span: TimeBounds, count: number, center?: CenterId): Float64Array;
|
|
56
|
+
/** The turn search found no full turn within its steps; a `RangeError` so existing range handlers still see it. */
|
|
57
|
+
export declare class NoFullTurnError extends RangeError {
|
|
58
|
+
constructor(maxSteps: number, stepMs: number);
|
|
59
|
+
}
|
|
56
60
|
/**
|
|
57
61
|
* How long a state source takes to sweep one full turn about its centre, found by walking forward from `startUtcMs` in `stepMs` steps,
|
|
58
62
|
* adding the angle between successive positions, and interpolating inside the step that completes the turn. For a path that should
|
|
@@ -50,7 +50,7 @@ export function createTwoBodyTrajectory(input, adapter) {
|
|
|
50
50
|
assertWithinBounds(bounds, timeUtcMs);
|
|
51
51
|
const position = new Float64Array(3);
|
|
52
52
|
adapter.propagateMemberInto(states, 0, (timeUtcMs - epochUtcMs) / 1000, native, position);
|
|
53
|
-
return createState({ body, center: native, timeUtcMs,
|
|
53
|
+
return createState({ body, center: native, timeUtcMs, plane: EQJ, positionKm: position, orientation: null });
|
|
54
54
|
},
|
|
55
55
|
});
|
|
56
56
|
}
|
|
@@ -155,6 +155,13 @@ export function samplePositionsKm(source, timesUtcMs, center) {
|
|
|
155
155
|
export function samplePathKm(source, span, count, center) {
|
|
156
156
|
return samplePositionsKm(source, pathTimesUtcMs(span, count), center);
|
|
157
157
|
}
|
|
158
|
+
/** The turn search found no full turn within its steps; a `RangeError` so existing range handlers still see it. */
|
|
159
|
+
export class NoFullTurnError extends RangeError {
|
|
160
|
+
constructor(maxSteps, stepMs) {
|
|
161
|
+
super(`no full turn within ${maxSteps} steps of ${stepMs} ms`);
|
|
162
|
+
this.name = "NoFullTurnError";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
158
165
|
/**
|
|
159
166
|
* How long a state source takes to sweep one full turn about its centre, found by walking forward from `startUtcMs` in `stepMs` steps,
|
|
160
167
|
* adding the angle between successive positions, and interpolating inside the step that completes the turn. For a path that should
|
|
@@ -175,5 +182,5 @@ export function fullTurnSpanMs(source, startUtcMs, stepMs, maxSteps, center) {
|
|
|
175
182
|
swept += angle;
|
|
176
183
|
previous = next;
|
|
177
184
|
}
|
|
178
|
-
throw new
|
|
185
|
+
throw new NoFullTurnError(maxSteps, stepMs);
|
|
179
186
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A moment: ISO text, a Date, or Unix milliseconds. Declared here so `core/` records can take one; the public `TimeInput` is this type. */
|
|
2
|
+
export type TimeInput = string | number | Date;
|
|
3
|
+
/** The moment as Unix milliseconds, or NaN when it is not one. The one conversion every moment input goes through; each caller reports a bad moment in its own words. */
|
|
4
|
+
export declare function timeInputMs(time: TimeInput): number;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The moment as Unix milliseconds, or NaN when it is not one. The one conversion every moment input goes through; each caller reports a bad moment in its own words. */
|
|
2
|
+
export function timeInputMs(time) {
|
|
3
|
+
return time instanceof Date ? time.getTime() : typeof time === "number" ? time : Date.parse(time);
|
|
4
|
+
}
|
|
@@ -15,6 +15,8 @@ import "./phone.css";
|
|
|
15
15
|
import "./embedded.css";
|
|
16
16
|
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
17
17
|
export declare function initialObjectId(experience: ExperienceConfig, timeUtcMs: number): string;
|
|
18
|
+
/** Who moved the selection: the visitor, or a move of time or the view (named by whatever last moved them). */
|
|
19
|
+
export type SelectionOrigin = "visitor" | "move";
|
|
18
20
|
interface Props {
|
|
19
21
|
readonly experience: ExperienceConfig;
|
|
20
22
|
readonly snapshot: ClockSnapshot;
|
|
@@ -28,7 +30,14 @@ interface Props {
|
|
|
28
30
|
readonly onCameraRequest: (request: ExperienceCameraPreset["request"]) => void;
|
|
29
31
|
/** Holds the camera where it is, its target fixed in the scene (a view's `stay` rule); a later camera request replaces it. */
|
|
30
32
|
readonly onCameraHold?: () => void;
|
|
31
|
-
|
|
33
|
+
/** True when the host has set the camera since the last view switch: that call answers the switch, so the view's own camera rule does not replace it. */
|
|
34
|
+
readonly hostCameraSet?: () => boolean;
|
|
35
|
+
/** Filled with the shell's story seek note, so a host's time jump re-bases the panel crossing check exactly as a visitor's seek does. */
|
|
36
|
+
readonly storySeekNote?: {
|
|
37
|
+
current: ((timeUtcMs: number) => void) | null;
|
|
38
|
+
};
|
|
39
|
+
/** `origin` is required so a new selection path must say who chose: "visitor" (a menu choice, pick, preset or marker) or "move" (time or the view moved and the selection followed). */
|
|
40
|
+
readonly onSelectionChange: (objectId: string, origin: SelectionOrigin) => void;
|
|
32
41
|
readonly scaleId: ScaleId;
|
|
33
42
|
readonly onScaleChange: (id: ScaleId) => void;
|
|
34
43
|
readonly scaleChoices?: readonly ScaleChoice[];
|
|
@@ -45,6 +54,7 @@ interface Props {
|
|
|
45
54
|
};
|
|
46
55
|
/** Live measurements for an object's info panel, from the app's own State; empty when it has none. */
|
|
47
56
|
readonly metricsFor?: (objectId: string, timeUtcMs: number) => readonly Metric[];
|
|
57
|
+
/** The Developer drawer's content; absent: the shell shows no Developer toggle and no drawer (the host did not ask for developer tools). */
|
|
48
58
|
readonly developerTools?: ReactNode;
|
|
49
59
|
/** The live story-panel settings (auto-open, pause length); absent: the experience's own defaults. */
|
|
50
60
|
readonly storyPanelSettings?: StoryPanelSettings;
|
|
@@ -72,6 +82,12 @@ interface Props {
|
|
|
72
82
|
/** Called with the key of the place whose information is open, or null, so the app can mark its scene marker. */
|
|
73
83
|
readonly onOpenFeatureChange?: (key: string | null) => void;
|
|
74
84
|
/** Asks the shell to fly to an object a tap or click picked in the scene (focus only, no information); a new `serial` asks again. */
|
|
85
|
+
/** A host `setSelected` (id "" clears the selection), applied after the shell's own view-switch choices so the host's call is the last word; `onSelectRequestApplied` tells the app it has been. */
|
|
86
|
+
readonly selectRequest?: {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly serial: number;
|
|
89
|
+
} | null;
|
|
90
|
+
readonly onSelectRequestApplied?: () => void;
|
|
75
91
|
readonly pickRequest?: {
|
|
76
92
|
readonly id: string;
|
|
77
93
|
readonly serial: number;
|
|
@@ -79,5 +95,5 @@ interface Props {
|
|
|
79
95
|
readonly children: ReactNode;
|
|
80
96
|
}
|
|
81
97
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
82
|
-
export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }: Props): import("react").JSX.Element;
|
|
98
|
+
export declare function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout, highlightedFamily, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }: Props): import("react").JSX.Element;
|
|
83
99
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
4
|
import { useDrawers } from "./useDrawers.js";
|
|
5
5
|
import { useStoryPanels } from "./useStoryPanels.js";
|
|
@@ -47,12 +47,24 @@ function ownStorySettings(storySet) {
|
|
|
47
47
|
function ShellTimeline({ hidden, ...bar }) {
|
|
48
48
|
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
49
49
|
}
|
|
50
|
+
/** The Developer cog and its drawer; drawn only when the host gave the drawer's content (absent: neither, so an outside page never sees a developer cog). */
|
|
51
|
+
function DeveloperDrawer({ developerMode, onDeveloperModeChange, children }) {
|
|
52
|
+
const drawerId = `${useId()}-developer-tools`;
|
|
53
|
+
if (children === undefined)
|
|
54
|
+
return null;
|
|
55
|
+
return (_jsxs(_Fragment, { children: [_jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, drawerId: drawerId }), _jsx("aside", { className: "developer-tools", id: drawerId, "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? children : null })] }));
|
|
56
|
+
}
|
|
50
57
|
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
51
58
|
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
52
|
-
|
|
59
|
+
const sheetId = `${useId()}-moons-panel`;
|
|
60
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": sheetId, onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: sheetId, className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
53
61
|
onClose(); }, children: children })] }));
|
|
54
62
|
}
|
|
55
63
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
64
|
+
/** Whether the selection has been lost and a fallback must take its place: the object is gone or not available now, unless the host cleared the selection on purpose. */
|
|
65
|
+
function selectionLost(selected, timeUtcMs, clearedByHost) {
|
|
66
|
+
return !clearedByHost && (selected === undefined || !isObjectAvailable(selected, timeUtcMs));
|
|
67
|
+
}
|
|
56
68
|
function serialOf(request) {
|
|
57
69
|
return request?.serial;
|
|
58
70
|
}
|
|
@@ -84,14 +96,15 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
84
96
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
85
97
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
86
98
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
87
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
99
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
100
|
+
const infoPanelId = `${useId()}-info-panel`;
|
|
88
101
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
89
102
|
const phone = usePhone();
|
|
90
103
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
91
104
|
const [embedded] = useState(isEmbedded);
|
|
92
105
|
const root = useRef(null);
|
|
93
106
|
// The drawer (with the moons in it) and the bottom sheets want the same screen: the drawer, being the one just asked for, takes it.
|
|
94
|
-
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
107
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, root, () => {
|
|
95
108
|
if (experience.moonFamilies !== undefined) {
|
|
96
109
|
setInfo(null);
|
|
97
110
|
story.close();
|
|
@@ -104,6 +117,10 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
104
117
|
const storySet = experience.storyPanels;
|
|
105
118
|
const storyPanels = panelsOf(storySet);
|
|
106
119
|
const story = useStoryPanels(storyPanels, storyPanelSettings ?? ownStorySettings(storySet), snapshot, onSetPlaying);
|
|
120
|
+
if (storySeekNote !== undefined)
|
|
121
|
+
storySeekNote.current = story.noteSeek;
|
|
122
|
+
useEffect(() => () => { if (storySeekNote !== undefined)
|
|
123
|
+
storySeekNote.current = null; }, [storySeekNote]);
|
|
107
124
|
const openPanelId = story.openPanel?.id ?? null;
|
|
108
125
|
useEffect(() => { onOpenPanelChange?.(openPanelId); }, [onOpenPanelChange, openPanelId]);
|
|
109
126
|
const requestedSerial = serialOf(panelRequest);
|
|
@@ -132,24 +149,31 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
132
149
|
story.open(panel.id);
|
|
133
150
|
};
|
|
134
151
|
useEffect(() => {
|
|
135
|
-
onSelectionChange(selectedObjectId);
|
|
152
|
+
onSelectionChange(selectedObjectId, "visitor");
|
|
136
153
|
}, [onSelectionChange, selectedObjectId]);
|
|
154
|
+
/** The host cleared the selection: the fallback that picks the first available object stays off until something is selected again. */
|
|
155
|
+
const hostCleared = useRef(false);
|
|
137
156
|
// A view switch is told from other changes of the experience by the view's id changing.
|
|
138
157
|
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
139
158
|
useEffect(() => {
|
|
140
159
|
const switchRule = takeSwitchRule();
|
|
160
|
+
if (selectedObjectId !== "")
|
|
161
|
+
hostCleared.current = false;
|
|
141
162
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
142
|
-
if (
|
|
163
|
+
if (selectionLost(selected, snapshot.timeUtcMs, hostCleared.current && selectedObjectId === "")) {
|
|
143
164
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
144
165
|
setSelectedObjectId(fallbackId);
|
|
145
|
-
onSelectionChange(fallbackId);
|
|
166
|
+
onSelectionChange(fallbackId, "move");
|
|
146
167
|
// The card of an object the view took away closes with it.
|
|
147
168
|
if (switchRule !== undefined && selected === undefined)
|
|
148
169
|
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
149
170
|
}
|
|
150
171
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
151
172
|
const activeRequest = active?.request;
|
|
152
|
-
if (
|
|
173
|
+
if (switchRule?.rule === "start" && switchRule.framing?.always === true) {
|
|
174
|
+
applyViewRule(switchRule); // opted in: the view's framing applies on every switch to it
|
|
175
|
+
}
|
|
176
|
+
else if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
153
177
|
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
154
178
|
if (switchRule !== undefined && target === undefined) {
|
|
155
179
|
applyViewRule(switchRule);
|
|
@@ -164,6 +188,19 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
164
188
|
}
|
|
165
189
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
190
|
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs, viewId]);
|
|
191
|
+
// A host `setSelected`: runs after the view-switch effect above in the same commit, so it wins over that effect's fallback or view rule.
|
|
192
|
+
const requestedSelectSerial = serialOf(selectRequest);
|
|
193
|
+
useEffect(() => {
|
|
194
|
+
if (selectRequest === null || selectRequest === undefined)
|
|
195
|
+
return;
|
|
196
|
+
hostCleared.current = selectRequest.id === "";
|
|
197
|
+
setSelectedObjectId(selectRequest.id);
|
|
198
|
+
// As a visitor's menu choice does: the object's card opens (the camera is left alone); a clear closes it.
|
|
199
|
+
setInfo((now) => (selectRequest.id === "" ? (now?.kind === "object" ? null : now) : { kind: "object" }));
|
|
200
|
+
onSelectRequestApplied?.();
|
|
201
|
+
// Only a new request applies.
|
|
202
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
203
|
+
}, [requestedSelectSerial]);
|
|
167
204
|
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
168
205
|
const applyViewRule = (rule) => {
|
|
169
206
|
const asked = presetForViewRule(rule, experience);
|
|
@@ -172,9 +209,11 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
172
209
|
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
173
210
|
if (target !== undefined) {
|
|
174
211
|
setSelectedObjectId(target.id);
|
|
175
|
-
onSelectionChange(target.id);
|
|
212
|
+
onSelectionChange(target.id, "move"); // only the move-driven effect applies a view rule
|
|
176
213
|
}
|
|
177
214
|
setActivePresetId(preset?.id ?? null);
|
|
215
|
+
if (hostCameraSet?.() === true)
|
|
216
|
+
return; // a host camera call made since the switch answers it and wins over the rule
|
|
178
217
|
if (preset !== undefined)
|
|
179
218
|
onCameraRequest(preset.request);
|
|
180
219
|
else
|
|
@@ -212,7 +251,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
212
251
|
if (object === undefined)
|
|
213
252
|
return;
|
|
214
253
|
setSelectedObjectId(id);
|
|
215
|
-
onSelectionChange(id);
|
|
254
|
+
onSelectionChange(id, "visitor");
|
|
216
255
|
setInfo({ kind: "object" });
|
|
217
256
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
218
257
|
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
@@ -236,14 +275,14 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
236
275
|
if (target === undefined)
|
|
237
276
|
return;
|
|
238
277
|
setSelectedObjectId(target.id);
|
|
239
|
-
onSelectionChange(target.id);
|
|
278
|
+
onSelectionChange(target.id, "visitor");
|
|
240
279
|
}
|
|
241
280
|
setActivePresetId(preset.id);
|
|
242
281
|
onCameraRequest(preset.request);
|
|
243
282
|
};
|
|
244
283
|
const seekToEvent = (event) => {
|
|
245
284
|
seek(event.timeUtcMs);
|
|
246
|
-
// The event's own object, framed as the picker's Focus does (and `camera.
|
|
285
|
+
// The event's own object, framed as the picker's Focus does (and `camera.focus` opens): the event, never a default body, names it.
|
|
247
286
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
248
287
|
if (object !== undefined)
|
|
249
288
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
@@ -265,7 +304,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
265
304
|
useEffect(() => { if (info !== null)
|
|
266
305
|
setMoonsOpen(false); }, [info]);
|
|
267
306
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
268
|
-
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
307
|
+
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
269
308
|
const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(PanelLoadBoundary, { message: "The moon list could not load. Reload the page to try again.", children: _jsx(Suspense, { fallback: null, children: _jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }) }) }));
|
|
270
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(
|
|
309
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
271
310
|
}
|