@johnmorrisdotca/wakusei-planets 0.34.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 (203) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE.md +48 -0
  3. package/README.md +21 -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.js +17 -3
  101. package/dist/places/67p.d.ts +13 -0
  102. package/dist/places/67p.js +14 -0
  103. package/dist/places/ariel.d.ts +13 -0
  104. package/dist/places/ariel.js +14 -0
  105. package/dist/places/bennu.d.ts +13 -0
  106. package/dist/places/bennu.js +14 -0
  107. package/dist/places/callisto.d.ts +13 -0
  108. package/dist/places/callisto.js +14 -0
  109. package/dist/places/ceres.d.ts +13 -0
  110. package/dist/places/ceres.js +14 -0
  111. package/dist/places/charon.d.ts +13 -0
  112. package/dist/places/charon.js +14 -0
  113. package/dist/places/dimorphos.d.ts +13 -0
  114. package/dist/places/dimorphos.js +14 -0
  115. package/dist/places/dione.d.ts +13 -0
  116. package/dist/places/dione.js +14 -0
  117. package/dist/places/enceladus.d.ts +13 -0
  118. package/dist/places/enceladus.js +14 -0
  119. package/dist/places/eros.d.ts +13 -0
  120. package/dist/places/eros.js +14 -0
  121. package/dist/places/europa.d.ts +13 -0
  122. package/dist/places/europa.js +14 -0
  123. package/dist/places/ganymede.d.ts +13 -0
  124. package/dist/places/ganymede.js +14 -0
  125. package/dist/places/iapetus.d.ts +13 -0
  126. package/dist/places/iapetus.js +14 -0
  127. package/dist/places/io.d.ts +13 -0
  128. package/dist/places/io.js +14 -0
  129. package/dist/places/jupiter.d.ts +13 -0
  130. package/dist/places/jupiter.js +14 -0
  131. package/dist/places/mars.d.ts +12 -0
  132. package/dist/places/mars.js +13 -0
  133. package/dist/places/mercury.d.ts +13 -0
  134. package/dist/places/mercury.js +14 -0
  135. package/dist/places/mimas.d.ts +13 -0
  136. package/dist/places/mimas.js +14 -0
  137. package/dist/places/miranda.d.ts +13 -0
  138. package/dist/places/miranda.js +14 -0
  139. package/dist/places/moon.d.ts +12 -0
  140. package/dist/places/moon.js +13 -0
  141. package/dist/places/oberon.d.ts +13 -0
  142. package/dist/places/oberon.js +14 -0
  143. package/dist/places/pluto.d.ts +13 -0
  144. package/dist/places/pluto.js +14 -0
  145. package/dist/places/rhea.d.ts +13 -0
  146. package/dist/places/rhea.js +14 -0
  147. package/dist/places/ryugu.d.ts +13 -0
  148. package/dist/places/ryugu.js +14 -0
  149. package/dist/places/saturn.d.ts +13 -0
  150. package/dist/places/saturn.js +14 -0
  151. package/dist/places/tempel-1.d.ts +13 -0
  152. package/dist/places/tempel-1.js +14 -0
  153. package/dist/places/tethys.d.ts +13 -0
  154. package/dist/places/tethys.js +14 -0
  155. package/dist/places/titan.d.ts +13 -0
  156. package/dist/places/titan.js +14 -0
  157. package/dist/places/titania.d.ts +13 -0
  158. package/dist/places/titania.js +14 -0
  159. package/dist/places/triton.d.ts +13 -0
  160. package/dist/places/triton.js +14 -0
  161. package/dist/places/umbriel.d.ts +13 -0
  162. package/dist/places/umbriel.js +14 -0
  163. package/dist/places/venus.d.ts +13 -0
  164. package/dist/places/venus.js +14 -0
  165. package/dist/places/vesta.d.ts +13 -0
  166. package/dist/places/vesta.js +14 -0
  167. package/dist/places.d.ts +354 -0
  168. package/dist/places.js +357 -0
  169. package/dist/plan/element.d.ts +52 -0
  170. package/dist/plan/element.js +258 -0
  171. package/dist/plan/index.d.ts +2 -0
  172. package/dist/plan/index.js +2 -0
  173. package/dist/plan/layout.d.ts +230 -0
  174. package/dist/plan/layout.js +229 -0
  175. package/dist/plan/svg.d.ts +125 -0
  176. package/dist/plan/svg.js +185 -0
  177. package/dist/roadster.d.ts +415 -0
  178. package/dist/roadster.js +496 -0
  179. package/dist/scene/body.js +10 -9
  180. package/dist/scene/painter.d.ts +1 -1
  181. package/dist/scene/painter.js +23 -7
  182. package/dist/scene/textures.d.ts +2 -2
  183. package/dist/space/beside.d.ts +4 -1
  184. package/dist/space/beside.js +47 -6
  185. package/dist/space/covered.d.ts +102 -0
  186. package/dist/space/covered.js +98 -0
  187. package/dist/space/element.d.ts +21 -1
  188. package/dist/space/element.js +126 -11
  189. package/dist/space/index.d.ts +1 -0
  190. package/dist/space/index.js +1 -0
  191. package/dist/space/scale.d.ts +2 -1
  192. package/dist/space/scale.js +13 -2
  193. package/dist/space/scene.d.ts +10 -0
  194. package/dist/space/scene.js +45 -22
  195. package/dist/spacecraft-facts.d.ts +4 -4
  196. package/dist/spacecraft-facts.js +158 -3
  197. package/dist/spacecraft.d.ts +69 -2
  198. package/dist/spacecraft.js +45 -2
  199. package/dist/textures/mimas-1024.webp +0 -0
  200. package/dist/textures/mimas-512.webp +0 -0
  201. package/dist/version.d.ts +1 -1
  202. package/dist/version.js +1 -1
  203. package/package.json +203 -1
