astraeus 0.8.0 → 0.9.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 +80 -0
- package/README.md +46 -17
- package/data/ephemerides/planets/planets.json +1 -1
- package/package.json +1 -1
- package/src/api/AstraeusScene.d.ts +1 -1
- package/src/api/AstraeusScene.js +4 -1
- package/src/api/AstraeusScene.node.js +4 -1
- package/src/api/assembleScene.d.ts +2 -0
- package/src/api/assembleScene.js +27 -5
- package/src/api/cameraRequest.d.ts +15 -0
- package/src/api/cameraRequest.js +89 -0
- package/src/api/errors.d.ts +10 -0
- package/src/api/index.d.ts +6 -3
- package/src/api/look.d.ts +49 -0
- package/src/api/lookInput.d.ts +1 -1
- package/src/api/lookInput.js +6 -1
- package/src/api/planCamera.d.ts +35 -7
- package/src/api/planCamera.js +94 -11
- package/src/api/planSkyFigures.d.ts +22 -0
- package/src/api/planSkyFigures.js +145 -0
- package/src/api/planStory.d.ts +2 -2
- package/src/api/planStory.js +14 -9
- package/src/api/planViews.js +1 -1
- package/src/api/scene.d.ts +17 -4
- package/src/api/scene.js +23 -5
- package/src/api/sceneReads.d.ts +21 -2
- package/src/api/skyFigureInput.d.ts +45 -0
- package/src/api/skyFigureInput.js +1 -0
- package/src/api/skyTraceInput.d.ts +33 -0
- package/src/api/skyTraceInput.js +45 -0
- package/src/api/story.d.ts +12 -3
- package/src/api/story.js +44 -1
- package/src/api/viewerCamera.d.ts +4 -3
- package/src/api/viewerCamera.js +10 -32
- package/src/api/viewerHandle.d.ts +34 -5
- package/src/api/viewerHandle.js +7 -0
- package/src/api/viewerLink.d.ts +50 -4
- package/src/api/viewerLink.js +33 -2
- package/src/api/viewerPanels.d.ts +26 -0
- package/src/api/viewerPanels.js +42 -0
- package/src/api/viewerSelection.d.ts +6 -1
- package/src/api/viewerSelection.js +15 -0
- package/src/api/views.d.ts +3 -1
- package/src/api/views.js +5 -1
- package/src/app/App.js +118 -16
- package/src/app/App.node.js +118 -16
- package/src/app/AstraeusScene.d.ts +22 -5
- package/src/app/AstraeusScene.js +3 -3
- package/src/app/CameraController.d.ts +17 -0
- package/src/app/CameraController.js +34 -9
- package/src/app/DeveloperSettings.d.ts +11 -3
- package/src/app/DeveloperSettings.js +13 -3
- package/src/app/SceneLabels.d.ts +20 -2
- package/src/app/SceneLabels.js +46 -6
- package/src/app/SkyFiguresView.d.ts +56 -0
- package/src/app/SkyFiguresView.js +242 -0
- package/src/app/StoryMarkers.d.ts +2 -2
- package/src/app/StoryMarkers.js +2 -2
- package/src/app/displaySwitches.d.ts +13 -3
- package/src/app/displaySwitches.js +17 -3
- package/src/app/experienceDefinition.d.ts +9 -3
- package/src/app/experienceDefinition.js +4 -2
- package/src/app/labelStyle.d.ts +17 -0
- package/src/app/labelStyle.js +13 -0
- package/src/app/liveLook.js +8 -0
- package/src/app/look.d.ts +9 -5
- package/src/app/look.js +11 -0
- package/src/app/lookOut.d.ts +32 -0
- package/src/app/lookOut.js +50 -0
- package/src/app/sceneCamera.d.ts +7 -3
- package/src/app/sceneCamera.js +68 -4
- package/src/app/sceneContentsHooks.d.ts +2 -1
- package/src/app/sceneContentsHooks.js +3 -2
- package/src/app/sceneFrame.d.ts +10 -1
- package/src/app/sceneFrame.js +45 -10
- package/src/app/sceneFraming.d.ts +7 -0
- package/src/app/sceneFraming.js +12 -0
- package/src/app/sceneHooks.d.ts +2 -0
- package/src/app/sceneHooks.js +4 -1
- package/src/app/scenePicking.d.ts +20 -0
- package/src/app/scenePicking.js +49 -0
- package/src/app/scenePointer.d.ts +3 -1
- package/src/app/scenePointer.js +3 -2
- package/src/app/skyFigures.d.ts +73 -0
- package/src/app/skyFigures.js +50 -0
- package/src/app/style.css +2 -1
- package/src/app/viewHiding.d.ts +2 -0
- package/src/app/viewHiding.js +7 -1
- package/src/app/viewLink.d.ts +8 -8
- package/src/app/viewLink.js +24 -4
- package/src/app/viewerPort.d.ts +32 -3
- package/src/app/views.d.ts +2 -0
- package/src/assets/sky.d.ts +13 -4
- package/src/assets/sky.js +33 -8
- package/src/assets/stars/hyg-v42-naked-eye.json +1 -1
- package/src/core/astronomyAdapter.d.ts +1 -1
- package/src/core/astronomyAdapter.js +3 -3
- package/src/core/bodies/index.js +13 -12
- package/src/core/bodies/jupiter.js +1 -1
- package/src/core/bodies/mars.js +1 -1
- package/src/core/bodies/mercury.js +1 -1
- package/src/core/bodies/moonSystem.js +1 -15
- 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 +28 -4
- package/src/core/bodies/venus.js +1 -1
- package/src/core/lookValues.d.ts +9 -0
- package/src/core/lookValues.js +24 -0
- package/src/core/planetModels.d.ts +1 -1
- package/src/core/planetModels.js +1 -1
- package/src/core/planetSeries.d.ts +2 -2
- package/src/core/planetSeries.js +1 -1
- package/src/core/readBytes.d.ts +1 -0
- package/src/core/readBytes.js +15 -0
- package/src/core/skyTrace.d.ts +49 -0
- package/src/core/skyTrace.js +39 -0
- package/src/core/startView.d.ts +39 -0
- package/src/core/startView.js +56 -0
- package/src/core/storyPanels.d.ts +51 -3
- package/src/core/storyPanels.js +52 -12
- package/src/shell/AstraeusShell.d.ts +27 -6
- package/src/shell/AstraeusShell.js +104 -18
- package/src/shell/AstraeusShell.node.js +104 -18
- package/src/shell/ObjectControls.js +11 -8
- package/src/shell/StoryPanelView.d.ts +12 -3
- package/src/shell/StoryPanelView.js +2 -2
- package/src/shell/experience.d.ts +24 -0
- package/src/shell/experience.js +4 -1
- package/src/shell/infoModel.js +9 -1
- package/src/shell/objectModel.d.ts +6 -2
- package/src/shell/objectModel.js +10 -1
- package/src/shell/phone.css +1 -1
- package/src/shell/storyPanels.d.ts +1 -1
- package/src/shell/storyPanels.js +1 -1
- package/src/shell/style.css +9 -1
- package/src/shell/topBarIcons.d.ts +1 -0
- package/src/shell/topBarIcons.js +1 -0
- package/src/shell/useStoryPanels.d.ts +9 -6
- package/src/shell/useStoryPanels.js +10 -6
package/src/api/viewerLink.js
CHANGED
|
@@ -3,10 +3,12 @@ import { ViewerLooks } from "./viewerLooks.js";
|
|
|
3
3
|
import { ViewerCamera } from "./viewerCamera.js";
|
|
4
4
|
import { ViewerClock } from "./viewerClock.js";
|
|
5
5
|
import { ViewerSelection } from "./viewerSelection.js";
|
|
6
|
+
import { ViewerPanels } from "./viewerPanels.js";
|
|
6
7
|
import { ViewerFirstDraw } from "./viewerFirstDraw.js";
|
|
7
8
|
import { ViewerPicker } from "./viewerPicker.js";
|
|
8
9
|
import { ViewerViews } from "./viewerViews.js";
|
|
9
10
|
import { ViewerZones } from "./viewerZones.js";
|
|
11
|
+
import { checkedClear, checkedTrace } from "./skyTraceInput.js";
|
|
10
12
|
const NOT_OPEN = "the viewer is not drawn yet (or is gone); wait for `ready` first";
|
|
11
13
|
function newWait() {
|
|
12
14
|
const wait = { done: false };
|
|
@@ -33,6 +35,7 @@ export class ViewerLink {
|
|
|
33
35
|
#camera = new ViewerCamera(this.#access);
|
|
34
36
|
#zones = new ViewerZones(this.#access);
|
|
35
37
|
#selection = new ViewerSelection(this.#access);
|
|
38
|
+
#panels = new ViewerPanels(this.#access);
|
|
36
39
|
#looks = new ViewerLooks(this.#access);
|
|
37
40
|
#frame = new ViewerFirstDraw();
|
|
38
41
|
#picker = new ViewerPicker(this.#access);
|
|
@@ -40,10 +43,13 @@ export class ViewerLink {
|
|
|
40
43
|
/** What last moved the clock or the view, as published; a selection dropped by time or the view names it. */
|
|
41
44
|
#mover = "playback";
|
|
42
45
|
#closed = false;
|
|
46
|
+
/** How many publishes have started, so one can tell that a listener's host call published inside another. */
|
|
47
|
+
#publishes = 0;
|
|
43
48
|
attach(control) {
|
|
44
49
|
this.#control = control;
|
|
45
50
|
this.#clock.reset(control.read());
|
|
46
51
|
this.#selection.reset(control.read());
|
|
52
|
+
this.#panels.reset(control.read());
|
|
47
53
|
this.#mover = "playback";
|
|
48
54
|
this.#camera.reset();
|
|
49
55
|
this.#picker.reset(control);
|
|
@@ -55,6 +61,7 @@ export class ViewerLink {
|
|
|
55
61
|
this.#control = undefined;
|
|
56
62
|
this.#clock.reset(undefined);
|
|
57
63
|
this.#selection.reset(undefined);
|
|
64
|
+
this.#panels.reset(undefined);
|
|
58
65
|
this.#mover = "playback";
|
|
59
66
|
this.#camera.reset();
|
|
60
67
|
this.#picker.reset(undefined);
|
|
@@ -78,6 +85,7 @@ export class ViewerLink {
|
|
|
78
85
|
this.#clock.clearListeners();
|
|
79
86
|
this.#zones.clearListeners();
|
|
80
87
|
this.#selection.clearListeners();
|
|
88
|
+
this.#panels.clearListeners();
|
|
81
89
|
this.#camera.clearListeners();
|
|
82
90
|
this.#frame.clearListeners();
|
|
83
91
|
this.#picker.clearListeners();
|
|
@@ -94,8 +102,10 @@ export class ViewerLink {
|
|
|
94
102
|
get eventZones() { return this.#zones.eventZones; }
|
|
95
103
|
get view() { return this.#views.view; }
|
|
96
104
|
get selected() { return this.#selection.selected; }
|
|
105
|
+
get panel() { return this.#panels.panel; }
|
|
97
106
|
get camera() { return this.#camera.camera; }
|
|
98
107
|
get pick() { return this.#picker.pick; }
|
|
108
|
+
get skyFigures() { const control = this.#access.control(); return control === undefined ? undefined : control.skyFigures ?? []; }
|
|
99
109
|
get look() { return this.#looks.look; }
|
|
100
110
|
get scale() { return this.#looks.scale; }
|
|
101
111
|
get switches() { return this.#looks.switches; }
|
|
@@ -108,8 +118,23 @@ export class ViewerLink {
|
|
|
108
118
|
setLook(look) { this.#looks.setLook(look); this.#afterHost(); }
|
|
109
119
|
setScale(id) { this.#looks.setScale(id); this.#afterHost(); }
|
|
110
120
|
setSwitch(id, on) { this.#looks.setSwitch(id, on); this.#afterHost(); }
|
|
121
|
+
setSelected(id) { this.#selection.setSelected(id); this.#afterHost(); }
|
|
122
|
+
setPanel(id) { this.#panels.setPanel(id); this.#afterHost(); }
|
|
123
|
+
onPanel(listener) { return this.#panels.onPanel(listener); }
|
|
111
124
|
onChange(listener) { return this.#clock.onChange(listener); }
|
|
112
125
|
onEventZone(listener) { return this.#zones.onEventZone(listener); }
|
|
126
|
+
/** Traces a sky figure line by line (checked here, `unknown-sky-figure` or `bad-sky-trace`); the viewer starts it at its next frame, after any host call made before it. */
|
|
127
|
+
traceSkyFigure(id, options) {
|
|
128
|
+
const control = this.#access.open("traceSkyFigure");
|
|
129
|
+
const { seconds, after } = checkedTrace(id, options, (control.skyFigures ?? []).map((figure) => figure.id));
|
|
130
|
+
control.traceSkyFigure(id, seconds, after);
|
|
131
|
+
}
|
|
132
|
+
/** Removes a figure's trace (checked here, `unknown-sky-figure` or `bad-sky-trace`); a figure with no trace is left alone. Takes its place in call order like `traceSkyFigure`. */
|
|
133
|
+
clearSkyTrace(id, options) {
|
|
134
|
+
const control = this.#access.open("clearSkyTrace");
|
|
135
|
+
const { seconds } = checkedClear(id, options, (control.skyFigures ?? []).map((figure) => figure.id));
|
|
136
|
+
control.clearSkyTrace(id, seconds);
|
|
137
|
+
}
|
|
113
138
|
setPick(value) { this.#picker.setPick(value); }
|
|
114
139
|
onPick(listener) { return this.#picker.onPick(listener); }
|
|
115
140
|
pickNow() { return this.#picker.pick; }
|
|
@@ -120,14 +145,20 @@ export class ViewerLink {
|
|
|
120
145
|
onSelect(listener) { return this.#selection.onSelect(listener); }
|
|
121
146
|
onCameraChange(listener) { return this.#camera.onCameraChange(listener); }
|
|
122
147
|
publish(state, cause) {
|
|
148
|
+
const serial = ++this.#publishes;
|
|
123
149
|
if (this.#clock.publish(state, cause))
|
|
124
150
|
this.#mover = cause;
|
|
125
|
-
this
|
|
126
|
-
this.#
|
|
151
|
+
// An `onChange` listener that made a host call published inside the call above, with a newer reading: the rest of this publish goes by that reading, not the older one it was handed.
|
|
152
|
+
const now = this.#publishes === serial ? state : this.#control?.read() ?? state;
|
|
153
|
+
this.#zones.publish(now, cause);
|
|
154
|
+
this.#selection.publish(now, cause);
|
|
155
|
+
this.#panels.publish(now, cause);
|
|
127
156
|
this.#camera.publish();
|
|
128
157
|
}
|
|
129
158
|
/** The selection changed. A drop by time or the view names whatever last moved them (`onChange` names the same), so the cause is never a second opinion. */
|
|
130
159
|
publishSelection(state, byMove) { this.#selection.publish(state, byMove ? this.#mover : "visitor"); }
|
|
160
|
+
/** The open story panel changed. A drop by a view switch names whatever last moved the view (`onChange` names the same). */
|
|
161
|
+
publishPanel(state, cause) { this.#panels.publish(state, cause === "move" ? this.#mover : cause); }
|
|
131
162
|
/** A host call moved the clock or the view: report the control's reading, change then zones. */
|
|
132
163
|
#afterHost() { this.publish(this.#access.open("publish").read(), "host"); }
|
|
133
164
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ViewerChangeCause, ViewerState } from "../app/viewerPort.js";
|
|
2
|
+
import type { LinkAccess } from "./viewerLink.js";
|
|
3
|
+
/** What a host is told when the open story panel changes. */
|
|
4
|
+
export interface PanelChange {
|
|
5
|
+
/** The panel now open; absent when it closed. */
|
|
6
|
+
readonly panel?: string;
|
|
7
|
+
/** The viewer's time, Unix milliseconds UTC. */
|
|
8
|
+
readonly timeUtcMs: number;
|
|
9
|
+
/** `visitor`, `host` (`setPanel`, or a drop by the host's `setView`) or `playback` (a moment panel opened by itself). */
|
|
10
|
+
readonly cause: ViewerChangeCause;
|
|
11
|
+
}
|
|
12
|
+
/** The host link's story panel: the open panel read, `setPanel` checked and the `onPanel` callbacks. */
|
|
13
|
+
export declare class ViewerPanels {
|
|
14
|
+
#private;
|
|
15
|
+
private readonly access;
|
|
16
|
+
constructor(access: LinkAccess);
|
|
17
|
+
/** The viewer attached (its first reading: the opening panel is read, not reported) or detached (undefined). */
|
|
18
|
+
reset(first: ViewerState | undefined): void;
|
|
19
|
+
clearListeners(): void;
|
|
20
|
+
/** The id of the open story panel; undefined before the viewer is drawn, after it is gone and when none is open. */
|
|
21
|
+
get panel(): string | undefined;
|
|
22
|
+
/** Opens a story panel the showing view shows, or closes the open one with `undefined`; the caller then publishes it as a host change. Any other id throws `bad-panels`; before the viewer is drawn or after it is gone, `not-mounted`. */
|
|
23
|
+
setPanel(id: unknown): void;
|
|
24
|
+
onPanel(listener: (change: PanelChange) => void): () => void;
|
|
25
|
+
publish(state: ViewerState, cause: ViewerChangeCause): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SceneError } from "./errors.js";
|
|
2
|
+
import { callListeners } from "./listeners.js";
|
|
3
|
+
/** The host link's story panel: the open panel read, `setPanel` checked and the `onPanel` callbacks. */
|
|
4
|
+
export class ViewerPanels {
|
|
5
|
+
access;
|
|
6
|
+
#listeners = new Set();
|
|
7
|
+
/** The panel last read or reported; meaningful only while `#known` (the viewer is attached). */
|
|
8
|
+
#last;
|
|
9
|
+
#known = false;
|
|
10
|
+
constructor(access) {
|
|
11
|
+
this.access = access;
|
|
12
|
+
}
|
|
13
|
+
/** The viewer attached (its first reading: the opening panel is read, not reported) or detached (undefined). */
|
|
14
|
+
reset(first) {
|
|
15
|
+
this.#known = first !== undefined;
|
|
16
|
+
this.#last = first?.panel;
|
|
17
|
+
}
|
|
18
|
+
clearListeners() { this.#listeners.clear(); }
|
|
19
|
+
/** The id of the open story panel; undefined before the viewer is drawn, after it is gone and when none is open. */
|
|
20
|
+
get panel() { return this.access.control()?.read().panel; }
|
|
21
|
+
/** Opens a story panel the showing view shows, or closes the open one with `undefined`; the caller then publishes it as a host change. Any other id throws `bad-panels`; before the viewer is drawn or after it is gone, `not-mounted`. */
|
|
22
|
+
setPanel(id) {
|
|
23
|
+
const control = this.access.open("setPanel");
|
|
24
|
+
if (id !== undefined) {
|
|
25
|
+
const shown = control.panels();
|
|
26
|
+
if (typeof id !== "string" || !shown.includes(id)) {
|
|
27
|
+
throw new SceneError("bad-panels", `setPanel: ${typeof id === "string" ? `"${id}"` : String(id)} is not a story panel the showing view shows (${shown.join(", ")}); give one of them, or undefined to close the open one`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
control.setPanel(id);
|
|
31
|
+
}
|
|
32
|
+
onPanel(listener) {
|
|
33
|
+
this.#listeners.add(listener);
|
|
34
|
+
return () => { this.#listeners.delete(listener); };
|
|
35
|
+
}
|
|
36
|
+
publish(state, cause) {
|
|
37
|
+
if (!this.#known || state.panel === this.#last)
|
|
38
|
+
return;
|
|
39
|
+
this.#last = state.panel;
|
|
40
|
+
callListeners(this.#listeners, { ...(state.panel === undefined ? {} : { panel: state.panel }), timeUtcMs: state.timeUtcMs, cause });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -6,7 +6,7 @@ export interface SelectionChange {
|
|
|
6
6
|
readonly object?: string;
|
|
7
7
|
/** The viewer's time at the report, Unix milliseconds UTC. */
|
|
8
8
|
readonly timeUtcMs: number;
|
|
9
|
-
/** `visitor`: the object menu, a click, or a clock or view change the visitor made; `host`: a host call (`setTime`, `setRate`, `setPlaying`, `setView`) moved the clock or view and the selection followed; `playback`: the clock running moved it. */
|
|
9
|
+
/** `visitor`: the object menu, a click, or a clock or view change the visitor made; `host`: a host call (`setSelected`, or `setTime`, `setRate`, `setPlaying`, `setView`) moved the clock or view and the selection followed; `playback`: the clock running moved it. */
|
|
10
10
|
readonly cause: ViewerChangeCause;
|
|
11
11
|
}
|
|
12
12
|
/** The host link's selection: the selected object read and the `onSelect` callbacks. */
|
|
@@ -19,6 +19,11 @@ export declare class ViewerSelection {
|
|
|
19
19
|
clearListeners(): void;
|
|
20
20
|
/** The id of the selected object; undefined before the viewer is drawn, after it is gone and when nothing is selected. */
|
|
21
21
|
get selected(): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Selects an object the showing view shows, or a sky figure (`handle.skyFigures`), or clears the selection with `undefined`; the caller then publishes it as a host change (`onSelect` with `cause: "host"`; nothing is reported when the selection is already that).
|
|
24
|
+
* Any other id (unknown, hidden by the showing view, empty) or a non-string throws `bad-selection`; before the viewer is drawn or after it is gone, `not-mounted`.
|
|
25
|
+
*/
|
|
26
|
+
setSelected(id: unknown): void;
|
|
22
27
|
/** Calls `listener` when the selected object changes; returns the function that stops it. */
|
|
23
28
|
onSelect(listener: (change: SelectionChange) => void): () => void;
|
|
24
29
|
publish(state: ViewerState, cause: ViewerChangeCause): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SceneError } from "./errors.js";
|
|
1
2
|
import { callListeners } from "./listeners.js";
|
|
2
3
|
/** The host link's selection: the selected object read and the `onSelect` callbacks. */
|
|
3
4
|
export class ViewerSelection {
|
|
@@ -17,6 +18,20 @@ export class ViewerSelection {
|
|
|
17
18
|
clearListeners() { this.#listeners.clear(); }
|
|
18
19
|
/** The id of the selected object; undefined before the viewer is drawn, after it is gone and when nothing is selected. */
|
|
19
20
|
get selected() { return this.access.control()?.read().selected; }
|
|
21
|
+
/**
|
|
22
|
+
* Selects an object the showing view shows, or a sky figure (`handle.skyFigures`), or clears the selection with `undefined`; the caller then publishes it as a host change (`onSelect` with `cause: "host"`; nothing is reported when the selection is already that).
|
|
23
|
+
* Any other id (unknown, hidden by the showing view, empty) or a non-string throws `bad-selection`; before the viewer is drawn or after it is gone, `not-mounted`.
|
|
24
|
+
*/
|
|
25
|
+
setSelected(id) {
|
|
26
|
+
const control = this.access.open("setSelected");
|
|
27
|
+
if (id !== undefined) {
|
|
28
|
+
const shown = [...control.cameraTargets(), ...(control.skyFigures ?? []).map((figure) => figure.id)];
|
|
29
|
+
if (typeof id !== "string" || !shown.includes(id)) {
|
|
30
|
+
throw new SceneError("bad-selection", `setSelected: ${typeof id === "string" ? `"${id}"` : String(id)} is not an object the showing view shows, or a sky figure (${shown.join(", ")}); give one of them, or undefined to clear`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
control.setSelected(id);
|
|
34
|
+
}
|
|
20
35
|
/** Calls `listener` when the selected object changes; returns the function that stops it. */
|
|
21
36
|
onSelect(listener) {
|
|
22
37
|
this.#listeners.add(listener);
|
package/src/api/views.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type ViewPlace, type ViewSettings } from "../app/views.js";
|
|
2
|
-
/** What a view's camera does when what it follows or focuses on is not in the view: `"stay"` (default) keeps the pose and stops following, `"start"` takes the scene's start, `{ follow: id }` / `{ focus: id }` takes that framing (the object must be in the view). */
|
|
2
|
+
/** What a view's camera does when what it follows or focuses on is not in the view: `"stay"` (default) keeps the pose and stops following, `"start"` takes the scene's start, `{ follow: id }` / `{ focus: id }` takes that framing (the object must be in the view). `always: true` on a framing applies it on every switch to the view, not only when the switch takes away what the camera follows or focuses on. */
|
|
3
3
|
export type ViewCameraInput = "stay" | "start" | {
|
|
4
4
|
readonly follow: string;
|
|
5
|
+
readonly always?: true;
|
|
5
6
|
} | {
|
|
6
7
|
readonly focus: string;
|
|
8
|
+
readonly always?: true;
|
|
7
9
|
};
|
|
8
10
|
/** One named view. `objects` are `addBody`, `addGroup` or `addTrajectory` ids, `events` are `addEvents` ids and `panels` are `addStoryPanels` ids. */
|
|
9
11
|
export interface ViewInput {
|
package/src/api/views.js
CHANGED
|
@@ -46,9 +46,13 @@ function cameraOf(view) {
|
|
|
46
46
|
const follow = camera?.follow;
|
|
47
47
|
const focus = camera?.focus;
|
|
48
48
|
const target = follow ?? focus;
|
|
49
|
+
const always = camera?.always;
|
|
50
|
+
if (always !== undefined && always !== true)
|
|
51
|
+
throw bad(`view "${view.id}" camera always must be true when given, got ${JSON.stringify(always)}`);
|
|
49
52
|
if (typeof camera !== "object" || camera === null || typeof target !== "string" || target === "" || (follow !== undefined) === (focus !== undefined))
|
|
50
53
|
throw bad(`view "${view.id}" camera must be "stay", "start", { follow: id } or { focus: id }, got ${JSON.stringify(camera)}`);
|
|
51
|
-
|
|
54
|
+
const keep = always === true ? { always: true } : {};
|
|
55
|
+
return { rule: "start", framing: follow === undefined ? { focus: target, ...keep } : { follow: target, ...keep } };
|
|
52
56
|
}
|
|
53
57
|
/**
|
|
54
58
|
* Resolves the membership once: for each kind, an id no view names shows in every view, and an id some views name shows only in those. Throws `bad-view` for an id the scene does not hold
|
package/src/app/App.js
CHANGED
|
@@ -4,6 +4,7 @@ import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
|
4
4
|
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
5
|
import { activeEventZones, applyPacing, startPaceEase } from "../core/pacing.js";
|
|
6
6
|
import { openClock } from "./openClock.js";
|
|
7
|
+
import { createProvenance } from "../core/provenance.js";
|
|
7
8
|
import { pickerSwitch } from "./listSwitch.js";
|
|
8
9
|
import { createSolarSystemScale } from "../core/scalePolicy.js";
|
|
9
10
|
import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
|
|
@@ -30,7 +31,10 @@ import { loadStarCatalogue } from "../assets/sky.js";
|
|
|
30
31
|
import { withSkyObject } from "./skyModel.js";
|
|
31
32
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
32
33
|
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
33
|
-
import { displaySwitchItems, hostReachable, orbitStart } from "./displaySwitches.js";
|
|
34
|
+
import { displaySwitchItems, hostReachable, orbitStart, skyLineStart } from "./displaySwitches.js";
|
|
35
|
+
import { TRACE_FADE_SECONDS } from "../core/skyTrace.js";
|
|
36
|
+
import { aimAtFigure, DEFAULT_SKY_LINES, prefersReducedMotion, skyColoursOf, skyFadeInSecondsOf } from "./skyFigures.js";
|
|
37
|
+
import { labelStyleOf } from "./labelStyle.js";
|
|
34
38
|
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
35
39
|
import { baseGlowOf, glowLookOf, markerSettingsOf } from "./bodyDraw.js";
|
|
36
40
|
import { resolveLook } from "./look.js";
|
|
@@ -57,6 +61,14 @@ export function loopFromSearch(search, fallback) {
|
|
|
57
61
|
return value === "on" ? true : value === "off" ? false : fallback;
|
|
58
62
|
}
|
|
59
63
|
/** 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). */
|
|
64
|
+
const NO_CARD_PROVENANCE = createProvenance({ sourceType: "illustrative", sources: ["Supplied by the caller"], accuracy: "As supplied; the engine makes no claim.", notes: "" });
|
|
65
|
+
/** The sky figures as the host link reads them: each drawn figure with its card words (`experience.skyFigures`). */
|
|
66
|
+
function skyFigureReads(layers, cards) {
|
|
67
|
+
return layers.map(({ id, label, kind }) => {
|
|
68
|
+
const card = cards?.find((candidate) => candidate.id === id); // a hand-written definition may draw a figure with no card: it then reads as listed, with the default provenance
|
|
69
|
+
return Object.freeze({ id, label, kind, listed: card?.listed ?? true, provenance: card?.provenance ?? NO_CARD_PROVENANCE, ...(card?.description === undefined ? {} : { description: card.description }), ...(card?.facts === undefined ? {} : { facts: card.facts }) });
|
|
70
|
+
});
|
|
71
|
+
}
|
|
60
72
|
function startViewId(definition, search) {
|
|
61
73
|
const asked = showFromSearch(search);
|
|
62
74
|
const known = asked !== undefined && definition.views?.views.some((view) => view.id === asked) === true;
|
|
@@ -113,6 +125,7 @@ function buildRuntime(definition, search) {
|
|
|
113
125
|
trackedBodies: trackedBodiesOf(definition),
|
|
114
126
|
groups: groupsOf(definition),
|
|
115
127
|
bodySets: bodySetsOf(definition),
|
|
128
|
+
skyFigures: definition.skyFigures ?? [],
|
|
116
129
|
...sunCentredOf(definition),
|
|
117
130
|
cameraReach: cameraReachOf(definition),
|
|
118
131
|
look,
|
|
@@ -133,17 +146,22 @@ function showsDisplayControls(definition, runtime, skyVisible, orbitPathCount, s
|
|
|
133
146
|
return orbitPathCount > 0 || runtime.trackedBodies.length > 0 || skyVisible || storyMarkerCount > 0 || (definition.experience.storyPanels?.panels.length ?? 0) > 0
|
|
134
147
|
|| runtime.bodies.some((id) => runtime.catalogue.get(id).visual.kind === "sphere");
|
|
135
148
|
}
|
|
136
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* 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`.
|
|
151
|
+
* Undefined for a look-out toward an id: its direction is known only once the first frame resolves it, and a guess would be a false reading.
|
|
152
|
+
*/
|
|
137
153
|
function openingCamera(definition, runtime, search) {
|
|
138
154
|
const start = viewFromSearch(search) ?? definition.startView;
|
|
139
155
|
if (start !== undefined)
|
|
140
|
-
return start;
|
|
156
|
+
return "kind" in start ? undefined : start;
|
|
141
157
|
const opening = createOrbitCameraState(START_CAMERA_DISTANCE, runtime.sceneCenter);
|
|
142
158
|
return viewFromAngles(opening.focus, opening.azimuth, opening.elevation, opening.distance);
|
|
143
159
|
}
|
|
144
160
|
/** The scene's live controls at mount: the address overrides the experience's own start values. */
|
|
145
161
|
function initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkers, suppliedPolicies, search) {
|
|
146
|
-
|
|
162
|
+
// A look-out toward an id is aimed as a `setCamera` one is: a sky figure becomes its label point here, an object is turned toward on the first frame.
|
|
163
|
+
const opening = definition.startView;
|
|
164
|
+
const startView = viewFromSearch(search) ?? (opening !== undefined && "kind" in opening ? aimAtFigure(opening, runtime.skyFigures) : opening);
|
|
147
165
|
return {
|
|
148
166
|
policy: scalePolicyFor(startScale, suppliedPolicies),
|
|
149
167
|
cameraRequest: null,
|
|
@@ -152,6 +170,11 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
|
|
|
152
170
|
...(definition.pacing === undefined ? {} : { paceAuto: true, pace: { shown: shownEventsOf(definition, startViewId(definition, search)) } }),
|
|
153
171
|
up: viewUpVector(startViewUp(definition, search)),
|
|
154
172
|
showMilkyWay: runtime.sky.milkyWay,
|
|
173
|
+
skyLines: skyLineStart(definition.displaySwitches, DEFAULT_SKY_LINES),
|
|
174
|
+
skyColours: skyColoursOf(runtime.look),
|
|
175
|
+
skyTraces: [],
|
|
176
|
+
skyFadeInSeconds: skyFadeInSecondsOf(runtime.look),
|
|
177
|
+
labelStyle: labelStyleOf(runtime.look),
|
|
155
178
|
skyVisible: runtime.sky.visible,
|
|
156
179
|
bodyMarker: markerSettingsOf(runtime.look),
|
|
157
180
|
...(glowBase === null ? {} : { glowLook: glowLookOf(runtime.look, glowBase) }),
|
|
@@ -230,7 +253,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
230
253
|
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
231
254
|
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
232
255
|
const storySet = definition.experience.storyPanels;
|
|
233
|
-
const storyMarkerSpecs = useMemo(() => (storySet?.panels ?? []).flatMap((panel) => (panel.objectId === undefined ? [] : [{ panelId: panel.id, objectId: panel.objectId, title: panel.title, timeUtcMs: panel.timeUtcMs }])), [storySet]);
|
|
256
|
+
const storyMarkerSpecs = useMemo(() => [...(storySet?.panels ?? []), ...(storySet?.steps ?? [])].flatMap((panel) => (panel.objectId === undefined ? [] : [{ panelId: panel.id, objectId: panel.objectId, title: panel.title, ..."timeUtcMs" in panel ? { timeUtcMs: panel.timeUtcMs } : {} }])), [storySet]);
|
|
234
257
|
const controls = useRef(initialSceneControls(definition, runtime, experience, startScale, glowBase, storyMarkerSpecs, suppliedPolicies, search));
|
|
235
258
|
const readout = useRef(null);
|
|
236
259
|
const [clockSnapshot, setClockSnapshot] = useState(() => runtime.clock.snapshot());
|
|
@@ -239,6 +262,9 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
239
262
|
const [timelineGlow, setTimelineGlow] = useState(DEFAULT_TIMELINE_GLOW);
|
|
240
263
|
const [phoneLayout, setPhoneLayout] = useState(DEFAULT_PHONE_LAYOUT);
|
|
241
264
|
const [anchorLabels, setAnchorLabels] = useState(controls.current.showAnchorLabels);
|
|
265
|
+
const [skyLinesShown, setSkyLinesShown] = useState(controls.current.skyLines);
|
|
266
|
+
const [skyColoursShown, setSkyColoursShown] = useState(controls.current.skyColours);
|
|
267
|
+
const [labelStyleShown, setLabelStyleShown] = useState(controls.current.labelStyle);
|
|
242
268
|
const [glowShown, setGlowShown] = useState(copyOfGlow(controls.current.glowLook));
|
|
243
269
|
const orbitPaths = orbitPathsOf(runtime);
|
|
244
270
|
const orbitDefault = useMemo(() => resolveOrbitLook(orbitPaths[0]?.look), [orbitPaths]);
|
|
@@ -286,14 +312,18 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
286
312
|
const [viewLink, setViewLink] = useState(null);
|
|
287
313
|
const [fills, setFills] = useState([]);
|
|
288
314
|
const updateCameraRequest = useCallback((request) => {
|
|
289
|
-
controls.current.cameraRequest = request;
|
|
290
|
-
}, []);
|
|
315
|
+
controls.current.cameraRequest = aimAtFigure(request, runtime.skyFigures);
|
|
316
|
+
}, [runtime]);
|
|
317
|
+
const turnToFigure = useCallback((id) => {
|
|
318
|
+
const now = controls.current.viewReadout;
|
|
319
|
+
if (now !== undefined && "lookOut" in now)
|
|
320
|
+
updateCameraRequest({ kind: "lookOut", body: now.lookOut, direction: id });
|
|
321
|
+
}, [updateCameraRequest]);
|
|
291
322
|
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
292
323
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
293
324
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
294
325
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
295
326
|
const markOpenFeature = useCallback((key) => { controls.current.openFeatureKey = key; }, []);
|
|
296
|
-
const markOpenPanel = useCallback((id) => { controls.current.openStoryPanelId = id; }, []);
|
|
297
327
|
const setPlaying = useCallback((playing) => {
|
|
298
328
|
if (playing)
|
|
299
329
|
runtime.clock.play();
|
|
@@ -312,6 +342,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
312
342
|
const viewRef = useRef(viewId);
|
|
313
343
|
const chooseView = useCallback((id) => {
|
|
314
344
|
viewRef.current = id;
|
|
345
|
+
controls.current.hostCameraRequest = null; // a host camera call counts from this switch on
|
|
315
346
|
controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
|
|
316
347
|
// The showing view's events choose the pacing zones; a paced rate that changes with them eases in rather than jumping.
|
|
317
348
|
if (controls.current.pace !== undefined) {
|
|
@@ -335,6 +366,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
335
366
|
...(runtime.eventZones === undefined ? {} : { zones: activeEventZones(runtime.eventZones, shownEventsOf(definition, viewRef.current), snapshot.timeUtcMs) }),
|
|
336
367
|
...(definition.views === undefined ? {} : { view: viewRef.current }),
|
|
337
368
|
...(controls.current.selectedObjectId === "" ? {} : { selected: controls.current.selectedObjectId }),
|
|
369
|
+
...(controls.current.openStoryPanelId == null ? {} : { panel: controls.current.openStoryPanelId }),
|
|
338
370
|
};
|
|
339
371
|
}, [runtime, definition]);
|
|
340
372
|
// 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,7 +374,29 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
342
374
|
// The presentation (scale, looks, switches) last told to the host, to find what a visitor changed.
|
|
343
375
|
const shownKey = useRef(null);
|
|
344
376
|
// `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).
|
|
377
|
+
// 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.
|
|
378
|
+
const hostSelect = useRef(null);
|
|
379
|
+
const [selectRequest, setSelectRequest] = useState(null);
|
|
380
|
+
/** `quiet`: a story panel's select, which follows the visitor-tap rule for the card (the shell decides: wide screens open it, phones do not); a host call opens it always. */
|
|
381
|
+
const selectWith = useCallback((id, quiet) => {
|
|
382
|
+
hostSelect.current = id ?? "";
|
|
383
|
+
controls.current.selectedObjectId = id ?? ""; // `read()` shows it at once
|
|
384
|
+
setSelectRequest((previous) => ({ id: id ?? "", serial: (previous?.serial ?? 0) + 1, ...(quiet ? { quiet } : {}) }));
|
|
385
|
+
}, []);
|
|
386
|
+
const hostSetSelected = useCallback((id) => selectWith(id, false), [selectWith]);
|
|
387
|
+
const hostSelectApplied = useCallback(() => { hostSelect.current = null; }, []);
|
|
388
|
+
const hostSetPanel = useCallback((id) => {
|
|
389
|
+
controls.current.openStoryPanelId = id ?? null; // `read()` shows it at once
|
|
390
|
+
setPanelRequest((previous) => ({ id: id ?? "", serial: (previous?.serial ?? 0) + 1, host: true }));
|
|
391
|
+
}, []);
|
|
392
|
+
const panelIds = useCallback(() => {
|
|
393
|
+
const set = definition.experience.storyPanels;
|
|
394
|
+
const hidden = controls.current.viewHidden?.panels;
|
|
395
|
+
return [...(set?.panels ?? []), ...(set?.steps ?? [])].map(({ id }) => id).filter((id) => hidden === undefined || !hidden.has(id));
|
|
396
|
+
}, [definition]);
|
|
345
397
|
const updateSelectedObject = useCallback((objectId, origin) => {
|
|
398
|
+
if (hostSelect.current !== null)
|
|
399
|
+
return; // a host `setSelected` is waiting for the shell: the shell's older choice must not undo it (the host-call order rule)
|
|
346
400
|
const changed = controls.current.selectedObjectId !== objectId;
|
|
347
401
|
controls.current.selectedObjectId = objectId;
|
|
348
402
|
if (changed && hostAttached.current)
|
|
@@ -373,6 +427,12 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
373
427
|
}
|
|
374
428
|
setClockSnapshot(runtime.clock.snapshot());
|
|
375
429
|
}, [runtime]);
|
|
430
|
+
// 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.
|
|
431
|
+
const storySeekNote = useRef(null);
|
|
432
|
+
const hostSeekTo = useCallback((timeUtcMs) => {
|
|
433
|
+
storySeekNote.current?.(timeUtcMs);
|
|
434
|
+
seekTo(timeUtcMs);
|
|
435
|
+
}, [seekTo]);
|
|
376
436
|
// A speed picked by the visitor or the host takes over from pacing; "auto" gives the rate back to it.
|
|
377
437
|
const [paceAuto, setPaceAuto] = useState(controls.current.paceAuto === true);
|
|
378
438
|
const changeRate = useCallback((rate) => {
|
|
@@ -397,21 +457,57 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
397
457
|
}, [experience]);
|
|
398
458
|
const opening = useMemo(() => openingCamera(definition, runtime, search), []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
399
459
|
const readCamera = useCallback(() => {
|
|
400
|
-
|
|
460
|
+
const view = controls.current.viewReadout ?? opening;
|
|
461
|
+
return view === undefined ? undefined : { ...view };
|
|
401
462
|
}, [opening]);
|
|
402
|
-
|
|
463
|
+
// 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.
|
|
464
|
+
const setCamera = useCallback((request) => { controls.current.cameraRequest = controls.current.hostCameraRequest = aimAtFigure(request, runtime.skyFigures); }, [runtime]);
|
|
465
|
+
const hostCameraSet = useCallback(() => controls.current.hostCameraRequest != null, []);
|
|
403
466
|
const hostScales = useMemo(() => scaleChoiceIds ?? SCALE_CHOICES.map((choice) => choice.id), [scaleChoiceIds]);
|
|
404
467
|
const hostSetLook = useCallback((look) => live.current?.setLook(look), []);
|
|
405
468
|
const hostSetScale = useCallback((id) => live.current?.setScale(id), []);
|
|
469
|
+
const hostClearSkyTrace = useCallback((id, seconds) => { controls.current.skyTraces.push({ id, seconds, reduced: prefersReducedMotion() }); }, []);
|
|
470
|
+
const hostTraceSkyFigure = useCallback((id, seconds, after) => { controls.current.skyTraces.push({ id, seconds, after, reduced: prefersReducedMotion() }); }, []);
|
|
406
471
|
const hostSetSwitch = useCallback((id, on) => live.current?.setSwitch(id, on), []);
|
|
472
|
+
/** The figure the open story panel traced when it opened; it is cleared (default fade) when the panel is left. */
|
|
473
|
+
const panelTrace = useRef(null);
|
|
474
|
+
/** The panel whose actions were last applied (a host `setPanel` shows its panel at once, so `openStoryPanelId` cannot say whether the shell has opened it yet). */
|
|
475
|
+
const actedPanel = useRef(null);
|
|
476
|
+
/** The shell's open panel changed (a visitor, a host call already shown, playback crossing a panel, or a view switch dropping it); a change is told to the host, the opening panel is read at attach. */
|
|
477
|
+
const markOpenPanel = useCallback((id, cause) => {
|
|
478
|
+
const changed = (controls.current.openStoryPanelId ?? null) !== id;
|
|
479
|
+
controls.current.openStoryPanelId = id;
|
|
480
|
+
if (changed && hostAttached.current)
|
|
481
|
+
host?.publishPanel(stateNow(), cause);
|
|
482
|
+
if (actedPanel.current === id)
|
|
483
|
+
return;
|
|
484
|
+
actedPanel.current = id;
|
|
485
|
+
// Leaving a panel clears the trace it started; what a host or visitor did since is left as it is.
|
|
486
|
+
if (panelTrace.current !== null)
|
|
487
|
+
hostClearSkyTrace(panelTrace.current, TRACE_FADE_SECONDS);
|
|
488
|
+
panelTrace.current = null;
|
|
489
|
+
const set = definition.experience.storyPanels;
|
|
490
|
+
const panel = id === null ? undefined : [...(set?.panels ?? []), ...(set?.steps ?? [])].find((candidate) => candidate.id === id);
|
|
491
|
+
if (panel === undefined)
|
|
492
|
+
return;
|
|
493
|
+
// The panel's actions go through the host calls, in this order: camera, select, trace.
|
|
494
|
+
if (panel.camera !== undefined)
|
|
495
|
+
setCamera(panel.camera);
|
|
496
|
+
if (panel.select === true && panel.objectId !== undefined)
|
|
497
|
+
selectWith(panel.objectId, true);
|
|
498
|
+
if (panel.trace !== undefined && panel.objectId !== undefined) {
|
|
499
|
+
hostTraceSkyFigure(panel.objectId, panel.trace.seconds, panel.trace.after);
|
|
500
|
+
panelTrace.current = panel.objectId;
|
|
501
|
+
}
|
|
502
|
+
}, [host, stateNow, definition, setCamera, selectWith, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
407
503
|
useEffect(() => {
|
|
408
504
|
if (host === undefined)
|
|
409
505
|
return undefined;
|
|
410
506
|
hostAttached.current = true;
|
|
411
507
|
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:
|
|
508
|
+
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, skyFigures: skyFigureReads(runtime.skyFigures, experience.skyFigures), 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, panels: panelIds, setPanel: hostSetPanel, scales: hostScales, setScale: hostSetScale, setLook: hostSetLook, setSwitch: hostSetSwitch, traceSkyFigure: hostTraceSkyFigure, clearSkyTrace: hostClearSkyTrace });
|
|
413
509
|
return () => { hostAttached.current = false; host.detach(); };
|
|
414
|
-
}, [host, runtime, definition,
|
|
510
|
+
}, [host, runtime, definition, hostSeekTo, changeRate, viewIds, chooseView, cameraTargets, readCamera, setCamera, hostSetSelected, panelIds, hostSetPanel, experience, hostSetPlaying, hostScales, hostSetScale, hostSetLook, hostSetSwitch, hostTraceSkyFigure, hostClearSkyTrace]);
|
|
415
511
|
useEffect(() => {
|
|
416
512
|
if (!developerMode)
|
|
417
513
|
return undefined;
|
|
@@ -452,6 +548,10 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
452
548
|
settings: definition.displaySwitches,
|
|
453
549
|
orbit: { present: orbitPaths.length > 0, look: { ...orbitDefault, ...controls.current.orbitLook }, set: setOrbit },
|
|
454
550
|
moons: { present: bodySets.length > 0, look: controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK, set: changeSetLook },
|
|
551
|
+
skyLines: {
|
|
552
|
+
figures: runtime.skyFigures.some(({ kind }) => kind === "figure"), boundaries: runtime.skyFigures.some(({ kind }) => kind === "boundary"), on: controls.current.skyLines,
|
|
553
|
+
set: (key, on) => { controls.current.skyLines = { ...controls.current.skyLines, [key]: on }; setSkyLinesShown(controls.current.skyLines); },
|
|
554
|
+
},
|
|
455
555
|
sky: { present: controls.current.skyVisible !== false, on: controls.current.showMilkyWay, set: (on) => { controls.current.showMilkyWay = on; setMilkyWayOn(on); } },
|
|
456
556
|
labels: {
|
|
457
557
|
objectIds: experience.objects.map((object) => object.id), hidden: controls.current.hiddenLabels ?? hiddenLabels,
|
|
@@ -471,6 +571,8 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
471
571
|
setGlowShown({ ...controls.current.glowLook });
|
|
472
572
|
setMarkerPx(read.markerSwapRadiusPx);
|
|
473
573
|
setLoadFade(read.loadFadeSeconds);
|
|
574
|
+
setSkyColoursShown(controls.current.skyColours);
|
|
575
|
+
setLabelStyleShown(controls.current.labelStyle);
|
|
474
576
|
},
|
|
475
577
|
setScale: updateScale,
|
|
476
578
|
items: () => displaySwitchItems({ ...bindingsNow(), settings: hostReachable(definition.displaySwitches) }),
|
|
@@ -485,7 +587,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
485
587
|
shownKey.current = key;
|
|
486
588
|
if (changed)
|
|
487
589
|
host?.publish(state, "visitor");
|
|
488
|
-
}, [host, stateNow, scale, skyVisible, starBrightness, milkyWayBrightness, milkyWayOn, glowShown, markerPx, loadFade, orbitShown, setLook, hiddenLabels, anchorLabels]);
|
|
590
|
+
}, [host, stateNow, scale, skyVisible, starBrightness, milkyWayBrightness, milkyWayOn, glowShown, markerPx, loadFade, orbitShown, setLook, hiddenLabels, anchorLabels, skyLinesShown, skyColoursShown, labelStyleShown]);
|
|
489
591
|
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
490
592
|
const showDisplay = showsDisplayControls(definition, runtime, skyVisible, orbitPaths.length, storyMarkerSpecs.length);
|
|
491
593
|
// Orbit-line sliders: the first four stay in view, the rest sit in a nested "Fine-tune" fold (T-090).
|
|
@@ -537,7 +639,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
537
639
|
},
|
|
538
640
|
{
|
|
539
641
|
id: "labels", title: "Labels",
|
|
540
|
-
body: (_jsx(LabelSettings, { controls: controls, hoverBrightness: hoverBrightness, setHoverBrightness: setHoverBrightness, labelToggles: labelToggles, trackedCount: runtime.trackedBodies.length, anchorLabels: anchorLabels, setAnchorLabels: setAnchorLabels, hiddenLabels: hiddenLabels, setHiddenLabels: setHiddenLabels })),
|
|
642
|
+
body: (_jsx(LabelSettings, { controls: controls, hoverBrightness: hoverBrightness, setHoverBrightness: setHoverBrightness, labelToggles: labelToggles, trackedCount: runtime.trackedBodies.length, anchorLabels: anchorLabels, setAnchorLabels: setAnchorLabels, hiddenLabels: hiddenLabels, setHiddenLabels: setHiddenLabels, labelStyle: labelStyleShown, setLabelStyle: setLabelStyleShown, skyColours: skyColoursShown, setSkyColours: setSkyColoursShown, hasSky: skyVisible })),
|
|
541
643
|
},
|
|
542
644
|
!showDisplay ? null : {
|
|
543
645
|
id: "phone-layout", title: "Phone layout",
|
|
@@ -556,7 +658,7 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
556
658
|
];
|
|
557
659
|
const presentGroups = groups.filter((group) => group !== null);
|
|
558
660
|
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)))] }) }) }));
|
|
559
|
-
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
661
|
+
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, paceAuto: runtime.pacing === undefined ? undefined : paceAuto, developerMode: developerMode, labelStyle: labelStyleShown, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
560
662
|
if (runtime.clock.playing)
|
|
561
663
|
runtime.clock.pause();
|
|
562
664
|
else
|
|
@@ -569,5 +671,5 @@ export function App({ definition, writeTitle = true, address, developerTools, ho
|
|
|
569
671
|
}, onSeek: (timeUtcMs) => {
|
|
570
672
|
seekTo(timeUtcMs);
|
|
571
673
|
host?.publish(stateNow(), "visitor");
|
|
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 }) }) }));
|
|
674
|
+
}, onCameraRequest: updateCameraRequest, onTurnToFigure: turnToFigure, 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 }) }) }));
|
|
573
675
|
}
|