@johnmorrisdotca/wakusei-planets 0.73.0 → 0.74.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.
@@ -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[];
@@ -0,0 +1,81 @@
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
+ /** 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
+ export const HERO_ARC = {
5
+ jupiter: ["callisto", "ganymede", "europa", "io"],
6
+ saturn: ["iapetus", "titan", "rhea", "dione", "tethys", "enceladus", "mimas"],
7
+ uranus: ["oberon", "titania", "umbriel", "ariel", "miranda"],
8
+ neptune: ["nereid", "triton", "proteus", "larissa"],
9
+ };
10
+ /** 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. */
11
+ export const HERO_SMALL = {
12
+ jupiter: ["thebe", "amalthea"],
13
+ saturn: ["pan", "atlas", "prometheus", "pandora", "janus", "epimetheus", "hyperion", "telesto", "calypso", "helene"],
14
+ uranus: [],
15
+ neptune: [],
16
+ };
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. */
18
+ export const HERO_POSE = {
19
+ jupiter: { meridian: 70, tilt: 14 },
20
+ saturn: { meridian: 30, tilt: 26.73, pitch: 22 },
21
+ uranus: { meridian: 10, tilt: 16 },
22
+ neptune: { meridian: 20, tilt: 16 },
23
+ };
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
+ */
27
+ export function heroZoom(host) {
28
+ if (host !== "jupiter")
29
+ return 1;
30
+ return Math.max(1.06, ringReach(BODIES[host]) * 1.04);
31
+ }
32
+ /** 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
+ export function heroMoons(cards, host, lang) {
34
+ const byId = new Map(cards.map((card) => [card.id, card]));
35
+ const chosen = HERO_ARC[host].flatMap((id) => {
36
+ const card = byId.get(id);
37
+ return card === undefined ? [] : [card];
38
+ });
39
+ const max = Math.max(1, ...chosen.map((card) => card.radiusKm));
40
+ const count = chosen.length;
41
+ const largest = count <= 4 ? 132 : count <= 5 ? 120 : 112;
42
+ return chosen.map((card, index) => {
43
+ const even = count <= 1 ? 0 : index / (count - 1);
44
+ // Saturn's first two discs are the large ones. A shared step sets Iapetus on Titan, so the first step is longer.
45
+ const t = host === "saturn" && count > 2 ? (index === 0 ? 0 : 0.34 + 0.66 * ((index - 1) / (count - 2))) : even;
46
+ const share = card.radiusKm / max;
47
+ return {
48
+ id: card.id,
49
+ name: lang === "ja" ? card.name.ja : card.name.en,
50
+ px: Math.max(64, Math.round(largest * share)),
51
+ left: Math.round((16 + even * 12) * 10) / 10,
52
+ top: Math.round((10 + t * 62) * 10) / 10,
53
+ };
54
+ });
55
+ }
56
+ /** 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. */
57
+ export function heroSmall(cards, host, lang) {
58
+ const byId = new Map(cards.map((card) => [card.id, card]));
59
+ const chosen = HERO_SMALL[host].flatMap((id) => {
60
+ const card = byId.get(id);
61
+ return card === undefined ? [] : [card];
62
+ });
63
+ const max = Math.max(1, ...chosen.map((card) => card.radiusKm));
64
+ return chosen.map((card) => ({
65
+ id: card.id,
66
+ name: `${lang === "ja" ? card.name.ja : card.name.en}*`,
67
+ px: Math.round(28 * Math.max(0.45, card.radiusKm / max)),
68
+ left: 0,
69
+ top: 0,
70
+ }));
71
+ }
72
+ /** The same moons as outline circles at their true diameters, the largest 56 pixels across. */
73
+ export function heroScale(cards, host) {
74
+ const byId = new Map(cards.map((card) => [card.id, card]));
75
+ const chosen = [...HERO_ARC[host], ...HERO_SMALL[host]].flatMap((id) => {
76
+ const card = byId.get(id);
77
+ return card === undefined ? [] : [card];
78
+ });
79
+ const max = Math.max(1, ...chosen.map((card) => card.radiusKm));
80
+ return chosen.map((card) => ({ id: card.id, diameterKm: card.radiusKm * 2, px: Math.max(4, Math.round(56 * (card.radiusKm / max))) }));
81
+ }
@@ -55,6 +55,12 @@ export declare const MOON_PAGE_WORDS: {
55
55
  readonly table_note: "≈ marks a size worked out from the moon's brightness, not measured. — means no source gives it. The place of discovery is known here only for the moons drawn in full, which are in bold.";
56
56
  readonly credits: "Every number on this page is the package's own, worked out when the page was built: the moons, their orbits, sizes and discoveries from NASA/JPL's moon pages and Horizons, read on {fetched}, and the places of discovery from the IAU Gazetteer.";
57
57
  readonly short: "{total} moons · {named} named · {retrograde} go the other way";
58
+ readonly hero_moons: "Main moons";
59
+ readonly full_screen: "Full screen";
60
+ readonly leave_full_screen: "Leave full screen";
61
+ readonly hero_fact: "{name}: {diameter} km across, {distance} km from {planet}. Found {found}.";
62
+ readonly hero_estimated: "* shape or size estimated";
63
+ readonly hero_scale: "The circles are the true sizes. The moons above are drawn large enough to see.";
58
64
  };
