@johnmorrisdotca/wakusei-planets 0.75.0 → 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 (43) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/NOTICE.md +4 -3
  3. package/README.md +3 -3
  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/facts.d.ts +1 -1
  22. package/dist/facts.js +4 -1
  23. package/dist/moon-catalogue.d.ts +9 -9
  24. package/dist/moon-catalogue.js +11 -10
  25. package/dist/moon-pages/element.js +0 -2
  26. package/dist/moon-pages/hero.d.ts +1 -4
  27. package/dist/moon-pages/hero.js +5 -10
  28. package/dist/portrait/model.js +3 -3
  29. package/dist/scene/body.d.ts +1 -0
  30. package/dist/scene/body.js +8 -4
  31. package/dist/scene/glsl.js +3 -1
  32. package/dist/scene/look.d.ts +15 -0
  33. package/dist/scene/look.js +19 -0
  34. package/dist/scene/name-label.d.ts +10 -0
  35. package/dist/scene/name-label.js +93 -1
  36. package/dist/scene/painter.d.ts +2 -1
  37. package/dist/scene/painter.js +8 -4
  38. package/dist/scene/textures.d.ts +2 -2
  39. package/dist/space/element.d.ts +15 -1
  40. package/dist/space/element.js +23 -1
  41. package/dist/version.d.ts +1 -1
  42. package/dist/version.js +1 -1
  43. 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/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]]) }),
@@ -163,8 +163,8 @@ export interface MoonDiscovery {
163
163
  */
164
164
  export type MoonSizeSource = "measured" | "sheet" | "derived";
165
165
  /**
166
- * Where a moon's magnitude comes from: `sheet` (the V(1,0) magnitude on its JPL Horizons data sheet) or `wikipedia` (the absolute magnitude of English Wikipedia's table of the moons of its planet, which takes the irregular
167
- * moons' from the Minor Planet Center's Natural Satellites Ephemeris Service; read on `MOON_MAGNITUDES_READ`, the page is in `MOON_MAGNITUDE_PAGES`). A size worked out from a `wikipedia` magnitude is an estimate: it assumes the
166
+ * Where a moon's magnitude comes from: `sheet` (the V(1,0) magnitude on its JPL Horizons data sheet) or `usno` (the V(1,0) column of the U.S. Naval Observatory's satellite table for The Astronomical Almanac, read on
167
+ * `MOON_MAGNITUDES_READ`; the file is in `MOON_MAGNITUDE_PAGES`). A size worked out from a `usno` magnitude is an estimate: it assumes the
168
168
  * albedo `ASSUMED_ALBEDO`, and `radiusFrom` says `derived`.
169
169
  *
170
170
  * @example
@@ -175,27 +175,27 @@ export type MoonSizeSource = "measured" | "sheet" | "derived";
175
175
  * console.log(from);
176
176
  * ```
177
177
  */
178
- export type MoonMagnitudeSource = "sheet" | "wikipedia";
178
+ export type MoonMagnitudeSource = "sheet" | "usno";
179
179
  /**
180
- * The day the magnitudes marked `wikipedia` were read from English Wikipedia's tables (CC BY-SA 4.0): one request for each of the four pages.
180
+ * The day the magnitudes marked `usno` were read from the U.S. Naval Observatory's satellite table (a US government work): one request.
181
181
  *
182
182
  * @example
183
183
  * ```ts
184
184
  * import { MOON_MAGNITUDES_READ } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
185
185
  *
186
- * console.log("Wikipedia read on", MOON_MAGNITUDES_READ);
186
+ * console.log("Almanac read on", MOON_MAGNITUDES_READ);
187
187
  * ```
188
188
  */
189
- export declare const MOON_MAGNITUDES_READ = "2026-11-18";
189
+ export declare const MOON_MAGNITUDES_READ = "2026-11-23";
190
190
  /**
191
- * The English Wikipedia page each host's `wikipedia` magnitudes were read from.
191
+ * The U.S. Naval Observatory file each host's `usno` magnitudes were read from.
192
192
  *
193
193
  * @example
194
194
  * ```ts
195
195
  * import { findCatalogueMoon, MOON_MAGNITUDE_PAGES } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
196
196
  *
197
197
  * const moon = findCatalogueMoon("Ymir")!;
198
- * if (moon.magnitudeFrom === "wikipedia") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
198
+ * if (moon.magnitudeFrom === "usno") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
199
199
  * ```
200
200
  */
201
201
  export declare const MOON_MAGNITUDE_PAGES: Readonly<Partial<Record<HostId, string>>>;
@@ -249,7 +249,7 @@ export interface CatalogueMoon {
249
249
  radiusFrom: MoonSizeSource | null;
250
250
  /** The geometric albedo, where the Horizons sheet gives one. */
251
251
  albedo: number | null;
252
- /** The V(1,0) magnitude (as bright as it would be 1 au from the Sun and from us), where the Horizons sheet gives one, else, for an irregular moon with no size, the absolute magnitude of English Wikipedia's table (see `magnitudeFrom`). */
252
+ /** The V(1,0) magnitude (as bright as it would be 1 au from the Sun and from us), where the Horizons sheet gives one, else, for an irregular moon with no size, the Almanac's V(1,0) where that column prints one (see `magnitudeFrom`). */
253
253
  magnitude: number | null;
254
254
  /** Where `magnitude` comes from; `null` when there is none. */
255
255
  magnitudeFrom: MoonMagnitudeSource | null;
@@ -59,32 +59,33 @@ const OSCULATING = new Map();
59
59
  }
60
60
  }
