@johnmorrisdotca/wakusei-planets 0.33.0 → 0.35.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 (207) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/NOTICE.md +52 -0
  3. package/README.md +26 -3
  4. package/dist/approaches.d.ts +276 -0
  5. package/dist/approaches.js +255 -0
  6. package/dist/asteroids.d.ts +397 -0
  7. package/dist/asteroids.js +338 -0
  8. package/dist/comets.d.ts +316 -0
  9. package/dist/comets.js +404 -0
  10. package/dist/craft/bepicolombo.d.ts +1 -0
  11. package/dist/craft/bepicolombo.js +923 -0
  12. package/dist/craft/europaclipper.d.ts +1 -0
  13. package/dist/craft/europaclipper.js +342 -0
  14. package/dist/craft/hayabusa2.d.ts +1 -0
  15. package/dist/craft/hayabusa2.js +73 -0
  16. package/dist/craft/juice.d.ts +1 -0
  17. package/dist/craft/juice.js +40 -0
  18. package/dist/craft/lucy.d.ts +1 -0
  19. package/dist/craft/lucy.js +42 -0
  20. package/dist/craft/osirisapex.d.ts +1 -0
  21. package/dist/craft/osirisapex.js +69 -0
  22. package/dist/craft/psyche.d.ts +1 -0
  23. package/dist/craft/psyche.js +30 -0
  24. package/dist/craft/solarorbiter.d.ts +1 -0
  25. package/dist/craft/solarorbiter.js +94 -0
  26. package/dist/data/approaches.d.ts +17 -0
  27. package/dist/data/approaches.js +4192 -0
  28. package/dist/data/asteroids.d.ts +3 -0
  29. package/dist/data/asteroids.js +107 -0
  30. package/dist/data/comets.d.ts +2 -0
  31. package/dist/data/comets.js +36 -0
  32. package/dist/data/places-67p.d.ts +27 -0
  33. package/dist/data/places-67p.js +2 -0
  34. package/dist/data/places-ariel.d.ts +602 -0
  35. package/dist/data/places-ariel.js +27 -0
  36. package/dist/data/places-bennu.d.ts +25 -0
  37. package/dist/data/places-bennu.js +2 -0
  38. package/dist/data/places-callisto.d.ts +3547 -0
  39. package/dist/data/places-callisto.js +155 -0
  40. package/dist/data/places-ceres.d.ts +3436 -0
  41. package/dist/data/places-ceres.js +150 -0
  42. package/dist/data/places-charon.d.ts +349 -0
  43. package/dist/data/places-charon.js +16 -0
  44. package/dist/data/places-dimorphos.d.ts +23 -0
  45. package/dist/data/places-dimorphos.js +2 -0
  46. package/dist/data/places-dione.d.ts +2258 -0
  47. package/dist/data/places-dione.js +99 -0
  48. package/dist/data/places-enceladus.d.ts +2009 -0
  49. package/dist/data/places-enceladus.js +88 -0
  50. package/dist/data/places-eros.d.ts +26 -0
  51. package/dist/data/places-eros.js +2 -0
  52. package/dist/data/places-europa.d.ts +2977 -0
  53. package/dist/data/places-europa.js +130 -0
  54. package/dist/data/places-ganymede.d.ts +4518 -0
  55. package/dist/data/places-ganymede.js +197 -0
  56. package/dist/data/places-iapetus.d.ts +1616 -0
  57. package/dist/data/places-iapetus.js +71 -0
  58. package/dist/data/places-io.d.ts +6012 -0
  59. package/dist/data/places-io.js +262 -0
  60. package/dist/data/places-jupiter.d.ts +46 -0
  61. package/dist/data/places-jupiter.js +3 -0
  62. package/dist/data/places-mars.d.ts +20701 -0
  63. package/dist/data/places-mars.js +942 -0
  64. package/dist/data/places-mercury.d.ts +9256 -0
  65. package/dist/data/places-mercury.js +403 -0
  66. package/dist/data/places-mimas.d.ts +968 -0
  67. package/dist/data/places-mimas.js +43 -0
  68. package/dist/data/places-miranda.d.ts +419 -0
  69. package/dist/data/places-miranda.js +19 -0
  70. package/dist/data/places-moon.d.ts +18849 -0
  71. package/dist/data/places-moon.js +861 -0
  72. package/dist/data/places-oberon.d.ts +235 -0
  73. package/dist/data/places-oberon.js +11 -0
  74. package/dist/data/places-pluto.d.ts +1687 -0
  75. package/dist/data/places-pluto.js +74 -0
  76. package/dist/data/places-rhea.d.ts +3317 -0
  77. package/dist/data/places-rhea.js +145 -0
  78. package/dist/data/places-ryugu.d.ts +87 -0
  79. package/dist/data/places-ryugu.js +5 -0
  80. package/dist/data/places-saturn.d.ts +25 -0
  81. package/dist/data/places-saturn.js +2 -0
  82. package/dist/data/places-tempel-1.d.ts +25 -0
  83. package/dist/data/places-tempel-1.js +2 -0
  84. package/dist/data/places-tethys.d.ts +1222 -0
  85. package/dist/data/places-tethys.js +54 -0
  86. package/dist/data/places-titan.d.ts +7031 -0
  87. package/dist/data/places-titan.js +306 -0
  88. package/dist/data/places-titania.d.ts +418 -0
  89. package/dist/data/places-titania.js +19 -0
  90. package/dist/data/places-triton.d.ts +1457 -0
  91. package/dist/data/places-triton.js +64 -0
  92. package/dist/data/places-umbriel.d.ts +303 -0
  93. package/dist/data/places-umbriel.js +14 -0
  94. package/dist/data/places-venus.d.ts +9290 -0
  95. package/dist/data/places-venus.js +405 -0
  96. package/dist/data/places-vesta.d.ts +2444 -0
  97. package/dist/data/places-vesta.js +107 -0
  98. package/dist/data/roadster.d.ts +8 -0
  99. package/dist/data/roadster.js +686 -0
  100. package/dist/element.d.ts +10 -1
  101. package/dist/element.js +39 -4
  102. package/dist/places/67p.d.ts +13 -0
  103. package/dist/places/67p.js +14 -0
  104. package/dist/places/ariel.d.ts +13 -0
  105. package/dist/places/ariel.js +14 -0
  106. package/dist/places/bennu.d.ts +13 -0
  107. package/dist/places/bennu.js +14 -0
  108. package/dist/places/callisto.d.ts +13 -0
  109. package/dist/places/callisto.js +14 -0
  110. package/dist/places/ceres.d.ts +13 -0
  111. package/dist/places/ceres.js +14 -0
  112. package/dist/places/charon.d.ts +13 -0
  113. package/dist/places/charon.js +14 -0
  114. package/dist/places/dimorphos.d.ts +13 -0
  115. package/dist/places/dimorphos.js +14 -0
  116. package/dist/places/dione.d.ts +13 -0
  117. package/dist/places/dione.js +14 -0
  118. package/dist/places/enceladus.d.ts +13 -0
  119. package/dist/places/enceladus.js +14 -0
  120. package/dist/places/eros.d.ts +13 -0
  121. package/dist/places/eros.js +14 -0
  122. package/dist/places/europa.d.ts +13 -0
  123. package/dist/places/europa.js +14 -0
  124. package/dist/places/ganymede.d.ts +13 -0
  125. package/dist/places/ganymede.js +14 -0
  126. package/dist/places/iapetus.d.ts +13 -0
  127. package/dist/places/iapetus.js +14 -0
  128. package/dist/places/io.d.ts +13 -0
  129. package/dist/places/io.js +14 -0
  130. package/dist/places/jupiter.d.ts +13 -0
  131. package/dist/places/jupiter.js +14 -0
  132. package/dist/places/mars.d.ts +12 -0
  133. package/dist/places/mars.js +13 -0
  134. package/dist/places/mercury.d.ts +13 -0
  135. package/dist/places/mercury.js +14 -0
  136. package/dist/places/mimas.d.ts +13 -0
  137. package/dist/places/mimas.js +14 -0
  138. package/dist/places/miranda.d.ts +13 -0
  139. package/dist/places/miranda.js +14 -0
  140. package/dist/places/moon.d.ts +12 -0
  141. package/dist/places/moon.js +13 -0
  142. package/dist/places/oberon.d.ts +13 -0
  143. package/dist/places/oberon.js +14 -0
  144. package/dist/places/pluto.d.ts +13 -0
  145. package/dist/places/pluto.js +14 -0
  146. package/dist/places/rhea.d.ts +13 -0
  147. package/dist/places/rhea.js +14 -0
  148. package/dist/places/ryugu.d.ts +13 -0
  149. package/dist/places/ryugu.js +14 -0
  150. package/dist/places/saturn.d.ts +13 -0
  151. package/dist/places/saturn.js +14 -0
  152. package/dist/places/tempel-1.d.ts +13 -0
  153. package/dist/places/tempel-1.js +14 -0
  154. package/dist/places/tethys.d.ts +13 -0
  155. package/dist/places/tethys.js +14 -0
  156. package/dist/places/titan.d.ts +13 -0
  157. package/dist/places/titan.js +14 -0
  158. package/dist/places/titania.d.ts +13 -0
  159. package/dist/places/titania.js +14 -0
  160. package/dist/places/triton.d.ts +13 -0
  161. package/dist/places/triton.js +14 -0
  162. package/dist/places/umbriel.d.ts +13 -0
  163. package/dist/places/umbriel.js +14 -0
  164. package/dist/places/venus.d.ts +13 -0
  165. package/dist/places/venus.js +14 -0
  166. package/dist/places/vesta.d.ts +13 -0
  167. package/dist/places/vesta.js +14 -0
  168. package/dist/places.d.ts +354 -0
  169. package/dist/places.js +357 -0
  170. package/dist/plan/element.d.ts +52 -0
  171. package/dist/plan/element.js +258 -0
  172. package/dist/plan/index.d.ts +2 -0
  173. package/dist/plan/index.js +2 -0
  174. package/dist/plan/layout.d.ts +230 -0
  175. package/dist/plan/layout.js +229 -0
  176. package/dist/plan/svg.d.ts +125 -0
  177. package/dist/plan/svg.js +185 -0
  178. package/dist/roadster.d.ts +415 -0
  179. package/dist/roadster.js +496 -0
  180. package/dist/scene/body.d.ts +13 -2
  181. package/dist/scene/body.js +36 -0
  182. package/dist/scene/name-label.d.ts +116 -0
  183. package/dist/scene/name-label.js +232 -0
  184. package/dist/scene/painter.d.ts +30 -1
  185. package/dist/scene/painter.js +56 -4
  186. package/dist/scene/textures.d.ts +2 -2
  187. package/dist/space/beside.d.ts +4 -1
  188. package/dist/space/beside.js +47 -6
  189. package/dist/space/covered.d.ts +102 -0
  190. package/dist/space/covered.js +98 -0
  191. package/dist/space/element.d.ts +37 -1
  192. package/dist/space/element.js +151 -11
  193. package/dist/space/index.d.ts +1 -0
  194. package/dist/space/index.js +1 -0
  195. package/dist/space/scale.d.ts +2 -1
  196. package/dist/space/scale.js +13 -2
  197. package/dist/space/scene.d.ts +23 -1
  198. package/dist/space/scene.js +62 -21
  199. package/dist/spacecraft-facts.d.ts +4 -4
  200. package/dist/spacecraft-facts.js +158 -3
  201. package/dist/spacecraft.d.ts +69 -2
  202. package/dist/spacecraft.js +45 -2
  203. package/dist/textures/mimas-1024.webp +0 -0
  204. package/dist/textures/mimas-512.webp +0 -0
  205. package/dist/version.d.ts +1 -1
  206. package/dist/version.js +1 -1
  207. package/package.json +204 -2
