@johnmorrisdotca/wakusei-planets 0.47.0 → 0.49.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,14 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.49.0] - 2026-11-13
6
+
7
+ - **Drive the Apollo 17 rover** (MODULES-1331). `drive="on"` on `<wakusei-surface>` puts the eyes behind the rover at its published place and lets you drive it: W and S (or the arrows, or the walking stick) for the throttle, A and D for the steering, C between the chase view and the commander's seat, a drag to turn the view round it. A pure drive step (`driveStep`) reads the four places the wheels touch on the same ground the eyes walk on, the measured heights and the made craters, so the rover tilts and settles on a spring and, where the ground falls away, is in free fall at the Moon's gravity; the speed follows the throttle to about 12 km/h, is slowed uphill, stops at 25 degrees and at big rocks and the things at the site, and a brake holds it still once it has nearly stopped. The wheels throw fine grey grains up and back in a fan, in parabolas at 1.62 m/s2 (made, not measured), and leave tracks like the published traverse. One draw per step while moving and nothing at rest; `driveFor(seconds, input)` drives by a set time, `vehicle` and `driveCamera` are its state and view. The rover's drawing is corrected to the published sizes (about 3.05 m by 2.13 m, wheels 0.81 m, wheelbase 2.29 m), the lunar module and the rover read as themselves (gold body, ladder and porch, fenders, seats, masts), and the dish stands on a taller mast so the seat view sees under it.
8
+
9
+ ## [0.48.0] - 2026-11-13
10
+
11
+ - **Which face of the body the view looks at** (MODULES-1330). `<wakusei-space>` has `subCameraPoint()`, the longitude (east) and latitude (north), in the centred body's own fixed frame at the moment shown, of the point under the camera (`null` while riding along), and `faceTo({ lon, lat }, { smooth })`, which turns the view round the body to bring a point there (the glide of `goToPlace`); `stats.camera.sub` says the same point as of the last draw. Beside a moon (`ride(moon, { view: "beside" })`, the way a moon is visited) `subCameraPoint()` is the point under the line from the moon's centre to the camera, and `faceTo` stands the camera as near that side as the view allows. `<wakusei-body>` has the same pair for its picture (the date's or the portrait's pose, the view's turn, tilt and roll counted in). The pure functions `subCameraPoint` and `faceView` are exported from `/space`, with `besideFace`, `facingPoint` and `surfaceDirection`. For a card picture that follows the main view, and the reverse. Guide: `docs/guides/which-face.md` and its Japanese twin.
12
+
5
13
  ## [0.47.0] - 2026-11-13
6
14
 
7
15
  - **Things at the Apollo 17 site, at their published places** (MODULES-1308). The descent stage of the lunar module, the flag, the ALSEP central station, the surface electrical properties transmitter and the rover stand at the coordinates of Haase et al. (2019, doi 10.1029/2018EA000408; two small files read by byte range from the PDS archive of its map, NOTICE.md), drawn by this package as plain shapes with flat colours (an octagonal gold body on four splayed legs with braces, pads and the ladder; a frame on four wheels with fenders, seats, console, dish and camera masts) and cast shadows, and the rover's nine traverses as a faint pair of tracks along the published line. Each has a small pressable button (`choose(id)`, `objects`, the `wakusei-surface-object` event, `objects="off"`) that goes to it and says it was placed by this package; the rover's place is the end of its last traverse line and its heading a reading of it, both labelled ours. The made craters and rocks keep away from them.
package/NOTICE.md CHANGED
@@ -269,7 +269,7 @@ The height tiles of `<wakusei-surface>` (`scripts/make-moon-terrain.py`; they ar
269
269
  - **The ground picture**: the browse picture of `NAC_ROI_APOLLO17LOC_E205N0306_5M`, the Apollo 17 low-Sun controlled narrow angle camera mosaic, 5 m a pixel (https://pds.lroc.im-ldi.com/data/LRO-L-LROC-5-RDR-V1.0/LROLRC_2001/EXTRAS/BROWSE/NAC_ROI/APOLLO17LOC/NAC_ROI_APOLLO17LOC_E205N0306_5M.TIF, 108,949,491 bytes). The build fits the Sun the mosaic was lit by to the heights, divides that shading out and keeps the ground's own light and dark (the fit for Apollo 17: azimuth 264 degrees, elevation 7 degrees, correlation 0.76).
270
270
  - **Heights beyond the model**: the Lunar Orbiter Laser Altimeter (LOLA) global height map at 64 pixels a degree (`ldem_64.img`, data set `LRO-L-LOLA-4-GDR-V1.0`, https://pds-geosciences.wustl.edu/lro/lro-l-lola-3-rdr-v1/lrolol_1xxx/data/lola_gdr/cylindrical/img/ldem_64.img, 23,040 x 11,520 samples of 16 bits, height = 0.5 m x value above a sphere of radius 1,737.4 km), of which only the window round the site is read, by HTTP byte ranges (about 25 MB of a 531 MB file).
271
271
  - **Terms**: the PDS Geosciences Node's FAQ (https://pds-geosciences.wustl.edu/faq.html, read 2026-11-13): "Data sets archived in the PDS are in the public domain." The LROC terms of use (https://lroc.im-ldi.com/about/terms, read 2026-11-13) say the products of the LROC data node and the PDS archive are in the public domain, that images elsewhere on the LROC website (featured images and curated products) are copyrighted and are not used here, and ask for the credit "NASA/GSFC/Arizona State University". The credit lines the page shows are that, and "LOLA Team (NASA/GSFC)", with the Planetary Data System as the publisher of the data sets (the PDS asks that a data set be cited like published research; its DOI is in the PDS DOI portal).
272
- - **Things at the Apollo 17 site** (`src/surface/objects-apollo-17.ts`, made by `scripts/make-apollo17-objects.py`, read on 2026-11-13): the positions of the lunar module's descent stage, the flag, the ALSEP central station and the surface electrical properties transmitter, and the rover's nine traverses, from the map of Haase, Wählisch, Gläser, Oberst and Robinson, "Coordinates and Maps of the Apollo 17 Landing Site", Earth and Space Science 6 (2019), https://doi.org/10.1029/2018EA000408, as archived by the PDS Cartography and Imaging Sciences Node and published by USGS Astrogeology (https://astrogeology.usgs.gov/search/map/moon_apollo_17_lroc_nac_landing_site_orthomosaic_50cm, whose use constraint reads "Please cite authors"). Two files are read out of its 1.7 GB zip by HTTP byte ranges (about 94 KB fetched; the zip is never downloaded): `APOLLO17_CONTROLPOINTS_2018.TAB` (body-fixed X, Y, Z in metres, the published positions) and `APOLLO17_TRAVERSE_2018.SHP` (the traverses, Transverse Mercator on a sphere of 1,737.4 km, central meridian 30.7 degrees). They are coordinates, which are facts; no picture, text or map of the paper is used. The rover's place and heading are this package's reading of the end of the last traverse line: the paper's own table of the rover's parking place was not available to this build (the publisher's page refused programs), so the rover's place is not that published position and the page says so. The shapes of all five things are plain drawings made here (boxes, cylinders and struts, from sizes of about 3.2 m for the descent stage's deck, 4.7 m from its middle to a footpad, and 3.1 m by 2.3 m for the rover); no flag, name or mark is drawn. uchusen-rockets has a lunar module (its descent and ascent stages, plain shapes) that this package does not use; no lunar rover model was found in it.
272
+ - **Things at the Apollo 17 site** (`src/surface/objects-apollo-17.ts`, made by `scripts/make-apollo17-objects.py`, read on 2026-11-13): the positions of the lunar module's descent stage, the flag, the ALSEP central station and the surface electrical properties transmitter, and the rover's nine traverses, from the map of Haase, Wählisch, Gläser, Oberst and Robinson, "Coordinates and Maps of the Apollo 17 Landing Site", Earth and Space Science 6 (2019), https://doi.org/10.1029/2018EA000408, as archived by the PDS Cartography and Imaging Sciences Node and published by USGS Astrogeology (https://astrogeology.usgs.gov/search/map/moon_apollo_17_lroc_nac_landing_site_orthomosaic_50cm, whose use constraint reads "Please cite authors"). Two files are read out of its 1.7 GB zip by HTTP byte ranges (about 94 KB fetched; the zip is never downloaded): `APOLLO17_CONTROLPOINTS_2018.TAB` (body-fixed X, Y, Z in metres, the published positions) and `APOLLO17_TRAVERSE_2018.SHP` (the traverses, Transverse Mercator on a sphere of 1,737.4 km, central meridian 30.7 degrees). They are coordinates, which are facts; no picture, text or map of the paper is used. The rover's place and heading are this package's reading of the end of the last traverse line: the paper's own table of the rover's parking place was not available to this build (the publisher's page refused programs), so the rover's place is not that published position and the page says so. The shapes of all five things are plain drawings made here (boxes, cylinders and struts, from sizes of about 3.2 m for the descent stage's deck, 4.7 m from its middle to a footpad, and about 3.05 m by 2.13 m for the rover, its wheels 0.81 m across, its wheelbase 2.29 m, its design speed about 13 km/h: read on 2026-11-13 from secondary tables, for example https://space-robotics.org/robots/lunar/apollo-lrv/, and to be checked against NASA's Lunar Roving Vehicle Operations Handbook); no flag, name or mark is drawn. uchusen-rockets has a lunar module (its descent and ascent stages, plain shapes) that this package does not use; no lunar rover model was found in it.
273
273
  - **Left out**: the merged LOLA and Kaguya (SELENE) height grid. The JAXA part's terms could not be found, and an MIT-licensed package can pass on only what it knows to be free to pass on.
274
274
  - **Made, not measured**: everything below the 5 m grid (small craters from 0.5 to 20 m, the roughness of the dust, rocks of 0.1 to 1.5 m) is made by this package from a seeded random grid, by the lunar size-frequency law, and is not a picture or a measurement of any place. The picture says so under the ground.
275
275
 
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.47.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.49.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.47.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.49.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
 
@@ -494,6 +494,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
494
494
  | [Starman and the Tesla Roadster](docs/guides/roadster.md) | where the car launched on the first Falcon Heavy is on any date from 2018 to the start of 2036, its distances, speeds, orbit and key moments |
495
495
  | [Comets](docs/guides/comets.md) | 34 well-known comets with orbits from JPL: where each is on any date, its distances, orbit line, last and next perihelion, meteor showers, and a door to add a new comet |
496
496
  | [Places on the Moon, Mars and 31 more bodies](docs/guides/places.md) | every landing, rover, crash, impact and atmospheric-entry site and the named features of 33 bodies, with positions, dates and sources, the famous ones marked, and the Sun's point, the terminator and the local solar time on any body |
497
+ | [Which face of a body the view looks at](docs/guides/which-face.md) | `subCameraPoint()` and `faceTo()` on the space view and on a body's picture: the longitude and latitude under the camera, and a turn to a point, for a card picture that follows the view |
497
498
  | [Data files](docs/guides/data-files.md) | CSV and Parquet tables of the bodies, orbits and spacecraft, for Python, R and Rust |
498
499
  | [Serve it yourself](docs/guides/serve-it-yourself.md) | A small Node server over the package, that you host |
499
500
  | [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
@@ -535,7 +536,7 @@ BODIES.pluto.kind; // "dwarf-planet"
535
536
 
536
537
  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:
537
538
 
538
- > Morris, J. (2026). *Wakusei Planets* (version 0.47.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
539
+ > Morris, J. (2026). *Wakusei Planets* (version 0.49.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
539
540
 
540
541
  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).
541
542
 
package/dist/element.d.ts CHANGED
@@ -109,6 +109,44 @@ export declare class WakuseiBody extends HTMLElement {
109
109
  x: number;
110
110
  y: number;
111
111
  }[];
112
+ /**
113
+ * Which point of the body is in the middle of the picture, as a longitude (east) and latitude (north) in the body's own fixed frame: what the camera looks straight down on, with the view's turn, tilt
114
+ * and roll and the pose of the date (or the portrait) counted in. `faceTo` is the other way round. `undefined` for a star.
115
+ *
116
+ * @returns The point, or `undefined`.
117
+ *
118
+ * @example
119
+ * ```ts no-run
120
+ * import type { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
121
+ *
122
+ * const body = document.querySelector<WakuseiBody>("wakusei-body")!;
123
+ * console.log(body.subCameraPoint());
124
+ * ```
125
+ */
126
+ subCameraPoint(): {
127
+ lon: number;
128
+ lat: number;
129
+ } | undefined;
130
+ /**
131
+ * Turn the body so a point of it (east longitude, north latitude, degrees) is in the middle of the disc: the turn `goToPlace` makes, for a point instead of a named place (at once for a still, for a reader who
132
+ * prefers reduced motion, or with `smooth: false`); the zoom stays.
133
+ *
134
+ * @param point - The longitude and latitude to bring to the middle.
135
+ * @param options - `smooth` (true by default).
136
+ *
137
+ * @example
138
+ * ```ts no-run
139
+ * import type { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
140
+ *
141
+ * document.querySelector<WakuseiBody>("wakusei-body")!.faceTo({ lon: 139.7, lat: 35.7 }, { smooth: false });
142
+ * ```
143
+ */
144
+ faceTo(point: {
145
+ lon: number;
146
+ lat: number;
147
+ }, options?: {
148
+ smooth?: boolean;
149
+ }): void;
112
150
  /**
113
151
  * Turn the body so a place is in the middle of the disc, at a pace you can follow while the picture is live (at once for a still, for a reader who prefers reduced motion, or with `smooth: false`); the zoom stays. The place is an id (`moon/apollo-11-lunar-module`),
114
152
  * or an English or Japanese name. A body that turns by itself carries the place on from there (`turn="0"` keeps it). Resolves the place, or `undefined` when the body has no place by that name.
package/dist/element.js CHANGED
@@ -21,7 +21,7 @@ import { createBodyItem } from "./scene/body.js";
21
21
  import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } from "./scene/name-label.js";
22
22
  import { delegates, onRegister } from "./scene/store.js";
23
23
  import { setThreeLoader, takeRenderer } from "./scene/shared.js";
24
- import { turn as turnVec } from "./vec.js";
24
+ import { cross, RAD, turn as turnVec } from "./vec.js";
25
25
  import { findPlace, PLACE_BODIES } from "./places.js";
26
26
  import { marksToShow, readPlaceLayers, readSurfaceNames, turnToPlace } from "./place-marks.js";
27
27
  import { createPlaceLayer, onPlacesLoader, placesLoader } from "./scene/place-layer.js";
@@ -291,6 +291,46 @@ export class WakuseiBody extends HTMLElement {
291
291
  get placesShown() {
292
292
  return this.#placeLayer?.shown ?? [];
293
293
  }
294
+ /**
295
+ * Which point of the body is in the middle of the picture, as a longitude (east) and latitude (north) in the body's own fixed frame: what the camera looks straight down on, with the view's turn, tilt
296
+ * and roll and the pose of the date (or the portrait) counted in. `faceTo` is the other way round. `undefined` for a star.
297
+ *
298
+ * @returns The point, or `undefined`.
299
+ *
300
+ * @example
301
+ * ```ts no-run
302
+ * import type { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
303
+ *
304
+ * const body = document.querySelector<WakuseiBody>("wakusei-body")!;
305
+ * console.log(body.subCameraPoint());
306
+ * ```
307
+ */
308
+ subCameraPoint() {
309
+ if (this.hasAttribute("star"))
310
+ return undefined;
311
+ const { pose } = this.#sceneOf(this.#frameNow());
312
+ const east = cross(pose.pole, pose.meridian);
313
+ return { lon: Math.atan2(east[2], pose.meridian[2]) / RAD, lat: Math.asin(Math.max(-1, Math.min(1, pose.pole[2]))) / RAD };
314
+ }
315
+ /**
316
+ * Turn the body so a point of it (east longitude, north latitude, degrees) is in the middle of the disc: the turn `goToPlace` makes, for a point instead of a named place (at once for a still, for a reader who
317
+ * prefers reduced motion, or with `smooth: false`); the zoom stays.
318
+ *
319
+ * @param point - The longitude and latitude to bring to the middle.
320
+ * @param options - `smooth` (true by default).
321
+ *
322
+ * @example
323
+ * ```ts no-run
324
+ * import type { WakuseiBody } from "@johnmorrisdotca/wakusei-planets/element";
325
+ *
326
+ * document.querySelector<WakuseiBody>("wakusei-body")!.faceTo({ lon: 139.7, lat: 35.7 }, { smooth: false });
327
+ * ```
328
+ */
329
+ faceTo(point, options = {}) {
330
+ if (this.hasAttribute("star") || !Number.isFinite(point.lon) || !Number.isFinite(point.lat))
331
+ return;
332
+ this.#turnTo(point.lat, point.lon, options.smooth);
333
+ }
294
334
  /**
295
335
  * Turn the body so a place is in the middle of the disc, at a pace you can follow while the picture is live (at once for a still, for a reader who prefers reduced motion, or with `smooth: false`); the zoom stays. The place is an id (`moon/apollo-11-lunar-module`),
296
336
  * or an English or Japanese name. A body that turns by itself carries the place on from there (`turn="0"` keeps it). Resolves the place, or `undefined` when the body has no place by that name.
@@ -304,8 +344,13 @@ export class WakuseiBody extends HTMLElement {
304
344
  const place = list === undefined ? undefined : findPlace(list, text);
305
345
  if (place === undefined)
306
346
  return undefined;
347
+ this.#turnTo(place.lat, place.lon, options.smooth);
348
+ return place;
349
+ }
350
+ /** Turn the body so a point of it (latitude, east longitude, degrees) is in the middle of the disc: the glide of `goToPlace` and `faceTo`. */
351
+ #turnTo(lat, lon, smooth) {
307
352
  const frame = this.#frameNow();
308
- const aim = turnToPlace(frame.pose.pole, frame.pose.meridian, place.lat, place.lon);
353
+ const aim = turnToPlace(frame.pose.pole, frame.pose.meridian, lat, lon);
309
354
  const to = { yaw: aim.yaw, tilt: this.#pitchDelta - aim.tilt };
310
355
  const from = { yaw: this.#yaw, tilt: this.#tilt };
311
356
  // the shorter way round
@@ -319,9 +364,9 @@ export class WakuseiBody extends HTMLElement {
319
364
  };
320
365
  const glide = (this.#placeGlide += 1);
321
366
  // a still (not live) is made again for every change of view: it goes there at once
322
- if (options.smooth === false || this.#reduce || this.#view?.live !== true || typeof requestAnimationFrame !== "function") {
367
+ if (smooth === false || this.#reduce || this.#view?.live !== true || typeof requestAnimationFrame !== "function") {
323
368
  apply(to.yaw, to.tilt, true);
324
- return place;
369
+ return;
325
370
  }
326
371
  const start = performance.now();
327
372
  const step = () => {
@@ -334,7 +379,6 @@ export class WakuseiBody extends HTMLElement {
334
379
  requestAnimationFrame(step);
335
380
  };
336
381
  requestAnimationFrame(step);
337
- return place;
338
382
  }
339
383
  /** The body's list of places, loaded the first time it is asked for; `undefined` for a body that has none. */
340
384
  async #loadPlaces() {
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
11
11
  * console.log(TEXTURE_BASE);
12
12
  * ```
13
13
  */
14
- export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.47.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.49.0/dist/textures/";
15
15
  /**
16
16
  * 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
17
17
  * never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
23
23
  * console.log(TEXTURE_FAR_BASE);
24
24
  * ```
25
25
  */
26
- export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.47.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.49.0/textures/";
27
27
  /**
28
28
  * 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:
29
29
  * 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.
@@ -245,6 +245,48 @@ export declare class WakuseiSpace extends HTMLElement {
245
245
  smooth?: boolean;
246
246
  zoom?: number;
247
247
  }): Promise<Place | undefined>;
248
+ /**
249
+ * Which point of the body in the middle of the view is under the camera, as a longitude (east) and latitude (north) in the body's own fixed frame at the moment shown: the camera looks along the line
250
+ * from that point through the body's centre. It carries the body's spin and, for the Moon, the way its pole and prime meridian are set; a camera held in the stars sees the body turn under it, so the same
251
+ * view names another point as the clock runs. Beside a moon (`ride(moon, { view: "beside" })`, the way a moon is visited) it is the point under the line from the moon's centre to the camera. `null` while the camera is riding along with anything else. `faceTo` is the other way round.
252
+ *
253
+ * @returns The point, or `null`.
254
+ *
255
+ * @example
256
+ * ```ts no-run
257
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
258
+ *
259
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
260
+ * space.goTo("moon");
261
+ * console.log(space.subCameraPoint());
262
+ * ```
263
+ */
264
+ subCameraPoint(): {
265
+ lon: number;
266
+ lat: number;
267
+ } | null;
268
+ /**
269
+ * 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`
270
+ * or for a reader who prefers reduced motion); the zoom stays. The turn is the shorter way round and never through the body. Beside a moon it stands the camera as near the side the point is on as the view allows (the camera keeps beyond the moon, off the line to its planet). Returns false while the camera is riding along with anything else.
271
+ *
272
+ * @param point - The longitude and latitude to bring to the middle.
273
+ * @param options - `smooth` (true by default).
274
+ * @returns Whether the turn was made.
275
+ *
276
+ * @example
277
+ * ```ts no-run
278
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
279
+ *
280
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
281
+ * space.faceTo({ lon: 30.8, lat: 20.2 }, { smooth: false });
282
+ * ```
283
+ */
284
+ faceTo(point: {
285
+ lon: number;
286
+ lat: number;
287
+ }, options?: {
288
+ smooth?: boolean;
289
+ }): boolean;
248
290
  /**
249
291
  * The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
250
292
  * `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
@@ -565,7 +607,11 @@ export declare class WakuseiSpace extends HTMLElement {
565
607
  position: [number, number, number];
566
608
  fov: number;
567
609
  up: [number, number, number];
568
- forward: [number, number, number];
610
+ forward: [number, number, number]; /** The point of the body in the middle that is under the camera (`subCameraPoint`), or `null` while riding. */
611
+ sub: {
612
+ lon: number;
613
+ lat: number;
614
+ } | null;
569
615
  };
570
616
  /** What the painter has made at the last draw: the bodies with a drawing, the moons shown round a planet that is near, and the moons made and not yet let go. */
571
617
  bodies: {
@@ -19,6 +19,7 @@ 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
23
  import { besideMoon } from "./beside.js";
23
24
  import { SUN_REGIONS } from "./regions.js";
24
25
  import { travelArrival } from "./travel.js";
@@ -549,6 +550,105 @@ export class WakuseiSpace extends HTMLElement {
549
550
  requestAnimationFrame(step);
550
551
  return place;
551
552
  }
553
+ /**
554
+ * Which point of the body in the middle of the view is under the camera, as a longitude (east) and latitude (north) in the body's own fixed frame at the moment shown: the camera looks along the line
555
+ * from that point through the body's centre. It carries the body's spin and, for the Moon, the way its pole and prime meridian are set; a camera held in the stars sees the body turn under it, so the same
556
+ * view names another point as the clock runs. Beside a moon (`ride(moon, { view: "beside" })`, the way a moon is visited) it is the point under the line from the moon's centre to the camera. `null` while the camera is riding along with anything else. `faceTo` is the other way round.
557
+ *
558
+ * @returns The point, or `null`.
559
+ *
560
+ * @example
561
+ * ```ts no-run
562
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
563
+ *
564
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
565
+ * space.goTo("moon");
566
+ * console.log(space.subCameraPoint());
567
+ * ```
568
+ */
569
+ subCameraPoint() {
570
+ const model = this.#model;
571
+ const ride = model.ride;
572
+ if (ride !== null) {
573
+ // beside a moon (the way a moon is visited): the camera stands outside it, so the point is the one under the line from the moon's centre to the camera as the last draw left it
574
+ if (ride.view !== "beside" || typeof ride.target !== "string")
575
+ return null;
576
+ // worked out from the view as it is now (the camera `besideMoon` gives for it), not from the last draw, so a turn just made is already counted
577
+ const moon = ride.target;
578
+ const camera = besideMoon({ ...this.#besideInput(moon), zoom: model.view.zoom, yaw: model.view.yaw, tilt: model.view.tilt });
579
+ const here = this.#site(moon).at;
580
+ const away = [camera.position[0] - here[0], camera.position[1] - here[1], camera.position[2] - here[2]];
581
+ return length(away) < 1e-12 ? null : facingPoint(moon, away, model.time);
582
+ }
583
+ return subCameraPoint(model.focus, model.view, model.centre, model.anchor ?? model.time, model.time);
584
+ }
585
+ /**
586
+ * 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`
587
+ * or for a reader who prefers reduced motion); the zoom stays. The turn is the shorter way round and never through the body. Beside a moon it stands the camera as near the side the point is on as the view allows (the camera keeps beyond the moon, off the line to its planet). Returns false while the camera is riding along with anything else.
588
+ *
589
+ * @param point - The longitude and latitude to bring to the middle.
590
+ * @param options - `smooth` (true by default).
591
+ * @returns Whether the turn was made.
592
+ *
593
+ * @example
594
+ * ```ts no-run
595
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
596
+ *
597
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
598
+ * space.faceTo({ lon: 30.8, lat: 20.2 }, { smooth: false });
599
+ * ```
600
+ */
601
+ faceTo(point, options = {}) {
602
+ const model = this.#model;
603
+ if (!Number.isFinite(point.lon) || !Number.isFinite(point.lat))
604
+ return false;
605
+ const ride = model.ride;
606
+ if (ride !== null && (ride.view !== "beside" || typeof ride.target !== "string"))
607
+ return false;
608
+ model.anchor ??= model.time;
609
+ const from = { ...model.view };
610
+ let to;
611
+ if (ride !== null) {
612
+ // beside a moon: the pair of the ride's yaw and tilt that stands the camera nearest the side of the moon the point is on (the view keeps the camera beyond the moon, so some sides are only approached)
613
+ const moon = ride.target;
614
+ const { moon: at, moonRadius, host, hostRadius, sun, north, aspect } = this.#besideInput(moon);
615
+ const found = besideFace({ moon: at, moonRadius, host, hostRadius, sun, north, aspect, zoom: from.zoom }, moon, point, model.time);
616
+ to = { yaw: from.yaw + ((((found.yaw - from.yaw + 180) % 360) + 360) % 360) - 180, tilt: found.tilt };
617
+ }
618
+ else
619
+ to = faceView(model.focus, point, model.centre, model.anchor, model.time, from.yaw);
620
+ const apply = (yaw, tilt, final) => {
621
+ if (this.#hands !== undefined && !this.hasAttribute("data-kazoku-bar"))
622
+ this.#hands.controller.set({ yaw, tilt, zoom: from.zoom }, final, "place");
623
+ else
624
+ this.setView({ yaw, tilt, zoom: from.zoom, roll: from.roll, panX: from.panX, panY: from.panY }, final);
625
+ };
626
+ const glide = (this.#placeGlide += 1);
627
+ const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
628
+ if (options.smooth === false || reduced || typeof requestAnimationFrame !== "function") {
629
+ apply(to.yaw, to.tilt, true);
630
+ return true;
631
+ }
632
+ const start = performance.now();
633
+ const step = () => {
634
+ if (glide !== this.#placeGlide || !this.isConnected)
635
+ return;
636
+ const k = Math.min(1, (performance.now() - start) / 900);
637
+ const ease = k * k * (3 - 2 * k);
638
+ apply(from.yaw + (to.yaw - from.yaw) * ease, from.tilt + (to.tilt - from.tilt) * ease, k >= 1);
639
+ if (k < 1)
640
+ requestAnimationFrame(step);
641
+ };
642
+ requestAnimationFrame(step);
643
+ return true;
644
+ }
645
+ /** What `besideMoon` is given for a moon, without the view's zoom, yaw and tilt: the places and sizes the scene draws with, worked out the same way. */
646
+ #besideInput(moon) {
647
+ const host = (hostOf(moon) ?? "earth");
648
+ const m = this.#site(moon), h = this.#site(host);
649
+ const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 16 / 9;
650
+ return { moon: m.at, moonRadius: m.radius, host: h.at, hostRadius: h.radius, sun: this.#site("sun").at, north: orientation(host, this.#model.time).pole, aspect };
651
+ }
552
652
  #readEarthPlaces() {
553
653
  const text = this.getAttribute("earth-places");
554
654
  const using = earthPlacesLayout();
@@ -1771,7 +1871,7 @@ export class WakuseiSpace extends HTMLElement {
1771
1871
  assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
1772
1872
  time: this.time,
1773
1873
  lookups: this.#model.lookups,
1774
- camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov, up: [...this.#model.camera.up], forward: [...this.#model.camera.forward] },
1874
+ camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov, up: [...this.#model.camera.up], forward: [...this.#model.camera.forward], sub: this.subCameraPoint() },
1775
1875
  bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
1776
1876
  tiles: { ...this.#model.tiles },
1777
1877
  door: { points: this.#model.door.points, belts: this.#model.door.belts, draws: this.#model.door.draws, sources: this.#door.book.stats() },
@@ -0,0 +1,132 @@
1
+ import type { BodyId } from "../facts.ts";
2
+ import { type Vec3 } from "../vec.ts";
3
+ import { type BesideInput } from "./beside.ts";
4
+ /**
5
+ * A place on a body's surface: east longitude and north latitude in the body's own fixed frame, degrees.
6
+ *
7
+ * @example
8
+ * ```ts no-run
9
+ * import type { Face } from "@johnmorrisdotca/wakusei-planets/space";
10
+ *
11
+ * const tranquility: Face = { lon: 23.47, lat: 0.67 };
12
+ * console.log(tranquility.lat);
13
+ * ```
14
+ */
15
+ export interface Face {
16
+ lon: number;
17
+ lat: number;
18
+ }
19
+ /**
20
+ * The camera's turn: the view's yaw and tilt, degrees (the view's `center` is given beside it, and the aim is counted from that).
21
+ *
22
+ * @example
23
+ * ```ts no-run
24
+ * import type { FaceView } from "@johnmorrisdotca/wakusei-planets/space";
25
+ *
26
+ * const view: FaceView = { yaw: 30, tilt: -10 };
27
+ * console.log(view.yaw);
28
+ * ```
29
+ */
30
+ export interface FaceView {
31
+ yaw: number;
32
+ tilt: number;
33
+ }
34
+ /**
35
+ * The longitude and latitude, on the body in the middle of the space view, of the point under the camera: the camera looks along the line from that point through the body's centre. It is the camera's
36
+ * direction (the Earth's ground direction of `center` less the yaw and tilt, as the stars saw it at `anchor`) put into the body's own frame (its pole and prime meridian at `time`, which carry its spin
37
+ * and, for the Moon, its libration). A body that turns with the clock moves under a camera held in the stars, so the same view names another face a minute later.
38
+ *
39
+ * @param body - The body in the middle of the view.
40
+ * @param view - The view's yaw and tilt, degrees.
41
+ * @param centre - The view's `center` (longitude and latitude, degrees).
42
+ * @param anchor - The moment the camera was last pointed, in milliseconds since the Unix epoch.
43
+ * @param time - The moment shown.
44
+ * @returns The point under the camera, longitude from -180 to 180 and latitude from -90 to 90.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { subCameraPoint } from "@johnmorrisdotca/wakusei-planets/space";
49
+ *
50
+ * const at = subCameraPoint("moon", { yaw: 0, tilt: 0 }, { lon: 0, lat: 0 }, Date.UTC(2026, 10, 2), Date.UTC(2026, 10, 2));
51
+ * console.log(at.lon.toFixed(0), at.lat.toFixed(0));
52
+ * ```
53
+ */
54
+ export declare function subCameraPoint(body: BodyId, view: FaceView, centre: Face, anchor: number, time: number): Face;
55
+ /**
56
+ * The yaw and tilt that put a point of the body under the camera: the other way round from {@link subCameraPoint}, for the same centre, anchor and moment. The yaw is the shorter way round from `from`.
57
+ *
58
+ * @param body - The body in the middle of the view.
59
+ * @param face - The point to bring to the middle.
60
+ * @param centre - The view's `center`.
61
+ * @param anchor - The moment the camera was last pointed.
62
+ * @param time - The moment shown.
63
+ * @param from - The yaw the view has now, so that the turn is the shorter way (0 when left out).
64
+ * @returns The yaw and tilt to give the view.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import { faceView, subCameraPoint } from "@johnmorrisdotca/wakusei-planets/space";
69
+ *
70
+ * const ms = Date.UTC(2026, 10, 2);
71
+ * const turn = faceView("mars", { lon: 100, lat: 20 }, { lon: 0, lat: 0 }, ms, ms);
72
+ * console.log(subCameraPoint("mars", turn, { lon: 0, lat: 0 }, ms, ms));
73
+ * ```
74
+ */
75
+ export declare function faceView(body: BodyId, face: Face, centre: Face, anchor: number, time: number, from?: number): FaceView;
76
+ /**
77
+ * The longitude and latitude on a body of a direction from its centre in the scene's axes: what a camera standing along that direction has under it. The body's pole and prime meridian are those at `time`.
78
+ *
79
+ * @param body - The body.
80
+ * @param direction - A direction from the body's centre (any length).
81
+ * @param time - The moment, in milliseconds since the Unix epoch.
82
+ * @returns The point on the body under that direction.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * import { facingPoint } from "@johnmorrisdotca/wakusei-planets/space";
87
+ *
88
+ * const ms = Date.UTC(2026, 10, 2);
89
+ * console.log(facingPoint("moon", [0, 1, 0], ms));
90
+ * ```
91
+ */
92
+ export declare function facingPoint(body: BodyId, direction: Vec3, time: number): Face;
93
+ /**
94
+ * The direction from a body's centre, in the scene's axes, of a point on its surface at a moment: the unit vector the other way from {@link facingPoint}.
95
+ *
96
+ * @param body - The body.
97
+ * @param face - The point on its surface.
98
+ * @param time - The moment, in milliseconds since the Unix epoch.
99
+ * @returns The unit direction.
100
+ *
101
+ * @example
102
+ * ```ts
103
+ * import { surfaceDirection } from "@johnmorrisdotca/wakusei-planets/space";
104
+ *
105
+ * console.log(surfaceDirection("moon", { lon: 0, lat: 0 }, Date.UTC(2026, 10, 2)).map((n) => n.toFixed(2)));
106
+ * ```
107
+ */
108
+ export declare function surfaceDirection(body: BodyId, face: Face, time: number): Vec3;
109
+ /**
110
+ * The yaw and tilt of a camera beside a moon (the view `ride(moon, { view: "beside" })` gives) that put it on the side of the moon the point is on: the camera stands along the direction from the moon's
111
+ * centre through the point. The camera there is placed by `besideMoon` (beyond the moon, off the line to its planet), so not every point can be reached: the pair returned brings the camera as near as
112
+ * the view goes, and `error` says by how many degrees it is still off.
113
+ *
114
+ * @param input - What `besideMoon` is given, without the yaw and tilt.
115
+ * @param body - The moon.
116
+ * @param face - The point to bring under the camera.
117
+ * @param time - The moment shown.
118
+ * @returns The yaw and tilt, and the angle in degrees between the camera's direction and the wanted one.
119
+ *
120
+ * @example
121
+ * ```ts
122
+ * import { besideFace } from "@johnmorrisdotca/wakusei-planets/space";
123
+ *
124
+ * const input = { moon: [60, 0, 0], moonRadius: 0.273, host: [0, 0, 0], hostRadius: 1, sun: [-23000, 0, 0], aspect: 1.6, zoom: 1 } as const;
125
+ * console.log(besideFace(input, "moon", { lon: 180, lat: 0 }, Date.UTC(2026, 10, 2)).error < 90);
126
+ * ```
127
+ */
128
+ export declare function besideFace(input: Omit<BesideInput, "yaw" | "tilt">, body: BodyId, face: Face, time: number): {
129
+ yaw: number;
130
+ tilt: number;
131
+ error: number;
132
+ };