@johnmorrisdotca/wakusei-planets 0.35.0 → 0.37.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 +18 -0
- package/NOTICE.md +31 -1
- package/README.md +5 -4
- package/dist/data/moon-catalogue.d.ts +31 -0
- package/dist/data/moon-catalogue.js +471 -0
- package/dist/data/orbiters.d.ts +368 -0
- package/dist/data/orbiters.js +370 -0
- package/dist/data/places-planned.d.ts +3 -0
- package/dist/data/places-planned.js +51 -0
- package/dist/element.d.ts +28 -0
- package/dist/element.js +172 -1
- package/dist/moon-catalogue.d.ts +296 -0
- package/dist/moon-catalogue.js +234 -0
- package/dist/orbiter-facts.d.ts +480 -0
- package/dist/orbiter-facts.js +189 -0
- package/dist/orbiters.d.ts +256 -0
- package/dist/orbiters.js +275 -0
- package/dist/place-marks.d.ts +182 -0
- package/dist/place-marks.js +194 -0
- package/dist/places/mars.d.ts +1 -1
- package/dist/places/mars.js +4 -2
- package/dist/places/moon.d.ts +1 -1
- package/dist/places/moon.js +4 -2
- package/dist/places.d.ts +4 -2
- package/dist/places.js +2 -0
- package/dist/scene/place-layer.d.ts +68 -0
- package/dist/scene/place-layer.js +213 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/all-moons.d.ts +30 -0
- package/dist/space/all-moons.js +61 -0
- package/dist/space/bodies.d.ts +18 -0
- package/dist/space/bodies.js +18 -0
- package/dist/space/element.d.ts +182 -6
- package/dist/space/element.js +763 -26
- package/dist/space/frame.d.ts +14 -0
- package/dist/space/frame.js +16 -0
- package/dist/space/index.d.ts +5 -2
- package/dist/space/index.js +5 -2
- package/dist/space/regions.d.ts +111 -0
- package/dist/space/regions.js +84 -0
- package/dist/space/scene.d.ts +131 -8
- package/dist/space/scene.js +312 -15
- package/dist/space/sight.d.ts +106 -0
- package/dist/space/sight.js +84 -0
- package/dist/space/travel.d.ts +256 -0
- package/dist/space/travel.js +597 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -2
package/dist/element.js
CHANGED
|
@@ -21,7 +21,11 @@ import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } fro
|
|
|
21
21
|
import { delegates, onRegister } from "./scene/store.js";
|
|
22
22
|
import { setThreeLoader, takeRenderer } from "./scene/shared.js";
|
|
23
23
|
import { turn as turnVec } from "./vec.js";
|
|
24
|
+
import { findPlace, PLACE_BODIES } from "./places.js";
|
|
25
|
+
import { placeMarks, readPlaceLayers, turnToPlace } from "./place-marks.js";
|
|
26
|
+
import { createPlaceLayer, onPlacesLoader, placesLoader } from "./scene/place-layer.js";
|
|
24
27
|
export { setThreeLoader };
|
|
28
|
+
export { placeLine, setPlacesLoader } from "./scene/place-layer.js";
|
|
25
29
|
const num = (value, fallback) => {
|
|
26
30
|
if (value === null || value.trim() === "")
|
|
27
31
|
return fallback;
|
|
@@ -79,6 +83,7 @@ const TEMPLATE = `<style>
|
|
|
79
83
|
* `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
|
|
80
84
|
* Close up, `tiles` is where the finer map tiles are (a folder address; `off` for none; by default the demo site's, unless `texture-base` names your own pictures): a window of them is laid over the painted map for the part in view and let go when it is not, and the zoom range of a body with tiles grows with them.
|
|
81
85
|
* Whatever moves the view, `setView` sends a `wakusei-view` event with its `yaw`, `tilt`, `roll`, `zoom`, `panX` and `panY`.
|
|
86
|
+
* `places` marks the places on the body in the shaded looks, by layer (`landing`, `crash`, `planned`, `feature`; the lists come from `setPlacesLoader`), with `wakusei-place` on a click and `goToPlace` to turn one to the middle: see the guide "Places on the Moon, Mars and 31 more bodies".
|
|
82
87
|
* `body-label` writes the body's name on its globe in the shaded looks (`painted`, `etched`, `outline` or `burned`; absent for none), with `body-label-strength`, `-repeat`, `-latitude`, `-facing`, `-font` and `-fallback-font` beside it, and the `bodyLabel` property takes the same as an object: see the guide "A name on the body".
|
|
83
88
|
* A dated picture (a `time`, or `moons`) has a clock: `rate` is the simulated seconds for each real second, and `rate="0"` holds it, drawing nothing. While it runs (`rate` not 0), `wakusei-timechange` carries
|
|
84
89
|
* `detail: { time, running: true }` (`time` is the moment shown in milliseconds since 1970; four times a second, once a second at real time; only while the tab is shown, whether or not the picture is on screen), and once with
|
|
@@ -96,7 +101,7 @@ const TEMPLATE = `<style>
|
|
|
96
101
|
* ```
|
|
97
102
|
*/
|
|
98
103
|
export class WakuseiBody extends HTMLElement {
|
|
99
|
-
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", ...NAME_LABEL_ATTRIBUTES];
|
|
104
|
+
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", ...NAME_LABEL_ATTRIBUTES];
|
|
100
105
|
#stage;
|
|
101
106
|
#state = "line";
|
|
102
107
|
#renderer;
|
|
@@ -138,6 +143,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
138
143
|
#tileLevels;
|
|
139
144
|
#tiles;
|
|
140
145
|
#bodyLabel;
|
|
146
|
+
#placeLayer;
|
|
147
|
+
#placeList;
|
|
148
|
+
#placeLoading;
|
|
149
|
+
#placeGlide = 0;
|
|
150
|
+
#placeResize;
|
|
151
|
+
#placeHeard;
|
|
141
152
|
#door = createDoorHost(this, {
|
|
142
153
|
own: () => {
|
|
143
154
|
// the body's own pictures and, where a window of the package's own tiles is on it, those
|
|
@@ -257,6 +268,145 @@ export class WakuseiBody extends HTMLElement {
|
|
|
257
268
|
this.#lastAnchors = -1;
|
|
258
269
|
this.#queue();
|
|
259
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* The layers of places marked on the body in the shaded looks: any of `landing` (the crewed landings, landers and rovers), `crash` (the crash, impact and atmospheric-entry sites), `planned` (announced landings) and
|
|
273
|
+
* `feature` (named features), from the `places` attribute (`places="landing crash"`; `places` alone or `all` for every layer). A body with no places (see `PLACE_BODIES` from `/places`) shows none. Setting it writes the attribute.
|
|
274
|
+
*/
|
|
275
|
+
get places() {
|
|
276
|
+
return readPlaceLayers(this.getAttribute("places"));
|
|
277
|
+
}
|
|
278
|
+
set places(layers) {
|
|
279
|
+
if (layers === null || layers.length === 0)
|
|
280
|
+
this.removeAttribute("places");
|
|
281
|
+
else
|
|
282
|
+
this.setAttribute("places", layers.join(" "));
|
|
283
|
+
}
|
|
284
|
+
/** The marks laid on the body now: each place's id, its layer and where its mark is, in CSS pixels from the picture's top left. */
|
|
285
|
+
get placesShown() {
|
|
286
|
+
return this.#placeLayer?.shown ?? [];
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Turn the body so a place is in the middle of the disc, at a pace you can follow while the picture is live (at once for a still, for a reader who prefers reduced motion, or with `smooth: false`); the zoom stays. The place is an id (`moon/apollo-11-lunar-module`),
|
|
290
|
+
* or an English or Japanese name. A body that turns by itself carries the place on from there (`turn="0"` keeps it). Resolves the place, or `undefined` when the body has no place by that name.
|
|
291
|
+
*
|
|
292
|
+
* @param text - The place's id or name.
|
|
293
|
+
* @param options - `smooth` (true by default).
|
|
294
|
+
* @returns The place, once the turn has started.
|
|
295
|
+
*/
|
|
296
|
+
async goToPlace(text, options = {}) {
|
|
297
|
+
const list = await this.#loadPlaces();
|
|
298
|
+
const place = list === undefined ? undefined : findPlace(list, text);
|
|
299
|
+
if (place === undefined)
|
|
300
|
+
return undefined;
|
|
301
|
+
const frame = this.#frameNow();
|
|
302
|
+
const aim = turnToPlace(frame.pose.pole, frame.pose.meridian, place.lat, place.lon);
|
|
303
|
+
const to = { yaw: aim.yaw, tilt: this.#pitchDelta - aim.tilt };
|
|
304
|
+
const from = { yaw: this.#yaw, tilt: this.#tilt };
|
|
305
|
+
// the shorter way round
|
|
306
|
+
to.yaw = from.yaw + ((((to.yaw - from.yaw + 180) % 360) + 360) % 360) - 180;
|
|
307
|
+
const apply = (yaw, tilt, final) => {
|
|
308
|
+
const controller = this.#hands?.controller;
|
|
309
|
+
if (controller !== undefined && !this.hasAttribute("data-kazoku-bar"))
|
|
310
|
+
controller.set({ yaw, tilt }, final, "place");
|
|
311
|
+
else
|
|
312
|
+
this.setView({ yaw, tilt, roll: this.#roll, zoom: this.#zoom });
|
|
313
|
+
};
|
|
314
|
+
const glide = (this.#placeGlide += 1);
|
|
315
|
+
// a still (not live) is made again for every change of view: it goes there at once
|
|
316
|
+
if (options.smooth === false || this.#reduce || this.#view?.live !== true || typeof requestAnimationFrame !== "function") {
|
|
317
|
+
apply(to.yaw, to.tilt, true);
|
|
318
|
+
return place;
|
|
319
|
+
}
|
|
320
|
+
const start = performance.now();
|
|
321
|
+
const step = () => {
|
|
322
|
+
if (glide !== this.#placeGlide || !this.isConnected)
|
|
323
|
+
return;
|
|
324
|
+
const k = Math.min(1, (performance.now() - start) / 900);
|
|
325
|
+
const ease = k * k * (3 - 2 * k);
|
|
326
|
+
apply(from.yaw + (to.yaw - from.yaw) * ease, from.tilt + (to.tilt - from.tilt) * ease, k >= 1);
|
|
327
|
+
if (k < 1)
|
|
328
|
+
requestAnimationFrame(step);
|
|
329
|
+
};
|
|
330
|
+
requestAnimationFrame(step);
|
|
331
|
+
return place;
|
|
332
|
+
}
|
|
333
|
+
/** The body's list of places, loaded the first time it is asked for; `undefined` for a body that has none. */
|
|
334
|
+
async #loadPlaces() {
|
|
335
|
+
const body = this.body;
|
|
336
|
+
if (this.#placeList?.body === body)
|
|
337
|
+
return this.#placeList.list;
|
|
338
|
+
const load = placesLoader();
|
|
339
|
+
if (load === undefined || this.hasAttribute("star") || !PLACE_BODIES.includes(body))
|
|
340
|
+
return undefined;
|
|
341
|
+
const list = await load(body);
|
|
342
|
+
if (this.body === body)
|
|
343
|
+
this.#placeList = { body, list };
|
|
344
|
+
return list;
|
|
345
|
+
}
|
|
346
|
+
/** Lay the marks of the places over the picture as the scene state has it, or take them away. Draws nothing. */
|
|
347
|
+
#markPlaces(state = this.#sceneState) {
|
|
348
|
+
const layers = this.places;
|
|
349
|
+
const shaded = this.look !== "line" && this.#view !== undefined && !this.hasAttribute("star");
|
|
350
|
+
if (layers.length === 0 || !shaded || state === undefined) {
|
|
351
|
+
if (this.#placeLayer !== undefined) {
|
|
352
|
+
this.#placeLayer.dispose();
|
|
353
|
+
this.#placeLayer = undefined;
|
|
354
|
+
if (this.getAttribute("role") === "group")
|
|
355
|
+
this.setAttribute("role", "img");
|
|
356
|
+
}
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const body = this.body;
|
|
360
|
+
if (this.#placeList?.body !== body) {
|
|
361
|
+
if (this.#placeLoading !== body && placesLoader() !== undefined && PLACE_BODIES.includes(body)) {
|
|
362
|
+
this.#placeLoading = body;
|
|
363
|
+
void this.#loadPlaces().then(() => {
|
|
364
|
+
this.#placeLoading = undefined;
|
|
365
|
+
if (this.#placeList?.body === body)
|
|
366
|
+
this.#markPlaces();
|
|
367
|
+
}, () => {
|
|
368
|
+
this.#placeLoading = undefined;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
this.#placeLayer?.clear();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
if (this.#placeLayer === undefined && this.shadowRoot !== null) {
|
|
375
|
+
this.#placeLayer = createPlaceLayer(this.shadowRoot, {
|
|
376
|
+
lang: () => (this.getAttribute("lang") === "ja" ? "ja" : "en"),
|
|
377
|
+
pick: (place, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body, place, x: at.x, y: at.y }, bubbles: true, composed: true })),
|
|
378
|
+
});
|
|
379
|
+
// a picture with buttons in it is a group, not an image
|
|
380
|
+
if (this.getAttribute("role") === "img")
|
|
381
|
+
this.setAttribute("role", "group");
|
|
382
|
+
}
|
|
383
|
+
const w = this.#stage.clientWidth;
|
|
384
|
+
const h = this.#stage.clientHeight;
|
|
385
|
+
if (this.#placeLayer === undefined || w <= 0 || h <= 0)
|
|
386
|
+
return;
|
|
387
|
+
const aspect = w / h;
|
|
388
|
+
const half = state.extent / Math.max(0.05, state.zoom);
|
|
389
|
+
const halfW = aspect >= 1 ? half * aspect : half;
|
|
390
|
+
const halfH = aspect >= 1 ? half : half / aspect;
|
|
391
|
+
const left = state.panX * half - halfW;
|
|
392
|
+
const top = state.panY * half + halfH;
|
|
393
|
+
const facts = this.#facts();
|
|
394
|
+
const ax = facts.axesKm;
|
|
395
|
+
const scale = ax ? [ax[1] / facts.radiusKm, ax[2] / facts.radiusKm, ax[0] / facts.radiusKm] : [1, 1 - facts.flattening, 1];
|
|
396
|
+
const marks = placeMarks(this.#placeList.list, layers, {
|
|
397
|
+
centre: [0, 0, 0],
|
|
398
|
+
radius: 1,
|
|
399
|
+
pole: state.pose.pole,
|
|
400
|
+
meridian: state.pose.meridian,
|
|
401
|
+
scale,
|
|
402
|
+
toward: [0, 0, 1],
|
|
403
|
+
project: (p) => ({ x: ((p[0] - left) / (2 * halfW)) * w, y: ((top - p[1]) / (2 * halfH)) * h }),
|
|
404
|
+
width: w,
|
|
405
|
+
height: h,
|
|
406
|
+
radiusPx: (Math.min(w, h) / 2) * (state.zoom / state.extent),
|
|
407
|
+
}, facts.radiusKm);
|
|
408
|
+
this.#placeLayer.set(marks);
|
|
409
|
+
}
|
|
260
410
|
/** What the element is doing now. */
|
|
261
411
|
get state() {
|
|
262
412
|
return this.#state;
|
|
@@ -302,6 +452,17 @@ export class WakuseiBody extends HTMLElement {
|
|
|
302
452
|
this.#applyHover();
|
|
303
453
|
for (const name of ["pointerdown", "wheel", "keydown"])
|
|
304
454
|
this.addEventListener(name, this.#measure, true);
|
|
455
|
+
if (typeof ResizeObserver === "function") {
|
|
456
|
+
this.#placeResize = new ResizeObserver(() => {
|
|
457
|
+
if (this.#placeLayer !== undefined)
|
|
458
|
+
this.#markPlaces();
|
|
459
|
+
});
|
|
460
|
+
this.#placeResize.observe(this.#stage);
|
|
461
|
+
}
|
|
462
|
+
this.#placeHeard = onPlacesLoader(() => {
|
|
463
|
+
this.#placeList = undefined;
|
|
464
|
+
this.#markPlaces();
|
|
465
|
+
});
|
|
305
466
|
this.#carry();
|
|
306
467
|
this.#queue();
|
|
307
468
|
}
|
|
@@ -320,6 +481,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
320
481
|
this.#hands = undefined;
|
|
321
482
|
this.#handsKey = "";
|
|
322
483
|
this.#disposeView(true);
|
|
484
|
+
this.#placeLayer?.dispose();
|
|
485
|
+
this.#placeLayer = undefined;
|
|
486
|
+
this.#placeResize?.disconnect();
|
|
487
|
+
this.#placeResize = undefined;
|
|
488
|
+
this.#placeHeard?.();
|
|
489
|
+
this.#placeHeard = undefined;
|
|
323
490
|
}
|
|
324
491
|
attributeChangedCallback(name) {
|
|
325
492
|
if (!this.isConnected)
|
|
@@ -343,6 +510,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
343
510
|
this.#refreshLimits();
|
|
344
511
|
}
|
|
345
512
|
this.#lastAnchors = -1;
|
|
513
|
+
if (name === "places" || name === "lang" || name === "body" || name === "look" || name === "star")
|
|
514
|
+
this.#markPlaces();
|
|
346
515
|
this.#queue();
|
|
347
516
|
}
|
|
348
517
|
/** Put the picture on the page's one WebGL context and draw it, moving if it is asked to. Resolves true when it is live. A `line` look has nothing to take and resolves false. */
|
|
@@ -835,6 +1004,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
835
1004
|
},
|
|
836
1005
|
});
|
|
837
1006
|
this.#view = this.#renderer.view(this.#stage, item);
|
|
1007
|
+
this.#markPlaces(state);
|
|
838
1008
|
this.#set("loading");
|
|
839
1009
|
if (this.#visible)
|
|
840
1010
|
this.#still();
|
|
@@ -898,6 +1068,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
898
1068
|
const state = this.#sceneOf(this.#frameNow());
|
|
899
1069
|
this.#sceneState = state;
|
|
900
1070
|
scene.apply(state);
|
|
1071
|
+
this.#markPlaces(state);
|
|
901
1072
|
this.#textureWidth = scene.textureWidth;
|
|
902
1073
|
this.#door.announce();
|
|
903
1074
|
}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import type { HostId } from "./facts.ts";
|
|
2
|
+
import { type Vec3 } from "./vec.ts";
|
|
3
|
+
import { type When } from "./when.ts";
|
|
4
|
+
export type { HostId } from "./facts.ts";
|
|
5
|
+
export type { When } from "./when.ts";
|
|
6
|
+
/**
|
|
7
|
+
* The dynamical group of a moon, by this package's rule on the mean orbit. A regular moon (close in, near its planet's equator) is `major` (150 km of radius or more: the Moon, the Galilean moons, Titan, Triton, Charon and
|
|
8
|
+
* the like), `inner` (a smaller one inside its planet's innermost major moon, near the rings) or `regular` (the others: Phobos, Deimos, Hyperion, Pluto's small moons). An irregular moon (one whose mean orbit JPL gives about
|
|
9
|
+
* the ecliptic, because the Sun's pull steers it, or one over 100 planet radii out) is in one of Jupiter's groups `themisto`, `himalia`, `carpo`, `valetudo`, `ananke`, `carme` and `pasiphae`, Saturn's `inuit`, `gallic` and
|
|
10
|
+
* `norse`, or, for Uranus and Neptune, `prograde` or `retrograde`. `none` is a moon with no mean orbit in the source. The guide "Every known moon" gives the numbers of the rule.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { MOON_GROUPS, type MoonGroup } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
15
|
+
*
|
|
16
|
+
* const group: MoonGroup = "carme";
|
|
17
|
+
* console.log(MOON_GROUPS.includes(group));
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type MoonGroup = "inner" | "major" | "regular" | "themisto" | "himalia" | "carpo" | "valetudo" | "ananke" | "carme" | "pasiphae" | "inuit" | "gallic" | "norse" | "prograde" | "retrograde" | "none";
|
|
21
|
+
/**
|
|
22
|
+
* Every group, in the order the guide lists them.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { MOON_GROUPS } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
27
|
+
*
|
|
28
|
+
* console.log(MOON_GROUPS.join(", "));
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const MOON_GROUPS: readonly MoonGroup[];
|
|
32
|
+
/**
|
|
33
|
+
* How well the catalogue places a moon, by the worst angle (seen from the planet's centre) between `catalogueMoonPosition` and JPL Horizons on 2025-07-02, 2026-07-02 and 2027-07-02, dates the orbit was not set from:
|
|
34
|
+
* `close` under 1 degree, `rough` under 10 degrees, `loose` 10 degrees or more (the moon is on the right orbit but not at the right place on it), `unmeasured` when Horizons has no position to measure against, and `none`
|
|
35
|
+
* when there is no orbit. Every grade is below the package's own 29 moons (`full`), which the main entry point places within arc-seconds to minutes (see the accuracy guide).
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { findCatalogueMoon, type MoonGrade } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
40
|
+
*
|
|
41
|
+
* const grade: MoonGrade = findCatalogueMoon("Himalia")!.grade;
|
|
42
|
+
* console.log(grade);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export type MoonGrade = "close" | "rough" | "loose" | "unmeasured" | "none";
|
|
46
|
+
/**
|
|
47
|
+
* A moon's mean orbit: JPL's "Planetary Satellite Mean Elements" (the ellipse, how fast its periapsis and node turn, and the plane it is measured from), carried at those rates to 2026-01-01 and with the mean anomaly set
|
|
48
|
+
* so the moon is where JPL Horizons puts it that day, and its rate along the orbit fitted to where Horizons puts it over the next three months. The shape, the plane and the turning of the periapsis and node are JPL's; the
|
|
49
|
+
* place along the orbit and the rate are from Horizons. Kilometres and degrees; the epoch is a Julian date (TDB).
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* import { findCatalogueMoon, type MoonOrbit } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
54
|
+
*
|
|
55
|
+
* const orbit: MoonOrbit = findCatalogueMoon("Carme")!.orbit!;
|
|
56
|
+
* console.log(orbit.frame, Math.round(orbit.a), "km,", orbit.periodDays.toFixed(1), "days");
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface MoonOrbit {
|
|
60
|
+
/** The plane the angles are measured from: `ecliptic` (J2000), `equatorial` (the planet's equator) or `laplace` (the plane round which the orbit's pole turns, with its pole in `pole`). */
|
|
61
|
+
frame: "ecliptic" | "equatorial" | "laplace";
|
|
62
|
+
/** The pole of the plane, right ascension and declination in degrees (ICRF): the Laplace plane's as the source gives it, or the planet's pole (the one its moons go round, for Uranus the IAU's south pole) for `equatorial`. Not for `ecliptic`. */
|
|
63
|
+
pole?: readonly [number, number];
|
|
64
|
+
/** The epoch, a Julian date (TDB): 2461041.5 (2026-01-01) for every orbit set from Horizons. */
|
|
65
|
+
epochJd: number;
|
|
66
|
+
/** Semi-major axis, km. */
|
|
67
|
+
a: number;
|
|
68
|
+
/** Eccentricity. */
|
|
69
|
+
e: number;
|
|
70
|
+
/** Argument of periapsis, degrees. */
|
|
71
|
+
w: number;
|
|
72
|
+
/** Mean anomaly at the epoch, degrees (set from JPL Horizons). */
|
|
73
|
+
m: number;
|
|
74
|
+
/** Inclination to the plane, degrees; over 90 is a retrograde orbit. */
|
|
75
|
+
i: number;
|
|
76
|
+
/** Longitude of the ascending node, degrees, from where the plane crosses the ICRF equator (from the equinox for the ecliptic). */
|
|
77
|
+
node: number;
|
|
78
|
+
/** The sidereal period, days: the rate along the orbit as fitted to where JPL Horizons puts the moon on 2026-01-01, -02, 02-01 and 04-01, which this package uses in place of the period JPL's mean elements print. */
|
|
79
|
+
periodDays: number;
|
|
80
|
+
/** How many years the periapsis takes to turn once round, where the source gives it. */
|
|
81
|
+
apsisYears: number | null;
|
|
82
|
+
/** How many years the node takes to turn once round, where the source gives it. */
|
|
83
|
+
nodeYears: number | null;
|
|
84
|
+
/** The JPL satellite ephemeris the mean elements were taken from ("JUP347", "SAT459"). */
|
|
85
|
+
ephemeris: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Who found a moon, when, and where it was announced, as JPL's "Planetary Satellite Discovery Circumstances" lists it (the moons of the dwarf planets besides Pluto: the year and the reference of JPL's Small-Body Satellites
|
|
89
|
+
* service, which names no discoverers). `null` where the source gives nothing (the Moon has no discovery).
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* import { findCatalogueMoon, type MoonDiscovery } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
94
|
+
*
|
|
95
|
+
* const found: MoonDiscovery = findCatalogueMoon("Io")!.discovery;
|
|
96
|
+
* console.log(found.year, found.by);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export interface MoonDiscovery {
|
|
100
|
+
/** The year it was found. */
|
|
101
|
+
year: number | null;
|
|
102
|
+
/** The discoverers, or the spacecraft team, as the source writes them. */
|
|
103
|
+
by: string | null;
|
|
104
|
+
/** Where it was announced: an IAU Circular ("IAUC 8116"), a Minor Planet Electronic Circular ("MPEC 2023-A14"), a CBET, a paper, or "IAU WGPSN" for the long-named moons. */
|
|
105
|
+
reference: string | null;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Where a moon's size comes from: `measured` (JPL's "Planetary Satellite Physical Parameters", with its uncertainty), `sheet` (the radius on the moon's JPL Horizons data sheet) or `derived` (worked out here from the
|
|
109
|
+
* moon's V(1,0) magnitude and an albedo: the sheet's albedo where it gives one, else `ASSUMED_ALBEDO`, by D = 10^(3.1236 - 0.5 log10(albedo) - 0.2 V), the formula of NASA/JPL's asteroid size estimator).
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { findCatalogueMoon, type MoonSizeSource } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
114
|
+
*
|
|
115
|
+
* const from: MoonSizeSource | null = findCatalogueMoon("Callirrhoe")!.radiusFrom;
|
|
116
|
+
* console.log(from);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export type MoonSizeSource = "measured" | "sheet" | "derived";
|
|
120
|
+
/**
|
|
121
|
+
* One moon of the catalogue. A number the sources do not give is `null`, never guessed.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { findCatalogueMoon, type CatalogueMoon } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
126
|
+
*
|
|
127
|
+
* const moon: CatalogueMoon = findCatalogueMoon("S/2003 J 18")!;
|
|
128
|
+
* console.log(moon.label, moon.host, moon.group, moon.retrograde, moon.discovery.year);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export interface CatalogueMoon {
|
|
132
|
+
/** A stable id: the name in lower case ("himalia"), or the designation ("s-2003-j-18"). The package's own moons keep their ids ("hiiaka"). */
|
|
133
|
+
id: string;
|
|
134
|
+
/** The IAU name, or `null` for a moon with only a designation. */
|
|
135
|
+
name: string | null;
|
|
136
|
+
/** The Japanese name, only for the moons the package draws in full (checked katakana); `null` for the others. */
|
|
137
|
+
ja: string | null;
|
|
138
|
+
/** The provisional designation, "S/2003 J 18", where it has one. */
|
|
139
|
+
designation: string | null;
|
|
140
|
+
/** What to print: the name, else the designation. */
|
|
141
|
+
label: string;
|
|
142
|
+
/** The IAU number in Roman numerals ("XIX"), where it has one. */
|
|
143
|
+
number: string | null;
|
|
144
|
+
/** The planet or dwarf planet it goes round. */
|
|
145
|
+
host: HostId;
|
|
146
|
+
/** The JPL (NAIF) id, as Horizons knows it (501 for Io), or `null` for a moon Horizons does not have. */
|
|
147
|
+
code: number | null;
|
|
148
|
+
/** Whether it has an IAU name. */
|
|
149
|
+
named: boolean;
|
|
150
|
+
/** `false` only for a moon its source marks as not confirmed. */
|
|
151
|
+
confirmed: boolean;
|
|
152
|
+
/** Who found it and when. */
|
|
153
|
+
discovery: MoonDiscovery;
|
|
154
|
+
/** The mean orbit, or `null` when the source gives none. */
|
|
155
|
+
orbit: MoonOrbit | null;
|
|
156
|
+
/** Whether it goes round against its planet's turn (an inclination over 90 degrees), or `null` with no orbit. */
|
|
157
|
+
retrograde: boolean | null;
|
|
158
|
+
/** The dynamical group. */
|
|
159
|
+
group: MoonGroup;
|
|
160
|
+
/** The mean radius in kilometres, or `null` when nothing gives it. */
|
|
161
|
+
radiusKm: number | null;
|
|
162
|
+
/** The radius's one-sigma uncertainty, km, when `measured`. */
|
|
163
|
+
radiusSigmaKm: number | null;
|
|
164
|
+
/** Where the radius comes from. */
|
|
165
|
+
radiusFrom: MoonSizeSource | null;
|
|
166
|
+
/** The geometric albedo, where the Horizons sheet gives one. */
|
|
167
|
+
albedo: number | null;
|
|
168
|
+
/** The V(1,0) magnitude (as bright as it would be 1 au from the Sun and from us), where the Horizons sheet gives one. */
|
|
169
|
+
magnitude: number | null;
|
|
170
|
+
/**
|
|
171
|
+
* How far `catalogueMoonPosition` was from JPL Horizons: the worst distance (km) and angle seen from the planet (degrees) on 2025-07-02, 2026-07-02 and 2027-07-02 (dates the orbit was not set from), and the worst angle
|
|
172
|
+
* decades away (1990, 2000 and 2040; `null` where Horizons has none of them). `null` when not measured.
|
|
173
|
+
*/
|
|
174
|
+
accuracy: {
|
|
175
|
+
worstKm: number;
|
|
176
|
+
worstDegrees: number;
|
|
177
|
+
farDegrees: number | null;
|
|
178
|
+
} | null;
|
|
179
|
+
/** The grade of `accuracy`. */
|
|
180
|
+
grade: MoonGrade;
|
|
181
|
+
/** Whether the package draws it in full (a look, a size, its own fitted orbit or theory): then the main entry point's `moonVector` and `system` place it far better. */
|
|
182
|
+
full: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The albedo a `derived` size takes when the Horizons sheet gives none: 0.04, the albedo the sheet gives for Himalia, the largest of the irregular moons. The few other irregular moons with an albedo on their sheets have 0.03
|
|
186
|
+
* (Elara) to 0.081 (Phoebe), and Nereid 0.2; a darker moon is larger than the estimate and a brighter one smaller, so a derived radius is a guide to the size, not a measurement.
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* import { ASSUMED_ALBEDO } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
191
|
+
*
|
|
192
|
+
* console.log(ASSUMED_ALBEDO);
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
export declare const ASSUMED_ALBEDO = 0.04;
|
|
196
|
+
/**
|
|
197
|
+
* Every known moon of the planets and the dwarf planets, as JPL lists them on `MOON_CATALOGUE_FETCHED`, in the order of the planets and, within a planet, of JPL's list (the long-known moons first, then by discovery).
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { MOON_CATALOGUE } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
202
|
+
*
|
|
203
|
+
* console.log(MOON_CATALOGUE.length, "moons;", MOON_CATALOGUE.filter((m) => m.named).length, "with a name");
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export declare const MOON_CATALOGUE: readonly CatalogueMoon[];
|
|
207
|
+
/**
|
|
208
|
+
* The day the catalogue was read from JPL. New moons are announced every year; `scripts/make-moon-catalogue.py --refresh` reads the sources again and prints what changed.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```ts
|
|
212
|
+
* import { MOON_CATALOGUE_FETCHED } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
213
|
+
*
|
|
214
|
+
* console.log("moons as of", MOON_CATALOGUE_FETCHED);
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare const MOON_CATALOGUE_FETCHED: string;
|
|
218
|
+
/**
|
|
219
|
+
* How many moons a planet or dwarf planet has in the catalogue, and how many of those have a name.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* import { moonCounts, type MoonCount } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
224
|
+
*
|
|
225
|
+
* const saturn: MoonCount = moonCounts().saturn!;
|
|
226
|
+
* console.log(saturn.total, "moons of Saturn,", saturn.named, "named");
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
export interface MoonCount {
|
|
230
|
+
/** Every moon. */
|
|
231
|
+
total: number;
|
|
232
|
+
/** The moons with an IAU name. */
|
|
233
|
+
named: number;
|
|
234
|
+
/** The moons with a mean orbit, which `catalogueMoonPosition` can place. */
|
|
235
|
+
placed: number;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The counts for every planet and dwarf planet that has a moon in the catalogue.
|
|
239
|
+
*
|
|
240
|
+
* @returns A count for each host, in the catalogue's order.
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { moonCounts } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
245
|
+
*
|
|
246
|
+
* for (const [host, count] of Object.entries(moonCounts())) console.log(host, count.total);
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function moonCounts(): Partial<Record<HostId, MoonCount>>;
|
|
250
|
+
/**
|
|
251
|
+
* The moons of one planet or dwarf planet, nearest first (by the mean orbit's semi-major axis; a moon with no orbit last), optionally of one group.
|
|
252
|
+
*
|
|
253
|
+
* @param host - The planet or dwarf planet: "jupiter", "eris".
|
|
254
|
+
* @param group - A group, to narrow the list.
|
|
255
|
+
* @returns The moons, which must not be changed.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { catalogueMoonsOf } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
260
|
+
*
|
|
261
|
+
* console.log(catalogueMoonsOf("jupiter", "himalia").map((m) => m.label).join(", "));
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export declare function catalogueMoonsOf(host: HostId, group?: MoonGroup): readonly CatalogueMoon[];
|
|
265
|
+
/**
|
|
266
|
+
* Finds a moon by its id, name (English, or Japanese for the package's own moons), designation (spaces and slashes do not matter: "S/2003 J 18", "s2003j18") or JPL code (501). Ignores case and accents.
|
|
267
|
+
*
|
|
268
|
+
* @param query - The id, name, designation or code.
|
|
269
|
+
* @returns The moon, or `undefined`.
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* import { findCatalogueMoon } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
274
|
+
*
|
|
275
|
+
* console.log(findCatalogueMoon("io")?.code, findCatalogueMoon(506)?.label, findCatalogueMoon("s2003j18")?.host, findCatalogueMoon("nothing"));
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export declare function findCatalogueMoon(query: string | number): CatalogueMoon | undefined;
|
|
279
|
+
/**
|
|
280
|
+
* Where a moon is at a moment, from its planet's centre, in kilometres, in the J2000 ecliptic frame (the axes of `moonVector`): its mean orbit, turned for the precession of its periapsis and node, solved by Kepler's
|
|
281
|
+
* equation. How close that is to the moon's real place near 2026 is the moon's `accuracy` and `grade`; decades away it drifts much further (`accuracy.farDegrees`). A moon the package draws in full is placed far better
|
|
282
|
+
* by the main entry point's `moonVector`.
|
|
283
|
+
*
|
|
284
|
+
* @param moon - A moon of the catalogue, or its id, name, designation or code.
|
|
285
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
286
|
+
* @returns x, y, z in kilometres, or `undefined` for a moon with no orbit.
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```ts
|
|
290
|
+
* import { catalogueMoonPosition } from "@johnmorrisdotca/wakusei-planets/moon-catalogue";
|
|
291
|
+
*
|
|
292
|
+
* const [x, y, z] = catalogueMoonPosition("Himalia", new Date("2026-11-11T00:00:00Z"))!;
|
|
293
|
+
* console.log(Math.round(Math.hypot(x, y, z) / 1e6), "million km from Jupiter");
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
export declare function catalogueMoonPosition(moon: CatalogueMoon | string | number, when: When): Vec3 | undefined;
|