astraeus 0.5.1 → 0.7.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 +26 -0
- package/README.md +31 -8
- package/data/moons/jupiter.json +351 -115
- package/data/moons/neptune.json +54 -16
- package/data/moons/pluto.json +21 -5
- package/data/moons/saturn.json +882 -292
- package/data/moons/uranus.json +90 -28
- package/package.json +1 -1
- package/src/api/AstraeusScene.d.ts +4 -2
- package/src/api/AstraeusScene.js +13 -10
- package/src/api/AstraeusScene.node.js +13 -10
- package/src/api/bodies.d.ts +6 -1
- package/src/api/bodies.js +15 -2
- package/src/api/data.d.ts +2 -1
- package/src/api/data.js +4 -13
- package/src/api/errors.d.ts +1 -1
- package/src/api/index.d.ts +2 -1
- package/src/api/index.js +1 -1
- package/src/api/index.node.js +1 -1
- package/src/api/mount.d.ts +5 -1
- package/src/api/mount.js +2 -0
- package/src/api/mount.node.js +2 -0
- package/src/api/pathProvenance.d.ts +15 -6
- package/src/api/pathProvenance.js +23 -11
- package/src/api/scene.d.ts +18 -1
- package/src/api/scene.js +110 -15
- package/src/api/sphereOfInfluence.d.ts +20 -0
- package/src/api/sphereOfInfluence.js +48 -0
- package/src/api/viewerLink.d.ts +7 -1
- package/src/api/viewerLink.js +13 -2
- package/src/api/views.d.ts +42 -0
- package/src/api/views.js +80 -0
- package/src/app/App.js +32 -5
- package/src/app/App.node.js +32 -5
- package/src/app/AstraeusScene.d.ts +3 -0
- package/src/app/CameraController.d.ts +6 -0
- package/src/app/CameraController.js +3 -1
- package/src/app/PathView.d.ts +3 -2
- package/src/app/PathView.js +5 -5
- package/src/app/StoryMarkers.d.ts +4 -1
- package/src/app/StoryMarkers.js +3 -2
- package/src/app/TrackedBodyView.d.ts +1 -1
- package/src/app/TrackedBodyView.js +20 -11
- package/src/app/experienceDefinition.d.ts +3 -0
- package/src/app/mission.d.ts +15 -2
- package/src/app/mission.js +15 -0
- package/src/app/sceneCamera.d.ts +2 -0
- package/src/app/sceneCamera.js +14 -0
- package/src/app/sceneFrame.d.ts +2 -0
- package/src/app/sceneFrame.js +42 -6
- package/src/app/sceneHooks.js +1 -1
- package/src/app/viewHiding.d.ts +13 -0
- package/src/app/viewHiding.js +37 -0
- package/src/app/viewerPort.d.ts +6 -0
- package/src/app/views.d.ts +31 -0
- package/src/app/views.js +2 -0
- package/src/assets/bodies/listedMoons.d.ts +4 -0
- package/src/assets/bodies/listedMoons.js +7 -0
- package/src/assets/catalogue.d.ts +3 -0
- package/src/assets/catalogue.js +8 -0
- package/src/assets/moonCatalogue.d.ts +3 -1
- package/src/assets/moonCatalogue.js +1 -0
- package/src/core/bodies/jupiterMoons.d.ts +1 -1
- package/src/core/bodies/listedMoonBodies.d.ts +18 -0
- package/src/core/bodies/listedMoonBodies.js +36 -0
- package/src/core/bodies/listedMoons.d.ts +18 -0
- package/src/core/bodies/listedMoons.js +483 -0
- package/src/core/bodies/moonSystem.d.ts +3 -2
- package/src/core/bodies/moonSystem.js +1 -1
- package/src/shell/AstraeusShell.d.ts +12 -2
- package/src/shell/AstraeusShell.js +42 -4
- package/src/shell/AstraeusShell.node.js +42 -4
- package/src/shell/DisplaySwitches.d.ts +18 -1
- package/src/shell/DisplaySwitches.js +18 -5
- package/src/shell/TimelineBar.css +18 -0
- package/src/shell/TimelineBar.js +29 -4
- package/src/shell/TimelineBar.node.js +29 -4
- package/src/shell/TopBar.d.ts +4 -2
- package/src/shell/TopBar.js +3 -3
- package/src/shell/TopBar.node.js +3 -3
- package/src/shell/timelineModel.d.ts +13 -0
- package/src/shell/timelineModel.js +25 -0
- package/src/shell/viewCamera.d.ts +4 -0
- package/src/shell/viewCamera.js +13 -0
- package/src/synthetic/syntheticJourneyScene.d.ts +2 -1
- package/src/synthetic/syntheticJourneyScene.js +29 -14
- package/src/synthetic/syntheticViewsDefinition.d.ts +6 -0
- package/src/synthetic/syntheticViewsDefinition.js +44 -0
package/src/api/viewerLink.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export interface ViewerChange {
|
|
|
7
7
|
/** Simulated seconds per real second. */
|
|
8
8
|
readonly rate: number;
|
|
9
9
|
readonly playing: boolean;
|
|
10
|
-
/**
|
|
10
|
+
/** Only in a scene with views: the id of the view showing. */
|
|
11
|
+
readonly view?: string;
|
|
12
|
+
/** `playback`: the clock ran on; `visitor`: someone used the timeline or the view choice; `host`: the host page called `setTime`, `setRate` or `setView`. */
|
|
11
13
|
readonly cause: ViewerChangeCause;
|
|
12
14
|
}
|
|
13
15
|
/** Where the playback rate comes from. `scene` is the rate the scene opened at; `chosen` is one a visitor or the host picked, which stays until it is released. */
|
|
@@ -27,6 +29,10 @@ export declare class ViewerLink implements ViewerPort {
|
|
|
27
29
|
get time(): number | undefined;
|
|
28
30
|
get rate(): number | undefined;
|
|
29
31
|
get playing(): boolean | undefined;
|
|
32
|
+
/** The id of the view showing; undefined before the viewer is drawn, after it is gone, and in a scene without views. */
|
|
33
|
+
get view(): string | undefined;
|
|
34
|
+
/** Switches to the view with this id. An id the scene does not name, or a scene without views, throws `bad-view`; before the viewer is drawn or after it is gone, `missing-data`. */
|
|
35
|
+
setView(id: string): void;
|
|
30
36
|
setTime(time: TimeInput): void;
|
|
31
37
|
/**
|
|
32
38
|
* Only a speed the timeline offers is taken, so the speed picker always shows what is running; any other number throws `bad-timeline`.
|
package/src/api/viewerLink.js
CHANGED
|
@@ -29,6 +29,17 @@ export class ViewerLink {
|
|
|
29
29
|
get time() { return this.#control?.read().timeUtcMs; }
|
|
30
30
|
get rate() { return this.#control?.read().rate; }
|
|
31
31
|
get playing() { return this.#control?.read().playing; }
|
|
32
|
+
/** The id of the view showing; undefined before the viewer is drawn, after it is gone, and in a scene without views. */
|
|
33
|
+
get view() { return this.#control?.read().view; }
|
|
34
|
+
/** Switches to the view with this id. An id the scene does not name, or a scene without views, throws `bad-view`; before the viewer is drawn or after it is gone, `missing-data`. */
|
|
35
|
+
setView(id) {
|
|
36
|
+
const control = this.#open("setView");
|
|
37
|
+
if (!control.views.includes(id)) {
|
|
38
|
+
throw new SceneError("bad-view", control.views.length === 0 ? "setView: the scene has no views; name them with setViews" : `setView: "${String(id)}" is not one of the scene's views (${control.views.join(", ")})`);
|
|
39
|
+
}
|
|
40
|
+
control.setView(id);
|
|
41
|
+
this.publish(control.read(), "host");
|
|
42
|
+
}
|
|
32
43
|
setTime(time) {
|
|
33
44
|
const control = this.#open("setTime");
|
|
34
45
|
const timeUtcMs = toUtcMs(time, "setTime");
|
|
@@ -67,14 +78,14 @@ export class ViewerLink {
|
|
|
67
78
|
}
|
|
68
79
|
publish(state, cause) {
|
|
69
80
|
const last = this.#last;
|
|
70
|
-
if (last !== undefined && last.timeUtcMs === state.timeUtcMs && last.rate === state.rate && last.playing === state.playing && last.auto === state.auto)
|
|
81
|
+
if (last !== undefined && last.timeUtcMs === state.timeUtcMs && last.rate === state.rate && last.playing === state.playing && last.auto === state.auto && last.view === state.view)
|
|
71
82
|
return;
|
|
72
83
|
if (state.auto !== undefined)
|
|
73
84
|
this.#rateSource = state.auto ? "scene" : "chosen";
|
|
74
85
|
else if (cause === "visitor" && last !== undefined && last.rate !== state.rate)
|
|
75
86
|
this.#rateSource = "chosen";
|
|
76
87
|
this.#last = state;
|
|
77
|
-
const change = { time: state.timeUtcMs, rate: state.rate, playing: state.playing, cause };
|
|
88
|
+
const change = { time: state.timeUtcMs, rate: state.rate, playing: state.playing, ...(state.view === undefined ? {} : { view: state.view }), cause };
|
|
78
89
|
for (const listener of [...this.#listeners])
|
|
79
90
|
listener(change);
|
|
80
91
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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). */
|
|
3
|
+
export type ViewCameraInput = "stay" | "start" | {
|
|
4
|
+
readonly follow: string;
|
|
5
|
+
} | {
|
|
6
|
+
readonly focus: string;
|
|
7
|
+
};
|
|
8
|
+
/** One named view. `paths` are `addTrajectory` ids, `bodies` are `addBody` or `addGroup` ids, `events` are `addEvents` ids and `panels` are `addStoryPanels` ids. */
|
|
9
|
+
export interface ViewInput {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly label: string;
|
|
12
|
+
readonly paths?: readonly string[];
|
|
13
|
+
readonly bodies?: readonly string[];
|
|
14
|
+
readonly events?: readonly string[];
|
|
15
|
+
readonly panels?: readonly string[];
|
|
16
|
+
readonly camera?: ViewCameraInput;
|
|
17
|
+
}
|
|
18
|
+
/** Options of `setViews`: where the choice shows (`"top-bar"` or `"panel"`) and the opening view (default the first). */
|
|
19
|
+
export interface ViewsOptions {
|
|
20
|
+
readonly place: ViewPlace;
|
|
21
|
+
readonly start?: string;
|
|
22
|
+
}
|
|
23
|
+
/** A `setViews` call, checked for shape; its ids are checked against the scene by `resolveViews`. */
|
|
24
|
+
export interface ViewsPlan {
|
|
25
|
+
readonly place: ViewPlace;
|
|
26
|
+
readonly start: string;
|
|
27
|
+
readonly views: readonly ViewInput[];
|
|
28
|
+
}
|
|
29
|
+
/** What the finished scene holds, for `resolveViews`. */
|
|
30
|
+
export interface ViewScope {
|
|
31
|
+
readonly paths: readonly string[];
|
|
32
|
+
readonly bodies: readonly string[];
|
|
33
|
+
readonly events: readonly string[];
|
|
34
|
+
readonly panels: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
/** Checks the shape of a `setViews` call (list, ids, labels, place, start, camera form, id lists); the ids are checked when the scene is built. */
|
|
37
|
+
export declare function viewsOf(input: readonly ViewInput[], options: ViewsOptions): ViewsPlan;
|
|
38
|
+
/**
|
|
39
|
+
* 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
|
|
40
|
+
* and for a camera target the view does not show.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveViews(plan: ViewsPlan, scope: ViewScope): ViewSettings;
|
package/src/api/views.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { VIEW_PLACES } from "../app/views.js";
|
|
2
|
+
import { SceneError } from "./errors.js";
|
|
3
|
+
const KINDS = ["paths", "bodies", "events", "panels"];
|
|
4
|
+
const bad = (message) => new SceneError("bad-view", `setViews: ${message}`);
|
|
5
|
+
/** Checks the shape of a `setViews` call (list, ids, labels, place, start, camera form, id lists); the ids are checked when the scene is built. */
|
|
6
|
+
export function viewsOf(input, options) {
|
|
7
|
+
// A deep copy first, so a later edit to the caller's objects cannot slip past the checks below.
|
|
8
|
+
const views = Array.isArray(input) ? structuredClone(input) : input;
|
|
9
|
+
if (!Array.isArray(views) || views.length === 0)
|
|
10
|
+
throw bad(`give a non-empty list such as [{ id: "all", label: "All" }]`);
|
|
11
|
+
if (typeof options !== "object" || options === null || !VIEW_PLACES.includes(options.place))
|
|
12
|
+
throw bad(`place must be one of ${VIEW_PLACES.join(", ")}, got ${JSON.stringify(options?.place)}`);
|
|
13
|
+
const seen = new Set();
|
|
14
|
+
views.forEach((view, index) => {
|
|
15
|
+
const where = `view ${index}`;
|
|
16
|
+
if (typeof view !== "object" || view === null)
|
|
17
|
+
throw bad(`${where} must be an object { id, label, ... }`);
|
|
18
|
+
if (typeof view.id !== "string" || view.id === "")
|
|
19
|
+
throw bad(`${where} needs a non-empty id`);
|
|
20
|
+
if (typeof view.label !== "string" || view.label === "")
|
|
21
|
+
throw bad(`view "${view.id}" needs a non-empty label`);
|
|
22
|
+
if (seen.has(view.id))
|
|
23
|
+
throw bad(`view "${view.id}" appears twice`);
|
|
24
|
+
seen.add(view.id);
|
|
25
|
+
for (const kind of KINDS) {
|
|
26
|
+
const ids = view[kind];
|
|
27
|
+
if (ids !== undefined && (!Array.isArray(ids) || !ids.every((id) => typeof id === "string" && id !== "")))
|
|
28
|
+
throw bad(`view "${view.id}" ${kind} must be a list of non-empty ids`);
|
|
29
|
+
}
|
|
30
|
+
cameraOf(view);
|
|
31
|
+
});
|
|
32
|
+
const start = options.start ?? views[0].id;
|
|
33
|
+
if (!seen.has(start))
|
|
34
|
+
throw bad(`start "${String(start)}" is not a view (views: ${[...seen].join(", ")})`);
|
|
35
|
+
return { place: options.place, start, views: views.map((view) => ({ ...view })) };
|
|
36
|
+
}
|
|
37
|
+
/** The camera rule a view asks for; a malformed one throws `bad-view`. */
|
|
38
|
+
function cameraOf(view) {
|
|
39
|
+
const camera = view.camera;
|
|
40
|
+
if (camera === undefined || camera === "stay")
|
|
41
|
+
return { rule: "stay" };
|
|
42
|
+
if (camera === "start")
|
|
43
|
+
return { rule: "start" };
|
|
44
|
+
const follow = camera?.follow;
|
|
45
|
+
const focus = camera?.focus;
|
|
46
|
+
const target = follow ?? focus;
|
|
47
|
+
if (typeof camera !== "object" || camera === null || typeof target !== "string" || target === "" || (follow !== undefined) === (focus !== undefined))
|
|
48
|
+
throw bad(`view "${view.id}" camera must be "stay", "start", { follow: id } or { focus: id }, got ${JSON.stringify(camera)}`);
|
|
49
|
+
return { rule: "start", framing: follow === undefined ? { focus: target } : { follow: target } };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 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
|
|
53
|
+
* and for a camera target the view does not show.
|
|
54
|
+
*/
|
|
55
|
+
export function resolveViews(plan, scope) {
|
|
56
|
+
const known = { paths: new Set(scope.paths), bodies: new Set(scope.bodies), events: new Set(scope.events), panels: new Set(scope.panels) };
|
|
57
|
+
const what = { paths: "a path (addTrajectory)", bodies: "a body or group", events: "an event (addEvents)", panels: "a story panel (addStoryPanels)" };
|
|
58
|
+
const named = { paths: new Set(), bodies: new Set(), events: new Set(), panels: new Set() };
|
|
59
|
+
for (const view of plan.views) {
|
|
60
|
+
for (const kind of KINDS) {
|
|
61
|
+
for (const id of view[kind] ?? []) {
|
|
62
|
+
if (!known[kind].has(id))
|
|
63
|
+
throw bad(`view "${view.id}" ${kind}: "${id}" is not ${what[kind]} in the scene`);
|
|
64
|
+
named[kind].add(id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const shows = (view, kind, id) => !named[kind].has(id) || (view[kind] ?? []).includes(id);
|
|
69
|
+
const views = plan.views.map((view) => {
|
|
70
|
+
const objects = new Set([...scope.paths.filter((id) => shows(view, "paths", id)), ...scope.bodies.filter((id) => shows(view, "bodies", id))]);
|
|
71
|
+
const camera = cameraOf(view);
|
|
72
|
+
if (camera.rule === "start" && camera.framing !== undefined) {
|
|
73
|
+
const target = "follow" in camera.framing ? camera.framing.follow : camera.framing.focus;
|
|
74
|
+
if (!objects.has(target))
|
|
75
|
+
throw bad(`view "${view.id}" camera: "${target}" is not shown in that view (a body or path of the scene it names, or one no view hides from it)`);
|
|
76
|
+
}
|
|
77
|
+
return { id: view.id, label: view.label, camera, objects, events: new Set(scope.events.filter((id) => shows(view, "events", id))), panels: new Set(scope.panels.filter((id) => shows(view, "panels", id))) };
|
|
78
|
+
});
|
|
79
|
+
return { place: plan.place, start: plan.start, views };
|
|
80
|
+
}
|
package/src/app/App.js
CHANGED
|
@@ -27,6 +27,7 @@ import { resolveSkySettings, withSkyObject } from "./skyModel.js";
|
|
|
27
27
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
28
28
|
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
29
29
|
import { displaySwitchItems, orbitStart } from "./displaySwitches.js";
|
|
30
|
+
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
30
31
|
import { baseGlowOf, glowLookFromSearch, markerSettingsFromSearch } from "./bodyDraw.js";
|
|
31
32
|
import { brightnessFromSearch, milkyWayFromSearch, skyHiddenBySearch } from "./SkyView.js";
|
|
32
33
|
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
@@ -137,6 +138,7 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
|
|
|
137
138
|
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
138
139
|
...startOrbitControls(definition),
|
|
139
140
|
labelObjects: experience.objects,
|
|
141
|
+
viewHidden: hiddenByView(definition.views, viewById(definition.views, definition.views?.start ?? ""), experience),
|
|
140
142
|
storyMarkers,
|
|
141
143
|
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
142
144
|
featureMinBodyPx: featureMinBodyPxFromSearch(search),
|
|
@@ -182,7 +184,11 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
182
184
|
});
|
|
183
185
|
return () => { cancelled = true; };
|
|
184
186
|
}, []);
|
|
185
|
-
|
|
187
|
+
// 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.views?.start ?? "");
|
|
189
|
+
const currentView = useMemo(() => viewById(definition.views, viewId), [definition.views, viewId]);
|
|
190
|
+
const viewExperience = useMemo(() => experienceInView(experience, definition.views, currentView), [experience, definition.views, currentView]);
|
|
191
|
+
const shellExperience = useMemo(() => withSkyObject(viewExperience, runtime.sky.visible, starStatus), [viewExperience, runtime.sky.visible, starStatus]);
|
|
186
192
|
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
187
193
|
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
188
194
|
const storySet = definition.experience.storyPanels;
|
|
@@ -244,6 +250,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
244
250
|
const updateCameraRequest = useCallback((request) => {
|
|
245
251
|
controls.current.cameraRequest = request;
|
|
246
252
|
}, []);
|
|
253
|
+
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
247
254
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
248
255
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
249
256
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
@@ -266,7 +273,19 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
266
273
|
controls.current.policy = scalePolicyFor(id, suppliedPolicies);
|
|
267
274
|
setScale(id);
|
|
268
275
|
}, [suppliedPolicies]);
|
|
269
|
-
|
|
276
|
+
// The view showing is read from a ref set at the switch, so a publish right after a switch already names the new view.
|
|
277
|
+
const viewRef = useRef(viewId);
|
|
278
|
+
const chooseView = useCallback((id) => {
|
|
279
|
+
viewRef.current = id;
|
|
280
|
+
controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
|
|
281
|
+
setViewId(id);
|
|
282
|
+
}, [definition, experience]);
|
|
283
|
+
const viewIds = useMemo(() => definition.views?.views.map((view) => view.id) ?? [], [definition]);
|
|
284
|
+
const stateNow = useCallback(() => ({
|
|
285
|
+
...runtime.clock.snapshot(),
|
|
286
|
+
...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }),
|
|
287
|
+
...(definition.views === undefined ? {} : { view: viewRef.current }),
|
|
288
|
+
}), [runtime, definition]);
|
|
270
289
|
useEffect(() => {
|
|
271
290
|
const id = window.setInterval(() => {
|
|
272
291
|
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
@@ -302,9 +321,9 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
302
321
|
useEffect(() => {
|
|
303
322
|
if (host === undefined)
|
|
304
323
|
return undefined;
|
|
305
|
-
host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate });
|
|
324
|
+
host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate, views: viewIds, setView: chooseView });
|
|
306
325
|
return () => host.detach();
|
|
307
|
-
}, [host, runtime, definition, seekTo, changeRate]);
|
|
326
|
+
}, [host, runtime, definition, seekTo, changeRate, viewIds, chooseView]);
|
|
308
327
|
useEffect(() => {
|
|
309
328
|
if (!developerMode)
|
|
310
329
|
return undefined;
|
|
@@ -333,6 +352,14 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
333
352
|
return;
|
|
334
353
|
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
335
354
|
};
|
|
355
|
+
const viewChoice = definition.views === undefined ? undefined : {
|
|
356
|
+
place: definition.views.place,
|
|
357
|
+
options: definition.views.views.map((view) => ({ id: view.id, label: view.label, active: view.id === currentView?.id })),
|
|
358
|
+
onSelect: (id) => {
|
|
359
|
+
chooseView(id);
|
|
360
|
+
host?.publish(stateNow(), "visitor");
|
|
361
|
+
},
|
|
362
|
+
};
|
|
336
363
|
const displaySwitches = displaySwitchItems({
|
|
337
364
|
settings: definition.displaySwitches,
|
|
338
365
|
orbit: { present: orbitPaths.length > 0, look: orbitShown, set: setOrbit },
|
|
@@ -433,5 +460,5 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
433
460
|
}, onSeek: (timeUtcMs) => {
|
|
434
461
|
seekTo(timeUtcMs);
|
|
435
462
|
host?.publish(stateNow(), "visitor");
|
|
436
|
-
}, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
|
|
463
|
+
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
|
|
437
464
|
}
|
package/src/app/App.node.js
CHANGED
|
@@ -27,6 +27,7 @@ import { resolveSkySettings, withSkyObject } from "./skyModel.js";
|
|
|
27
27
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
28
28
|
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
29
29
|
import { displaySwitchItems, orbitStart } from "./displaySwitches.js";
|
|
30
|
+
import { experienceInView, hiddenByView, viewById } from "./viewHiding.js";
|
|
30
31
|
import { baseGlowOf, glowLookFromSearch, markerSettingsFromSearch } from "./bodyDraw.js";
|
|
31
32
|
import { brightnessFromSearch, milkyWayFromSearch, skyHiddenBySearch } from "./SkyView.js";
|
|
32
33
|
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
@@ -137,6 +138,7 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
|
|
|
137
138
|
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
138
139
|
...startOrbitControls(definition),
|
|
139
140
|
labelObjects: experience.objects,
|
|
141
|
+
viewHidden: hiddenByView(definition.views, viewById(definition.views, definition.views?.start ?? ""), experience),
|
|
140
142
|
storyMarkers,
|
|
141
143
|
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
142
144
|
featureMinBodyPx: featureMinBodyPxFromSearch(search),
|
|
@@ -182,7 +184,11 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
182
184
|
});
|
|
183
185
|
return () => { cancelled = true; };
|
|
184
186
|
}, []);
|
|
185
|
-
|
|
187
|
+
// 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.views?.start ?? "");
|
|
189
|
+
const currentView = useMemo(() => viewById(definition.views, viewId), [definition.views, viewId]);
|
|
190
|
+
const viewExperience = useMemo(() => experienceInView(experience, definition.views, currentView), [experience, definition.views, currentView]);
|
|
191
|
+
const shellExperience = useMemo(() => withSkyObject(viewExperience, runtime.sky.visible, starStatus), [viewExperience, runtime.sky.visible, starStatus]);
|
|
186
192
|
const metricsFor = useMemo(() => definition.createMetrics(experienceRuntime), [definition, experienceRuntime]);
|
|
187
193
|
const glowBase = useMemo(() => baseGlowOf(runtime.bodies.map((id) => runtime.catalogue.get(id))), [runtime]);
|
|
188
194
|
const storySet = definition.experience.storyPanels;
|
|
@@ -244,6 +250,7 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
244
250
|
const updateCameraRequest = useCallback((request) => {
|
|
245
251
|
controls.current.cameraRequest = request;
|
|
246
252
|
}, []);
|
|
253
|
+
const holdCamera = useCallback(() => { controls.current.cameraRequest = { kind: "hold" }; }, []);
|
|
247
254
|
const requestPanel = useCallback((id) => setPanelRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
248
255
|
const requestPick = useCallback((id) => setPickRequest((previous) => ({ id, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
249
256
|
const requestFeature = useCallback((key) => setFeatureRequest((previous) => ({ key, serial: (previous?.serial ?? 0) + 1 })), []);
|
|
@@ -266,7 +273,19 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
266
273
|
controls.current.policy = scalePolicyFor(id, suppliedPolicies);
|
|
267
274
|
setScale(id);
|
|
268
275
|
}, [suppliedPolicies]);
|
|
269
|
-
|
|
276
|
+
// The view showing is read from a ref set at the switch, so a publish right after a switch already names the new view.
|
|
277
|
+
const viewRef = useRef(viewId);
|
|
278
|
+
const chooseView = useCallback((id) => {
|
|
279
|
+
viewRef.current = id;
|
|
280
|
+
controls.current.viewHidden = hiddenByView(definition.views, viewById(definition.views, id), experience);
|
|
281
|
+
setViewId(id);
|
|
282
|
+
}, [definition, experience]);
|
|
283
|
+
const viewIds = useMemo(() => definition.views?.views.map((view) => view.id) ?? [], [definition]);
|
|
284
|
+
const stateNow = useCallback(() => ({
|
|
285
|
+
...runtime.clock.snapshot(),
|
|
286
|
+
...(runtime.pacing === undefined ? {} : { auto: controls.current.paceAuto === true }),
|
|
287
|
+
...(definition.views === undefined ? {} : { view: viewRef.current }),
|
|
288
|
+
}), [runtime, definition]);
|
|
270
289
|
useEffect(() => {
|
|
271
290
|
const id = window.setInterval(() => {
|
|
272
291
|
// The readout wraps with the scene, so the shown time never rests past the end while looping.
|
|
@@ -302,9 +321,9 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
302
321
|
useEffect(() => {
|
|
303
322
|
if (host === undefined)
|
|
304
323
|
return undefined;
|
|
305
|
-
host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate });
|
|
324
|
+
host.attach({ window: runtime.loopWindow, rates: definition.experience.rates, paced: runtime.pacing !== undefined, read: stateNow, seek: seekTo, setRate: changeRate, views: viewIds, setView: chooseView });
|
|
306
325
|
return () => host.detach();
|
|
307
|
-
}, [host, runtime, definition, seekTo, changeRate]);
|
|
326
|
+
}, [host, runtime, definition, seekTo, changeRate, viewIds, chooseView]);
|
|
308
327
|
useEffect(() => {
|
|
309
328
|
if (!developerMode)
|
|
310
329
|
return undefined;
|
|
@@ -333,6 +352,14 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
333
352
|
return;
|
|
334
353
|
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
335
354
|
};
|
|
355
|
+
const viewChoice = definition.views === undefined ? undefined : {
|
|
356
|
+
place: definition.views.place,
|
|
357
|
+
options: definition.views.views.map((view) => ({ id: view.id, label: view.label, active: view.id === currentView?.id })),
|
|
358
|
+
onSelect: (id) => {
|
|
359
|
+
chooseView(id);
|
|
360
|
+
host?.publish(stateNow(), "visitor");
|
|
361
|
+
},
|
|
362
|
+
};
|
|
336
363
|
const displaySwitches = displaySwitchItems({
|
|
337
364
|
settings: definition.displaySwitches,
|
|
338
365
|
orbit: { present: orbitPaths.length > 0, look: orbitShown, set: setOrbit },
|
|
@@ -433,5 +460,5 @@ export function App({ definition, onOpenAddress, writeTitle = true, host }) {
|
|
|
433
460
|
}, onSeek: (timeUtcMs) => {
|
|
434
461
|
seekTo(timeUtcMs);
|
|
435
462
|
host?.publish(stateNow(), "visitor");
|
|
436
|
-
}, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
|
|
463
|
+
}, onCameraRequest: updateCameraRequest, onCameraHold: holdCamera, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), displaySwitches: displaySwitches, viewChoice: viewChoice, viewCamera: currentView === undefined ? undefined : { id: currentView.id, rule: currentView.camera }, metricsFor: metricsFor, developerTools: developerTools, storyPanelSettings: { autoOpen: storyAutoOpen, pauseSeconds: storyPauseSeconds }, timelineGlow: timelineGlow, phoneLayout: phoneLayout, highlightedFamily: setLook.highlightFamily, onHighlightFamily: highlightFamily, onSetPlaying: setPlaying, panelRequest: panelRequest, onOpenPanelChange: markOpenPanel, featureRequest: featureRequest, pickRequest: pickRequest, onOpenFeatureChange: markOpenFeature, children: _jsx("div", { className: "canvas-host", children: _jsx(AstraeusScene, { runtime: runtime, controls: controls.current, readout: readout, scaleId: scale }) }) }));
|
|
437
464
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ViewHidden } from "./viewHiding.js";
|
|
1
2
|
import type { SimulationClock } from "../core/clock.js";
|
|
2
3
|
import type { Pacing } from "../core/pacing.js";
|
|
3
4
|
import type { BodyId } from "../core/body.js";
|
|
@@ -99,6 +100,8 @@ export interface SceneControls {
|
|
|
99
100
|
up?: RenderVector;
|
|
100
101
|
/** Ids of objects whose label is switched off (live). Their objects stay listed and selectable. */
|
|
101
102
|
hiddenLabels?: Set<string>;
|
|
103
|
+
/** Presentation only (views): the ids the current view hides, read by the frame stages (groups, labels, picking, story markers). Absent or empty: everything shows. Replaced, never edited, on a switch. */
|
|
104
|
+
viewHidden?: ViewHidden;
|
|
102
105
|
readonly labelObjects: readonly ExperienceObject[];
|
|
103
106
|
/** Objects that story panels name; each gets a marker that reopens its panel. */
|
|
104
107
|
readonly storyMarkers?: readonly StoryMarkerSpec[];
|
|
@@ -10,6 +10,10 @@ export type CameraRequest = {
|
|
|
10
10
|
readonly target: FocusId;
|
|
11
11
|
} | {
|
|
12
12
|
readonly kind: "overview";
|
|
13
|
+
}
|
|
14
|
+
/** Holds the camera where it is: its target becomes the point it looks at now, fixed in the scene frame; the pose is kept. A later focus, follow or overview request replaces it. */
|
|
15
|
+
| {
|
|
16
|
+
readonly kind: "hold";
|
|
13
17
|
};
|
|
14
18
|
export interface OrbitCameraState {
|
|
15
19
|
azimuth: number;
|
|
@@ -20,6 +24,8 @@ export interface OrbitCameraState {
|
|
|
20
24
|
distance: number;
|
|
21
25
|
targetDistance: number;
|
|
22
26
|
focus: FocusId;
|
|
27
|
+
/** Set by a `hold` request: the target stays at this scaled point (scene frame, render axes) whatever `focus` does, until a new focus request clears it. */
|
|
28
|
+
fixedPoint: [number, number, number] | null;
|
|
23
29
|
/** Decaying offset that tweens the displayed target from the previous focus to the new one. */
|
|
24
30
|
transition: [number, number, number];
|
|
25
31
|
/** Scaled absolute camera/target positions (Float64, render axes) for the latest frame. */
|
|
@@ -9,6 +9,7 @@ export function createOrbitCameraState(distance, focus) {
|
|
|
9
9
|
distance,
|
|
10
10
|
targetDistance: distance,
|
|
11
11
|
focus,
|
|
12
|
+
fixedPoint: null,
|
|
12
13
|
transition: [0, 0, 0],
|
|
13
14
|
cameraAbsolute: [0, 0, 0],
|
|
14
15
|
targetAbsolute: [0, 0, 0],
|
|
@@ -114,11 +115,12 @@ function pointerSpread(pointers) {
|
|
|
114
115
|
}
|
|
115
116
|
/** Starts a tween from the currently displayed target to a new focus without moving the camera. */
|
|
116
117
|
export function switchFocus(state, focus, newTargetAbsolute) {
|
|
117
|
-
if (focus === state.focus)
|
|
118
|
+
if (focus === state.focus && state.fixedPoint === null)
|
|
118
119
|
return;
|
|
119
120
|
for (let i = 0; i < 3; i += 1)
|
|
120
121
|
state.transition[i] = state.targetAbsolute[i] - newTargetAbsolute[i];
|
|
121
122
|
state.focus = focus;
|
|
123
|
+
state.fixedPoint = null;
|
|
122
124
|
}
|
|
123
125
|
/**
|
|
124
126
|
* Step 1 (before bodies are placed): computes the absolute target/camera in Float64 render axes
|
package/src/app/PathView.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Group, type Camera } from "three";
|
|
|
2
2
|
import type { CenterId } from "../core/body.js";
|
|
3
3
|
import type { ScalePolicy } from "../core/scalePolicy.js";
|
|
4
4
|
import type { StateResolver } from "../core/stateResolver.js";
|
|
5
|
+
import { type BodyCatalogue } from "../assets/catalogue.js";
|
|
5
6
|
import { type OrbitLook } from "../assets/orbitLook.js";
|
|
6
7
|
import type { CompositionPath } from "../assets/compositions.js";
|
|
7
8
|
import { type PathLayer } from "./experienceDefinition.js";
|
|
@@ -130,6 +131,6 @@ export declare const COMPOSITION_PATH_STYLE: PathStyle;
|
|
|
130
131
|
* A composition's declared path as an orbit layer: the body's positions about its parent from the resolver, over a window about the
|
|
131
132
|
* clock, carried with the parent.
|
|
132
133
|
*/
|
|
133
|
-
export declare function compositionPathLayer(path: CompositionPath, resolver: StateResolver): PathLayer;
|
|
134
|
+
export declare function compositionPathLayer(path: CompositionPath, resolver: StateResolver, bodies?: BodyCatalogue): PathLayer;
|
|
134
135
|
/** A composition path drawn with its orbit look (the path's own settings over the defaults), on the scene's own layer. */
|
|
135
|
-
export declare function compositionPathView(path: CompositionPath, resolver: StateResolver): PathView;
|
|
136
|
+
export declare function compositionPathView(path: CompositionPath, resolver: StateResolver, bodies?: BodyCatalogue): PathView;
|
package/src/app/PathView.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BufferAttribute, BufferGeometry, DoubleSide, Group, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, Vector3 } from "three";
|
|
2
2
|
import { eccentricPathTimesUtcMs, pathTimesUtcMs, samplePositionsKm, windowTimesUtcMs } from "../core/sunCentredSources.js";
|
|
3
|
-
import { catalogue } from "../assets/catalogue.js";
|
|
3
|
+
import { catalogue as builtInCatalogue } from "../assets/catalogue.js";
|
|
4
4
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
5
5
|
import { DEFAULT_ECCENTRIC_SAMPLE_COUNT, DEFAULT_PATH_SAMPLE_COUNT, DEFAULT_WINDOW_SAMPLE_COUNT, isRollingSpan, validatePathSpec, } from "./experienceDefinition.js";
|
|
6
6
|
import { arcSegmentAlpha, inertialTrailKm, mapPathKm, ringAlpha, windowEdgeAlpha, orbitKm, pathNeedsRefresh, relativeTrailKm, rootFrameKm, DEFAULT_PATH_REFRESH } from "./pathRules.js";
|
|
@@ -552,8 +552,8 @@ export const COMPOSITION_PATH_STYLE = Object.freeze({ opacity: 0.45, depthTest:
|
|
|
552
552
|
* A composition's declared path as an orbit layer: the body's positions about its parent from the resolver, over a window about the
|
|
553
553
|
* clock, carried with the parent.
|
|
554
554
|
*/
|
|
555
|
-
export function compositionPathLayer(path, resolver) {
|
|
556
|
-
const parent =
|
|
555
|
+
export function compositionPathLayer(path, resolver, bodies = builtInCatalogue) {
|
|
556
|
+
const parent = bodies.get(path.body).definition.parentId;
|
|
557
557
|
if (parent === undefined)
|
|
558
558
|
throw new RangeError(`path body "${path.body}" has no parent to orbit`);
|
|
559
559
|
const source = { body: path.body, stateAt: (timeUtcMs, center = parent) => resolver.stateOf(path.body, timeUtcMs, center) };
|
|
@@ -569,6 +569,6 @@ export function compositionPathLayer(path, resolver) {
|
|
|
569
569
|
};
|
|
570
570
|
}
|
|
571
571
|
/** A composition path drawn with its orbit look (the path's own settings over the defaults), on the scene's own layer. */
|
|
572
|
-
export function compositionPathView(path, resolver) {
|
|
573
|
-
return new PathView(compositionPathLayer(path, resolver), { ...COMPOSITION_PATH_STYLE, orbitLook: resolveOrbitLook(path.look, `path for "${path.body}"`) });
|
|
572
|
+
export function compositionPathView(path, resolver, bodies = builtInCatalogue) {
|
|
573
|
+
return new PathView(compositionPathLayer(path, resolver, bodies), { ...COMPOSITION_PATH_STYLE, orbitLook: resolveOrbitLook(path.look, `path for "${path.body}"`) });
|
|
574
574
|
}
|
|
@@ -33,6 +33,9 @@ export declare function panelForMarkerPress(group: StoryMarkerGroup, timeUtcMs:
|
|
|
33
33
|
export declare class StoryMarkerLayer {
|
|
34
34
|
#private;
|
|
35
35
|
constructor(host: HTMLElement, specs: readonly StoryMarkerSpec[], onOpen: (panelId: string) => void);
|
|
36
|
-
update(positionFor: (objectId: string) => RenderVector | null, camera: Camera, widthPx: number, heightPx: number, origin: FloatingOrigin, openPanelId: string | null, timeUtcMs: number
|
|
36
|
+
update(positionFor: (objectId: string) => RenderVector | null, camera: Camera, widthPx: number, heightPx: number, origin: FloatingOrigin, openPanelId: string | null, timeUtcMs: number, hidden?: {
|
|
37
|
+
readonly objects: ReadonlySet<string>;
|
|
38
|
+
readonly panels: ReadonlySet<string>;
|
|
39
|
+
}): void;
|
|
37
40
|
dispose(): void;
|
|
38
41
|
}
|
package/src/app/StoryMarkers.js
CHANGED
|
@@ -61,12 +61,13 @@ export class StoryMarkerLayer {
|
|
|
61
61
|
});
|
|
62
62
|
host.appendChild(this.#root);
|
|
63
63
|
}
|
|
64
|
-
update(positionFor, camera, widthPx, heightPx, origin, openPanelId, timeUtcMs) {
|
|
64
|
+
update(positionFor, camera, widthPx, heightPx, origin, openPanelId, timeUtcMs, hidden) {
|
|
65
65
|
this.#timeUtcMs = timeUtcMs;
|
|
66
66
|
this.#openPanelId = openPanelId;
|
|
67
67
|
camera.updateMatrixWorld(true);
|
|
68
68
|
for (const { group, element } of this.#entries) {
|
|
69
|
-
|
|
69
|
+
// A marker the current view owns no panel of, or on an object the view hides, is not drawn.
|
|
70
|
+
const absolute = hidden?.objects.has(group.objectId) === true || group.panels.every((panel) => hidden?.panels.has(panel.panelId) === true) ? null : positionFor(group.objectId);
|
|
70
71
|
const screen = absolute === null ? null : projectToScreen(this.#local.fromArray(origin.toLocal(absolute)), camera, widthPx, heightPx);
|
|
71
72
|
element.hidden = screen === null;
|
|
72
73
|
if (screen === null)
|
|
@@ -23,7 +23,7 @@ export declare function releaseAnchorSprite(): void;
|
|
|
23
23
|
export declare class TrackedBodyView {
|
|
24
24
|
#private;
|
|
25
25
|
readonly body: TrackedBody;
|
|
26
|
-
/** Every tracked body's path is one rule, a relative trail (`pathRules.ts`); the body it is drawn against is the path's own `lineFixedTo
|
|
26
|
+
/** Every tracked body's path is one rule, a relative trail (`pathRules.ts`); the body it is drawn against is the path's own `lineFixedTo` (one body or per-stretch), default the scene centre. */
|
|
27
27
|
static readonly pathRule: PathRule;
|
|
28
28
|
readonly group: Group<import("three").Object3DEventMap>;
|
|
29
29
|
/** Anchor labels in anchor order, or null when the body has none. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BufferAttribute, BufferGeometry, DataTexture, Group, Line, LineBasicMaterial, Mesh, MeshBasicMaterial, Points, RGBAFormat, SphereGeometry, Vector3, } from "three";
|
|
2
2
|
import { dotMaterial } from "./dotMaterial.js";
|
|
3
|
-
import { anchorLabelsOf, markerRadiusUnits, sampleTrackedPositions, stateClampedToBounds, stateIfInBounds, travelledCount } from "./mission.js";
|
|
3
|
+
import { anchorLabelsOf, markerRadiusUnits, lineAgainstAt, lineBodies, sampleTrackedPositions, stateClampedToBounds, stateIfInBounds, travelledCount } from "./mission.js";
|
|
4
4
|
import { mapPathKm, relativeTrailKm, shiftedBy } from "./pathRules.js";
|
|
5
5
|
import { eqjToRenderVector } from "./renderCoordinates.js";
|
|
6
6
|
import { sceneOffsetKm, trackedAbsolute } from "./sceneLayout.js";
|
|
@@ -55,7 +55,7 @@ export function releaseAnchorSprite() {
|
|
|
55
55
|
*/
|
|
56
56
|
export class TrackedBodyView {
|
|
57
57
|
body;
|
|
58
|
-
/** Every tracked body's path is one rule, a relative trail (`pathRules.ts`); the body it is drawn against is the path's own `lineFixedTo
|
|
58
|
+
/** Every tracked body's path is one rule, a relative trail (`pathRules.ts`); the body it is drawn against is the path's own `lineFixedTo` (one body or per-stretch), default the scene centre. */
|
|
59
59
|
static pathRule = Object.freeze({ kind: "trail", frame: "relative" });
|
|
60
60
|
group = new Group();
|
|
61
61
|
#marker;
|
|
@@ -131,7 +131,7 @@ export class TrackedBodyView {
|
|
|
131
131
|
*/
|
|
132
132
|
#remap(policy, placement, timeUtcMs) {
|
|
133
133
|
const placed = placement.center;
|
|
134
|
-
const moves = this
|
|
134
|
+
const moves = lineBodies(this.body.lineFixedTo).some(({ body }) => body !== placed);
|
|
135
135
|
if (this.#mappedFor === policy.id && this.#placedFor === placed && (!moves || this.#mappedAt === timeUtcMs))
|
|
136
136
|
return;
|
|
137
137
|
this.#mappedPath = mapPathKm(this.#relative(this.#samples, placement, timeUtcMs), policy);
|
|
@@ -140,16 +140,25 @@ export class TrackedBodyView {
|
|
|
140
140
|
this.#placedFor = placed;
|
|
141
141
|
this.#mappedAt = timeUtcMs;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
return this.body.lineFixedTo ?? placement.center;
|
|
145
|
-
}
|
|
143
|
+
/** Each run of samples drawn against one body (a plain `lineFixedTo` is one run) is placed from that body at its own times, then carried to the scene centre at the display time. */
|
|
146
144
|
#relative(samples, placement, timeUtcMs) {
|
|
147
|
-
|
|
145
|
+
const count = samples.timesUtcMs.length;
|
|
146
|
+
if (count === 0)
|
|
148
147
|
return samples.positionsKm;
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
const native = this.body.trajectory.stateAt(samples.timesUtcMs[0]).center;
|
|
149
|
+
const out = new Float64Array(samples.positionsKm.length);
|
|
150
|
+
for (let from = 0; from < count;) {
|
|
151
|
+
const against = lineAgainstAt(this.body.lineFixedTo, samples.timesUtcMs[from], placement.center);
|
|
152
|
+
let to = from + 1;
|
|
153
|
+
while (to < count && lineAgainstAt(this.body.lineFixedTo, samples.timesUtcMs[to], placement.center) === against)
|
|
154
|
+
to += 1;
|
|
155
|
+
const run = { timesUtcMs: samples.timesUtcMs.slice(from, to), positionsKm: samples.positionsKm.subarray(from * 3, to * 3) };
|
|
156
|
+
const drawn = relativeTrailKm(run, native, placement, against);
|
|
157
|
+
const carry = sceneOffsetKm(placement, against, timeUtcMs);
|
|
158
|
+
out.set(carry === null ? drawn : shiftedBy(drawn, carry), from * 3);
|
|
159
|
+
from = to;
|
|
160
|
+
}
|
|
161
|
+
return out;
|
|
153
162
|
}
|
|
154
163
|
/** Writes [leading?] samples [from, to) [trailing?] into the line and sets how much of it is drawn. */
|
|
155
164
|
#fillPath(line, from, to, leading, trailing, origin) {
|
|
@@ -16,6 +16,7 @@ import type { TrackedBody } from "./mission.js";
|
|
|
16
16
|
import type { SkySettings } from "../assets/sky.js";
|
|
17
17
|
import { type BodySetLayer } from "./bodySet.js";
|
|
18
18
|
import type { DisplaySwitchSettings } from "./displaySwitches.js";
|
|
19
|
+
import type { ViewSettings } from "./views.js";
|
|
19
20
|
/** Generic scene parts an experience opts into. Nothing here names a mission. */
|
|
20
21
|
export type SceneLayerId = "tracked-bodies" | "points" | "sun-centred";
|
|
21
22
|
/** What the generic app owns and hands to the experience's factories. */
|
|
@@ -213,6 +214,8 @@ export interface ExperienceDefinition {
|
|
|
213
214
|
readonly switcher?: import("../shell/SwitchControl.js").ExperienceSwitch;
|
|
214
215
|
/** Where the orbit-lines, labels and Milky Way switches show (top bar, switch panel or the Developer drawer only) and whether each starts on. Absent: all in the Developer drawer, the scene's own start. The address (`?labels=`, `?sky=`) still overrides the start. */
|
|
215
216
|
readonly displaySwitches?: DisplaySwitchSettings;
|
|
217
|
+
/** Named views of this one scene (presentation only), resolved once: per view, the object, event and story-panel ids it shows. Anything no view names is in every view. Absent: no views, everything shows. */
|
|
218
|
+
readonly views?: ViewSettings;
|
|
216
219
|
/** Which direction the camera treats as up (default "equatorial", celestial north; "ecliptic" orbits about the ecliptic pole so the planets' plane reads flat). */
|
|
217
220
|
readonly viewUp?: import("./viewUp.js").ViewUp;
|
|
218
221
|
/** The camera view to open on (focus id, azimuth and elevation in degrees, distance in scaled units). Absent: the usual opening. `?view=` overrides it. */
|
package/src/app/mission.d.ts
CHANGED
|
@@ -4,6 +4,19 @@ import type { Provenance } from "../core/provenance.js";
|
|
|
4
4
|
import type { State } from "../core/state.js";
|
|
5
5
|
import type { TimeBounds, Trajectory } from "../core/trajectory.js";
|
|
6
6
|
import type { PathSamples } from "./pathRules.js";
|
|
7
|
+
/** One stretch of a path's line, `[startUtcMs, endUtcMs)` (the last may include its end), drawn against `body`. */
|
|
8
|
+
export interface LineStretch {
|
|
9
|
+
readonly startUtcMs: number;
|
|
10
|
+
readonly endUtcMs: number;
|
|
11
|
+
readonly body: string;
|
|
12
|
+
}
|
|
13
|
+
/** The body a path's line is drawn against at `timeUtcMs`: the one named, the covering stretch's, or `fallback` (the scene centre). A shared boundary belongs to the later stretch. */
|
|
14
|
+
export declare function lineAgainstAt(lineFixedTo: TrackedBody["lineFixedTo"], timeUtcMs: number, fallback: string): string;
|
|
15
|
+
/** Every body a path's line is drawn against, in order, with the `lineFixedTo` index of each (a plain id is index null). */
|
|
16
|
+
export declare function lineBodies(lineFixedTo: TrackedBody["lineFixedTo"]): readonly {
|
|
17
|
+
readonly index: number | null;
|
|
18
|
+
readonly body: string;
|
|
19
|
+
}[];
|
|
7
20
|
/** A bounded trajectory the scene can draw. Nothing here names a mission. */
|
|
8
21
|
export interface TrackedBody {
|
|
9
22
|
readonly id: string;
|
|
@@ -20,8 +33,8 @@ export interface TrackedBody {
|
|
|
20
33
|
readonly anchorLabels?: readonly string[];
|
|
21
34
|
/** Published position discrepancy per reconstruction segment, in time order. */
|
|
22
35
|
readonly positionDiscrepancies?: readonly PositionDiscrepancy[];
|
|
23
|
-
/** The body the line is drawn against, at each sample's own time; absent: the scene centre. */
|
|
24
|
-
readonly lineFixedTo?: string;
|
|
36
|
+
/** The body the line is drawn against, at each sample's own time; absent: the scene centre. A list draws each stretch against its own body (time outside every stretch: the scene centre). */
|
|
37
|
+
readonly lineFixedTo?: string | readonly LineStretch[];
|
|
25
38
|
/** The trajectory's own Provenance, passed through unchanged. */
|
|
26
39
|
readonly provenance?: Provenance;
|
|
27
40
|
}
|