@johnmorrisdotca/wakusei-planets 0.23.0 → 0.25.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +41 -14
  3. package/dist/blackbody.d.ts +2 -0
  4. package/dist/blackbody.js +10 -0
  5. package/dist/element.d.ts +12 -0
  6. package/dist/element.js +160 -23
  7. package/dist/embed.d.ts +5 -0
  8. package/dist/embed.js +32 -8
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +2 -0
  11. package/dist/kids/data.d.ts +109 -0
  12. package/dist/kids/data.js +164 -0
  13. package/dist/kids/index.d.ts +4 -0
  14. package/dist/kids/index.js +5 -0
  15. package/dist/kids/land.d.ts +3 -0
  16. package/dist/kids/land.js +29 -0
  17. package/dist/kids/picture.d.ts +39 -0
  18. package/dist/kids/picture.js +255 -0
  19. package/dist/kids/sheet.d.ts +60 -0
  20. package/dist/kids/sheet.js +79 -0
  21. package/dist/kids/svg.d.ts +46 -0
  22. package/dist/kids/svg.js +193 -0
  23. package/dist/line.d.ts +9 -1
  24. package/dist/line.js +3 -4
  25. package/dist/portrait/element.d.ts +9 -0
  26. package/dist/portrait/element.js +39 -5
  27. package/dist/scene/body.d.ts +8 -1
  28. package/dist/scene/body.js +33 -9
  29. package/dist/scene/glsl.d.ts +7 -2
  30. package/dist/scene/glsl.js +49 -3
  31. package/dist/scene/look.d.ts +43 -0
  32. package/dist/scene/look.js +39 -1
  33. package/dist/scene/store.d.ts +3 -0
  34. package/dist/scene/store.js +3 -1
  35. package/dist/scene/textures.d.ts +2 -2
  36. package/dist/space/element.d.ts +6 -0
  37. package/dist/space/element.js +18 -0
  38. package/dist/star-line.d.ts +20 -0
  39. package/dist/star-line.js +59 -0
  40. package/dist/star.d.ts +193 -0
  41. package/dist/star.js +261 -0
  42. package/dist/stars.js +3 -5
  43. package/dist/version.d.ts +1 -1
  44. package/dist/version.js +1 -1
  45. package/package.json +9 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.25.0] - 2026-11-09
6
+
7
+ - **A star from its numbers** (MODULES-720). `<wakusei-body star="...">` (or the `star` property) draws any star in 3D (`realistic`) or as a line drawing, in the same look system as the planets and through the same shared renderer, from `temperatureK`, `radiusSun`, `luminosityClass`, `rotationDays`, `activity`, `oblateness`, `corona` and `estimated`: the black-body colour, edge darkening, a surface grained by class, boiling granulation, spots, prominences and flares on active stars, gravity darkening on flattened ones, a bloom and a soft corona. `starLook(numbers)`, `starLineSvg(numbers)`, `STAR_SUN` and `LUMINOSITY_CLASSES` in the main entry; `registerStarLook(name, numbers)` and `starLookOf(name)` in `/look`. Every star lists `parts`: measured, estimated, derived or illustrative, in English and Japanese. `quality="low"` is a cheaper star for weak devices (chosen by itself on 2 GB or two cores). The line look draws the Sun, the Earth's orbit and Jupiter's orbit round the star to its size. `embedCode({ star })` writes the code for every kind of page, `embed.html` takes the numbers in its address, and the demo has a star page. The package holds no star catalogue. The Sun is unchanged: `e2e/sun.demo.ts` compares its three shaded frames with pictures drawn before this change and `test/sun-line.test.ts` its line drawing.
8
+ - **Printable colouring sheets for children** (MODULES-684). `/sheets` has a sheet for the Sun, the eight planets, Pluto, the Moon, Io, Europa, Ganymede, Callisto, Titan, Triton and Charon, and a lineup of the eight planets at one scale: a picture in thick lines (outline 3 mm, inner lines 2.5 mm) drawn from the package's numbers, two to four squares of the body's real colours with names, and three facts worked out from the numbers (width and how it compares with Earth, spin, year or orbit, the face a moon shows), in English and plain Japanese. `kidsSvg` is a sheet's one SVG in millimetres (no browser), `kidsSheet` the whole printable page in kazoku-ui's print layout (the `kid` type, the brand "Space Program X", a Name box, credits, version and a QR code back to the demo) on A4, US Letter, A3 or Tabloid, measured so the picture prints at its drawn size. The demo has a new `kids.html`: pick a sheet and a paper, see it, press Print / save PDF. The Pages build makes a PDF of every sheet on A4 and Letter in both languages (`scripts/make-pdfs.mjs`, under `pdf/`). kazoku-ui is now `^0.22.0`. EN/JA guide `docs/guides/kids-sheets.md`.
9
+ - **Data files for other languages, and a server you host** (MODULES-690). Each release attaches `wakusei-planets-data-v<version>.zip` and its files: CSV and Parquet tables of the bodies (the Sun, planets, dwarf planets and moons: radius, flattening, mass or GM, gravity, tilt, rotation, pole, colour, kind and parent), the orbital elements (the planets' mean semi-major axes for now, the dwarf planets' osculating elements, the moons' mean elements), the spacecraft and their events, each with a `<table>.schema.json` (type, unit, meaning and source of every column), `LICENCE-DATA.md` (each table keeps its sources' terms) and `SHA256SUMS` (`pnpm export:data`, `scripts/export-parquet.py`). The theory tables (VSOP87, ELP2000, TASS, L1.2) are left out until their terms are settled. `examples/serve/server.mjs` is a 40-line `node:http` server with `/body`, `/position` and `/distance`. EN/JA guides `docs/guides/data-files.md` and `docs/guides/serve-it-yourself.md`.
10
+
11
+ ## [0.24.0] - 2026-11-08
12
+
13
+ - **Every view zooms and pans by itself** (MODULES-642). `<wakusei-body>`, `<wakusei-portrait>` and `<wakusei-space>` carry the shared view controls (kazoku-ui 0.21.1, `carryControls`): a drag, a pinch, Ctrl, Command or Alt with the wheel (the plain wheel still scrolls the page at Fit), and the arrows, `+`, `-` and `0` once focused. `controls="none"` turns them off, `live="off"` starts a body without them, `zoom-min` and `zoom-max` set the range. The ranges: the body's line look 0.1x to 50x (vector, detail at any scale), its shaded looks and the portrait 0.1x to 8x (the 2048 pixel painted maps are sharp to about 1.5x and soften after that), the space view a millionth to 3x (the camera is held 1.05 radii from the surface). A `<kazoku-view-controls>` takes over and reads the range; point its `for` at the element itself. `wakusei-view` is sent when the view changes, `space.controller` is the shared controller, and `<wakusei-portrait>` has `setView`. `embed.html` zooms with the drag, pinch, wheel, keys and + and - buttons and keeps the view in its address (`zoom=2`; the view's tilt is `vtilt`), and `embedCode` takes `zoom` for the iframe way. The code builder's picture zooms too. See the new Zoom and pan guide.
14
+
5
15
  ## [0.23.0] - 2026-11-08