@@ -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
@@ -155,6 +155,8 @@ 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;
160
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. */
@@ -201,6 +203,10 @@ export interface SpaceModel {
201
203
  camera: {
202
204
  position: [number, number, number];
203
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];
204
210
  };
205
211
  /** The body or point the camera rides along with, or null. */
206
212
  ride: RideState | null;
@@ -237,6 +243,10 @@ export interface BodyPlace {
237
243
  x: number;
238
244
  y: number;
239
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;
240
250
  }
241
251
  export interface SpaceDeps {
242
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,6 +67,7 @@ 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,
71
73
  label: null,
@@ -77,7 +79,7 @@ export const newSpaceModel = () => ({
77
79
  motion: 0,
78
80
  drawnView: null,
79
81
  heightPx: 420,
80
- camera: { position: [0, 0, 0], fov: FOV },
82
+ camera: { position: [0, 0, 0], fov: FOV, up: [0, 1, 0], forward: [0, 0, -1] },
81
83
  ride: null,
82
84
  rideLost: false,
83
85
  transition: null,
@@ -305,7 +307,7 @@ export function createSpaceItem(model, deps) {
305
307
  if (ride.view === "beside") {
306
308
  // beyond the Moon and off the line to the Earth, the Earth in view behind it
307
309
  if (id === "moon")
308
- 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 };
309
311
  focus = id;
310
312
  focusPos = pos[id];
311
313
  focusRadius = radiusOf(id);
@@ -333,7 +335,7 @@ export function createSpaceItem(model, deps) {
333
335
  if (ride.view === "beside") {
334
336
  const there = [centre[0] + offset[0] * unitWorld, centre[1] + offset[1] * unitWorld, centre[2] + offset[2] * unitWorld];
335
337
  const radius = Math.max(1e-6, (BODIES[id].radiusKm / BODIES[around].radiusKm) * unitWorld);
336
- 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 };
337
339
  focus = id;
338
340
  focusPos = there;
339
341
  focusRadius = radius;
@@ -441,7 +443,8 @@ export function createSpaceItem(model, deps) {
441
443
  camera.updateMatrixWorld();
442
444
  const hiddenBody = rideFrom?.hiddenBody ?? null;
443
445
  const hiddenMoon = rideFrom?.hiddenMoon ?? null;
444
- 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]] };
445
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 };
446
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 };
447
450
  model.heightPx = size.height;
@@ -589,6 +592,8 @@ export function createSpaceItem(model, deps) {
589
592
  arrowGeometry.getAttribute("color").needsUpdate = true;
590
593
  // help mode: on the body looked at, the line of its axis and a curved arrow round it the way it turns
591
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;
592
597
  model.helpDrawn = null;
593
598
  if (model.help) {
594
599
  const turn = spinAxis(focus, model.time);
@@ -618,6 +623,7 @@ export function createSpaceItem(model, deps) {
618
623
  const now = performance.now();
619
624
  const seen = new Set();
620
625
  const moonPlaces = {};
626
+ const moonDistances = {};
621
627
  for (const id of [...SPACE_PLANETS, ...SPACE_DWARFS]) {
622
628
  const planet = slotOf(id).drawing;
623
629
  if (!planet)
@@ -658,8 +664,10 @@ export function createSpaceItem(model, deps) {
658
664
  const moonPx = away <= drawn * 1.001 ? 1e5 : ((size.height / 2) * (drawn / Math.sqrt(away * away - drawn * drawn))) / half;
659
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 } });
660
666
  const spot = labelFor(at);
661
- if (spot)
662
- 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
+ }
663
671
  }
664
672
  }
