@johnmorrisdotca/wakusei-planets 0.54.0 → 0.56.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,26 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.56.0] - 2026-11-17
6
+
7
+ - **A move from the Earth view out to a planet or the Sun goes straight, not out to the whole system and back** (MODULES-1388, linked to MODULES-1371; John Morris, 2026-11-16). The site hands the planets view over at the Earth view's far distance (187 Earth radii, the Earth a few pixels across) with the destination turned into the picture; in the squeezed scale that distance already shows the whole system, and the planner then backed off from the Earth to a stand on the line of the last view, 2.2 times the distance between the two bodies for the Earth to Pluto, to turn there and come in. Where that stand is more than 1.2 times as far from the body left as the camera began (`BACK_UP`), the planner now tries the straight way, a swing (straight at the destination with it in the picture, the look direction turned round it over the last stretch), and takes it when its walk has no fault of any kind more than the other. Measured on the inputs the space view handed the planner (`test/data/travel-site-inputs.json`), how far out the camera goes, in the larger of the distance between the bodies and where it began (`out` in `test/travel-harness.ts`): the Earth to Mars 1.52 before and 1.00 now, to Pluto 2.23 and 0.64, to the Sun 1.00 and 1.00; over 180 moves from the Earth (ten destinations, three directions, both pictures' shapes, both scales) the ones over 1.2 fall from 15 to 3 (the tall picture with the destination 50 degrees off, where the swing has a fault) and the farthest from 3.22 to 1.6. Stops between the turn and the way on (MODULES-1384), over the 54 moves of `test/travel-smooth.test.ts`: 26 before and 26 now; the moves that start the way on during the turn fall from 42 to 35, those 7 being swings, which keep their own timing.
8
+ - **A planet or moon left in the same breath as another move no longer backs out to the whole system** (MODULES-1388, linked to MODULES-1371). `goTo` and `ride` took the body the camera is at from the view's focus, so a page that calls `ride(null)` and then `ride("europa")` before the first has drawn left the planet from beside Io: the planner was told the body left was Jupiter, the camera far from it in the picture, and backed out to 480 Earth radii (34 times the distance between the moons) and in again; Titan to Enceladus went to 376. A move that has been asked for and not yet drawn has not moved the camera, so the next move now leaves the body the first one was leaving: Io to Europa stays within 1.05 of the distance between them, Titan to Enceladus within 0.7. `e2e/space-travel.demo.ts` has the spec.
9
+ - **Pluto's tiles no longer show a seam against the unmapped south** (MODULES-1388, linked to MODULES-1371). The 2048 picture fades the New Horizons detail into a plain tone over 8 percent of its height at the edge of the mapped ground, but the level 1 tiles put the source's detail back up to the ragged edge of the data (4 cells of 8 pixels), so the crisp ground ended in a line against the smooth brown. `scripts/make-body-tiles.py` takes a `fade` (cells of 8 pixels, 4 by default) for a source whose picture fades its edge, and Pluto's is 14. The tiles are built by the Pages workflow and never committed.
10
+
11
+ ## [0.55.0] - 2026-11-17
12
+
13
+ - **The lit side wins over the body left** (John Morris, 2026-11-16). Keeping the body left behind the destination at the end of a move put the body gone to in its own night: the Sun behind Mercury, the Earth behind Jupiter. `arrivalSide`'s `behind` is now taken only where the body gone to is still at least half lit (`BEHIND_LIT`, one half, the rule every other arrival keeps); everywhere else, which is every move outward to a planet beyond the body left, the camera arrives on the sunlit side with one of the body's moons in the picture, and the body left is in the picture for as long as the way allows (through the turn, and, between a planet and its moon, all through) but not in the last view. Of 78 walks of 13 pairs in both scales and three picture shapes, 25 keep the body left in the picture all through and 53 lose it for the rest of the way; every walk's last view is at least half lit. This is also the real fix for two demo specs that failed in CI on the 0.55.0 candidate: the label on Mars is seen on its lit side (in the CI image the etched, outline and burned looks change 1,983 to 2,205 pixels inside Mars's disc where the specs want more than 300; with the Earth behind Mars they were 287), and the soak's walk to the planets and back arrives on the same sides as before 0.55.0 (146 GPU objects at the start and after every walk but one that read 148, four or five walks, three runs in the CI image). A way on that starts while the turn is still going now also keeps the body left (or the planet circled) in the picture through the turn, as the turn always did (`Faults.held`); that costs some of the overlap (26 of 54 moves still stop between turn and way on, where 9 did). The GL walks of the Sun to each inner planet, a planet to its moon and a moon to another planet now read each draw for "the body left or the destination is on the screen" and, between a planet and its moon, "together all through"; the pair and body frame walks turn the camera round the body until the companion is in the picture, as an arrival no longer does it.
14
+
15
+ - **An arrival that keeps the body left behind the destination also keeps a moon, where a side does both** (fix for the demo specs of 0.55.0). `arrivalSide` now prefers, among the sides that put the body left at the back left or right, one that also frames a moon of the body (or its planet) and returns that moon as `companion`; the space view names it in `stats.companion`. Jupiter from the Earth keeps one of its four moons again, as before. The arrival spec passes on all four projects. `e2e/moon-size.demo.ts` now reads the largest of Jupiter's four moons, not Ganymede, because which moon is near the camera depends on the side the arrival stands on.
16
+
17
+ - **A drag in the rover's chase view turns the view from where the camera is, not the camera round the rover** (MODULES-1381). In the chase view (the default of `drive="on"`) the eyes stood 6.5 m behind the rover along its heading plus the drag's turn, so a drag took the camera round the rover as it looked, the rover stayed in the middle of the picture and the whole vehicle seemed to be moved. A drag now turns the view where the camera is, like turning your head: the camera keeps its place 6.5 m behind and 2.8 m above the rover, the ground and the sky turn round it, and the rover leaves the picture as you look away and comes back when you turn back. The same change chikyu-earth 0.52.0 made to rides, with the same names. **A change of behaviour**: `drive-drag="orbit"` (the property `driveDrag`) brings the old look-around back; the default is `head`. `driveView` takes the choice as an optional last argument, `drag` (`DriveDrag`, `"head"` or `"orbit"`), and without it works as before. The seat view and driving are unchanged. Tests: unit tests of the view maths (the eyes do not move under any drag in `head`, the rover holds its place in `orbit`, the seat is the same in both) and a browser test of both modes in `e2e/surface.demo.ts`. English and Japanese surface guides and the upgrading page.
18
+ - **The camera can be held to a body or to a pair while time runs: `frame="stars"`, `"body"` or `"pair"`** (John Morris, 2026-11-16; no ticket yet). The camera was fixed to the stars: at Ceres or Mars the ground turned under it, and the Sun went right round Mercury. `frame="body"` (an attribute, and `space.frame`) turns the camera with the body in focus, so its ground stays still under the viewer as it spins (any body; a body with no known rotation, Halley, Nereid, Hiiaka and Namaka, is held to the stars and `stats.frame` says so). `frame="pair"` turns it with the body in focus and a companion (`pair-with`, and `space.pairWith`; with none, the companion the last move arrived with), so the companion stays at the same place in the picture while the two move and the camera circles the body in focus: the Sun stays behind Mercury at the back left. A drag changes the framing and the new framing is kept; a `goTo` or `ride` ends a pair unless the move arrives with a companion, which becomes the pair; the companion never passes behind the body (the camera slides to one side by as little as it takes). No draw of its own: the direction is carried in the draws the running clock already makes, and nothing is drawn at rest. `stats.frame` is `{ asked, frame, pair }`, `wakusei-frame` is sent when the frame held changes, and the pure parts (`FRAMES`, `readFrame`, `bodyBasis`, `hasRotation`, `pairAxis`, `pairBasis`, `carry`, `keepClear`, `directionBetween`, `holdSite`) are in `/space`. GL walks: Mercury paired with the Sun for 30 days at a day a second, the Moon paired with the Earth, Mars turned with for a day at an hour a second (the Sun stayed within 0.0 px of its place (fixed to the stars it left the picture), the Earth within 0.7 px, the point under the camera on Mars moved 0.000 degrees where fixed to the stars it moved 117 in eight hours, and after a drag of the pair the Sun moved 636 px and then stayed within 0.1 px for 20 days); the freeze test runs both frames at a day a second.
19
+ - **The camera moves along one smooth curve, not in an L** (MODULES-1371). A move that turned beside the body left and then went to the destination was two motions with a stop and a corner between them: it turned (backing up and swinging round the body), stood still, and then went in a straight line. Now the way on starts while the turn is still going, so the camera never stops between the two and its path has no corner, and the move is shorter by the time they share (`TravelPlan.blend` is the share of the turn the way on overlaps, from 0 to 1; 0 is the old move). Where the body left and the destination can share the picture the camera backs up a little, until the body left keeps about half of the picture's height, and stands so that the body left is large on one side and the destination small on the other, on whichever side needs less movement; where the destination is not in the picture it is the least shift that brings it in. The overlap and the framing are taken only where they leave no kind of fault more than the plain move had, so every guarantee stands: no empty picture, the body left or the destination always in the picture, the pace limits and the 60 ms planning budget (a plan takes a median of 2 to 3 ms here). Of the 360 walks of six pairs of moons from ten sides, 1 now passes through a stretch of empty picture (15 of 86,760 samples), where 4 did (27 samples) on the same machine before; the plain walks that had a drifting or a lost destination have none. Over 54 moves of nine pairs, the camera stopped between turn and way on in 42 and now in 9.
20
+ - **Bodies near the way are passed, not routed round** (MODULES-1371). `TRAVEL_CLEARANCE` is 0.35 radii above the surface (it was 1): the camera never flies through a planet, a dwarf planet, a small body, the Sun or the Moon, and passes one near the way as close as that. Moves that had to stand clear of the body left by two radii can now stand nearer, and many plain moves between moons got simpler.
21
+ - **The body left stays in the picture** (MODULES-1371). `travelArrival` and `arrivalSide` take `behind`, the place of the body the move comes from, and return `behind: true` when the last view has it in the picture at the back left or right of the destination (above or below in a tall picture), clear of the disc, whatever the lit share: the Sun behind Mercury shows a crescent. The space view passes it, so on every move the body left is on the screen at every moment where the way allows it, and where it cannot the camera slows near the destination, comes round it and ends with the body left behind it. A near-square picture has no room beside the disc, and there the arrival is as before. GL walks of the Sun to each inner planet, the Earth to the Moon, Saturn to Titan and the Moon to Mars read each draw: the Sun was off the screen in 13 of 30 draws going to Mercury, 14 of 26 to Venus, 17 of 31 to the Earth, 41 of 70 to Mars, Saturn in 34 of 51 going to Titan and the Moon in 45 of 89 going to Mars; now the Sun, the Earth and Saturn are on the screen at every draw (49 to 72 draws a move), and the Moon, off the screen in 55 of 206 draws going to Mars, ends behind Mars at its back left. The ten earlier walks keep their 0 empty draws; at pace 2 a move now takes 7.6 to 18 s (before 6.6 to 18).
22
+ - A move asked for while another is going starts from the camera's place at that moment, with no jump (it always did; the unit tests now say so).
23
+ - Tests: `test/travel-smooth.test.ts` (no stop and no corner, the framing, the least shift, passing, the interrupt, the body left in the picture); the baseline test now holds every move to no more faults than the 0.52.0 planner's (the digests are not compared: a Mac and the CI machine disagree on them in the last bits, and the turning moves are new); the ceilings of the plain walks fall to the one that is left.
24
+
5
25
  ## [0.54.0] - 2026-11-14
