@johnmorrisdotca/wakusei-planets 0.59.0 → 0.60.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,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.60.0] - 2026-11-17
6
+
7
+ - **Flat maps of the Moon and Mars: `<wakusei-flat body="moon|mars">`** (MODULES-1395; John Morris, 2026-11-17). A new entry, `@johnmorrisdotca/wakusei-planets/flat/define` (the element) and `@johnmorrisdotca/wakusei-planets/flat` (the pure side, with no DOM): the body's own painted picture as a flat, wrapping equirectangular map, with the night side shaded from the Sun's place for the time shown (sharp on the Moon, an 8 degree dusk on Mars), the Sun's mark, the landing, rover, crash and planned sites and the named features of the places data as marks, and the orbiters as dots that move over it for the time shown, with a coverage circle (`footprint`) and a ground track (`track`) cut at the map's edge (longitude 180) and the poles. The Moon draws LRO, Chandrayaan-2, Danuri, ARTEMIS P1 and P2 and Mars draws MRO, Odyssey, MAVEN, Mars Express, TGO and Hope; CAPSTONE and Tianwen-1 have no public path and are not drawn, and a craft whose place may be more than 2 per cent of the body's radius out is drawn as a ring. It uses the space view's game clock, so it is smooth at any speed (a short streak at a fast clock), and draws nothing at rest, out of sight or in a hidden tab. It has the same attributes and events as chikyu-earth's `<chikyu-flat>` (`center`, `home-lon`, `home-lat`, `time`, `speed`, `paused`, `footprint`, `track`, `selected`, `shade`, `dot-size`, `controls`, `lang`; `wakusei-flat-pick`, `-view`, `-filter` and `wakusei-timechange`), so one control can swap bodies. A press or tap sends one `wakusei-flat-pick` for every pressable thing (an orbiter, a place of the tables, a crater or mountain, a landing site), with `kind`, `id`, `name`, `via`, and for a place its `place` record and its `site` from `/landing-sites`; the landing sites are named by their own names and carry their country's flag as `<hata-flag>` with `site-flags` (the page imports hata; no new dependency), and the demo draws a card from the event; the marks and dots can be reached with the arrow keys; a drag pans and two fingers pinch. English and Japanese through `FLAT_WORDS`. The demo is `flat.html`, the guide is "Flat maps of the Moon and Mars" in both languages, and the tests are `test/flat.test.ts`, `e2e/flat.demo.ts` and `e2e/flat-freeze.demo.ts` (a canvas: no WebGL context, no graphics object, the canvas inside 6 MP and 4096 a side, and no draw at rest). The tiles are not used yet: the map is the 1024 and 2048 pixel pictures.
8
+
5
9
  ## [0.59.0] - 2026-11-17
6
10
 
