astraeus 0.6.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 +192 -0
- package/README.md +205 -34
- package/package.json +5 -4
- package/src/api/AstraeusScene.d.ts +24 -6
- package/src/api/AstraeusScene.js +46 -19
- package/src/api/AstraeusScene.node.js +46 -19
- 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 +19 -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 +10 -16
- package/src/api/mount.js +27 -11
- package/src/api/mount.node.js +27 -11
- package/src/api/pathProvenance.d.ts +15 -6
- package/src/api/pathProvenance.js +23 -11
- 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 +176 -65
- package/src/api/scene.js +257 -725
- 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/sphereOfInfluence.d.ts +20 -0
- package/src/api/sphereOfInfluence.js +48 -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 +91 -13
- package/src/api/viewerLink.js +111 -64
- 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 +41 -0
- package/src/api/views.js +82 -0
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +211 -75
- package/src/app/App.node.js +211 -75
- package/src/app/AstraeusScene.d.ts +19 -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 +12 -0
- package/src/app/CameraController.js +3 -1
- 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/StoryMarkers.d.ts +4 -1
- package/src/app/StoryMarkers.js +3 -2
- package/src/app/TrackedBodyView.d.ts +1 -1
- package/src/app/TrackedBodyView.js +20 -11
- package/src/app/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 +14 -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 +16 -3
- package/src/app/mission.js +16 -1
- package/src/app/openClock.d.ts +3 -2
- package/src/app/openClock.js +3 -3
- package/src/app/sceneCamera.d.ts +2 -0
- package/src/app/sceneCamera.js +23 -0
- package/src/app/sceneFrame.d.ts +6 -4
- package/src/app/sceneFrame.js +55 -14
- 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/viewHiding.d.ts +13 -0
- package/src/app/viewHiding.js +37 -0
- package/src/app/viewLink.d.ts +10 -32
- package/src/app/viewLink.js +10 -49
- package/src/app/viewerPort.d.ts +56 -0
- package/src/app/views.d.ts +32 -0
- package/src/app/views.js +2 -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 +17 -3
- package/src/shell/AstraeusShell.js +60 -13
- package/src/shell/AstraeusShell.node.js +60 -13
- 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.d.ts +18 -1
- package/src/shell/DisplaySwitches.js +20 -6
- 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 +84 -66
- package/src/shell/TimelineBar.d.ts +5 -2
- package/src/shell/TimelineBar.js +37 -11
- package/src/shell/TimelineBar.node.js +37 -11
- package/src/shell/TopBar.css +22 -22
- package/src/shell/TopBar.d.ts +9 -3
- package/src/shell/TopBar.js +5 -5
- package/src/shell/TopBar.node.js +5 -5
- 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/timelineModel.d.ts +13 -0
- package/src/shell/timelineModel.js +25 -0
- package/src/shell/useDrawers.d.ts +3 -2
- package/src/shell/useDrawers.js +4 -3
- package/src/shell/viewCamera.d.ts +4 -0
- package/src/shell/viewCamera.js +13 -0
- 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 +14 -4
- package/src/synthetic/syntheticProbeDefinition.js +2 -1
- package/src/synthetic/syntheticViewsDefinition.d.ts +3 -0
- package/src/synthetic/syntheticViewsDefinition.js +38 -0
- 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.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.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,28 +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";
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
33
|
+
import { displaySwitchItems, hostReachable, orbitStart } from "./displaySwitches.js";
|
|
34
|
+
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
35
|
+
import { baseGlowOf, glowLookOf, markerSettingsOf } from "./bodyDraw.js";
|
|
36
|
+
import { resolveLook } from "./look.js";
|
|
37
|
+
import { applyLook, desktopPicturesOf, lookReadOf, presentationOf, skySettingsOf } from "./liveLook.js";
|
|
32
38
|
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
33
39
|
const FPS_HISTORY = 60;
|
|
34
|
-
/** The sky settings in force: the experience's own, hidden when the address says `?sky=off`. */
|
|
35
|
-
function skySettingsOf(definition) {
|
|
36
|
-
const settings = resolveSkySettings(definition.sky);
|
|
37
|
-
const milkyWay = milkyWayFromSearch(window.location.search) ?? definition.displaySwitches?.milkyWay?.on ?? settings.milkyWay;
|
|
38
|
-
const starBrightness = brightnessFromSearch(window.location.search, "stars") ?? settings.starBrightness;
|
|
39
|
-
const milkyWayBrightness = brightnessFromSearch(window.location.search, "milkywaybrightness") ?? settings.milkyWayBrightness;
|
|
40
|
-
return { ...settings, milkyWay, starBrightness, milkyWayBrightness, visible: settings.visible && !skyHiddenBySearch(window.location.search) };
|
|
41
|
-
}
|
|
42
40
|
/** The labels switched off at the start: objects that set `showLabel: false`, then `?labels=<id>:on|off,...` over them. */
|
|
43
41
|
export function hiddenLabelsFrom(search, objects) {
|
|
44
42
|
const hidden = new Set(objects.filter((object) => object.showLabel === false).map((object) => object.id));
|
|
@@ -58,6 +56,18 @@ export function loopFromSearch(search, fallback) {
|
|
|
58
56
|
const value = new URLSearchParams(search).get("loop");
|
|
59
57
|
return value === "on" ? true : value === "off" ? false : fallback;
|
|
60
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
|
+
}
|
|
61
71
|
/** The labels switch's starting state, if the story gave one. */
|
|
62
72
|
function labelStart(definition) {
|
|
63
73
|
return definition.displaySwitches?.labels?.on;
|
|
@@ -74,20 +84,19 @@ function orbitPathsOf(runtime) {
|
|
|
74
84
|
return runtime.composition?.paths ?? [];
|
|
75
85
|
}
|
|
76
86
|
/** The up direction at the start: `?up=` in the address, else the experience's own, else the equatorial pole. */
|
|
77
|
-
function startViewUp(definition) {
|
|
78
|
-
return viewUpFromSearch(
|
|
87
|
+
function startViewUp(definition, search) {
|
|
88
|
+
return viewUpFromSearch(search, definition.viewUp ?? "equatorial");
|
|
79
89
|
}
|
|
80
90
|
function storyStartOf(storySet) {
|
|
81
91
|
return { autoOpen: storySet?.autoOpen ?? false, pauseSeconds: storySet?.pauseSeconds ?? 0 };
|
|
82
92
|
}
|
|
83
|
-
function switcherOf(definition, runtime, open) {
|
|
84
|
-
return definition.switcher === undefined ? undefined : { ...definition.switcher, currentTimeUtcMs: () => runtime.clock.snapshot().timeUtcMs, open };
|
|
85
|
-
}
|
|
86
93
|
/** Everything one mounted experience shares: clock, resolver, catalogue and the settings read from its definition and the address. */
|
|
87
|
-
function buildRuntime(definition) {
|
|
94
|
+
function buildRuntime(definition, search) {
|
|
88
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);
|
|
89
98
|
// A copied view link carries the time it was copied at.
|
|
90
|
-
const clock = openClock(definition, timeFromSearch(
|
|
99
|
+
const clock = openClock(definition, timeFromSearch(search), shownEventsOf(definition, startViewId(definition, search)));
|
|
91
100
|
// One resolver per mount: every position in the scene comes from it, whatever the scene centre.
|
|
92
101
|
const resolver = createSceneResolver(adapter, catalogueOf(definition));
|
|
93
102
|
return {
|
|
@@ -98,66 +107,95 @@ function buildRuntime(definition) {
|
|
|
98
107
|
bodies: mountedBodiesOf(definition),
|
|
99
108
|
composition: compositionOf(definition),
|
|
100
109
|
overrides: visualOverridesOf(definition),
|
|
101
|
-
desktopTextures: definition
|
|
110
|
+
desktopTextures: desktopPicturesOf(definition, look),
|
|
111
|
+
...(definition.pictures === undefined ? {} : { pictures: definition.pictures }),
|
|
102
112
|
sceneCenter: sceneCenterOf(definition),
|
|
103
113
|
trackedBodies: trackedBodiesOf(definition),
|
|
104
114
|
groups: groupsOf(definition),
|
|
105
115
|
bodySets: bodySetsOf(definition),
|
|
106
116
|
...sunCentredOf(definition),
|
|
107
117
|
cameraReach: cameraReachOf(definition),
|
|
108
|
-
|
|
118
|
+
look,
|
|
119
|
+
sky: skySettingsOf(definition, look),
|
|
109
120
|
loopWindow: definition.experience.window,
|
|
110
121
|
...(definition.experience.hideTimeline === true ? {} : { stopAtWindow: true }),
|
|
111
122
|
...(definition.pacing === undefined ? {} : { pacing: definition.pacing }),
|
|
112
|
-
|
|
123
|
+
...(definition.eventZones === undefined ? {} : { eventZones: definition.eventZones }),
|
|
124
|
+
up: viewUpVector(startViewUp(definition, search)),
|
|
113
125
|
};
|
|
114
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
|
+
}
|
|
115
131
|
/** Whether the experience has anything the Display controls (markers, labels, timeline, phone layout) act on. */
|
|
116
|
-
function showsDisplayControls(definition, runtime, orbitPathCount, storyMarkerCount) {
|
|
117
|
-
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
|
|
118
134
|
|| runtime.bodies.some((id) => runtime.catalogue.get(id).visual.kind === "sphere");
|
|
119
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
|
+
}
|
|
120
144
|
/** The scene's live controls at mount: the address overrides the experience's own start values. */
|
|
121
|
-
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies) {
|
|
122
|
-
const search = window.location.search;
|
|
145
|
+
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies, search) {
|
|
123
146
|
const startView = viewFromSearch(search) ?? definition.startView;
|
|
124
147
|
return {
|
|
125
148
|
policy: scalePolicyFor(startScale, suppliedPolicies),
|
|
126
149
|
cameraRequest: null,
|
|
127
150
|
showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
|
|
128
151
|
loop: loopFromSearch(search, definition.loop === true),
|
|
129
|
-
...(definition.pacing === undefined ? {} : { paceAuto: true }),
|
|
130
|
-
up: viewUpVector(startViewUp(definition)),
|
|
152
|
+
...(definition.pacing === undefined ? {} : { paceAuto: true, pace: { shown: shownEventsOf(definition, startViewId(definition, search)) } }),
|
|
153
|
+
up: viewUpVector(startViewUp(definition, search)),
|
|
131
154
|
showMilkyWay: runtime.sky.milkyWay,
|
|
132
|
-
|
|
133
|
-
|
|
155
|
+
skyVisible: runtime.sky.visible,
|
|
156
|
+
bodyMarker: markerSettingsOf(runtime.look),
|
|
157
|
+
...(glowBase === null ? {} : { glowLook: glowLookOf(runtime.look, glowBase) }),
|
|
134
158
|
starBrightness: runtime.sky.starBrightness,
|
|
135
159
|
milkyWayBrightness: runtime.sky.milkyWayBrightness,
|
|
136
160
|
illuminateAll: DEFAULT_ILLUMINATE_ALL,
|
|
137
161
|
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
138
162
|
...startOrbitControls(definition),
|
|
139
163
|
labelObjects: experience.objects,
|
|
164
|
+
viewHidden: hiddenByView(definition.views, viewById(definition.views, startViewId(definition, search)), experience),
|
|
165
|
+
loadFadeSeconds: bootFadeSeconds(runtime.look),
|
|
166
|
+
desktopPictures: runtime.desktopTextures,
|
|
140
167
|
storyMarkers,
|
|
141
168
|
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
142
|
-
featureMinBodyPx:
|
|
169
|
+
featureMinBodyPx: featureMinBodyPxOf(runtime.look),
|
|
143
170
|
selectedObjectId: initialObjectIdOf(definition),
|
|
144
171
|
frameStats: null,
|
|
145
172
|
groupFills: [],
|
|
146
173
|
...(startView === undefined ? {} : { startView }),
|
|
147
174
|
};
|
|
148
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);
|
|
149
178
|
/**
|
|
150
|
-
* `onOpenAddress`: the entry's way to open a switch's address in place; without it a switch navigates the page.
|
|
151
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).
|
|
152
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.
|
|
153
183
|
*/
|
|
154
|
-
export function App({ definition,
|
|
184
|
+
export function App({ definition, writeTitle = true, address, developerTools, host }) {
|
|
155
185
|
// The page heading names the experience once it is open; app.html says only "Astraeus" until then.
|
|
156
186
|
useEffect(() => {
|
|
157
187
|
if (writeTitle)
|
|
158
188
|
document.title = pageTitleOf(definition);
|
|
159
189
|
}, [definition, writeTitle]);
|
|
160
|
-
|
|
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]);
|
|
161
199
|
const experienceRuntime = useMemo(() => ({ clock: runtime.clock, resolver: runtime.resolver, catalogue: runtime.catalogue }), [runtime]);
|
|
162
200
|
// The choices offered, in the experience's order; the solar-system policy enlarges only the bodies the experience names.
|
|
163
201
|
const scaleChoiceIds = useMemo(() => scaleChoiceIdsOf(definition), [definition]);
|
|
@@ -169,7 +207,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
169
207
|
exaggeration[id] = override.exaggeration;
|
|
170
208
|
return [createSolarSystemScale({ exaggeration, defaultExaggeration: 1 })];
|
|
171
209
|
}, [runtime]);
|
|
172
|
-
const linkedScale = scaleFromSearch(
|
|
210
|
+
const linkedScale = scaleFromSearch(search);
|
|
173
211
|
const startScale = startScaleFor(linkedScale, scaleChoiceIds);
|
|
174
212
|
const experience = useMemo(() => experienceWithGroups(definition), [definition]);
|
|
175
213
|
// The shell also lists the sky, citing its sources and saying whether the stars were fetched.
|
|
@@ -182,12 +220,18 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
182
220
|
});
|
|
183
221
|
return () => { cancelled = true; };
|
|
184
222
|
}, []);
|
|
185
|
-
|
|
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`.
|
|
224
|
+
const [viewId, setViewId] = useState(() => startViewId(definition, search));
|
|
225
|
+
const currentView = useMemo(() => viewById(definition.views, viewId), [definition.views, viewId]);
|
|
226
|
+
const viewExperience = useMemo(() => experienceInView(experience, definition.views, currentView), [experience, definition.views, currentView]);
|
|
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]);
|
|
186
230
|
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
187
231
|
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
188
232
|
const storySet = definition.experience.storyPanels;
|
|
189
233
|
const storyMarkerSpecs = useMemo(() => (storySet?.panels ?? []).flatMap((panel) => (panel.objectId === undefined ? [] : [{ panelId: panel.id, objectId: panel.objectId, title: panel.title, timeUtcMs: panel.timeUtcMs }])), [storySet]);
|
|
190
|
-
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies));
|
|
234
|
+
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies, search));
|
|
191
235
|
const readout = useRef(null);
|
|
192
236
|
const [clockSnapshot, setClockSnapshot] = useState(() => runtime.clock.snapshot());
|
|
193
237
|
const [scale, setScale] = useState(startScale);
|
|
@@ -222,13 +266,13 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
222
266
|
const labelToggles = useMemo(() => experience.objects.filter((object) => object.showLabel !== undefined), [experience]);
|
|
223
267
|
const [hiddenLabels, setHiddenLabels] = useState(() => new Set(controls.current.hiddenLabels));
|
|
224
268
|
const [loopOn, setLoopOn] = useState(controls.current.loop === true);
|
|
225
|
-
const [upChoice, setUpChoice] = useState(startViewUp(definition));
|
|
269
|
+
const [upChoice, setUpChoice] = useState(startViewUp(definition, search));
|
|
226
270
|
const [illuminateAll, setIlluminateAll] = useState(controls.current.illuminateAll);
|
|
227
271
|
const [milkyWayOn, setMilkyWayOn] = useState(runtime.sky.milkyWay);
|
|
228
272
|
const [hoverBrightness, setHoverBrightness] = useState(HOVER_BRIGHTNESS_DEFAULT);
|
|
229
273
|
const [starBrightness, setStarBrightness] = useState(runtime.sky.starBrightness);
|
|
230
274
|
const [milkyWayBrightness, setMilkyWayBrightness] = useState(runtime.sky.milkyWayBrightness);
|
|
231
|
-
const [loadFade, setLoadFade] = useState(() => bootFadeSeconds());
|
|
275
|
+
const [loadFade, setLoadFade] = useState(() => bootFadeSeconds(runtime.look));
|
|
232
276
|
const [markerPx, setMarkerPx] = useState(() => controls.current.bodyMarker.minSpherePx);
|
|
233
277
|
const [storyAutoOpen, setStoryAutoOpen] = useState(storyStartOf(storySet).autoOpen);
|
|
234
278
|
const [storyPauseSeconds, setStoryPauseSeconds] = useState(storyStartOf(storySet).pauseSeconds);
|
|
@@ -244,6 +288,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
244
288
|
const updateCameraRequest = useCallback((request) => {
|
|
245
289
|
controls.current.cameraRequest = request;
|
|
246
290
|
}, []);
|
|
291
|
+
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
247
292
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
248
293
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
249
294
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
@@ -259,14 +304,50 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
259
304
|
controls.current.onStoryMarker = requestPanel;
|
|
260
305
|
controls.current.onFeatureMarker = requestFeature;
|
|
261
306
|
controls.current.onPickObject = requestPick;
|
|
262
|
-
const updateSelectedObject = useCallback((objectId) => {
|
|
263
|
-
controls.current.selectedObjectId = objectId;
|
|
264
|
-
}, []);
|
|
265
307
|
const updateScale = useCallback((id) => {
|
|
266
308
|
controls.current.policy = scalePolicyFor(id, suppliedPolicies);
|
|
267
309
|
setScale(id);
|
|
268
310
|
}, [suppliedPolicies]);
|
|
269
|
-
|
|
311
|
+
// The view showing is read from a ref set at the switch, so a publish right after a switch already names the new view.
|
|
312
|
+
const viewRef = useRef(viewId);
|
|
313
|
+
const chooseView = useCallback((id) => {
|
|
314
|
+
viewRef.current = id;
|
|
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
|
+
}
|
|
322
|
+
setViewId(id);
|
|
323
|
+
}, [definition, experience, runtime]);
|
|
324
|
+
const viewIds = useMemo(() => definition.views?.views.map((view) => view.id) ?? [], [definition]);
|
|
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]);
|
|
270
351
|
useEffect(() => {
|
|
271
352
|
const id = window.setInterval(() => {
|
|
272
353
|
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
@@ -275,7 +356,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
275
356
|
else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
|
|
276
357
|
runtime.clock.stopWithin(runtime.loopWindow);
|
|
277
358
|
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
278
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
359
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
279
360
|
setClockSnapshot(runtime.clock.snapshot());
|
|
280
361
|
host?.publish(stateNow(), "playback");
|
|
281
362
|
}, 100);
|
|
@@ -284,14 +365,22 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
284
365
|
// The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
|
|
285
366
|
const seekTo = useCallback((timeUtcMs) => {
|
|
286
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
|
+
}
|
|
287
374
|
setClockSnapshot(runtime.clock.snapshot());
|
|
288
375
|
}, [runtime]);
|
|
289
376
|
// A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
|
|
290
377
|
const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
|
|
291
378
|
const changeRate = useCallback((rate) => {
|
|
292
379
|
if (rate === "auto") {
|
|
380
|
+
if (controls.current.pace !== undefined)
|
|
381
|
+
delete controls.current.pace.ease;
|
|
293
382
|
if (runtime.pacing !== undefined)
|
|
294
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
383
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
295
384
|
}
|
|
296
385
|
else
|
|
297
386
|
runtime.clock.setRate(rate);
|
|
@@ -299,12 +388,30 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
299
388
|
setPaceAuto(rate === "auto");
|
|
300
389
|
setClockSnapshot(runtime.clock.snapshot());
|
|
301
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), []);
|
|
302
407
|
useEffect(() => {
|
|
303
408
|
if (host === undefined)
|
|
304
409
|
return undefined;
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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]);
|
|
308
415
|
useEffect(() => {
|
|
309
416
|
if (!developerMode)
|
|
310
417
|
return undefined;
|
|
@@ -331,23 +438,56 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
331
438
|
const view = controls.current.viewReadout;
|
|
332
439
|
if (view === undefined)
|
|
333
440
|
return;
|
|
334
|
-
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 }) }));
|
|
442
|
+
};
|
|
443
|
+
const viewChoice = definition.views === undefined ? undefined : {
|
|
444
|
+
place: definition.views.place,
|
|
445
|
+
options: definition.views.views.map((view) => ({ id: view.id, label: view.label, active: view.id === currentView?.id })),
|
|
446
|
+
onSelect: (id) => {
|
|
447
|
+
chooseView(id);
|
|
448
|
+
host?.publish(stateNow(), "visitor");
|
|
449
|
+
},
|
|
335
450
|
};
|
|
336
|
-
const
|
|
451
|
+
const bindingsNow = () => ({
|
|
337
452
|
settings: definition.displaySwitches,
|
|
338
|
-
orbit: { present: orbitPaths.length > 0, look:
|
|
339
|
-
moons: { present: bodySets.length > 0, look:
|
|
340
|
-
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); } },
|
|
341
456
|
labels: {
|
|
342
|
-
objectIds: experience.objects.map((object) => object.id), hidden: hiddenLabels,
|
|
457
|
+
objectIds: experience.objects.map((object) => object.id), hidden: controls.current.hiddenLabels ?? hiddenLabels,
|
|
343
458
|
setHidden: (hidden) => { controls.current.hiddenLabels = new Set(hidden); setHiddenLabels(new Set(hidden)); },
|
|
344
|
-
anchorsPresent: runtime.trackedBodies.length > 0, anchors:
|
|
459
|
+
anchorsPresent: runtime.trackedBodies.length > 0, anchors: controls.current.showAnchorLabels, setAnchors: (on) => { controls.current.showAnchorLabels = on; setAnchorLabels(on); },
|
|
345
460
|
},
|
|
346
461
|
});
|
|
347
|
-
const
|
|
348
|
-
|
|
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]);
|
|
349
489
|
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
350
|
-
const showDisplay = showsDisplayControls(definition, runtime, orbitPaths.length, storyMarkerSpecs.length);
|
|
490
|
+
const showDisplay = showsDisplayControls(definition, runtime, skyVisible, orbitPaths.length, storyMarkerSpecs.length);
|
|
351
491
|
// Orbit-line sliders: the first four stay in view, the rest sit in a nested "Fine-tune" fold (T-090).
|
|
352
492
|
const orbitSliders = {
|
|
353
493
|
main: [
|
|
@@ -368,17 +508,13 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
368
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));
|
|
369
509
|
// The panel's folds, in order; the first one present opens by default and the rest start closed (T-090).
|
|
370
510
|
const groups = [
|
|
371
|
-
sections.length === 0 ? null : {
|
|
372
|
-
id: "demo", title: "This demo", className: "dev-group-cards",
|
|
373
|
-
body: (_jsxs(_Fragment, { children: [sections.filter((section) => section.placement === "before-scene").map(renderSection), sections.filter((section) => section.placement === "after-scene").map(renderSection)] })),
|
|
374
|
-
},
|
|
375
511
|
!showDisplay ? null : {
|
|
376
512
|
id: "camera", title: "Camera and view",
|
|
377
|
-
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" }) })] })),
|
|
378
514
|
},
|
|
379
515
|
!showDisplay ? null : {
|
|
380
516
|
id: "timeline", title: "Timeline and stories",
|
|
381
|
-
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 }) }), [
|
|
382
518
|
["minBrightness", "Quiet brightness", "Timeline quiet brightness", "glow-min-value", 0, 1, 0.01],
|
|
383
519
|
["steadyBrightness", "Steady brightness (no rate)", "Timeline steady brightness", "glow-steady-value", 0, 1, 0.01],
|
|
384
520
|
["curve", "Curve (rate to brightness)", "Timeline glow curve", "glow-curve-value", 0.2, 3, 0.05],
|
|
@@ -389,15 +525,15 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
389
525
|
},
|
|
390
526
|
orbitPaths.length === 0 ? null : {
|
|
391
527
|
id: "orbit-lines", title: "Orbit lines",
|
|
392
|
-
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" }) })] })),
|
|
393
529
|
},
|
|
394
530
|
bodySets.length === 0 && ringSystems.length === 0 ? null : {
|
|
395
531
|
id: "moons-rings", title: "Moons and rings",
|
|
396
532
|
body: (_jsx(MoonsAndRingsSettings, { bodySets: bodySets, ringSystems: ringSystems, setLook: setLook, changeSetLook: changeSetLook, ringLook: ringLook, changeRing: changeRing, controls: controls, setSetLook: setSetLook, setRingLook: setRingLook })),
|
|
397
533
|
},
|
|
398
|
-
!(
|
|
534
|
+
!(skyVisible || glowShown !== null) ? null : {
|
|
399
535
|
id: "sky-sun", title: "Sky and Sun",
|
|
400
|
-
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 })),
|
|
401
537
|
},
|
|
402
538
|
{
|
|
403
539
|
id: "labels", title: "Labels",
|
|
@@ -415,11 +551,11 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
415
551
|
},
|
|
416
552
|
{
|
|
417
553
|
id: "under-the-hood", title: "Under the hood",
|
|
418
|
-
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory
|
|
554
|
+
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory })),
|
|
419
555
|
},
|
|
420
556
|
];
|
|
421
557
|
const presentGroups = groups.filter((group) => group !== null);
|
|
422
|
-
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)))] }) }) }));
|
|
423
559
|
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
424
560
|
if (runtime.clock.playing)
|
|
425
561
|
runtime.clock.pause();
|
|
@@ -433,5 +569,5 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
433
569
|
}, onSeek: (timeUtcMs) => {
|
|
434
570
|
seekTo(timeUtcMs);
|
|
435
571
|
host?.publish(stateNow(), "visitor");
|
|
436
|
-
}, onCameraRequest: updateCameraRequest, 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 }) }) }));
|
|
437
573
|
}
|