astraeus 0.1.1 → 0.3.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 +51 -0
- package/README.md +76 -7
- package/package.json +10 -6
- package/src/api/AstraeusScene.d.ts +27 -0
- package/src/api/AstraeusScene.js +38 -0
- package/src/api/AstraeusScene.node.js +37 -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 +89 -0
- package/src/api/group.js +121 -0
- package/src/api/index.d.ts +6 -1
- package/src/api/index.js +3 -1
- package/src/api/index.node.js +8 -0
- package/src/api/mount.d.ts +10 -1
- package/src/api/mount.js +15 -4
- package/src/api/mount.node.js +36 -0
- package/src/api/prepared.d.ts +10 -0
- package/src/api/prepared.js +5 -0
- package/src/api/scene.d.ts +148 -9
- package/src/api/scene.js +563 -59
- package/src/api/story.d.ts +69 -0
- package/src/api/story.js +63 -0
- package/src/api/sunOrbit.d.ts +20 -0
- package/src/api/sunOrbit.js +85 -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.d.ts +6 -2
- package/src/app/App.js +43 -21
- package/src/app/App.node.js +401 -0
- 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 +19 -0
- package/src/app/PanelLoadBoundary.js +17 -0
- package/src/app/SkyView.d.ts +3 -3
- package/src/app/SkyView.js +19 -10
- 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 +13 -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/sceneContentsHooks.js +2 -2
- package/src/app/sceneDebug.d.ts +1 -1
- package/src/app/sceneDebug.js +1 -1
- package/src/app/sceneFrame.js +4 -3
- package/src/app/sceneFraming.d.ts +13 -0
- package/src/app/sceneFraming.js +22 -0
- package/src/app/skyModel.js +3 -1
- 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/assets/pictures.d.ts +1 -1
- package/src/assets/sky.d.ts +4 -4
- package/src/assets/sky.js +12 -13
- package/src/core/bodies/index.d.ts +3 -0
- package/src/core/bodies/index.js +3 -1
- package/src/core/bodies/io.js +1 -1
- package/src/core/bodies/jupiterData.js +2 -2
- package/src/core/bodies/jupiterMoons.js +8 -12
- package/src/core/bodies/moon.d.ts +8 -0
- package/src/core/bodies/moon.js +28 -5
- package/src/core/bodies/outerPlanetData.js +7 -7
- package/src/core/bodies/planetMoons.js +18 -27
- package/src/core/bodies/swiftTuttle.js +2 -0
- package/src/core/elementsBody.d.ts +2 -0
- package/src/core/elementsBody.js +3 -0
- package/src/core/moonTrajectory.js +3 -5
- package/src/core/planetModels.js +1 -1
- package/src/core/planetSeries.d.ts +2 -0
- package/src/core/planetSeries.js +4 -0
- package/src/core/provenance.d.ts +7 -2
- package/src/core/provenance.js +3 -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 +12 -6
- package/src/shell/AstraeusShell.node.js +225 -0
- package/src/shell/DisplaySwitches.d.ts +16 -0
- package/src/shell/DisplaySwitches.js +31 -0
- package/src/shell/StoryPanelView.js +3 -1
- package/src/shell/TimelineBar.css +4 -0
- package/src/shell/TimelineBar.node.js +75 -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/TopBar.node.js +14 -0
- package/src/shell/experience.d.ts +4 -0
- package/src/shell/infoModel.js +3 -1
- package/src/shell/phone.css +4 -1
- package/src/shell/topBarIcons.d.ts +1 -0
- package/src/shell/topBarIcons.js +1 -0
- package/src/shell/useDrawers.js +1 -1
- package/src/shell/useZoomThrough.d.ts +7 -0
- package/src/shell/useZoomThrough.js +51 -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
package/src/app/SkyView.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { AdditiveBlending, BufferAttribute, BufferGeometry, DoubleSide, LinearFilter, LinearMipmapLinearFilter, Group, Mesh, Points, ShaderMaterial, NoColorSpace, TextureLoader, Vector3 } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import { MILKY_WAY_PICTURE } from "../assets/sky.js";
|
|
3
3
|
import { buildPictureMesh, buildStarBuffers } from "./skyModel.js";
|
|
4
4
|
// Both draws sit before everything else in the first pass (the layer-0 pass), ignore depth, and write none.
|
|
5
5
|
const SKY_ORDER = -1000;
|
|
6
|
-
/** Strength of the picture at brightness 1
|
|
7
|
-
const PICTURE_GAIN =
|
|
6
|
+
/** Strength of the picture at brightness 1, applied after the dimming below (1: the slider scales what the dimming leaves). */
|
|
7
|
+
const PICTURE_GAIN = 1;
|
|
8
|
+
/**
|
|
9
|
+
* The picture is a bright render, so it is dimmed the way Star Explorer dims its sky texture (an sRGB texture times a dark grey, drawn
|
|
10
|
+
* additively): decode to linear light, multiply, encode again. 0.04 gives a mean grey of about 2.2%, the level of the owner's
|
|
11
|
+
* 2026-10-27 trial (linear x 0.04, which at the old gain of 0.5 was written x 2). With a pure 2.2 power the decode and encode cancel,
|
|
12
|
+
* so this is a flat scale of the stored (sRGB) value by 0.04^(1/2.2), about 0.2315, the same for faint and bright values. Look-tuning is the Milky Way brightness setting, which scales the result.
|
|
13
|
+
*/
|
|
14
|
+
const PICTURE_DIM = 0.04;
|
|
8
15
|
/** A fixed render-frame direction used to read the sky back: where it lands on screen depends only on the camera orientation. */
|
|
9
16
|
const PROBE_DIRECTION = new Vector3(0.62, 0.35, -0.7).normalize();
|
|
10
17
|
const PICTURE_VERTEX = `
|
|
@@ -16,9 +23,11 @@ void main() {
|
|
|
16
23
|
const PICTURE_FRAGMENT = `
|
|
17
24
|
uniform sampler2D uMap;
|
|
18
25
|
uniform float uGain;
|
|
26
|
+
uniform float uDim;
|
|
19
27
|
varying vec2 vUv;
|
|
20
28
|
void main() {
|
|
21
|
-
|
|
29
|
+
vec3 linear = pow(texture2D(uMap, vUv).rgb, vec3(2.2)) * uDim;
|
|
30
|
+
gl_FragColor = vec4(pow(linear, vec3(1.0 / 2.2)) * uGain, 1.0);
|
|
22
31
|
}`;
|
|
23
32
|
// A star is a small Gaussian core: `aSize` is its width at half maximum in CSS pixels, the sprite is wide enough to hold three
|
|
24
33
|
// sigma either side, and the fragment measures the distance from the star's centre in device pixels, so it is sharp at any pixel ratio.
|
|
@@ -71,9 +80,9 @@ export class SkyView {
|
|
|
71
80
|
this.#brightness = milkyWayBrightness;
|
|
72
81
|
this.#maxAnisotropy = maxAnisotropy;
|
|
73
82
|
if (options.pictures !== undefined)
|
|
74
|
-
this.#build(
|
|
83
|
+
this.#build(MILKY_WAY_PICTURE, options.pictures);
|
|
75
84
|
else if (options.picture !== null)
|
|
76
|
-
this.#build(options.picture ??
|
|
85
|
+
this.#build(options.picture ?? MILKY_WAY_PICTURE);
|
|
77
86
|
this.#starMaterial = new ShaderMaterial({
|
|
78
87
|
vertexShader: STAR_VERTEX,
|
|
79
88
|
fragmentShader: STAR_FRAGMENT,
|
|
@@ -93,7 +102,7 @@ export class SkyView {
|
|
|
93
102
|
set.tiles.forEach((tile, index) => {
|
|
94
103
|
const texture = textures?.[index] ?? new TextureLoader().load(tile.url);
|
|
95
104
|
this.#textures.push(texture);
|
|
96
|
-
//
|
|
105
|
+
// The texture is read as raw sRGB values and the shader does the dimming (PICTURE_DIM); mipmaps and anisotropic filtering keep the
|
|
97
106
|
// picture from sparkling when it is drawn smaller than the file, and the magnified case is plain bilinear.
|
|
98
107
|
texture.colorSpace = NoColorSpace;
|
|
99
108
|
texture.generateMipmaps = true;
|
|
@@ -104,7 +113,7 @@ export class SkyView {
|
|
|
104
113
|
const material = new ShaderMaterial({
|
|
105
114
|
vertexShader: PICTURE_VERTEX,
|
|
106
115
|
fragmentShader: PICTURE_FRAGMENT,
|
|
107
|
-
uniforms: { uMap: { value: texture }, uGain: { value: PICTURE_GAIN * this.#brightness } },
|
|
116
|
+
uniforms: { uMap: { value: texture }, uDim: { value: PICTURE_DIM }, uGain: { value: PICTURE_GAIN * this.#brightness } },
|
|
108
117
|
side: DoubleSide,
|
|
109
118
|
depthTest: false,
|
|
110
119
|
depthWrite: false,
|
|
@@ -137,10 +146,10 @@ export class SkyView {
|
|
|
137
146
|
this.#textures = [];
|
|
138
147
|
this.#held = false;
|
|
139
148
|
}
|
|
140
|
-
/** Builds the
|
|
149
|
+
/** Builds the Milky Way picture the first time it is wanted (nothing is decoded while the picture stays off); a no-op once a picture is held. */
|
|
141
150
|
requestPicture() {
|
|
142
151
|
if (!this.#held)
|
|
143
|
-
this.#build(
|
|
152
|
+
this.#build(MILKY_WAY_PICTURE);
|
|
144
153
|
}
|
|
145
154
|
/** Sets the star strength in place (0 to 2); no rebuild. */
|
|
146
155
|
setStarBrightness(value) {
|
|
@@ -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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { lazy } from "react";
|
|
2
|
+
function onDemand(name) {
|
|
3
|
+
const Lazy = lazy(() => import("./DeveloperSettings.js").then((module) => ({ default: module[name] })));
|
|
4
|
+
return Lazy;
|
|
5
|
+
}
|
|
6
|
+
export const StoryPanelSettings = onDemand("StoryPanelSettings");
|
|
7
|
+
export const MoonsAndRingsSettings = onDemand("MoonsAndRingsSettings");
|
|
8
|
+
export const SkyAndSunSettings = onDemand("SkyAndSunSettings");
|
|
9
|
+
export const LabelSettings = onDemand("LabelSettings");
|
|
10
|
+
export const ViewLinkReadout = onDemand("ViewLinkReadout");
|
|
11
|
+
export const UnderTheHoodSettings = onDemand("UnderTheHoodSettings");
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DisplaySwitchItem } from "../shell/DisplaySwitches.js";
|
|
2
|
+
import type { OrbitLook } from "../assets/orbitLook.js";
|
|
3
|
+
import type { BodySetLook } from "./bodySet.js";
|
|
4
|
+
/** The display switches a story can place. Each one drives the same state as its Developer-drawer buttons, so the two never disagree. */
|
|
5
|
+
export declare const DISPLAY_SWITCH_IDS: readonly ["orbitLines", "labels", "milkyWay"];
|
|
6
|
+
export type DisplaySwitchId = (typeof DISPLAY_SWITCH_IDS)[number];
|
|
7
|
+
/** Where a switch shows: a button in the top bar, a row in the story switch panel opened from the bar, or only in the Developer drawer (where every switch stays). */
|
|
8
|
+
export declare const DISPLAY_SWITCH_PLACES: readonly ["top-bar", "panel", "developer"];
|
|
9
|
+
export type DisplaySwitchPlace = (typeof DISPLAY_SWITCH_PLACES)[number];
|
|
10
|
+
/** One switch's placement, and whether it starts on (absent: the scene's own start, which is on). */
|
|
11
|
+
export interface DisplaySwitchSetting {
|
|
12
|
+
readonly place: DisplaySwitchPlace;
|
|
13
|
+
readonly on?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type DisplaySwitchSettings = Readonly<Partial<Record<DisplaySwitchId, DisplaySwitchSetting>>>;
|
|
16
|
+
export declare const DISPLAY_SWITCH_LABELS: Readonly<Record<DisplaySwitchId, string>>;
|
|
17
|
+
/** Orbit lines are on while the ring, the trailing arc or the moon orbits show: the Developer buttons for any of them keep the switch in step. */
|
|
18
|
+
export declare function orbitLinesOn(orbit: Pick<OrbitLook, "baseOn" | "arcOn"> | null, moonOrbitsOn: boolean | null): boolean;
|
|
19
|
+
/** Labels are on while anchor labels or any object's name shows. */
|
|
20
|
+
export declare function labelsOn(objectIds: readonly string[], hidden: ReadonlySet<string>, anchorLabels: boolean | null): boolean;
|
|
21
|
+
/** The orbit-line state a start of `on` leaves; undefined: the scene's own start (on). */
|
|
22
|
+
export declare function orbitStart(setting: DisplaySwitchSetting | undefined): {
|
|
23
|
+
readonly look: Pick<OrbitLook, "baseOn" | "arcOn">;
|
|
24
|
+
readonly moonOrbitsOn: false;
|
|
25
|
+
} | undefined;
|
|
26
|
+
/** The pieces of live state the switches read and write; the setters write the scene's controls and the Developer drawer's state together. */
|
|
27
|
+
export interface SwitchBindings {
|
|
28
|
+
readonly settings: DisplaySwitchSettings | undefined;
|
|
29
|
+
readonly orbit: {
|
|
30
|
+
readonly present: boolean;
|
|
31
|
+
readonly look: Pick<OrbitLook, "baseOn" | "arcOn">;
|
|
32
|
+
readonly set: (change: Partial<OrbitLook>) => void;
|
|
33
|
+
};
|
|
34
|
+
readonly moons: {
|
|
35
|
+
readonly present: boolean;
|
|
36
|
+
readonly look: Pick<BodySetLook, "orbitsOn">;
|
|
37
|
+
readonly set: (change: Partial<BodySetLook>) => void;
|
|
38
|
+
};
|
|
39
|
+
readonly sky: {
|
|
40
|
+
readonly present: boolean;
|
|
41
|
+
readonly on: boolean;
|
|
42
|
+
readonly set: (on: boolean) => void;
|
|
43
|
+
};
|
|
44
|
+
readonly labels: {
|
|
45
|
+
readonly objectIds: readonly string[];
|
|
46
|
+
readonly hidden: ReadonlySet<string>;
|
|
47
|
+
readonly setHidden: (hidden: ReadonlySet<string>) => void;
|
|
48
|
+
readonly anchorsPresent: boolean;
|
|
49
|
+
readonly anchors: boolean;
|
|
50
|
+
readonly setAnchors: (on: boolean) => void;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The switches to draw in the top bar and the switch panel: the placed ones the scene has something for, in the order orbit lines, labels, Milky Way. */
|
|
54
|
+
export declare function displaySwitchItems(bindings: SwitchBindings): readonly DisplaySwitchItem[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** The display switches a story can place. Each one drives the same state as its Developer-drawer buttons, so the two never disagree. */
|
|
2
|
+
export const DISPLAY_SWITCH_IDS = ["orbitLines", "labels", "milkyWay"];
|
|
3
|
+
/** Where a switch shows: a button in the top bar, a row in the story switch panel opened from the bar, or only in the Developer drawer (where every switch stays). */
|
|
4
|
+
export const DISPLAY_SWITCH_PLACES = ["top-bar", "panel", "developer"];
|
|
5
|
+
export const DISPLAY_SWITCH_LABELS = { orbitLines: "Orbit lines", labels: "Labels", milkyWay: "Milky Way" };
|
|
6
|
+
/** Orbit lines are on while the ring, the trailing arc or the moon orbits show: the Developer buttons for any of them keep the switch in step. */
|
|
7
|
+
export function orbitLinesOn(orbit, moonOrbitsOn) {
|
|
8
|
+
return (orbit !== null && (orbit.baseOn || orbit.arcOn)) || moonOrbitsOn === true;
|
|
9
|
+
}
|
|
10
|
+
/** Labels are on while anchor labels or any object's name shows. */
|
|
11
|
+
export function labelsOn(objectIds, hidden, anchorLabels) {
|
|
12
|
+
return anchorLabels === true || objectIds.some((id) => !hidden.has(id));
|
|
13
|
+
}
|
|
14
|
+
/** The orbit-line state a start of `on` leaves; undefined: the scene's own start (on). */
|
|
15
|
+
export function orbitStart(setting) {
|
|
16
|
+
return setting?.on === false ? { look: { baseOn: false, arcOn: false }, moonOrbitsOn: false } : undefined;
|
|
17
|
+
}
|
|
18
|
+
function setOrbitLines(bindings, on) {
|
|
19
|
+
if (bindings.orbit.present)
|
|
20
|
+
bindings.orbit.set({ baseOn: on, arcOn: on });
|
|
21
|
+
if (bindings.moons.present)
|
|
22
|
+
bindings.moons.set({ orbitsOn: on });
|
|
23
|
+
}
|
|
24
|
+
function setLabels(bindings, on) {
|
|
25
|
+
const { labels } = bindings;
|
|
26
|
+
labels.setHidden(on ? new Set() : new Set(labels.objectIds));
|
|
27
|
+
if (labels.anchorsPresent)
|
|
28
|
+
labels.setAnchors(on);
|
|
29
|
+
}
|
|
30
|
+
/** The switches to draw in the top bar and the switch panel: the placed ones the scene has something for, in the order orbit lines, labels, Milky Way. */
|
|
31
|
+
export function displaySwitchItems(bindings) {
|
|
32
|
+
const { settings } = bindings;
|
|
33
|
+
if (settings === undefined)
|
|
34
|
+
return [];
|
|
35
|
+
const orbitOn = orbitLinesOn(bindings.orbit.present ? bindings.orbit.look : null, bindings.moons.present ? bindings.moons.look.orbitsOn : null);
|
|
36
|
+
const labelsNow = labelsOn(bindings.labels.objectIds, bindings.labels.hidden, bindings.labels.anchorsPresent ? bindings.labels.anchors : null);
|
|
37
|
+
const state = {
|
|
38
|
+
orbitLines: { applies: bindings.orbit.present || bindings.moons.present, on: orbitOn, toggle: () => setOrbitLines(bindings, !orbitOn) },
|
|
39
|
+
labels: { applies: bindings.labels.objectIds.length > 0 || bindings.labels.anchorsPresent, on: labelsNow, toggle: () => setLabels(bindings, !labelsNow) },
|
|
40
|
+
milkyWay: { applies: bindings.sky.present, on: bindings.sky.on, toggle: () => bindings.sky.set(!bindings.sky.on) },
|
|
41
|
+
};
|
|
42
|
+
return DISPLAY_SWITCH_IDS.flatMap((id) => {
|
|
43
|
+
const place = settings[id]?.place;
|
|
44
|
+
if ((place !== "top-bar" && place !== "panel") || !state[id].applies)
|
|
45
|
+
return [];
|
|
46
|
+
return [{ id, label: DISPLAY_SWITCH_LABELS[id], place, on: state[id].on, onToggle: state[id].toggle }];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -14,6 +14,7 @@ import { type ScaleId } from "../shell/scaleModel.js";
|
|
|
14
14
|
import type { TrackedBody } from "./mission.js";
|
|
15
15
|
import type { SkySettings } from "../assets/sky.js";
|
|
16
16
|
import { type BodySetLayer } from "./bodySet.js";
|
|
17
|
+
import type { DisplaySwitchSettings } from "./displaySwitches.js";
|
|
17
18
|
/** Generic scene parts an experience opts into. Nothing here names a mission. */
|
|
18
19
|
export type SceneLayerId = "tracked-bodies" | "points" | "sun-centred";
|
|
19
20
|
/** What the generic app owns and hands to the experience's factories. */
|
|
@@ -128,6 +129,14 @@ export interface CameraReach {
|
|
|
128
129
|
readonly maxFocusDistance?: number;
|
|
129
130
|
/** Far clipping plane; must exceed `maxFocusDistance` when both are given. */
|
|
130
131
|
readonly far?: number;
|
|
132
|
+
/**
|
|
133
|
+
* Fit the farthest zoom-out to one orbit about the Sun instead of a fixed `maxFocusDistance`: `farthestKm` is the orbit's farthest Sun distance
|
|
134
|
+
* (read once the viewer needs it, after the planet series load). The viewer turns it into a distance for the live canvas shape (`fitReach`) and
|
|
135
|
+
* re-fits when the canvas changes shape. Takes the place of `maxFocusDistance` and `far`, which a fitting reach does not carry.
|
|
136
|
+
*/
|
|
137
|
+
readonly fitOrbit?: {
|
|
138
|
+
readonly farthestKm: () => number;
|
|
139
|
+
};
|
|
131
140
|
}
|
|
132
141
|
/** The scene's far plane when an experience declares none. */
|
|
133
142
|
export declare const DEFAULT_CAMERA_FAR = 5000;
|
|
@@ -141,7 +150,8 @@ export interface ExperienceDefinition {
|
|
|
141
150
|
readonly experience: ExperienceConfig;
|
|
142
151
|
readonly clock: {
|
|
143
152
|
readonly startUtcMs: number;
|
|
144
|
-
readonly rate: number;
|
|
153
|
+
readonly rate: number; /** False leaves the clock paused at `startUtcMs` when the scene opens (default true: it plays). */
|
|
154
|
+
readonly playing?: boolean;
|
|
145
155
|
};
|
|
146
156
|
/** Layers the scene mounts, e.g. the tracked-body list. */
|
|
147
157
|
readonly sceneLayers: readonly SceneLayerId[];
|
|
@@ -189,6 +199,8 @@ export interface ExperienceDefinition {
|
|
|
189
199
|
}[];
|
|
190
200
|
/** A choice between versions of this experience, shown in the top bar and the phone drawer: choosing one opens it again with `?param=value` (the camera view and time of the old address are dropped). Absent: none. */
|
|
191
201
|
readonly switcher?: import("../shell/SwitchControl.js").ExperienceSwitch;
|
|
202
|
+
/** 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. */
|
|
203
|
+
readonly displaySwitches?: DisplaySwitchSettings;
|
|
192
204
|
/** Which direction the camera treats as up (default "equatorial", celestial north; "ecliptic" orbits about the ecliptic pole so the planets' plane reads flat). */
|
|
193
205
|
readonly viewUp?: import("./viewUp.js").ViewUp;
|
|
194
206
|
/** The camera view to open on (focus id, azimuth and elevation in degrees, distance in scaled units). Absent: the usual opening. `?view=` overrides it. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExperienceSwitch } from "../shell/SwitchControl.js";
|
|
2
|
+
/** One entry the experience can open: its settings file's name, its label, and its place in the switch (the lowest `order` is the default). */
|
|
3
|
+
export interface SwitchEntry {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly order: number;
|
|
7
|
+
}
|
|
8
|
+
/** The entry to open (the requested one when it exists, else `preferred`, else the first by `order`, then name) and the switch listing every entry. Undefined when there are none. */
|
|
9
|
+
export declare function chooseSwitch<T extends SwitchEntry>(entries: readonly T[], requested: string | null, switchOf: {
|
|
10
|
+
readonly label: string;
|
|
11
|
+
readonly param: string;
|
|
12
|
+
readonly keep?: readonly string[];
|
|
13
|
+
}, preferred?: string): {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly switcher: ExperienceSwitch;
|
|
16
|
+
} | undefined;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/** The
|
|
2
|
-
export const SHOWER_PARAM = "shower";
|
|
3
|
-
/** The label the switch carries as its accessible name. */
|
|
4
|
-
export const SHOWER_SWITCH_LABEL = "Shower";
|
|
5
|
-
/** The entry to open (the requested one when it exists, else `preferred`, else the first by `order`, then name) and the switch listing every entry. Undefined when there are none. Shared by the experiences that offer such a switch. */
|
|
1
|
+
/** The entry to open (the requested one when it exists, else `preferred`, else the first by `order`, then name) and the switch listing every entry. Undefined when there are none. */
|
|
6
2
|
export function chooseSwitch(entries, requested, switchOf, preferred) {
|
|
7
3
|
const sorted = [...entries].sort((a, b) => a.order - b.order || a.name.localeCompare(b.name));
|
|
8
4
|
const chosen = sorted.find((entry) => entry.name === requested) ?? sorted.find((entry) => entry.name === preferred) ?? sorted[0];
|
|
@@ -13,7 +9,3 @@ export function chooseSwitch(entries, requested, switchOf, preferred) {
|
|
|
13
9
|
switcher: { label: switchOf.label, param: switchOf.param, ...(switchOf.keep === undefined ? {} : { keep: switchOf.keep }), options: sorted.map((entry) => ({ label: entry.label, value: entry.name, active: entry === chosen })) },
|
|
14
10
|
};
|
|
15
11
|
}
|
|
16
|
-
/** The shower to open (the requested one when it exists, else the first by `order`, then name) and the switch listing every shower. Undefined when there are no showers. */
|
|
17
|
-
export function chooseShower(entries, requested) {
|
|
18
|
-
return chooseSwitch(entries, requested, { label: SHOWER_SWITCH_LABEL, param: SHOWER_PARAM });
|
|
19
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TimelineEvent } from "../core/events.js";
|
|
2
2
|
import type { Metric, ProgressMetric } from "../shell/metrics.js";
|
|
3
|
-
import { type DebugReadout } from "./
|
|
3
|
+
import { type DebugReadout } from "./debugReadout.js";
|
|
4
4
|
/** Elapsed time from the first to the last event, with every event as a milestone. */
|
|
5
5
|
export declare function journeyProgressMetric(events: readonly TimelineEvent[], timeUtcMs: number, labels: {
|
|
6
6
|
readonly start: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EARTH_MOON_LABELS } from "./
|
|
1
|
+
import { EARTH_MOON_LABELS } from "./debugReadout.js";
|
|
2
2
|
const HOUR_MS = 3_600_000;
|
|
3
3
|
const centreName = (center) => `${center.charAt(0).toUpperCase()}${center.slice(1)} centre`;
|
|
4
4
|
/** Elapsed time from the first to the last event, with every event as a milestone. */
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SimulationClock } from "../core/clock.js";
|
|
2
|
+
import type { ExperienceDefinition } from "./experienceDefinition.js";
|
|
3
|
+
/**
|
|
4
|
+
* The clock a mounted experience opens with: at its start moment and rate (or at the moment a copied link carried), playing unless the definition says
|
|
5
|
+
* `clock.playing: false`, which leaves it frozen there.
|
|
6
|
+
*/
|
|
7
|
+
export declare function openClock(definition: Pick<ExperienceDefinition, "clock">, linkedTimeUtcMs?: number): SimulationClock;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SimulationClock } from "../core/clock.js";
|
|
2
|
+
/**
|
|
3
|
+
* The clock a mounted experience opens with: at its start moment and rate (or at the moment a copied link carried), playing unless the definition says
|
|
4
|
+
* `clock.playing: false`, which leaves it frozen there.
|
|
5
|
+
*/
|
|
6
|
+
export function openClock(definition, linkedTimeUtcMs) {
|
|
7
|
+
const clock = new SimulationClock(definition.clock.startUtcMs);
|
|
8
|
+
clock.setRate(definition.clock.rate);
|
|
9
|
+
if (linkedTimeUtcMs !== undefined)
|
|
10
|
+
clock.seek(linkedTimeUtcMs);
|
|
11
|
+
if (definition.clock.playing !== false)
|
|
12
|
+
clock.play();
|
|
13
|
+
return clock;
|
|
14
|
+
}
|
|
@@ -23,9 +23,9 @@ export declare function bodyIdOf(runtime: {
|
|
|
23
23
|
export declare function refFor<T>(map: Map<BodyId, T>, id: BodyId): (node: T | null) => void;
|
|
24
24
|
/** The mounted nodes of every body: groups, orientation nodes, lights and body parts, with one stable parts callback per body. */
|
|
25
25
|
export declare function useBodyRefs(runtime: SceneRuntime): {
|
|
26
|
-
groupRefs: import("react").
|
|
27
|
-
orientRefs: import("react").
|
|
28
|
-
lightRefs: import("react").
|
|
26
|
+
groupRefs: import("react").RefObject<Map<string, Group<import("three").Object3DEventMap>>>;
|
|
27
|
+
orientRefs: import("react").RefObject<Map<string, Group<import("three").Object3DEventMap>>>;
|
|
28
|
+
lightRefs: import("react").RefObject<Map<string, DirectionalLight>>;
|
|
29
29
|
partsFor: Map<string, (node: BodyParts | null) => void>;
|
|
30
30
|
bodyRefs: BodyRefs;
|
|
31
31
|
};
|
|
@@ -9,7 +9,7 @@ import { releaseGlowTexture } from "./bodyDraw.js";
|
|
|
9
9
|
import { assetWithOverride } from "./experienceDefinition.js";
|
|
10
10
|
import { FeatureMarkerLayer } from "./FeatureMarkers.js";
|
|
11
11
|
import { bodiesMounted, runFrame } from "./sceneFrame.js";
|
|
12
|
-
import { focusLimits } from "./sceneFraming.js";
|
|
12
|
+
import { focusLimits, liveReach } from "./sceneFraming.js";
|
|
13
13
|
import { useHostLayer } from "./sceneHooks.js";
|
|
14
14
|
import { readoutPairOf } from "./sceneLayout.js";
|
|
15
15
|
import { SceneLabelLayer } from "./SceneLabels.js";
|
|
@@ -76,7 +76,7 @@ export function useOverlayLayers(canvas, controls, trackedViews, bodySetViews) {
|
|
|
76
76
|
/** Wires the canvas's orbit gestures, hover and tap picking to the camera and frame state. */
|
|
77
77
|
export function useScenePointer(canvas, runtime, controls, catalogue, orbit, state) {
|
|
78
78
|
useEffect(() => {
|
|
79
|
-
const limits = () => focusLimits(bodyIdOf(runtime, catalogue, orbit.current.focus) ?? orbit.current.focus, { centre: runtime.sceneCenter, span: state.current.spanScaled, bodies: catalogue }, controls.policy, runtime.cameraReach);
|
|
79
|
+
const limits = () => focusLimits(bodyIdOf(runtime, catalogue, orbit.current.focus) ?? orbit.current.focus, { centre: runtime.sceneCenter, span: state.current.spanScaled, bodies: catalogue }, controls.policy, liveReach(runtime.cameraReach, controls.policy, canvas.clientHeight > 0 ? canvas.clientWidth / canvas.clientHeight : 1));
|
|
80
80
|
return attachScenePointer(canvas, orbit.current, state.current, limits, (id) => controls.onPickObject?.(id));
|
|
81
81
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
82
82
|
}, [canvas, controls]);
|
package/src/app/sceneDebug.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { StateResolver } from "../core/stateResolver.js";
|
|
|
5
5
|
import type { Camera } from "three";
|
|
6
6
|
import type { PathView } from "./PathView.js";
|
|
7
7
|
import type { BodyScreenReadout } from "./sceneBodies.js";
|
|
8
|
-
import { type DebugReadout } from "./
|
|
8
|
+
import { type DebugReadout } from "./debugReadout.js";
|
|
9
9
|
import type { FloatingOrigin } from "./floatingOrigin.js";
|
|
10
10
|
import type { FrameStats } from "./frameStats.js";
|
|
11
11
|
import type { GroupFill } from "./FrameRateSection.js";
|
package/src/app/sceneDebug.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { rootBodyId } from "../assets/catalogue.js";
|
|
2
|
-
import { buildDebugReadout } from "./
|
|
2
|
+
import { buildDebugReadout } from "./debugReadout.js";
|
|
3
3
|
/** Sets one `data-` attribute on the canvas, only when it changed (the browser scripts read these). */
|
|
4
4
|
export function setDatum(canvas, key, value) {
|
|
5
5
|
if (canvas.dataset[key] !== value)
|
package/src/app/sceneFrame.js
CHANGED
|
@@ -6,7 +6,7 @@ import { DEFAULT_CAMERA_FAR } from "./experienceDefinition.js";
|
|
|
6
6
|
import { DEFAULT_FEATURE_MIN_BODY_PX } from "./FeatureMarkers.js";
|
|
7
7
|
import { rescaleCameraForPolicy, stepCameraTarget } from "./sceneCamera.js";
|
|
8
8
|
import { buildFrameReadout, publishBodyData, publishPathData, publishPointsData, publishSceneData, recordFrameStats } from "./sceneDebug.js";
|
|
9
|
-
import { focusRadius } from "./sceneFraming.js";
|
|
9
|
+
import { focusRadius, liveReach } from "./sceneFraming.js";
|
|
10
10
|
import { bodyScreenReadouts, placeBodies, swapSmallBodiesToMarkers } from "./sceneBodies.js";
|
|
11
11
|
import { publishBodySets } from "./sceneBodySets.js";
|
|
12
12
|
import { bodyAbsolute, placeComposition } from "./sceneLayout.js";
|
|
@@ -95,11 +95,12 @@ export function stepAndPoseCamera(ctx, t, placed) {
|
|
|
95
95
|
const targets = { bodyIdFor: ctx.bodyIdFor, placed: placed.composed.absolutes, absoluteOf: placed.absoluteOf, groupViews: views.groupViews, sunCentredViews: views.sunCentredViews, trackedViews: views.trackedViews, bodySetViews: views.bodySetViews, timeUtcMs: t, policy, placement: ctx.placement };
|
|
96
96
|
const firstFrame = !state.started;
|
|
97
97
|
state.started = true;
|
|
98
|
-
const
|
|
98
|
+
const reach = liveReach(runtime.cameraReach, policy, camera.aspect);
|
|
99
|
+
const focusBody = stepCameraTarget({ camState: orbit, controls, targets, frame, catalogue, reach, fovDeg: camera.fov, viewUp, firstFrame, previousUp: state.lastUp });
|
|
99
100
|
state.lastUp = viewUp;
|
|
100
101
|
resolveCamera(orbit, focusAbsoluteOf(targets, orbit.focus), ctx.origin, ctx.delta, REBASE_THRESHOLD, viewUp);
|
|
101
102
|
placeBodies(ctx.assets, placed.composed.states, ctx.bodyRefs, policy, ctx.origin);
|
|
102
|
-
poseCamera(camera, orbit, focusRadius(focusBody, policy, catalogue), ctx.origin,
|
|
103
|
+
poseCamera(camera, orbit, focusRadius(focusBody, policy, catalogue), ctx.origin, reach.far ?? DEFAULT_CAMERA_FAR, viewUp);
|
|
103
104
|
if (firstFrame)
|
|
104
105
|
requestAnimationFrame(() => hideBootLoader(state.coverShowing));
|
|
105
106
|
controls.viewReadout = viewFromAngles(orbit.focus, orbit.azimuth, orbit.elevation, orbit.distance);
|
|
@@ -32,6 +32,19 @@ export interface SceneFrame {
|
|
|
32
32
|
* `poseCamera`), so even a 1 km moon's ball is drawn rather than cut away.
|
|
33
33
|
*/
|
|
34
34
|
export declare const MEMBER_MIN_DISTANCE = 0.0015;
|
|
35
|
+
/** The camera's vertical field of view in degrees (the Canvas's `fov`). */
|
|
36
|
+
export declare const CAMERA_FOV_DEG = 45;
|
|
37
|
+
/** Room left round a fitted orbit, as a multiple. */
|
|
38
|
+
export declare const ORBIT_FIT_MARGIN = 1.1;
|
|
39
|
+
/** The far plane of a fitted reach, as a multiple of the reach (what `camera.setReach` uses too). */
|
|
40
|
+
export declare const FAR_PER_REACH = 2.5;
|
|
41
|
+
/**
|
|
42
|
+
* The camera-to-focus distance at which a sphere of radius `farthestUnits` about the focus fits the canvas from any view direction:
|
|
43
|
+
* the farthest distance divided by the sine of the narrower half field of view (vertical, or horizontal from the aspect ratio), times the margin.
|
|
44
|
+
*/
|
|
45
|
+
export declare function fitReach(farthestUnits: number, aspect: number, fovDeg?: number): number;
|
|
46
|
+
/** The declared reach as the viewer applies it now: a fitting reach becomes a farthest zoom-out and far plane for the canvas shape `aspect` (width over height); any other is returned as is. */
|
|
47
|
+
export declare function liveReach(declared: CameraReach, policy: ScalePolicy, aspect: number): CameraReach;
|
|
35
48
|
/** Zoom limits per focus kind; a declared reach replaces only the farthest distance. */
|
|
36
49
|
export declare function focusLimits(focus: BodyId, frame: SceneFrame, policy: ScalePolicy, declared: CameraReach): {
|
|
37
50
|
min: number;
|
package/src/app/sceneFraming.js
CHANGED
|
@@ -35,6 +35,28 @@ function sphereRadius(focus, policy, source) {
|
|
|
35
35
|
// A marker-kind body that also draws a self-bright sphere (emissive) has that radius too: the camera must stay outside it.
|
|
36
36
|
return asset.visual.kind === "sphere" || asset.visual.emissive === true ? policy.mapRadius(asset.definition.radiusKm, asset.definition.id) : null;
|
|
37
37
|
}
|
|
38
|
+
/** The camera's vertical field of view in degrees (the Canvas's `fov`). */
|
|
39
|
+
export const CAMERA_FOV_DEG = 45;
|
|
40
|
+
/** Room left round a fitted orbit, as a multiple. */
|
|
41
|
+
export const ORBIT_FIT_MARGIN = 1.1;
|
|
42
|
+
/** The far plane of a fitted reach, as a multiple of the reach (what `camera.setReach` uses too). */
|
|
43
|
+
export const FAR_PER_REACH = 2.5;
|
|
44
|
+
/**
|
|
45
|
+
* The camera-to-focus distance at which a sphere of radius `farthestUnits` about the focus fits the canvas from any view direction:
|
|
46
|
+
* the farthest distance divided by the sine of the narrower half field of view (vertical, or horizontal from the aspect ratio), times the margin.
|
|
47
|
+
*/
|
|
48
|
+
export function fitReach(farthestUnits, aspect, fovDeg = CAMERA_FOV_DEG) {
|
|
49
|
+
const halfVertical = (fovDeg * Math.PI) / 360;
|
|
50
|
+
const halfHorizontal = Math.atan(Math.tan(halfVertical) * aspect);
|
|
51
|
+
return (ORBIT_FIT_MARGIN * farthestUnits) / Math.sin(Math.min(halfVertical, halfHorizontal));
|
|
52
|
+
}
|
|
53
|
+
/** The declared reach as the viewer applies it now: a fitting reach becomes a farthest zoom-out and far plane for the canvas shape `aspect` (width over height); any other is returned as is. */
|
|
54
|
+
export function liveReach(declared, policy, aspect) {
|
|
55
|
+
if (declared.fitOrbit === undefined)
|
|
56
|
+
return declared;
|
|
57
|
+
const maxFocusDistance = fitReach(scaleLength(policy, declared.fitOrbit.farthestKm()), aspect > 0 ? aspect : 1);
|
|
58
|
+
return { maxFocusDistance, far: maxFocusDistance * FAR_PER_REACH };
|
|
59
|
+
}
|
|
38
60
|
/** Zoom limits per focus kind; a declared reach replaces only the farthest distance. */
|
|
39
61
|
export function focusLimits(focus, frame, policy, declared) {
|
|
40
62
|
const max = declared.maxFocusDistance ?? Math.max(30, frame.span * 3.5);
|
package/src/app/skyModel.js
CHANGED
|
@@ -32,12 +32,14 @@ export function skyObject(status) {
|
|
|
32
32
|
const provenance = createProvenance({
|
|
33
33
|
sourceType: "observed",
|
|
34
34
|
sources: SKY_SOURCES,
|
|
35
|
-
accuracy: "Star directions are the catalogue's J2000 positions to about an arcsecond. The Milky Way picture is the
|
|
35
|
+
accuracy: "Star directions are the catalogue's J2000 positions to about an arcsecond. The Milky Way picture is a Gaia EDR3 render with the foreground stars removed, placed by its galactic coordinates (the Magellanic Clouds land within half a degree).",
|
|
36
36
|
notes: starLine,
|
|
37
37
|
});
|
|
38
38
|
return {
|
|
39
39
|
id: SKY_OBJECT_ID,
|
|
40
40
|
label: "Sky",
|
|
41
|
+
// Drawn and still an object, but not offered in the object drop-downs (owner, 2026-10-24); its credits stay in NOTICE and on the home page.
|
|
42
|
+
listed: false,
|
|
41
43
|
description: "Stars and the Milky Way, drawn at infinity behind the scene. The sky turns only with the camera; the scene centre, scale and followed object do not move it.",
|
|
42
44
|
provenance,
|
|
43
45
|
knownLimitations: [
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BodyId } from "../core/body.js";
|
|
2
|
+
import type { StateResolver } from "../core/stateResolver.js";
|
|
3
|
+
import { type BodyCatalogue } from "../assets/catalogue.js";
|
|
4
|
+
import type { CenteredPosition } from "../core/state.js";
|
|
5
|
+
import { type TrackedBody, type TrackedReadout } from "./mission.js";
|
|
6
|
+
import type { AltitudeMetric, DistanceMetric, Metric, MetricReference, RelativeDistanceMetric, SpeedMetric, UncertaintyMetric } from "../shell/metrics.js";
|
|
7
|
+
/**
|
|
8
|
+
* Highest speed at the body's NASA source anchors, the honest top of its speed gauge. Anchors rather
|
|
9
|
+
* than reconstructed samples, because a smoothed join can carry a known non-physical spike (I-008).
|
|
10
|
+
* Null when the body has no anchors or the trajectory carries no velocity.
|
|
11
|
+
*/
|
|
12
|
+
export declare function peakAnchorSpeedKmS(body: TrackedBody): number | null;
|
|
13
|
+
/** A reference marker only when it is measured from the same centre and in the same frame as the value. */
|
|
14
|
+
export declare function referenceInSameFrame(label: string, row: Pick<TrackedReadout, "frame" | "center">, reference: CenteredPosition | null): MetricReference | null;
|
|
15
|
+
export declare function spacecraftRangeMetric(row: TrackedReadout, moon: MetricReference | null): DistanceMetric;
|
|
16
|
+
export declare function spacecraftSpeedMetric(row: TrackedReadout, peakKmS: number | null): SpeedMetric;
|
|
17
|
+
/** A body a path's readouts are measured against: its id, its name and its mean radius. */
|
|
18
|
+
export interface ReadoutTarget {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly label: string;
|
|
21
|
+
readonly radiusKm: number;
|
|
22
|
+
}
|
|
23
|
+
/** The target's state when it shares the path's centre and frame, otherwise null. */
|
|
24
|
+
export declare function inSameFrame(row: Pick<TrackedReadout, "frame" | "center">, state: CenteredPosition | null): CenteredPosition | null;
|
|
25
|
+
export declare const separationKm: (a: readonly number[], b: ArrayLike<number>) => number;
|
|
26
|
+
/** Centre-to-centre distance from the path to a body, drawn in that body's radii. */
|
|
27
|
+
export declare function pathDistanceMetric(row: TrackedReadout, target: ReadoutTarget, state: CenteredPosition | null): RelativeDistanceMetric;
|
|
28
|
+
/** Height above a body's mean radius (not terrain: on the surface the value can be negative); null when the body has no state in the path's frame. */
|
|
29
|
+
export declare function pathAltitudeMetric(row: TrackedReadout, target: ReadoutTarget, state: CenteredPosition | null): AltitudeMetric;
|
|
30
|
+
/** The data's own discrepancy for the segment at this time, compared with the vehicle's largest. */
|
|
31
|
+
export declare function spacecraftDiscrepancyMetric(body: TrackedBody, timeUtcMs: number): UncertaintyMetric;
|
|
32
|
+
/** One bar on a path's info card. */
|
|
33
|
+
export type ReadoutSpec = {
|
|
34
|
+
readonly kind: "range";
|
|
35
|
+
readonly marker?: BodyId;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "speed";
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "distance";
|
|
40
|
+
readonly to: BodyId;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "altitude";
|
|
43
|
+
readonly above: BodyId;
|
|
44
|
+
};
|
|
45
|
+
export interface PathReadouts {
|
|
46
|
+
readonly body: TrackedBody;
|
|
47
|
+
readonly readouts: readonly ReadoutSpec[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The info card's bars for paths that ask for readouts, from State only. Range is from the path's centre body; a named body is read from the
|
|
51
|
+
* resolver about that centre, so it shares the path's frame. A path outside its bounds and any other id have none.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createReadoutMetrics(paths: readonly PathReadouts[], resolver: StateResolver, source?: BodyCatalogue): (objectId: string, timeUtcMs: number) => readonly Metric[];
|