59
65
  readonly ja: {
60
66
  readonly tabs: "表示";
@@ -111,5 +117,11 @@ export declare const MOON_PAGE_WORDS: {
111
117
  readonly table_note: "≈ は、測定ではなく衛星の明るさから見積もった大きさです。— は、資料に値がないことを表します。発見した場所は、くわしく描いている衛星(太字)だけにあります。";
112
118
  readonly credits: "このページの数字はすべて、ページを作ったときにパッケージのデータから計算したものです。衛星の軌道・大きさ・発見は NASA/JPL の衛星のページと Horizons({fetched}に読み込み)から、発見した場所は IAU 惑星地名辞典からです。";
113
119
  readonly short: "衛星{total}個・名前つき{named}個・反対向き{retrograde}個";
120
+ readonly hero_moons: "主な衛星";
121
+ readonly full_screen: "全画面";
122
+ readonly leave_full_screen: "全画面をやめる";
123
+ readonly hero_fact: "{name}:直径 {diameter} km、{planet}から {distance} km。発見は{found}。";
124
+ readonly hero_estimated: "* 形や大きさは推定";
125
+ readonly hero_scale: "円が実際の大きさです。上の衛星は見える大きさに描いています。";
114
126
  };
115
127
  };
@@ -56,6 +56,12 @@ export const MOON_PAGE_WORDS = {
56
56
  table_note: "≈ marks a size worked out from the moon's brightness, not measured. — means no source gives it. The place of discovery is known here only for the moons drawn in full, which are in bold.",
57
57
  credits: "Every number on this page is the package's own, worked out when the page was built: the moons, their orbits, sizes and discoveries from NASA/JPL's moon pages and Horizons, read on {fetched}, and the places of discovery from the IAU Gazetteer.",
58
58
  short: "{total} moons · {named} named · {retrograde} go the other way",
59
+ hero_moons: "Main moons",
60
+ full_screen: "Full screen",
61
+ leave_full_screen: "Leave full screen",
62
+ hero_fact: "{name}: {diameter} km across, {distance} km from {planet}. Found {found}.",
63
+ hero_estimated: "* shape or size estimated",
64
+ hero_scale: "The circles are the true sizes. The moons above are drawn large enough to see.",
59
65
  },
60
66
  ja: {
61
67
  tabs: "表示",
@@ -112,5 +118,11 @@ export const MOON_PAGE_WORDS = {
112
118
  table_note: "≈ は、測定ではなく衛星の明るさから見積もった大きさです。— は、資料に値がないことを表します。発見した場所は、くわしく描いている衛星(太字)だけにあります。",
113
119
  credits: "このページの数字はすべて、ページを作ったときにパッケージのデータから計算したものです。衛星の軌道・大きさ・発見は NASA/JPL の衛星のページと Horizons({fetched}に読み込み)から、発見した場所は IAU 惑星地名辞典からです。",
114
120
  short: "衛星{total}個・名前つき{named}個・反対向き{retrograde}個",
121
+ hero_moons: "主な衛星",
122
+ full_screen: "全画面",
123
+ leave_full_screen: "全画面をやめる",
124
+ hero_fact: "{name}:直径 {diameter} km、{planet}から {distance} km。発見は{found}。",
125
+ hero_estimated: "* 形や大きさは推定",
126
+ hero_scale: "円が実際の大きさです。上の衛星は見える大きさに描いています。",
115
127
  },
116
128
  };