61
61
  /**
62
- * The day the magnitudes marked `wikipedia` were read from English Wikipedia's tables (CC BY-SA 4.0): one request for each of the four pages.
62
+ * The day the magnitudes marked `usno` were read from the U.S. Naval Observatory's satellite table (a US government work): one request.
63
63
  *
64
64
  * @example
65
65
  * ```ts
66
66
  * import { MOON_MAGNITUDES_READ } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
67
67
  *
68
- * console.log("Wikipedia read on", MOON_MAGNITUDES_READ);
68
+ * console.log("Almanac read on", MOON_MAGNITUDES_READ);
69
69
  * ```
70
70
  */
71
- export const MOON_MAGNITUDES_READ = "2026-11-18";
71
+ export const MOON_MAGNITUDES_READ = "2026-11-23";
72
+ const ALMANAC = "https://aa.usno.navy.mil/downloads/publications/Satellite_data_web_b_2024_2.txt";
72
73
  /**
73
- * The English Wikipedia page each host's `wikipedia` magnitudes were read from.
74
+ * The U.S. Naval Observatory file each host's `usno` magnitudes were read from.
74
75
  *
75
76
  * @example
76
77
  * ```ts
77
78
  * import { findCatalogueMoon, MOON_MAGNITUDE_PAGES } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
78
79
  *
79
80
  * const moon = findCatalogueMoon("Ymir")!;
80
- * if (moon.magnitudeFrom === "wikipedia") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
81
+ * if (moon.magnitudeFrom === "usno") console.log(MOON_MAGNITUDE_PAGES[moon.host]);
81
82
  * ```
82
83
  */
83
84
  export const MOON_MAGNITUDE_PAGES = {
84
- jupiter: "https://en.wikipedia.org/wiki/Moons_of_Jupiter",
85
- saturn: "https://en.wikipedia.org/wiki/Moons_of_Saturn",
86
- uranus: "https://en.wikipedia.org/wiki/Moons_of_Uranus",
87
- neptune: "https://en.wikipedia.org/wiki/Moons_of_Neptune",
85
+ jupiter: ALMANAC,
86
+ saturn: ALMANAC,
87
+ uranus: ALMANAC,
88
+ neptune: ALMANAC,
88
89
  };
