astraeus 0.1.1 → 0.2.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 +23 -0
- package/README.md +39 -6
- package/package.json +9 -6
- package/src/api/AstraeusScene.d.ts +27 -0
- package/src/api/AstraeusScene.js +38 -0
- package/src/api/activity.d.ts +50 -0
- package/src/api/activity.js +62 -0
- package/src/api/bodies.d.ts +24 -0
- package/src/api/bodies.js +24 -0
- package/src/api/errors.d.ts +1 -1
- package/src/api/group.d.ts +83 -0
- package/src/api/group.js +121 -0
- package/src/api/index.d.ts +5 -1
- package/src/api/index.js +2 -1
- package/src/api/mount.d.ts +10 -1
- package/src/api/mount.js +12 -3
- package/src/api/prepared.d.ts +10 -0
- package/src/api/prepared.js +5 -0
- package/src/api/scene.d.ts +121 -8
- package/src/api/scene.js +464 -57
- package/src/api/story.d.ts +63 -0
- package/src/api/story.js +52 -0
- package/src/api/sunOrbit.d.ts +14 -0
- package/src/api/sunOrbit.js +61 -0
- package/src/api/switches.d.ts +14 -0
- package/src/api/switches.js +19 -0
- package/src/api/time.d.ts +4 -0
- package/src/api/time.js +8 -0
- package/src/app/App.js +35 -17
- package/src/app/AstraeusScene.d.ts +1 -1
- package/src/app/DebugOverlay.d.ts +3 -52
- package/src/app/DebugOverlay.js +2 -29
- package/src/app/PanelLoadBoundary.d.ts +18 -0
- package/src/app/PanelLoadBoundary.js +17 -0
- package/src/app/debugReadout.d.ts +53 -0
- package/src/app/debugReadout.js +30 -0
- package/src/app/developerPanels.d.ts +6 -0
- package/src/app/developerPanels.js +11 -0
- package/src/app/displaySwitches.d.ts +54 -0
- package/src/app/displaySwitches.js +48 -0
- package/src/app/experienceDefinition.d.ts +5 -1
- package/src/app/listSwitch.d.ts +16 -0
- package/src/{experiences/showers/showerChoice.js → app/listSwitch.js} +1 -9
- package/src/app/metricReadouts.d.ts +1 -1
- package/src/app/metricReadouts.js +1 -1
- package/src/app/openClock.d.ts +7 -0
- package/src/app/openClock.js +14 -0
- package/src/app/sceneContentsHooks.d.ts +3 -3
- package/src/app/sceneDebug.d.ts +1 -1
- package/src/app/sceneDebug.js +1 -1
- package/src/app/skyModel.js +2 -0
- package/src/app/trackedMetrics.d.ts +53 -0
- package/src/{experiences/apollo11/spacecraftMetrics.js → app/trackedMetrics.js} +40 -56
- package/src/assets/licence.d.ts +1 -0
- package/src/core/bodies/index.d.ts +3 -0
- package/src/core/bodies/index.js +3 -1
- package/src/core/planetSeries.d.ts +2 -0
- package/src/core/planetSeries.js +4 -0
- package/src/core/provenance.d.ts +2 -1
- package/src/core/scalePolicy.d.ts +3 -0
- package/src/core/scalePolicy.js +2 -0
- package/src/core/state.d.ts +1 -0
- package/src/shell/AstraeusShell.d.ts +4 -1
- package/src/shell/AstraeusShell.js +7 -3
- package/src/shell/DisplaySwitches.d.ts +16 -0
- package/src/shell/DisplaySwitches.js +31 -0
- package/src/shell/TimelineBar.css +4 -0
- package/src/shell/TopBar.css +20 -0
- package/src/shell/TopBar.d.ts +4 -1
- package/src/shell/TopBar.js +3 -2
- package/src/shell/experience.d.ts +2 -0
- package/src/shell/phone.css +3 -0
- package/src/shell/topBarIcons.d.ts +1 -0
- package/src/shell/topBarIcons.js +1 -0
- package/src/synthetic/syntheticDefinition.js +3 -3
- package/src/experiences/apollo11/spacecraftMetrics.d.ts +0 -34
- package/src/experiences/showers/showerChoice.d.ts +0 -25
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type TimelineEvent } from "../core/events.js";
|
|
2
|
+
import type { Provenance } from "../core/provenance.js";
|
|
3
|
+
import type { TimeBounds } from "../core/trajectory.js";
|
|
4
|
+
import { type PanelLookup, type StoryPanelSet } from "../shell/storyPanels.js";
|
|
5
|
+
import { type TimeInput } from "./time.js";
|
|
6
|
+
/** A timed event: a labelled moment on the timeline. The id is unique among the scene's events. */
|
|
7
|
+
export interface EventInput {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly label: string;
|
|
10
|
+
readonly time: TimeInput;
|
|
11
|
+
/** A free word the timeline may group by, such as "launch". */
|
|
12
|
+
readonly type?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Options of `addEvents`. */
|
|
15
|
+
export interface AddEventsOptions {
|
|
16
|
+
/** Where the event times come from; shown with every event. */
|
|
17
|
+
readonly provenance?: Provenance;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The timeline. With `start` and `end`: its span, the playback speeds offered (`rates`, simulated seconds per real second) and the speed it opens at
|
|
21
|
+
* (`rate`, default 60). With `none: true`: no timeline at all, so the viewer draws no timeline bar; the time is frozen at `at` (else the time of `setTime`),
|
|
22
|
+
* or, when `rate` is given, runs on from there at that rate.
|
|
23
|
+
*/
|
|
24
|
+
export type TimelineInput = {
|
|
25
|
+
readonly start: TimeInput;
|
|
26
|
+
readonly end: TimeInput;
|
|
27
|
+
readonly rates?: readonly number[];
|
|
28
|
+
readonly rate?: number; /** True: while playing, reaching the end wraps to the start and plays on. The viewer can still seek and pause. Default false. */
|
|
29
|
+
readonly loop?: boolean;
|
|
30
|
+
readonly none?: undefined;
|
|
31
|
+
} | {
|
|
32
|
+
readonly none: true;
|
|
33
|
+
readonly at?: TimeInput;
|
|
34
|
+
readonly rate?: number;
|
|
35
|
+
};
|
|
36
|
+
/** What `setTimeline` was given, checked and converted. */
|
|
37
|
+
export interface TimelineSetting {
|
|
38
|
+
readonly window?: TimeBounds;
|
|
39
|
+
readonly rates?: readonly number[];
|
|
40
|
+
readonly rate?: number;
|
|
41
|
+
/** Playback wraps from the end of the span to its start. */
|
|
42
|
+
readonly loop?: boolean;
|
|
43
|
+
/** No timeline bar. */
|
|
44
|
+
readonly none: boolean;
|
|
45
|
+
/** For no timeline: the moment time is frozen at, or runs on from. */
|
|
46
|
+
readonly atUtcMs?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The raw settings of a scene's story panels: `{ pauseSeconds?, autoOpen?, panels: [{ id, at: { utc } | { event } | { anchor }, title, body, details?, badge, sources, object? }] }`.
|
|
50
|
+
* `badge` is "observed", "modelled" or "illustrative"; `sources` is never empty. A panel's time may name an event of `addEvents` or an anchor of a path, and `object` a
|
|
51
|
+
* body or path of the scene; these are checked when the scene is turned into a definition (mount), and a mistake throws `bad-panels` naming the panel and field.
|
|
52
|
+
*/
|
|
53
|
+
export interface StoryPanelsInput {
|
|
54
|
+
readonly pauseSeconds?: number;
|
|
55
|
+
readonly autoOpen?: boolean;
|
|
56
|
+
readonly panels: readonly unknown[];
|
|
57
|
+
}
|
|
58
|
+
/** The events merged with `inputs`, sorted by time; each needs a distinct non-empty id and label and a valid moment. */
|
|
59
|
+
export declare function eventsOf(inputs: readonly EventInput[], known: readonly TimelineEvent[]): readonly TimelineEvent[];
|
|
60
|
+
/** Checks a `setTimeline` argument and converts its moments. */
|
|
61
|
+
export declare function timelineOf(input: TimelineInput): TimelineSetting;
|
|
62
|
+
/** The story panels resolved against the scene's events, anchors, objects and window; a mistake becomes a `bad-panels` SceneError. */
|
|
63
|
+
export declare function panelsOf(raw: StoryPanelsInput, lookup: PanelLookup): StoryPanelSet;
|
package/src/api/story.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createEvents } from "../core/events.js";
|
|
2
|
+
import { parseStoryPanels, StoryPanelError } from "../shell/storyPanels.js";
|
|
3
|
+
import { SceneError } from "./errors.js";
|
|
4
|
+
import { toUtcMs } from "./time.js";
|
|
5
|
+
/** The events merged with `inputs`, sorted by time; each needs a distinct non-empty id and label and a valid moment. */
|
|
6
|
+
export function eventsOf(inputs, known) {
|
|
7
|
+
if (!Array.isArray(inputs))
|
|
8
|
+
throw new SceneError("bad-event", "addEvents: events must be a list");
|
|
9
|
+
const ids = new Set(known.map((event) => event.id));
|
|
10
|
+
const added = inputs.map((input) => {
|
|
11
|
+
if (typeof input?.id !== "string" || input.id === "")
|
|
12
|
+
throw new SceneError("bad-event", "addEvents: every event needs a non-empty id");
|
|
13
|
+
if (typeof input.label !== "string" || input.label === "")
|
|
14
|
+
throw new SceneError("bad-event", `addEvents: event "${input.id}" needs a non-empty label`);
|
|
15
|
+
if (ids.has(input.id))
|
|
16
|
+
throw new SceneError("bad-event", `addEvents: event "${input.id}" appears twice`);
|
|
17
|
+
ids.add(input.id);
|
|
18
|
+
const timeUtcMs = toUtcMs(input.time, `addEvents: event "${input.id}" time`);
|
|
19
|
+
return { id: input.id, label: input.label, timeUtcMs, ...(input.type === undefined ? {} : { type: input.type }) };
|
|
20
|
+
});
|
|
21
|
+
return createEvents([...known, ...added].sort((a, b) => a.timeUtcMs - b.timeUtcMs));
|
|
22
|
+
}
|
|
23
|
+
/** Checks a `setTimeline` argument and converts its moments. */
|
|
24
|
+
export function timelineOf(input) {
|
|
25
|
+
const bad = (message) => new SceneError("bad-timeline", `setTimeline: ${message}`);
|
|
26
|
+
if (typeof input !== "object" || input === null)
|
|
27
|
+
throw bad("give an object such as { start, end } or { none: true }");
|
|
28
|
+
if (input.rate !== undefined && !(Number.isFinite(input.rate) && input.rate !== 0))
|
|
29
|
+
throw bad(`rate must be a finite, non-zero number, got ${String(input.rate)}`);
|
|
30
|
+
if (input.loop !== undefined && typeof input.loop !== "boolean")
|
|
31
|
+
throw bad("loop must be true or false");
|
|
32
|
+
if (input.none === true)
|
|
33
|
+
return { none: true, ...(input.at === undefined ? {} : { atUtcMs: toUtcMs(input.at, "setTimeline at") }), ...(input.rate === undefined ? {} : { rate: input.rate }) };
|
|
34
|
+
const window = { startUtcMs: toUtcMs(input.start, "setTimeline start"), endUtcMs: toUtcMs(input.end, "setTimeline end") };
|
|
35
|
+
if (window.endUtcMs <= window.startUtcMs)
|
|
36
|
+
throw bad("end must be after start");
|
|
37
|
+
const rates = input.rates;
|
|
38
|
+
if (rates !== undefined && (!Array.isArray(rates) || rates.length === 0 || !rates.every((rate) => Number.isFinite(rate) && rate > 0)))
|
|
39
|
+
throw bad("rates must be a non-empty list of positive numbers");
|
|
40
|
+
return { none: false, window, ...(rates === undefined ? {} : { rates }), ...(input.rate === undefined ? {} : { rate: input.rate }), ...(input.loop === true ? { loop: true } : {}) };
|
|
41
|
+
}
|
|
42
|
+
/** The story panels resolved against the scene's events, anchors, objects and window; a mistake becomes a `bad-panels` SceneError. */
|
|
43
|
+
export function panelsOf(raw, lookup) {
|
|
44
|
+
try {
|
|
45
|
+
return parseStoryPanels(raw, lookup);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof StoryPanelError)
|
|
49
|
+
throw new SceneError("bad-panels", `addStoryPanels: ${error.message}`);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BodyId } from "../core/body.js";
|
|
2
|
+
import { type EccentricSampling } from "../core/sunCentredSources.js";
|
|
3
|
+
import { type BodyCatalogue } from "../assets/catalogue.js";
|
|
4
|
+
import type { PathLayer } from "../app/experienceDefinition.js";
|
|
5
|
+
/** The id of a body's Sun-orbit line. */
|
|
6
|
+
export declare const sunOrbitIdOf: (id: BodyId) => string;
|
|
7
|
+
/** Whether the catalogue holds this body and it circles the Sun (the catalogue's root). */
|
|
8
|
+
export declare function circlesTheSun(catalogue: BodyCatalogue, id: BodyId): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The orbit line of a body that circles the Sun: one full turn from `startUtcMs`, from the body's own state source. A body given published elements
|
|
11
|
+
* (`sampling`) is drawn from its periapsis for one period with samples spaced by eccentric anomaly, so a sharp orbit is smooth. Returns undefined when
|
|
12
|
+
* the body completes no turn within the search (a comet's century-long orbit given without elements).
|
|
13
|
+
*/
|
|
14
|
+
export declare function sunOrbitLayer(catalogue: BodyCatalogue, id: BodyId, startUtcMs: number, color: string, given?: EccentricSampling): PathLayer | undefined;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
2
|
+
import { BUILT_IN_SAMPLING, EARTH_EPHEMERIS } from "../core/bodies/index.js";
|
|
3
|
+
import { createEarthSunTrajectory, fullTurnSpanMs } from "../core/sunCentredSources.js";
|
|
4
|
+
import { rootBodyId } from "../assets/catalogue.js";
|
|
5
|
+
const DAY_MS = 86_400_000;
|
|
6
|
+
/** The turn search walks in two-day steps; the longest orbit among the planets is a dozen years. */
|
|
7
|
+
const TURN_STEP_MS = 2 * DAY_MS;
|
|
8
|
+
const TURN_MAX_STEPS = 3_000;
|
|
9
|
+
const TURN_SAMPLES = 361;
|
|
10
|
+
/** The id of a body's Sun-orbit line. */
|
|
11
|
+
export const sunOrbitIdOf = (id) => `${id}-orbit`;
|
|
12
|
+
/** Whether the catalogue holds this body and it circles the Sun (the catalogue's root). */
|
|
13
|
+
export function circlesTheSun(catalogue, id) {
|
|
14
|
+
return catalogue.has(id) && catalogue.get(id).definition.parentId === rootBodyId(catalogue);
|
|
15
|
+
}
|
|
16
|
+
function trajectoryOf(catalogue, id) {
|
|
17
|
+
const adapter = createOrbAstronomyAdapter();
|
|
18
|
+
return id === "earth" ? createEarthSunTrajectory(adapter) : catalogue.get(id).source.create(adapter);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The orbit line of a body that circles the Sun: one full turn from `startUtcMs`, from the body's own state source. A body given published elements
|
|
22
|
+
* (`sampling`) is drawn from its periapsis for one period with samples spaced by eccentric anomaly, so a sharp orbit is smooth. Returns undefined when
|
|
23
|
+
* the body completes no turn within the search (a comet's century-long orbit given without elements).
|
|
24
|
+
*/
|
|
25
|
+
export function sunOrbitLayer(catalogue, id, startUtcMs, color, given) {
|
|
26
|
+
const sampling = given ?? BUILT_IN_SAMPLING[id];
|
|
27
|
+
const { definition, visual } = catalogue.get(id);
|
|
28
|
+
const source = trajectoryOf(catalogue, id);
|
|
29
|
+
const span = sampling === undefined ? turnSpan(source, startUtcMs) : { startUtcMs: sampling.periapsisUtcMs, endUtcMs: sampling.periapsisUtcMs + Math.round(sampling.periodMs) };
|
|
30
|
+
if (span === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const provenance = id === "earth" ? EARTH_EPHEMERIS.provenance : definition.accuracy.position;
|
|
33
|
+
return {
|
|
34
|
+
kind: "orbit",
|
|
35
|
+
color: color || visual.material.color,
|
|
36
|
+
source,
|
|
37
|
+
span,
|
|
38
|
+
...(sampling === undefined ? { samples: TURN_SAMPLES } : { sampling }),
|
|
39
|
+
object: {
|
|
40
|
+
id: sunOrbitIdOf(id),
|
|
41
|
+
partOf: id,
|
|
42
|
+
label: `${definition.label}'s orbit`,
|
|
43
|
+
color: color || visual.material.color,
|
|
44
|
+
labelPriority: 50,
|
|
45
|
+
showLabel: false,
|
|
46
|
+
description: `${definition.label}'s path round the Sun for one full turn, drawn from the same position source that places ${definition.label}.`,
|
|
47
|
+
provenance,
|
|
48
|
+
knownLimitations: [sampling === undefined ? "A turn's samples joined by straight segments." : "One full turn of unperturbed two-body motion from periapsis; samples are spaced by eccentric anomaly and joined by straight segments."],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function turnSpan(source, startUtcMs) {
|
|
53
|
+
try {
|
|
54
|
+
return { startUtcMs, endUtcMs: startUtcMs + fullTurnSpanMs(source, startUtcMs, TURN_STEP_MS, TURN_MAX_STEPS) };
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof RangeError && /no full turn/.test(error.message))
|
|
58
|
+
return undefined;
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DisplaySwitchId, type DisplaySwitchPlace, type DisplaySwitchSettings } from "../app/displaySwitches.js";
|
|
2
|
+
/**
|
|
3
|
+
* Where each display switch shows, and whether it starts on. `orbitLines` is the orbit ring, the trailing arc and the moon orbits as one switch; `labels` is body labels and
|
|
4
|
+
* anchor labels; `milkyWay` is the sky picture. `place` is `"top-bar"` (a button in the bar), `"panel"` (a row in one switch panel opened from the bar) or `"developer"`
|
|
5
|
+
* (only in the Developer drawer, where every switch stays). `on` is the starting state (default on).
|
|
6
|
+
*/
|
|
7
|
+
export type SwitchesInput = {
|
|
8
|
+
readonly [id in DisplaySwitchId]?: {
|
|
9
|
+
readonly place: DisplaySwitchPlace;
|
|
10
|
+
readonly on?: boolean;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/** Checks a `setSwitches` argument against the switch names and places; returns the settings laid over the ones already set. */
|
|
14
|
+
export declare function switchesOf(input: SwitchesInput, known?: DisplaySwitchSettings): DisplaySwitchSettings;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DISPLAY_SWITCH_IDS, DISPLAY_SWITCH_PLACES } from "../app/displaySwitches.js";
|
|
2
|
+
import { SceneError } from "./errors.js";
|
|
3
|
+
/** Checks a `setSwitches` argument against the switch names and places; returns the settings laid over the ones already set. */
|
|
4
|
+
export function switchesOf(input, known = {}) {
|
|
5
|
+
const bad = (message) => new SceneError("bad-switch", `setSwitches: ${message}`);
|
|
6
|
+
if (typeof input !== "object" || input === null || Array.isArray(input))
|
|
7
|
+
throw bad(`give an object such as { orbitLines: { place: "top-bar" } } (switches: ${DISPLAY_SWITCH_IDS.join(", ")})`);
|
|
8
|
+
const settings = { ...known };
|
|
9
|
+
for (const [id, setting] of Object.entries(input)) {
|
|
10
|
+
if (!DISPLAY_SWITCH_IDS.includes(id))
|
|
11
|
+
throw bad(`"${id}" is not a switch (known: ${DISPLAY_SWITCH_IDS.join(", ")})`);
|
|
12
|
+
if (typeof setting !== "object" || setting === null || !DISPLAY_SWITCH_PLACES.includes(setting.place))
|
|
13
|
+
throw bad(`${id}.place must be one of ${DISPLAY_SWITCH_PLACES.join(", ")}, got ${JSON.stringify(setting?.place)}`);
|
|
14
|
+
if (setting.on !== undefined && typeof setting.on !== "boolean")
|
|
15
|
+
throw bad(`${id}.on must be true or false, got ${JSON.stringify(setting.on)}`);
|
|
16
|
+
settings[id] = { place: setting.place, ...(setting.on === undefined ? {} : { on: setting.on }) };
|
|
17
|
+
}
|
|
18
|
+
return settings;
|
|
19
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A moment: ISO text, a Date, or Unix milliseconds. */
|
|
2
|
+
export type TimeInput = string | number | Date;
|
|
3
|
+
/** Converts a moment to Unix milliseconds, or throws a `bad-time` SceneError naming it. */
|
|
4
|
+
export declare function toUtcMs(time: TimeInput, what?: string): number;
|
package/src/api/time.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SceneError } from "./errors.js";
|
|
2
|
+
/** Converts a moment to Unix milliseconds, or throws a `bad-time` SceneError naming it. */
|
|
3
|
+
export function toUtcMs(time, what = "time") {
|
|
4
|
+
const ms = time instanceof Date ? time.getTime() : typeof time === "number" ? time : Date.parse(time);
|
|
5
|
+
if (!Number.isFinite(ms))
|
|
6
|
+
throw new SceneError("bad-time", `${what} "${String(time)}" is not a valid moment; use an ISO text such as "1969-07-20T20:17:40Z", a Date or Unix milliseconds`);
|
|
7
|
+
return ms;
|
|
8
|
+
}
|
package/src/app/App.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Suspense, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { createOrbAstronomyAdapter } from "../core/astronomyAdapter.js";
|
|
4
4
|
import { viewUpFromSearch, viewUpVector } from "./viewUp.js";
|
|
5
|
-
import {
|
|
5
|
+
import { openClock } from "./openClock.js";
|
|
6
6
|
import { createSolarSystemScale } from "../core/scalePolicy.js";
|
|
7
7
|
import { bodySetsOf, cameraReachOf, catalogueOf, compositionOf, experienceWithGroups, groupsOf, initialObjectIdOf, mountedBodiesOf, pageTitleOf, scaleChoiceIdsOf, sceneCenterOf, sunCentredOf, trackedBodiesOf, visualOverridesOf } from "./experienceDefinition.js";
|
|
8
8
|
import { AstraeusShell } from "../shell/AstraeusShell.js";
|
|
9
9
|
import { scaleChoicesFor, scalePolicyFor, startScaleFor } from "../shell/scaleModel.js";
|
|
10
10
|
import { scaleFromSearch, timeFromSearch, viewFromSearch, shareViewLink } from "./viewLink.js";
|
|
11
11
|
import { Collapsible } from "../shell/Collapsible.js";
|
|
12
|
+
import { PanelLoadBoundary } from "./PanelLoadBoundary.js";
|
|
12
13
|
import { BOOT_FADE_LIMITS, bootFadeSeconds, saveBootFadeSeconds } from "../shell/bootLoader.js";
|
|
13
|
-
import { LabelSettings, UnderTheHoodSettings, ViewLinkReadout, MoonsAndRingsSettings, SkyAndSunSettings, StoryPanelSettings } from "./
|
|
14
|
+
import { LabelSettings, UnderTheHoodSettings, ViewLinkReadout, MoonsAndRingsSettings, SkyAndSunSettings, StoryPanelSettings } from "./developerPanels.js";
|
|
14
15
|
import { DEFAULT_ILLUMINATE_ALL } from "./lighting.js";
|
|
15
16
|
import { SettingButtons, SettingColor, SettingGroup, SettingSlider } from "./SettingControls.js";
|
|
16
17
|
import { DEFAULT_TIMELINE_GLOW } from "../shell/timelineGlow.js";
|
|
@@ -24,6 +25,7 @@ import { loadStarCatalogue } from "../assets/sky.js";
|
|
|
24
25
|
import { resolveSkySettings, withSkyObject } from "./skyModel.js";
|
|
25
26
|
import { ORBIT_LOOK_LIMITS, resolveOrbitLook } from "../assets/orbitLook.js";
|
|
26
27
|
import { DEFAULT_BODY_SET_LOOK } from "./bodySet.js";
|
|
28
|
+
import { displaySwitchItems, orbitStart } from "./displaySwitches.js";
|
|
27
29
|
import { baseGlowOf, glowLookFromSearch, markerSettingsFromSearch } from "./bodyDraw.js";
|
|
28
30
|
import { brightnessFromSearch, milkyWayFromSearch, skyHiddenBySearch } from "./SkyView.js";
|
|
29
31
|
/** Frames-per-second readings kept for the graph: one per 250 ms poll, so about 15 seconds. */
|
|
@@ -31,7 +33,7 @@ const FPS_HISTORY = 60;
|
|
|
31
33
|
/** The sky settings in force: the experience's own, hidden when the address says `?sky=off`. */
|
|
32
34
|
function skySettingsOf(definition) {
|
|
33
35
|
const settings = resolveSkySettings(definition.sky);
|
|
34
|
-
const milkyWay = milkyWayFromSearch(window.location.search) ?? settings.milkyWay;
|
|
36
|
+
const milkyWay = milkyWayFromSearch(window.location.search) ?? definition.displaySwitches?.milkyWay?.on ?? settings.milkyWay;
|
|
35
37
|
const starBrightness = brightnessFromSearch(window.location.search, "stars") ?? settings.starBrightness;
|
|
36
38
|
const milkyWayBrightness = brightnessFromSearch(window.location.search, "milkywaybrightness") ?? settings.milkyWayBrightness;
|
|
37
39
|
return { ...settings, milkyWay, starBrightness, milkyWayBrightness, visible: settings.visible && !skyHiddenBySearch(window.location.search) };
|
|
@@ -55,6 +57,15 @@ export function loopFromSearch(search, fallback) {
|
|
|
55
57
|
const value = new URLSearchParams(search).get("loop");
|
|
56
58
|
return value === "on" ? true : value === "off" ? false : fallback;
|
|
57
59
|
}
|
|
60
|
+
/** The labels switch's starting state, if the story gave one. */
|
|
61
|
+
function labelStart(definition) {
|
|
62
|
+
return definition.displaySwitches?.labels?.on;
|
|
63
|
+
}
|
|
64
|
+
/** The orbit lines a story starts off: the ring and arc, and the moon orbits. */
|
|
65
|
+
function startOrbitControls(definition) {
|
|
66
|
+
const start = orbitStart(definition.displaySwitches?.orbitLines);
|
|
67
|
+
return start === undefined ? {} : { orbitLook: start.look, bodySetLook: { ...DEFAULT_BODY_SET_LOOK, orbitsOn: false } };
|
|
68
|
+
}
|
|
58
69
|
function copyOfGlow(look) {
|
|
59
70
|
return look === undefined ? null : { ...look };
|
|
60
71
|
}
|
|
@@ -74,13 +85,8 @@ function switcherOf(definition, runtime, open) {
|
|
|
74
85
|
/** Everything one mounted experience shares: clock, resolver, catalogue and the settings read from its definition and the address. */
|
|
75
86
|
function buildRuntime(definition) {
|
|
76
87
|
const adapter = createOrbAstronomyAdapter();
|
|
77
|
-
const clock = new SimulationClock(definition.clock.startUtcMs);
|
|
78
|
-
clock.setRate(definition.clock.rate);
|
|
79
88
|
// A copied view link carries the time it was copied at.
|
|
80
|
-
const
|
|
81
|
-
if (linkedTime !== undefined)
|
|
82
|
-
clock.seek(linkedTime);
|
|
83
|
-
clock.play();
|
|
89
|
+
const clock = openClock(definition, timeFromSearch(window.location.search));
|
|
84
90
|
// One resolver per mount: every position in the scene comes from it, whatever the scene centre.
|
|
85
91
|
const resolver = createSceneResolver(adapter, catalogueOf(definition));
|
|
86
92
|
return {
|
|
@@ -115,7 +121,7 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
|
|
|
115
121
|
return {
|
|
116
122
|
policy: scalePolicyFor(startScale, suppliedPolicies),
|
|
117
123
|
cameraRequest: null,
|
|
118
|
-
showAnchorLabels:
|
|
124
|
+
showAnchorLabels: labelStart(definition) === true && runtime.trackedBodies.length > 0,
|
|
119
125
|
loop: loopFromSearch(search, definition.loop === true),
|
|
120
126
|
up: viewUpVector(startViewUp(definition)),
|
|
121
127
|
showMilkyWay: runtime.sky.milkyWay,
|
|
@@ -124,7 +130,8 @@ function initialSceneControls(definition, runtime, experience, startScale, glowB
|
|
|
124
130
|
starBrightness: runtime.sky.starBrightness,
|
|
125
131
|
milkyWayBrightness: runtime.sky.milkyWayBrightness,
|
|
126
132
|
illuminateAll: DEFAULT_ILLUMINATE_ALL,
|
|
127
|
-
hiddenLabels: hiddenLabelsFrom(search, experience.objects),
|
|
133
|
+
hiddenLabels: hiddenLabelsFrom(search, labelStart(definition) === undefined ? experience.objects : experience.objects.map(({ id }) => ({ id, showLabel: labelStart(definition) }))),
|
|
134
|
+
...startOrbitControls(definition),
|
|
128
135
|
labelObjects: experience.objects,
|
|
129
136
|
storyMarkers,
|
|
130
137
|
featureMarkers: featureMarkerSpecs(definition.experience.bodyFeatures),
|
|
@@ -178,18 +185,18 @@ export function App({ definition, onOpenAddress }) {
|
|
|
178
185
|
const [developerMode, setDeveloperMode] = useState(false);
|
|
179
186
|
const [timelineGlow, setTimelineGlow] = useState(DEFAULT_TIMELINE_GLOW);
|
|
180
187
|
const [phoneLayout, setPhoneLayout] = useState(DEFAULT_PHONE_LAYOUT);
|
|
181
|
-
const [anchorLabels, setAnchorLabels] = useState(
|
|
188
|
+
const [anchorLabels, setAnchorLabels] = useState(controls.current.showAnchorLabels);
|
|
182
189
|
const [glowShown, setGlowShown] = useState(copyOfGlow(controls.current.glowLook));
|
|
183
190
|
const orbitPaths = orbitPathsOf(runtime);
|
|
184
191
|
const orbitDefault = useMemo(() => resolveOrbitLook(orbitPaths[0]?.look), [orbitPaths]);
|
|
185
|
-
const [orbitShown, setOrbitShown] = useState(orbitDefault);
|
|
192
|
+
const [orbitShown, setOrbitShown] = useState({ ...orbitDefault, ...controls.current.orbitLook });
|
|
186
193
|
const setOrbit = (change) => {
|
|
187
194
|
controls.current.orbitLook = { ...controls.current.orbitLook, ...change };
|
|
188
195
|
setOrbitShown({ ...orbitDefault, ...controls.current.orbitLook });
|
|
189
196
|
};
|
|
190
197
|
const resetOrbit = () => { delete controls.current.orbitLook; setOrbitShown(orbitDefault); };
|
|
191
198
|
const bodySets = runtime.bodySets;
|
|
192
|
-
const [setLook, setSetLook] = useState(DEFAULT_BODY_SET_LOOK);
|
|
199
|
+
const [setLook, setSetLook] = useState(controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK);
|
|
193
200
|
const changeSetLook = (change) => {
|
|
194
201
|
const next = { ...(controls.current.bodySetLook ?? DEFAULT_BODY_SET_LOOK), ...change };
|
|
195
202
|
controls.current.bodySetLook = next;
|
|
@@ -287,6 +294,17 @@ export function App({ definition, onOpenAddress }) {
|
|
|
287
294
|
return;
|
|
288
295
|
setViewLink(await shareViewLink({ view, scaleId: scale, up: upChoice, timeUtcMs: runtime.clock.snapshot().timeUtcMs }));
|
|
289
296
|
};
|
|
297
|
+
const displaySwitches = displaySwitchItems({
|
|
298
|
+
settings: definition.displaySwitches,
|
|
299
|
+
orbit: { present: orbitPaths.length > 0, look: orbitShown, set: setOrbit },
|
|
300
|
+
moons: { present: bodySets.length > 0, look: setLook, set: changeSetLook },
|
|
301
|
+
sky: { present: runtime.sky.visible, on: milkyWayOn, set: (on) => { controls.current.showMilkyWay = on; setMilkyWayOn(on); } },
|
|
302
|
+
labels: {
|
|
303
|
+
objectIds: experience.objects.map((object) => object.id), hidden: hiddenLabels,
|
|
304
|
+
setHidden: (hidden) => { controls.current.hiddenLabels = new Set(hidden); setHiddenLabels(new Set(hidden)); },
|
|
305
|
+
anchorsPresent: runtime.trackedBodies.length > 0, anchors: anchorLabels, setAnchors: (on) => { controls.current.showAnchorLabels = on; setAnchorLabels(on); },
|
|
306
|
+
},
|
|
307
|
+
});
|
|
290
308
|
const sections = definition.developerSections ?? [];
|
|
291
309
|
const renderSection = (section) => (_jsxs("section", { className: section.id === "clock" ? "hud-section hud-section-clock" : "hud-section", "aria-labelledby": `developer-${section.id}-heading`, children: [_jsx("h3", { id: `developer-${section.id}-heading`, children: section.heading }), section.render(experienceRuntime)] }, section.id));
|
|
292
310
|
const hasStoryPanels = (storySet?.panels.length ?? 0) > 0;
|
|
@@ -362,7 +380,7 @@ export function App({ definition, onOpenAddress }) {
|
|
|
362
380
|
},
|
|
363
381
|
];
|
|
364
382
|
const presentGroups = groups.filter((group) => group !== null);
|
|
365
|
-
const developerTools = (_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, { id: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }));
|
|
383
|
+
const developerTools = (_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, { id: group.id, title: group.title, defaultOpen: index === 0, className: `dev-group${group.className === undefined ? "" : ` ${group.className}`}`, children: group.body }, group.id)))] }) }) }));
|
|
366
384
|
return (_jsx(AstraeusShell, { experience: shellExperience, snapshot: clockSnapshot, developerMode: developerMode, onDeveloperModeChange: setDeveloperMode, onTogglePlayback: () => {
|
|
367
385
|
if (runtime.clock.playing)
|
|
368
386
|
runtime.clock.pause();
|
|
@@ -375,5 +393,5 @@ export function App({ definition, onOpenAddress }) {
|
|
|
375
393
|
}, onSeek: (timeUtcMs) => {
|
|
376
394
|
runtime.clock.seek(timeUtcMs);
|
|
377
395
|
setClockSnapshot(runtime.clock.snapshot());
|
|
378
|
-
}, onCameraRequest: updateCameraRequest, onSelectionChange: updateSelectedObject, scaleId: scale, onScaleChange: updateScale, scaleChoices: scaleChoices, switcher: switcherOf(definition, runtime, onOpenAddress), 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 }) }) }));
|
|
396
|
+
}, 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 }) }) }));
|
|
379
397
|
}
|
|
@@ -7,7 +7,7 @@ import type { SystemComposition } from "../assets/compositions.js";
|
|
|
7
7
|
import { type BodyMarkerSettings, type GlowLook } from "./bodyDraw.js";
|
|
8
8
|
import type { OrbitLook } from "../assets/orbitLook.js";
|
|
9
9
|
import { type CameraRequest } from "./CameraController.js";
|
|
10
|
-
import type { DebugReadout } from "./
|
|
10
|
+
import type { DebugReadout } from "./debugReadout.js";
|
|
11
11
|
import { type CameraReach, type GroupLayer, type PathLayer, type SunBody, type VisualOverride } from "./experienceDefinition.js";
|
|
12
12
|
import type { TrackedBody } from "./mission.js";
|
|
13
13
|
import type { RenderVector } from "./renderCoordinates.js";
|
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ScalePolicy } from "../core/scalePolicy.js";
|
|
3
|
-
import type { FloatingOrigin } from "./floatingOrigin.js";
|
|
4
|
-
import type { PlacedState } from "./sceneLayout.js";
|
|
1
|
+
import { type DebugReadout } from "./debugReadout.js";
|
|
5
2
|
export { formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
6
|
-
|
|
7
|
-
type
|
|
8
|
-
/** Diagnostic snapshot. Scientific fields never depend on the scale policy; render fields do. */
|
|
9
|
-
export interface DebugReadout {
|
|
10
|
-
readonly timeUtcMs: number;
|
|
11
|
-
readonly rate: number;
|
|
12
|
-
readonly policyId: ScalePolicy["id"];
|
|
13
|
-
readonly moonPosition: {
|
|
14
|
-
readonly frame: string;
|
|
15
|
-
readonly center: string;
|
|
16
|
-
readonly units: "km";
|
|
17
|
-
readonly positionKm: Triple;
|
|
18
|
-
};
|
|
19
|
-
readonly moonDistanceKm: number;
|
|
20
|
-
/** Earth–Moon distance in scene units (Earth radii) from the same mapping that places the bodies. */
|
|
21
|
-
readonly renderedDistanceUnits: number;
|
|
22
|
-
readonly earthOrientation: Quad | null;
|
|
23
|
-
readonly moonOrientation: Quad | null;
|
|
24
|
-
readonly earthSunDirection: Triple;
|
|
25
|
-
readonly moonSunDirection: Triple;
|
|
26
|
-
/** Fraction of the child's disc lit, seen from the parent's centre (any satellite pair, not only the Moon). */
|
|
27
|
-
readonly lunarIlluminatedFraction: number;
|
|
28
|
-
/** Labels of the measured pair; absent means Earth and Moon. */
|
|
29
|
-
readonly pair?: PairLabels;
|
|
30
|
-
readonly scaledOrigin: Triple;
|
|
31
|
-
readonly earthLocal: Triple;
|
|
32
|
-
readonly moonLocal: Triple;
|
|
33
|
-
}
|
|
34
|
-
/** Display names of the pair the readout measures. */
|
|
35
|
-
export interface PairLabels {
|
|
36
|
-
readonly parent: string;
|
|
37
|
-
readonly child: string;
|
|
38
|
-
}
|
|
39
|
-
export declare const EARTH_MOON_LABELS: PairLabels;
|
|
40
|
-
export interface DebugReadoutInput {
|
|
41
|
-
readonly pair?: PairLabels;
|
|
42
|
-
readonly timeUtcMs: number;
|
|
43
|
-
readonly rate: number;
|
|
44
|
-
readonly policy: ScalePolicy;
|
|
45
|
-
readonly earth: State;
|
|
46
|
-
readonly moonFromEarth: State;
|
|
47
|
-
readonly sunFromEarth: CenteredPosition;
|
|
48
|
-
readonly placed: PlacedState;
|
|
49
|
-
readonly renderedDistanceUnits: number;
|
|
50
|
-
readonly origin: FloatingOrigin;
|
|
51
|
-
}
|
|
52
|
-
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
53
|
-
export declare function buildDebugReadout(input: DebugReadoutInput): DebugReadout;
|
|
3
|
+
export { buildDebugReadout, EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
4
|
+
export type { DebugReadout, DebugReadoutInput, PairLabels } from "./debugReadout.js";
|
|
54
5
|
/** Ordered label/value rows; kept separate from JSX so tests can read what the overlay shows. */
|
|
55
6
|
export declare function overlayRows(r: DebugReadout): ReadonlyArray<readonly [string, string]>;
|
|
56
7
|
export declare function DebugOverlay({ readout }: {
|
package/src/app/DebugOverlay.js
CHANGED
|
@@ -1,37 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { directionFromCenterToSun, directionToSun, illuminatedFraction } from "../core/illumination.js";
|
|
3
2
|
import { describePlaybackRate, formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
4
3
|
import { MetricVisual } from "../shell/MetricVisual.js";
|
|
5
4
|
import { sceneMetrics } from "./metricReadouts.js";
|
|
5
|
+
import { EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
6
6
|
export { formatUtcTimestamp } from "../shell/timelineModel.js";
|
|
7
|
-
export
|
|
8
|
-
const triple = (v) => [v[0], v[1], v[2]];
|
|
9
|
-
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
10
|
-
export function buildDebugReadout(input) {
|
|
11
|
-
const { moonFromEarth, sunFromEarth, origin, placed } = input;
|
|
12
|
-
return {
|
|
13
|
-
timeUtcMs: input.timeUtcMs,
|
|
14
|
-
rate: input.rate,
|
|
15
|
-
policyId: input.policy.id,
|
|
16
|
-
...(input.pair === undefined ? {} : { pair: input.pair }),
|
|
17
|
-
moonPosition: {
|
|
18
|
-
frame: moonFromEarth.frame,
|
|
19
|
-
center: moonFromEarth.center,
|
|
20
|
-
units: "km",
|
|
21
|
-
positionKm: triple(moonFromEarth.positionKm),
|
|
22
|
-
},
|
|
23
|
-
moonDistanceKm: Math.hypot(...triple(moonFromEarth.positionKm)),
|
|
24
|
-
renderedDistanceUnits: input.renderedDistanceUnits,
|
|
25
|
-
earthOrientation: input.earth.orientation,
|
|
26
|
-
moonOrientation: moonFromEarth.orientation,
|
|
27
|
-
earthSunDirection: triple(directionFromCenterToSun(sunFromEarth)),
|
|
28
|
-
moonSunDirection: triple(directionToSun(moonFromEarth, sunFromEarth)),
|
|
29
|
-
lunarIlluminatedFraction: illuminatedFraction(moonFromEarth, sunFromEarth),
|
|
30
|
-
scaledOrigin: triple(origin.scaledCameraOrigin),
|
|
31
|
-
earthLocal: triple(origin.toLocal(placed.earthAbsolute)),
|
|
32
|
-
moonLocal: triple(origin.toLocal(placed.moonAbsolute)),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
7
|
+
export { buildDebugReadout, EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
35
8
|
const vec = (v, digits) => `(${v.map((c) => c.toFixed(digits)).join(", ")})`;
|
|
36
9
|
/** Ordered label/value rows; kept separate from JSX so tests can read what the overlay shows. */
|
|
37
10
|
export function overlayRows(r) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Catches a failed on-demand load of the developer panels (offline, or a tab left open across a redeploy) so the
|
|
4
|
+
* rest of the app keeps drawing; React.lazy keeps the failed load, so the message asks for a reload.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PanelLoadBoundary extends Component<{
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}, {
|
|
9
|
+
failed: boolean;
|
|
10
|
+
}> {
|
|
11
|
+
state: {
|
|
12
|
+
failed: boolean;
|
|
13
|
+
};
|
|
14
|
+
static getDerivedStateFromError(): {
|
|
15
|
+
failed: boolean;
|
|
16
|
+
};
|
|
17
|
+
render(): ReactNode;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Catches a failed on-demand load of the developer panels (offline, or a tab left open across a redeploy) so the
|
|
5
|
+
* rest of the app keeps drawing; React.lazy keeps the failed load, so the message asks for a reload.
|
|
6
|
+
*/
|
|
7
|
+
export class PanelLoadBoundary extends Component {
|
|
8
|
+
state = { failed: false };
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
return { failed: true };
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
if (this.state.failed)
|
|
14
|
+
return _jsx("p", { className: "developer-loading", role: "alert", children: "Developer tools could not load. Reload the page to try again." });
|
|
15
|
+
return this.props.children;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CenteredPosition, State } from "../core/state.js";
|
|
2
|
+
import type { ScalePolicy } from "../core/scalePolicy.js";
|
|
3
|
+
import type { FloatingOrigin } from "./floatingOrigin.js";
|
|
4
|
+
import type { PlacedState } from "./sceneLayout.js";
|
|
5
|
+
type Triple = readonly [number, number, number];
|
|
6
|
+
type Quad = readonly [number, number, number, number];
|
|
7
|
+
/** Diagnostic snapshot. Scientific fields never depend on the scale policy; render fields do. */
|
|
8
|
+
export interface DebugReadout {
|
|
9
|
+
readonly timeUtcMs: number;
|
|
10
|
+
readonly rate: number;
|
|
11
|
+
readonly policyId: ScalePolicy["id"];
|
|
12
|
+
readonly moonPosition: {
|
|
13
|
+
readonly frame: string;
|
|
14
|
+
readonly center: string;
|
|
15
|
+
readonly units: "km";
|
|
16
|
+
readonly positionKm: Triple;
|
|
17
|
+
};
|
|
18
|
+
readonly moonDistanceKm: number;
|
|
19
|
+
/** Earth–Moon distance in scene units (Earth radii) from the same mapping that places the bodies. */
|
|
20
|
+
readonly renderedDistanceUnits: number;
|
|
21
|
+
readonly earthOrientation: Quad | null;
|
|
22
|
+
readonly moonOrientation: Quad | null;
|
|
23
|
+
readonly earthSunDirection: Triple;
|
|
24
|
+
readonly moonSunDirection: Triple;
|
|
25
|
+
/** Fraction of the child's disc lit, seen from the parent's centre (any satellite pair, not only the Moon). */
|
|
26
|
+
readonly lunarIlluminatedFraction: number;
|
|
27
|
+
/** Labels of the measured pair; absent means Earth and Moon. */
|
|
28
|
+
readonly pair?: PairLabels;
|
|
29
|
+
readonly scaledOrigin: Triple;
|
|
30
|
+
readonly earthLocal: Triple;
|
|
31
|
+
readonly moonLocal: Triple;
|
|
32
|
+
}
|
|
33
|
+
/** Display names of the pair the readout measures. */
|
|
34
|
+
export interface PairLabels {
|
|
35
|
+
readonly parent: string;
|
|
36
|
+
readonly child: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const EARTH_MOON_LABELS: PairLabels;
|
|
39
|
+
export interface DebugReadoutInput {
|
|
40
|
+
readonly pair?: PairLabels;
|
|
41
|
+
readonly timeUtcMs: number;
|
|
42
|
+
readonly rate: number;
|
|
43
|
+
readonly policy: ScalePolicy;
|
|
44
|
+
readonly earth: State;
|
|
45
|
+
readonly moonFromEarth: State;
|
|
46
|
+
readonly sunFromEarth: CenteredPosition;
|
|
47
|
+
readonly placed: PlacedState;
|
|
48
|
+
readonly renderedDistanceUnits: number;
|
|
49
|
+
readonly origin: FloatingOrigin;
|
|
50
|
+
}
|
|
51
|
+
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
52
|
+
export declare function buildDebugReadout(input: DebugReadoutInput): DebugReadout;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The debug readout's values, built every frame by the scene. The panel that draws them is DebugOverlay.tsx (loaded on demand, T-179).
|
|
2
|
+
import { directionFromCenterToSun, directionToSun, illuminatedFraction } from "../core/illumination.js";
|
|
3
|
+
export const EARTH_MOON_LABELS = Object.freeze({ parent: "Earth", child: "Moon" });
|
|
4
|
+
const triple = (v) => [v[0], v[1], v[2]];
|
|
5
|
+
/** Builds the overlay values from the very state, mapping and origin the scene just used. */
|
|
6
|
+
export function buildDebugReadout(input) {
|
|
7
|
+
const { moonFromEarth, sunFromEarth, origin, placed } = input;
|
|
8
|
+
return {
|
|
9
|
+
timeUtcMs: input.timeUtcMs,
|
|
10
|
+
rate: input.rate,
|
|
11
|
+
policyId: input.policy.id,
|
|
12
|
+
...(input.pair === undefined ? {} : { pair: input.pair }),
|
|
13
|
+
moonPosition: {
|
|
14
|
+
frame: moonFromEarth.frame,
|
|
15
|
+
center: moonFromEarth.center,
|
|
16
|
+
units: "km",
|
|
17
|
+
positionKm: triple(moonFromEarth.positionKm),
|
|
18
|
+
},
|
|
19
|
+
moonDistanceKm: Math.hypot(...triple(moonFromEarth.positionKm)),
|
|
20
|
+
renderedDistanceUnits: input.renderedDistanceUnits,
|
|
21
|
+
earthOrientation: input.earth.orientation,
|
|
22
|
+
moonOrientation: moonFromEarth.orientation,
|
|
23
|
+
earthSunDirection: triple(directionFromCenterToSun(sunFromEarth)),
|
|
24
|
+
moonSunDirection: triple(directionToSun(moonFromEarth, sunFromEarth)),
|
|
25
|
+
lunarIlluminatedFraction: illuminatedFraction(moonFromEarth, sunFromEarth),
|
|
26
|
+
scaledOrigin: triple(origin.scaledCameraOrigin),
|
|
27
|
+
earthLocal: triple(origin.toLocal(placed.earthAbsolute)),
|
|
28
|
+
moonLocal: triple(origin.toLocal(placed.moonAbsolute)),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const StoryPanelSettings: typeof import("./DeveloperSettings.js").StoryPanelSettings;
|
|
2
|
+
export declare const MoonsAndRingsSettings: typeof import("./DeveloperSettings.js").MoonsAndRingsSettings;
|
|
3
|
+
export declare const SkyAndSunSettings: typeof import("./DeveloperSettings.js").SkyAndSunSettings;
|
|
4
|
+
export declare const LabelSettings: typeof import("./DeveloperSettings.js").LabelSettings;
|
|
5
|
+
export declare const ViewLinkReadout: typeof import("./DeveloperSettings.js").ViewLinkReadout;
|
|
6
|
+
export declare const UnderTheHoodSettings: typeof import("./DeveloperSettings.js").UnderTheHoodSettings;
|