astraeus 0.8.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/README.md +104 -31
  3. package/package.json +1 -1
  4. package/src/api/AstraeusScene.d.ts +1 -1
  5. package/src/api/AstraeusScene.js +4 -1
  6. package/src/api/AstraeusScene.node.js +4 -1
  7. package/src/api/assembleScene.d.ts +2 -0
  8. package/src/api/assembleScene.js +28 -6
  9. package/src/api/cameraRequest.d.ts +15 -0
  10. package/src/api/cameraRequest.js +89 -0
  11. package/src/api/errors.d.ts +9 -1
  12. package/src/api/index.d.ts +6 -3
  13. package/src/api/look.d.ts +49 -0
  14. package/src/api/lookInput.d.ts +1 -1
  15. package/src/api/lookInput.js +6 -1
  16. package/src/api/planBodies.d.ts +2 -1
  17. package/src/api/planBodies.js +6 -1
  18. package/src/api/planCamera.d.ts +35 -7
  19. package/src/api/planCamera.js +94 -11
  20. package/src/api/planPaths.d.ts +2 -0
  21. package/src/api/planPaths.js +14 -9
  22. package/src/api/planSkyFigures.d.ts +22 -0
  23. package/src/api/planSkyFigures.js +145 -0
  24. package/src/api/planStory.d.ts +2 -2
  25. package/src/api/planStory.js +14 -9
  26. package/src/api/planViews.js +1 -1
  27. package/src/api/providerPathTimes.d.ts +10 -0
  28. package/src/api/providerPathTimes.js +109 -0
  29. package/src/api/scene.d.ts +23 -4
  30. package/src/api/scene.js +23 -5
  31. package/src/api/sceneReads.d.ts +21 -2
  32. package/src/api/shownDuring.d.ts +12 -0
  33. package/src/api/shownDuring.js +30 -0
  34. package/src/api/skyFigureInput.d.ts +45 -0
  35. package/src/api/skyFigureInput.js +1 -0
  36. package/src/api/skyTraceInput.d.ts +33 -0
  37. package/src/api/skyTraceInput.js +45 -0
  38. package/src/api/story.d.ts +13 -4
  39. package/src/api/story.js +45 -2
  40. package/src/api/viewerCamera.d.ts +4 -3
  41. package/src/api/viewerCamera.js +10 -32
  42. package/src/api/viewerHandle.d.ts +27 -4
  43. package/src/api/viewerHandle.js +6 -0
  44. package/src/api/viewerLink.d.ts +49 -4
  45. package/src/api/viewerLink.js +25 -0
  46. package/src/api/viewerPanels.d.ts +26 -0
  47. package/src/api/viewerPanels.js +42 -0
  48. package/src/api/viewerSelection.d.ts +1 -1
  49. package/src/api/viewerSelection.js +3 -3
  50. package/src/app/App.js +129 -30
  51. package/src/app/App.node.js +129 -30
  52. package/src/app/AstraeusScene.d.ts +20 -5
  53. package/src/app/AstraeusScene.js +3 -3
  54. package/src/app/CameraController.d.ts +19 -1
  55. package/src/app/CameraController.js +38 -11
  56. package/src/app/DeveloperSettings.d.ts +11 -3
  57. package/src/app/DeveloperSettings.js +13 -3
  58. package/src/app/SceneLabels.d.ts +20 -2
  59. package/src/app/SceneLabels.js +46 -6
  60. package/src/app/SkyFiguresView.d.ts +56 -0
  61. package/src/app/SkyFiguresView.js +242 -0
  62. package/src/app/StoryMarkers.d.ts +2 -2
  63. package/src/app/StoryMarkers.js +2 -2
  64. package/src/app/displaySwitches.d.ts +13 -3
  65. package/src/app/displaySwitches.js +17 -3
  66. package/src/app/experienceDefinition.d.ts +9 -3
  67. package/src/app/experienceDefinition.js +4 -2
  68. package/src/app/labelStyle.d.ts +17 -0
  69. package/src/app/labelStyle.js +13 -0
  70. package/src/app/liveLook.js +8 -0
  71. package/src/app/look.d.ts +9 -5
  72. package/src/app/look.js +11 -0
  73. package/src/app/lookOut.d.ts +32 -0
  74. package/src/app/lookOut.js +50 -0
  75. package/src/app/sceneCamera.d.ts +5 -3
  76. package/src/app/sceneCamera.js +66 -3
  77. package/src/app/sceneContentsHooks.d.ts +2 -1
  78. package/src/app/sceneContentsHooks.js +3 -2
  79. package/src/app/sceneFrame.d.ts +22 -4
  80. package/src/app/sceneFrame.js +67 -22
  81. package/src/app/sceneFraming.d.ts +7 -0
  82. package/src/app/sceneFraming.js +12 -0
  83. package/src/app/sceneHooks.d.ts +2 -0
  84. package/src/app/sceneHooks.js +4 -1
  85. package/src/app/scenePicking.d.ts +20 -0
  86. package/src/app/scenePicking.js +49 -0
  87. package/src/app/scenePointer.d.ts +3 -1
  88. package/src/app/scenePointer.js +3 -2
  89. package/src/app/skyFigures.d.ts +73 -0
  90. package/src/app/skyFigures.js +50 -0
  91. package/src/app/style.css +2 -1
  92. package/src/app/viewHiding.d.ts +10 -1
  93. package/src/app/viewHiding.js +30 -1
  94. package/src/app/viewLink.d.ts +8 -8
  95. package/src/app/viewLink.js +24 -4
  96. package/src/app/viewerPort.d.ts +30 -3
  97. package/src/assets/sky.d.ts +13 -4
  98. package/src/assets/sky.js +33 -8
  99. package/src/assets/stars/hyg-v42-naked-eye.json +1 -1
  100. package/src/core/bodies/moonSystem.js +1 -15
  101. package/src/core/lookValues.d.ts +9 -0
  102. package/src/core/lookValues.js +24 -0
  103. package/src/core/pacing.d.ts +38 -6
  104. package/src/core/pacing.js +141 -21
  105. package/src/core/readBytes.d.ts +1 -0
  106. package/src/core/readBytes.js +15 -0
  107. package/src/core/skyTrace.d.ts +49 -0
  108. package/src/core/skyTrace.js +39 -0
  109. package/src/core/startView.d.ts +39 -0
  110. package/src/core/startView.js +56 -0
  111. package/src/core/storyPanels.d.ts +51 -3
  112. package/src/core/storyPanels.js +52 -12
  113. package/src/shell/AstraeusShell.d.ts +17 -6
  114. package/src/shell/AstraeusShell.js +100 -26
  115. package/src/shell/AstraeusShell.node.js +100 -26
  116. package/src/shell/ObjectControls.js +11 -8
  117. package/src/shell/StoryPanelView.d.ts +12 -3
  118. package/src/shell/StoryPanelView.js +2 -2
  119. package/src/shell/experience.d.ts +31 -0
  120. package/src/shell/experience.js +4 -1
  121. package/src/shell/infoModel.js +9 -1
  122. package/src/shell/objectModel.d.ts +9 -4
  123. package/src/shell/objectModel.js +16 -5
  124. package/src/shell/phone.css +1 -1
  125. package/src/shell/storyPanels.d.ts +1 -1
  126. package/src/shell/storyPanels.js +1 -1
  127. package/src/shell/style.css +9 -1
  128. package/src/shell/topBarIcons.d.ts +1 -0
  129. package/src/shell/topBarIcons.js +1 -0
  130. package/src/shell/useStoryPanels.d.ts +9 -6
  131. package/src/shell/useStoryPanels.js +10 -6