89
90
  /**
90
91
  * The albedo a `derived` size takes when the Horizons sheet gives none: 0.04, the albedo the sheet gives for Himalia, the largest of the irregular moons. The few other irregular moons with an albedo on their sheets have 0.03
@@ -100,7 +101,7 @@ export const MOON_MAGNITUDE_PAGES = {
100
101
  export const ASSUMED_ALBEDO = 0.04;
101
102
  const FRAMES = ["ecliptic", "equatorial", "laplace"];
102
103
  const SIZE_FROM = ["measured", "sheet"];
103
- const MAGNITUDE_FROM = ["sheet", "wikipedia"];
104
+ const MAGNITUDE_FROM = ["sheet", "usno"];
104
105
  function moonOf(row) {
105
106
  const [id, name, designation, number, host, code, year, by, reference, o, radius, sigma, from, albedo, magnitude, worstKm, worstDegrees, farDegrees, group, ja, confirmed, drawn, magnitudeSource] = row;
106
107
  const orbit = o === null
@@ -102,7 +102,6 @@ tr:last-child > * { border-bottom: 0; }
102
102
  .hero { position: relative; overflow: hidden; height: min(78vh, 720px); min-height: 520px; background: #000; border-radius: 16px; }
103
103
  .hero:fullscreen { width: 100%; height: 100%; min-height: 0; border-radius: 0; }
104
104
  .hero-planet { position: absolute; z-index: 1; top: 50%; right: -70%; width: 124%; aspect-ratio: 1; transform: translateY(-50%); pointer-events: none; }
105
- .hero-planet.clip-disc { width: 52%; right: 4%; border-radius: 50%; overflow: hidden; }
106
105
  .hero-planet wakusei-body, .hero-disc wakusei-body { --wakusei-size: 100%; width: 100%; height: 100%; display: block; }
107
106
  .hero-moons { position: absolute; inset: 0; z-index: 2; }
108
107
  .hero-moon { position: absolute; transform: translate(-50%, -50%); display: block; margin: 0; padding: 0; border: 0; background: none; color: #fff; touch-action: manipulation; }
@@ -497,7 +496,6 @@ export class WakuseiMoonPages extends HTMLElement {
497
496
  planet.setAttribute("pitch", String(pose.pitch));
498
497
  this.#textures(planet);
499
498
  const frame = this.#$("#hero-planet");
500
- frame.classList.toggle("clip-disc", host === "jupiter");
501
499
  frame.replaceChildren(planet);
502
500
  const zoom = heroZoom(host);
503
501
  if (zoom !== 1)
@@ -3,15 +3,12 @@ import type { MoonPageHost, PageCard } from "./data.ts";
3
3
  export declare const HERO_ARC: Record<MoonPageHost, readonly string[]>;
4
4
  /** A second, smaller row: the named moons the package draws that are not in the arc. Saturn's list is the small moons of the reference; Methone is not drawn here. None of these has a photo map. */
5
5
  export declare const HERO_SMALL: Record<MoonPageHost, readonly string[]>;
6
- /** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
6
+ /** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Jupiter's and Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe, and the ring is an ellipse. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
7
7
  export declare const HERO_POSE: Record<MoonPageHost, {
8
8
  meridian: number;
9
9
  tilt: number;
10
10
  pitch?: number;
11
11
  }>;
12
- /**
13
- * How far a hero planet is zoomed. A tight portrait fits the rings, and Jupiter's faint rings would shrink the globe to a third of the frame, so Jupiter is zoomed until the globe fills it. Saturn's rings are the picture, and stay at 1.
14
- */
15
12
  export declare function heroZoom(host: MoonPageHost): number;
16
13
  /** One moon of the hero: its name, the disc's width in pixels, and the centre as a percent of the hero. */
