astraeus 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +46 -17
  3. package/data/ephemerides/planets/planets.json +1 -1
  4. package/package.json +1 -1
  5. package/src/api/AstraeusScene.d.ts +1 -1
  6. package/src/api/AstraeusScene.js +4 -1
  7. package/src/api/AstraeusScene.node.js +4 -1
  8. package/src/api/assembleScene.d.ts +2 -0
  9. package/src/api/assembleScene.js +27 -5
  10. package/src/api/cameraRequest.d.ts +15 -0
  11. package/src/api/cameraRequest.js +89 -0
  12. package/src/api/errors.d.ts +10 -0
  13. package/src/api/index.d.ts +6 -3
  14. package/src/api/look.d.ts +49 -0
  15. package/src/api/lookInput.d.ts +1 -1
  16. package/src/api/lookInput.js +6 -1
  17. package/src/api/planCamera.d.ts +35 -7
  18. package/src/api/planCamera.js +94 -11
  19. package/src/api/planSkyFigures.d.ts +22 -0
  20. package/src/api/planSkyFigures.js +145 -0
  21. package/src/api/planStory.d.ts +2 -2
  22. package/src/api/planStory.js +14 -9
  23. package/src/api/planViews.js +1 -1
  24. package/src/api/scene.d.ts +17 -4
  25. package/src/api/scene.js +23 -5
  26. package/src/api/sceneReads.d.ts +21 -2
  27. package/src/api/skyFigureInput.d.ts +45 -0
  28. package/src/api/skyFigureInput.js +1 -0
  29. package/src/api/skyTraceInput.d.ts +33 -0
  30. package/src/api/skyTraceInput.js +45 -0
  31. package/src/api/story.d.ts +12 -3
  32. package/src/api/story.js +44 -1
  33. package/src/api/viewerCamera.d.ts +4 -3
  34. package/src/api/viewerCamera.js +10 -32
  35. package/src/api/viewerHandle.d.ts +34 -5
  36. package/src/api/viewerHandle.js +7 -0
  37. package/src/api/viewerLink.d.ts +50 -4
  38. package/src/api/viewerLink.js +33 -2
  39. package/src/api/viewerPanels.d.ts +26 -0
  40. package/src/api/viewerPanels.js +42 -0
  41. package/src/api/viewerSelection.d.ts +6 -1
  42. package/src/api/viewerSelection.js +15 -0
  43. package/src/api/views.d.ts +3 -1
  44. package/src/api/views.js +5 -1
  45. package/src/app/App.js +118 -16
  46. package/src/app/App.node.js +118 -16
  47. package/src/app/AstraeusScene.d.ts +22 -5
  48. package/src/app/AstraeusScene.js +3 -3
  49. package/src/app/CameraController.d.ts +17 -0
  50. package/src/app/CameraController.js +34 -9
  51. package/src/app/DeveloperSettings.d.ts +11 -3
  52. package/src/app/DeveloperSettings.js +13 -3
  53. package/src/app/SceneLabels.d.ts +20 -2
  54. package/src/app/SceneLabels.js +46 -6
  55. package/src/app/SkyFiguresView.d.ts +56 -0
  56. package/src/app/SkyFiguresView.js +242 -0
  57. package/src/app/StoryMarkers.d.ts +2 -2
  58. package/src/app/StoryMarkers.js +2 -2
  59. package/src/app/displaySwitches.d.ts +13 -3
  60. package/src/app/displaySwitches.js +17 -3
  61. package/src/app/experienceDefinition.d.ts +9 -3
  62. package/src/app/experienceDefinition.js +4 -2
  63. package/src/app/labelStyle.d.ts +17 -0
  64. package/src/app/labelStyle.js +13 -0
  65. package/src/app/liveLook.js +8 -0
  66. package/src/app/look.d.ts +9 -5
  67. package/src/app/look.js +11 -0
  68. package/src/app/lookOut.d.ts +32 -0
  69. package/src/app/lookOut.js +50 -0
  70. package/src/app/sceneCamera.d.ts +7 -3
  71. package/src/app/sceneCamera.js +68 -4
  72. package/src/app/sceneContentsHooks.d.ts +2 -1
  73. package/src/app/sceneContentsHooks.js +3 -2
  74. package/src/app/sceneFrame.d.ts +10 -1
  75. package/src/app/sceneFrame.js +45 -10
  76. package/src/app/sceneFraming.d.ts +7 -0
  77. package/src/app/sceneFraming.js +12 -0
  78. package/src/app/sceneHooks.d.ts +2 -0
  79. package/src/app/sceneHooks.js +4 -1
  80. package/src/app/scenePicking.d.ts +20 -0
  81. package/src/app/scenePicking.js +49 -0
  82. package/src/app/scenePointer.d.ts +3 -1
  83. package/src/app/scenePointer.js +3 -2
  84. package/src/app/skyFigures.d.ts +73 -0
  85. package/src/app/skyFigures.js +50 -0
  86. package/src/app/style.css +2 -1
  87. package/src/app/viewHiding.d.ts +2 -0
  88. package/src/app/viewHiding.js +7 -1
  89. package/src/app/viewLink.d.ts +8 -8
  90. package/src/app/viewLink.js +24 -4
  91. package/src/app/viewerPort.d.ts +32 -3
  92. package/src/app/views.d.ts +2 -0
  93. package/src/assets/sky.d.ts +13 -4
  94. package/src/assets/sky.js +33 -8
  95. package/src/assets/stars/hyg-v42-naked-eye.json +1 -1
  96. package/src/core/astronomyAdapter.d.ts +1 -1
  97. package/src/core/astronomyAdapter.js +3 -3
  98. package/src/core/bodies/index.js +13 -12
  99. package/src/core/bodies/jupiter.js +1 -1
  100. package/src/core/bodies/mars.js +1 -1
  101. package/src/core/bodies/mercury.js +1 -1
  102. package/src/core/bodies/moonSystem.js +1 -15
  103. package/src/core/bodies/outerPlanets.d.ts +2 -3
  104. package/src/core/bodies/outerPlanets.js +4 -13
  105. package/src/core/bodies/planetMoons.d.ts +0 -2
  106. package/src/core/bodies/planetMoons.js +1 -18
  107. package/src/core/bodies/planetRecords.d.ts +8 -2
  108. package/src/core/bodies/planetRecords.js +13 -5
  109. package/src/core/bodies/planetTrajectory.d.ts +21 -4
  110. package/src/core/bodies/planetTrajectory.js +28 -4
  111. package/src/core/bodies/venus.js +1 -1
  112. package/src/core/lookValues.d.ts +9 -0
  113. package/src/core/lookValues.js +24 -0
  114. package/src/core/planetModels.d.ts +1 -1
  115. package/src/core/planetModels.js +1 -1
  116. package/src/core/planetSeries.d.ts +2 -2
  117. package/src/core/planetSeries.js +1 -1
  118. package/src/core/readBytes.d.ts +1 -0
  119. package/src/core/readBytes.js +15 -0
  120. package/src/core/skyTrace.d.ts +49 -0
  121. package/src/core/skyTrace.js +39 -0
  122. package/src/core/startView.d.ts +39 -0
  123. package/src/core/startView.js +56 -0
  124. package/src/core/storyPanels.d.ts +51 -3
  125. package/src/core/storyPanels.js +52 -12
  126. package/src/shell/AstraeusShell.d.ts +27 -6
  127. package/src/shell/AstraeusShell.js +104 -18
  128. package/src/shell/AstraeusShell.node.js +104 -18
  129. package/src/shell/ObjectControls.js +11 -8
  130. package/src/shell/StoryPanelView.d.ts +12 -3
  131. package/src/shell/StoryPanelView.js +2 -2
  132. package/src/shell/experience.d.ts +24 -0
  133. package/src/shell/experience.js +4 -1
  134. package/src/shell/infoModel.js +9 -1
  135. package/src/shell/objectModel.d.ts +6 -2
  136. package/src/shell/objectModel.js +10 -1
  137. package/src/shell/phone.css +1 -1
  138. package/src/shell/storyPanels.d.ts +1 -1
  139. package/src/shell/storyPanels.js +1 -1
  140. package/src/shell/style.css +9 -1
  141. package/src/shell/topBarIcons.d.ts +1 -0
  142. package/src/shell/topBarIcons.js +1 -0
  143. package/src/shell/useStoryPanels.d.ts +9 -6
  144. 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,15 +1,19 @@
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;
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). */
16
+ hostCameraRequest?: CameraRequest | null;
13
17
  }
