@johnmorrisdotca/wakusei-planets 0.72.0 → 0.74.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/dist/element.js CHANGED
@@ -19,6 +19,7 @@ export { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE } from "./scene/textures.js"
19
19
  import { mapWidthOf, ringWidthOf, zoomLimit } from "./scene/reach.js";
20
20
  import { viewPose } from "./scene/tumble.js";
21
21
  import { createBodyItem } from "./scene/body.js";
22
+ import { estimatedRock, estimatedRockLine } from "./scene/estimated-rock.js";
22
23
  import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } from "./scene/name-label.js";
23
24
  import { delegates, onRegister } from "./scene/store.js";
24
25
  import { setThreeLoader, takeRenderer } from "./scene/shared.js";
@@ -72,13 +73,17 @@ const TEMPLATE = `<style>
72
73
  #cutaway li { display: grid; grid-template-columns: 12px 1fr; gap: 2px 8px; align-items: baseline; }
73
74
  #cutaway [data-swatch] { width: 12px; height: 12px; }
74
75
  #stage svg { display: block; width: 100%; height: 100%; }
75
- </style><div id="stage"></div><ol id="cutaway" hidden></ol>`;
76
+ #estimate { position: absolute; z-index: 2; left: 2px; right: 2px; bottom: 1px; margin: 0; max-height: 2.4em; overflow: hidden; text-align: center; font: 10px/1.2 system-ui, sans-serif; color: inherit; pointer-events: none; }
77
+ #estimate[hidden] { display: none; }
78
+ :host([data-shape="estimated"]) #stage { bottom: 22px; }
79
+ </style><div id="stage"></div><p id="estimate" hidden></p><ol id="cutaway" hidden></ol>`;
76
80
  /**
77
81
  * The `<wakusei-body>` custom element: a body of the solar system, drawn in a look.
78
82
  *
79
83
  * Attributes: `body` (a name, such as `jupiter`), `look` (`line`, `realistic` or `painted`), `size` (pixels across), `time` (`now` or an ISO date: the body as the Earth sees it then; leave it out for a portrait),
80
84
  * `tilt`, `pitch`, `phase` and `meridian` (a portrait's pose, degrees), `turn` (a portrait turns this many degrees a second; left out, 12 a second, backwards when the body is, and a date keeps its orientation and adds this turn; `live="off"` stays still unless this is set; `0` stays still; reduced motion keeps a quarter of it), `rate` (simulated seconds for each real second), `moons` (draw the planet's moons on their orbits),
81
85
  * `range` (planet radii the moons picture reaches), `scale-to` (draw to scale with another body), `span-km` (draw to scale: the half-width of the picture in kilometres, the same in every picture of a lineup), `live` (`always`, `hover` or `off`: when it takes the page's one WebGL context), `texture-base` (where the surface pictures are) and `lang` (`en` or `ja`).
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.
82
87
  *
83
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.
84
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.
@@ -686,9 +691,18 @@ export class WakuseiBody extends HTMLElement {
686
691
  }
687
692
  return this.#starMade;
688
693
  }
689
- /** The facts of what is drawn: the body's, or the star's (the Sun's with its own size, shape and outlines). */
694
+ /** A catalogue moon this element draws as an estimated rock, or `null` when `body` is a body the package draws in full (or not a moon). */
695
+ #estimate() {
696
+ if (this.hasAttribute("star"))
697
+ return null;
698
+ const id = this.getAttribute("body");
699
+ if (id === null || id in BODIES)
700
+ return null;
701
+ return estimatedRock(id);
702
+ }
703
+ /** The facts of what is drawn: the body's, the star's (the Sun's with its own size, shape and outlines), or an estimated rock's. */
690
704
  #facts() {
691
- return this.#star()?.facts ?? BODIES[this.body];
705
+ return this.#star()?.facts ?? this.#estimate()?.facts ?? BODIES[this.body];
692
706
  }
693
707
  // --- the clock ------------------------------------------------------------------------------------------------------------------------------------
694
708
  #clockFromAttributes() {
@@ -793,7 +807,7 @@ export class WakuseiBody extends HTMLElement {
793
807
  #limits() {
794
808
  if (this.look === "line")
795
809
  return LINE_LIMITS;
796
- if (this.hasAttribute("star"))
810
+ if (this.hasAttribute("star") || this.#estimate() !== null)
797
811
  return { zoomMin: 0.1, zoomMax: zoomLimit(1, 0, false), tiltMax: 90 };
798
812
  const moons = this.hasAttribute("moons");
799
813
  const look = lookOf(this.body);
@@ -901,7 +915,7 @@ export class WakuseiBody extends HTMLElement {
901
915
  }
902
916
  /** The picture's identity: a new one disposes the view and builds it again, so a cutaway gives its shells back when it is turned off. */
903
917
  #signature() {
904
- return `${this.#star()?.key ?? this.body}|${this.look}|${this.#cutawayOn() ? "cut" : "whole"}`;
918
+ return `${this.#star()?.key ?? this.#estimate()?.id ?? this.body}|${this.look}|${this.#cutawayOn() ? "cut" : "whole"}`;
905
919
  }