@@ -9,7 +9,7 @@ import { type BodyAsset, type BodyCatalogue } from "../assets/catalogue.js";
9
9
  import type { SystemComposition } from "../assets/compositions.js";
10
10
  import type { BodyVisual } from "../assets/visual.js";
11
11
  import type { Metric } from "../shell/metrics.js";
12
- import type { ExperienceConfig, ExperienceObject } from "../shell/experience.js";
12
+ import { type ExperienceConfig, type ExperienceObject } from "../shell/experience.js";
13
13
  import { type ScaleId } from "../shell/scaleModel.js";
14
14
  import type { TrackedBody } from "./mission.js";
15
15
  import type { SkySettings } from "../assets/sky.js";
@@ -17,6 +17,7 @@ import type { LookInput } from "./look.js";
17
17
  import type { Pictures } from "../assets/pictures.js";
18
18
  import { type BodySetLayer } from "./bodySet.js";
19
19
  import type { DisplaySwitchSettings } from "./displaySwitches.js";
20
+ import type { SkyFigureLayer } from "./skyFigures.js";
20
21
  import type { ViewSettings } from "./views.js";
21
22
  /** Generic scene parts an experience opts into. Nothing here names a mission. */
22
23
  export type SceneLayerId = "tracked-bodies" | "points" | "sun-centred";
@@ -204,14 +205,19 @@ export interface ExperienceDefinition {
204
205
  readonly views?: ViewSettings;
205
206
  /** Which direction the camera treats as up (default "equatorial", celestial north; "ecliptic" orbits about the ecliptic pole so the planets' plane reads flat). */
206
207
  readonly viewUp?: import("./viewUp.js").ViewUp;
207
- /** The camera view to open on (focus id, azimuth and elevation in degrees, distance in scaled units). Absent: the usual opening. `?view=` overrides it. */
208
- readonly startView?: import("./viewLink.js").StartView;
208
+ /**
209
+ * The camera view to open on (focus id, azimuth and elevation in degrees, distance in scaled units; or a sky view), or a look-out request whose direction is an id (`scene.camera.lookOut` toward an object or sky figure),
210
+ * which the viewer resolves on the first frame by the same steps as a `setCamera` look-out. Absent: the usual opening. `?view=` overrides it.
211
+ */
212
+ readonly startView?: import("./sceneCamera.js").OpeningView;
209
213
  /** The sky behind the scene (stars and the Milky Way, at infinity). On at full brightness unless this says otherwise; presentation only. */
210
214
  readonly sky?: SkySettings;
211
215
  /** The looks the scene set (`Scene.setLook`); the page address (when on) overrides them, see `app/look.ts`. Presentation only. */
212
216
  readonly look?: LookInput;
213
217
  /** Many small bodies drawn as batches (dots with a pixel floor, balls close up, names on demand, orbit lines by family). Absent: none. */
214
218
  readonly bodySets?: readonly BodySetLayer[];
219
+ /** Figures and outlines drawn on the sky at infinity (EQJ unit directions). Filled by `prepare` when a star list is needed to place them; the viewer draws after it resolves. Absent: none. */
220
+ readonly skyFigures?: readonly SkyFigureLayer[];
215
221
  /** Data to load before the scene mounts (for example the curve-fit chunks of the window). The entry awaits it once. */
216
222
  readonly prepare?: () => Promise<void>;
217
223
  }
@@ -1,4 +1,5 @@
1
1
  import { catalogue as builtInCatalogue, rootBodyId } from "../assets/catalogue.js";
2
+ import { requestObjectId } from "../shell/experience.js";
2
3
  import { scaleChoicesFor } from "../shell/scaleModel.js";
3
4
  import { validateBodySet } from "./bodySet.js";
4
5
  /** The scene's far plane when an experience declares none. */
