@johnmorrisdotca/wakusei-planets 0.74.2 → 0.75.1

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 (59) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/NOTICE.md +4 -3
  3. package/README.md +7 -7
  4. package/dist/bodies/dwarfs.js +1 -1
  5. package/dist/bodies/earth-look.js +1 -1
  6. package/dist/bodies/jupiter.js +1 -1
  7. package/dist/bodies/mars.js +1 -1
  8. package/dist/bodies/moons-neptune.js +1 -1
  9. package/dist/bodies/moons-pluto.js +2 -0
  10. package/dist/bodies/moons-saturn.js +1 -1
  11. package/dist/bodies/neptune.js +1 -1
  12. package/dist/bodies/pluto.js +1 -0
  13. package/dist/bodies/saturn.js +1 -1
  14. package/dist/bodies/uranus.js +1 -1
  15. package/dist/bodies/venus.js +1 -1
  16. package/dist/data/discovery.js +30 -0
  17. package/dist/data/estimated-moons.js +354 -354
  18. package/dist/data/moon-catalogue.d.ts +1 -1
  19. package/dist/data/moon-catalogue.js +368 -368
  20. package/dist/data/orbits.js +3 -0
  21. package/dist/element.d.ts +1 -1
  22. package/dist/element.js +19 -2
  23. package/dist/facts.d.ts +1 -1
  24. package/dist/facts.js +4 -1
  25. package/dist/flat/bodies.d.ts +11 -10
  26. package/dist/flat/bodies.js +62 -28
  27. package/dist/flat/element.d.ts +55 -16
  28. package/dist/flat/element.js +746 -86
  29. package/dist/flat/index.d.ts +4 -2
  30. package/dist/flat/index.js +5 -3
  31. package/dist/flat/look.d.ts +206 -0
  32. package/dist/flat/look.js +305 -0
  33. package/dist/flat/marks.d.ts +122 -0
  34. package/dist/flat/marks.js +60 -0
  35. package/dist/flat/scene.d.ts +119 -2
  36. package/dist/flat/scene.js +130 -2
  37. package/dist/flat/words.d.ts +16 -0
  38. package/dist/flat/words.js +74 -1
  39. package/dist/moon-catalogue.d.ts +9 -9
  40. package/dist/moon-catalogue.js +11 -10
  41. package/dist/moon-pages/element.js +0 -2
  42. package/dist/moon-pages/hero.d.ts +1 -4
  43. package/dist/moon-pages/hero.js +5 -10
  44. package/dist/portrait/model.js +3 -3
  45. package/dist/scene/body.d.ts +1 -0
  46. package/dist/scene/body.js +8 -4
  47. package/dist/scene/glsl.js +3 -1
  48. package/dist/scene/look.d.ts +15 -0
  49. package/dist/scene/look.js +19 -0
  50. package/dist/scene/name-label.d.ts +10 -0
  51. package/dist/scene/name-label.js +93 -1
  52. package/dist/scene/painter.d.ts +2 -1
  53. package/dist/scene/painter.js +8 -4
  54. package/dist/scene/textures.d.ts +2 -2
  55. package/dist/space/element.d.ts +15 -1
  56. package/dist/space/element.js +23 -1
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.js +1 -1
  59. package/package.json +1 -1
