@johnmorrisdotca/wakusei-planets 0.42.0 → 0.43.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.
package/CHANGELOG.md CHANGED
@@ -2,13 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.43.0] - 2026-11-13
6
+
7
+ - **The space view draws the deep-space craft** (MODULES-1207). `spacecraft` on `<wakusei-space>` (and `space.spacecraft`) is off by default. `"all"` or `true` draws every craft whose record covers the date, as one points object with a name each; a space-separated list draws those. A craft outside its record is not drawn and `stats.spacecraft.status[id]` is `"outside"`. Each table loads the first time that craft is shown. `sight()` and `wakusei-sight` give each drawn craft `{ id, kind: "spacecraft" }` using the craft's own id. A press sends `wakusei-body-click` with that kind and does not go to the craft. No path line.
8
+
9
+ - **The Roadster joins the spacecraft list** (MODULES-1208). `roadster` is the nineteenth entry of `SPACECRAFT`: Starman / スターマン, other names Tesla Roadster, Starman and Tesla, kind `other`, Horizons `-143205`, the Falcon Heavy launch from Kennedy Space Center 39A. `findSpacecraft` matches an id, either name or an other name, with case, letter width, spaces and punctuation folded. `spacecraftPosition`, `spacecraftSpeed`, `spacecraftSunDistance`, `spacecraftLightTime` and `spacecraftStats` answer for it from the Roadster's own path, and the 20 kB table loads only with `loadSpacecraft("roadster")`. `/roadster` is unchanged. The craft page's picker shows it.
10
+
5
11
  ## [0.42.0] - 2026-11-13
6
12
 
7
13
  - **An arrival keeps a companion in the picture** (MODULES-1026). `arrivalSide` (and `travelArrival`, which uses it) stands on the side where the frame is not empty black: the body's own moons, or its planet when it is a moon; else the body the camera came from, or the nearest planet in that direction; else the Sun, only while at least half the body stays lit. A side that would turn the globe black is refused. `goTo` and a double click (the zoom jump to 1 or to 2) set the controls to that side; a drag afterwards is left as the reader set it. `stats.companion` names the body kept beside it, and that name is not dropped when names would otherwise clash. The swing is not applied to a straight move (`direct`, `look-back`), which keeps its destination in the picture the whole way.
8
14
 
9
15
  - **Moons are larger than life in the squeezed view** (MODULES-989). `moon-size` on `<wakusei-space>` (and `space.moonSize`) is 2 by default: moons are drawn that many times their real radius, only while `scale` is `compressed`. 1 is today's size; 4 and 8 go further. True distances ignore it. Every moon of one planet takes the same factor, so they keep their real order of size. The factor is cut when a moon would be larger than a quarter of its planet, would touch the planet or its rings, or would reach the next moon's orbit, and `stats.moonSize` reports the factor used and `clamped`. Picking, the name on the body and the hidden-body rule use that drawn size. `moonSizeFactor` from `/space` is the same rule on plain numbers. A moon looked at, or gone to, is framed at the size it is drawn, so it still fits the view.
10
16
 
11
- - **A page for the spacecraft** (MODULES-875). `craft.html` picks one of the eighteen craft, draws its path and where it is on a date, and lists the facts and the voyage. The craft's table loads only when it is chosen. The date plays when the page opens, and every time shown is the reader's own. English and Japanese.
17
+ - **A page for the spacecraft** (MODULES-875). `craft.html` picks one of the nineteen craft, draws its path and where it is on a date, and lists the facts and the voyage. The craft's table loads only when it is chosen. The date plays when the page opens, and every time shown is the reader's own. English and Japanese.
12
18
 
13
19
  ## [0.41.0] - 2026-11-13
14
20
 
package/README.md CHANGED
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
19
19
 
20
20
  <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
21
 
22
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.42.0/docs/images/lineup-desk.png" width="640"></p>
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.43.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
388
388
 
389
389
  ## The portrait builder
390
390
 
391
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.42.0/docs/images/portrait-family.png" width="640"></p>
391
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.43.0/docs/images/portrait-family.png" width="640"></p>
392
392
 
393
393
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
394
394
 
@@ -534,7 +534,7 @@ BODIES.pluto.kind; // "dwarf-planet"
534
534
 
535
535
  If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
536
536
 
