@johnmorrisdotca/wakusei-planets 0.26.0 → 0.27.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 +8 -0
- package/NOTICE.md +30 -0
- package/README.md +5 -4
- package/dist/element.d.ts +6 -2
- package/dist/element.js +75 -37
- package/dist/portrait/scene3d.js +5 -4
- package/dist/scene/body.d.ts +11 -0
- package/dist/scene/body.js +61 -8
- package/dist/scene/detail.d.ts +73 -0
- package/dist/scene/detail.js +289 -0
- package/dist/scene/extent.d.ts +10 -0
- package/dist/scene/extent.js +21 -0
- package/dist/scene/glsl.d.ts +23 -2
- package/dist/scene/glsl.js +119 -4
- package/dist/scene/look.d.ts +26 -0
- package/dist/scene/look.js +29 -0
- package/dist/scene/reach.d.ts +34 -0
- package/dist/scene/reach.js +44 -0
- package/dist/scene/textures.d.ts +16 -2
- package/dist/scene/textures.js +21 -0
- package/dist/scene/tiles.d.ts +108 -0
- package/dist/scene/tiles.js +228 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.27.0] - 2026-11-09
|
|
6
|
+
|
|
7
|
+
- **Close zoom: every shaded body zooms as far as its detail goes, with finer map tiles** (MODULES-646). `<wakusei-body>` stopped at 8x for every body, because the painted maps are 2048 pixels round; in a moons picture that was Saturn a third of the frame wide, with + greyed. The limit is now worked out for each body from the widest map it has, the size of its picture and how soft its surface is (`src/scene/reach.ts`; the table of all 47 bodies is in the new guide, Close zoom and map tiles): Saturn goes to 36x alone and 1000x in its moons picture, Mars, the Moon and the Earth to 44x alone, ten moons to 22x, and no body below 8x. Behind it: **finer map tiles** (`scripts/make-body-tiles.py`, `pnpm tiles`): the big public-domain maps of 15 bodies (Mars, the Moon, the Earth, Mercury, Io, Callisto, Rhea, Enceladus, Tethys, Dione, Iapetus, Triton, Pluto, Charon, Mimas) cut into 512 pixel tiles up to 16384 pixels round, built by the Pages workflow and served beside the demo (not in git, not in the npm package: 3552 tiles, 76.5 MB); the part in view is laid over the 2048 map as one window of at most 16 tiles (about 22 MB of graphics memory), fetched when the zoom needs it and the view has settled, and let go with every decoded tile 4 seconds after it does not. The new `tiles` attribute says where they are (`off` for none; by default the demo site's, unless `texture-base` names your own pictures), `stats.tiles` and `stats.zoomMax` say what the element is doing. **Generic detail**: where a map is enlarged more than a quarter, the shader adds octaves of noise (grain for a rock, faint streaks along the latitudes for a gas giant, none for the Sun or a star) so a body never goes smooth; it is noise, not a feature of the body, and the guide says so. **Saturn's rings** get generic ringlets where the strip is enlarged; the strip, the gaps and the shadows are as they were. The sphere has 192 by 96 segments (was 128 by 64), so its edge stays round at a deep zoom. `<wakusei-portrait>` (8x) and `<wakusei-space>` (3x) are unchanged. The freeze test's limits are unchanged and it passes.
|
|
8
|
+
|
|
9
|
+
## [0.26.1] - 2026-11-09
|
|
10
|
+
|
|
11
|
+
- A planet off the middle of the view is no longer cut by a straight edge (MODULES-739, MODULES-742 part 4). The body, the space view and their pictures fill the whole stage, and the pan, the roll and the turn agree with the shape of the view: the shaded body's pan is in the pixels the controls say on a wide or tall view (it moved by the aspect ratio too far), the portrait's 3D view no longer moves everything twice as far as a pan asks (its camera was put at the centre of the view and the window was too), the body and the space view are laid on the view with its four edges (WebKit left the body as tall as it is wide), and the gesture tests take the square in the middle where they turn a picture. `checkGestures` also runs on the star page and the embed page (a body, and a flat portrait).
|
|
12
|
+
|
|
5
13
|
## [0.26.0] - 2026-11-09
|
|
6
14
|
|
|
7
15
|
- **The compressed scale keeps the order of the orbits** (MODULES-742). The Moon was drawn outside Venus's orbit (10 Earth radii out, with the Sun 44 away) and the Earth was not on its own orbit. The Moon is now 3.5 Earth radii out and an astronomical unit is 70 Earth radii; the Sun, the bodies and the orbit lines (the Earth's too) all go through one mapping, `placeBodies` and `orbitLine`, so every body lies on its own orbit line, and the moons of Mars, Jupiter, Saturn, Uranus, Neptune and Pluto are drawn nearer when they would cross the next planet's orbit (`moonDistance`). Tests: every body is on its orbit line at four dates in both scales, and no moon's orbit reaches a neighbouring planet's. `SUN_COMPRESSED` is 70 (was 44) and `MOON_COMPRESSED` 3.5 (was 10).
|
package/NOTICE.md
CHANGED
|
@@ -82,6 +82,36 @@ Venus, Saturn, Neptune and the Sun were replaced from Solar System Scope's equir
|
|
|
82
82
|
|
|
83
83
|
The package does not ship the 2048 pixel widths: `TEXTURE_FAR_BASE` fetches them from this repository by jsDelivr's GitHub address when a view is zoomed in. The 512 and 1024 pixel widths of every picture, and the ring strip, are 1.94 MB in the package (the nine of 0.2.0 were 0.53 MB; Ceres adds 0.13 MB and Tethys, Dione, Iapetus, Triton and Charon 0.45 MB). Where a source does not say where its map is centred, its row says what the picture was matched to.
|
|
84
84
|
|
|
85
|
+
## Finer map tiles
|
|
86
|
+
|
|
87
|
+
`scripts/make-body-tiles.py` cuts the big public-domain maps of 15 bodies into a pyramid of 512 pixel WebP tiles (docs/guides/close-zoom.md): 3552 tiles and 76.5 MB in all. The tiles are built in CI and served by GitHub Pages beside the demo at `/tiles/`; they are not in git and not in the npm package. Each source is downloaded once, and a file whose SHA-256 is not the one below is never used. The licence of each source on Wikimedia Commons was read from Commons' own metadata on 2026-11-09 and is public domain for every one of them; they are the files the 2048 pictures above were made from (`scripts/make-textures.py` reads the same metadata and stops unless it says public domain), taken here at their full size. The two NASA sources are not on Commons: their pages are named below.
|
|
88
|
+
|
|
89
|
+
NASA's terms, read on 2026-11-09 at https://www.nasa.gov/nasa-brand-center/images-and-media/ (NASA Images and Media Usage Guidelines): "NASA content – images, audio, video, and media files used in the rendition of 3-dimensional models, such as texture maps and polygon data in any format – generally are not subject to copyright in the United States." and "NASA should be acknowledged as the source of the material." USGS and JPL maps are works of the United States government. Not endorsed by NASA, the USGS or any mission; no NASA insignia or logotype is used.
|
|
90
|
+
|
|
91
|
+
A tile is the package's own 2048 picture of the body, enlarged, with the source's detail added where the source really holds data. So its colour is the 2048 picture's, and the credits of that picture (the table above) apply to the tile as well as the credits of the source below.
|
|
92
|
+
|
|
93
|
+
| Body | Tiles | Source file (page, size, address, SHA-256) | Licence | Credit | What was done |
|
|
94
|
+
|---|---|---|---|---|---|
|
|
95
|
+
| Mercury | levels 1 to 2, up to 8192 x 4096 (160 tiles, 6.0 MB) | [Mercury MESSENGER MDIS Basemap EnhancedColor Mosaic Global 32ppd.jpg](https://commons.wikimedia.org/wiki/File:Mercury_MESSENGER_MDIS_Basemap_EnhancedColor_Mosaic_Global_32ppd.jpg), 11520 x 5760, https://upload.wikimedia.org/wikipedia/commons/4/41/Mercury_MESSENGER_MDIS_Basemap_EnhancedColor_Mosaic_Global_32ppd.jpg, SHA-256 `e9d394bfd4ab472aa1463878b389e7f84cb898ac072211d68cc5f457fe2f4fa0` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / Johns Hopkins University Applied Physics Laboratory / Carnegie Institution of Washington (MESSENGER MDIS global basemap, enhanced colour, 32 pixels a degree) | Detail from MESSENGER's brightness only (the source is in false colour); the colour is the 2048 picture's (Solar System Scope's map, CC BY 4.0, above), so these tiles carry that credit too |
|
|
96
|
+
| Mars | levels 1 to 3, up to 16384 x 8192 (672 tiles, 21.4 MB) | [Mars Viking MDIM21 ClrMosaic 1km.jpg](https://commons.wikimedia.org/wiki/File:Mars_Viking_MDIM21_ClrMosaic_1km.jpg), 21339 x 10670, https://upload.wikimedia.org/wikipedia/commons/1/1f/Mars_Viking_MDIM21_ClrMosaic_1km.jpg, SHA-256 `fdfcd335559c3dc67052b7e8a9565d850e336ac0d1f3ea7f5eb7826ffb44ecb2` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / Jet Propulsion Laboratory / U.S. Geological Survey (Viking Mars Digital Image Mosaic 2.1, colour, 1 km a pixel) | Detail added to the 2048 picture; the poles the mosaic has no data for are the 2048 picture's |
|
|
97
|
+
| The Moon | levels 1 to 3, up to 16384 x 8192 (672 tiles, 11.9 MB) | [lroc_color_poles_16k.tif](https://svs.gsfc.nasa.gov/4720/), 16384 x 8192, https://svs.gsfc.nasa.gov/vis/a000000/a004700/a004720/lroc_color_poles_16k.tif, SHA-256 `dbff4356479764d89f9fd7722140043eddbc2cafbad4dec5950858e2df77ac54` | Not subject to copyright (NASA content, see above); SVS asks for the credit on the page: "Please give credit for this item to: NASA's Scientific Visualization Studio" | NASA's Scientific Visualization Studio (Ernie Wright, Noah Petro), CGI Moon Kit: Lunar Reconnaissance Orbiter Camera colour map with the poles filled, 16384 pixels across | Detail added to the 2048 picture (the same map, finer) |
|
|
98
|
+
| Earth | levels 1 to 3, up to 16384 x 8192 (672 tiles, 8.9 MB) | [world.topo.bathy.200409.3x21600x10800.jpg](https://science.nasa.gov/earth/earth-observatory/blue-marble-next-generation/), 21600 x 10800, https://assets.science.nasa.gov/content/dam/science/esd/eo/images/bmng/bmng-topography-bathymetry/september/world.topo.bathy.200409.3x21600x10800.jpg, SHA-256 `863036b622ba3dab4eb4ffb7149730b02cfa433ce49672e9b7267022051e04a2` | Not subject to copyright (NASA content, see above); the page asks to credit "NASA Earth Observatory" | NASA Earth Observatory (Reto Stockli): Blue Marble Next Generation with topography and bathymetry, September 2004, 21600 pixels across | Detail added to the 2048 picture (the same month and layer, finer) |
|
|
99
|
+
| Pluto | levels 1 to 1, up to 4096 x 2048 (32 tiles, 0.4 MB) | [Pluto color mapmosaic.jpg](https://commons.wikimedia.org/wiki/File:Pluto_color_mapmosaic.jpg), 5926 x 2963, https://upload.wikimedia.org/wikipedia/commons/a/ad/Pluto_color_mapmosaic.jpg, SHA-256 `d63da5ee9eab8d0b98ebef3c0cdc3a92676d7c9b247b2383294fb5da5c67a71a` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute (New Horizons global colour mosaic) | Turned half a turn to put longitude 0 in the middle, as the 2048 picture was; the polar night to the south is the 2048 picture's |
|
|
100
|
+
| Charon | levels 1 to 1, up to 4096 x 2048 (32 tiles, 0.5 MB) | [Charon map iau1803c.jpg](https://commons.wikimedia.org/wiki/File:Charon_map_iau1803c.jpg), 6000 x 3000, https://upload.wikimedia.org/wikipedia/commons/3/39/Charon_map_iau1803c.jpg, SHA-256 `a8c2ff578b810f3ec84a42751d3a00920fa4c610f5125e938e294aa4e0804405` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute (New Horizons, IAU image iau1803c) | The polar night to the south is the 2048 picture's |
|
|
101
|
+
| Io | levels 1 to 2, up to 8192 x 4096 (160 tiles, 1.4 MB) | [Io from Galileo and Voyager missions.jpg](https://commons.wikimedia.org/wiki/File:Io_from_Galileo_and_Voyager_missions.jpg), 11445 x 3643, https://upload.wikimedia.org/wikipedia/commons/e/e4/Io_from_Galileo_and_Voyager_missions.jpg, SHA-256 `e5523d1ea98d2ad03ca4dcb7c73aebb1a869b4fba6c941f7f77f0fba17c64dae` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL (Galileo SSI and Voyager images) | A strip of an equirectangular map (57.3 degrees each side of the equator), turned half a turn; the poles are the 2048 picture's |
|
|
102
|
+
| Callisto | levels 1 to 2, up to 8192 x 4096 (160 tiles, 2.1 MB) | [Callisto equatorial.jpg](https://commons.wikimedia.org/wiki/File:Callisto_equatorial.jpg), 11921 x 4617, https://upload.wikimedia.org/wikipedia/commons/a/a3/Callisto_equatorial.jpg, SHA-256 `f262cd1f307a9d7adf05c39499ad6bcc636c45af102b5ab243df6585834b4f80` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | USGS (Callisto equatorial region map, I-2770, from Voyager and Galileo images) | A Mercator strip (57 degrees each side) put on the sphere; the poles are the 2048 picture's |
|
|
103
|
+
| Rhea | levels 1 to 2, up to 8192 x 4096 (160 tiles, 5.5 MB) | [Rhea Color Map.jpg](https://commons.wikimedia.org/wiki/File:Rhea_Color_Map.jpg), 12015 x 6008, https://upload.wikimedia.org/wikipedia/commons/2/21/Rhea_Color_Map.jpg, SHA-256 `4a3f4c5cca6ec558a6dcd664ee818dd700df527fc07fe623d1c56d4e2ae81bc4` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL-Caltech / Space Science Institute / Lunar and Planetary Institute (Cassini, PIA18438) | Turned half a turn, colour kept at 55 percent |
|
|
104
|
+
| Enceladus | levels 1 to 2, up to 8192 x 4096 (160 tiles, 6.4 MB) | [Enceladus Color Map.jpg](https://commons.wikimedia.org/wiki/File:Enceladus_Color_Map.jpg), 15960 x 7980, https://upload.wikimedia.org/wikipedia/commons/a/aa/Enceladus_Color_Map.jpg, SHA-256 `5b60d0161efd659f6d95281559ad4b30826fd02ee72944dbb3f8b7679f65ed4d` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL-Caltech / Space Science Institute / Lunar and Planetary Institute (Cassini, PIA18435) | Turned half a turn, colour kept at 30 percent |
|
|
105
|
+
| Tethys | levels 1 to 2, up to 8192 x 4096 (160 tiles, 4.7 MB) | [Tethys Color Map.jpg](https://commons.wikimedia.org/wiki/File:Tethys_Color_Map.jpg), 13467 x 6734, https://upload.wikimedia.org/wikipedia/commons/4/40/Tethys_Color_Map.jpg, SHA-256 `aa3c249de2432699157638dae11c6f5c5e22c3dda94dd803af8666269f1a3da4` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL-Caltech / Space Science Institute / Lunar and Planetary Institute (Cassini, PIA18439) | Turned half a turn, colour kept at 55 percent |
|
|
106
|
+
| Dione | levels 1 to 2, up to 8192 x 4096 (160 tiles, 3.8 MB) | [Dione Color Map.jpg](https://commons.wikimedia.org/wiki/File:Dione_Color_Map.jpg), 14134 x 7067, https://upload.wikimedia.org/wikipedia/commons/1/18/Dione_Color_Map.jpg, SHA-256 `5e885d0e3bac1e1ee36934063d5c9cdf609dc10ad44677cba31bc9e703b674ff` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL-Caltech / Space Science Institute / Lunar and Planetary Institute (Cassini, PIA18434) | Turned half a turn, colour kept at 55 percent |
|
|
107
|
+
| Iapetus | levels 1 to 2, up to 8192 x 4096 (160 tiles, 2.2 MB) | [Iapetus Color Map.jpg](https://commons.wikimedia.org/wiki/File:Iapetus_Color_Map.jpg), 11741 x 5871, https://upload.wikimedia.org/wikipedia/commons/5/53/Iapetus_Color_Map.jpg, SHA-256 `6e0e1d17a50343d9176912d047392c4f7cd67c48bdb30789918a4ff24d9f683b` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL-Caltech / Space Science Institute / Lunar and Planetary Institute (Cassini, PIA18436) | Turned half a turn, colour kept at 70 percent |
|
|
108
|
+
| Triton | levels 1 to 2, up to 8192 x 4096 (160 tiles, 1.0 MB) | [Triton map no grid.jpg](https://commons.wikimedia.org/wiki/File:Triton_map_no_grid.jpg), 14138 x 7069, https://upload.wikimedia.org/wikipedia/commons/6/61/Triton_map_no_grid.jpg, SHA-256 `ff533af3163f53cc5560cd983cfe0f06b1c2cd0f3db36518d4c5cc5f5ddfeabb` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | Paul Schenk, Lunar and Planetary Institute (Voyager 2 mosaic), NASA | Colour kept at 45 percent; the north in the polar night is the 2048 picture's |
|
|
109
|
+
| Mimas | levels 1 to 1, up to 4096 x 2048 (32 tiles, 0.4 MB) | [Map of Mimas 2010-02 PIA12780.jpg](https://commons.wikimedia.org/wiki/File:Map_of_Mimas_2010-02_PIA12780.jpg), 5828 x 2947, https://upload.wikimedia.org/wikipedia/commons/5/5a/Map_of_Mimas_2010-02_PIA12780.jpg, SHA-256 `8dd786afff003466f196bdd5c9f4c63a6bffddbd0d384c04fac0706068602943` | Public domain (the file page's licence as Commons' own metadata gave it, read 2026-11-09) | NASA / JPL / Space Science Institute (Cassini, PIA12780) | Cropped to the map as the 2048 picture was |
|
|
110
|
+
|
|
111
|
+
Not tiled, because no finer public-domain map was found that this package can use: Venus (the 2048 picture is Solar System Scope's, CC BY 4.0), Jupiter, Saturn, Uranus, Neptune and the Sun (the same, or Nestaeric's, CC BY 4.0, or one photograph), Titan and Ceres (the maps in `textures/` are the finest the sources have: 4046 and 4000 pixels), Ganymede (3126 pixels) and Europa (1024). Where a finer USGS mosaic of Ganymede, Europa or Titan exists, it is a separate piece of work (its licence read first).
|
|
112
|
+
|
|
113
|
+
The generic detail of a close zoom (docs/guides/close-zoom.md) is noise made in the shader. It is no data and takes nothing from any source.
|
|
114
|
+
|
|
85
115
|
## Orbiter's MIT notice
|
|
86
116
|
|
|
87
117
|
The TASS1.7 table above was read from Orbiter (https://github.com/orbitersim/orbiter), whose licence is:
|
package/README.md
CHANGED
|
@@ -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.
|
|
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.27.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.
|
|
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.27.0/docs/images/lineup-desk.png" width="640"></p>
|
|
21
21
|
|
|
22
22
|
## One minute
|
|
23
23
|
|
|
@@ -107,7 +107,7 @@ Import the element once in client code, and the entry point of each body you dra
|
|
|
107
107
|
|---|---|---|
|
|
108
108
|
| `line` | A clean outline drawing with the body's key features: bands, craters, rings and their gaps, caps, the dark side dashed off. An SVG. | nothing |
|
|
109
109
|
| `realistic` | A shaded sphere drawn from the body's real colours and features, lit from the Sun's side, with the rings casting shadows. No pictures: the surface is worked out in a shader. | `three`, the body's entry point |
|
|
110
|
-
| `painted` | A real surface map from public-domain NASA, USGS and JPL imagery. Small pictures first (1.31 MB for all of them in the package), a sharper one fetched when you zoom in. | `three`, the body's entry point |
|
|
110
|
+
| `painted` | A real surface map from public-domain NASA, USGS and JPL imagery. Small pictures first (1.31 MB for all of them in the package), a sharper one fetched when you zoom in, and finer map tiles for the part in view when you zoom right up (Mars, the Moon, the Earth and ten moons: [close zoom](docs/guides/close-zoom.md)). | `three`, the body's entry point |
|
|
111
111
|
|
|
112
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.
|
|
113
113
|
|
|
@@ -290,7 +290,7 @@ A body that turns by itself and a moving sky, in HTML:
|
|
|
290
290
|
|
|
291
291
|
## The portrait builder
|
|
292
292
|
|
|
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.
|
|
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.27.0/docs/images/portrait-family.png" width="640"></p>
|
|
294
294
|
|
|
295
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.
|
|
296
296
|
|
|
@@ -378,6 +378,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
378
378
|
| [The space view](docs/guides/space-view.md) | The Earth, Moon, Sun and planets in their places; two scales; time both ways |
|
|
379
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
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 |
|
|
381
|
+
| [Close zoom and map tiles](docs/guides/close-zoom.md) | How far each body zooms and why, the finer map tiles for a close zoom (made from public-domain maps, served beside the demo, never in the package), the generic detail, what it costs |
|
|
381
382
|
| [Riding along](docs/guides/ride-along.md) | The camera on a moon, a planet or any moving point, looking at what it goes round |
|
|
382
383
|
| [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
|
|
383
384
|
| [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
|
package/dist/element.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import "./tables/ceres.ts";
|
|
|
3
3
|
import "./tables/dwarfs.ts";
|
|
4
4
|
import { type BodyId, type Look } from "./facts.ts";
|
|
5
5
|
import { type StarLook, type StarNumbers } from "./star.ts";
|
|
6
|
-
export { TEXTURE_BASE, TEXTURE_FAR_BASE } from "./scene/textures.ts";
|
|
6
|
+
export { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE } from "./scene/textures.ts";
|
|
7
|
+
import type { DetailStats } from "./scene/detail.ts";
|
|
7
8
|
import { type ThreeParts } from "./scene/body.ts";
|
|
8
9
|
import { setThreeLoader } from "./scene/shared.ts";
|
|
9
10
|
export { setThreeLoader };
|
|
@@ -27,7 +28,8 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
|
|
|
27
28
|
* `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`).
|
|
28
29
|
*
|
|
29
30
|
* 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
|
|
31
|
+
* `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
|
|
32
|
+
* Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
|
|
31
33
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
32
34
|
*
|
|
33
35
|
* @example
|
|
@@ -63,6 +65,8 @@ export declare class WakuseiBody extends HTMLElement {
|
|
|
63
65
|
textureWidth: number;
|
|
64
66
|
anchors: number;
|
|
65
67
|
renderer: SharedRenderer<ThreeParts>["stats"] | undefined;
|
|
68
|
+
tiles: DetailStats | undefined;
|
|
69
|
+
zoomMax: number | undefined;
|
|
66
70
|
};
|
|
67
71
|
connectedCallback(): void;
|
|
68
72
|
disconnectedCallback(): void;
|
package/dist/element.js
CHANGED
|
@@ -2,16 +2,18 @@ import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
|
2
2
|
import "./tables/ceres.js";
|
|
3
3
|
import "./tables/dwarfs.js";
|
|
4
4
|
import { loadMoonTheory } from "./tables/lazy.js";
|
|
5
|
-
import { orbitPath
|
|
6
|
-
import { BODIES
|
|
5
|
+
import { orbitPath } from "./ephemeris.js";
|
|
6
|
+
import { BODIES } from "./facts.js";
|
|
7
|
+
import { extentOf, ROOM } from "./scene/extent.js";
|
|
7
8
|
import { createGate, frameCap } from "./gate.js";
|
|
8
9
|
import { lineSvg } from "./line.js";
|
|
9
10
|
import { starLook } from "./star.js";
|
|
10
11
|
import { starLineSvg } from "./star-line.js";
|
|
11
|
-
import { starLookOf } from "./scene/look.js";
|
|
12
|
+
import { detailOf, lookOf, starLookOf } from "./scene/look.js";
|
|
12
13
|
import { createLive, defaultTurn, REDUCED_TURN } from "./live.js";
|
|
13
|
-
import { texturePaths } from "./scene/textures.js";
|
|
14
|
-
export { TEXTURE_BASE, TEXTURE_FAR_BASE } from "./scene/textures.js";
|
|
14
|
+
import { texturePaths, tilesBase } from "./scene/textures.js";
|
|
15
|
+
export { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE } from "./scene/textures.js";
|
|
16
|
+
import { mapWidthOf, ringWidthOf, zoomLimit } from "./scene/reach.js";
|
|
15
17
|
import { createBodyItem } from "./scene/body.js";
|
|
16
18
|
import { delegates, onRegister } from "./scene/store.js";
|
|
17
19
|
import { setThreeLoader, takeRenderer } from "./scene/shared.js";
|
|
@@ -45,24 +47,6 @@ function turnPose(pose, axis, degrees) {
|
|
|
45
47
|
pose.meridian = turnVec(pose.meridian, axis, degrees);
|
|
46
48
|
pose.light = turnVec(pose.light, axis, degrees);
|
|
47
49
|
}
|
|
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. */
|
|
49
|
-
const ROOM = 2.2;
|
|
50
|
-
function extentOf(f, options) {
|
|
51
|
-
if (options.moons === true && f.parent === undefined && f.id !== "sun") {
|
|
52
|
-
const near = nearMoons(f.id);
|
|
53
|
-
const far = Math.max(1.8, ringReach(f) * 1.15, ...near.map((m) => m.reach * 1.1));
|
|
54
|
-
return options.range ?? far;
|
|
55
|
-
}
|
|
56
|
-
if (options.spanKm !== undefined)
|
|
57
|
-
return options.spanKm / f.radiusKm;
|
|
58
|
-
if (options.scaleTo !== undefined)
|
|
59
|
-
return (BODIES[options.scaleTo].radiusKm * 1.06) / f.radiusKm;
|
|
60
|
-
if (options.tight !== true)
|
|
61
|
-
return ROOM;
|
|
62
|
-
// tight (a thumbnail): the picture holds the body and its rings, and an irregular body (Deimos, Phobos, Nix, Hydra) whole along its longest axis
|
|
63
|
-
const longest = f.axesKm === undefined ? 1 : Math.max(...f.axesKm) / f.radiusKm;
|
|
64
|
-
return Math.max(1.06, ringReach(f) * 1.04, longest * 1.06);
|
|
65
|
-
}
|
|
66
50
|
/** 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. */
|
|
67
51
|
function clampPan(pan, extent, zoom) {
|
|
68
52
|
const half = extent / Math.max(0.05, zoom);
|
|
@@ -71,11 +55,11 @@ function clampPan(pan, extent, zoom) {
|
|
|
71
55
|
}
|
|
72
56
|
/**
|
|
73
57
|
* 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
|
|
75
|
-
*
|
|
58
|
+
* The shaded looks go as far as their detail does (`#limits`, `scene/reach.ts`): the real detail of a map runs out when a texel of it is wider than about a pixel and a half, and the generic detail the shader adds
|
|
59
|
+
* (noise, so a body never goes smooth) carries a rocky body twice as far and a soft one (a gas giant) three times. The widest map of a body is its finest tile level when the tiles are found, else its 2048 picture, so
|
|
60
|
+
* the limit of a body with tiles rises when they are found. No body goes below 8, the limit these looks had before the tiles, and none above 1000.
|
|
76
61
|
*/
|
|
77
62
|
const LINE_LIMITS = { zoomMin: 0.1, zoomMax: 50, tiltMax: 90 };
|
|
78
|
-
const SHADED_LIMITS = { zoomMin: 0.1, zoomMax: 8, tiltMax: 90 };
|
|
79
63
|
const TEMPLATE = `<style>
|
|
80
64
|
:host { display: block; width: var(--wakusei-size, 320px); max-width: 100%; aspect-ratio: 1 / 1; position: relative; contain: layout style; }
|
|
81
65
|
#stage { position: absolute; inset: 0; }
|
|
@@ -89,7 +73,8 @@ const TEMPLATE = `<style>
|
|
|
89
73
|
* `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`).
|
|
90
74
|
*
|
|
91
75
|
* 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
|
|
76
|
+
* `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
|
|
77
|
+
* Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
|
|
93
78
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
94
79
|
*
|
|
95
80
|
* @example
|
|
@@ -104,7 +89,7 @@ const TEMPLATE = `<style>
|
|
|
104
89
|
* ```
|
|
105
90
|
*/
|
|
106
91
|
export class WakuseiBody extends HTMLElement {
|
|
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"];
|
|
92
|
+
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", "tiles", "lang", "labels"];
|
|
108
93
|
#stage;
|
|
109
94
|
#state = "line";
|
|
110
95
|
#renderer;
|
|
@@ -140,6 +125,9 @@ export class WakuseiBody extends HTMLElement {
|
|
|
140
125
|
#reduce = false;
|
|
141
126
|
#hands;
|
|
142
127
|
#handsKey = "";
|
|
128
|
+
#limitKey = "";
|
|
129
|
+
#tileLevels;
|
|
130
|
+
#tiles;
|
|
143
131
|
#hover = () => void this.goLive();
|
|
144
132
|
#onContext = (state) => {
|
|
145
133
|
if (state === "unavailable")
|
|
@@ -157,7 +145,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
157
145
|
};
|
|
158
146
|
/** 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. */
|
|
159
147
|
get discRadius() {
|
|
160
|
-
|
|
148
|
+
const { width, height } = this.getBoundingClientRect();
|
|
149
|
+
return (Math.min(width, height) / 2) * this.#fill();
|
|
161
150
|
}
|
|
162
151
|
get body() {
|
|
163
152
|
if (this.hasAttribute("star"))
|
|
@@ -190,7 +179,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
190
179
|
}
|
|
191
180
|
/** Numbers for a test or a status line: the state, the texture width in use and the renderer's own counts. */
|
|
192
181
|
get stats() {
|
|
193
|
-
return { state: this.#state, textureWidth: this.#textureWidth, anchors: this.#live.anchors, renderer: this.#renderer?.stats };
|
|
182
|
+
return { state: this.#state, textureWidth: this.#textureWidth, anchors: this.#live.anchors, renderer: this.#renderer?.stats, tiles: this.#view?.scene?.detail ?? this.#tiles, zoomMax: this.#hands?.controller.limits.zoomMax };
|
|
194
183
|
}
|
|
195
184
|
connectedCallback() {
|
|
196
185
|
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
@@ -253,6 +242,11 @@ export class WakuseiBody extends HTMLElement {
|
|
|
253
242
|
this.#applyHover();
|
|
254
243
|
if (name === "live" || name === "look" || name === "body")
|
|
255
244
|
this.#carry();
|
|
245
|
+
if (name === "body" || name === "look" || name === "moons" || name === "range" || name === "scale-to" || name === "span-km" || name === "fit" || name === "star") {
|
|
246
|
+
if (name === "body" || name === "look")
|
|
247
|
+
this.#tileLevels = undefined;
|
|
248
|
+
this.#refreshLimits();
|
|
249
|
+
}
|
|
256
250
|
this.#lastAnchors = -1;
|
|
257
251
|
this.#queue();
|
|
258
252
|
}
|
|
@@ -286,7 +280,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
286
280
|
}
|
|
287
281
|
/** 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. */
|
|
288
282
|
setView(view) {
|
|
289
|
-
const half = Math.max(1, this.clientWidth) / 2;
|
|
283
|
+
const half = Math.max(1, Math.min(this.clientWidth, this.clientHeight)) / 2;
|
|
290
284
|
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
285
|
if (yaw === this.#yaw && tilt === this.#tilt && roll === this.#roll && zoom === this.#zoom && panX === this.#panX && panY === this.#panY)
|
|
292
286
|
return;
|
|
@@ -298,11 +292,15 @@ export class WakuseiBody extends HTMLElement {
|
|
|
298
292
|
#carry() {
|
|
299
293
|
const on = this.getAttribute("live") !== "off" && !(this.look === "line" && delegates.has(this.body));
|
|
300
294
|
const key = `${on}|${this.look === "line"}`;
|
|
301
|
-
if (this.#handsKey === key)
|
|
295
|
+
if (this.#handsKey === key) {
|
|
296
|
+
this.#refreshLimits();
|
|
302
297
|
return;
|
|
298
|
+
}
|
|
303
299
|
this.#hands?.unbind();
|
|
304
300
|
this.#handsKey = key;
|
|
305
|
-
|
|
301
|
+
const limits = this.#limits();
|
|
302
|
+
this.#limitKey = `${limits.zoomMax}|${this.look}`;
|
|
303
|
+
this.#hands = carryControls(this, { on, limits, grabRadius: this.discRadius, objectSize: { width: this.discRadius * 2, height: this.discRadius * 2 }, onChange: (view) => this.setView(view) });
|
|
306
304
|
if (this.#zoom !== 1 || this.#yaw !== 0 || this.#tilt !== 0 || this.#panX !== 0 || this.#panY !== 0 || this.#roll !== 0) {
|
|
307
305
|
if (!this.hasAttribute("data-kazoku-bar"))
|
|
308
306
|
this.setView({});
|
|
@@ -406,18 +404,49 @@ export class WakuseiBody extends HTMLElement {
|
|
|
406
404
|
if (roll !== 0)
|
|
407
405
|
turnPose(pose, [0, 0, 1], roll);
|
|
408
406
|
const r = this.#request();
|
|
407
|
+
const extent = this.#extent(r.moons);
|
|
408
|
+
const moons = r.moons ? this.#moonsOf(frame, extent, tiltBy, roll) : undefined;
|
|
409
|
+
return { pose, extent, sky: frame.time !== undefined, zoom: this.#zoom, panX: clampPan(this.#panX, extent, this.#zoom), panY: clampPan(this.#panY, extent, this.#zoom), moons };
|
|
410
|
+
}
|
|
411
|
+
/** Body radii from the middle of the picture to its edge at zoom 1, for the attributes now. */
|
|
412
|
+
#extent(moons) {
|
|
409
413
|
const scaleTo = this.getAttribute("scale-to");
|
|
410
414
|
const range = this.hasAttribute("range") ? num(this.getAttribute("range"), 0) : undefined;
|
|
411
415
|
const span = num(this.getAttribute("span-km"), 0);
|
|
412
|
-
|
|
416
|
+
return extentOf(this.#facts(), {
|
|
413
417
|
tight: this.getAttribute("fit") === "tight",
|
|
414
418
|
spanKm: span > 0 ? span : undefined,
|
|
415
419
|
scaleTo: scaleTo !== null && scaleTo in BODIES ? scaleTo : undefined,
|
|
416
|
-
moons
|
|
420
|
+
moons,
|
|
417
421
|
range: range !== undefined && range > 0 ? range : undefined,
|
|
418
422
|
});
|
|
419
|
-
|
|
420
|
-
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* The zoom range now: a line drawing to 50; a shaded body as far as its detail goes (`scene/reach.ts`), which depends on how big its picture is (the radii it reaches at zoom 1: a moons picture reaches
|
|
426
|
+
* six or more), on the widest map it has (the finest tile level, once the tiles are found) and on whether its surface is soft.
|
|
427
|
+
*/
|
|
428
|
+
#limits() {
|
|
429
|
+
if (this.look === "line")
|
|
430
|
+
return LINE_LIMITS;
|
|
431
|
+
if (this.hasAttribute("star"))
|
|
432
|
+
return { zoomMin: 0.1, zoomMax: zoomLimit(1, 0, false), tiltMax: 90 };
|
|
433
|
+
const moons = this.hasAttribute("moons");
|
|
434
|
+
const look = lookOf(this.body);
|
|
435
|
+
const painted = this.look !== "illustrated" && look?.painted !== undefined;
|
|
436
|
+
const width = mapWidthOf(look, painted, this.#tileLevels);
|
|
437
|
+
const smooth = look !== undefined && detailOf(look).stretch > 1;
|
|
438
|
+
return { zoomMin: 0.1, zoomMax: look?.emissive === true ? zoomLimit(1, 0, false) : zoomLimit(this.#extent(moons), width, smooth, painted ? ringWidthOf(look, BODIES[this.body].radiusKm) : 0), tiltMax: 90 };
|
|
439
|
+
}
|
|
440
|
+
/** Tell the shared controls the zoom range, when it has changed (a new body, the moons turned on, the tiles found). */
|
|
441
|
+
#refreshLimits() {
|
|
442
|
+
if (this.#hands === undefined)
|
|
443
|
+
return;
|
|
444
|
+
const limits = this.#limits();
|
|
445
|
+
const key = `${limits.zoomMax}|${this.look}`;
|
|
446
|
+
if (key === this.#limitKey)
|
|
447
|
+
return;
|
|
448
|
+
this.#limitKey = key;
|
|
449
|
+
this.#hands.setLimits(limits);
|
|
421
450
|
}
|
|
422
451
|
#moonsOf(frame, extent, tilt, roll) {
|
|
423
452
|
const moons = [];
|
|
@@ -632,6 +661,15 @@ export class WakuseiBody extends HTMLElement {
|
|
|
632
661
|
state: () => this.#sceneState ?? state,
|
|
633
662
|
...texturePaths(this),
|
|
634
663
|
wantedWidth: (discPx) => discPx * Math.min(2, window.devicePixelRatio || 1) * 1.6,
|
|
664
|
+
tiles: {
|
|
665
|
+
base: () => tilesBase(this),
|
|
666
|
+
ratio: () => window.devicePixelRatio || 1,
|
|
667
|
+
allowed: () => (navigator.deviceMemory ?? 8) > 2,
|
|
668
|
+
onLevels: (levels) => {
|
|
669
|
+
this.#tileLevels = levels;
|
|
670
|
+
this.#refreshLimits();
|
|
671
|
+
},
|
|
672
|
+
},
|
|
635
673
|
redraw: () => this.#view?.invalidate(),
|
|
636
674
|
report: (note) => {
|
|
637
675
|
this.#textureWidth = note.width;
|
package/dist/portrait/scene3d.js
CHANGED
|
@@ -58,10 +58,11 @@ export function createPortraitItem(options) {
|
|
|
58
58
|
const slot = 7 * Math.max(1e-6, ...placed.map((p) => Math.max(p.r, MIN_RADIUS_PX / pxPerUnit)));
|
|
59
59
|
const far = (placed.length + 1) * slot;
|
|
60
60
|
const distance = far + 300 * Math.max(halfW, halfH);
|
|
61
|
-
camera
|
|
62
|
-
camera.
|
|
63
|
-
camera.
|
|
64
|
-
camera.
|
|
61
|
+
// the camera is placed at the centre of the view below, so the window is round it: putting the centre in the window too moved everything twice as far as the view was moved
|
|
62
|
+
camera.left = -halfW;
|
|
63
|
+
camera.right = halfW;
|
|
64
|
+
camera.top = halfH;
|
|
65
|
+
camera.bottom = -halfH;
|
|
65
66
|
camera.near = Math.max(1e-6, distance - far - slot);
|
|
66
67
|
camera.far = distance + slot;
|
|
67
68
|
camera.position.set(cam.x, cam.y, distance);
|
package/dist/scene/body.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ import type * as THREE from "three";
|
|
|
3
3
|
import type { Pose } from "../ephemeris.ts";
|
|
4
4
|
import { type BodyFacts, type BodyId } from "../facts.ts";
|
|
5
5
|
import { type BodyLook } from "./look.ts";
|
|
6
|
+
import { type DetailStats } from "./detail.ts";
|
|
7
|
+
import type { TileLevel } from "./tiles.ts";
|
|
6
8
|
export { fallbackLook } from "./fallback.ts";
|
|
7
9
|
/** The parts of three.js the bodies use: a page may hand over a module with only these (see `setThreeLoader`). */
|
|
8
10
|
export type ThreeParts = Pick<typeof THREE, "AdditiveBlending" | "BufferAttribute" | "BufferGeometry" | "ClampToEdgeWrapping" | "DataTexture" | "DoubleSide" | "Group" | "Line" | "LineBasicMaterial" | "LinearFilter" | "Mesh" | "NoColorSpace" | "OrthographicCamera" | "PlaneGeometry" | "RepeatWrapping" | "RGBAFormat" | "RingGeometry" | "Scene" | "ShaderMaterial" | "SphereGeometry" | "TextureLoader" | "Vector2" | "Vector3" | "WebGLRenderer">;
|
|
@@ -37,6 +39,8 @@ export interface BodyScene extends Scene3D {
|
|
|
37
39
|
/** What the scene is drawing now: the texture width in use, or 0 for the shader. */
|
|
38
40
|
readonly textureWidth: number;
|
|
39
41
|
readonly painted: boolean;
|
|
42
|
+
/** The window of finer map on the body, or `undefined` for a body with none (a glowing one, or one with no painted map). */
|
|
43
|
+
readonly detail: DetailStats | undefined;
|
|
40
44
|
}
|
|
41
45
|
export interface BodyItemOptions {
|
|
42
46
|
id: BodyId;
|
|
@@ -64,6 +68,13 @@ export interface BodyItemOptions {
|
|
|
64
68
|
width: number;
|
|
65
69
|
failed?: boolean;
|
|
66
70
|
}): void;
|
|
71
|
+
/** Finer map tiles for a close zoom (see `scene/detail.ts`): where they are (`undefined` for none), the pixel ratio, whether this device may use them, and what to do when the tile set's levels for the body are known. */
|
|
72
|
+
tiles?: {
|
|
73
|
+
base(): string | undefined;
|
|
74
|
+
ratio(): number;
|
|
75
|
+
allowed(): boolean;
|
|
76
|
+
onLevels?(levels: readonly TileLevel[] | undefined): void;
|
|
77
|
+
};
|
|
67
78
|
}
|
|
68
79
|
/**
|
|
69
80
|
* The shared-renderer item for a body: what `renderer.view(host, item)` shows. `state()` is read when the scene is built and `apply` moves it afterwards.
|
package/dist/scene/body.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BODIES } from "../facts.js";
|
|
2
2
|
import { silhouette } from "../pose.js";
|
|
3
3
|
import { cross } from "../vec.js";
|
|
4
|
-
import { BALL_FRAGMENT, bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE,
|
|
5
|
-
import { lookOf } from "./look.js";
|
|
4
|
+
import { BALL_FRAGMENT, bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_DETAIL, RING_VERTEX, STAR_GLOW_FRAGMENT, VERTEX } from "./glsl.js";
|
|
5
|
+
import { detailOf, lookOf } from "./look.js";
|
|
6
|
+
import { createDetail } from "./detail.js";
|
|
6
7
|
import { fallbackLook } from "./fallback.js";
|
|
7
8
|
import { writeBasis } from "./basis.js";
|
|
8
9
|
import { loadImage } from "./textures.js";
|
|
@@ -10,10 +11,21 @@ import { ringStrip } from "./rings.js";
|
|
|
10
11
|
export { fallbackLook } from "./fallback.js";
|
|
11
12
|
function makeBodyMaterial(T, look, painted) {
|
|
12
13
|
const a = look.atmosphere;
|
|
14
|
+
// a glowing body (the Sun, a star) is drawn as it always was: no window of finer map and no generic detail
|
|
15
|
+
const generic = look.emissive !== true;
|
|
16
|
+
const fine = detailOf(look);
|
|
13
17
|
return new T.ShaderMaterial({
|
|
14
18
|
vertexShader: VERTEX,
|
|
15
|
-
fragmentShader: bodyFragment(painted ? PAINTED_SURFACE : look.surface, painted, false, look.limbTint),
|
|
19
|
+
fragmentShader: bodyFragment(painted ? (generic ? PAINTED_SURFACE_WINDOWED : PAINTED_SURFACE) : look.surface, painted, false, look.limbTint, generic),
|
|
16
20
|
uniforms: {
|
|
21
|
+
...(generic
|
|
22
|
+
? {
|
|
23
|
+
uTexel: { value: painted ? (2 * Math.PI) / (look.painted?.widths[0] ?? 2048) : 0.005 },
|
|
24
|
+
uDetailAmp: { value: fine.amount },
|
|
25
|
+
uDetailStretch: { value: fine.stretch },
|
|
26
|
+
...(painted ? { uDetail: { value: null }, uDetailRect: { value: [0, 1, 1, 1] }, uDetailFade: { value: new T.Vector2(0, 0) }, uDetailOn: { value: 0 }, uDetailTexel: { value: 0.003 } } : {}),
|
|
27
|
+
}
|
|
28
|
+
: {}),
|
|
17
29
|
uLight: { value: new T.Vector3(-0.6, 0.2, 0.77) },
|
|
18
30
|
uRelief: { value: (painted ? (look.painted?.relief ?? 0) : (look.relief ?? 0.6)) },
|
|
19
31
|
uAmbient: { value: look.ambient ?? 0.04 },
|
|
@@ -54,7 +66,7 @@ export function createBodyItem(options) {
|
|
|
54
66
|
async build({ three: T, assets, width, height }) {
|
|
55
67
|
const look = options.shaded ?? lookOf(options.id) ?? fallbackLook(facts);
|
|
56
68
|
const wantPainted = (options.look === "painted" || look.mapped === true) && look.painted !== undefined;
|
|
57
|
-
const geometry = assets.acquire("wk:sphere", () => new T.SphereGeometry(1,
|
|
69
|
+
const geometry = assets.acquire("wk:sphere", () => new T.SphereGeometry(1, 192, 96), (g) => g.dispose());
|
|
58
70
|
const shader = assets.acquire(`wk:body:${held}:r`, () => makeBodyMaterial(T, look, false), (m) => m.dispose());
|
|
59
71
|
const paintedMaterial = wantPainted ? assets.acquire(`wk:body:${held}:p`, () => makeBodyMaterial(T, look, true), (m) => m.dispose()) : undefined;
|
|
60
72
|
const materials = paintedMaterial === undefined ? [shader] : [shader, paintedMaterial];
|
|
@@ -105,13 +117,13 @@ export function createBodyItem(options) {
|
|
|
105
117
|
photoTexture.dispose();
|
|
106
118
|
const ringMaterial = (key, depthTest) => assets.acquire(`wk:ringmat:${ringKey}:${key}`, () => new T.ShaderMaterial({
|
|
107
119
|
vertexShader: RING_VERTEX,
|
|
108
|
-
fragmentShader:
|
|
120
|
+
fragmentShader: RING_FRAGMENT_DETAIL,
|
|
109
121
|
side: T.DoubleSide,
|
|
110
122
|
transparent: true,
|
|
111
123
|
premultipliedAlpha: photoTexture === undefined,
|
|
112
124
|
depthWrite: false,
|
|
113
125
|
depthTest,
|
|
114
|
-
uniforms: { uRingTex: { value: ringTexture }, uRingR: { value: new T.Vector2(ringInner, ringOuter) }, uLight: { value: new T.Vector3(0, 0, 1) }, uRingN: { value: new T.Vector3(0, 1, 0) } },
|
|
126
|
+
uniforms: { uRingTex: { value: ringTexture }, uRingR: { value: new T.Vector2(ringInner, ringOuter) }, uLight: { value: new T.Vector3(0, 0, 1) }, uRingN: { value: new T.Vector3(0, 1, 0) }, uRingTexel: { value: 1 / (photoTexture !== undefined ? photo.width : table.width) } },
|
|
115
127
|
}), (m) => m.dispose());
|
|
116
128
|
// 0..pi is the +Y half. The basis maps local +Y onto +east.
|
|
117
129
|
const half = (key, depthTest) => {
|
|
@@ -176,6 +188,8 @@ export function createBodyItem(options) {
|
|
|
176
188
|
drop(t);
|
|
177
189
|
textureWidth = w;
|
|
178
190
|
paintedMaterial.uniforms.uMap.value = shared;
|
|
191
|
+
if (paintedMaterial.uniforms.uTexel !== undefined)
|
|
192
|
+
paintedMaterial.uniforms.uTexel.value = (2 * Math.PI) / w;
|
|
179
193
|
mesh.material = paintedMaterial;
|
|
180
194
|
options.report?.({ painted: true, width: w });
|
|
181
195
|
};
|
|
@@ -185,6 +199,30 @@ export function createBodyItem(options) {
|
|
|
185
199
|
textureWidth = 0;
|
|
186
200
|
options.report?.({ painted: false, width: 0, failed: true });
|
|
187
201
|
};
|
|
202
|
+
// the window of finer map for a close zoom, laid over the painted map by the painted material
|
|
203
|
+
const windowUniforms = wantPainted && paintedMaterial !== undefined && look.emissive !== true && options.tiles !== undefined && look.painted !== undefined ? paintedMaterial.uniforms : undefined;
|
|
204
|
+
const detail = windowUniforms === undefined || options.tiles === undefined
|
|
205
|
+
? undefined
|
|
206
|
+
: createDetail(T, {
|
|
207
|
+
base: () => options.tiles.base(),
|
|
208
|
+
body: look.painted.map,
|
|
209
|
+
ratio: () => options.tiles.ratio(),
|
|
210
|
+
allowed: () => options.tiles.allowed(),
|
|
211
|
+
redraw: () => options.redraw(),
|
|
212
|
+
...(options.tiles.onLevels === undefined ? {} : { onLevels: (levels) => options.tiles.onLevels(levels) }),
|
|
213
|
+
apply: (shown) => {
|
|
214
|
+
if (shown === null) {
|
|
215
|
+
windowUniforms.uDetailOn.value = 0;
|
|
216
|
+
windowUniforms.uDetail.value = null;
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
windowUniforms.uDetail.value = shown.texture;
|
|
220
|
+
windowUniforms.uDetailRect.value = [shown.rect.u0, shown.rect.vTop, shown.rect.du, shown.rect.dv];
|
|
221
|
+
windowUniforms.uDetailFade.value.set(shown.fade.u, shown.fade.v);
|
|
222
|
+
windowUniforms.uDetailTexel.value = shown.texel;
|
|
223
|
+
windowUniforms.uDetailOn.value = 1;
|
|
224
|
+
},
|
|
225
|
+
});
|
|
188
226
|
if (wantPainted && paintedMaterial !== undefined) {
|
|
189
227
|
const widths = look.painted.widths;
|
|
190
228
|
try {
|
|
@@ -222,8 +260,9 @@ export function createBodyItem(options) {
|
|
|
222
260
|
const half = state.extent / Math.max(0.05, state.zoom);
|
|
223
261
|
const halfW = aspect >= 1 ? half * aspect : half;
|
|
224
262
|
const halfH = aspect >= 1 ? half : half / aspect;
|
|
225
|
-
|
|
226
|
-
const
|
|
263
|
+
// the pan is in units of the short side's half (what the element divides the pixels by), so a wide or tall view moves by the pixels asked
|
|
264
|
+
const cx = state.panX * half;
|
|
265
|
+
const cy = state.panY * half;
|
|
227
266
|
camera.left = cx - halfW;
|
|
228
267
|
camera.right = cx + halfW;
|
|
229
268
|
camera.top = cy + halfH;
|
|
@@ -359,6 +398,12 @@ export function createBodyItem(options) {
|
|
|
359
398
|
glow.scale.setScalar(1);
|
|
360
399
|
}
|
|
361
400
|
requestSharperTexture(state);
|
|
401
|
+
if (detail !== undefined && textureWidth > 0) {
|
|
402
|
+
const east = cross(state.pose.pole, state.pose.meridian);
|
|
403
|
+
const ax = facts.axesKm;
|
|
404
|
+
const mean = facts.radiusKm;
|
|
405
|
+
detail.sync({ left: camera.left, right: camera.right, bottom: camera.bottom, top: camera.top }, { east, pole: state.pose.pole, meridian: state.pose.meridian, scale: [ax ? ax[1] / mean : 1, ax ? ax[2] / mean : 1 - facts.flattening, ax ? ax[0] / mean : 1] }, viewWidth);
|
|
406
|
+
}
|
|
362
407
|
};
|
|
363
408
|
apply(latest);
|
|
364
409
|
return {
|
|
@@ -371,6 +416,9 @@ export function createBodyItem(options) {
|
|
|
371
416
|
get painted() {
|
|
372
417
|
return textureWidth > 0;
|
|
373
418
|
},
|
|
419
|
+
get detail() {
|
|
420
|
+
return detail?.stats;
|
|
421
|
+
},
|
|
374
422
|
resize(w, h) {
|
|
375
423
|
viewWidth = w;
|
|
376
424
|
viewHeight = h;
|
|
@@ -383,6 +431,11 @@ export function createBodyItem(options) {
|
|
|
383
431
|
},
|
|
384
432
|
dispose() {
|
|
385
433
|
gone = true;
|
|
434
|
+
if (windowUniforms !== undefined) {
|
|
435
|
+
windowUniforms.uDetailOn.value = 0;
|
|
436
|
+
windowUniforms.uDetail.value = null;
|
|
437
|
+
}
|
|
438
|
+
detail?.dispose();
|
|
386
439
|
for (const o of orbitLines.values())
|
|
387
440
|
o.line.geometry.dispose();
|
|
388
441
|
orbitMaterial.dispose();
|