astraeus 0.8.1 → 0.9.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 +67 -0
- package/README.md +28 -15
- package/package.json +1 -1
- package/src/api/AstraeusScene.d.ts +1 -1
- package/src/api/AstraeusScene.js +4 -1
- package/src/api/AstraeusScene.node.js +4 -1
- package/src/api/assembleScene.d.ts +2 -0
- package/src/api/assembleScene.js +27 -5
- package/src/api/cameraRequest.d.ts +15 -0
- package/src/api/cameraRequest.js +89 -0
- package/src/api/errors.d.ts +9 -1
- package/src/api/index.d.ts +6 -3
- package/src/api/look.d.ts +49 -0
- package/src/api/lookInput.d.ts +1 -1
- package/src/api/lookInput.js +6 -1
- package/src/api/planCamera.d.ts +35 -7
- package/src/api/planCamera.js +94 -11
- package/src/api/planSkyFigures.d.ts +22 -0
- package/src/api/planSkyFigures.js +145 -0
- package/src/api/planStory.d.ts +2 -2
- package/src/api/planStory.js +14 -9
- package/src/api/planViews.js +1 -1
- package/src/api/scene.d.ts +17 -4
- package/src/api/scene.js +23 -5
- package/src/api/sceneReads.d.ts +21 -2
- package/src/api/skyFigureInput.d.ts +45 -0
- package/src/api/skyFigureInput.js +1 -0
- package/src/api/skyTraceInput.d.ts +33 -0
- package/src/api/skyTraceInput.js +45 -0
- package/src/api/story.d.ts +12 -3
- package/src/api/story.js +44 -1
- package/src/api/viewerCamera.d.ts +4 -3
- package/src/api/viewerCamera.js +10 -32
- package/src/api/viewerHandle.d.ts +27 -4
- package/src/api/viewerHandle.js +6 -0
- package/src/api/viewerLink.d.ts +49 -4
- package/src/api/viewerLink.js +25 -0
- package/src/api/viewerPanels.d.ts +26 -0
- package/src/api/viewerPanels.js +42 -0
- package/src/api/viewerSelection.d.ts +1 -1
- package/src/api/viewerSelection.js +3 -3
- package/src/app/App.js +100 -18
- package/src/app/App.node.js +100 -18
- package/src/app/AstraeusScene.d.ts +20 -5
- package/src/app/AstraeusScene.js +3 -3
- package/src/app/CameraController.d.ts +17 -0
- package/src/app/CameraController.js +34 -9
- package/src/app/DeveloperSettings.d.ts +11 -3
- package/src/app/DeveloperSettings.js +13 -3
- package/src/app/SceneLabels.d.ts +20 -2
- package/src/app/SceneLabels.js +46 -6
- package/src/app/SkyFiguresView.d.ts +56 -0
- package/src/app/SkyFiguresView.js +242 -0
- package/src/app/StoryMarkers.d.ts +2 -2
- package/src/app/StoryMarkers.js +2 -2
- package/src/app/displaySwitches.d.ts +13 -3
- package/src/app/displaySwitches.js +17 -3
- package/src/app/experienceDefinition.d.ts +9 -3
- package/src/app/experienceDefinition.js +4 -2
- package/src/app/labelStyle.d.ts +17 -0
- package/src/app/labelStyle.js +13 -0
- package/src/app/liveLook.js +8 -0
- package/src/app/look.d.ts +9 -5
- package/src/app/look.js +11 -0
- package/src/app/lookOut.d.ts +32 -0
- package/src/app/lookOut.js +50 -0
- package/src/app/sceneCamera.d.ts +5 -3
- package/src/app/sceneCamera.js +66 -3
- package/src/app/sceneContentsHooks.d.ts +2 -1
- package/src/app/sceneContentsHooks.js +3 -2
- package/src/app/sceneFrame.d.ts +10 -1
- package/src/app/sceneFrame.js +45 -10
- package/src/app/sceneFraming.d.ts +7 -0
- package/src/app/sceneFraming.js +12 -0
- package/src/app/sceneHooks.d.ts +2 -0
- package/src/app/sceneHooks.js +4 -1
- package/src/app/scenePicking.d.ts +20 -0
- package/src/app/scenePicking.js +49 -0
- package/src/app/scenePointer.d.ts +3 -1
- package/src/app/scenePointer.js +3 -2
- package/src/app/skyFigures.d.ts +73 -0
- package/src/app/skyFigures.js +50 -0
- package/src/app/style.css +2 -1
- package/src/app/viewHiding.d.ts +2 -0
- package/src/app/viewHiding.js +7 -1
- package/src/app/viewLink.d.ts +8 -8
- package/src/app/viewLink.js +24 -4
- package/src/app/viewerPort.d.ts +30 -3
- package/src/assets/sky.d.ts +13 -4
- package/src/assets/sky.js +33 -8
- package/src/assets/stars/hyg-v42-naked-eye.json +1 -1
- package/src/core/bodies/moonSystem.js +1 -15
- package/src/core/lookValues.d.ts +9 -0
- package/src/core/lookValues.js +24 -0
- package/src/core/readBytes.d.ts +1 -0
- package/src/core/readBytes.js +15 -0
- package/src/core/skyTrace.d.ts +49 -0
- package/src/core/skyTrace.js +39 -0
- package/src/core/startView.d.ts +39 -0
- package/src/core/startView.js +56 -0
- package/src/core/storyPanels.d.ts +51 -3
- package/src/core/storyPanels.js +52 -12
- package/src/shell/AstraeusShell.d.ts +15 -6
- package/src/shell/AstraeusShell.js +76 -20
- package/src/shell/AstraeusShell.node.js +76 -20
- package/src/shell/ObjectControls.js +11 -8
- package/src/shell/StoryPanelView.d.ts +12 -3
- package/src/shell/StoryPanelView.js +2 -2
- package/src/shell/experience.d.ts +24 -0
- package/src/shell/experience.js +4 -1
- package/src/shell/infoModel.js +9 -1
- package/src/shell/objectModel.d.ts +6 -2
- package/src/shell/objectModel.js +10 -1
- package/src/shell/phone.css +1 -1
- package/src/shell/storyPanels.d.ts +1 -1
- package/src/shell/storyPanels.js +1 -1
- package/src/shell/style.css +9 -1
- package/src/shell/topBarIcons.d.ts +1 -0
- package/src/shell/topBarIcons.js +1 -0
- package/src/shell/useStoryPanels.d.ts +9 -6
- package/src/shell/useStoryPanels.js +10 -6
|
@@ -3,16 +3,19 @@ import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";
|
|
|
3
3
|
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
4
|
import { useDrawers } from "./useDrawers.js";
|
|
5
5
|
import { useStoryPanels } from "./useStoryPanels.js";
|
|
6
|
+
import { neighbourStep } from "./storyPanels.js";
|
|
6
7
|
import { TimelineBar } from "./TimelineBar.js";
|
|
8
|
+
import { requestObjectId } from "./experience.js";
|
|
7
9
|
import { InfoPanel } from "./InfoPanel.js";
|
|
8
10
|
import { infoView } from "./infoModel.js";
|
|
9
11
|
import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
10
12
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
13
|
import { isEmbedded } from "./embedded.js";
|
|
14
|
+
import { labelStyleVars } from "../app/labelStyle.js";
|
|
12
15
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
16
|
import { presetForViewRule } from "./viewCamera.js";
|
|
14
17
|
import { DeveloperToggle, TopBar } from "./TopBar.js";
|
|
15
|
-
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
18
|
+
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable, skyFigureById } from "./objectModel.js";
|
|
16
19
|
import "./controls.css";
|
|
17
20
|
import "./style.css";
|
|
18
21
|
import "./phone.css";
|
|
@@ -35,8 +38,9 @@ function useTimelineSpace(root, phone) {
|
|
|
35
38
|
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
36
39
|
export function initialObjectId(experience, timeUtcMs) {
|
|
37
40
|
const start = experience.cameraPresets.find((preset) => preset.id === experience.startCameraPresetId)?.request;
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
const startId = start === undefined ? undefined : requestObjectId(start);
|
|
42
|
+
if (startId !== undefined && experience.objects.some((object) => object.id === startId))
|
|
43
|
+
return startId;
|
|
40
44
|
return firstAvailableObject(experience, timeUtcMs)?.id ?? experience.objects[0]?.id ?? "";
|
|
41
45
|
}
|
|
42
46
|
/** The story-panel settings the experience carries itself, used when the app gives none live. */
|
|
@@ -62,8 +66,9 @@ function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
|
62
66
|
}
|
|
63
67
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
64
68
|
/** Whether the selection has been lost and a fallback must take its place: the object is gone or not available now, unless the host cleared the selection on purpose. */
|
|
65
|
-
function selectionLost(selected, timeUtcMs, clearedByHost) {
|
|
66
|
-
|
|
69
|
+
function selectionLost(selected, timeUtcMs, clearedByHost, isFigure) {
|
|
70
|
+
// A selected sky figure is never lost: it has no availability and no view hides it.
|
|
71
|
+
return !clearedByHost && !isFigure && (selected === undefined || !isObjectAvailable(selected, timeUtcMs));
|
|
67
72
|
}
|
|
68
73
|
function serialOf(request) {
|
|
69
74
|
return request?.serial;
|
|
@@ -82,21 +87,44 @@ function useViewSwitch(viewCamera) {
|
|
|
82
87
|
function panelsOf(storySet) {
|
|
83
88
|
return storySet?.panels ?? [];
|
|
84
89
|
}
|
|
90
|
+
/** Back and Next for the open panel when it is a step: each is absent where there is no neighbour. */
|
|
91
|
+
function stepNavOf(panel, steps, open) {
|
|
92
|
+
if (panel === null || !("step" in panel))
|
|
93
|
+
return undefined;
|
|
94
|
+
const to = (by) => {
|
|
95
|
+
const neighbour = neighbourStep(steps, panel, by);
|
|
96
|
+
return neighbour === undefined ? undefined : () => open(neighbour.id);
|
|
97
|
+
};
|
|
98
|
+
return { number: panel.step, count: steps.length, onBack: to(-1), onNext: to(1) };
|
|
99
|
+
}
|
|
100
|
+
/** A request to open a panel (a marker press or the host's `setPanel`; id "" closes the open one), told with who made it. */
|
|
101
|
+
function applyPanelRequest(story, request) {
|
|
102
|
+
if (request === null || request === undefined)
|
|
103
|
+
return;
|
|
104
|
+
const by = request.host === true ? "host" : "visitor";
|
|
105
|
+
if (request.id === "")
|
|
106
|
+
story.close(by);
|
|
107
|
+
else
|
|
108
|
+
story.open(request.id, by);
|
|
109
|
+
}
|
|
110
|
+
function stepsOf(storySet) {
|
|
111
|
+
return storySet?.steps ?? [];
|
|
112
|
+
}
|
|
85
113
|
function objectLabelOr(experience, objectId, fallback) {
|
|
86
|
-
return experience.objects.find((object) => object.id === objectId)?.label ?? fallback;
|
|
114
|
+
return experience.objects.find((object) => object.id === objectId)?.label ?? skyFigureById(experience, objectId)?.label ?? fallback;
|
|
87
115
|
}
|
|
88
116
|
/** The information panel's content and, for an object, its live measurements. */
|
|
89
117
|
function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor) {
|
|
90
118
|
const view = info === null
|
|
91
119
|
? null
|
|
92
120
|
: infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs);
|
|
93
|
-
const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
121
|
+
const metrics = view?.target.kind === "object" && metricsFor !== undefined && skyFigureById(experience, view.target.id) === undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
94
122
|
return { view, metrics };
|
|
95
123
|
}
|
|
96
124
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
97
125
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
98
126
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
99
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
127
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onTurnToFigure, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, labelStyle, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
100
128
|
const infoPanelId = `${useId()}-info-panel`;
|
|
101
129
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
102
130
|
const phone = usePhone();
|
|
@@ -116,17 +144,23 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
116
144
|
const [info, setInfo] = useState(null);
|
|
117
145
|
const storySet = experience.storyPanels;
|
|
118
146
|
const storyPanels = panelsOf(storySet);
|
|
119
|
-
const
|
|
147
|
+
const storySteps = stepsOf(storySet);
|
|
148
|
+
const story = useStoryPanels(storyPanels, storySteps, storyPanelSettings ?? ownStorySettings(storySet), snapshot, onSetPlaying);
|
|
120
149
|
if (storySeekNote !== undefined)
|
|
121
150
|
storySeekNote.current = story.noteSeek;
|
|
122
151
|
useEffect(() => () => { if (storySeekNote !== undefined)
|
|
123
152
|
storySeekNote.current = null; }, [storySeekNote]);
|
|
124
153
|
const openPanelId = story.openPanel?.id ?? null;
|
|
125
|
-
|
|
154
|
+
const storyCause = story.cause;
|
|
155
|
+
// Only a change of the open panel is reported; the cause read then is the one that change came with.
|
|
156
|
+
const lastCause = useRef(storyCause);
|
|
157
|
+
lastCause.current = storyCause;
|
|
158
|
+
useEffect(() => { onOpenPanelChange?.(openPanelId, lastCause.current); }, [onOpenPanelChange, openPanelId]);
|
|
159
|
+
const closePanel = () => story.close();
|
|
160
|
+
const stepNav = stepNavOf(story.openPanel, storySteps, story.open);
|
|
126
161
|
const requestedSerial = serialOf(panelRequest);
|
|
127
162
|
useEffect(() => {
|
|
128
|
-
|
|
129
|
-
story.open(panelRequest.id);
|
|
163
|
+
applyPanelRequest(story, panelRequest);
|
|
130
164
|
// Only a new request opens a panel; the open function is stable.
|
|
131
165
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
166
|
}, [requestedSerial]);
|
|
@@ -160,7 +194,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
160
194
|
if (selectedObjectId !== "")
|
|
161
195
|
hostCleared.current = false;
|
|
162
196
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
163
|
-
if (selectionLost(selected, snapshot.timeUtcMs, hostCleared.current && selectedObjectId === "")) {
|
|
197
|
+
if (selectionLost(selected, snapshot.timeUtcMs, hostCleared.current && selectedObjectId === "", skyFigureById(experience, selectedObjectId) !== undefined)) {
|
|
164
198
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
165
199
|
setSelectedObjectId(fallbackId);
|
|
166
200
|
onSelectionChange(fallbackId, "move");
|
|
@@ -174,7 +208,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
174
208
|
applyViewRule(switchRule); // opted in: the view's framing applies on every switch to it
|
|
175
209
|
}
|
|
176
210
|
else if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
177
|
-
const target = experience.objects.find((object) => object.id === activeRequest
|
|
211
|
+
const target = experience.objects.find((object) => object.id === requestObjectId(activeRequest));
|
|
178
212
|
if (switchRule !== undefined && target === undefined) {
|
|
179
213
|
applyViewRule(switchRule);
|
|
180
214
|
}
|
|
@@ -196,7 +230,9 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
196
230
|
hostCleared.current = selectRequest.id === "";
|
|
197
231
|
setSelectedObjectId(selectRequest.id);
|
|
198
232
|
// As a visitor's menu choice does: the object's card opens (the camera is left alone); a clear closes it.
|
|
199
|
-
|
|
233
|
+
// A story panel's select (`quiet`) follows the visitor-tap rule: on a phone it selects without opening the card, which would cover the panel's Back and Next.
|
|
234
|
+
const opens = selectRequest.quiet === true ? pickOpensInfo(phone) : true;
|
|
235
|
+
setInfo((now) => (selectRequest.id === "" ? (now?.kind === "object" ? null : now) : opens ? { kind: "object" } : now));
|
|
200
236
|
onSelectRequestApplied?.();
|
|
201
237
|
// Only a new request applies.
|
|
202
238
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -204,7 +240,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
204
240
|
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
205
241
|
const applyViewRule = (rule) => {
|
|
206
242
|
const asked = presetForViewRule(rule, experience);
|
|
207
|
-
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request
|
|
243
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, requestObjectId(asked.request) ?? "", snapshot.timeUtcMs);
|
|
208
244
|
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
209
245
|
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
210
246
|
if (target !== undefined) {
|
|
@@ -231,7 +267,10 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
231
267
|
/** 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. */
|
|
232
268
|
const pickObject = (id) => {
|
|
233
269
|
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
234
|
-
if (
|
|
270
|
+
if (skyFigureById(experience, id) !== undefined) {
|
|
271
|
+
selectFigure(id, pickOpensInfo(phone));
|
|
272
|
+
}
|
|
273
|
+
else if (object !== undefined) {
|
|
235
274
|
activatePreset(focusPresetFor(experience, object));
|
|
236
275
|
if (pickOpensInfo(phone))
|
|
237
276
|
setInfo({ kind: "object" });
|
|
@@ -246,7 +285,18 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
246
285
|
// Only a new request flies; the handler reads the current time and experience.
|
|
247
286
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
248
287
|
}, [requestedPickSerial]);
|
|
288
|
+
/** A sky figure chosen in the object menu or tapped in the scene: it becomes the selection (the one selection path) and its card opens when `open`; the camera is left alone. */
|
|
289
|
+
const selectFigure = (id, open) => {
|
|
290
|
+
setSelectedObjectId(id);
|
|
291
|
+
onSelectionChange(id, "visitor");
|
|
292
|
+
if (open)
|
|
293
|
+
setInfo({ kind: "object" });
|
|
294
|
+
};
|
|
249
295
|
const selectObject = (id) => {
|
|
296
|
+
if (skyFigureById(experience, id) !== undefined) {
|
|
297
|
+
selectFigure(id, true);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
250
300
|
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
251
301
|
if (object === undefined)
|
|
252
302
|
return;
|
|
@@ -270,8 +320,9 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
270
320
|
}
|
|
271
321
|
};
|
|
272
322
|
const activatePreset = (preset, atUtcMs = snapshot.timeUtcMs) => {
|
|
273
|
-
|
|
274
|
-
|
|
323
|
+
const objectId = requestObjectId(preset.request);
|
|
324
|
+
if (objectId !== undefined) {
|
|
325
|
+
const target = availableObjectById(experience, objectId, atUtcMs);
|
|
275
326
|
if (target === undefined)
|
|
276
327
|
return;
|
|
277
328
|
setSelectedObjectId(target.id);
|
|
@@ -286,6 +337,11 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
286
337
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
287
338
|
if (object !== undefined)
|
|
288
339
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
340
|
+
// A sky figure is selected (its card stays as it is) and turned toward only while the camera looks out.
|
|
341
|
+
else if (event.object !== undefined && skyFigureById(experience, event.object) !== undefined) {
|
|
342
|
+
selectFigure(event.object, false);
|
|
343
|
+
onTurnToFigure?.(event.object);
|
|
344
|
+
}
|
|
289
345
|
if (info?.kind === "event")
|
|
290
346
|
setInfo({ kind: "event", id: event.id });
|
|
291
347
|
};
|
|
@@ -306,5 +362,5 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
306
362
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
307
363
|
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
308
364
|
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 }) }) }));
|
|
309
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose:
|
|
365
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: { ...phoneLayoutStyle(phoneLayout), ...labelStyleVars(labelStyle) }, children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: closePanel, onContinue: story.continuePlayback, step: stepNav })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
310
366
|
}
|
|
@@ -3,16 +3,19 @@ import { lazy, Suspense, useEffect, useId, useRef, useState } from "react";
|
|
|
3
3
|
import { StoryPanelView } from "./StoryPanelView.js";
|
|
4
4
|
import { useDrawers } from "./useDrawers.js";
|
|
5
5
|
import { useStoryPanels } from "./useStoryPanels.js";
|
|
6
|
+
import { neighbourStep } from "./storyPanels.js";
|
|
6
7
|
import { TimelineBar } from "./TimelineBar.node.js";
|
|
8
|
+
import { requestObjectId } from "./experience.js";
|
|
7
9
|
import { InfoPanel } from "./InfoPanel.js";
|
|
8
10
|
import { infoView } from "./infoModel.js";
|
|
9
11
|
import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
10
12
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
13
|
import { isEmbedded } from "./embedded.js";
|
|
14
|
+
import { labelStyleVars } from "../app/labelStyle.js";
|
|
12
15
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
16
|
import { presetForViewRule } from "./viewCamera.js";
|
|
14
17
|
import { DeveloperToggle, TopBar } from "./TopBar.node.js";
|
|
15
|
-
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
18
|
+
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable, skyFigureById } from "./objectModel.js";
|
|
16
19
|
/** 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. */
|
|
17
20
|
function useTimelineSpace(root, phone) {
|
|
18
21
|
useEffect(() => {
|
|
@@ -31,8 +34,9 @@ function useTimelineSpace(root, phone) {
|
|
|
31
34
|
/** The object selected when the shell opens: the first one available at the clock time, else the first listed. */
|
|
32
35
|
export function initialObjectId(experience, timeUtcMs) {
|
|
33
36
|
const start = experience.cameraPresets.find((preset) => preset.id === experience.startCameraPresetId)?.request;
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
const startId = start === undefined ? undefined : requestObjectId(start);
|
|
38
|
+
if (startId !== undefined && experience.objects.some((object) => object.id === startId))
|
|
39
|
+
return startId;
|
|
36
40
|
return firstAvailableObject(experience, timeUtcMs)?.id ?? experience.objects[0]?.id ?? "";
|
|
37
41
|
}
|
|
38
42
|
/** The story-panel settings the experience carries itself, used when the app gives none live. */
|
|
@@ -58,8 +62,9 @@ function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
|
58
62
|
}
|
|
59
63
|
/** The serial of a request that is asked again by sending a new one; absent request: undefined. */
|
|
60
64
|
/** Whether the selection has been lost and a fallback must take its place: the object is gone or not available now, unless the host cleared the selection on purpose. */
|
|
61
|
-
function selectionLost(selected, timeUtcMs, clearedByHost) {
|
|
62
|
-
|
|
65
|
+
function selectionLost(selected, timeUtcMs, clearedByHost, isFigure) {
|
|
66
|
+
// A selected sky figure is never lost: it has no availability and no view hides it.
|
|
67
|
+
return !clearedByHost && !isFigure && (selected === undefined || !isObjectAvailable(selected, timeUtcMs));
|
|
63
68
|
}
|
|
64
69
|
function serialOf(request) {
|
|
65
70
|
return request?.serial;
|
|
@@ -78,21 +83,44 @@ function useViewSwitch(viewCamera) {
|
|
|
78
83
|
function panelsOf(storySet) {
|
|
79
84
|
return storySet?.panels ?? [];
|
|
80
85
|
}
|
|
86
|
+
/** Back and Next for the open panel when it is a step: each is absent where there is no neighbour. */
|
|
87
|
+
function stepNavOf(panel, steps, open) {
|
|
88
|
+
if (panel === null || !("step" in panel))
|
|
89
|
+
return undefined;
|
|
90
|
+
const to = (by) => {
|
|
91
|
+
const neighbour = neighbourStep(steps, panel, by);
|
|
92
|
+
return neighbour === undefined ? undefined : () => open(neighbour.id);
|
|
93
|
+
};
|
|
94
|
+
return { number: panel.step, count: steps.length, onBack: to(-1), onNext: to(1) };
|
|
95
|
+
}
|
|
96
|
+
/** A request to open a panel (a marker press or the host's `setPanel`; id "" closes the open one), told with who made it. */
|
|
97
|
+
function applyPanelRequest(story, request) {
|
|
98
|
+
if (request === null || request === undefined)
|
|
99
|
+
return;
|
|
100
|
+
const by = request.host === true ? "host" : "visitor";
|
|
101
|
+
if (request.id === "")
|
|
102
|
+
story.close(by);
|
|
103
|
+
else
|
|
104
|
+
story.open(request.id, by);
|
|
105
|
+
}
|
|
106
|
+
function stepsOf(storySet) {
|
|
107
|
+
return storySet?.steps ?? [];
|
|
108
|
+
}
|
|
81
109
|
function objectLabelOr(experience, objectId, fallback) {
|
|
82
|
-
return experience.objects.find((object) => object.id === objectId)?.label ?? fallback;
|
|
110
|
+
return experience.objects.find((object) => object.id === objectId)?.label ?? skyFigureById(experience, objectId)?.label ?? fallback;
|
|
83
111
|
}
|
|
84
112
|
/** The information panel's content and, for an object, its live measurements. */
|
|
85
113
|
function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor) {
|
|
86
114
|
const view = info === null
|
|
87
115
|
? null
|
|
88
116
|
: infoView(experience, info.kind === "object" ? { kind: "object", id: selectedObjectId } : info, timeUtcMs);
|
|
89
|
-
const metrics = view?.target.kind === "object" && metricsFor !== undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
117
|
+
const metrics = view?.target.kind === "object" && metricsFor !== undefined && skyFigureById(experience, view.target.id) === undefined ? metricsFor(view.target.id, timeUtcMs) : [];
|
|
90
118
|
return { view, metrics };
|
|
91
119
|
}
|
|
92
120
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
93
121
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
94
122
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
95
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
123
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onTurnToFigure, onCameraHold, hostCameraSet, storySeekNote, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, labelStyle, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, selectRequest, onSelectRequestApplied, children, }) {
|
|
96
124
|
const infoPanelId = `${useId()}-info-panel`;
|
|
97
125
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
98
126
|
const phone = usePhone();
|
|
@@ -112,17 +140,23 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
112
140
|
const [info, setInfo] = useState(null);
|
|
113
141
|
const storySet = experience.storyPanels;
|
|
114
142
|
const storyPanels = panelsOf(storySet);
|
|
115
|
-
const
|
|
143
|
+
const storySteps = stepsOf(storySet);
|
|
144
|
+
const story = useStoryPanels(storyPanels, storySteps, storyPanelSettings ?? ownStorySettings(storySet), snapshot, onSetPlaying);
|
|
116
145
|
if (storySeekNote !== undefined)
|
|
117
146
|
storySeekNote.current = story.noteSeek;
|
|
118
147
|
useEffect(() => () => { if (storySeekNote !== undefined)
|
|
119
148
|
storySeekNote.current = null; }, [storySeekNote]);
|
|
120
149
|
const openPanelId = story.openPanel?.id ?? null;
|
|
121
|
-
|
|
150
|
+
const storyCause = story.cause;
|
|
151
|
+
// Only a change of the open panel is reported; the cause read then is the one that change came with.
|
|
152
|
+
const lastCause = useRef(storyCause);
|
|
153
|
+
lastCause.current = storyCause;
|
|
154
|
+
useEffect(() => { onOpenPanelChange?.(openPanelId, lastCause.current); }, [onOpenPanelChange, openPanelId]);
|
|
155
|
+
const closePanel = () => story.close();
|
|
156
|
+
const stepNav = stepNavOf(story.openPanel, storySteps, story.open);
|
|
122
157
|
const requestedSerial = serialOf(panelRequest);
|
|
123
158
|
useEffect(() => {
|
|
124
|
-
|
|
125
|
-
story.open(panelRequest.id);
|
|
159
|
+
applyPanelRequest(story, panelRequest);
|
|
126
160
|
// Only a new request opens a panel; the open function is stable.
|
|
127
161
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
162
|
}, [requestedSerial]);
|
|
@@ -156,7 +190,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
156
190
|
if (selectedObjectId !== "")
|
|
157
191
|
hostCleared.current = false;
|
|
158
192
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
159
|
-
if (selectionLost(selected, snapshot.timeUtcMs, hostCleared.current && selectedObjectId === "")) {
|
|
193
|
+
if (selectionLost(selected, snapshot.timeUtcMs, hostCleared.current && selectedObjectId === "", skyFigureById(experience, selectedObjectId) !== undefined)) {
|
|
160
194
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
161
195
|
setSelectedObjectId(fallbackId);
|
|
162
196
|
onSelectionChange(fallbackId, "move");
|
|
@@ -170,7 +204,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
170
204
|
applyViewRule(switchRule); // opted in: the view's framing applies on every switch to it
|
|
171
205
|
}
|
|
172
206
|
else if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
173
|
-
const target = experience.objects.find((object) => object.id === activeRequest
|
|
207
|
+
const target = experience.objects.find((object) => object.id === requestObjectId(activeRequest));
|
|
174
208
|
if (switchRule !== undefined && target === undefined) {
|
|
175
209
|
applyViewRule(switchRule);
|
|
176
210
|
}
|
|
@@ -192,7 +226,9 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
192
226
|
hostCleared.current = selectRequest.id === "";
|
|
193
227
|
setSelectedObjectId(selectRequest.id);
|
|
194
228
|
// As a visitor's menu choice does: the object's card opens (the camera is left alone); a clear closes it.
|
|
195
|
-
|
|
229
|
+
// A story panel's select (`quiet`) follows the visitor-tap rule: on a phone it selects without opening the card, which would cover the panel's Back and Next.
|
|
230
|
+
const opens = selectRequest.quiet === true ? pickOpensInfo(phone) : true;
|
|
231
|
+
setInfo((now) => (selectRequest.id === "" ? (now?.kind === "object" ? null : now) : opens ? { kind: "object" } : now));
|
|
196
232
|
onSelectRequestApplied?.();
|
|
197
233
|
// Only a new request applies.
|
|
198
234
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -200,7 +236,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
200
236
|
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
201
237
|
const applyViewRule = (rule) => {
|
|
202
238
|
const asked = presetForViewRule(rule, experience);
|
|
203
|
-
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request
|
|
239
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, requestObjectId(asked.request) ?? "", snapshot.timeUtcMs);
|
|
204
240
|
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
205
241
|
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
206
242
|
if (target !== undefined) {
|
|
@@ -227,7 +263,10 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
227
263
|
/** 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. */
|
|
228
264
|
const pickObject = (id) => {
|
|
229
265
|
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
230
|
-
if (
|
|
266
|
+
if (skyFigureById(experience, id) !== undefined) {
|
|
267
|
+
selectFigure(id, pickOpensInfo(phone));
|
|
268
|
+
}
|
|
269
|
+
else if (object !== undefined) {
|
|
231
270
|
activatePreset(focusPresetFor(experience, object));
|
|
232
271
|
if (pickOpensInfo(phone))
|
|
233
272
|
setInfo({ kind: "object" });
|
|
@@ -242,7 +281,18 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
242
281
|
// Only a new request flies; the handler reads the current time and experience.
|
|
243
282
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
283
|
}, [requestedPickSerial]);
|
|
284
|
+
/** A sky figure chosen in the object menu or tapped in the scene: it becomes the selection (the one selection path) and its card opens when `open`; the camera is left alone. */
|
|
285
|
+
const selectFigure = (id, open) => {
|
|
286
|
+
setSelectedObjectId(id);
|
|
287
|
+
onSelectionChange(id, "visitor");
|
|
288
|
+
if (open)
|
|
289
|
+
setInfo({ kind: "object" });
|
|
290
|
+
};
|
|
245
291
|
const selectObject = (id) => {
|
|
292
|
+
if (skyFigureById(experience, id) !== undefined) {
|
|
293
|
+
selectFigure(id, true);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
246
296
|
const object = availableObjectById(experience, id, snapshot.timeUtcMs);
|
|
247
297
|
if (object === undefined)
|
|
248
298
|
return;
|
|
@@ -266,8 +316,9 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
266
316
|
}
|
|
267
317
|
};
|
|
268
318
|
const activatePreset = (preset, atUtcMs = snapshot.timeUtcMs) => {
|
|
269
|
-
|
|
270
|
-
|
|
319
|
+
const objectId = requestObjectId(preset.request);
|
|
320
|
+
if (objectId !== undefined) {
|
|
321
|
+
const target = availableObjectById(experience, objectId, atUtcMs);
|
|
271
322
|
if (target === undefined)
|
|
272
323
|
return;
|
|
273
324
|
setSelectedObjectId(target.id);
|
|
@@ -282,6 +333,11 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
282
333
|
const object = event.object === undefined ? undefined : availableObjectById(experience, event.object, event.timeUtcMs);
|
|
283
334
|
if (object !== undefined)
|
|
284
335
|
activatePreset(focusPresetFor(experience, object), event.timeUtcMs);
|
|
336
|
+
// A sky figure is selected (its card stays as it is) and turned toward only while the camera looks out.
|
|
337
|
+
else if (event.object !== undefined && skyFigureById(experience, event.object) !== undefined) {
|
|
338
|
+
selectFigure(event.object, false);
|
|
339
|
+
onTurnToFigure?.(event.object);
|
|
340
|
+
}
|
|
285
341
|
if (info?.kind === "event")
|
|
286
342
|
setInfo({ kind: "event", id: event.id });
|
|
287
343
|
};
|
|
@@ -302,5 +358,5 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
302
358
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
303
359
|
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), infoPanelId: infoPanelId, scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
304
360
|
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 }) }) }));
|
|
305
|
-
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose:
|
|
361
|
+
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: { ...phoneLayoutStyle(phoneLayout), ...labelStyleVars(labelStyle) }, children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null), id: infoPanelId })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: closePanel, onContinue: story.continuePlayback, step: stepNav })), _jsx(DeveloperDrawer, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange, children: developerTools }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, paceAuto: paceAuto, onSeek: seek, panels: storyPanels, openPanelId: openPanelId, onPanelOpen: openPanelFromTimeline, onEventSeek: seekToEvent, onEventInfo: (event) => setInfo({ kind: "event", id: event.id }), onWindowSeek: seekToWindow, onWindowInfo: (window) => setInfo({ kind: "window", id: window.id }), glowLook: timelineGlow, infoPanelId: infoPanelId, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
306
362
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { findCameraPreset, focusPresetFor, isObjectAvailable, listedObjects, relatedObjects } from "./objectModel.js";
|
|
3
|
-
import { ButtonText, FocusIcon, FollowIcon, InfoIcon, OrbitIcon, OverviewIcon } from "./topBarIcons.js";
|
|
2
|
+
import { findCameraPreset, focusPresetFor, isObjectAvailable, listedFigures, listedObjects, relatedObjects, skyFigureById } from "./objectModel.js";
|
|
3
|
+
import { ButtonText, FocusIcon, LookOutIcon, FollowIcon, InfoIcon, OrbitIcon, OverviewIcon } from "./topBarIcons.js";
|
|
4
4
|
export function ObjectControls({ experience, timeUtcMs, selectedObjectId, activePresetId, onSelectObject, onCameraPreset, infoOpen, onToggleInfo, infoPanelId, }) {
|
|
5
5
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
6
|
+
const selectedFigure = skyFigureById(experience, selectedObjectId);
|
|
6
7
|
const selectedAvailable = selected !== undefined && isObjectAvailable(selected, timeUtcMs);
|
|
8
|
+
const infoLabel = selected?.label ?? selectedFigure?.label;
|
|
7
9
|
const overview = findCameraPreset(experience, "overview");
|
|
8
10
|
const focus = selected === undefined ? undefined : focusPresetFor(experience, selected);
|
|
9
11
|
const follow = selected === undefined ? undefined : findCameraPreset(experience, "follow", selected.id);
|
|
12
|
+
const lookOut = selected === undefined ? undefined : findCameraPreset(experience, "lookOut", selected.id);
|
|
10
13
|
const related = selected === undefined ? [] : relatedObjects(experience, selected.id);
|
|
11
|
-
const presetIcon = (preset) => preset.request.kind === "overview" ? _jsx(OverviewIcon, {}) : preset.request.kind === "follow" ? _jsx(FollowIcon, {}) : _jsx(FocusIcon, {});
|
|
12
|
-
const presetText = (preset) => (preset.request.kind === "overview" ? "Overview" : preset.request.kind === "follow" ? "Follow" : "Focus");
|
|
14
|
+
const presetIcon = (preset) => preset.request.kind === "overview" ? _jsx(OverviewIcon, {}) : preset.request.kind === "follow" ? _jsx(FollowIcon, {}) : preset.request.kind === "lookOut" ? _jsx(LookOutIcon, {}) : _jsx(FocusIcon, {});
|
|
15
|
+
const presetText = (preset) => (preset.request.kind === "overview" ? "Overview" : preset.request.kind === "follow" ? "Follow" : preset.request.kind === "lookOut" ? "Look out" : "Focus");
|
|
13
16
|
const renderPreset = (preset) => preset && (_jsxs("button", { type: "button", className: "top-bar-button ui-icon", "data-closes-drawer": "", "aria-label": preset.label, title: preset.label, "aria-pressed": activePresetId === preset.id, "data-camera-preset": preset.id, onClick: () => onCameraPreset(preset), disabled: preset.request.kind !== "overview" && !selectedAvailable, children: [presetIcon(preset), _jsx(ButtonText, { children: presetText(preset) })] }, preset.id));
|
|
14
|
-
return (_jsxs("section", { className: "object-controls", "aria-label": "Object and camera controls", children: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
return (_jsxs("section", { className: "object-controls", "aria-label": "Object and camera controls", children: [_jsxs("select", { className: "object-picker", "data-closes-drawer": "", "aria-label": "Select object", value: selectedObjectId, onChange: (event) => onSelectObject(event.target.value), children: [listedObjects(experience, selectedObjectId).map((object) => {
|
|
18
|
+
const available = isObjectAvailable(object, timeUtcMs);
|
|
19
|
+
return (_jsxs("option", { value: object.id, disabled: !available, "data-available": available, "data-available-from": object.availability?.startUtcMs, "data-available-to": object.availability?.endUtcMs, children: [object.label, available ? "" : " (Unavailable)"] }, object.id));
|
|
20
|
+
}), listedFigures(experience, selectedObjectId).map((figure) => _jsx("option", { value: figure.id, "data-sky-figure": "", children: figure.label }, figure.id))] }), _jsxs("button", { type: "button", className: "top-bar-button ui-icon object-info-toggle", "data-closes-drawer": "", "aria-label": infoLabel === undefined ? "Information" : `Information about ${infoLabel}`, title: infoLabel === undefined ? "Information" : `Information about ${infoLabel}`, "aria-expanded": infoOpen, "aria-controls": infoPanelId, disabled: !selectedAvailable && selectedFigure === undefined, onClick: onToggleInfo, children: [_jsx(InfoIcon, {}), _jsx(ButtonText, { children: "Info" })] }), _jsxs("div", { className: "object-camera-actions", children: [renderPreset(focus), renderPreset(follow), renderPreset(lookOut), renderPreset(overview), related.map((object) => (_jsxs("button", { type: "button", className: "top-bar-button ui-icon object-related", "aria-label": object.label, title: object.label, "data-related-object": object.id, disabled: !isObjectAvailable(object, timeUtcMs), onClick: () => onSelectObject(object.id), children: [_jsx(OrbitIcon, {}), _jsx(ButtonText, { children: object.label })] }, object.id)))] })] }));
|
|
18
21
|
}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { ProvenanceSourceType } from "../core/provenance.js";
|
|
2
|
-
import type { StoryPanel } from "./storyPanels.js";
|
|
2
|
+
import type { StoryPanel, StoryStep } from "./storyPanels.js";
|
|
3
3
|
/** A small pill saying how far to trust a panel's facts, after Planetary Explorer's Badge. */
|
|
4
4
|
export declare function StoryBadge({ sourceType }: {
|
|
5
5
|
readonly sourceType: ProvenanceSourceType;
|
|
6
6
|
}): import("react").JSX.Element;
|
|
7
|
+
/** A step's place and its neighbours: `onBack` and `onNext` are absent at the first and last step. */
|
|
8
|
+
export interface StepNav {
|
|
9
|
+
readonly number: number;
|
|
10
|
+
readonly count: number;
|
|
11
|
+
readonly onBack?: (() => void) | undefined;
|
|
12
|
+
readonly onNext?: (() => void) | undefined;
|
|
13
|
+
}
|
|
7
14
|
interface Props {
|
|
8
|
-
readonly panel: StoryPanel;
|
|
15
|
+
readonly panel: StoryPanel | StoryStep;
|
|
16
|
+
/** Present when the panel is a step: shows "Step n of m", Back and Next. */
|
|
17
|
+
readonly step?: StepNav | undefined;
|
|
9
18
|
/** True while playback is held for this panel; shows the Continue button. */
|
|
10
19
|
readonly holding: boolean;
|
|
11
20
|
readonly onClose: () => void;
|
|
@@ -15,5 +24,5 @@ interface Props {
|
|
|
15
24
|
* One story panel: a side panel beside the scene on a wide screen, a bottom sheet with a grab handle on a phone
|
|
16
25
|
* (the stylesheet chooses). Closing, Escape and a swipe down all dismiss it.
|
|
17
26
|
*/
|
|
18
|
-
export declare function StoryPanelView({ panel, holding, onClose, onContinue }: Props): import("react").JSX.Element;
|
|
27
|
+
export declare function StoryPanelView({ panel, step, holding, onClose, onContinue }: Props): import("react").JSX.Element;
|
|
19
28
|
export {};
|
|
@@ -13,7 +13,7 @@ export function StoryBadge({ sourceType }) {
|
|
|
13
13
|
* One story panel: a side panel beside the scene on a wide screen, a bottom sheet with a grab handle on a phone
|
|
14
14
|
* (the stylesheet chooses). Closing, Escape and a swipe down all dismiss it.
|
|
15
15
|
*/
|
|
16
|
-
export function StoryPanelView({ panel, holding, onClose, onContinue }) {
|
|
16
|
+
export function StoryPanelView({ panel, step, holding, onClose, onContinue }) {
|
|
17
17
|
const titleId = `${useId()}-title`;
|
|
18
18
|
const sheet = useRef(null);
|
|
19
19
|
useSwipeToDismiss(sheet, onClose);
|
|
@@ -24,5 +24,5 @@ export function StoryPanelView({ panel, holding, onClose, onContinue }) {
|
|
|
24
24
|
document.addEventListener("keydown", onKey);
|
|
25
25
|
return () => document.removeEventListener("keydown", onKey);
|
|
26
26
|
}, [onClose]);
|
|
27
|
-
return (_jsxs("aside", { className: "story-panel", ref: sheet, role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-panel-id": panel.id, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "story-panel-header", children: [_jsx(StoryBadge, { sourceType: panel.provenance.sourceType }), _jsx("button", { type: "button", className: "story-panel-close ui-icon", "aria-label": "Close story panel", onClick: onClose, children: "\u00D7" })] }), _jsx("h2", { id: titleId, children: panel.title }), _jsx("div", { className: "story-panel-body", children: panel.body.map((paragraph) => _jsx("p", { children: paragraph }, paragraph)) }), _jsx(Sources, { sources: panel.provenance.sources, details: panel.details, accuracy: panel.provenance.accuracy, notes: panel.provenance.notes }), holding && _jsx("button", { type: "button", className: "story-panel-continue ui-accent", onClick: onContinue, children: "Continue playback" })] }));
|
|
27
|
+
return (_jsxs("aside", { className: "story-panel", ref: sheet, role: "dialog", "aria-modal": "false", "aria-labelledby": titleId, "data-panel-id": panel.id, children: [_jsx("div", { className: "sheet-handle", "aria-hidden": "true" }), _jsxs("header", { className: "story-panel-header", children: [_jsx(StoryBadge, { sourceType: panel.provenance.sourceType }), _jsx("button", { type: "button", className: "story-panel-close ui-icon", "aria-label": "Close story panel", onClick: onClose, children: "\u00D7" })] }), _jsx("h2", { id: titleId, children: panel.title }), _jsx("div", { className: "story-panel-body", children: panel.body.map((paragraph) => _jsx("p", { children: paragraph }, paragraph)) }), _jsx(Sources, { sources: panel.provenance.sources, details: panel.details, accuracy: panel.provenance.accuracy, notes: panel.provenance.notes }), step !== undefined && (_jsxs("nav", { className: "story-panel-steps", "aria-label": "Story steps", children: [_jsx("button", { type: "button", className: "story-panel-back ui-icon", disabled: step.onBack === undefined, onClick: step.onBack, children: "Back" }), _jsxs("span", { className: "story-panel-step-count", children: ["Step ", step.number, " of ", step.count] }), _jsx("button", { type: "button", className: "story-panel-next ui-accent", disabled: step.onNext === undefined, onClick: step.onNext, children: "Next" })] })), holding && _jsx("button", { type: "button", className: "story-panel-continue ui-accent", onClick: onContinue, children: "Continue playback" })] }));
|
|
28
28
|
}
|
|
@@ -46,13 +46,35 @@ export type ExperienceCameraRequest = {
|
|
|
46
46
|
} | {
|
|
47
47
|
readonly kind: "focus" | "follow";
|
|
48
48
|
readonly target: string;
|
|
49
|
+
}
|
|
50
|
+
/** Stand inside `body` looking out: `direction` is a unit vector in the J2000 equatorial frame, or an object id to turn toward. */
|
|
51
|
+
| {
|
|
52
|
+
readonly kind: "lookOut";
|
|
53
|
+
readonly body: string;
|
|
54
|
+
readonly direction: readonly [number, number, number] | string;
|
|
55
|
+
readonly fovDeg?: number;
|
|
49
56
|
};
|
|
57
|
+
/** The object a camera request frames or stands in: none for the overview. */
|
|
58
|
+
export declare function requestObjectId(request: ExperienceCameraRequest): string | undefined;
|
|
50
59
|
export interface ExperienceCameraPreset {
|
|
51
60
|
readonly id: string;
|
|
52
61
|
readonly label: string;
|
|
53
62
|
readonly request: ExperienceCameraRequest;
|
|
54
63
|
}
|
|
55
64
|
/** The labels and timeline data a reusable viewer shell needs from an experience. */
|
|
65
|
+
/** What the info card and object menu show for a sky figure (`Scene.addSkyFigures`); the figure's lines and name are drawn by the app, not by the shell. */
|
|
66
|
+
export interface SkyFigureCard {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly label: string;
|
|
69
|
+
readonly description?: string;
|
|
70
|
+
readonly facts?: readonly {
|
|
71
|
+
readonly label: string;
|
|
72
|
+
readonly value: string;
|
|
73
|
+
}[];
|
|
74
|
+
readonly provenance: Provenance;
|
|
75
|
+
/** False leaves it out of the object menu (the menu shows it while it is selected). */
|
|
76
|
+
readonly listed: boolean;
|
|
77
|
+
}
|
|
56
78
|
export interface ExperienceConfig {
|
|
57
79
|
readonly objects: readonly ExperienceObject[];
|
|
58
80
|
readonly cameraPresets: readonly ExperienceCameraPreset[];
|
|
@@ -71,6 +93,8 @@ export interface ExperienceConfig {
|
|
|
71
93
|
readonly moonFamilies?: MoonFamilyList;
|
|
72
94
|
/** Tagged places on bodies (a body package's features): drawn as markers on the body and opened in the information panel. Omit for an experience with none. */
|
|
73
95
|
readonly bodyFeatures?: readonly BodyFeatureSet[];
|
|
96
|
+
/** Sky figures a visitor can select (tap or object menu): their cards and menu flags. Omit for an experience with none. Ids are distinct from every object id. */
|
|
97
|
+
readonly skyFigures?: readonly SkyFigureCard[];
|
|
74
98
|
/** Where the event times come from, shown with every event. */
|
|
75
99
|
readonly eventProvenance?: Provenance;
|
|
76
100
|
/** Provenance of single events by event id; an event listed here shows it instead of `eventProvenance`. */
|
package/src/shell/experience.js
CHANGED