astraeus 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +72 -9
  3. package/package.json +2 -1
  4. package/src/api/AstraeusScene.js +1 -1
  5. package/src/api/AstraeusScene.node.js +37 -0
  6. package/src/api/activity.d.ts +1 -1
  7. package/src/api/activity.js +1 -1
  8. package/src/api/bodies.d.ts +2 -0
  9. package/src/api/bodies.js +2 -0
  10. package/src/api/group.d.ts +7 -1
  11. package/src/api/index.d.ts +2 -1
  12. package/src/api/index.js +2 -1
  13. package/src/api/index.node.js +8 -0
  14. package/src/api/mount.js +3 -1
  15. package/src/api/mount.node.js +36 -0
  16. package/src/api/scene.d.ts +51 -10
  17. package/src/api/scene.js +216 -55
  18. package/src/api/story.d.ts +8 -2
  19. package/src/api/story.js +11 -0
  20. package/src/api/sunOrbit.d.ts +6 -0
  21. package/src/api/sunOrbit.js +24 -0
  22. package/src/app/App.d.ts +6 -2
  23. package/src/app/App.js +8 -4
  24. package/src/app/App.node.js +401 -0
  25. package/src/app/PanelLoadBoundary.d.ts +2 -1
  26. package/src/app/PanelLoadBoundary.js +2 -2
  27. package/src/app/SceneLabels.d.ts +2 -0
  28. package/src/app/SceneLabels.js +5 -1
  29. package/src/app/SkyView.d.ts +3 -3
  30. package/src/app/SkyView.js +19 -10
  31. package/src/app/TrackedBodyView.d.ts +9 -3
  32. package/src/app/TrackedBodyView.js +52 -13
  33. package/src/app/experienceDefinition.d.ts +8 -0
  34. package/src/app/mission.d.ts +2 -0
  35. package/src/app/pathRules.d.ts +7 -3
  36. package/src/app/pathRules.js +9 -5
  37. package/src/app/sceneContentsHooks.js +2 -2
  38. package/src/app/sceneDebug.d.ts +4 -2
  39. package/src/app/sceneFrame.js +5 -4
  40. package/src/app/sceneFraming.d.ts +13 -0
  41. package/src/app/sceneFraming.js +22 -0
  42. package/src/app/skyModel.js +1 -1
  43. package/src/assets/pictures.d.ts +1 -1
  44. package/src/assets/sky.d.ts +4 -4
  45. package/src/assets/sky.js +12 -13
  46. package/src/core/bodies/io.js +1 -1
  47. package/src/core/bodies/jupiterData.js +2 -2
  48. package/src/core/bodies/jupiterMoons.js +8 -12
  49. package/src/core/bodies/moon.d.ts +8 -0
  50. package/src/core/bodies/moon.js +28 -5
  51. package/src/core/bodies/outerPlanetData.js +7 -7
  52. package/src/core/bodies/planetMoons.js +18 -27
  53. package/src/core/bodies/swiftTuttle.js +2 -0
  54. package/src/core/elementsBody.d.ts +2 -0
  55. package/src/core/elementsBody.js +3 -0
  56. package/src/core/moonTrajectory.js +3 -5
  57. package/src/core/planetModels.js +1 -1
  58. package/src/core/provenance.d.ts +6 -2
  59. package/src/core/provenance.js +3 -1
  60. package/src/core/scalePolicy.d.ts +2 -0
  61. package/src/core/scalePolicy.js +2 -0
  62. package/src/shell/AstraeusShell.js +5 -3
  63. package/src/shell/AstraeusShell.node.js +225 -0
  64. package/src/shell/DisplaySwitches.js +1 -1
  65. package/src/shell/StoryPanelView.js +3 -1
  66. package/src/shell/TimelineBar.node.js +75 -0
  67. package/src/shell/TopBar.node.js +14 -0
  68. package/src/shell/experience.d.ts +2 -0
  69. package/src/shell/infoModel.js +3 -1
  70. package/src/shell/phone.css +1 -1
  71. package/src/shell/useDrawers.js +1 -1
  72. package/src/shell/useZoomThrough.d.ts +7 -0
  73. package/src/shell/useZoomThrough.js +51 -0
  74. package/src/synthetic/syntheticProbeDefinition.d.ts +5 -0
  75. package/src/synthetic/syntheticProbeDefinition.js +38 -0
