@johnmorrisdotca/wakusei-planets 0.41.0 → 0.43.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/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +28 -3
- package/dist/space/element.js +156 -20
- 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 +45 -1
- package/dist/space/scene.js +103 -3
- package/dist/space/travel.d.ts +55 -4
- package/dist/space/travel.js +105 -16
- package/dist/spacecraft-facts.d.ts +11 -5
- package/dist/spacecraft-facts.js +20 -3
- package/dist/spacecraft.d.ts +15 -1
- package/dist/spacecraft.js +50 -1
- 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,20 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.43.0] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **The space view draws the deep-space craft** (MODULES-1207). `spacecraft` on `<wakusei-space>` (and `space.spacecraft`) is off by default. `"all"` or `true` draws every craft whose record covers the date, as one points object with a name each; a space-separated list draws those. A craft outside its record is not drawn and `stats.spacecraft.status[id]` is `"outside"`. Each table loads the first time that craft is shown. `sight()` and `wakusei-sight` give each drawn craft `{ id, kind: "spacecraft" }` using the craft's own id. A press sends `wakusei-body-click` with that kind and does not go to the craft. No path line.
|
|
8
|
+
|
|
9
|
+
- **The Roadster joins the spacecraft list** (MODULES-1208). `roadster` is the nineteenth entry of `SPACECRAFT`: Starman / スターマン, other names Tesla Roadster, Starman and Tesla, kind `other`, Horizons `-143205`, the Falcon Heavy launch from Kennedy Space Center 39A. `findSpacecraft` matches an id, either name or an other name, with case, letter width, spaces and punctuation folded. `spacecraftPosition`, `spacecraftSpeed`, `spacecraftSunDistance`, `spacecraftLightTime` and `spacecraftStats` answer for it from the Roadster's own path, and the 20 kB table loads only with `loadSpacecraft("roadster")`. `/roadster` is unchanged. The craft page's picker shows it.
|
|
10
|
+
|
|
11
|
+
## [0.42.0] - 2026-11-13
|
|
12
|
+
|
|
13
|
+
- **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.
|
|
14
|
+
|
|
15
|
+
- **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.
|
|
16
|
+
|
|
17
|
+
- **A page for the spacecraft** (MODULES-875). `craft.html` picks one of the nineteen 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.
|
|
18
|
+
|
|
5
19
|
## [0.41.0] - 2026-11-13
|
|
6
20
|
|
|
7
21
|
- **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.43.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.43.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.43.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.43.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.43.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
|
@@ -78,8 +78,9 @@ export interface BodyHover extends BodyInfo {
|
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
80
|
export interface BodySight extends Sight {
|
|
81
|
-
id
|
|
82
|
-
|
|
81
|
+
/** A body's id, or a craft's own id (`voyager1`, `roadster`) when `kind` is `spacecraft`. */
|
|
82
|
+
id: string;
|
|
83
|
+
kind: SpaceKind | "spacecraft";
|
|
83
84
|
host?: BodyId;
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
@@ -257,6 +258,11 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
257
258
|
/** `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
259
|
get scale(): ScaleMode;
|
|
259
260
|
set scale(value: ScaleMode);
|
|
261
|
+
/**
|
|
262
|
+
* 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.
|
|
263
|
+
*/
|
|
264
|
+
get moonSize(): number;
|
|
265
|
+
set moonSize(value: number);
|
|
260
266
|
/** 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
267
|
get scaleNames(): Partial<Record<ScaleMode, string>>;
|
|
262
268
|
set scaleNames(value: Partial<Record<ScaleMode, string>>);
|
|
@@ -308,6 +314,11 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
308
314
|
*/
|
|
309
315
|
get roadster(): boolean;
|
|
310
316
|
set roadster(value: boolean);
|
|
317
|
+
/**
|
|
318
|
+
* The deep-space craft (the attribute `spacecraft`; off by default). `true` or `"all"` draws every craft whose record covers the date. A space-separated list (`"voyager1 juno"`) draws those. Each craft's table loads the first time it is shown, and nothing loads while this is off. `stats.spacecraft` says what was drawn.
|
|
319
|
+
*/
|
|
320
|
+
get spacecraft(): false | "all" | string;
|
|
321
|
+
set spacecraft(value: boolean | string);
|
|
311
322
|
/**
|
|
312
323
|
* The orbiter picked out (the attribute `orbiter`, an id from `/orbiters` such as `lro`; none by default): its orbit line is drawn brighter, it alone keeps its line when `orbiterLines` is
|
|
313
324
|
* `chosen`, and its ground track is drawn when `orbiterTrack` is on.
|
|
@@ -398,7 +409,7 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
398
409
|
roll?: number;
|
|
399
410
|
panX?: number;
|
|
400
411
|
panY?: number;
|
|
401
|
-
}, final?: boolean): void;
|
|
412
|
+
}, final?: boolean, reason?: string): void;
|
|
402
413
|
/** 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
414
|
get body(): BodyId;
|
|
404
415
|
set body(name: BodyId | string);
|
|
@@ -624,6 +635,18 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
624
635
|
position: [number, number, number] | null;
|
|
625
636
|
radiusPx: number;
|
|
626
637
|
};
|
|
638
|
+
/** The deep-space craft at the last draw: how many dots, each id's status (`drawn` or `outside` the record), and the ids drawn. */
|
|
639
|
+
spacecraft: {
|
|
640
|
+
count: number;
|
|
641
|
+
status: Record<string, "drawn" | "outside">;
|
|
642
|
+
drawn: string[];
|
|
643
|
+
};
|
|
644
|
+
/** 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. */
|
|
645
|
+
moonSize: {
|
|
646
|
+
asked: number;
|
|
647
|
+
factor: number;
|
|
648
|
+
clamped: boolean;
|
|
649
|
+
};
|
|
627
650
|
/** 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
651
|
orbiters: {
|
|
629
652
|
count: number;
|
|
@@ -632,6 +655,8 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
632
655
|
lines: number;
|
|
633
656
|
track: number;
|
|
634
657
|
};
|
|
658
|
+
/** The body the last arrival kept in the picture beside the one gone to, or null. */
|
|
659
|
+
companion: string | null;
|
|
635
660
|
};
|
|
636
661
|
/** 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
662
|
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", "spacecraft", "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,10 +204,14 @@ 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";
|
|
210
211
|
this.roadster = this.hasAttribute("roadster") && this.getAttribute("roadster") !== "off";
|
|
212
|
+
const craft = this.getAttribute("spacecraft");
|
|
213
|
+
if (craft !== null && craft !== "off")
|
|
214
|
+
this.spacecraft = craft;
|
|
211
215
|
this.orbiters = this.hasAttribute("orbiters") && this.getAttribute("orbiters") !== "off";
|
|
212
216
|
this.#model.orbiterChosen = this.getAttribute("orbiter") || null;
|
|
213
217
|
this.#model.orbiterLines = orbiterLines(this.getAttribute("orbiter-lines"));
|
|
@@ -297,7 +301,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
297
301
|
this.addEventListener("pointerleave", this.#leave);
|
|
298
302
|
// before the shared hands (which hear it after this): a plain wheel in an immersive view zooms
|
|
299
303
|
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) });
|
|
304
|
+
this.#hands = carryControls(this, { limits: CARRIED_LIMITS, onChange: (view, info) => this.setView(view, info.final, info.reason) });
|
|
301
305
|
this.#markHeard = onPlacesLoader(() => {
|
|
302
306
|
this.#markList = undefined;
|
|
303
307
|
this.#markSurface();
|
|
@@ -351,6 +355,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
351
355
|
this.speed = this.#readSpeed();
|
|
352
356
|
else if (name === "scale")
|
|
353
357
|
this.scale = value === "compressed" ? "compressed" : "true";
|
|
358
|
+
else if (name === "moon-size")
|
|
359
|
+
this.moonSize = readMoonSize(value);
|
|
354
360
|
else if (name === "labels")
|
|
355
361
|
this.labels = value !== "off";
|
|
356
362
|
else if (name === "labels-always")
|
|
@@ -359,6 +365,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
359
365
|
this.covered = value === "arrow" ? "arrow" : "name";
|
|
360
366
|
else if (name === "roadster")
|
|
361
367
|
this.roadster = value !== null && value !== "off";
|
|
368
|
+
else if (name === "spacecraft")
|
|
369
|
+
this.spacecraft = value === null || value === "off" ? false : value;
|
|
362
370
|
else if (name === "orbiters")
|
|
363
371
|
this.orbiters = value !== null && value !== "off";
|
|
364
372
|
else if (name === "orbiter")
|
|
@@ -701,6 +709,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
701
709
|
this.#nameScale();
|
|
702
710
|
this.#gate?.request();
|
|
703
711
|
}
|
|
712
|
+
/**
|
|
713
|
+
* 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.
|
|
714
|
+
*/
|
|
715
|
+
get moonSize() {
|
|
716
|
+
return this.#model.moonSize;
|
|
717
|
+
}
|
|
718
|
+
set moonSize(value) {
|
|
719
|
+
this.#model.moonSize = readMoonSize(value);
|
|
720
|
+
this.#gate?.request();
|
|
721
|
+
}
|
|
704
722
|
/** 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
723
|
get scaleNames() {
|
|
706
724
|
return { ...this.#scaleNames };
|
|
@@ -838,6 +856,50 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
838
856
|
}
|
|
839
857
|
this.#gate?.request();
|
|
840
858
|
}
|
|
859
|
+
#craftToken = 0;
|
|
860
|
+
/**
|
|
861
|
+
* The deep-space craft (the attribute `spacecraft`; off by default). `true` or `"all"` draws every craft whose record covers the date. A space-separated list (`"voyager1 juno"`) draws those. Each craft's table loads the first time it is shown, and nothing loads while this is off. `stats.spacecraft` says what was drawn.
|
|
862
|
+
*/
|
|
863
|
+
get spacecraft() {
|
|
864
|
+
const show = this.#model.craftShow;
|
|
865
|
+
if (show === null)
|
|
866
|
+
return false;
|
|
867
|
+
return show === "all" ? "all" : show.join(" ");
|
|
868
|
+
}
|
|
869
|
+
set spacecraft(value) {
|
|
870
|
+
const next = value === false || value === "off" ? null : value === true || value === "all" || value === "true" ? "all" : value.split(/\s+/).filter((id) => id.length > 0);
|
|
871
|
+
this.#model.craftShow = next === null || next === "all" ? next : next;
|
|
872
|
+
if (next === null) {
|
|
873
|
+
this.#model.craftPlaces = null;
|
|
874
|
+
this.#model.craftIds = [];
|
|
875
|
+
this.#model.craftNames = null;
|
|
876
|
+
this.#gate?.request();
|
|
877
|
+
return;
|
|
878
|
+
}
|
|
879
|
+
const token = ++this.#craftToken;
|
|
880
|
+
const wanted = next;
|
|
881
|
+
void import("../spacecraft.js").then(async (mod) => {
|
|
882
|
+
if (token !== this.#craftToken)
|
|
883
|
+
return;
|
|
884
|
+
const known = mod.SPACECRAFT_IDS;
|
|
885
|
+
const ids = (wanted === "all" ? [...known] : wanted.filter((id) => known.includes(id)));
|
|
886
|
+
await mod.loadSpacecraft(...ids);
|
|
887
|
+
if (token !== this.#craftToken || this.#model.craftShow === null)
|
|
888
|
+
return;
|
|
889
|
+
const au = 149_597_870.7;
|
|
890
|
+
this.#model.craftIds = ids;
|
|
891
|
+
this.#model.craftNames = (id, lang) => mod.SPACECRAFT[id].name[lang];
|
|
892
|
+
this.#model.craftPlaces = (ms) => ids.map((id) => {
|
|
893
|
+
const craft = mod.SPACECRAFT[id];
|
|
894
|
+
if (ms < craft.record.start || ms > craft.record.end || craft.record.end === 0)
|
|
895
|
+
return { id, au: null };
|
|
896
|
+
const km = mod.spacecraftPosition(id, ms);
|
|
897
|
+
return { id, au: [km[0] / au, km[1] / au, km[2] / au] };
|
|
898
|
+
});
|
|
899
|
+
this.#gate?.request();
|
|
900
|
+
});
|
|
901
|
+
this.#gate?.request();
|
|
902
|
+
}
|
|
841
903
|
/**
|
|
842
904
|
* The orbiter picked out (the attribute `orbiter`, an id from `/orbiters` such as `lro`; none by default): its orbit line is drawn brighter, it alone keeps its line when `orbiterLines` is
|
|
843
905
|
* `chosen`, and its ground track is drawn when `orbiterTrack` is on.
|
|
@@ -1036,7 +1098,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1036
1098
|
* @param view - The controls' yaw and tilt in degrees and zoom.
|
|
1037
1099
|
* @param final - False for the frames of a turn that is still going on (Auto-turn, a drag); true when it has settled.
|
|
1038
1100
|
*/
|
|
1039
|
-
setView(view, final = true) {
|
|
1101
|
+
setView(view, final = true, reason) {
|
|
1040
1102
|
const now = this.#model.view;
|
|
1041
1103
|
if (this.#model.region !== null && view.zoom !== 1) {
|
|
1042
1104
|
// 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 +1120,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1058
1120
|
const [roll, panX, panY] = [view.roll ?? 0, view.panX ?? 0, view.panY ?? 0];
|
|
1059
1121
|
if (view.yaw === now.yaw && view.tilt === now.tilt && view.zoom === now.zoom && roll === now.roll && panX === now.panX && panY === now.panY)
|
|
1060
1122
|
return;
|
|
1123
|
+
// 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.
|
|
1124
|
+
if (!this.#siding && reason === "zoom" && (view.zoom === 1 || view.zoom === 2) && Math.abs(view.zoom - now.zoom) > 0.4 && this.#model.pose.valid) {
|
|
1125
|
+
const side = this.#faceApproach(this.#model.focus);
|
|
1126
|
+
if (side) {
|
|
1127
|
+
this.#siding = true;
|
|
1128
|
+
this.#hands?.controller.set({ ...side, zoom: view.zoom, roll, panX: 0, panY: 0 }, true, "set");
|
|
1129
|
+
this.#siding = false;
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1061
1133
|
this.#model.view = { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY };
|
|
1062
1134
|
this.dispatchEvent(new CustomEvent("wakusei-view", { detail: { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom, roll, panX, panY } }));
|
|
1063
1135
|
const drawn = this.#model.drawnView;
|
|
@@ -1113,6 +1185,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1113
1185
|
return false;
|
|
1114
1186
|
const model = this.#model;
|
|
1115
1187
|
const leaving = this.#leaving();
|
|
1188
|
+
this.#arrivedFrom = leaving;
|
|
1116
1189
|
const kind = this.#moveKind(options, id);
|
|
1117
1190
|
if (model.ride !== null)
|
|
1118
1191
|
this.ride(null, { smooth: false });
|
|
@@ -1123,7 +1196,10 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1123
1196
|
this.#model.focus = id;
|
|
1124
1197
|
const zoom = options.zoom ?? 1;
|
|
1125
1198
|
// 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
|
-
|
|
1199
|
+
// 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
|
|
1200
|
+
// works round the planet in a way that never leaves the picture empty (`travelPlan`).
|
|
1201
|
+
const swing = kind === "cut" || kind === "turn-travel";
|
|
1202
|
+
const side = this.#faceApproach(id, swing);
|
|
1127
1203
|
if (!this.hasAttribute("data-kazoku-bar"))
|
|
1128
1204
|
this.#hands?.controller.set(side ? { ...side, zoom } : { zoom }, true, "jump");
|
|
1129
1205
|
this.#schedule();
|
|
@@ -1184,19 +1260,61 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1184
1260
|
const d = Math.hypot(real[0], real[1], real[2]);
|
|
1185
1261
|
const k = (d === 0 ? 1 : moonDistance(mode, host, d) / d) * radiusIn(host, mode);
|
|
1186
1262
|
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)) };
|
|
1263
|
+
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) };
|
|
1264
|
+
}
|
|
1265
|
+
#siding = false;
|
|
1266
|
+
/** The body the camera was at when the latest arrival was chosen, so that body can stay in the picture. */
|
|
1267
|
+
#arrivedFrom = null;
|
|
1268
|
+
/** Moons or the planet first, then the body left or the planet nearest that way, then the Sun. */
|
|
1269
|
+
#companions(id) {
|
|
1270
|
+
const out = [];
|
|
1271
|
+
const seen = new Set();
|
|
1272
|
+
const add = (body, rank) => {
|
|
1273
|
+
if (body === id || seen.has(body))
|
|
1274
|
+
return;
|
|
1275
|
+
seen.add(body);
|
|
1276
|
+
out.push({ id: body, at: this.#site(body).at, rank });
|
|
1277
|
+
};
|
|
1278
|
+
const host = hostOf(id);
|
|
1279
|
+
if (host !== undefined)
|
|
1280
|
+
add(host, 1);
|
|
1281
|
+
for (const moon of MOONS_OF[id] ?? [])
|
|
1282
|
+
add(moon, 1);
|
|
1283
|
+
if (this.#arrivedFrom !== null)
|
|
1284
|
+
add(this.#arrivedFrom, 2);
|
|
1285
|
+
const here = this.#site(id).at;
|
|
1286
|
+
const from = sub(this.#model.camera.position, here);
|
|
1287
|
+
const approach = length(from) < 1e-9 ? [0, 0, 1] : unit(from);
|
|
1288
|
+
let nearest = null;
|
|
1289
|
+
for (const planet of ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune"]) {
|
|
1290
|
+
if (planet === id)
|
|
1291
|
+
continue;
|
|
1292
|
+
const away = sub(this.#site(planet).at, here);
|
|
1293
|
+
if (length(away) < 1e-9)
|
|
1294
|
+
continue;
|
|
1295
|
+
const score = dot(unit(away), approach);
|
|
1296
|
+
if (score > 0.15 && (nearest === null || score > nearest.score))
|
|
1297
|
+
nearest = { id: planet, score };
|
|
1298
|
+
}
|
|
1299
|
+
if (nearest !== null)
|
|
1300
|
+
add(nearest.id, 2);
|
|
1301
|
+
if (id !== "sun")
|
|
1302
|
+
add("sun", 3);
|
|
1303
|
+
return out;
|
|
1188
1304
|
}
|
|
1189
1305
|
/**
|
|
1190
|
-
* The controls' yaw and tilt that look at a body from the side the camera comes from
|
|
1191
|
-
*
|
|
1306
|
+
* 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.
|
|
1307
|
+
* The reader's own later turn is not touched: this runs for an arrival and for a double click, not for a drag.
|
|
1192
1308
|
*/
|
|
1193
|
-
#faceApproach(id) {
|
|
1309
|
+
#faceApproach(id, swing = true) {
|
|
1194
1310
|
const model = this.#model;
|
|
1195
1311
|
if (!model.pose.valid)
|
|
1196
1312
|
return null;
|
|
1197
1313
|
const body = this.#site(id);
|
|
1198
1314
|
const sun = id === "sun" ? undefined : this.#site("sun").at;
|
|
1199
|
-
const
|
|
1315
|
+
const aspect = this.clientWidth > 0 && this.clientHeight > 0 ? this.clientWidth / this.clientHeight : 16 / 9;
|
|
1316
|
+
const wanted = travelArrival({ body: body.at, radius: body.radius, from: model.camera.position, sun, aspect, companions: swing ? this.#companions(id) : [] });
|
|
1317
|
+
model.companion = wanted.companion;
|
|
1200
1318
|
const side = [wanted.position[0] - body.at[0], wanted.position[1] - body.at[1], wanted.position[2] - body.at[2]];
|
|
1201
1319
|
const anchor = model.anchor ?? model.time;
|
|
1202
1320
|
// 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 +1747,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1629
1747
|
bodyLabels: { count: this.#model.labelsDrawn.count, focus: this.#model.labelsDrawn.focus === null ? null : { ...this.#model.labelsDrawn.focus } },
|
|
1630
1748
|
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
1749
|
roadster: { shown: this.#model.roadsterDrawn.shown, position: this.#model.roadsterDrawn.position === null ? null : [...this.#model.roadsterDrawn.position], radiusPx: this.#model.roadsterDrawn.radiusPx },
|
|
1750
|
+
spacecraft: { count: this.#model.craftDrawn.count, status: { ...this.#model.craftDrawn.status }, drawn: [...this.#model.craftDrawn.drawn] },
|
|
1751
|
+
companion: this.#model.companion,
|
|
1752
|
+
moonSize: { asked: this.#model.moonSize, factor: this.#model.moonDrawn.factor, clamped: this.#model.moonDrawn.clamped },
|
|
1632
1753
|
};
|
|
1633
1754
|
}
|
|
1634
1755
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
@@ -1676,6 +1797,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1676
1797
|
const lang = this.getAttribute("lang") === "ja" ? "ja" : "en";
|
|
1677
1798
|
if (id === "roadster")
|
|
1678
1799
|
return this.#names[id] ?? this.#model.roadsterPath?.name[lang] ?? "Starman";
|
|
1800
|
+
if (this.#model.craftIds.includes(id))
|
|
1801
|
+
return this.#names[id] ?? this.#model.craftNames?.(id, lang) ?? id;
|
|
1679
1802
|
if (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))
|
|
1680
1803
|
return this.#names[id] ?? this.#model.orbiterSet.name(id)[lang];
|
|
1681
1804
|
return this.#names[id] ?? BODIES[id].name[lang];
|
|
@@ -1729,6 +1852,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1729
1852
|
}
|
|
1730
1853
|
// no two names overlap: a moon gives way to its planet and a planet to the Sun
|
|
1731
1854
|
const shown = chooseLabels(wanted);
|
|
1855
|
+
for (const id of this.#model.craftIds)
|
|
1856
|
+
if (spots.has(id))
|
|
1857
|
+
shown.add(id);
|
|
1858
|
+
const companion = this.#model.companion;
|
|
1859
|
+
if (companion !== null && spots.has(companion))
|
|
1860
|
+
shown.add(companion);
|
|
1732
1861
|
this.#nameBoxes = wanted.filter((one) => shown.has(one.id));
|
|
1733
1862
|
for (const id of ids) {
|
|
1734
1863
|
const label = this.#pool.get(id);
|
|
@@ -1777,9 +1906,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1777
1906
|
/** The bodies drawn at full strength: the system of the body under the pointer, or else the one in the middle of the view. */
|
|
1778
1907
|
#lit() {
|
|
1779
1908
|
// the Sun in the middle lights the Sun and the eight planets; a body pointed at, the Sun too, lights its own system
|
|
1780
|
-
|
|
1909
|
+
// a craft's name under the pointer is no body: it lights what the view's own focus lights
|
|
1910
|
+
const pointed = this.#hovered !== null && Object.hasOwn(BODIES, this.#hovered) ? this.#hovered : null;
|
|
1911
|
+
if (pointed === null && this.#model.focus === "sun")
|
|
1781
1912
|
return new Set(["sun", ...BODY_IDS.filter((id) => BODIES[id].kind === "planet")]);
|
|
1782
|
-
const { host, moons } = systemOf(
|
|
1913
|
+
const { host, moons } = systemOf(pointed ?? this.#model.focus);
|
|
1783
1914
|
return new Set([host, ...moons]);
|
|
1784
1915
|
}
|
|
1785
1916
|
/** Mark the names, rings and arrows of the bodies outside the lit system: they are drawn at the far strength. Only what changed is touched, and nothing is drawn again. */
|
|
@@ -1808,7 +1939,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1808
1939
|
this.#hovered = id;
|
|
1809
1940
|
this.#hoverBy = by;
|
|
1810
1941
|
this.#markFar();
|
|
1811
|
-
if (id !== null)
|
|
1942
|
+
if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id)))
|
|
1943
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
|
|
1944
|
+
else if (id !== null)
|
|
1812
1945
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
|
|
1813
1946
|
else if (was !== null)
|
|
1814
1947
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: was }, bubbles: true, composed: true }));
|
|
@@ -1863,8 +1996,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1863
1996
|
const now = {};
|
|
1864
1997
|
for (const [id, input] of Object.entries(bodies)) {
|
|
1865
1998
|
const body = id;
|
|
1866
|
-
const
|
|
1867
|
-
const
|
|
1999
|
+
const craft = this.#model.craftIds.includes(id) || id === "roadster";
|
|
2000
|
+
const one = { id, kind: craft ? "spacecraft" : bodyKindOf(body), ...sightOf(input, frame.width, frame.height, frame.axis) };
|
|
2001
|
+
const host = craft ? undefined : hostOf(body);
|
|
1868
2002
|
if (host !== undefined)
|
|
1869
2003
|
one.host = host;
|
|
1870
2004
|
now[id] = one;
|
|
@@ -1931,7 +2065,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1931
2065
|
return 0;
|
|
1932
2066
|
if (id === "sun")
|
|
1933
2067
|
return 1;
|
|
1934
|
-
if (id === "roadster")
|
|
2068
|
+
if (id === "roadster" || this.#model.craftIds.includes(id))
|
|
1935
2069
|
return 3;
|
|
1936
2070
|
if (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))
|
|
1937
2071
|
return 5;
|
|
@@ -2056,7 +2190,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2056
2190
|
*/
|
|
2057
2191
|
#press(id) {
|
|
2058
2192
|
// the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
|
|
2059
|
-
if (id === "roadster" || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))) {
|
|
2193
|
+
if (id === "roadster" || this.#model.craftIds.includes(id) || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id))) {
|
|
2060
2194
|
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
|
|
2061
2195
|
return;
|
|
2062
2196
|
}
|
|
@@ -2073,7 +2207,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2073
2207
|
const id = event.target?.dataset?.["body"];
|
|
2074
2208
|
if (!id)
|
|
2075
2209
|
return;
|
|
2076
|
-
|
|
2210
|
+
// a craft's name is no body: focus tells the page its id and name, as a press does
|
|
2211
|
+
const craft = id === "roadster" || this.#model.craftIds.includes(id) || (this.#model.orbiterSet !== null && this.#model.orbiterSet.ids.includes(id));
|
|
2212
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-focus", { detail: craft ? { id, name: this.#nameOf(id), kind: "spacecraft" } : this.bodyInfo(id), bubbles: true, composed: true }));
|
|
2077
2213
|
this.#hover(id, "focus");
|
|
2078
2214
|
};
|
|
2079
2215
|
// --- the rest --------------------------------------------------------------------------------------------------------------------------------------
|
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];
|