537
- > Morris, J. (2026). *Wakusei Planets* (version 0.42.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
537
+ > Morris, J. (2026). *Wakusei Planets* (version 0.43.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
538
538
 
539
539
  Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
540
540
 
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
11
11
  * console.log(TEXTURE_BASE);
12
12
  * ```
13
13
  */
14
- export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.42.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.43.0/dist/textures/";
15
15
  /**
16
16
  * Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
17
17
  * never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
23
23
  * console.log(TEXTURE_FAR_BASE);
24
24
  * ```
25
25
  */
26
- export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.42.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.43.0/textures/";
27
27
  /**
28
28
  * Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
29
29
  * a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
@@ -78,8 +78,9 @@ export interface BodyHover extends BodyInfo {
78
78
  * ```
79
79
  */
80
80
  export interface BodySight extends Sight {
81
- id: BodyId;
82
- kind: SpaceKind;
81
+ /** A body's id, or a craft's own id (`voyager1`, `roadster`) when `kind` is `spacecraft`. */
82
+ id: string;
83
+ kind: SpaceKind | "spacecraft";
83
84
  host?: BodyId;
84
85
  }
85
86
  /**
@@ -313,6 +314,11 @@ export declare class WakuseiSpace extends HTMLElement {
313
314
  */
314
315
  get roadster(): boolean;
315
316
  set roadster(value: boolean);
317
+ /**
318
+ * The deep-space craft (the attribute `spacecraft`; off by default). `true` or `"all"` draws every craft whose record covers the date. A space-separated list (`"voyager1 juno"`) draws those. Each craft's table loads the first time it is shown, and nothing loads while this is off. `stats.spacecraft` says what was drawn.
319
+ */
320
+ get spacecraft(): false | "all" | string;
321
+ set spacecraft(value: boolean | string);
316
322
  /**
317
323
  * The orbiter picked out (the attribute `orbiter`, an id from `/orbiters` such as `lro`; none by default): its orbit line is drawn brighter, it alone keeps its line when `orbiterLines` is
318
324
  * `chosen`, and its ground track is drawn when `orbiterTrack` is on.
@@ -629,6 +635,12 @@ export declare class WakuseiSpace extends HTMLElement {
629
635
  position: [number, number, number] | null;
630
636
  radiusPx: number;
631
637
  };
638
+ /** The deep-space craft at the last draw: how many dots, each id's status (`drawn` or `outside` the record), and the ids drawn. */
639
+ spacecraft: {
640
+ count: number;
641
+ status: Record<string, "drawn" | "outside">;
642
+ drawn: string[];
643
+ };
632
644
  /** How large the squeezed view drew the moons of the system in the middle: the factor asked for, the one used, and whether a limit cut it. At true distances `factor` is 1. */
633
645
  moonSize: {
634
646
  asked: number;
@@ -140,7 +140,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
140
140
  * ```
141
141
  */
142
142
  export class WakuseiSpace extends HTMLElement {
143
- static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
143
+ static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
144
144
  #model = newSpaceModel();
145
145
  #allMoons = false;
146
146
  #catalogue;
@@ -209,6 +209,9 @@ export class WakuseiSpace extends HTMLElement {
209
209
  this.#labelsAlways = this.hasAttribute("labels-always") && this.getAttribute("labels-always") !== "off";
210
210
  this.#covered = this.getAttribute("covered") === "arrow" ? "arrow" : "name";
211
211
  this.roadster = this.hasAttribute("roadster") && this.getAttribute("roadster") !== "off";
212
+ const craft = this.getAttribute("spacecraft");
213
+ if (craft !== null && craft !== "off")
214
+ this.spacecraft = craft;
212
215
  this.orbiters = this.hasAttribute("orbiters") && this.getAttribute("orbiters") !== "off";
213
216
  this.#model.orbiterChosen = this.getAttribute("orbiter") || null;
214
217
  this.#model.orbiterLines = orbiterLines(this.getAttribute("orbiter-lines"));
@@ -362,6 +365,8 @@ export class WakuseiSpace extends HTMLElement {
362
365
  this.covered = value === "arrow" ? "arrow" : "name";
363
366
  else if (name === "roadster")
364
367
  this.roadster = value !== null && value !== "off";
368
+ else if (name === "spacecraft")
369
+ this.spacecraft = value === null || value === "off" ? false : value;
365
370
  else if (name === "orbiters")
366
371
  this.orbiters = value !== null && value !== "off";
367
372
  else if (name === "orbiter")
@@ -851,6 +856,50 @@ export class WakuseiSpace extends HTMLElement {
851
856
  }
852
857
  this.#gate?.request();
853
858
  }
859
+ #craftToken = 0;
860
+ /**
861
+ * The deep-space craft (the attribute `spacecraft`; off by default). `true` or `"all"` draws every craft whose record covers the date. A space-separated list (`"voyager1 juno"`) draws those. Each craft's table loads the first time it is shown, and nothing loads while this is off. `stats.spacecraft` says what was drawn.
862
+ */
863
+ get spacecraft() {
864
+ const show = this.#model.craftShow;
865
+ if (show === null)
866
+ return false;
867
+ return show === "all" ? "all" : show.join(" ");
868
+ }
869
+ set spacecraft(value) {
870
+ const next = value === false || value === "off" ? null : value === true || value === "all" || value === "true" ? "all" : value.split(/\s+/).filter((id) => id.length > 0);
871
+ this.#model.craftShow = next === null || next === "all" ? next : next;
872
+ if (next === null) {
873
+ this.#model.craftPlaces = null;
874
+ this.#model.craftIds = [];
875
+ this.#model.craftNames = null;
876
+ this.#gate?.request();
877
+ return;
878
+ }
879
+ const token = ++this.#craftToken;
880
+ const wanted = next;
881
+ void import("../spacecraft.js").then(async (mod) => {
882
+ if (token !== this.#craftToken)
883
+ return;
884
+ const known = mod.SPACECRAFT_IDS;
885
+ const ids = (wanted === "all" ? [...known] : wanted.filter((id) => known.includes(id)));
886
+ await mod.loadSpacecraft(...ids);
887
+ if (token !== this.#craftToken || this.#model.craftShow === null)
888
+ return;
889
+ const au = 149_597_870.7;
890
+ this.#model.craftIds = ids;
891
+ this.#model.craftNames = (id, lang) => mod.SPACECRAFT[id].name[lang];
892
+ this.#model.craftPlaces = (ms) => ids.map((id) => {
893
+ const craft = mod.SPACECRAFT[id];
894
+ if (ms < craft.record.start || ms > craft.record.end || craft.record.end === 0)
895
+ return { id, au: null };
896
+ const km = mod.spacecraftPosition(id, ms);
897
+ return { id, au: [km[0] / au, km[1] / au, km[2] / au] };
898
+ });
899
+ this.#gate?.request();
900
+ });
901
+ this.#gate?.request();
902
+ }
854
903
  /**
855
904
  * The orbiter picked out (the attribute `orbiter`, an id from `/orbiters` such as `lro`; none by default): its orbit line is drawn brighter, it alone keeps its line when `orbiterLines` is
856
905
  * `chosen`, and its ground track is drawn when `orbiterTrack` is on.
@@ -1698,6 +1747,7 @@ export class WakuseiSpace extends HTMLElement {
1698
1747
  bodyLabels: { count: this.#model.labelsDrawn.count, focus: this.#model.labelsDrawn.focus === null ? null : { ...this.#model.labelsDrawn.focus } },
1699
1748
  orbiters: { count: this.#model.orbitersDrawn.count, status: { ...this.#model.orbitersDrawn.status }, dim: [...this.#model.orbitersDrawn.dim], lines: this.#model.orbitersDrawn.lines, track: this.#model.orbitersDrawn.track },
1700
1749
  roadster: { shown: this.#model.roadsterDrawn.shown, position: this.#model.roadsterDrawn.position === null ? null : [...this.#model.roadsterDrawn.position], radiusPx: this.#model.roadsterDrawn.radiusPx },
1750
+ spacecraft: { count: this.#model.craftDrawn.count, status: { ...this.#model.craftDrawn.status }, drawn: [...this.#model.craftDrawn.drawn] },
1701
1751
  companion: this.#model.companion,
1702
1752
  moonSize: { asked: this.#model.moonSize, factor: this.#model.moonDrawn.factor, clamped: this.#model.moonDrawn.clamped },
1703
1753
  };
@@ -1747,6 +1797,8 @@ export class WakuseiSpace extends HTMLElement {
1747
1797
  const lang = this.getAttribute("lang") === "ja" ? "ja" : "en";
1748
1798
  if (id === "roadster")
1749
1799
  return this.#names[id] ?? this.#model.roadsterPath?.name[lang] ?? "Starman";
1800
+ if (this.#model.craftIds.includes(id))
1801
+ return this.#names[id] ?? this.#model.craftNames?.(id, lang) ?? id;
1750
1802
  if (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))
1751
1803
  return this.#names[id] ?? this.#model.orbiterSet.name(id)[lang];
1752
1804
  return this.#names[id] ?? BODIES[id].name[lang];
@@ -1800,6 +1852,9 @@ export class WakuseiSpace extends HTMLElement {
1800
1852
  }
1801
1853
  // no two names overlap: a moon gives way to its planet and a planet to the Sun
1802
1854
  const shown = chooseLabels(wanted);
1855
+ for (const id of this.#model.craftIds)
1856
+ if (spots.has(id))
1857
+ shown.add(id);
1803
1858
  const companion = this.#model.companion;
1804
1859
  if (companion !== null && spots.has(companion))
1805
1860
  shown.add(companion);
@@ -1851,9 +1906,11 @@ export class WakuseiSpace extends HTMLElement {
1851
1906
  /** The bodies drawn at full strength: the system of the body under the pointer, or else the one in the middle of the view. */
1852
1907
  #lit() {
1853
1908
  // the Sun in the middle lights the Sun and the eight planets; a body pointed at, the Sun too, lights its own system
1854
- if (this.#hovered === null && this.#model.focus === "sun")
1909
+ // a craft's name under the pointer is no body: it lights what the view's own focus lights
1910
+ const pointed = this.#hovered !== null && Object.hasOwn(BODIES, this.#hovered) ? this.#hovered : null;
1911
+ if (pointed === null && this.#model.focus === "sun")
1855
1912
  return new Set(["sun", ...BODY_IDS.filter((id) => BODIES[id].kind === "planet")]);
1856
- const { host, moons } = systemOf(this.#hovered ?? this.#model.focus);
1913
+ const { host, moons } = systemOf(pointed ?? this.#model.focus);
1857
1914
  return new Set([host, ...moons]);
1858
1915
  }
1859
1916
  /** Mark the names, rings and arrows of the bodies outside the lit system: they are drawn at the far strength. Only what changed is touched, and nothing is drawn again. */
@@ -1882,7 +1939,9 @@ export class WakuseiSpace extends HTMLElement {
1882
1939
  this.#hovered = id;
1883
1940
  this.#hoverBy = by;
1884
1941
  this.#markFar();
1885
- if (id !== null)
1942
+ if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id)))
1943
+ this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
1944
+ else if (id !== null)
1886
1945
  this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
1887
1946
  else if (was !== null)
1888
1947
  this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: was }, bubbles: true, composed: true }));
@@ -1937,8 +1996,9 @@ export class WakuseiSpace extends HTMLElement {
1937
1996
  const now = {};
1938
1997
  for (const [id, input] of Object.entries(bodies)) {
1939
1998
  const body = id;
1940
- const one = { id: body, kind: bodyKindOf(body), ...sightOf(input, frame.width, frame.height, frame.axis) };
1941
- const host = hostOf(body);
1999
+ const craft = this.#model.craftIds.includes(id) || id === "roadster";
2000
+ const one = { id, kind: craft ? "spacecraft" : bodyKindOf(body), ...sightOf(input, frame.width, frame.height, frame.axis) };
2001
+ const host = craft ? undefined : hostOf(body);
1942
2002
  if (host !== undefined)
1943
2003
  one.host = host;
1944
2004
  now[id] = one;
@@ -2005,7 +2065,7 @@ export class WakuseiSpace extends HTMLElement {
2005
2065
  return 0;
2006
2066
  if (id === "sun")
2007
2067
  return 1;
2008
- if (id === "roadster")
2068
+ if (id === "roadster" || this.#model.craftIds.includes(id))
2009
2069
  return 3;
2010
2070
  if (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))
2011
2071
  return 5;
@@ -2130,7 +2190,7 @@ export class WakuseiSpace extends HTMLElement {
2130
2190
  */
2131
2191
  #press(id) {
2132
2192
  // the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
2133
- if (id === "roadster" || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))) {
2193
+ if (id === "roadster" || this.#model.craftIds.includes(id) || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))) {
2134
2194
  this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
2135
2195
  return;
2136
2196
  }
@@ -2147,7 +2207,9 @@ export class WakuseiSpace extends HTMLElement {
2147
2207
  const id = event.target?.dataset?.["body"];
2148
2208
  if (!id)
2149
2209
  return;
2150
- this.dispatchEvent(new CustomEvent("wakusei-body-focus", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
2210
+ // a craft's name is no body: focus tells the page its id and name, as a press does
2211
+ const craft = id === "roadster" || this.#model.craftIds.includes(id) || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id));
2212
+ this.dispatchEvent(new CustomEvent("wakusei-body-focus", { detail: craft ? { id, name: this.#nameOf(id), kind: "spacecraft" } : this.bodyInfo(id), bubbles: true, composed: true }));
2151
2213
  this.#hover(id, "focus");
2152
2214
  };
2153
2215
  // --- the rest --------------------------------------------------------------------------------------------------------------------------------------
@@ -241,6 +241,21 @@ export interface SpaceModel {
241
241
  position: [number, number, number] | null;
242
242
  radiusPx: number;
243
243
  };
244
+ /** Places of the deep-space craft for this frame, or null when they are off. `au` is null when the date is outside that craft's record. */
245
+ /** Off, every craft, or the ids asked for. */
246
+ craftShow: null | "all" | readonly string[];
247
+ craftIds: readonly string[];
248
+ craftNames: ((id: string, lang: "en" | "ja") => string) | null;
249
+ craftPlaces: ((ms: number) => {
250
+ id: string;
251
+ au: [number, number, number] | null;
252
+ }[]) | null;
253
+ /** What the last draw did with those craft. */
254
+ craftDrawn: {
255
+ count: number;
256
+ status: Record<string, "drawn" | "outside">;
257
+ drawn: string[];
258
+ };
244
259
  /** 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. */
245
260
  label: PaintLabel | null;
246
261
  labelVersion: number;
@@ -108,6 +108,11 @@ export const newSpaceModel = () => ({
108
108
  roadster: false,
109
109
  roadsterPath: null,
110
110
  roadsterDrawn: { shown: false, position: null, radiusPx: 0 },
111
+ craftShow: null,
112
+ craftIds: [],
113
+ craftNames: null,
114
+ craftPlaces: null,
115
+ craftDrawn: { count: 0, status: {}, drawn: [] },
111
116
  label: null,
112
117
  labelVersion: 0,
113
118
  labelsDrawn: { count: 0, focus: null },
@@ -318,6 +323,20 @@ export function createSpaceItem(model, deps) {
318
323
  roadsterLine.visible = false;
319
324
  roadsterLine.frustumCulled = false;
320
325
  scene.add(roadsterLine);
326
+ const CRAFT_DOTS = 19;
327
+ const craftPositions = new Float32Array(CRAFT_DOTS * 3);
328
+ const craftGeometry = new three.BufferGeometry();
329
+ const craftAttribute = new three.BufferAttribute(craftPositions, 3);
330
+ craftGeometry.setAttribute("position", craftAttribute);
331
+ craftGeometry.setDrawRange(0, 0);
332
+ const CraftPoints = three;
333
+ const craftMaterial = typeof CraftPoints.PointsMaterial === "function" ? new CraftPoints.PointsMaterial({ color: 0x9fd0ff, size: 4, sizeAttenuation: false, depthWrite: false }) : null;
334
+ const craftPoints = craftMaterial !== null && typeof CraftPoints.Points === "function" ? new CraftPoints.Points(craftGeometry, craftMaterial) : null;
335
+ if (craftPoints !== null) {
336
+ craftPoints.frustumCulled = false;
337
+ craftPoints.visible = false;
338
+ scene.add(craftPoints);
339
+ }
321
340
  const roadsterOrbit = { samples: [], epoch: Number.NaN };
322
341
  const orbiterDrawings = new Map();
323
342
  const orbiterGeometry = new three.SphereGeometry(1, 16, 8);
@@ -853,6 +872,42 @@ export function createSpaceItem(model, deps) {
853
872
  roadsterMesh.visible = false;
854
873
  roadsterLine.visible = false;
855
874
  }
875
+ // the deep-space craft: one points draw, a dot each, no path line. A date outside a craft's record draws nothing for it.
876
+ const craftAts = [];
877
+ const craftStatus = {};
878
+ const craftDrawn = [];
879
+ const craftList = model.craftPlaces?.(model.time) ?? [];
880
+ if (craftPoints !== null) {
881
+ let n = 0;
882
+ for (const craft of craftList) {
883
+ // the Roadster has its own drawing when `roadster` is on: it is not drawn twice
884
+ if (craft.id === "roadster" && model.roadster)
885
+ continue;
886
+ if (craft.au === null) {
887
+ craftStatus[craft.id] = "outside";
888
+ continue;
889
+ }
890
+ if (n >= CRAFT_DOTS)
891
+ break;
892
+ const at = placeAround(mode, sunPos, eclipticToScene(craft.au));
893
+ craftPositions[n * 3] = at[0];
894
+ craftPositions[n * 3 + 1] = at[1];
895
+ craftPositions[n * 3 + 2] = at[2];
896
+ const away = Math.hypot(at[0] - camera.position.x, at[1] - camera.position.y, at[2] - camera.position.z);
897
+ const drawn = (away * half * 4) / (size.height / 2);
898
+ const dotPx = away <= drawn ? 1e5 : ((size.height / 2) * (drawn / Math.sqrt(Math.max(away * away - drawn * drawn, 1e-12)))) / half;
899
+ craftAts.push({ id: craft.id, at, px: dotPx });
900
+ craftStatus[craft.id] = "drawn";
901
+ craftDrawn.push(craft.id);
902
+ n += 1;
903
+ }
904
+ craftAttribute.needsUpdate = true;
905
+ craftGeometry.setDrawRange(0, n);
906
+ craftPoints.visible = n > 0;
907
+ model.craftDrawn = { count: n, status: craftStatus, drawn: craftDrawn };
908
+ }
909
+ else
910
+ model.craftDrawn = { count: 0, status: craftStatus, drawn: [] };
856
911
  // the orbiters round the Moon and Mars: each a dot at the table's place, scaled with its body's drawn radius, on its orbit line, once its body is big enough on the screen; a modelled path is drawn dim
857
912
  const orbiterSet = model.orbiters ? model.orbiterSet : null;
858
913
  const orbiterPlaces = {};
@@ -1169,6 +1224,12 @@ export function createSpaceItem(model, deps) {
1169
1224
  if (spot)
1170
1225
  moonDistances["roadster"] = Math.hypot(roadsterAt[0] - camera.position.x, roadsterAt[1] - camera.position.y, roadsterAt[2] - camera.position.z);
1171
1226
  }
1227
+ for (const craft of craftAts) {
1228
+ const spot = labelFor(craft.at);
1229
+ places[craft.id] = spot ? { x: spot.x, y: spot.y, r: craft.px } : null;
1230
+ if (spot)
1231
+ moonDistances[craft.id] = Math.hypot(craft.at[0] - camera.position.x, craft.at[1] - camera.position.y, craft.at[2] - camera.position.z);
1232
+ }
1172
1233
  // a body behind another: its place is inside a nearer body's disc
1173
1234
  const entries = [];
1174
1235
  for (const [id, at] of Object.entries(places)) {
@@ -1211,6 +1272,8 @@ export function createSpaceItem(model, deps) {
1211
1272
  for (const id of moons)
1212
1273
  if (id !== hiddenMoon && !SPACE_BODIES.includes(id))
1213
1274
  sight(id, absoluteSite(id), moonPlaces[id]?.r ?? 0);
1275
+ for (const craft of craftAts)
1276
+ sight(craft.id, craft.at, craft.px);
1214
1277
  projected.set(0, 0, -1).applyMatrix4(camera.projectionMatrix);
1215
1278
  deps.onSight(sights, { width: size.width, height: size.height, axis: { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height } });
1216
1279
  }
@@ -1248,6 +1311,8 @@ export function createSpaceItem(model, deps) {
1248
1311
  }
1249
1312
  roadsterGeometry.dispose();
1250
1313
  roadsterMaterial.dispose();
1314
+ craftGeometry.dispose();
1315
+ craftMaterial?.dispose();
1251
1316
  for (const drawing of orbiterDrawings.values()) {
1252
1317
  drawing.material.dispose();
1253
1318
  drawing.line.geometry.dispose();
@@ -1,6 +1,6 @@
1
1
  import type { PlanetId } from "./facts.ts";
2
2
  /**
3
- * The eighteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex` and `solarorbiter`.
3
+ * The nineteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex`, `solarorbiter` and `roadster` (Starman, the Tesla Roadster).
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", "bepicolombo", "psyche", "europaclipper", "lucy", "juice", "hayabusa2", "osirisapex", "solarorbiter"];
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", "roadster"];
13
13
  /**
14
14
  * The name of a craft: `voyager1`, `cassini`, `webb`...
15
15
  *
@@ -34,8 +34,8 @@ export type SpacecraftId = (typeof SPACECRAFT_IDS)[number];
34
34
  * ```
35
35
  */
36
36
  export interface SpacecraftEvent {
37
- /** What happened: the launch, a flyby, going into orbit round a planet, getting to the place the craft works from, or the end of the mission. */
38
- kind: "launch" | "flyby" | "orbit-insertion" | "arrival" | "end";
37
+ /** What happened: the launch, a flyby, going into orbit round a planet, getting to the place the craft works from, the end of the mission, or (the Roadster) a perihelion or an aphelion. */
38
+ kind: "launch" | "flyby" | "orbit-insertion" | "arrival" | "end" | "perihelion" | "aphelion";
39
39
  /** The moment, in milliseconds since 1970 (UTC). Where `precision` is "day", only the date is known: this is that day's noon. */
40
40
  date: number;
41
41
  /** "minute" where the page gives a time, "day" where it gives only a date. */
@@ -68,6 +68,12 @@ export interface SpacecraftFacts {
68
68
  en: string;
69
69
  ja: string;
70
70
  };
71
+ /** Other names a search should find. Left off when the craft has none. */
72
+ otherNames?: readonly string[];
73
+ /**
74
+ * What sort of craft it is. Left off for a probe. `observatory` is a telescope that stays put (the James Webb Space Telescope). `other` is the Roadster: a car, not a probe.
75
+ */
76
+ kind?: "probe" | "observatory" | "other";
71
77
  /** The agency or agencies. */
72
78
  agency: string;
73
79
  /** The launch: when, from where and on what. */
@@ -102,7 +108,7 @@ export interface SpacecraftFacts {
102
108
  events: readonly SpacecraftEvent[];
103
109
  }
104
110
  /**
105
- * The eighteen craft and their facts, keyed by id.
111
+ * The nineteen craft and their facts, keyed by id.
106
112
  *
107
113
  * @example
108
114
  * ```ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The eighteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex` and `solarorbiter`.
2
+ * The nineteen craft: `voyager1`, `voyager2`, `newhorizons`, `pioneer10`, `pioneer11`, `cassini`, `galileo`, `juno`, `parker`, `webb`, `bepicolombo`, `psyche`, `europaclipper`, `lucy`, `juice`, `hayabusa2`, `osirisapex`, `solarorbiter` and `roadster` (Starman, the Tesla Roadster).
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", "bepicolombo", "psyche", "europaclipper", "lucy", "juice", "hayabusa2", "osirisapex", "solarorbiter"];
11
+ export const SPACECRAFT_IDS = ["voyager1", "voyager2", "newhorizons", "pioneer10", "pioneer11", "cassini", "galileo", "juno", "parker", "webb", "bepicolombo", "psyche", "europaclipper", "lucy", "juice", "hayabusa2", "osirisapex", "solarorbiter", "roadster"];
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 eighteen craft and their facts, keyed by id.
17
+ * The nineteen craft and their facts, keyed by id.
18
18
  *
19
19
  * @example
20
20
  * ```ts
@@ -198,6 +198,7 @@ export const SPACECRAFT = {
198
198
  },
199
199
  webb: {
200
200
  id: "webb",
201
+ kind: "observatory",
201
202
  name: { en: "James Webb Space Telescope", ja: "ジェイムズ・ウェッブ宇宙望遠鏡" },
202
203
  agency: "NASA, ESA, CSA",
203
204
  launch: { date: T(2021, 11, 25, 12, 20), precision: "minute", site: { en: "Kourou, French Guiana (ELA-3)", ja: "クールー (フランス領ギアナ) ELA-3" }, vehicle: "Ariane 5" },
@@ -367,4 +368,20 @@ export const SPACECRAFT = {
367
368
  flyby(noon(2030, 9, 3), "day", "Sixth Venus flyby", "6回目の金星フライバイ", "venus"),
368
369
  ],
369
370
  },
371
+ roadster: {
372
+ id: "roadster",
373
+ name: { en: "Starman", ja: "スターマン" },
374
+ otherNames: ["Tesla Roadster", "Starman", "Tesla"],
375
+ kind: "other",
376
+ agency: "SpaceX",
377
+ launch: { date: T(2018, 1, 6, 20, 45), precision: "minute", site: { en: "Kennedy Space Center, Launch Complex 39A", ja: "ケネディ宇宙センター 39A発射施設" }, vehicle: "Falcon Heavy" },
378
+ end: undefined,
379
+ status: "active",
380
+ url: "https://ssd.jpl.nasa.gov/api/horizons.api",
381
+ horizons: "-143205",
382
+ // filled from ROADSTER.record when the path is loaded, so this file does not carry the 20 kB table
383
+ record: { start: 0, end: 0 },
384
+ joins: [],
385
+ events: [ev("launch", T(2018, 1, 6, 20, 45), "minute", "Launch", "打ち上げ")],
386
+ },
370
387
  };
@@ -7,7 +7,7 @@ export type { When } from "./when.ts";
7
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 eighteen.
10
+ * @param ids - The craft to load; none means all nineteen.
11
11
  * @returns A promise that settles when every table is registered.
12
12
  *
13
13
  * @example
@@ -199,3 +199,17 @@ export interface SpacecraftStats {
199
199
  * ```
200
200
  */
201
201
  export declare function spacecraftStats(id: SpacecraftId, when: When): SpacecraftStats;
202
+ /**
203
+ * The craft a search matches: the id, either name, or an `otherNames` entry, with case, letter width, spaces and punctuation folded. `voyager` matches both Voyagers. An empty string matches nothing.
204
+ *
205
+ * @param text - What was typed.
206
+ * @returns The matching ids, in the order of `SPACECRAFT_IDS`.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * import { findSpacecraft } from "@johnmorrisdotca/wakusei-planets/spacecraft";
211
+ *
212
+ * console.log(findSpacecraft("tesla").join(","), findSpacecraft("スターマン").join(","));
213
+ * ```
214
+ */
215
+ export declare function findSpacecraft(text: string): SpacecraftId[];
@@ -10,6 +10,13 @@ export { SPACECRAFT, SPACECRAFT_IDS } from "./spacecraft-facts.js";
10
10
  const AU_KM = 149_597_870.7;
11
11
  /** The speed of light in kilometres a second. */
12
12
  const LIGHT_KM_PER_SECOND = 299_792.458;
13
+ /** The Roadster module, kept once `loadSpacecraft("roadster")` has imported it. Importing it is what brings in the 20 kB table. */
14
+ let roadsterMod;
15
+ const roadsterReady = () => {
16
+ if (roadsterMod === undefined)
17
+ throw new Error(`the path of Starman is not loaded: await loadSpacecraft("roadster") first`);
18
+ return roadsterMod;
19
+ };
13
20
  const LOADERS = {
14
21
  voyager1: () => import("./craft/voyager1.js"),
15
22
  voyager2: () => import("./craft/voyager2.js"),
@@ -29,6 +36,18 @@ const LOADERS = {
29
36
  hayabusa2: () => import("./craft/hayabusa2.js"),
30
37
  osirisapex: () => import("./craft/osirisapex.js"),
31
38
  solarorbiter: () => import("./craft/solarorbiter.js"),
39
+ roadster: async () => {
40
+ roadsterMod = await import("./roadster.js");
41
+ const craft = SPACECRAFT.roadster;
42
+ craft.record.start = roadsterMod.ROADSTER.record.start;
43
+ craft.record.end = roadsterMod.ROADSTER.record.end;
44
+ const events = roadsterMod.roadsterEvents().map((event) => {
45
+ const body = event.kind === "earth-approach" ? "earth" : event.kind === "mars-approach" ? "mars" : undefined;
46
+ const kind = event.kind === "earth-approach" || event.kind === "mars-approach" ? "flyby" : event.kind;
47
+ return { kind, date: event.date, precision: "minute", name: event.name, ...(body === undefined ? {} : { body }), ...(event.distanceKm === undefined ? {} : { distanceKm: event.distanceKm }) };
48
+ });
49
+ craft.events = events;
50
+ },
32
51
  };
33
52
  function facts(id) {
34
53
  const found = SPACECRAFT[id];
@@ -40,7 +59,7 @@ function facts(id) {
40
59
  * 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.
41
60
  * Call it once before the other functions; it is safe to call again.
42
61
  *
43
- * @param ids - The craft to load; none means all eighteen.
62
+ * @param ids - The craft to load; none means all nineteen.
44
63
  * @returns A promise that settles when every table is registered.
45
64
  *
46
65
  * @example
@@ -89,6 +108,8 @@ function onPath(id, when) {
89
108
  * ```
90
109
  */
91
110
  export function spacecraftPosition(id, when) {
111
+ if (id === "roadster")
112
+ return roadsterReady().roadsterPosition(when);
92
113
  const { tt, table } = onPath(id, when);
93
114
  return craftState(table, tt).position;
94
115
  }
@@ -108,6 +129,8 @@ export function spacecraftPosition(id, when) {
108
129
  * ```
109
130
  */
110
131
  export function spacecraftVelocity(id, when) {
132
+ if (id === "roadster")
133
+ return roadsterReady().roadsterVelocity(when);
111
134
  const { tt, table } = onPath(id, when);
112
135
  return craftState(table, tt).velocity;
113
136
  }
@@ -199,6 +222,8 @@ export function spacecraftLightTime(id, when) {
199
222
  * ```
200
223
  */
201
224
  export function spacecraftErrorKm(id) {
225
+ if (id === "roadster")
226
+ return roadsterReady().ROADSTER_ACCURACY.interpolationKm;
202
227
  const table = craftTable(id);
203
228
  if (table === undefined)
204
229
  throw new Error(`the path of ${facts(id).name.en} is not loaded: await loadSpacecraft(${JSON.stringify(id)}) first`);
@@ -239,3 +264,27 @@ export function spacecraftStats(id, when) {
239
264
  daysSinceLaunch: (ms - facts(id).launch.date) / 86_400_000,
240
265
  };
241
266
  }
267
+ /** Fold case, full-width letters, spaces and punctuation so `tesla` matches `Tesla`, `スターマン` matches `スターマン` and `europa-clipper` matches `Europa Clipper`. */
268
+ const fold = (text) => text.normalize("NFKC").toLowerCase().replace(/[\s\p{P}\p{S}]/gu, "");
269
+ /**
270
+ * The craft a search matches: the id, either name, or an `otherNames` entry, with case, letter width, spaces and punctuation folded. `voyager` matches both Voyagers. An empty string matches nothing.
271
+ *
272
+ * @param text - What was typed.
273
+ * @returns The matching ids, in the order of `SPACECRAFT_IDS`.
274
+ *
275
+ * @example
276
+ * ```ts
277
+ * import { findSpacecraft } from "@johnmorrisdotca/wakusei-planets/spacecraft";
278
+ *
279
+ * console.log(findSpacecraft("tesla").join(","), findSpacecraft("スターマン").join(","));
280
+ * ```
281
+ */
282
+ export function findSpacecraft(text) {
283
+ const needle = fold(text.trim());
284
+ if (needle.length === 0)
285
+ return [];
286
+ return SPACECRAFT_IDS.filter((id) => {
287
+ const craft = SPACECRAFT[id];
288
+ return [id, craft.name.en, craft.name.ja, ...(craft.otherNames ?? [])].some((part) => fold(part).includes(needle));
289
+ });
290
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.42.0";
1
+ export declare const VERSION = "0.43.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.42.0";
1
+ export const VERSION = "0.43.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/wakusei-planets",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
5
5
  "keywords": [
6
6
  "planets",