astraeus 0.1.1 → 0.3.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 +51 -0
- package/README.md +76 -7
- package/package.json +10 -6
- package/src/api/AstraeusScene.d.ts +27 -0
- package/src/api/AstraeusScene.js +38 -0
- package/src/api/AstraeusScene.node.js +37 -0
- package/src/api/activity.d.ts +50 -0
- package/src/api/activity.js +62 -0
- package/src/api/bodies.d.ts +24 -0
- package/src/api/bodies.js +24 -0
- package/src/api/errors.d.ts +1 -1
- package/src/api/group.d.ts +89 -0
- package/src/api/group.js +121 -0
- package/src/api/index.d.ts +6 -1
- package/src/api/index.js +3 -1
- package/src/api/index.node.js +8 -0
- package/src/api/mount.d.ts +10 -1
- package/src/api/mount.js +15 -4
- package/src/api/mount.node.js +36 -0
- package/src/api/prepared.d.ts +10 -0
- package/src/api/prepared.js +5 -0
- package/src/api/scene.d.ts +148 -9
- package/src/api/scene.js +563 -59
- package/src/api/story.d.ts +69 -0
- package/src/api/story.js +63 -0
- package/src/api/sunOrbit.d.ts +20 -0
- package/src/api/sunOrbit.js +85 -0
- package/src/api/switches.d.ts +14 -0
- package/src/api/switches.js +19 -0
- package/src/api/time.d.ts +4 -0
- package/src/api/time.js +8 -0
- package/src/app/App.d.ts +6 -2
- package/src/app/App.js +43 -21
- package/src/app/App.node.js +401 -0
- package/src/app/AstraeusScene.d.ts +1 -1
- package/src/app/DebugOverlay.d.ts +3 -52
- package/src/app/DebugOverlay.js +2 -29
- package/src/app/PanelLoadBoundary.d.ts +19 -0
- package/src/app/PanelLoadBoundary.js +17 -0
- package/src/app/SkyView.d.ts +3 -3
- package/src/app/SkyView.js +19 -10
- package/src/app/debugReadout.d.ts +53 -0
- package/src/app/debugReadout.js +30 -0
- package/src/app/developerPanels.d.ts +6 -0
- package/src/app/developerPanels.js +11 -0
- package/src/app/displaySwitches.d.ts +54 -0
- package/src/app/displaySwitches.js +48 -0
- package/src/app/experienceDefinition.d.ts +13 -1
- package/src/app/listSwitch.d.ts +16 -0
- package/src/{experiences/showers/showerChoice.js → app/listSwitch.js} +1 -9
- package/src/app/metricReadouts.d.ts +1 -1
- package/src/app/metricReadouts.js +1 -1
- package/src/app/openClock.d.ts +7 -0
- package/src/app/openClock.js +14 -0
- package/src/app/sceneContentsHooks.d.ts +3 -3
- package/src/app/sceneContentsHooks.js +2 -2
- package/src/app/sceneDebug.d.ts +1 -1
- package/src/app/sceneDebug.js +1 -1
- package/src/app/sceneFrame.js +4 -3
- package/src/app/sceneFraming.d.ts +13 -0
- package/src/app/sceneFraming.js +22 -0
- package/src/app/skyModel.js +3 -1
- package/src/app/trackedMetrics.d.ts +53 -0
- package/src/{experiences/apollo11/spacecraftMetrics.js → app/trackedMetrics.js} +40 -56
- package/src/assets/licence.d.ts +1 -0
- 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/index.d.ts +3 -0
- package/src/core/bodies/index.js +3 -1
- 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/planetSeries.d.ts +2 -0
- package/src/core/planetSeries.js +4 -0
- package/src/core/provenance.d.ts +7 -2
- package/src/core/provenance.js +3 -1
- package/src/core/scalePolicy.d.ts +3 -0
- package/src/core/scalePolicy.js +2 -0
- package/src/core/state.d.ts +1 -0
- package/src/shell/AstraeusShell.d.ts +4 -1
- package/src/shell/AstraeusShell.js +12 -6
- package/src/shell/AstraeusShell.node.js +225 -0
- package/src/shell/DisplaySwitches.d.ts +16 -0
- package/src/shell/DisplaySwitches.js +31 -0
- package/src/shell/StoryPanelView.js +3 -1
- package/src/shell/TimelineBar.css +4 -0
- package/src/shell/TimelineBar.node.js +75 -0
- package/src/shell/TopBar.css +20 -0
- package/src/shell/TopBar.d.ts +4 -1
- package/src/shell/TopBar.js +3 -2
- package/src/shell/TopBar.node.js +14 -0
- package/src/shell/experience.d.ts +4 -0
- package/src/shell/infoModel.js +3 -1
- package/src/shell/phone.css +4 -1
- package/src/shell/topBarIcons.d.ts +1 -0
- package/src/shell/topBarIcons.js +1 -0
- 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/syntheticDefinition.js +3 -3
- package/src/experiences/apollo11/spacecraftMetrics.d.ts +0 -34
- package/src/experiences/showers/showerChoice.d.ts +0 -25
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
4
|
+
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
|
+
import { openClock } from "./openClock.js";
|
|
6
|
+
import { createSolarSystemScale } from "../core/scalePolicy.js";
|
|
7
|
+
import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
|
|
8
|
+
import { AstraeusShell } from "../shell/AstraeusShell.node.js";
|
|
9
|
+
import { scaleChoicesFor, scalePolicyFor, startScaleFor } from "../shell/scaleModel.js";
|
|
10
|
+
import { scaleFromSearch, timeFromSearch, viewFromSearch, shareViewLink } from "./viewLink.js";
|
|
11
|
+
import { Collapsible } from "../shell/Collapsible.js";
|
|
12
|
+
import { PanelLoadBoundary } from "./PanelLoadBoundary.js";
|
|
13
|
+
import { BOOT_FADE_LIMITS, bootFadeSeconds, saveBootFadeSeconds } from "../shell/bootLoader.js";
|
|
14
|
+
import { LabelSettings, UnderTheHoodSettings, ViewLinkReadout, MoonsAndRingsSettings, SkyAndSunSettings, StoryPanelSettings } from "./developerPanels.js";
|
|
15
|
+
import { DEFAULT_ILLUMINATE_ALL } from "./lighting.js";
|
|
16
|
+
import { SettingButtons, SettingColor, SettingGroup, SettingSlider } from "./SettingControls.js";
|
|
17
|
+
import { DEFAULT_TIMELINE_GLOW } from "../shell/timelineGlow.js";
|
|
18
|
+
import { DEFAULT_PHONE_LAYOUT, PHONE_LAYOUT_LIMITS } from "../shell/phoneLayout.js";
|
|
19
|
+
import { featureMarkerSpecs, featureMinBodyPxFromSearch } from "./FeatureMarkers.js";
|
|
20
|
+
import { FrameStats } from "./frameStats.js";
|
|
21
|
+
import { AstraeusScene } from "./AstraeusScene.js";
|
|
22
|
+
import { HOVER_BRIGHTNESS_DEFAULT } from "./scenePicking.js";
|
|
23
|
+
import { createSceneResolver } from "./sceneLayout.js";
|
|
24
|
+
import { loadStarCatalogue } from "../assets/sky.js";
|
|
25
|
+
import { resolveSkySettings, withSkyObject } from "./skyModel.js";
|
|
26
|
+
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
27
|
+
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
28
|
+
import { displaySwitchItems, orbitStart } from "./displaySwitches.js";
|
|
29
|
+
import { baseGlowOf, glowLookFromSearch, markerSettingsFromSearch } from "./bodyDraw.js";
|
|
30
|
+
import { brightnessFromSearch, milkyWayFromSearch, skyHiddenBySearch } from "./SkyView.js";
|
|
31
|
+
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
32
|
+
const FPS_HISTORY = 60;
|
|
33
|
+
/** The sky settings in force: the experience's own, hidden when the address says `?sky=off`. */
|
|
34
|
+
function skySettingsOf(definition) {
|
|
35
|
+
const settings = resolveSkySettings(definition.sky);
|
|
36
|
+
const milkyWay = milkyWayFromSearch(window.location.search) ?? definition.displaySwitches?.milkyWay?.on ?? settings.milkyWay;
|
|
37
|
+
const starBrightness = brightnessFromSearch(window.location.search, "stars") ?? settings.starBrightness;
|
|
38
|
+
const milkyWayBrightness = brightnessFromSearch(window.location.search, "milkywaybrightness") ?? settings.milkyWayBrightness;
|
|
39
|
+
return { ...settings, milkyWay, starBrightness, milkyWayBrightness, visible: settings.visible && !skyHiddenBySearch(window.location.search) };
|
|
40
|
+
}
|
|
41
|
+
/** The labels switched off at the start: objects that set `showLabel: false`, then `?labels=<id>:on|off,...` over them. */
|
|
42
|
+
export function hiddenLabelsFrom(search, objects) {
|
|
43
|
+
const hidden = new Set(objects.filter((object) => object.showLabel === false).map((object) => object.id));
|
|
44
|
+
for (const part of (new URLSearchParams(search).get("labels") ?? "").split(",")) {
|
|
45
|
+
const [id, state] = part.split(":");
|
|
46
|
+
if (id === undefined || id === "" || (state !== "on" && state !== "off"))
|
|
47
|
+
continue;
|
|
48
|
+
if (state === "off")
|
|
49
|
+
hidden.add(id);
|
|
50
|
+
else
|
|
51
|
+
hidden.delete(id);
|
|
52
|
+
}
|
|
53
|
+
return hidden;
|
|
54
|
+
}
|
|
55
|
+
/** `?loop=on` or `?loop=off` overrides the experience's own looping setting. */
|
|
56
|
+
export function loopFromSearch(search, fallback) {
|
|
57
|
+
const value = new URLSearchParams(search).get("loop");
|
|
58
|
+
return value === "on" ? true : value === "off" ? false : fallback;
|
|
59
|
+
}
|
|
60
|
+
/** The labels switch's starting state, if the story gave one. */
|
|
61
|
+
function labelStart(definition) {
|
|
62
|
+
return definition.displaySwitches?.labels?.on;
|
|
63
|
+
}
|
|
64
|
+
/** The orbit lines a story starts off: the ring and arc, and the moon orbits. */
|
|
65
|
+
function startOrbitControls(definition) {
|
|
66
|
+
const start = orbitStart(definition.displaySwitches?.orbitLines);
|
|
67
|
+
return start === undefined ? {} : { orbitLook: start.look, bodySetLook: { ...DEFAULT_BODY_SET_LOOK, orbitsOn: false } };
|
|
68
|
+
}
|
|
69
|
+
function copyOfGlow(look) {
|
|
70
|
+
return look === undefined ? null : { ...look };
|
|
71
|
+
}
|
|
72
|
+
function orbitPathsOf(runtime) {
|
|
73
|
+
return runtime.composition?.paths ?? [];
|
|
74
|
+
}
|
|
75
|
+
/** The up direction at the start: `?up=` in the address, else the experience's own, else the equatorial pole. */
|
|
76
|
+
function startViewUp(definition) {
|
|
77
|
+
return viewUpFromSearch(window.location.search, definition.viewUp ?? "equatorial");
|
|
78
|
+
}
|
|
79
|
+
function storyStartOf(storySet) {
|
|
80
|
+
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
|
|
81
|
+
}
|
|
82
|
+
function switcherOf(definition, runtime, open) {
|
|
83
|
+
return definition.switcher === undefined ? undefined : { ...definition.switcher, currentTimeUtcMs: () => runtime.clock.snapshot().timeUtcMs, open };
|
|
84
|
+
}
|
|
85
|
+
/** Everything one mounted experience shares: clock, resolver, catalogue and the settings read from its definition and the address. */
|
|
86
|
+
function buildRuntime(definition) {
|
|
87
|
+
const adapter = createOrbAstronomyAdapter();
|
|
88
|
+
// A copied view link carries the time it was copied at.
|
|
89
|
+
const clock = openClock(definition, timeFromSearch(window.location.search));
|
|
90
|
+
// One resolver per mount: every position in the scene comes from it, whatever the scene centre.
|
|
91
|
+
const resolver = createSceneResolver(adapter, catalogueOf(definition));
|
|
92
|
+
return {
|
|
93
|
+
clock,
|
|
94
|
+
adapter,
|
|
95
|
+
resolver,
|
|
96
|
+
catalogue: catalogueOf(definition),
|
|
97
|
+
bodies: mountedBodiesOf(definition),
|
|
98
|
+
composition: compositionOf(definition),
|
|
99
|
+
overrides: visualOverridesOf(definition),
|
|
100
|
+
desktopTextures: definition.desktopTextures === true,
|
|
101
|
+
sceneCenter: sceneCenterOf(definition),
|
|
102
|
+
trackedBodies: trackedBodiesOf(definition),
|
|
103
|
+
groups: groupsOf(definition),
|
|
104
|
+
bodySets: bodySetsOf(definition),
|
|
105
|
+
...sunCentredOf(definition),
|
|
106
|
+
cameraReach: cameraReachOf(definition),
|
|
107
|
+
sky: skySettingsOf(definition),
|
|
108
|
+
loopWindow: definition.experience.window,
|
|
109
|
+
up: viewUpVector(startViewUp(definition)),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Whether the experience has anything the Display controls (markers, labels, timeline, phone layout) act on. */
|
|
113
|
+
function showsDisplayControls(definition, runtime, orbitPathCount, storyMarkerCount) {
|
|
114
|
+
return orbitPathCount > 0 || runtime.trackedBodies.length > 0 || runtime.sky.visible || storyMarkerCount > 0 || (definition.experience.storyPanels?.panels.length ?? 0) > 0
|
|
115
|
+
|| runtime.bodies.some((id) => runtime.catalogue.get(id).visual.kind === "sphere");
|
|
116
|
+
}
|
|
117
|
+
/** The scene's live controls at mount: the address overrides the experience's own start values. */
|
|
118
|
+
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies) {
|
|
119
|
+
const search = window.location.search;
|
|
120
|
+
const startView = viewFromSearch(search) ?? definition.startView;
|
|
121
|
+
return {
|
|
122
|
+
policy: scalePolicyFor(startScale, suppliedPolicies),
|
|
123
|
+
cameraRequest: null,
|
|
124
|
+
showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
|
|
125
|
+
loop: loopFromSearch(search, definition.loop === true),
|
|
126
|
+
up: viewUpVector(startViewUp(definition)),
|
|
127
|
+
showMilkyWay: runtime.sky.milkyWay,
|
|
128
|
+
bodyMarker: markerSettingsFromSearch(search),
|
|
129
|
+
...(glowBase === null ? {} : { glowLook: glowLookFromSearch(search, glowBase) }),
|
|
130
|
+
starBrightness: runtime.sky.starBrightness,
|
|
131
|
+
milkyWayBrightness: runtime.sky.milkyWayBrightness,
|
|
132
|
+
illuminateAll: DEFAULT_ILLUMINATE_ALL,
|
|
133
|
+
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
134
|
+
...startOrbitControls(definition),
|
|
135
|
+
labelObjects: experience.objects,
|
|
136
|
+
storyMarkers,
|
|
137
|
+
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
138
|
+
featureMinBodyPx: featureMinBodyPxFromSearch(search),
|
|
139
|
+
selectedObjectId: initialObjectIdOf(definition),
|
|
140
|
+
frameStats: null,
|
|
141
|
+
groupFills: [],
|
|
142
|
+
...(startView === undefined ? {} : { startView }),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
|
|
147
|
+
* `writeTitle`: whether the page heading is set to the experience's name (default true); `mount` and `AstraeusScene` pass false so a host page keeps its own title.
|
|
148
|
+
*/
|
|
149
|
+
export function App({ definition, onOpenAddress, writeTitle = true }) {
|
|
150
|
+
// The page heading names the experience once it is open; app.html says only "Astraeus" until then.
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
if (writeTitle)
|
|
153
|
+
document.title = pageTitleOf(definition);
|
|
154
|
+
}, [definition, writeTitle]);
|
|
155
|
+
const runtime = useMemo(() => buildRuntime(definition), [definition]);
|
|
156
|
+
const experienceRuntime = useMemo(() => ({ clock: runtime.clock, resolver: runtime.resolver, catalogue: runtime.catalogue }), [runtime]);
|
|
157
|
+
// The choices offered, in the experience's order; the solar-system policy enlarges only the bodies the experience names.
|
|
158
|
+
const scaleChoiceIds = useMemo(() => scaleChoiceIdsOf(definition), [definition]);
|
|
159
|
+
const scaleChoices = useMemo(() => (scaleChoiceIds === undefined ? undefined : scaleChoicesFor(scaleChoiceIds)), [scaleChoiceIds]);
|
|
160
|
+
const suppliedPolicies = useMemo(() => {
|
|
161
|
+
const exaggeration = {};
|
|
162
|
+
for (const [id, override] of runtime.overrides)
|
|
163
|
+
if (override.exaggeration !== undefined)
|
|
164
|
+
exaggeration[id] = override.exaggeration;
|
|
165
|
+
return [createSolarSystemScale({ exaggeration, defaultExaggeration: 1 })];
|
|
166
|
+
}, [runtime]);
|
|
167
|
+
const linkedScale = scaleFromSearch(window.location.search);
|
|
168
|
+
const startScale = startScaleFor(linkedScale, scaleChoiceIds);
|
|
169
|
+
const experience = useMemo(() => experienceWithGroups(definition), [definition]);
|
|
170
|
+
// The shell also lists the sky, citing its sources and saying whether the stars were fetched.
|
|
171
|
+
const [starStatus, setStarStatus] = useState({ kind: "loading" });
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
let cancelled = false;
|
|
174
|
+
void loadStarCatalogue().then((loaded) => {
|
|
175
|
+
if (!cancelled)
|
|
176
|
+
setStarStatus(loaded === null ? { kind: "absent" } : { kind: "loaded", count: loaded.stars.length });
|
|
177
|
+
});
|
|
178
|
+
return () => { cancelled = true; };
|
|
179
|
+
}, []);
|
|
180
|
+
const shellExperience = useMemo(() => withSkyObject(experience, runtime.sky.visible, starStatus), [experience, runtime.sky.visible, starStatus]);
|
|
181
|
+
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
182
|
+
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
183
|
+
const storySet = definition.experience.storyPanels;
|
|
184
|
+
const storyMarkerSpecs = useMemo(() => (storySet?.panels ?? []).flatMap((panel) => (panel.objectId === undefined ? [] : [{ panelId: panel.id, objectId: panel.objectId, title: panel.title, timeUtcMs: panel.timeUtcMs }])), [storySet]);
|
|
185
|
+
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies));
|
|
186
|
+
const readout = useRef(null);
|
|
187
|
+
const [clockSnapshot, setClockSnapshot] = useState(() => runtime.clock.snapshot());
|
|
188
|
+
const [scale, setScale] = useState(startScale);
|
|
189
|
+
const [developerMode, setDeveloperMode] = useState(false);
|
|
190
|
+
const [timelineGlow, setTimelineGlow] = useState(DEFAULT_TIMELINE_GLOW);
|
|
191
|
+
const [phoneLayout, setPhoneLayout] = useState(DEFAULT_PHONE_LAYOUT);
|
|
192
|
+
const [anchorLabels, setAnchorLabels] = useState(controls.current.showAnchorLabels);
|
|
193
|
+
const [glowShown, setGlowShown] = useState(copyOfGlow(controls.current.glowLook));
|
|
194
|
+
const orbitPaths = orbitPathsOf(runtime);
|
|
195
|
+
const orbitDefault = useMemo(() => resolveOrbitLook(orbitPaths[0]?.look), [orbitPaths]);
|
|
196
|
+
const [orbitShown, setOrbitShown] = useState({ ...orbitDefault, ...controls.current.orbitLook });
|
|
197
|
+
const setOrbit = (change) => {
|
|
198
|
+
controls.current.orbitLook = { ...controls.current.orbitLook, ...change };
|
|
199
|
+
setOrbitShown({ ...orbitDefault, ...controls.current.orbitLook });
|
|
200
|
+
};
|
|
201
|
+
const resetOrbit = () => { delete controls.current.orbitLook; setOrbitShown(orbitDefault); };
|
|
202
|
+
const bodySets = runtime.bodySets;
|
|
203
|
+
const [setLook, setSetLook] = useState(controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK);
|
|
204
|
+
const changeSetLook = (change) => {
|
|
205
|
+
const next = { ...(controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK), ...change };
|
|
206
|
+
controls.current.bodySetLook = next;
|
|
207
|
+
setSetLook(next);
|
|
208
|
+
};
|
|
209
|
+
const highlightFamily = (family) => changeSetLook({ highlightFamily: family });
|
|
210
|
+
const ringSystems = useMemo(() => runtime.bodies.flatMap((id) => { const rings = runtime.overrides.get(id)?.rings ?? runtime.catalogue.get(id).visual.rings; return rings === undefined ? [] : [rings]; }), [runtime]);
|
|
211
|
+
const [ringLook, setRingLook] = useState({});
|
|
212
|
+
const changeRing = (band, change) => {
|
|
213
|
+
const next = { ...ringLook, [band]: { ...ringLook[band], ...change } };
|
|
214
|
+
controls.current.ringLook = next;
|
|
215
|
+
setRingLook(next);
|
|
216
|
+
};
|
|
217
|
+
const labelToggles = useMemo(() => experience.objects.filter((object) => object.showLabel !== undefined), [experience]);
|
|
218
|
+
const [hiddenLabels, setHiddenLabels] = useState(() => new Set(controls.current.hiddenLabels));
|
|
219
|
+
const [loopOn, setLoopOn] = useState(controls.current.loop === true);
|
|
220
|
+
const [upChoice, setUpChoice] = useState(startViewUp(definition));
|
|
221
|
+
const [illuminateAll, setIlluminateAll] = useState(controls.current.illuminateAll);
|
|
222
|
+
const [milkyWayOn, setMilkyWayOn] = useState(runtime.sky.milkyWay);
|
|
223
|
+
const [hoverBrightness, setHoverBrightness] = useState(HOVER_BRIGHTNESS_DEFAULT);
|
|
224
|
+
const [starBrightness, setStarBrightness] = useState(runtime.sky.starBrightness);
|
|
225
|
+
const [milkyWayBrightness, setMilkyWayBrightness] = useState(runtime.sky.milkyWayBrightness);
|
|
226
|
+
const [loadFade, setLoadFade] = useState(() => bootFadeSeconds());
|
|
227
|
+
const [markerPx, setMarkerPx] = useState(() => controls.current.bodyMarker.minSpherePx);
|
|
228
|
+
const [storyAutoOpen, setStoryAutoOpen] = useState(storyStartOf(storySet).autoOpen);
|
|
229
|
+
const [storyPauseSeconds, setStoryPauseSeconds] = useState(storyStartOf(storySet).pauseSeconds);
|
|
230
|
+
const [panelRequest, setPanelRequest] = useState(null);
|
|
231
|
+
const [pickRequest, setPickRequest] = useState(null);
|
|
232
|
+
const [featureRequest, setFeatureRequest] = useState(null);
|
|
233
|
+
const [hud, setHud] = useState(null);
|
|
234
|
+
const [frames, setFrames] = useState(null);
|
|
235
|
+
const [fpsHistory, setFpsHistory] = useState([]);
|
|
236
|
+
const [viewNow, setViewNow] = useState(null);
|
|
237
|
+
const [viewLink, setViewLink] = useState(null);
|
|
238
|
+
const [fills, setFills] = useState([]);
|
|
239
|
+
const updateCameraRequest = useCallback((request) => {
|
|
240
|
+
controls.current.cameraRequest = request;
|
|
241
|
+
}, []);
|
|
242
|
+
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
243
|
+
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
244
|
+
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
245
|
+
const markOpenFeature = useCallback((key) => { controls.current.openFeatureKey = key; }, []);
|
|
246
|
+
const markOpenPanel = useCallback((id) => { controls.current.openStoryPanelId = id; }, []);
|
|
247
|
+
const setPlaying = useCallback((playing) => {
|
|
248
|
+
if (playing)
|
|
249
|
+
runtime.clock.play();
|
|
250
|
+
else
|
|
251
|
+
runtime.clock.pause();
|
|
252
|
+
setClockSnapshot(runtime.clock.snapshot());
|
|
253
|
+
}, [runtime]);
|
|
254
|
+
controls.current.onStoryMarker = requestPanel;
|
|
255
|
+
controls.current.onFeatureMarker = requestFeature;
|
|
256
|
+
controls.current.onPickObject = requestPick;
|
|
257
|
+
const updateSelectedObject = useCallback((objectId) => {
|
|
258
|
+
controls.current.selectedObjectId = objectId;
|
|
259
|
+
}, []);
|
|
260
|
+
const updateScale = useCallback((id) => {
|
|
261
|
+
controls.current.policy = scalePolicyFor(id, suppliedPolicies);
|
|
262
|
+
setScale(id);
|
|
263
|
+
}, [suppliedPolicies]);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
const id = window.setInterval(() => {
|
|
266
|
+
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
267
|
+
if (controls.current.loop === true)
|
|
268
|
+
runtime.clock.wrapWithin(runtime.loopWindow);
|
|
269
|
+
setClockSnapshot(runtime.clock.snapshot());
|
|
270
|
+
}, 100);
|
|
271
|
+
return () => window.clearInterval(id);
|
|
272
|
+
}, [runtime]);
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
if (!developerMode)
|
|
275
|
+
return undefined;
|
|
276
|
+
const stats = new FrameStats();
|
|
277
|
+
controls.current.frameStats = stats;
|
|
278
|
+
const id = window.setInterval(() => {
|
|
279
|
+
setHud(readout.current);
|
|
280
|
+
const snapshot = stats.snapshot();
|
|
281
|
+
setFrames(snapshot);
|
|
282
|
+
if (snapshot.frames > 0)
|
|
283
|
+
setFpsHistory((history) => [...history.slice(-(FPS_HISTORY - 1)), snapshot.fps]);
|
|
284
|
+
setFills(controls.current.groupFills.map((fill) => ({ ...fill })));
|
|
285
|
+
setViewNow(controls.current.viewReadout === undefined ? null : { ...controls.current.viewReadout });
|
|
286
|
+
}, 250);
|
|
287
|
+
return () => {
|
|
288
|
+
window.clearInterval(id);
|
|
289
|
+
controls.current.frameStats = null;
|
|
290
|
+
setFrames(null);
|
|
291
|
+
setFpsHistory([]);
|
|
292
|
+
};
|
|
293
|
+
}, [developerMode, runtime]);
|
|
294
|
+
/** Writes the current view, scale, up direction and time into the address, then copies the full link (or shows it to copy by hand). */
|
|
295
|
+
const copyViewLink = async () => {
|
|
296
|
+
const view = controls.current.viewReadout;
|
|
297
|
+
if (view === undefined)
|
|
298
|
+
return;
|
|
299
|
+
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
300
|
+
};
|
|
301
|
+
const displaySwitches = displaySwitchItems({
|
|
302
|
+
settings: definition.displaySwitches,
|
|
303
|
+
orbit: { present: orbitPaths.length > 0, look: orbitShown, set: setOrbit },
|
|
304
|
+
moons: { present: bodySets.length > 0, look: setLook, set: changeSetLook },
|
|
305
|
+
sky: { present: runtime.sky.visible, on: milkyWayOn, set: (on) => { controls.current.showMilkyWay = on; setMilkyWayOn(on); } },
|
|
306
|
+
labels: {
|
|
307
|
+
objectIds: experience.objects.map((object) => object.id), hidden: hiddenLabels,
|
|
308
|
+
setHidden: (hidden) => { controls.current.hiddenLabels = new Set(hidden); setHiddenLabels(new Set(hidden)); },
|
|
309
|
+
anchorsPresent: runtime.trackedBodies.length > 0, anchors: anchorLabels, setAnchors: (on) => { controls.current.showAnchorLabels = on; setAnchorLabels(on); },
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
const sections = definition.developerSections ?? [];
|
|
313
|
+
const renderSection = (section) => (_jsxs("section", { className: section.id === "clock" ? "hud-section hud-section-clock" : "hud-section", "aria-labelledby": `developer-${section.id}-heading`, children: [_jsx("h3", { id: `developer-${section.id}-heading`, children: section.heading }), section.render(experienceRuntime)] }, section.id));
|
|
314
|
+
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
315
|
+
const showDisplay = showsDisplayControls(definition, runtime, orbitPaths.length, storyMarkerSpecs.length);
|
|
316
|
+
// Orbit-line sliders: the first four stay in view, the rest sit in a nested "Fine-tune" fold (T-090).
|
|
317
|
+
const orbitSliders = {
|
|
318
|
+
main: [
|
|
319
|
+
["baseOpacity", "Ring opacity", "orbit-base-opacity", 0.01],
|
|
320
|
+
["endFade", "End fade (of ring)", "orbit-end-fade", 0.01],
|
|
321
|
+
["arcFraction", "Arc length (of orbit)", "orbit-arc-fraction", 0.01],
|
|
322
|
+
["arcPeak", "Arc opacity", "orbit-arc-peak", 0.01],
|
|
323
|
+
],
|
|
324
|
+
fine: [
|
|
325
|
+
["arcExponent", "Fade curve (power)", "orbit-arc-exponent", 0.1],
|
|
326
|
+
["arcSegments", "Arc segments", "orbit-arc-segments", 1],
|
|
327
|
+
["arcWidth", "Arc width (of orbit)", "orbit-arc-width", 0.0001],
|
|
328
|
+
["arcMaxWidthPx", "Arc max width (px)", "orbit-arc-max-width", 0.5],
|
|
329
|
+
["zoomBoostBase", "Zoom boost (ring)", "orbit-zoom-boost-base", 0.01],
|
|
330
|
+
["zoomBoostArc", "Zoom boost (arc)", "orbit-zoom-boost-arc", 0.01],
|
|
331
|
+
],
|
|
332
|
+
};
|
|
333
|
+
const orbitSlider = ([key, label, testId, step]) => (_jsx(SettingSlider, { label: label, ariaLabel: label, testId: `${testId}-value`, display: orbitShown[key].toFixed(step === 1 ? 0 : step === 0.5 ? 1 : step < 0.01 ? 4 : 2), min: ORBIT_LOOK_LIMITS[key].min, max: ORBIT_LOOK_LIMITS[key].max, step: step, value: orbitShown[key], onChange: (value) => setOrbit({ [key]: value }) }, key));
|
|
334
|
+
// The panel's folds, in order; the first one present opens by default and the rest start closed (T-090).
|
|
335
|
+
const groups = [
|
|
336
|
+
sections.length === 0 ? null : {
|
|
337
|
+
id: "demo", title: "This demo", className: "dev-group-cards",
|
|
338
|
+
body: (_jsxs(_Fragment, { children: [sections.filter((section) => section.placement === "before-scene").map(renderSection), sections.filter((section) => section.placement === "after-scene").map(renderSection)] })),
|
|
339
|
+
},
|
|
340
|
+
!showDisplay ? null : {
|
|
341
|
+
id: "camera", title: "Camera and view",
|
|
342
|
+
body: (_jsxs(_Fragment, { children: [_jsx(SettingButtons, { label: "Up direction", children: [["ecliptic", "Planets' plane (ecliptic)"], ["equatorial", "Earth's pole (equatorial)"]].map(([choice, text]) => (_jsx("button", { "aria-pressed": upChoice === choice, onClick: () => { controls.current.up = viewUpVector(choice); setUpChoice(choice); }, children: text }, choice))) }), _jsx(SettingSlider, { label: "Marker threshold (px)", ariaLabel: "Body marker threshold", testId: "body-marker-value", display: markerPx.toFixed(1), min: 0, max: 20, step: 0.5, value: markerPx, onChange: (value) => { controls.current.bodyMarker = { ...controls.current.bodyMarker, minSpherePx: value }; setMarkerPx(value); } }), _jsx(SettingSlider, { label: "Loading fade (s, next load)", ariaLabel: "Loading fade", testId: "load-fade-value", display: loadFade.toFixed(1), min: BOOT_FADE_LIMITS.min, max: BOOT_FADE_LIMITS.max, step: 0.1, value: loadFade, onChange: (value) => { saveBootFadeSeconds(value); setLoadFade(value); } }), _jsxs("div", { className: "view-link", role: "group", "aria-label": "Camera view", children: [_jsx(SettingButtons, { label: "Camera view", children: _jsx("button", { onClick: () => void copyViewLink(), children: "Copy view link" }) }), _jsx(ViewLinkReadout, { viewNow: viewNow, viewLink: viewLink, scale: scale, upChoice: upChoice })] }), _jsx(SettingButtons, { children: _jsx("button", { "aria-pressed": loopOn, onClick: () => { controls.current.loop = !loopOn; setLoopOn(!loopOn); }, children: "Loop playback" }) })] })),
|
|
343
|
+
},
|
|
344
|
+
!showDisplay ? null : {
|
|
345
|
+
id: "timeline", title: "Timeline and stories",
|
|
346
|
+
body: (_jsxs(_Fragment, { children: [_jsxs(SettingGroup, { id: "timeline-glow", title: "Timeline glow", children: [_jsx(SettingColor, { label: "Glow colour", ariaLabel: "Timeline glow colour", testId: "glow-color-value", value: timelineGlow.color, onChange: (color) => setTimelineGlow({ ...timelineGlow, color }) }), _jsx(SettingColor, { label: "Played colour", ariaLabel: "Timeline played colour", testId: "glow-played-value", value: timelineGlow.playedColor, onChange: (playedColor) => setTimelineGlow({ ...timelineGlow, playedColor }) }), [
|
|
347
|
+
["minBrightness", "Quiet brightness", "Timeline quiet brightness", "glow-min-value", 0, 1, 0.01],
|
|
348
|
+
["steadyBrightness", "Steady brightness (no rate)", "Timeline steady brightness", "glow-steady-value", 0, 1, 0.01],
|
|
349
|
+
["curve", "Curve (rate to brightness)", "Timeline glow curve", "glow-curve-value", 0.2, 3, 0.05],
|
|
350
|
+
["playedFloor", "Played brightness floor", "Timeline played floor", "glow-floor-value", 0, 1, 0.01],
|
|
351
|
+
["thicknessPx", "Thickness (px)", "Timeline glow thickness", "glow-thickness-value", 2, 14, 0.5],
|
|
352
|
+
["haloPx", "Halo blur (px)", "Timeline glow halo", "glow-halo-value", 0, 20, 0.5],
|
|
353
|
+
].map(([key, label, ariaLabel, testId, min, max, step]) => (_jsx(SettingSlider, { label: label, ariaLabel: ariaLabel, testId: testId, display: timelineGlow[key].toFixed(step < 0.1 ? 2 : step < 1 ? 1 : 0), min: min, max: max, step: step, value: timelineGlow[key], onChange: (value) => setTimelineGlow({ ...timelineGlow, [key]: value }) }, key))), _jsx(SettingButtons, { children: _jsx("button", { onClick: () => setTimelineGlow(DEFAULT_TIMELINE_GLOW), children: "Reset glow" }) })] }), hasStoryPanels && _jsx(StoryPanelSettings, { storyAutoOpen: storyAutoOpen, setStoryAutoOpen: setStoryAutoOpen, storyPauseSeconds: storyPauseSeconds, setStoryPauseSeconds: setStoryPauseSeconds })] })),
|
|
354
|
+
},
|
|
355
|
+
orbitPaths.length === 0 ? null : {
|
|
356
|
+
id: "orbit-lines", title: "Orbit lines",
|
|
357
|
+
body: (_jsxs(_Fragment, { children: [_jsxs(SettingButtons, { children: [_jsx("button", { "aria-pressed": orbitShown.baseOn, onClick: () => setOrbit({ baseOn: !orbitShown.baseOn }), children: "Orbit ring" }), _jsx("button", { "aria-pressed": orbitShown.endFadeOn, onClick: () => setOrbit({ endFadeOn: !orbitShown.endFadeOn }), children: "Fade ring ends" }), _jsx("button", { "aria-pressed": orbitShown.arcOn, onClick: () => setOrbit({ arcOn: !orbitShown.arcOn }), children: "Trailing arc" }), _jsx("button", { "aria-pressed": orbitShown.zoomOn, onClick: () => setOrbit({ zoomOn: !orbitShown.zoomOn }), children: "Brighten when zoomed out" })] }), orbitSliders.main.map(orbitSlider), _jsx(Collapsible, { id: "orbit-fine-tune", title: "Fine-tune", level: 4, nested: true, children: orbitSliders.fine.map(orbitSlider) }), _jsx(SettingButtons, { children: _jsx("button", { onClick: resetOrbit, children: "Reset orbit lines" }) })] })),
|
|
358
|
+
},
|
|
359
|
+
bodySets.length === 0 && ringSystems.length === 0 ? null : {
|
|
360
|
+
id: "moons-rings", title: "Moons and rings",
|
|
361
|
+
body: (_jsx(MoonsAndRingsSettings, { bodySets: bodySets, ringSystems: ringSystems, setLook: setLook, changeSetLook: changeSetLook, ringLook: ringLook, changeRing: changeRing, controls: controls, setSetLook: setSetLook, setRingLook: setRingLook })),
|
|
362
|
+
},
|
|
363
|
+
!(runtime.sky.visible || glowShown !== null) ? null : {
|
|
364
|
+
id: "sky-sun", title: "Sky and Sun",
|
|
365
|
+
body: (_jsx(SkyAndSunSettings, { illuminateAll: illuminateAll, setIlluminateAll: setIlluminateAll, visible: runtime.sky.visible, glowShown: glowShown, setGlowShown: setGlowShown, controls: controls, milkyWayOn: milkyWayOn, setMilkyWayOn: setMilkyWayOn, starBrightness: starBrightness, setStarBrightness: setStarBrightness, milkyWayBrightness: milkyWayBrightness, setMilkyWayBrightness: setMilkyWayBrightness })),
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
id: "labels", title: "Labels",
|
|
369
|
+
body: (_jsx(LabelSettings, { controls: controls, hoverBrightness: hoverBrightness, setHoverBrightness: setHoverBrightness, labelToggles: labelToggles, trackedCount: runtime.trackedBodies.length, anchorLabels: anchorLabels, setAnchorLabels: setAnchorLabels, hiddenLabels: hiddenLabels, setHiddenLabels: setHiddenLabels })),
|
|
370
|
+
},
|
|
371
|
+
!showDisplay ? null : {
|
|
372
|
+
id: "phone-layout", title: "Phone layout",
|
|
373
|
+
body: (_jsxs(_Fragment, { children: [[
|
|
374
|
+
["animationMs", "Drawer animation (ms)", "Phone drawer animation", "phone-animation-value"],
|
|
375
|
+
["controlsDrawerMaxPercent", "Top drawer height (% of screen)", "Phone top drawer height", "phone-controls-height-value"],
|
|
376
|
+
["timelineDrawerMaxPercent", "Timeline drawer height (% of screen)", "Phone timeline drawer height", "phone-timeline-height-value"],
|
|
377
|
+
["sheetMaxPercent", "Sheet height (% of screen)", "Phone sheet height", "phone-sheet-height-value"],
|
|
378
|
+
["swipeThresholdPx", "Swipe distance (px)", "Phone swipe distance", "phone-swipe-value"],
|
|
379
|
+
].map(([key, label, ariaLabel, testId]) => (_jsx(SettingSlider, { label: label, ariaLabel: ariaLabel, testId: testId, display: String(phoneLayout[key]), min: PHONE_LAYOUT_LIMITS[key].min, max: PHONE_LAYOUT_LIMITS[key].max, step: PHONE_LAYOUT_LIMITS[key].step, value: phoneLayout[key], onChange: (value) => setPhoneLayout({ ...phoneLayout, [key]: value }) }, key))), _jsx(SettingButtons, { children: _jsx("button", { onClick: () => setPhoneLayout(DEFAULT_PHONE_LAYOUT), children: "Reset phone layout" }) })] })),
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
id: "under-the-hood", title: "Under the hood",
|
|
383
|
+
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory, alternates: showDisplay ? definition.alternates : undefined })),
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
const presentGroups = groups.filter((group) => group !== null);
|
|
387
|
+
const developerTools = (_jsx(PanelLoadBoundary, { children: _jsx(Suspense, { fallback: _jsx("p", { className: "developer-loading", role: "status", children: "Loading developer tools..." }), children: _jsxs("div", { className: "hud", children: [_jsxs("header", { className: "developer-heading", children: [_jsx("h2", { children: "Developer tools" }), _jsx("p", { children: "Live readouts, controls and diagnostics for this scene." })] }), presentGroups.map((group, index) => (_jsx(Collapsible, { id: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }) }) }));
|
|
388
|
+
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
389
|
+
if (runtime.clock.playing)
|
|
390
|
+
runtime.clock.pause();
|
|
391
|
+
else
|
|
392
|
+
runtime.clock.play();
|
|
393
|
+
setClockSnapshot(runtime.clock.snapshot());
|
|
394
|
+
}, onRateChange: (rate) => {
|
|
395
|
+
runtime.clock.setRate(rate);
|
|
396
|
+
setClockSnapshot(runtime.clock.snapshot());
|
|
397
|
+
}, onSeek: (timeUtcMs) => {
|
|
398
|
+
runtime.clock.seek(timeUtcMs);
|
|
399
|
+
setClockSnapshot(runtime.clock.snapshot());
|
|
400
|
+
}, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
|
|
401
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { SystemComposition } from "../assets/compositions.js";
|
|
|
7
7
|
import { type BodyMarkerSettings, type GlowLook } from "./bodyDraw.js";
|
|
8
8
|
import type { OrbitLook } from "../assets/orbitLook.js";
|
|
9
9
|
import { type CameraRequest } from "./CameraController.js";
|
|
10
|
-
import type { DebugReadout } from "./
|
|
10
|
+
import type { DebugReadout } from "./debugReadout.js";
|
|
11
11
|
import { type CameraReach, type GroupLayer, type PathLayer, type SunBody, type VisualOverride } from "./experienceDefinition.js";
|
|
12
12
|
import type { TrackedBody } from "./mission.js";
|
|
13
13
|
import type { RenderVector } from "./renderCoordinates.js";
|
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ScalePolicy } from "../core/scalePolicy.js";
|
|
3
|
-
import type { FloatingOrigin } from "./floatingOrigin.js";
|
|
4
|
-
import type { PlacedState } from "./sceneLayout.js";
|
|
1
|
+
import { type DebugReadout } from "./debugReadout.js";
|
|
5
2
|
export { formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
/** Diagnostic snapshot. Scientific fields never depend on the scale policy; render fields do. */
|
|
9
|
-
export interface DebugReadout {
|
|
10
|
-
readonly timeUtcMs: number;
|
|
11
|
-
readonly rate: number;
|
|
12
|
-
readonly policyId: ScalePolicy["id"];
|
|
13
|
-
readonly moonPosition: {
|
|
14
|
-
readonly frame: string;
|
|
15
|
-
readonly center: string;
|
|
16
|
-
readonly units: "km";
|
|
17
|
-
readonly positionKm: Triple;
|
|
18
|
-
};
|
|
19
|
-
readonly moonDistanceKm: number;
|
|
20
|
-
/** Earth–Moon distance in scene units (Earth radii) from the same mapping that places the bodies. */
|
|
21
|
-
readonly renderedDistanceUnits: number;
|
|
22
|
-
readonly earthOrientation: Quad | null;
|
|
23
|
-
readonly moonOrientation: Quad | null;
|
|
24
|
-
readonly earthSunDirection: Triple;
|
|
25
|
-
readonly moonSunDirection: Triple;
|
|
26
|
-
/** Fraction of the child's disc lit, seen from the parent's centre (any satellite pair, not only the Moon). */
|
|
27
|
-
readonly lunarIlluminatedFraction: number;
|
|
28
|
-
/** Labels of the measured pair; absent means Earth and Moon. */
|
|
29
|
-
readonly pair?: PairLabels;
|
|
30
|
-
readonly scaledOrigin: Triple;
|
|
31
|
-
readonly earthLocal: Triple;
|
|
32
|
-
readonly moonLocal: Triple;
|
|
33
|
-
}
|
|
34
|
-
/** Display names of the pair the readout measures. */
|
|
35
|
-
export interface PairLabels {
|
|
36
|
-
readonly parent: string;
|
|
37
|
-
readonly child: string;
|
|
38
|
-
}
|
|
39
|
-
export declare const EARTH_MOON_LABELS: PairLabels;
|
|
40
|
-
export interface DebugReadoutInput {
|
|
41
|
-
readonly pair?: PairLabels;
|
|
42
|
-
readonly timeUtcMs: number;
|
|
43
|
-
readonly rate: number;
|
|
44
|
-
readonly policy: ScalePolicy;
|
|
45
|
-
readonly earth: State;
|
|
46
|
-
readonly moonFromEarth: State;
|
|
47
|
-
readonly sunFromEarth: CenteredPosition;
|
|
48
|
-
readonly placed: PlacedState;
|
|
49
|
-
readonly renderedDistanceUnits: number;
|
|
50
|
-
readonly origin: FloatingOrigin;
|
|
51
|
-
}
|
|
52
|
-
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
53
|
-
export declare function buildDebugReadout(input: DebugReadoutInput): DebugReadout;
|
|
3
|
+
export { buildDebugReadout, EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
4
|
+
export type { DebugReadout, DebugReadoutInput, PairLabels } from "./debugReadout.js";
|
|
54
5
|
/** Ordered label/value rows; kept separate from JSX so tests can read what the overlay shows. */
|
|
55
6
|
export declare function overlayRows(r: DebugReadout): ReadonlyArray<readonly [string, string]>;
|
|
56
7
|
export declare function DebugOverlay({ readout }: {
|
package/src/app/DebugOverlay.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { directionFromCenterToSun, directionToSun, illuminatedFraction } from "../core/illumination.js";
|
|
3
2
|
import { describePlaybackRate, formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
4
3
|
import { MetricVisual } from "../shell/MetricVisual.js";
|
|
5
4
|
import { sceneMetrics } from "./metricReadouts.js";
|
|
5
|
+
import { EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
6
6
|
export { formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
7
|
-
export
|
|
8
|
-
const triple = (v) => [v[0], v[1], v[2]];
|
|
9
|
-
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
10
|
-
export function buildDebugReadout(input) {
|
|
11
|
-
const { moonFromEarth, sunFromEarth, origin, placed } = input;
|
|
12
|
-
return {
|
|
13
|
-
timeUtcMs: input.timeUtcMs,
|
|
14
|
-
rate: input.rate,
|
|
15
|
-
policyId: input.policy.id,
|
|
16
|
-
...(input.pair === undefined ? {} : { pair: input.pair }),
|
|
17
|
-
moonPosition: {
|
|
18
|
-
frame: moonFromEarth.frame,
|
|
19
|
-
center: moonFromEarth.center,
|
|
20
|
-
units: "km",
|
|
21
|
-
positionKm: triple(moonFromEarth.positionKm),
|
|
22
|
-
},
|
|
23
|
-
moonDistanceKm: Math.hypot(...triple(moonFromEarth.positionKm)),
|
|
24
|
-
renderedDistanceUnits: input.renderedDistanceUnits,
|
|
25
|
-
earthOrientation: input.earth.orientation,
|
|
26
|
-
moonOrientation: moonFromEarth.orientation,
|
|
27
|
-
earthSunDirection: triple(directionFromCenterToSun(sunFromEarth)),
|
|
28
|
-
moonSunDirection: triple(directionToSun(moonFromEarth, sunFromEarth)),
|
|
29
|
-
lunarIlluminatedFraction: illuminatedFraction(moonFromEarth, sunFromEarth),
|
|
30
|
-
scaledOrigin: triple(origin.scaledCameraOrigin),
|
|
31
|
-
earthLocal: triple(origin.toLocal(placed.earthAbsolute)),
|
|
32
|
-
moonLocal: triple(origin.toLocal(placed.moonAbsolute)),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
7
|
+
export { buildDebugReadout, EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
35
8
|
const vec = (v, digits) => `(${v.map((c) => c.toFixed(digits)).join(", ")})`;
|
|
36
9
|
/** Ordered label/value rows; kept separate from JSX so tests can read what the overlay shows. */
|
|
37
10
|
export function overlayRows(r) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Component, type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Catches a failed on-demand load of a panel (the developer panels, the moon families; `message` replaces the default text) (offline, or a tab left open across a redeploy) so the
|
|
4
|
+
* rest of the app keeps drawing; React.lazy keeps the failed load, so the message asks for a reload.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PanelLoadBoundary extends Component<{
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
message?: string;
|
|
9
|
+
}, {
|
|
10
|
+
failed: boolean;
|
|
11
|
+
}> {
|
|
12
|
+
state: {
|
|
13
|
+
failed: boolean;
|
|
14
|
+
};
|
|
15
|
+
static getDerivedStateFromError(): {
|
|
16
|
+
failed: boolean;
|
|
17
|
+
};
|
|
18
|
+
render(): ReactNode;
|
|
19
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Catches a failed on-demand load of a panel (the developer panels, the moon families; `message` replaces the default text) (offline, or a tab left open across a redeploy) so the
|
|
5
|
+
* rest of the app keeps drawing; React.lazy keeps the failed load, so the message asks for a reload.
|
|
6
|
+
*/
|
|
7
|
+
export class PanelLoadBoundary extends Component {
|
|
8
|
+
state = { failed: false };
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
return { failed: true };
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
if (this.state.failed)
|
|
14
|
+
return _jsx("p", { className: "developer-loading", role: "alert", children: this.props.message ?? "Developer tools could not load. Reload the page to try again." });
|
|
15
|
+
return this.props.children;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/app/SkyView.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ export interface SkyViewOptions {
|
|
|
11
11
|
readonly maxAnisotropy?: number;
|
|
12
12
|
/** Whether the picture is drawn. Defaults to true. */
|
|
13
13
|
readonly milkyWay?: boolean;
|
|
14
|
-
/** Legacy:
|
|
14
|
+
/** Legacy: ready textures, one per tile (a test may pass empty ones). Overrides `picture`. */
|
|
15
15
|
readonly pictures?: readonly Texture[];
|
|
16
|
-
/** The picture to draw, as a tile grid; defaults to the
|
|
16
|
+
/** The picture to draw, as a tile grid; defaults to the Milky Way picture. `null` draws none until `requestPicture` is called. */
|
|
17
17
|
readonly picture?: PictureSet | null;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -26,7 +26,7 @@ export declare class SkyView {
|
|
|
26
26
|
readonly group: Group<import("three").Object3DEventMap>;
|
|
27
27
|
/** `options.picture` is the tile set; the scene passes the one it resolved, a test may pass `pictures` (empty textures). */
|
|
28
28
|
constructor(options: SkyViewOptions);
|
|
29
|
-
/** Builds the
|
|
29
|
+
/** Builds the Milky Way picture the first time it is wanted (nothing is decoded while the picture stays off); a no-op once a picture is held. */
|
|
30
30
|
requestPicture(): void;
|
|
31
31
|
/** Sets the star strength in place (0 to 2); no rebuild. */
|
|
32
32
|
setStarBrightness(value: number): void;
|