6
16
 
7
17
  - **`/nearest`: what is nearby, and when bodies come close** (MODULES-651). `nearest(target, { count, within, kind, bodies, by, date, observer })` lists the Sun, planets, dwarf planets and moons nearest to a body on a date, by the angle between them in the sky of the Earth's centre, a place on the Earth (the Moon's parallax counts) or another body (`by: "sky"`, exact near 0 and 180 degrees, astrometric as Horizons' RA and DEC are) or by the distance between their centres (`by: "space"`, km and au); `within(target, radius, options)` lists all inside a radius; `closestApproach(a, b, { from, to })` and `conjunctions({ from, to, within, bodies })` scan a span in coarse steps (the fastest body's period over 40, at most 2 days) and narrow each minimum to about a second of time by golden-section search. Every result carries the accuracy to expect from the theories (`uncertaintyArcseconds` or `uncertaintyKm`, and `uncertaintySeconds` for the moment), with the part of the error that two bodies share cancelled. Against JPL Horizons (`test/data/horizons-approach.json`, `scripts/fetch-horizons-approach.py`): the Jupiter-Saturn great conjunction of 2020-12-21 within 270 s and 0.27 arc-second, Venus and Jupiter of 2023-03-02 within 23 s and 0.54, the Moon's nine closest approaches to the planets in December 2026 within 8 s and 1.5 arc-seconds, and the Moon and Venus from Vancouver within 0.9 arc-second; also against a brute-force scan. `distance(a, b, date)` is the straight-line distance of any two bodies in km and au; `distanceRange(a, b, { from, to })` is the least and the greatest distance over a span, each with its moment, found the same way (the greatest on the negated distance): Earth and Mars come to 0.3727 au on 2003-08-27 and go to 2.676 au in 2066, and the guide tabulates every pair of planets for 1900 to 2100 (`scripts/distance-table.ts`); on three pairs against Horizons (`test/data/horizons-distance.json`, `scripts/fetch-horizons-distance.py`) the distances are within 4,000 km, inside the claimed uncertainty. A year's search of the Sun and the planets takes 18 ms (`scripts/bench-nearest.ts`). A separate entry point that nothing else imports. EN/JA guide `docs/guides/nearest.md`.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <p align="center"><strong>The Sun, the planets and their moons, for the web.</strong><br>
6
6
  A clean line drawing, a shaded realistic drawing, or a painted surface map, with each body's real size, axial tilt and rotation as data, and a planet's moons where they are at any date and time.</p>
7
7
 
8
- <p align="center">Part of <strong>SpaceProgramX (SPX)</strong>, the space packages: <a href="https://github.com/johnmorrisdotca/wakusei-planets">Wakusei Planets</a> · <a href="https://github.com/johnmorrisdotca/hoshi-stars">Hoshi Stars</a> · <a href="https://github.com/johnmorrisdotca/chikyu-earth">Chikyu Earth</a> · <a href="https://github.com/johnmorrisdotca/uchusen-rockets">Uchusen Rockets</a></p>
8
+ <p align="center">Part of <strong>Space Program X (SPX)</strong>, the space packages: <a href="https://github.com/johnmorrisdotca/wakusei-planets">Wakusei Planets</a> · <a href="https://github.com/johnmorrisdotca/hoshi-stars">Hoshi Stars</a> · <a href="https://github.com/johnmorrisdotca/chikyu-earth">Chikyu Earth</a> · <a href="https://github.com/johnmorrisdotca/uchusen-rockets">Uchusen Rockets</a></p>
9
9
 
10
10
  <p align="center">
11
11
  <a href="https://github.com/johnmorrisdotca/wakusei-planets/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/johnmorrisdotca/wakusei-planets/actions/workflows/ci.yml/badge.svg"></a>
@@ -15,9 +15,9 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
15
15
 
16
16
  <p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><strong>Open the demo →</strong></a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/embed.html">Embed page</a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/docs/">Docs</a></p>
17
17
 
18
- <p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.23.0/docs/images/hero-desk.png" width="640"></p>
18
+ <p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.25.0/docs/images/hero-desk.png" width="640"></p>
19
19
 
20
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.23.0/docs/images/lineup-desk.png" width="640"></p>
20
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.25.0/docs/images/lineup-desk.png" width="640"></p>
21
21
 
22
22
  ## One minute
23
23
 
@@ -42,7 +42,7 @@ A page with no build step needs one tag. `look="line"` is an SVG and needs nothi
42
42
  </html>
43
43
  ```
44
44
 
45
- The same tag with the shared [kazoku-ui](https://github.com/johnmorrisdotca/kazoku-ui) controls, which turn, tip, zoom and pan the body:
45
+ Every view already turns, zooms and pans with a drag, a pinch, Ctrl and the wheel and the keys (the plain wheel still scrolls the page). To add the shared [kazoku-ui](https://github.com/johnmorrisdotca/kazoku-ui) bar, with buttons and sliders, point it at the tag:
46
46
 
47
47
  ```html
48
48
  <!doctype html>