7
11
  - **A name, a ring or a note behind a nearer body is hidden, not drawn over its disc** (MODULES-1404; John Morris, 2026-11-17, from the view at Pholus on spaceprogramx.com: Jupiter, Mercury with its ring, Halley and the Hildas' name were drawn over the dark disc as if it were glass). In `<wakusei-space>` a body whose place is inside a nearer body's drawn disc now fades its floating name and ring out (the 0.35 s fade the far names already use, none under reduced motion) and back as it comes out; a body's own name stays. The disc is the one drawn, at the edge-round radius 0.57 gave it (`placeOf(id).r`), tested once per label per draw against the few discs of 6 pixels of radius or more, with nothing read back from the picture. This is the new default of the `covered` attribute and property: `hide`; `arrow` is as before and `name` is the old way, names over the disc. The Oort cloud's note and the marks of the places on a body (the body looked at, or the Earth's `earth-places`) that is itself behind another go the same way. New: `space.coveredAt(point)`, the id of the body whose disc hides a point of the scene (as `stats.camera` has it) or `null`, for a page's own labels over the view (spaceprogramx's belt names: the Hildas, the Centaurs, the Kuiper belt, the Jupiter Trojans); and `coverOf(point, discs, self?)` from `/space`, the maths, which `coveredBy` now uses. Unit tests of the maths; `e2e/space-occlude.demo.ts` goes to Pholus at 2026-11-30T06:01Z and checks that the names behind its disc are hidden and Pholus's own is not, and that `coveredAt` hides a point behind the disc and none beside or in front of it.
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.59.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.60.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -163,6 +163,17 @@ const io = planAt(Date.UTC(2026, 10, 11), { system: "jupiter", mark: "io", spaci
163
163
  console.log(io?.distance.toFixed(1), "Jupiter radii from Jupiter");
164
164
  ```
165
165
 
166
+ ## Flat maps of the Moon and Mars
167
+
168
+ `<wakusei-flat body="moon" track>` is the Moon on a flat map (`body="mars"` is Mars): the body's own painted picture with day and night for the time shown, the landing, rover and crash sites marked, and the spacecraft in orbit as dots that move over it with their coverage circles and ground tracks. It is a canvas with no WebGL, takes `time`, `speed` and `paused`, sends `wakusei-flat-pick` when an orbiter or a mark is pressed, works by keyboard and touch, and has the same attributes and events as chikyu-earth's `<chikyu-flat>`, so one control can swap the Earth, the Moon and Mars. It draws five lunar orbiters (LRO, Chandrayaan-2, Danuri, ARTEMIS P1 and P2) and six Martian ones (MRO, Odyssey, MAVEN, Mars Express, TGO and Hope); CAPSTONE and Tianwen-1 have no public path and are not drawn.
169
+
170
+ ```ts
171
+ import { flatOrbiter } from "@johnmorrisdotca/wakusei-planets/flat";
172
+
173
+ const lro = flatOrbiter("lro", Date.UTC(2026, 10, 12));
174
+ console.log(lro?.altitudeKm.toFixed(0), "km up");
175
+ ```
176
+
166
177
  ## A name on the body
167
178
 
168
179
  `body-label="painted"` writes the body's name on its own globe, large and in capitals, lying on the surface and turning with it, as a film lays a title over the thing it names: on `<wakusei-body>` and on every body of `<wakusei-space>`, in the page's language, in Michroma by default or a font of yours. Four looks (`painted`, `etched`, `outline`, `burned`), once or on both sides, at the equator or near a pole, turning with the body or always facing you; nothing on a body too small on the screen. [A name on the body](docs/guides/name-on-the-body.md) has the attributes.
@@ -388,7 +399,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
388
399
 
389
400
  ## The portrait builder
390
401
 
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.59.0/docs/images/portrait-family.png" width="640"></p>
402
+ <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.60.0/docs/images/portrait-family.png" width="640"></p>
392
403
 
393
404
  [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
405
 
@@ -444,6 +455,7 @@ The reference is a site, made from the source's own doc comments: every export h
444
455
  | `.../portrait` | `<wakusei-portrait>`: many bodies in one scene. The scene model (`addBody`, `layoutPortrait`, `encodeScene`, `decodeScene`) is in the main entry. |
445
456
  | `.../space` | Where the Sun, the Moon and the planets are for a date, in two scales, and where a camera riding along looks: `frameAt`, `createTrack`, `placeSun`, `placeAround`, `ridePose`. No browser. |
446
457
  | `.../space/element` | `<wakusei-space>`: the Earth, the Moon, the Sun and the planets in their places. |
458
+ | `.../flat` | The flat maps' pure side: `flatSun`, `flatOrbiter`, `shadeNight`, `circleOutline`, `flatTrack`, the geometry and the words. `.../flat/define` is `<wakusei-flat>`, the Moon or Mars on a flat map, in a canvas with no WebGL. |
447
459
  | `.../plan` | The top-down plan: `planAt`, `planSvg`, `planText`. `.../plan/element` is `<wakusei-plan>`, in SVG with no WebGL. |
448
460
  | `.../landing-sites` | The 39 soft landings on the Moon and Mars as plain data: `LANDING_SITES`, `landingSitesOf`, `findLandingSite`, `flagCodeOf`. No browser, no three.js. |
449
461
  | `.../nearest` | The bodies nearest to a body on a date (`nearest`, `within`), when two bodies come closest (`closestApproach`, `conjunctions`) and how far apart they are (`distance`, `distanceRange`). No browser. |
@@ -479,6 +491,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
479
491
  | [The space view](docs/guides/space-view.md) | The Earth, Moon, Sun and planets in their places; two scales; time both ways |
480
492
  | [A star from its numbers](docs/guides/star-look.md) | Any star in 3D or as lines, what is measured and what is drawn, every way to put it in a page |
481
493
  | [The size line-up](docs/guides/size-lineup.md) | The Sun and the largest stars at true relative size, with each radius, its error and its paper, where the papers disagree, every way to put it in a page |
494
+ | [Flat maps of the Moon and Mars](docs/guides/flat.md) | The Moon or Mars on a flat map: day and night, the sites, the orbiters moving with their coverage and ground tracks, the same attributes and events as the Earth's flat map |
482
495
  | [The top-down plan](docs/guides/plan.md) | The solar system or one planet's moons from above, with one body marked: squeezed or to-scale distances, drawing only on change |
483
496
  | [Zoom and pan](docs/guides/zoom-and-pan.md) | Every view zooms and moves by itself: the range of each and why it ends there, the bar, the embed page |
484
497
  | [Close zoom and map tiles](docs/guides/close-zoom.md) | How far each body zooms and why, the finer map tiles for a close zoom (made from public-domain maps, served beside the demo, never in the package), the generic detail, what it costs |
@@ -539,7 +552,7 @@ BODIES.pluto.kind; // "dwarf-planet"
539
552
 
540
553
  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:
541
554
 
542
- > Morris, J. (2026). *Wakusei Planets* (version 0.59.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
555
+ > Morris, J. (2026). *Wakusei Planets* (version 0.60.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
543
556
 
544
557
  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).
545
558
 
@@ -0,0 +1,122 @@
1
+ import { type OrbiterId } from "../orbiters.ts";
2
+ /**
3
+ * The bodies the flat map draws: the Moon and Mars. They have the painted maps, the landing, rover and crash sites and the spacecraft in orbit that the package holds; the Earth's flat map is chikyu-earth's `<chikyu-flat>`.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { FLAT_BODIES } from "@johnmorrisdotca/wakusei-planets/flat";
8
+ *
9
+ * console.log(FLAT_BODIES.join(", "));
10
+ * ```
11
+ */
12
+ export declare const FLAT_BODIES: readonly ["moon", "mars"];
13
+ /**
14
+ * A body the flat map draws.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { FlatBodyId } from "@johnmorrisdotca/wakusei-planets/flat";
19
+ *
20
+ * const body: FlatBodyId = "mars";
21
+ * console.log(body);
22
+ * ```
23
+ */
24
+ export type FlatBodyId = (typeof FLAT_BODIES)[number];
25
+ /**
26
+ * What is particular to one body on the flat map.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { flatBody, type FlatBodyInfo } from "@johnmorrisdotca/wakusei-planets/flat";
31
+ *
32
+ * const mars: FlatBodyInfo = flatBody("mars");
33
+ * console.log(mars.radiusKm, mars.twilightDeg);
34
+ * ```
35
+ */
36
+ export interface FlatBodyInfo {
37
+ id: FlatBodyId;
38
+ /** The mean radius in kilometres (IAU): the sphere a craft's height is measured above and the footprint is worked out on. */
39
+ radiusKm: number;
40
+ /** How far the Sun is below the horizon, in degrees, when the shading has gone to full night: 1 on the Moon (no air to spread the light), 8 on Mars (its dust lights the sky for a while after sunset). */
41
+ twilightDeg: number;
42
+ /** The colour of the night side as red, green and blue, and how dark it is at most (0 to 1): the map never goes quite black, since the night side still shows its ground. */
43
+ night: readonly [number, number, number, number];
44
+ /** The colour the map shows while its picture is on its way, or when it cannot be loaded. */
45
+ ground: string;
46
+ /** The longitudes the "centre the map on" buttons go to, with the word each is called by (`FLAT_WORDS` keys). */
47
+ centres: readonly {
48
+ lon: number;
49
+ say: "nearSide" | "farSide" | "primeMeridian";
50
+ }[];
51
+ /** The orbiters that go round it, in the package's order. */
52
+ orbiters: readonly OrbiterId[];
53
+ }
54
+ /**
55
+ * Whether a text is a body the flat map draws.
56
+ *
57
+ * @param value - Any text, in any case.
58
+ * @returns True for `moon` and `mars`.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { isFlatBody } from "@johnmorrisdotca/wakusei-planets/flat";
63
+ *
64
+ * console.log(isFlatBody("Mars"), isFlatBody("venus"));
65
+ * ```
66
+ */
67
+ export declare const isFlatBody: (value: string | null | undefined) => value is FlatBodyId;
68
+ /**
69
+ * What is particular to a body on the flat map.
70
+ *
71
+ * @param id - `moon` or `mars`.
72
+ * @returns Its numbers.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { flatBody } from "@johnmorrisdotca/wakusei-planets/flat";
77
+ *
78
+ * console.log(flatBody("moon").orbiters.join(", "));
79
+ * ```
80
+ */
81
+ export declare function flatBody(id: string): FlatBodyInfo;
82
+ /**
83
+ * The colour each orbiter is drawn in: colours kept for a dark map, one for each orbiter in the package's order, so an orbiter is the same colour in a list and on the map.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { ORBITER_COLOURS } from "@johnmorrisdotca/wakusei-planets/flat";
88
+ *
89
+ * console.log(ORBITER_COLOURS.length, ORBITER_COLOURS[0]);
90
+ * ```
91
+ */
92
+ export declare const ORBITER_COLOURS: readonly string[];
93
+ /**
94
+ * The colour of one orbiter on the map.
95
+ *
96
+ * @param id - The orbiter.
97
+ * @returns A CSS colour.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * import { orbiterColour } from "@johnmorrisdotca/wakusei-planets/flat";
102
+ *
103
+ * console.log(orbiterColour("lro"), orbiterColour("mro"));
104
+ * ```
105
+ */
106
+ export declare function orbiterColour(id: OrbiterId): string;
107
+ /**
108
+ * An orbiter's name, in a language: the craft's own, or its short form for a crowded map.
109
+ *
110
+ * @param id - The orbiter.
111
+ * @param lang - `en` or `ja`.
112
+ * @param short - True for the short name.
113
+ * @returns The name.
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * import { orbiterName } from "@johnmorrisdotca/wakusei-planets/flat";
118
+ *
119
+ * console.log(orbiterName("lro", "en"), "|", orbiterName("lro", "en", true), "|", orbiterName("hope", "ja", true));
120
+ * ```
121
+ */
122
+ export declare const orbiterName: (id: OrbiterId, lang: "en" | "ja", short?: boolean) => string;
@@ -0,0 +1,115 @@
1
+ // The bodies the flat map draws and what is particular to each: its mean radius (for how far a craft sees), how soft its sunset is, the colour of its night, where its "centre the map" buttons point, and which orbiters go round it.
2
+ // Pure: no DOM.
3
+ import { ORBITER_FACTS, ORBITER_IDS, orbiterCentre } from "../orbiters.js";
4
+ /**
5
+ * The bodies the flat map draws: the Moon and Mars. They have the painted maps, the landing, rover and crash sites and the spacecraft in orbit that the package holds; the Earth's flat map is chikyu-earth's `<chikyu-flat>`.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { FLAT_BODIES } from "@johnmorrisdotca/wakusei-planets/flat";
10
+ *
11
+ * console.log(FLAT_BODIES.join(", "));
12
+ * ```
13
+ */
14
+ export const FLAT_BODIES = ["moon", "mars"];
15
+ const orbitersOf = (body) => ORBITER_IDS.filter((id) => orbiterCentre(id) === body);
16
+ const INFO = {
17
+ moon: {
18
+ id: "moon",
19
+ radiusKm: 1737.4,
20
+ twilightDeg: 1,
21
+ night: [3, 5, 12, 0.78],
22
+ ground: "#4a4945",
23
+ centres: [
24
+ { lon: 0, say: "nearSide" },
25
+ { lon: 180, say: "farSide" },
26
+ ],
27
+ orbiters: orbitersOf("moon"),
28
+ },
29
+ mars: {
30
+ id: "mars",
31
+ radiusKm: 3389.5,
32
+ twilightDeg: 8,
33
+ night: [6, 4, 14, 0.72],
34
+ ground: "#7a3f24",
35
+ centres: [{ lon: 0, say: "primeMeridian" }],
36
+ orbiters: orbitersOf("mars"),
37
+ },
38
+ };
39
+ /**
40
+ * Whether a text is a body the flat map draws.
41
+ *
42
+ * @param value - Any text, in any case.
43
+ * @returns True for `moon` and `mars`.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { isFlatBody } from "@johnmorrisdotca/wakusei-planets/flat";
48
+ *
49
+ * console.log(isFlatBody("Mars"), isFlatBody("venus"));
50
+ * ```
51
+ */
52
+ export const isFlatBody = (value) => value !== null && value !== undefined && FLAT_BODIES.includes(value.trim().toLowerCase());
53
+ /**
54
+ * What is particular to a body on the flat map.
55
+ *
56
+ * @param id - `moon` or `mars`.
57
+ * @returns Its numbers.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { flatBody } from "@johnmorrisdotca/wakusei-planets/flat";
62
+ *
63
+ * console.log(flatBody("moon").orbiters.join(", "));
64
+ * ```
65
+ */
66
+ export function flatBody(id) {
67
+ const key = id.trim().toLowerCase();
68
+ if (!isFlatBody(key))
69
+ throw new RangeError(`the flat map draws ${FLAT_BODIES.join(" and ")}, not ${JSON.stringify(id)}`);
70
+ return INFO[key];
71
+ }
72
+ /**
73
+ * The colour each orbiter is drawn in: colours kept for a dark map, one for each orbiter in the package's order, so an orbiter is the same colour in a list and on the map.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { ORBITER_COLOURS } from "@johnmorrisdotca/wakusei-planets/flat";
78
+ *
79
+ * console.log(ORBITER_COLOURS.length, ORBITER_COLOURS[0]);
80
+ * ```
81
+ */
82
+ export const ORBITER_COLOURS = ["#ffd23f", "#4cc9f0", "#6ee7a0", "#ff7a59", "#a78bfa", "#ff9ecb", "#f4a261", "#b8e986", "#5eead4", "#7aa2ff", "#e879f9", "#fde68a", "#ffffff"];
83
+ /**
84
+ * The colour of one orbiter on the map.
85
+ *
86
+ * @param id - The orbiter.
87
+ * @returns A CSS colour.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import { orbiterColour } from "@johnmorrisdotca/wakusei-planets/flat";
92
+ *
93
+ * console.log(orbiterColour("lro"), orbiterColour("mro"));
94
+ * ```
95
+ */
96
+ export function orbiterColour(id) {
97
+ const at = ORBITER_IDS.indexOf(id);
98
+ return ORBITER_COLOURS[(at < 0 ? 0 : at) % ORBITER_COLOURS.length];
99
+ }
100
+ /**
101
+ * An orbiter's name, in a language: the craft's own, or its short form for a crowded map.
102
+ *
103
+ * @param id - The orbiter.
104
+ * @param lang - `en` or `ja`.
105
+ * @param short - True for the short name.
106
+ * @returns The name.
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { orbiterName } from "@johnmorrisdotca/wakusei-planets/flat";
111
+ *
112
+ * console.log(orbiterName("lro", "en"), "|", orbiterName("lro", "en", true), "|", orbiterName("hope", "ja", true));
113
+ * ```
114
+ */
115
+ export const orbiterName = (id, lang, short = false) => (short ? ORBITER_FACTS[id].short[lang] : ORBITER_FACTS[id].name[lang]);
@@ -0,0 +1,3 @@
1
+ import { WakuseiFlat } from "./element.ts";
2
+ export { WakuseiFlat };
3
+ export type { FlatPick } from "./element.ts";
@@ -0,0 +1,6 @@
1
+ // Registers <wakusei-flat>. Importing this entry point (`@johnmorrisdotca/wakusei-planets/flat/define`) defines the tag once. It needs no WebGL and no peer.
2
+ import { WakuseiFlat } from "./element.js";
3
+ export { WakuseiFlat };
4
+ if (typeof customElements !== "undefined" && !customElements.get("wakusei-flat")) {
5
+ customElements.define("wakusei-flat", WakuseiFlat);
6
+ }
@@ -0,0 +1,145 @@
1
+ import { type LandingSite } from "../landing-sites.ts";
2
+ import { type PlaceLayer } from "../place-marks.ts";
3
+ import { type Place, type PlaceKind } from "../places.ts";
4
+ import { type FlatBodyId } from "./bodies.ts";
5
+ import { type FlatLang } from "./words.ts";
6
+ import type { OrbiterStatus } from "../orbiters.ts";
7
+ /**
8
+ * What `wakusei-flat-pick` carries: an orbiter or a place under the pointer, tapped, or reached by the keyboard. A tap on nothing sends `id: null` and clears the choice.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import type { FlatPick } from "@johnmorrisdotca/wakusei-planets/flat";
13
+ *
14
+ * const show = (pick: FlatPick): string => (pick.id === null ? "nothing" : `${pick.name} (${pick.kind})`);
15
+ * console.log(typeof show);
16
+ * ```
17
+ */
18
+ export interface FlatPick {
19
+ /** What was chosen: an orbiter or a place on the surface. */
20
+ kind: "orbiter" | "place" | null;
21
+ /** An orbiter's id (`lro`) or a place's (`moon/apollo-11-lunar-module`); null when a tap lands on nothing. */
22
+ id: string | null;
23
+ name: string | null;
24
+ body: FlatBodyId;
25
+ /** Where it is: an orbiter's place on the ground below it at this moment. */
26
+ lat: number | null;
27
+ lon: number | null;
28
+ /** An orbiter's height above the surface in kilometres. */
29
+ altitudeKm: number | null;
30
+ /** Where an orbiter's path comes from at this moment. */
31
+ status: OrbiterStatus | null;
32
+ /** A place's kind (`crewed`, `landing`, `rover`, `crash`, `feature`, ...). */
33
+ placeKind: PlaceKind | null;
34
+ /** For a place: the record of the place tables (the names in both languages, the kind, the mission, the operator, the country, the date, the feature's type and size). Left out for an orbiter and for a tap on nothing. */
35
+ place?: Place;
36
+ /** For a place that is a landing on the Moon or Mars (the lander, or the rover or descent stage on the same spot): the landing site (`/landing-sites`: names, the day, the agency, the country and its flag code, where each number is from). Left out for any other place. */
37
+ site?: LandingSite;
38
+ /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
39
+ via: "hover" | "tap" | "key";
40
+ }
41
+ /**
42
+ * The `<wakusei-flat>` custom element: the Moon or Mars on a flat map, with day and night from the Sun's direction for the time shown, the landing, rover and crash sites marked, and the spacecraft in orbit as dots that move over it. Import
43
+ * `@johnmorrisdotca/wakusei-planets/flat/define` to register the tag. It needs no WebGL and no peer: the map is the package's own picture of the body (the same one the 3D views are painted from), fetched from the package's CDN folder unless `texture-base` says where yours are.
44
+ *
45
+ * Attributes (the ones marked "same" are the names and meanings `<chikyu-flat>` has): `body` (`moon`, the default, or `mars`), `center` (same: the longitude in the middle, degrees; 0, the near side or the prime meridian, by default; the map wraps round the body),
46
+ * `home-lon` and `home-lat` (same: the reader's place, a chosen site: a marker, and the "My place" button, which appear only when given),
47
+ * `footprint` and `track` (same: the circle on the ground the orbiter can see, and its ground track for one trip round; the footprint and track of the chosen orbiter, or of every orbiter shown when none is chosen), `footprint-elevation` (same: degrees above the horizon the circle is drawn for; 10 by default),
48
+ * `paused` (same: hold the clock and keep the speed; nothing is drawn while it is held), `time` (same: `now`, an ISO date or milliseconds since 1970; live when absent), `speed` (same: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards),
49
+ * `selected` (same: the chosen orbiter's id such as `lro`, or a place's id such as `moon/apollo-11-lunar-module`), `shade` (same: `off` for no night), `dot-size` (same: pixels), `controls` (same: `none`, or any of `centre zoom footprint track chips`; all by default), `lang` (same: `en` or `ja`; the page's language by default),
50
+ * `orbiters` (`all`, the default, `off`, or some ids with commas: the orbiters drawn), `places` (the kinds of place marked, from `landing` (crewed, landing and rover sites), `crash` (crashes and impacts), `planned` and `feature` (named craters, seas and mountains); `landing` by default, `all` for every kind, `off` for none),
51
+ * `names` (`off` for no names beside the marks, or the most names to show), `site-flags` (the landing sites carry their country's flag: `<hata-flag>` beside the name on the map and in the tip; the page imports `@johnmorrisdotca/hata`, and without it the name stands alone), `texture-base` and `texture-far-base` (where the body's pictures are: the package's folder on jsDelivr by default).
52
+ *
53
+ * Events (the same names as chikyu's with `wakusei-` for `chikyu-`): `wakusei-flat-pick` (an orbiter, a place of the tables (a landing, a rover, a crash, a crater, a mountain) or a landing site under the pointer, tapped, or reached by the keyboard: a `FlatPick` with `kind`, `id`, `name`, `via` and, for a place, `place` (its record) and `site` (the landing site, where it is one); `detail.id` is null when a tap lands on nothing and clears the choice), `wakusei-flat-filter` (a chip changed what is shown: `{ orbiters, layers }`),
54
+ * `wakusei-flat-view` (the reader panned or zoomed: `{ center, zoom }`) and `wakusei-timechange` (`{ time, running, paused }`, at most four a second while time runs; the name the space view uses).
55
+ * Style it with the custom properties `--wakusei-flat-sea`, `--wakusei-flat-aspect`, `--wakusei-flat-aspect-narrow` and `--wakusei-flat-radius`.
56
+ *
57
+ * @example
58
+ * ```ts no-run
59
+ * import "@johnmorrisdotca/wakusei-planets/flat/define";
60
+ * import type { WakuseiFlat } from "@johnmorrisdotca/wakusei-planets/flat/define";
61
+ *
62
+ * const flat = document.createElement("wakusei-flat") as WakuseiFlat;
63
+ * flat.setAttribute("body", "moon");
64
+ * flat.setAttribute("track", "");
65
+ * document.body.append(flat);
66
+ * flat.addEventListener("wakusei-flat-pick", (event) => console.log((event as CustomEvent).detail.name));
67
+ * ```
68
+ */
69
+ export declare class WakuseiFlat extends HTMLElement {
70
+ #private;
71
+ static observedAttributes: string[];
72
+ /** The body on the map: `moon` or `mars`. */
73
+ get body(): FlatBodyId;
74
+ set body(value: FlatBodyId);
75
+ /** Whether the landing sites carry their country's flag (the attribute `site-flags`): beside the name on the map, and in the tip. The flag is `<hata-flag>` from `@johnmorrisdotca/hata`, which the page imports; where it is not defined the name stands alone. */
76
+ get siteFlags(): boolean;
77
+ set siteFlags(on: boolean);
78
+ /** The id of the chosen orbiter or place, or null. Set it to choose one from code (no `wakusei-flat-pick` is sent), `null` to clear. */
79
+ get selected(): string | null;
80
+ set selected(id: string | null);
81
+ /** The longitude in the middle, degrees. Set it to centre the map there; a reader's pan changes it, and `wakusei-flat-view` tells the page. */
82
+ get center(): number;
83
+ set center(lon: number);
84
+ /** The zoom: 1 shows the whole body, up to 8. */
85
+ get zoom(): number;
86
+ set zoom(value: number);
87
+ /** The moment shown, in milliseconds since the Unix epoch. Set it to a number (or a `Date`) to move the clock, or "now" to go live. */
88
+ get time(): number;
89
+ set time(value: number | Date | "now");
90
+ /** How fast the clock runs: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards. */
91
+ get speed(): number;
92
+ set speed(value: number);
93
+ /** True while the clock is held with its speed kept (the page's Pause): nothing is drawn but what the reader changes. Setting it false carries on from the moment shown at the same speed. */
94
+ get paused(): boolean;
95
+ set paused(value: boolean);
96
+ /** The language of the words: the `lang` attribute, else the page's. */
97
+ get language(): FlatLang;
98
+ /** The orbiters the map can draw for this body now: their ids, names and colours, and whether each has a path at the moment shown. A craft with no public path (Tianwen-1, CAPSTONE) is not in the list. */
99
+ get orbiters(): readonly {
100
+ id: string;
101
+ name: string;
102
+ colour: string;
103
+ shown: boolean;
104
+ }[];
105
+ /** The places loaded for this body (every kind; the `places` attribute and the chips choose which are marked), or an empty list while they load. */
106
+ get places(): readonly Place[];
107
+ /** The kinds of place marked now: `landing`, `crash`, `planned` and `feature`. */
108
+ get layers(): readonly PlaceLayer[];
109
+ /** Counters for a test or a page: draws of the dots, draws of the map, the orbiters drawn at the last draw, the milliseconds the last draw and the slowest took, the marks drawn, and the canvases' size in pixels. */
110
+ get stats(): {
111
+ draws: number;
112
+ mapDraws: number;
113
+ dots: number;
114
+ marks: number;
115
+ lastDrawMs: number;
116
+ maxDrawMs: number;
117
+ averageDrawMs: number;
118
+ running: boolean;
119
+ paused: boolean;
120
+ fast: boolean;
121
+ mapLoaded: boolean;
122
+ canvases: {
123
+ width: number;
124
+ height: number;
125
+ }[];
126
+ };
127
+ /** Where an orbiter or a place is on the screen as of the last draw, in CSS pixels from the map's top left, or null when it is not drawn (not shown, off the map, or an orbiter with no path). */
128
+ placeOf(id: string): {
129
+ x: number;
130
+ y: number;
131
+ lon: number;
132
+ lat: number;
133
+ altitudeKm: number | null;
134
+ } | null;
135
+ /** Choose an orbiter or a place from code, as a reader's tap would, without sending `wakusei-flat-pick`. An id the map does not hold, or `null`, clears the choice. */
136
+ pick(id: string | null): void;
137
+ connectedCallback(): void;
138
+ disconnectedCallback(): void;
139
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
140
+ }
141
+ declare global {
142
+ interface HTMLElementTagNameMap {
143
+ "wakusei-flat": WakuseiFlat;
144
+ }
145
+ }