astraeus 0.7.0 → 0.8.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 +176 -0
- package/README.md +185 -37
- package/package.json +5 -4
- package/src/api/AstraeusScene.d.ts +21 -5
- package/src/api/AstraeusScene.js +34 -10
- package/src/api/AstraeusScene.node.js +34 -10
- package/src/api/assembleScene.d.ts +36 -0
- package/src/api/assembleScene.js +175 -0
- package/src/api/bodySetChecks.d.ts +10 -0
- package/src/api/bodySetChecks.js +117 -0
- package/src/api/bodySetInput.d.ts +81 -0
- package/src/api/bodySetInput.js +1 -0
- package/src/api/containingBlock.d.ts +6 -0
- package/src/api/containingBlock.js +16 -0
- package/src/api/data.d.ts +17 -5
- package/src/api/data.js +28 -10
- package/src/api/definitionOf.d.ts +16 -0
- package/src/api/definitionOf.js +20 -0
- package/src/api/errors.d.ts +61 -1
- package/src/api/frozenCopy.d.ts +6 -0
- package/src/api/frozenCopy.js +26 -0
- package/src/api/group.d.ts +8 -2
- package/src/api/group.js +24 -5
- package/src/api/index.d.ts +18 -7
- package/src/api/index.js +2 -2
- package/src/api/index.node.js +2 -2
- package/src/api/listeners.d.ts +5 -0
- package/src/api/listeners.js +25 -0
- package/src/api/look.d.ts +47 -0
- package/src/api/look.js +1 -0
- package/src/api/lookInput.d.ts +3 -0
- package/src/api/lookInput.js +41 -0
- package/src/api/moonPanelInput.d.ts +60 -0
- package/src/api/moonPanelInput.js +1 -0
- package/src/api/mount.d.ts +9 -19
- package/src/api/mount.js +27 -13
- package/src/api/mount.node.js +27 -13
- package/src/api/pathProvenance.js +1 -1
- package/src/api/pickerInput.d.ts +25 -0
- package/src/api/pickerInput.js +1 -0
- package/src/api/planBodies.d.ts +72 -0
- package/src/api/planBodies.js +300 -0
- package/src/api/planBodySets.d.ts +68 -0
- package/src/api/planBodySets.js +234 -0
- package/src/api/planCamera.d.ts +83 -0
- package/src/api/planCamera.js +184 -0
- package/src/api/planGroups.d.ts +36 -0
- package/src/api/planGroups.js +103 -0
- package/src/api/planMoonPanel.d.ts +19 -0
- package/src/api/planMoonPanel.js +104 -0
- package/src/api/planPaths.d.ts +40 -0
- package/src/api/planPaths.js +212 -0
- package/src/api/planPicker.d.ts +12 -0
- package/src/api/planPicker.js +40 -0
- package/src/api/planPlaces.d.ts +16 -0
- package/src/api/planPlaces.js +99 -0
- package/src/api/planStory.d.ts +26 -0
- package/src/api/planStory.js +66 -0
- package/src/api/planTimeline.d.ts +27 -0
- package/src/api/planTimeline.js +68 -0
- package/src/api/planViews.d.ts +25 -0
- package/src/api/planViews.js +35 -0
- package/src/api/prepared.js +4 -1
- package/src/api/renamedInputs.d.ts +15 -0
- package/src/api/renamedInputs.js +39 -0
- package/src/api/scene.d.ts +162 -68
- package/src/api/scene.js +247 -793
- package/src/api/sceneFreeze.d.ts +4 -0
- package/src/api/sceneFreeze.js +10 -0
- package/src/api/sceneReads.d.ts +171 -0
- package/src/api/sceneReads.js +6 -0
- package/src/api/story.d.ts +49 -19
- package/src/api/story.js +54 -22
- package/src/api/sunOrbit.js +9 -11
- package/src/api/time.d.ts +2 -1
- package/src/api/time.js +2 -1
- package/src/api/viewerCamera.d.ts +22 -0
- package/src/api/viewerCamera.js +84 -0
- package/src/api/viewerClock.d.ts +30 -0
- package/src/api/viewerClock.js +85 -0
- package/src/api/viewerFirstDraw.d.ts +14 -0
- package/src/api/viewerFirstDraw.js +26 -0
- package/src/api/viewerHandle.d.ts +79 -0
- package/src/api/viewerHandle.js +31 -0
- package/src/api/viewerLink.d.ts +87 -15
- package/src/api/viewerLink.js +111 -75
- package/src/api/viewerLooks.d.ts +19 -0
- package/src/api/viewerLooks.js +37 -0
- package/src/api/viewerPicker.d.ts +22 -0
- package/src/api/viewerPicker.js +49 -0
- package/src/api/viewerSelection.d.ts +25 -0
- package/src/api/viewerSelection.js +31 -0
- package/src/api/viewerViews.d.ts +10 -0
- package/src/api/viewerViews.js +18 -0
- package/src/api/viewerZones.d.ts +20 -0
- package/src/api/viewerZones.js +47 -0
- package/src/api/views.d.ts +4 -5
- package/src/api/views.js +7 -5
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +191 -82
- package/src/app/App.node.js +191 -82
- package/src/app/AstraeusScene.d.ts +16 -2
- package/src/app/AstraeusScene.js +4 -4
- package/src/app/BodyView.d.ts +4 -1
- package/src/app/BodyView.js +2 -2
- package/src/app/CameraController.d.ts +6 -0
- package/src/app/DeveloperSettings.d.ts +1 -4
- package/src/app/DeveloperSettings.js +6 -10
- package/src/app/FeatureMarkers.d.ts +4 -3
- package/src/app/FeatureMarkers.js +8 -13
- package/src/app/FrameRateSection.js +2 -1
- package/src/app/OrbitSetView.js +1 -1
- package/src/app/SettingControls.d.ts +11 -3
- package/src/app/SettingControls.js +10 -2
- package/src/app/SkyView.d.ts +3 -10
- package/src/app/SkyView.js +6 -28
- package/src/app/address.d.ts +16 -0
- package/src/app/address.js +31 -0
- package/src/app/bodyDraw.d.ts +10 -7
- package/src/app/bodyDraw.js +12 -32
- package/src/app/bodyMetrics.js +2 -2
- package/src/app/bodySet.d.ts +4 -20
- package/src/app/bodySet.js +5 -16
- package/src/app/debugReadout.js +1 -1
- package/src/app/displaySwitches.d.ts +4 -0
- package/src/app/displaySwitches.js +6 -0
- package/src/app/experienceDefinition.d.ts +11 -23
- package/src/app/listSwitch.d.ts +8 -14
- package/src/app/listSwitch.js +3 -10
- package/src/app/liveLook.d.ts +39 -0
- package/src/app/liveLook.js +66 -0
- package/src/app/look.d.ts +36 -0
- package/src/app/look.js +61 -0
- package/src/app/mission.d.ts +1 -1
- package/src/app/mission.js +1 -1
- package/src/app/openClock.d.ts +3 -2
- package/src/app/openClock.js +3 -3
- package/src/app/sceneCamera.js +9 -0
- package/src/app/sceneFrame.d.ts +4 -4
- package/src/app/sceneFrame.js +13 -8
- package/src/app/sceneHooks.js +3 -2
- package/src/app/style.css +114 -139
- package/src/app/trackedMetrics.d.ts +10 -3
- package/src/app/trackedMetrics.js +22 -11
- package/src/app/viewLink.d.ts +10 -32
- package/src/app/viewLink.js +10 -49
- package/src/app/viewerPort.d.ts +50 -0
- package/src/app/views.d.ts +1 -0
- package/src/assets/bodies/galileanMoons.js +1 -2
- package/src/assets/bodies/io.js +2 -2
- package/src/assets/bodies/listedMoons.d.ts +1 -1
- package/src/assets/bodies/listedMoons.js +2 -3
- package/src/assets/bodies/planetSystemMaps.js +2 -3
- package/src/assets/bodies/venus.js +2 -6
- package/src/assets/catalogue.js +1 -2
- package/src/assets/licence.d.ts +3 -3
- package/src/assets/licence.js +3 -3
- package/src/assets/pictures.d.ts +15 -12
- package/src/assets/pictures.js +24 -20
- package/src/assets/sky.d.ts +6 -5
- package/src/assets/sky.js +6 -9
- package/src/assets/visual.d.ts +4 -0
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +1 -6
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/moonSystem.d.ts +1 -1
- package/src/core/bodies/moonSystem.js +102 -55
- package/src/core/bodies/outerPlanetRingData.js +2 -2
- package/src/core/bodies/planetTrajectory.js +1 -1
- package/src/core/bodySetFamilies.d.ts +20 -0
- package/src/core/bodySetFamilies.js +14 -0
- package/src/core/chebyshevEphemeris.js +1 -1
- package/src/core/elementsBody.d.ts +8 -4
- package/src/core/elementsBody.js +32 -11
- package/src/core/elementsGroup.d.ts +27 -0
- package/src/core/elementsGroup.js +85 -0
- package/src/core/events.d.ts +2 -0
- package/src/core/events.js +2 -0
- package/src/core/illumination.js +1 -1
- package/src/core/listedOrbitGroup.d.ts +2 -0
- package/src/core/listedOrbitGroup.js +11 -7
- package/src/core/moonListText.d.ts +6 -0
- package/src/core/moonListText.js +19 -0
- package/src/core/moonTrajectory.js +1 -1
- package/src/core/pacing.d.ts +38 -3
- package/src/core/pacing.js +55 -4
- package/src/core/planetModels.js +2 -2
- package/src/core/planetSeries.d.ts +8 -0
- package/src/core/planetSeries.js +16 -2
- package/src/core/pointGroup.js +1 -1
- package/src/core/provenance.d.ts +2 -1
- package/src/core/provenance.js +2 -2
- package/src/core/referenceCenters.js +5 -5
- package/src/core/sampledTrajectory.js +1 -1
- package/src/core/scalePolicy.d.ts +1 -0
- package/src/core/startView.d.ts +19 -0
- package/src/core/startView.js +28 -0
- package/src/core/state.d.ts +6 -2
- package/src/core/state.js +3 -3
- package/src/core/storyPanels.d.ts +63 -0
- package/src/core/storyPanels.js +111 -0
- package/src/core/sunCentredSources.d.ts +4 -0
- package/src/core/sunCentredSources.js +9 -2
- package/src/core/timeInput.d.ts +4 -0
- package/src/core/timeInput.js +4 -0
- package/src/shell/AstraeusShell.d.ts +5 -1
- package/src/shell/AstraeusShell.js +20 -11
- package/src/shell/AstraeusShell.node.js +20 -11
- package/src/shell/Collapsible.d.ts +4 -3
- package/src/shell/Collapsible.js +5 -5
- package/src/shell/ControlsDrawer.d.ts +1 -1
- package/src/shell/ControlsDrawer.js +3 -1
- package/src/shell/DisplaySwitches.js +2 -1
- package/src/shell/InfoPanel.d.ts +3 -1
- package/src/shell/InfoPanel.js +5 -4
- package/src/shell/MoonFamilyPanel.js +1 -1
- package/src/shell/ObjectControls.d.ts +3 -1
- package/src/shell/ObjectControls.js +2 -2
- package/src/shell/Sources.d.ts +5 -3
- package/src/shell/Sources.js +5 -5
- package/src/shell/StoryPanelView.d.ts +4 -3
- package/src/shell/StoryPanelView.js +8 -6
- package/src/shell/SwitchControl.d.ts +5 -11
- package/src/shell/SwitchControl.js +2 -20
- package/src/shell/TimelineBar.css +81 -81
- package/src/shell/TimelineBar.d.ts +5 -2
- package/src/shell/TimelineBar.js +9 -8
- package/src/shell/TimelineBar.node.js +9 -8
- package/src/shell/TopBar.css +22 -22
- package/src/shell/TopBar.d.ts +5 -1
- package/src/shell/TopBar.js +2 -2
- package/src/shell/TopBar.node.js +2 -2
- package/src/shell/bootLoader.d.ts +4 -10
- package/src/shell/bootLoader.js +6 -52
- package/src/shell/embedded.css +18 -18
- package/src/shell/experience.d.ts +1 -1
- package/src/shell/moonFamilies.d.ts +2 -6
- package/src/shell/moonFamilies.js +2 -18
- package/src/shell/phone.css +58 -58
- package/src/shell/storyPanels.d.ts +2 -53
- package/src/shell/storyPanels.js +1 -106
- package/src/shell/style.css +153 -134
- package/src/shell/useDrawers.d.ts +3 -2
- package/src/shell/useDrawers.js +4 -3
- package/src/shell/viewerKeys.d.ts +8 -0
- package/src/shell/viewerKeys.js +16 -0
- package/src/synthetic/syntheticDefinition.js +20 -24
- package/src/synthetic/syntheticJourneyScene.js +3 -3
- package/src/synthetic/syntheticProbeDefinition.js +2 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +0 -3
- package/src/synthetic/syntheticViewsDefinition.js +10 -16
- package/data/moons/jupiter.json +0 -3333
- package/data/moons/neptune.json +0 -555
- package/data/moons/pluto.json +0 -205
- package/data/moons/saturn.json +0 -8267
- package/data/moons/uranus.json +0 -887
- package/src/app/addressNavigation.d.ts +0 -17
- package/src/app/addressNavigation.js +0 -16
- package/src/assets/bodies/jupiterMoonCatalogue.d.ts +0 -3
- package/src/assets/bodies/jupiterMoonCatalogue.js +0 -4
- package/src/assets/bodies/outerPlanetCatalogues.d.ts +0 -7
- package/src/assets/bodies/outerPlanetCatalogues.js +0 -8
- package/src/assets/bodies/swiftTuttle.d.ts +0 -12
- package/src/assets/bodies/swiftTuttle.js +0 -13
- package/src/assets/moonCatalogue.d.ts +0 -49
- package/src/assets/moonCatalogue.js +0 -80
- package/src/core/bodies/outerPlanetData.d.ts +0 -4
- package/src/core/bodies/outerPlanetData.js +0 -13
- package/src/core/bodies/swiftTuttle.d.ts +0 -46
- package/src/core/bodies/swiftTuttle.js +0 -106
package/src/app/App.node.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
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";
|
|
2
|
+
import { Suspense, useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
4
4
|
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
|
-
import { applyPacing } from "../core/pacing.js";
|
|
5
|
+
import { activeEventZones, applyPacing, startPaceEase } from "../core/pacing.js";
|
|
6
6
|
import { openClock } from "./openClock.js";
|
|
7
|
+
import { pickerSwitch } from "./listSwitch.js";
|
|
7
8
|
import { createSolarSystemScale } from "../core/scalePolicy.js";
|
|
8
9
|
import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
|
|
9
10
|
import { AstraeusShell } from "../shell/AstraeusShell.node.js";
|
|
10
|
-
import { scaleChoicesFor, scalePolicyFor, startScaleFor } from "../shell/scaleModel.js";
|
|
11
|
-
import { scaleFromSearch, timeFromSearch,
|
|
11
|
+
import { SCALE_CHOICES, scaleChoicesFor, scalePolicyFor, startScaleFor } from "../shell/scaleModel.js";
|
|
12
|
+
import { scaleFromSearch, showFromSearch, timeFromSearch, viewFromAngles, viewFromSearch } from "./viewLink.js";
|
|
13
|
+
import { createOrbitCameraState } from "./CameraController.js";
|
|
14
|
+
import { START_CAMERA_DISTANCE } from "./sceneFraming.js";
|
|
15
|
+
import { addressSearch, shareViewLink } from "./address.js";
|
|
12
16
|
import { Collapsible } from "../shell/Collapsible.js";
|
|
13
17
|
import { PanelLoadBoundary } from "./PanelLoadBoundary.js";
|
|
14
18
|
import { BOOT_FADE_LIMITS, bootFadeSeconds, saveBootFadeSeconds } from "../shell/bootLoader.js";
|
|
@@ -17,29 +21,22 @@ import { DEFAULT_ILLUMINATE_ALL } from "./lighting.js";
|
|
|
17
21
|
import { SettingButtons, SettingColor, SettingGroup, SettingSlider } from "./SettingControls.js";
|
|
18
22
|
import { DEFAULT_TIMELINE_GLOW } from "../shell/timelineGlow.js";
|
|
19
23
|
import { DEFAULT_PHONE_LAYOUT, PHONE_LAYOUT_LIMITS } from "../shell/phoneLayout.js";
|
|
20
|
-
import { featureMarkerSpecs,
|
|
24
|
+
import { featureMarkerSpecs, featureMinBodyPxOf } from "./FeatureMarkers.js";
|
|
21
25
|
import { FrameStats } from "./frameStats.js";
|
|
22
26
|
import { AstraeusScene } from "./AstraeusScene.js";
|
|
23
27
|
import { HOVER_BRIGHTNESS_DEFAULT } from "./scenePicking.js";
|
|
24
28
|
import { createSceneResolver } from "./sceneLayout.js";
|
|
25
29
|
import { loadStarCatalogue } from "../assets/sky.js";
|
|
26
|
-
import {
|
|
30
|
+
import { withSkyObject } from "./skyModel.js";
|
|
27
31
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
28
32
|
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
29
|
-
import { displaySwitchItems, orbitStart } from "./displaySwitches.js";
|
|
33
|
+
import { displaySwitchItems, hostReachable, orbitStart } from "./displaySwitches.js";
|
|
30
34
|
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
31
|
-
import { baseGlowOf,
|
|
32
|
-
import {
|
|
35
|
+
import { baseGlowOf, glowLookOf, markerSettingsOf } from "./bodyDraw.js";
|
|
36
|
+
import { resolveLook } from "./look.js";
|
|
37
|
+
import { applyLook, desktopPicturesOf, lookReadOf, presentationOf, skySettingsOf } from "./liveLook.js";
|
|
33
38
|
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
34
39
|
const FPS_HISTORY = 60;
|
|
35
|
-
/** The sky settings in force: the experience's own, hidden when the address says `?sky=off`. */
|
|
36
|
-
function skySettingsOf(definition) {
|
|
37
|
-
const settings = resolveSkySettings(definition.sky);
|
|
38
|
-
const milkyWay = milkyWayFromSearch(window.location.search) ?? definition.displaySwitches?.milkyWay?.on ?? settings.milkyWay;
|
|
39
|
-
const starBrightness = brightnessFromSearch(window.location.search, "stars") ?? settings.starBrightness;
|
|
40
|
-
const milkyWayBrightness = brightnessFromSearch(window.location.search, "milkywaybrightness") ?? settings.milkyWayBrightness;
|
|
41
|
-
return { ...settings, milkyWay, starBrightness, milkyWayBrightness, visible: settings.visible && !skyHiddenBySearch(window.location.search) };
|
|
42
|
-
}
|
|
43
40
|
/** The labels switched off at the start: objects that set `showLabel: false`, then `?labels=<id>:on|off,...` over them. */
|
|
44
41
|
export function hiddenLabelsFrom(search, objects) {
|
|
45
42
|
const hidden = new Set(objects.filter((object) => object.showLabel === false).map((object) => object.id));
|
|
@@ -59,6 +56,18 @@ export function loopFromSearch(search, fallback) {
|
|
|
59
56
|
const value = new URLSearchParams(search).get("loop");
|
|
60
57
|
return value === "on" ? true : value === "off" ? false : fallback;
|
|
61
58
|
}
|
|
59
|
+
/** The scene view showing at the start: `?show=<id>` when it names one of the scene's views, else the scene's own `start` (an unknown id is not an error). */
|
|
60
|
+
function startViewId(definition, search) {
|
|
61
|
+
const asked = showFromSearch(search);
|
|
62
|
+
const known = asked !== undefined && definition.views?.views.some((view) => view.id === asked) === true;
|
|
63
|
+
return known ? asked : definition.views?.start ?? "";
|
|
64
|
+
}
|
|
65
|
+
/** The "Copy view link" button and its readout: offered only when the host turned the address option on (nothing else writes the address). */
|
|
66
|
+
function ViewLinkGroup({ offered, onCopy, ...readout }) {
|
|
67
|
+
if (!offered)
|
|
68
|
+
return null;
|
|
69
|
+
return (_jsxs("div", { className: "view-link", role: "group", "aria-label": "Camera view", children: [_jsx(SettingButtons, { label: "Camera view", children: _jsx("button", { onClick: onCopy, children: "Copy view link" }) }), _jsx(ViewLinkReadout, { ...readout })] }));
|
|
70
|
+
}
|
|
62
71
|
/** The labels switch's starting state, if the story gave one. */
|
|
63
72
|
function labelStart(definition) {
|
|
64
73
|
return definition.displaySwitches?.labels?.on;
|
|
@@ -75,20 +84,19 @@ function orbitPathsOf(runtime) {
|
|
|
75
84
|
return runtime.composition?.paths ?? [];
|
|
76
85
|
}
|
|
77
86
|
/** The up direction at the start: `?up=` in the address, else the experience's own, else the equatorial pole. */
|
|
78
|
-
function startViewUp(definition) {
|
|
79
|
-
return viewUpFromSearch(
|
|
87
|
+
function startViewUp(definition, search) {
|
|
88
|
+
return viewUpFromSearch(search, definition.viewUp ?? "equatorial");
|
|
80
89
|
}
|
|
81
90
|
function storyStartOf(storySet) {
|
|
82
91
|
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
|
|
83
92
|
}
|
|
84
|
-
function switcherOf(definition, runtime, open) {
|
|
85
|
-
return definition.switcher === undefined ? undefined : { ...definition.switcher, currentTimeUtcMs: () => runtime.clock.snapshot().timeUtcMs, open };
|
|
86
|
-
}
|
|
87
93
|
/** Everything one mounted experience shares: clock, resolver, catalogue and the settings read from its definition and the address. */
|
|
88
|
-
function buildRuntime(definition) {
|
|
94
|
+
function buildRuntime(definition, search) {
|
|
89
95
|
const adapter = createOrbAstronomyAdapter();
|
|
96
|
+
// The looks in force: the scene's, with the address over them; the one source every look reader below uses.
|
|
97
|
+
const look = resolveLook(definition.look, search);
|
|
90
98
|
// A copied view link carries the time it was copied at.
|
|
91
|
-
const clock = openClock(definition, timeFromSearch(
|
|
99
|
+
const clock = openClock(definition, timeFromSearch(search), shownEventsOf(definition, startViewId(definition, search)));
|
|
92
100
|
// One resolver per mount: every position in the scene comes from it, whatever the scene centre.
|
|
93
101
|
const resolver = createSceneResolver(adapter, catalogueOf(definition));
|
|
94
102
|
return {
|
|
@@ -99,67 +107,95 @@ function buildRuntime(definition) {
|
|
|
99
107
|
bodies: mountedBodiesOf(definition),
|
|
100
108
|
composition: compositionOf(definition),
|
|
101
109
|
overrides: visualOverridesOf(definition),
|
|
102
|
-
desktopTextures: definition
|
|
110
|
+
desktopTextures: desktopPicturesOf(definition, look),
|
|
111
|
+
...(definition.pictures === undefined ? {} : { pictures: definition.pictures }),
|
|
103
112
|
sceneCenter: sceneCenterOf(definition),
|
|
104
113
|
trackedBodies: trackedBodiesOf(definition),
|
|
105
114
|
groups: groupsOf(definition),
|
|
106
115
|
bodySets: bodySetsOf(definition),
|
|
107
116
|
...sunCentredOf(definition),
|
|
108
117
|
cameraReach: cameraReachOf(definition),
|
|
109
|
-
|
|
118
|
+
look,
|
|
119
|
+
sky: skySettingsOf(definition, look),
|
|
110
120
|
loopWindow: definition.experience.window,
|
|
111
121
|
...(definition.experience.hideTimeline === true ? {} : { stopAtWindow: true }),
|
|
112
122
|
...(definition.pacing === undefined ? {} : { pacing: definition.pacing }),
|
|
113
|
-
|
|
123
|
+
...(definition.eventZones === undefined ? {} : { eventZones: definition.eventZones }),
|
|
124
|
+
up: viewUpVector(startViewUp(definition, search)),
|
|
114
125
|
};
|
|
115
126
|
}
|
|
127
|
+
/** The event ids the view shows, which choose the pacing zones that apply; undefined for a scene without views (every zone applies). */
|
|
128
|
+
function shownEventsOf(definition, viewId) {
|
|
129
|
+
return viewById(definition.views, viewId)?.events;
|
|
130
|
+
}
|
|
116
131
|
/** Whether the experience has anything the Display controls (markers, labels, timeline, phone layout) act on. */
|
|
117
|
-
function showsDisplayControls(definition, runtime, orbitPathCount, storyMarkerCount) {
|
|
118
|
-
return orbitPathCount > 0 || runtime.trackedBodies.length > 0 ||
|
|
132
|
+
function showsDisplayControls(definition, runtime, skyVisible, orbitPathCount, storyMarkerCount) {
|
|
133
|
+
return orbitPathCount > 0 || runtime.trackedBodies.length > 0 || skyVisible || storyMarkerCount > 0 || (definition.experience.storyPanels?.panels.length ?? 0) > 0
|
|
119
134
|
|| runtime.bodies.some((id) => runtime.catalogue.get(id).visual.kind === "sphere");
|
|
120
135
|
}
|
|
136
|
+
/** The camera as the scene opens it (the start view, else its default framing): what a host reads before the scene's first frame writes `viewReadout`. */
|
|
137
|
+
function openingCamera(definition, runtime, search) {
|
|
138
|
+
const start = viewFromSearch(search) ?? definition.startView;
|
|
139
|
+
if (start !== undefined)
|
|
140
|
+
return start;
|
|
141
|
+
const opening = createOrbitCameraState(START_CAMERA_DISTANCE, runtime.sceneCenter);
|
|
142
|
+
return viewFromAngles(opening.focus, opening.azimuth, opening.elevation, opening.distance);
|
|
143
|
+
}
|
|
121
144
|
/** The scene's live controls at mount: the address overrides the experience's own start values. */
|
|
122
|
-
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies) {
|
|
123
|
-
const search = window.location.search;
|
|
145
|
+
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies, search) {
|
|
124
146
|
const startView = viewFromSearch(search) ?? definition.startView;
|
|
125
147
|
return {
|
|
126
148
|
policy: scalePolicyFor(startScale, suppliedPolicies),
|
|
127
149
|
cameraRequest: null,
|
|
128
150
|
showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
|
|
129
151
|
loop: loopFromSearch(search, definition.loop === true),
|
|
130
|
-
...(definition.pacing === undefined ? {} : { paceAuto: true }),
|
|
131
|
-
up: viewUpVector(startViewUp(definition)),
|
|
152
|
+
...(definition.pacing === undefined ? {} : { paceAuto: true, pace: { shown: shownEventsOf(definition, startViewId(definition, search)) } }),
|
|
153
|
+
up: viewUpVector(startViewUp(definition, search)),
|
|
132
154
|
showMilkyWay: runtime.sky.milkyWay,
|
|
133
|
-
|
|
134
|
-
|
|
155
|
+
skyVisible: runtime.sky.visible,
|
|
156
|
+
bodyMarker: markerSettingsOf(runtime.look),
|
|
157
|
+
...(glowBase === null ? {} : { glowLook: glowLookOf(runtime.look, glowBase) }),
|
|
135
158
|
starBrightness: runtime.sky.starBrightness,
|
|
136
159
|
milkyWayBrightness: runtime.sky.milkyWayBrightness,
|
|
137
160
|
illuminateAll: DEFAULT_ILLUMINATE_ALL,
|
|
138
161
|
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
139
162
|
...startOrbitControls(definition),
|
|
140
163
|
labelObjects: experience.objects,
|
|
141
|
-
viewHidden: hiddenByView(definition.views, viewById(definition.views, definition
|
|
164
|
+
viewHidden: hiddenByView(definition.views, viewById(definition.views, startViewId(definition, search)), experience),
|
|
165
|
+
loadFadeSeconds: bootFadeSeconds(runtime.look),
|
|
166
|
+
desktopPictures: runtime.desktopTextures,
|
|
142
167
|
storyMarkers,
|
|
143
168
|
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
144
|
-
featureMinBodyPx:
|
|
169
|
+
featureMinBodyPx: featureMinBodyPxOf(runtime.look),
|
|
145
170
|
selectedObjectId: initialObjectIdOf(definition),
|
|
146
171
|
frameStats: null,
|
|
147
172
|
groupFills: [],
|
|
148
173
|
...(startView === undefined ? {} : { startView }),
|
|
149
174
|
};
|
|
150
175
|
}
|
|
176
|
+
/** The Developer drawer when the host asked for developer tools, else nothing (the shell then draws no toggle and no drawer). */
|
|
177
|
+
const drawerWhen = (asked, drawer) => (asked === true ? drawer : undefined);
|
|
151
178
|
/**
|
|
152
|
-
* `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
|
|
153
179
|
* `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.
|
|
180
|
+
* `developerTools`: whether the viewer shows the Developer toggle and drawer (default false; the drawer's code is fetched only when a visitor opens it, so off never fetches it; the demo site passes true).
|
|
181
|
+
* `address`: whether the viewer reads the page address (`view`, `t`, `scale`, `up`, `show`, `stars`, `milkyway`, `labels` and the other parameters in the README) and offers a copy-link button that writes it (default false: a host page's address is its own; the demo site passes true).
|
|
154
182
|
* `host`: the link a host page reads and sets the one clock through (time, speed) and hears its changes from; every change goes through the same handlers as the timeline's own controls.
|
|
155
183
|
*/
|
|
156
|
-
export function App({ definition,
|
|
184
|
+
export function App({ definition, writeTitle = true, address, developerTools, host }) {
|
|
157
185
|
// The page heading names the experience once it is open; app.html says only "Astraeus" until then.
|
|
158
186
|
useEffect(() => {
|
|
159
187
|
if (writeTitle)
|
|
160
188
|
document.title = pageTitleOf(definition);
|
|
161
189
|
}, [definition, writeTitle]);
|
|
162
|
-
|
|
190
|
+
// The address text every reader below uses: the page's when the host turned the option on, else empty. Read once per scene, as before.
|
|
191
|
+
const search = useMemo(() => addressSearch(address), [definition, address]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
192
|
+
const runtime = useMemo(() => buildRuntime(definition, search), [definition, search]);
|
|
193
|
+
// The host link hears the scene's first drawn frame (`onFirstDraw`).
|
|
194
|
+
const told = useCallback(() => host?.firstDraw(), [host]);
|
|
195
|
+
// The host's picker: the pressed option is the host's to move (`setPick`), and a press is only reported (`onPick`).
|
|
196
|
+
const watchPick = useCallback((watcher) => host?.watchPick(watcher) ?? (() => undefined), [host]);
|
|
197
|
+
const hostPick = useSyncExternalStore(watchPick, () => host?.pickNow());
|
|
198
|
+
const choosePick = useCallback((value) => host?.picked(value), [host]);
|
|
163
199
|
const experienceRuntime = useMemo(() => ({ clock: runtime.clock, resolver: runtime.resolver, catalogue: runtime.catalogue }), [runtime]);
|
|
164
200
|
// The choices offered, in the experience's order; the solar-system policy enlarges only the bodies the experience names.
|
|
165
201
|
const scaleChoiceIds = useMemo(() => scaleChoiceIdsOf(definition), [definition]);
|
|
@@ -171,7 +207,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
171
207
|
exaggeration[id] = override.exaggeration;
|
|
172
208
|
return [createSolarSystemScale({ exaggeration, defaultExaggeration: 1 })];
|
|
173
209
|
}, [runtime]);
|
|
174
|
-
const linkedScale = scaleFromSearch(
|
|
210
|
+
const linkedScale = scaleFromSearch(search);
|
|
175
211
|
const startScale = startScaleFor(linkedScale, scaleChoiceIds);
|
|
176
212
|
const experience = useMemo(() => experienceWithGroups(definition), [definition]);
|
|
177
213
|
// The shell also lists the sky, citing its sources and saying whether the stars were fetched.
|
|
@@ -185,15 +221,17 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
185
221
|
return () => { cancelled = true; };
|
|
186
222
|
}, []);
|
|
187
223
|
// The current view (App state, like the display switches). The shell's lists read one experience, filtered here once; the scene hides the same ids from `controls.viewHidden`.
|
|
188
|
-
const [viewId, setViewId] = useState(() => definition
|
|
224
|
+
const [viewId, setViewId] = useState(() => startViewId(definition, search));
|
|
189
225
|
const currentView = useMemo(() => viewById(definition.views, viewId), [definition.views, viewId]);
|
|
190
226
|
const viewExperience = useMemo(() => experienceInView(experience, definition.views, currentView), [experience, definition.views, currentView]);
|
|
191
|
-
|
|
227
|
+
// Whether the sky is drawn: the look's `skyVisible`, live (a host's `setLook` changes it).
|
|
228
|
+
const [skyVisible, setSkyVisible] = useState(runtime.sky.visible);
|
|
229
|
+
const shellExperience = useMemo(() => withSkyObject(viewExperience, skyVisible, starStatus), [viewExperience, skyVisible, starStatus]);
|
|
192
230
|
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
193
231
|
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
194
232
|
const storySet = definition.experience.storyPanels;
|
|
195
233
|
const storyMarkerSpecs = useMemo(() => (storySet?.panels ?? []).flatMap((panel) => (panel.objectId === undefined ? [] : [{ panelId: panel.id, objectId: panel.objectId, title: panel.title, timeUtcMs: panel.timeUtcMs }])), [storySet]);
|
|
196
|
-
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies));
|
|
234
|
+
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies, search));
|
|
197
235
|
const readout = useRef(null);
|
|
198
236
|
const [clockSnapshot, setClockSnapshot] = useState(() => runtime.clock.snapshot());
|
|
199
237
|
const [scale, setScale] = useState(startScale);
|
|
@@ -228,13 +266,13 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
228
266
|
const labelToggles = useMemo(() => experience.objects.filter((object) => object.showLabel !== undefined), [experience]);
|
|
229
267
|
const [hiddenLabels, setHiddenLabels] = useState(() => new Set(controls.current.hiddenLabels));
|
|
230
268
|
const [loopOn, setLoopOn] = useState(controls.current.loop === true);
|
|
231
|
-
const [upChoice, setUpChoice] = useState(startViewUp(definition));
|
|
269
|
+
const [upChoice, setUpChoice] = useState(startViewUp(definition, search));
|
|
232
270
|
const [illuminateAll, setIlluminateAll] = useState(controls.current.illuminateAll);
|
|
233
271
|
const [milkyWayOn, setMilkyWayOn] = useState(runtime.sky.milkyWay);
|
|
234
272
|
const [hoverBrightness, setHoverBrightness] = useState(HOVER_BRIGHTNESS_DEFAULT);
|
|
235
273
|
const [starBrightness, setStarBrightness] = useState(runtime.sky.starBrightness);
|
|
236
274
|
const [milkyWayBrightness, setMilkyWayBrightness] = useState(runtime.sky.milkyWayBrightness);
|
|
237
|
-
const [loadFade, setLoadFade] = useState(() => bootFadeSeconds());
|
|
275
|
+
const [loadFade, setLoadFade] = useState(() => bootFadeSeconds(runtime.look));
|
|
238
276
|
const [markerPx, setMarkerPx] = useState(() => controls.current.bodyMarker.minSpherePx);
|
|
239
277
|
const [storyAutoOpen, setStoryAutoOpen] = useState(storyStartOf(storySet).autoOpen);
|
|
240
278
|
const [storyPauseSeconds, setStoryPauseSeconds] = useState(storyStartOf(storySet).pauseSeconds);
|
|
@@ -266,9 +304,6 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
266
304
|
controls.current.onStoryMarker = requestPanel;
|
|
267
305
|
controls.current.onFeatureMarker = requestFeature;
|
|
268
306
|
controls.current.onPickObject = requestPick;
|
|
269
|
-
const updateSelectedObject = useCallback((objectId) => {
|
|
270
|
-
controls.current.selectedObjectId = objectId;
|
|
271
|
-
}, []);
|
|
272
307
|
const updateScale = useCallback((id) => {
|
|
273
308
|
controls.current.policy = scalePolicyFor(id, suppliedPolicies);
|
|
274
309
|
setScale(id);
|
|
@@ -278,14 +313,41 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
278
313
|
const chooseView = useCallback((id) => {
|
|
279
314
|
viewRef.current = id;
|
|
280
315
|
controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
|
|
316
|
+
// The showing view's events choose the pacing zones; a paced rate that changes with them eases in rather than jumping.
|
|
317
|
+
if (controls.current.pace !== undefined) {
|
|
318
|
+
controls.current.pace.shown = shownEventsOf(definition, id);
|
|
319
|
+
if (controls.current.paceAuto === true)
|
|
320
|
+
startPaceEase(controls.current.pace, runtime.clock.rate, performance.now());
|
|
321
|
+
}
|
|
281
322
|
setViewId(id);
|
|
282
|
-
}, [definition, experience]);
|
|
323
|
+
}, [definition, experience, runtime]);
|
|
283
324
|
const viewIds = useMemo(() => definition.views?.views.map((view) => view.id) ?? [], [definition]);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
325
|
+
// The presentation a host reads and sets (looks, switches, scale), rebuilt every render over the live controls; the stable callbacks below call through it.
|
|
326
|
+
const live = useRef(null);
|
|
327
|
+
const stateNow = useCallback(() => {
|
|
328
|
+
const snapshot = runtime.clock.snapshot();
|
|
329
|
+
return {
|
|
330
|
+
...snapshot,
|
|
331
|
+
scale: controls.current.policy.id,
|
|
332
|
+
look: lookReadOf(controls.current),
|
|
333
|
+
switches: live.current?.switches() ?? {},
|
|
334
|
+
...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }),
|
|
335
|
+
...(runtime.eventZones === undefined ? {} : { zones: activeEventZones(runtime.eventZones, shownEventsOf(definition, viewRef.current), snapshot.timeUtcMs) }),
|
|
336
|
+
...(definition.views === undefined ? {} : { view: viewRef.current }),
|
|
337
|
+
...(controls.current.selectedObjectId === "" ? {} : { selected: controls.current.selectedObjectId }),
|
|
338
|
+
};
|
|
339
|
+
}, [runtime, definition]);
|
|
340
|
+
// A selection that changes is told to the host at once (the shell calls this for a menu choice, a pick and a view switch that drops the object); the opening selection and any before the host is attached wait for the attach reading.
|
|
341
|
+
const hostAttached = useRef(false);
|
|
342
|
+
// The presentation (scale, looks, switches) last told to the host, to find what a visitor changed.
|
|
343
|
+
const shownKey = useRef(null);
|
|
344
|
+
// `origin` "move": time or the view moved and the selection followed (a drop or a view rule's framing target); the link names whatever last moved them (a host call, the visitor or playback).
|
|
345
|
+
const updateSelectedObject = useCallback((objectId, origin) => {
|
|
346
|
+
const changed = controls.current.selectedObjectId !== objectId;
|
|
347
|
+
controls.current.selectedObjectId = objectId;
|
|
348
|
+
if (changed && hostAttached.current)
|
|
349
|
+
host?.publishSelection(stateNow(), origin === "move");
|
|
350
|
+
}, [host, stateNow]);
|
|
289
351
|
useEffect(() => {
|
|
290
352
|
const id = window.setInterval(() => {
|
|
291
353
|
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
@@ -294,7 +356,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
294
356
|
else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
|
|
295
357
|
runtime.clock.stopWithin(runtime.loopWindow);
|
|
296
358
|
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
297
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
359
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
298
360
|
setClockSnapshot(runtime.clock.snapshot());
|
|
299
361
|
host?.publish(stateNow(), "playback");
|
|
300
362
|
}, 100);
|
|
@@ -303,14 +365,22 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
303
365
|
// The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
|
|
304
366
|
const seekTo = useCallback((timeUtcMs) => {
|
|
305
367
|
runtime.clock.seek(timeUtcMs);
|
|
368
|
+
// A seek lands on the paced rate for the new time at once, not through a view-switch ease.
|
|
369
|
+
if (controls.current.pace !== undefined) {
|
|
370
|
+
delete controls.current.pace.ease;
|
|
371
|
+
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
372
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
373
|
+
}
|
|
306
374
|
setClockSnapshot(runtime.clock.snapshot());
|
|
307
375
|
}, [runtime]);
|
|
308
376
|
// A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
|
|
309
377
|
const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
|
|
310
378
|
const changeRate = useCallback((rate) => {
|
|
311
379
|
if (rate === "auto") {
|
|
380
|
+
if (controls.current.pace !== undefined)
|
|
381
|
+
delete controls.current.pace.ease;
|
|
312
382
|
if (runtime.pacing !== undefined)
|
|
313
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
383
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
314
384
|
}
|
|
315
385
|
else
|
|
316
386
|
runtime.clock.setRate(rate);
|
|
@@ -318,12 +388,30 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
318
388
|
setPaceAuto(rate === "auto");
|
|
319
389
|
setClockSnapshot(runtime.clock.snapshot());
|
|
320
390
|
}, [runtime]);
|
|
391
|
+
// The same play handler the visitor's button reaches, so a host and a visitor share one clock.
|
|
392
|
+
const hostSetPlaying = setPlaying;
|
|
393
|
+
// The objects a host may point the camera at: those the showing view shows (read live, so a view switch is already counted).
|
|
394
|
+
const cameraTargets = useCallback(() => {
|
|
395
|
+
const hidden = controls.current.viewHidden?.objects;
|
|
396
|
+
return experience.objects.map(({ id }) => id).filter((id) => hidden === undefined || !hidden.has(id));
|
|
397
|
+
}, [experience]);
|
|
398
|
+
const opening = useMemo(() => openingCamera(definition, runtime, search), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
399
|
+
const readCamera = useCallback(() => {
|
|
400
|
+
return { ...(controls.current.viewReadout ?? opening) };
|
|
401
|
+
}, [opening]);
|
|
402
|
+
const setCamera = useCallback((request) => { controls.current.cameraRequest = request; }, []);
|
|
403
|
+
const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
|
|
404
|
+
const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
|
|
405
|
+
const hostSetScale = useCallback((id) => live.current?.setScale(id), []);
|
|
406
|
+
const hostSetSwitch = useCallback((id, on) => live.current?.setSwitch(id, on), []);
|
|
321
407
|
useEffect(() => {
|
|
322
408
|
if (host === undefined)
|
|
323
409
|
return undefined;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
410
|
+
hostAttached.current = true;
|
|
411
|
+
shownKey.current = null; // the presentation is read afresh after each attach
|
|
412
|
+
host.attach({ ...(definition.picker === undefined ? {} : { picker: { id: definition.picker.id, values: definition.picker.options.map((option) => option.value), start: definition.picker.value } }), window: runtime.loopWindow, events: experience.events, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
|
|
413
|
+
return () => { hostAttached.current = false; host.detach(); };
|
|
414
|
+
}, [host, runtime, definition, seekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
|
|
327
415
|
useEffect(() => {
|
|
328
416
|
if (!developerMode)
|
|
329
417
|
return undefined;
|
|
@@ -350,7 +438,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
350
438
|
const view = controls.current.viewReadout;
|
|
351
439
|
if (view === undefined)
|
|
352
440
|
return;
|
|
353
|
-
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
441
|
+
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs, ...(definition.views === undefined ? {} : { show: viewRef.current }) }));
|
|
354
442
|
};
|
|
355
443
|
const viewChoice = definition.views === undefined ? undefined : {
|
|
356
444
|
place: definition.views.place,
|
|
@@ -360,21 +448,46 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
360
448
|
host?.publish(stateNow(), "visitor");
|
|
361
449
|
},
|
|
362
450
|
};
|
|
363
|
-
const
|
|
451
|
+
const bindingsNow = () => ({
|
|
364
452
|
settings: definition.displaySwitches,
|
|
365
|
-
orbit: { present: orbitPaths.length > 0, look:
|
|
366
|
-
moons: { present: bodySets.length > 0, look:
|
|
367
|
-
sky: { present:
|
|
453
|
+
orbit: { present: orbitPaths.length > 0, look: { ...orbitDefault, ...controls.current.orbitLook }, set: setOrbit },
|
|
454
|
+
moons: { present: bodySets.length > 0, look: controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK, set: changeSetLook },
|
|
455
|
+
sky: { present: controls.current.skyVisible !== false, on: controls.current.showMilkyWay, set: (on) => { controls.current.showMilkyWay = on; setMilkyWayOn(on); } },
|
|
368
456
|
labels: {
|
|
369
|
-
objectIds: experience.objects.map((object) => object.id), hidden: hiddenLabels,
|
|
457
|
+
objectIds: experience.objects.map((object) => object.id), hidden: controls.current.hiddenLabels ?? hiddenLabels,
|
|
370
458
|
setHidden: (hidden) => { controls.current.hiddenLabels = new Set(hidden); setHiddenLabels(new Set(hidden)); },
|
|
371
|
-
anchorsPresent: runtime.trackedBodies.length > 0, anchors:
|
|
459
|
+
anchorsPresent: runtime.trackedBodies.length > 0, anchors: controls.current.showAnchorLabels, setAnchors: (on) => { controls.current.showAnchorLabels = on; setAnchorLabels(on); },
|
|
372
460
|
},
|
|
373
461
|
});
|
|
374
|
-
const
|
|
375
|
-
|
|
462
|
+
const displaySwitches = displaySwitchItems(bindingsNow());
|
|
463
|
+
live.current = presentationOf({
|
|
464
|
+
setLook: (look) => {
|
|
465
|
+
const read = applyLook(controls.current, definition, glowBase, look);
|
|
466
|
+
setStarBrightness(read.starBrightness);
|
|
467
|
+
setMilkyWayBrightness(read.milkyWayBrightness);
|
|
468
|
+
setMilkyWayOn(read.milkyWay);
|
|
469
|
+
setSkyVisible(read.skyVisible);
|
|
470
|
+
if (read.sunGlow !== undefined)
|
|
471
|
+
setGlowShown({ ...controls.current.glowLook });
|
|
472
|
+
setMarkerPx(read.markerSwapRadiusPx);
|
|
473
|
+
setLoadFade(read.loadFadeSeconds);
|
|
474
|
+
},
|
|
475
|
+
setScale: updateScale,
|
|
476
|
+
items: () => displaySwitchItems({ ...bindingsNow(), settings: hostReachable(definition.displaySwitches) }),
|
|
477
|
+
});
|
|
478
|
+
// A change the visitor made (the scale or a switch in the shell, a slider or button in the Developer drawer) is told to the host once the screen has it; a host call has already been told, so this finds nothing new.
|
|
479
|
+
useEffect(() => {
|
|
480
|
+
if (!hostAttached.current)
|
|
481
|
+
return;
|
|
482
|
+
const state = stateNow();
|
|
483
|
+
const key = JSON.stringify([state.scale, state.look, state.switches]);
|
|
484
|
+
const changed = shownKey.current !== null && shownKey.current !== key;
|
|
485
|
+
shownKey.current = key;
|
|
486
|
+
if (changed)
|
|
487
|
+
host?.publish(state, "visitor");
|
|
488
|
+
}, [host, stateNow, scale, skyVisible, starBrightness, milkyWayBrightness, milkyWayOn, glowShown, markerPx, loadFade, orbitShown, setLook, hiddenLabels, anchorLabels]);
|
|
376
489
|
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
377
|
-
const showDisplay = showsDisplayControls(definition, runtime, orbitPaths.length, storyMarkerSpecs.length);
|
|
490
|
+
const showDisplay = showsDisplayControls(definition, runtime, skyVisible, orbitPaths.length, storyMarkerSpecs.length);
|
|
378
491
|
// Orbit-line sliders: the first four stay in view, the rest sit in a nested "Fine-tune" fold (T-090).
|
|
379
492
|
const orbitSliders = {
|
|
380
493
|
main: [
|
|
@@ -395,17 +508,13 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
395
508
|
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));
|
|
396
509
|
// The panel's folds, in order; the first one present opens by default and the rest start closed (T-090).
|
|
397
510
|
const groups = [
|
|
398
|
-
sections.length === 0 ? null : {
|
|
399
|
-
id: "demo", title: "This demo", className: "dev-group-cards",
|
|
400
|
-
body: (_jsxs(_Fragment, { children: [sections.filter((section) => section.placement === "before-scene").map(renderSection), sections.filter((section) => section.placement === "after-scene").map(renderSection)] })),
|
|
401
|
-
},
|
|
402
511
|
!showDisplay ? null : {
|
|
403
512
|
id: "camera", title: "Camera and view",
|
|
404
|
-
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); } }),
|
|
513
|
+
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); controls.current.loadFadeSeconds = value; setLoadFade(value); } }), _jsx(ViewLinkGroup, { offered: address === true, onCopy: () => void copyViewLink(), 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" }) })] })),
|
|
405
514
|
},
|
|
406
515
|
!showDisplay ? null : {
|
|
407
516
|
id: "timeline", title: "Timeline and stories",
|
|
408
|
-
body: (_jsxs(_Fragment, { children: [_jsxs(SettingGroup, {
|
|
517
|
+
body: (_jsxs(_Fragment, { children: [_jsxs(SettingGroup, { name: "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 }) }), [
|
|
409
518
|
["minBrightness", "Quiet brightness", "Timeline quiet brightness", "glow-min-value", 0, 1, 0.01],
|
|
410
519
|
["steadyBrightness", "Steady brightness (no rate)", "Timeline steady brightness", "glow-steady-value", 0, 1, 0.01],
|
|
411
520
|
["curve", "Curve (rate to brightness)", "Timeline glow curve", "glow-curve-value", 0.2, 3, 0.05],
|
|
@@ -416,15 +525,15 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
416
525
|
},
|
|
417
526
|
orbitPaths.length === 0 ? null : {
|
|
418
527
|
id: "orbit-lines", title: "Orbit lines",
|
|
419
|
-
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, {
|
|
528
|
+
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, { fold: "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" }) })] })),
|
|
420
529
|
},
|
|
421
530
|
bodySets.length === 0 && ringSystems.length === 0 ? null : {
|
|
422
531
|
id: "moons-rings", title: "Moons and rings",
|
|
423
532
|
body: (_jsx(MoonsAndRingsSettings, { bodySets: bodySets, ringSystems: ringSystems, setLook: setLook, changeSetLook: changeSetLook, ringLook: ringLook, changeRing: changeRing, controls: controls, setSetLook: setSetLook, setRingLook: setRingLook })),
|
|
424
533
|
},
|
|
425
|
-
!(
|
|
534
|
+
!(skyVisible || glowShown !== null) ? null : {
|
|
426
535
|
id: "sky-sun", title: "Sky and Sun",
|
|
427
|
-
body: (_jsx(SkyAndSunSettings, { illuminateAll: illuminateAll, setIlluminateAll: setIlluminateAll, visible:
|
|
536
|
+
body: (_jsx(SkyAndSunSettings, { illuminateAll: illuminateAll, setIlluminateAll: setIlluminateAll, visible: skyVisible, glowShown: glowShown, setGlowShown: setGlowShown, controls: controls, milkyWayOn: milkyWayOn, setMilkyWayOn: setMilkyWayOn, starBrightness: starBrightness, setStarBrightness: setStarBrightness, milkyWayBrightness: milkyWayBrightness, setMilkyWayBrightness: setMilkyWayBrightness })),
|
|
428
537
|
},
|
|
429
538
|
{
|
|
430
539
|
id: "labels", title: "Labels",
|
|
@@ -442,11 +551,11 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
442
551
|
},
|
|
443
552
|
{
|
|
444
553
|
id: "under-the-hood", title: "Under the hood",
|
|
445
|
-
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory
|
|
554
|
+
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory })),
|
|
446
555
|
},
|
|
447
556
|
];
|
|
448
557
|
const presentGroups = groups.filter((group) => group !== null);
|
|
449
|
-
const
|
|
558
|
+
const drawer = (_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, { fold: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }) }) }));
|
|
450
559
|
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
451
560
|
if (runtime.clock.playing)
|
|
452
561
|
runtime.clock.pause();
|
|
@@ -460,5 +569,5 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
460
569
|
}, onSeek: (timeUtcMs) => {
|
|
461
570
|
seekTo(timeUtcMs);
|
|
462
571
|
host?.publish(stateNow(), "visitor");
|
|
463
|
-
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher:
|
|
572
|
+
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: definition.picker === undefined ? undefined : pickerSwitch(definition.picker, hostPick ?? definition.picker.value, choosePick), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: drawerWhen(developerTools, drawer), 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, onFirstDraw: host === undefined ? undefined : told }) }) }));
|
|
464
573
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ViewHidden } from "./viewHiding.js";
|
|
2
2
|
import type { SimulationClock } from "../core/clock.js";
|
|
3
|
-
import type { Pacing } from "../core/pacing.js";
|
|
3
|
+
import type { PaceView, Pacing } from "../core/pacing.js";
|
|
4
4
|
import type { BodyId } from "../core/body.js";
|
|
5
5
|
import type { ScalePolicy } from "../core/scalePolicy.js";
|
|
6
6
|
import type { StateResolver } from "../core/stateResolver.js";
|
|
@@ -18,6 +18,7 @@ import type { FrameStats } from "./frameStats.js";
|
|
|
18
18
|
import type { GroupFill } from "./FrameRateSection.js";
|
|
19
19
|
import { type BodySetLayer, type BodySetLook } from "./bodySet.js";
|
|
20
20
|
import type { RingLook } from "../assets/rings.js";
|
|
21
|
+
import type { Pictures } from "../assets/pictures.js";
|
|
21
22
|
import { type StoryMarkerSpec } from "./StoryMarkers.js";
|
|
22
23
|
import { type FeatureMarkerSpec } from "./FeatureMarkers.js";
|
|
23
24
|
import type { ExperienceObject } from "../shell/experience.js";
|
|
@@ -56,16 +57,19 @@ export interface SceneRuntime {
|
|
|
56
57
|
readonly overrides?: ReadonlyMap<BodyId, VisualOverride>;
|
|
57
58
|
/** Whether bodies may use their desktop texture variant on wide viewports (the definition's opt-in). Absent: no. */
|
|
58
59
|
readonly desktopTextures?: boolean;
|
|
60
|
+
/** The pictures of the data packages this viewer was given (the definition's `pictures`); absent: none, so bodies are flat colours and the sky has no Milky Way. */
|
|
61
|
+
readonly pictures?: Pictures;
|
|
59
62
|
/** Paths the `sun-centred` layer draws; empty when the experience has none. */
|
|
60
63
|
readonly paths?: readonly PathLayer[];
|
|
61
64
|
/** The experience's declared camera reach; empty keeps the built-in limits. */
|
|
62
65
|
readonly cameraReach: CameraReach;
|
|
63
|
-
/** The sky behind the scene: whether it is drawn and how bright. Absent means no sky. */
|
|
66
|
+
/** The sky behind the scene: whether it is drawn and how bright. Absent means no sky. `live`: the host may show a sky that starts hidden (`SceneControls.skyVisible`), so it is built either way. */
|
|
64
67
|
readonly sky?: {
|
|
65
68
|
readonly visible: boolean;
|
|
66
69
|
readonly starBrightness: number;
|
|
67
70
|
readonly milkyWayBrightness: number;
|
|
68
71
|
readonly milkyWay: boolean;
|
|
72
|
+
readonly live?: boolean;
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
export interface SceneControls {
|
|
@@ -90,12 +94,16 @@ export interface SceneControls {
|
|
|
90
94
|
/** Presentation only: live sky strengths, 0 to 2, set from Developer > Display settings. */
|
|
91
95
|
starBrightness: number;
|
|
92
96
|
milkyWayBrightness: number;
|
|
97
|
+
/** Presentation only: false hides the whole sky (stars and Milky Way) without rebuilding it (live; `Scene.setLook({ skyVisible })`). Absent: shown. */
|
|
98
|
+
skyVisible?: boolean;
|
|
93
99
|
/** Presentation only: light every body from the camera's side, keeping its shading (Developer > Sky and Sun). Off: true sunlight. */
|
|
94
100
|
illuminateAll: boolean;
|
|
95
101
|
/** Looping playback is on (live; set from the experience, `?loop=` and Developer > Display settings). Needs `SceneRuntime.loopWindow`. */
|
|
96
102
|
loop?: boolean;
|
|
97
103
|
/** Paced playback is in charge of the rate (live): true until a visitor or the host picks a speed, true again when they choose Auto. Meaningful with `SceneRuntime.pacing`. */
|
|
98
104
|
paceAuto?: boolean;
|
|
105
|
+
/** Which event zones pace the clock (the showing view's events) and the ease after a view switch. Read and updated by `applyPacing`. */
|
|
106
|
+
pace?: PaceView;
|
|
99
107
|
/** The render-frame up vector now in force (live; Developer > Display settings). Absent: the runtime's own. Switching it re-poses the camera in place. */
|
|
100
108
|
up?: RenderVector;
|
|
101
109
|
/** Ids of objects whose label is switched off (live). Their objects stay listed and selectable. */
|
|
@@ -128,6 +136,10 @@ export interface SceneControls {
|
|
|
128
136
|
startView?: StartView;
|
|
129
137
|
/** The camera's current view, written every frame by the scene for "Copy view link". */
|
|
130
138
|
viewReadout?: StartView;
|
|
139
|
+
/** How long the loading cover fades when the first frame is drawn (the address's `loadfade` when the address is on, else the saved setting). */
|
|
140
|
+
loadFadeSeconds?: number;
|
|
141
|
+
/** Whether wide screens draw the larger desktop pictures: set when the viewer is built, read back by `look`. */
|
|
142
|
+
desktopPictures: boolean;
|
|
131
143
|
}
|
|
132
144
|
export type SceneReadout = DebugReadout;
|
|
133
145
|
interface Props {
|
|
@@ -138,6 +150,8 @@ interface Props {
|
|
|
138
150
|
};
|
|
139
151
|
/** Changes when the scale policy changes so mesh radii re-render. */
|
|
140
152
|
readonly scaleId: ScalePolicy["id"];
|
|
153
|
+
/** Told once when the scene's first frame has been drawn (the host's `onFirstDraw`). */
|
|
154
|
+
readonly onFirstDraw?: () => void;
|
|
141
155
|
}
|
|
142
156
|
export declare function AstraeusScene(props: Props): import("react").JSX.Element;
|
|
143
157
|
export {};
|