@@ -27,6 +27,9 @@ export const ORBITS = {
27
27
  charon: { parent: "pluto", frame: "laplace", pole: [132.9930, -6.1630], epoch: 946728000000, a: 19594, e: 0.000170, w: 145.5839, m: 148.8112, i: 0.0832, node: 9.7573, sid: 56.3625307, dw: -0.000061, dn: 0.000064 },
28
28
  nix: { parent: "pluto", frame: "laplace", pole: [132.9930, -6.1630], epoch: 946728000000, a: 49331, e: 0.015290, w: 307.1081, m: 135.3103, i: 0.0847, node: 9.7013, sid: 14.4841691, dw: -0.574755, dn: 0.000064 },
29
29
  hydra: { parent: "pluto", frame: "laplace", pole: [132.9930, -6.1630], epoch: 946728000000, a: 65177, e: 0.008508, w: 152.6898, m: 325.4937, i: 0.2857, node: 114.7977, sid: 9.4235842, dw: 3.910425, dn: -0.070598 },
30
+ // the moon catalogue's mean elements (JPL Planetary Satellite Mean Elements, ephemeris PLU060, epoch JD 2461041.5 = 2026-01-01), not a Horizons fit. The catalogue gives no apsis rate, so dw and dn are 0.
31
+ styx: { parent: "pluto", frame: "laplace", pole: [132.9930, -6.1630], epoch: 1767225600000, a: 43200, e: 0.025, w: 322.5, m: 236.1894, i: 0, node: 0, sid: 17.7626192, dw: 0, dn: 0 },
32
+ kerberos: { parent: "pluto", frame: "laplace", pole: [132.9930, -6.1630], epoch: 1767225600000, a: 58300, e: 0.01, w: 32.1, m: 317.7946, i: 0.4, node: 354.3, sid: 11.2139054, dw: 0, dn: 0 },
30
33
  amalthea: { parent: "jupiter", frame: "laplace", pole: [268.1000, 64.5000], epoch: 946728000000, a: 181993, e: 0.004296, w: 46.8101, m: 84.2641, i: 0.3765, node: 282.8314, sid: 722.6317267, dw: 3.400548, dn: -2.504860 },
31
34
  thebe: { parent: "jupiter", frame: "laplace", pole: [268.1000, 64.5000], epoch: 946728000000, a: 222399, e: 0.017625, w: 26.6213, m: 182.3500, i: 1.0681, node: 340.3485, sid: 533.7002763, dw: 2.474866, dn: -1.236316 },
32
35
  hyperion: { parent: "saturn", frame: "laplace", pole: [40.2000, 83.6000], epoch: 946728000000, a: 1481519, e: 0.104281, w: 230.0620, m: 55.0746, i: 0.7997, node: 4.4314, sid: 16.9199504, dw: -0.048079, dn: -0.003045 },
package/dist/element.d.ts CHANGED
@@ -35,7 +35,7 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
35
35
  * A `body` that names a catalogue moon the package does not draw in full (such as `himalia`, or `S/2003 J 18`) is an estimated rock: the size is the catalogue radius, the shape is a guess from that id, and the picture says the shape is estimated. A size worked out from the brightness says so. Any other unknown name stays the Earth.
36
36
  *
37
37
  * It carries the shared view controls itself: a drag turns the body, two fingers pinch, Ctrl, Command or Alt with the wheel zooms (the plain wheel scrolls the page at Fit), the arrow keys, + and - and 0 work once it is focused.
38
- * `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
38
+ * `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `still-size` is the long side of the still in CSS pixels; the still is made at that times the device pixel ratio (up to 3), where the page's default is 160 device pixels, so a still shown large is sharp. `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
39
39
  * Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
40
40
  * Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
41
41
  * `cutaway` (off when absent or `off`) opens a quarter of the globe toward the camera, turning with the body, and lists the interior layers. Only a body with sourced figures is cut; the others stay whole and the legend says so. See the guide "A cutaway of the interior".
package/dist/element.js CHANGED
@@ -86,7 +86,7 @@ const TEMPLATE = `<style>
86
86
  * A `body` that names a catalogue moon the package does not draw in full (such as `himalia`, or `S/2003 J 18`) is an estimated rock: the size is the catalogue radius, the shape is a guess from that id, and the picture says the shape is estimated. A size worked out from the brightness says so. Any other unknown name stays the Earth.
87
87
  *
88
88
  * It carries the shared view controls itself: a drag turns the body, two fingers pinch, Ctrl, Command or Alt with the wheel zooms (the plain wheel scrolls the page at Fit), the arrow keys, + and - and 0 work once it is focused.
89
- * `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
89
+ * `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `still-size` is the long side of the still in CSS pixels; the still is made at that times the device pixel ratio (up to 3), where the page's default is 160 device pixels, so a still shown large is sharp. `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
90
90
  * Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
91
91
  * Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
92
92
  * `cutaway` (off when absent or `off`) opens a quarter of the globe toward the camera, turning with the body, and lists the interior layers. Only a body with sourced figures is cut; the others stay whole and the legend says so. See the guide "A cutaway of the interior".
@@ -108,7 +108,7 @@ const TEMPLATE = `<style>
108
108
  * ```
109
109
  */
110
110
  export class WakuseiBody extends HTMLElement {
111
- static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", "surface-names", "site-flags", "cutaway", ...NAME_LABEL_ATTRIBUTES];
111
+ static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "still-size", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", "surface-names", "site-flags", "cutaway", ...NAME_LABEL_ATTRIBUTES];
112
112
  #stage;
113
113
  #state = "line";
114
114
  #renderer;
@@ -489,6 +489,7 @@ export class WakuseiBody extends HTMLElement {
489
489
  this.#door.book.ownOnly(this.getAttribute("data") === "own");
490
490
  this.#reduce = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
491
491
  this.#clockFromAttributes();
492
+ this.#stillSide();
492
493
  if (!this.hasAttribute("role"))
493
494
  this.setAttribute("role", "img");
494
495
  this.#gate = createGate(1000 / frameCap(30, { deviceMemory: navigator.deviceMemory, hardwareConcurrency: navigator.hardwareConcurrency }), () => this.#frame());
@@ -554,6 +555,20 @@ export class WakuseiBody extends HTMLElement {
554
555
  this.#placeHeard?.();
555
556
  this.#placeHeard = undefined;
556
557
  }
558
+ /**
559
+ * The sharpness of the still, from `still-size` (CSS pixels on its long side): the shared renderer reads `data-still-size` (device pixels) from the element, so it is kept at `still-size` times the device pixel ratio (up to 3), and the picture is sharp on a screen that has more pixels than CSS pixels.
560
+ * A page that sets `data-still-size` itself, and no `still-size`, is left alone. Returns true when the value changed.
561
+ */
562
+ #stillSide() {
563
+ const asked = Number(this.getAttribute("still-size"));
564
+ if (!this.hasAttribute("still-size") || !Number.isFinite(asked) || asked <= 0)
565
+ return false;
566
+ const side = String(Math.round(Math.min(2048, Math.max(16, asked * Math.min(3, window.devicePixelRatio || 1)))));
567
+ if (this.getAttribute("data-still-size") === side)
568
+ return false;
569
+ this.setAttribute("data-still-size", side);
570
+ return true;
571
+ }
557
572
  attributeChangedCallback(name) {
558
573
  if (!this.isConnected)
559
574
  return;
@@ -568,6 +583,8 @@ export class WakuseiBody extends HTMLElement {
568
583
  this.#door.book.ownOnly(this.getAttribute("data") === "own");
569
584
  if (name === "live")
570
585
  this.#applyHover();
586
+ if (name === "still-size" && this.#stillSide())
587
+ this.#still();
571
588
  if (name === "live" || name === "look" || name === "body")
572
589
  this.#carry();
573
590
  if (name === "body" || name === "look" || name === "moons" || name === "range" || name === "scale-to" || name === "span-km" || name === "fit" || name === "star") {
package/dist/facts.d.ts CHANGED
@@ -48,7 +48,7 @@ export declare const MOONS_OF: {
48
48
  readonly saturn: readonly ["mimas", "enceladus", "tethys", "dione", "rhea", "titan", "iapetus", "pan", "daphnis", "atlas", "prometheus", "pandora", "epimetheus", "janus", "telesto", "calypso", "helene", "hyperion", "phoebe"];
49
49
  readonly uranus: readonly ["miranda", "ariel", "umbriel", "titania", "oberon"];
50
50
  readonly neptune: readonly ["proteus", "triton", "nereid", "larissa"];
51
- readonly pluto: readonly ["charon", "nix", "hydra"];
51
+ readonly pluto: readonly ["charon", "styx", "nix", "kerberos", "hydra"];
52
52
  readonly orcus: readonly ["vanth"];
53
53
  readonly haumea: readonly ["hiiaka", "namaka"];
54
54
  readonly eris: readonly ["dysnomia"];
package/dist/facts.js CHANGED
@@ -50,7 +50,7 @@ export const MOONS_OF = {
50
50
  saturn: ["mimas", "enceladus", "tethys", "dione", "rhea", "titan", "iapetus", "pan", "daphnis", "atlas", "prometheus", "pandora", "epimetheus", "janus", "telesto", "calypso", "helene", "hyperion", "phoebe"],
51
51
  uranus: ["miranda", "ariel", "umbriel", "titania", "oberon"],
52
52
  neptune: ["proteus", "triton", "nereid", "larissa"],
53
- pluto: ["charon", "nix", "hydra"],
53
+ pluto: ["charon", "styx", "nix", "kerberos", "hydra"],
54
54
  orcus: ["vanth"],
55
55
  haumea: ["hiiaka", "namaka"],
56
56
  eris: ["dysnomia"],
@@ -265,6 +265,9 @@ export const BODIES = {
265
265
  charon: f("charon", "moon", "Charon", "カロン", 606, 0, 0, 132.993, -6.163, 122.695, 56.3625225, 153.2935, "#9c9189", { parent: "pluto", synchronous: true, features: [{ kind: "oval", lon: 0, lat: 76, rx: 90, ry: 14, fill: true }, { kind: "circle", lon: 40, lat: -15, radius: 12 }, ...dots([[-60, 10, 8], [120, 30, 7]])] }),
266
266
  nix: f("nix", "moon", "Nix", "ニクス", 19.3, 0.3, 0, 132.993, -6.163, 0, 14.48, 0, "#b3ada7", { parent: "pluto", axesKm: [24.9, 16.6, 15.6], features: [{ kind: "circle", lon: 0, lat: 0, radius: 18 }] }),
267
267
  hydra: f("hydra", "moon", "Hydra", "ヒドラ", 19.5, 0.4, 0, 132.993, -6.163, 0, 9.42, 0, "#c4beb6", { parent: "pluto", axesKm: [32.5, 22.5, 12.5], features: [{ kind: "circle", lon: 30, lat: 10, radius: 20 }] }),
268
+ // radii from the moon catalogue (JPL physical parameters). No measured shape or spin, so each is a sphere that does not turn.
269
+ styx: f("styx", "moon", "Styx", "ステュクス", 5.2, 0, 0, 132.993, -6.163, 0, 0, 0, "#b7b2aa", { parent: "pluto", features: dots([[0, 10, 16]]) }),
270
+ kerberos: f("kerberos", "moon", "Kerberos", "ケルベロス", 6, 0, 0, 132.993, -6.163, 0, 0, 0, "#aea89f", { parent: "pluto", features: dots([[20, -10, 16]]) }),
268
271
  vanth: f("vanth", "moon", "Vanth", "ヴァンス", 221, 0, 0, 142.474, 15.004, 0, 37.738618, 228.9488, "#6e6a66", { parent: "orcus", synchronous: true, features: dots([[-50, 15, 10], [80, -20, 9], [150, 30, 8]]) }),
269
272
  hiiaka: f("hiiaka", "moon", "Hiʻiaka", "ヒイアカ", 185, 0, 0, 282.6, -13, 0, 0, 0, "#e0e0e0", { parent: "haumea", features: dots([[-30, 20, 12], [70, -25, 10]]) }),
270
273
  namaka: f("namaka", "moon", "Namaka", "ナマカ", 75, 0, 0, 282.6, -13, 0, 0, 0, "#d0d0d0", { parent: "haumea", features: dots([[0, 0, 14]]) }),
@@ -1,15 +1,16 @@
1
1
  import { type OrbiterId } from "../orbiters.ts";
2
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>`.
3
+ * The bodies the flat map draws: every planet and dwarf planet, the Moon and the other moons, and the two asteroids that have a painted picture in the package. Each has its own surface picture to lay flat and a pole and a spin to work out where the Sun is overhead.
4
+ * Only the Moon and Mars have orbiters and landing sites to draw; for the others the map is the picture, the night, the Sun and whatever a page adds with `setMarks`. The Earth's own flat map with satellites is chikyu-earth's `<chikyu-flat>`.
4
5
  *
5
6
  * @example
6
7
  * ```ts
7
8
  * import { FLAT_BODIES } from "@johnmorrisdotca/wakusei-planets/flat";
8
9
  *
9
- * console.log(FLAT_BODIES.join(", "));
10
+ * console.log(FLAT_BODIES.length, FLAT_BODIES.join(", "));
10
11
  * ```
11
12
  */
12
- export declare const FLAT_BODIES: readonly ["moon", "mars"];
13
+ export declare const FLAT_BODIES: readonly ["mercury", "venus", "earth", "moon", "mars", "phobos", "deimos", "ceres", "vesta", "jupiter", "io", "europa", "ganymede", "callisto", "saturn", "mimas", "enceladus", "tethys", "dione", "rhea", "titan", "iapetus", "phoebe", "uranus", "neptune", "triton", "pluto", "charon"];
13
14
  /**
14
15
  * A body the flat map draws.
15
16
  *
@@ -35,9 +36,9 @@ export type FlatBodyId = (typeof FLAT_BODIES)[number];
35
36
  */
36
37
  export interface FlatBodyInfo {
37
38
  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
+ /** The mean radius in kilometres (IAU) for the Moon and Mars, the body's radius for the rest: the sphere a craft's height is measured above and the footprint is worked out on. */
39
40
  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
+ /** How far the Sun is below the horizon, in degrees, when the shading has gone to full night: 1 on a body with no air (the Moon), 8 on Mars (its dust lights the sky for a while after sunset), more where the air is thick. */
41
42
  twilightDeg: number;
42
43
  /** 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
44
  night: readonly [number, number, number, number];
@@ -46,29 +47,29 @@ export interface FlatBodyInfo {
46
47
  /** The longitudes the "centre the map on" buttons go to, with the word each is called by (`FLAT_WORDS` keys). */
47
48
  centres: readonly {
48
49
  lon: number;
49
- say: "nearSide" | "farSide" | "primeMeridian";
50
+ say: "nearSide" | "farSide" | "primeMeridian" | "oppositeMeridian";
50
51
  }[];
51
- /** The orbiters that go round it, in the package's order. */
52
+ /** The orbiters that go round it, in the package's order: none for any body but the Moon and Mars. */
52
53
  orbiters: readonly OrbiterId[];
53
54
  }
54
55
  /**
55
56
  * Whether a text is a body the flat map draws.
56
57
  *
57
58
  * @param value - Any text, in any case.
58
- * @returns True for `moon` and `mars`.
59
+ * @returns True for any of `FLAT_BODIES`.
59
60
  *
60
61
  * @example
61
62
  * ```ts
62
63
  * import { isFlatBody } from "@johnmorrisdotca/wakusei-planets/flat";
63
64
  *
64
- * console.log(isFlatBody("Mars"), isFlatBody("venus"));
65
+ * console.log(isFlatBody("Mars"), isFlatBody("sun"));
65
66
  * ```
66
67
  */
67
68
  export declare const isFlatBody: (value: string | null | undefined) => value is FlatBodyId;
68
69
  /**
69
70
  * What is particular to a body on the flat map.
70
71
  *
71
- * @param id - `moon` or `mars`.
72
+ * @param id - Any of `FLAT_BODIES`, in any case.
72
73
  * @returns Its numbers.
73
74
  *
74
75
  * @example
@@ -1,59 +1,93 @@
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.
1
+ // The bodies the flat map draws and what is particular to each: its 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
2
  // Pure: no DOM.
3
+ import { BODIES } from "../facts.js";
3
4
  import { ORBITER_FACTS, ORBITER_IDS, orbiterCentre } from "../orbiters.js";
4
5
  /**
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
+ * The bodies the flat map draws: every planet and dwarf planet, the Moon and the other moons, and the two asteroids that have a painted picture in the package. Each has its own surface picture to lay flat and a pole and a spin to work out where the Sun is overhead.
7
+ * Only the Moon and Mars have orbiters and landing sites to draw; for the others the map is the picture, the night, the Sun and whatever a page adds with `setMarks`. The Earth's own flat map with satellites is chikyu-earth's `<chikyu-flat>`.
6
8
  *
7
9
  * @example
8
10
  * ```ts
9
11
  * import { FLAT_BODIES } from "@johnmorrisdotca/wakusei-planets/flat";
10
12
  *
11
- * console.log(FLAT_BODIES.join(", "));
13
+ * console.log(FLAT_BODIES.length, FLAT_BODIES.join(", "));
12
14
  * ```
13
15
  */
14
- export const FLAT_BODIES = ["moon", "mars"];
16
+ export const FLAT_BODIES = [
17
+ "mercury",
18
+ "venus",
19
+ "earth",
20
+ "moon",
21
+ "mars",
22
+ "phobos",
23
+ "deimos",
24
+ "ceres",
25
+ "vesta",
26
+ "jupiter",
27
+ "io",
28
+ "europa",
29
+ "ganymede",
30
+ "callisto",
31
+ "saturn",
32
+ "mimas",
33
+ "enceladus",
34
+ "tethys",
35
+ "dione",
36
+ "rhea",
37
+ "titan",
38
+ "iapetus",
39
+ "phoebe",
40
+ "uranus",
41
+ "neptune",
42
+ "triton",
43
+ "pluto",
44
+ "charon",
45
+ ];
15
46
  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",
47
+ /** How far below the horizon the Sun is when the night is full, for the bodies with air to spread the light; every other body has 1. */
48
+ const TWILIGHT = { earth: 12, venus: 10, mars: 8, titan: 10, jupiter: 4, saturn: 4, uranus: 4, neptune: 4, pluto: 3, triton: 2 };
49
+ const AIR_NIGHT = [6, 4, 14, 0.72];
50
+ const BARE_NIGHT = [3, 5, 12, 0.78];
51
+ const NEAR_FAR = [
52
+ { lon: 0, say: "nearSide" },
53
+ { lon: 180, say: "farSide" },
54
+ ];
55
+ const infoOf = (id) => {
56
+ const twilightDeg = TWILIGHT[id] ?? 1;
57
+ const base = { id, twilightDeg, night: twilightDeg > 1 ? AIR_NIGHT : BARE_NIGHT, orbiters: orbitersOf(id) };
58
+ if (id === "moon")
59
+ return { ...base, radiusKm: 1737.4, ground: "#4a4945", centres: NEAR_FAR };
60
+ if (id === "mars")
61
+ return { ...base, radiusKm: 3389.5, ground: "#7a3f24", centres: [{ lon: 0, say: "primeMeridian" }] };
62
+ return {
63
+ ...base,
64
+ radiusKm: BODIES[id].radiusKm,
65
+ ground: BODIES[id].colour,
23
66
  centres: [
24
- { lon: 0, say: "nearSide" },
25
- { lon: 180, say: "farSide" },
67
+ { lon: 0, say: "primeMeridian" },
68
+ { lon: 180, say: "oppositeMeridian" },
26
69
  ],
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
- },
70
+ };
38
71
  };
72
+ const INFO = Object.fromEntries(FLAT_BODIES.map((id) => [id, infoOf(id)]));
39
73
  /**
40
74
  * Whether a text is a body the flat map draws.
41
75
  *
42
76
  * @param value - Any text, in any case.
43
- * @returns True for `moon` and `mars`.
77
+ * @returns True for any of `FLAT_BODIES`.
44
78
  *
45
79
  * @example
46
80
  * ```ts
47
81
  * import { isFlatBody } from "@johnmorrisdotca/wakusei-planets/flat";
48
82
  *
49
- * console.log(isFlatBody("Mars"), isFlatBody("venus"));
83
+ * console.log(isFlatBody("Mars"), isFlatBody("sun"));
50
84
  * ```
51
85
  */
52
86
  export const isFlatBody = (value) => value !== null && value !== undefined && FLAT_BODIES.includes(value.trim().toLowerCase());
53
87
  /**
54
88
  * What is particular to a body on the flat map.
55
89
  *
56
- * @param id - `moon` or `mars`.
90
+ * @param id - Any of `FLAT_BODIES`, in any case.
57
91
  * @returns Its numbers.
58
92
  *
59
93
  * @example
@@ -66,7 +100,7 @@ export const isFlatBody = (value) => value !== null && value !== undefined && FL
66
100
  export function flatBody(id) {
67
101
  const key = id.trim().toLowerCase();
68
102
  if (!isFlatBody(key))
69
- throw new RangeError(`the flat map draws ${FLAT_BODIES.join(" and ")}, not ${JSON.stringify(id)}`);
103
+ throw new RangeError(`the flat map draws ${FLAT_BODIES.join(", ")}, not ${JSON.stringify(id)}`);
70
104
  return INFO[key];
71
105
  }
72
106
  /**
@@ -2,10 +2,12 @@ import { type LandingSite } from "../landing-sites.ts";
2
2
  import { type PlaceLayer } from "../place-marks.ts";
3
3
  import { type Place, type PlaceKind } from "../places.ts";
4
4
  import { type FlatBodyId } from "./bodies.ts";
5
+ import { type FlatLook } from "./look.ts";
6
+ import { type FlatMark, type HeldMark } from "./marks.ts";
5
7
  import { type FlatLang } from "./words.ts";
6
8
  import type { OrbiterStatus } from "../orbiters.ts";
7
9
  /**
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.
10
+ * What `wakusei-flat-pick` carries: an orbiter, a place or one of the page's marks under the pointer, tapped, or reached by the keyboard. A tap on nothing sends `id: null` and clears the choice.
9
11
  *
10
12
  * @example
11
13
  * ```ts
@@ -16,9 +18,9 @@ import type { OrbiterStatus } from "../orbiters.ts";
16
18
  * ```
17
19
  */
18
20
  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. */
21
+ /** What was chosen: an orbiter, a place on the surface, or a mark the page added (`setMarks`). */
22
+ kind: "orbiter" | "place" | "mark" | null;
23
+ /** An orbiter's id (`lro`), a place's (`moon/apollo-11-lunar-module`) or a mark's own; null when a tap lands on nothing. */
22
24
  id: string | null;
23
25
  name: string | null;
24
26
  body: FlatBodyId;
@@ -35,24 +37,30 @@ export interface FlatPick {
35
37
  place?: Place;
36
38
  /** 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
39
  site?: LandingSite;
40
+ /** For a mark the page added: its record as the map holds it (its `group`, `data` and the rest). Left out otherwise. */
41
+ mark?: HeldMark;
38
42
  /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
39
43
  via: "hover" | "tap" | "key";
40
44
  }
41
45
  /**
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
46
+ * The `<wakusei-flat>` custom element: any body the package has a picture of (every planet and dwarf planet, the Moon and the other moons, Vesta) on a flat map, with day and night from the Sun's direction for the time shown, the sunrise and sunset line, the Sun's mark,
47
+ * the landing, rover and crash sites and the named features where the package has them, the spacecraft in orbit round the Moon and Mars as dots that move over it, and any marks the page adds (`setMarks`). Import
43
48
  * `@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.
49
+ * It has two looks: `photo` (the default: the picture itself) and `map` (a line map drawn from the same picture: dark tones, a line where one tone meets the next, a grid with its degrees, the names). The picture's credit is one small line at the map's bottom edge in both.
44
50
  *
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),
51
+ * Attributes (the ones marked "same" are the names and meanings `<chikyu-flat>` has): `body` (`moon`, the default, or any of `FLAT_BODIES`: `mars`, `jupiter`, `titan`, ...), `look` (same: `photo`, the default here, or `map`), `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
52
  * `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),
53
+ * `moons` (the moons of the body, each marked over the place on the ground it is straight above, named and pressable; `all` or empty for every moon, some ids with commas, `off` or absent for none; Earth has one, Mars two, Jupiter six, Saturn nineteen, Uranus five, Neptune four, Pluto three),
54
+ * `footprint` and `track` (same, for the Moon and Mars, the bodies with orbiters: 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; `track` also draws each moon's path over the ground, half a turn of the body either way), `footprint-elevation` (same: degrees above the horizon the circle is drawn for; 10 by default),
48
55
  * `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),
56
+ * `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 key look`: the buttons, filter chips, key and Map / Photo pair shown; all but `look` by default), `lang` (same: `en` or `ja`; the page's language by default),
57
+ * `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 and in the photo look, `landing` and `feature` in the map look, `all` for every kind, `off` for none),
51
58
  * `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
59
  *
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`.
60
+ * 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), a landing site or a mark the page added, 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), for a mark `mark` (its record, with the page's `data`); `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 }`),
61
+ * `wakusei-flat-look` (the look or how it stands changed: `{ look, state }`), `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).
62
+ * For the page's own marks: `setMarks(group, marks, label)`, `clearMarks(group?)`, the `marks` property and `groups` (the groups the key names).
63
+ * Style it with the custom properties `--wakusei-flat-sea` and `--wakusei-flat-land` (the darkest and lightest tone of the map look), `--wakusei-flat-line` (the line between tones), `--wakusei-flat-key-inset` (room kept at the left of the key, for a card lying over the map's left side), `--wakusei-flat-aspect`, `--wakusei-flat-aspect-narrow` and `--wakusei-flat-radius`.
56
64
  *
57
65
  * @example
58
66
  * ```ts no-run
@@ -69,9 +77,37 @@ export interface FlatPick {
69
77
  export declare class WakuseiFlat extends HTMLElement {
70
78
  #private;
71
79
  static observedAttributes: string[];
72
- /** The body on the map: `moon` or `mars`. */
80
+ /** The body on the map: any of `FLAT_BODIES` (`moon` by default). */
73
81
  get body(): FlatBodyId;
74
82
  set body(value: FlatBodyId);
83
+ /** The look of the map: `photo`, the body's own picture (the default), or `map`, a line map drawn from the same picture. The `look` attribute. */
84
+ get look(): FlatLook;
85
+ set look(value: FlatLook);
86
+ /** How the look stands: `loading` (the picture is on its way; the plain ground, the grid and the marks show meanwhile), `map` or `photo` (that look is drawn) or `failed` (the picture could not be had; the plain ground, the grid and the marks stay). */
87
+ get lookState(): "loading" | "map" | "photo" | "failed";
88
+ /** Whether the key's list is open: what the reader chose, else open on a map 600 pixels wide or more and shut on a narrower one. Set it to fold the key from code. */
89
+ get keyOpen(): boolean;
90
+ set keyOpen(value: boolean);
91
+ /** The page's marks, all groups together, in the order they were given. Set it to replace every group at once (a mark's own `group` names its group, `marks` the rest). */
92
+ get marks(): readonly HeldMark[];
93
+ set marks(list: readonly FlatMark[]);
94
+ /** The groups of the page's marks and what the key calls each: `[{ group, label, count }]`. */
95
+ get groups(): readonly {
96
+ group: string;
97
+ label: FlatMark["name"] | null;
98
+ count: number;
99
+ }[];
100
+ /**
101
+ * Replace one group of the page's marks: points on the ground that the map draws over the picture, names when they are pointed at, pressed or reached by the keyboard, lists in the key under `label`, and sends `wakusei-flat-pick` (`kind: "mark"`) for.
102
+ * A page that moves a mark (a moon's sub-point, an orbiter) calls this again with the new places; the map draws at the next frame. An empty list or `null` takes the group away.
103
+ *
104
+ * @param group - The group's name; a mark's own `group` wins when it has one.
105
+ * @param marks - The marks of the group.
106
+ * @param label - What the key calls the group (one text, or `{ en, ja }`); the group's name when left out.
107
+ */
108
+ setMarks(group: string, marks: readonly FlatMark[] | null, label?: FlatMark["name"]): void;
109
+ /** Take away one group of the page's marks, or all of them. */
110
+ clearMarks(group?: string): void;
75
111
  /** 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
112
  get siteFlags(): boolean;
77
113
  set siteFlags(on: boolean);
@@ -106,12 +142,13 @@ export declare class WakuseiFlat extends HTMLElement {
106
142
  get places(): readonly Place[];
107
143
  /** The kinds of place marked now: `landing`, `crash`, `planned` and `feature`. */
108
144
  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. */
145
+ /** Counters for a test or a page: draws of the dots, draws of the map, the orbiters drawn at the last draw, the marks drawn (the places of the tables, and `custom` for the page's own), the milliseconds the last draw and the slowest took, whether the picture is in and which look is drawn, and the canvases' size in pixels. */
110
146
  get stats(): {
111
147
  draws: number;
112
148
  mapDraws: number;
113
149
  dots: number;
114
150
  marks: number;
151
+ custom: number;
115
152
  lastDrawMs: number;
116
153
  maxDrawMs: number;
117
154
  averageDrawMs: number;
@@ -119,12 +156,14 @@ export declare class WakuseiFlat extends HTMLElement {
119
156
  paused: boolean;
120
157
  fast: boolean;
121
158
  mapLoaded: boolean;
159
+ look: FlatLook;
160
+ lookState: "loading" | "map" | "photo" | "failed";
122
161
  canvases: {
123
162
  width: number;
124
163
  height: number;
125
164
  }[];
126
165
  };
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). */
166
+ /** Where an orbiter, a place or one of the page's marks 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
167
  placeOf(id: string): {
129
168
  x: number;
130
169
  y: number;
@@ -132,7 +171,7 @@ export declare class WakuseiFlat extends HTMLElement {
132
171
  lat: number;
133
172
  altitudeKm: number | null;
134
173
  } | 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. */
174
+ /** Choose an orbiter, a place or a mark 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
175
  pick(id: string | null): void;
137
176
  connectedCallback(): void;
138
177
  disconnectedCallback(): void;