@johnmorrisdotca/wakusei-planets 0.49.0 → 0.51.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 +12 -0
- package/README.md +3 -3
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +32 -3
- package/dist/space/element.js +80 -4
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/scene.d.ts +2 -0
- package/dist/space/scene.js +9 -2
- package/dist/space/sight.d.ts +23 -0
- package/dist/space/sight.js +20 -0
- package/dist/surface/element.d.ts +27 -0
- package/dist/surface/element.js +255 -7
- package/dist/surface/glsl.d.ts +5 -2
- package/dist/surface/glsl.js +33 -2
- package/dist/surface/index.d.ts +2 -1
- package/dist/surface/index.js +2 -1
- package/dist/surface/land.d.ts +6 -0
- package/dist/surface/land.js +8 -0
- package/dist/surface/landing.d.ts +134 -0
- package/dist/surface/landing.js +237 -0
- package/dist/surface/scene.d.ts +9 -0
- package/dist/surface/scene.js +108 -3
- package/dist/surface/shapes.d.ts +14 -0
- package/dist/surface/shapes.js +33 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.51.0] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **What a page can ask of the view's sight** (MODULES-1220). Every entry of `sight()` and `wakusei-sight` now says `offAxis` (degrees between the camera's forward direction and the body, 0 to 180), `distance` (from the camera, in Earth radii) and `distanceKm` (in kilometres in the true scale, `null` in the compressed one), so a page can rank its edge markers by nearness; `angle` is unchanged. `turnTo(id, { smooth, margin })` turns the camera where it stands until a body is in the picture, by the least turn, and says whether it did: in the picture means the body's middle is inside the picture less `margin` of each side (0.15 of the width for the left and right and of the height for the top and bottom by default, 0 to 0.45); a body already so, the body looked at, an unknown id and a ride answer `false` and draw nothing. The camera does not move (the body becomes the one looked at, from where the camera stands). An orbiter is an entry of `sight()` with `kind: "orbiter"` and the id `orbiter` takes (`lro`, `mro`), and a press on its name sends `wakusei-orbiter-click` with `{ id, name }` as well as `wakusei-body-click`, which is unchanged. Guide: the space-view guide and its Japanese twin.
|
|
8
|
+
|
|
9
|
+
- **The spacecraft page plays on frames, and has a freeze test** (MODULES-1210). `demo/craft.html` no longer runs a timer every 0.7 s: Play drives `requestAnimationFrame` while it is on and the tab is seen, at the same pace (a ninetieth of the record in 0.7 s of the page's time), and a paused or hidden page schedules nothing. `e2e/craft-freeze.demo.ts` counts the frames the page asks for and the changes made to it on the page's own held clock: playing asks for a frame each page frame and changes the page, paused or hidden asks for none and changes nothing in two seconds, and on a phone the page has no sideways scroll, the picker, chart and events inside the screen and every button at least 40 px tall. In short, the craft page plays on frames and rests when paused or hidden. Demo page only: the package is unchanged.
|
|
10
|
+
|
|
11
|
+
- **Rates are read on the page's own clock** (test only, no change to the package): the tests of how fast things run (draws a second, game days a second, the ride's rate, the drag's frames, the date box) now install the page's clock, hold it and step it themselves (`e2e/clock.ts`), so a count is a count of the simulated seconds and does not depend on the speed of the machine; the soak runs one minute by default (`SOAK_MINUTES`) and its limit is not raised. Five repeats under CPU throttle 4 pass for each, and each has a fault that fails it, except the freeze drag test, whose new form is unproven (the fault tried did not reach it).
|
|
12
|
+
|
|
13
|
+
## [0.50.0] - 2026-11-13
|
|
14
|
+
|
|
15
|
+
- **Watch Apollo 17's powered descent** (MODULES-1333). `watch="landing"` on `<wakusei-surface>` (and `land(site, { watch: "landing" })` on `<wakusei-space>`) runs the descent at the real moment (the Sun, the Earth and the shadows of 19:42:52 to 19:54:57 UTC on 1972-12-11) from the commander's window or from the ground, with the clock, the report's moments shown as they pass, a scrubber (`landingTime`), `playLanding()`, `pauseLanding()`, `landingRate` and the `wakusei-landing-clock` event. **Real**: the times of the Apollo 17 Mission Report's table of events (ignition 110:09:53, radar lock T+3:35, throttle down T+7:26, high gate T+9:22, the first of eight redesignations, low gate T+10:58, touchdown T+12:05), the state at ignition (19.13 N, 48.75 E, 8.7 nautical miles, 5,550 ft/s, heading 276 degrees) and the altitudes it names (30,000 ft, 13,000 ft, pitchover at about 7,500 ft, manual takeover under 300 ft, dust at 60 to 70 ft, touchdown at about 3 ft/s). **Made, and said on the picture**: the altitude and speed between those moments (a smooth curve through them that covers the real distance), the ground path, the window's attitude, the plume, and the dust, thrown as a low sheet of many soft grains along the ground from the 60 to 70 ft call-out. The view starts at T+4:00 (the first minutes are beyond the ground the package has). The lunar module is drawn whole, with its plume and shadow; the ground camera stands 150 m north of the touchdown point (`watch-from`, `watch-camera`) and draws a ring with the height beside it until the stage is larger than about 6 pixels. Nothing is drawn once the descent is paused or finished.
|
|
16
|
+
|
|
5
17
|
## [0.49.0] - 2026-11-13
|
|
6
18
|
|
|
7
19
|
- **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.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
|
|
|
19
19
|
|
|
20
20
|
<p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
|
|
21
21
|
|
|
22
|
-
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
22
|
+
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.51.0/docs/images/lineup-desk.png" width="640"></p>
|
|
23
23
|
|
|
24
24
|
## Who it is for
|
|
25
25
|
|
|
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
|
|
|
388
388
|
|
|
389
389
|
## The portrait builder
|
|
390
390
|
|
|
391
|
-
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
391
|
+
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.51.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
|
|
|
@@ -536,7 +536,7 @@ BODIES.pluto.kind; // "dwarf-planet"
|
|
|
536
536
|
|
|
537
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:
|
|
538
538
|
|
|
539
|
-
> Morris, J. (2026). *Wakusei Planets* (version 0.
|
|
539
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.51.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
|
|
540
540
|
|
|
541
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).
|
|
542
542
|
|
package/dist/scene/textures.d.ts
CHANGED
|
@@ -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.
|
|
14
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.51.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.
|
|
26
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.51.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.
|
package/dist/space/element.d.ts
CHANGED
|
@@ -73,15 +73,21 @@ export interface BodyHover extends BodyInfo {
|
|
|
73
73
|
* ```ts no-run
|
|
74
74
|
* import type { BodySight } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
75
75
|
*
|
|
76
|
-
* const mars: BodySight = { id: "mars", kind: "planet", inView: false, behind: false, edge: "right", x: 640, y: 210, along: 210, angle: 84 };
|
|
76
|
+
* const mars: BodySight = { id: "mars", kind: "planet", inView: false, behind: false, edge: "right", x: 640, y: 210, along: 210, angle: 84, offAxis: 31, distance: 52_000, distanceKm: 3.3e8 };
|
|
77
77
|
* console.log(mars.inView ? "in view" : `beyond the ${mars.edge} edge`);
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
export interface BodySight extends Sight {
|
|
81
|
-
/** A body's id,
|
|
81
|
+
/** A body's id, a craft's own id (`voyager1`, `roadster`) when `kind` is `spacecraft`, or an orbiter's id (`mro`, the one `orbiter` takes) when `kind` is `orbiter`. */
|
|
82
82
|
id: string;
|
|
83
|
-
kind: SpaceKind | "spacecraft";
|
|
83
|
+
kind: SpaceKind | "spacecraft" | "orbiter";
|
|
84
84
|
host?: BodyId;
|
|
85
|
+
/** Degrees between the camera's forward direction and the body, 0 (straight ahead) to 180 (straight behind). */
|
|
86
|
+
offAxis: number;
|
|
87
|
+
/** How far the body is from the camera, in the view's units: Earth radii. In the compressed scale these are the drawn distances, not the real ones. */
|
|
88
|
+
distance: number;
|
|
89
|
+
/** The distance in kilometres, in the true scale; `null` in the compressed one, where the drawn distances are not real. */
|
|
90
|
+
distanceKm: number | null;
|
|
85
91
|
}
|
|
86
92
|
/**
|
|
87
93
|
* What the space view is doing: `loading`, `live`, `unavailable` (no WebGL), `lost` (the GPU took the context; it comes back by itself).
|
|
@@ -496,6 +502,29 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
496
502
|
transition?: TravelKind;
|
|
497
503
|
duration?: number;
|
|
498
504
|
}): boolean;
|
|
505
|
+
/**
|
|
506
|
+
* Turn the camera where it stands until a body is in the picture, by the least turn: no move of the camera's place, only the way it looks. A body is in the picture when its middle is inside the picture less `margin` of
|
|
507
|
+
* each side (the left and right margins are `margin` of the width, the top and bottom `margin` of the height; 0.15 by default, 0 to 0.45). One already so is left alone and the answer is `false`, as it is for an id the
|
|
508
|
+
* view does not know, the body already looked at, and a view that is riding. The body becomes the one looked at: the camera stays at its place and looks at it, from as far
|
|
509
|
+
* as it stands (the zoom is worked out from that distance, inside the controls' limits; a body so far that the zoom's limit would move the camera is not turned to). It glides the way a move does, or at once with
|
|
510
|
+
* `smooth: false` or for a reader who prefers reduced motion; nothing is drawn at rest and one draw more at most ends it.
|
|
511
|
+
*
|
|
512
|
+
* @param target - The body's id.
|
|
513
|
+
* @param options - `smooth` (true by default) and `margin`.
|
|
514
|
+
* @returns Whether the view turned.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```ts no-run
|
|
518
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
519
|
+
*
|
|
520
|
+
* const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
|
|
521
|
+
* console.log(space.turnTo("mars", { smooth: false }));
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
turnTo(target: BodyId | string, options?: {
|
|
525
|
+
smooth?: boolean;
|
|
526
|
+
margin?: number;
|
|
527
|
+
}): boolean;
|
|
499
528
|
/** The next stage out from the Sun from where the view is (the first stage from a body), with the same move as `goTo`; null, and nothing done, when the view is already at the widest stage. */
|
|
500
529
|
stepOut(options?: {
|
|
501
530
|
smooth?: boolean;
|
package/dist/space/element.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createGate, frameCap } from "../gate.js";
|
|
|
5
5
|
import { arrowCount } from "./arrows.js";
|
|
6
6
|
import { createGameClock } from "./clock.js";
|
|
7
7
|
import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER, systemOf } from "./bodies.js";
|
|
8
|
-
import { sightChanged, sightOf } from "./sight.js";
|
|
8
|
+
import { sightChanged, sightOf, withinMargin } from "./sight.js";
|
|
9
9
|
import { chooseLabels, nameSpot } from "./labels.js";
|
|
10
10
|
import { coverArrows } from "./covered.js";
|
|
11
11
|
import { createPainter, picturesPending } from "../scene/painter.js";
|
|
@@ -28,7 +28,7 @@ import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView }
|
|
|
28
28
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
29
29
|
import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
|
|
30
30
|
import { cross, dot, length, sub, unit } from "../vec.js";
|
|
31
|
-
import { createSpaceItem, FIT_DISTANCE, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
31
|
+
import { createSpaceItem, FIT_DISTANCE, framedOf, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
32
32
|
import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
|
|
33
33
|
export { setPlacesLoader } from "../scene/place-layer.js";
|
|
34
34
|
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "../scene/earth-places.js";
|
|
@@ -1346,6 +1346,78 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1346
1346
|
this.#announceHop(zoom, side ?? undefined);
|
|
1347
1347
|
return true;
|
|
1348
1348
|
}
|
|
1349
|
+
/**
|
|
1350
|
+
* Turn the camera where it stands until a body is in the picture, by the least turn: no move of the camera's place, only the way it looks. A body is in the picture when its middle is inside the picture less `margin` of
|
|
1351
|
+
* each side (the left and right margins are `margin` of the width, the top and bottom `margin` of the height; 0.15 by default, 0 to 0.45). One already so is left alone and the answer is `false`, as it is for an id the
|
|
1352
|
+
* view does not know, the body already looked at, and a view that is riding. The body becomes the one looked at: the camera stays at its place and looks at it, from as far
|
|
1353
|
+
* as it stands (the zoom is worked out from that distance, inside the controls' limits; a body so far that the zoom's limit would move the camera is not turned to). It glides the way a move does, or at once with
|
|
1354
|
+
* `smooth: false` or for a reader who prefers reduced motion; nothing is drawn at rest and one draw more at most ends it.
|
|
1355
|
+
*
|
|
1356
|
+
* @param target - The body's id.
|
|
1357
|
+
* @param options - `smooth` (true by default) and `margin`.
|
|
1358
|
+
* @returns Whether the view turned.
|
|
1359
|
+
*
|
|
1360
|
+
* @example
|
|
1361
|
+
* ```ts no-run
|
|
1362
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
1363
|
+
*
|
|
1364
|
+
* const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
|
|
1365
|
+
* console.log(space.turnTo("mars", { smooth: false }));
|
|
1366
|
+
* ```
|
|
1367
|
+
*/
|
|
1368
|
+
turnTo(target, options = {}) {
|
|
1369
|
+
const id = readBody(target);
|
|
1370
|
+
const model = this.#model;
|
|
1371
|
+
if (!id || model.ride !== null || !model.pose.valid || id === model.focus)
|
|
1372
|
+
return false;
|
|
1373
|
+
const margin = Number.isFinite(options.margin) ? Math.min(0.45, Math.max(0, options.margin)) : 0.15;
|
|
1374
|
+
const site = this.#site(id);
|
|
1375
|
+
const p = model.pose.p;
|
|
1376
|
+
const [qx, qy, qz, qw] = model.pose.q;
|
|
1377
|
+
// the body in the camera's axes (it looks down -z): rotate by the inverse of the camera's turn
|
|
1378
|
+
const v = [site.at[0] - p[0], site.at[1] - p[1], site.at[2] - p[2]];
|
|
1379
|
+
// v' = v + w t + q x t, with t = 2 (-q x v): the vector turned by the conjugate
|
|
1380
|
+
const tx = 2 * (-(qy * v[2] - qz * v[1])), ty = 2 * (-(qz * v[0] - qx * v[2])), tz = 2 * (-(qx * v[1] - qy * v[0]));
|
|
1381
|
+
const c = [v[0] + qw * tx + (-qy * tz - -qz * ty), v[1] + qw * ty + (-qz * tx - -qx * tz), v[2] + qw * tz + (-qx * ty - -qy * tx)];
|
|
1382
|
+
const tall = Math.tan((model.pose.fov * Math.PI) / 360);
|
|
1383
|
+
const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 1;
|
|
1384
|
+
if (c[2] < 0) {
|
|
1385
|
+
const nx = c[0] / (-c[2] * tall * aspect), ny = c[1] / (-c[2] * tall);
|
|
1386
|
+
if (withinMargin(nx, ny, margin))
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
// the camera's place as seen from the body: the controls' yaw and tilt and the zoom that put the camera there, looking at it
|
|
1390
|
+
const away = Math.hypot(v[0], v[1], v[2]);
|
|
1391
|
+
if (away === 0)
|
|
1392
|
+
return false;
|
|
1393
|
+
const aim = [-v[0] / away, -v[1] / away, -v[2] / away];
|
|
1394
|
+
const across = site.radius * framedOf(id) * Math.max(1, (this.clientHeight || 1) / Math.max(1, this.clientWidth || 1));
|
|
1395
|
+
const zoom = (FIT_DISTANCE * across) / away;
|
|
1396
|
+
if (!(zoom >= CARRIED_LIMITS.zoomMin && zoom <= CARRIED_LIMITS.zoomMax) || away < 1.05 * site.radius)
|
|
1397
|
+
return false;
|
|
1398
|
+
model.anchor ??= model.time;
|
|
1399
|
+
const earth = orientation("earth", model.anchor);
|
|
1400
|
+
const lat = Math.asin(Math.max(-1, Math.min(1, dot(aim, earth.pole)))) / RAD;
|
|
1401
|
+
const lon = Math.atan2(dot(aim, cross(earth.pole, earth.meridian)), dot(aim, earth.meridian)) / RAD;
|
|
1402
|
+
const from = { ...model.view };
|
|
1403
|
+
const yaw = from.yaw + ((((model.centre.lon - lon - from.yaw + 180) % 360) + 360) % 360) - 180;
|
|
1404
|
+
const tilt = model.centre.lat - lat;
|
|
1405
|
+
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1406
|
+
const leaving = this.#leaving();
|
|
1407
|
+
this.#arrivedFrom = leaving;
|
|
1408
|
+
model.transition = options.smooth === false || reduced ? null : this.#startMove("direct", leaving, id);
|
|
1409
|
+
model.region = null;
|
|
1410
|
+
this.#showRegion();
|
|
1411
|
+
this.#selected = id;
|
|
1412
|
+
model.focus = id;
|
|
1413
|
+
if (this.#hands !== undefined && !this.hasAttribute("data-kazoku-bar"))
|
|
1414
|
+
this.#hands.controller.set({ yaw, tilt, zoom }, true, "jump");
|
|
1415
|
+
else
|
|
1416
|
+
this.setView({ yaw, tilt, zoom, roll: from.roll, panX: from.panX, panY: from.panY }, true);
|
|
1417
|
+
this.#schedule();
|
|
1418
|
+
this.#gate?.request();
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1349
1421
|
/** The body the camera is at now: the target of the ride, or the body looked at. */
|
|
1350
1422
|
#leaving() {
|
|
1351
1423
|
const ride = this.#model.ride;
|
|
@@ -2138,8 +2210,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2138
2210
|
const now = {};
|
|
2139
2211
|
for (const [id, input] of Object.entries(bodies)) {
|
|
2140
2212
|
const body = id;
|
|
2141
|
-
const
|
|
2142
|
-
const
|
|
2213
|
+
const orbiter = this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id);
|
|
2214
|
+
const craft = orbiter || this.#model.craftIds.includes(id) || id === "roadster";
|
|
2215
|
+
const one = { id, kind: orbiter ? "orbiter" : craft ? "spacecraft" : bodyKindOf(body), ...sightOf(input, frame.width, frame.height, frame.axis), offAxis: input.offAxis ?? 0, distance: input.distance ?? 0, distanceKm: input.distanceKm ?? null };
|
|
2143
2216
|
const host = craft ? undefined : hostOf(body);
|
|
2144
2217
|
if (host !== undefined)
|
|
2145
2218
|
one.host = host;
|
|
@@ -2334,6 +2407,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2334
2407
|
// the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
|
|
2335
2408
|
if (id === "roadster" || this.#model.craftIds.includes(id) || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))) {
|
|
2336
2409
|
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
|
|
2410
|
+
// an orbiter is told in an event of its own as well (`{ id, name }`, the id `orbiter` takes), the one above unchanged
|
|
2411
|
+
if (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))
|
|
2412
|
+
this.dispatchEvent(new CustomEvent("wakusei-orbiter-click", { detail: { id, name: this.#nameOf(id) }, bubbles: true, composed: true }));
|
|
2337
2413
|
return;
|
|
2338
2414
|
}
|
|
2339
2415
|
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
|
package/dist/space/index.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export { spinAxis, type SpinAxis } from "./spin.ts";
|
|
|
10
10
|
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, type CoverArrow, type CoverEntry } from "./covered.ts";
|
|
11
11
|
export { TRAVEL_CLEARANCE, arrivalSide, travelArrival, travelPlan, travelPose, type ArrivalCompanion, type TravelBody, type TravelInput, type TravelKind, type TravelPlan, type TravelSample, type TravelSight, type TravelView } from "./travel.ts";
|
|
12
12
|
export { regionOrbits, regionView, SUN_REGIONS, type SunRegion } from "./regions.ts";
|
|
13
|
-
export { SIGHT_STEP_PX, sightChanged, sightOf, type Sight, type SightEdge, type SightInput } from "./sight.ts";
|
|
13
|
+
export { SIGHT_STEP_PX, sightChanged, sightOf, withinMargin, type Sight, type SightEdge, type SightInput } from "./sight.ts";
|
|
14
14
|
export { besideFace, facingPoint, faceView, subCameraPoint, surfaceDirection, type Face, type FaceView } from "./face.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -11,5 +11,5 @@ export { spinAxis } from "./spin.js";
|
|
|
11
11
|
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy } from "./covered.js";
|
|
12
12
|
export { TRAVEL_CLEARANCE, arrivalSide, travelArrival, travelPlan, travelPose } from "./travel.js";
|
|
13
13
|
export { regionOrbits, regionView, SUN_REGIONS } from "./regions.js";
|
|
14
|
-
export { SIGHT_STEP_PX, sightChanged, sightOf } from "./sight.js";
|
|
14
|
+
export { SIGHT_STEP_PX, sightChanged, sightOf, withinMargin } from "./sight.js";
|
|
15
15
|
export { besideFace, facingPoint, faceView, subCameraPoint, surfaceDirection } from "./face.js";
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ import { type TravelInput, type TravelKind, type TravelPlan } from "./travel.ts"
|
|
|
20
20
|
export type SpaceThree = ThreeParts & Pick<typeof THREE, "PerspectiveCamera">;
|
|
21
21
|
/** The camera's distance, in radii of the body it looks at, at which that body fills the view at zoom 1. */
|
|
22
22
|
export declare const FIT_DISTANCE = 4.1;
|
|
23
|
+
/** How much of the picture's shorter side a body's disc is framed across at zoom 1, in the body's radii: 1, and more for a ringed body. */
|
|
24
|
+
export declare const framedOf: (id: string) => number;
|
|
23
25
|
/**
|
|
24
26
|
* The twenty-four bodies the space view places, names and lets a reader choose: the Earth, the Sun, the Moon, the seven other planets, Pluto, the eight other dwarf planets and the five minor bodies (Vesta, Pallas, Chiron, Pholus and Halley). The moons of the planets and of the dwarf planets are placed round their hosts.
|
|
25
27
|
*
|
package/dist/space/scene.js
CHANGED
|
@@ -13,7 +13,7 @@ import { arrowSites, ARROWS_PER_ORBIT, chevron, MAX_ARROWS_PER_ORBIT, spinArrow
|
|
|
13
13
|
import { besideMoon } from "./beside.js";
|
|
14
14
|
import { coveredBy } from "./covered.js";
|
|
15
15
|
import { spinAxis } from "./spin.js";
|
|
16
|
-
import { createTrack, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
16
|
+
import { createTrack, EARTH_RADIUS_KM, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
17
17
|
import { createPaintOverlay } from "./paint-overlay.js";
|
|
18
18
|
import { createPaintTrail, groundUnder, paintMinute } from "../paint/trail.js";
|
|
19
19
|
import { BALL_FRAGMENT, VERTEX } from "../scene/glsl.js";
|
|
@@ -39,6 +39,8 @@ const CLOSE_UP_PX = 30;
|
|
|
39
39
|
const MOON_RING_KEEP_MS = 5 * 86_400_000;
|
|
40
40
|
/** How many radii across the picture of a body is at zoom 1 when it has more than its globe: Saturn's rings (to 2.27 radii) are inside the view, not cut by it. */
|
|
41
41
|
const FRAMED = { saturn: 2.3 };
|
|
42
|
+
/** How much of the picture's shorter side a body's disc is framed across at zoom 1, in the body's radii: 1, and more for a ringed body. */
|
|
43
|
+
export const framedOf = (id) => FRAMED[id] ?? 1;
|
|
42
44
|
/** The moons of a planet are shown once the planet is this many CSS pixels across its radius, and each is drawn at least this many pixels across its radius. */
|
|
43
45
|
const MOON_MIN_PLANET_PX = 4;
|
|
44
46
|
const MOON_MIN_PX = 2.2;
|
|
@@ -1262,8 +1264,11 @@ export function createSpaceItem(model, deps) {
|
|
|
1262
1264
|
const sight = (id, at, r) => {
|
|
1263
1265
|
projected.set(at[0], at[1], at[2]).applyMatrix4(camera.matrixWorldInverse);
|
|
1264
1266
|
const [cx, cy, front] = [projected.x, projected.y, projected.z < 0];
|
|
1267
|
+
// how far off the line of sight, and how far, in the camera's own axes (it looks down -z)
|
|
1268
|
+
const away = Math.hypot(projected.x, projected.y, projected.z);
|
|
1269
|
+
const offAxis = away === 0 ? 0 : (Math.acos(Math.max(-1, Math.min(1, -projected.z / away))) * 180) / Math.PI;
|
|
1265
1270
|
projected.applyMatrix4(camera.projectionMatrix);
|
|
1266
|
-
sights[id] = { front, x: front ? ((projected.x + 1) / 2) * size.width : 0, y: front ? ((1 - projected.y) / 2) * size.height : 0, r: front ? r : 0, dx: cx, dy: -cy };
|
|
1271
|
+
sights[id] = { front, x: front ? ((projected.x + 1) / 2) * size.width : 0, y: front ? ((1 - projected.y) / 2) * size.height : 0, r: front ? r : 0, dx: cx, dy: -cy, offAxis, distance: away, distanceKm: mode === "true" ? away * EARTH_RADIUS_KM : null };
|
|
1267
1272
|
};
|
|
1268
1273
|
for (const id of SPACE_BODIES)
|
|
1269
1274
|
if (id !== hiddenBody && !(rideFrom && id === rideFrom.around))
|
|
@@ -1274,6 +1279,8 @@ export function createSpaceItem(model, deps) {
|
|
|
1274
1279
|
sight(id, absoluteSite(id), moonPlaces[id]?.r ?? 0);
|
|
1275
1280
|
for (const craft of craftAts)
|
|
1276
1281
|
sight(craft.id, craft.at, craft.px);
|
|
1282
|
+
for (const [id, { at, px: dotPx }] of Object.entries(orbiterPlaces))
|
|
1283
|
+
sight(id, at, dotPx);
|
|
1277
1284
|
projected.set(0, 0, -1).applyMatrix4(camera.projectionMatrix);
|
|
1278
1285
|
deps.onSight(sights, { width: size.width, height: size.height, axis: { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height } });
|
|
1279
1286
|
}
|
package/dist/space/sight.d.ts
CHANGED
|
@@ -29,6 +29,12 @@ export interface SightInput {
|
|
|
29
29
|
r: number;
|
|
30
30
|
dx: number;
|
|
31
31
|
dy: number;
|
|
32
|
+
/** Degrees between the camera's forward direction and the body, 0 to 180, when the caller knows it. */
|
|
33
|
+
offAxis?: number;
|
|
34
|
+
/** How far the body is from the camera, in the view's units (Earth radii), when the caller knows it. */
|
|
35
|
+
distance?: number;
|
|
36
|
+
/** The same distance in kilometres in the true scale, `null` in the compressed one. */
|
|
37
|
+
distanceKm?: number | null;
|
|
32
38
|
}
|
|
33
39
|
/**
|
|
34
40
|
* Where a body is for the picture: `inView` when its disc is on the picture; otherwise the `edge` it lies beyond, and `x`, `y`, the point on that edge where a line from the middle of the view to the body crosses it, with
|
|
@@ -75,6 +81,23 @@ export declare function sightOf(input: SightInput, width: number, height: number
|
|
|
75
81
|
x: number;
|
|
76
82
|
y: number;
|
|
77
83
|
}): Sight;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a point of the picture is inside it less a margin on every side: `nx` and `ny` are its place from the middle in halves of the picture's width and height (-1 the left or top edge, 1 the right or bottom),
|
|
86
|
+
* and `margin` a fraction of the width for the left and right and of the height for the top and bottom. `turnTo` and a page's own "show" use the same test.
|
|
87
|
+
*
|
|
88
|
+
* @param nx - The place across, -1 to 1.
|
|
89
|
+
* @param ny - The place down, -1 to 1.
|
|
90
|
+
* @param margin - The fraction of each side kept clear, 0 to 0.5.
|
|
91
|
+
* @returns True when the point is inside the picture less the margin.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { withinMargin } from "@johnmorrisdotca/wakusei-planets/space";
|
|
96
|
+
*
|
|
97
|
+
* console.log(withinMargin(0.5, 0, 0.15), withinMargin(0.8, 0, 0.15));
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function withinMargin(nx: number, ny: number, margin: number): boolean;
|
|
78
101
|
/**
|
|
79
102
|
* How far, in CSS pixels, a body out of view moves along its edge before the view tells the page again.
|
|
80
103
|
*
|
package/dist/space/sight.js
CHANGED
|
@@ -40,6 +40,26 @@ export function sightOf(input, width, height, axis = { x: width / 2, y: height /
|
|
|
40
40
|
return { inView: false, behind: !input.front, edge, x, y, along: edge === "top" || edge === "bottom" ? x : y, angle: angleOf(dx, dy) };
|
|
41
41
|
}
|
|
42
42
|
const angleOf = (dx, dy) => (dx === 0 && dy === 0 ? 0 : ((Math.atan2(dx, -dy) * 180) / Math.PI + 360) % 360);
|
|
43
|
+
/**
|
|
44
|
+
* Whether a point of the picture is inside it less a margin on every side: `nx` and `ny` are its place from the middle in halves of the picture's width and height (-1 the left or top edge, 1 the right or bottom),
|
|
45
|
+
* and `margin` a fraction of the width for the left and right and of the height for the top and bottom. `turnTo` and a page's own "show" use the same test.
|
|
46
|
+
*
|
|
47
|
+
* @param nx - The place across, -1 to 1.
|
|
48
|
+
* @param ny - The place down, -1 to 1.
|
|
49
|
+
* @param margin - The fraction of each side kept clear, 0 to 0.5.
|
|
50
|
+
* @returns True when the point is inside the picture less the margin.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { withinMargin } from "@johnmorrisdotca/wakusei-planets/space";
|
|
55
|
+
*
|
|
56
|
+
* console.log(withinMargin(0.5, 0, 0.15), withinMargin(0.8, 0, 0.15));
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function withinMargin(nx, ny, margin) {
|
|
60
|
+
const inner = 1 - 2 * margin;
|
|
61
|
+
return Math.abs(nx) <= inner && Math.abs(ny) <= inner;
|
|
62
|
+
}
|
|
43
63
|
/**
|
|
44
64
|
* How far, in CSS pixels, a body out of view moves along its edge before the view tells the page again.
|
|
45
65
|
*
|
|
@@ -78,6 +78,13 @@ export declare class WakuseiSurface extends HTMLElement {
|
|
|
78
78
|
quality: string;
|
|
79
79
|
scale: number;
|
|
80
80
|
scaled: number;
|
|
81
|
+
landing: {
|
|
82
|
+
t: number;
|
|
83
|
+
playing: boolean;
|
|
84
|
+
camera: string;
|
|
85
|
+
altitude: number;
|
|
86
|
+
speed: number;
|
|
87
|
+
} | undefined;
|
|
81
88
|
vehicle: DriveState | undefined;
|
|
82
89
|
drawMs: number | undefined;
|
|
83
90
|
rocks: number;
|
|
@@ -109,6 +116,26 @@ export declare class WakuseiSurface extends HTMLElement {
|
|
|
109
116
|
throttle: number;
|
|
110
117
|
steer: number;
|
|
111
118
|
}): boolean;
|
|
119
|
+
/** The descent being watched: its clock in seconds from ignition, whether it runs, the camera and what the lunar module is doing at that moment; `undefined` when it is not watched. */
|
|
120
|
+
get landing(): {
|
|
121
|
+
t: number;
|
|
122
|
+
playing: boolean;
|
|
123
|
+
rate: number;
|
|
124
|
+
camera: "lander" | "ground";
|
|
125
|
+
altitude: number;
|
|
126
|
+
speed: number;
|
|
127
|
+
descent: number;
|
|
128
|
+
} | undefined;
|
|
129
|
+
/** The clock of the descent, in seconds from ignition (0 to 725). Setting it goes there at once, whether it runs or not. */
|
|
130
|
+
get landingTime(): number;
|
|
131
|
+
set landingTime(value: number);
|
|
132
|
+
/** How fast the descent runs: 1 is the real time of it (12 minutes 5 seconds); 2, 4 and 8 are quicker. */
|
|
133
|
+
get landingRate(): number;
|
|
134
|
+
set landingRate(value: number);
|
|
135
|
+
/** Run the descent from where the clock is (from the start again if it had ended). */
|
|
136
|
+
playLanding(): void;
|
|
137
|
+
/** Hold the descent where it is. */
|
|
138
|
+
pauseLanding(): void;
|
|
112
139
|
/** The things at the site, at their published places (none where the site has none or `objects="off"`). */
|
|
113
140
|
get objects(): readonly SiteObject[];
|
|
114
141
|
/**
|