17
14
  export interface HeroMoon {
@@ -1,5 +1,3 @@
1
- // The hero above a moon page's tabs: the planet's edge, and its main moons in an arc, farthest at the top. Disc sizes follow the moons' own diameters, squeezed so a small moon stays visible. No DOM.
2
- import { BODIES, ringReach } from "../facts.js";
3
1
  /** The moons in the hero's arc, farthest from the planet first. Jupiter's four are the Galileans. Saturn's seven are the large named moons. */
4
2
  export const HERO_ARC = {
5
3
  jupiter: ["callisto", "ganymede", "europa", "io"],
@@ -14,20 +12,17 @@ export const HERO_SMALL = {
14
12
  uranus: [],
15
13
  neptune: [],
16
14
  };
17
- /** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
15
+ /** Where the painted face is turned, in degrees, so the familiar side of the planet meets the moons. Jupiter's longitude is the package's best-known side, turned so the Great Red Spot sits in the visible half. Jupiter's and Saturn's pitch looks over the pole: the near half of the rings, the one drawn in front of the globe, then crosses the lower part of the globe, and the ring is an ellipse. A negative pitch puts that half on the upper globe and the far half, which the globe hides, on the lower. */
18
16
  export const HERO_POSE = {
19
- jupiter: { meridian: 70, tilt: 14 },
17
+ jupiter: { meridian: 70, tilt: 14, pitch: 22 },
20
18
  saturn: { meridian: 30, tilt: 26.73, pitch: 22 },
21
19
  uranus: { meridian: 10, tilt: 16 },
22
20
  neptune: { meridian: 20, tilt: 16 },
23
21
  };
24
- /**
25
- * How far a hero planet is zoomed. A tight portrait fits the rings, and Jupiter's faint rings would shrink the globe to a third of the frame, so Jupiter is zoomed until the globe fills it. Saturn's rings are the picture, and stay at 1.
26
- */
22
+ /** How far a hero planet is zoomed. 1 frames the globe and its rings, so the ring is the ellipse of the ring plane. Zooming in until the globe filled the frame made Jupiter's wide faint ring the rectangle of the picture. */
23
+ const HERO_ZOOM = { jupiter: 1, saturn: 1, uranus: 1, neptune: 1 };
27
24
  export function heroZoom(host) {
28
- if (host !== "jupiter")
29
- return 1;
30
- return Math.max(1.06, ringReach(BODIES[host]) * 1.04);
25
+ return HERO_ZOOM[host];
31
26
  }
32
27
  /** The hero's moons for one planet, farthest first, in the arc from the upper left down toward the planet's limb. A moon that is not drawn is left out. */
33
28
  export function heroMoons(cards, host, lang) {
@@ -699,9 +699,9 @@ const POSTER_ARC = {
699
699
  uranus: ["oberon", "titania", "umbriel", "ariel", "miranda"],
700
700
  neptune: ["nereid", "triton", "proteus"],
701
701
  };
702
- /** The turn that puts the familiar face toward the moons. Saturn looks over the pole so the near half of the rings crosses the lower globe. */
702
+ /** The turn that puts the familiar face toward the moons. Jupiter and Saturn look over the pole so the near half of the rings crosses the lower globe and the ring is an ellipse. */
703
703
  const POSTER_POSE = {
704
- jupiter: { spin: 70, tilt: 14 },
704
+ jupiter: { spin: 70, tilt: 14, pitch: 22 },
705
705
  saturn: { spin: 30, tilt: 26.73, pitch: 22 },
706
706
  uranus: { spin: 10, tilt: 16 },
707
707
  neptune: { spin: 20, tilt: 16 },
@@ -714,7 +714,7 @@ function posterEdge(host) {
714
714
  const sized = sizesFor(moons, "readable");
715
715
  const moonScale = (count <= 4 ? 0.2 : 0.13) / Math.max(...sized);
716
716
  const pose = POSTER_POSE[host];
717
- const planetR = host === "jupiter" ? 0.72 : 0.82 / reachOf(host);
717
+ const planetR = 0.82 / reachOf(host);
718
718
  const planet = {
719
719
  body: host,
720
720
  x: aspect * 0.92 - planetR * 0.15,
@@ -54,6 +54,7 @@ export interface BodyScene extends Scene3D {
54
54
  text: string;
55
55
  turn: number;
56
56
  look: string;
57
+ shell: number;
57
58
  } | null;
58
59
  }
59
60
  export interface BodyItemOptions {
@@ -2,7 +2,7 @@ import { BODIES } from "../facts.js";
2
2
  import { silhouette } from "../pose.js";
3
3
  import { cross } from "../vec.js";
4
4
  import { BALL_FRAGMENT, bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_DETAIL, RING_VERTEX, STAR_GLOW_FRAGMENT, VERTEX } from "./glsl.js";
5
- import { detailOf, lookOf } from "./look.js";
5
+ import { atmosphereTint, detailOf, lookOf } from "./look.js";
6
6
  import { shapeGeometry } from "./shape.js";
7
7
  import { createDetail } from "./detail.js";
8
8
  import { fallbackLook } from "./fallback.js";
@@ -10,7 +10,7 @@ import { writeBasis } from "./basis.js";
10
10
  import { interiorOf } from "../interior.js";
11
11
  import { loadImage } from "./textures.js";
12
12
  import { ringStrip } from "./rings.js";
13
- import { createNameLabel } from "./name-label.js";
13
+ import { createNameLabel, shapeReach } from "./name-label.js";
14
14
  export { fallbackLook } from "./fallback.js";
15
15
  /** The shader material of a body: its surface code with the look's lighting and glow uniforms. A star made from numbers is drawn with it too (the size line-up). */
16
16
  export function makeBodyMaterial(T, look, painted) {
@@ -35,7 +35,7 @@ export function makeBodyMaterial(T, look, painted) {
35
35
  uAmbient: { value: look.ambient ?? 0.04 },
36
36
  uLimb: { value: look.limb ?? 0 },
37
37
  uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
38
- uAtmos: { value: new T.Vector3(...(a?.colour ?? [0, 0, 0])) },
38
+ uAtmos: { value: new T.Vector3(...atmosphereTint(a)) },
39
39
  uAtmosPow: { value: a?.power ?? 3 },
40
40
  uRimBase: { value: 0.12 },
41
41
  uEmissive: { value: look.emissive === true ? 1 : 0 },
@@ -419,6 +419,10 @@ export function createBodyItem(options) {
419
419
  if (label === undefined) {
420
420
  label = createNameLabel(T, state.label.text, state.label, look.emissive === true, () => options.redraw(), facts.colour);
421
421
  mesh.add(label.object);
422
+ // a lumpy shape (Thebe, Amalthea, Phobos) stands out past the sphere the name is written on in places: the name is written on the shell that clears its highest point, so no letter is hidden inside the surface
423
+ const reach = shapeReach(geometry);
424
+ if (reach > 1.002)
425
+ label.object.scale.setScalar(reach);
422
426
  }
423
427
  else {
424
428
  label.set(state.label.text, state.label);
@@ -499,7 +503,7 @@ export function createBodyItem(options) {
499
503
  },
500
504
  get label() {
501
505
  const inner = label?.object.children[0];
502
- return label === undefined || latest.label === undefined || latest.label === null ? null : { shown: label.ready && inner !== undefined && inner.visible, text: latest.label.text, turn: inner?.rotation.y ?? 0, look: label.look };
506
+ return label === undefined || latest.label === undefined || latest.label === null ? null : { shown: label.ready && inner !== undefined && inner.visible, text: latest.label.text, turn: inner?.rotation.y ?? 0, look: label.look, shell: label.object.scale.x };
503
507
  },
504
508
  resize(w, h) {
505
509
  viewWidth = w;
@@ -170,7 +170,9 @@ ${world ? ` for (int i = 0; i < 6; i++) {
170
170
  vec3 alb = pow(s.rgb, vec3(2.2));
171
171
  vec3 lit = alb * (uAmbient + (1.0 - uAmbient) * diff * 1.18);
172
172
  float rim = pow(1.0 - mu, uAtmosPow);
173
- lit += pow(uAtmos, vec3(2.2)) * rim * (uRimBase + (1.0 - uRimBase) * clamp(dg * 1.6 + 0.35, 0.0, 1.0));
173
+ // the extra haze stops at the terminator: the old +0.35 stayed bright a little way onto the night side and drew a lighter strip beside the line
174
+ float dayRim = clamp(dg * 1.6 + 0.35, 0.0, 1.0) * smoothstep(-0.02, 0.08, dg);
175
+ lit += pow(uAtmos, vec3(2.2)) * rim * (uRimBase + (1.0 - uRimBase) * dayRim);
174
176
  lit *= mix(1.0, pow(mu, 0.45), uLimb);
175
177
  gl_FragColor = vec4(pow(lit, vec3(1.0 / 2.2)), 1.0);
176
178
  }`;
@@ -15,6 +15,7 @@ export { shapeRadii, type ShapeTable } from "./shape.ts";
15
15
  */
16
16
  export interface Atmosphere {
17
17
  colour: readonly [number, number, number];
18
+ /** How much of `colour` the limb adds, from 0 to 1. The shader draws `colour` times this. */
18
19
  strength: number;
19
20
  /** How thin the rim is: higher is thinner. Default 3. */
20
21
  power?: number;
@@ -136,6 +137,20 @@ export declare function detailOf(look: BodyLook): {
136
137
  amount: number;
137
138
  stretch: number;
138
139
  };
140
+ /**
141
+ * The haze colour a body is drawn with: its atmosphere colour at `strength`, or black when it has none.
142
+ *
143
+ * @param atmosphere - The body's atmosphere, if it has one.
144
+ * @returns The colour the limb adds, each channel from 0 to 1.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * import { atmosphereTint } from "@johnmorrisdotca/wakusei-planets/look";
149
+ *
150
+ * console.log(atmosphereTint({ colour: [0.6, 0.7, 0.9], strength: 0.12 }));
151
+ * ```
152
+ */
153
+ export declare function atmosphereTint(atmosphere: Atmosphere | undefined): [number, number, number];
139
154
  /**
140
155
  * Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
141
156
  *
@@ -30,6 +30,25 @@ export function detailOf(look) {
30
30
  const own = SMOOTH[look.id];
31
31
  return { amount: look.detail?.amount ?? own?.amount ?? 0.32, stretch: look.detail?.stretch ?? own?.stretch ?? 1 };
32
32
  }
33
+ /**
34
+ * The haze colour a body is drawn with: its atmosphere colour at `strength`, or black when it has none.
35
+ *
36
+ * @param atmosphere - The body's atmosphere, if it has one.
37
+ * @returns The colour the limb adds, each channel from 0 to 1.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { atmosphereTint } from "@johnmorrisdotca/wakusei-planets/look";
42
+ *
43
+ * console.log(atmosphereTint({ colour: [0.6, 0.7, 0.9], strength: 0.12 }));
44
+ * ```
45
+ */
46
+ export function atmosphereTint(atmosphere) {
47
+ if (atmosphere === undefined)
48
+ return [0, 0, 0];
49
+ const strength = atmosphere.strength;
50
+ return [atmosphere.colour[0] * strength, atmosphere.colour[1] * strength, atmosphere.colour[2] * strength];
51
+ }
33
52
  /**
34
53
  * Teach the package how to draw a body in three.js. Each body's entry point (`@johnmorrisdotca/wakusei-planets/jupiter`) calls this once as it loads; call it yourself to add or replace a look.
35
54
  *
@@ -177,3 +177,13 @@ export declare function setBodyLabelFontUrl(url: string | URL): void;
177
177
  * @param squeeze - The uniforms a body drawn round shares with its name (see `round.ts`), so the name is squeezed with the globe. Left out, the name is not squeezed.
178
178
  */
179
179
  export declare function createNameLabel(T: ThreeParts, text: string, options: NameLabelOptions, emissive: boolean, onReady: () => void, colour?: string, squeeze?: RoundUniforms): NameLabel;
180
+ /**
181
+ * The turn about the pole, in radians, that keeps a whole name on the side facing the camera. Zero when it is already clear of the limb. The name that faces the camera best is the one that moves,
182
+ * and only as far as its corners need, so a name that sits on the front still turns with the body. `camera` is in the shared label's frame (longitude 0 along +x, east towards -z).
183
+ */
184
+ export declare function nameClearYaw(x: number, y: number, z: number, latitude: number, height: number, spans: readonly {
185
+ centre: number;
186
+ width: number;
187
+ }[]): number;
188
+ /** How far the highest point of a body's mesh is from its centre, in the mesh's own units (1 for a plain sphere): the radius of the smallest shell that clears the whole surface. */
189
+ export declare function shapeReach(geometry: THREE.BufferGeometry): number;
@@ -226,6 +226,7 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
226
226
  let disposed = false;
227
227
  let ready = false;
228
228
  const light = new T.Vector3(0, 0, 1);
229
+ const eye = new T.Vector3();
229
230
  const able = hasLabelParts(T) && canDraw();
230
231
  if (!able && !warned && canDraw()) {
231
232
  warned = true;
@@ -266,7 +267,22 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
266
267
  u.uLight.value.copy(light);
267
268
  u.uOpacity.value = m.opacity;
268
269
  }
269
- return label.update((camera ?? FAR_EYE), radiusPx);
270
+ const changed = label.update((camera ?? FAR_EYE), radiusPx);
271
+ // a name that turns with the body runs off the limb and the planet cuts the letters: slide it, only as far as it needs, so the whole word stays on the near side
272
+ if (wanted.options.facing || camera === undefined)
273
+ return changed;
274
+ const mesh = label.object;
275
+ const parent = mesh.parent;
276
+ if (parent === null)
277
+ return changed;
278
+ camera.getWorldPosition(eye);
279
+ parent.updateWorldMatrix(true, false);
280
+ parent.worldToLocal(eye);
281
+ const yaw = nameClearYaw(eye.x, eye.y, eye.z, label.layout.latitude, label.layout.height, label.layout.spans);
282
+ if (Math.abs(mesh.rotation.y - yaw) <= 1e-4)
283
+ return changed;
284
+ mesh.rotation.y = yaw;
285
+ return true;
270
286
  },
271
287
  set(nextText, next) {
272
288
  wanted = { text: nextText, options: shared(next) };
@@ -298,3 +314,79 @@ export function createNameLabel(T, text, options, emissive, onReady, colour, squ
298
314
  function withoutUndefined(value) {
299
315
  return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
300
316
  }
317
+ /** How far inside the limb a letter must stay, as a dot with the direction to the camera: about 56 degrees from the centre of the disc, so a letter is read face-on and not shaved off at the edge. */
318
+ const NAME_CLEAR = 0.55;
319
+ const pointOnBand = (latitude, longitude) => {
320
+ const lat = (latitude * Math.PI) / 180;
321
+ const lon = (longitude * Math.PI) / 180;
322
+ const ring = Math.cos(lat);
323
+ return [ring * Math.cos(lon), Math.sin(lat), -ring * Math.sin(lon)];
324
+ };
325
+ const turnedAboutPole = (point, yaw) => {
326
+ const c = Math.cos(yaw);
327
+ const s = Math.sin(yaw);
328
+ return [point[0] * c + point[2] * s, point[1], -point[0] * s + point[2] * c];
329
+ };
330
+ /** The smallest dot a name's four corners make with the camera, after a turn `yaw` about the pole. */
331
+ const nameCornerDot = (camera, latitude, centre, halfWidth, halfHeight, yaw) => {
332
+ let least = Infinity;
333
+ for (const longitude of [centre - halfWidth, centre + halfWidth]) {
334
+ for (const band of [latitude - halfHeight, latitude + halfHeight]) {
335
+ const point = turnedAboutPole(pointOnBand(band, longitude), yaw);
336
+ least = Math.min(least, point[0] * camera[0] + point[1] * camera[1] + point[2] * camera[2]);
337
+ }
338
+ }
339
+ return least;
340
+ };
341
+ /**
342
+ * The turn about the pole, in radians, that keeps a whole name on the side facing the camera. Zero when it is already clear of the limb. The name that faces the camera best is the one that moves,
343
+ * and only as far as its corners need, so a name that sits on the front still turns with the body. `camera` is in the shared label's frame (longitude 0 along +x, east towards -z).
344
+ */
345
+ export function nameClearYaw(x, y, z, latitude, height, spans) {
346
+ const length = Math.hypot(x, y, z);
347
+ if (length < 1e-8 || spans.length === 0)
348
+ return 0;
349
+ const camera = [x / length, y / length, z / length];
350
+ let span = spans[0];
351
+ let facingDot = -Infinity;
352
+ for (const one of spans) {
353
+ const point = pointOnBand(latitude, one.centre);
354
+ const dot = point[0] * camera[0] + point[1] * camera[1] + point[2] * camera[2];
355
+ if (dot > facingDot) {
356
+ facingDot = dot;
357
+ span = one;
358
+ }
359
+ }
360
+ const halfWidth = span.width / 2;
361
+ const halfHeight = height / 2;
362
+ if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, 0) >= NAME_CLEAR)
363
+ return 0;
364
+ const cameraLongitude = Math.atan2(-camera[2], camera[0]);
365
+ const toward = cameraLongitude - (span.centre * Math.PI) / 180;
366
+ const facing = Math.atan2(Math.sin(toward), Math.cos(toward));
367
+ if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, facing) < NAME_CLEAR)
368
+ return facing;
369
+ let near = 0;
370
+ let far = 1;
371
+ for (let step = 0; step < 16; step += 1) {
372
+ const mid = (near + far) / 2;
373
+ if (nameCornerDot(camera, latitude, span.centre, halfWidth, halfHeight, mid * facing) >= NAME_CLEAR)
374
+ far = mid;
375
+ else
376
+ near = mid;
377
+ }
378
+ return far * facing;
379
+ }
380
+ const reaches = new WeakMap();
381
+ /** How far the highest point of a body's mesh is from its centre, in the mesh's own units (1 for a plain sphere): the radius of the smallest shell that clears the whole surface. */
382
+ export function shapeReach(geometry) {
383
+ let reach = reaches.get(geometry);
384
+ if (reach === undefined) {
385
+ const at = geometry.getAttribute("position");
386
+ reach = 1;
387
+ for (let i = 0; i < at.count; i += 1)
388
+ reach = Math.max(reach, Math.hypot(at.getX(i), at.getY(i), at.getZ(i)));
389
+ reaches.set(geometry, reach);
390
+ }
391
+ return reach;
392
+ }
@@ -162,12 +162,13 @@ export interface Painting {
162
162
  readonly tiles?: DetailStats;
163
163
  /** Write the body's name on its globe, change how, or take it off (`null`). The name is drawn when the font is in, and `context.invalidate` is called then. */
164
164
  setLabel(label: PaintLabel | null): void;
165
- /** The name on the globe now: whether one is drawn (made and big enough on the screen at the last `update`), the text, and the group's turn about the pole in radians (for `facing`). */
165
+ /** The name on the globe now: whether one is drawn (made and big enough on the screen at the last `update`), the text, and the group's turn about the pole in radians (for `facing`), and `shell`, the radius of the shell the name is written on in the mesh's units (1 on a smooth globe, more on a lumpy moon). */
166
166
  readonly label: {
167
167
  shown: boolean;
168
168
  text: string;
169
169
  turn: number;
170
170
  look: string;
171
+ shell: number;
171
172
  } | null;
172
173
  dispose(): void;
173
174
  }
@@ -9,12 +9,12 @@ import { cross } from "../vec.js";
9
9
  import { bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_WORLD, RING_VERTEX_WORLD, VERTEX_WORLD } from "./glsl.js";
10
10
  import { fallbackLook } from "./fallback.js";
11
11
  import { createDetail } from "./detail.js";
12
- import { detailOf, lookOf } from "./look.js";
12
+ import { atmosphereTint, detailOf, lookOf } from "./look.js";
13
13
  import { shapeGeometry } from "./shape.js";
14
14
  import { seenRegion } from "./tiles.js";
15
15
  import { moonOffset, orientation } from "./orient.js";
16
16
  import { ringStrip } from "./rings.js";
17
- import { createNameLabel, nameLabelText } from "./name-label.js";
17
+ import { createNameLabel, nameLabelText, shapeReach } from "./name-label.js";
18
18
  import { roundShape } from "./round.js";
19
19
  let pictureLoads = 0;
20
20
  /**
@@ -154,7 +154,7 @@ function paint(T, id, context, bases, hold) {
154
154
  uAmbient: { value: look.ambient ?? 0.04 },
155
155
  uLimb: { value: look.limb ?? 0 },
156
156
  uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
157
- uAtmos: { value: new T.Vector3(...(a?.colour ?? [0, 0, 0])) },
157
+ uAtmos: { value: new T.Vector3(...atmosphereTint(a)) },
158
158
  uAtmosPow: { value: a?.power ?? 3 },
159
159
  uRimBase: { value: 0.12 },
160
160
  uEmissive: { value: look.emissive === true ? 1 : 0 },
@@ -411,7 +411,7 @@ function paint(T, id, context, bases, hold) {
411
411
  let labelText = "";
412
412
  let labelShown = false;
413
413
  // what `label` reports: one object, written at each draw (it is read for every body at every frame)
414
- const labelReport = { shown: false, text: "", turn: 0, look: "" };
414
+ const labelReport = { shown: false, text: "", turn: 0, look: "", shell: 1 };
415
415
  const setLabel = (next) => {
416
416
  if (next === null || next === undefined || gone) {
417
417
  if (label !== undefined) {
@@ -502,6 +502,10 @@ function paint(T, id, context, bases, hold) {
502
502
  }
503
503
  keepSized(info.radiusPx);
504
504
  if (label !== undefined) {
505
+ // a lumpy shape stands out past the sphere the name is written on: the shell clears its highest point
506
+ labelReport.shell = shapeReach(mesh.geometry);
507
+ if (labelReport.shell > 1.002 || label.object.scale.x !== 1)
508
+ label.object.scale.setScalar(Math.max(1, labelReport.shell));
505
509
  label.update(info.view?.camera, info.radiusPx, info.toSun);
506
510
  const inner = label.object.children[0];
507
511
  labelShown = inner !== undefined && inner.visible;
@@ -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.75.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.75.1/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.75.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.75.1/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.
@@ -606,6 +606,20 @@ export declare class WakuseiSpace extends HTMLElement {
606
606
  }, final?: boolean, reason?: string): void;
607
607
  /** The body the camera looks at: any body the view places, by name in any case (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`, and the moons of the planets such as `titan`). At zoom 1 it fills the view; the yaw and tilt turn the camera round it. Setting it moves the camera there at once and keeps the zoom; `goTo` glides and brings the body into view. */
608
608
  get body(): BodyId;
609
+ /**
610
+ * The body the camera is at, which is `body` unless `turnTo` has turned the view to another body from where the camera stands: then `body` is the body looked at and `at` is the one the camera is still at, so a page can tell "looking at" from "at".
611
+ * It follows `body` the moment the camera goes anywhere (`goTo`, setting `body`, a hop).
612
+ *
613
+ * @example
614
+ * ```ts no-run
615
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
616
+ *
617
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
618
+ * space.turnTo("mars", { smooth: false });
619
+ * console.log(space.body, space.at);
620
+ * ```
621
+ */
622
+ get at(): BodyId;
609
623
  set body(name: BodyId | string);
610
624
  /** What the hopper can do from where it is: the body at the middle, and the bodies the previous and next hop lead to. */
611
625
  get hopper(): {
@@ -651,7 +665,7 @@ export declare class WakuseiSpace extends HTMLElement {
651
665
  /**
652
666
  * Turn the camera where it stands until a body is in the picture, by the least turn: no move of the camera's place, only the way it looks. A body is in the picture when its middle is inside the picture less `margin` of
653
667
  * each side (the left and right margins are `margin` of the width, the top and bottom `margin` of the height; 0.15 by default, 0 to 0.45). One already so is left alone and the answer is `false`, as it is for an id the
654
- * view does not know, the body already looked at, and a view that is riding. The body becomes the one looked at: the camera stays at its place and looks at it, from as far
668
+ * view does not know, the body already looked at, and a view that is riding (a camera beside the Moon in a ride is not turned: ride off first). The body becomes the one looked at (`body`) while `at` still names the body the camera stands at: the camera stays at its place and looks at it, from as far
655
669
  * as it stands (the zoom is worked out from that distance, inside the controls' limits; a body so far that the zoom's limit would move the camera is not turned to). It glides the way a move does, or at once with
656
670
  * `smooth: false` or for a reader who prefers reduced motion; nothing is drawn at rest and one draw more at most ends it.
657
671
  *