@johnmorrisdotca/wakusei-planets 0.41.0 → 0.42.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 +8 -0
- package/README.md +3 -3
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +14 -1
- package/dist/space/element.js +86 -12
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +2 -2
- package/dist/space/scale.d.ts +27 -0
- package/dist/space/scale.js +49 -0
- package/dist/space/scene.d.ts +30 -1
- package/dist/space/scene.js +38 -3
- package/dist/space/travel.d.ts +55 -4
- package/dist/space/travel.js +105 -16
- 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,14 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.42.0] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **An arrival keeps a companion in the picture** (MODULES-1026). `arrivalSide` (and `travelArrival`, which uses it) stands on the side where the frame is not empty black: the body's own moons, or its planet when it is a moon; else the body the camera came from, or the nearest planet in that direction; else the Sun, only while at least half the body stays lit. A side that would turn the globe black is refused. `goTo` and a double click (the zoom jump to 1 or to 2) set the controls to that side; a drag afterwards is left as the reader set it. `stats.companion` names the body kept beside it, and that name is not dropped when names would otherwise clash. The swing is not applied to a straight move (`direct`, `look-back`), which keeps its destination in the picture the whole way.
|
|
8
|
+
|
|
9
|
+
- **Moons are larger than life in the squeezed view** (MODULES-989). `moon-size` on `<wakusei-space>` (and `space.moonSize`) is 2 by default: moons are drawn that many times their real radius, only while `scale` is `compressed`. 1 is today's size; 4 and 8 go further. True distances ignore it. Every moon of one planet takes the same factor, so they keep their real order of size. The factor is cut when a moon would be larger than a quarter of its planet, would touch the planet or its rings, or would reach the next moon's orbit, and `stats.moonSize` reports the factor used and `clamped`. Picking, the name on the body and the hidden-body rule use that drawn size. `moonSizeFactor` from `/space` is the same rule on plain numbers. A moon looked at, or gone to, is framed at the size it is drawn, so it still fits the view.
|
|
10
|
+
|
|
11
|
+
- **A page for the spacecraft** (MODULES-875). `craft.html` picks one of the eighteen craft, draws its path and where it is on a date, and lists the facts and the voyage. The craft's table loads only when it is chosen. The date plays when the page opens, and every time shown is the reader's own. English and Japanese.
|
|
12
|
+
|
|
5
13
|
## [0.41.0] - 2026-11-13
|
|
6
14
|
|
|
7
15
|
- **The name on a body reads on every body** (MODULES-983). One pale look for every body made the name vanish on Uranus, Venus, Saturn and the ice moons. The letters now take the tone that stands out: `body-label-tone` (and `tone` in `bodyLabel`) is `auto` by default, `light` or `dark`. Auto reads the body's own mean colour (`BODIES[id].colour`): dark letters (the `burned` look) when its relative luminance is above 0.5 (Venus, Saturn, Uranus, the Sun, Io, Europa, Enceladus, Tethys, Dione, Rhea, Triton, Hydra, Eris, Haumea), pale letters (`painted`) below it (Mars, the Moon, the Earth, Mercury, Jupiter, Neptune, Pluto and the rest); only a `painted` look is changed (to dark `burned` on a light body); `etched`, `burned` and `outline` are drawn as the page asked, and a forced `light` or `dark` wins over any look. The same rule on plain values is `nameTone(colour)` and `nameLabelLook(options, colour)` from `/painter`, and `stats.label.look` and `stats.bodyLabels.focus.look` report the look drawn. Picture test in `e2e/body-label.demo.ts` (realistic look, strength 0.5, name facing the reader): the letters' contrast (mean of the top 2 percent of brightness changes) on Uranus is 0.106 with pale letters, which is all origin/main draws, and 0.147 with dark ones; Venus 0.244 to 0.295, Saturn 0.242 to 0.346, Europa 0.237 to 0.297; the pale bodies are unchanged. The Moon (mean colour luminance 0.463) and Jupiter (0.492) stay pale, just under the line. Docs in English and Japanese.
|
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.42.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.42.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
|
|
|
@@ -534,7 +534,7 @@ BODIES.pluto.kind; // "dwarf-planet"
|
|
|
534
534
|
|
|
535
535
|
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:
|
|
536
536
|
|
|
537
|
-
> Morris, J. (2026). *Wakusei Planets* (version 0.
|
|
537
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.42.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
|
|
538
538
|
|
|
539
539
|
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).
|
|
540
540
|
|
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.42.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.42.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
|
@@ -257,6 +257,11 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
257
257
|
/** `true` (the default: real distances and sizes; a body too small to see is marked with a ring and its name) or `compressed` (every direction real, the distances squeezed). The scale in use is always named on the view. */
|
|
258
258
|
get scale(): ScaleMode;
|
|
259
259
|
set scale(value: ScaleMode);
|
|
260
|
+
/**
|
|
261
|
+
* How many times larger than life to draw moons in the squeezed scale (`moon-size`; 2 by default, from 1 to 8). 1 is the real size. Ignored at true distances. A moon is never drawn larger than a quarter of its planet, into the planet or its rings, or across to the next moon's orbit: every moon of one planet is reduced by the same factor, so they keep their order of size, and `stats.moonSize` says the factor used.
|
|
262
|
+
*/
|
|
263
|
+
get moonSize(): number;
|
|
264
|
+
set moonSize(value: number);
|
|
260
265
|
/** The words naming the scale on the view, for a page in another language (`{ true: "距離はそのまま" }`). A scale left out keeps its words in the element's `lang`. */
|
|
261
266
|
get scaleNames(): Partial<Record<ScaleMode, string>>;
|
|
262
267
|
set scaleNames(value: Partial<Record<ScaleMode, string>>);
|
|
@@ -398,7 +403,7 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
398
403
|
roll?: number;
|
|
399
404
|
panX?: number;
|
|
400
405
|
panY?: number;
|
|
401
|
-
}, final?: boolean): void;
|
|
406
|
+
}, final?: boolean, reason?: string): void;
|
|
402
407
|
/** The body the camera looks at: any body the view places, by name in any case (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`, and the moons of the planets such as `titan`). At zoom 1 it fills the view; the yaw and tilt turn the camera round it. Setting it moves the camera there at once and keeps the zoom; `goTo` glides and brings the body into view. */
|
|
403
408
|
get body(): BodyId;
|
|
404
409
|
set body(name: BodyId | string);
|
|
@@ -624,6 +629,12 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
624
629
|
position: [number, number, number] | null;
|
|
625
630
|
radiusPx: number;
|
|
626
631
|
};
|
|
632
|
+
/** How large the squeezed view drew the moons of the system in the middle: the factor asked for, the one used, and whether a limit cut it. At true distances `factor` is 1. */
|
|
633
|
+
moonSize: {
|
|
634
|
+
asked: number;
|
|
635
|
+
factor: number;
|
|
636
|
+
clamped: boolean;
|
|
637
|
+
};
|
|
627
638
|
/** The orbiters at the last draw: how many dots were drawn (their body big enough on the screen), each drawn craft's status (`tracked`, `predicted`, `modelled`); `dim` lists the craft drawn dim (`orbiterDim` from `/orbiters`); `lines` how many orbit lines and `track` how many points of ground track were drawn. */
|
|
628
639
|
orbiters: {
|
|
629
640
|
count: number;
|
|
@@ -632,6 +643,8 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
632
643
|
lines: number;
|
|
633
644
|
track: number;
|
|
634
645
|
};
|
|
646
|
+
/** The body the last arrival kept in the picture beside the one gone to, or null. */
|
|
647
|
+
companion: string | null;
|
|
635
648
|
};
|
|
636
649
|
/** 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. */
|
|
637
650
|
placeOf(id: BodyId): BodyPlace | null;
|
package/dist/space/element.js
CHANGED
|
@@ -17,7 +17,7 @@ import { setThreeLoader, takeRenderer } from "../scene/shared.js";
|
|
|
17
17
|
import { texturePaths, tilesBase } from "../scene/textures.js";
|
|
18
18
|
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
19
19
|
import { moonOffset, orientation } from "../scene/orient.js";
|
|
20
|
-
import { moonDistance, placeBodies, radiusIn } from "./scale.js";
|
|
20
|
+
import { moonDistance, placeBodies, radiusIn, readMoonSize } from "./scale.js";
|
|
21
21
|
import { groundDirection } from "./aim.js";
|
|
22
22
|
import { besideMoon } from "./beside.js";
|
|
23
23
|
import { SUN_REGIONS } from "./regions.js";
|
|
@@ -26,8 +26,8 @@ import { findPlace, PLACE_BODIES } from "../places.js";
|
|
|
26
26
|
import { placeMarks, pointUnder, readPlaceLayers, spotView } from "../place-marks.js";
|
|
27
27
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
28
28
|
import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
|
|
29
|
-
import { cross, dot } from "../vec.js";
|
|
30
|
-
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
29
|
+
import { cross, dot, length, sub, unit } from "../vec.js";
|
|
30
|
+
import { createSpaceItem, FIT_DISTANCE, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
31
31
|
import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
|
|
32
32
|
export { setPlacesLoader } from "../scene/place-layer.js";
|
|
33
33
|
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "../scene/earth-places.js";
|
|
@@ -140,7 +140,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
|
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
142
|
export class WakuseiSpace extends HTMLElement {
|
|
143
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", ...NAME_LABEL_ATTRIBUTES];
|
|
143
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
144
144
|
#model = newSpaceModel();
|
|
145
145
|
#allMoons = false;
|
|
146
146
|
#catalogue;
|
|
@@ -204,6 +204,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
204
204
|
this.#clock = createGameClock(readTime(this.getAttribute("time")), this.#readSpeed());
|
|
205
205
|
this.#model.time = this.#clock.time;
|
|
206
206
|
this.#model.mode = this.getAttribute("scale") === "compressed" ? "compressed" : "true";
|
|
207
|
+
this.#model.moonSize = readMoonSize(this.getAttribute("moon-size") ?? 2);
|
|
207
208
|
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
208
209
|
this.#labelsAlways = this.hasAttribute("labels-always") && this.getAttribute("labels-always") !== "off";
|
|
209
210
|
this.#covered = this.getAttribute("covered") === "arrow" ? "arrow" : "name";
|
|
@@ -297,7 +298,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
297
298
|
this.addEventListener("pointerleave", this.#leave);
|
|
298
299
|
// before the shared hands (which hear it after this): a plain wheel in an immersive view zooms
|
|
299
300
|
this.addEventListener("wheel", this.#wheel, { capture: true, passive: false });
|
|
300
|
-
this.#hands = carryControls(this, { limits: CARRIED_LIMITS, onChange: (view, info) => this.setView(view, info.final) });
|
|
301
|
+
this.#hands = carryControls(this, { limits: CARRIED_LIMITS, onChange: (view, info) => this.setView(view, info.final, info.reason) });
|
|
301
302
|
this.#markHeard = onPlacesLoader(() => {
|
|
302
303
|
this.#markList = undefined;
|
|
303
304
|
this.#markSurface();
|
|
@@ -351,6 +352,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
351
352
|
this.speed = this.#readSpeed();
|
|
352
353
|
else if (name === "scale")
|
|
353
354
|
this.scale = value === "compressed" ? "compressed" : "true";
|
|
355
|
+
else if (name === "moon-size")
|
|
356
|
+
this.moonSize = readMoonSize(value);
|
|
354
357
|
else if (name === "labels")
|
|
355
358
|
this.labels = value !== "off";
|
|
356
359
|
else if (name === "labels-always")
|
|
@@ -701,6 +704,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
701
704
|
this.#nameScale();
|
|
702
705
|
this.#gate?.request();
|
|
703
706
|
}
|
|
707
|
+
/**
|
|
708
|
+
* How many times larger than life to draw moons in the squeezed scale (`moon-size`; 2 by default, from 1 to 8). 1 is the real size. Ignored at true distances. A moon is never drawn larger than a quarter of its planet, into the planet or its rings, or across to the next moon's orbit: every moon of one planet is reduced by the same factor, so they keep their order of size, and `stats.moonSize` says the factor used.
|
|
709
|
+
*/
|
|
710
|
+
get moonSize() {
|
|
711
|
+
return this.#model.moonSize;
|
|
712
|
+
}
|
|
713
|
+
set moonSize(value) {
|
|
714
|
+
this.#model.moonSize = readMoonSize(value);
|
|
715
|
+
this.#gate?.request();
|
|
716
|
+
}
|
|
704
717
|
/** The words naming the scale on the view, for a page in another language (`{ true: "距離はそのまま" }`). A scale left out keeps its words in the element's `lang`. */
|
|
705
718
|
get scaleNames() {
|
|
706
719
|
return { ...this.#scaleNames };
|
|
@@ -1036,7 +1049,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1036
1049
|
* @param view - The controls' yaw and tilt in degrees and zoom.
|
|
1037
1050
|
* @param final - False for the frames of a turn that is still going on (Auto-turn, a drag); true when it has settled.
|
|
1038
1051
|
*/
|
|
1039
|
-
setView(view, final = true) {
|
|
1052
|
+
setView(view, final = true, reason) {
|
|
1040
1053
|
const now = this.#model.view;
|
|
1041
1054
|
if (this.#model.region !== null && view.zoom !== 1) {
|
|
1042
1055
|
// at a stage out from the Sun a zoom gesture is a step: out to the next stage, in to the one before (or the Sun); one gesture, one step, and the controls go back to holding zoom 1 (the element's own
|
|
@@ -1058,6 +1071,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1058
1071
|
const [roll, panX, panY] = [view.roll ?? 0, view.panX ?? 0, view.panY ?? 0];
|
|
1059
1072
|
if (view.yaw === now.yaw && view.tilt === now.tilt && view.zoom === now.zoom && roll === now.roll && panX === now.panX && panY === now.panY)
|
|
1060
1073
|
return;
|
|
1074
|
+
// a double click jumps the zoom to 1 or to 2: stand so a companion is in the picture. A drag, a wheel step or the side just chosen does not.
|
|
1075
|
+
if (!this.#siding && reason === "zoom" && (view.zoom === 1 || view.zoom === 2) && Math.abs(view.zoom - now.zoom) > 0.4 && this.#model.pose.valid) {
|
|
1076
|
+
const side = this.#faceApproach(this.#model.focus);
|
|
1077
|
+
if (side) {
|
|
1078
|
+
this.#siding = true;
|
|
1079
|
+
this.#hands?.controller.set({ ...side, zoom: view.zoom, roll, panX: 0, panY: 0 }, true, "set");
|
|
1080
|
+
this.#siding = false;
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1061
1084
|
this.#model.view = { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY };
|
|
1062
1085
|
this.dispatchEvent(new CustomEvent("wakusei-view", { detail: { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY } }));
|
|
1063
1086
|
const drawn = this.#model.drawnView;
|
|
@@ -1113,6 +1136,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1113
1136
|
return false;
|
|
1114
1137
|
const model = this.#model;
|
|
1115
1138
|
const leaving = this.#leaving();
|
|
1139
|
+
this.#arrivedFrom = leaving;
|
|
1116
1140
|
const kind = this.#moveKind(options, id);
|
|
1117
1141
|
if (model.ride !== null)
|
|
1118
1142
|
this.ride(null, { smooth: false });
|
|
@@ -1123,7 +1147,10 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1123
1147
|
this.#model.focus = id;
|
|
1124
1148
|
const zoom = options.zoom ?? 1;
|
|
1125
1149
|
// the side the camera comes from, as the controls' yaw and tilt: the element's own hands are set to it here, and a bar bound to the element (which holds the view's state) hears it in the event with the zoom
|
|
1126
|
-
|
|
1150
|
+
// 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
|
|
1151
|
+
// works round the planet in a way that never leaves the picture empty (`travelPlan`).
|
|
1152
|
+
const swing = kind === "cut" || kind === "turn-travel";
|
|
1153
|
+
const side = this.#faceApproach(id, swing);
|
|
1127
1154
|
if (!this.hasAttribute("data-kazoku-bar"))
|
|
1128
1155
|
this.#hands?.controller.set(side ? { ...side, zoom } : { zoom }, true, "jump");
|
|
1129
1156
|
this.#schedule();
|
|
@@ -1184,19 +1211,61 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1184
1211
|
const d = Math.hypot(real[0], real[1], real[2]);
|
|
1185
1212
|
const k = (d === 0 ? 1 : moonDistance(mode, host, d) / d) * radiusIn(host, mode);
|
|
1186
1213
|
const centre = pos[host];
|
|
1187
|
-
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)) };
|
|
1214
|
+
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) };
|
|
1215
|
+
}
|
|
1216
|
+
#siding = false;
|
|
1217
|
+
/** The body the camera was at when the latest arrival was chosen, so that body can stay in the picture. */
|
|
1218
|
+
#arrivedFrom = null;
|
|
1219
|
+
/** Moons or the planet first, then the body left or the planet nearest that way, then the Sun. */
|
|
1220
|
+
#companions(id) {
|
|
1221
|
+
const out = [];
|
|
1222
|
+
const seen = new Set();
|
|
1223
|
+
const add = (body, rank) => {
|
|
1224
|
+
if (body === id || seen.has(body))
|
|
1225
|
+
return;
|
|
1226
|
+
seen.add(body);
|
|
1227
|
+
out.push({ id: body, at: this.#site(body).at, rank });
|
|
1228
|
+
};
|
|
1229
|
+
const host = hostOf(id);
|
|
1230
|
+
if (host !== undefined)
|
|
1231
|
+
add(host, 1);
|
|
1232
|
+
for (const moon of MOONS_OF[id] ?? [])
|
|
1233
|
+
add(moon, 1);
|
|
1234
|
+
if (this.#arrivedFrom !== null)
|
|
1235
|
+
add(this.#arrivedFrom, 2);
|
|
1236
|
+
const here = this.#site(id).at;
|
|
1237
|
+
const from = sub(this.#model.camera.position, here);
|
|
1238
|
+
const approach = length(from) < 1e-9 ? [0, 0, 1] : unit(from);
|
|
1239
|
+
let nearest = null;
|
|
1240
|
+
for (const planet of ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"]) {
|
|
1241
|
+
if (planet === id)
|
|
1242
|
+
continue;
|
|
1243
|
+
const away = sub(this.#site(planet).at, here);
|
|
1244
|
+
if (length(away) < 1e-9)
|
|
1245
|
+
continue;
|
|
1246
|
+
const score = dot(unit(away), approach);
|
|
1247
|
+
if (score > 0.15 && (nearest === null || score > nearest.score))
|
|
1248
|
+
nearest = { id: planet, score };
|
|
1249
|
+
}
|
|
1250
|
+
if (nearest !== null)
|
|
1251
|
+
add(nearest.id, 2);
|
|
1252
|
+
if (id !== "sun")
|
|
1253
|
+
add("sun", 3);
|
|
1254
|
+
return out;
|
|
1188
1255
|
}
|
|
1189
1256
|
/**
|
|
1190
|
-
* The controls' yaw and tilt that look at a body from the side the camera comes from
|
|
1191
|
-
*
|
|
1257
|
+
* The controls' yaw and tilt that look at a body from the side the camera comes from, swung so a companion is in the picture and the body stays at least half lit; null when the camera has not drawn yet.
|
|
1258
|
+
* The reader's own later turn is not touched: this runs for an arrival and for a double click, not for a drag.
|
|
1192
1259
|
*/
|
|
1193
|
-
#faceApproach(id) {
|
|
1260
|
+
#faceApproach(id, swing = true) {
|
|
1194
1261
|
const model = this.#model;
|
|
1195
1262
|
if (!model.pose.valid)
|
|
1196
1263
|
return null;
|
|
1197
1264
|
const body = this.#site(id);
|
|
1198
1265
|
const sun = id === "sun" ? undefined : this.#site("sun").at;
|
|
1199
|
-
const
|
|
1266
|
+
const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 16 / 9;
|
|
1267
|
+
const wanted = travelArrival({ body: body.at, radius: body.radius, from: model.camera.position, sun, aspect, companions: swing ? this.#companions(id) : [] });
|
|
1268
|
+
model.companion = wanted.companion;
|
|
1200
1269
|
const side = [wanted.position[0] - body.at[0], wanted.position[1] - body.at[1], wanted.position[2] - body.at[2]];
|
|
1201
1270
|
const anchor = model.anchor ?? model.time;
|
|
1202
1271
|
// 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
|
|
@@ -1629,6 +1698,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1629
1698
|
bodyLabels: { count: this.#model.labelsDrawn.count, focus: this.#model.labelsDrawn.focus === null ? null : { ...this.#model.labelsDrawn.focus } },
|
|
1630
1699
|
orbiters: { count: this.#model.orbitersDrawn.count, status: { ...this.#model.orbitersDrawn.status }, dim: [...this.#model.orbitersDrawn.dim], lines: this.#model.orbitersDrawn.lines, track: this.#model.orbitersDrawn.track },
|
|
1631
1700
|
roadster: { shown: this.#model.roadsterDrawn.shown, position: this.#model.roadsterDrawn.position === null ? null : [...this.#model.roadsterDrawn.position], radiusPx: this.#model.roadsterDrawn.radiusPx },
|
|
1701
|
+
companion: this.#model.companion,
|
|
1702
|
+
moonSize: { asked: this.#model.moonSize, factor: this.#model.moonDrawn.factor, clamped: this.#model.moonDrawn.clamped },
|
|
1632
1703
|
};
|
|
1633
1704
|
}
|
|
1634
1705
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
@@ -1729,6 +1800,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1729
1800
|
}
|
|
1730
1801
|
// no two names overlap: a moon gives way to its planet and a planet to the Sun
|
|
1731
1802
|
const shown = chooseLabels(wanted);
|
|
1803
|
+
const companion = this.#model.companion;
|
|
1804
|
+
if (companion !== null && spots.has(companion))
|
|
1805
|
+
shown.add(companion);
|
|
1732
1806
|
this.#nameBoxes = wanted.filter((one) => shown.has(one.id));
|
|
1733
1807
|
for (const id of ids) {
|
|
1734
1808
|
const label = this.#pool.get(id);
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS, type SpaceDwarf, type SpaceFrame, type SpaceMinor, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
2
|
-
export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition, type ScaleMode } from "./scale.ts";
|
|
2
|
+
export { compress, MOON_COMPRESSED, moonDistance, moonSizeFactor, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition, type ScaleMode } from "./scale.ts";
|
|
3
3
|
export { groundDirection } from "./aim.ts";
|
|
4
4
|
export { RIDE_FOV, ridePose, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
5
5
|
export { chooseLabels, LABEL_GAP, nameSpot, type LabelBox } from "./labels.ts";
|
|
@@ -8,6 +8,6 @@ export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from ".
|
|
|
8
8
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
|
|
9
9
|
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
|
-
export { TRAVEL_CLEARANCE, travelArrival, travelPlan, travelPose, type TravelBody, type TravelInput, type TravelKind, type TravelPlan, type TravelSample, type TravelSight, type TravelView } from "./travel.ts";
|
|
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
13
|
export { SIGHT_STEP_PX, sightChanged, sightOf, type Sight, type SightEdge, type SightInput } from "./sight.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The space view's pure parts: where the bodies are (this package's own models), the two scales and, for riding along, where a camera looks. They import on a server. The element is `@johnmorrisdotca/wakusei-planets/space/element`.
|
|
2
2
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
3
|
-
export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
3
|
+
export { compress, MOON_COMPRESSED, moonDistance, moonSizeFactor, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
4
4
|
export { groundDirection } from "./aim.js";
|
|
5
5
|
export { RIDE_FOV, ridePose } from "./ride.js";
|
|
6
6
|
export { chooseLabels, LABEL_GAP, nameSpot } from "./labels.js";
|
|
@@ -9,6 +9,6 @@ export { besideMoon, BESIDE_RADII } from "./beside.js";
|
|
|
9
9
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
|
|
10
10
|
export { spinAxis } from "./spin.js";
|
|
11
11
|
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy } from "./covered.js";
|
|
12
|
-
export { TRAVEL_CLEARANCE, travelArrival, travelPlan, travelPose } from "./travel.js";
|
|
12
|
+
export { TRAVEL_CLEARANCE, arrivalSide, travelArrival, travelPlan, travelPose } from "./travel.js";
|
|
13
13
|
export { regionOrbits, regionView, SUN_REGIONS } from "./regions.js";
|
|
14
14
|
export { SIGHT_STEP_PX, sightChanged, sightOf } from "./sight.js";
|
package/dist/space/scale.d.ts
CHANGED
|
@@ -143,6 +143,33 @@ export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | Sp
|
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
145
|
export declare function moonDistance(mode: ScaleMode, host: SpacePlanet | SpaceDwarf, distance: number): number;
|
|
146
|
+
/** The squeezed view draws moons this many times their real size, unless a moon would pass a limit. 1 is today's size. True distances ignore it. */
|
|
147
|
+
export declare const MOON_SIZE_DEFAULT = 2;
|
|
148
|
+
/**
|
|
149
|
+
* How many times larger than life to draw a planet's moons in the squeezed view. Every moon gets the same factor, so they keep their real order of size. The factor is the one asked for, or less when that would draw a moon bigger than a quarter of its planet, into the planet or its rings, or across to the next moon's orbit. True scale always returns 1 and is not clamped.
|
|
150
|
+
*
|
|
151
|
+
* @param mode - The scale. `true` ignores `size`.
|
|
152
|
+
* @param host - The planet the moons go round.
|
|
153
|
+
* @param size - The factor asked for (1, 2, 4, 8, or any number from 1 to 8).
|
|
154
|
+
* @param moons - Each moon's radius and orbital distance, both in radii of the planet. The distance is the one `moonDistance` draws.
|
|
155
|
+
* @returns The factor to use, and whether it is less than the one asked for.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* import { moonSizeFactor } from "@johnmorrisdotca/wakusei-planets/space";
|
|
160
|
+
*
|
|
161
|
+
* console.log(moonSizeFactor("true", "jupiter", 4, [{ radius: 0.04, orbit: 6 }]).factor);
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export declare function moonSizeFactor(mode: ScaleMode, host: SpacePlanet | SpaceDwarf, size: number, moons: readonly {
|
|
165
|
+
radius: number;
|
|
166
|
+
orbit: number;
|
|
167
|
+
}[]): {
|
|
168
|
+
factor: number;
|
|
169
|
+
clamped: boolean;
|
|
170
|
+
};
|
|
171
|
+
/** Read a `moon-size` attribute or property: a number from 1 to 8, or 2 when it is missing or not a number. */
|
|
172
|
+
export declare function readMoonSize(value: string | number | null | undefined): number;
|
|
146
173
|
/**
|
|
147
174
|
* Where every body of the view is, in Earth radii from the Earth's centre, at one moment: the Earth at the centre, the Moon, the Sun and the planets. The same mapping places
|
|
148
175
|
* the bodies and the lines of their orbits (`orbitLine`), so a body is always on its own orbit.
|
package/dist/space/scale.js
CHANGED
|
@@ -204,6 +204,55 @@ export function moonDistance(mode, host, distance) {
|
|
|
204
204
|
const far = Math.max(space / radius, near * 1.6);
|
|
205
205
|
return Math.min(distance, near + (far - near) * Math.sqrt(distance / reach));
|
|
206
206
|
}
|
|
207
|
+
/** The squeezed view draws moons this many times their real size, unless a moon would pass a limit. 1 is today's size. True distances ignore it. */
|
|
208
|
+
export const MOON_SIZE_DEFAULT = 2;
|
|
209
|
+
/**
|
|
210
|
+
* How many times larger than life to draw a planet's moons in the squeezed view. Every moon gets the same factor, so they keep their real order of size. The factor is the one asked for, or less when that would draw a moon bigger than a quarter of its planet, into the planet or its rings, or across to the next moon's orbit. True scale always returns 1 and is not clamped.
|
|
211
|
+
*
|
|
212
|
+
* @param mode - The scale. `true` ignores `size`.
|
|
213
|
+
* @param host - The planet the moons go round.
|
|
214
|
+
* @param size - The factor asked for (1, 2, 4, 8, or any number from 1 to 8).
|
|
215
|
+
* @param moons - Each moon's radius and orbital distance, both in radii of the planet. The distance is the one `moonDistance` draws.
|
|
216
|
+
* @returns The factor to use, and whether it is less than the one asked for.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* import { moonSizeFactor } from "@johnmorrisdotca/wakusei-planets/space";
|
|
221
|
+
*
|
|
222
|
+
* console.log(moonSizeFactor("true", "jupiter", 4, [{ radius: 0.04, orbit: 6 }]).factor);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
export function moonSizeFactor(mode, host, size, moons) {
|
|
226
|
+
if (mode !== "compressed")
|
|
227
|
+
return { factor: 1, clamped: false };
|
|
228
|
+
const asked = Math.min(8, Math.max(1, Number.isFinite(size) ? size : MOON_SIZE_DEFAULT));
|
|
229
|
+
const bands = BODIES[host].rings ?? [];
|
|
230
|
+
const ringOuter = bands.length === 0 ? 0 : Math.max(...bands.map((band) => band.to)) / BODIES[host].radiusKm;
|
|
231
|
+
let factor = asked;
|
|
232
|
+
for (const moon of moons) {
|
|
233
|
+
if (!(moon.radius > 0))
|
|
234
|
+
continue;
|
|
235
|
+
let cap = 0.25;
|
|
236
|
+
cap = Math.min(cap, Math.max(moon.radius, moon.orbit - 1.05));
|
|
237
|
+
if (ringOuter > 0 && moon.orbit > ringOuter + 0.05)
|
|
238
|
+
cap = Math.min(cap, Math.max(moon.radius, moon.orbit - ringOuter - 0.05));
|
|
239
|
+
for (const other of moons) {
|
|
240
|
+
if (other === moon)
|
|
241
|
+
continue;
|
|
242
|
+
cap = Math.min(cap, Math.max(moon.radius, Math.abs(moon.orbit - other.orbit) * 0.9));
|
|
243
|
+
}
|
|
244
|
+
factor = Math.min(factor, cap / moon.radius);
|
|
245
|
+
}
|
|
246
|
+
factor = Math.max(1, factor);
|
|
247
|
+
return { factor, clamped: factor + 1e-6 < asked };
|
|
248
|
+
}
|
|
249
|
+
/** Read a `moon-size` attribute or property: a number from 1 to 8, or 2 when it is missing or not a number. */
|
|
250
|
+
export function readMoonSize(value) {
|
|
251
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
252
|
+
if (!Number.isFinite(n))
|
|
253
|
+
return MOON_SIZE_DEFAULT;
|
|
254
|
+
return Math.min(8, Math.max(1, n));
|
|
255
|
+
}
|
|
207
256
|
/** The nearest a moon is drawn to its planet in a compressed view, in the planet's radii: outside the globe, and outside its rings with a little room, so the moon never sits in the ring plane. */
|
|
208
257
|
function nearestOf(host) {
|
|
209
258
|
const facts = BODIES[host];
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ import "../bodies/all.ts";
|
|
|
10
10
|
import { type Vec3 } from "../vec.ts";
|
|
11
11
|
import { type OrbitArrow } from "./arrows.ts";
|
|
12
12
|
import type { SightInput } from "./sight.ts";
|
|
13
|
-
import { type SpaceFrame, type SpaceVec3 } from "./frame.ts";
|
|
13
|
+
import { type SpaceDwarf, type SpaceFrame, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
14
14
|
import { type PaintSpec, type PaintTrail } from "../paint/trail.ts";
|
|
15
15
|
import { type RideLook } from "./ride.ts";
|
|
16
16
|
import { type ScaleMode } from "./scale.ts";
|
|
@@ -166,6 +166,15 @@ export interface SpaceModel {
|
|
|
166
166
|
speed: number;
|
|
167
167
|
/** The body the camera looks at, and (in `zoom`) fills the view with at 1x: any body the package knows that the view can place (the eleven of `SPACE_BODIES` and the moons of the planets). */
|
|
168
168
|
focus: BodyId;
|
|
169
|
+
/** The body kept in the picture beside the one arrived at, or null. Its name is not dropped for a clash. */
|
|
170
|
+
companion: string | null;
|
|
171
|
+
/** How many times larger than life the squeezed view draws moons. Ignored at true distances. 2 by default. */
|
|
172
|
+
moonSize: number;
|
|
173
|
+
/** The factor actually used for the system in the middle, and whether a limit cut the one asked for. */
|
|
174
|
+
moonDrawn: {
|
|
175
|
+
factor: number;
|
|
176
|
+
clamped: boolean;
|
|
177
|
+
};
|
|
169
178
|
light: SpaceLight;
|
|
170
179
|
/** How the painter draws the bodies (`realistic` or `painted`). */
|
|
171
180
|
look: string;
|
|
@@ -436,4 +445,24 @@ export interface SpaceDeps {
|
|
|
436
445
|
/** The painter could not make a body (the three.js parts handed over lack something it needs). */
|
|
437
446
|
onPainterError?: (error: unknown) => void;
|
|
438
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* The factor the squeezed view draws the moons of one planet at (1 at true distances), worked out from the planet's moons as the drawing does, so a camera that frames a moon frames the size it is drawn.
|
|
450
|
+
*
|
|
451
|
+
* @param mode - The scale.
|
|
452
|
+
* @param host - The planet or dwarf planet the moons go round.
|
|
453
|
+
* @param size - The `moon-size` asked for.
|
|
454
|
+
* @param time - The moment, in milliseconds, that sets where the moons are.
|
|
455
|
+
* @returns The factor used, and whether a limit cut it.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```ts no-run
|
|
459
|
+
* import { moonScaleFor } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
460
|
+
*
|
|
461
|
+
* console.log(moonScaleFor("compressed", "jupiter", 4, Date.UTC(2026, 10, 11)).factor);
|
|
462
|
+
* ```
|
|
463
|
+
*/
|
|
464
|
+
export declare function moonScaleFor(mode: ScaleMode, host: SpacePlanet | SpaceDwarf, size: number, time: number): {
|
|
465
|
+
factor: number;
|
|
466
|
+
clamped: boolean;
|
|
467
|
+
};
|
|
439
468
|
export declare function createSpaceItem(model: SpaceModel, deps: SpaceDeps): Item3D<ThreeParts>;
|
package/dist/space/scene.js
CHANGED
|
@@ -18,7 +18,7 @@ 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";
|
|
20
20
|
import { ridePose } from "./ride.js";
|
|
21
|
-
import { moonDistance, orbitLine, placeAround, placeBodies, placeMoon, radiusIn } from "./scale.js";
|
|
21
|
+
import { moonDistance, moonSizeFactor, orbitLine, placeAround, placeBodies, placeMoon, radiusIn } from "./scale.js";
|
|
22
22
|
import { regionOrbits, regionView } from "./regions.js";
|
|
23
23
|
import { travelPlan, travelPose } from "./travel.js";
|
|
24
24
|
const RAD = Math.PI / 180;
|
|
@@ -83,6 +83,9 @@ export const newSpaceModel = () => ({
|
|
|
83
83
|
stepMs: 1000,
|
|
84
84
|
speed: 1,
|
|
85
85
|
focus: "earth",
|
|
86
|
+
companion: null,
|
|
87
|
+
moonSize: 2,
|
|
88
|
+
moonDrawn: { factor: 1, clamped: false },
|
|
86
89
|
light: "sun",
|
|
87
90
|
look: "realistic",
|
|
88
91
|
drawn: null,
|
|
@@ -128,6 +131,29 @@ export const newSpaceModel = () => ({
|
|
|
128
131
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
129
132
|
});
|
|
130
133
|
const minus = (a, b) => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
|
134
|
+
/**
|
|
135
|
+
* The factor the squeezed view draws the moons of one planet at (1 at true distances), worked out from the planet's moons as the drawing does, so a camera that frames a moon frames the size it is drawn.
|
|
136
|
+
*
|
|
137
|
+
* @param mode - The scale.
|
|
138
|
+
* @param host - The planet or dwarf planet the moons go round.
|
|
139
|
+
* @param size - The `moon-size` asked for.
|
|
140
|
+
* @param time - The moment, in milliseconds, that sets where the moons are.
|
|
141
|
+
* @returns The factor used, and whether a limit cut it.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts no-run
|
|
145
|
+
* import { moonScaleFor } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
146
|
+
*
|
|
147
|
+
* console.log(moonScaleFor("compressed", "jupiter", 4, Date.UTC(2026, 10, 11)).factor);
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export function moonScaleFor(mode, host, size, time) {
|
|
151
|
+
const moons = (MOONS_OF[host] ?? []).map((moon) => {
|
|
152
|
+
const offset = moonOffset(moon, time);
|
|
153
|
+
return { radius: BODIES[moon].radiusKm / BODIES[host].radiusKm, orbit: moonDistance(mode, host, Math.hypot(offset[0], offset[1], offset[2])) };
|
|
154
|
+
});
|
|
155
|
+
return moonSizeFactor(mode, host, size, moons);
|
|
156
|
+
}
|
|
131
157
|
/** How far a place is from the nearest point of a line through `points`, in the line's units. */
|
|
132
158
|
const plus = (a, b) => [a[0] + b[0], a[1] + b[1], a[2] + b[2]];
|
|
133
159
|
function distanceToLine(place, points) {
|
|
@@ -391,7 +417,8 @@ export function createSpaceItem(model, deps) {
|
|
|
391
417
|
const offset = moonSite(focus, model.time, host);
|
|
392
418
|
const hostRadius = radiusOf(host);
|
|
393
419
|
focusPos = [pos[host][0] + offset[0] * hostRadius, pos[host][1] + offset[1] * hostRadius, pos[host][2] + offset[2] * hostRadius];
|
|
394
|
-
|
|
420
|
+
// a moon the view draws larger than life is framed at the size it is drawn
|
|
421
|
+
focusRadius = Math.max(1e-9, (BODIES[focus].radiusKm / BODIES[host].radiusKm) * hostRadius * moonScaleFor(mode, host, model.moonSize, model.time).factor);
|
|
395
422
|
}
|
|
396
423
|
let aimWay = 1;
|
|
397
424
|
let besideIn = null;
|
|
@@ -1020,6 +1047,9 @@ export function createSpaceItem(model, deps) {
|
|
|
1020
1047
|
if (!planet)
|
|
1021
1048
|
continue;
|
|
1022
1049
|
const sites = (MOONS_OF[id] ?? []).map((moon) => ({ name: moon, offset: moonOffset(moon, model.time), radius: BODIES[moon].radiusKm / BODIES[id].radiusKm }));
|
|
1050
|
+
const sized = moonSizeFactor(mode, id, model.moonSize, sites.map((site) => ({ radius: site.radius, orbit: moonDistance(mode, id, Math.hypot(site.offset[0], site.offset[1], site.offset[2])) })));
|
|
1051
|
+
if (id === model.focus || hostOf(model.focus) === id)
|
|
1052
|
+
model.moonDrawn = { factor: sized.factor, clamped: sized.clamped };
|
|
1023
1053
|
// the moons are shown once the planet is a few pixels across, or the system round it is wide enough on the screen to tell its moons from the planet, or one of its moons is the body looked at
|
|
1024
1054
|
let spread = 1;
|
|
1025
1055
|
for (const site of sites)
|
|
@@ -1048,7 +1078,12 @@ export function createSpaceItem(model, deps) {
|
|
|
1048
1078
|
if (!drawing)
|
|
1049
1079
|
continue;
|
|
1050
1080
|
const away = Math.hypot(at[0] - camera.position.x, at[1] - camera.position.y, at[2] - camera.position.z);
|
|
1051
|
-
const
|
|
1081
|
+
const floor = (away * half * MOON_MIN_PX) / (size.height / 2);
|
|
1082
|
+
const wanted = Math.max(site.radius * radius, floor) * sized.factor;
|
|
1083
|
+
const cap = 0.25 * radius;
|
|
1084
|
+
const drawn = Math.min(wanted, cap);
|
|
1085
|
+
if (drawn + 1e-4 < wanted && (id === model.focus || hostOf(model.focus) === id))
|
|
1086
|
+
model.moonDrawn = { factor: sized.factor, clamped: true };
|
|
1052
1087
|
drawing.object.visible = true;
|
|
1053
1088
|
drawing.object.position.set(at[0], at[1], at[2]);
|
|
1054
1089
|
drawing.object.scale.setScalar(drawn);
|
package/dist/space/travel.d.ts
CHANGED
|
@@ -226,13 +226,62 @@ export declare function travelPlan(input: TravelInput): TravelPlan;
|
|
|
226
226
|
* ```
|
|
227
227
|
*/
|
|
228
228
|
export declare function travelPose(input: TravelInput, t: number, plan?: TravelPlan): TravelSample;
|
|
229
|
+
/**
|
|
230
|
+
* One body that might keep an arrival from being an empty black picture: where it is, and which rule it belongs to.
|
|
231
|
+
* `1` is the body's own moon, or its planet when the body is a moon. `2` is the body the camera came from, or the nearest planet in that direction. `3` is the Sun.
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```ts
|
|
235
|
+
* import type { ArrivalCompanion } from "@johnmorrisdotca/wakusei-planets/space";
|
|
236
|
+
*
|
|
237
|
+
* const moon: ArrivalCompanion = { id: "io", at: [10, 0, 0], rank: 1 };
|
|
238
|
+
* console.log(moon.rank);
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
export interface ArrivalCompanion {
|
|
242
|
+
/** A name the page can put on the marker. Left out, the side is still chosen. */
|
|
243
|
+
id?: string;
|
|
244
|
+
at: Vec3;
|
|
245
|
+
rank: 1 | 2 | 3;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The side of a body to stand on so a companion is in the picture, and the body stays at least half lit.
|
|
249
|
+
* Companions are tried in rank order (1, then 2, then 3). The first rank that fits wins; within a rank the side nearest the approach is kept.
|
|
250
|
+
* A side more than 90 degrees from the Sun is refused, so a lit globe is never traded for a black one. With no companion that fits, the side is the
|
|
251
|
+
* approach, swung toward the Sun when it would show less than about three fifths of the body lit (never more than 75 degrees off the Sun).
|
|
252
|
+
*
|
|
253
|
+
* @param input - The body, where the move comes from, the Sun, and the companions in rank order.
|
|
254
|
+
* @returns A unit side from the body toward the camera, how much of the disc is lit, and the companion's id (null when none was framed).
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* import { arrivalSide } from "@johnmorrisdotca/wakusei-planets/space";
|
|
259
|
+
*
|
|
260
|
+
* const side = arrivalSide({ body: [0, 0, 0], radius: 1, from: [0, 0, 20], sun: [0, 0, 100], companions: [{ id: "io", at: [8, 1, 0], rank: 1 }] });
|
|
261
|
+
* console.log(side.companion, side.lit >= 0.5);
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export declare function arrivalSide(input: {
|
|
265
|
+
body: Vec3;
|
|
266
|
+
radius: number;
|
|
267
|
+
from: Vec3;
|
|
268
|
+
sun?: Vec3;
|
|
269
|
+
companions?: readonly ArrivalCompanion[];
|
|
270
|
+
fov?: number;
|
|
271
|
+
aspect?: number;
|
|
272
|
+
fit?: number;
|
|
273
|
+
}): {
|
|
274
|
+
side: Vec3;
|
|
275
|
+
lit: number;
|
|
276
|
+
companion: string | null;
|
|
277
|
+
};
|
|
229
278
|
/**
|
|
230
279
|
* A framed view of a whole body to arrive at, from the side the move comes from, so the approach is straight and nothing has to be turned back: the camera stands on the line towards `from`, moved round
|
|
231
|
-
* towards the Sun where that side would show less than about three fifths of the body lit (never more than 75 degrees off the Sun's direction),
|
|
232
|
-
* taller than wide), looking at the body with `north` up.
|
|
280
|
+
* towards the Sun where that side would show less than about three fifths of the body lit (never more than 75 degrees off the Sun's direction), and further round, still at least half lit, when that puts a
|
|
281
|
+
* companion in the picture (`arrivalSide`). It stands at `fit` radii away (4.1, and as much again as a tall picture is taller than wide), looking at the body with `north` up.
|
|
233
282
|
*
|
|
234
|
-
* @param input - The body's place and radius, where the move comes from, the Sun's place (left out for the Sun itself), the picture's shape, and optionally `fov`, `fit` and `north`.
|
|
235
|
-
* @returns The view,
|
|
283
|
+
* @param input - The body's place and radius, where the move comes from, the Sun's place (left out for the Sun itself), the picture's shape, the companions to keep in the picture, and optionally `fov`, `fit` and `north`.
|
|
284
|
+
* @returns The view, `lit` (the share of the disc that is lit from there, 1 when no Sun is given), and `companion` (the id framed beside it, or null).
|
|
236
285
|
*
|
|
237
286
|
* @example
|
|
238
287
|
* ```ts
|
|
@@ -251,6 +300,8 @@ export declare function travelArrival(input: {
|
|
|
251
300
|
fov?: number;
|
|
252
301
|
fit?: number;
|
|
253
302
|
north?: Vec3;
|
|
303
|
+
companions?: readonly ArrivalCompanion[];
|
|
254
304
|
}): TravelView & {
|
|
255
305
|
lit: number;
|
|
306
|
+
companion: string | null;
|
|
256
307
|
};
|
package/dist/space/travel.js
CHANGED
|
@@ -561,13 +561,111 @@ export function travelPose(input, t, plan) {
|
|
|
561
561
|
sample.around = sightOf(input.around, time, view.position, o, frame);
|
|
562
562
|
return sample;
|
|
563
563
|
}
|
|
564
|
+
/**
|
|
565
|
+
* The side of a body to stand on so a companion is in the picture, and the body stays at least half lit.
|
|
566
|
+
* Companions are tried in rank order (1, then 2, then 3). The first rank that fits wins; within a rank the side nearest the approach is kept.
|
|
567
|
+
* A side more than 90 degrees from the Sun is refused, so a lit globe is never traded for a black one. With no companion that fits, the side is the
|
|
568
|
+
* approach, swung toward the Sun when it would show less than about three fifths of the body lit (never more than 75 degrees off the Sun).
|
|
569
|
+
*
|
|
570
|
+
* @param input - The body, where the move comes from, the Sun, and the companions in rank order.
|
|
571
|
+
* @returns A unit side from the body toward the camera, how much of the disc is lit, and the companion's id (null when none was framed).
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* ```ts
|
|
575
|
+
* import { arrivalSide } from "@johnmorrisdotca/wakusei-planets/space";
|
|
576
|
+
*
|
|
577
|
+
* const side = arrivalSide({ body: [0, 0, 0], radius: 1, from: [0, 0, 20], sun: [0, 0, 100], companions: [{ id: "io", at: [8, 1, 0], rank: 1 }] });
|
|
578
|
+
* console.log(side.companion, side.lit >= 0.5);
|
|
579
|
+
* ```
|
|
580
|
+
*/
|
|
581
|
+
export function arrivalSide(input) {
|
|
582
|
+
let approach = sub(input.from, input.body);
|
|
583
|
+
approach = length(approach) < 1e-9 ? [0, 0, 1] : unit(approach);
|
|
584
|
+
const sunFar = input.sun ? sub(input.sun, input.body) : null;
|
|
585
|
+
const sunDir = sunFar && length(sunFar) > 1e-9 ? unit(sunFar) : null;
|
|
586
|
+
const litOf = (side) => (sunDir ? (1 + Math.cos(Math.min(Math.PI, angleOf(side, sunDir)))) / 2 : 1);
|
|
587
|
+
const swing = (side) => {
|
|
588
|
+
if (!sunDir)
|
|
589
|
+
return side;
|
|
590
|
+
const off = angleOf(side, sunDir);
|
|
591
|
+
const most = 75 * RAD;
|
|
592
|
+
return off > most ? arc(side, sunDir, (off - most) / off) : side;
|
|
593
|
+
};
|
|
594
|
+
const distance = Math.max(1e-6, input.radius) * (input.fit ?? 4.1) * Math.max(1, 1 / Math.max(1e-3, input.aspect ?? 1));
|
|
595
|
+
const fov = ((input.fov ?? 35) / 2) * RAD;
|
|
596
|
+
const tv = Math.tan(fov);
|
|
597
|
+
const aspect = Math.max(1e-3, input.aspect ?? 1);
|
|
598
|
+
const frames = (side, at) => {
|
|
599
|
+
const forward = scale(side, -1);
|
|
600
|
+
const north = sub([0, 1, 0], scale(forward, forward[1]));
|
|
601
|
+
const up = length(north) < 1e-6 ? squareTo(forward) : unit(north);
|
|
602
|
+
const camera = add(input.body, scale(side, distance));
|
|
603
|
+
const v = sub(at, camera);
|
|
604
|
+
const z = dot(v, forward);
|
|
605
|
+
if (!(z > 0))
|
|
606
|
+
return false;
|
|
607
|
+
if (Math.abs(dot(v, cross(forward, up))) > 0.92 * tv * aspect * z)
|
|
608
|
+
return false;
|
|
609
|
+
if (Math.abs(dot(v, up)) > 0.92 * tv * z)
|
|
610
|
+
return false;
|
|
611
|
+
const limb = Math.atan(input.radius / distance);
|
|
612
|
+
return angleOf(forward, unit(v)) > limb * 1.15;
|
|
613
|
+
};
|
|
614
|
+
const found = [];
|
|
615
|
+
const half = Math.PI / 2 + 1e-4;
|
|
616
|
+
const companions = input.companions ?? [];
|
|
617
|
+
const consider = (side) => {
|
|
618
|
+
const u = length(side) < 1e-9 ? approach : unit(side);
|
|
619
|
+
if (sunDir && angleOf(u, sunDir) > half)
|
|
620
|
+
return;
|
|
621
|
+
let rank = 99;
|
|
622
|
+
let id = null;
|
|
623
|
+
for (const companion of companions) {
|
|
624
|
+
if (companion.rank < rank && frames(u, companion.at)) {
|
|
625
|
+
rank = companion.rank;
|
|
626
|
+
id = companion.id ?? null;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (rank === 99)
|
|
630
|
+
return;
|
|
631
|
+
const near = angleOf(u, approach);
|
|
632
|
+
const top = found[0];
|
|
633
|
+
if (top === undefined || rank < top.rank || (rank === top.rank && near < top.near - 1e-6))
|
|
634
|
+
found[0] = { side: u, rank, near, id };
|
|
635
|
+
};
|
|
636
|
+
consider(approach);
|
|
637
|
+
for (const companion of companions) {
|
|
638
|
+
const away = sub(input.body, companion.at);
|
|
639
|
+
if (length(away) < 1e-6)
|
|
640
|
+
continue;
|
|
641
|
+
const u = unit(away);
|
|
642
|
+
const perp = Math.abs(u[1]) < 0.9 ? unit(cross(u, [0, 1, 0])) : unit(cross(u, [1, 0, 0]));
|
|
643
|
+
const perp2 = unit(cross(u, perp));
|
|
644
|
+
for (const deg of [8, 14, 22, 32, 48, 70]) {
|
|
645
|
+
const e = deg * RAD;
|
|
646
|
+
for (const axis of [perp, perp2]) {
|
|
647
|
+
consider(add(scale(u, Math.cos(e)), scale(axis, Math.sin(e))));
|
|
648
|
+
consider(add(scale(u, Math.cos(e)), scale(axis, -Math.sin(e))));
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
for (let lat = -75; lat <= 75; lat += 15) {
|
|
653
|
+
for (let lon = 0; lon < 360; lon += 15) {
|
|
654
|
+
const c = Math.cos(lat * RAD);
|
|
655
|
+
consider([c * Math.cos(lon * RAD), Math.sin(lat * RAD), c * Math.sin(lon * RAD)]);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const picked = found[0];
|
|
659
|
+
const side = picked?.side ?? swing(approach);
|
|
660
|
+
return { side, lit: litOf(side), companion: picked?.id ?? null };
|
|
661
|
+
}
|
|
564
662
|
/**
|
|
565
663
|
* A framed view of a whole body to arrive at, from the side the move comes from, so the approach is straight and nothing has to be turned back: the camera stands on the line towards `from`, moved round
|
|
566
|
-
* towards the Sun where that side would show less than about three fifths of the body lit (never more than 75 degrees off the Sun's direction),
|
|
567
|
-
* taller than wide), looking at the body with `north` up.
|
|
664
|
+
* towards the Sun where that side would show less than about three fifths of the body lit (never more than 75 degrees off the Sun's direction), and further round, still at least half lit, when that puts a
|
|
665
|
+
* companion in the picture (`arrivalSide`). It stands at `fit` radii away (4.1, and as much again as a tall picture is taller than wide), looking at the body with `north` up.
|
|
568
666
|
*
|
|
569
|
-
* @param input - The body's place and radius, where the move comes from, the Sun's place (left out for the Sun itself), the picture's shape, and optionally `fov`, `fit` and `north`.
|
|
570
|
-
* @returns The view,
|
|
667
|
+
* @param input - The body's place and radius, where the move comes from, the Sun's place (left out for the Sun itself), the picture's shape, the companions to keep in the picture, and optionally `fov`, `fit` and `north`.
|
|
668
|
+
* @returns The view, `lit` (the share of the disc that is lit from there, 1 when no Sun is given), and `companion` (the id framed beside it, or null).
|
|
571
669
|
*
|
|
572
670
|
* @example
|
|
573
671
|
* ```ts
|
|
@@ -578,20 +676,11 @@ export function travelPose(input, t, plan) {
|
|
|
578
676
|
* ```
|
|
579
677
|
*/
|
|
580
678
|
export function travelArrival(input) {
|
|
581
|
-
|
|
582
|
-
side =
|
|
583
|
-
let lit = 1;
|
|
584
|
-
if (input.sun && length(sub(input.sun, input.body)) > 1e-12) {
|
|
585
|
-
const sun = unit(sub(input.sun, input.body));
|
|
586
|
-
const off = angleOf(side, sun);
|
|
587
|
-
const most = 75 * RAD;
|
|
588
|
-
if (off > most)
|
|
589
|
-
side = arc(side, sun, (off - most) / off);
|
|
590
|
-
lit = (1 + Math.cos(Math.min(off, most))) / 2;
|
|
591
|
-
}
|
|
679
|
+
const picked = arrivalSide(input);
|
|
680
|
+
const side = picked.side;
|
|
592
681
|
const distance = input.radius * (input.fit ?? 4.1) * Math.max(1, 1 / Math.max(1e-3, input.aspect));
|
|
593
682
|
const forward = scale(side, -1);
|
|
594
683
|
const north = input.north ?? [0, 1, 0];
|
|
595
684
|
const across = sub(north, scale(forward, dot(north, forward)));
|
|
596
|
-
return { position: add(input.body, scale(side, distance)), forward, up: length(across) < 1e-6 ? squareTo(forward) : unit(across), fov: input.fov ?? 35, lit };
|
|
685
|
+
return { position: add(input.body, scale(side, distance)), forward, up: length(across) < 1e-6 ? squareTo(forward) : unit(across), fov: input.fov ?? 35, lit: picked.lit, companion: picked.companion };
|
|
597
686
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.42.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.42.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|