@@ -62,10 +62,8 @@ The same tag with the shared [kazoku-ui](https://github.com/johnmorrisdotca/kazo
62
62
  </script>
63
63
  </head>
64
64
  <body>
65
- <div id="view" tabindex="0">
66
- <wakusei-body body="saturn" look="line" size="420"></wakusei-body>
67
- </div>
68
- <kazoku-view-controls for="view" address controls="advanced" tilt-max="90" speed="0"></kazoku-view-controls>
65
+ <wakusei-body id="planet" body="saturn" look="line" size="420" tabindex="0"></wakusei-body>
66
+ <kazoku-view-controls for="planet" address controls="advanced" speed="0"></kazoku-view-controls>
69
67
  </body>
70
68
  </html>
71
69
  ```
@@ -113,6 +111,17 @@ Import the element once in client code, and the entry point of each body you dra
113
111
 
114
112
  Every body has its real size relative to the others (`scale-to="jupiter"`), its axial tilt and its rotation. The Sun, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune and Pluto are drawn, and so are the eight other dwarf planets (Ceres, Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna; Haumea and Quaoar as the long shapes they are, and Ceres with a painted map from Dawn) and 29 moons (the Moon, Phobos and Deimos, the four Galilean moons, Saturn's seven larger moons, Uranus's five, Proteus, Triton and Nereid, Charon, Nix and Hydra, and Vanth, Hiʻiaka, Namaka and Dysnomia, the moons of the dwarf planets whose orbits are published with a date). The Earth is drawn like the rest in the realistic and painted looks (NASA's Blue Marble), and its line look is [chikyu-earth](https://github.com/johnmorrisdotca/chikyu-earth)'s own globe: `import "@johnmorrisdotca/wakusei-planets/earth"` (it needs `@johnmorrisdotca/chikyu-earth` 0.10.0 or later installed). The painted looks cover the Sun, the planets from Mercury to Earth and Pluto, Ceres, the Moon, the four Galilean moons, Saturn's Mimas, Enceladus, Tethys, Dione, Rhea, Titan and Iapetus, Triton and Charon, and Saturn's rings are Cassini's own picture of them.
115
113
 
114
+ ## A star from its numbers
115
+
116
+ `<wakusei-body star="Betelgeuse" temperature-k="3600" radius-sun="764" luminosity-class="Iab">` draws any star in 3D or as a line drawing, from a few numbers and with no catalogue: the temperature gives the colour, the radius the size beside the Sun, the luminosity class the grain of the surface, the rotation how it turns, and a flattened star such as Vega or Altair is squashed with hotter poles. Granulation boils, an active star has spots, prominences and flares, and a soft corona glows round it, all through the same shared renderer, with a cheaper `quality="low"` for weak devices. Every star says which parts are measured and which are drawn for looks: *drawn from its numbers, not a photo*. The Sun keeps its own look. See [A star from its numbers](docs/guides/star-look.md) and the [star page](https://johnmorrisdotca.github.io/wakusei-planets/star.html).
117
+
118
+ ```ts
119
+ import { starLook } from "@johnmorrisdotca/wakusei-planets";
120
+
121
+ const vega = starLook({ name: "Vega", temperatureK: 9602, radiusSun: 2.362, oblateness: 0.11, rotationDays: 0.68 });
122
+ console.log(vega.colour, vega.parts.map((part) => part.status).join(", "));
123
+ ```
124
+
116
125
  ## Two packages: this one and chikyu-earth
117
126
 
118
127
  This package is the Sun, the planets, the dwarf planets and the moons, and where they are. [chikyu-earth](https://github.com/johnmorrisdotca/chikyu-earth) is the Earth in detail: its countries, day and night, places and satellites. Each works alone; install both and the Earth's line look becomes chikyu-earth's globe with the countries. The dependency runs one way: this package may use chikyu-earth, never the reverse. [Why two packages](docs/guides/two-packages.md) has the rule, a table of what lives where and how to use them together.
@@ -184,6 +193,8 @@ The pure side has no DOM: `BODIES`, `apparent(id, time)`, `system(planet, time)`
184
193
 
185
194
  Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is a table fitted to Horizons; the Moon's are the lunar solution ELP2000-82B cut down; Jupiter's four big moons are the theory L1.2 and Saturn's seven inner ones TASS1.7, and the others are fitted to JPL Horizons' positions, and every body is tested against Horizons ([accuracy](docs/guides/accuracy.md)). Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
186
195
 
196
+ The same data comes as files for other languages: every release attaches CSV and Parquet tables of the bodies, their orbital elements, the spacecraft and their events, each with a schema, the data licence and checksums, for pandas, polars, R or Rust ([data files](docs/guides/data-files.md)). [Serve it yourself](docs/guides/serve-it-yourself.md) is a small Node server that answers a body's facts, its position on a date and the distance between two bodies; we host nothing, you run it.
197
+
187
198
  ## Examples
188
199
 
189
200
  Every `ts` block in this README is type-checked and run against the package as npm packs it (`pnpm test:readme`).
@@ -279,7 +290,7 @@ A body that turns by itself and a moving sky, in HTML:
279
290
 
280
291
  ## The portrait builder
281
292
 
282
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.23.0/docs/images/portrait-family.png" width="640"></p>
293
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.25.0/docs/images/portrait-family.png" width="640"></p>
283
294
 
284
295
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
285
296
 
@@ -330,12 +341,13 @@ The reference is a site, made from the source's own doc comments: every export h
330
341
 
331
342
  | Entry point | What it gives |
332
343
  | --- | --- |
333
- | `@johnmorrisdotca/wakusei-planets` | The pure side: `BODIES`, `apparent`, `system`, `orbitPath`, `portrait`, `lineSvg`, `embedCode`. No browser. |
344
+ | `@johnmorrisdotca/wakusei-planets` | The pure side: `BODIES`, `apparent`, `system`, `orbitPath`, `portrait`, `lineSvg`, `embedCode`, `starLook`, `starLineSvg`. No browser. |
334
345
  | `.../element` | `<wakusei-body>`; three.js is loaded only for a shaded look. |
335
346
  | `.../portrait` | `<wakusei-portrait>`: many bodies in one scene. The scene model (`addBody`, `layoutPortrait`, `encodeScene`, `decodeScene`) is in the main entry. |
336
347
  | `.../space` | Where the Sun, the Moon and the planets are for a date, in two scales, and where a camera riding along looks: `frameAt`, `createTrack`, `placeSun`, `placeAround`, `ridePose`. No browser. |
337
348
  | `.../space/element` | `<wakusei-space>`: the Earth, the Moon, the Sun and the planets in their places. |
338
349
  | `.../nearest` | The bodies nearest to a body on a date (`nearest`, `within`), when two bodies come closest (`closestApproach`, `conjunctions`) and how far apart they are (`distance`, `distanceRange`). No browser. |
350
+ | `.../sheets` | Printable colouring sheets for children: the Sun, the planets and the big moons in thick lines with the real colours and three facts, and all the planets at one scale, in English and Japanese (`kidsSvg`, `kidsSheet`, `kidsFacts`). |
339
351
  | `.../look` | What a body needs to be drawn with three.js. |
340
352
  | `.../painter` | The bodies as objects for a scene of your own. |
341
353
  | `.../all` | Every body's shaded look, at once. |
@@ -364,13 +376,18 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
364
376
  | [Why two packages](docs/guides/two-packages.md) | This package and chikyu-earth: which to install, alone or together |
365
377
  | [Moons and time](docs/guides/moons-and-time.md) | The sky on a date, time that runs fast |
366
378
  | [The space view](docs/guides/space-view.md) | The Earth, Moon, Sun and planets in their places; two scales; time both ways |
379
+ | [A star from its numbers](docs/guides/star-look.md) | Any star in 3D or as lines, what is measured and what is drawn, every way to put it in a page |
380
+ | [Zoom and pan](docs/guides/zoom-and-pan.md) | Every view zooms and moves by itself: the range of each and why it ends there, the bar, the embed page |
367
381
  | [Riding along](docs/guides/ride-along.md) | The camera on a moon, a planet or any moving point, looking at what it goes round |
368
382
  | [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
369
383
  | [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
370
384
  | [Time](docs/guides/time.md) | Julian dates, calendars, time scales, sidereal time, Mars time |
371
385
  | [The stars you can see without a telescope](docs/guides/stars.md) | 5,080 stars with names, positions, proper motion, distance and colour |
372
386
  | [What is nearby, and when bodies come close](docs/guides/nearest.md) | The nearest bodies to a body on a date, closest approaches and conjunctions, and how close they are to Horizons |
387
+ | [Colouring sheets for children](docs/guides/kids-sheets.md) | Printable sheets of the Sun, planets and big moons, A4 and US Letter, English and Japanese, and the ready-made PDFs |
373
388
  | [Famous spacecraft](docs/guides/spacecraft.md) | Voyager, New Horizons, Pioneer, Cassini, Galileo, Juno, Parker and Webb: where they are and their whole voyage |
389
+ | [Data files](docs/guides/data-files.md) | CSV and Parquet tables of the bodies, orbits and spacecraft, for Python, R and Rust |
390
+ | [Serve it yourself](docs/guides/serve-it-yourself.md) | A small Node server over the package, that you host |
374
391
  | [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
375
392
  | [Coordinate conversions](docs/guides/coordinates.md) | Pure spherical, ecliptic, equatorial and horizontal coordinate conversions |
376
393
  | [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
@@ -477,7 +494,7 @@ Wakusei (惑星, わくせい) is Japanese for a planet.
477
494
  ## The family
478
495
 
479
496
  <!-- family:start (made by scripts/family-readme.mjs from scripts/family-template.mjs; change those, not this) -->
480
- Wakusei Planets is one of thirty-four packages, each made for the same site, each at
497
+ Wakusei Planets is one of forty-one packages, each made for the same site, each at
481
498
  [github.com/johnmorrisdotca](https://github.com/johnmorrisdotca) or [github.com/spxis](https://github.com/spxis). The code of every one is MIT.
482
499
 
483
500
  **Games — board**
@@ -490,6 +507,7 @@ Wakusei Planets is one of thirty-four packages, each made for the same site, eac
490
507
 
491
508
  **Games — cards & tiles**
492
509
 
510
+ - [Fuda Cards](https://github.com/johnmorrisdotca/fuda-cards) (札): collectible card frames with a true thickness, foil, stacks, wear and a binder, as two web components. [Demo](https://johnmorrisdotca.github.io/fuda-cards/).
493
511
  - [Hitotsu](https://github.com/johnmorrisdotca/hitotsu) (一つ): a colour-card shedding game for two to eight, with the house rules people play. [Demo](https://johnmorrisdotca.github.io/hitotsu/).
494
512
  - [Jarajara](https://github.com/johnmorrisdotca/jarajara) (ジャラジャラ): mahjong tiles drawn as SVG, stacked layouts, and the matching solitaire Awase. [Demo](https://johnmorrisdotca.github.io/jarajara/).
495
513
  - [Kumimoji](https://github.com/johnmorrisdotca/kumimoji) (組み文字): a crossword tile race, in English and Japanese kana. [Demo](https://johnmorrisdotca.github.io/kumimoji/).
@@ -516,21 +534,30 @@ Wakusei Planets is one of thirty-four packages, each made for the same site, eac
516
534
 
517
535
  - [Bushu](https://github.com/johnmorrisdotca/bushu) (部首): find a kanji by the parts it is made of. [Demo](https://johnmorrisdotca.github.io/bushu/).
518
536
  - [Hikidashi](https://github.com/johnmorrisdotca/hikidashi) (引き出し): a drawer of small Japanese text tools: era dates, kanji numerals, readings and sentence difficulty. [Demo](https://johnmorrisdotca.github.io/hikidashi/).
537
+ - [Jisho](https://github.com/johnmorrisdotca/jisho) (辞書): words of Japanese looked up by reading or written form, and the grades, JLPT levels, readings and look-alike pairs of 2,999 kanji. [Demo](https://johnmorrisdotca.github.io/jisho/).
519
538
  - [Kotoba](https://github.com/johnmorrisdotca/kotoba) (言葉): word lists and word-game rules in English, French, German and Japanese. [Demo](https://johnmorrisdotca.github.io/kotoba/).
520
539
 
540
+ **Space Program X**
541
+
542
+ - [Chikyu Earth](https://github.com/johnmorrisdotca/chikyu-earth) (地球): a line-drawn globe that turns at the Earth's own rate, with an optional realistic Earth from space and markers for any place. [Demo](https://johnmorrisdotca.github.io/chikyu-earth/).
543
+ - [Hoshi Stars](https://github.com/johnmorrisdotca/hoshi-stars) (星): the stars you can see without a telescope, with names, colours and distances, the constellations with their lines and boundaries, and the Messier objects, drawn on any of seven sky maps. [Demo](https://johnmorrisdotca.github.io/hoshi-stars/).
544
+ - [Uchusen Rockets](https://github.com/johnmorrisdotca/uchusen-rockets) (宇宙船): rockets drawn from sourced sizes, as line drawings and 3D views you can take apart and turn, with a check that a rocket really goes together. [Demo](https://johnmorrisdotca.github.io/uchusen-rockets/).
545
+ - [Wakusei Planets](https://github.com/johnmorrisdotca/wakusei-planets) (惑星): the Sun, the planets and their moons, as line drawings, shaded drawings and painted surface maps, with their real sizes, tilt and rotation. [Demo](https://johnmorrisdotca.github.io/wakusei-planets/).
546
+
521
547
  **Geography & data**
522
548
 
523
549
  - [address-plus](https://github.com/johnmorrisdotca/address-plus) (アドレスプラス): parse and format addresses in the United States, Canada, Japan, Australia, France, Germany and the United Kingdom. [Demo](https://johnmorrisdotca.github.io/address-plus/).
524
- - [Chikyu Earth](https://github.com/johnmorrisdotca/chikyu-earth) (地球): a line-drawn globe that turns at the Earth's own rate, with an optional realistic Earth from space and markers for any place. [Demo](https://johnmorrisdotca.github.io/chikyu-earth/).
525
550
  - [Chizu](https://github.com/johnmorrisdotca/chizu) (地図): maps of the world and of countries' regions, in English and Japanese, with a quiz and callouts. [Demo](https://johnmorrisdotca.github.io/chizu/).
551
+ - [Hako Devices](https://github.com/johnmorrisdotca/hako-devices) (箱): line drawings and 3D views of computers, phones, consoles and NAS boxes, from published sizes. [Demo](https://johnmorrisdotca.github.io/hako-devices/).
526
552
  - [Hata](https://github.com/johnmorrisdotca/hata) (旗): country and regional flags as SVG, at their true proportions and keyed by ISO code. [Demo](https://johnmorrisdotca.github.io/hata/).
553
+ - [Koyomi Calendars](https://github.com/johnmorrisdotca/koyomi-calendars) (暦): calendar-page icons and whole months as SVG, in light and dark, with page-turning from one day to the next. [Demo](https://johnmorrisdotca.github.io/koyomi-calendars/).
527
554
  - [Kuni](https://github.com/johnmorrisdotca/kuni) (国): countries and their regions, with ISO codes and names in English and Japanese. [Demo](https://johnmorrisdotca.github.io/kuni/).
528
- - [Wakusei Planets](https://github.com/johnmorrisdotca/wakusei-planets) (惑星): the Sun, the planets and their moons, as line drawings, shaded drawings and painted surface maps, with their real sizes, tilt and rotation. [Demo](https://johnmorrisdotca.github.io/wakusei-planets/).
529
555
 
530
556
  **Sports**
531
557
 
532
558
  - [Dougu Sports](https://github.com/johnmorrisdotca/dougu-sports) (道具): sports emblems as SVG: trophies, medals, crests, and the ball and gear of every sport, with optional 3D turning. [Demo](https://johnmorrisdotca.github.io/dougu-sports/).
533
559
  - [Kyogijo Stadiums](https://github.com/johnmorrisdotca/kyogijo-stadiums) (競技場): sports fields, rinks, courts and ballparks drawn to scale as SVG, with each team and the score on them. [Demo](https://johnmorrisdotca.github.io/kyogijo-stadiums/).
560
+ - [Meigen Sports](https://github.com/johnmorrisdotca/meigen-sports) (名言): sports quotations and on-this-day history. [Demo](https://johnmorrisdotca.github.io/meigen-sports/).
534
561
  - [Senshu Jerseys](https://github.com/johnmorrisdotca/senshu-jerseys) (選手): sports jerseys, sweaters, kits, caps, helmets and retired-number banners as SVG, front and back, with optional 2.5D turning. [Demo](https://johnmorrisdotca.github.io/senshu-jerseys/).
535
562
  - [Taisen Brackets](https://github.com/johnmorrisdotca/taisen-brackets) (対戦): a sport-agnostic tournament bracket, drawn as SVG, from a list of ties. [Demo](https://johnmorrisdotca.github.io/taisen-brackets/).
536
563
 
@@ -539,5 +566,5 @@ Wakusei Planets is one of thirty-four packages, each made for the same site, eac
539
566
  - [REST in Pieces](https://github.com/spxis/rest-in-pieces) (レスト・イン・ピーシーズ): seeded test data and REST APIs for frontend development, with latency and error drills. [Demo](https://spxis.github.io/rest-in-pieces/).
540
567
 
541
568
 
542
- **This package is Wakusei Planets.** The demos of all thirty-four share one header and footer, so each links the rest.
569
+ **This package is Wakusei Planets.** The demos of all forty-one share one header and footer, so each links the rest.
543
570
  <!-- family:end -->
@@ -0,0 +1,2 @@
1
+ /** Red, green and blue, 0 to 255, of a black body at `kelvin` (held between 1,000 and 40,000). */
2
+ export declare function blackBodyRgb(kelvin: number): [number, number, number];
@@ -0,0 +1,10 @@
1
+ // The colour of a black body, as red, green and blue from 0 to 255 (Tanner Helland's fit of the black-body locus, good to a few percent from 1,000 to 40,000 K). Shared by the star drawings and the star catalogue.
2
+ /** Red, green and blue, 0 to 255, of a black body at `kelvin` (held between 1,000 and 40,000). */
3
+ export function blackBodyRgb(kelvin) {
4
+ const t = Math.min(40_000, Math.max(1_000, kelvin)) / 100;
5
+ const red = t <= 66 ? 255 : 329.698727446 * (t - 60) ** -0.1332047592;
6
+ const green = t <= 66 ? 99.4708025861 * Math.log(t) - 161.1195681661 : 288.1221695283 * (t - 60) ** -0.0755148492;
7
+ const blue = t >= 66 ? 255 : t <= 19 ? 0 : 138.5177312231 * Math.log(t - 10) - 305.0447927307;
8
+ const clamp = (v) => Math.min(255, Math.max(0, v));
9
+ return [clamp(red), clamp(green), clamp(blue)];
10
+ }
package/dist/element.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { SharedRenderer } from "@johnmorrisdotca/kazoku-ui/renderer";
2
2
  import "./tables/ceres.ts";
3
3
  import "./tables/dwarfs.ts";
4
4
  import { type BodyId, type Look } from "./facts.ts";
5
+ import { type StarLook, type StarNumbers } from "./star.ts";
5
6
  export { TEXTURE_BASE, TEXTURE_FAR_BASE } from "./scene/textures.ts";
6
7
  import { type ThreeParts } from "./scene/body.ts";
7
8
  import { setThreeLoader } from "./scene/shared.ts";
@@ -25,6 +26,10 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
25
26
  * `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),
