astraeus 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +72 -9
- package/package.json +2 -1
- package/src/api/AstraeusScene.js +1 -1
- package/src/api/AstraeusScene.node.js +37 -0
- package/src/api/activity.d.ts +1 -1
- package/src/api/activity.js +1 -1
- package/src/api/bodies.d.ts +2 -0
- package/src/api/bodies.js +2 -0
- package/src/api/group.d.ts +7 -1
- package/src/api/index.d.ts +2 -1
- package/src/api/index.js +2 -1
- package/src/api/index.node.js +8 -0
- package/src/api/mount.js +3 -1
- package/src/api/mount.node.js +36 -0
- package/src/api/scene.d.ts +51 -10
- package/src/api/scene.js +216 -55
- package/src/api/story.d.ts +8 -2
- package/src/api/story.js +11 -0
- package/src/api/sunOrbit.d.ts +6 -0
- package/src/api/sunOrbit.js +24 -0
- package/src/app/App.d.ts +6 -2
- package/src/app/App.js +8 -4
- package/src/app/App.node.js +401 -0
- package/src/app/PanelLoadBoundary.d.ts +2 -1
- package/src/app/PanelLoadBoundary.js +2 -2
- package/src/app/SceneLabels.d.ts +2 -0
- package/src/app/SceneLabels.js +5 -1
- package/src/app/SkyView.d.ts +3 -3
- package/src/app/SkyView.js +19 -10
- package/src/app/TrackedBodyView.d.ts +9 -3
- package/src/app/TrackedBodyView.js +52 -13
- package/src/app/experienceDefinition.d.ts +8 -0
- package/src/app/mission.d.ts +2 -0
- package/src/app/pathRules.d.ts +7 -3
- package/src/app/pathRules.js +9 -5
- package/src/app/sceneContentsHooks.js +2 -2
- package/src/app/sceneDebug.d.ts +4 -2
- package/src/app/sceneFrame.js +5 -4
- package/src/app/sceneFraming.d.ts +13 -0
- package/src/app/sceneFraming.js +22 -0
- package/src/app/skyModel.js +1 -1
- package/src/assets/pictures.d.ts +1 -1
- package/src/assets/sky.d.ts +4 -4
- package/src/assets/sky.js +12 -13
- package/src/core/bodies/io.js +1 -1
- package/src/core/bodies/jupiterData.js +2 -2
- package/src/core/bodies/jupiterMoons.js +8 -12
- package/src/core/bodies/moon.d.ts +8 -0
- package/src/core/bodies/moon.js +28 -5
- package/src/core/bodies/outerPlanetData.js +7 -7
- package/src/core/bodies/planetMoons.js +18 -27
- package/src/core/bodies/swiftTuttle.js +2 -0
- package/src/core/elementsBody.d.ts +2 -0
- package/src/core/elementsBody.js +3 -0
- package/src/core/moonTrajectory.js +3 -5
- package/src/core/planetModels.js +1 -1
- package/src/core/provenance.d.ts +6 -2
- package/src/core/provenance.js +3 -1
- package/src/core/scalePolicy.d.ts +2 -0
- package/src/core/scalePolicy.js +2 -0
- package/src/shell/AstraeusShell.js +5 -3
- package/src/shell/AstraeusShell.node.js +225 -0
- package/src/shell/DisplaySwitches.js +1 -1
- package/src/shell/StoryPanelView.js +3 -1
- package/src/shell/TimelineBar.node.js +75 -0
- package/src/shell/TopBar.node.js +14 -0
- package/src/shell/experience.d.ts +2 -0
- package/src/shell/infoModel.js +3 -1
- package/src/shell/phone.css +1 -1
- package/src/shell/useDrawers.js +1 -1
- package/src/shell/useZoomThrough.d.ts +7 -0
- package/src/shell/useZoomThrough.js +51 -0
- package/src/synthetic/syntheticProbeDefinition.d.ts +5 -0
- package/src/synthetic/syntheticProbeDefinition.js +38 -0
package/src/core/bodies/moon.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { createProvenance } from "../provenance.js";
|
|
2
|
-
|
|
3
|
-
const
|
|
2
|
+
/** Source of the Moon's rotation constants (PROV-01). The 2015 report gives none for the Moon, so these are the 2009 report's, as NAIF saved them. */
|
|
3
|
+
export const MOON_IAU_REPORT = "Archinal et al., Report of the IAU Working Group on Cartographic Coordinates and Rotational Elements: 2009, Celestial Mechanics and Dynamical Astronomy 109, 101 (2011), as transcribed in NAIF pck00011.tpc (2022-12-27), BODY301 and BODY3_NUT_PREC_ANGLES";
|
|
4
|
+
/**
|
|
5
|
+
* The Moon's pole and prime meridian, including the report's libration terms E1 to E13 (the pole and W terms the report lists): degrees, pole per Julian
|
|
6
|
+
* century, W per day, from J2000 TDB. The report's -1.4e-12 d^2 term in W is left out (0.0005 degrees at 50 years from J2000). Body +X is longitude 0, +Z the pole.
|
|
7
|
+
*/
|
|
8
|
+
export const MOON_ROTATION = Object.freeze({
|
|
9
|
+
poleRaDeg: [269.9949, 0.0031],
|
|
10
|
+
poleDecDeg: [66.5392, 0.013],
|
|
11
|
+
primeMeridianDeg: [38.3213, 13.17635815],
|
|
12
|
+
periodic: Object.freeze({
|
|
13
|
+
anglesDeg: [
|
|
14
|
+
[125.045, -1935.5364525], [250.089, -3871.072905], [260.008, 475263.3328725], [176.625, 487269.629985],
|
|
15
|
+
[357.529, 35999.0509575], [311.589, 964468.49931], [134.963, 477198.869325], [276.617, 12006.300765],
|
|
16
|
+
[34.226, 63863.5132425], [15.134, -5806.6093575], [119.743, 131.84064], [239.961, 6003.1503825],
|
|
17
|
+
[25.053, 473327.79642],
|
|
18
|
+
],
|
|
19
|
+
poleRaDeg: [-3.8787, -0.1204, 0.07, -0.0172, 0, 0.0072, 0, 0, 0, -0.0052, 0, 0, 0.0043],
|
|
20
|
+
poleDecDeg: [1.5419, 0.0239, -0.0278, 0.0068, 0, -0.0029, 0.0009, 0, 0, 0.0008, 0, 0, -0.0009],
|
|
21
|
+
primeMeridianDeg: [3.561, 0.1208, -0.0642, 0.0158, 0.0252, -0.0066, -0.0047, -0.0046, 0.0028, 0.0052, 0.004, 0.0019, -0.0044],
|
|
22
|
+
}),
|
|
23
|
+
citation: MOON_IAU_REPORT,
|
|
24
|
+
});
|
|
25
|
+
const ROTATION_LIMITATION = "The Moon's orientation is the IAU mean-Earth rotation model with its libration terms, so the Moon shows libration in longitude and latitude. It is a published series, not the JPL lunar ephemeris: its sub-Earth point and pole differ from Horizons' by at most 0.01 degrees (about 0.3 km on the surface) at the seven dates from 1969 to 2050 that were checked, and its accuracy elsewhere is not stated by the source.";
|
|
26
|
+
const LANDING_SITE_OFFSET = "A landing site placed by the IAU model (a mission reconstruction's, measured at the Sea of Tranquility) sits 0.01 km (under 0.001 degrees) from the same selenographic coordinates on this Moon at touchdown, because the reconstruction and the drawn Moon use the same IAU model (docs/ASTRAEUS_SPIKE_02.md measured 254 km, 8.4 degrees, under the earlier tidal lock).";
|
|
4
27
|
export const MOON_EPHEMERIS = {
|
|
5
28
|
provenance: createProvenance({
|
|
6
29
|
sourceType: "ephemeris",
|
|
@@ -9,7 +32,7 @@ export const MOON_EPHEMERIS = {
|
|
|
9
32
|
notes: "Body size is the volumetric mean radius (NASA NSSDC fact sheet).",
|
|
10
33
|
}),
|
|
11
34
|
knownLimitations: [
|
|
12
|
-
|
|
35
|
+
ROTATION_LIMITATION,
|
|
13
36
|
"No velocity is modelled for the Moon, so it has no speed readout.",
|
|
14
37
|
],
|
|
15
38
|
};
|
|
@@ -20,7 +43,7 @@ export const MOON = Object.freeze({
|
|
|
20
43
|
radiusKm: 1737.4,
|
|
21
44
|
gmKm3S2: 4902.800066,
|
|
22
45
|
parentId: "earth",
|
|
23
|
-
orientation: "
|
|
46
|
+
orientation: "iau-rotation",
|
|
24
47
|
accuracy: Object.freeze({
|
|
25
48
|
dimensions: createProvenance({
|
|
26
49
|
sourceType: "observed",
|
|
@@ -31,6 +54,6 @@ export const MOON = Object.freeze({
|
|
|
31
54
|
position: MOON_EPHEMERIS.provenance,
|
|
32
55
|
// The sampled Horizons comparison range (tests/fixtures/moon-horizons.json); the truncated series states no validity range of its own.
|
|
33
56
|
validUtc: Object.freeze({ startUtcMs: Date.UTC(2022, 5, 1), endUtcMs: Date.UTC(2025, 5, 1) }),
|
|
34
|
-
orientationLimitations: Object.freeze([
|
|
57
|
+
orientationLimitations: Object.freeze([ROTATION_LIMITATION, LANDING_SITE_OFFSET]),
|
|
35
58
|
}),
|
|
36
59
|
});
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* (data/moons/<planet>.json, T-115) and the ring bands (data/rings/<planet>.json). Raw JSON: src/assets parses and checks them (layer rule:
|
|
4
4
|
* assets reach data through core), as `jupiterData.ts` does for Jupiter.
|
|
5
5
|
*/
|
|
6
|
-
import neptuneMoons from "../../../data/moons/neptune.json";
|
|
7
|
-
import plutoMoons from "../../../data/moons/pluto.json";
|
|
8
|
-
import saturnMoons from "../../../data/moons/saturn.json";
|
|
9
|
-
import uranusMoons from "../../../data/moons/uranus.json";
|
|
10
|
-
import neptuneRings from "../../../data/rings/neptune.json";
|
|
11
|
-
import saturnRings from "../../../data/rings/saturn.json";
|
|
12
|
-
import uranusRings from "../../../data/rings/uranus.json";
|
|
6
|
+
import neptuneMoons from "../../../data/moons/neptune.json" with { type: "json" };
|
|
7
|
+
import plutoMoons from "../../../data/moons/pluto.json" with { type: "json" };
|
|
8
|
+
import saturnMoons from "../../../data/moons/saturn.json" with { type: "json" };
|
|
9
|
+
import uranusMoons from "../../../data/moons/uranus.json" with { type: "json" };
|
|
10
|
+
import neptuneRings from "../../../data/rings/neptune.json" with { type: "json" };
|
|
11
|
+
import saturnRings from "../../../data/rings/saturn.json" with { type: "json" };
|
|
12
|
+
import uranusRings from "../../../data/rings/uranus.json" with { type: "json" };
|
|
13
13
|
export const SATURN_MOON_CATALOGUE_FILE = saturnMoons;
|
|
14
14
|
export const URANUS_MOON_CATALOGUE_FILE = uranusMoons;
|
|
15
15
|
export const NEPTUNE_MOON_CATALOGUE_FILE = neptuneMoons;
|
|
@@ -3,24 +3,15 @@ import { createPlanetSunTrajectory } from "./planetTrajectory.js";
|
|
|
3
3
|
import { MARS } from "./mars.js";
|
|
4
4
|
import { createMoonSystem, moonFitSource } from "./moonSystem.js";
|
|
5
5
|
import { NEPTUNE, PLUTO, PLUTO_ROTATION, SATURN, URANUS } from "./outerPlanets.js";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import
|
|
15
|
-
const { rotation: mimasRotation } = json9;
|
|
16
|
-
import json10 from "../../../data/orbits/rhea.json";
|
|
17
|
-
const { rotation: rheaRotation } = json10;
|
|
18
|
-
import json11 from "../../../data/orbits/tethys.json";
|
|
19
|
-
const { rotation: tethysRotation } = json11;
|
|
20
|
-
import json12 from "../../../data/orbits/titan.json";
|
|
21
|
-
const { rotation: titanRotation } = json12;
|
|
22
|
-
import json13 from "../../../data/orbits/triton.json";
|
|
23
|
-
const { rotation: tritonRotation } = json13;
|
|
6
|
+
import charonOrbit from "../../../data/orbits/charon.json" with { type: "json" };
|
|
7
|
+
import dioneOrbit from "../../../data/orbits/dione.json" with { type: "json" };
|
|
8
|
+
import enceladusOrbit from "../../../data/orbits/enceladus.json" with { type: "json" };
|
|
9
|
+
import iapetusOrbit from "../../../data/orbits/iapetus.json" with { type: "json" };
|
|
10
|
+
import mimasOrbit from "../../../data/orbits/mimas.json" with { type: "json" };
|
|
11
|
+
import rheaOrbit from "../../../data/orbits/rhea.json" with { type: "json" };
|
|
12
|
+
import tethysOrbit from "../../../data/orbits/tethys.json" with { type: "json" };
|
|
13
|
+
import titanOrbit from "../../../data/orbits/titan.json" with { type: "json" };
|
|
14
|
+
import tritonOrbit from "../../../data/orbits/triton.json" with { type: "json" };
|
|
24
15
|
export const MARS_MOON_SYSTEM = createMoonSystem({
|
|
25
16
|
centre: "mars", centreLabel: "Mars", centreGmKm3S2: MARS.gmKm3S2, ephemerisName: "mar099", fitSource: moonFitSource("Mars")
|
|
26
17
|
});
|
|
@@ -58,15 +49,15 @@ export const PLANET_MOON_DEFINITIONS = Object.freeze([PHOBOS, DEIMOS, MIMAS, ENC
|
|
|
58
49
|
export const PLANET_MOON_BINDINGS = Object.freeze([
|
|
59
50
|
MARS_MOON_SYSTEM.binding(PHOBOS.id),
|
|
60
51
|
MARS_MOON_SYSTEM.binding(DEIMOS.id),
|
|
61
|
-
SATURN_MOON_SYSTEM.binding(MIMAS.id, iauElementsFromRecord(
|
|
62
|
-
SATURN_MOON_SYSTEM.binding(ENCELADUS.id, iauElementsFromRecord(
|
|
63
|
-
SATURN_MOON_SYSTEM.binding(TETHYS.id, iauElementsFromRecord(
|
|
64
|
-
SATURN_MOON_SYSTEM.binding(DIONE.id, iauElementsFromRecord(
|
|
65
|
-
SATURN_MOON_SYSTEM.binding(RHEA.id, iauElementsFromRecord(
|
|
66
|
-
SATURN_MOON_SYSTEM.binding(TITAN.id, iauElementsFromRecord(
|
|
67
|
-
SATURN_MOON_SYSTEM.binding(IAPETUS.id, iauElementsFromRecord(
|
|
68
|
-
NEPTUNE_MOON_SYSTEM.binding(TRITON.id, iauElementsFromRecord(
|
|
69
|
-
PLUTO_MOON_SYSTEM.binding(CHARON.id, iauElementsFromRecord(
|
|
52
|
+
SATURN_MOON_SYSTEM.binding(MIMAS.id, iauElementsFromRecord(mimasOrbit.rotation)),
|
|
53
|
+
SATURN_MOON_SYSTEM.binding(ENCELADUS.id, iauElementsFromRecord(enceladusOrbit.rotation)),
|
|
54
|
+
SATURN_MOON_SYSTEM.binding(TETHYS.id, iauElementsFromRecord(tethysOrbit.rotation)),
|
|
55
|
+
SATURN_MOON_SYSTEM.binding(DIONE.id, iauElementsFromRecord(dioneOrbit.rotation)),
|
|
56
|
+
SATURN_MOON_SYSTEM.binding(RHEA.id, iauElementsFromRecord(rheaOrbit.rotation)),
|
|
57
|
+
SATURN_MOON_SYSTEM.binding(TITAN.id, iauElementsFromRecord(titanOrbit.rotation)),
|
|
58
|
+
SATURN_MOON_SYSTEM.binding(IAPETUS.id, iauElementsFromRecord(iapetusOrbit.rotation)),
|
|
59
|
+
NEPTUNE_MOON_SYSTEM.binding(TRITON.id, iauElementsFromRecord(tritonOrbit.rotation)),
|
|
60
|
+
PLUTO_MOON_SYSTEM.binding(CHARON.id, iauElementsFromRecord(charonOrbit.rotation)),
|
|
70
61
|
]);
|
|
71
62
|
/**
|
|
72
63
|
* Pluto's own offset from the system barycentre at `timeUtcMs`, from its system's centre series, or null while the system is not loaded or the
|
|
@@ -96,6 +96,8 @@ export const SWIFT_TUTTLE = Object.freeze({
|
|
|
96
96
|
sources: [SWIFT_TUTTLE_ELEMENTS.citation, "Two-body motion about the Sun's gravitational parameter (catalogue)", "Compared with JPL Horizons, target DES=109P;CAP (solution JPL#32), centre 500@10, ICRF"],
|
|
97
97
|
accuracy: `Position was compared with JPL Horizons at eight dates from 1990 to 2030: the largest Sun-centred difference is about ${SWIFT_TUTTLE_MAX_ERROR_KM.toLocaleString("en-US")} km (${(SWIFT_TUTTLE_MAX_ERROR_FRACTION * 100).toFixed(2)}% of its distance from the Sun at that date), so this is an approximate position for drawing the orbit and the comet's place on it, not an ephemeris. This is the largest difference at the eight dates compared, not a bound for every date.`,
|
|
98
98
|
notes: "Geometric position about the Sun's centre; no light-time. Elements are osculating at the epoch.",
|
|
99
|
+
accuracyClass: "approximate",
|
|
100
|
+
maxErrorFraction: SWIFT_TUTTLE_MAX_ERROR_FRACTION,
|
|
99
101
|
}),
|
|
100
102
|
validUtc: COMPARED_UTC,
|
|
101
103
|
orientationLimitations: SWIFT_TUTTLE_LIMITATIONS,
|
|
@@ -9,10 +9,12 @@ export declare const DEFAULT_ELEMENTS_MARKER_SIZE_PX = 7;
|
|
|
9
9
|
* within the larger one, "indicative". Both are good enough to draw where the body is on its orbit at overview scale and neither is an ephemeris.
|
|
10
10
|
*/
|
|
11
11
|
export declare const APPROXIMATE_LIMIT_FRACTION = 0.01;
|
|
12
|
+
/** The larger limit of the same rule: within 5% of the body's distance from the Sun at every compared date is "indicative". */
|
|
12
13
|
export declare const INDICATIVE_LIMIT_FRACTION = 0.05;
|
|
13
14
|
/** The classification a largest error fraction earns, or null when it earns neither (the body should not be drawn from its elements alone). */
|
|
14
15
|
export declare function classifyPositionError(maxFraction: number): AccuracyClassification | null;
|
|
15
16
|
export type ElementsTimeScale = "TDB" | "TT" | "UTC";
|
|
17
|
+
/** The class a position comparison earns: `"approximate"` or `"indicative"` (see `classifyPositionError`). */
|
|
16
18
|
export type AccuracyClassification = "approximate" | "indicative";
|
|
17
19
|
/** A cited fact: the solution it came from, where it was read, and when. */
|
|
18
20
|
export interface ElementsSource {
|
package/src/core/elementsBody.js
CHANGED
|
@@ -15,6 +15,7 @@ export const DEFAULT_ELEMENTS_MARKER_SIZE_PX = 7;
|
|
|
15
15
|
* within the larger one, "indicative". Both are good enough to draw where the body is on its orbit at overview scale and neither is an ephemeris.
|
|
16
16
|
*/
|
|
17
17
|
export const APPROXIMATE_LIMIT_FRACTION = 0.01;
|
|
18
|
+
/** The larger limit of the same rule: within 5% of the body's distance from the Sun at every compared date is "indicative". */
|
|
18
19
|
export const INDICATIVE_LIMIT_FRACTION = 0.05;
|
|
19
20
|
/** The classification a largest error fraction earns, or null when it earns neither (the body should not be drawn from its elements alone). */
|
|
20
21
|
export function classifyPositionError(maxFraction) {
|
|
@@ -183,6 +184,8 @@ export function buildElementsBody(input, centre) {
|
|
|
183
184
|
sources: [citation, `Two-body motion about the gravitational parameter of "${centre.id}" (catalogue)`],
|
|
184
185
|
accuracy: `${body.accuracy.classification}: ${body.accuracy.statement}`,
|
|
185
186
|
notes: "Geometric position about the Sun's centre; no light-time. Elements are osculating at the epoch.",
|
|
187
|
+
accuracyClass: body.accuracy.classification,
|
|
188
|
+
maxErrorFraction: body.accuracy.classification === "approximate" ? APPROXIMATE_LIMIT_FRACTION : INDICATIVE_LIMIT_FRACTION,
|
|
186
189
|
}),
|
|
187
190
|
validUtc: Object.freeze({ startUtcMs: Date.parse(body.accuracy.validFromUtc), endUtcMs: Date.parse(body.accuracy.validToUtc) }),
|
|
188
191
|
orientationLimitations: Object.freeze([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MOON_ROTATION } from "./bodies/moon.js";
|
|
2
|
+
import { iauOrientation } from "./iauRotation.js";
|
|
2
3
|
import { assertUtcUnixMs, createState, EQJ } from "./state.js";
|
|
3
|
-
const ORIENTATION_SAMPLE_SECONDS = 1800;
|
|
4
4
|
/** The Moon in its one native centre, Earth. Any other centre is the state resolver's composition, not this provider's. */
|
|
5
5
|
export class MoonTrajectory {
|
|
6
6
|
adapter;
|
|
@@ -13,9 +13,7 @@ export class MoonTrajectory {
|
|
|
13
13
|
if (center !== "earth")
|
|
14
14
|
throw new RangeError("Moon trajectory center must be Earth; the state resolver recentres it");
|
|
15
15
|
const moonFromEarthKm = this.adapter.moonPositionKm(timeUtcMs);
|
|
16
|
-
const
|
|
17
|
-
const later = this.adapter.moonPositionKm(timeUtcMs + ORIENTATION_SAMPLE_SECONDS * 1000);
|
|
18
|
-
const orientation = moonOrientationFromOrbit(moonFromEarthKm, earlier, later);
|
|
16
|
+
const orientation = iauOrientation(MOON_ROTATION, this.adapter.daysSinceJ2000Tt(timeUtcMs));
|
|
19
17
|
return createState({
|
|
20
18
|
body: "moon",
|
|
21
19
|
center: "earth",
|
package/src/core/planetModels.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fits from "../../data/ephemerides/planets/planets.json";
|
|
1
|
+
import fits from "../../data/ephemerides/planets/planets.json" with { type: "json" };
|
|
2
2
|
import { chunkCovers, chunkPositionInto, decodeChunk } from "./chebyshevSeries.js";
|
|
3
3
|
import { PLANET_IDS } from "./planetSeries.js";
|
|
4
4
|
import { assertTimeScaleTable, ttMinusUtcSeconds } from "./timeScale.js";
|
package/src/core/provenance.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
/** What kind of source a path or body position comes from. */
|
|
2
|
-
export type ProvenanceSourceType = "ephemeris" | "observed" | "reconstructed" | "illustrative";
|
|
1
|
+
/** What kind of source a path or body position comes from. `"modelled"` is a computed result of a stated model (shown as "Modelled", the same word as the story-panel badge). */
|
|
2
|
+
export type ProvenanceSourceType = "ephemeris" | "observed" | "reconstructed" | "modelled" | "illustrative";
|
|
3
3
|
/** Where a path or body position came from and how far to trust it: `sourceType`, the `sources`, the `accuracy` and `notes`. Pass one as `addTrajectory({ provenance })`. Never affects State. */
|
|
4
4
|
export interface Provenance {
|
|
5
5
|
readonly sourceType: ProvenanceSourceType;
|
|
6
6
|
readonly sources: readonly string[];
|
|
7
7
|
readonly accuracy: string;
|
|
8
8
|
readonly notes: string;
|
|
9
|
+
/** For a position compared with an independent ephemeris: the class the comparison earned (`"approximate"` within 1% of the body's distance from the Sun, `"indicative"` within 5%). Absent for a body that has no such comparison. */
|
|
10
|
+
readonly accuracyClass?: "approximate" | "indicative";
|
|
11
|
+
/** The largest difference found, or the limit of the class, as a fraction of the body's distance from the Sun at the compared date (0.00857 is 0.857%). Absent with `accuracyClass`. */
|
|
12
|
+
readonly maxErrorFraction?: number;
|
|
9
13
|
}
|
|
10
14
|
export declare function createProvenance(input: Provenance): Provenance;
|
package/src/core/provenance.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const SOURCE_TYPES = ["ephemeris", "observed", "reconstructed", "illustrative"];
|
|
1
|
+
const SOURCE_TYPES = ["ephemeris", "observed", "reconstructed", "modelled", "illustrative"];
|
|
2
2
|
export function createProvenance(input) {
|
|
3
3
|
if (!SOURCE_TYPES.includes(input.sourceType))
|
|
4
4
|
throw new RangeError("provenance sourceType is not recognised");
|
|
@@ -10,5 +10,7 @@ export function createProvenance(input) {
|
|
|
10
10
|
sources: Object.freeze([...input.sources]),
|
|
11
11
|
accuracy: input.accuracy,
|
|
12
12
|
notes: input.notes,
|
|
13
|
+
...(input.accuracyClass === undefined ? {} : { accuracyClass: input.accuracyClass }),
|
|
14
|
+
...(input.maxErrorFraction === undefined ? {} : { maxErrorFraction: input.maxErrorFraction }),
|
|
13
15
|
});
|
|
14
16
|
}
|
|
@@ -44,4 +44,6 @@ export interface SolarSystemScalePolicy extends ScalePolicy {
|
|
|
44
44
|
readonly explanation: string;
|
|
45
45
|
}
|
|
46
46
|
export declare function createSolarSystemScale(options: SolarSystemScaleOptions): SolarSystemScalePolicy;
|
|
47
|
+
/** The Solar system scale: true distances with bodies enlarged. This one enlarges nothing itself; a viewer builds the working policy from the scene's declared factors, and `Scene.setScale` accepts it for a Sun-centred scene with an enlarged body. */
|
|
48
|
+
export declare const solarSystemScale: SolarSystemScalePolicy;
|
|
47
49
|
export {};
|
package/src/core/scalePolicy.js
CHANGED
|
@@ -58,3 +58,5 @@ export function createSolarSystemScale(options) {
|
|
|
58
58
|
mapRadius: (radiusKm, bodyId) => trueScale.mapRadius(radiusKm) * factorFor(bodyId),
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
/** The Solar system scale: true distances with bodies enlarged. This one enlarges nothing itself; a viewer builds the working policy from the scene's declared factors, and `Scene.setScale` accepts it for a Sun-centred scene with an enlarged body. */
|
|
62
|
+
export const solarSystemScale = createSolarSystemScale({ exaggeration: {}, defaultExaggeration: 1 });
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, 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";
|
|
6
6
|
import { TimelineBar } from "./TimelineBar.js";
|
|
7
7
|
import { InfoPanel } from "./InfoPanel.js";
|
|
8
8
|
import { infoView } from "./infoModel.js";
|
|
9
|
-
import {
|
|
9
|
+
import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
10
10
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
11
|
import { isEmbedded } from "./embedded.js";
|
|
12
12
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
@@ -69,6 +69,8 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
69
69
|
const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
70
70
|
return { view, metrics };
|
|
71
71
|
}
|
|
72
|
+
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
73
|
+
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
72
74
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
73
75
|
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
74
76
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
@@ -222,6 +224,6 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
222
224
|
setMoonsOpen(false); }, [info]);
|
|
223
225
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
224
226
|
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 }));
|
|
225
|
-
const moonPanel = experience.moonFamilies === undefined ? null : (_jsx(MoonFamilyPanel, { list: experience.moonFamilies, highlightedFamily: highlightedFamily, onHighlight: (id) => onHighlightFamily?.(id), onSelectMoon: chooseMoon }));
|
|
227
|
+
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 }) }) }));
|
|
226
228
|
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(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange }), _jsx("aside", { className: "developer-tools", id: "developer-tools", "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? developerTools : null }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, 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, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
227
229
|
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { lazy, Suspense, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
|
+
import { useDrawers } from "./useDrawers.js";
|
|
5
|
+
import { useStoryPanels } from "./useStoryPanels.js";
|
|
6
|
+
import { TimelineBar } from "./TimelineBar.node.js";
|
|
7
|
+
import { InfoPanel } from "./InfoPanel.js";
|
|
8
|
+
import { infoView } from "./infoModel.js";
|
|
9
|
+
import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
10
|
+
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
|
+
import { isEmbedded } from "./embedded.js";
|
|
12
|
+
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
|
+
import { DeveloperToggle, TopBar } from "./TopBar.node.js";
|
|
14
|
+
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
15
|
+
/** Keeps `--timeline-space` at the distance from the screen's bottom to the top of the timeline bar, so a phone sheet can sit above it. */
|
|
16
|
+
function useTimelineSpace(root, phone) {
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const shell = root.current;
|
|
19
|
+
const bar = shell?.querySelector(".timeline-bar") ?? null;
|
|
20
|
+
if (shell === null || bar === null || typeof ResizeObserver === "undefined")
|
|
21
|
+
return undefined;
|
|
22
|
+
const measure = () => shell.style.setProperty("--timeline-space", `${Math.ceil(window.innerHeight - bar.getBoundingClientRect().top)}px`);
|
|
23
|
+
measure();
|
|
24
|
+
const observer = new ResizeObserver(measure);
|
|
25
|
+
observer.observe(bar);
|
|
26
|
+
window.addEventListener("resize", measure);
|
|
27
|
+
return () => { observer.disconnect(); window.removeEventListener("resize", measure); shell.style.removeProperty("--timeline-space"); };
|
|
28
|
+
}, [root, phone]);
|
|
29
|
+
}
|
|
30
|
+
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
31
|
+
function initialObjectId(experience, timeUtcMs) {
|
|
32
|
+
const start = experience.cameraPresets.find((preset) => preset.id === experience.startCameraPresetId)?.request;
|
|
33
|
+
if (start !== undefined && start.kind !== "overview" && experience.objects.some((object) => object.id === start.target))
|
|
34
|
+
return start.target;
|
|
35
|
+
return firstAvailableObject(experience, timeUtcMs)?.id ?? experience.objects[0]?.id ?? "";
|
|
36
|
+
}
|
|
37
|
+
/** The story-panel settings the experience carries itself, used when the app gives none live. */
|
|
38
|
+
function ownStorySettings(storySet) {
|
|
39
|
+
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
|
|
40
|
+
}
|
|
41
|
+
/** The timeline bar, or nothing when the experience says it has no timeline. */
|
|
42
|
+
function ShellTimeline({ hidden, ...bar }) {
|
|
43
|
+
return hidden ? null : _jsx(TimelineBar, { ...bar });
|
|
44
|
+
}
|
|
45
|
+
/** The wide-screen moons toggle and the sheet it opens under the toolbar. */
|
|
46
|
+
function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
47
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "moons-toggle ui-pill", "aria-expanded": open, "aria-controls": "moons-panel", onClick: onToggle, children: [planetLabel, " moons"] }), _jsx("aside", { id: "moons-panel", className: "moons-sheet", "data-open": open, "aria-label": "Moons by family", onKeyDown: (event) => { if (event.key === "Escape")
|
|
48
|
+
onClose(); }, children: children })] }));
|
|
49
|
+
}
|
|
50
|
+
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
51
|
+
function serialOf(request) {
|
|
52
|
+
return request?.serial;
|
|
53
|
+
}
|
|
54
|
+
function panelsOf(storySet) {
|
|
55
|
+
return storySet?.panels ?? [];
|
|
56
|
+
}
|
|
57
|
+
function objectLabelOr(experience, objectId, fallback) {
|
|
58
|
+
return experience.objects.find((object) => object.id === objectId)?.label ?? fallback;
|
|
59
|
+
}
|
|
60
|
+
/** The information panel's content and, for an object, its live measurements. */
|
|
61
|
+
function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor) {
|
|
62
|
+
const view = info === null
|
|
63
|
+
? null
|
|
64
|
+
: infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs);
|
|
65
|
+
const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
66
|
+
return { view, metrics };
|
|
67
|
+
}
|
|
68
|
+
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
69
|
+
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
70
|
+
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
71
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
72
|
+
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
73
|
+
const phone = usePhone();
|
|
74
|
+
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
75
|
+
const [embedded] = useState(isEmbedded);
|
|
76
|
+
const root = useRef(null);
|
|
77
|
+
// 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.
|
|
78
|
+
const { controlsOpen, timelineOpen, openControls, openTimeline } = useDrawers(phone, () => {
|
|
79
|
+
if (experience.moonFamilies !== undefined) {
|
|
80
|
+
setInfo(null);
|
|
81
|
+
story.close();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
useTimelineSpace(root, phone);
|
|
85
|
+
const [activePresetId, setActivePresetId] = useState(experience.startCameraPresetId ?? null);
|
|
86
|
+
/** The object panel follows the selected object; an event panel names its event. */
|
|
87
|
+
const [info, setInfo] = useState(null);
|
|
88
|
+
const storySet = experience.storyPanels;
|
|
89
|
+
const storyPanels = panelsOf(storySet);
|
|
90
|
+
const story = useStoryPanels(storyPanels, storyPanelSettings ?? ownStorySettings(storySet), snapshot, onSetPlaying);
|
|
91
|
+
const openPanelId = story.openPanel?.id ?? null;
|
|
92
|
+
useEffect(() => { onOpenPanelChange?.(openPanelId); }, [onOpenPanelChange, openPanelId]);
|
|
93
|
+
const requestedSerial = serialOf(panelRequest);
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (panelRequest !== null && panelRequest !== undefined)
|
|
96
|
+
story.open(panelRequest.id);
|
|
97
|
+
// Only a new request opens a panel; the open function is stable.
|
|
98
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
99
|
+
}, [requestedSerial]);
|
|
100
|
+
const requestedFeatureSerial = serialOf(featureRequest);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (featureRequest !== null && featureRequest !== undefined)
|
|
103
|
+
setInfo({ kind: "feature", id: featureRequest.key });
|
|
104
|
+
// Only a new request opens a place.
|
|
105
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
|
+
}, [requestedFeatureSerial]);
|
|
107
|
+
const openFeatureKey = info?.kind === "feature" ? info.id : null;
|
|
108
|
+
useEffect(() => { onOpenFeatureChange?.(openFeatureKey); }, [onOpenFeatureChange, openFeatureKey]);
|
|
109
|
+
/** Every time change a person makes goes through here, so a seek is never mistaken for playback crossing a panel. */
|
|
110
|
+
const seek = (timeUtcMs) => {
|
|
111
|
+
story.noteSeek(timeUtcMs);
|
|
112
|
+
onSeek(timeUtcMs);
|
|
113
|
+
};
|
|
114
|
+
const openPanelFromTimeline = (panel) => {
|
|
115
|
+
seek(panel.timeUtcMs);
|
|
116
|
+
story.open(panel.id);
|
|
117
|
+
};
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
onSelectionChange(selectedObjectId);
|
|
120
|
+
}, [onSelectionChange, selectedObjectId]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
123
|
+
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
124
|
+
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
125
|
+
setSelectedObjectId(fallbackId);
|
|
126
|
+
onSelectionChange(fallbackId);
|
|
127
|
+
}
|
|
128
|
+
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
129
|
+
const activeRequest = active?.request;
|
|
130
|
+
if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
131
|
+
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
132
|
+
if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
|
|
133
|
+
const overview = findCameraPreset(experience, "overview");
|
|
134
|
+
if (overview !== undefined) {
|
|
135
|
+
setActivePresetId(overview.id);
|
|
136
|
+
onCameraRequest(overview.request);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs]);
|
|
141
|
+
const [moonsOpen, setMoonsOpen] = useState(false);
|
|
142
|
+
/** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
|
|
143
|
+
const chooseMoon = (id) => {
|
|
144
|
+
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
145
|
+
if (object === undefined)
|
|
146
|
+
return;
|
|
147
|
+
activatePreset(focusPresetFor(experience, object));
|
|
148
|
+
setInfo({ kind: "object" });
|
|
149
|
+
};
|
|
150
|
+
/** An object tapped or clicked in the scene: the picker's focus; on a wide screen it also opens the card, on a phone it does not (T-138). A tapped body-set member that is no listed object just flies there. */
|
|
151
|
+
const pickObject = (id) => {
|
|
152
|
+
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
153
|
+
if (object !== undefined) {
|
|
154
|
+
activatePreset(focusPresetFor(experience, object));
|
|
155
|
+
if (pickOpensInfo(phone))
|
|
156
|
+
setInfo({ kind: "object" });
|
|
157
|
+
}
|
|
158
|
+
else if (!experience.objects.some((candidate) => candidate.id === id))
|
|
159
|
+
onCameraRequest({ kind: "focus", target: id });
|
|
160
|
+
};
|
|
161
|
+
const requestedPickSerial = serialOf(pickRequest);
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (pickRequest !== null && pickRequest !== undefined)
|
|
164
|
+
pickObject(pickRequest.id);
|
|
165
|
+
// Only a new request flies; the handler reads the current time and experience.
|
|
166
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
167
|
+
}, [requestedPickSerial]);
|
|
168
|
+
const selectObject = (id) => {
|
|
169
|
+
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
170
|
+
if (object === undefined)
|
|
171
|
+
return;
|
|
172
|
+
setSelectedObjectId(id);
|
|
173
|
+
onSelectionChange(id);
|
|
174
|
+
setInfo({ kind: "object" });
|
|
175
|
+
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
176
|
+
if (active?.request.kind === "focus" || active?.request.kind === "follow") {
|
|
177
|
+
const next = findCameraPreset(experience, active.request.kind, id)
|
|
178
|
+
?? (active.request.kind === "follow" ? findCameraPreset(experience, "focus", id) : undefined);
|
|
179
|
+
if (next !== undefined) {
|
|
180
|
+
setActivePresetId(next.id);
|
|
181
|
+
onCameraRequest(next.request);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
const overview = findCameraPreset(experience, "overview");
|
|
185
|
+
setActivePresetId(overview?.id ?? null);
|
|
186
|
+
if (overview !== undefined)
|
|
187
|
+
onCameraRequest(overview.request);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const activatePreset = (preset) => {
|
|
192
|
+
if (preset.request.kind !== "overview") {
|
|
193
|
+
const target = availableObjectById(experience, preset.request.target, snapshot.timeUtcMs);
|
|
194
|
+
if (target === undefined)
|
|
195
|
+
return;
|
|
196
|
+
setSelectedObjectId(target.id);
|
|
197
|
+
onSelectionChange(target.id);
|
|
198
|
+
}
|
|
199
|
+
setActivePresetId(preset.id);
|
|
200
|
+
onCameraRequest(preset.request);
|
|
201
|
+
};
|
|
202
|
+
const seekToEvent = (event) => {
|
|
203
|
+
seek(event.timeUtcMs);
|
|
204
|
+
if (info?.kind === "event")
|
|
205
|
+
setInfo({ kind: "event", id: event.id });
|
|
206
|
+
};
|
|
207
|
+
const seekToWindow = (window, timeUtcMs) => {
|
|
208
|
+
seek(timeUtcMs);
|
|
209
|
+
if (info?.kind === "window")
|
|
210
|
+
setInfo({ kind: "window", id: window.id });
|
|
211
|
+
};
|
|
212
|
+
const { view, metrics } = infoContent(experience, info, selectedObjectId, snapshot.timeUtcMs, metricsFor);
|
|
213
|
+
// On a wide screen the moons sheet and the information panel share the left column under the toolbar: opening one closes the other.
|
|
214
|
+
const toggleMoons = () => {
|
|
215
|
+
if (!moonsOpen)
|
|
216
|
+
setInfo(null);
|
|
217
|
+
setMoonsOpen(!moonsOpen);
|
|
218
|
+
};
|
|
219
|
+
useEffect(() => { if (info !== null)
|
|
220
|
+
setMoonsOpen(false); }, [info]);
|
|
221
|
+
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
222
|
+
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 }));
|
|
223
|
+
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 }) }) }));
|
|
224
|
+
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(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange }), _jsx("aside", { className: "developer-tools", id: "developer-tools", "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? developerTools : null }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, 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, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
225
|
+
}
|
|
@@ -21,7 +21,7 @@ function SwitchPanel({ switches }) {
|
|
|
21
21
|
return undefined;
|
|
22
22
|
const outside = (event) => { if (!root.current?.contains(event.target))
|
|
23
23
|
setOpen(false); };
|
|
24
|
-
const escape = (event) => { if (event.key === "Escape")
|
|
24
|
+
const escape = (event) => { if (!event.defaultPrevented && event.key === "Escape")
|
|
25
25
|
setOpen(false); };
|
|
26
26
|
document.addEventListener("pointerdown", outside);
|
|
27
27
|
document.addEventListener("keydown", escape);
|
|
@@ -3,6 +3,7 @@ import { useEffect, useRef } from "react";
|
|
|
3
3
|
import { Sources } from "./Sources.js";
|
|
4
4
|
import { BADGE_LABELS } from "./storyPanels.js";
|
|
5
5
|
import { useSwipeToDismiss } from "./useSwipeToDismiss.js";
|
|
6
|
+
import { useZoomThrough } from "./useZoomThrough.js";
|
|
6
7
|
/** A small pill saying how far to trust a panel's facts, after Planetary Explorer's Badge. */
|
|
7
8
|
export function StoryBadge({ badge }) {
|
|
8
9
|
return _jsx("span", { className: "story-badge", "data-badge": badge, children: BADGE_LABELS[badge] });
|
|
@@ -14,8 +15,9 @@ export function StoryBadge({ badge }) {
|
|
|
14
15
|
export function StoryPanelView({ panel, holding, onClose, onContinue }) {
|
|
15
16
|
const sheet = useRef(null);
|
|
16
17
|
useSwipeToDismiss(sheet, onClose);
|
|
18
|
+
useZoomThrough(sheet);
|
|
17
19
|
useEffect(() => {
|
|
18
|
-
const onKey = (event) => { if (event.key === "Escape")
|
|
20
|
+
const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape")
|
|
19
21
|
onClose(); };
|
|
20
22
|
document.addEventListener("keydown", onKey);
|
|
21
23
|
return () => document.removeEventListener("keydown", onKey);
|