@johnmorrisdotca/wakusei-planets 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -6
- package/README.md +258 -2
- package/dist/element.d.ts +2 -2
- package/dist/element.js +12 -6
- package/dist/line.js +1 -1
- package/dist/scene/body.d.ts +2 -0
- package/dist/scene/body.js +12 -2
- package/dist/scene/glsl.js +2 -1
- package/dist/scene/painter.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.6.0 - 2026-11-03
|
|
4
|
+
|
|
5
|
+
The demo's pickers, and a scale that is a scale.
|
|
6
|
+
|
|
7
|
+
- **A compact picker** (MODULES-285): the ten bodies in one row, and when the one chosen has moons, its moons on the row below, in the same place; no long list down the page. The moons' own section is gone. Every picture in it is a picture, in the line, the realistic and the painted look: a test looks at all 35 (10 bodies and 25 moons) for blank and single-colour pictures. (The broken thumbnails of 0.3.0 were the tiles being drawn to scale, which 0.3.1 stopped.) The same picker is in "Put it in your page" (MODULES-286), so the body for the code is chosen beside the code; Copy's word can be read (it was ink on ink).
|
|
8
|
+
- **The buttons under the view stay where they are** (MODULES-283): one push button for each body of the system (the planet and its moons), the chosen one pressed, and others pressed with it to see them side by side under the view, at equal sizes or at their true relative sizes (`span-km`), kept in the address (`?with=phobos,deimos&rel=1`). The orbit-distance layout is not made yet.
|
|
9
|
+
- **To scale says what it is against** (MODULES-284): "Its planet" (for a moon), "Earth" or "Sun", and draws it so: Deimos is 0.0018 times Mars's radius, a magnified picture beside it with a line, the caption says so. `?scale=1&ref=planet`.
|
|
10
|
+
- **Deimos is drawn whole** (MODULES-287): an irregular body reaches past its mean radius along its longest axis, and its picture was cut off at the sides.
|
|
11
|
+
- **Every body is fitted by its globe** (MODULES-293): at about half the view's height, the same for all, so Saturn's rings, the Sun's glow and a haze have room, and the Sun is no smaller than a planet. `fit="tight"` on an element gives the old fit (thumbnails).
|
|
12
|
+
- **The sky shows the real phase** (MODULES-294): in "As seen from Earth" the night side is dark (no wrapped terminator, no rim of air round it), so Venus a few days from new is a thin crescent, not a full disc.
|
|
13
|
+
- **A line under every choice** (MODULES-298) says what it does, in English and Japanese, always on the page and tied to its button with `aria-describedby`.
|
|
14
|
+
|
|
15
|
+
## 0.5.1 - 2026-11-03
|
|
16
|
+
|
|
17
|
+
- kazoku-ui 0.12.0: the demo's view controls have a zoom slider, on top of 0.11's Centre button and exact grab.
|
|
18
|
+
- Documentation: an architecture guide and a fuller upgrading guide, each with its Japanese twin; a code builder page (`builder.html`); eight new pictures; a longer README whose examples run (`pnpm test:readme`); and every release of this changelog dated. No behaviour changed.
|
|
19
|
+
- The README opens with the package's thumbnail, and the demo carries it as its link preview (og:image) and publishes the card, a dark card and an icon on Pages at `thumbnail.png`, `thumbnail-dark.png` and `icon.png`.
|
|
20
|
+
|
|
21
|
+
## 0.5.0 - 2026-11-03
|
|
4
22
|
|
|
5
23
|
The bodies for someone else's three.js scene.
|
|
6
24
|
|
|
@@ -9,7 +27,7 @@ The bodies for someone else's three.js scene.
|
|
|
9
27
|
- `orientation(id, ms)` and `moonOffset(id, ms)`: a body's pole and prime meridian, and a moon's place from its planet, in the same axes.
|
|
10
28
|
- A guide, "In your own three.js scene", in English and Japanese.
|
|
11
29
|
|
|
12
|
-
## 0.4.0
|
|
30
|
+
## 0.4.0 - 2026-11-03
|
|
13
31
|
|
|
14
32
|
"Put it in your page" is a configurator.
|
|
15
33
|
|
|
@@ -18,7 +36,7 @@ The bodies for someone else's three.js scene.
|
|
|
18
36
|
- A guide, "Put it in your page", in English and Japanese.
|
|
19
37
|
- **kazoku-ui 0.11.0**: the view controls' Centre button (it appears once the body is dragged away), a pan that keeps a quarter of the body in sight (told the body's size with `object-size`), and a drag that keeps the touched point under the pointer (`grab-radius`). The 0.3.1 stopgap that made Fit re-centre is gone.
|
|
20
38
|
|
|
21
|
-
## 0.3.1
|
|
39
|
+
## 0.3.1 - 2026-11-03
|
|
22
40
|
|
|
23
41
|
The Earth is a body like the others, and "To scale" is a comparison.
|
|
24
42
|
|
|
@@ -28,7 +46,7 @@ The Earth is a body like the others, and "To scale" is a comparison.
|
|
|
28
46
|
- **The body cannot be dragged out of the view** (a quarter of it stays in), and Fit centres it and returns it to its first angle.
|
|
29
47
|
- The README's pictures are absolute addresses pinned to the release's tag (npm's page showed a different picture from GitHub's), and a test holds it (`pnpm readme:images` pins them after a version bump).
|
|
30
48
|
|
|
31
|
-
## 0.3.0
|
|
49
|
+
## 0.3.0 - 2026-11-03
|
|
32
50
|
|
|
33
51
|
Painted moons, Saturn's rings from Cassini, and a drag that goes the right way up.
|
|
34
52
|
|
|
@@ -40,7 +58,7 @@ Painted moons, Saturn's rings from Cassini, and a drag that goes the right way u
|
|
|
40
58
|
- **A drag up moves the surface up** (it moved it down), in every look: the controls' tilt tipped the pole toward you as it grew, and now tips the top of the body away, so the near surface goes up, as in chikyu-earth 0.9.1. Drag right, the right arrow and the up arrow agree. Test (`e2e/drag.demo.ts`): a real pointer and real key presses on Mars (line, shaded, painted), Venus and the Moon (painted); the vertical checks fail on 0.2.0.
|
|
41
59
|
- `scripts/make-textures.py` makes the moons and the ring strip too (`python3 scripts/make-textures.py io saturn-ring`) and writes each source's file page, licence and credit into `textures/SOURCES.json`.
|
|
42
60
|
|
|
43
|
-
## 0.2.0
|
|
61
|
+
## 0.2.0 - 2026-11-02
|
|
44
62
|
|
|
45
63
|
The painted looks.
|
|
46
64
|
|
|
@@ -48,7 +66,7 @@ The painted looks.
|
|
|
48
66
|
- Small pictures by default: the 512 and 1024 pixel widths are in the package (0.53 MB in all); a view that is zoomed in fetches the 2048 pixel width from the repository by jsDelivr's GitHub address (`texture-far-base` to serve it yourself). A picture that fails to load leaves the shaded look drawn, and no picture is asked for twice.
|
|
49
67
|
- A texture is freed when a sharper one replaces it and when the element leaves.
|
|
50
68
|
|
|
51
|
-
## 0.1.0
|
|
69
|
+
## 0.1.0 - 2026-11-03
|
|
52
70
|
|
|
53
71
|
The first release. The package, to the family's standard from the start: a demo and an embed page on GitHub Pages, a documentation site in English and Japanese, a README with every way to use it (each one tested), the shared release workflow with its freeze test.
|
|
54
72
|
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
<p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/thumbnail-dark.png"><img src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/thumbnail.png" alt="Wakusei Planets: Mars, the Earth, Saturn with its rings, Jupiter and Neptune, shaded in 3D, side by side." width="1200"></picture></a></p>
|
|
2
|
+
|
|
1
3
|
<h1 align="center">Wakusei Planets <sub>惑星</sub></h1>
|
|
2
4
|
|
|
3
5
|
<p align="center"><strong>The Sun, the planets and their moons, for the web.</strong><br>
|
|
@@ -11,9 +13,9 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
|
|
|
11
13
|
|
|
12
14
|
<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>
|
|
13
15
|
|
|
14
|
-
<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.
|
|
16
|
+
<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.6.0/docs/images/hero-desk.png" width="640"></p>
|
|
15
17
|
|
|
16
|
-
<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.
|
|
18
|
+
<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.6.0/docs/images/lineup-desk.png" width="640"></p>
|
|
17
19
|
|
|
18
20
|
## One minute
|
|
19
21
|
|
|
@@ -68,6 +70,37 @@ The same tag with the shared [kazoku-ui](https://github.com/johnmorrisdotca/kazo
|
|
|
68
70
|
|
|
69
71
|
A bundled app imports it: `import "@johnmorrisdotca/wakusei-planets/element"` (and `import { lineSvg } from "@johnmorrisdotca/wakusei-planets"` for the SVG string, which needs no browser). For the shaded look add the body's own entry point, `import "@johnmorrisdotca/wakusei-planets/jupiter"`, and `three` (an optional peer).
|
|
70
72
|
|
|
73
|
+
## Who it is for
|
|
74
|
+
|
|
75
|
+
- **A developer who wants a planet on a page** with one tag, no build step, and a drawing that is an SVG before any 3D has loaded.
|
|
76
|
+
- **A teacher, writer or museum** who needs the Sun, the planets and their moons at their real sizes and tilts, with every number traceable to the IAU, NASA or JPL.
|
|
77
|
+
- **A maker of sky tools** who wants a planet's pole, phase, ring opening and its moons' places for any date and time as plain data, on a server or in a browser.
|
|
78
|
+
- **A three.js developer** who wants the bodies as objects for a scene of their own.
|
|
79
|
+
|
|
80
|
+
## Features
|
|
81
|
+
|
|
82
|
+
- The Sun, the eight planets, Pluto and 25 moons, each with its real size, flattening, axial tilt, pole and rotation as data.
|
|
83
|
+
- Three looks: a clean `line` drawing (an SVG string), a shaded `realistic` sphere worked out in a shader, and a `painted` surface map from public-domain imagery.
|
|
84
|
+
- The sky for any date and time: a body's pole, rotation, phase and ring opening as the Earth sees it, and a planet's moons where they are then.
|
|
85
|
+
- One WebGL context for the page, nothing drawn at rest, at most thirty frames a second, and everything freed when an element leaves.
|
|
86
|
+
- A pure side that runs on a server: `BODIES`, `apparent`, `system`, `orbitPath`, `portrait` and `lineSvg`.
|
|
87
|
+
- `embedCode` writes the code that puts a body in a page for HTML, a module, React, Vue, Angular, Svelte or an iframe.
|
|
88
|
+
- `painter.make` hands a body to a three.js scene of your own.
|
|
89
|
+
- Every guide in English and Japanese; the demo's words too.
|
|
90
|
+
|
|
91
|
+
## Use it in your project
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
npm install @johnmorrisdotca/wakusei-planets three
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```ts no-run
|
|
98
|
+
import "@johnmorrisdotca/wakusei-planets/element";
|
|
99
|
+
import "@johnmorrisdotca/wakusei-planets/saturn";
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Import the element once in client code, and the entry point of each body you draw in a shaded look (or `/all`). A line drawing needs neither `three` nor an entry point. [Bundlers](docs/guides/bundlers.md) and [Frameworks](docs/guides/frameworks.md) go through it.
|
|
103
|
+
|
|
71
104
|
## Three looks
|
|
72
105
|
|
|
73
106
|
| Look | What it is | Needs |
|
|
@@ -145,6 +178,229 @@ The pure side has no DOM: `BODIES`, `apparent(id, time)`, `system(planet, time)`
|
|
|
145
178
|
|
|
146
179
|
Sizes, flattening, poles and rotation are the IAU's and NASA's; planet positions are JPL's approximate elements; the Moon's are Meeus's largest terms; the other moons are JPL's mean elements. Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
|
|
147
180
|
|
|
181
|
+
## Examples
|
|
182
|
+
|
|
183
|
+
Every `ts` block in this README is type-checked and run against the package as npm packs it (`pnpm test:readme`).
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
import { BODIES, MOONS_OF, PLANET_IDS } from "@johnmorrisdotca/wakusei-planets";
|
|
187
|
+
|
|
188
|
+
BODIES.saturn.radiusKm; // 60268
|
|
189
|
+
PLANET_IDS.length; // 9
|
|
190
|
+
Object.values(MOONS_OF).flat().length; // 25
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The planets' state as the Earth sees them on a date:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { apparent } from "@johnmorrisdotca/wakusei-planets";
|
|
197
|
+
|
|
198
|
+
const saturn = apparent("saturn", Date.UTC(2026, 10, 2));
|
|
199
|
+
console.log(saturn.subObserverLat.toFixed(1), saturn.illumination.toFixed(2));
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
A planet's moons where they are on a date, as offsets from it in the planet's radii:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
import { system } from "@johnmorrisdotca/wakusei-planets";
|
|
206
|
+
|
|
207
|
+
const { moons } = system("jupiter", Date.UTC(2026, 10, 2));
|
|
208
|
+
console.log(moons.map((moon) => `${moon.id} ${moon.x.toFixed(1)}`).join(", "));
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
A line drawing as an SVG string, with no browser:
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import { lineSvg } from "@johnmorrisdotca/wakusei-planets";
|
|
215
|
+
|
|
216
|
+
const svg = lineSvg("mars", { size: 200, tilt: 15, lang: "ja" });
|
|
217
|
+
if (!svg.startsWith("<svg") || !svg.includes("火星")) throw new Error("not a Mars drawing");
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The code that puts a body in a page, for any of the ways a page is made:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
import { EMBED_KINDS, embedCode } from "@johnmorrisdotca/wakusei-planets";
|
|
224
|
+
|
|
225
|
+
for (const kind of EMBED_KINDS) console.log(kind, embedCode({ body: "mars", look: "line", size: 240 }, kind).split("\n")[0]);
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
A body for your own three.js scene, in the browser:
|
|
229
|
+
|
|
230
|
+
The moons' places on an orbit, as points for a line you draw yourself:
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { orbitPath } from "@johnmorrisdotca/wakusei-planets";
|
|
234
|
+
|
|
235
|
+
const path = orbitPath("io", Date.UTC(2026, 10, 2), 8);
|
|
236
|
+
console.log(path.length / 3, "points");
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
How much of the Moon is lit on a date:
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
import { apparent } from "@johnmorrisdotca/wakusei-planets";
|
|
243
|
+
|
|
244
|
+
const moon = apparent("moon", Date.UTC(2026, 10, 24, 14));
|
|
245
|
+
if (moon.illumination < 0.9) throw new Error("the Moon is nearly full on 24 November 2026");
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
A page that cannot run script uses an iframe of the embed page:
|
|
249
|
+
|
|
250
|
+
```html
|
|
251
|
+
<iframe src="https://johnmorrisdotca.github.io/wakusei-planets/embed.html?body=mars&look=line" title="Mars" width="320" height="320" style="border:0"></iframe>
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
```ts no-run
|
|
255
|
+
import * as THREE from "three";
|
|
256
|
+
import { painter } from "@johnmorrisdotca/wakusei-planets/painter";
|
|
257
|
+
|
|
258
|
+
const scene = new THREE.Scene();
|
|
259
|
+
const jupiter = painter.make(THREE, "Jupiter", { look: "realistic", invalidate: () => {}, ratio: 1 });
|
|
260
|
+
scene.add(jupiter.object);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
A body that turns by itself and a moving sky, in HTML:
|
|
264
|
+
|
|
265
|
+
```html
|
|
266
|
+
<wakusei-body body="jupiter" look="line" moons time="now" rate="600" size="360"></wakusei-body>
|
|
267
|
+
<wakusei-body body="venus" look="realistic" time="2026-11-02T12:00:00Z" turn="12" live="hover"></wakusei-body>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## The code builder
|
|
271
|
+
|
|
272
|
+
[The code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html) is one screen: choose which planet's system, the body, the look, the size, the sky and the turning, then pick how your page is made and copy the code. It is built from `embedCode`, so it writes what the package writes. [Put it in your page](docs/guides/put-it-in-your-page.md) is its guide.
|
|
273
|
+
|
|
274
|
+
## API
|
|
275
|
+
|
|
276
|
+
The reference is a site, made from the source's own doc comments: every export has a summary, its parameters, what it returns and an example that runs when the site is built. [Open the reference](https://johnmorrisdotca.github.io/wakusei-planets/docs/).
|
|
277
|
+
|
|
278
|
+
| Entry point | What it gives |
|
|
279
|
+
| --- | --- |
|
|
280
|
+
| `@johnmorrisdotca/wakusei-planets` | The pure side: `BODIES`, `apparent`, `system`, `orbitPath`, `portrait`, `lineSvg`, `embedCode`. No browser. |
|
|
281
|
+
| `.../element` | `<wakusei-body>`; three.js is loaded only for a shaded look. |
|
|
282
|
+
| `.../look` | What a body needs to be drawn with three.js. |
|
|
283
|
+
| `.../painter` | The bodies as objects for a scene of your own. |
|
|
284
|
+
| `.../all` | Every body's shaded look, at once. |
|
|
285
|
+
| `.../saturn`, `.../jupiter` and the rest | One body's shaded look. `.../moons-jupiter` and its siblings: a planet's moons. |
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import * as pure from "@johnmorrisdotca/wakusei-planets";
|
|
289
|
+
|
|
290
|
+
console.log(Object.keys(pure).sort().join(", "));
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## Guides
|
|
294
|
+
|
|
295
|
+
Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-started.md).
|
|
296
|
+
|
|
297
|
+
| Guide | What it is for |
|
|
298
|
+
| --- | --- |
|
|
299
|
+
| [Getting started](docs/guides/getting-started.md) | A body on a page |
|
|
300
|
+
| [HTML and CDN](docs/guides/html-and-cdn.md) | A script tag from jsDelivr or unpkg |
|
|
301
|
+
| [Bundlers](docs/guides/bundlers.md) | Vite and webpack, only the bodies you need |
|
|
302
|
+
| [Frameworks](docs/guides/frameworks.md) | React, Vue, Svelte, Angular |
|
|
303
|
+
| [Embed in an iframe](docs/guides/embed-in-an-iframe.md) | No script of your own |
|
|
304
|
+
| [Put it in your page](docs/guides/put-it-in-your-page.md) | Set up a body and copy the code |
|
|
305
|
+
| [Looks and bodies](docs/guides/looks-and-bodies.md) | The looks and each body's entry point |
|
|
306
|
+
| [Moons and time](docs/guides/moons-and-time.md) | The sky on a date, time that runs fast |
|
|
307
|
+
| [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
|
|
308
|
+
| [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
|
|
309
|
+
| [How it works](docs/guides/how-it-works.md) | Where the numbers come from |
|
|
310
|
+
| [Architecture](docs/guides/architecture.md) | How the layers fit |
|
|
311
|
+
| [Troubleshooting](docs/guides/troubleshooting.md) | Something does not appear |
|
|
312
|
+
| [Upgrading](docs/guides/upgrading.md) | What to act on between versions |
|
|
313
|
+
|
|
314
|
+
## Limits
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
import { BODIES } from "@johnmorrisdotca/wakusei-planets";
|
|
318
|
+
|
|
319
|
+
BODIES.pluto.kind; // "dwarf-planet"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
- A fact with no source is left out, never guessed. Moon positions are JPL's mean elements and are accurate to a few degrees on the orbit, about the size of the moon on screen.
|
|
323
|
+
- The shaded `realistic` look works out a surface from the body's real colours and features in a shader: it is a likeness, not a map. The `painted` look is a real map where one exists; the Sun, Saturn, Uranus and Neptune have no global map, so theirs are made from one photograph each, as `NOTICE.md` says.
|
|
324
|
+
- A shaded look needs WebGL. Without it the line drawing is drawn.
|
|
325
|
+
- Saturn and Uranus have their rings drawn.
|
|
326
|
+
- Pictures for the painted look are 1.31 MB in the package at 512 and 1024 pixels; a sharper picture is fetched when you zoom in.
|
|
327
|
+
|
|
328
|
+
## Accessibility
|
|
329
|
+
|
|
330
|
+
- Every `<wakusei-body>` is an image with an accessible name from its body and look, such as "Saturn, line drawing", or the Japanese name with `lang="ja"`.
|
|
331
|
+
- A reader who prefers reduced motion gets no turning and no moving sky.
|
|
332
|
+
- A body can be turned, tipped, zoomed and panned with the keyboard, and the view controls are at least 48 pixels.
|
|
333
|
+
- Names and labels are in English and Japanese (`lang="ja"`).
|
|
334
|
+
|
|
335
|
+
```html
|
|
336
|
+
<wakusei-body body="saturn" look="line" lang="ja" size="320"></wakusei-body>
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## Browser and runtime support
|
|
340
|
+
|
|
341
|
+
- The package needs Node 24 or later. The pure side runs in Node and in any current browser; the element needs a current browser.
|
|
342
|
+
- The shaded looks need WebGL and `three` `>=0.160.0` (an optional peer).
|
|
343
|
+
- The tests run the demo in Chromium and WebKit, at a phone's width and a desk's, and draw WebGL in software.
|
|
344
|
+
|
|
345
|
+
## Languages
|
|
346
|
+
|
|
347
|
+
The names and labels in the element are in English and Japanese (`lang`), and so are the demo's words and every guide: each guide in [docs/guides](docs/guides) has a twin in [docs/guides/ja](docs/guides/ja/getting-started.md), one language to a page.
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
import { lineSvg } from "@johnmorrisdotca/wakusei-planets";
|
|
351
|
+
|
|
352
|
+
console.log(lineSvg("saturn", { size: 160, lang: "ja" }).includes("土星"));
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Japanese names and labels need only the `lang` attribute; the SVG string takes the same option.
|
|
356
|
+
|
|
357
|
+
## Architecture
|
|
358
|
+
|
|
359
|
+
The lowest layers are pure and import with no browser: the facts, the positions, the pose and the line drawing. The shaded looks are one entry point for each body, registered by name, and every `<wakusei-body>` shares one WebGL context through kazoku-ui. [Architecture](docs/guides/architecture.md) has the layers.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
import { portrait } from "@johnmorrisdotca/wakusei-planets";
|
|
363
|
+
|
|
364
|
+
const pose = portrait("uranus");
|
|
365
|
+
console.log(pose.pole.length);
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Development
|
|
369
|
+
|
|
370
|
+
```sh
|
|
371
|
+
pnpm install
|
|
372
|
+
pnpm check # lint, types, unit tests, the build and the packed package
|
|
373
|
+
pnpm test:readme # every ts block of the README, type-checked and run against the packed package
|
|
374
|
+
pnpm test:usage # every way of using it in the README and the guides, built and opened
|
|
375
|
+
pnpm docs:check # the reference site's checks
|
|
376
|
+
pnpm test:demo # the demo and the docs site in a real browser
|
|
377
|
+
pnpm dev # the demo on http://127.0.0.1:8300/wakusei-planets/
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
The pictures in `docs/images` are made by the package's own script:
|
|
381
|
+
|
|
382
|
+
```sh
|
|
383
|
+
ONLY=hero-saturn-painted,builder-desk pnpm screenshots
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## Contributing
|
|
387
|
+
|
|
388
|
+
Work in a git worktree from `origin/main`, one branch per change:
|
|
389
|
+
|
|
390
|
+
```sh
|
|
391
|
+
git worktree add ../wakusei-work -b my-change origin/main
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md). The rules that matter most: draw from public facts and cite them, pictures only from public-domain sources, a fact with no source is left out, and performance is not optional.
|
|
395
|
+
|
|
396
|
+
## Changes
|
|
397
|
+
|
|
398
|
+
[CHANGELOG.md](CHANGELOG.md) lists every release with its date.
|
|
399
|
+
|
|
400
|
+
## Licence
|
|
401
|
+
|
|
402
|
+
MIT: see [LICENSE](LICENSE). The pictures are public-domain NASA, USGS and JPL imagery, each file credited in [NOTICE.md](NOTICE.md).
|
|
403
|
+
|
|
148
404
|
## The name
|
|
149
405
|
|
|
150
406
|
Wakusei (惑星, わくせい) is Japanese for a planet.
|
package/dist/element.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
|
|
|
25
25
|
* console.log(TEXTURE_BASE);
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.
|
|
28
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.6.0/dist/textures/";
|
|
29
29
|
/**
|
|
30
30
|
* 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
|
|
31
31
|
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
@@ -37,7 +37,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
|
|
|
37
37
|
* console.log(TEXTURE_FAR_BASE);
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.
|
|
40
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.6.0/textures/";
|
|
41
41
|
/**
|
|
42
42
|
* The `<wakusei-body>` custom element: a body of the solar system, drawn in a look.
|
|
43
43
|
*
|
package/dist/element.js
CHANGED
|
@@ -48,6 +48,8 @@ const readTime = (value) => {
|
|
|
48
48
|
return Number.isFinite(ms) ? ms : undefined;
|
|
49
49
|
};
|
|
50
50
|
/** The half-width of the picture, in body radii, for a body alone, with a scale to another body, or with its moons. */
|
|
51
|
+
/** 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. */
|
|
52
|
+
const ROOM = 2.2;
|
|
51
53
|
function extentOf(id, options) {
|
|
52
54
|
const f = BODIES[id];
|
|
53
55
|
if (options.moons === true && id in BODIES && f.parent === undefined && id !== "sun") {
|
|
@@ -59,7 +61,11 @@ function extentOf(id, options) {
|
|
|
59
61
|
return options.spanKm / f.radiusKm;
|
|
60
62
|
if (options.scaleTo !== undefined)
|
|
61
63
|
return (BODIES[options.scaleTo].radiusKm * 1.06) / f.radiusKm;
|
|
62
|
-
|
|
64
|
+
if (options.tight !== true)
|
|
65
|
+
return ROOM;
|
|
66
|
+
// tight (a thumbnail): the picture holds the body and its rings, and an irregular body (Deimos, Phobos, Nix, Hydra) whole along its longest axis
|
|
67
|
+
const longest = f.axesKm === undefined ? 1 : Math.max(...f.axesKm) / f.radiusKm;
|
|
68
|
+
return Math.max(1.06, ringReach(f) * 1.04, longest * 1.06);
|
|
63
69
|
}
|
|
64
70
|
/** Keep the body in the picture: at least a quarter of its width stays inside the edge, however far the view is moved. `pan` is in half-widths of the picture. */
|
|
65
71
|
function clampPan(pan, extent, zoom) {
|
|
@@ -91,7 +97,7 @@ const TEMPLATE = `<style>
|
|
|
91
97
|
* ```
|
|
92
98
|
*/
|
|
93
99
|
export class WakuseiBody extends HTMLElement {
|
|
94
|
-
static observedAttributes = ["body", "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "live", "texture-base", "texture-far-base", "lang", "labels"];
|
|
100
|
+
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"];
|
|
95
101
|
#stage;
|
|
96
102
|
#state = "line";
|
|
97
103
|
#renderer;
|
|
@@ -293,7 +299,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
293
299
|
const scaleTo = this.getAttribute("scale-to");
|
|
294
300
|
const range = this.hasAttribute("range") ? num(this.getAttribute("range"), 0) : undefined;
|
|
295
301
|
const span = num(this.getAttribute("span-km"), 0);
|
|
296
|
-
const extent = extentOf(this.body, { ...(span > 0 ? { spanKm: span } : {}), ...(scaleTo !== null && scaleTo in BODIES ? { scaleTo } : {}), moons: r.moons, ...(range !== undefined && range > 0 ? { range } : {}) });
|
|
302
|
+
const extent = extentOf(this.body, { ...(this.getAttribute("fit") === "tight" ? { tight: true } : {}), ...(span > 0 ? { spanKm: span } : {}), ...(scaleTo !== null && scaleTo in BODIES ? { scaleTo } : {}), moons: r.moons, ...(range !== undefined && range > 0 ? { range } : {}) });
|
|
297
303
|
const moons = r.moons
|
|
298
304
|
? frame.moons
|
|
299
305
|
.filter((m) => m.distance <= extent * 1.05)
|
|
@@ -303,7 +309,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
303
309
|
return { id: m.id, x: rotated[0], y: rotated[1], z: rotated[2], ...(orbit !== undefined ? { orbit: tiltBy === 0 ? orbit : this.#tiltedOrbit(m.id, orbit, tiltBy) } : {}) };
|
|
304
310
|
})
|
|
305
311
|
: undefined;
|
|
306
|
-
return { pose: { pole, meridian, light }, extent, zoom: this.#zoom, panX: clampPan(this.#panX, extent, this.#zoom), panY: clampPan(this.#panY, extent, this.#zoom), ...(moons !== undefined ? { moons } : {}) };
|
|
312
|
+
return { pose: { pole, meridian, light }, extent, sky: frame.time !== undefined, zoom: this.#zoom, panX: clampPan(this.#panX, extent, this.#zoom), panY: clampPan(this.#panY, extent, this.#zoom), ...(moons !== undefined ? { moons } : {}) };
|
|
307
313
|
}
|
|
308
314
|
#tilted = new Map();
|
|
309
315
|
#tiltedOrbit(id, orbit, tilt) {
|
|
@@ -442,7 +448,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
442
448
|
size,
|
|
443
449
|
pose: scene.pose,
|
|
444
450
|
...(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])) } : {}),
|
|
445
|
-
...(scaleTo !== null || this.hasAttribute("span-km") ? { fill: this.#fill() } : {}),
|
|
451
|
+
...(scaleTo !== null || this.hasAttribute("span-km") || this.getAttribute("fit") !== "tight" ? { fill: this.#fill() } : {}),
|
|
446
452
|
...(this.getAttribute("lang") === "ja" ? { lang: "ja" } : {}),
|
|
447
453
|
...(this.getAttribute("labels") === "off" ? { labels: false } : {}),
|
|
448
454
|
...(stroke !== "" ? { stroke } : {}),
|
|
@@ -532,7 +538,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
532
538
|
const scaleTo = this.getAttribute("scale-to");
|
|
533
539
|
const span = num(this.getAttribute("span-km"), 0);
|
|
534
540
|
const half = span > 0 ? span : scaleTo !== null && scaleTo in BODIES ? BODIES[scaleTo].radiusKm * 1.06 : 0;
|
|
535
|
-
return half > 0 ? Math.max(0.01, Math.min(1, BODIES[this.body].radiusKm / half)) : 1;
|
|
541
|
+
return half > 0 ? Math.max(0.01, Math.min(1, BODIES[this.body].radiusKm / half)) : this.getAttribute("fit") === "tight" ? 1 : 1 / ROOM;
|
|
536
542
|
}
|
|
537
543
|
/** Make the view's still, once, when it is in sight. */
|
|
538
544
|
#still() {
|
package/dist/line.js
CHANGED
|
@@ -227,7 +227,7 @@ export function lineSvg(id, options = {}) {
|
|
|
227
227
|
if (options.moons === true && facts.parent === undefined && id !== "sun")
|
|
228
228
|
return systemSvg(id, options, size, stroke, paper, hair, head);
|
|
229
229
|
const pose = poseFor(id, options);
|
|
230
|
-
const reach = Math.max(ringReach(facts), id === "sun" ? 1.
|
|
230
|
+
const reach = Math.max(ringReach(facts), id === "sun" ? 1.08 : 1);
|
|
231
231
|
const fit = options.fill === undefined ? 0.94 / reach : options.fill;
|
|
232
232
|
const zoom = options.zoom ?? 1;
|
|
233
233
|
const frame = { cx: (size / 2) * (1 - (options.panX ?? 0)), cy: (size / 2) * (1 + (options.panY ?? 0)), r: (size / 2) * fit * zoom };
|
package/dist/scene/body.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export interface SceneState {
|
|
|
23
23
|
panX: number;
|
|
24
24
|
panY: number;
|
|
25
25
|
moons?: readonly MoonDraw[];
|
|
26
|
+
/** The body is drawn as the sky shows it at a date: its real phase, with no light on the night side from a wrapped terminator or a rim of air. */
|
|
27
|
+
sky?: boolean;
|
|
26
28
|
/** The smallest a moon is drawn, in CSS pixels across its radius. Default 2.5. */
|
|
27
29
|
minMoonPx?: number;
|
|
28
30
|
/** The colour of the orbit lines, `#rrggbb`. */
|
package/dist/scene/body.js
CHANGED
|
@@ -23,6 +23,7 @@ function makeBodyMaterial(T, look, painted) {
|
|
|
23
23
|
uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
|
|
24
24
|
uAtmos: { value: col3(T, a?.colour ?? [0, 0, 0]) },
|
|
25
25
|
uAtmosPow: { value: a?.power ?? 3 },
|
|
26
|
+
uRimBase: { value: 0.12 },
|
|
26
27
|
uEmissive: { value: look.emissive === true ? 1 : 0 },
|
|
27
28
|
uRingN: { value: new T.Vector3(0, 1, 0) },
|
|
28
29
|
uRingR: { value: new T.Vector2(1, 2) },
|
|
@@ -56,6 +57,8 @@ export function createBodyItem(options) {
|
|
|
56
57
|
const geometry = assets.acquire("wk:sphere", () => new T.SphereGeometry(1, 128, 64), (g) => g.dispose());
|
|
57
58
|
const shader = assets.acquire(`wk:body:${options.id}:r`, () => makeBodyMaterial(T, look, false), (m) => m.dispose());
|
|
58
59
|
const paintedMaterial = wantPainted ? assets.acquire(`wk:body:${options.id}:p`, () => makeBodyMaterial(T, look, true), (m) => m.dispose()) : undefined;
|
|
60
|
+
const baseWrap = look.wrap ?? (look.atmosphere === undefined ? 0.04 : 0.3);
|
|
61
|
+
const baseAmbient = look.ambient ?? 0.04;
|
|
59
62
|
const scene = new T.Scene();
|
|
60
63
|
const camera = new T.OrthographicCamera(-1, 1, 1, -1, 0.1, 400);
|
|
61
64
|
camera.position.set(0, 0, 200);
|
|
@@ -279,8 +282,15 @@ export function createBodyItem(options) {
|
|
|
279
282
|
mat.uniforms.uRingTex.value = ringTexture;
|
|
280
283
|
}
|
|
281
284
|
}
|
|
282
|
-
for (const mat of [shader, paintedMaterial])
|
|
283
|
-
mat
|
|
285
|
+
for (const mat of [shader, paintedMaterial]) {
|
|
286
|
+
if (mat === undefined)
|
|
287
|
+
continue;
|
|
288
|
+
mat.uniforms.uLight.value.copy(v3(T, state.pose.light));
|
|
289
|
+
const sky = state.sky === true;
|
|
290
|
+
mat.uniforms.uWrap.value = sky ? 0.02 : (mat === paintedMaterial ? baseWrap : baseWrap);
|
|
291
|
+
mat.uniforms.uAmbient.value = sky ? 0.012 : baseAmbient;
|
|
292
|
+
mat.uniforms.uRimBase.value = sky ? 0.02 : 0.12;
|
|
293
|
+
}
|
|
284
294
|
if (glow !== undefined)
|
|
285
295
|
glow.scale.setScalar(1);
|
|
286
296
|
// a sharper picture, when the disc is big enough to show it
|
package/dist/scene/glsl.js
CHANGED
|
@@ -61,6 +61,7 @@ uniform float uLimb;
|
|
|
61
61
|
uniform float uWrap;
|
|
62
62
|
uniform vec3 uAtmos;
|
|
63
63
|
uniform float uAtmosPow;
|
|
64
|
+
uniform float uRimBase;
|
|
64
65
|
uniform float uEmissive;
|
|
65
66
|
uniform vec3 uRingN;
|
|
66
67
|
uniform vec2 uRingR;
|
|
@@ -106,7 +107,7 @@ void main() {
|
|
|
106
107
|
vec3 alb = pow(s.rgb, vec3(2.2));
|
|
107
108
|
vec3 lit = alb * (uAmbient + (1.0 - uAmbient) * diff * 1.18);
|
|
108
109
|
float rim = pow(1.0 - mu, uAtmosPow);
|
|
109
|
-
lit += pow(uAtmos, vec3(2.2)) * rim * (
|
|
110
|
+
lit += pow(uAtmos, vec3(2.2)) * rim * (uRimBase + (1.0 - uRimBase) * clamp(dg * 1.6 + 0.35, 0.0, 1.0));
|
|
110
111
|
lit *= mix(1.0, pow(mu, 0.45), uLimb);
|
|
111
112
|
gl_FragColor = vec4(pow(lit, vec3(1.0 / 2.2)), 1.0);
|
|
112
113
|
}`;
|
package/dist/scene/painter.js
CHANGED
|
@@ -87,6 +87,7 @@ function paint(T, id, context, bases) {
|
|
|
87
87
|
uWrap: { value: look.wrap ?? (a === undefined ? 0.04 : 0.3) },
|
|
88
88
|
uAtmos: { value: new T.Vector3(...(a?.colour ?? [0, 0, 0])) },
|
|
89
89
|
uAtmosPow: { value: a?.power ?? 3 },
|
|
90
|
+
uRimBase: { value: 0.12 },
|
|
90
91
|
uEmissive: { value: look.emissive === true ? 1 : 0 },
|
|
91
92
|
uRingN: { value: new T.Vector3(0, 1, 0) },
|
|
92
93
|
uRingR: { value: new T.Vector2(1, 2) },
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.6.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.6.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|
|
@@ -184,7 +184,8 @@
|
|
|
184
184
|
"docs:check": "pnpm build && node scripts/docs-site.mjs check",
|
|
185
185
|
"size": "node scripts/docs-site.mjs size",
|
|
186
186
|
"test:usage": "pnpm site && node scripts/check-usage.ts",
|
|
187
|
-
"check:standard": "node scripts/check-standard.mjs"
|
|
187
|
+
"check:standard": "node scripts/check-standard.mjs",
|
|
188
|
+
"test:readme": "pnpm build && node scripts/check-usage.ts readme"
|
|
188
189
|
},
|
|
189
190
|
"devDependencies": {
|
|
190
191
|
"@angular/common": "^22.2.4",
|
|
@@ -222,7 +223,7 @@
|
|
|
222
223
|
},
|
|
223
224
|
"packageManager": "pnpm@10.28.0",
|
|
224
225
|
"dependencies": {
|
|
225
|
-
"@johnmorrisdotca/kazoku-ui": "^0.
|
|
226
|
+
"@johnmorrisdotca/kazoku-ui": "^0.12.0"
|
|
226
227
|
},
|
|
227
228
|
"peerDependencies": {
|
|
228
229
|
"@johnmorrisdotca/chikyu-earth": ">=0.10.0",
|