26
27
  * `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`).
27
28
  *
29
+ * 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.
30
+ * `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 8 for the shaded looks, 0.1 to 50 for the line drawing); a `<kazoku-view-controls for="...">` takes over and reads it.
31
+ * Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
32
+ *
28
33
  * @example
29
34
  * ```ts no-run
30
35
  * import { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
@@ -42,6 +47,13 @@ export declare class WakuseiBody extends HTMLElement {
42
47
  /** The radius of the body's disc on the screen in CSS pixels, at the picture's own size: what `grab-radius` on the shared view controls wants for a drag that keeps the touched point under the pointer. */
43
48
  get discRadius(): number;
44
49
  get body(): BodyId;
50
+ /**
51
+ * The star drawn instead of a body, when the `star` attribute is there: its numbers with the defaults filled in, its colour, the turn it shows, and `parts`, which says what is measured and what is invented.
52
+ * `undefined` for a body, or while the star's numbers are not complete (`data-error` says what is wrong). Set it to an object of numbers to draw a star, or to `null` to go back to the body.
53
+ */
54
+ get starLook(): StarLook | undefined;
55
+ set star(numbers: StarNumbers | string | null | undefined);
56
+ get star(): StarNumbers | undefined;
45
57
  get look(): Look;
46
58
  /** What the element is doing now. */
47
59
  get state(): WakuseiState;
package/dist/element.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
1
2
  import "./tables/ceres.js";
2
3
  import "./tables/dwarfs.js";
3
4
  import { loadMoonTheory } from "./tables/lazy.js";
@@ -5,6 +6,9 @@ import { orbitPath, nearMoons } from "./ephemeris.js";
5
6
  import { BODIES, ringReach } from "./facts.js";
6
7
  import { createGate, frameCap } from "./gate.js";
7
8
  import { lineSvg } from "./line.js";
9
+ import { starLook } from "./star.js";
10
+ import { starLineSvg } from "./star-line.js";
11
+ import { starLookOf } from "./scene/look.js";
8
12
  import { createLive, defaultTurn, REDUCED_TURN } from "./live.js";
9
13
  import { texturePaths } from "./scene/textures.js";
10
14
  export { TEXTURE_BASE, TEXTURE_FAR_BASE } from "./scene/textures.js";
@@ -19,6 +23,13 @@ const num = (value, fallback) => {
19
23
  const n = Number(value);
20
24
  return Number.isFinite(n) ? n : fallback;
21
25
  };
26
+ /** A device that should get the cheaper star: little memory or two cores or fewer. `quality="full"` or `quality="low"` on the element decides it instead. */
27
+ const weakDevice = () => {
28
+ const nav = typeof navigator === "undefined" ? undefined : navigator;
29
+ return nav !== undefined && ((nav.deviceMemory ?? 8) <= 2 || (nav.hardwareConcurrency ?? 8) <= 2);
30
+ };
31
+ /** The attributes that carry a star's numbers beside `star`, and the number each is. */
32
+ const STAR_ATTRS = ["temperature-k", "radius-sun", "luminosity-class", "rotation-days", "activity", "oblateness", "corona", "estimated"];
22
33
  const readLook = (value) => (value === "realistic" || value === "painted" || value === "illustrated" ? value : "line");
23
34
  const readTime = (value) => {
24
35
  if (value === null || value === "")
@@ -36,10 +47,9 @@ function turnPose(pose, axis, degrees) {
36
47
  }
37
48
  /** The half-width of a body's picture, in its radii, when it has no scale of its own: the globe takes a little under half the height, so its rings, glow and haze have room round it. */
38
49
  const ROOM = 2.2;
39
- function extentOf(id, options) {
40
- const f = BODIES[id];
41
- if (options.moons === true && id in BODIES && f.parent === undefined && id !== "sun") {
42
- const near = nearMoons(id);
50
+ function extentOf(f, options) {
51
+ if (options.moons === true && f.parent === undefined && f.id !== "sun") {
52
+ const near = nearMoons(f.id);
43
53
  const far = Math.max(1.8, ringReach(f) * 1.15, ...near.map((m) => m.reach * 1.1));
44
54
  return options.range ?? far;
45
55
  }
@@ -59,6 +69,13 @@ function clampPan(pan, extent, zoom) {
59
69
  const limit = 1 + 0.5 / half;
60
70
  return Math.max(-limit, Math.min(limit, pan));
61
71
  }
72
+ /**
73
+ * The zoom range of a body that carries its own controls. The floor is arbitrary: a tenth of Fit leaves room to see the whole body small. A line drawing is vector and has detail at any scale, so it goes to 50.
74
+ * The shaded looks stop at 8: the sharpest painted map is 2048 pixels round the body, sharp to about 1.5 times the size at Fit on a picture of the usual size and softening after that, and 8 times is as far as
75
+ * the shader's own detail (bands, craters, ring edges) carries before the map runs out.
76
+ */
77
+ const LINE_LIMITS = { zoomMin: 0.1, zoomMax: 50, tiltMax: 90 };
78
+ const SHADED_LIMITS = { zoomMin: 0.1, zoomMax: 8, tiltMax: 90 };
62
79
  const TEMPLATE = `<style>
63
80
  :host { display: block; width: var(--wakusei-size, 320px); max-width: 100%; aspect-ratio: 1 / 1; position: relative; contain: layout style; }
64
81
  #stage { position: absolute; inset: 0; }
@@ -71,6 +88,10 @@ const TEMPLATE = `<style>
71
88
  * `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),
72
89
  * `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`).
73
90
  *
91
+ * 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.
92
+ * `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 8 for the shaded looks, 0.1 to 50 for the line drawing); a `<kazoku-view-controls for="...">` takes over and reads it.
93
+ * Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
94
+ *
74
95
  * @example
75
96
  * ```ts no-run
76
97
  * import { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
@@ -83,7 +104,7 @@ const TEMPLATE = `<style>
83
104
  * ```
84
105
  */
85
106
  export class WakuseiBody extends HTMLElement {
86
- static observedAttributes = ["body", "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "lang", "labels"];
107
+ static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "lang", "labels"];
87
108
  #stage;
88
109
  #state = "line";
89
110
  #renderer;
@@ -117,6 +138,8 @@ export class WakuseiBody extends HTMLElement {
117
138
  #sceneState;
118
139
  #unsub;
119
140
  #reduce = false;
141
+ #hands;
142
+ #handsKey = "";
120
143
  #hover = () => void this.goLive();
121
144
  #onContext = (state) => {
122
145
  if (state === "unavailable")
@@ -137,9 +160,27 @@ export class WakuseiBody extends HTMLElement {
137
160
  return (this.getBoundingClientRect().width / 2) * this.#fill();
138
161
  }
139
162
  get body() {
163
+ if (this.hasAttribute("star"))
164
+ return "sun";
140
165
  const id = this.getAttribute("body");
141
166
  return id !== null && id in BODIES ? id : "earth";
142
167
  }
168
+ /**
169
+ * The star drawn instead of a body, when the `star` attribute is there: its numbers with the defaults filled in, its colour, the turn it shows, and `parts`, which says what is measured and what is invented.
170
+ * `undefined` for a body, or while the star's numbers are not complete (`data-error` says what is wrong). Set it to an object of numbers to draw a star, or to `null` to go back to the body.
171
+ */
172
+ get starLook() {
173
+ return this.#star();
174
+ }
175
+ set star(numbers) {
176
+ if (numbers === null || numbers === undefined)
177
+ this.removeAttribute("star");
178
+ else
179
+ this.setAttribute("star", typeof numbers === "string" ? numbers : JSON.stringify(numbers));
180
+ }
181
+ get star() {
182
+ return this.#star()?.numbers;
183
+ }
143
184
  get look() {
144
185
  return readLook(this.getAttribute("look"));
145
186
  }
@@ -179,8 +220,14 @@ export class WakuseiBody extends HTMLElement {
179
220
  this.#io.observe(this);
180
221
  }
181
222
  document.addEventListener("visibilitychange", this.#onHidden);
182
- this.#unsub = onRegister(() => this.#queue());
223
+ this.#unsub = onRegister(() => {
224
+ this.#carry();
225
+ this.#queue();
226
+ });
183
227
  this.#applyHover();
228
+ for (const name of ["pointerdown", "wheel", "keydown"])
229
+ this.addEventListener(name, this.#measure, true);
230
+ this.#carry();
184
231
  this.#queue();
185
232
  }
186
233
  disconnectedCallback() {
@@ -190,6 +237,11 @@ export class WakuseiBody extends HTMLElement {
190
237
  document.removeEventListener("visibilitychange", this.#onHidden);
191
238
  this.#unsub?.();
192
239
  this.#applyHover(false);
240
+ for (const name of ["pointerdown", "wheel", "keydown"])
241
+ this.removeEventListener(name, this.#measure, true);
242
+ this.#hands?.unbind();
243
+ this.#hands = undefined;
244
+ this.#handsKey = "";
193
245
  this.#disposeView(true);
194
246
  }
195
247
  attributeChangedCallback(name) {
@@ -199,6 +251,8 @@ export class WakuseiBody extends HTMLElement {
199
251
  this.#clockFromAttributes();
200
252
  if (name === "live")
201
253
  this.#applyHover();
254
+ if (name === "live" || name === "look" || name === "body")
255
+ this.#carry();
202
256
  this.#lastAnchors = -1;
203
257
  this.#queue();
204
258
  }
@@ -233,14 +287,83 @@ export class WakuseiBody extends HTMLElement {
233
287
  /** The shared controllers' camera: `yaw` turns the body about its pole, `tilt` tips its top away from you as it grows (a drag up moves the surface up), `roll` turns the picture clockwise about the line of sight, `zoom` scales it, and `panX` and `panY` move it by that many CSS pixels from the middle. */
234
288
  setView(view) {
235
289
  const half = Math.max(1, this.clientWidth) / 2;
236
- this.#yaw = view.yaw ?? 0;
237
- this.#tilt = view.tilt ?? 0;
238
- this.#roll = view.roll ?? 0;
239
- this.#zoom = view.zoom ?? 1;
240
- this.#panX = -(view.panX ?? 0) / half;
241
- this.#panY = (view.panY ?? 0) / half;
290
+ const [yaw, tilt, roll, zoom, panX, panY] = [view.yaw ?? 0, view.tilt ?? 0, view.roll ?? 0, view.zoom ?? 1, -(view.panX ?? 0) / half, (view.panY ?? 0) / half];
291
+ if (yaw === this.#yaw && tilt === this.#tilt && roll === this.#roll && zoom === this.#zoom && panX === this.#panX && panY === this.#panY)
292
+ return;
293
+ [this.#yaw, this.#tilt, this.#roll, this.#zoom, this.#panX, this.#panY] = [yaw, tilt, roll, zoom, panX, panY];
294
+ this.dispatchEvent(new CustomEvent("wakusei-view", { detail: { yaw: this.#yaw, tilt: this.#tilt, roll: this.#roll, zoom: this.#zoom, panX: view.panX ?? 0, panY: view.panY ?? 0 } }));
242
295
  this.#queue(true);
243
296
  }
297
+ /** Take the shared hands, unless the picture is a still (`live="off"`) or another package's drawing (the Earth's line look); the look decides the zoom range, so a new look takes new hands. */
298
+ #carry() {
299
+ const on = this.getAttribute("live") !== "off" && !(this.look === "line" && delegates.has(this.body));
300
+ const key = `${on}|${this.look === "line"}`;
301
+ if (this.#handsKey === key)
302
+ return;
303
+ this.#hands?.unbind();
304
+ this.#handsKey = key;
305
+ this.#hands = carryControls(this, { on, limits: this.look === "line" ? LINE_LIMITS : SHADED_LIMITS, grabRadius: this.discRadius, objectSize: { width: this.discRadius * 2, height: this.discRadius * 2 }, onChange: (view) => this.setView(view) });
306
+ if (this.#zoom !== 1 || this.#yaw !== 0 || this.#tilt !== 0 || this.#panX !== 0 || this.#panY !== 0 || this.#roll !== 0) {
307
+ if (!this.hasAttribute("data-kazoku-bar"))
308
+ this.setView({});
309
+ }
310
+ }
311
+ /** The disc is a different size on the screen after the picture or the page is resized: a gesture is told before it starts. */
312
+ #measure = () => {
313
+ const controller = this.#hands?.controller;
314
+ if (controller === undefined)
315
+ return;
316
+ const disc = this.discRadius;
317
+ if (disc <= 0)
318
+ return;
319
+ controller.grabRadius = disc;
320
+ controller.objectSize = { width: disc * 2, height: disc * 2 };
321
+ };
322
+ // --- the star ---------------------------------------------------------------------------------------------------------------------------------------
323
+ #starKey = "";
324
+ #starMade;
325
+ /** The star the attributes describe: `star` is a JSON object of numbers, the name of a star registered with `registerStarLook`, or empty with the numbers in the other attributes, which are laid over it. */
326
+ #star() {
327
+ if (!this.hasAttribute("star"))
328
+ return undefined;
329
+ const quality = this.getAttribute("quality") === "low" || (this.getAttribute("quality") !== "full" && weakDevice()) ? "low" : "full";
330
+ const key = JSON.stringify([quality, this.getAttribute("star"), ...STAR_ATTRS.map((name) => this.getAttribute(name)), starLookOf(this.getAttribute("star") ?? "")?.key]);
331
+ if (key === this.#starKey)
332
+ return this.#starMade;
333
+ this.#starKey = key;
334
+ this.#starMade = undefined;
335
+ this.removeAttribute("data-error");
336
+ try {
337
+ const value = (this.getAttribute("star") ?? "").trim();
338
+ let base = {};
339
+ if (value.startsWith("{"))
340
+ base = JSON.parse(value);
341
+ else if (value !== "")
342
+ base = starLookOf(value)?.numbers ?? { name: value };
343
+ const pick = (name) => this.getAttribute(name);
344
+ const number = (name) => (pick(name) === null ? undefined : Number(pick(name)));
345
+ const numbers = {
346
+ ...base,
347
+ ...(pick("temperature-k") !== null ? { temperatureK: number("temperature-k") } : {}),
348
+ ...(pick("radius-sun") !== null ? { radiusSun: number("radius-sun") } : {}),
349
+ ...(pick("luminosity-class") !== null ? { luminosityClass: pick("luminosity-class") } : {}),
350
+ ...(pick("rotation-days") !== null ? { rotationDays: number("rotation-days") } : {}),
351
+ ...(pick("activity") !== null ? { activity: number("activity") } : {}),
352
+ ...(pick("oblateness") !== null ? { oblateness: number("oblateness") } : {}),
353
+ ...(pick("corona") !== null ? { corona: number("corona") } : {}),
354
+ ...(pick("estimated") !== null ? { estimated: pick("estimated").split(",").map((part) => part.trim()).filter((part) => part !== "") } : {}),
355
+ };
356
+ this.#starMade = starLook(numbers, { quality });
357
+ }
358
+ catch (error) {
359
+ this.setAttribute("data-error", `star: ${error instanceof Error ? error.message : String(error)}`);
360
+ }
361
+ return this.#starMade;
362
+ }
363
+ /** The facts of what is drawn: the body's, or the star's (the Sun's with its own size, shape and outlines). */
364
+ #facts() {
365
+ return this.#star()?.facts ?? BODIES[this.body];
366
+ }
244
367
  // --- the clock ------------------------------------------------------------------------------------------------------------------------------------
245
368
  #clockFromAttributes() {
246
369
  const t = readTime(this.getAttribute("time"));
@@ -248,10 +371,11 @@ export class WakuseiBody extends HTMLElement {
248
371
  this.#start = t === "now" ? Date.now() : t;
249
372
  }
250
373
  #request() {
251
- const moons = this.hasAttribute("moons");
374
+ const star = this.#star();
375
+ const moons = this.hasAttribute("moons") && !this.hasAttribute("star");
252
376
  return {
253
377
  id: this.body,
254
- start: this.#start ?? (moons ? Date.now() : undefined),
378
+ start: this.hasAttribute("star") ? undefined : (this.#start ?? (moons ? Date.now() : undefined)),
255
379
  startedAt: this.#startedAt,
256
380
  rate: Math.max(-1e7, Math.min(1e7, num(this.getAttribute("rate"), 1))),
257
381
  moons,
@@ -261,13 +385,13 @@ export class WakuseiBody extends HTMLElement {
261
385
  phase: this.hasAttribute("phase") ? num(this.getAttribute("phase"), 0) : undefined,
262
386
  spin: this.hasAttribute("meridian") ? num(this.getAttribute("meridian"), 0) : undefined,
263
387
  },
264
- turn: (this.hasAttribute("turn") ? num(this.getAttribute("turn"), 0) : this.getAttribute("live") === "off" ? 0 : defaultTurn(this.body)) * (this.#reduce ? REDUCED_TURN : 1),
388
+ turn: (this.hasAttribute("turn") ? num(this.getAttribute("turn"), 0) : this.getAttribute("live") === "off" ? 0 : star !== undefined ? star.turn.degreesPerSecond : defaultTurn(this.body)) * (this.#reduce ? REDUCED_TURN : 1),
265
389
  };
266
390
  }
267
391
  /** The picture moves on its own: a turn, or time running faster than the clock. */
268
392
  get #moving() {
269
393
  const r = this.#request();
270
- const turning = r.turn !== 0 || ((this.#start !== undefined || r.moons) && r.rate !== 1);
394
+ const turning = r.turn !== 0 || (r.start !== undefined && r.rate !== 1);
271
395
  return this.#reduce ? r.turn !== 0 : turning;
272
396
  }
273
397
  // --- the state of the scene --------------------------------------------------------------------------------------------------------------------
@@ -285,7 +409,7 @@ export class WakuseiBody extends HTMLElement {
285
409
  const scaleTo = this.getAttribute("scale-to");
286
410
  const range = this.hasAttribute("range") ? num(this.getAttribute("range"), 0) : undefined;
287
411
  const span = num(this.getAttribute("span-km"), 0);
288
- const extent = extentOf(this.body, {
412
+ const extent = extentOf(this.#facts(), {
289
413
  tight: this.getAttribute("fit") === "tight",
290
414
  spanKm: span > 0 ? span : undefined,
291
415
  scaleTo: scaleTo !== null && scaleTo in BODIES ? scaleTo : undefined,
@@ -376,6 +500,12 @@ export class WakuseiBody extends HTMLElement {
376
500
  this.setAttribute("aria-label", this.#label());
377
501
  if (this.hasAttribute("size"))
378
502
  this.style.setProperty("--wakusei-size", `${num(this.getAttribute("size"), 320)}px`);
503
+ if (this.hasAttribute("star") && this.#star() === undefined) {
504
+ this.#disposeView(true);
505
+ this.#stage.innerHTML = "";
506
+ this.#set("line");
507
+ return;
508
+ }
379
509
  const delegate = this.look === "line" ? delegates.get(this.body) : undefined;
380
510
  if (delegate !== undefined && (await this.#delegated(delegate)))
381
511
  return;
@@ -393,7 +523,7 @@ export class WakuseiBody extends HTMLElement {
393
523
  this.#set("line");
394
524
  return;
395
525
  }
396
- const sig = `${this.body}|${this.look}`;
526
+ const sig = `${this.#star()?.key ?? this.body}|${this.look}`;
397
527
  if (this.#view !== undefined && this.#viewSig !== sig) {
398
528
  if (this.#view.live)
399
529
  this.#wantLive = true;
@@ -429,8 +559,11 @@ export class WakuseiBody extends HTMLElement {
429
559
  }
430
560
  }
431
561
  #label() {
432
- const f = BODIES[this.body];
562
+ const star = this.#star();
433
563
  const ja = this.getAttribute("lang") === "ja";
564
+ if (star !== undefined)
565
+ 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}`;
566
+ const f = BODIES[this.body];
434
567
  const looks = { line: ja ? "線画" : "line drawing", realistic: ja ? "表面の地図" : "painted surface", painted: ja ? "表面の地図" : "painted surface", illustrated: ja ? "イラスト" : "illustrated drawing" };
435
568
  return ja ? `${f.name.ja}の${looks[this.look]}` : `${f.name.en}, ${looks[this.look]}`;
436
569
  }
@@ -442,7 +575,9 @@ export class WakuseiBody extends HTMLElement {
442
575
  const paper = getComputedStyle(this).getPropertyValue("--wakusei-paper").trim();
443
576
  const scene = this.#sceneOf(frame);
444
577
  const size = 480;
445
- const html = lineSvg(this.body, {
578
+ const star = this.#star();
579
+ const draw = star === undefined ? (options) => lineSvg(this.body, options) : (options) => starLineSvg(star, options);
580
+ const html = draw({
446
581
  size,
447
582
  pose: scene.pose,
448
583
  ...(r.moons ? { moons: true, ...(frame.time !== undefined ? { time: frame.time } : {}), range: scene.extent, moonsAt: (scene.moons ?? []).map((m) => ({ id: m.id, x: m.x, y: m.y, z: m.z, distance: Math.hypot(m.x, m.y, m.z) })), orbits: new Map((scene.moons ?? []).filter((m) => m.orbit !== undefined).map((m) => [m.id, m.orbit])) } : {}),
@@ -457,7 +592,7 @@ export class WakuseiBody extends HTMLElement {
457
592
  }
458
593
  #key(state) {
459
594
  const moons = (state.moons ?? []).map((m) => `${m.id}:${m.x.toFixed(1)},${m.y.toFixed(1)}`).join(";");
460
- return `${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}`;
595
+ 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}`;
461
596
  }
462
597
  // Replacing a view keeps the renderer lease; leaving 3D gives it back.
463
598
  #disposeView(releaseRenderer = false) {
@@ -485,11 +620,13 @@ export class WakuseiBody extends HTMLElement {
485
620
  const state = this.#sceneOf(frame);
486
621
  this.#sceneState = state;
487
622
  this.#viewKey = this.#key(state);
488
- this.#viewSig = `${this.body}|${this.look}`;
623
+ this.#viewSig = `${this.#star()?.key ?? this.body}|${this.look}`;
489
624
  this.#stilled = false;
490
625
  this.#stage.innerHTML = "";
626
+ const star = this.#star();
491
627
  const item = createBodyItem({
492
628
  id: this.body,
629
+ ...(star === undefined ? {} : { shaded: star.look, facts: star.facts, assetKey: `star:${star.key}` }),
493
630
  look: this.look === "illustrated" ? "realistic" : "painted",
494
631
  key: this.#viewKey,
495
632
  state: () => this.#sceneState ?? state,
@@ -537,7 +674,7 @@ export class WakuseiBody extends HTMLElement {
537
674
  const scaleTo = this.getAttribute("scale-to");
538
675
  const span = num(this.getAttribute("span-km"), 0);
539
676
  const half = span > 0 ? span : scaleTo !== null && scaleTo in BODIES ? BODIES[scaleTo].radiusKm * 1.06 : 0;
540
- return half > 0 ? Math.max(0.01, Math.min(1, BODIES[this.body].radiusKm / half)) : this.getAttribute("fit") === "tight" ? 1 : 1 / ROOM;
677
+ return half > 0 ? Math.max(this.hasAttribute("star") ? 0.001 : 0.01, Math.min(1, this.#facts().radiusKm / half)) : this.getAttribute("fit") === "tight" ? 1 : 1 / ROOM;
541
678
  }
542
679
  /** Make the view's still, once, when it is in sight. */
543
680
  #still() {