@@ -0,0 +1,102 @@
1
+ import type { BodyPlace } from "./scene.ts";
2
+ /**
3
+ * A placed body as the covering test sees it: where it is on the screen (CSS pixels), its radius there, and how far it is from the camera (any unit, the same for all).
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import type { CoverEntry } from "@johnmorrisdotca/wakusei-planets/space";
8
+ *
9
+ * const earth: CoverEntry = { id: "earth", x: 300, y: 300, r: 120, distance: 4 };
10
+ * console.log(earth.r);
11
+ * ```
12
+ */
13
+ export interface CoverEntry {
14
+ id: string;
15
+ x: number;
16
+ y: number;
17
+ r: number;
18
+ distance: number;
19
+ }
20
+ /**
21
+ * A disc narrower than this many CSS pixels of radius covers nothing: a dot hides no name.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { COVER_MIN_PX } from "@johnmorrisdotca/wakusei-planets/space";
26
+ *
27
+ * console.log(COVER_MIN_PX);
28
+ * ```
29
+ */
30
+ export declare const COVER_MIN_PX = 6;
31
+ /**
32
+ * Which body, if any, covers each: the nearest body whose disc on the screen holds the body's place and which is nearer the camera than it is. A body is never covered by itself, nor by a disc
33
+ * narrower than `COVER_MIN_PX`.
34
+ *
35
+ * @param entries - The placed bodies.
36
+ * @returns For each covered body's id, the id of the body covering it.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import { coveredBy } from "@johnmorrisdotca/wakusei-planets/space";
41
+ *
42
+ * const behind = coveredBy([
43
+ * { id: "earth", x: 300, y: 300, r: 120, distance: 4 },
44
+ * { id: "uranus", x: 340, y: 280, r: 1, distance: 60_000 },
45
+ * { id: "moon", x: 80, y: 300, r: 30, distance: 3 },
46
+ * ]);
47
+ * console.log(JSON.stringify([...behind]));
48
+ * ```
49
+ */
50
+ export declare function coveredBy(entries: readonly CoverEntry[]): Map<string, string>;
51
+ /**
52
+ * One quiet arrow: outside the covering body's disc, on the side nearest the bodies behind it, pointing in behind it, with the surest of them named and the rest counted.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import type { CoverArrow } from "@johnmorrisdotca/wakusei-planets/space";
57
+ *
58
+ * const arrow: CoverArrow = { cover: "earth", lead: "uranus", bodies: ["uranus", "ariel"], x: 426, y: 280, angle: 180 };
59
+ * console.log(arrow.bodies.length);
60
+ * ```
61
+ */
62
+ export interface CoverArrow {
63
+ /** The body whose disc covers them. */
64
+ cover: string;
65
+ /** The surest of the bodies behind (the lowest rank): the arrow is named for it and a press goes to it. */
66
+ lead: string;
67
+ /** Every body behind, the lead first. */
68
+ bodies: string[];
69
+ /** Where the arrow's tip sits, in CSS pixels in the box: just outside the disc's edge. */
70
+ x: number;
71
+ y: number;
72
+ /** The way the arrow points, in degrees clockwise from pointing right: into the disc, towards the bodies behind it. */
73
+ angle: number;
74
+ }
75
+ /**
76
+ * How far outside the disc's edge the arrow's tip sits, in CSS pixels.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { COVER_ARROW_GAP } from "@johnmorrisdotca/wakusei-planets/space";
81
+ *
82
+ * console.log(COVER_ARROW_GAP);
83
+ * ```
84
+ */
85
+ export declare const COVER_ARROW_GAP = 6;
86
+ /**
87
+ * The arrows for the bodies behind others: one for each covering body, placed on its edge on the side nearest the surest body behind it, pointing in. Bodies behind the same disc share the arrow,
88
+ * the lead named and the others counted by the host.
89
+ *
90
+ * @param places - Where each body is on the screen, with `behind` set for a covered one (from `coveredBy`), or `null` for one off the screen.
91
+ * @param rank - How sure a body's name is (lower is surer): the lead of a group.
92
+ * @returns The arrows, in the order of their covering bodies' ids.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { coverArrows } from "@johnmorrisdotca/wakusei-planets/space";
97
+ *
98
+ * const arrows = coverArrows({ earth: { x: 300, y: 300, r: 120 }, uranus: { x: 340, y: 280, r: 1, behind: "earth" }, ariel: { x: 342, y: 281, r: 0.1, behind: "earth" } }, (id) => (id === "uranus" ? 2 : 4));
99
+ * console.log(JSON.stringify(arrows.map((a) => [a.lead, a.bodies.length, Math.round(a.x), Math.round(a.y), Math.round(a.angle)])));
100
+ * ```
101
+ */
102
+ export declare function coverArrows(places: Readonly<Record<string, BodyPlace | null>>, rank: (id: string) => number): CoverArrow[];
@@ -0,0 +1,98 @@
1
+ /**
2
+ * A disc narrower than this many CSS pixels of radius covers nothing: a dot hides no name.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { COVER_MIN_PX } from "@johnmorrisdotca/wakusei-planets/space";
7
+ *
8
+ * console.log(COVER_MIN_PX);
9
+ * ```
10
+ */
11
+ export const COVER_MIN_PX = 6;
12
+ /**
13
+ * Which body, if any, covers each: the nearest body whose disc on the screen holds the body's place and which is nearer the camera than it is. A body is never covered by itself, nor by a disc
14
+ * narrower than `COVER_MIN_PX`.
15
+ *
16
+ * @param entries - The placed bodies.
17
+ * @returns For each covered body's id, the id of the body covering it.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { coveredBy } from "@johnmorrisdotca/wakusei-planets/space";
22
+ *
23
+ * const behind = coveredBy([
24
+ * { id: "earth", x: 300, y: 300, r: 120, distance: 4 },
25
+ * { id: "uranus", x: 340, y: 280, r: 1, distance: 60_000 },
26
+ * { id: "moon", x: 80, y: 300, r: 30, distance: 3 },
27
+ * ]);
28
+ * console.log(JSON.stringify([...behind]));
29
+ * ```
30
+ */
31
+ export function coveredBy(entries) {
32
+ const behind = new Map();
33
+ for (const body of entries) {
34
+ let cover;
35
+ for (const other of entries) {
36
+ if (other === body || other.r < COVER_MIN_PX || other.distance >= body.distance)
37
+ continue;
38
+ if (Math.hypot(body.x - other.x, body.y - other.y) >= other.r)
39
+ continue;
40
+ if (cover === undefined || other.distance < cover.distance)
41
+ cover = other;
42
+ }
43
+ if (cover !== undefined)
44
+ behind.set(body.id, cover.id);
45
+ }
46
+ return behind;
47
+ }
48
+ /**
49
+ * How far outside the disc's edge the arrow's tip sits, in CSS pixels.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { COVER_ARROW_GAP } from "@johnmorrisdotca/wakusei-planets/space";
54
+ *
55
+ * console.log(COVER_ARROW_GAP);
56
+ * ```
57
+ */
58
+ export const COVER_ARROW_GAP = 6;
59
+ /**
60
+ * The arrows for the bodies behind others: one for each covering body, placed on its edge on the side nearest the surest body behind it, pointing in. Bodies behind the same disc share the arrow,
61
+ * the lead named and the others counted by the host.
62
+ *
63
+ * @param places - Where each body is on the screen, with `behind` set for a covered one (from `coveredBy`), or `null` for one off the screen.
64
+ * @param rank - How sure a body's name is (lower is surer): the lead of a group.
65
+ * @returns The arrows, in the order of their covering bodies' ids.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * import { coverArrows } from "@johnmorrisdotca/wakusei-planets/space";
70
+ *
71
+ * const arrows = coverArrows({ earth: { x: 300, y: 300, r: 120 }, uranus: { x: 340, y: 280, r: 1, behind: "earth" }, ariel: { x: 342, y: 281, r: 0.1, behind: "earth" } }, (id) => (id === "uranus" ? 2 : 4));
72
+ * console.log(JSON.stringify(arrows.map((a) => [a.lead, a.bodies.length, Math.round(a.x), Math.round(a.y), Math.round(a.angle)])));
73
+ * ```
74
+ */
75
+ export function coverArrows(places, rank) {
76
+ const groups = new Map();
77
+ for (const [id, at] of Object.entries(places)) {
78
+ if (at === null || at.behind === undefined || places[at.behind] === null || places[at.behind] === undefined)
79
+ continue;
80
+ const list = groups.get(at.behind) ?? [];
81
+ list.push(id);
82
+ groups.set(at.behind, list);
83
+ }
84
+ const arrows = [];
85
+ for (const cover of [...groups.keys()].sort()) {
86
+ const bodies = groups.get(cover).sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : 1));
87
+ const lead = bodies[0];
88
+ const disc = places[cover];
89
+ const at = places[lead];
90
+ const dx = at.x - disc.x;
91
+ const dy = at.y - disc.y;
92
+ const length = Math.hypot(dx, dy);
93
+ const [ux, uy] = length < 1e-6 ? [1, 0] : [dx / length, dy / length];
94
+ const reach = disc.r + COVER_ARROW_GAP;
95
+ arrows.push({ cover, lead, bodies, x: disc.x + ux * reach, y: disc.y + uy * reach, angle: (Math.atan2(-uy, -ux) * 180) / Math.PI });
96
+ }
97
+ return arrows;
98
+ }
@@ -2,6 +2,7 @@ import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
2
  import "../tables/minor.ts";