@@ -0,0 +1,75 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { eventContextAt, eventPositionPercent, formatUtcTimestamp, formatWindowRate, navigationStops, windowContextAt, timePositionPercent, mergeSpeeds, DEFAULT_PLAYBACK_SPEEDS, TIMELINE_STEP_MS, clampToBounds, formatRateCompact } from "./timelineModel.js";
4
+ import { activityAt, DEFAULT_TIMELINE_GLOW, glowDescription, glowGradient, glowProfile, glowTooltip } from "./timelineGlow.js";
5
+ import { Label } from "./Label.js";
6
+ import { useDrawerSwipe } from "./useDrawerSwipe.js";
7
+ /** The seek slider's spoken value: the time, with the activity window and its rate when one is running. */
8
+ function seekValueText(timeUtcMs, activityNow) {
9
+ if (activityNow === null || activityNow.window.rate === undefined)
10
+ return formatUtcTimestamp(timeUtcMs);
11
+ return `${formatUtcTimestamp(timeUtcMs)}, ${activityNow.window.label}: ${formatWindowRate(activityNow.rate, activityNow.window.rate.unit)}`;
12
+ }
13
+ export function TimelineBar({ experience, snapshot, onTogglePlayback, onRateChange, onSeek, panels = [], openPanelId = null, onPanelOpen, onEventSeek, onEventInfo, onWindowSeek, onWindowInfo, glowLook = DEFAULT_TIMELINE_GLOW, drawer }) {
14
+ const windows = experience.windows ?? [];
15
+ const profile = useMemo(() => glowProfile(windows, experience.window), [windows, experience.window]);
16
+ const gradients = useMemo(() => ({ ahead: glowGradient(profile, glowLook, "ahead"), played: glowGradient(profile, glowLook, "played") }), [profile, glowLook]);
17
+ const description = glowDescription(windows);
18
+ const [hoverTitle, setHoverTitle] = useState(null);
19
+ const playedPercent = timePositionPercent(clampToBounds(snapshot.timeUtcMs, experience.window), experience.window);
20
+ const activityNow = activityAt(windows, snapshot.timeUtcMs);
21
+ const valueText = seekValueText(snapshot.timeUtcMs, activityNow);
22
+ const moveOnTrack = (event) => {
23
+ if (profile === null)
24
+ return;
25
+ const box = event.currentTarget.getBoundingClientRect();
26
+ const fraction = box.width > 16 ? Math.max(0, Math.min(1, (event.clientX - box.left - 8) / (box.width - 16))) : 0;
27
+ const text = glowTooltip(windows, experience.window.startUtcMs + (experience.window.endUtcMs - experience.window.startUtcMs) * fraction);
28
+ setHoverTitle((previous) => (previous === text ? previous : text));
29
+ };
30
+ const navigation = navigationStops(experience.events, windows, snapshot.timeUtcMs);
31
+ const goToStop = (stop) => {
32
+ if (stop.event !== undefined)
33
+ onEventSeek(stop.event);
34
+ else if (stop.window !== undefined)
35
+ onWindowSeek(stop.window, stop.timeUtcMs);
36
+ };
37
+ const stopLabel = (direction, stop) => windows.length === 0 || stop === null ? `${direction} event` : `${direction}: ${stop.label}`;
38
+ const speeds = mergeSpeeds(DEFAULT_PLAYBACK_SPEEDS, experience.rates);
39
+ const timestamp = formatUtcTimestamp(snapshot.timeUtcMs);
40
+ const handle = useDrawerSwipe({
41
+ thresholdPx: drawer?.swipeThresholdPx ?? 0,
42
+ onTap: () => drawer?.onOpenChange(!drawer.open),
43
+ onSwipe: (direction) => drawer?.onOpenChange(direction === "up"),
44
+ });
45
+ const speedIndex = Math.max(0, speeds.findIndex((speed) => speed.rate === snapshot.rate));
46
+ 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: {
47
+ "--glow-ahead": gradients.ahead,
48
+ "--glow-played": gradients.played,
49
+ "--glow-played-edge": `${(100 - playedPercent).toFixed(3)}%`,
50
+ "--glow-thickness": `${glowLook.thicknessPx}px`,
51
+ "--glow-halo": `${glowLook.haloPx}px`,
52
+ }, children: [_jsx("span", { className: "timeline-glow-ahead" }), _jsx("span", { className: "timeline-glow-played", children: _jsx("span", { className: "timeline-glow-line" }) })] }), _jsxs("div", { className: "timeline-markers", "aria-label": "Timeline event markers", children: [experience.events.map((event) => (_jsx("button", { className: "timeline-marker", type: "button", "aria-label": `Go to ${event.label}`, title: event.label, style: { left: `${eventPositionPercent(event, experience.window)}%` }, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: _jsx(Label, { text: event.label, className: "timeline-marker-label" }) }, event.id))), panels.map((panel) => (_jsx("button", { className: "timeline-marker timeline-panel-marker", type: "button", "data-panel-id": panel.id, "aria-pressed": openPanelId === panel.id, "aria-label": `Open story panel: ${panel.title}`, title: panel.title, style: { left: `${timePositionPercent(panel.timeUtcMs, experience.window)}%` }, onClick: () => onPanelOpen?.(panel), children: _jsx(Label, { text: panel.title, className: "timeline-marker-label" }) }, panel.id))), windows.filter((window) => window.peakUtcMs !== undefined).map((window) => (_jsx("button", { type: "button", className: "timeline-marker timeline-window-peak", "aria-label": `Go to peak of ${window.label}`, title: `${window.label} peak`, "data-time-utc-ms": window.peakUtcMs, style: { left: `${timePositionPercent(window.peakUtcMs ?? 0, experience.window)}%` }, onClick: () => { if (window.peakUtcMs !== undefined)
53
+ onWindowSeek(window, window.peakUtcMs); onWindowInfo(window); } }, `peak-${window.id}`)))] }), _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) })] })] }));
54
+ 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)
55
+ 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)
56
+ 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", " ") })] }), _jsxs("label", { className: "timeline-speed", children: [_jsx("span", { children: "Playback rate" }), _jsx("select", { "aria-label": "Playback speed", title: "Playback speed", value: snapshot.rate, onChange: (event) => onRateChange(Number(event.target.value)), children: speeds.map((speed) => _jsx("option", { value: speed.rate, children: drawer === undefined ? speed.label : formatRateCompact(speed.rate) }, speed.rate)) })] }), 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")
57
+ drawer.onOpenChange(false); }, children: _jsxs("div", { className: "timeline-drawer-body", children: [_jsxs("div", { className: "timeline-speed-slider", children: [_jsx("span", { "aria-hidden": "true", children: "Playback speed" }), _jsx("input", { type: "range", "aria-label": "Speed slider", "aria-valuetext": speeds[speedIndex]?.label, min: 0, max: speeds.length - 1, step: 1, value: speedIndex, onChange: (event) => { const next = speeds[Number(event.target.value)]; if (next !== undefined)
58
+ onRateChange(next.rate); } }), _jsx("output", { children: speeds[speedIndex]?.label })] }), _jsx(TimelineExpanded, { experience: experience, snapshot: snapshot, onEventSeek: onEventSeek, onEventInfo: onEventInfo, onWindowInfo: onWindowInfo })] }) }))] }));
59
+ }
60
+ /** A 24x24 filled symbol; the button around it carries the accessible name and tooltip. */
61
+ function Symbol({ path }) {
62
+ return _jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: _jsx("path", { d: path }) });
63
+ }
64
+ /**
65
+ * The timeline's expanded content: "Just happened / Up next / Inside" and the full event list.
66
+ * On larger screens it opens from the Events button; the phone drawer shows the same content when expanded.
67
+ */
68
+ export function TimelineExpanded({ experience, snapshot, onEventSeek, onEventInfo, onWindowInfo }) {
69
+ const context = eventContextAt(experience.events, snapshot.timeUtcMs);
70
+ const inside = windowContextAt(experience.windows ?? [], snapshot.timeUtcMs);
71
+ return (_jsxs("div", { className: "timeline-expanded", children: [_jsxs("div", { className: "timeline-event-context", "aria-label": "Event context", children: [context.current === null
72
+ ? _jsxs("span", { children: [_jsx("strong", { children: "Just happened:" }), " No event yet"] })
73
+ : (_jsxs("button", { type: "button", className: "timeline-event-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${context.current.label}`, "aria-controls": "info-panel", onClick: () => { if (context.current !== null)
74
+ onEventInfo(context.current); }, children: [_jsx("strong", { children: "Just happened:" }), " ", context.current.label, " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] })), _jsxs("span", { children: [_jsx("strong", { children: "Up next:" }), " ", context.next?.label ?? "No upcoming event"] }), inside.map(({ window, rate }) => (_jsxs("button", { type: "button", className: "timeline-event-current timeline-window-current ui-row", "data-closes-drawer": "", "aria-label": `Information about ${window.label}`, "aria-controls": "info-panel", onClick: () => onWindowInfo(window), children: [_jsx("strong", { children: "Inside:" }), " ", window.label, rate !== null && window.rate !== undefined && _jsxs(_Fragment, { children: [" \u2014 ", formatWindowRate(rate, window.rate.unit)] }), " ", _jsx("span", { "aria-hidden": "true", children: "\u24D8" })] }, window.id)))] }), _jsx("ol", { children: experience.events.map((event) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "ui-row", "data-closes-drawer": "", "aria-current": context.current?.id === event.id ? "time" : undefined, onClick: () => { onEventSeek(event); onEventInfo(event); }, children: [_jsx("time", { dateTime: formatUtcTimestamp(event.timeUtcMs), children: formatUtcTimestamp(event.timeUtcMs) }), _jsx("span", { children: event.label })] }) }, event.id))) })] }));
75
+ }
@@ -0,0 +1,14 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ObjectControls } from "./ObjectControls.js";
3
+ import { ScaleControl } from "./ScaleControl.js";
4
+ import { DisplaySwitches } from "./DisplaySwitches.js";
5
+ import { SwitchControl } from "./SwitchControl.js";
6
+ import { CogIcon } from "./topBarIcons.js";
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 })] }))] }) }));
10
+ }
11
+ /** Developer mode stays public, as a cog on its own at the top right of the shell. */
12
+ export function DeveloperToggle({ developerMode, onDeveloperModeChange }) {
13
+ return (_jsx("button", { className: "developer-mode-toggle ui-icon ui-pill", type: "button", "aria-label": "Developer mode", title: "Developer mode", "aria-pressed": developerMode, "aria-expanded": developerMode, "aria-controls": "developer-tools", onClick: () => onDeveloperModeChange(!developerMode), children: _jsx(CogIcon, {}) }));
14
+ }
@@ -71,4 +71,6 @@ export interface ExperienceConfig {
71
71
  readonly bodyFeatures?: readonly BodyFeatureSet[];
72
72
  /** Where the event times come from, shown with every event. */
73
73
  readonly eventProvenance?: Provenance;
74
+ /** Provenance of single events by event id; an event listed here shows it instead of `eventProvenance`. */
75
+ readonly eventProvenanceById?: Readonly<Record<string, Provenance>>;
74
76
  }