@@ -117,8 +118,9 @@ export function initialObjectIdOf(definition) {
117
118
  const config = experienceWithGroups(definition);
118
119
  const objects = config.objects;
119
120
  const start = config.cameraPresets.find((preset) => preset.id === config.startCameraPresetId)?.request;
120
- if (start !== undefined && start.kind !== "overview" && objects.some((object) => object.id === start.target))
121
- return start.target;
121
+ const startId = start === undefined ? undefined : requestObjectId(start);
122
+ if (startId !== undefined && objects.some((object) => object.id === startId))
123
+ return startId;
122
124
  const centre = sceneCenterOf(definition);
123
125
  return objects.some((object) => object.id === centre) ? centre : objects[0]?.id ?? centre;
124
126
  }
@@ -0,0 +1,17 @@
1
+ import type { CSSProperties } from "react";
2
+ export interface LabelStyle {
3
+ readonly fontFamily: string;
4
+ readonly sizePx: number;
5
+ }
6
+ /** Today's label look: the page's own font (`inherit`) at 12 px. */
7
+ export declare const DEFAULT_LABEL_STYLE: Readonly<LabelStyle>;
8
+ export { LABEL_SIZE_LIMITS } from "../core/lookValues.js";
9
+ /** The label style in force: the look's `labels`, every part not named at its default. */
10
+ export declare function labelStyleOf(look: {
11
+ readonly labels?: Partial<LabelStyle>;
12
+ }): LabelStyle;
13
+ /** The CSS variables that carry a label style on the viewer root. A part at its default sets nothing, so a viewer with the default look carries no variable and the stylesheet's own value (the same one) stands. */
14
+ export declare function labelStyleVars(style?: {
15
+ readonly fontFamily?: string;
16
+ readonly sizePx?: number;
17
+ }): CSSProperties;
@@ -0,0 +1,13 @@
1
+ /** Today's label look: the page's own font (`inherit`) at 12 px. */
2
+ export const DEFAULT_LABEL_STYLE = Object.freeze({ fontFamily: "inherit", sizePx: 12 });
3
+ export { LABEL_SIZE_LIMITS } from "../core/lookValues.js";
4
+ /** The label style in force: the look's `labels`, every part not named at its default. */
5
+ export function labelStyleOf(look) {
6
+ return { ...DEFAULT_LABEL_STYLE, ...look.labels };
7
+ }
8
+ /** The CSS variables that carry a label style on the viewer root. A part at its default sets nothing, so a viewer with the default look carries no variable and the stylesheet's own value (the same one) stands. */
9
+ export function labelStyleVars(style = {}) {
10
+ const font = style.fontFamily !== undefined && style.fontFamily !== DEFAULT_LABEL_STYLE.fontFamily;
11
+ const size = style.sizePx !== undefined && style.sizePx !== DEFAULT_LABEL_STYLE.sizePx;
12
+ return { ...(font ? { "--label-font": style.fontFamily } : {}), ...(size ? { "--label-size": `${style.sizePx}px` } : {}) };
13
+ }
@@ -3,6 +3,8 @@ import { glowLookOf, markerSettingsOf } from "./bodyDraw.js";
3
3
  import { featureMinBodyPxOf } from "./FeatureMarkers.js";
4
4
  import { resolveLook } from "./look.js";
5
5
  import { resolveSkySettings } from "./skyModel.js";
6
+ import { labelStyleOf } from "./labelStyle.js";
7
+ import { skyColoursOf, skyFadeInSecondsOf } from "./skyFigures.js";
6
8
  /** The sky settings in force: the experience's own, then the look (the scene's `setLook`, with the address over it). The Milky Way switch's start sits between the two. */
7
9
  export function skySettingsOf(definition, look) {
8
10
  const settings = resolveSkySettings(definition.sky);
@@ -30,7 +32,10 @@ export function lookReadOf(controls) {
30
32
  markerSwapRadiusPx: controls.bodyMarker.minSpherePx,
31
33
  featureMinBodyPx: featureMinBodyPxOf({ featureMinBodyPx: controls.featureMinBodyPx }),
32
34
  loadFadeSeconds: controls.loadFadeSeconds ?? bootFadeSeconds(),
35
+ skyFadeInSeconds: controls.skyFadeInSeconds,
33
36
  desktopPictures: controls.desktopPictures,
37
+ skyLines: { ...controls.skyColours },
38
+ labels: { ...controls.labelStyle },
34
39
  };
35
40
  }
36
41
  /**
@@ -49,6 +54,9 @@ export function applyLook(controls, definition, glowBase, input) {
49
54
  controls.bodyMarker = { ...controls.bodyMarker, minSpherePx: markerSettingsOf(look).minSpherePx };
50
55
  controls.featureMinBodyPx = featureMinBodyPxOf(look);
51
56
  controls.loadFadeSeconds = bootFadeSeconds(look);
57
+ controls.skyColours = skyColoursOf(look);
58
+ controls.skyFadeInSeconds = skyFadeInSecondsOf(look);
59
+ controls.labelStyle = labelStyleOf(look);
52
60
  return lookReadOf(controls);
53
61
  }
54
62
  /** The host's view of the presentation: `items` (read fresh each time) are the display switches the scene placed (those with something to act on), so a switch is read and set exactly as its visible button does. */
package/src/app/look.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { LookInput } from "../api/look.js";
7
7
  export type { LookInput } from "../api/look.js";
8
8
  /** The address parameters that set a look. */
9
9
  export type LookParam = "stars" | "milkyway" | "milkywaybrightness" | "sky" | "sunglow" | "sunbrightness" | "sunglowscale" | "markerpx" | "featurepx" | "loadfade" | "desktop";