6
26
 
7
27
  - **A move within one planet's family no longer swings the destination across the picture, and loses it far less** (MODULES-1254, MODULES-1228). Between two moons (Titan to Enceladus, Phobos to Deimos), the straight way in could pass within a little more than the clearance of the planet, so the camera slid sideways over it and the destination swung across the picture, and sometimes out of it. Where that happens the way on is now made as a swing from a stand that clears the planet, the nearest one or one beyond the destination on the side away from the planet; of the ways tried the one with the fewest faults that has none of any kind more than the first way is taken, so every other move is the same, sample for sample, and a view that kept the planet in the picture all through keeps it. Walked from ten sides at three picture shapes and both scales, six pairs of moons (Callisto to Europa, Io to Ganymede, Titan to Enceladus, Oberon to Miranda, Phobos to Deimos, Triton to Proteus; 360 walks of 241 samples): samples where the destination drifted away from its place on the screen went from 605 to 61 to 69, empty pictures from 394 to 28 to 70, and samples where the destination was out of the picture after the turn from 45 to 12 to 15, with the planner's 60 ms budget (the range is over six runs, three of them under load; 54, 27 and 12 with no budget). What is left: Titan to Enceladus (drift on 2 sides of the compressed square, 2 of the compressed tall, where the destination is also lost, 2 of the true square and 1 of the true tall) and Phobos to Deimos (drift on 9 sides of the compressed tall, and an empty picture on 1 of the true tall). The planet is out of the picture more often in plain views, which never promised it.
