@johnmorrisdotca/wakusei-planets 0.54.0 → 0.55.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 +14 -0
- package/README.md +3 -3
- package/dist/space/element.d.ts +19 -0
- package/dist/space/element.js +111 -6
- package/dist/space/hold.d.ts +217 -0
- package/dist/space/hold.js +248 -0
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +1 -0
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +67 -4
- package/dist/space/travel.d.ts +16 -4
- package/dist/space/travel.js +281 -18
- package/dist/surface/drive.d.ts +22 -4
- package/dist/surface/drive.js +11 -5
- package/dist/surface/element.d.ts +15 -1
- package/dist/surface/element.js +27 -2
- package/dist/surface/index.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.55.0] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
|
|
9
|
+
- **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.
|
|
10
|
+
|
|
11
|
+
- **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.
|
|
12
|
+
- **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.
|
|
13
|
+
- **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.
|
|
14
|
+
- **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.
|
|
15
|
+
- **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).
|
|
16
|
+
- 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).
|
|
17
|
+
- 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.
|
|
18
|
+
|
|
5
19
|
## [0.54.0] - 2026-11-14
|
|
6
20
|
|
|
7
21
|
- **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/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.55.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.55.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.
|
|
540
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.55.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
|
|
package/dist/space/element.d.ts
CHANGED
|
@@ -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;
|
package/dist/space/element.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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();
|
|
@@ -1487,6 +1539,50 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1487
1539
|
const centre = pos[host];
|
|
1488
1540
|
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
1541
|
}
|
|
1542
|
+
#frameTold = "stars||";
|
|
1543
|
+
/** Tell the page when the frame the camera is held in changes (`wakusei-frame`): after a draw, which has worked out what was held. */
|
|
1544
|
+
#announceFrame() {
|
|
1545
|
+
const drawn = this.#model.frameDrawn;
|
|
1546
|
+
const key = `${drawn.drawn}|${drawn.pair ?? ""}|`;
|
|
1547
|
+
if (key === this.#frameTold)
|
|
1548
|
+
return;
|
|
1549
|
+
const previous = this.#frameTold.split("|")[0];
|
|
1550
|
+
this.#frameTold = key;
|
|
1551
|
+
this.dispatchEvent(new CustomEvent("wakusei-frame", { detail: { frame: drawn.drawn, asked: drawn.asked, pair: drawn.pair, previous } }));
|
|
1552
|
+
}
|
|
1553
|
+
/**
|
|
1554
|
+
* 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
|
|
1555
|
+
* 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.
|
|
1556
|
+
*/
|
|
1557
|
+
#reanchor(dyaw, dtilt, view) {
|
|
1558
|
+
const model = this.#model;
|
|
1559
|
+
if (model.anchor === null)
|
|
1560
|
+
return;
|
|
1561
|
+
const was = model.holdBias !== null && model.holdBias.anchor === model.anchor ? model.holdBias : { yaw: 0, tilt: 0, up: [0, 1, 0] };
|
|
1562
|
+
const before = { yaw: view.yaw - dyaw + was.yaw, tilt: view.tilt - dtilt + was.tilt };
|
|
1563
|
+
const base = groundDirection(model.centre.lon - before.yaw, Math.max(-90, Math.min(90, model.centre.lat - before.tilt)), model.anchor);
|
|
1564
|
+
const held = heldAim(model, model.focus, base, was.up, model.mode, (id) => this.#site(id).at, 0);
|
|
1565
|
+
const aim = held.aim;
|
|
1566
|
+
// the stars' direction, taken from now, that looks from here once the drag has turned it
|
|
1567
|
+
const turned = controlsFor(aim, model.centre, model.time);
|
|
1568
|
+
const yaw = turned.yaw + dyaw;
|
|
1569
|
+
const tilt = turned.tilt + dtilt;
|
|
1570
|
+
model.anchor = model.time;
|
|
1571
|
+
model.holdBias = { anchor: model.time, yaw: yaw - view.yaw, tilt: tilt - view.tilt, up: held.up };
|
|
1572
|
+
}
|
|
1573
|
+
/** A move ends a pair unless it arrives with a companion, which becomes the pair. */
|
|
1574
|
+
#endPair() {
|
|
1575
|
+
const model = this.#model;
|
|
1576
|
+
if (model.frame !== "pair")
|
|
1577
|
+
return;
|
|
1578
|
+
if (model.companion !== null) {
|
|
1579
|
+
model.pairWith = model.companion;
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
model.frame = "stars";
|
|
1583
|
+
model.pairWith = null;
|
|
1584
|
+
this.#gate?.request();
|
|
1585
|
+
}
|
|
1490
1586
|
#siding = false;
|
|
1491
1587
|
/** The body the camera was at when the latest arrival was chosen, so that body can stay in the picture. */
|
|
1492
1588
|
#arrivedFrom = null;
|
|
@@ -1538,8 +1634,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1538
1634
|
const body = this.#site(id);
|
|
1539
1635
|
const sun = id === "sun" ? undefined : this.#site("sun").at;
|
|
1540
1636
|
const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 16 / 9;
|
|
1541
|
-
|
|
1542
|
-
|
|
1637
|
+
// 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
|
|
1638
|
+
const behind = swing && this.#arrivedFrom !== null && this.#arrivedFrom !== id ? this.#site(this.#arrivedFrom).at : undefined;
|
|
1639
|
+
const wanted = travelArrival({ body: body.at, radius: body.radius, from: model.camera.position, sun, aspect, companions: swing ? this.#companions(id) : [], ...(behind === undefined ? {} : { behind }) });
|
|
1640
|
+
// the body left, kept in the picture behind the body gone to, is the companion of that arrival
|
|
1641
|
+
model.companion = wanted.behind ? (wanted.companion ?? this.#arrivedFrom) : wanted.companion;
|
|
1543
1642
|
const side = [wanted.position[0] - body.at[0], wanted.position[1] - body.at[1], wanted.position[2] - body.at[2]];
|
|
1544
1643
|
const anchor = model.anchor ?? model.time;
|
|
1545
1644
|
// 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 +1669,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1570
1669
|
if (model.ride !== null)
|
|
1571
1670
|
this.ride(null, { smooth: false });
|
|
1572
1671
|
model.transition = this.#startMove(kind, model.region !== null ? "sun" : leaving, "sun", options.duration);
|
|
1672
|
+
model.companion = null;
|
|
1673
|
+
this.#endPair();
|
|
1573
1674
|
model.region = region;
|
|
1574
1675
|
this.#selected = "sun";
|
|
1575
1676
|
model.focus = "sun";
|
|
@@ -1715,6 +1816,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1715
1816
|
if (!wasRiding)
|
|
1716
1817
|
this.#focusBeforeRide = model.focus;
|
|
1717
1818
|
model.ride = found;
|
|
1819
|
+
// a ride arrives with no companion: it ends a pair
|
|
1820
|
+
model.companion = null;
|
|
1821
|
+
this.#endPair();
|
|
1718
1822
|
if (found.view === "follow" && typeof target === "string" && SPACE_BODIES.includes(target))
|
|
1719
1823
|
model.focus = target;
|
|
1720
1824
|
else if (wasRiding)
|
|
@@ -1974,6 +2078,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1974
2078
|
roadster: { shown: this.#model.roadsterDrawn.shown, position: this.#model.roadsterDrawn.position === null ? null : [...this.#model.roadsterDrawn.position], radiusPx: this.#model.roadsterDrawn.radiusPx },
|
|
1975
2079
|
spacecraft: { count: this.#model.craftDrawn.count, status: { ...this.#model.craftDrawn.status }, drawn: [...this.#model.craftDrawn.drawn] },
|
|
1976
2080
|
companion: this.#model.companion,
|
|
2081
|
+
frame: { asked: this.#model.frameDrawn.asked, frame: this.#model.frameDrawn.drawn, pair: this.#model.frameDrawn.pair },
|
|
1977
2082
|
moonSize: { asked: this.#model.moonSize, factor: this.#model.moonDrawn.factor, clamped: this.#model.moonDrawn.clamped },
|
|
1978
2083
|
pictures: { pending: picturesPending() },
|
|
1979
2084
|
};
|
|
@@ -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
|
+
};
|