906
920
  #cutawayOn() {
907
921
  const value = this.getAttribute("cutaway");
@@ -953,6 +967,7 @@ export class WakuseiBody extends HTMLElement {
953
967
  if (!this.isConnected)
954
968
  return;
955
969
  this.#syncLegend();
970
+ this.#syncEstimate();
956
971
  this.setAttribute("aria-label", this.#label());
957
972
  if (this.hasAttribute("size"))
958
973
  this.style.setProperty("--wakusei-size", `${num(this.getAttribute("size"), 320)}px`);
@@ -962,7 +977,7 @@ export class WakuseiBody extends HTMLElement {
962
977
  this.#set("line");
963
978
  return;
964
979
  }
965
- const delegate = this.look === "line" ? delegates.get(this.body) : undefined;
980
+ const delegate = this.#estimate() === null && this.look === "line" ? delegates.get(this.body) : undefined;
966
981
  if (delegate !== undefined && (await this.#delegated(delegate)))
967
982
  return;
968
983
  const undelegated = this.#delegateEl !== undefined;
@@ -1018,9 +1033,36 @@ export class WakuseiBody extends HTMLElement {
1018
1033
  this.addEventListener(name, this.#hover);
1019
1034
  }
1020
1035
  }
1036
+ #syncEstimate() {
1037
+ const rock = this.#estimate();
1038
+ const note = this.shadowRoot?.querySelector("#estimate");
1039
+ if (rock === null) {
1040
+ this.removeAttribute("data-shape");
1041
+ this.removeAttribute("data-size");
1042
+ this.removeAttribute("data-estimated");
1043
+ if (note instanceof HTMLElement) {
1044
+ note.hidden = true;
1045
+ note.textContent = "";
1046
+ }
1047
+ return;
1048
+ }
1049
+ this.dataset.shape = "estimated";
1050
+ this.dataset.size = rock.sizeFrom;
1051
+ this.dataset.estimated = rock.id;
1052
+ if (note instanceof HTMLElement) {
1053
+ note.hidden = false;
1054
+ note.textContent = this.getAttribute("lang") === "ja" ? rock.line.ja : rock.line.en;
1055
+ note.title = this.getAttribute("lang") === "ja" ? rock.legend.ja : rock.legend.en;
1056
+ }
1057
+ }
1021
1058
  #label() {
1022
1059
  const star = this.#star();
1023
1060
  const ja = this.getAttribute("lang") === "ja";
1061
+ const rock = this.#estimate();
1062
+ if (rock !== null) {
1063
+ const note = ja ? rock.note.ja : rock.note.en;
1064
+ return ja ? `${rock.label}。${note}` : `${rock.label}. ${note}`;
1065
+ }
1024
1066
  if (star !== undefined)
1025
1067
  return this.look === "line" ? (ja ? `${star.facts.name.ja}の線画。${star.disclaimer.ja}` : `${star.facts.name.en}, line drawing. ${star.disclaimer.en}`) : ja ? `${star.facts.name.ja}の陰影つきの絵。${star.disclaimer.ja}` : `${star.facts.name.en}, shaded star. ${star.disclaimer.en}`;
1026
1068
  const f = BODIES[this.body];
@@ -1028,6 +1070,11 @@ export class WakuseiBody extends HTMLElement {
1028
1070
  return ja ? `${f.name.ja}の${looks[this.look]}` : `${f.name.en}, ${looks[this.look]}`;
1029
1071
  }
1030
1072
  #drawLine() {
1073
+ const rock = this.#estimate();
1074
+ if (rock !== null) {
1075
+ this.#stage.innerHTML = estimatedRockLine(rock, 480);
1076
+ return;
1077
+ }
1031
1078
  const r = this.#request();
1032
1079
  const frame = this.#frameNow();
1033
1080
  const scaleTo = this.getAttribute("scale-to");
@@ -1052,7 +1099,7 @@ export class WakuseiBody extends HTMLElement {
1052
1099
  }
1053
1100
  #key(state) {
1054
1101
  const moons = (state.moons ?? []).map((m) => `${m.id}:${m.x.toFixed(1)},${m.y.toFixed(1)}`).join(";");
1055
- return `${this.#star()?.key ?? this.body}|${this.look}|${vectorKey(state.pose.pole)}|${vectorKey(state.pose.meridian)}|${vectorKey(state.pose.light)}|${state.extent.toFixed(2)}|${state.zoom.toFixed(2)}|${state.panX.toFixed(2)},${state.panY.toFixed(2)}|${moons}|${this.#labelKey()}`;
1102
+ return `${this.#star()?.key ?? this.#estimate()?.id ?? this.body}|${this.look}|${vectorKey(state.pose.pole)}|${vectorKey(state.pose.meridian)}|${vectorKey(state.pose.light)}|${state.extent.toFixed(2)}|${state.zoom.toFixed(2)}|${state.panX.toFixed(2)},${state.panY.toFixed(2)}|${moons}|${this.#labelKey()}`;
1056
1103
  }
1057
1104
  // Replacing a view keeps the renderer lease; leaving 3D gives it back.
1058
1105
  #disposeView(releaseRenderer = false) {
@@ -1084,11 +1131,12 @@ export class WakuseiBody extends HTMLElement {
1084
1131
  this.#stilled = false;
1085
1132
  this.#stage.innerHTML = "";
1086
1133
  const star = this.#star();
1134
+ const rock = this.#estimate();
1087
1135
  const item = createBodyItem({
1088
1136
  id: this.body,
1089
- ...(star === undefined ? {} : { shaded: star.look, facts: star.facts, assetKey: `star:${star.key}` }),
1137
+ ...(star !== undefined ? { shaded: star.look, facts: star.facts, assetKey: `star:${star.key}` } : rock === null ? {} : { shaded: rock.look, facts: rock.facts, assetKey: `rock:${rock.id}`, coarse: true }),
1090
1138
  look: this.look === "illustrated" ? "realistic" : "painted",
1091
- cutaway: this.#cutawayOn(),
1139
+ cutaway: rock === null && this.#cutawayOn(),
1092
1140
  onShells: (count) => {
1093
1141
  this.dataset.shells = String(count);
1094
1142
  },
@@ -0,0 +1,20 @@
1
+ /** The nine the count grid draws, in solar-system order. Pluto is last, as on the poster. */
2
+ export declare const MOON_COUNT_IDS: readonly ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
3
+ export type MoonCountId = (typeof MOON_COUNT_IDS)[number];
4
+ export interface MoonCountRow {
5
+ id: MoonCountId;
6
+ name: {
7
+ en: string;
8
+ ja: string;
9
+ };
10
+ /** Moons in the catalogue. Zero when the host has no entry. */
11
+ total: number;
12
+ /** True for every row that shares the highest count, and only when that count is at least one. */
13
+ most: boolean;
14
+ }
15
+ /** One row per painted planet, solar-system order, counts from `moonCounts()`. */
16
+ export declare function moonCountGrid(): MoonCountRow[];
17
+ /** Where a tile goes. A giant planet opens its moon page. The others have no moon page, so the tile opens that body on the demo. */
18
+ export declare function moonCountHref(id: MoonCountId): string;
19
+ /** The day the moon catalogue was read. The grid says so, because the counts change. */
20
+ export declare const MOON_COUNT_READ: string;
@@ -0,0 +1,24 @@
1
+ // Who has the most moons: the planets the package already paints, Mercury through Pluto, with each one's count taken from the moon catalogue. A host the catalogue does not list has none. No DOM.
2
+ import { BODIES } from "./facts.js";
3
+ import { MOON_CATALOGUE_FETCHED, moonCounts } from "./moon-catalogue.js";
4
+ import { MOON_PAGE_HOSTS } from "./moon-pages/data.js";
5
+ /** The nine the count grid draws, in solar-system order. Pluto is last, as on the poster. */
6
+ export const MOON_COUNT_IDS = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
7
+ /** One row per painted planet, solar-system order, counts from `moonCounts()`. */
8
+ export function moonCountGrid() {
9
+ const counts = moonCounts();
10
+ const rows = MOON_COUNT_IDS.map((id) => ({
11
+ id,
12
+ name: { en: BODIES[id].name.en, ja: BODIES[id].name.ja },
13
+ total: counts[id]?.total ?? 0,
14
+ most: false,
15
+ }));
16
+ const max = Math.max(...rows.map((row) => row.total));
17
+ return rows.map((row) => ({ ...row, most: max > 0 && row.total === max }));
18
+ }
19
+ /** Where a tile goes. A giant planet opens its moon page. The others have no moon page, so the tile opens that body on the demo. */
20
+ export function moonCountHref(id) {
21
+ return MOON_PAGE_HOSTS.includes(id) ? `${id}.html` : `index.html?body=${id}`;
22
+ }
23
+ /** The day the moon catalogue was read. The grid says so, because the counts change. */
24
+ export const MOON_COUNT_READ = MOON_CATALOGUE_FETCHED;
@@ -0,0 +1,19 @@
1
+ import { MOON_PAGE_HOSTS, type MoonPageHost } from "./moon-pages/data.ts";
2
+ /** How high an IAU number the column keeps. XVI is the last moon on the Jupiter reference. */
3
+ export declare const MOON_DOT_LIMIT = 16;
4
+ /** The value of a Roman numeral, or null when the text is not one. */
5
+ export declare function romanValue(text: string): number | null;
6
+ export interface MoonDot {
7
+ id: string;
8
+ label: string;
9
+ ja: string | null;
10
+ radiusKm: number | null;
11
+ /** True when the radius is derived from a magnitude, not measured. */
12
+ estimate: boolean;
13
+ distanceKm: number;
14
+ /** The drawn diameter in pixels. A moon with no size gets the smallest dot. */
15
+ px: number;
16
+ }
17
+ /** The moons numbered I to XVI, nearest the planet first. A dot's pixels follow the radius, with a floor so a small moon stays visible. */
18
+ export declare function moonDotColumn(host: MoonPageHost): MoonDot[];
19
+ export { MOON_PAGE_HOSTS };
@@ -0,0 +1,41 @@
1
+ // A planet's edge and a column of dots: the moons numbered I to XVI, nearest first, each dot sized by its diameter. No pictures of the moons, and no DOM.
2
+ import { catalogueMoonsOf } from "./moon-catalogue.js";
3
+ import { MOON_PAGE_HOSTS } from "./moon-pages/data.js";
4
+ /** How high an IAU number the column keeps. XVI is the last moon on the Jupiter reference. */
5
+ export const MOON_DOT_LIMIT = 16;
6
+ const ROMAN = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
7
+ /** The value of a Roman numeral, or null when the text is not one. */
8
+ export function romanValue(text) {
9
+ if (!/^[IVXLCDM]+$/.test(text))
10
+ return null;
11
+ let total = 0;
12
+ let prev = 0;
13
+ for (const ch of [...text].reverse()) {
14
+ const value = ROMAN[ch] ?? 0;
15
+ total += value < prev ? -value : value;
16
+ prev = Math.max(prev, value);
17
+ }
18
+ return total;
19
+ }
20
+ /** The moons numbered I to XVI, nearest the planet first. A dot's pixels follow the radius, with a floor so a small moon stays visible. */
21
+ export function moonDotColumn(host) {
22
+ const chosen = catalogueMoonsOf(host).flatMap((moon) => {
23
+ if (moon.number === null)
24
+ return [];
25
+ const n = romanValue(moon.number);
26
+ if (n === null || n < 1 || n > MOON_DOT_LIMIT)
27
+ return [];
28
+ return [moon];
29
+ });
30
+ const max = Math.max(1, ...chosen.map((moon) => moon.radiusKm ?? 0));
31
+ return chosen.map((moon) => ({
32
+ id: moon.id,
33
+ label: moon.label,
34
+ ja: moon.ja,
35
+ radiusKm: moon.radiusKm,
36
+ estimate: moon.radiusFrom === "derived",
37
+ distanceKm: moon.orbit?.a ?? 0,
38
+ px: moon.radiusKm === null ? 8 : Math.max(8, Math.round(72 * (moon.radiusKm / max))),
39
+ }));
40
+ }
41
+ export { MOON_PAGE_HOSTS };
@@ -0,0 +1,24 @@
1
+ import { MOON_PAGE_HOSTS, type MoonPageHost } from "./moon-pages/data.ts";
2
+ export { MOON_PAGE_HOSTS };
3
+ export interface GroupMoon {
4
+ id: string;
5
+ /** Where it sits in the list, from 1, in family order. */
6
+ number: number;
7
+ /** The name to print. An estimated rock already carries the star. */
8
+ line: {
9
+ en: string;
10
+ ja: string;
11
+ };
12
+ estimated: boolean;
13
+ }
14
+ export interface MoonGroup {
15
+ id: string;
16
+ name: {
17
+ en: string;
18
+ ja: string;
19
+ };
20
+ count: number;
21
+ moons: GroupMoon[];
22
+ }
23
+ /** The families of one giant planet, in list order, every catalogue moon once. Numbers run through that order. */
24
+ export declare function moonGroupPoster(host: MoonPageHost): MoonGroup[];
@@ -0,0 +1,20 @@
1
+ // A planet, then every one of its moons in the catalogue's families. A moon the package draws in full keeps its own picture. The rest are the estimated rocks. No DOM.
2
+ import { moonFamilies } from "./moon-catalogue.js";
3
+ import { MOON_PAGE_HOSTS } from "./moon-pages/data.js";
4
+ import { estimatedRock } from "./scene/estimated-rock.js";
5
+ export { MOON_PAGE_HOSTS };
6
+ /** The families of one giant planet, in list order, every catalogue moon once. Numbers run through that order. */
7
+ export function moonGroupPoster(host) {
8
+ let number = 0;
9
+ return moonFamilies(host).map((family) => ({
10
+ id: family.id,
11
+ name: { en: family.names.en, ja: family.names.ja },
12
+ count: family.count,
13
+ moons: family.moons.map((moon) => {
14
+ number += 1;
15
+ const rock = estimatedRock(moon.id);
16
+ const line = rock === null ? { en: moon.label, ja: moon.ja ?? moon.label } : { en: rock.line.en, ja: rock.line.ja };
17
+ return { id: moon.id, number, line, estimated: rock !== null };
18
+ }),
19
+ }));
20
+ }
@@ -53,7 +53,7 @@ export interface MoonPagesState {
53
53
  *
54
54
  * It never writes the page's address. A choice made in it is reflected on its attribute and sent as `wakusei-moon-pages-change` (bubbling, composed) with `detail` the whole `MoonPagesState`; a page that keeps its
55
55
  * address writes the detail there and sets the attributes back from it when it loads. Setting an attribute sends no event. The numbers are `moonPage(planet)`'s, worked out in a few milliseconds. The plan, the
56
- * portrait, the cards' bodies and the planet's looks are fetched only when their tab is first opened, so a page that shows only the orbits and the table loads no WebGL. Nothing runs on a timer; the orbits are drawn
56
+ * portrait and the cards' bodies are fetched only when their tab is first opened. The hero above the tabs is always there: the planet cropped at the right and its main moons in an arc, each a painted sphere, and it loads those looks when the element connects. Nothing runs on a timer; the orbits are drawn
57
57
  * again only when a choice, the language or the element's width changes. `data-state` is `ready` once it has drawn.
58
58
  *
59
59
  * @example
@@ -1,10 +1,11 @@
1
1
  // <wakusei-moon-pages>: one giant planet's moons in four tabs, each one screen. Orbits: every orbit of /moon-catalogue in SVG, from above, at an angle or from the side, coloured by direction or by family.
2
2
  // Map and portrait: <wakusei-plan> and <wakusei-portrait>. Main moons: a card with a picture for each moon drawn in full. Every moon: the whole list in a table that sorts. Every number is worked out from the
3
- // package's data (moonPage). The WebGL parts and the bodies' looks are fetched only when their tab is first opened. Nothing runs on a timer; it never writes the page's address: a choice is reflected on its
3
+ // package's data (moonPage). The hero above the tabs draws the planet and its main moons as soon as the element connects. The other WebGL parts are fetched when their tab is first opened. Nothing runs on a timer; it never writes the page's address: a choice is reflected on its
4
4
  // own attributes and sent as `wakusei-moon-pages-change`, for the page to keep where it likes.
5
5
  import { MOONS_OF } from "../facts.js";
6
6
  import { addBody, addMoons, defaultPortrait, encodeScene } from "../portrait/model.js";
7
7
  import { moonPage, MOON_PAGE_HOSTS } from "./data.js";
8
+ import { HERO_POSE, heroMoons, heroScale, heroSmall, heroZoom } from "./hero.js";
8
9
  import { MOON_PAGE_WORDS } from "./words.js";
9
10
  /**
10
11
  * The four tabs of `<wakusei-moon-pages>`, in their order: `orbits`, `views` (the map and the portrait), `cards` (the moons drawn in full) and `table` (every moon).
@@ -97,11 +98,41 @@ tbody th { font-weight: 400; }
97
98
  td:nth-child(7), td:nth-child(8) { white-space: normal; min-width: 9rem; max-width: 16rem; }
98
99
  tr:last-child > * { border-bottom: 0; }
99
100
  .credits { margin-top: 20px; }
101
+ .hero-wrap { display: grid; gap: 8px; margin: 0 0 14px; }
102
+ .hero { position: relative; overflow: hidden; height: min(78vh, 720px); min-height: 520px; background: #000; border-radius: 16px; }
103
+ .hero:fullscreen { width: 100%; height: 100%; min-height: 0; border-radius: 0; }
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
+ .hero-planet wakusei-body, .hero-disc wakusei-body { --wakusei-size: 100%; width: 100%; height: 100%; display: block; }
107
+ .hero-moons { position: absolute; inset: 0; z-index: 2; }
108
+ .hero-moon { position: absolute; transform: translate(-50%, -50%); display: block; margin: 0; padding: 0; border: 0; background: none; color: #fff; touch-action: manipulation; }
109
+ .hero-disc { display: block; width: calc(var(--disc) * 1px); aspect-ratio: 1; border-radius: 50%; }
110
+ .hero-disc wakusei-body { pointer-events: none; }
111
+ .hero-name { position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%); font-size: 13px; font-weight: 650; line-height: 1.2; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; }
112
+ .hero-moon:hover .hero-disc, .hero-moon:focus-visible .hero-disc, .hero-moon[aria-pressed="true"] .hero-disc { outline: 2px solid #fff; outline-offset: 3px; }
113
+ .hero-small { position: absolute; z-index: 2; left: 10px; bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: end; max-width: 52%; }
114
+ .hero-small .hero-moon { position: static; transform: none; display: grid; justify-items: center; gap: 1px; min-width: 36px; min-height: 44px; }
115
+ .hero-small .hero-name, .hero-small .hero-est { position: static; transform: none; left: auto; top: auto; font-size: 9px; line-height: 1.1; }
116
+ .hero-est { color: #d7d2c6; font-weight: 500; }
117
+ .hero-scale { display: flex; flex-wrap: nowrap; gap: 4px 10px; align-items: end; margin: 0; overflow-x: auto; }
118
+ .hero-note { margin: 4px 0 0; }
119
+ .scale-name { display: block; font-size: 11px; font-weight: 650; white-space: nowrap; }
120
+ .scale-moon { display: grid; justify-items: center; align-content: end; gap: 2px; min-width: 44px; min-height: 44px; margin: 0; padding: 2px; border: 0; border-radius: 8px; background: none; color: inherit; font: 600 11px/1.2 system-ui, sans-serif; }
121
+ .scale-moon svg { display: block; }
122
+ .scale-moon:hover, .scale-moon:focus-visible, .scale-moon[aria-pressed="true"] { outline: 2px solid currentColor; outline-offset: 2px; }
123
+ .fs { position: absolute; z-index: 3; top: 10px; left: 10px; min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.5); background: rgba(0,0,0,.45); color: #fff; font: 600 14px/1 system-ui, sans-serif; }
124
+ .hero-fact { margin: 0; min-height: 1.4em; font-size: .9rem; }
100
125
  @media (max-width: 600px) {
101
126
  .top { gap: 6px; margin-bottom: 8px; }
102
127
  h2 { font-size: 1.2rem; }
103
128
  .lede { display: none; }
104
129
  .short { display: block; }
130
+ .hero { height: min(68vh, 640px); min-height: 420px; border-radius: 12px; }
131
+ .hero-moons { bottom: 6.5rem; }
132
+ .hero-disc { width: calc(var(--disc) * 0.78px); }
133
+ .hero-name { font-size: 12px; }
134
+ .hero-small { max-width: 62%; }
135
+ .hero-small .hero-moon { min-width: 28px; }
105
136
  }
106
137
  </style>
107
138
  <section class="top" part="top">
@@ -110,6 +141,17 @@ tr:last-child > * { border-bottom: 0; }
110
141
  <p class="fine lede" id="lede"></p>
111
142
  <p class="fine short" id="short"></p>
112
143
  </section>
144
+ <section class="hero-wrap" part="hero">
145
+ <div class="hero" id="hero">
146
+ <button type="button" class="fs" id="full-screen"></button>
147
+ <div class="hero-planet" id="hero-planet"></div>
148
+ <div class="hero-moons" id="hero-moons" data-w-label="hero_moons"></div>
149
+ <div class="hero-small" id="hero-small"></div>
150
+ </div>
151
+ <p class="hero-fact" id="hero-fact" role="status"></p>
152
+ <p class="fine hero-note" id="hero-note"></p>
153
+ <div class="hero-scale" id="hero-scale" data-w-label="hero_scale"></div>
154
+ </section>
113
155
  <div class="panels" part="panels">
114
156
  <div class="tabs" role="tablist" id="tabs" data-w-label="tabs">
115
157
  <button type="button" role="tab" id="tab-orbits" aria-controls="panel-orbits" data-tab="orbits" data-w="tab_orbits"></button>
@@ -177,7 +219,7 @@ tr:last-child > * { border-bottom: 0; }
177
219
  *
178
220
  * It never writes the page's address. A choice made in it is reflected on its attribute and sent as `wakusei-moon-pages-change` (bubbling, composed) with `detail` the whole `MoonPagesState`; a page that keeps its
179
221
  * address writes the detail there and sets the attributes back from it when it loads. Setting an attribute sends no event. The numbers are `moonPage(planet)`'s, worked out in a few milliseconds. The plan, the
180
- * portrait, the cards' bodies and the planet's looks are fetched only when their tab is first opened, so a page that shows only the orbits and the table loads no WebGL. Nothing runs on a timer; the orbits are drawn
222
+ * portrait and the cards' bodies are fetched only when their tab is first opened. The hero above the tabs is always there: the planet cropped at the right and its main moons in an arc, each a painted sphere, and it loads those looks when the element connects. Nothing runs on a timer; the orbits are drawn
181
223
  * again only when a choice, the language or the element's width changes. `data-state` is `ready` once it has drawn.
182
224
  *
183
225
  * @example
@@ -205,6 +247,9 @@ export class WakuseiMoonPages extends HTMLElement {
205
247
  #plan;
206
248
  #portrait;
207
249
  #cardsFor;
250
+ #heroHost;
251
+ #heroMoon = null;
252
+ #onFull;
208
253
  #watch;
209
254
  #resize;
210
255
  #reflecting = false;
@@ -239,11 +284,15 @@ export class WakuseiMoonPages extends HTMLElement {
239
284
  });
240
285
  this.#resize.observe(this);
241
286
  }
287
+ this.#onFull = () => this.#paintFullscreen();
288
+ document.addEventListener("fullscreenchange", this.#onFull);
242
289
  this.#render();
243
290
  }
244
291
  disconnectedCallback() {
245
292
  this.#watch?.disconnect();
246
293
  this.#resize?.disconnect();
294
+ if (this.#onFull !== undefined)
295
+ document.removeEventListener("fullscreenchange", this.#onFull);
247
296
  }
248
297
  attributeChangedCallback(name, before, after) {
249
298
  if (this.#reflecting || before === after || this.#root === undefined)
@@ -260,8 +309,11 @@ export class WakuseiMoonPages extends HTMLElement {
260
309
  if (value !== null && ALLOWED[key].includes(value))
261
310
  next[key] = value;
262
311
  }
263
- if (next.planet !== this.#state.planet)
312
+ if (next.planet !== this.#state.planet) {
264
313
  this.#picked = null;
314
+ this.#heroMoon = null;
315
+ this.#heroHost = undefined;
316
+ }
265
317
  this.#state = next;
266
318
  }
267
319
  /** A choice made here: kept, reflected on the attributes, sent. */
@@ -357,6 +409,21 @@ export class WakuseiMoonPages extends HTMLElement {
357
409
  this.#light(this.#nearest(event.clientX, event.clientY));
358
410
  });
359
411
  svg.addEventListener("pointerdown", (event) => this.#light(this.#nearest(event.clientX, event.clientY)));
412
+ this.#$("#full-screen").addEventListener("click", () => {
413
+ const hero = this.#$("#hero");
414
+ if (document.fullscreenElement === hero)
415
+ void document.exitFullscreen();
416
+ else
417
+ void hero.requestFullscreen();
418
+ });
419
+ this.#$(".hero-wrap").addEventListener("click", (event) => {
420
+ const button = event.target?.closest("[data-moon]");
421
+ if (button === null || button === undefined)
422
+ return;
423
+ this.#heroMoon = button.dataset["moon"] ?? null;
424
+ this.#paintHero();
425
+ this.dispatchEvent(new CustomEvent("wakusei-moon-pages-change", { detail: { ...this.state, moon: this.#heroMoon }, bubbles: true, composed: true }));
426
+ });
360
427
  }
361
428
  // --- drawing -------------------------------------------------------------------------------------------------------------------------------------------
362
429
  #render() {
@@ -396,8 +463,132 @@ export class WakuseiMoonPages extends HTMLElement {
396
463
  this.#drawCards();
397
464
  if (this.#state.tab === "table")
398
465
  this.#drawTable();
466
+ this.#mountHero();
467
+ this.#paintFullscreen();
399
468
  this.setAttribute("data-state", "ready");
400
469
  }
470
+ /** The planet's edge and the arc. The spheres are made once a planet; a later draw only renames them. */
471
+ #mountHero() {
472
+ const host = this.#page().host;
473
+ if (this.#heroHost !== host) {
474
+ this.#heroHost = host;
475
+ this.#heroMoon = null;
476
+ void this.#loadHero(host);
477
+ return;
478
+ }
479
+ this.#paintHero();
480
+ }
481
+ async #loadHero(host) {
482
+ await LOOKS[host]();
483
+ await import("../element.js");
484
+ if (!this.isConnected || this.#heroHost !== host)
485
+ return;
486
+ const pose = HERO_POSE[host];
487
+ const planet = document.createElement("wakusei-body");
488
+ planet.setAttribute("body", host);
489
+ planet.setAttribute("data-still-size", "960");
490
+ planet.setAttribute("look", "painted");
491
+ planet.setAttribute("live", "off");
492
+ planet.setAttribute("fit", "tight");
493
+ planet.setAttribute("labels", "off");
494
+ planet.setAttribute("meridian", String(pose.meridian));
495
+ planet.setAttribute("tilt", String(pose.tilt));
496
+ if (pose.pitch !== undefined)
497
+ planet.setAttribute("pitch", String(pose.pitch));
498
+ this.#textures(planet);
499
+ const frame = this.#$("#hero-planet");
500
+ frame.classList.toggle("clip-disc", host === "jupiter");
501
+ frame.replaceChildren(planet);
502
+ const zoom = heroZoom(host);
503
+ if (zoom !== 1)
504
+ planet.setView({ zoom });
505
+ const cards = this.#page().cards;
506
+ const moons = heroMoons(cards, host, this.#lang());
507
+ const discButton = (id, px, look) => {
508
+ const button = document.createElement("button");
509
+ button.type = "button";
510
+ button.className = "hero-moon";
511
+ button.dataset["moon"] = id;
512
+ const disc = document.createElement("span");
513
+ disc.className = "hero-disc";
514
+ disc.style.setProperty("--disc", String(px));
515
+ const body = document.createElement("wakusei-body");
516
+ body.setAttribute("body", id);
517
+ body.setAttribute("look", look);
518
+ body.setAttribute("live", "off");
519
+ body.setAttribute("fit", "tight");
520
+ body.setAttribute("labels", "off");
521
+ this.#textures(body);
522
+ const name = document.createElement("span");
523
+ name.className = "hero-name";
524
+ disc.append(body);
525
+ button.append(disc, name);
526
+ return button;
527
+ };
528
+ this.#$("#hero-moons").replaceChildren(...moons.map((moon) => {
529
+ const button = discButton(moon.id, moon.px, "painted");
530
+ button.style.left = `${moon.left}%`;
531
+ button.style.top = `${moon.top}%`;
532
+ return button;
533
+ }));
534
+ this.#$("#hero-small").replaceChildren(...heroSmall(cards, host, this.#lang()).map((moon) => discButton(moon.id, moon.px, "illustrated")));
535
+ this.#$("#hero-scale").replaceChildren(...heroScale(cards, host).map((circle) => {
536
+ const button = document.createElement("button");
537
+ button.type = "button";
538
+ button.className = "scale-moon";
539
+ button.dataset["moon"] = circle.id;
540
+ const r = Math.max(1.5, (circle.px / 56) * 26);
541
+ button.innerHTML = `<svg width="56" height="56" viewBox="0 0 56 56" aria-hidden="true"><circle cx="28" cy="28" r="${r}" fill="none" stroke="currentColor" stroke-width="1.5"/></svg><span class="scale-name"></span><span class="scale-km"></span>`;
542
+ return button;
543
+ }));
544
+ this.#paintHero();
545
+ }
546
+ #paintHero() {
547
+ const page = this.#page();
548
+ const lang = this.#lang();
549
+ const named = new Map([...heroMoons(page.cards, page.host, lang), ...heroSmall(page.cards, page.host, lang)].map((moon) => [moon.id, moon.name]));
550
+ for (const button of this.#$$("[data-moon]")) {
551
+ const id = button.dataset["moon"] ?? "";
552
+ button.setAttribute("aria-pressed", String(id === this.#heroMoon));
553
+ const name = button.querySelector(".hero-name");
554
+ if (name !== null && named.has(id))
555
+ name.textContent = named.get(id) ?? "";
556
+ if (button.closest("#hero-small") !== null)
557
+ button.title = this.#say("hero_estimated");
558
+ const scaleName = button.querySelector(".scale-name");
559
+ if (scaleName !== null)
560
+ scaleName.textContent = named.get(id) ?? "";
561
+ const km = button.querySelector(".scale-km");
562
+ if (km !== null) {
563
+ const card = page.cards.find((item) => item.id === id);
564
+ if (card !== undefined)
565
+ km.textContent = `${this.#diameter(card.radiusKm)} km`;
566
+ }
567
+ button.querySelector("wakusei-body")?.setAttribute("lang", lang);
568
+ }
569
+ this.#$("#hero-planet").querySelector("wakusei-body")?.setAttribute("lang", lang);
570
+ this.#$("#hero-note").textContent = `${this.#say("hero_scale")} ${this.#say("hero_estimated")}`;
571
+ this.#paintFact();
572
+ this.#paintFullscreen();
573
+ }
574
+ #paintFact() {
575
+ const card = this.#page().cards.find((item) => item.id === this.#heroMoon);
576
+ const fact = this.#$("#hero-fact");
577
+ if (card === undefined) {
578
+ fact.textContent = "";
579
+ return;
580
+ }
581
+ const name = this.#lang() === "ja" ? card.name.ja : card.name.en;
582
+ fact.textContent = this.#say("hero_fact", { name, diameter: this.#diameter(card.radiusKm), distance: card.a === null ? NONE : this.#number(card.a), planet: this.#planetName(), found: card.date ?? NONE });
583
+ }
584
+ #paintFullscreen() {
585
+ if (this.#root === undefined)
586
+ return;
587
+ const on = document.fullscreenElement === this.#$("#hero");
588
+ const button = this.#$("#full-screen");
589
+ button.textContent = this.#say(on ? "leave_full_screen" : "full_screen");
590
+ button.setAttribute("aria-pressed", String(on));
591
+ }
401
592
  #drawOrbits() {
