@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
@@ -3,7 +3,7 @@ import type { Item3D } from "@johnmorrisdotca/kazoku-ui/renderer";
3
3
  import { type BodyId, type MoonId } from "../facts.ts";
4
4
  import type { ThreeParts } from "../scene/body.ts";
5
5
  import type { SourceBook } from "../door/book.ts";
6
- import { type WakuseiPainter } from "../scene/painter.ts";
6
+ import { type PaintLabel, type WakuseiPainter } from "../scene/painter.ts";
7
7
  import "../bodies/all.ts";
8
8
  import type { Vec3 } from "../vec.ts";
9
9
  import { type OrbitArrow } from "./arrows.ts";
@@ -155,8 +155,22 @@ export interface SpaceModel {
155
155
  arrows: Record<string, OrbitArrow[]>;
156
156
  /** Help mode: draw, on the body looked at, the axis it turns about and a curved arrow showing which way it turns. */
157
157
  help: boolean;
158
+ /** Help mode draws its lines whole over the globe (`true`); by default they have depth against the body they are on, so the axis shows only outside the globe and the part of the arrow behind it is hidden. */
159
+ helpThrough: boolean;
158
160
  /** How many arrowheads each orbit line carries: 0 to `MAX_ARROWS_PER_ORBIT`, two by default. */
159
161
  arrowCount: number;
162
+ /** The name written on each body's globe, or null for none; `labelVersion` goes up whenever it (or the language) changes, so each body is told once. */
163
+ label: PaintLabel | null;
164
+ labelVersion: number;
165
+ /** The names on the globes at the last draw: how many are drawn (made, their font in, and big enough on the screen), and the one on the body looked at, or null. */
166
+ labelsDrawn: {
167
+ count: number;
168
+ focus: {
169
+ shown: boolean;
170
+ text: string;
171
+ turn: number;
172
+ } | null;
173
+ };
160
174
  /** How long an arrowhead drawn at the last draw is on the screen, in CSS pixels (measured from its own points), or 0 when none was drawn. */
161
175
  arrowPx: number;
162
176
  /** What the help arrow drew at the last draw, or null: the body, the axis it spins about (right-hand rule), the north pole, and the axis the drawn arc itself turns about (measured from its points). */
@@ -189,6 +203,10 @@ export interface SpaceModel {
189
203
  camera: {
190
204
  position: [number, number, number];
191
205
  fov: number;
206
+ /** The picture's up in the scene's axes (y is the Earth's north): beside a moon it is the planet's own pole laid across the line of sight. */
207
+ up: [number, number, number];
208
+ /** Which way the camera looks, a unit vector in the scene's axes. */
209
+ forward: [number, number, number];
192
210
  };
193
211
  /** The body or point the camera rides along with, or null. */
194
212
  ride: RideState | null;
@@ -225,6 +243,10 @@ export interface BodyPlace {
225
243
  x: number;
226
244
  y: number;
227
245
  r: number;
246
+ /** True while the body's name is drawn on its globe (`body-label` on, and the body big enough): the floating name beside it gives way. */
247
+ named?: boolean;
248
+ /** The id of the nearer body whose disc covers this body's place on the screen, when one does. */
249
+ behind?: string;
228
250
  }
229
251
  export interface SpaceDeps {
230
252
  painter: () => WakuseiPainter;
@@ -1,13 +1,14 @@
1
1
  import { BODIES, MOONS_OF } from "../facts.js";
2
2
  import { createSmallBodyPoints } from "../door/points.js";
3
3
  import { toTerrestrialTime } from "../clock.js";
4
- import { moonOffset } from "../scene/orient.js";
4
+ import { moonOffset, orientation } from "../scene/orient.js";
5
5
  import {} from "../scene/painter.js";
6
6
  import "../bodies/all.js";
7
7
  import { groundDirection } from "./aim.js";
8
8
  import { hostOf } from "./bodies.js";
9
9
  import { arrowSites, ARROWS_PER_ORBIT, chevron, MAX_ARROWS_PER_ORBIT, spinArrow } from "./arrows.js";
10
10
  import { besideMoon } from "./beside.js";
11
+ import { coveredBy } from "./covered.js";
11
12
  import { spinAxis } from "./spin.js";
12
13
  import { createTrack, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
13
14
  import { ridePose } from "./ride.js";
@@ -66,15 +67,19 @@ export const newSpaceModel = () => ({
66
67
  rings: { drawn: [], miss: {}, hidden: [] },
67
68
  arrows: {},
68
69
  help: false,
70
+ helpThrough: false,
69
71
  arrowPx: 0,
70
72
  arrowCount: ARROWS_PER_ORBIT,
73
+ label: null,
74
+ labelVersion: 0,
75
+ labelsDrawn: { count: 0, focus: null },
71
76
  helpDrawn: null,
72
77
  door: { points: 0, used: {} },
73
78
  lookups: 0,
74
79
  motion: 0,
75
80
  drawnView: null,
76
81
  heightPx: 420,
77
- camera: { position: [0, 0, 0], fov: FOV },
82
+ camera: { position: [0, 0, 0], fov: FOV, up: [0, 1, 0], forward: [0, 0, -1] },
78
83
  ride: null,
79
84
  rideLost: false,
80
85
  transition: null,
@@ -136,12 +141,13 @@ export function createSpaceItem(model, deps) {
136
141
  empty(slot);
137
142
  slot.look = model.look;
138
143
  try {
139
- const made = deps.painter().make(three, id, { look: model.look, mapped: true, invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap() });
144
+ const made = deps.painter().make(three, id, { look: model.look, mapped: true, invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap(), label: model.label });
140
145
  if (ended) {
141
146
  made.dispose();
142
147
  return;
143
148
  }
144
149
  slot.drawing = made;
150
+ slot.labelled = model.labelVersion;
145
151
  scene.add(made.object);
146
152
  }
147
153
  catch (error) {
@@ -152,9 +158,16 @@ export function createSpaceItem(model, deps) {
152
158
  const slotOf = (id) => {
153
159
  let slot = slots.get(id);
154
160
  if (!slot)
155
- slots.set(id, (slot = { drawing: undefined, look: null, failed: false }));
161
+ slots.set(id, (slot = { drawing: undefined, look: null, failed: false, labelled: -1 }));
156
162
  return slot;
157
163
  };
164
+ /** A body whose name setting changed since it was made is told the new one (once). */
165
+ const relabel = (slot) => {
166
+ if (slot.drawing === undefined || slot.labelled === model.labelVersion)
167
+ return;
168
+ slot.labelled = model.labelVersion;
169
+ slot.drawing.setLabel(model.label);
170
+ };
158
171
  // each line has its colour and a fade (the fourth number of the colour) at every point, so that near the body looked at the part of a line that would cross it is let go
159
172
  const orbits = new Map();
160
173
  for (const id of ORBIT_BODIES) {
@@ -294,7 +307,7 @@ export function createSpaceItem(model, deps) {
294
307
  if (ride.view === "beside") {
295
308
  // beyond the Moon and off the line to the Earth, the Earth in view behind it
296
309
  if (id === "moon")
297
- besideIn = { moon: pos.moon, moonRadius: radiusOf("moon"), host: pos.earth, hostRadius: radiusOf("earth"), sun: pos.sun };
310
+ besideIn = { moon: pos.moon, moonRadius: radiusOf("moon"), host: pos.earth, hostRadius: radiusOf("earth"), sun: pos.sun, north: orientation("earth", model.time).pole };
298
311
  focus = id;
299
312
  focusPos = pos[id];
300
313
  focusRadius = radiusOf(id);
@@ -322,7 +335,7 @@ export function createSpaceItem(model, deps) {
322
335
  if (ride.view === "beside") {
323
336
  const there = [centre[0] + offset[0] * unitWorld, centre[1] + offset[1] * unitWorld, centre[2] + offset[2] * unitWorld];
324
337
  const radius = Math.max(1e-6, (BODIES[id].radiusKm / BODIES[around].radiusKm) * unitWorld);
325
- besideIn = { moon: there, moonRadius: radius, host: centre, hostRadius: unitWorld, sun: pos.sun };
338
+ besideIn = { moon: there, moonRadius: radius, host: centre, hostRadius: unitWorld, sun: pos.sun, north: orientation(around, model.time).pole };
326
339
  focus = id;
327
340
  focusPos = there;
328
341
  focusRadius = radius;
@@ -430,7 +443,8 @@ export function createSpaceItem(model, deps) {
430
443
  camera.updateMatrixWorld();
431
444
  const hiddenBody = rideFrom?.hiddenBody ?? null;
432
445
  const hiddenMoon = rideFrom?.hiddenMoon ?? null;
433
- model.camera = { position: [camera.position.x + origin[0], camera.position.y + origin[1], camera.position.z + origin[2]], fov: fovNow };
446
+ const e2 = camera.matrixWorld.elements;
447
+ model.camera = { position: [camera.position.x + origin[0], camera.position.y + origin[1], camera.position.z + origin[2]], fov: fovNow, up: [e2[4], e2[5], e2[6]], forward: [-e2[8], -e2[9], -e2[10]] };
434
448
  model.pose = { p: [camera.position.x + origin[0], camera.position.y + origin[1], camera.position.z + origin[2]], q: [camera.quaternion.x, camera.quaternion.y, camera.quaternion.z, camera.quaternion.w], fov: fovNow, valid: true };
435
449
  model.drawnView = { yaw: model.view.yaw, tilt: model.view.tilt, zoom: model.view.zoom, roll: model.view.roll, panX: model.view.panX, panY: model.view.panY };
436
450
  model.heightPx = size.height;
@@ -461,6 +475,7 @@ export function createSpaceItem(model, deps) {
461
475
  continue;
462
476
  }
463
477
  fill(id, slot);
478
+ relabel(slot);
464
479
  const drawing = slot.drawing;
465
480
  if (!drawing)
466
481
  continue;
@@ -577,6 +592,8 @@ export function createSpaceItem(model, deps) {
577
592
  arrowGeometry.getAttribute("color").needsUpdate = true;
578
593
  // help mode: on the body looked at, the line of its axis and a curved arrow round it the way it turns
579
594
  helpLines.visible = model.help;
595
+ // by default the lines are hidden where the globe covers them: the depth test against the body, whose own drawing writes depth
596
+ helpLines.material.depthTest = !model.helpThrough;
580
597
  model.helpDrawn = null;
581
598
  if (model.help) {
582
599
  const turn = spinAxis(focus, model.time);
@@ -606,6 +623,7 @@ export function createSpaceItem(model, deps) {
606
623
  const now = performance.now();
607
624
  const seen = new Set();
608
625
  const moonPlaces = {};
626
+ const moonDistances = {};
609
627
  for (const id of [...SPACE_PLANETS, ...SPACE_DWARFS]) {
610
628
  const planet = slotOf(id).drawing;
611
629
  if (!planet)
@@ -630,10 +648,11 @@ export function createSpaceItem(model, deps) {
630
648
  continue;
631
649
  let held = moonSlots.get(key);
632
650
  if (!held)
633
- moonSlots.set(key, (held = { slot: { drawing: undefined, look: null, failed: false }, seen: now }));
651
+ moonSlots.set(key, (held = { slot: { drawing: undefined, look: null, failed: false, labelled: -1 }, seen: now }));
634
652
  held.seen = now;
635
653
  seen.add(key);
636
654
  fill(key, held.slot);
655
+ relabel(held.slot);
637
656
  const drawing = held.slot.drawing;
638
657
  if (!drawing)
639
658
  continue;
@@ -645,8 +664,10 @@ export function createSpaceItem(model, deps) {
645
664
  const moonPx = away <= drawn * 1.001 ? 1e5 : ((size.height / 2) * (drawn / Math.sqrt(away * away - drawn * drawn))) / half;
646
665
  drawing.update({ toSun: model.light === "lit" ? unit([camera.position.x - at[0], camera.position.y - at[1], camera.position.z - at[2]]) : toSunOf(id), ms: model.time, radiusPx: moonPx, view: { camera, width: size.width, height: size.height } });
647
666
  const spot = labelFor(at);
648
- if (spot)
649
- moonPlaces[key] = { x: spot.x, y: spot.y, r: moonPx };
667
+ if (spot) {
668
+ moonPlaces[key] = { x: spot.x, y: spot.y, r: moonPx, named: drawing.label?.shown === true };
669
+ moonDistances[key] = away;
670
+ }
650
671
  }
651
672
  }
652
673
  let soonest = Number.POSITIVE_INFINITY;
@@ -672,24 +693,32 @@ export function createSpaceItem(model, deps) {
672
693
  paintedMoons += 1;
673
694
  model.painted.moons = paintedMoons;
674
695
  model.painted.held = moonSlots.size;
696
+ // one pass over every drawing (the bodies, then the moons): the names drawn, the tile windows summed, and the sources whose tiles are on a body
697
+ let labelsDrawn = 0;
675
698
  const tiles = { requested: 0, loading: 0, failed: 0, shown: null };
676
- for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)]) {
677
- const stats = painting?.tiles;
699
+ const used = {};
700
+ const tally = (painting) => {
701
+ if (painting === undefined)
702
+ return;
703
+ if (painting.object.visible && painting.label?.shown)
704
+ labelsDrawn += 1;
705
+ const stats = painting.tiles;
678
706
  if (stats === undefined)
679
- continue;
707
+ return;
680
708
  tiles.requested += stats.requested;
681
709
  tiles.loading += stats.loading;
682
710
  tiles.failed += stats.failed;
683
711
  if (stats.shown !== null)
684
712
  tiles.shown = Math.max(tiles.shown ?? 0, stats.shown);
685
- }
713
+ if (stats.source !== undefined)
714
+ used[stats.source.id] = (used[stats.source.id] ?? 0) + stats.used;
715
+ };
716
+ for (const slot of slots.values())
717
+ tally(slot.drawing);
718
+ for (const held of moonSlots.values())
719
+ tally(held.slot.drawing);
720
+ model.labelsDrawn = { count: labelsDrawn, focus: (slots.get(focus)?.drawing ?? moonSlots.get(focus)?.slot.drawing)?.label ?? null };
686
721
  model.tiles = tiles;
687
- const used = {};
688
- for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)]) {
689
- const shown = painting?.tiles;
690
- if (shown?.source !== undefined)
691
- used[shown.source.id] = (used[shown.source.id] ?? 0) + shown.used;
692
- }
693
722
  if (points !== undefined && deps.book !== undefined && points.count > 0)
694
723
  for (const [id, read] of deps.book.recordReads())
695
724
  used[id] = read.records.length;
@@ -698,8 +727,20 @@ export function createSpaceItem(model, deps) {
698
727
  const places = { ...moonPlaces };
699
728
  for (const id of SPACE_BODIES) {
700
729
  const at = id === hiddenBody || (rideFrom && id === rideFrom.around) ? null : labelFor(pos[id]);
701
- places[id] = at ? { x: at.x, y: at.y, r: px[id] } : null;
730
+ const drawing = slots.get(id)?.drawing;
731
+ places[id] = at ? { x: at.x, y: at.y, r: px[id], named: drawing !== undefined && drawing.object.visible && drawing.label?.shown === true } : null;
732
+ }
733
+ // a body behind another: its place is inside a nearer body's disc
734
+ const entries = [];
735
+ for (const [id, at] of Object.entries(places)) {
736
+ if (at === null)
737
+ continue;
738
+ const distance = SPACE_BODIES.includes(id) ? Math.hypot(pos[id][0] - camera.position.x, pos[id][1] - camera.position.y, pos[id][2] - camera.position.z) : moonDistances[id];
739
+ if (distance !== undefined)
740
+ entries.push({ id, x: at.x, y: at.y, r: at.r, distance });
702
741
  }
742
+ for (const [id, cover] of coveredBy(entries))
743
+ places[id].behind = cover;
703
744
  deps.onLabels(places);
704
745
  }
705
746
  if (model.rideLost)
@@ -1,6 +1,6 @@
1
1
  import type { PlanetId } from "./facts.ts";
2
2
  /**
3
- * The ten craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker` and `webb`.
3
+ * The eighteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex` and `solarorbiter`.
4
4
  *
5
5
  * @example
6
6
  * ```ts
@@ -9,7 +9,7 @@ import type { PlanetId } from "./facts.ts";
9
9
  * console.log(SPACECRAFT_IDS.join(", "));
10
10
  * ```
11
11
  */
12
- export declare const SPACECRAFT_IDS: readonly ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb"];
12
+ export declare const SPACECRAFT_IDS: readonly ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb", "bepicolombo", "psyche", "europaclipper", "lucy", "juice", "hayabusa2", "osirisapex", "solarorbiter"];
13
13
  /**
14
14
  * The name of a craft: `voyager1`, `cassini`, `webb`...
15
15
  *
@@ -84,7 +84,7 @@ export interface SpacecraftFacts {
84
84
  end: number | undefined;
85
85
  /** "active" while NASA's page lists the mission as active, else "ended". */
86
86
  status: "active" | "ended";
87
- /** NASA's page for the mission. */
87
+ /** The mission's page: NASA's, or the lead agency's (ESA's or JAXA's) where NASA has none. */
88
88
  url: string;
89
89
  /** The craft's number in JPL Horizons. */
90
90
  horizons: string;
@@ -102,7 +102,7 @@ export interface SpacecraftFacts {
102
102
  events: readonly SpacecraftEvent[];
103
103
  }
104
104
  /**
105
- * The ten craft and their facts, keyed by id.
105
+ * The eighteen craft and their facts, keyed by id.
106
106
  *
107
107
  * @example
108
108
  * ```ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The ten craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker` and `webb`.
2
+ * The eighteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex` and `solarorbiter`.
3
3
  *
4
4
  * @example
5
5
  * ```ts
@@ -8,13 +8,13 @@
8
8
  * console.log(SPACECRAFT_IDS.join(", "));
9
9
  * ```
10
10
  */
11
- export const SPACECRAFT_IDS = ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb"];
11
+ export const SPACECRAFT_IDS = ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb", "bepicolombo", "psyche", "europaclipper", "lucy", "juice", "hayabusa2", "osirisapex", "solarorbiter"];
12
12
  const T = Date.UTC;
13
13
  const noon = (y, m, d) => T(y, m - 1, d, 12);
14
14
  const ev = (kind, date, precision, en, ja, more = {}) => ({ kind, date, precision, name: { en, ja }, ...more });
15
15
  const flyby = (date, precision, en, ja, body, distanceKm) => ev("flyby", date, precision, en, ja, { ...(body === undefined ? {} : { body }), ...(distanceKm === undefined ? {} : { distanceKm }) });
16
16
  /**
17
- * The ten craft and their facts, keyed by id.
17
+ * The eighteen craft and their facts, keyed by id.
18
18
  *
19
19
  * @example
20
20
  * ```ts
@@ -212,4 +212,159 @@ export const SPACECRAFT = {
212
212
  ev("arrival", noon(2022, 1, 24), "day", "Arrival at the Sun–Earth second Lagrange point (L2)", "太陽・地球系の第2ラグランジュ点 (L2) に到着"),
213
213
  ],
214
214
  },
215
+ bepicolombo: {
216
+ id: "bepicolombo",
217
+ name: { en: "BepiColombo", ja: "ベピコロンボ" },
218
+ agency: "ESA, JAXA",
219
+ launch: { date: T(2018, 9, 20, 1, 45, 28), precision: "minute", site: { en: "Kourou, French Guiana (ELA-3)", ja: "クールー (フランス領ギアナ) ELA-3" }, vehicle: "Ariane 5 ECA" },
220
+ end: undefined,
221
+ status: "active",
222
+ url: "https://www.esa.int/Science_Exploration/Space_Science/BepiColombo",
223
+ horizons: "-121",
224
+ record: { start: 1_540_001_540_535, end: 1_807_401_598_535 },
225
+ joins: [],
226
+ events: [
227
+ ev("launch", T(2018, 9, 20, 1, 45, 28), "minute", "Launch", "打ち上げ"),
228
+ flyby(noon(2020, 4, 10), "day", "Earth flyby", "地球フライバイ", "earth", 12_700),
229
+ flyby(noon(2020, 10, 15), "day", "Venus flyby", "金星フライバイ", "venus", 10_700),
230
+ flyby(noon(2021, 8, 10), "day", "Second Venus flyby", "2回目の金星フライバイ", "venus", 550),
231
+ flyby(noon(2021, 10, 1), "day", "Mercury flyby", "水星フライバイ", "mercury", 200),
232
+ flyby(noon(2022, 6, 23), "day", "Second Mercury flyby", "2回目の水星フライバイ", "mercury", 200),
233
+ flyby(noon(2023, 6, 19), "day", "Third Mercury flyby", "3回目の水星フライバイ", "mercury", 236),
234
+ flyby(noon(2024, 9, 4), "day", "Fourth Mercury flyby", "4回目の水星フライバイ", "mercury", 165),
235
+ flyby(noon(2024, 12, 1), "day", "Fifth Mercury flyby", "5回目の水星フライバイ", "mercury", 37_600),
236
+ flyby(noon(2025, 1, 8), "day", "Sixth Mercury flyby", "6回目の水星フライバイ", "mercury", 295),
237
+ ],
238
+ },
239
+ psyche: {
240
+ id: "psyche",
241
+ name: { en: "Psyche", ja: "プシケ" },
242
+ agency: "NASA",
243
+ launch: { date: T(2023, 9, 13, 14, 19), precision: "minute", site: { en: "Kennedy Space Center, Florida (Launch Complex 39A)", ja: "ケネディ宇宙センター 39A発射施設 (フロリダ州)" }, vehicle: "Falcon Heavy" },
244
+ end: undefined,
245
+ status: "active",
246
+ url: "https://science.nasa.gov/mission/psyche/",
247
+ horizons: "-255",
248
+ record: { start: 1_697_210_508_955, end: 1_866_668_591_955 },
249
+ joins: [{ date: 1_803_902_406_955, km: 1_968_170 }],
250
+ events: [ev("launch", T(2023, 9, 13, 14, 19), "minute", "Launch", "打ち上げ"), flyby(noon(2026, 5, 15), "day", "Mars flyby", "火星フライバイ", "mars", 4_500)],
251
+ },
252
+ europaclipper: {
253
+ id: "europaclipper",
254
+ name: { en: "Europa Clipper", ja: "エウロパ・クリッパー" },
255
+ agency: "NASA",
256
+ launch: { date: T(2024, 9, 14, 16, 6), precision: "minute", site: { en: "Kennedy Space Center, Florida (Launch Complex 39A)", ja: "ケネディ宇宙センター 39A発射施設 (フロリダ州)" }, vehicle: "Falcon Heavy" },
257
+ end: undefined,
258
+ status: "active",
259
+ url: "https://science.nasa.gov/mission/europa-clipper/",
260
+ horizons: "-159",
261
+ record: { start: 1_728_922_435_528, end: 2_040_871_502_528 },
262
+ joins: [{ date: 1_800_662_414_528, km: 3_985 }],
263
+ events: [
264
+ ev("launch", T(2024, 9, 14, 16, 6), "minute", "Launch", "打ち上げ"),
265
+ flyby(noon(2025, 3, 1), "day", "Mars flyby", "火星フライバイ", "mars", 884),
266
+ flyby(noon(2026, 12, 3), "day", "Earth flyby", "地球フライバイ", "earth", 3_200),
267
+ ],
268
+ },
269
+ lucy: {
270
+ id: "lucy",
271
+ name: { en: "Lucy", ja: "ルーシー" },
272
+ agency: "NASA",
273
+ launch: { date: T(2021, 9, 16, 9, 34), precision: "minute", site: { en: "Cape Canaveral, Florida (Space Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Atlas V 401" },
274
+ end: undefined,
275
+ status: "active",
276
+ url: "https://science.nasa.gov/mission/lucy/",
277
+ horizons: "-49",
278
+ record: { start: 1_634_380_320_099, end: 1_994_344_859_099 },
279
+ joins: [],
280
+ events: [
281
+ ev("launch", T(2021, 9, 16, 9, 34), "minute", "Launch", "打ち上げ"),
282
+ flyby(noon(2022, 10, 16), "day", "Earth flyby", "地球フライバイ", "earth", 350),
283
+ flyby(noon(2023, 11, 1), "day", "Flyby of the asteroid Dinkinesh", "小惑星ディンキネシュのフライバイ"),
284
+ flyby(noon(2024, 12, 13), "day", "Second Earth flyby", "2回目の地球フライバイ", "earth", 360),
285
+ flyby(noon(2025, 4, 20), "day", "Flyby of the asteroid Donaldjohanson", "小惑星ドナルドジョハンソンのフライバイ"),
286
+ flyby(noon(2027, 8, 11), "day", "Flyby of the Jupiter trojan Eurybates", "木星トロヤ群のエウリュバテスのフライバイ"),
287
+ flyby(noon(2027, 9, 15), "day", "Flyby of the Jupiter trojan Polymele", "木星トロヤ群のポリュメレのフライバイ"),
288
+ flyby(noon(2028, 4, 18), "day", "Flyby of the Jupiter trojan Leucus", "木星トロヤ群のレウコスのフライバイ"),
289
+ flyby(noon(2028, 11, 11), "day", "Flyby of the Jupiter trojan Orus", "木星トロヤ群のオルスのフライバイ"),
290
+ flyby(noon(2033, 2, 27), "day", "Flyby of the Jupiter trojan Patroclus and its moon Menoetius", "木星トロヤ群のパトロクロスと衛星メノイティオスのフライバイ"),
291
+ ],
292
+ },
293
+ juice: {
294
+ id: "juice",
295
+ name: { en: "JUICE (Jupiter Icy Moons Explorer)", ja: "ジュース (木星氷衛星探査機)" },
296
+ agency: "ESA",
297
+ launch: { date: T(2023, 3, 14, 12, 14, 36), precision: "minute", site: { en: "Kourou, French Guiana (ELA-3)", ja: "クールー (フランス領ギアナ) ELA-3" }, vehicle: "Ariane 5 ECA+" },
298
+ end: undefined,
299
+ status: "active",
300
+ url: "https://www.esa.int/Science_Exploration/Space_Science/Juice",
301
+ horizons: "-28",
302
+ record: { start: 1_681_476_138_659, end: 1_942_381_664_659 },
303
+ joins: [],
304
+ events: [
305
+ ev("launch", T(2023, 3, 14, 12, 14, 36), "minute", "Launch", "打ち上げ"),
306
+ flyby(noon(2024, 8, 19), "day", "Moon flyby", "月フライバイ"),
307
+ flyby(noon(2024, 8, 20), "day", "Earth flyby", "地球フライバイ", "earth", 6_800),
308
+ flyby(noon(2025, 8, 31), "day", "Venus flyby", "金星フライバイ", "venus", 5_000),
309
+ flyby(noon(2026, 9, 28), "day", "Second Earth flyby", "2回目の地球フライバイ", "earth"),
310
+ flyby(noon(2029, 1, 17), "day", "Third Earth flyby", "3回目の地球フライバイ", "earth"),
311
+ ],
312
+ },
313
+ hayabusa2: {
314
+ id: "hayabusa2",
315
+ name: { en: "Hayabusa2", ja: "はやぶさ2" },
316
+ agency: "JAXA",
317
+ launch: { date: T(2014, 11, 3, 4, 22, 4), precision: "minute", site: { en: "Tanegashima Space Center, Japan", ja: "種子島宇宙センター (鹿児島県)" }, vehicle: "H-IIA" },
318
+ end: undefined,
319
+ status: "active",
320
+ url: "https://www.hayabusa2.jaxa.jp/en/",
321
+ horizons: "-37",
322
+ record: { start: 1_417_587_226_999, end: 1_801_180_729_999 },
323
+ joins: [{ date: 1_417_737_616_999, km: 2_185 }, { date: 1_418_083_216_999, km: 1_859 }, { date: 1_435_802_403_999, km: 85_277 }, { date: 1_461_887_936_999, km: 29_220 }, { date: 1_472_601_540_999, km: 476_604 }, { date: 1_481_846_346_999, km: 846_314 }, { date: 1_520_380_743_999, km: 39_005 }, { date: 1_574_812_736_999, km: 3_170 }, { date: 1_629_244_750_999, km: 5_730 }, { date: 1_660_694_341_999, km: 1_937 }, { date: 1_661_903_933_999, km: 3_572 }, { date: 1_708_473_544_999, km: 1_970 }, { date: 1_710_892_750_999, km: 1_914 }, { date: 1_715_731_141_999, km: 6_222 }, { date: 1_717_545_540_999, km: 6_692 }, { date: 1_719_359_939_999, km: 2_423 }, { date: 1_748_390_345_999, km: 2_376 }, { date: 1_750_204_744_999, km: 1_950 }, { date: 1_755_043_134_999, km: 2_491 }, { date: 1_785_887_940_999, km: 5_934 }, { date: 1_786_492_746_999, km: 3_540 }, { date: 1_787_702_339_999, km: 3_833 }, { date: 1_788_307_145_999, km: 1_926 }, { date: 1_788_911_931_999, km: 2_361 }, { date: 1_789_516_738_999, km: 2_300 }, { date: 1_793_145_536_999, km: 2_217 }],
324
+ events: [
325
+ ev("launch", T(2014, 11, 3, 4, 22, 4), "minute", "Launch", "打ち上げ"),
326
+ flyby(noon(2015, 12, 3), "day", "Earth flyby", "地球スイングバイ", "earth", 3_090),
327
+ ev("arrival", noon(2018, 6, 27), "day", "Arrival at the asteroid Ryugu", "小惑星リュウグウに到着"),
328
+ flyby(T(2026, 6, 5, 9, 30), "minute", "Flyby of the asteroid Torifune", "小惑星トリフネのフライバイ"),
329
+ ],
330
+ },
331
+ osirisapex: {
332
+ id: "osirisapex",
333
+ name: { en: "OSIRIS-APEX (OSIRIS-REx)", ja: "オシリス・エイペックス (オシリス・レックス)" },
334
+ agency: "NASA",
335
+ launch: { date: T(2016, 8, 8, 23, 5), precision: "minute", site: { en: "Cape Canaveral, Florida (Space Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Atlas V 411" },
336
+ end: undefined,
337
+ status: "active",
338
+ url: "https://science.nasa.gov/mission/osiris-apex/",
339
+ horizons: "-64",
340
+ record: { start: 1_473_375_901_098, end: 1_900_439_930_098 },
341
+ joins: [{ date: 1_728_518_339_098, km: 2_622 }],
342
+ events: [
343
+ ev("launch", T(2016, 8, 8, 23, 5), "minute", "Launch", "打ち上げ"),
344
+ flyby(noon(2017, 9, 22), "day", "Earth flyby", "地球フライバイ", "earth", 17_200),
345
+ ev("arrival", noon(2018, 12, 3), "day", "Arrival at the asteroid Bennu", "小惑星ベンヌに到着"),
346
+ ],
347
+ },
348
+ solarorbiter: {
349
+ id: "solarorbiter",
350
+ name: { en: "Solar Orbiter", ja: "ソーラー・オービター" },
351
+ agency: "ESA, NASA",
352
+ launch: { date: T(2020, 1, 10, 4, 3), precision: "minute", site: { en: "Cape Canaveral, Florida (Space Launch Complex 41)", ja: "ケープカナベラル 41番発射施設 (フロリダ州)" }, vehicle: "Atlas V 411" },
353
+ end: undefined,
354
+ status: "active",
355
+ url: "https://www.esa.int/Science_Exploration/Space_Science/Solar_Orbiter",
356
+ horizons: "-144",
357
+ record: { start: 1_581_310_550_671, end: 1_921_380_611_671 },
358
+ joins: [],
359
+ events: [
360
+ ev("launch", T(2020, 1, 10, 4, 3), "minute", "Launch", "打ち上げ"),
361
+ flyby(noon(2020, 12, 27), "day", "Venus flyby", "金星フライバイ", "venus", 7_500),
362
+ flyby(noon(2021, 8, 9), "day", "Second Venus flyby", "2回目の金星フライバイ", "venus", 7_995),
363
+ flyby(noon(2021, 11, 27), "day", "Earth flyby", "地球フライバイ", "earth", 460),
364
+ flyby(noon(2022, 9, 4), "day", "Third Venus flyby", "3回目の金星フライバイ", "venus"),
365
+ flyby(noon(2025, 2, 18), "day", "Fourth Venus flyby", "4回目の金星フライバイ", "venus", 379),
366
+ flyby(noon(2026, 12, 24), "day", "Fifth Venus flyby", "5回目の金星フライバイ", "venus"),
367
+ flyby(noon(2030, 9, 3), "day", "Sixth Venus flyby", "6回目の金星フライバイ", "venus"),
368
+ ],
369
+ },
215
370
  };
@@ -4,10 +4,10 @@ import { type When } from "./when.ts";
4
4
  export { SPACECRAFT, SPACECRAFT_IDS, type SpacecraftEvent, type SpacecraftFacts, type SpacecraftId } from "./spacecraft-facts.ts";
5
5
  export type { When } from "./when.ts";
6
6
  /**
7
- * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet.
7
+ * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet or fly past many.
8
8
  * Call it once before the other functions; it is safe to call again.
9
9
  *
10
- * @param ids - The craft to load; none means all ten.
10
+ * @param ids - The craft to load; none means all eighteen.
11
11
  * @returns A promise that settles when every table is registered.
12
12
  *
13
13
  * @example
@@ -132,3 +132,70 @@ export declare function spacecraftLightTime(id: SpacecraftId, when: When): numbe
132
132
  * ```
133
133
  */
134
134
  export declare function spacecraftErrorKm(id: SpacecraftId): number;
135
+ /**
136
+ * A distance in the units a page shows it in.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { loadSpacecraft, spacecraftStats, type SpacecraftDistance } from "@johnmorrisdotca/wakusei-planets/spacecraft";
141
+ *
142
+ * await loadSpacecraft("lucy");
143
+ * const d: SpacecraftDistance = spacecraftStats("lucy", Date.UTC(2026, 10, 11)).earth;
144
+ * console.log(d.km, d.au, d.lightSeconds);
145
+ * ```
146
+ */
147
+ export interface SpacecraftDistance {
148
+ /** In kilometres. */
149
+ km: number;
150
+ /** In astronomical units. */
151
+ au: number;
152
+ /** The one-way light time in seconds. */
153
+ lightSeconds: number;
154
+ }
155
+ /**
156
+ * The numbers a page shows about a craft at a moment.
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { loadSpacecraft, spacecraftStats, type SpacecraftStats } from "@johnmorrisdotca/wakusei-planets/spacecraft";
161
+ *
162
+ * await loadSpacecraft("juice");
163
+ * const stats: SpacecraftStats = spacecraftStats("juice", Date.UTC(2026, 10, 11));
164
+ * console.log(stats.daysSinceLaunch.toFixed(0), "days since launch");
165
+ * ```
166
+ */
167
+ export interface SpacecraftStats {
168
+ /** The craft. */
169
+ id: SpacecraftId;
170
+ /** The moment, in milliseconds since 1970 (UTC). */
171
+ when: number;
172
+ /** Distance from the Sun's centre. */
173
+ sun: SpacecraftDistance;
174
+ /** Distance from the Earth's centre (no allowance for the light's travel). */
175
+ earth: SpacecraftDistance;
176
+ /** Speed in kilometres a second relative to the Sun and to the Earth. */
177
+ speed: {
178
+ sun: number;
179
+ earth: number;
180
+ };
181
+ /** Days since the launch (a fraction of a day counts). */
182
+ daysSinceLaunch: number;
183
+ }
184
+ /**
185
+ * A craft's numbers at a moment, like the Roadster's: its distance from the Sun and the Earth in kilometres and astronomical units with the light time, its speed relative to each, and the days since launch. The Earth is the
186
+ * package's own (`heliocentric`). A moment outside the record of the craft throws a `RangeError`.
187
+ *
188
+ * @param id - The craft (its path must be loaded).
189
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
190
+ * @returns The numbers.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * import { loadSpacecraft, spacecraftStats } from "@johnmorrisdotca/wakusei-planets/spacecraft";
195
+ *
196
+ * await loadSpacecraft("lucy");
197
+ * const stats = spacecraftStats("lucy", new Date("2026-11-11T12:00:00Z"));
198
+ * console.log(stats.sun.au.toFixed(2), "au from the Sun,", (stats.earth.km / 1e6).toFixed(0), "million km from the Earth,", stats.earth.lightSeconds.toFixed(0), "light seconds,", stats.speed.sun.toFixed(1), "km/s");
199
+ * ```
200
+ */
201
+ export declare function spacecraftStats(id: SpacecraftId, when: When): SpacecraftStats;
@@ -21,6 +21,14 @@ const LOADERS = {
21
21
  juno: () => import("./craft/juno.js"),
22
22
  parker: () => import("./craft/parker.js"),
23
23
  webb: () => import("./craft/webb.js"),
24
+ bepicolombo: () => import("./craft/bepicolombo.js"),
25
+ psyche: () => import("./craft/psyche.js"),
26
+ europaclipper: () => import("./craft/europaclipper.js"),
27
+ lucy: () => import("./craft/lucy.js"),
28
+ juice: () => import("./craft/juice.js"),
29
+ hayabusa2: () => import("./craft/hayabusa2.js"),
30
+ osirisapex: () => import("./craft/osirisapex.js"),
31
+ solarorbiter: () => import("./craft/solarorbiter.js"),
24
32
  };
25
33
  function facts(id) {
26
34
  const found = SPACECRAFT[id];
@@ -29,10 +37,10 @@ function facts(id) {
29
37
  return found;
30
38
  }
31
39
  /**
32
- * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet.
40
+ * Load the fitted paths of some spacecraft (or all of them), each a table of its own that nothing else imports: about 6 kB gzipped for the Voyagers, the Pioneers, New Horizons and JWST, and more for the craft that orbited a planet or fly past many.
33
41
  * Call it once before the other functions; it is safe to call again.
34
42
  *
35
- * @param ids - The craft to load; none means all ten.
43
+ * @param ids - The craft to load; none means all eighteen.
36
44
  * @returns A promise that settles when every table is registered.
37
45
  *
38
46
  * @example
@@ -196,3 +204,38 @@ export function spacecraftErrorKm(id) {
196
204
  throw new Error(`the path of ${facts(id).name.en} is not loaded: await loadSpacecraft(${JSON.stringify(id)}) first`);
197
205
  return table.worst;
198
206
  }
207
+ /**
208
+ * A craft's numbers at a moment, like the Roadster's: its distance from the Sun and the Earth in kilometres and astronomical units with the light time, its speed relative to each, and the days since launch. The Earth is the
209
+ * package's own (`heliocentric`). A moment outside the record of the craft throws a `RangeError`.
210
+ *
211
+ * @param id - The craft (its path must be loaded).
212
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
213
+ * @returns The numbers.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { loadSpacecraft, spacecraftStats } from "@johnmorrisdotca/wakusei-planets/spacecraft";
218
+ *
219
+ * await loadSpacecraft("lucy");
220
+ * const stats = spacecraftStats("lucy", new Date("2026-11-11T12:00:00Z"));
221
+ * console.log(stats.sun.au.toFixed(2), "au from the Sun,", (stats.earth.km / 1e6).toFixed(0), "million km from the Earth,", stats.earth.lightSeconds.toFixed(0), "light seconds,", stats.speed.sun.toFixed(1), "km/s");
222
+ * ```
223
+ */
224
+ export function spacecraftStats(id, when) {
225
+ const ms = moment(when);
226
+ const position = spacecraftPosition(id, ms);
227
+ const velocity = spacecraftVelocity(id, ms);
228
+ const h = 3_600_000;
229
+ const earthAt = (t) => scale(heliocentric("earth", t), AU_KM);
230
+ const earth = earthAt(ms);
231
+ const earthVelocity = scale(sub(earthAt(ms + h), earthAt(ms - h)), 1 / 7200);
232
+ const distance = (km) => ({ km, au: km / AU_KM, lightSeconds: km / LIGHT_KM_PER_SECOND });
233
+ return {
234
+ id,
235
+ when: ms,
236
+ sun: distance(length(position)),
237
+ earth: distance(length(sub(position, earth))),
238
+ speed: { sun: length(velocity), earth: length(sub(velocity, earthVelocity)) },
239
+ daysSinceLaunch: (ms - facts(id).launch.date) / 86_400_000,
240
+ };
241
+ }
Binary file
Binary file
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.33.0";
1
+ export declare const VERSION = "0.35.0";