@@ -285,7 +285,7 @@ export interface Preset {
285
285
  scene: Portrait;
286
286
  }
287
287
  /**
288
- * Ready-made scenes to start from: a family photo of the Sun and the planets, the gas giants to scale, Jupiter and the Galileans, the Earth and the Moon to scale (size and distance), Mars and its moons at their true distance, and the inner planets round the Sun.
288
+ * Ready-made scenes to start from: a family photo of the Sun and the planets, the gas giants to scale, Jupiter and the Galileans, the Earth and the Moon to scale (size and distance), Mars and its moons at their true distance, the inner planets round the Sun, a giant planet's edge with its main moons in an arc, and every drawn moon beside its planet.
289
289
  *
290
290
  * @example
291
291
  * ```ts
@@ -692,8 +692,85 @@ export function decodeScene(text) {
692
692
  return p;
693
693
  }
694
694
  const fromList = (ids, change = {}) => ids.reduce((p, id) => addBody(p, id), { ...defaultPortrait(), ...change });
695
+ /** The poster arc, farthest from the planet first. These are the moons the package draws. */
696
+ const POSTER_ARC = {
697
+ jupiter: ["callisto", "ganymede", "europa", "io"],
698
+ saturn: ["iapetus", "titan", "rhea", "dione", "tethys", "enceladus", "mimas"],
699
+ uranus: ["oberon", "titania", "umbriel", "ariel", "miranda"],
700
+ neptune: ["nereid", "triton", "proteus"],
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. */
703
+ const POSTER_POSE = {
704
+ jupiter: { spin: 70, tilt: 14 },
705
+ saturn: { spin: 30, tilt: 26.73, pitch: 22 },
706
+ uranus: { spin: 10, tilt: 16 },
707
+ neptune: { spin: 20, tilt: 16 },
708
+ };
709
+ /** A manual scene of one poster: the planet large at the right, its main moons in an arc, farthest at the top. Saturn's first step is longer, so Iapetus sits clear of Titan. */
710
+ function posterEdge(host) {
711
+ const moons = POSTER_ARC[host];
712
+ const aspect = 16 / 9;
713
+ const count = moons.length;
714
+ const sized = sizesFor(moons, "readable");
715
+ const moonScale = (count <= 4 ? 0.2 : 0.13) / Math.max(...sized);
716
+ const pose = POSTER_POSE[host];
717
+ const planetR = host === "jupiter" ? 0.72 : 0.82 / reachOf(host);
718
+ const planet = {
719
+ body: host,
720
+ x: aspect * 0.92 - planetR * 0.15,
721
+ y: 0,
722
+ r: planetR,
723
+ spin: pose.spin,
724
+ tilt: pose.tilt,
725
+ turn: 0,
726
+ ...(pose.pitch !== undefined ? { pitch: pose.pitch } : {}),
727
+ };
728
+ let y = 0.78;
729
+ let previous = 0;
730
+ const items = [
731
+ planet,
732
+ ...moons.map((id, index) => {
733
+ const even = count <= 1 ? 0 : index / (count - 1);
734
+ const r = sized[index] * moonScale;
735
+ if (index > 0)
736
+ y -= previous + r + (host === "saturn" && index === 1 ? 0.16 : 0.04);
737
+ previous = r;
738
+ return { body: id, x: -aspect + (0.16 + even * 0.14) * 2 * aspect, y, r, spin: BODIES[id].showLon ?? 0, turn: 0 };
739
+ }),
740
+ ];
741
+ return { ...defaultPortrait(), items, layout: "manual", arrange: "arc", scale: "readable", moons: "manual", orbits: false, labels: true, aspect, camera: { x: 0, y: 0, h: 1 } };
742
+ }
743
+ /** A manual scene of the groups poster: each giant planet with the moons the package draws, in a row beside it. */
744
+ function posterGroups() {
745
+ const hosts = ["jupiter", "saturn", "uranus", "neptune"];
746
+ const aspect = 16 / 9;
747
+ const rows = hosts.map((host) => {
748
+ const ids = [host, ...[...MOONS_OF[host]].sort(byDistance)];
749
+ const sized = sizesFor(ids, "readable");
750
+ const scale = 0.22 / Math.max(...sized);
751
+ return ids.map((id, index) => {
752
+ const r = Math.max(0.04, sized[index] * scale);
753
+ return { id, r, span: r * (id === "saturn" ? reachOf(id) : 1.15) };
754
+ });
755
+ });
756
+ const gap = 0.1;
757
+ const heights = rows.map((row) => Math.max(...row.map((body) => body.span)) * 2);
758
+ let yCursor = heights.reduce((sum, height) => sum + height, 0) / 2 + (gap * (rows.length - 1)) / 2;
759
+ const items = [];
760
+ rows.forEach((row, index) => {
761
+ const y = yCursor - heights[index] / 2;
762
+ yCursor -= heights[index] + gap;
763
+ let x = 0;
764
+ row.forEach((body, place) => {
765
+ x += body.span;
766
+ items.push({ body: body.id, x, y, r: body.r, spin: BODIES[body.id].showLon ?? 0, turn: 0 });
767
+ x += body.span + (place === 0 ? 0.12 : 0.04);
768
+ });
769
+ });
770
+ return fitAll({ ...defaultPortrait(), items, layout: "manual", arrange: "row", scale: "readable", moons: "manual", orbits: false, labels: false, aspect, camera: { x: 0, y: 0, h: 1 } });
771
+ }
695
772
  /**
696
- * Ready-made scenes to start from: a family photo of the Sun and the planets, the gas giants to scale, Jupiter and the Galileans, the Earth and the Moon to scale (size and distance), Mars and its moons at their true distance, and the inner planets round the Sun.
773
+ * Ready-made scenes to start from: a family photo of the Sun and the planets, the gas giants to scale, Jupiter and the Galileans, the Earth and the Moon to scale (size and distance), Mars and its moons at their true distance, the inner planets round the Sun, a giant planet's edge with its main moons in an arc, and every drawn moon beside its planet.
697
774
  *
698
775
  * @example
699
776
  * ```ts
@@ -709,4 +786,9 @@ export const PRESETS = [
709
786
  { id: "earthmoon", name: { en: "Earth and Moon to scale", ja: "地球と月 (大きさと距離の比)" }, scene: fromList(["earth", "moon"], { arrange: "orbit", scale: "true", moons: "auto", orbits: true }) },
710
787
  { id: "marsmoons", name: { en: "Mars and its moons at true distance", ja: "火星と衛星 (本当の距離)" }, scene: fromList(["mars", "phobos", "deimos"], { arrange: "orbit", scale: "readable", moons: "auto", orbits: true }) },
711
788
  { id: "orrery", name: { en: "The inner planets round the Sun", ja: "太陽と内側の惑星 (本当の距離)" }, scene: fromList(["sun", "mercury", "venus", "earth", "mars"], { arrange: "orbit", scale: "readable", moons: "auto", orbits: true, bg: "black" }) },
789
+ { id: "jupiter-edge", name: { en: "Jupiter's edge", ja: "木星の縁" }, scene: posterEdge("jupiter") },
790
+ { id: "saturn-edge", name: { en: "Saturn's edge", ja: "土星の縁" }, scene: posterEdge("saturn") },
791
+ { id: "uranus-edge", name: { en: "Uranus's edge", ja: "天王星の縁" }, scene: posterEdge("uranus") },
792
+ { id: "neptune-edge", name: { en: "Neptune's edge", ja: "海王星の縁" }, scene: posterEdge("neptune") },
793
+ { id: "moons-by-planet", name: { en: "Moons beside their planet", ja: "惑星のそばの衛星" }, scene: posterGroups() },
712
794
  ];
@@ -146,8 +146,8 @@ export function createBodyItem(options) {
146
146
  ringTexture = assets.acquire(`wk:ringtex:${ringKey}`, () => {
147
147
  if (photoTexture !== undefined) {
148
148
  photoTexture.magFilter = T.LinearFilter;
149
- photoTexture.minFilter = T.LinearFilter;
150
- photoTexture.generateMipmaps = false;
149
+ photoTexture.minFilter = 1008; // LinearMipmapLinearFilter: the ring is drawn smaller than its picture, and a linear sample of the full picture stair-steps the edges
150
+ photoTexture.generateMipmaps = true;
151
151
  photoTexture.wrapS = T.ClampToEdgeWrapping;
152
152
  photoTexture.colorSpace = T.NoColorSpace;
153
153
  return photoTexture;
@@ -228,13 +228,33 @@ function paint(T, id, context, bases, hold) {
228
228
  ringTexture = t;
229
229
  ringInner = photo.from / facts.radiusKm;
230
230
  ringOuter = photo.to / facts.radiusKm;
231
- ringMesh.geometry.dispose();
231
+ const stripGeometry = ringMesh.geometry;
232
+ const stripAt = disposables.indexOf(stripGeometry);
233
+ if (stripAt >= 0)
234
+ disposables.splice(stripAt, 1);
235
+ stripGeometry.dispose();
232
236
  ringMesh.geometry = new T.RingGeometry(ringInner, ringOuter, 256, 1);
233
237
  disposables.push(ringMesh.geometry);
234
- ringMaterial.premultipliedAlpha = false;
235
- ringMaterial.needsUpdate = true;
236
- ringMaterial.uniforms.uRingTex.value = t;
237
- ringMaterial.uniforms.uRingR.value.set(ringInner, ringOuter);
238
+ // the picture is not premultiplied and the strip was. three.js keeps every program a material has compiled, so changing the flag would leave the strip's program and its vertex array on the card: the strip's material is let go and a new one is made
239
+ const stripMaterial = ringMaterial;
240
+ stripMaterial.uniforms.uRingTex.value = t;
241
+ stripMaterial.uniforms.uRingR.value.set(ringInner, ringOuter);
242
+ const photoMaterial = new T.ShaderMaterial({
243
+ vertexShader: RING_VERTEX_WORLD,
244
+ fragmentShader: RING_FRAGMENT_WORLD,
245
+ side: T.DoubleSide,
246
+ transparent: true,
247
+ premultipliedAlpha: false,
248
+ depthWrite: false,
249
+ uniforms: stripMaterial.uniforms,
250
+ });
251
+ ringMesh.material = photoMaterial;
252
+ const materialAt = disposables.indexOf(stripMaterial);
253
+ if (materialAt >= 0)
254
+ disposables.splice(materialAt, 1);
255
+ stripMaterial.dispose();
256
+ disposables.push(photoMaterial);
257
+ ringMaterial = photoMaterial;
238
258
  for (const m of materials) {
239
259
  m.uniforms.uRingTex.value = t;
240
260
  m.uniforms.uRingR.value.set(ringInner, ringOuter);
@@ -29,9 +29,10 @@ export function takeRenderer(onContext) {
29
29
  listeners.add(onContext);
30
30
  shared ??= createSharedRenderer({
31
31
  load: () => loader(),
32
- // A still is this many pixels on its long side, and the page keeps 32 MB of them. A square still is that side squared, times four bytes.
33
- // 160 holds every moon of Saturn (293) with the planet, which a 480-pixel still cannot: those are about 0.9 MB each, and past the budget the picture is dropped and the view shows a broken image.
32
+ // 160 holds every moon of Saturn (293) with the planet. A hero planet sets data-still-size="960" on its own element, so a grid tile stays at 160. One 960 still is about 3.7 MB, so the budget is the 32 MB of small stills plus that one picture.
34
33
  stillSize: 160,
34
+ antialias: true,
35
+ stillBytes: 36 * 1024 * 1024,
35
36
  onContext: (state) => {
36
37
  for (const listener of listeners)
37
38
  listener(state);
@@ -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.73.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.74.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.73.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.74.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.