10
- /** How a look is written: a number in a range, an `on`/`off` switch, or a switch the address can only turn off. */
10
+ /** How a look is written: a number in a range, an `on`/`off` switch, a switch the address can only turn off, a CSS colour text or a font-family text. */
11
11
  export type LookKind = {
12
12
  readonly kind: "range";
13
13
  readonly min: number;
@@ -16,11 +16,15 @@ export type LookKind = {
16
16
  readonly kind: "onoff";
17
17
  } | {
18
18
  readonly kind: "offOnly";
19
+ } | {
20
+ readonly kind: "colour";
21
+ } | {
22
+ readonly kind: "font";
19
23
  };
20
- /** One look: where it sits in `LookInput` (`["sunGlow", "sizePx"]` for a nested one), its address parameter and how it is written. */
24
+ /** One look: where it sits in `LookInput` (`["sunGlow", "sizePx"]` for a nested one), its address parameter (null: the look has none, it is set only with `setLook`) and how it is written. */
21
25
  export interface LookField {
22
26
  readonly path: readonly [string] | readonly [string, string];
23
- readonly param: LookParam;
27
+ readonly param: LookParam | null;
24
28
  readonly spec: LookKind;
25
29
  }
26
30
  /** Every look. The one table; the order is the order of `LookInput`. */
@@ -28,8 +32,8 @@ export declare const LOOK_FIELDS: readonly LookField[];
28
32
  /** The name a look is called in a message: `sunGlow.sizePx`. */
29
33
  export declare const lookName: (field: LookField) => string;
30
34
  /** The value a look has in `look`, or undefined. */
31
- export declare function lookValue(look: LookInput, field: LookField): number | boolean | undefined;
32
- declare function withValue(look: LookInput, field: LookField, value: number | boolean): LookInput;
35
+ export declare function lookValue(look: LookInput, field: LookField): number | boolean | string | undefined;
36
+ declare function withValue(look: LookInput, field: LookField, value: number | boolean | string): LookInput;
33
37
  /** Sets a look in a copy of `look` (used by `Scene.setLook` to build the checked look). */
34
38
  export declare const lookWith: typeof withValue;
35
39
  /** The looks in force: `base` (what the scene set) with the address text laid over it (`search` is empty when the host's `address` option is off). Pure; a live change (T-262) resolves a new base the same way. */
package/src/app/look.js CHANGED
@@ -1,4 +1,6 @@
1
+ import { LABEL_SIZE_LIMITS } from "../core/lookValues.js";
1
2
  const range = (path, param, min, max) => ({ path, param, spec: { kind: "range", min, max } });
3
+ const colour = (name) => ({ path: ["skyLines", name], param: null, spec: { kind: "colour" } });
2
4
  /** Every look. The one table; the order is the order of `LookInput`. */
3
5
  export const LOOK_FIELDS = [
4
6
  range(["starBrightness"], "stars", 0, 2),
@@ -11,7 +13,12 @@ export const LOOK_FIELDS = [
11
13
  range(["markerSwapRadiusPx"], "markerpx", 0, 100),
12
14
  range(["featureMinBodyPx"], "featurepx", 0, 2000),
13
15
  range(["loadFadeSeconds"], "loadfade", 0, 3),
16
+ range(["skyFadeInSeconds"], null, 0, 3),
14
17
  { path: ["desktopPictures"], param: "desktop", spec: { kind: "onoff" } },
18
+ // Sky line colours and the label font and size have no address parameter (T-296, owner decision): they are set with `setLook` and the Developer drawer only.
19
+ colour("figure"), colour("label"), colour("boundary"), colour("ecliptic"), colour("equator"), colour("traced"), colour("faded"), colour("selected"),
20
+ { path: ["labels", "fontFamily"], param: null, spec: { kind: "font" } },
21
+ range(["labels", "sizePx"], null, LABEL_SIZE_LIMITS.min, LABEL_SIZE_LIMITS.max),
15
22
  ];
16
23
  /** The name a look is called in a message: `sunGlow.sizePx`. */
17
24
  export const lookName = (field) => field.path.join(".");
@@ -34,10 +41,14 @@ function rawParam(search, param) {
34
41
  }
35
42
  /** What one address parameter says: the value, or undefined when it is absent or unusable (an unusable number warns on the console, never throws). */
36
43
  function fromAddress(search, field) {
44
+ if (field.param === null)
45
+ return undefined;
37
46
  const raw = rawParam(search, field.param);
38
47
  if (raw === null)
39
48
  return undefined;
40
49
  const { spec } = field;
50
+ if (spec.kind === "colour" || spec.kind === "font")
51
+ return undefined;
41
52
  if (spec.kind === "onoff")
42
53
  return raw === "on" ? true : raw === "off" ? false : undefined;
43
54
  if (spec.kind === "offOnly")
@@ -0,0 +1,32 @@
1
+ import { type SkyView } from "../core/startView.js";
2
+ import type { RenderVector } from "./renderCoordinates.js";
3
+ /** What a camera that stands inside a body carries beyond the orbit angles: the field of view is its zoom. The look direction is the orbit state's azimuth and elevation about the up in force. */
4
+ export interface LookOutState {
5
+ /** Vertical field of view in degrees, within `LOOK_OUT_FOV_RANGE_DEG`. */
6
+ fovDeg: number;
7
+ }
8
+ export declare const LOOK_OUT_FOV_RANGE_DEG: {
9
+ readonly min: 5;
10
+ readonly max: 100;
11
+ };
12
+ export declare const LOOK_OUT_OPENING_FOV_DEG = 60;
13
+ /** The nearest the look-out camera draws: positive, and far inside anything a sky shows. */
14
+ export declare const LOOK_OUT_NEAR = 0.001;
15
+ export declare function clampFov(fovDeg: number): number;
16
+ export declare function clampLookElevation(elevation: number): number;
17
+ /** The angles a look-out pan changes. */
18
+ export interface LookAngles {
19
+ azimuth: number;
20
+ elevation: number;
21
+ }
22
+ /**
23
+ * Direct manipulation: a drag of `dxPx`, `dyPx` moves the sky with the pointer, so the view turns the other way. One viewport height spans the field of view,
24
+ * which makes a narrow view pan slowly. Azimuth grows leftwards about the up in force, elevation upwards.
25
+ */
26
+ export declare function panLookOut(angles: LookAngles, fovDeg: number, dxPx: number, dyPx: number, heightPx: number): void;
27
+ /** A wheel or pinch factor above 1 widens the view, below 1 narrows it. */
28
+ export declare function zoomLookOut(look: LookOutState, factor: number): void;
29
+ /** The unit direction at `azimuth` and `elevation` about `up`, given the orbit basis: the one rule the orbit offset and the look direction share. */
30
+ export declare function directionAt(azimuth: number, elevation: number, east: RenderVector, south: RenderVector, up: RenderVector): RenderVector;
31
+ /** The look-out camera as a sky reading: the way it looks (render axes, from the angles about `up`) as J2000 equatorial degrees, rounded the way a link rounds them. */
32
+ export declare function skyViewOf(body: string, azimuth: number, elevation: number, up: RenderVector, fovDeg: number): SkyView;
@@ -0,0 +1,50 @@
1
+ // Look-out camera: standing at a body's centre and turning to look around the sky. Camera-only state; nothing in State is read or written.
2
+ import { orbitBasis } from "./viewUp.js";
3
+ import { SKY_FOV_RANGE_DEG, SKY_OPENING_FOV_DEG } from "../core/startView.js";
4
+ export const LOOK_OUT_FOV_RANGE_DEG = SKY_FOV_RANGE_DEG;
5
+ export const LOOK_OUT_OPENING_FOV_DEG = SKY_OPENING_FOV_DEG;
6
+ /** The nearest the look-out camera draws: positive, and far inside anything a sky shows. */
7
+ export const LOOK_OUT_NEAR = 1e-3;
8
+ const MAX_LOOK_ELEVATION = (89 * Math.PI) / 180;
9
+ /** Azimuth turns faster near the zenith; the pan divides by cos(elevation) down to this floor so a drag stays under the finger without running away at the pole. */
10
+ const MIN_PAN_COS = 0.1;
11
+ export function clampFov(fovDeg) {
12
+ return Math.min(LOOK_OUT_FOV_RANGE_DEG.max, Math.max(LOOK_OUT_FOV_RANGE_DEG.min, fovDeg));
13
+ }
14
+ export function clampLookElevation(elevation) {
15
+ return Math.max(-MAX_LOOK_ELEVATION, Math.min(MAX_LOOK_ELEVATION, elevation));
16
+ }
17
+ /**
18
+ * Direct manipulation: a drag of `dxPx`, `dyPx` moves the sky with the pointer, so the view turns the other way. One viewport height spans the field of view,
19
+ * which makes a narrow view pan slowly. Azimuth grows leftwards about the up in force, elevation upwards.
20
+ */
21
+ export function panLookOut(angles, fovDeg, dxPx, dyPx, heightPx) {
22
+ const perPx = ((fovDeg * Math.PI) / 180) / heightPx;
23
+ angles.azimuth += (dxPx * perPx) / Math.max(MIN_PAN_COS, Math.cos(angles.elevation));
24
+ angles.elevation = clampLookElevation(angles.elevation + dyPx * perPx);
25
+ }
26
+ /** A wheel or pinch factor above 1 widens the view, below 1 narrows it. */
27
+ export function zoomLookOut(look, factor) {
28
+ look.fovDeg = clampFov(look.fovDeg * factor);
29
+ }
30
+ /** The unit direction at `azimuth` and `elevation` about `up`, given the orbit basis: the one rule the orbit offset and the look direction share. */
31
+ export function directionAt(azimuth, elevation, east, south, up) {
32
+ const cosEl = Math.cos(elevation);
33
+ const [sa, ca, se] = [Math.sin(azimuth), Math.cos(azimuth), Math.sin(elevation)];
34
+ return [0, 1, 2].map((k) => cosEl * (sa * east[k] + ca * south[k]) + se * up[k]);
35
+ }
36
+ const round2 = (value) => Number(value.toFixed(2));
37
+ /** The look-out camera as a sky reading: the way it looks (render axes, from the angles about `up`) as J2000 equatorial degrees, rounded the way a link rounds them. */
38
+ export function skyViewOf(body, azimuth, elevation, up, fovDeg) {
39
+ const { east, south } = orbitBasis(up);
40
+ const [rx, ry, rz] = directionAt(azimuth, elevation, east, south, up);
41
+ // The inverse of `eqjToRenderVector`: render (x, y, z) is EQJ (x, -z, y).
42
+ const [x, y, z] = [rx, -rz, ry];
43
+ const deg = 180 / Math.PI;
44
+ return {
45
+ lookOut: body,
46
+ raDeg: round2(((Math.atan2(y, x) * deg) % 360 + 360) % 360) % 360,
47
+ decDeg: round2(Math.asin(Math.max(-1, Math.min(1, z))) * deg),
48
+ fovDeg: round2(fovDeg),
49
+ };
50
+ }
@@ -1,14 +1,16 @@
1
1
  import type { BodyCatalogue } from "../assets/catalogue.js";
2
2
  import type { BodyId } from "../core/body.js";
3
- import { type CameraRequest, type OrbitCameraState } from "./CameraController.js";
3
+ import { type CameraRequest, type LookOutRequest, type OrbitCameraState } from "./CameraController.js";
4
4
  import type { CameraReach } from "./experienceDefinition.js";
5
5
  import type { RenderVector } from "./renderCoordinates.js";
6
6
  import { type SceneFrame } from "./sceneFraming.js";
7
7
  import { type SceneTargets } from "./sceneTargets.js";
8
- import type { StartView } from "./viewLink.js";
8
+ import { type CameraView } from "../core/startView.js";
9
+ /** What the scene opens on: a view in numbers, or a look-out request whose direction is an id, resolved on the first frame as a `setCamera` look-out is (the figure aim already applied, `aimAtFigure`). */
10
+ export type OpeningView = CameraView | LookOutRequest;
9
11
  /** The two control fields the camera step reads and clears. */
10
12
  export interface CameraControls {
11
- startView?: StartView;
13
+ startView?: OpeningView;
12
14
  cameraRequest: CameraRequest | null;
13
15
  /** The host's last `setCamera`, kept apart from `cameraRequest` so the opening view and a view's own camera rule cannot discard it (the host-call order rule). */
14
16
  hostCameraRequest?: CameraRequest | null;
@@ -2,7 +2,10 @@ import { clampDistance, switchFocus, } from "./CameraController.js";
2
2
  import { PathView, pathReachKm } from "./PathView.js";
3
3
  import { defaultDistance, fitDistance, focusLimits, GROUP_FRAMING, scaleLength, startsInsideFocus, TRACKED_DEFAULT_DISTANCE, } from "./sceneFraming.js";
4
4
  import { canFocus, focusAbsoluteOf, framedViewOf } from "./sceneTargets.js";
5
+ import { clampFov, clampLookElevation, LOOK_OUT_OPENING_FOV_DEG } from "./lookOut.js";
6
+ import { eqjToRenderVector } from "./renderCoordinates.js";
5
7
  import { orbitAnglesFor, orbitBasis } from "./viewUp.js";
8
+ import { eqjUnitVector, isSkyView } from "../core/startView.js";
6
9
  /** Keeps the same relative framing when the visual scale changes (physical state is untouched). */
7
10
  export function rescaleCameraForPolicy(camState, sceneCenter, factor) {
8
11
  if (camState.focus === sceneCenter)
@@ -33,8 +36,13 @@ function applyStartView(camState, view) {
33
36
  function openFirstFrame(input) {
34
37
  const { camState, controls, targets, frame, reach } = input;
35
38
  const view = controls.startView;
36
- if (view !== undefined && canFocus(targets, view.focus)) {
37
- applyStartView(camState, view);
39
+ // A sky view opens through the same look-out step as a request does.
40
+ const opening = view === undefined || "kind" in view || !isSkyView(view) ? view : { kind: "lookOut", body: view.lookOut, direction: eqjUnitVector(view.raDeg, view.decDeg), fovDeg: view.fovDeg };
41
+ if (opening !== undefined && canFocus(targets, "kind" in opening ? opening.body : opening.focus)) {
42
+ if ("kind" in opening)
43
+ applyLookOut(input, opening);
44
+ else
45
+ applyStartView(camState, opening);
38
46
  // The opening view replaces any request made before the first frame, except the host's: that one is applied after it.
39
47
  controls.cameraRequest = controls.hostCameraRequest ?? null;
40
48
  return false;
@@ -72,8 +80,61 @@ function faceParent(camState, targets, viewUp, body, parent) {
72
80
  camState.targetElevation = Math.asin(along(viewUp) / distance);
73
81
  camState.targetAzimuth = Math.atan2(along(east), along(south));
74
82
  }
83
+ /** The render-frame direction a look-out request names: an EQJ vector, or the way from the body to the object to turn toward. Null when it names no direction. */
84
+ function lookDirectionOf(input, request) {
85
+ const { targets } = input;
86
+ let direction;
87
+ if (request.direction === undefined) {
88
+ direction = eqjToRenderVector([1, 0, 0]);
89
+ }
90
+ else if (typeof request.direction === "string") {
91
+ if (!canFocus(targets, request.direction))
92
+ return null;
93
+ const from = focusAbsoluteOf(targets, request.body);
94
+ const to = focusAbsoluteOf(targets, request.direction);
95
+ direction = [to[0] - from[0], to[1] - from[1], to[2] - from[2]];
96
+ }
97
+ else {
98
+ direction = eqjToRenderVector(request.direction);
99
+ }
100
+ return direction.every(Number.isFinite) && Math.hypot(...direction) > 0 ? direction : null;
101
+ }
102
+ /** Stands the camera at the body's centre looking along the requested direction; nothing happens for a body or direction it cannot resolve. */
103
+ function applyLookOut(input, request) {
104
+ const { camState, targets, viewUp } = input;
105
+ if (!canFocus(targets, request.body))
106
+ return;
107
+ // No direction: keep the one already looked along while looking out, else right ascension 0, declination 0.
108
+ const keep = request.direction === undefined && camState.lookOut !== null;
109
+ const direction = lookDirectionOf(input, request);
110
+ const angles = direction === null ? null : orbitAnglesFor(direction, viewUp);
111
+ if (angles === null && !keep)
112
+ return;
113
+ camState.focus = request.body;
114
+ camState.fixedPoint = null;
115
+ camState.transition.fill(0);
116
+ if (angles !== null && !keep) {
117
+ camState.azimuth = camState.targetAzimuth = angles.azimuth;
118
+ camState.elevation = camState.targetElevation = clampLookElevation(angles.elevation);
119
+ }
120
+ camState.lookOut = { fovDeg: clampFov(request.fovDeg ?? camState.lookOut?.fovDeg ?? LOOK_OUT_OPENING_FOV_DEG) };
121
+ }
122
+ /** Back to the orbit camera: the target tween starts from where the camera stood, not from the aiming point one unit out. */
123
+ function leaveLookOut(camState) {
124
+ if (camState.lookOut === null)
125
+ return;
126
+ camState.lookOut = null;
127
+ for (let i = 0; i < 3; i += 1)
128
+ camState.targetAbsolute[i] = camState.cameraAbsolute[i];
129
+ }
75
130
  function applyCameraRequest(input, request) {
76
131
  const { camState, targets, frame, catalogue, viewUp } = input;
132
+ if (request.kind === "lookOut")
133
+ return applyLookOut(input, request);
134
+ // A hold would keep the aiming point as a place; looking out already holds the camera where it stands.
135
+ if (request.kind === "hold" && camState.lookOut !== null)
136
+ return;
137
+ leaveLookOut(camState);
77
138
  if (request.kind === "hold") {
78
139
  // The target stops where it is (including any tween still running); angles and distance are untouched. Scene-frame state only: nothing in State changes.
79
140
  const now = cameraTargetAbsolute(camState, targets);
@@ -104,7 +165,9 @@ function applyCameraRequest(input, request) {
104
165
  function keepViewOnUpChange(camState, previousUp, viewUp) {
105
166
  if (previousUp === null || !previousUp.some((v, k) => v !== viewUp[k]))
106
167
  return;
107
- const offset = [0, 1, 2].map((k) => camState.cameraAbsolute[k] - camState.targetAbsolute[k]);
168
+ // Orbiting, the angles are of the camera's offset from its target; looking out, of the way it looks (the target is a unit ahead).
169
+ const side = camState.lookOut === null ? 1 : -1;
170
+ const offset = [0, 1, 2].map((k) => side * (camState.cameraAbsolute[k] - camState.targetAbsolute[k]));
108
171
  const angles = orbitAnglesFor(offset, viewUp);
109
172
  if (angles === null)
110
173
  return;
@@ -9,6 +9,7 @@ import type { BodyRefs } from "./sceneBodies.js";
9
9
  import { type FrameLayers, type FrameState } from "./sceneFrame.js";
10
10
  import { type useSceneViews } from "./sceneHooks.js";
11
11
  import { type ScenePlacement } from "./sceneLayout.js";
12
+ import type { SkyLabelSpec } from "./SkyFiguresView.js";
12
13
  import type { BodySetView } from "./BodySetView.js";
13
14
  import { type TrackedBodyView } from "./TrackedBodyView.js";
14
15
  /** The catalogued body a focus or label id names: the Sun's shell item stands for the Sun body. */
@@ -48,7 +49,7 @@ export declare function useSceneDerived(runtime: SceneRuntime, catalogue: BodyCa
48
49
  }[];
49
50
  };
50
51
  /** Mounts every DOM layer the frame updates (names, anchor labels, story and feature markers) and returns the refs the frame reads. */
51
- export declare function useOverlayLayers(canvas: HTMLCanvasElement, controls: SceneControls, trackedViews: readonly TrackedBodyView[], bodySetViews: readonly BodySetView[]): FrameLayers;
52
+ export declare function useOverlayLayers(canvas: HTMLCanvasElement, controls: SceneControls, trackedViews: readonly TrackedBodyView[], bodySetViews: readonly BodySetView[], skyLabels?: readonly SkyLabelSpec[]): FrameLayers;
52
53
  /** Wires the canvas's orbit gestures, hover and tap picking to the camera and frame state. */
53
54
  export declare function useScenePointer(canvas: HTMLCanvasElement, runtime: SceneRuntime, controls: SceneControls, catalogue: BodyCatalogue, orbit: {
54
55
  current: OrbitCameraState;
@@ -52,8 +52,9 @@ export function useSceneDerived(runtime, catalogue) {
52
52
  const bodyFamilies = useMemo(() => (runtime.bodySets ?? []).flatMap((layer) => Object.entries(layer.bodyFamilies ?? {}).map(([body, family]) => ({ layer, body, family }))), [runtime.bodySets]);
53
53
  return { placement, readoutPair, pairLabels, assets, bodyFamilies };
54
54
  }
55
+ const NO_SKY_LABELS = [];
55
56
  /** Mounts every DOM layer the frame updates (names, anchor labels, story and feature markers) and returns the refs the frame reads. */
56
- export function useOverlayLayers(canvas, controls, trackedViews, bodySetViews) {
57
+ export function useOverlayLayers(canvas, controls, trackedViews, bodySetViews, skyLabels = NO_SKY_LABELS) {
57
58
  const bodySetLabels = useRef([]);
58
59
  const anchorLabels = useRef(null);
59
60
  const sceneLabels = useRef(null);
@@ -69,7 +70,7 @@ export function useOverlayLayers(canvas, controls, trackedViews, bodySetViews) {
69
70
  layer.dispose(); bodySetLabels.current = []; };
70
71
  }, [canvas, bodySetViews, controls]);
71
72
  useHostLayer(canvas, anchorLabels, (host) => new AnchorLabelLayer(host, trackedViews), [canvas, trackedViews]);
72
- useHostLayer(canvas, sceneLabels, (host) => new SceneLabelLayer(host, controls.labelObjects), [canvas, controls.labelObjects]);
73
+ useHostLayer(canvas, sceneLabels, (host) => new SceneLabelLayer(host, controls.labelObjects, skyLabels), [canvas, controls.labelObjects, skyLabels]);
73
74
  useHostLayer(canvas, storyMarkers, (host) => (controls.storyMarkers === undefined || controls.storyMarkers.length === 0 ? null : new StoryMarkerLayer(host, controls.storyMarkers, (panelId) => controls.onStoryMarker?.(panelId))), [canvas, controls]);
74
75
  useHostLayer(canvas, featureMarkers, (host) => (controls.featureMarkers === undefined || controls.featureMarkers.length === 0 ? null : new FeatureMarkerLayer(host, controls.featureMarkers, (key) => controls.onFeatureMarker?.(key))), [canvas, controls]);
75
76
  return { bodySetLabels, anchorLabels, sceneLabels, storyMarkers, featureMarkers };
@@ -15,10 +15,11 @@ import type { SceneControls, SceneReadout, SceneRuntime } from "./AstraeusScene.
15
15
  import { type BodyRefs } from "./sceneBodies.js";
16
16
  import type { useSceneViews } from "./sceneHooks.js";
17
17
  import { type PlacedComposition, type ScenePlacement } from "./sceneLayout.js";
18
- import { type PickCandidate } from "./scenePicking.js";
18
+ import { type PickCandidate, type SkyPickFigure } from "./scenePicking.js";
19
19
  import type { SceneLabelLayer } from "./SceneLabels.js";
20
20
  import { type SceneTargets } from "./sceneTargets.js";
21
21
  import type { StoryMarkerLayer } from "./StoryMarkers.js";
22
+ import { type ViewHidden } from "./viewHiding.js";
22
23
  /** What survives from one frame to the next. The component owns one and hands it to every frame. */
23
24
  export interface FrameState {
24
25
  started: boolean;
@@ -35,6 +36,8 @@ export interface FrameState {
35
36
  x: number;
36
37
  y: number;
37
38
  } | null;
39
+ /** The sky figures a tap can select (names and lines, screen px from the canvas); read by a tap only. */
40
+ skyFigures: () => readonly SkyPickFigure[];
38
41
  /** Whether the renderer should draw this frame (`decideDraw`). True until the first frame has decided. */
39
42
  drawThisFrame: boolean;
40
43
  /** Frames the renderer has drawn since mount (`data-frames-drawn`). */
@@ -128,8 +131,11 @@ export interface CameraStep {
128
131
  export declare function viewUpOf(ctx: Pick<FrameContext, "runtime" | "controls">): RenderVector;
129
132
  /** A frame is drawn only once every body's group and orientation node is mounted. */
130
133
  export declare function bodiesMounted(runtime: SceneRuntime, refs: BodyRefs): boolean;
131
- /** Stage 0: the time of this frame; looping playback wraps inside its window first, and other playback stops on the window's edge (a scene with a timeline bar). */
132
- export declare function frameTime(runtime: SceneRuntime, controls: Pick<SceneControls, "loop" | "paceAuto" | "pace">): number;
134
+ /**
135
+ * Stage 0: the time of this frame. While pacing is in charge the clock is first stepped through the frame's real time under the paced rate (so no frame passes over a slow-down); looping playback then wraps inside its window,
136
+ * and other playback stops on the window's edge (a scene with a timeline bar). A wrap or stop lands on the paced rate for its new time at once.
137
+ */
138
+ export declare function frameTime(runtime: SceneRuntime, controls: Pick<SceneControls, "loop" | "paceAuto" | "pace">, nowMs?: number): number;
133
139
  /** Stage 1: brings every view to the time of the frame. Returns the live body-set look. */
134
140
  export declare function syncViews(ctx: FrameContext, t: number): BodySetLook;
135
141
  /** Stage 2: places the composition about the scene centre and keeps the camera's framing when the scale policy changed. */
@@ -140,12 +146,24 @@ export declare function stepAndPoseCamera(ctx: FrameContext, t: number, placed:
140
146
  export declare function publishOrbitHeadGap(canvas: HTMLCanvasElement, views: readonly PathView[], absoluteOf: (id: BodyId) => RenderVector, policy: ScalePolicy): void;
141
147
  /** Stage 4: swaps small bodies for markers, publishes the scene's canvas readouts and updates the sky. */
142
148
  export declare function publishCanvasReadouts(ctx: FrameContext): void;
149
+ /** Stage 4b: stands the sky figures, outlines and reference circles on the camera and shows the kinds the switches say. Looks only at the camera's orientation and the switches (ARCH-02). */
150
+ export declare function placeSkyFigures(ctx: FrameContext): void;
151
+ /** Stage 4c: starts the traces and removes the ones the host asked for since the last frame (in call order) and moves every trace on by this frame's real time; a moving trace wakes the draw rule. Wall time only (CODE-02, ARCH-02). */
152
+ export declare function advanceSkyTraces(ctx: FrameContext): void;
143
153
  /** Stage 5: places every view about the floating origin and publishes the views' readouts. Returns the hover brightness gain. */
144
154
  export declare function placeViews(ctx: FrameContext, t: number, placed: PlacedScene, setLook: BodySetLook): number;
155
+ /** What this frame hides: the view's hidden ids, the objects not shown at clock time `t` (`shownDuring`; none when `t` is not given), and the body the camera stands inside while looking out (the one hidden-set path, read by the visibility, label and tap stages). */
156
+ export declare function hiddenOf(ctx: Pick<FrameContext, "controls" | "orbit">, t?: number): ViewHidden | undefined;
145
157
  /** Stage 5b: shows or hides each drawn group by the current view's hidden ids (bodies, paths, point groups, body sets). One set, read here; nothing is rebuilt. */
146
- export declare function applyViewVisibility(ctx: FrameContext): void;
158
+ export declare function applyViewVisibility(ctx: FrameContext, t?: number): void;
147
159
  /** A mounted body's drawn sphere and radius for the feature markers, or null when the body is not drawn as a sphere. */
148
160
  export declare function featureHostOf(assets: readonly BodyAsset[], parts: ReadonlyMap<BodyId, BodyParts>, id: string, policy: ScalePolicy): FeatureHost | null;
161
+ /** What the labels and taps see under the current view: the objects and body sets it shows, and the label-hidden ids with the view's own added. Allocates only when a view hides something. */
162
+ export declare function shownUnderView(ctx: FrameContext, t?: number): {
163
+ objects: readonly import("../shell/experience.js").ExperienceObject[];
164
+ bodySetViews: import("./BodySetView.js").BodySetView[];
165
+ hiddenLabels: Set<string> | undefined;
166
+ };
149
167
  /** Stage 6: updates the overlay layers (names, story and feature markers) and rebuilds what a tap or hover can pick. */
150
168
  export declare function updateOverlays(ctx: FrameContext, t: number, step: CameraStep, hoverGain: number): void;
151
169
  /** Stage 7: places each body's light and builds the frame readout the shell reads. */