@@ -6,6 +6,7 @@ export const PROVENANCE_STATUS = {
6
6
  ephemeris: "Ephemeris",
7
7
  observed: "Observed",
8
8
  reconstructed: "Reconstructed",
9
+ modelled: "Modelled",
9
10
  illustrative: "Illustrative",
10
11
  };
11
12
  export function provenanceView(provenance, knownLimitations = []) {
@@ -71,10 +72,11 @@ function eventInfo(experience, target) {
71
72
  const event = experience.events.find((candidate) => candidate.id === target.id);
72
73
  if (event === undefined)
73
74
  return null;
75
+ const source = experience.eventProvenanceById?.[event.id] ?? experience.eventProvenance;
74
76
  return {
75
77
  target,
76
78
  title: event.label,
77
79
  subtitle: formatUtcTimestamp(event.timeUtcMs),
78
- provenance: experience.eventProvenance === undefined ? null : provenanceView(experience.eventProvenance),
80
+ provenance: source === undefined ? null : provenanceView(source),
79
81
  };
80
82
  }
@@ -159,7 +159,7 @@
159
159
  animation: story-sheet-in var(--drawer-ms, 240ms) var(--drawer-ease);
160
160
  }
161
161
  [data-phone="true"] .info-panel { z-index: 8; background: #0e0e13; }
162
- [data-phone="true"] .story-panel { z-index: 4; }
162
+ [data-phone="true"] .story-panel { z-index: 4; touch-action: pan-y; } /* a pinch reaches the scene beneath (useZoomThrough); a vertical drag still scrolls or dismisses */
163
163
  [data-phone="true"] .info-panel-header h2 { margin: 0; font-size: 22px; }
164
164
 
165
165
  /* ---- The Developer panel below the pill, above the timeline ---- */
@@ -18,7 +18,7 @@ export function useDrawers(phone, onControlsOpened) {
18
18
  useEffect(() => {
19
19
  if (!phone || (!controlsOpen && !timelineOpen))
20
20
  return undefined;
21
- const onKey = (event) => { if (event.key === "Escape") {
21
+ const onKey = (event) => { if (!event.defaultPrevented && event.key === "Escape") {
22
22
  setControlsOpen(false);
23
23
  setTimelineOpen(false);
24
24
  } };
@@ -0,0 +1,7 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * Lets a phone bottom sheet pass zoom input to the scene beneath it: a wheel, or a two-finger pinch, over the sheet is forwarded to the canvas as a
4
+ * wheel event, which the camera control already turns into a zoom. A sheet with something to scroll keeps its wheel (reading wins); a pinch always zooms.
5
+ * Does nothing on a wide screen, where the panel sits beside the scene.
6
+ */
7
+ export declare function useZoomThrough(ref: RefObject<HTMLElement | null>): void;
@@ -0,0 +1,51 @@
1
+ import { useEffect } from "react";
2
+ /** A pinch's spread change (px) counts as this many wheel units, matching the camera's pinch (0.006) and wheel (0.0012) sensitivities. */
3
+ const PINCH_TO_WHEEL = 5;
4
+ /**
5
+ * Lets a phone bottom sheet pass zoom input to the scene beneath it: a wheel, or a two-finger pinch, over the sheet is forwarded to the canvas as a
6
+ * wheel event, which the camera control already turns into a zoom. A sheet with something to scroll keeps its wheel (reading wins); a pinch always zooms.
7
+ * Does nothing on a wide screen, where the panel sits beside the scene.
8
+ */
9
+ export function useZoomThrough(ref) {
10
+ useEffect(() => {
11
+ const sheet = ref.current;
12
+ if (sheet === null)
13
+ return undefined;
14
+ const shell = sheet.closest(".astraeus-shell");
15
+ const forward = (deltaY) => {
16
+ shell?.querySelector("canvas")?.dispatchEvent(new WheelEvent("wheel", { deltaY, bubbles: true, cancelable: true }));
17
+ };
18
+ const phone = () => shell?.dataset.phone === "true";
19
+ const onWheel = (event) => {
20
+ if (!phone() || sheet.scrollHeight > sheet.clientHeight)
21
+ return;
22
+ event.preventDefault();
23
+ forward(event.deltaY);
24
+ };
25
+ let spread = null;
26
+ const spreadOf = (touches) => {
27
+ const [a, b] = [touches[0], touches[1]];
28
+ return touches.length === 2 && a !== undefined && b !== undefined ? Math.hypot(a.clientX - b.clientX, a.clientY - b.clientY) : null;
29
+ };
30
+ const onTouch = (event) => {
31
+ const next = phone() ? spreadOf(event.touches) : null;
32
+ if (next !== null && spread !== null) {
33
+ event.preventDefault();
34
+ forward(-(next - spread) * PINCH_TO_WHEEL);
35
+ }
36
+ spread = next;
37
+ };
38
+ sheet.addEventListener("wheel", onWheel, { passive: false });
39
+ sheet.addEventListener("touchstart", onTouch, { passive: true });
40
+ sheet.addEventListener("touchmove", onTouch, { passive: false });
41
+ sheet.addEventListener("touchend", onTouch, { passive: true });
42
+ sheet.addEventListener("touchcancel", onTouch, { passive: true });
43
+ return () => {
44
+ sheet.removeEventListener("wheel", onWheel);
45
+ sheet.removeEventListener("touchstart", onTouch);
46
+ sheet.removeEventListener("touchmove", onTouch);
47
+ sheet.removeEventListener("touchend", onTouch);
48
+ sheet.removeEventListener("touchcancel", onTouch);
49
+ };
50
+ }, [ref]);
51
+ }
@@ -0,0 +1,5 @@
1
+ import type { ExperienceDefinition } from "../app/experienceDefinition.js";
2
+ export declare const PROBE_START_UTC_MS: number;
3
+ /** The moment the made-up probe is at Earth. */
4
+ export declare const PROBE_FLYBY_UTC_MS: number;
5
+ export declare const syntheticProbeDefinition: ExperienceDefinition;
@@ -0,0 +1,38 @@
1
+ import { earth, mars, sun, venus } from "../api/bodies.js";
2
+ import { Scene } from "../api/scene.js";
3
+ import { solarSystemScale } from "../core/scalePolicy.js";
4
+ import { createOrbTwoBodyAdapter } from "../core/twoBodyAdapter.js";
5
+ export const PROBE_START_UTC_MS = Date.parse("2026-01-01T00:00:00Z");
6
+ const DAY_MS = 86_400_000;
7
+ /** The moment the made-up probe is at Earth. */
8
+ export const PROBE_FLYBY_UTC_MS = PROBE_START_UTC_MS + 200 * DAY_MS;
9
+ /** The engine's own ecliptic-to-equator rotation (row-major 3x3); its transpose turns equator vectors back to the ecliptic (STYLE-07: no second obliquity constant). */
10
+ const ECLIPTIC_TO_EQJ = createOrbTwoBodyAdapter().eclipticJ2000ToEqjMatrix();
11
+ const scene = new Scene().addBody(sun).addBody(venus, { enlarge: 60, orbit: true }).addBody(earth, { enlarge: 60, orbit: true }).addBody(mars, { enlarge: 60, orbit: true }).setTime(PROBE_START_UTC_MS);
12
+ /** A planet's place from the Sun at `timeUtcMs`, turned from the equator frame the scene answers in to the ecliptic frame the path is given in (km). */
13
+ function eclipticPlace(id, timeUtcMs) {
14
+ const [x, y, z] = scene.stateOf(id, timeUtcMs).positionKm;
15
+ const m = ECLIPTIC_TO_EQJ;
16
+ return [m[0] * x + m[3] * y + m[6] * z, m[1] * x + m[4] * y + m[7] * z, m[2] * x + m[5] * y + m[8] * z];
17
+ }
18
+ // A straight leg from a point 0.6 of the way from the Sun to Earth's place at the start, to Earth's place at the flyby, ten samples, then on along the same line for five more.
19
+ const from = eclipticPlace("earth", PROBE_START_UTC_MS).map((v) => v * 0.6);
20
+ const to = eclipticPlace("earth", PROBE_FLYBY_UTC_MS);
21
+ const samples = Array.from({ length: 16 }, (_, i) => ({ time: PROBE_START_UTC_MS + i * 20 * DAY_MS, positionKm: from.map((v, k) => v + ((to[k] - v) * i) / 10) }));
22
+ scene.addTrajectory({
23
+ id: "probe",
24
+ label: "Made-up probe",
25
+ samples,
26
+ center: "sun",
27
+ plane: "ecliptic-j2000",
28
+ lineFixedTo: "sun",
29
+ provenance: { sourceType: "illustrative", sources: ["Made up for the Sun-centred path test; not a real spacecraft"], accuracy: "None claimed. A straight line ending at Earth's place on day 200.", notes: "Exists to prove a recorded path can be drawn fixed to the Sun beside enlarged planets." },
30
+ description: "An invented probe that starts inside Earth's orbit and is at Earth on day 200.",
31
+ knownLimitations: ["Made up; not a real spacecraft.", "A straight line: it ignores the Sun's gravity."],
32
+ anchors: [{ id: "probe-flyby", time: PROBE_FLYBY_UTC_MS }],
33
+ });
34
+ scene.addEvents([{ id: "probe-flyby", label: "Made-up flyby of Earth", time: PROBE_FLYBY_UTC_MS }], { provenance: { sourceType: "illustrative", sources: ["Made up"], accuracy: "None claimed.", notes: "Not a real flyby." } });
35
+ scene.setScale(solarSystemScale);
36
+ scene.camera.follow("probe", { distance: 70_000 });
37
+ scene.camera.fitOrbit(mars);
38
+ export const syntheticProbeDefinition = scene.toDefinition();