665
673
  let soonest = Number.POSITIVE_INFINITY;
@@ -685,29 +693,32 @@ export function createSpaceItem(model, deps) {
685
693
  paintedMoons += 1;
686
694
  model.painted.moons = paintedMoons;
687
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
688
697
  let labelsDrawn = 0;
689
- for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)])
690
- if (painting?.object.visible && painting.label?.shown)
691
- labelsDrawn += 1;
692
- model.labelsDrawn = { count: labelsDrawn, focus: (slots.get(focus)?.drawing ?? moonSlots.get(focus)?.slot.drawing)?.label ?? null };
693
698
  const tiles = { requested: 0, loading: 0, failed: 0, shown: null };
694
- for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)]) {
695
- 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;
696
706
  if (stats === undefined)
697
- continue;
707
+ return;
698
708
  tiles.requested += stats.requested;
699
709
  tiles.loading += stats.loading;
700
710
  tiles.failed += stats.failed;
701
711
  if (stats.shown !== null)
702
712
  tiles.shown = Math.max(tiles.shown ?? 0, stats.shown);
703
- }
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 };
704
721
  model.tiles = tiles;
705
- const used = {};
706
- for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)]) {
707
- const shown = painting?.tiles;
708
- if (shown?.source !== undefined)
709
- used[shown.source.id] = (used[shown.source.id] ?? 0) + shown.used;
710
- }
711
722
  if (points !== undefined && deps.book !== undefined && points.count > 0)
712
723
  for (const [id, read] of deps.book.recordReads())
713
724
  used[id] = read.records.length;
@@ -716,8 +727,20 @@ export function createSpaceItem(model, deps) {
716
727
  const places = { ...moonPlaces };
717
728
  for (const id of SPACE_BODIES) {
718
729
  const at = id === hiddenBody || (rideFrom && id === rideFrom.around) ? null : labelFor(pos[id]);
719
- 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 });
720
741
  }
742
+ for (const [id, cover] of coveredBy(entries))
743
+ places[id].behind = cover;
721
744
  deps.onLabels(places);
722
745
  }
723
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.34.0";
1
+ export declare const VERSION = "0.35.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.34.0";
1
+ export const VERSION = "0.35.0";