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