14
18
  export interface CameraStepInput {
15
19
  readonly camState: OrbitCameraState;
@@ -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,9 +36,15 @@ 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);
38
- controls.cameraRequest = null;
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);
46
+ // The opening view replaces any request made before the first frame, except the host's: that one is applied after it.
47
+ controls.cameraRequest = controls.hostCameraRequest ?? null;
39
48
  return false;
40
49
  }
41
50
  if (controls.cameraRequest === null && startsInsideFocus(camState.distance, targets.bodyIdFor(camState.focus) ?? camState.focus, frame, targets.policy, reach)) {
@@ -71,8 +80,61 @@ function faceParent(camState, targets, viewUp, body, parent) {
71
80
  camState.targetElevation = Math.asin(along(viewUp) / distance);
72
81
  camState.targetAzimuth = Math.atan2(along(east), along(south));
73
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
+ }
74
130
  function applyCameraRequest(input, request) {
75
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);
76
138
  if (request.kind === "hold") {
77
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.
78
140
  const now = cameraTargetAbsolute(camState, targets);
@@ -103,7 +165,9 @@ function applyCameraRequest(input, request) {
103
165
  function keepViewOnUpChange(camState, previousUp, viewUp) {
104
166
  if (previousUp === null || !previousUp.some((v, k) => v !== viewUp[k]))
105
167
  return;
106
- 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]));
107
171
  const angles = orbitAnglesFor(offset, viewUp);
108
172
  if (angles === null)
109
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`). */
@@ -140,8 +143,14 @@ export declare function stepAndPoseCamera(ctx: FrameContext, t: number, placed:
140
143
  export declare function publishOrbitHeadGap(canvas: HTMLCanvasElement, views: readonly PathView[], absoluteOf: (id: BodyId) => RenderVector, policy: ScalePolicy): void;
141
144
  /** Stage 4: swaps small bodies for markers, publishes the scene's canvas readouts and updates the sky. */
142
145
  export declare function publishCanvasReadouts(ctx: FrameContext): void;
146
+ /** 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). */
147
+ export declare function placeSkyFigures(ctx: FrameContext): void;
148
+ /** 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). */
149
+ export declare function advanceSkyTraces(ctx: FrameContext): void;
143
150
  /** Stage 5: places every view about the floating origin and publishes the views' readouts. Returns the hover brightness gain. */
144
151
  export declare function placeViews(ctx: FrameContext, t: number, placed: PlacedScene, setLook: BodySetLook): number;
152
+ /** What this frame hides: the view's hidden ids, and the body the camera stands inside while looking out (the one hidden-set path, read by the visibility, label and tap stages). */
153
+ export declare function hiddenOf(ctx: Pick<FrameContext, "controls" | "orbit">): ViewHidden | undefined;
145
154
  /** 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
155
  export declare function applyViewVisibility(ctx: FrameContext): void;
147
156
  /** A mounted body's drawn sphere and radius for the feature markers, or null when the body is not drawn as a sphere. */
@@ -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 { cameraTargetAbsolute, rescaleCameraForPolicy, stepCameraTarget } from "./sceneCamera.js";
8
8
  import { buildFrameReadout, publishBodyData, publishPathData, publishPointsData, publishSceneData, recordFrameStats } from "./sceneDebug.js";
9
- import { focusRadius, liveReach } from "./sceneFraming.js";
9
+ import { CAMERA_FOV_DEG, focusRadius, liveReach, lookOutFar } 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";
@@ -14,13 +14,16 @@ import { placeBodyLights } from "./sceneLights.js";
14
14
  import { clampHoverBrightness, HOVER_BRIGHTNESS_DEFAULT, hoverTarget, pickCandidatesOf } from "./scenePicking.js";
15
15
  import { updateSky } from "./sceneSky.js";
16
16
  import { labelPositionOf } from "./sceneTargets.js";
17
+ import { skyViewOf } from "./lookOut.js";
18
+ import { hiddenWithLookOut } from "./viewHiding.js";
17
19
  import { viewFromAngles } from "./viewLink.js";
18
20
  import { EQUATORIAL_UP } from "./viewUp.js";
21
+ import { prefersReducedMotion } from "./skyFigures.js";
19
22
  /** Floating-origin rebase threshold in scaled units (Earth radii). */
20
23
  const REBASE_THRESHOLD = 1;
21
24
  export function createFrameState(policyId, onFirstDraw) {
22
25
  return {
23
- started: false, onFirstDraw, spanScaled: 6, lastPolicyId: policyId, lastUp: null, pickables: [], hoverPoint: null,
26
+ started: false, onFirstDraw, spanScaled: 6, lastPolicyId: policyId, lastUp: null, pickables: [], hoverPoint: null, skyFigures: () => [],
24
27
  drawThisFrame: true, framesDrawn: 0, wakes: 0,
25
28
  drawn: { timeUtcMs: Number.NaN, pose: [], size: "", controls: new Map(), wakes: 0, mounted: -1, quietFrames: 0 },
26
29
  };
@@ -100,16 +103,20 @@ export function stepAndPoseCamera(ctx, t, placed) {
100
103
  const firstFrame = !state.started;
101
104
  state.started = true;
102
105
  const reach = liveReach(runtime.cameraReach, policy, camera.aspect);
103
- const focusBody = stepCameraTarget({ camState: orbit, controls, targets, frame, catalogue, reach, fovDeg: camera.fov, viewUp, firstFrame, previousUp: state.lastUp });
106
+ const focusBody = stepCameraTarget({ camState: orbit, controls, targets, frame, catalogue, reach, fovDeg: orbit.lookOut === null ? camera.fov : CAMERA_FOV_DEG, viewUp, firstFrame, previousUp: state.lastUp });
104
107
  state.lastUp = viewUp;
105
108
  resolveCamera(orbit, cameraTargetAbsolute(orbit, targets), ctx.origin, ctx.delta, REBASE_THRESHOLD, viewUp);
106
109
  placeBodies(ctx.assets, placed.composed.states, ctx.bodyRefs, policy, ctx.origin);
107
- poseCamera(camera, orbit, focusRadius(focusBody, policy, catalogue), ctx.origin, reach.far ?? DEFAULT_CAMERA_FAR, viewUp);
110
+ const baseFar = reach.far ?? DEFAULT_CAMERA_FAR;
111
+ // Looking out, the camera stands at a body, so a far plane sized for orbit framing could cut off the Sun or any body beyond it: reach everything placed.
112
+ const far = orbit.lookOut === null ? baseFar : lookOutFar(baseFar, orbit.cameraAbsolute, placed.composed.absolutes);
113
+ poseCamera(camera, orbit, focusRadius(focusBody, policy, catalogue), ctx.origin, far, viewUp);
108
114
  if (firstFrame && state.onFirstDraw !== undefined) {
109
115
  const told = state.onFirstDraw;
110
116
  requestAnimationFrame(told);
111
117
  }
112
- controls.viewReadout = viewFromAngles(orbit.focus, orbit.azimuth, orbit.elevation, orbit.distance);
118
+ // Looking out, the angles are the way the camera looks, not an offset from a target: a sky reading, never orbit values.
119
+ controls.viewReadout = orbit.lookOut === null ? viewFromAngles(orbit.focus, orbit.azimuth, orbit.elevation, orbit.distance) : skyViewOf(orbit.focus, orbit.azimuth, orbit.elevation, viewUp, orbit.lookOut.fovDeg);
113
120
  return { targets };
114
121
  }
115
122
  /** Diagnostic for the browser checks: how far the first orbit arc's head is from its body's drawn position, as a share of the orbit's size (`data-orbit-head-gap`) and its longest segment as a share of the same (`data-orbit-arc-segment`). */
@@ -135,6 +142,26 @@ export function publishCanvasReadouts(ctx) {
135
142
  updateSky(views.skyView, camera, canvas, controls, controls.frameStats !== null);
136
143
  }
137
144
  }
145
+ /** 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). */
146
+ export function placeSkyFigures(ctx) {
147
+ const { controls, camera, canvas, views } = ctx;
148
+ views.skyFiguresView.place(camera, controls.skyLines, controls.skyColours, controls.selectedObjectId);
149
+ canvas.dataset.skyLines = views.skyFiguresView.shown.join(",");
150
+ }
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 function advanceSkyTraces(ctx) {
153
+ const { controls, state, views, delta } = ctx;
154
+ for (const request of controls.skyTraces.splice(0)) {
155
+ if ("after" in request)
156
+ views.skyFiguresView.startTrace(request);
157
+ else
158
+ views.skyFiguresView.clearTrace(request);
159
+ }
160
+ if (views.skyFiguresView.advanceTraces(delta, controls.skyColours, controls.skyLines, controls.selectedObjectId))
161
+ state.wakes += 1;
162
+ if (views.skyFiguresView.advanceFadeIn(delta, prefersReducedMotion() ? 0 : controls.skyFadeInSeconds, controls.skyLines))
163
+ state.wakes += 1;
164
+ }
138
165
  /** Stage 5: places every view about the floating origin and publishes the views' readouts. Returns the hover brightness gain. */
139
166
  export function placeViews(ctx, t, placed, setLook) {
140
167
  const { controls, camera, canvas, size, views, origin } = ctx;
@@ -161,9 +188,13 @@ export function placeViews(ctx, t, placed, setLook) {
161
188
  publishPointsData(canvas, views.groupViews, camera, views.bodySetViews);
162
189
  return hoverGain;
163
190
  }
191
+ /** What this frame hides: the view's hidden ids, and the body the camera stands inside while looking out (the one hidden-set path, read by the visibility, label and tap stages). */
192
+ export function hiddenOf(ctx) {
193
+ return hiddenWithLookOut(ctx.controls.viewHidden, ctx.orbit.lookOut === null ? null : ctx.orbit.focus);
194
+ }
164
195
  /** 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. */
165
196
  export function applyViewVisibility(ctx) {
166
- const hidden = ctx.controls.viewHidden?.objects;
197
+ const hidden = hiddenOf(ctx)?.objects;
167
198
  const { views, bodyRefs } = ctx;
168
199
  const show = (id, group) => { group.visible = hidden?.has(id) !== true; };
169
200
  for (const [id, group] of bodyRefs.groups)
@@ -192,7 +223,7 @@ export function featureHostOf(assets, parts, id, policy) {
192
223
  /** 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. */
193
224
  function shownUnderView(ctx) {
194
225
  const { controls, views } = ctx;
195
- const hidden = controls.viewHidden?.objects;
226
+ const hidden = hiddenOf(ctx)?.objects;
196
227
  if (hidden === undefined || hidden.size === 0)
197
228
  return { objects: controls.labelObjects, bodySetViews: views.bodySetViews, hiddenLabels: controls.hiddenLabels };
198
229
  return {
@@ -203,19 +234,21 @@ function shownUnderView(ctx) {
203
234
  }
204
235
  /** Stage 6: updates the overlay layers (names, story and feature markers) and rebuilds what a tap or hover can pick. */
205
236
  export function updateOverlays(ctx, t, step, hoverGain) {
206
- const { controls, camera, canvas, size, origin, state, layers } = ctx;
237
+ const { controls, camera, canvas, size, origin, state, layers, views } = ctx;
207
238
  const bodyScreens = bodyScreenReadouts(ctx.assets, ctx.bodyRefs, camera, camera.fov, size.height, controls.policy, controls.glowLook);
208
239
  publishBodyData(canvas, bodyScreens);
209
240
  layers.anchorLabels.current?.update(controls.showAnchorLabels, camera, size.width, size.height);
210
241
  const positionFor = (id) => labelPositionOf(step.targets, id);
211
242
  const shown = shownUnderView(ctx);
212
- layers.sceneLabels.current?.update(positionFor, camera, size.width, size.height, origin, controls.selectedObjectId, shown.hiddenLabels);
243
+ layers.sceneLabels.current?.update(positionFor, camera, size.width, size.height, origin, controls.selectedObjectId, shown.hiddenLabels, { on: controls.skyLines, labelColor: controls.skyColours.label, selectedColor: controls.skyColours.selected, opacity: (id) => ctx.views.skyFiguresView.labelOpacity(id), distance: 0.5 * (camera.near + camera.far) });
213
244
  state.pickables = pickCandidatesOf({ objects: shown.objects, bodyIdFor: ctx.bodyIdFor, bodyScreens, widthPx: size.width, heightPx: size.height, labelRects: layers.sceneLabels.current?.shownRects, canvas, bodySetViews: shown.bodySetViews });
245
+ // Sky figures are projected only when a tap asks, from this frame's camera and shown names (no per-frame work).
246
+ state.skyFigures = () => views.skyFiguresView.screenFigures(camera, size.width, size.height, controls.skyLines, layers.sceneLabels.current?.shownRects, canvas.getBoundingClientRect());
214
247
  const hover = state.hoverPoint === null ? null : hoverTarget(state.pickables, state.hoverPoint.x, state.hoverPoint.y, "mouse");
215
248
  canvas.style.cursor = hover === null ? "" : "pointer";
216
249
  canvas.dataset.pickHover = hover ?? "";
217
250
  layers.sceneLabels.current?.setHover(hover, hoverGain);
218
- layers.storyMarkers.current?.update(positionFor, camera, size.width, size.height, origin, controls.openStoryPanelId ?? null, t, controls.viewHidden);
251
+ layers.storyMarkers.current?.update(positionFor, camera, size.width, size.height, origin, controls.openStoryPanelId ?? null, t, hiddenOf(ctx));
219
252
  const featureReadout = layers.featureMarkers.current?.update((id) => featureHostOf(ctx.assets, ctx.bodyRefs.parts, id, controls.policy), camera, camera.fov, size.width, size.height, controls.openFeatureKey ?? null, controls.featureMinBodyPx ?? DEFAULT_FEATURE_MIN_BODY_PX);
220
253
  if (featureReadout !== null && featureReadout !== undefined)
221
254
  canvas.dataset.featureMarkers = JSON.stringify(featureReadout);
@@ -311,6 +344,8 @@ export function runFrame(ctx) {
311
344
  const placed = placeScene(ctx, t);
312
345
  const step = stepAndPoseCamera(ctx, t, placed);
313
346
  publishCanvasReadouts(ctx);
347
+ placeSkyFigures(ctx);
348
+ advanceSkyTraces(ctx);
314
349
  applyViewVisibility(ctx);
315
350
  const hoverGain = placeViews(ctx, t, placed, setLook);
316
351
  updateOverlays(ctx, t, step, hoverGain);