astraeus 0.6.0 → 0.7.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 +16 -0
- package/README.md +31 -8
- package/package.json +1 -1
- package/src/api/AstraeusScene.d.ts +4 -2
- package/src/api/AstraeusScene.js +13 -10
- package/src/api/AstraeusScene.node.js +13 -10
- package/src/api/errors.d.ts +1 -1
- package/src/api/index.d.ts +1 -0
- package/src/api/mount.d.ts +5 -1
- package/src/api/mount.js +2 -0
- package/src/api/mount.node.js +2 -0
- package/src/api/pathProvenance.d.ts +15 -6
- package/src/api/pathProvenance.js +23 -11
- package/src/api/scene.d.ts +18 -1
- package/src/api/scene.js +88 -10
- package/src/api/sphereOfInfluence.d.ts +20 -0
- package/src/api/sphereOfInfluence.js +48 -0
- package/src/api/viewerLink.d.ts +7 -1
- package/src/api/viewerLink.js +13 -2
- package/src/api/views.d.ts +42 -0
- package/src/api/views.js +80 -0
- package/src/app/App.js +32 -5
- package/src/app/App.node.js +32 -5
- package/src/app/AstraeusScene.d.ts +3 -0
- package/src/app/CameraController.d.ts +6 -0
- package/src/app/CameraController.js +3 -1
- package/src/app/StoryMarkers.d.ts +4 -1
- package/src/app/StoryMarkers.js +3 -2
- package/src/app/TrackedBodyView.d.ts +1 -1
- package/src/app/TrackedBodyView.js +20 -11
- package/src/app/experienceDefinition.d.ts +3 -0
- package/src/app/mission.d.ts +15 -2
- package/src/app/mission.js +15 -0
- package/src/app/sceneCamera.d.ts +2 -0
- package/src/app/sceneCamera.js +14 -0
- package/src/app/sceneFrame.d.ts +2 -0
- package/src/app/sceneFrame.js +42 -6
- package/src/app/viewHiding.d.ts +13 -0
- package/src/app/viewHiding.js +37 -0
- package/src/app/viewerPort.d.ts +6 -0
- package/src/app/views.d.ts +31 -0
- package/src/app/views.js +2 -0
- package/src/shell/AstraeusShell.d.ts +12 -2
- package/src/shell/AstraeusShell.js +42 -4
- package/src/shell/AstraeusShell.node.js +42 -4
- package/src/shell/DisplaySwitches.d.ts +18 -1
- package/src/shell/DisplaySwitches.js +18 -5
- package/src/shell/TimelineBar.css +18 -0
- package/src/shell/TimelineBar.js +29 -4
- package/src/shell/TimelineBar.node.js +29 -4
- package/src/shell/TopBar.d.ts +4 -2
- package/src/shell/TopBar.js +3 -3
- package/src/shell/TopBar.node.js +3 -3
- package/src/shell/timelineModel.d.ts +13 -0
- package/src/shell/timelineModel.js +25 -0
- package/src/shell/viewCamera.d.ts +4 -0
- package/src/shell/viewCamera.js +13 -0
- package/src/synthetic/syntheticJourneyScene.js +11 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +6 -0
- package/src/synthetic/syntheticViewsDefinition.js +44 -0
|
@@ -10,6 +10,7 @@ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
|
10
10
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
11
|
import { isEmbedded } from "./embedded.js";
|
|
12
12
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
|
+
import { presetForViewRule } from "./viewCamera.js";
|
|
13
14
|
import { DeveloperToggle, TopBar } from "./TopBar.js";
|
|
14
15
|
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
15
16
|
import "./controls.css";
|
|
@@ -55,6 +56,17 @@ function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
|
55
56
|
function serialOf(request) {
|
|
56
57
|
return request?.serial;
|
|
57
58
|
}
|
|
59
|
+
/** Tells a switch of view from any other change of the experience: `takeSwitchRule` gives the new view's camera rule once after the view's id changed, else undefined. */
|
|
60
|
+
function useViewSwitch(viewCamera) {
|
|
61
|
+
const viewId = viewCamera?.id;
|
|
62
|
+
const last = useRef(viewId);
|
|
63
|
+
const takeSwitchRule = () => {
|
|
64
|
+
const switched = viewId !== last.current;
|
|
65
|
+
last.current = viewId;
|
|
66
|
+
return switched ? viewCamera?.rule : undefined;
|
|
67
|
+
};
|
|
68
|
+
return { viewId, takeSwitchRule };
|
|
69
|
+
}
|
|
58
70
|
function panelsOf(storySet) {
|
|
59
71
|
return storySet?.panels ?? [];
|
|
60
72
|
}
|
|
@@ -72,7 +84,7 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
72
84
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
73
85
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
74
86
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
75
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
87
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
76
88
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
77
89
|
const phone = usePhone();
|
|
78
90
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
@@ -122,18 +134,27 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
122
134
|
useEffect(() => {
|
|
123
135
|
onSelectionChange(selectedObjectId);
|
|
124
136
|
}, [onSelectionChange, selectedObjectId]);
|
|
137
|
+
// A view switch is told from other changes of the experience by the view's id changing.
|
|
138
|
+
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
125
139
|
useEffect(() => {
|
|
140
|
+
const switchRule = takeSwitchRule();
|
|
126
141
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
127
142
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
128
143
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
129
144
|
setSelectedObjectId(fallbackId);
|
|
130
145
|
onSelectionChange(fallbackId);
|
|
146
|
+
// The card of an object the view took away closes with it.
|
|
147
|
+
if (switchRule !== undefined && selected === undefined)
|
|
148
|
+
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
131
149
|
}
|
|
132
150
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
133
151
|
const activeRequest = active?.request;
|
|
134
152
|
if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
135
153
|
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
136
|
-
if (
|
|
154
|
+
if (switchRule !== undefined && target === undefined) {
|
|
155
|
+
applyViewRule(switchRule);
|
|
156
|
+
}
|
|
157
|
+
else if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
|
|
137
158
|
const overview = findCameraPreset(experience, "overview");
|
|
138
159
|
if (overview !== undefined) {
|
|
139
160
|
setActivePresetId(overview.id);
|
|
@@ -141,7 +162,24 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
141
162
|
}
|
|
142
163
|
}
|
|
143
164
|
}
|
|
144
|
-
|
|
165
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
166
|
+
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs, viewId]);
|
|
167
|
+
/** The view's camera rule for a followed or focused object the new view does not show: `stay` keeps the pose and stops following; otherwise the rule's framing is requested. */
|
|
168
|
+
const applyViewRule = (rule) => {
|
|
169
|
+
const asked = presetForViewRule(rule, experience);
|
|
170
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request.target, snapshot.timeUtcMs);
|
|
171
|
+
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
172
|
+
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
173
|
+
if (target !== undefined) {
|
|
174
|
+
setSelectedObjectId(target.id);
|
|
175
|
+
onSelectionChange(target.id);
|
|
176
|
+
}
|
|
177
|
+
setActivePresetId(preset?.id ?? null);
|
|
178
|
+
if (preset !== undefined)
|
|
179
|
+
onCameraRequest(preset.request);
|
|
180
|
+
else
|
|
181
|
+
onCameraHold?.();
|
|
182
|
+
};
|
|
145
183
|
const [moonsOpen, setMoonsOpen] = useState(false);
|
|
146
184
|
/** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
|
|
147
185
|
const chooseMoon = (id) => {
|
|
@@ -227,7 +265,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
227
265
|
useEffect(() => { if (info !== null)
|
|
228
266
|
setMoonsOpen(false); }, [info]);
|
|
229
267
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
230
|
-
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches }));
|
|
268
|
+
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
231
269
|
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 }) }) }));
|
|
232
270
|
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange }), _jsx("aside", { className: "developer-tools", id: "developer-tools", "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? developerTools : null }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, 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, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
233
271
|
}
|
|
@@ -10,6 +10,7 @@ import { PanelLoadBoundary } from "../app/PanelLoadBoundary.js";
|
|
|
10
10
|
import { ControlsDrawer } from "./ControlsDrawer.js";
|
|
11
11
|
import { isEmbedded } from "./embedded.js";
|
|
12
12
|
import { DEFAULT_PHONE_LAYOUT, phoneLayoutStyle, pickOpensInfo, usePhone } from "./phoneLayout.js";
|
|
13
|
+
import { presetForViewRule } from "./viewCamera.js";
|
|
13
14
|
import { DeveloperToggle, TopBar } from "./TopBar.node.js";
|
|
14
15
|
import { availableObjectById, findCameraPreset, firstAvailableObject, focusPresetFor, isObjectAvailable } from "./objectModel.js";
|
|
15
16
|
/** 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. */
|
|
@@ -51,6 +52,17 @@ function MoonsSheet({ planetLabel, open, onToggle, onClose, children }) {
|
|
|
51
52
|
function serialOf(request) {
|
|
52
53
|
return request?.serial;
|
|
53
54
|
}
|
|
55
|
+
/** Tells a switch of view from any other change of the experience: `takeSwitchRule` gives the new view's camera rule once after the view's id changed, else undefined. */
|
|
56
|
+
function useViewSwitch(viewCamera) {
|
|
57
|
+
const viewId = viewCamera?.id;
|
|
58
|
+
const last = useRef(viewId);
|
|
59
|
+
const takeSwitchRule = () => {
|
|
60
|
+
const switched = viewId !== last.current;
|
|
61
|
+
last.current = viewId;
|
|
62
|
+
return switched ? viewCamera?.rule : undefined;
|
|
63
|
+
};
|
|
64
|
+
return { viewId, takeSwitchRule };
|
|
65
|
+
}
|
|
54
66
|
function panelsOf(storySet) {
|
|
55
67
|
return storySet?.panels ?? [];
|
|
56
68
|
}
|
|
@@ -68,7 +80,7 @@ function infoContent(experience, info, selectedObjectId, timeUtcMs, metricsFor)
|
|
|
68
80
|
/** The moon families load on demand: only an experience with `moonFamilies` draws them (I-089). */
|
|
69
81
|
const MoonFamilyPanel = lazy(() => import("./MoonFamilyPanel.js").then((module) => ({ default: module.MoonFamilyPanel })));
|
|
70
82
|
/** Canvas-first layout shared by astronomy experiences. Scene and diagnostics stay app-owned. */
|
|
71
|
-
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
83
|
+
export function AstraeusShell({ experience, snapshot, developerMode, onDeveloperModeChange, onTogglePlayback, onRateChange, paceAuto, onSeek, onCameraRequest, onCameraHold, onSelectionChange, scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, viewCamera, metricsFor, developerTools, storyPanelSettings, timelineGlow, phoneLayout = DEFAULT_PHONE_LAYOUT, highlightedFamily = null, onHighlightFamily, onSetPlaying, panelRequest, onOpenPanelChange, featureRequest, onOpenFeatureChange, pickRequest, children, }) {
|
|
72
84
|
const [selectedObjectId, setSelectedObjectId] = useState(() => initialObjectId(experience, snapshot.timeUtcMs));
|
|
73
85
|
const phone = usePhone();
|
|
74
86
|
/** Fixed for the page: a frame does not appear or vanish while the app runs. */
|
|
@@ -118,18 +130,27 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
118
130
|
useEffect(() => {
|
|
119
131
|
onSelectionChange(selectedObjectId);
|
|
120
132
|
}, [onSelectionChange, selectedObjectId]);
|
|
133
|
+
// A view switch is told from other changes of the experience by the view's id changing.
|
|
134
|
+
const { viewId, takeSwitchRule } = useViewSwitch(viewCamera);
|
|
121
135
|
useEffect(() => {
|
|
136
|
+
const switchRule = takeSwitchRule();
|
|
122
137
|
const selected = experience.objects.find((object) => object.id === selectedObjectId);
|
|
123
138
|
if (selected === undefined || !isObjectAvailable(selected, snapshot.timeUtcMs)) {
|
|
124
139
|
const fallbackId = firstAvailableObject(experience, snapshot.timeUtcMs)?.id ?? "";
|
|
125
140
|
setSelectedObjectId(fallbackId);
|
|
126
141
|
onSelectionChange(fallbackId);
|
|
142
|
+
// The card of an object the view took away closes with it.
|
|
143
|
+
if (switchRule !== undefined && selected === undefined)
|
|
144
|
+
setInfo((now) => (now?.kind === "object" ? null : now));
|
|
127
145
|
}
|
|
128
146
|
const active = experience.cameraPresets.find((preset) => preset.id === activePresetId);
|
|
129
147
|
const activeRequest = active?.request;
|
|
130
148
|
if (activeRequest !== undefined && activeRequest.kind !== "overview") {
|
|
131
149
|
const target = experience.objects.find((object) => object.id === activeRequest.target);
|
|
132
|
-
if (
|
|
150
|
+
if (switchRule !== undefined && target === undefined) {
|
|
151
|
+
applyViewRule(switchRule);
|
|
152
|
+
}
|
|
153
|
+
else if (target === undefined || !isObjectAvailable(target, snapshot.timeUtcMs)) {
|
|
133
154
|
const overview = findCameraPreset(experience, "overview");
|
|
134
155
|
if (overview !== undefined) {
|
|
135
156
|
setActivePresetId(overview.id);
|
|
@@ -137,7 +158,24 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
137
158
|
}
|
|
138
159
|
}
|
|
139
160
|
}
|
|
140
|
-
|
|
161
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
162
|
+
}, [activePresetId, experience, onCameraRequest, onSelectionChange, selectedObjectId, snapshot.timeUtcMs, viewId]);
|
|
163
|
+
/** 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. */
|
|
164
|
+
const applyViewRule = (rule) => {
|
|
165
|
+
const asked = presetForViewRule(rule, experience);
|
|
166
|
+
const target = asked === undefined || asked.request.kind === "overview" ? undefined : availableObjectById(experience, asked.request.target, snapshot.timeUtcMs);
|
|
167
|
+
// A framing whose object is not available now falls back to the overview, like any other lost target.
|
|
168
|
+
const preset = asked !== undefined && asked.request.kind !== "overview" && target === undefined ? findCameraPreset(experience, "overview") : asked;
|
|
169
|
+
if (target !== undefined) {
|
|
170
|
+
setSelectedObjectId(target.id);
|
|
171
|
+
onSelectionChange(target.id);
|
|
172
|
+
}
|
|
173
|
+
setActivePresetId(preset?.id ?? null);
|
|
174
|
+
if (preset !== undefined)
|
|
175
|
+
onCameraRequest(preset.request);
|
|
176
|
+
else
|
|
177
|
+
onCameraHold?.();
|
|
178
|
+
};
|
|
141
179
|
const [moonsOpen, setMoonsOpen] = useState(false);
|
|
142
180
|
/** A moon chosen in the moon panel: flies to it (the same focus as the object picker) and opens its information. */
|
|
143
181
|
const chooseMoon = (id) => {
|
|
@@ -223,7 +261,7 @@ export function AstraeusShell({ experience, snapshot, developerMode, onDeveloper
|
|
|
223
261
|
useEffect(() => { if (info !== null)
|
|
224
262
|
setMoonsOpen(false); }, [info]);
|
|
225
263
|
const selectedLabel = objectLabelOr(experience, selectedObjectId, "Controls");
|
|
226
|
-
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches }));
|
|
264
|
+
const topBar = (_jsx(TopBar, { experience: experience, timeUtcMs: snapshot.timeUtcMs, selectedObjectId: selectedObjectId, activePresetId: activePresetId, onSelectObject: selectObject, onCameraPreset: activatePreset, infoOpen: info?.kind === "object", onToggleInfo: () => setInfo(info?.kind === "object" ? null : { kind: "object" }), scaleId: scaleId, onScaleChange: onScaleChange, scaleChoices: scaleChoices, switcher: switcher, displaySwitches: displaySwitches, viewChoice: viewChoice }));
|
|
227
265
|
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 }) }) }));
|
|
228
266
|
return (_jsxs("main", { className: "astraeus-shell", ref: root, "data-phone": phone, "data-timeline-hidden": experience.hideTimeline === true, "data-embedded": embedded, style: phoneLayoutStyle(phoneLayout), children: [_jsx("div", { className: "shell-canvas", children: children }), phone && _jsxs(ControlsDrawer, { label: selectedLabel, open: controlsOpen, onOpenChange: openControls, swipeThresholdPx: phoneLayout.swipeThresholdPx, children: [topBar, moonPanel] }), _jsxs("div", { className: "shell-top", children: [!phone && topBar, !phone && moonPanel !== null && _jsx(MoonsSheet, { planetLabel: experience.moonFamilies?.planetLabel, open: moonsOpen, onToggle: toggleMoons, onClose: () => setMoonsOpen(false), children: moonPanel }), view !== null && _jsx(InfoPanel, { view: view, metrics: metrics, onClose: () => setInfo(null) })] }), story.openPanel !== null && (_jsx(StoryPanelView, { panel: story.openPanel, holding: story.holding, onClose: story.close, onContinue: story.continuePlayback })), _jsx(DeveloperToggle, { developerMode: developerMode, onDeveloperModeChange: onDeveloperModeChange }), _jsx("aside", { className: "developer-tools", id: "developer-tools", "data-developer-panel": "", "aria-label": "Developer diagnostics", hidden: !developerMode, children: developerMode ? developerTools : null }), _jsx(ShellTimeline, { hidden: experience.hideTimeline === true, experience: experience, snapshot: snapshot, onTogglePlayback: onTogglePlayback, onRateChange: onRateChange, 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, drawer: phone ? { open: timelineOpen, onOpenChange: openTimeline, swipeThresholdPx: phoneLayout.swipeThresholdPx } : undefined })] }));
|
|
229
267
|
}
|
|
@@ -7,10 +7,27 @@ export interface DisplaySwitchItem {
|
|
|
7
7
|
readonly on: boolean;
|
|
8
8
|
readonly onToggle: () => void;
|
|
9
9
|
}
|
|
10
|
+
/** The views a scene names, as the bar shows them: one option each, exactly one active. Choosing never rebuilds the scene or touches the clock. */
|
|
11
|
+
export interface ViewChoice {
|
|
12
|
+
readonly place: "top-bar" | "panel";
|
|
13
|
+
readonly options: readonly {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly label: string;
|
|
16
|
+
readonly active: boolean;
|
|
17
|
+
}[];
|
|
18
|
+
readonly onSelect: (id: string) => void;
|
|
19
|
+
}
|
|
20
|
+
/** The view choice as a button group in the bar (and the phone drawer's grid), with the look of the experience switch's options. Fewer than two views: nothing to choose. */
|
|
21
|
+
export declare function ViewButtons({ choice }: {
|
|
22
|
+
readonly choice: ViewChoice;
|
|
23
|
+
}): import("react").JSX.Element | null;
|
|
24
|
+
/** Whether the switch panel has anything to show: a panel-placed switch or the view choice placed there. */
|
|
25
|
+
export declare function viewChoiceInPanel(choice: ViewChoice | undefined): choice is ViewChoice;
|
|
10
26
|
/**
|
|
11
27
|
* The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
|
|
12
28
|
* beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
|
|
13
29
|
*/
|
|
14
|
-
export declare function DisplaySwitches({ switches }: {
|
|
30
|
+
export declare function DisplaySwitches({ switches, viewChoice }: {
|
|
15
31
|
readonly switches: readonly DisplaySwitchItem[];
|
|
32
|
+
readonly viewChoice?: ViewChoice;
|
|
16
33
|
}): import("react").JSX.Element | null;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useId, useRef, useState } from "react";
|
|
3
3
|
import { ButtonText, OrbitIcon, SwitchesIcon } from "./topBarIcons.js";
|
|
4
|
+
/** The view choice as a button group in the bar (and the phone drawer's grid), with the look of the experience switch's options. Fewer than two views: nothing to choose. */
|
|
5
|
+
export function ViewButtons({ choice }) {
|
|
6
|
+
if (choice.place !== "top-bar" || choice.options.length < 2)
|
|
7
|
+
return null;
|
|
8
|
+
return (_jsx("section", { className: "switch-control view-choice", role: "group", "aria-label": "View", "data-view-choice": "", children: choice.options.map((option) => (_jsx("button", { type: "button", className: `switch-option top-bar-button ${option.active ? "ui-accent" : ""}`, "aria-pressed": option.active, "data-view-id": option.id, onClick: () => { if (!option.active)
|
|
9
|
+
choice.onSelect(option.id); }, children: _jsx("span", { children: option.label }) }, option.id))) }));
|
|
10
|
+
}
|
|
11
|
+
/** Whether the switch panel has anything to show: a panel-placed switch or the view choice placed there. */
|
|
12
|
+
export function viewChoiceInPanel(choice) {
|
|
13
|
+
return choice !== undefined && choice.place === "panel" && choice.options.length > 1;
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* The switches a story placed. Top-bar ones are buttons in the bar (and in the phone drawer's grid); panel ones sit in one small panel opened by a "Display" button
|
|
6
17
|
* beside them. Nothing placed: nothing drawn, so the bar is exactly as it was. The panel closes on an outside press or Escape.
|
|
7
18
|
*/
|
|
8
|
-
export function DisplaySwitches({ switches }) {
|
|
19
|
+
export function DisplaySwitches({ switches, viewChoice }) {
|
|
9
20
|
const barSwitches = switches.filter((item) => item.place === "top-bar");
|
|
10
21
|
const panelSwitches = switches.filter((item) => item.place === "panel");
|
|
11
|
-
|
|
22
|
+
const viewsInPanel = viewChoiceInPanel(viewChoice) ? viewChoice : undefined;
|
|
23
|
+
if (switches.length === 0 && viewsInPanel === undefined)
|
|
12
24
|
return null;
|
|
13
|
-
return (_jsxs("section", { className: "display-switches", role: "group", "aria-label": "Display switches", children: [barSwitches.map((item) => (_jsxs("button", { type: "button", className: "display-switch top-bar-button ui-icon", "aria-label": item.label, title: item.label, "aria-pressed": item.on, "data-display-switch": item.id, "data-closes-drawer": "", onClick: item.onToggle, children: [item.id === "orbitLines" ? _jsx(OrbitIcon, {}) : _jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: item.label })] }, item.id))), panelSwitches.length > 0 && _jsx(SwitchPanel, { switches: panelSwitches })] }));
|
|
25
|
+
return (_jsxs("section", { className: "display-switches", role: "group", "aria-label": "Display switches", children: [barSwitches.map((item) => (_jsxs("button", { type: "button", className: "display-switch top-bar-button ui-icon", "aria-label": item.label, title: item.label, "aria-pressed": item.on, "data-display-switch": item.id, "data-closes-drawer": "", onClick: item.onToggle, children: [item.id === "orbitLines" ? _jsx(OrbitIcon, {}) : _jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: item.label })] }, item.id))), (panelSwitches.length > 0 || viewsInPanel !== undefined) && _jsx(SwitchPanel, { switches: panelSwitches, viewChoice: viewsInPanel })] }));
|
|
14
26
|
}
|
|
15
|
-
function SwitchPanel({ switches }) {
|
|
27
|
+
function SwitchPanel({ switches, viewChoice }) {
|
|
16
28
|
const [open, setOpen] = useState(false);
|
|
17
29
|
const panelId = useId();
|
|
18
30
|
const root = useRef(null);
|
|
@@ -27,5 +39,6 @@ function SwitchPanel({ switches }) {
|
|
|
27
39
|
document.addEventListener("keydown", escape);
|
|
28
40
|
return () => { document.removeEventListener("pointerdown", outside); document.removeEventListener("keydown", escape); };
|
|
29
41
|
}, [open]);
|
|
30
|
-
return (_jsxs("div", { className: "switch-panel-host", ref: root, children: [_jsxs("button", { type: "button", className: "switch-panel-toggle top-bar-button ui-icon", "aria-label": "Switch panel", title: "Switch panel", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen(!open), children: [_jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: "Display" })] }),
|
|
42
|
+
return (_jsxs("div", { className: "switch-panel-host", ref: root, children: [_jsxs("button", { type: "button", className: "switch-panel-toggle top-bar-button ui-icon", "aria-label": "Switch panel", title: "Switch panel", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen(!open), children: [_jsx(SwitchesIcon, {}), _jsx(ButtonText, { children: "Display" })] }), _jsxs("div", { id: panelId, className: "switch-panel", role: "group", "aria-label": "Switches in the panel", hidden: !open, children: [viewChoice?.options.map((option) => (_jsx("button", { type: "button", className: "switch-panel-row ui-row", "aria-pressed": option.active, "data-view-id": option.id, onClick: () => { if (!option.active)
|
|
43
|
+
viewChoice.onSelect(option.id); }, children: option.label }, `view-${option.id}`))), switches.map((item) => (_jsx("button", { type: "button", className: "switch-panel-row ui-row", "aria-pressed": item.on, "data-display-switch": item.id, onClick: item.onToggle, children: item.label }, item.id)))] })] }));
|
|
31
44
|
}
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
}
|
|
16
16
|
/* The open Events list rises over the panel rather than hiding behind it. */
|
|
17
17
|
.timeline-bar:has(.timeline-event-list[open]) { z-index: 5; }
|
|
18
|
+
/* An open marker group lists above the bar; the bar rises over the phone information sheet (z-index 8) so each item stays reachable (O-050 T-217). */
|
|
19
|
+
.timeline-bar:has(.timeline-group-list),
|
|
20
|
+
[data-phone="true"] .timeline-bar:has(.timeline-group-list) { z-index: 9; }
|
|
18
21
|
|
|
19
22
|
.timeline-main-row { display: flex; align-items: center; gap: 14px; min-width: 0; }
|
|
20
23
|
.timeline-transport { display: flex; flex: 0 0 auto; gap: 4px; }
|
|
@@ -122,3 +125,18 @@
|
|
|
122
125
|
/* No timeline (experience.hideTimeline): nothing sits at the bottom, so nothing is reserved for it on a wide or a phone screen. */
|
|
123
126
|
main.astraeus-shell[data-timeline-hidden="true"] { --timeline-space: 0px; }
|
|
124
127
|
main.astraeus-shell[data-timeline-hidden="true"] .shell-top { --shell-timeline-space: 0px; }
|
|
128
|
+
|
|
129
|
+
/* Markers that sit closer than the minimum spacing gather under one numbered mark; pressing it lists them, each a full-size button. The list opens above the track, aligned to the screen side the mark is near so it stays on a phone. */
|
|
130
|
+
.timeline-marker-group { position: absolute; top: 0; height: 100%; width: 18px; transform: translateX(-50%); pointer-events: none; }
|
|
131
|
+
.timeline-marker-group .timeline-group-toggle { left: 0; width: 100%; pointer-events: auto; }
|
|
132
|
+
.timeline-marker-group .timeline-group-toggle::after { display: none; }
|
|
133
|
+
.timeline-group-count { display: block; width: 18px; height: 18px; border: 1.5px solid var(--ui-accent, #fc6323); border-radius: 50%; background: rgba(13, 13, 13, .85); color: var(--ui-color, #f0e6da); font: 600 11px/15px ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
|
|
134
|
+
.timeline-group-toggle:hover .timeline-group-count,
|
|
135
|
+
.timeline-group-toggle:focus-visible .timeline-group-count,
|
|
136
|
+
.timeline-group-toggle[aria-expanded="true"] .timeline-group-count { background: var(--ui-accent, #fc6323); color: #0d0d0d; }
|
|
137
|
+
.timeline-group-list { position: absolute; z-index: 3; bottom: calc(100% + 6px); left: 50%; display: flex; flex-direction: column; gap: 2px; width: max-content; max-width: min(300px, calc(100vw - 32px)); max-height: 40vh; margin: 0; padding: 4px; overflow-y: auto; border: 1px solid #2b2927; border-radius: 6px; background: rgba(13, 13, 13, .95); list-style: none; transform: translateX(-50%); pointer-events: auto; }
|
|
138
|
+
.timeline-marker-group[data-align="start"] .timeline-group-list { left: 0; transform: none; }
|
|
139
|
+
.timeline-marker-group[data-align="end"] .timeline-group-list { right: 0; left: auto; transform: none; }
|
|
140
|
+
.timeline-group-item { display: block; width: 100%; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--ui-color, #f0e6da); font: inherit; text-align: left; white-space: normal; cursor: pointer; }
|
|
141
|
+
.timeline-group-item:hover,
|
|
142
|
+
.timeline-group-item:focus-visible { background: #2b2927; }
|
package/src/shell/TimelineBar.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
3
|
-
import { eventContextAt,
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { eventContextAt, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
4
4
|
import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
|
|
5
5
|
import { Label } from "./Label.js";
|
|
6
6
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
@@ -53,14 +53,39 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
53
53
|
});
|
|
54
54
|
const speedIndex = Math.max(0, speeds.findIndex((speed) => speed.rate === snapshot.rate));
|
|
55
55
|
const speedText = paceAuto === true ? autoLabel(true, snapshot.rate) : speeds[speedIndex]?.label;
|
|
56
|
+
const markersRef = useRef(null);
|
|
57
|
+
const [trackWidth, setTrackWidth] = useState(0);
|
|
58
|
+
const [openGroup, setOpenGroup] = useState(null);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const node = markersRef.current;
|
|
61
|
+
if (node === null)
|
|
62
|
+
return undefined;
|
|
63
|
+
const measure = () => { const width = node.getBoundingClientRect().width; if (width > 0)
|
|
64
|
+
setTrackWidth(width); };
|
|
65
|
+
measure();
|
|
66
|
+
if (typeof ResizeObserver === "undefined")
|
|
67
|
+
return undefined;
|
|
68
|
+
const observer = new ResizeObserver(measure);
|
|
69
|
+
observer.observe(node);
|
|
70
|
+
return () => observer.disconnect();
|
|
71
|
+
}, [drawer?.open]);
|
|
72
|
+
const markers = [
|
|
73
|
+
...experience.events.map((event) => ({ kind: "event", key: event.id, timeUtcMs: event.timeUtcMs, text: event.label, ariaLabel: `Go to ${event.label}`, activate: () => { onEventSeek(event); onEventInfo(event); } })),
|
|
74
|
+
...panels.map((panel) => ({ kind: "panel", key: panel.id, timeUtcMs: panel.timeUtcMs, text: panel.title, ariaLabel: `Open story panel: ${panel.title}`, activate: () => onPanelOpen?.(panel) })),
|
|
75
|
+
...windows.flatMap((window) => window.peakUtcMs === undefined ? [] : [{ kind: "peak", key: `peak-${window.id}`, timeUtcMs: window.peakUtcMs, text: `${window.label} peak`, ariaLabel: `Go to peak of ${window.label}`, activate: () => { onWindowSeek(window, window.peakUtcMs ?? 0); onWindowInfo(window); } }]),
|
|
76
|
+
];
|
|
77
|
+
const groups = groupMarkers(markers, experience.window, trackWidth);
|
|
78
|
+
const renderMarker = (marker, percent) => marker.kind === "event" ? (_jsx("button", { className: "timeline-marker", type: "button", "aria-label": marker.ariaLabel, title: marker.text, style: { left: `${percent}%` }, onClick: marker.activate, children: _jsx(Label, { text: marker.text, className: "timeline-marker-label" }) }, marker.key)) : marker.kind === "panel" ? (_jsx("button", { className: "timeline-marker timeline-panel-marker", type: "button", "data-panel-id": marker.key, "aria-pressed": openPanelId === marker.key, "aria-label": marker.ariaLabel, title: marker.text, style: { left: `${percent}%` }, onClick: marker.activate, children: _jsx(Label, { text: marker.text, className: "timeline-marker-label" }) }, marker.key)) : (_jsx("button", { type: "button", className: "timeline-marker timeline-window-peak", "aria-label": marker.ariaLabel, title: marker.text, "data-time-utc-ms": marker.timeUtcMs, style: { left: `${percent}%` }, onClick: marker.activate }, marker.key));
|
|
56
79
|
const scrubber = (_jsxs("div", { className: "timeline-scrubber", children: [_jsxs("div", { className: "timeline-track", title: profile === null ? undefined : hoverTitle ?? description, onPointerMove: moveOnTrack, onPointerLeave: () => setHoverTitle(null), children: [_jsxs("div", { className: "timeline-glow", ...(description === "" ? { "aria-hidden": true } : { role: "img", "aria-label": description }), style: {
|
|
57
80
|
"--glow-ahead": gradients.ahead,
|
|
58
81
|
"--glow-played": gradients.played,
|
|
59
82
|
"--glow-played-edge": `${(100 - playedPercent).toFixed(3)}%`,
|
|
60
83
|
"--glow-thickness": `${glowLook.thicknessPx}px`,
|
|
61
84
|
"--glow-halo": `${glowLook.haloPx}px`,
|
|
62
|
-
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }),
|
|
63
|
-
|
|
85
|
+
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsx("div", { className: "timeline-markers", ref: markersRef, "aria-label": "Timeline event markers", children: groups.map((group) => group.members.length === 1
|
|
86
|
+
? renderMarker(group.members[0], group.positionPercent)
|
|
87
|
+
: (_jsxs("div", { className: "timeline-marker-group", "data-align": group.positionPercent < 25 ? "start" : group.positionPercent > 75 ? "end" : "middle", style: { left: `${group.positionPercent}%` }, onKeyDown: (event) => { if (event.key === "Escape")
|
|
88
|
+
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children: formatUtcTimestamp(experience.window.startUtcMs).slice(0, 10) }), _jsx("time", { dateTime: formatUtcTimestamp(experience.window.endUtcMs), children: formatUtcTimestamp(experience.window.endUtcMs).slice(0, 10) })] })] }));
|
|
64
89
|
return (_jsxs("section", { className: "timeline-bar", "aria-label": "Timeline controls", "data-drawer-open": drawer?.open, children: [drawer !== undefined && (_jsx("button", { type: "button", className: "drawer-handle drawer-handle-top ui-bare", "aria-label": "Timeline drawer", "aria-expanded": drawer.open, "aria-controls": "timeline-drawer", ...handle, children: _jsx("span", {}) })), _jsxs("div", { className: "timeline-main-row", children: [_jsxs("div", { className: "timeline-transport", children: [_jsx("button", { type: "button", className: "timeline-play ui-icon ui-accent", title: snapshot.playing ? "Pause" : "Play", onClick: onTogglePlayback, "aria-label": snapshot.playing ? "Pause playback" : "Play playback", children: snapshot.playing ? _jsx(Symbol, { path: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z" }) : _jsx(Symbol, { path: "M7 5v14l12-7z" }) }), _jsx("button", { type: "button", className: "timeline-previous ui-icon ui-ghost", "aria-label": stopLabel("Previous", navigation.previous), title: stopLabel("Previous", navigation.previous), disabled: navigation.previous === null, onClick: () => { if (navigation.previous !== null)
|
|
65
90
|
goToStop(navigation.previous); }, children: _jsx(Symbol, { path: "M6 5h2v14H6zM19 5v14L9 12z" }) }), _jsx("button", { type: "button", className: "timeline-next ui-icon ui-ghost", "aria-label": stopLabel("Next", navigation.next), title: stopLabel("Next", navigation.next), disabled: navigation.next === null, onClick: () => { if (navigation.next !== null)
|
|
66
91
|
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime: timestamp, "aria-label": timestamp, children: [_jsx("span", { className: "timeline-time-full", children: timestamp }), _jsx("span", { className: "timeline-time-short", "aria-hidden": "true", children: timestamp.slice(0, 16).replace("T", " ") })] }), _jsx(SpeedMenu, { speeds: speeds, rate: snapshot.rate, paceAuto: paceAuto, compact: drawer !== undefined, onRateChange: onRateChange }), scrubber, drawer === undefined && (_jsxs("details", { className: "timeline-event-list", children: [_jsxs("summary", { className: "ui-button", title: "Events: what just happened, what is next, and the full list", children: ["Events ", _jsxs("span", { children: ["(", experience.events.length, ")"] })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo })] }))] }), drawer !== undefined && (_jsx("div", { id: "timeline-drawer", className: "timeline-drawer", role: "region", "aria-label": "Timeline details", "data-open": drawer.open, onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
3
|
-
import { eventContextAt,
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { eventContextAt, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, speedsOf, TIMELINE_STEP_MS, clampToBounds, formatRateCompact, formatRate, groupMarkers } from "./timelineModel.js";
|
|
4
4
|
import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
|
|
5
5
|
import { Label } from "./Label.js";
|
|
6
6
|
import { useDrawerSwipe } from "./useDrawerSwipe.js";
|
|
@@ -52,14 +52,39 @@ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChan
|
|
|
52
52
|
});
|
|
53
53
|
const speedIndex = Math.max(0, speeds.findIndex((speed) => speed.rate === snapshot.rate));
|
|
54
54
|
const speedText = paceAuto === true ? autoLabel(true, snapshot.rate) : speeds[speedIndex]?.label;
|
|
55
|
+
const markersRef = useRef(null);
|
|
56
|
+
const [trackWidth, setTrackWidth] = useState(0);
|
|
57
|
+
const [openGroup, setOpenGroup] = useState(null);
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const node = markersRef.current;
|
|
60
|
+
if (node === null)
|
|
61
|
+
return undefined;
|
|
62
|
+
const measure = () => { const width = node.getBoundingClientRect().width; if (width > 0)
|
|
63
|
+
setTrackWidth(width); };
|
|
64
|
+
measure();
|
|
65
|
+
if (typeof ResizeObserver === "undefined")
|
|
66
|
+
return undefined;
|
|
67
|
+
const observer = new ResizeObserver(measure);
|
|
68
|
+
observer.observe(node);
|
|
69
|
+
return () => observer.disconnect();
|
|
70
|
+
}, [drawer?.open]);
|
|
71
|
+
const markers = [
|
|
72
|
+
...experience.events.map((event) => ({ kind: "event", key: event.id, timeUtcMs: event.timeUtcMs, text: event.label, ariaLabel: `Go to ${event.label}`, activate: () => { onEventSeek(event); onEventInfo(event); } })),
|
|
73
|
+
...panels.map((panel) => ({ kind: "panel", key: panel.id, timeUtcMs: panel.timeUtcMs, text: panel.title, ariaLabel: `Open story panel: ${panel.title}`, activate: () => onPanelOpen?.(panel) })),
|
|
74
|
+
...windows.flatMap((window) => window.peakUtcMs === undefined ? [] : [{ kind: "peak", key: `peak-${window.id}`, timeUtcMs: window.peakUtcMs, text: `${window.label} peak`, ariaLabel: `Go to peak of ${window.label}`, activate: () => { onWindowSeek(window, window.peakUtcMs ?? 0); onWindowInfo(window); } }]),
|
|
75
|
+
];
|
|
76
|
+
const groups = groupMarkers(markers, experience.window, trackWidth);
|
|
77
|
+
const renderMarker = (marker, percent) => marker.kind === "event" ? (_jsx("button", { className: "timeline-marker", type: "button", "aria-label": marker.ariaLabel, title: marker.text, style: { left: `${percent}%` }, onClick: marker.activate, children: _jsx(Label, { text: marker.text, className: "timeline-marker-label" }) }, marker.key)) : marker.kind === "panel" ? (_jsx("button", { className: "timeline-marker timeline-panel-marker", type: "button", "data-panel-id": marker.key, "aria-pressed": openPanelId === marker.key, "aria-label": marker.ariaLabel, title: marker.text, style: { left: `${percent}%` }, onClick: marker.activate, children: _jsx(Label, { text: marker.text, className: "timeline-marker-label" }) }, marker.key)) : (_jsx("button", { type: "button", className: "timeline-marker timeline-window-peak", "aria-label": marker.ariaLabel, title: marker.text, "data-time-utc-ms": marker.timeUtcMs, style: { left: `${percent}%` }, onClick: marker.activate }, marker.key));
|
|
55
78
|
const scrubber = (_jsxs("div", { className: "timeline-scrubber", children: [_jsxs("div", { className: "timeline-track", title: profile === null ? undefined : hoverTitle ?? description, onPointerMove: moveOnTrack, onPointerLeave: () => setHoverTitle(null), children: [_jsxs("div", { className: "timeline-glow", ...(description === "" ? { "aria-hidden": true } : { role: "img", "aria-label": description }), style: {
|
|
56
79
|
"--glow-ahead": gradients.ahead,
|
|
57
80
|
"--glow-played": gradients.played,
|
|
58
81
|
"--glow-played-edge": `${(100 - playedPercent).toFixed(3)}%`,
|
|
59
82
|
"--glow-thickness": `${glowLook.thicknessPx}px`,
|
|
60
83
|
"--glow-halo": `${glowLook.haloPx}px`,
|
|
61
|
-
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }),
|
|
62
|
-
|
|
84
|
+
}, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsx("div", { className: "timeline-markers", ref: markersRef, "aria-label": "Timeline event markers", children: groups.map((group) => group.members.length === 1
|
|
85
|
+
? renderMarker(group.members[0], group.positionPercent)
|
|
86
|
+
: (_jsxs("div", { className: "timeline-marker-group", "data-align": group.positionPercent < 25 ? "start" : group.positionPercent > 75 ? "end" : "middle", style: { left: `${group.positionPercent}%` }, onKeyDown: (event) => { if (event.key === "Escape")
|
|
87
|
+
setOpenGroup(null); }, children: [_jsx("button", { type: "button", className: "timeline-marker timeline-group-toggle", "aria-expanded": openGroup === group.members[0].key, "aria-label": `${group.members.length} markers close together: show list`, title: `${group.members.length} markers`, onClick: () => setOpenGroup((open) => (open === group.members[0].key ? null : group.members[0].key)), children: _jsx("span", { className: "timeline-group-count", children: group.members.length }) }), openGroup === group.members[0].key && (_jsx("ul", { className: "timeline-group-list", "aria-label": "Markers close together", children: group.members.map((member) => (_jsx("li", { children: _jsx("button", { type: "button", className: "timeline-group-item", "aria-label": member.ariaLabel, "data-time-utc-ms": member.timeUtcMs, "data-panel-id": member.kind === "panel" ? member.key : undefined, onClick: () => { member.activate(); setOpenGroup(null); }, children: member.text }) }, member.key))) }))] }, `group-${group.members[0].key}`))) }), _jsx("input", { type: "range", "aria-label": "Seek timeline", "aria-valuetext": valueText, min: experience.window.startUtcMs, max: experience.window.endUtcMs, step: TIMELINE_STEP_MS, value: clampToBounds(snapshot.timeUtcMs, experience.window), onChange: (event) => onSeek(Number(event.target.value)) })] }), _jsxs("div", { className: "timeline-bounds", "aria-hidden": "true", children: [_jsx("time", { dateTime: formatUtcTimestamp(experience.window.startUtcMs), children: formatUtcTimestamp(experience.window.startUtcMs).slice(0, 10) }), _jsx("time", { dateTime: formatUtcTimestamp(experience.window.endUtcMs), children: formatUtcTimestamp(experience.window.endUtcMs).slice(0, 10) })] })] }));
|
|
63
88
|
return (_jsxs("section", { className: "timeline-bar", "aria-label": "Timeline controls", "data-drawer-open": drawer?.open, children: [drawer !== undefined && (_jsx("button", { type: "button", className: "drawer-handle drawer-handle-top ui-bare", "aria-label": "Timeline drawer", "aria-expanded": drawer.open, "aria-controls": "timeline-drawer", ...handle, children: _jsx("span", {}) })), _jsxs("div", { className: "timeline-main-row", children: [_jsxs("div", { className: "timeline-transport", children: [_jsx("button", { type: "button", className: "timeline-play ui-icon ui-accent", title: snapshot.playing ? "Pause" : "Play", onClick: onTogglePlayback, "aria-label": snapshot.playing ? "Pause playback" : "Play playback", children: snapshot.playing ? _jsx(Symbol, { path: "M7 5h3.5v14H7zM13.5 5H17v14h-3.5z" }) : _jsx(Symbol, { path: "M7 5v14l12-7z" }) }), _jsx("button", { type: "button", className: "timeline-previous ui-icon ui-ghost", "aria-label": stopLabel("Previous", navigation.previous), title: stopLabel("Previous", navigation.previous), disabled: navigation.previous === null, onClick: () => { if (navigation.previous !== null)
|
|
64
89
|
goToStop(navigation.previous); }, children: _jsx(Symbol, { path: "M6 5h2v14H6zM19 5v14L9 12z" }) }), _jsx("button", { type: "button", className: "timeline-next ui-icon ui-ghost", "aria-label": stopLabel("Next", navigation.next), title: stopLabel("Next", navigation.next), disabled: navigation.next === null, onClick: () => { if (navigation.next !== null)
|
|
65
90
|
goToStop(navigation.next); }, children: _jsx(Symbol, { path: "M16 5h2v14h-2zM5 5v14l10-7z" }) })] }), _jsxs("time", { className: "timeline-time", dateTime: timestamp, "aria-label": timestamp, children: [_jsx("span", { className: "timeline-time-full", children: timestamp }), _jsx("span", { className: "timeline-time-short", "aria-hidden": "true", children: timestamp.slice(0, 16).replace("T", " ") })] }), _jsx(SpeedMenu, { speeds: speeds, rate: snapshot.rate, paceAuto: paceAuto, compact: drawer !== undefined, onRateChange: onRateChange }), scrubber, drawer === undefined && (_jsxs("details", { className: "timeline-event-list", children: [_jsxs("summary", { className: "ui-button", title: "Events: what just happened, what is next, and the full list", children: ["Events ", _jsxs("span", { children: ["(", experience.events.length, ")"] })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo })] }))] }), drawer !== undefined && (_jsx("div", { id: "timeline-drawer", className: "timeline-drawer", role: "region", "aria-label": "Timeline details", "data-open": drawer.open, onClick: (event) => { const closer = event.target.closest("[data-closes-drawer]"); if (closer !== null && closer.tagName !== "SELECT")
|
package/src/shell/TopBar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExperienceCameraPreset, ExperienceConfig } from "./experience.js";
|
|
2
|
-
import { type DisplaySwitchItem } from "./DisplaySwitches.js";
|
|
2
|
+
import { type DisplaySwitchItem, type ViewChoice } from "./DisplaySwitches.js";
|
|
3
3
|
import { type ExperienceSwitch } from "./SwitchControl.js";
|
|
4
4
|
import type { ScaleChoice, ScaleId } from "./scaleModel.js";
|
|
5
5
|
import "./TopBar.css";
|
|
@@ -19,13 +19,15 @@ interface Props {
|
|
|
19
19
|
readonly switcher?: ExperienceSwitch;
|
|
20
20
|
/** Display switches a story placed in the bar or its panel; absent or empty: none, the bar as it was. */
|
|
21
21
|
readonly displaySwitches?: readonly DisplaySwitchItem[];
|
|
22
|
+
/** The views the scene names, in the bar or its switch panel; absent: none. */
|
|
23
|
+
readonly viewChoice?: ViewChoice;
|
|
22
24
|
}
|
|
23
25
|
interface DeveloperProps {
|
|
24
26
|
readonly developerMode: boolean;
|
|
25
27
|
readonly onDeveloperModeChange: (enabled: boolean) => void;
|
|
26
28
|
}
|
|
27
29
|
/** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
|
|
28
|
-
export declare function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, ...objectControls }: Props): import("react").JSX.Element;
|
|
30
|
+
export declare function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches, viewChoice, ...objectControls }: Props): import("react").JSX.Element;
|
|
29
31
|
/** Developer mode stays public, as a cog on its own at the top right of the shell. */
|
|
30
32
|
export declare function DeveloperToggle({ developerMode, onDeveloperModeChange }: DeveloperProps): import("react").JSX.Element;
|
|
31
33
|
export {};
|
package/src/shell/TopBar.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ObjectControls } from "./ObjectControls.js";
|
|
3
3
|
import { ScaleControl } from "./ScaleControl.js";
|
|
4
|
-
import { DisplaySwitches } from "./DisplaySwitches.js";
|
|
4
|
+
import { DisplaySwitches, ViewButtons, viewChoiceInPanel } from "./DisplaySwitches.js";
|
|
5
5
|
import { SwitchControl } from "./SwitchControl.js";
|
|
6
6
|
import { CogIcon } from "./topBarIcons.js";
|
|
7
7
|
import "./TopBar.css";
|
|
8
8
|
/** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
|
|
9
|
-
export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], ...objectControls }) {
|
|
10
|
-
return (_jsx("div", { className: "shell-toolbar", children: _jsxs("div", { className: "top-bar", children: [switcher !== undefined && switcher.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SwitchControl, { choice: switcher }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), _jsx(ObjectControls, { ...objectControls }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(ScaleControl, { scaleId: scaleId, onScaleChange: onScaleChange, choices: scaleChoices }), displaySwitches.length > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(DisplaySwitches, { switches: displaySwitches })] }))] }) }));
|
|
9
|
+
export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], viewChoice, ...objectControls }) {
|
|
10
|
+
return (_jsx("div", { className: "shell-toolbar", children: _jsxs("div", { className: "top-bar", children: [switcher !== undefined && switcher.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SwitchControl, { choice: switcher }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), viewChoice !== undefined && viewChoice.place === "top-bar" && viewChoice.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(ViewButtons, { choice: viewChoice }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), _jsx(ObjectControls, { ...objectControls }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(ScaleControl, { scaleId: scaleId, onScaleChange: onScaleChange, choices: scaleChoices }), (displaySwitches.length > 0 || viewChoiceInPanel(viewChoice)) && (_jsxs(_Fragment, { children: [_jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(DisplaySwitches, { switches: displaySwitches, viewChoice: viewChoice })] }))] }) }));
|
|
11
11
|
}
|
|
12
12
|
/** Developer mode stays public, as a cog on its own at the top right of the shell. */
|
|
13
13
|
export function DeveloperToggle({ developerMode, onDeveloperModeChange }) {
|
package/src/shell/TopBar.node.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ObjectControls } from "./ObjectControls.js";
|
|
3
3
|
import { ScaleControl } from "./ScaleControl.js";
|
|
4
|
-
import { DisplaySwitches } from "./DisplaySwitches.js";
|
|
4
|
+
import { DisplaySwitches, ViewButtons, viewChoiceInPanel } from "./DisplaySwitches.js";
|
|
5
5
|
import { SwitchControl } from "./SwitchControl.js";
|
|
6
6
|
import { CogIcon } from "./topBarIcons.js";
|
|
7
7
|
/** The single compact bar: body picker, Info, camera buttons and Scale in one row. */
|
|
8
|
-
export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], ...objectControls }) {
|
|
9
|
-
return (_jsx("div", { className: "shell-toolbar", children: _jsxs("div", { className: "top-bar", children: [switcher !== undefined && switcher.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SwitchControl, { choice: switcher }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), _jsx(ObjectControls, { ...objectControls }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(ScaleControl, { scaleId: scaleId, onScaleChange: onScaleChange, choices: scaleChoices }), displaySwitches.length > 0 && (_jsxs(_Fragment, { children: [_jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(DisplaySwitches, { switches: displaySwitches })] }))] }) }));
|
|
8
|
+
export function TopBar({ scaleId, onScaleChange, scaleChoices, switcher, displaySwitches = [], viewChoice, ...objectControls }) {
|
|
9
|
+
return (_jsx("div", { className: "shell-toolbar", children: _jsxs("div", { className: "top-bar", children: [switcher !== undefined && switcher.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(SwitchControl, { choice: switcher }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), viewChoice !== undefined && viewChoice.place === "top-bar" && viewChoice.options.length > 1 && (_jsxs(_Fragment, { children: [_jsx(ViewButtons, { choice: viewChoice }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" })] })), _jsx(ObjectControls, { ...objectControls }), _jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(ScaleControl, { scaleId: scaleId, onScaleChange: onScaleChange, choices: scaleChoices }), (displaySwitches.length > 0 || viewChoiceInPanel(viewChoice)) && (_jsxs(_Fragment, { children: [_jsx("span", { className: "top-bar-divider", "aria-hidden": "true" }), _jsx(DisplaySwitches, { switches: displaySwitches, viewChoice: viewChoice })] }))] }) }));
|
|
10
10
|
}
|
|
11
11
|
/** Developer mode stays public, as a cog on its own at the top right of the shell. */
|
|
12
12
|
export function DeveloperToggle({ developerMode, onDeveloperModeChange }) {
|
|
@@ -62,3 +62,16 @@ export declare function navigationStops(events: readonly TimelineEvent[], window
|
|
|
62
62
|
readonly previous: NavigationStop | null;
|
|
63
63
|
readonly next: NavigationStop | null;
|
|
64
64
|
};
|
|
65
|
+
/** The least gap (px) between two markers on the track; markers closer than this are gathered into one group. An 18 px marker button plus a small margin. */
|
|
66
|
+
export declare const MARKER_MIN_SPACING_PX = 22;
|
|
67
|
+
/** One or more markers that sit together on the track: a single member is an ordinary marker, several are gathered under one group mark. */
|
|
68
|
+
export interface MarkerGroup<T> {
|
|
69
|
+
/** Members in time order. */
|
|
70
|
+
readonly members: readonly T[];
|
|
71
|
+
/** Where the mark sits on the track, as a percent of its width (the mean of the members' own positions). */
|
|
72
|
+
readonly positionPercent: number;
|
|
73
|
+
}
|
|
74
|
+
/** Gathers markers whose pixel gaps on a track of this width are under the minimum spacing (chained: each member is close to the one before). Markers keep their true times; a group lists them all. */
|
|
75
|
+
export declare function groupMarkers<T extends {
|
|
76
|
+
readonly timeUtcMs: number;
|
|
77
|
+
}>(items: readonly T[], bounds: TimeBounds, trackWidthPx: number, minSpacingPx?: number): readonly MarkerGroup<T>[];
|
|
@@ -143,3 +143,28 @@ export function navigationStops(events, windows, timeUtcMs) {
|
|
|
143
143
|
}
|
|
144
144
|
return { previous, next };
|
|
145
145
|
}
|
|
146
|
+
/** The least gap (px) between two markers on the track; markers closer than this are gathered into one group. An 18 px marker button plus a small margin. */
|
|
147
|
+
export const MARKER_MIN_SPACING_PX = 22;
|
|
148
|
+
/** Gathers markers whose pixel gaps on a track of this width are under the minimum spacing (chained: each member is close to the one before). Markers keep their true times; a group lists them all. */
|
|
149
|
+
export function groupMarkers(items, bounds, trackWidthPx, minSpacingPx = MARKER_MIN_SPACING_PX) {
|
|
150
|
+
// An unmeasured track (no layout yet, or a page without one) gathers nothing: every marker stays its own.
|
|
151
|
+
if (!(trackWidthPx > 0))
|
|
152
|
+
return [...items].sort((a, b) => a.timeUtcMs - b.timeUtcMs).map((item) => ({ members: [item], positionPercent: timePositionPercent(item.timeUtcMs, bounds) }));
|
|
153
|
+
const sorted = [...items].sort((a, b) => a.timeUtcMs - b.timeUtcMs);
|
|
154
|
+
const px = (item) => (timePositionPercent(item.timeUtcMs, bounds) / 100) * trackWidthPx;
|
|
155
|
+
const groups = [];
|
|
156
|
+
let previous = Number.NEGATIVE_INFINITY;
|
|
157
|
+
for (const item of sorted) {
|
|
158
|
+
const at = px(item);
|
|
159
|
+
const last = groups[groups.length - 1];
|
|
160
|
+
if (last !== undefined && at - previous < minSpacingPx)
|
|
161
|
+
last.push(item);
|
|
162
|
+
else
|
|
163
|
+
groups.push([item]);
|
|
164
|
+
previous = at;
|
|
165
|
+
}
|
|
166
|
+
return groups.map((members) => ({
|
|
167
|
+
members,
|
|
168
|
+
positionPercent: members.reduce((sum, item) => sum + timePositionPercent(item.timeUtcMs, bounds), 0) / members.length,
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ViewCameraRule } from "../app/views.js";
|
|
2
|
+
import type { ExperienceCameraPreset, ExperienceConfig } from "./experience.js";
|
|
3
|
+
/** The preset a view's rule asks for, or undefined for `stay` (no request: the pose is kept and following stops). The scene's start framing is its start preset, else the overview. */
|
|
4
|
+
export declare function presetForViewRule(rule: ViewCameraRule, experience: ExperienceConfig): ExperienceCameraPreset | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { findCameraPreset } from "./objectModel.js";
|
|
2
|
+
/** The preset a view's rule asks for, or undefined for `stay` (no request: the pose is kept and following stops). The scene's start framing is its start preset, else the overview. */
|
|
3
|
+
export function presetForViewRule(rule, experience) {
|
|
4
|
+
if (rule.rule === "stay")
|
|
5
|
+
return undefined;
|
|
6
|
+
const framing = rule.framing;
|
|
7
|
+
if (framing !== undefined) {
|
|
8
|
+
const kind = "follow" in framing ? "follow" : "focus";
|
|
9
|
+
const target = "follow" in framing ? framing.follow : framing.focus;
|
|
10
|
+
return findCameraPreset(experience, kind, target) ?? { id: `${kind}-${target}`, label: `${kind === "follow" ? "Follow" : "Focus"} ${target}`, request: { kind, target } };
|
|
11
|
+
}
|
|
12
|
+
return experience.cameraPresets.find((preset) => preset.id === experience.startCameraPresetId) ?? findCameraPreset(experience, "overview");
|
|
13
|
+
}
|