@johnmorrisdotca/wakusei-planets 0.30.0 → 0.31.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 CHANGED
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.31.0] - 2026-11-10
6
+
7
+ - **The body looked at is shown whole with a margin, no orbit line crosses it, and the demo opens moving** (machine1's review of the first hand-in). Zoom 1 now frames the body about 80% of the view's shorter side across (`FIT_DISTANCE` 4.1, it was 3.4 and the disc nearly touched the edges; Saturn is framed with its rings at 2.3 radii), so the zoom ceiling is 3.6 (the camera is as near as before). Close to a body (its disc 30 CSS pixels or more across its radius) only the orbit lines of its own system are drawn and the part of them within about twelve radii fades out, so no line is ever seen across the disc (`stats.orbits.hidden`). The demo's space page opens playing, from now, an hour a second, when its address names no date, speed or play and the reader has not asked for reduced motion; with reduced motion it opens still with Play ready. On the full-screen page the scale line sits at the bottom right and overlaps nothing. Browser tests: the disc is 72% to 88% of the shorter side, centred, at 1440x900, 390x844 and 2400x700 in the panel and full screen; the picture of the disc is the same with the lines on and off; the picture changes within two seconds with nothing touched.
8
+ - **Arrows on an orbit show which way the body goes, and the help mode shows its spin** (MODULES-857). With `orbits` on, six arrowheads about nine CSS pixels long sit along each orbit line (the Moon's too), pointing the way the body goes round; they keep their pixel size at every zoom, stay clear of the body, and show the real direction of travel, so they do not turn round when the clock runs backwards. `help` (new attribute and property, off by default) draws, on the body looked at, the line of its axis and a curved arrow round it for the way it spins, by the right-hand rule about the axis it really turns about (`spinAxis(id, ms)`, from its prime meridian's motion): the north pole for the Earth, the opposite way about the pole for Venus and Uranus, the way it goes round for a moon that keeps one face to its planet. `arrowSites`, `chevron`, `spinArrow`, `spinAxis` and `ARROWS_PER_ORBIT` are new in `/space`; `stats.arrows`, `stats.arrowPx` and `stats.help` read what was drawn. The three.js parts the view needs now include `LineSegments` (a page's own `setThreeLoader` subset adds it; the demo's does). The demo's Help switch turns the help mode on.
9
+ - **The space view offers every body the package knows: the dwarf planets are placed, and every moon can be gone to and ridden** (MODULES-741). `SPACE_BODIES` is now the nineteen bodies the view places (it was eleven): the Earth, the Sun, the Moon, the seven other planets, Pluto and the eight other dwarf planets, which `frameAt` gives in `frame.dwarfs` (new) from their osculating elements; `placeBodies`, `radiusIn` (a dwarf planet is its real size, or 0.3 Earth radii when compressed, whichever is larger), `moonDistance` and `planetOrbit` take them, `SPACE_DWARFS` and `SpaceDwarf` are new in `/space`, and `orbits` draws their lines, each body on its own. The moons of Orcus, Haumea and Eris are placed and drawn like those of the planets, `zoomFor` has `orcus-moons`, `haumea-moons` and `eris-moons` beside the planets', and every body of the 47 can be at the middle, gone to, hopped to and ridden. A dwarf planet under half a pixel across its radius is named and ringed but not drawn or made. The demo's picker is a kind, for a moon its planet, then the body, with a search by name and a "With its moons" button. `stats.bodies.painted` counts the dwarf planets made, so it can be above eleven.
10
+ - **Every planet and moon of the space view shows its real picture in every look** (MODULES-850, MODULES-809). The painter's context takes `mapped: true`: every body that has a surface map is drawn from it, whatever the look. `<wakusei-space>` passes it, so the realistic look, its default, draws Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto, the Moon and the moons that have maps from their pictures (it was the Earth alone) and the finer map tiles reach Mars and the Moon in it as they do in the painted look (MODULES-809); a body with no picture (Phobos, Deimos, Uranus's moons) is still shaded. The portrait and the single body are unchanged.
11
+ - **A view from beside the Moon with the Earth still in view** (MODULES-854). `space.ride("moon", { view: "beside" })`, and the same for any moon of a planet (`"io"`), puts the camera beyond the moon and off the line to its planet: the moon large in the foreground (about 20 degrees across its radius), the planet in view behind it at its real angular size (the Earth about two degrees from the Moon in the true scale) and never hidden by the moon, with a glide there and back. The camera opens off the line until the two discs clear each other, sits on the Sun's side where it can, turns the picture so the planet is beside the moon, and widens the field of view to fit the narrower side of the view; yaw swings it round the line, tilt opens the angle and zoom goes closer. `besideMoon(input)` and `BESIDE_RADII` (new, `/space`) are the pure maths. A planet or a point of your own with `view: "beside"` is refused. The demo's Ride along row has it as "Beside the Moon".
12
+ - **Any body can be at the middle of the space view, a press selects and a second press goes there, and a hopper goes through the bodies** (MODULES-858). `space.body` takes any body of the view by name in any case, in English or Japanese, including the moons of the planets (`titan`); `space.goTo(name, { smooth, zoom })` glides there and brings it whole into view. A first press selects (`wakusei-body-select`, `space.selected`) and a second goes there; a press never sends the view back to the Earth. `space.next()`, `previous()`, `hopper`, `bodyList()` and the `wakusei-hop` event give the order Sun, Mercury, Venus, Earth, Moon, Mars, Phobos, Deimos, Jupiter and its moons, and on; `HOP_ORDER`, `findBody`, `hopFrom`, `hostOf` and `bodyKindOf` are new in `/space`; `BodyInfo` gains `kind` and `host`. The names of a planet's moons are shown and placed (`placeOf`) once they are drawn. A test checks that `body = "Saturn"`, in any case, puts Saturn at the middle; `zoomFor` takes a preset in any case, and gives 1 for a name that is no preset (it gave NaN, or threw, for a capital: very likely why the prototype's `body = "Saturn"` with `zoomFor("Saturn-moons")` left the view on the Earth, since `body` itself always took the name in any case).
13
+ - **`<wakusei-space>` works full screen** (MODULES-848). `immersive` (new attribute and property) makes the element fill its box in any shape, a plain wheel zoom and a drag anywhere (a touch drag too) turn it, as the home page prototype needed; without it kazoku-ui's rules stand (Ctrl, Command or Alt with the wheel zooms, the plain wheel scrolls the page). At zoom 1 the body looked at is framed by the shorter side of the view in any shape, so it is never cut off, and Saturn is framed with its rings (2.4 radii across). A browser test (`fill-frame.demo.ts`) holds the space view, the portrait and the line-up of the demo to fill their frame edge to edge, canvas included, to within a pixel, at 1440, 390 and a wide short window. The demo has the page `space-full.html`, and `checkGestures` passes on it (the plain wheel's pan is named as the one gesture it lacks, because there the plain wheel zooms).
14
+ - **The Moon's orbit round the Earth is drawn, and every body is checked to sit on its own line** (MODULES-852). With `orbits` on, the view draws the Moon's path round the Earth (`moonOrbit(ms)`, new in `/space`: one sidereal month from the Moon's own place, closed, worked out again every five days of the clock) beside the Earth's and the planets' round the Sun, through the same mapping as the bodies in both scales. `stats.orbits` (new) lists the lines drawn and how far each body is from its own, as a fraction of the line's radius.
15
+ - **No two names of the space view overlap** (MODULES-855). The names of the bodies are chosen by rank (the body looked at, the Sun, the planets, the Moon) and one that would cover a surer one is left out, with its ring: a moon gives way to its planet and a planet to the Sun, and zooming in brings the names back. `chooseLabels(boxes)` and `LABEL_GAP` (new, `/space`) are the rule on plain boxes.
16
+ - **The space view opens at true distances, and says so** (MODULES-856). `scale` is `true` by default (it was `compressed`); the scale in use is named on the view itself ("True distances" or "Distances squeezed to fit", in the element's `lang`, with `scaleNames` for a page's own words and `::part(scale)` to style the line); a body whose disc is under 4 CSS pixels across its radius is marked with a ring as well as its name; and in the compressed scale the Moon is drawn at its true 0.273 of the Earth (it was 0.9, nearly as big as the Earth). A page that relied on the old default writes `scale="compressed"`. `space.placeOf(id)` (new) says where a body is on the screen.
17
+
5
18
  ## [0.30.0] - 2026-11-10
6
19
 
7
20
  - **The portrait and the space view zoom to their bodies' detail, with the finer map tiles** (MODULES-773). The painter, which draws every body of `<wakusei-portrait>` and `<wakusei-space>`, now takes the tiles, the window and the zoom table that `<wakusei-body>` got in 0.27.0. `PaintInfo.view` (new, optional: the camera and the size of its view in CSS pixels) lets a body work out which part of its surface the camera sees (`seenRegion`: rays through a grid of the view and round the edge of the near side, met with the body in its own frame, for an orthographic camera and a perspective one alike); a body whose disc is 150 device pixels across its radius or more, once the 2048 pixel map is not sharp enough, reads the tile set and lays the window over its map. `createPainter({ tiles })` says where the tiles are (`off` for none; the demo site's by default unless `textureBase` is given), `PaintContext.onLevels` is told what levels a body has, and `Painting.tiles` says what the window is doing. A caller that gives no `view` (chikyu-earth's space view) draws as it always did. Bodies that are not glowing take the generic detail in the painter's shader too, as in `<wakusei-body>`.
package/README.md CHANGED
@@ -15,9 +15,33 @@ 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.30.0/docs/images/hero-desk.png" width="640"></p>
18
+ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing to install, no account, and it is free.
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.30.0/docs/images/lineup-desk.png" width="640"></p>
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
+
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.31.0/docs/images/lineup-desk.png" width="640"></p>
23
+
24
+ ## Who it is for
25
+
26
+ - **Teachers and students:** [the size line-up](https://johnmorrisdotca.github.io/wakusei-planets/lineup.html) puts the Sun and the largest stars side by side at true relative size, each with its radius, its error and its paper, and [colouring sheets](https://johnmorrisdotca.github.io/wakusei-planets/kids.html) of the Sun, the planets and the big moons print on A4 or US Letter in English and Japanese, with the real colours and three facts each.
27
+ - **Space enthusiasts:** [the space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html) puts the Earth, the Moon, the Sun and the planets where they are now, or on any date you set, and zooms out to the whole solar system; [Jupiter and its moons as the Earth sees them now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1) is one click. The ten famous spacecraft (Voyager 1 and 2, New Horizons, Cassini, Juno, the Webb telescope and the rest) and where each is on any date are in [the spacecraft guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/spacecraft.html): that is code and a table, and there is no demo page for it yet.
28
+ - **Researchers and outreach staff:** every planet and the Moon is held within 6 arc-seconds of NASA's JPL Horizons on 60 dates from 1800 to 2200, and Jupiter's four big moons within 0.15 degree; [the accuracy guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/accuracy.html) gives each body's number and [NOTICE.md](NOTICE.md) names every source. The tables download as CSV and Parquet ([data files](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/data-files.html)). Read [Limits](#limits) first, and see [How to cite](#how-to-cite).
29
+ - **Writers, museums and site owners:** [the code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html) and [the portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) write the code that puts a body, or a picture of several, in your page as an `<iframe>` or a tag, with no build step.
30
+ - **Developers:** one `<wakusei-body>` tag, an SVG string with no browser at all, and typed data for the sizes, tilts, poles and places, and the bodies as objects for a three.js scene of your own; [One minute](#one-minute) and the [API](#api) are below.
31
+
32
+ ## Try it now, nothing to install
33
+
34
+ **Learn:** **[Colouring sheets to print](https://johnmorrisdotca.github.io/wakusei-planets/kids.html)** · **[Saturn's sheet](https://johnmorrisdotca.github.io/wakusei-planets/kids.html?sheet=saturn)** · **[The size line-up, the Sun to the largest stars](https://johnmorrisdotca.github.io/wakusei-planets/lineup.html)**
35
+
36
+ **Look:** **[Saturn, painted](https://johnmorrisdotca.github.io/wakusei-planets/?body=saturn&look=painted)** · **[Jupiter and its moons now](https://johnmorrisdotca.github.io/wakusei-planets/?body=jupiter&sky=real&moons=1)** · **[The space view](https://johnmorrisdotca.github.io/wakusei-planets/space.html)** · **[A star from its numbers: Vega](https://johnmorrisdotca.github.io/wakusei-planets/star.html?star=vega)**
37
+
38
+ **Make:** **[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html)** · **[The code builder](https://johnmorrisdotca.github.io/wakusei-planets/builder.html)**
39
+
40
+ **Language:** **[日本語](https://johnmorrisdotca.github.io/wakusei-planets/?lang=ja)** · **[English](https://johnmorrisdotca.github.io/wakusei-planets/?lang=en)**
41
+
42
+ ## For teachers and families
43
+
44
+ Wakusei Planets works on a phone or a tablet as well as on a computer, in the browser, and it is free: the code is MIT-licensed, and nothing is installed or signed up for. [The colouring-sheets guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/kids-sheets.html) says what each sheet is and how to print it, and [the size line-up guide](https://johnmorrisdotca.github.io/wakusei-planets/docs/guides/size-lineup.html) says where each star's radius comes from. Every source is credited in [NOTICE.md](NOTICE.md) and at the foot of each demo page.
21
45
 
22
46
  ## One minute
23
47
 
@@ -70,13 +94,6 @@ Every view already turns, zooms and pans with a drag, a pinch, Ctrl and the whee
70
94
 
71
95
  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).
72
96
 
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
97
  ## Features
81
98
 
82
99
  - The Sun, the eight planets, Pluto, eight more dwarf planets and 29 moons, each with its real size, flattening, axial tilt, pole and rotation as data.
@@ -302,7 +319,7 @@ A body that turns by itself and a moving sky, in HTML:
302
319
 
303
320
  ## The portrait builder
304
321
 
305
- <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.30.0/docs/images/portrait-family.png" width="640"></p>
322
+ <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.31.0/docs/images/portrait-family.png" width="640"></p>
306
323
 
307
324
  [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.
308
325
 
@@ -418,13 +435,28 @@ import { BODIES } from "@johnmorrisdotca/wakusei-planets";
418
435
  BODIES.pluto.kind; // "dwarf-planet"
419
436
  ```
420
437
 
421
- - A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the planets within a few arc-seconds on 60 dates from 1800 to 2200; the moons are within a degree or two on the orbit for almost every moon, about the size of the moon on screen, and Jupiter's four within a few hundredths of a degree; [accuracy](docs/guides/accuracy.md) has each body's number.
438
+ - **What it is for.** Pictures, charts, teaching and stories about the sky. It is not an ephemeris for pointing a telescope or planning a flight: for that use [JPL Horizons](https://ssd.jpl.nasa.gov/horizons/) itself, which every position here is checked against.
439
+ - **The planets** (Mercury to Neptune, VSOP87B cut to 995 of its 35,080 terms) are within 5 arc-seconds of Horizons on 60 dates from 1800 to 2200, Mars the worst at 4.8, and the tests hold each to 6 or less; the series is good for the years 1750 to 2250 and slowly worse beyond. Pluto's table is within 0.2.
440
+ - **The Moon** (ELP2000-82B cut to its 540 largest terms) is within 4.7 arc-seconds on the same 60 dates, held to 5.8.
441
+ - **The moons** are less exact: Jupiter's four big moons are within 0.15 degree and Saturn's seven inner ones within 2.1, Uranus's Miranda within 3 and Neptune's Nereid within 6.3; one degree on a moon's orbit is about the width of the moon on a screen. [Accuracy](docs/guides/accuracy.md) has each moon's number.
442
+ - **The dwarf planets** are within 0.2 arc-seconds of Horizons in the years their tables cover (1800 to 2200, Ceres 1900 to 2100); outside them the positions are plain ellipses, good for a few years either side of June 2026. Their moons other than Pluto's are not checked against Horizons, and a dwarf planet's pole is estimated where it is not measured (NOTICE.md says which).
443
+ - **The spacecraft** follow Horizons' own record, within 1,000 km near a planet and elsewhere a millionth of the distance from the Sun; a path after today is Horizons' prediction, not a fact.
444
+ - **Star sizes** in the line-up are each from a refereed paper, with the paper's error; WOH G64's and Stephenson 2-18's are estimated (from the spectrum and the brightness, and from a dust-shell fit) and not measured, and UY Scuti's distance is not a parallax. A star's surface (cells, spots, glow) is drawn for looks and says so.
445
+ - **Nothing is guessed.** A fact with no source is left out. [Accuracy](docs/guides/accuracy.md) has each body's number and how to run the check yourself.
422
446
  - `realistic` and `painted` are the photo maps (`painted` is the same maps, so an older page still works). `illustrated` is the shaded drawing from the numbers, and it is not a default. Venus, Saturn, Neptune and the Sun use Solar System Scope's maps (CC BY 4.0). Mercury uses the natural grey 8K map (Shady Tex and Solar System Scope, CC BY 4.0). Mars stays on the Viking mosaic, graded toward a butterscotch ochre, with the frost in Hellas toned to the basin and the polar ice left. Jupiter and Uranus use Nestaeric's maps (CC BY 4.0), and Saturn's poles use Nestaeric's caps (CC BY 4.0). The Earth and the Moon stay on their NASA maps until those have been compared. The rest are the public-domain maps in `NOTICE.md`.
423
447
  - A shaded look needs WebGL. Without it the line drawing is drawn.
424
448
  - Jupiter, Saturn, Uranus and Neptune have their rings drawn.
425
449
  - A portrait with no `turn` turns at 12 degrees a second, backwards when the body turns backwards. A picture with a date keeps that orientation and adds the same turn. `turn="0"` stays still.
426
450
  - 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.
427
451
 
452
+ ## How to cite
453
+
454
+ 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:
455
+
456
+ > Morris, J. (2026). *Wakusei Planets* (version 0.31.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
457
+
458
+ 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).
459
+
428
460
  ## Accessibility
429
461
 
430
462
  - 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"`.
@@ -474,7 +506,7 @@ pnpm test:readme # every ts block of the README, type-checked and run against
474
506
  pnpm test:usage # every way of using it in the README and the guides, built and opened
475
507
  pnpm docs:check # the reference site's checks
476
508
  pnpm test:demo # the demo and the docs site in a real browser
477
- pnpm dev # the demo on http://127.0.0.1:8225/wakusei-planets/
509
+ pnpm dev # the demo on http://127.0.0.1:8300/wakusei-planets/
478
510
  ```
479
511
 
480
512
  The pictures in `docs/images` are made by the package's own script:
@@ -7,7 +7,7 @@ import { type DetailStats } from "./detail.ts";
7
7
  import type { TileLevel } from "./tiles.ts";
8
8
  export { fallbackLook } from "./fallback.ts";
9
9
  /** The parts of three.js the bodies use: a page may hand over a module with only these (see `setThreeLoader`). */
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">;
10
+ export type ThreeParts = Pick<typeof THREE, "AdditiveBlending" | "BufferAttribute" | "BufferGeometry" | "ClampToEdgeWrapping" | "DataTexture" | "DoubleSide" | "Group" | "Line" | "LineBasicMaterial" | "LineSegments" | "LinearFilter" | "Mesh" | "NoColorSpace" | "OrthographicCamera" | "PlaneGeometry" | "RepeatWrapping" | "RGBAFormat" | "RingGeometry" | "Scene" | "ShaderMaterial" | "SphereGeometry" | "TextureLoader" | "Vector2" | "Vector3" | "WebGLRenderer">;
11
11
  /** One moon in a system view: its place in planet radii (viewer's frame) and the points of its orbit, if they changed. */
12
12
  export interface MoonDraw {
13
13
  id: BodyId;
@@ -43,6 +43,8 @@ export type PainterLook = (typeof LOOKS)[number];
43
43
  export interface PaintContext {
44
44
  /** `realistic` (the default) or `painted`. */
45
45
  look?: string;
46
+ /** True to draw every body that has a surface picture from it, in any look (the space view does: a planet or a moon with a real map never shows the shaded look instead). A body with no picture is still shaded. */
47
+ mapped?: boolean;
46
48
  /** Ask for a new draw: a sharper picture has arrived. */
47
49
  invalidate?(): void;
48
50
  /** Device pixels to a CSS pixel; default 1. */
@@ -92,7 +92,7 @@ function sightOf(T, view) {
92
92
  function paint(T, id, context, bases) {
93
93
  const facts = BODIES[id];
94
94
  const look = lookOf(id) ?? fallbackLook(facts);
95
- const wantPainted = (context.look === "painted" || look.mapped === true) && look.painted !== undefined;
95
+ const wantPainted = (context.look === "painted" || look.mapped === true || context.mapped === true) && look.painted !== undefined;
96
96
  const ratio = context.ratio ?? 1;
97
97
  const maxWidth = context.maxTexture ?? 2048;
98
98
  const redraw = () => context.invalidate?.();
@@ -9,7 +9,7 @@ import type * as THREE from "three";
9
9
  * console.log(TEXTURE_BASE);
10
10
  * ```
11
11
  */
12
- export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.30.0/dist/textures/";
12
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.31.0/dist/textures/";
13
13
  /**
14
14
  * 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
15
15
  * never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
@@ -21,7 +21,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
21
21
  * console.log(TEXTURE_FAR_BASE);
22
22
  * ```
23
23
  */
24
- export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.30.0/textures/";
24
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.31.0/textures/";
25
25
  /**
26
26
  * Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
27
27
  * a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
@@ -0,0 +1,87 @@
1
+ import { type Vec3 } from "../vec.ts";
2
+ /**
3
+ * How many arrowheads an orbit line carries.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { ARROWS_PER_ORBIT } from "@johnmorrisdotca/wakusei-planets/space";
8
+ *
9
+ * console.log(ARROWS_PER_ORBIT);
10
+ * ```
11
+ */
12
+ export declare const ARROWS_PER_ORBIT = 6;
13
+ /**
14
+ * One arrowhead on an orbit line: where its tip is and the way it points, the way the body goes along the line.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { OrbitArrow } from "@johnmorrisdotca/wakusei-planets/space";
19
+ *
20
+ * const arrow: OrbitArrow = { position: [1, 0, 0], direction: [0, 1, 0] };
21
+ * console.log(arrow.direction);
22
+ * ```
23
+ */
24
+ export interface OrbitArrow {
25
+ position: Vec3;
26
+ direction: Vec3;
27
+ }
28
+ /**
29
+ * Where the arrowheads go on an orbit line, and which way each points. The line is the points of `planetOrbit` as the view places them: they run from where the body is now once round in the order the body
30
+ * goes, so the direction of each arrow is the line's own direction there, from the point before to the point after. The arrows are spread evenly round the line and stay clear of the body, which is at its first point.
31
+ * They show the real way the body travels, which is the same whichever way the clock runs.
32
+ *
33
+ * @param line - The orbit line, `count + 1` points whose last is near the first.
34
+ * @param arrows - How many arrowheads (`ARROWS_PER_ORBIT` by default).
35
+ * @returns The arrows, each at a point of the line.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { arrowSites } from "@johnmorrisdotca/wakusei-planets/space";
40
+ *
41
+ * const circle = Array.from({ length: 97 }, (_, i) => [Math.cos((i / 96) * 2 * Math.PI), 0, Math.sin((i / 96) * 2 * Math.PI)] as const);
42
+ * console.log(arrowSites(circle, 4).map((a) => a.direction.map((n) => n.toFixed(2)).join(",")).join(" | "));
43
+ * ```
44
+ */
45
+ export declare function arrowSites(line: readonly (readonly [number, number, number])[], arrows?: number): OrbitArrow[];
46
+ /**
47
+ * The three points of a small arrowhead that is `size` long in the picture: its tip at `position`, and the ends of its two wings, laid in the plane of the picture so it points the way `direction` goes on the screen.
48
+ * A direction straight into or out of the picture has no way on the screen and gives none.
49
+ *
50
+ * @param position - The tip, in the scene's units.
51
+ * @param direction - The way it points in the scene.
52
+ * @param right - The camera's right-hand direction (a unit vector).
53
+ * @param up - The camera's up direction (a unit vector).
54
+ * @param size - The length of a wing, in the scene's units at the tip (pixels times the size of a pixel there).
55
+ * @returns The tip and the two wing ends, or `null`.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { chevron } from "@johnmorrisdotca/wakusei-planets/space";
60
+ *
61
+ * console.log(chevron([0, 0, 0], [1, 0, 0], [1, 0, 0], [0, 1, 0], 2)?.map((p) => p.map((n) => n.toFixed(1)).join(",")).join(" "));
62
+ * ```
63
+ */
64
+ export declare function chevron(position: Vec3, direction: Vec3, right: Vec3, up: Vec3, size: number): [Vec3, Vec3, Vec3] | null;
65
+ /**
66
+ * The curved arrow of the help mode: points on a circle round the axis a body spins about, turning the way it turns (by the right-hand rule about `axis`), as `segments + 1` points from its tail to its head, and the
67
+ * two ends of the head's wings. The circle has radius `radius` and sits `lift` along the axis from `centre`; the arc covers 250 degrees, ending where it started 250 degrees on.
68
+ *
69
+ * @param centre - The body's centre.
70
+ * @param axis - The unit axis it spins about (the right-hand rule: the fingers curl the way it turns).
71
+ * @param radius - The circle's radius, in the scene's units.
72
+ * @param lift - How far along the axis the circle is from the centre.
73
+ * @param segments - How many pieces the arc is cut into.
74
+ * @returns The points of the arc, and the points of the arrowhead's wings (the head is at the arc's last point).
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { spinArrow } from "@johnmorrisdotca/wakusei-planets/space";
79
+ *
80
+ * const { arc } = spinArrow([0, 0, 0], [0, 1, 0], 1.3, 0.5, 20);
81
+ * console.log(arc.length);
82
+ * ```
83
+ */
84
+ export declare function spinArrow(centre: Vec3, axis: Vec3, radius: number, lift: number, segments?: number): {
85
+ arc: Vec3[];
86
+ head: [Vec3, Vec3];
87
+ };
@@ -0,0 +1,117 @@
1
+ // The little arrows on an orbit line that show which way the body goes, and the shapes the help mode draws round the body looked at. Pure: lines in, places and directions out; the scene turns them into lines on the screen.
2
+ import { add, cross, dot, RAD, scale, unit } from "../vec.js";
3
+ /**
4
+ * How many arrowheads an orbit line carries.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { ARROWS_PER_ORBIT } from "@johnmorrisdotca/wakusei-planets/space";
9
+ *
10
+ * console.log(ARROWS_PER_ORBIT);
11
+ * ```
12
+ */
13
+ export const ARROWS_PER_ORBIT = 6;
14
+ /**
15
+ * Where the arrowheads go on an orbit line, and which way each points. The line is the points of `planetOrbit` as the view places them: they run from where the body is now once round in the order the body
16
+ * goes, so the direction of each arrow is the line's own direction there, from the point before to the point after. The arrows are spread evenly round the line and stay clear of the body, which is at its first point.
17
+ * They show the real way the body travels, which is the same whichever way the clock runs.
18
+ *
19
+ * @param line - The orbit line, `count + 1` points whose last is near the first.
20
+ * @param arrows - How many arrowheads (`ARROWS_PER_ORBIT` by default).
21
+ * @returns The arrows, each at a point of the line.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { arrowSites } from "@johnmorrisdotca/wakusei-planets/space";
26
+ *
27
+ * const circle = Array.from({ length: 97 }, (_, i) => [Math.cos((i / 96) * 2 * Math.PI), 0, Math.sin((i / 96) * 2 * Math.PI)] as const);
28
+ * console.log(arrowSites(circle, 4).map((a) => a.direction.map((n) => n.toFixed(2)).join(",")).join(" | "));
29
+ * ```
30
+ */
31
+ export function arrowSites(line, arrows = ARROWS_PER_ORBIT) {
32
+ const n = line.length - 1;
33
+ const out = [];
34
+ if (n < 4 || arrows < 1)
35
+ return out;
36
+ for (let k = 0; k < arrows; k += 1) {
37
+ // k + 1/2 of the way round in equal steps: never at the body (the first point) or at the join
38
+ const i = Math.min(n - 1, Math.max(1, Math.round(((k + 0.5) / arrows) * n)));
39
+ const before = line[i - 1];
40
+ const after = line[i + 1];
41
+ const direction = unit([after[0] - before[0], after[1] - before[1], after[2] - before[2]]);
42
+ out.push({ position: line[i], direction });
43
+ }
44
+ return out;
45
+ }
46
+ /**
47
+ * The three points of a small arrowhead that is `size` long in the picture: its tip at `position`, and the ends of its two wings, laid in the plane of the picture so it points the way `direction` goes on the screen.
48
+ * A direction straight into or out of the picture has no way on the screen and gives none.
49
+ *
50
+ * @param position - The tip, in the scene's units.
51
+ * @param direction - The way it points in the scene.
52
+ * @param right - The camera's right-hand direction (a unit vector).
53
+ * @param up - The camera's up direction (a unit vector).
54
+ * @param size - The length of a wing, in the scene's units at the tip (pixels times the size of a pixel there).
55
+ * @returns The tip and the two wing ends, or `null`.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { chevron } from "@johnmorrisdotca/wakusei-planets/space";
60
+ *
61
+ * console.log(chevron([0, 0, 0], [1, 0, 0], [1, 0, 0], [0, 1, 0], 2)?.map((p) => p.map((n) => n.toFixed(1)).join(",")).join(" "));
62
+ * ```
63
+ */
64
+ export function chevron(position, direction, right, up, size) {
65
+ const dx = dot(direction, right);
66
+ const dy = dot(direction, up);
67
+ const l = Math.hypot(dx, dy);
68
+ if (l < 1e-3)
69
+ return null;
70
+ const [ux, uy] = [dx / l, dy / l];
71
+ const alpha = 28 * RAD;
72
+ const wing = (sign) => {
73
+ // the direction on the screen, turned back by `alpha` to one side or the other
74
+ const vx = -(ux * Math.cos(alpha) - sign * uy * Math.sin(alpha));
75
+ const vy = -(uy * Math.cos(alpha) + sign * ux * Math.sin(alpha));
76
+ return add(position, add(scale(right, vx * size), scale(up, vy * size)));
77
+ };
78
+ return [position, wing(1), wing(-1)];
79
+ }
80
+ /**
81
+ * The curved arrow of the help mode: points on a circle round the axis a body spins about, turning the way it turns (by the right-hand rule about `axis`), as `segments + 1` points from its tail to its head, and the
82
+ * two ends of the head's wings. The circle has radius `radius` and sits `lift` along the axis from `centre`; the arc covers 250 degrees, ending where it started 250 degrees on.
83
+ *
84
+ * @param centre - The body's centre.
85
+ * @param axis - The unit axis it spins about (the right-hand rule: the fingers curl the way it turns).
86
+ * @param radius - The circle's radius, in the scene's units.
87
+ * @param lift - How far along the axis the circle is from the centre.
88
+ * @param segments - How many pieces the arc is cut into.
89
+ * @returns The points of the arc, and the points of the arrowhead's wings (the head is at the arc's last point).
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * import { spinArrow } from "@johnmorrisdotca/wakusei-planets/space";
94
+ *
95
+ * const { arc } = spinArrow([0, 0, 0], [0, 1, 0], 1.3, 0.5, 20);
96
+ * console.log(arc.length);
97
+ * ```
98
+ */
99
+ export function spinArrow(centre, axis, radius, lift, segments = 28) {
100
+ const k = unit(axis);
101
+ const seed = Math.abs(k[1]) < 0.9 ? [0, 1, 0] : [1, 0, 0];
102
+ const e1 = unit(cross(seed, k));
103
+ const e2 = cross(k, e1);
104
+ const span = 250 * RAD;
105
+ const at = (phi) => add(add(centre, scale(k, lift)), add(scale(e1, radius * Math.cos(phi)), scale(e2, radius * Math.sin(phi))));
106
+ const arc = [];
107
+ for (let i = 0; i <= segments; i += 1)
108
+ arc.push(at(-span / 2 + (i / segments) * span));
109
+ // the head: two short strokes back from the tip, in the plane of the circle, either side of the way it goes (the tangent, increasing phi)
110
+ const tip = arc[segments];
111
+ const phi = span / 2;
112
+ const tangent = unit(add(scale(e1, -Math.sin(phi)), scale(e2, Math.cos(phi))));
113
+ const outward = unit(add(scale(e1, Math.cos(phi)), scale(e2, Math.sin(phi))));
114
+ const back = 0.16 * radius;
115
+ const head = [add(tip, add(scale(tangent, -back), scale(outward, back * 0.55))), add(tip, add(scale(tangent, -back), scale(outward, -back * 0.55)))];
116
+ return { arc, head };
117
+ }
@@ -0,0 +1,74 @@
1
+ import { type Vec3 } from "../vec.ts";
2
+ /**
3
+ * How many radii of the moon the camera keeps from it at zoom 1: the moon then spans about 20 degrees of the view.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { BESIDE_RADII } from "@johnmorrisdotca/wakusei-planets/space";
8
+ *
9
+ * console.log(BESIDE_RADII);
10
+ * ```
11
+ */
12
+ export declare const BESIDE_RADII = 5.8;
13
+ /**
14
+ * What `besideMoon` is asked: where the moon, the planet it goes round and the Sun are and how big the moon and the planet are (one unit for all), the shape of the view, and the shared controls' zoom, yaw and tilt.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { BesideInput } from "@johnmorrisdotca/wakusei-planets/space";
19
+ *
20
+ * const input: BesideInput = { moon: [60, 0, 0], moonRadius: 0.273, host: [0, 0, 0], hostRadius: 1, sun: [-23000, 0, 0], aspect: 1.6, zoom: 1, yaw: 0, tilt: 0 };
21
+ * console.log(input.moonRadius);
22
+ * ```
23
+ */
24
+ export interface BesideInput {
25
+ moon: Vec3;
26
+ moonRadius: number;
27
+ host: Vec3;
28
+ hostRadius: number;
29
+ sun: Vec3;
30
+ /** The view's width over its height. */
31
+ aspect: number;
32
+ /** 1 keeps `BESIDE_RADII` moon radii from the moon; more goes closer, less goes further. */
33
+ zoom: number;
34
+ /** Degrees the camera swings round the line from the planet through the moon (a drag across the view is 180). */
35
+ yaw: number;
36
+ /** Degrees the camera opens further off that line (a drag down the view is 60). */
37
+ tilt: number;
38
+ }
39
+ /**
40
+ * The camera `besideMoon` works out: where it is, which way it looks and its up, its vertical field of view in degrees, how far it is from the moon, and the angle in degrees between the moon and the planet as the camera sees them.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import type { BesideCamera } from "@johnmorrisdotca/wakusei-planets/space";
45
+ *
46
+ * const describe = (camera: BesideCamera): string => `${camera.separation.toFixed(0)} degrees apart in a ${camera.fov.toFixed(0)} degree view`;
47
+ * console.log(typeof describe);
48
+ * ```
49
+ */
50
+ export interface BesideCamera {
51
+ position: Vec3;
52
+ forward: Vec3;
53
+ up: Vec3;
54
+ fov: number;
55
+ distance: number;
56
+ separation: number;
57
+ }
58
+ /**
59
+ * The camera for a view from near a moon with its planet still in view: beyond the moon on the side away from the planet and a little off the line to it, so the moon is large in the foreground and the planet is behind it,
60
+ * at the angular size it really has from there. The camera sits on the Sun's side of that line where it can, so the moon shows a lit face. It opens off the line, from 25 degrees, until the two discs no longer touch
61
+ * (with 2 degrees to spare), turns the picture so the planet is to one side of the moon, and widens the field of view until both fit the view's narrower side.
62
+ *
63
+ * @param input - The places and sizes, the view's shape, and the zoom, yaw and tilt.
64
+ * @returns The camera.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { besideMoon } from "@johnmorrisdotca/wakusei-planets/space";
69
+ *
70
+ * const camera = besideMoon({ moon: [60.3, 0, 0], moonRadius: 0.273, host: [0, 0, 0], hostRadius: 1, sun: [-23000, 5000, 9000], aspect: 1.6, zoom: 1, yaw: 0, tilt: 0 });
71
+ * console.log(camera.distance.toFixed(2), camera.separation.toFixed(0));
72
+ * ```
73
+ */
74
+ export declare function besideMoon(input: BesideInput): BesideCamera;
@@ -0,0 +1,76 @@
1
+ // A camera placed beside and beyond a moon, off the line to the planet it goes round: the moon is large in the foreground and the planet is in view behind it, at its real angular size. Pure: places in, a camera out.
2
+ import { add, cross, dot, length, RAD, scale, unit } from "../vec.js";
3
+ /**
4
+ * How many radii of the moon the camera keeps from it at zoom 1: the moon then spans about 20 degrees of the view.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { BESIDE_RADII } from "@johnmorrisdotca/wakusei-planets/space";
9
+ *
10
+ * console.log(BESIDE_RADII);
11
+ * ```
12
+ */
13
+ export const BESIDE_RADII = 5.8;
14
+ /** The angle off the line from the planet through the moon, in degrees, the camera first tries; it opens wider until the planet clears the moon. */
15
+ const FIRST_ANGLE = 25;
16
+ const angleBetween = (a, b) => Math.acos(Math.max(-1, Math.min(1, dot(unit(a), unit(b))))) / RAD;
17
+ const minus = (a, b) => add(a, scale(b, -1));
18
+ /**
19
+ * The camera for a view from near a moon with its planet still in view: beyond the moon on the side away from the planet and a little off the line to it, so the moon is large in the foreground and the planet is behind it,
20
+ * at the angular size it really has from there. The camera sits on the Sun's side of that line where it can, so the moon shows a lit face. It opens off the line, from 25 degrees, until the two discs no longer touch
21
+ * (with 2 degrees to spare), turns the picture so the planet is to one side of the moon, and widens the field of view until both fit the view's narrower side.
22
+ *
23
+ * @param input - The places and sizes, the view's shape, and the zoom, yaw and tilt.
24
+ * @returns The camera.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { besideMoon } from "@johnmorrisdotca/wakusei-planets/space";
29
+ *
30
+ * const camera = besideMoon({ moon: [60.3, 0, 0], moonRadius: 0.273, host: [0, 0, 0], hostRadius: 1, sun: [-23000, 5000, 9000], aspect: 1.6, zoom: 1, yaw: 0, tilt: 0 });
31
+ * console.log(camera.distance.toFixed(2), camera.separation.toFixed(0));
32
+ * ```
33
+ */
34
+ export function besideMoon(input) {
35
+ const { moon, moonRadius, host, hostRadius } = input;
36
+ const away = unit(minus(moon, host));
37
+ const toSun = unit(minus(input.sun, moon));
38
+ let side = minus(toSun, scale(away, dot(toSun, away)));
39
+ if (length(side) < 1e-3)
40
+ side = cross(away, [0, 1, 0]);
41
+ if (length(side) < 1e-3)
42
+ side = cross(away, [1, 0, 0]);
43
+ side = unit(side);
44
+ const distance = Math.max(1.05 * moonRadius, (BESIDE_RADII * moonRadius) / Math.max(1e-9, input.zoom));
45
+ const swing = (v) => {
46
+ // the camera swings round the line from the planet through the moon by `yaw`
47
+ const turn = input.yaw * RAD;
48
+ return add(add(scale(v, Math.cos(turn)), scale(cross(away, v), Math.sin(turn))), scale(away, dot(away, v) * (1 - Math.cos(turn))));
49
+ };
50
+ const place = (angle) => {
51
+ const direction = swing(add(scale(away, Math.cos(angle * RAD)), scale(side, Math.sin(angle * RAD))));
52
+ const position = add(moon, scale(direction, distance));
53
+ return { position, separation: angleBetween(minus(moon, position), minus(host, position)) };
54
+ };
55
+ const moonHalf = (position) => Math.asin(Math.min(1, moonRadius / Math.max(moonRadius * 1.0001, length(minus(moon, position))))) / RAD;
56
+ const hostHalf = (position) => Math.asin(Math.min(1, hostRadius / Math.max(hostRadius * 1.0001, length(minus(host, position))))) / RAD;
57
+ let angle = Math.max(5, Math.min(85, FIRST_ANGLE + input.tilt));
58
+ let spot = place(angle);
59
+ while (angle < 85 && spot.separation < moonHalf(spot.position) + hostHalf(spot.position) + 2) {
60
+ angle += 2;
61
+ spot = place(angle);
62
+ }
63
+ const { position } = spot;
64
+ const toMoon = unit(minus(moon, position));
65
+ const toHost = unit(minus(host, position));
66
+ // look between the two, and turn the picture so the planet is to the side of the moon, not above or below it
67
+ const forward = unit(add(toMoon, toHost));
68
+ const shift = minus(toHost, toMoon);
69
+ const across = unit(minus(shift, scale(forward, dot(shift, forward))));
70
+ const up = unit(cross(across, forward));
71
+ // both discs fit: the half-angle from the middle to the far edge of each, across and up
72
+ const reach = Math.max(angleBetween(forward, toMoon) + moonHalf(position), angleBetween(forward, toHost) + hostHalf(position)) + 3;
73
+ const half = Math.max(Math.tan(reach * RAD) / Math.min(1.6, Math.max(0.3, input.aspect)), Math.tan((moonHalf(position) + 3) * RAD));
74
+ const fov = Math.min(110, Math.max(35, 2 * Math.atan(half) / RAD));
75
+ return { position, forward, up, fov, distance, separation: spot.separation };
76
+ }
@@ -0,0 +1,83 @@
1
+ import { type BodyId, type HostId } from "../facts.ts";
2
+ /**
3
+ * What a body is: the Sun, one of the eight planets, a dwarf planet (Pluto among them) or a moon.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { bodyKindOf, type SpaceKind } from "@johnmorrisdotca/wakusei-planets/space";
8
+ *
9
+ * const kind: SpaceKind = bodyKindOf("titan");
10
+ * console.log(kind);
11
+ * ```
12
+ */
13
+ export type SpaceKind = "star" | "planet" | "dwarf-planet" | "moon";
14
+ /**
15
+ * Every body the package knows, in the order a hopper goes: the Sun, then each planet and dwarf planet from the Sun outwards, each followed by its moons nearest first (Mercury, Venus, the Earth and the
16
+ * Moon, Mars, Phobos and Deimos, Ceres, Jupiter and its four large moons, and on to Sedna).
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { HOP_ORDER } from "@johnmorrisdotca/wakusei-planets/space";
21
+ *
22
+ * console.log(HOP_ORDER.slice(0, 7).join(", "));
23
+ * ```
24
+ */
25
+ export declare const HOP_ORDER: readonly BodyId[];
26
+ /**
27
+ * What kind of body a name is.
28
+ *
29
+ * @param id - A body's name.
30
+ * @returns `star` for the Sun, `planet` for the eight planets, `dwarf-planet` for Pluto and the others, or `moon`.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { bodyKindOf } from "@johnmorrisdotca/wakusei-planets/space";
35
+ *
36
+ * console.log(bodyKindOf("ceres"), bodyKindOf("moon"));
37
+ * ```
38
+ */
39
+ export declare function bodyKindOf(id: BodyId): SpaceKind;
40
+ /**
41
+ * The planet or dwarf planet a moon goes round, or `undefined` for a body that is not a moon.
42
+ *
43
+ * @param id - A body's name.
44
+ * @returns The host's name for a moon, `undefined` for any other body.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { hostOf } from "@johnmorrisdotca/wakusei-planets/space";
49
+ *
50
+ * console.log(hostOf("titan"), hostOf("mars"));
51
+ * ```
52
+ */
53
+ export declare function hostOf(id: BodyId): HostId | undefined;
54
+ /**
55
+ * Read a body from what a reader or a page might write: its name in the package's lower case, in English or in Japanese, in any case.
56
+ *
57
+ * @param text - `saturn`, `Saturn`, `土星`.
58
+ * @returns The body's name, or `undefined` when no body has it.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { findBody } from "@johnmorrisdotca/wakusei-planets/space";
63
+ *
64
+ * console.log(findBody("Saturn"), findBody("土星"), findBody("nothing"));
65
+ * ```
66
+ */
67
+ export declare function findBody(text: string): BodyId | undefined;
68
+ /**
69
+ * The body after `id` in the hopper's order (or before it with a negative `step`), among those `can` accepts, going round from the last to the first.
70
+ *
71
+ * @param id - Where the hopper is.
72
+ * @param step - `1` for the next body, `-1` for the previous one.
73
+ * @param can - Which bodies the view can go to (all of them by default).
74
+ * @returns The next body, or `id` itself when no other is accepted.
75
+ *
76
+ * @example
77
+ * ```ts
78
+ * import { hopFrom } from "@johnmorrisdotca/wakusei-planets/space";
79
+ *
80
+ * console.log(hopFrom("earth", 1), hopFrom("earth", -1), hopFrom("sun", -1, (id) => id !== "sedna"));
81
+ * ```
82
+ */
83
+ export declare function hopFrom(id: BodyId, step: 1 | -1, can?: (id: BodyId) => boolean): BodyId;