3
3
  import { type BodyId } from "../facts.ts";
4
4
  import { type SpaceKind } from "./bodies.ts";
5
+ import { type NameLabelOptions } from "../scene/name-label.ts";
5
6
  import type { Credit, DataSource } from "../data-door.ts";
6
7
  import { type DoorHost } from "../door/host.ts";
7
8
  import { setThreeLoader } from "../scene/shared.ts";
@@ -128,6 +129,12 @@ export declare class WakuseiSpace extends HTMLElement {
128
129
  connectedCallback(): void;
129
130
  disconnectedCallback(): void;
130
131
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
132
+ /**
133
+ * The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
134
+ * `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
135
+ */
136
+ get bodyLabel(): NameLabelOptions | null;
137
+ set bodyLabel(value: NameLabelOptions | null | undefined);
131
138
  /** The home place the camera starts above, as longitude and latitude in degrees. */
132
139
  get centre(): {
133
140
  lon: number;
@@ -151,6 +158,18 @@ export declare class WakuseiSpace extends HTMLElement {
151
158
  set scaleNames(value: Partial<Record<ScaleMode, string>>);
152
159
  get labels(): boolean;
153
160
  set labels(value: boolean);
161
+ /**
162
+ * What a body behind another gets (the attribute `covered`): `name` (the default) draws its floating name and ring over the nearer body's disc as always; `arrow` draws instead one small quiet arrow just outside the
163
+ * disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out.
164
+ */
165
+ get covered(): "name" | "arrow";
166
+ set covered(value: "name" | "arrow");
167
+ /**
168
+ * Keep a body's floating name and dot while its name is drawn on its globe (the attribute `labels-always`; off by default). Off, a body that carries its drawn name (`body-label` on, and the body at least 24 CSS pixels in
169
+ * radius) fades its floating name and dot out, and they fade back when it shrinks below that; bodies with no drawn name keep their floating names.
170
+ */
171
+ get labelsAlways(): boolean;
172
+ set labelsAlways(value: boolean);
154
173
  get orbits(): boolean;
155
174
  set orbits(value: boolean);
156
175
  /** How many small arrowheads each orbit line carries to show which way the body goes: 2 by default, at most 4, 0 for none (the attribute `arrows` says the same). Anything else is made a whole number in that range. */
@@ -158,10 +177,16 @@ export declare class WakuseiSpace extends HTMLElement {
158
177
  set arrows(value: number);
159
178
  /**
160
179
  * Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
161
- * right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
180
+ * right for Venus and Uranus, which turn backwards, and for Uranus on its side. By default the lines are hidden where the globe covers them (`helpThrough` draws them whole over it).
162
181
  */
163
182
  get help(): boolean;
164
183
  set help(value: boolean);
184
+ /**
185
+ * Whether help mode's lines are drawn whole over the globe, as they were (the attribute `help-through`; off by default). Off, they have depth against the body they are on: the axis runs into the near pole and comes out of the
186
+ * far pole only where that end is not behind the globe, and the part of the curved arrow that passes behind the globe is hidden.
187
+ */
188
+ get helpThrough(): boolean;
189
+ set helpThrough(value: boolean);
165
190
  /** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
166
191
  get look(): "realistic" | "painted";
167
192
  set look(value: "realistic" | "painted");
@@ -279,6 +304,8 @@ export declare class WakuseiSpace extends HTMLElement {
279
304
  camera: {
280
305
  position: [number, number, number];
281
306
  fov: number;
307
+ up: [number, number, number];
308
+ forward: [number, number, number];
282
309
  };
283
310
  /** What the painter has made at the last draw: the bodies with a drawing, the moons shown round a planet that is near, and the moons made and not yet let go. */
284
311
  bodies: {
@@ -325,6 +352,15 @@ export declare class WakuseiSpace extends HTMLElement {
325
352
  retrograde: boolean;
326
353
  arcTurn: [number, number, number];
327
354
  } | null;
355
+ /** The names on the globes at the last draw: how many are drawn (made, their font in, and the body big enough on the screen), and the one on the body looked at (its text and its turn about the pole in radians), or null. */
356
+ bodyLabels: {
357
+ count: number;
358
+ focus: {
359
+ shown: boolean;
360
+ text: string;
361
+ turn: number;
362
+ } | null;
363
+ };
328
364
  };
329
365
  /** Where a body is on the screen now: its centre and radius in CSS pixels in the element, or `null` when it is behind the camera or not drawn. */
330
366
  placeOf(id: BodyId): BodyPlace | null;
@@ -6,7 +6,9 @@ import { arrowCount } from "./arrows.js";
6
6
  import { createGameClock } from "./clock.js";
7
7
  import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER } from "./bodies.js";
8
8
  import { chooseLabels } from "./labels.js";
9
+ import { coverArrows } from "./covered.js";
9
10
  import { createPainter } from "../scene/painter.js";
11
+ import { NAME_LABEL_ATTRIBUTES, readNameLabel } from "../scene/name-label.js";
10
12
  import { createDoorHost } from "../door/host.js";
11
13
  import { ownCredit } from "../door/own.js";
12
14
  import { setThreeLoader, takeRenderer } from "../scene/shared.js";
@@ -55,7 +57,7 @@ const readBody = (value) => {
55
57
  * 1.05 radii from the surface (`FIT_DISTANCE` over the zoom), so past a zoom of about 3.9 nothing moves; 3.6 is where the finest map tiles of the Earth, Mars and the Moon (16384 pixels round) run out of detail too, so it is the same ceiling for both.
56
58
  */
57
59
  const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
58
- const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p>`;
60
+ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label,.sp-ring{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p>`;
59
61
  /**
60
62
  * The `<wakusei-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`
61
63
  * (`"lon,lat"`), `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `look` (`realistic` or `painted`),
@@ -85,7 +87,7 @@ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;ove
85
87
  * ```
86
88
  */
87
89
  export class WakuseiSpace extends HTMLElement {
88
- static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data", "arrows"];
90
+ static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", ...NAME_LABEL_ATTRIBUTES];
89
91
  #model = newSpaceModel();
90
92
  #clock = createGameClock("now", 1);
91
93
  #view;
@@ -132,11 +134,15 @@ export class WakuseiSpace extends HTMLElement {
132
134
  this.#model.time = this.#clock.time;
133
135
  this.#model.mode = this.getAttribute("scale") === "compressed" ? "compressed" : "true";
134
136
  this.#model.labels = this.getAttribute("labels") !== "off";
137
+ this.#labelsAlways = this.hasAttribute("labels-always") && this.getAttribute("labels-always") !== "off";
138
+ this.#covered = this.getAttribute("covered") === "arrow" ? "arrow" : "name";
135
139
  this.#model.orbits = this.getAttribute("orbits") !== "off";
136
140
  this.#model.arrowCount = arrowCount(this.getAttribute("arrows"));
137
141
  this.#model.help = this.hasAttribute("help") && this.getAttribute("help") !== "off";
142
+ this.#model.helpThrough = this.hasAttribute("help-through") && this.getAttribute("help-through") !== "off";
138
143
  this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
139
144
  this.#model.light = readLight(this.getAttribute("light"));
145
+ this.#relabel();
140
146
  this.#door.book.ownOnly(this.getAttribute("data") === "own");
141
147
  this.#model.stepMs = Math.max(1000, Math.abs(this.#clock.speed) * 1000);
142
148
  if (!this.hasAttribute("role"))
@@ -153,6 +159,7 @@ export class WakuseiSpace extends HTMLElement {
153
159
  this.#nameScale();
154
160
  this.#pool.clear();
155
161
  this.#rings.clear();
162
+ this.#arrows.clear();
156
163
  const nav = navigator;
157
164
  this.#gate = createGate(1000 / frameCap(30, { deviceMemory: nav.deviceMemory, hardwareConcurrency: nav.hardwareConcurrency }), () => this.#view?.invalidate());
158
165
  this.#stage.addEventListener("webglcontextlost", this.#lost, true);
@@ -219,12 +226,18 @@ export class WakuseiSpace extends HTMLElement {
219
226
  this.scale = value === "compressed" ? "compressed" : "true";
220
227
  else if (name === "labels")
221
228
  this.labels = value !== "off";
229
+ else if (name === "labels-always")
230
+ this.labelsAlways = value !== null && value !== "off";
231
+ else if (name === "covered")
232
+ this.covered = value === "arrow" ? "arrow" : "name";
222
233
  else if (name === "orbits")
223
234
  this.orbits = value !== "off";
224
235
  else if (name === "arrows")
225
236
  this.arrows = arrowCount(value);
226
237
  else if (name === "help")
227
238
  this.help = value !== null && value !== "off";
239
+ else if (name === "help-through")
240
+ this.helpThrough = value !== null && value !== "off";
228
241
  else if (name === "look")
229
242
  this.look = value === "painted" ? "painted" : "realistic";
230
243
  else if (name === "light")
@@ -235,7 +248,29 @@ export class WakuseiSpace extends HTMLElement {
235
248
  for (const [id, button] of this.#pool)
236
249
  this.#nameLabel(button, id);
237
250
  this.#nameScale();
251
+ this.#relabel();
238
252
  }
253
+ else if (NAME_LABEL_ATTRIBUTES.includes(name))
254
+ this.#relabel();
255
+ }
256
+ #bodyLabel;
257
+ /**
258
+ * The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
259
+ * `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
260
+ */
261
+ get bodyLabel() {
262
+ return this.#bodyLabel !== undefined ? this.#bodyLabel : readNameLabel(this);
263
+ }
264
+ set bodyLabel(value) {
265
+ this.#bodyLabel = value;
266
+ this.#relabel();
267
+ }
268
+ /** Tell the scene the name on the globes changed (the attributes, the property or the language): each body is told once at the next draw. */
269
+ #relabel() {
270
+ const options = this.bodyLabel;
271
+ this.#model.label = options === null ? null : { ...options, lang: this.getAttribute("lang") === "ja" ? "ja" : "en" };
272
+ this.#model.labelVersion += 1;
273
+ this.#gate?.request();
239
274
  }
240
275
  /** The home place the camera starts above, as longitude and latitude in degrees. */
241
276
  get centre() {
@@ -296,10 +331,37 @@ export class WakuseiSpace extends HTMLElement {
296
331
  set labels(value) {
297
332
  this.#model.labels = value;
298
333
  if (!value)
299
- for (const label of [...this.#pool.values(), ...this.#rings.values()])
334
+ for (const label of [...this.#pool.values(), ...this.#rings.values(), ...this.#arrows.values()])
300
335
  label.hidden = true;
301
336
  this.#gate?.request();
302
337
  }
338
+ #covered = "name";
339
+ #arrows = new Map();
340
+ /**
341
+ * What a body behind another gets (the attribute `covered`): `name` (the default) draws its floating name and ring over the nearer body's disc as always; `arrow` draws instead one small quiet arrow just outside the
342
+ * disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out.
343
+ */
344
+ get covered() {
345
+ return this.#covered;
346
+ }
347
+ set covered(value) {
348
+ this.#covered = value;
349
+ if (this.#places)
350
+ this.#placeLabels(this.#places);
351
+ }
352
+ #labelsAlways = false;
353
+ /**
354
+ * Keep a body's floating name and dot while its name is drawn on its globe (the attribute `labels-always`; off by default). Off, a body that carries its drawn name (`body-label` on, and the body at least 24 CSS pixels in
355
+ * radius) fades its floating name and dot out, and they fade back when it shrinks below that; bodies with no drawn name keep their floating names.
356
+ */
357
+ get labelsAlways() {
358
+ return this.#labelsAlways;
359
+ }
360
+ set labelsAlways(value) {
361
+ this.#labelsAlways = value;
362
+ if (this.#places)
363
+ this.#placeLabels(this.#places);
364
+ }
303
365
  get orbits() {
304
366
  return this.#model.orbits;
305
367
  }
@@ -317,7 +379,7 @@ export class WakuseiSpace extends HTMLElement {
317
379
  }
318
380
  /**
319
381
  * Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
320
- * right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
382
+ * right for Venus and Uranus, which turn backwards, and for Uranus on its side. By default the lines are hidden where the globe covers them (`helpThrough` draws them whole over it).
321
383
  */
322
384
  get help() {
323
385
  return this.#model.help;
@@ -326,6 +388,17 @@ export class WakuseiSpace extends HTMLElement {
326
388
  this.#model.help = value;
327
389
  this.#gate?.request();
328
390
  }
391
+ /**
392
+ * Whether help mode's lines are drawn whole over the globe, as they were (the attribute `help-through`; off by default). Off, they have depth against the body they are on: the axis runs into the near pole and comes out of the
393
+ * far pole only where that end is not behind the globe, and the part of the curved arrow that passes behind the globe is hidden.
394
+ */
395
+ get helpThrough() {
396
+ return this.#model.helpThrough;
397
+ }
398
+ set helpThrough(value) {
399
+ this.#model.helpThrough = value;
400
+ this.#gate?.request();
401
+ }
329
402
  /** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
330
403
  get look() {
331
404
  return this.#model.look === "painted" ? "painted" : "realistic";
@@ -634,7 +707,7 @@ export class WakuseiSpace extends HTMLElement {
634
707
  assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
635
708
  time: this.time,
636
709
  lookups: this.#model.lookups,
637
- camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov },
710
+ camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov, up: [...this.#model.camera.up], forward: [...this.#model.camera.forward] },
638
711
  bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
639
712
  tiles: { ...this.#model.tiles },
640
713
  door: { points: this.#model.door.points, sources: this.#door.book.stats() },
@@ -643,6 +716,7 @@ export class WakuseiSpace extends HTMLElement {
643
716
  arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
644
717
  arrowPx: this.#model.arrowPx,
645
718
  help: this.#model.helpDrawn ? { body: this.#model.helpDrawn.body, axis: [...this.#model.helpDrawn.axis], pole: [...this.#model.helpDrawn.pole], retrograde: this.#model.helpDrawn.retrograde, arcTurn: [...this.#model.helpDrawn.arcTurn] } : null,
719
+ bodyLabels: { count: this.#model.labelsDrawn.count, focus: this.#model.labelsDrawn.focus === null ? null : { ...this.#model.labelsDrawn.focus } },
646
720
  };
647
721
  }
648
722
  // --- the game clock ----------------------------------------------------------------------------------------------------------------------------
@@ -725,8 +799,14 @@ export class WakuseiSpace extends HTMLElement {
725
799
  continue;
726
800
  const x = Math.round(at.x + Math.max(4, Math.min(at.r, 40)));
727
801
  const y = Math.round(at.y - 8);
728
- spots.set(id, { x, y, small: at.r < RING_BELOW_PX });
729
- wanted.push({ id, x, y, width: this.#widthOf(label), height: 16, rank: this.#rank(id), size: at.r });
802
+ // a body that carries its drawn name gives its floating name up (it fades, and leaves its place to the others) unless the page keeps both; a body behind another gives it up for the arrow
803
+ const carried = at.named === true && !this.#labelsAlways;
804
+ const covered = at.behind !== undefined && this.#covered === "arrow";
805
+ if (covered)
806
+ continue;
807
+ spots.set(id, { x, y, small: at.r < RING_BELOW_PX, carried });
808
+ if (!carried)
809
+ wanted.push({ id, x, y, width: this.#widthOf(label), height: 16, rank: this.#rank(id), size: at.r });
730
810
  }
731
811
  // no two names overlap: a moon gives way to its planet and a planet to the Sun
732
812
  const shown = chooseLabels(wanted);
@@ -736,15 +816,28 @@ export class WakuseiSpace extends HTMLElement {
736
816
  if (!label || !ring)
737
817
  continue;
738
818
  const spot = spots.get(id);
739
- if (!spot || !shown.has(id)) {
819
+ if (!spot || (!spot.carried && !shown.has(id))) {
740
820
  if (!label.hidden)
741
821
  label.hidden = true;
742
822
  if (!ring.hidden)
743
823
  ring.hidden = true;
824
+ // a hidden name forgets its fade, so that when it comes back it fades in rather than popping
825
+ if (label.hasAttribute("data-carried")) {
826
+ label.removeAttribute("data-carried");
827
+ ring.removeAttribute("data-carried");
828
+ label.setAttribute("aria-hidden", "false");
829
+ label.tabIndex = 0;
830
+ }
744
831
  continue;
745
832
  }
746
833
  if (label.hidden)
747
834
  label.hidden = false;
835
+ if (label.hasAttribute("data-carried") !== spot.carried) {
836
+ label.toggleAttribute("data-carried", spot.carried);
837
+ ring.toggleAttribute("data-carried", spot.carried);
838
+ label.setAttribute("aria-hidden", String(spot.carried));
839
+ label.tabIndex = spot.carried ? -1 : 0;
840
+ }
748
841
  label.style.transform = `translate(${spot.x}px,${spot.y}px)`;
749
842
  // a body too small to see is marked: a ring round the place it is, as well as its name
750
843
  if (ring.hidden === spot.small)
@@ -752,6 +845,43 @@ export class WakuseiSpace extends HTMLElement {
752
845
  if (spot.small)
753
846
  ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
754
847
  }
848
+ this.#placeArrows(places);
849
+ }
850
+ /** The quiet arrows for the bodies behind others (`covered="arrow"`): one per covering disc, just outside its edge, named for the surest body behind and counting the rest. */
851
+ #placeArrows(places) {
852
+ const box = this.#labelBox;
853
+ if (!box)
854
+ return;
855
+ const arrows = this.#covered === "arrow" && this.#model.labels ? coverArrows(places, (id) => this.#rank(id)) : [];
856
+ const live = new Set();
857
+ for (const arrow of arrows) {
858
+ live.add(arrow.cover);
859
+ let el = this.#arrows.get(arrow.cover);
860
+ if (!el) {
861
+ const button = box.ownerDocument.createElement("button");
862
+ button.type = "button";
863
+ el = button;
864
+ el.className = "sp-arrow";
865
+ el.dataset["cover"] = arrow.cover;
866
+ box.append(el);
867
+ this.#arrows.set(arrow.cover, el);
868
+ }
869
+ const text = arrow.bodies.length > 1 ? `${this.#nameOf(arrow.lead)} +${arrow.bodies.length - 1}` : this.#nameOf(arrow.lead);
870
+ if (el.dataset["body"] !== arrow.lead || el.textContent !== text) {
871
+ el.dataset["body"] = arrow.lead;
872
+ el.textContent = text;
873
+ el.setAttribute("aria-label", `${arrow.bodies.map((id) => this.#nameOf(id)).join(", ")}: ${this.#nameOf(arrow.cover)} ${this.getAttribute("lang") === "ja" ? "の後ろ" : "is in front"}. ${this.#hint}`);
874
+ }
875
+ // the tip sits at the arrow's place and points into the disc; the name hangs off the far side, to the right of the tip for an arrow on the right half of the disc and to the left for one on the left
876
+ const onLeft = Math.cos((arrow.angle * Math.PI) / 180) > 0;
877
+ el.style.setProperty("--turn", `${Math.round(arrow.angle)}deg`);
878
+ el.style.transform = `translate(${Math.round(arrow.x)}px,${Math.round(arrow.y - 8)}px)${onLeft ? " translateX(-100%)" : ""}`;
879
+ if (el.hidden)
880
+ el.hidden = false;
881
+ }
882
+ for (const [cover, el] of this.#arrows)
883
+ if (!live.has(cover) && !el.hidden)
884
+ el.hidden = true;
755
885
  }
756
886
  /** How sure a body's name is of its place: the body looked at first, then the Sun, the planets, the dwarf planets and minor bodies, and the moons. */
757
887
  #rank(id) {
@@ -846,9 +976,19 @@ export class WakuseiSpace extends HTMLElement {
846
976
  this.#press(best);
847
977
  };
848
978
  #labelClick = (event) => {
849
- const id = event.target?.dataset?.["body"];
850
- if (id)
851
- this.#press(id);
979
+ const target = event.target;
980
+ const id = target?.dataset?.["body"];
981
+ if (!id)
982
+ return;
983
+ // a press on a quiet arrow (a body behind another) goes to that body at once; a press on a name selects it first, as always
984
+ if (target?.dataset?.["cover"] !== undefined) {
985
+ if (canCentre(id))
986
+ this.goTo(id);
987
+ else
988
+ this.#press(id);
989
+ return;
990
+ }
991
+ this.#press(id);
852
992
  };
853
993
  /**
854
994
  * A press on a body or its name. `wakusei-body-click` tells the page every time. The first press on a body selects it (`wakusei-body-select`, for the page's card); a second press on the body that is selected makes it
@@ -7,3 +7,4 @@ export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, type SpaceKind } from
7
7
  export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from "./beside.ts";
8
8
  export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
9
9
  export { spinAxis, type SpinAxis } from "./spin.ts";
10
+ export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, type CoverArrow, type CoverEntry } from "./covered.ts";
@@ -8,3 +8,4 @@ export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf } from "./bodies.js";
8
8
  export { besideMoon, BESIDE_RADII } from "./beside.js";
9
9
  export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
10
10
  export { spinAxis } from "./spin.js";
11
+ export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy } from "./covered.js";
@@ -127,7 +127,8 @@ type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor
127
127
  export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor, mode: ScaleMode): number;
128
128
  /**
129
129
  * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
130
- * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's.
130
+ * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's,
131
+ * and none is drawn nearer than 1.5 radii or inside the planet's rings (Mimas stays outside Saturn's, Proteus outside Neptune's), so a camera at a moon is never in the ring plane.
131
132
  *
132
133
  * @param mode - The scale.
133
134
  * @param host - The planet or dwarf planet the moon goes round.
@@ -176,7 +176,8 @@ function reachOf(host) {
176
176
  }
177
177
  /**
178
178
  * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
179
- * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's.
179
+ * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's,
180
+ * and none is drawn nearer than 1.5 radii or inside the planet's rings (Mimas stays outside Saturn's, Proteus outside Neptune's), so a camera at a moon is never in the ring plane.
180
181
  *
181
182
  * @param mode - The scale.
182
183
  * @param host - The planet or dwarf planet the moon goes round.
@@ -198,7 +199,17 @@ export function moonDistance(mode, host, distance) {
198
199
  const space = room(host);
199
200
  if (reach === 0 || reach * radius <= space)
200
201
  return distance;
201
- return Math.min(distance, (space * Math.sqrt(distance / reach)) / radius);
202
+ // from the nearest a moon may be drawn (clear of the globe and its rings) out to the room's edge, in the order the moons are: a moon drawn in the ring plane, or inside the globe, put the camera riding beside it in the rings
203
+ const near = nearestOf(host);
204
+ const far = Math.max(space / radius, near * 1.6);
205
+ return Math.min(distance, near + (far - near) * Math.sqrt(distance / reach));
206
+ }
207
+ /** The nearest a moon is drawn to its planet in a compressed view, in the planet's radii: outside the globe, and outside its rings with a little room, so the moon never sits in the ring plane. */
208
+ function nearestOf(host) {
209
+ const facts = BODIES[host];
210
+ const bands = facts.rings ?? [];
211
+ const ringEdge = bands.length === 0 ? 0 : Math.max(...bands.map((band) => band.to)) / facts.radiusKm;
212
+ return Math.max(1.5, ringEdge * 1.15);
202
213
  }
203
214
  /**
204
215
  * Where every body of the view is, in Earth radii from the Earth's centre, at one moment: the Earth at the centre, the Moon, the Sun and the planets. The same mapping places