package/NOTICE.md CHANGED
@@ -146,7 +146,7 @@ A tile is the package's own 2048 picture of the body, enlarged, with the source'
146
146
  | 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 |
147
147
  | 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) |
148
148
  | 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) |
149
- | 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 |
149
+ | 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; the detail of the map fades into that plain tone over 14 cells of 8 pixels at the edge of the data (`fade`), as the 2048 picture's does, so the tiles show no seam there |
150
150
  | 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 |
151
151
  | 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 |
152
152
  | 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 |
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.54.0/docs/images/lineup-desk.png" width="640"></p>
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.56.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.54.0/docs/images/portrait-family.png" width="640"></p>
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.56.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
 
@@ -537,7 +537,7 @@ BODIES.pluto.kind; // "dwarf-planet"
537
537
 
538
538
  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:
539
539
 
540
- > Morris, J. (2026). *Wakusei Planets* (version 0.54.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
540
+ > Morris, J. (2026). *Wakusei Planets* (version 0.56.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
541
541
 
542
542
  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).
543
543
 
@@ -14,6 +14,7 @@ import { type ScaleMode } from "./scale.ts";
14
14
  import type { RideLook } from "./ride.ts";
15
15
  import { type SunRegion } from "./regions.ts";
16
16
  import { type TravelKind } from "./travel.ts";
17
+ import { type FrameKind } from "./hold.ts";
17
18
  import { type Place } from "../places.ts";
18
19
  import { type PlaceLayer } from "../place-marks.ts";
19
20
  import { type EarthPlace, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
@@ -462,6 +463,18 @@ export declare class WakuseiSpace extends HTMLElement {
462
463
  */
463
464
  get helpPlace(): HelpPlace;
464
465
  set helpPlace(value: HelpPlace);
466
+ /**
467
+ * How the camera holds its direction while time runs (the attribute `frame`): `stars` (the default: fixed to the stars, the ground of the body turns under it), `body` (it turns with the body in focus, so
468
+ * the body's ground stays still under the viewer as it spins: Ceres, Mars, a moon), or `pair` (it turns with the body in focus and a companion, `pairWith`, so the companion stays at the same place in the picture,
469
+ * the Sun behind Mercury at the back left, and the camera circles the body in focus as the two move). A drag changes the framing and the new framing is kept, in any frame. `goTo` and `ride` end a pair unless
470
+ * the move arrives with a companion, which becomes the pair. A body with no known rotation is held to the stars in `body`, and `stats.frame` says so. It costs no draw of its own: it is worked out in the draws the running
471
+ * clock already makes.
472
+ */
473
+ get frame(): FrameKind;
474
+ set frame(value: FrameKind);
475
+ /** The body a pair is held with (the attribute `pair-with`): the one set, or, when none is, the companion the last move arrived with; null when there is none. */
476
+ get pairWith(): BodyId | null;
477
+ set pairWith(value: BodyId | string | null);
465
478
  /** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
466
479
  get look(): "realistic" | "painted";
467
480
  set look(value: "realistic" | "painted");
@@ -761,6 +774,12 @@ export declare class WakuseiSpace extends HTMLElement {
761
774
  };
762
775
  /** The body the last arrival kept in the picture beside the one gone to, or null. */
763
776
  companion: string | null;
777
+ /** How the camera is held while time runs, as the last draw held it: the frame asked for, the frame held (`body` for a body with no known rotation, and `pair` with no companion, are held to the `stars`) and the body a pair is held with. */
778
+ frame: {
779
+ asked: FrameKind;
780
+ frame: FrameKind;
781
+ pair: string | null;
782
+ };
764
783
  };
765
784
  /** Where a body is on the screen now: its centre and radius in CSS pixels in the element, or `null` when it is behind the camera or not drawn. */
766
785
  placeOf(id: BodyId): BodyPlace | null;
@@ -19,16 +19,17 @@ import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_MINORS
19
19
  import { moonOffset, orientation } from "../scene/orient.js";
20
20
  import { moonDistance, placeBodies, radiusIn, readMoonSize } from "./scale.js";
21
21
  import { groundDirection } from "./aim.js";
22
- import { besideFace, faceView, facingPoint, subCameraPoint } from "./face.js";
22
+ import { besideFace, faceView, facingPoint } from "./face.js";
23
23
  import { besideMoon } from "./beside.js";
24
24
  import { SUN_REGIONS } from "./regions.js";
25
25
  import { travelArrival } from "./travel.js";
26
+ import { controlsFor, readFrame } from "./hold.js";
26
27
  import { findPlace, PLACE_BODIES } from "../places.js";
27
28
  import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView } from "../place-marks.js";
28
29
  import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
29
30
  import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
30
31
  import { cross, dot, length, sub, unit } from "../vec.js";
31
- import { createSpaceItem, FIT_DISTANCE, framedOf, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
32
+ import { createSpaceItem, FIT_DISTANCE, framedOf, heldAim, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
32
33
  import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
33
34
  export { setPlacesLoader } from "../scene/place-layer.js";
34
35
  export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "../scene/earth-places.js";
@@ -141,7 +142,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
141
142
  * ```
142
143
  */
143
144
  export class WakuseiSpace extends HTMLElement {
144
- static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
145
+ static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
145
146
  #model = newSpaceModel();
146
147
  #allMoons = false;
147
148
  #catalogue;
@@ -222,6 +223,8 @@ export class WakuseiSpace extends HTMLElement {
222
223
  this.#model.help = this.hasAttribute("help") && this.getAttribute("help") !== "off";
223
224
  this.#model.helpThrough = this.hasAttribute("help-through") && this.getAttribute("help-through") !== "off";
224
225
  this.#model.helpPlace = readHelpPlace(this.getAttribute("help-place"));
226
+ this.#model.frame = readFrame(this.getAttribute("frame"));
227
+ this.#model.pairWith = readBody(this.getAttribute("pair-with") ?? "") || null;
225
228
  this.#travel = { kind: readTravel(this.getAttribute("transition"), "turn-travel"), pace: readPace(this.getAttribute("pace"), 1) };
226
229
  this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
227
230
  this.#model.light = readLight(this.getAttribute("light"));
@@ -271,6 +274,7 @@ export class WakuseiSpace extends HTMLElement {
271
274
  this.#placeLabels(places);
272
275
  this.#placeOort();
273
276
  this.#door.announce();
277
+ this.#announceFrame();
274
278
  },
275
279
  onSight: (bodies, frame) => this.#see(bodies, frame),
276
280
  wantSight: () => this.#sightAsked || this.#sightListeners.size > 0,
@@ -391,6 +395,10 @@ export class WakuseiSpace extends HTMLElement {
391
395
  this.helpThrough = value !== null && value !== "off";
392
396
  else if (name === "help-place")
393
397
  this.helpPlace = readHelpPlace(value);
398
+ else if (name === "frame")
399
+ this.frame = readFrame(value);
400
+ else if (name === "pair-with")
401
+ this.pairWith = value;
394
402
  else if (name === "transition")
395
403
  this.transition = readTravel(value, "turn-travel");
396
404
  else if (name === "pace")
@@ -583,7 +591,12 @@ export class WakuseiSpace extends HTMLElement {
583
591
  const away = [camera.position[0] - here[0], camera.position[1] - here[1], camera.position[2] - here[2]];
584
592
  return length(away) < 1e-12 ? null : facingPoint(moon, away, model.time);
585
593
  }
586
- return subCameraPoint(model.focus, model.view, model.centre, model.anchor ?? model.time, model.time);
594
+ // the stars' direction (with what a drag in a held frame added to the controls), carried to now when the frame holds the camera to a body or a pair
595
+ const anchor = model.anchor ?? model.time;
596
+ const bias = model.holdBias !== null && model.holdBias.anchor === model.anchor ? model.holdBias : { yaw: 0, tilt: 0, up: [0, 1, 0] };
597
+ const base = groundDirection(model.centre.lon - model.view.yaw - bias.yaw, Math.max(-90, Math.min(90, model.centre.lat - model.view.tilt - bias.tilt)), anchor);
598
+ const held = model.frame !== "stars" && model.frameDrawn.drawn !== "stars" && model.anchor !== null;
599
+ return facingPoint(model.focus, held ? heldAim(model, model.focus, base, bias.up, model.mode, (id) => this.#site(id).at, 0).aim : base, model.time);
587
600
  }
588
601
  /**
589
602
  * Turn the view round the body in the middle so that a point of its surface (east longitude, north latitude, degrees) is under the camera: a glide the way `goToPlace` goes (at once with `smooth: false`
@@ -1228,6 +1241,35 @@ export class WakuseiSpace extends HTMLElement {
1228
1241
  this.#model.helpPlace = value === "across" ? "across" : "pole";
1229
1242
  this.#gate?.request();
1230
1243
  }
1244
+ /**
1245
+ * How the camera holds its direction while time runs (the attribute `frame`): `stars` (the default: fixed to the stars, the ground of the body turns under it), `body` (it turns with the body in focus, so
1246
+ * the body's ground stays still under the viewer as it spins: Ceres, Mars, a moon), or `pair` (it turns with the body in focus and a companion, `pairWith`, so the companion stays at the same place in the picture,
1247
+ * the Sun behind Mercury at the back left, and the camera circles the body in focus as the two move). A drag changes the framing and the new framing is kept, in any frame. `goTo` and `ride` end a pair unless
1248
+ * the move arrives with a companion, which becomes the pair. A body with no known rotation is held to the stars in `body`, and `stats.frame` says so. It costs no draw of its own: it is worked out in the draws the running
1249
+ * clock already makes.
1250
+ */
1251
+ get frame() {
1252
+ return this.#model.frame;
1253
+ }
1254
+ set frame(value) {
1255
+ const next = readFrame(value);
1256
+ if (next === this.#model.frame)
1257
+ return;
1258
+ // the direction the camera looks from now is kept: the stars' direction is taken from this moment under the frame that held it until now
1259
+ this.#reanchor(0, 0, this.#model.view);
1260
+ this.#model.frame = next;
1261
+ this.#gate?.request();
1262
+ }
1263
+ /** The body a pair is held with (the attribute `pair-with`): the one set, or, when none is, the companion the last move arrived with; null when there is none. */
1264
+ get pairWith() {
1265
+ return this.#model.pairWith ?? (this.#model.companion ?? null);
1266
+ }
1267
+ set pairWith(value) {
1268
+ const id = typeof value === "string" ? readBody(value) : null;
1269
+ this.#reanchor(0, 0, this.#model.view);
1270
+ this.#model.pairWith = id || null;
1271
+ this.#gate?.request();
1272
+ }
1231
1273
  /** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
1232
1274
  get look() {
1233
1275
  return this.#model.look === "painted" ? "painted" : "realistic";
@@ -1283,6 +1325,10 @@ export class WakuseiSpace extends HTMLElement {
1283
1325
  return;
1284
1326
  }
1285
1327
  }
1328
+ // a drag in a held frame (`body`, `pair`) turns the camera from the direction it is looking from now, and the new framing is kept as the frame goes on: the stars' direction is taken from now
1329
+ if (!this.#siding && this.#model.frame !== "stars" && this.#model.frameDrawn.drawn !== "stars" && this.#model.ride === null && this.#model.anchor !== null && this.#model.anchor !== this.#model.time && (view.yaw !== now.yaw || view.tilt !== now.tilt) && reason !== "set" && reason !== "jump") {
1330
+ this.#reanchor(view.yaw - now.yaw, view.tilt - now.tilt, view);
1331
+ }
1286
1332
  this.#model.view = { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY };
1287
1333
  this.dispatchEvent(new CustomEvent("wakusei-view", { detail: { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY } }));
1288
1334
  const drawn = this.#model.drawnView;
@@ -1352,7 +1398,13 @@ export class WakuseiSpace extends HTMLElement {
1352
1398
  // a straight move (`direct`, `look-back`) keeps its destination in the picture all the way, and is not turned to a companion's side: that could take the destination out of the picture. A turning move may be, and its plan
1353
1399
  // works round the planet in a way that never leaves the picture empty (`travelPlan`).
1354
1400
  const swing = kind === "cut" || kind === "turn-travel";
1401
+ // in a held frame the side the camera arrives from is chosen for this moment: the stars' direction is taken from now
1402
+ if (model.frame !== "stars") {
1403
+ model.anchor = model.time;
1404
+ model.holdBias = null;
1405
+ }
1355
1406
  const side = this.#faceApproach(id, swing);
1407
+ this.#endPair();
1356
1408
  if (!this.hasAttribute("data-kazoku-bar"))
1357
1409
  this.#hands?.controller.set(side ? { ...side, zoom } : { zoom }, true, "jump");
1358
1410
  this.#schedule();
@@ -1434,6 +1486,11 @@ export class WakuseiSpace extends HTMLElement {
1434
1486
  }
1435
1487
  /** The body the camera is at now: the target of the ride, or the body looked at. */
1436
1488
  #leaving() {
1489
+ // a move that has been asked for and not yet drawn has not moved the camera: the body it leaves is still the one the camera is at, not the one the move was going to (a page that leaves a ride and then rides
1490
+ // on, in the same breath, would otherwise leave the planet from beside its moon and back out to the whole system to do it)
1491
+ const pending = this.#model.transition;
1492
+ if (pending !== null && pending.input === null && pending.leaving !== null)
1493
+ return pending.leaving;
1437
1494
  const ride = this.#model.ride;
1438
1495
  if (ride !== null)
1439
1496
  return typeof ride.target === "string" ? ride.target : ride.around;
@@ -1487,6 +1544,50 @@ export class WakuseiSpace extends HTMLElement {
1487
1544
  const centre = pos[host];
1488
1545
  return { at: [centre[0] + real[0] * k, centre[1] + real[1] * k, centre[2] + real[2] * k], radius: Math.max(1e-6, (BODIES[id].radiusKm / BODIES[host].radiusKm) * radiusIn(host, mode) * moonScaleFor(mode, host, this.#model.moonSize, this.#model.time).factor) };
1489
1546
  }
1547
+ #frameTold = "stars||";
1548
+ /** Tell the page when the frame the camera is held in changes (`wakusei-frame`): after a draw, which has worked out what was held. */
1549
+ #announceFrame() {
1550
+ const drawn = this.#model.frameDrawn;
1551
+ const key = `${drawn.drawn}|${drawn.pair ?? ""}|`;
1552
+ if (key === this.#frameTold)
1553
+ return;
1554
+ const previous = this.#frameTold.split("|")[0];
1555
+ this.#frameTold = key;
1556
+ this.dispatchEvent(new CustomEvent("wakusei-frame", { detail: { frame: drawn.drawn, asked: drawn.asked, pair: drawn.pair, previous } }));
1557
+ }
1558
+ /**
1559
+ * The direction the held frame has the camera looking from now, turned by a drag (`dyaw`, `dtilt`), and the stars' direction taken from now on: the drag moves the picture as it does in the stars' frame, and the framing
1560
+ * it leaves is the one the frame then keeps. The controls are left as they are; what the stars' direction needs more than their yaw and tilt is kept as a bias (`holdBias`) that holds while the anchor is this moment.
1561
+ */
1562
+ #reanchor(dyaw, dtilt, view) {
1563
+ const model = this.#model;
1564
+ if (model.anchor === null)
1565
+ return;
1566
+ const was = model.holdBias !== null && model.holdBias.anchor === model.anchor ? model.holdBias : { yaw: 0, tilt: 0, up: [0, 1, 0] };
1567
+ const before = { yaw: view.yaw - dyaw + was.yaw, tilt: view.tilt - dtilt + was.tilt };
1568
+ const base = groundDirection(model.centre.lon - before.yaw, Math.max(-90, Math.min(90, model.centre.lat - before.tilt)), model.anchor);
1569
+ const held = heldAim(model, model.focus, base, was.up, model.mode, (id) => this.#site(id).at, 0);
1570
+ const aim = held.aim;
1571
+ // the stars' direction, taken from now, that looks from here once the drag has turned it
1572
+ const turned = controlsFor(aim, model.centre, model.time);
1573
+ const yaw = turned.yaw + dyaw;
1574
+ const tilt = turned.tilt + dtilt;
1575
+ model.anchor = model.time;
1576
+ model.holdBias = { anchor: model.time, yaw: yaw - view.yaw, tilt: tilt - view.tilt, up: held.up };
1577
+ }
1578
+ /** A move ends a pair unless it arrives with a companion, which becomes the pair. */
1579
+ #endPair() {
1580
+ const model = this.#model;
1581
+ if (model.frame !== "pair")
1582
+ return;
1583
+ if (model.companion !== null) {
1584
+ model.pairWith = model.companion;
1585
+ return;
1586
+ }
1587
+ model.frame = "stars";
1588
+ model.pairWith = null;
1589
+ this.#gate?.request();
1590
+ }
1490
1591
  #siding = false;
1491
1592
  /** The body the camera was at when the latest arrival was chosen, so that body can stay in the picture. */
1492
1593
  #arrivedFrom = null;
@@ -1538,8 +1639,11 @@ export class WakuseiSpace extends HTMLElement {
1538
1639
  const body = this.#site(id);
1539
1640
  const sun = id === "sun" ? undefined : this.#site("sun").at;
1540
1641
  const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 16 / 9;
1541
- const wanted = travelArrival({ body: body.at, radius: body.radius, from: model.camera.position, sun, aspect, companions: swing ? this.#companions(id) : [] });
1542
- model.companion = wanted.companion;
1642
+ // the body left is kept in the picture, behind the body gone to at its back left or right (`travelArrival`'s `behind`), whatever it does to the lit side
1643
+ const behind = swing && this.#arrivedFrom !== null && this.#arrivedFrom !== id ? this.#site(this.#arrivedFrom).at : undefined;
1644
+ const wanted = travelArrival({ body: body.at, radius: body.radius, from: model.camera.position, sun, aspect, companions: swing ? this.#companions(id) : [], ...(behind === undefined ? {} : { behind }) });
1645
+ // the body left, kept in the picture behind the body gone to, is the companion of that arrival
1646
+ model.companion = wanted.behind ? (wanted.companion ?? this.#arrivedFrom) : wanted.companion;
1543
1647
  const side = [wanted.position[0] - body.at[0], wanted.position[1] - body.at[1], wanted.position[2] - body.at[2]];
1544
1648
  const anchor = model.anchor ?? model.time;
1545
1649
  // the scene aims from the ground direction of (lon - yaw, lat - tilt) at the anchor moment: search the pair that lies along the wanted side, coarse then fine
@@ -1570,6 +1674,8 @@ export class WakuseiSpace extends HTMLElement {
1570
1674
  if (model.ride !== null)
1571
1675
  this.ride(null, { smooth: false });
1572
1676
  model.transition = this.#startMove(kind, model.region !== null ? "sun" : leaving, "sun", options.duration);
1677
+ model.companion = null;
1678
+ this.#endPair();
1573
1679
  model.region = region;
1574
1680
  this.#selected = "sun";
1575
1681
  model.focus = "sun";
@@ -1715,6 +1821,9 @@ export class WakuseiSpace extends HTMLElement {
1715
1821
  if (!wasRiding)
1716
1822
  this.#focusBeforeRide = model.focus;
1717
1823
  model.ride = found;
1824
+ // a ride arrives with no companion: it ends a pair
1825
+ model.companion = null;
1826
+ this.#endPair();
1718
1827
  if (found.view === "follow" && typeof target === "string" && SPACE_BODIES.includes(target))
1719
1828
  model.focus = target;
1720
1829
  else if (wasRiding)
@@ -1974,6 +2083,7 @@ export class WakuseiSpace extends HTMLElement {
1974
2083
  roadster: { shown: this.#model.roadsterDrawn.shown, position: this.#model.roadsterDrawn.position === null ? null : [...this.#model.roadsterDrawn.position], radiusPx: this.#model.roadsterDrawn.radiusPx },
1975
2084
  spacecraft: { count: this.#model.craftDrawn.count, status: { ...this.#model.craftDrawn.status }, drawn: [...this.#model.craftDrawn.drawn] },
1976
2085
  companion: this.#model.companion,
2086
+ frame: { asked: this.#model.frameDrawn.asked, frame: this.#model.frameDrawn.drawn, pair: this.#model.frameDrawn.pair },
1977
2087
  moonSize: { asked: this.#model.moonSize, factor: this.#model.moonDrawn.factor, clamped: this.#model.moonDrawn.clamped },
1978
2088
  pictures: { pending: picturesPending() },
1979
2089
  };
@@ -0,0 +1,217 @@
1
+ import { type BodyId } from "../facts.ts";
2
+ import { type Vec3 } from "../vec.ts";
3
+ import { type ScaleMode } from "./scale.ts";
4
+ /**
5
+ * How the camera holds its direction while time runs: `stars` (fixed to the stars, today's way and the default), `body` (turning with the body in focus, so its ground stays still under the viewer as it spins) and `pair`
6
+ * (turning with the body in focus and a companion, so the companion stays at the same place in the picture).
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { FrameKind } from "@johnmorrisdotca/wakusei-planets/space";
11
+ *
12
+ * const frame: FrameKind = "pair";
13
+ * console.log(frame);
14
+ * ```
15
+ */
16
+ export type FrameKind = "stars" | "body" | "pair";
17
+ /**
18
+ * The frames, in the order a control lists them.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { FRAMES } from "@johnmorrisdotca/wakusei-planets/space";
23
+ *
24
+ * console.log(FRAMES.join(", "));
25
+ * ```
26
+ */
27
+ export declare const FRAMES: readonly FrameKind[];
28
+ /**
29
+ * A frame from what a page wrote (an attribute or a property): `body` and `pair` as written, anything else `stars`.
30
+ *
31
+ * @param value - What was written.
32
+ * @returns The frame.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * import { readFrame } from "@johnmorrisdotca/wakusei-planets/space";
37
+ *
38
+ * console.log(readFrame("pair"), readFrame("nonsense"));
39
+ * ```
40
+ */
41
+ export declare function readFrame(value: unknown): FrameKind;
42
+ /**
43
+ * Three unit vectors square to one another, right-handed (`a` cross `b` is `c`): the axes a direction is carried by.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import type { HoldBasis } from "@johnmorrisdotca/wakusei-planets/space";
48
+ *
49
+ * const basis: HoldBasis = { a: [1, 0, 0], b: [0, 1, 0], c: [0, 0, 1] };
50
+ * console.log(basis.c);
51
+ * ```
52
+ */
53
+ export interface HoldBasis {
54
+ a: Vec3;
55
+ b: Vec3;
56
+ c: Vec3;
57
+ }
58
+ /**
59
+ * Whether a body has a rotation the package knows: a moon that keeps one face to its planet, or a body whose prime meridian turns. A body without one cannot be turned with.
60
+ *
61
+ * @param id - A body's name.
62
+ * @returns True when the body's ground turns in a way the package can work out.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { hasRotation } from "@johnmorrisdotca/wakusei-planets/space";
67
+ *
68
+ * console.log(hasRotation("mars"));
69
+ * ```
70
+ */
71
+ export declare function hasRotation(id: BodyId): boolean;
72
+ /**
73
+ * The basis that turns with a body's ground at a moment: its prime meridian, its east and its north pole, in the scene's axes. Null for a body with no known rotation.
74
+ *
75
+ * @param id - A body's name.
76
+ * @param ms - The moment, in milliseconds since the Unix epoch.
77
+ * @returns The basis, or null.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { bodyBasis } from "@johnmorrisdotca/wakusei-planets/space";
82
+ *
83
+ * const basis = bodyBasis("mars", Date.UTC(2026, 10, 2));
84
+ * console.log(basis !== null);
85
+ * ```
86
+ */
87
+ export declare function bodyBasis(id: BodyId, ms: number): HoldBasis | null;
88
+ /**
89
+ * The basis that turns with a pair: `a` towards the companion, `c` the axis (the part of `axis` square to `a`, so `axis` need not be), and `b` completing it. As the companion goes round the body in focus the basis
90
+ * turns about the axis by the same angle, and never jumps while `toward` is not along `axis`, which the axis of the pair's own orbit (`pairAxis`) never is.
91
+ *
92
+ * @param toward - The direction from the body in focus to the companion.
93
+ * @param axis - A direction the pair turns about.
94
+ * @returns The basis.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { pairBasis } from "@johnmorrisdotca/wakusei-planets/space";
99
+ *
100
+ * const basis = pairBasis([1, 0, 0], [0, 1, 0]);
101
+ * console.log(basis.b);
102
+ * ```
103
+ */
104
+ export declare function pairBasis(toward: Vec3, axis: Vec3): HoldBasis;
105
+ /**
106
+ * The axis a pair turns about: the direction of the angular momentum of the companion's motion about the body in focus at a moment, from where `toward` puts the companion half an hour either side. It is the same axis
107
+ * all the way round an orbit (a moon of Uranus, which goes round over the poles, gets its own), so a basis made with it turns about it and never jumps.
108
+ *
109
+ * @param toward - The direction from the body in focus to the companion at a moment.
110
+ * @param ms - The moment the axis is taken at.
111
+ * @returns A unit vector.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { pairAxis } from "@johnmorrisdotca/wakusei-planets/space";
116
+ *
117
+ * const axis = pairAxis((ms) => [Math.cos(ms / 1e8), 0, Math.sin(ms / 1e8)], 0);
118
+ * console.log(axis.map((n) => n.toFixed(2)).join(", "));
119
+ * ```
120
+ */
121
+ export declare function pairAxis(toward: (ms: number) => Vec3, ms: number): Vec3;
122
+ /**
123
+ * A direction carried from one basis to another: the vector that has in `to` the three numbers `aim` has in `from`.
124
+ *
125
+ * @param aim - The direction, from the body in focus to the camera.
126
+ * @param from - The basis it was framed in.
127
+ * @param to - The basis at the later moment.
128
+ * @returns The direction at the later moment.
129
+ *
130
+ * @example
131
+ * ```ts
132
+ * import { carry } from "@johnmorrisdotca/wakusei-planets/space";
133
+ *
134
+ * const turned = carry([1, 0, 0], { a: [1, 0, 0], b: [0, 1, 0], c: [0, 0, 1] }, { a: [0, 1, 0], b: [-1, 0, 0], c: [0, 0, 1] });
135
+ * console.log(turned.map((n) => n.toFixed(2)).join(", "));
136
+ * ```
137
+ */
138
+ export declare function carry(aim: Vec3, from: HoldBasis, to: HoldBasis): Vec3;
139
+ /**
140
+ * A direction pushed away from the line to a companion as far as it takes to keep the companion out of sight behind the body in focus, and no further: the camera on the far side of the body from the companion, looking at
141
+ * the body, has the companion directly behind it. Where `aim` is within `least` radians of the direction away from the companion it is moved to that distance, along the way from the companion's far side that it leans
142
+ * to, so the change is continuous (the companion passing behind the body slides the camera to one side and never makes it jump).
143
+ *
144
+ * @param aim - The direction from the body in focus to the camera.
145
+ * @param toward - The direction from the body in focus to the companion.
146
+ * @param least - How far from straight behind it the camera may be, in radians.
147
+ * @returns The direction, `aim` itself when it is already clear.
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * import { keepClear } from "@johnmorrisdotca/wakusei-planets/space";
152
+ *
153
+ * console.log(keepClear([-1, 0, 0], [1, 0, 0], 0.3).map((n) => n.toFixed(2)).join(", "));
154
+ * ```
155
+ */
156
+ export declare function keepClear(aim: Vec3, toward: Vec3, least: number): Vec3;
157
+ /**
158
+ * Where a body is at a moment, in the scene's places for a scale (Earth radii from the Earth's centre) and its drawn radius. A moon is at its planet's place and offset by its orbit at the scale's distance.
159
+ *
160
+ * @param id - A body's name.
161
+ * @param mode - The scale.
162
+ * @param ms - The moment.
163
+ * @returns The place.
164
+ *
165
+ * @example
166
+ * ```ts
167
+ * import { holdSite } from "@johnmorrisdotca/wakusei-planets/space";
168
+ *
169
+ * console.log(holdSite("sun", "compressed", Date.UTC(2026, 10, 2)).radius > 0);
170
+ * ```
171
+ */
172
+ export declare function holdSite(id: BodyId, mode: ScaleMode, ms: number): {
173
+ at: Vec3;
174
+ radius: number;
175
+ };
176
+ /**
177
+ * The unit direction from one body to another at a moment, in the scene's places for a scale.
178
+ *
179
+ * @param from - The body in focus.
180
+ * @param to - The companion.
181
+ * @param mode - The scale.
182
+ * @param ms - The moment.
183
+ * @returns A unit vector.
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * import { directionBetween } from "@johnmorrisdotca/wakusei-planets/space";
188
+ *
189
+ * console.log(directionBetween("mercury", "sun", "compressed", Date.UTC(2026, 10, 2)).length);
190
+ * ```
191
+ */
192
+ export declare function directionBetween(from: BodyId, to: BodyId, mode: ScaleMode, ms: number): Vec3;
193
+ /**
194
+ * The controls' yaw and tilt, in degrees, that make the stars' direction (`groundDirection`) at a moment the given direction, for a view whose centre is a longitude and latitude: the inverse of how the view turns yaw and tilt
195
+ * into a direction. A frame that carries the direction uses it to take the stars' direction again from now, with the direction it has now.
196
+ *
197
+ * @param aim - The direction, from the body in focus to the camera.
198
+ * @param centre - The view's centre, east longitude and north latitude in degrees.
199
+ * @param ms - The moment the stars' direction is taken at.
200
+ * @returns The yaw and the tilt.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * import { controlsFor, groundDirection } from "@johnmorrisdotca/wakusei-planets/space";
205
+ *
206
+ * const now = Date.UTC(2026, 10, 2);
207
+ * const { yaw, tilt } = controlsFor(groundDirection(20 - 30, 10 - 5, now), { lon: 20, lat: 10 }, now);
208
+ * console.log(yaw.toFixed(1), tilt.toFixed(1));
209
+ * ```
210
+ */
211
+ export declare function controlsFor(aim: Vec3, centre: {
212
+ lon: number;
213
+ lat: number;
214
+ }, ms: number): {
215
+ yaw: number;
216
+ tilt: number;
217
+ };