402
593
  const data = this.#page();
403
594
  const svg = this.#$("#orbits");
@@ -0,0 +1,34 @@
1
+ import type { MoonPageHost, PageCard } from "./data.ts";
2
+ /** 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. */
3
+ export declare const HERO_ARC: Record<MoonPageHost, readonly string[]>;
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
+ 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. */
7
+ export declare const HERO_POSE: Record<MoonPageHost, {
8
+ meridian: number;
9
+ tilt: number;
10
+ pitch?: number;
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
+ export declare function heroZoom(host: MoonPageHost): number;
16
+ /** One moon of the hero: its name, the disc's width in pixels, and the centre as a percent of the hero. */
17
+ export interface HeroMoon {
18
+ id: string;
19
+ name: string;
20
+ px: number;
21
+ left: number;
22
+ top: number;
23
+ }
24
+ /** 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. */
25
+ export declare function heroMoons(cards: readonly PageCard[], host: MoonPageHost, lang: "en" | "ja"): HeroMoon[];
26
+ /** The second row, in list order. Disc sizes follow diameter, with a floor so a small rock stays a disc. Every one is marked estimated: the package has no photo map for these. */
27
+ export declare function heroSmall(cards: readonly PageCard[], host: MoonPageHost, lang: "en" | "ja"): HeroMoon[];
28
+ export interface HeroCircle {
29
+ id: string;
30
+ px: number;
31
+ diameterKm: number;
32
+ }
33
+ /** The same moons as outline circles at their true diameters, the largest 56 pixels across. */
34
+ export declare function heroScale(cards: readonly PageCard[], host: MoonPageHost): HeroCircle[];