astraeus 0.7.0 → 0.8.1
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 +189 -0
- package/README.md +202 -38
- package/data/ephemerides/planets/planets.json +1 -1
- 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 +63 -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 +85 -0
- package/src/api/viewerHandle.js +32 -0
- package/src/api/viewerLink.d.ts +88 -15
- package/src/api/viewerLink.js +117 -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 +30 -0
- package/src/api/viewerSelection.js +46 -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 +7 -6
- package/src/api/views.js +12 -6
- package/src/app/App.d.ts +5 -3
- package/src/app/App.js +211 -82
- package/src/app/App.node.js +211 -82
- package/src/app/AstraeusScene.d.ts +18 -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.d.ts +2 -0
- package/src/app/sceneCamera.js +11 -1
- 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 +52 -0
- package/src/app/views.d.ts +3 -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/astronomyAdapter.d.ts +1 -1
- package/src/core/astronomyAdapter.js +3 -3
- package/src/core/bodies/index.d.ts +0 -4
- package/src/core/bodies/index.js +14 -18
- package/src/core/bodies/jupiter.js +1 -1
- package/src/core/bodies/jupiterData.d.ts +0 -1
- package/src/core/bodies/jupiterData.js +2 -5
- package/src/core/bodies/mars.js +1 -1
- package/src/core/bodies/mercury.js +1 -1
- 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/outerPlanets.d.ts +2 -3
- package/src/core/bodies/outerPlanets.js +4 -13
- package/src/core/bodies/planetMoons.d.ts +0 -2
- package/src/core/bodies/planetMoons.js +1 -18
- package/src/core/bodies/planetRecords.d.ts +8 -2
- package/src/core/bodies/planetRecords.js +13 -5
- package/src/core/bodies/planetTrajectory.d.ts +21 -4
- package/src/core/bodies/planetTrajectory.js +29 -5
- package/src/core/bodies/venus.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.d.ts +1 -1
- package/src/core/planetModels.js +3 -3
- package/src/core/planetSeries.d.ts +10 -2
- package/src/core/planetSeries.js +17 -3
- 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 +18 -2
- package/src/shell/AstraeusShell.js +53 -14
- package/src/shell/AstraeusShell.node.js +53 -14
- 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.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,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);
|
|
@@ -277,15 +312,54 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
277
312
|
const viewRef = useRef(viewId);
|
|
278
313
|
const chooseView = useCallback((id) => {
|
|
279
314
|
viewRef.current = id;
|
|
315
|
+
controls.current.hostCameraRequest = null; // a host camera call counts from this switch on
|
|
280
316
|
controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
|
|
317
|
+
// The showing view's events choose the pacing zones; a paced rate that changes with them eases in rather than jumping.
|
|
318
|
+
if (controls.current.pace !== undefined) {
|
|
319
|
+
controls.current.pace.shown = shownEventsOf(definition, id);
|
|
320
|
+
if (controls.current.paceAuto === true)
|
|
321
|
+
startPaceEase(controls.current.pace, runtime.clock.rate, performance.now());
|
|
322
|
+
}
|
|
281
323
|
setViewId(id);
|
|
282
|
-
}, [definition, experience]);
|
|
324
|
+
}, [definition, experience, runtime]);
|
|
283
325
|
const viewIds = useMemo(() => definition.views?.views.map((view) => view.id) ?? [], [definition]);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
326
|
+
// The presentation a host reads and sets (looks, switches, scale), rebuilt every render over the live controls; the stable callbacks below call through it.
|
|
327
|
+
const live = useRef(null);
|
|
328
|
+
const stateNow = useCallback(() => {
|
|
329
|
+
const snapshot = runtime.clock.snapshot();
|
|
330
|
+
return {
|
|
331
|
+
...snapshot,
|
|
332
|
+
scale: controls.current.policy.id,
|
|
333
|
+
look: lookReadOf(controls.current),
|
|
334
|
+
switches: live.current?.switches() ?? {},
|
|
335
|
+
...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }),
|
|
336
|
+
...(runtime.eventZones === undefined ? {} : { zones: activeEventZones(runtime.eventZones, shownEventsOf(definition, viewRef.current), snapshot.timeUtcMs) }),
|
|
337
|
+
...(definition.views === undefined ? {} : { view: viewRef.current }),
|
|
338
|
+
...(controls.current.selectedObjectId === "" ? {} : { selected: controls.current.selectedObjectId }),
|
|
339
|
+
};
|
|
340
|
+
}, [runtime, definition]);
|
|
341
|
+
// 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.
|
|
342
|
+
const hostAttached = useRef(false);
|
|
343
|
+
// The presentation (scale, looks, switches) last told to the host, to find what a visitor changed.
|
|
344
|
+
const shownKey = useRef(null);
|
|
345
|
+
// `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).
|
|
346
|
+
// The host's `setSelected` not yet applied by the shell (id "" clears); the shell applies it after its own view-switch choices, so the host call is the last word.
|
|
347
|
+
const hostSelect = useRef(null);
|
|
348
|
+
const [selectRequest, setSelectRequest] = useState(null);
|
|
349
|
+
const hostSetSelected = useCallback((id) => {
|
|
350
|
+
hostSelect.current = id ?? "";
|
|
351
|
+
controls.current.selectedObjectId = id ?? ""; // `read()` shows it at once
|
|
352
|
+
setSelectRequest((previous) => ({ id: id ?? "", serial: (previous?.serial ?? 0) + 1 }));
|
|
353
|
+
}, []);
|
|
354
|
+
const hostSelectApplied = useCallback(() => { hostSelect.current = null; }, []);
|
|
355
|
+
const updateSelectedObject = useCallback((objectId, origin) => {
|
|
356
|
+
if (hostSelect.current !== null)
|
|
357
|
+
return; // a host `setSelected` is waiting for the shell: the shell's older choice must not undo it (the host-call order rule)
|
|
358
|
+
const changed = controls.current.selectedObjectId !== objectId;
|
|
359
|
+
controls.current.selectedObjectId = objectId;
|
|
360
|
+
if (changed && hostAttached.current)
|
|
361
|
+
host?.publishSelection(stateNow(), origin === "move");
|
|
362
|
+
}, [host, stateNow]);
|
|
289
363
|
useEffect(() => {
|
|
290
364
|
const id = window.setInterval(() => {
|
|
291
365
|
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
@@ -294,7 +368,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
294
368
|
else if (runtime.stopAtWindow === true && runtime.loopWindow !== undefined)
|
|
295
369
|
runtime.clock.stopWithin(runtime.loopWindow);
|
|
296
370
|
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
297
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
371
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
298
372
|
setClockSnapshot(runtime.clock.snapshot());
|
|
299
373
|
host?.publish(stateNow(), "playback");
|
|
300
374
|
}, 100);
|
|
@@ -303,14 +377,28 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
303
377
|
// The host reaches the one clock through the same seek and rate handlers a visitor's timeline uses.
|
|
304
378
|
const seekTo = useCallback((timeUtcMs) => {
|
|
305
379
|
runtime.clock.seek(timeUtcMs);
|
|
380
|
+
// A seek lands on the paced rate for the new time at once, not through a view-switch ease.
|
|
381
|
+
if (controls.current.pace !== undefined) {
|
|
382
|
+
delete controls.current.pace.ease;
|
|
383
|
+
if (controls.current.paceAuto === true && runtime.pacing !== undefined)
|
|
384
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
385
|
+
}
|
|
306
386
|
setClockSnapshot(runtime.clock.snapshot());
|
|
307
387
|
}, [runtime]);
|
|
388
|
+
// A host's time jump is a seek for story panels, as a visitor's is: the shell's note re-bases the crossing check first.
|
|
389
|
+
const storySeekNote = useRef(null);
|
|
390
|
+
const hostSeekTo = useCallback((timeUtcMs) => {
|
|
391
|
+
storySeekNote.current?.(timeUtcMs);
|
|
392
|
+
seekTo(timeUtcMs);
|
|
393
|
+
}, [seekTo]);
|
|
308
394
|
// A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
|
|
309
395
|
const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
|
|
310
396
|
const changeRate = useCallback((rate) => {
|
|
311
397
|
if (rate === "auto") {
|
|
398
|
+
if (controls.current.pace !== undefined)
|
|
399
|
+
delete controls.current.pace.ease;
|
|
312
400
|
if (runtime.pacing !== undefined)
|
|
313
|
-
applyPacing(runtime.clock, runtime.pacing);
|
|
401
|
+
applyPacing(runtime.clock, runtime.pacing, controls.current.pace);
|
|
314
402
|
}
|
|
315
403
|
else
|
|
316
404
|
runtime.clock.setRate(rate);
|
|
@@ -318,12 +406,32 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
318
406
|
setPaceAuto(rate === "auto");
|
|
319
407
|
setClockSnapshot(runtime.clock.snapshot());
|
|
320
408
|
}, [runtime]);
|
|
409
|
+
// The same play handler the visitor's button reaches, so a host and a visitor share one clock.
|
|
410
|
+
const hostSetPlaying = setPlaying;
|
|
411
|
+
// The objects a host may point the camera at: those the showing view shows (read live, so a view switch is already counted).
|
|
412
|
+
const cameraTargets = useCallback(() => {
|
|
413
|
+
const hidden = controls.current.viewHidden?.objects;
|
|
414
|
+
return experience.objects.map(({ id }) => id).filter((id) => hidden === undefined || !hidden.has(id));
|
|
415
|
+
}, [experience]);
|
|
416
|
+
const opening = useMemo(() => openingCamera(definition, runtime, search), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
417
|
+
const readCamera = useCallback(() => {
|
|
418
|
+
return { ...(controls.current.viewReadout ?? opening) };
|
|
419
|
+
}, [opening]);
|
|
420
|
+
// A host camera call is the last word: it is also kept in `hostCameraRequest`, so the opening view (first frame) and a view's own camera rule (shell) yield to it.
|
|
421
|
+
const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = request; }, []);
|
|
422
|
+
const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
|
|
423
|
+
const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
|
|
424
|
+
const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
|
|
425
|
+
const hostSetScale = useCallback((id) => live.current?.setScale(id), []);
|
|
426
|
+
const hostSetSwitch = useCallback((id, on) => live.current?.setSwitch(id, on), []);
|
|
321
427
|
useEffect(() => {
|
|
322
428
|
if (host === undefined)
|
|
323
429
|
return undefined;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
430
|
+
hostAttached.current = true;
|
|
431
|
+
shownKey.current = null; // the presentation is read afresh after each attach
|
|
432
|
+
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: hostSeekTo, setRate: changeRate, playable: definition.experience.hideTimeline !== true, setPlaying: hostSetPlaying, views: viewIds, setView: chooseView, cameraTargets, readCamera, setCamera, setSelected: hostSetSelected, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch });
|
|
433
|
+
return () => { hostAttached.current = false; host.detach(); };
|
|
434
|
+
}, [host, runtime, definition, hostSeekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, hostSetSelected, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch]);
|
|
327
435
|
useEffect(() => {
|
|
328
436
|
if (!developerMode)
|
|
329
437
|
return undefined;
|
|
@@ -350,7 +458,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
350
458
|
const view = controls.current.viewReadout;
|
|
351
459
|
if (view === undefined)
|
|
352
460
|
return;
|
|
353
|
-
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
461
|
+
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs, ...(definition.views === undefined ? {} : { show: viewRef.current }) }));
|
|
354
462
|
};
|
|
355
463
|
const viewChoice = definition.views === undefined ? undefined : {
|
|
356
464
|
place: definition.views.place,
|
|
@@ -360,21 +468,46 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
360
468
|
host?.publish(stateNow(), "visitor");
|
|
361
469
|
},
|
|
362
470
|
};
|
|
363
|
-
const
|
|
471
|
+
const bindingsNow = () => ({
|
|
364
472
|
settings: definition.displaySwitches,
|
|
365
|
-
orbit: { present: orbitPaths.length > 0, look:
|
|
366
|
-
moons: { present: bodySets.length > 0, look:
|
|
367
|
-
sky: { present:
|
|
473
|
+
orbit: { present: orbitPaths.length > 0, look: { ...orbitDefault, ...controls.current.orbitLook }, set: setOrbit },
|
|
474
|
+
moons: { present: bodySets.length > 0, look: controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK, set: changeSetLook },
|
|
475
|
+
sky: { present: controls.current.skyVisible !== false, on: controls.current.showMilkyWay, set: (on) => { controls.current.showMilkyWay = on; setMilkyWayOn(on); } },
|
|
368
476
|
labels: {
|
|
369
|
-
objectIds: experience.objects.map((object) => object.id), hidden: hiddenLabels,
|
|
477
|
+
objectIds: experience.objects.map((object) => object.id), hidden: controls.current.hiddenLabels ?? hiddenLabels,
|
|
370
478
|
setHidden: (hidden) => { controls.current.hiddenLabels = new Set(hidden); setHiddenLabels(new Set(hidden)); },
|
|
371
|
-
anchorsPresent: runtime.trackedBodies.length > 0, anchors:
|
|
479
|
+
anchorsPresent: runtime.trackedBodies.length > 0, anchors: controls.current.showAnchorLabels, setAnchors: (on) => { controls.current.showAnchorLabels = on; setAnchorLabels(on); },
|
|
372
480
|
},
|
|
373
481
|
});
|
|
374
|
-
const
|
|
375
|
-
|
|
482
|
+
const displaySwitches = displaySwitchItems(bindingsNow());
|
|
483
|
+
live.current = presentationOf({
|
|
484
|
+
setLook: (look) => {
|
|
485
|
+
const read = applyLook(controls.current, definition, glowBase, look);
|
|
486
|
+
setStarBrightness(read.starBrightness);
|
|
487
|
+
setMilkyWayBrightness(read.milkyWayBrightness);
|
|
488
|
+
setMilkyWayOn(read.milkyWay);
|
|
489
|
+
setSkyVisible(read.skyVisible);
|
|
490
|
+
if (read.sunGlow !== undefined)
|
|
491
|
+
setGlowShown({ ...controls.current.glowLook });
|
|
492
|
+
setMarkerPx(read.markerSwapRadiusPx);
|
|
493
|
+
setLoadFade(read.loadFadeSeconds);
|
|
494
|
+
},
|
|
495
|
+
setScale: updateScale,
|
|
496
|
+
items: () => displaySwitchItems({ ...bindingsNow(), settings: hostReachable(definition.displaySwitches) }),
|
|
497
|
+
});
|
|
498
|
+
// 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.
|
|
499
|
+
useEffect(() => {
|
|
500
|
+
if (!hostAttached.current)
|
|
501
|
+
return;
|
|
502
|
+
const state = stateNow();
|
|
503
|
+
const key = JSON.stringify([state.scale, state.look, state.switches]);
|
|
504
|
+
const changed = shownKey.current !== null && shownKey.current !== key;
|
|
505
|
+
shownKey.current = key;
|
|
506
|
+
if (changed)
|
|
507
|
+
host?.publish(state, "visitor");
|
|
508
|
+
}, [host, stateNow, scale, skyVisible, starBrightness, milkyWayBrightness, milkyWayOn, glowShown, markerPx, loadFade, orbitShown, setLook, hiddenLabels, anchorLabels]);
|
|
376
509
|
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
377
|
-
const showDisplay = showsDisplayControls(definition, runtime, orbitPaths.length, storyMarkerSpecs.length);
|
|
510
|
+
const showDisplay = showsDisplayControls(definition, runtime, skyVisible, orbitPaths.length, storyMarkerSpecs.length);
|
|
378
511
|
// Orbit-line sliders: the first four stay in view, the rest sit in a nested "Fine-tune" fold (T-090).
|
|
379
512
|
const orbitSliders = {
|
|
380
513
|
main: [
|
|
@@ -395,17 +528,13 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
395
528
|
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
529
|
// The panel's folds, in order; the first one present opens by default and the rest start closed (T-090).
|
|
397
530
|
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
531
|
!showDisplay ? null : {
|
|
403
532
|
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); } }),
|
|
533
|
+
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
534
|
},
|
|
406
535
|
!showDisplay ? null : {
|
|
407
536
|
id: "timeline", title: "Timeline and stories",
|
|
408
|
-
body: (_jsxs(_Fragment, { children: [_jsxs(SettingGroup, {
|
|
537
|
+
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
538
|
["minBrightness", "Quiet brightness", "Timeline quiet brightness", "glow-min-value", 0, 1, 0.01],
|
|
410
539
|
["steadyBrightness", "Steady brightness (no rate)", "Timeline steady brightness", "glow-steady-value", 0, 1, 0.01],
|
|
411
540
|
["curve", "Curve (rate to brightness)", "Timeline glow curve", "glow-curve-value", 0.2, 3, 0.05],
|
|
@@ -416,15 +545,15 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
416
545
|
},
|
|
417
546
|
orbitPaths.length === 0 ? null : {
|
|
418
547
|
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, {
|
|
548
|
+
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
549
|
},
|
|
421
550
|
bodySets.length === 0 && ringSystems.length === 0 ? null : {
|
|
422
551
|
id: "moons-rings", title: "Moons and rings",
|
|
423
552
|
body: (_jsx(MoonsAndRingsSettings, { bodySets: bodySets, ringSystems: ringSystems, setLook: setLook, changeSetLook: changeSetLook, ringLook: ringLook, changeRing: changeRing, controls: controls, setSetLook: setSetLook, setRingLook: setRingLook })),
|
|
424
553
|
},
|
|
425
|
-
!(
|
|
554
|
+
!(skyVisible || glowShown !== null) ? null : {
|
|
426
555
|
id: "sky-sun", title: "Sky and Sun",
|
|
427
|
-
body: (_jsx(SkyAndSunSettings, { illuminateAll: illuminateAll, setIlluminateAll: setIlluminateAll, visible:
|
|
556
|
+
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
557
|
},
|
|
429
558
|
{
|
|
430
559
|
id: "labels", title: "Labels",
|
|
@@ -442,11 +571,11 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
442
571
|
},
|
|
443
572
|
{
|
|
444
573
|
id: "under-the-hood", title: "Under the hood",
|
|
445
|
-
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory
|
|
574
|
+
body: (_jsx(UnderTheHoodSettings, { hud: hud, frames: frames, fills: fills, fpsHistory: fpsHistory })),
|
|
446
575
|
},
|
|
447
576
|
];
|
|
448
577
|
const presentGroups = groups.filter((group) => group !== null);
|
|
449
|
-
const
|
|
578
|
+
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
579
|
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
451
580
|
if (runtime.clock.playing)
|
|
452
581
|
runtime.clock.pause();
|
|
@@ -460,5 +589,5 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
460
589
|
}, onSeek: (timeUtcMs) => {
|
|
461
590
|
seekTo(timeUtcMs);
|
|
462
591
|
host?.publish(stateNow(), "visitor");
|
|
463
|
-
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher:
|
|
592
|
+
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, hostCameraSet: hostCameraSet, storySeekNote: storySeekNote, 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, selectRequest: selectRequest, onSelectRequestApplied: hostSelectApplied, 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
593
|
}
|