@johnmorrisdotca/wakusei-planets 0.39.0 → 0.41.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 +17 -0
- package/NOTICE.md +1 -1
- package/README.md +3 -3
- package/dist/element.d.ts +1 -1
- package/dist/element.js +1 -1
- package/dist/ground-track.d.ts +80 -0
- package/dist/ground-track.js +137 -0
- package/dist/paint/trail.d.ts +80 -0
- package/dist/paint/trail.js +322 -0
- package/dist/scene/body.d.ts +1 -0
- package/dist/scene/body.js +2 -2
- package/dist/scene/glsl.d.ts +2 -2
- package/dist/scene/glsl.js +4 -2
- package/dist/scene/name-label.d.ts +56 -3
- package/dist/scene/name-label.js +72 -7
- package/dist/scene/painter.d.ts +2 -1
- package/dist/scene/painter.js +5 -3
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +24 -0
- package/dist/space/element.js +51 -6
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/labels.d.ts +32 -0
- package/dist/space/labels.js +39 -0
- package/dist/space/paint-overlay.d.ts +11 -0
- package/dist/space/paint-overlay.js +84 -0
- package/dist/space/scene.d.ts +6 -0
- package/dist/space/scene.js +25 -0
- package/dist/textures/pluto-1024.webp +0 -0
- package/dist/textures/pluto-512.webp +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.41.0] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **The name on a body reads on every body** (MODULES-983). One pale look for every body made the name vanish on Uranus, Venus, Saturn and the ice moons. The letters now take the tone that stands out: `body-label-tone` (and `tone` in `bodyLabel`) is `auto` by default, `light` or `dark`. Auto reads the body's own mean colour (`BODIES[id].colour`): dark letters (the `burned` look) when its relative luminance is above 0.5 (Venus, Saturn, Uranus, the Sun, Io, Europa, Enceladus, Tethys, Dione, Rhea, Triton, Hydra, Eris, Haumea), pale letters (`painted`) below it (Mars, the Moon, the Earth, Mercury, Jupiter, Neptune, Pluto and the rest); only a `painted` look is changed (to dark `burned` on a light body); `etched`, `burned` and `outline` are drawn as the page asked, and a forced `light` or `dark` wins over any look. The same rule on plain values is `nameTone(colour)` and `nameLabelLook(options, colour)` from `/painter`, and `stats.label.look` and `stats.bodyLabels.focus.look` report the look drawn. Picture test in `e2e/body-label.demo.ts` (realistic look, strength 0.5, name facing the reader): the letters' contrast (mean of the top 2 percent of brightness changes) on Uranus is 0.106 with pale letters, which is all origin/main draws, and 0.147 with dark ones; Venus 0.244 to 0.295, Saturn 0.242 to 0.346, Europa 0.237 to 0.297; the pale bodies are unchanged. The Moon (mean colour luminance 0.463) and Jupiter (0.492) stay pale, just under the line. Docs in English and Japanese.
|
|
8
|
+
|
|
9
|
+
- **Small moons with no map are drawn clean: no black rings and specks** (MODULES-994). Nix, Hydra, Miranda, Proteus, Phobos and the other cratered rock the shader makes showed a grid of dark edges over the disc. It was not number precision (the scene is moved to the body looked at, so Nix, 5 billion kilometres from the Sun, is drawn within about eight Earth radii of the origin, and near and far planes and depth hold): each crater's slope came from the difference between neighbouring pixels and tipped the surface by up to fifteen times that, so the wall of every crater a few pixels across turned away from the light and drew a black ring, and a crater of two or three pixels a speck. Now a crater fades out below about 3 to 8 pixels (it was 1 to 3), and the tip of the surface is held to about 50 degrees. Picture test `e2e/space-small-moons.demo.ts`, lit from the camera's side, share of the middle of the disc darker than a fifth of white: Nix 10.3%, Hydra 14.4%, Miranda 16.5%, Proteus 25.2% before, 0.0%, 3.8%, 0.1%, 3.5% after (the bowls that are really dark). A painted body changes only where its relief is steeper than that.
|
|
10
|
+
|
|
11
|
+
- **Pluto's unseen south is a plain tone with a soft edge, not a dark half** (MODULES-993). New Horizons never saw the south in daylight, and the map made it a dark brown that began on one straight line about 7 degrees south of the equator, so a globe showed a hard-edged dark half and the name written on the equator ran into it. The never-imaged part is now one plain tone, the mapped ground's average times 0.85, and the mapped detail fades into it over 8 percent of the map's height along an edge that follows the real coverage (about 30 degrees south), so the equator, and a name on it, are all on mapped ground. The three maps (512, 1024 and 2048) are 12.6, 44.6 and 179.4 KB, up from 10.0, 36.2 and 147.5 KB (+43.9 KB in all). Picture test `e2e/map-gaps.demo.ts` reads the shipped map: the detail lost over 1.5 percent of its height is 0.59 to 0.64 of the most before and 0.16 to 0.19 after; the unseen part's brightness is 0.26 of the mapped ground's before and 0.75 after. The finer map tiles of Pluto are made from this picture and need making again (`pnpm tiles`).
|
|
12
|
+
|
|
13
|
+
- **A floating name is no longer cut off at the view's edge** (MODULES-1144). A name beside a body near the right edge ran past the edge and was cut. It now goes to the dot's left side (the dot follows the text), and if it fits on neither side, or would pass the top or the bottom, it is held inside the edge; a body whose dot is outside the view keeps its name where it falls. `nameSpot(dot, size, frame)` from `/space` is the placing on plain numbers. `e2e/space-names.demo.ts` reads 3 names cut at three view sizes on the old code, none now.
|
|
14
|
+
|
|
15
|
+
## [0.40.0] - 2026-11-13
|
|
16
|
+
|
|
17
|
+
- **Paint an orbiter's path on the Moon or Mars** (MODULES-1168). `space.paint = { id, length, swath }` on `<wakusei-space>` paints that craft's ground track on the body it goes round (`id` such as `lro` or `mro`; `length` `1d` by default, or `1w`, `1m`, in the clock's time; `swath` `track` by default, or `coverage`, the ground where the craft is at least 10° up). `clearPaint()` takes it off, and another craft clears the old trail. Parts older than `length` fade and are dropped. The line is filled between frames, including backwards. One upload a frame while time moves, nothing at rest, and nothing while paint is off, when the picture and its sphere are freed on the graphics card. The craft's place is sampled at most a third of a trip apart, so a fast clock follows the orbit; a clock run backwards lays down the older end; a `coverage` swath over the date line is painted on both edges. The date-line split, the pole split and the swath radius are `@johnmorrisdotca/wakusei-planets/ground-track` (no DOM, no three.js). The space page has Paint, Clear, and 1 day, 1 week, 1 month.
|
|
18
|
+
- **Ride Off puts the demo's clock back** (the space page). A ride along starts the clock, and Off used to leave it running, at 3,600 times real time, with the view drawing every frame. Off now holds the clock again when the ride started it, and leaves it running at its own speed when it was already playing. Demo only.
|
|
19
|
+
- **The freeze test of the space view holds the clock** (MODULES-1187). "Changes to the space view give back what they took" read 183 graphics objects against a limit of 182 in the image: the rides in its round started the demo's clock, so the moons came and went with the time and the count was of a different moment each round. The round now holds the clock after the rides and waits for 30 frames with no draw before it counts. Test only.
|
|
20
|
+
- **The travel test watches a move on the page** (MODULES-1186). `e2e/space-travel.demo.ts` counted the draws of a move from the test, one round trip for each reading, so a loaded machine saw 6 frames of a move it needs more than 6 of. It now records each new draw at every animation frame on the page until the move ends. Test only.
|
|
21
|
+
|
|
5
22
|
## [0.39.0] - 2026-11-13
|
|
6
23
|
|
|
7
24
|
- **The portrait builder's credit names each body's picture** (MODULES-1157). It was one fixed public-domain sentence for every painted scene; it is now `picturesCredit` for the bodies in the scene, so Saturn names Solar System Scope, Nestaeric, CC BY 4.0 and the changes. The builder's browser test now expects the source names of the body it shows, not the old public-domain sentence.
|
package/NOTICE.md
CHANGED
|
@@ -108,7 +108,7 @@ The same rows are `PICTURE_CREDITS` (`picturesCredit` writes the line for the bo
|
|
|
108
108
|
| `saturn-*.webp` | Saturn | [2k_saturn.jpg](https://www.solarsystemscope.com/textures/) and [Nestaeric's Saturn](https://sketchfab.com/3d-models/saturn-c09a1970148c43ad99db134a9d6d00b5) | CC BY 4.0 | Solar System Scope; pole caps by Nestaeric | The bands are Solar System Scope's map. The last 20 degrees at each pole are reprojected from Nestaeric's caps, and the north cap has the hexagon. The band map itself has little east-west detail |
|
|
109
109
|
| `uranus-*.webp` | Uranus | [Uranus](https://sketchfab.com/3d-models/uranus-0009a69dbace44608c0bd09af9ba20db) by NestaEric | CC BY 4.0 | This work is based on "Uranus" (https://sketchfab.com/3d-models/uranus-0009a69dbace44608c0bd09af9ba20db) by NestaEric (https://sketchfab.com/Nestaeric) licensed under CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/) | The band half of the texture, which has a bright spot, resized to 512, 1024 and 2048 |
|
|
110
110
|
| `neptune-*.webp` | Neptune | [2k_neptune.jpg](https://www.solarsystemscope.com/textures/) | CC BY 4.0 | Solar System Scope | Equirectangular map, resized to 512, 1024 and 2048 |
|
|
111
|
-
| `pluto-*.webp` | Pluto | [Pluto color mapmosaic.jpg](https://commons.wikimedia.org/wiki/File:Pluto_color_mapmosaic.jpg) | Public domain | NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute | New Horizons global colour map, turned so Sputnik Planitia is at 178 degrees east; the south, in the polar night New Horizons never saw, fades into
|
|
111
|
+
| `pluto-*.webp` | Pluto | [Pluto color mapmosaic.jpg](https://commons.wikimedia.org/wiki/File:Pluto_color_mapmosaic.jpg) | Public domain | NASA / Johns Hopkins University Applied Physics Laboratory / Southwest Research Institute | New Horizons global colour map, turned so Sputnik Planitia is at 178 degrees east; the south, in the polar night New Horizons never saw (about 30 degrees south and beyond, ragged), is one plain tone, the mapped ground's own average (rows weighted by the width of their circle of latitude) times 0.85, so it reads as not yet mapped; the mapped detail fades into it over 8 percent of the map's height (`scripts/make-textures.py`, `fill_unseen_plain`) |
|
|
112
112
|
| `sun-*.webp` | Sun | [2k_sun.jpg](https://www.solarsystemscope.com/textures/) | CC BY 4.0 | Solar System Scope | Equirectangular map, resized to 512, 1024 and 2048 |
|
|
113
113
|
| `moon-*.webp` | The Moon | [CGI Moon Kit - Lroc color poles.tif](https://commons.wikimedia.org/wiki/File:CGI_Moon_Kit_-_Lroc_color_poles.tif) | Public domain | NASA's Scientific Visualization Studio (Ernie Wright, Noah Petro); Lunar Reconnaissance Orbiter Camera | LRO WAC colour map from the SVS Moon Kit (4720), kept until it has been compared with Solar System Scope beside a photograph |
|
|
114
114
|
| `io-*.webp` | Io | [Io from Galileo and Voyager missions.jpg](https://commons.wikimedia.org/wiki/File:Io_from_Galileo_and_Voyager_missions.jpg) | Public domain | NASA / JPL (Galileo SSI and Voyager images); the file page names no author | Galileo and Voyager colour map between 57 degrees north and south, turned so Pele is at 105 degrees east; the poles it does not reach fade from the map's edge into its mean colour |
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
|
|
|
19
19
|
|
|
20
20
|
<p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
|
|
21
21
|
|
|
22
|
-
<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.
|
|
22
|
+
<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.41.0/docs/images/lineup-desk.png" width="640"></p>
|
|
23
23
|
|
|
24
24
|
## Who it is for
|
|
25
25
|
|
|
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
|
|
|
388
388
|
|
|
389
389
|
## The portrait builder
|
|
390
390
|
|
|
391
|
-
<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.
|
|
391
|
+
<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.41.0/docs/images/portrait-family.png" width="640"></p>
|
|
392
392
|
|
|
393
393
|
[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.
|
|
394
394
|
|
|
@@ -534,7 +534,7 @@ BODIES.pluto.kind; // "dwarf-planet"
|
|
|
534
534
|
|
|
535
535
|
If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
|
|
536
536
|
|
|
537
|
-
> Morris, J. (2026). *Wakusei Planets* (version 0.
|
|
537
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.41.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
|
|
538
538
|
|
|
539
539
|
Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
|
|
540
540
|
|
package/dist/element.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export type WakuseiState = "line" | "loading" | "still" | "live" | "lost" | "una
|
|
|
38
38
|
* 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.
|
|
39
39
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
40
40
|
* `places` marks the places on the body in the shaded looks, by layer (`landing`, `crash`, `planned`, `feature`; the lists come from `setPlacesLoader`), with `wakusei-place` on a click and `goToPlace` to turn one to the middle: see the guide "Places on the Moon, Mars and 31 more bodies".
|
|
41
|
-
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font
|
|
41
|
+
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font`, `-fallback-font` and `-tone` (`auto`, `light` or `dark` letters: auto takes dark ones for a `painted` look on a light body) beside it, and the `bodyLabel` property takes the same as an object: see the guide "A name on the body".
|
|
42
42
|
* A dated picture (a `time`, or `moons`) has a clock: `rate` is the simulated seconds for each real second, and `rate="0"` holds it, drawing nothing. While it runs (`rate` not 0), `wakusei-timechange` carries
|
|
43
43
|
* `detail: { time, running: true }` (`time` is the moment shown in milliseconds since 1970; four times a second, once a second at real time; only while the tab is shown, whether or not the picture is on screen), and once with
|
|
44
44
|
* `running: false` when the clock is held: a page writes the date into its date box from it. The `time` property reads the moment shown, and `undefined` for a portrait with no date.
|
package/dist/element.js
CHANGED
|
@@ -84,7 +84,7 @@ const TEMPLATE = `<style>
|
|
|
84
84
|
* 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.
|
|
85
85
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
86
86
|
* `places` marks the places on the body in the shaded looks, by layer (`landing`, `crash`, `planned`, `feature`; the lists come from `setPlacesLoader`), with `wakusei-place` on a click and `goToPlace` to turn one to the middle: see the guide "Places on the Moon, Mars and 31 more bodies".
|
|
87
|
-
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font
|
|
87
|
+
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font`, `-fallback-font` and `-tone` (`auto`, `light` or `dark` letters: auto takes dark ones for a `painted` look on a light body) beside it, and the `bodyLabel` property takes the same as an object: see the guide "A name on the body".
|
|
88
88
|
* A dated picture (a `time`, or `moons`) has a clock: `rate` is the simulated seconds for each real second, and `rate="0"` holds it, drawing nothing. While it runs (`rate` not 0), `wakusei-timechange` carries
|
|
89
89
|
* `detail: { time, running: true }` (`time` is the moment shown in milliseconds since 1970; four times a second, once a second at real time; only while the tab is shown, whether or not the picture is on screen), and once with
|
|
90
90
|
* `running: false` when the clock is held: a page writes the date into its date box from it. The `time` property reads the moment shown, and `undefined` for a portrait with no date.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A point on a body: longitude and latitude in degrees. Longitude runs from −180 to 180.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { splitDateLine, type GroundPoint } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
7
|
+
*
|
|
8
|
+
* const point: GroundPoint = { lon: 170, lat: 10 };
|
|
9
|
+
* console.log(splitDateLine(point, { lon: -170, lat: 12 }).length);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export interface GroundPoint {
|
|
13
|
+
lon: number;
|
|
14
|
+
lat: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The angle at the body's centre, in radians, out to where a craft `heightKm` above the surface is `elevationDeg` above the horizon (10 when left out).
|
|
18
|
+
* 0 when the craft is on the surface or below, or so low that it is never that high. `radiusKm` is the body's radius.
|
|
19
|
+
*
|
|
20
|
+
* @param heightKm - Height above the surface, in kilometres.
|
|
21
|
+
* @param radiusKm - The body's radius, in kilometres.
|
|
22
|
+
* @param elevationDeg - The elevation that still counts, in degrees. 10 when left out.
|
|
23
|
+
* @returns The angle, in radians.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { coverageAngleRad } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
28
|
+
*
|
|
29
|
+
* console.log(coverageAngleRad(400, 6371) > coverageAngleRad(50, 1737.4));
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function coverageAngleRad(heightKm: number, radiusKm: number, elevationDeg?: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Points from `a` to `b` along the great circle, about `stepDeg` apart, including both ends. A fast clock stays a continuous line.
|
|
35
|
+
*
|
|
36
|
+
* @param a - The start.
|
|
37
|
+
* @param b - The end.
|
|
38
|
+
* @param stepDeg - The longest step, in degrees.
|
|
39
|
+
* @returns The points, including both ends.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { trackSteps } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
44
|
+
*
|
|
45
|
+
* console.log(trackSteps({ lon: 0, lat: 0 }, { lon: 10, lat: 0 }, 2).length > 2);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function trackSteps(a: GroundPoint, b: GroundPoint, stepDeg: number): GroundPoint[];
|
|
49
|
+
/**
|
|
50
|
+
* One segment, or two when the short way from `a` to `b` crosses the date line, so an equirectangular line does not cross the whole map.
|
|
51
|
+
* Longitude is degrees, −180 to 180. This is the same split chikyu-earth uses for a satellite over the Earth.
|
|
52
|
+
*
|
|
53
|
+
* @param a - The start.
|
|
54
|
+
* @param b - The end.
|
|
55
|
+
* @returns One segment, or two that meet at ±180.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { splitDateLine } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
60
|
+
*
|
|
61
|
+
* console.log(splitDateLine({ lon: 170, lat: 0 }, { lon: -170, lat: 0 }).length);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function splitDateLine(a: GroundPoint, b: GroundPoint): [GroundPoint, GroundPoint][];
|
|
65
|
+
/**
|
|
66
|
+
* `splitDateLine`, and a split at a pole when the short way between two high-latitude points would cross the pole.
|
|
67
|
+
* Each piece is safe to draw as a straight line on an equirectangular map.
|
|
68
|
+
*
|
|
69
|
+
* @param a - The start.
|
|
70
|
+
* @param b - The end.
|
|
71
|
+
* @returns The pieces, in order.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { splitTrail } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
76
|
+
*
|
|
77
|
+
* console.log(splitTrail({ lon: 10, lat: 80 }, { lon: 170, lat: 75 }).length > 1);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function splitTrail(a: GroundPoint, b: GroundPoint): [GroundPoint, GroundPoint][];
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// The ground track of a craft over a body: the date line, the poles, and the circle where the craft stands 10° up.
|
|
2
|
+
// Pure: no DOM, no three.js, no clock. chikyu-earth can import this later. Its Earth-only `coverageAngleRad(heightKm)` matches `coverageAngleRad(heightKm, 6371)`.
|
|
3
|
+
const RAD = Math.PI / 180;
|
|
4
|
+
/**
|
|
5
|
+
* The angle at the body's centre, in radians, out to where a craft `heightKm` above the surface is `elevationDeg` above the horizon (10 when left out).
|
|
6
|
+
* 0 when the craft is on the surface or below, or so low that it is never that high. `radiusKm` is the body's radius.
|
|
7
|
+
*
|
|
8
|
+
* @param heightKm - Height above the surface, in kilometres.
|
|
9
|
+
* @param radiusKm - The body's radius, in kilometres.
|
|
10
|
+
* @param elevationDeg - The elevation that still counts, in degrees. 10 when left out.
|
|
11
|
+
* @returns The angle, in radians.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { coverageAngleRad } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
16
|
+
*
|
|
17
|
+
* console.log(coverageAngleRad(400, 6371) > coverageAngleRad(50, 1737.4));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function coverageAngleRad(heightKm, radiusKm, elevationDeg = 10) {
|
|
21
|
+
const r = radiusKm + heightKm;
|
|
22
|
+
if (!(r > radiusKm) || !(radiusKm > 0))
|
|
23
|
+
return 0;
|
|
24
|
+
const elevation = elevationDeg * RAD;
|
|
25
|
+
const cosAlpha = (radiusKm / r) * Math.cos(elevation);
|
|
26
|
+
if (!(cosAlpha < 1))
|
|
27
|
+
return 0;
|
|
28
|
+
const alpha = Math.acos(Math.max(-1, cosAlpha));
|
|
29
|
+
return Math.max(0, alpha - elevation);
|
|
30
|
+
}
|
|
31
|
+
/** A unit vector for a longitude and latitude (+z at longitude 0, +x east, +y north). */
|
|
32
|
+
const unitOf = (point) => {
|
|
33
|
+
const lon = point.lon * RAD;
|
|
34
|
+
const lat = point.lat * RAD;
|
|
35
|
+
const c = Math.cos(lat);
|
|
36
|
+
return [c * Math.sin(lon), Math.sin(lat), c * Math.cos(lon)];
|
|
37
|
+
};
|
|
38
|
+
const fromUnit = (x, y, z) => {
|
|
39
|
+
const length = Math.hypot(x, y, z) || 1;
|
|
40
|
+
return { lon: (Math.atan2(x, z) * 180) / Math.PI, lat: (Math.asin(Math.max(-1, Math.min(1, y / length))) * 180) / Math.PI };
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Points from `a` to `b` along the great circle, about `stepDeg` apart, including both ends. A fast clock stays a continuous line.
|
|
44
|
+
*
|
|
45
|
+
* @param a - The start.
|
|
46
|
+
* @param b - The end.
|
|
47
|
+
* @param stepDeg - The longest step, in degrees.
|
|
48
|
+
* @returns The points, including both ends.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { trackSteps } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
53
|
+
*
|
|
54
|
+
* console.log(trackSteps({ lon: 0, lat: 0 }, { lon: 10, lat: 0 }, 2).length > 2);
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function trackSteps(a, b, stepDeg) {
|
|
58
|
+
const u = unitOf(a);
|
|
59
|
+
const v = unitOf(b);
|
|
60
|
+
const dot = Math.max(-1, Math.min(1, u[0] * v[0] + u[1] * v[1] + u[2] * v[2]));
|
|
61
|
+
const angle = Math.acos(dot);
|
|
62
|
+
const step = Math.max(0.25, stepDeg) * RAD;
|
|
63
|
+
if (!(angle > step))
|
|
64
|
+
return [a, b];
|
|
65
|
+
const count = Math.ceil(angle / step);
|
|
66
|
+
const sin = Math.sin(angle) || 1;
|
|
67
|
+
const out = [];
|
|
68
|
+
for (let i = 0; i <= count; i += 1) {
|
|
69
|
+
const t = i / count;
|
|
70
|
+
const left = Math.sin((1 - t) * angle) / sin;
|
|
71
|
+
const right = Math.sin(t * angle) / sin;
|
|
72
|
+
out.push(fromUnit(u[0] * left + v[0] * right, u[1] * left + v[1] * right, u[2] * left + v[2] * right));
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One segment, or two when the short way from `a` to `b` crosses the date line, so an equirectangular line does not cross the whole map.
|
|
78
|
+
* Longitude is degrees, −180 to 180. This is the same split chikyu-earth uses for a satellite over the Earth.
|
|
79
|
+
*
|
|
80
|
+
* @param a - The start.
|
|
81
|
+
* @param b - The end.
|
|
82
|
+
* @returns One segment, or two that meet at ±180.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* import { splitDateLine } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
87
|
+
*
|
|
88
|
+
* console.log(splitDateLine({ lon: 170, lat: 0 }, { lon: -170, lat: 0 }).length);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function splitDateLine(a, b) {
|
|
92
|
+
let delta = b.lon - a.lon;
|
|
93
|
+
if (delta > 180)
|
|
94
|
+
delta -= 360;
|
|
95
|
+
if (delta < -180)
|
|
96
|
+
delta += 360;
|
|
97
|
+
const end = a.lon + delta;
|
|
98
|
+
if (end <= 180 && end >= -180)
|
|
99
|
+
return [[a, { lon: end, lat: b.lat }]];
|
|
100
|
+
const edge = end > 180 ? 180 : -180;
|
|
101
|
+
const span = end - a.lon;
|
|
102
|
+
const t = span === 0 ? 0 : (edge - a.lon) / span;
|
|
103
|
+
const lat = a.lat + (b.lat - a.lat) * t;
|
|
104
|
+
const other = edge === 180 ? -180 : 180;
|
|
105
|
+
const rest = end > 180 ? end - 360 : end + 360;
|
|
106
|
+
return [
|
|
107
|
+
[a, { lon: edge, lat }],
|
|
108
|
+
[{ lon: other, lat }, { lon: rest, lat: b.lat }],
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* `splitDateLine`, and a split at a pole when the short way between two high-latitude points would cross the pole.
|
|
113
|
+
* Each piece is safe to draw as a straight line on an equirectangular map.
|
|
114
|
+
*
|
|
115
|
+
* @param a - The start.
|
|
116
|
+
* @param b - The end.
|
|
117
|
+
* @returns The pieces, in order.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { splitTrail } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
122
|
+
*
|
|
123
|
+
* console.log(splitTrail({ lon: 10, lat: 80 }, { lon: 170, lat: 75 }).length > 1);
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export function splitTrail(a, b) {
|
|
127
|
+
let delta = b.lon - a.lon;
|
|
128
|
+
if (delta > 180)
|
|
129
|
+
delta -= 360;
|
|
130
|
+
if (delta < -180)
|
|
131
|
+
delta += 360;
|
|
132
|
+
if (Math.abs(delta) > 90 && Math.abs(a.lat) > 45 && Math.abs(b.lat) > 45 && Math.sign(a.lat) === Math.sign(b.lat)) {
|
|
133
|
+
const pole = a.lat > 0 ? 90 : -90;
|
|
134
|
+
return [...splitDateLine(a, { lon: a.lon, lat: pole }), ...splitDateLine({ lon: b.lon, lat: pole }, b)];
|
|
135
|
+
}
|
|
136
|
+
return splitDateLine(a, b);
|
|
137
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type BodyId } from "../facts.ts";
|
|
2
|
+
import { type GroundPoint } from "../ground-track.ts";
|
|
3
|
+
import { type Vec3 } from "../vec.ts";
|
|
4
|
+
export type PaintLength = "1d" | "1w" | "1m";
|
|
5
|
+
export type PaintSwath = "track" | "coverage";
|
|
6
|
+
/**
|
|
7
|
+
* What to paint: which craft, how long the trail is kept, and whether it is the line under the craft or the ground where it stands 10° up.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import type { PaintSpec } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
12
|
+
*
|
|
13
|
+
* const spec: PaintSpec = { id: "lro", length: "1d", swath: "track" };
|
|
14
|
+
* console.log(spec.id);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export interface PaintSpec {
|
|
18
|
+
/** An orbiter id, such as `lro` or `mro`. */
|
|
19
|
+
id: string;
|
|
20
|
+
/** How long the trail is kept, in simulated time. `1d` when left out. */
|
|
21
|
+
length?: PaintLength;
|
|
22
|
+
/** `track` paints the point under the craft (the default). `coverage` paints where it is at least 10° above the horizon. */
|
|
23
|
+
swath?: PaintSwath;
|
|
24
|
+
}
|
|
25
|
+
/** Equirectangular, north at the first row, longitude −180 at the first column. */
|
|
26
|
+
export declare const PAINT_W = 1024;
|
|
27
|
+
export declare const PAINT_H = 512;
|
|
28
|
+
export declare const paintLengthOf: (length: PaintLength | undefined) => PaintLength;
|
|
29
|
+
export declare const paintSwathOf: (swath: PaintSwath | undefined) => PaintSwath;
|
|
30
|
+
/** Ticks since the epoch, in 16 bits. One tick is two minutes, so a month fits in a signed 16-bit age. */
|
|
31
|
+
export declare const paintMinute: (ms: number) => number;
|
|
32
|
+
/**
|
|
33
|
+
* Where a craft is on a body's surface. `eclipticKm` is from the body's centre, ecliptic J2000, the same axes `/orbiters` uses.
|
|
34
|
+
*
|
|
35
|
+
* @param body - The body the craft goes round.
|
|
36
|
+
* @param eclipticKm - The place, in kilometres from the body's centre.
|
|
37
|
+
* @param ms - The instant, so the body has turned under the craft.
|
|
38
|
+
* @returns Longitude, latitude and height.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```ts
|
|
42
|
+
* import { orientation } from "@johnmorrisdotca/wakusei-planets/painter";
|
|
43
|
+
*
|
|
44
|
+
* console.log(orientation("moon", Date.UTC(2026, 10, 11)).pole.length === 3);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function groundUnder(body: BodyId, eclipticKm: Vec3, ms: number): GroundPoint & {
|
|
48
|
+
heightKm: number;
|
|
49
|
+
};
|
|
50
|
+
export interface PaintTrail {
|
|
51
|
+
readonly data: Uint8Array;
|
|
52
|
+
readonly width: number;
|
|
53
|
+
readonly height: number;
|
|
54
|
+
readonly pixels: number;
|
|
55
|
+
readonly on: boolean;
|
|
56
|
+
readonly length: PaintLength;
|
|
57
|
+
readonly swath: PaintSwath;
|
|
58
|
+
readonly id: string;
|
|
59
|
+
readonly spanMinutes: number;
|
|
60
|
+
set(spec: PaintSpec | null): void;
|
|
61
|
+
clear(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Stamp the ground crossed since the last call, and drop what has fallen out of the length. Returns true when `data` changed and should be uploaded. At rest, or with painting off, false.
|
|
64
|
+
* `periodMs` is one trip of the craft: samples are taken often enough that the line between two follows the orbit, however fast the clock. A clock run backwards fills in the older end of the length.
|
|
65
|
+
*/
|
|
66
|
+
step(ms: number, radiusKm: number, sample: (ms: number) => (GroundPoint & {
|
|
67
|
+
heightKm: number;
|
|
68
|
+
}) | null, periodMs?: number): boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The trail buffer. One for a view. `set` with another craft clears what was painted.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { splitDateLine } from "@johnmorrisdotca/wakusei-planets/ground-track";
|
|
76
|
+
*
|
|
77
|
+
* console.log(splitDateLine({ lon: 170, lat: 0 }, { lon: -170, lat: 4 }).length === 2);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function createPaintTrail(): PaintTrail;
|