@johnmorrisdotca/wakusei-planets 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/NOTICE.md +11 -1
- package/README.md +6 -5
- package/dist/bodies/all.d.ts +1 -0
- package/dist/bodies/all.js +1 -0
- package/dist/bodies/minor.d.ts +1 -0
- package/dist/bodies/minor.js +16 -0
- package/dist/data/minor.d.ts +3 -0
- package/dist/data/minor.js +7 -0
- package/dist/data/tables.d.ts +4 -2
- package/dist/data/tables.js +1 -1
- package/dist/element.js +11 -2
- package/dist/embed.d.ts +1 -1
- package/dist/embed.js +3 -3
- package/dist/ephemeris.d.ts +7 -7
- package/dist/ephemeris.js +36 -13
- package/dist/facts.d.ts +28 -4
- package/dist/facts.js +24 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/nearest.js +6 -4
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/arrows.d.ts +29 -3
- package/dist/space/arrows.js +38 -6
- package/dist/space/bodies.d.ts +6 -6
- package/dist/space/bodies.js +6 -6
- package/dist/space/element.d.ts +4 -0
- package/dist/space/element.js +19 -4
- package/dist/space/frame.d.ts +28 -3
- package/dist/space/frame.js +40 -4
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +2 -2
- package/dist/space/scale.d.ts +4 -4
- package/dist/space/scale.js +8 -2
- package/dist/space/scene.d.ts +4 -2
- package/dist/space/scene.js +15 -14
- package/dist/stops.d.ts +1 -1
- package/dist/stops.js +4 -1
- package/dist/tables/all.d.ts +1 -0
- package/dist/tables/all.js +1 -0
- package/dist/tables/lazy.d.ts +5 -0
- package/dist/tables/lazy.js +12 -0
- package/dist/tables/minor.d.ts +1 -0
- package/dist/tables/minor.js +317 -0
- package/dist/textures/vesta-1024.webp +0 -0
- package/dist/textures/vesta-512.webp +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -2
package/dist/nearest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Which bodies are nearest to a body on a date, and when two bodies come closest over a span: for the Sun, the planets, the dwarf planets and the moons, by the angle between them in the sky of an observer
|
|
1
|
+
// Which bodies are nearest to a body on a date, and when two bodies come closest over a span: for the Sun, the planets, the dwarf planets, the minor bodies and the moons, by the angle between them in the sky of an observer
|
|
2
2
|
// or by the distance between them in space. The positions are this package's own (heliocentric, ephemeris.ts): a sky angle is astrometric (the Earth's or the observer's place at the date, the body's place when
|
|
3
3
|
// its light left, no aberration or light bending), a distance is the geometry at one instant. Each result carries the accuracy the theories are held to (docs/guides/accuracy.md). Pure: no DOM, no three.js.
|
|
4
4
|
import { heliocentric, heliocentricModel, meanSunAu, moonVector } from "./ephemeris.js";
|
|
@@ -14,12 +14,14 @@ const AU_KM = 149_597_870.7;
|
|
|
14
14
|
const LIGHT_SECONDS_PER_AU = 499.004784;
|
|
15
15
|
const DAY_MS = 86_400_000;
|
|
16
16
|
const ARCSECONDS_PER_RADIAN = 206_264.806;
|
|
17
|
-
const KINDS = ["star", "planet", "dwarf-planet", "moon"];
|
|
17
|
+
const KINDS = ["star", "planet", "dwarf-planet", "moon", "asteroid", "centaur", "comet"];
|
|
18
18
|
/** The worst direction error from the Sun in arc-seconds over 60 dates from 1800 to 2200, as the accuracy guide holds each planet to. */
|
|
19
19
|
const PLANET_ARCSECONDS = { mercury: 4.5, venus: 2.6, earth: 4, mars: 6, jupiter: 3.6, saturn: 5.7, uranus: 5, neptune: 3.4, pluto: 0.2 };
|
|
20
20
|
/** The same for a dwarf planet inside its fitted table's years. */
|
|
21
21
|
const DWARF_ARCSECONDS = { ceres: 0.3, orcus: 0.1, haumea: 0.1, quaoar: 0.15, makemake: 0.15, gonggong: 0.1, eris: 0.1, sedna: 0.1 };
|
|
22
|
-
/**
|
|
22
|
+
/** The same for a minor body inside its fitted table's years: the worst of the held-back samples of each fit (scripts/make-minor-data.py), rounded up. */
|
|
23
|
+
const MINOR_ARCSECONDS = { vesta: 1, pallas: 1, chiron: 0.6, pholus: 0.7, halley: 1 };
|
|
24
|
+
/** A dwarf planet or minor body outside its table's years runs on the osculating elements of one epoch, and Pluto outside 1800 to 2200 on JPL's approximate elements. */
|
|
23
25
|
const OSCULATING_ARCSECONDS = 3600;
|
|
24
26
|
const APPROXIMATE_ARCSECONDS = 120;
|
|
25
27
|
/** The worst direction error from the planet in degrees over 60 dates, for the Moon and each moon; a moon the accuracy guide does not measure is given 5 degrees. */
|
|
@@ -104,7 +106,7 @@ function separation(by, a, b) {
|
|
|
104
106
|
}
|
|
105
107
|
function hostErrorKm(host, ms) {
|
|
106
108
|
const model = heliocentricModel(host, ms);
|
|
107
|
-
const arcseconds = model.theory === "vsop87b" ? PLANET_ARCSECONDS[host] : model.theory === "chebyshev" ? (PLANET_ARCSECONDS[host] ?? DWARF_ARCSECONDS[host]) : model.theory === "osculating-elements" ? OSCULATING_ARCSECONDS : APPROXIMATE_ARCSECONDS;
|
|
109
|
+
const arcseconds = model.theory === "vsop87b" ? PLANET_ARCSECONDS[host] : model.theory === "chebyshev" ? (PLANET_ARCSECONDS[host] ?? DWARF_ARCSECONDS[host] ?? MINOR_ARCSECONDS[host]) : model.theory === "osculating-elements" ? OSCULATING_ARCSECONDS : APPROXIMATE_ARCSECONDS;
|
|
108
110
|
return length(heliocentric(host, ms)) * AU_KM * Math.tan(arcseconds / ARCSECONDS_PER_RADIAN);
|
|
109
111
|
}
|
|
110
112
|
/** The independent parts of how far a body's place may be off, kilometres: the planet it goes round (which its moons share) and its own part. */
|
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.33.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.33.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/arrows.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Vec3 } from "../vec.ts";
|
|
2
2
|
/**
|
|
3
|
-
* How many arrowheads an orbit line carries.
|
|
3
|
+
* How many arrowheads an orbit line carries by default: two are enough to show which way a body goes round.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -9,7 +9,33 @@ import { type Vec3 } from "../vec.ts";
|
|
|
9
9
|
* console.log(ARROWS_PER_ORBIT);
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
|
-
export declare const ARROWS_PER_ORBIT =
|
|
12
|
+
export declare const ARROWS_PER_ORBIT = 2;
|
|
13
|
+
/**
|
|
14
|
+
* The most arrowheads an orbit line may carry, whatever a page asks for.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { MAX_ARROWS_PER_ORBIT } from "@johnmorrisdotca/wakusei-planets/space";
|
|
19
|
+
*
|
|
20
|
+
* console.log(MAX_ARROWS_PER_ORBIT);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const MAX_ARROWS_PER_ORBIT = 4;
|
|
24
|
+
/**
|
|
25
|
+
* Reads the number of arrowheads a page asks for (the attribute `arrows` or the property): a whole number from 0 (none) to `MAX_ARROWS_PER_ORBIT`; more is four, less is none, and anything that is not a number is
|
|
26
|
+
* the default, `ARROWS_PER_ORBIT`.
|
|
27
|
+
*
|
|
28
|
+
* @param value - A number, the text of an attribute, or nothing.
|
|
29
|
+
* @returns How many arrowheads to draw on each orbit line.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { arrowCount } from "@johnmorrisdotca/wakusei-planets/space";
|
|
34
|
+
*
|
|
35
|
+
* console.log(arrowCount(undefined), arrowCount("3"), arrowCount(9), arrowCount("-1"), arrowCount("many"));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function arrowCount(value: unknown): number;
|
|
13
39
|
/**
|
|
14
40
|
* One arrowhead on an orbit line: where its tip is and the way it points, the way the body goes along the line.
|
|
15
41
|
*
|
|
@@ -31,7 +57,7 @@ export interface OrbitArrow {
|
|
|
31
57
|
* They show the real way the body travels, which is the same whichever way the clock runs.
|
|
32
58
|
*
|
|
33
59
|
* @param line - The orbit line, `count + 1` points whose last is near the first.
|
|
34
|
-
* @param arrows - How many arrowheads (`ARROWS_PER_ORBIT
|
|
60
|
+
* @param arrows - How many arrowheads (`ARROWS_PER_ORBIT`, two, by default; at most `MAX_ARROWS_PER_ORBIT`).
|
|
35
61
|
* @returns The arrows, each at a point of the line.
|
|
36
62
|
*
|
|
37
63
|
* @example
|
package/dist/space/arrows.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The little arrows on an orbit line that show which way the body goes, and the shapes the help mode draws round the body looked at. Pure: lines in, places and directions out; the scene turns them into lines on the screen.
|
|
2
2
|
import { add, cross, dot, RAD, scale, unit } from "../vec.js";
|
|
3
3
|
/**
|
|
4
|
-
* How many arrowheads an orbit line carries.
|
|
4
|
+
* How many arrowheads an orbit line carries by default: two are enough to show which way a body goes round.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
@@ -10,14 +10,45 @@ import { add, cross, dot, RAD, scale, unit } from "../vec.js";
|
|
|
10
10
|
* console.log(ARROWS_PER_ORBIT);
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export const ARROWS_PER_ORBIT =
|
|
13
|
+
export const ARROWS_PER_ORBIT = 2;
|
|
14
|
+
/**
|
|
15
|
+
* The most arrowheads an orbit line may carry, whatever a page asks for.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { MAX_ARROWS_PER_ORBIT } from "@johnmorrisdotca/wakusei-planets/space";
|
|
20
|
+
*
|
|
21
|
+
* console.log(MAX_ARROWS_PER_ORBIT);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const MAX_ARROWS_PER_ORBIT = 4;
|
|
25
|
+
/**
|
|
26
|
+
* Reads the number of arrowheads a page asks for (the attribute `arrows` or the property): a whole number from 0 (none) to `MAX_ARROWS_PER_ORBIT`; more is four, less is none, and anything that is not a number is
|
|
27
|
+
* the default, `ARROWS_PER_ORBIT`.
|
|
28
|
+
*
|
|
29
|
+
* @param value - A number, the text of an attribute, or nothing.
|
|
30
|
+
* @returns How many arrowheads to draw on each orbit line.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { arrowCount } from "@johnmorrisdotca/wakusei-planets/space";
|
|
35
|
+
*
|
|
36
|
+
* console.log(arrowCount(undefined), arrowCount("3"), arrowCount(9), arrowCount("-1"), arrowCount("many"));
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function arrowCount(value) {
|
|
40
|
+
const n = typeof value === "string" && value.trim() !== "" ? Number(value) : value;
|
|
41
|
+
if (typeof n !== "number" || !Number.isFinite(n))
|
|
42
|
+
return ARROWS_PER_ORBIT;
|
|
43
|
+
return Math.min(MAX_ARROWS_PER_ORBIT, Math.max(0, Math.round(n)));
|
|
44
|
+
}
|
|
14
45
|
/**
|
|
15
46
|
* Where the arrowheads go on an orbit line, and which way each points. The line is the points of `planetOrbit` as the view places them: they run from where the body is now once round in the order the body
|
|
16
47
|
* goes, so the direction of each arrow is the line's own direction there, from the point before to the point after. The arrows are spread evenly round the line and stay clear of the body, which is at its first point.
|
|
17
48
|
* They show the real way the body travels, which is the same whichever way the clock runs.
|
|
18
49
|
*
|
|
19
50
|
* @param line - The orbit line, `count + 1` points whose last is near the first.
|
|
20
|
-
* @param arrows - How many arrowheads (`ARROWS_PER_ORBIT
|
|
51
|
+
* @param arrows - How many arrowheads (`ARROWS_PER_ORBIT`, two, by default; at most `MAX_ARROWS_PER_ORBIT`).
|
|
21
52
|
* @returns The arrows, each at a point of the line.
|
|
22
53
|
*
|
|
23
54
|
* @example
|
|
@@ -31,11 +62,12 @@ export const ARROWS_PER_ORBIT = 6;
|
|
|
31
62
|
export function arrowSites(line, arrows = ARROWS_PER_ORBIT) {
|
|
32
63
|
const n = line.length - 1;
|
|
33
64
|
const out = [];
|
|
34
|
-
|
|
65
|
+
const count = arrowCount(arrows);
|
|
66
|
+
if (n < 4 || count < 1)
|
|
35
67
|
return out;
|
|
36
|
-
for (let k = 0; k <
|
|
68
|
+
for (let k = 0; k < count; k += 1) {
|
|
37
69
|
// k + 1/2 of the way round in equal steps: never at the body (the first point) or at the join
|
|
38
|
-
const i = Math.min(n - 1, Math.max(1, Math.round(((k + 0.5) /
|
|
70
|
+
const i = Math.min(n - 1, Math.max(1, Math.round(((k + 0.5) / count) * n)));
|
|
39
71
|
const before = line[i - 1];
|
|
40
72
|
const after = line[i + 1];
|
|
41
73
|
const direction = unit([after[0] - before[0], after[1] - before[1], after[2] - before[2]]);
|
package/dist/space/bodies.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BodyId, type HostId } from "../facts.ts";
|
|
2
2
|
/**
|
|
3
|
-
* What a body is: the Sun, one of the eight planets, a dwarf planet (Pluto among them) or a
|
|
3
|
+
* What a body is: the Sun, one of the eight planets, a dwarf planet (Pluto among them), a moon, or a minor body: an `asteroid` (Vesta, Pallas), a `centaur` (Chiron, Pholus) or a `comet` (Halley).
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
6
|
* ```ts
|
|
@@ -10,10 +10,10 @@ import { type BodyId, type HostId } from "../facts.ts";
|
|
|
10
10
|
* console.log(kind);
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export type SpaceKind = "star" | "planet" | "dwarf-planet" | "moon";
|
|
13
|
+
export type SpaceKind = "star" | "planet" | "dwarf-planet" | "moon" | "asteroid" | "centaur" | "comet";
|
|
14
14
|
/**
|
|
15
|
-
* Every body the package knows, in the order a hopper goes: the Sun, then each planet
|
|
16
|
-
* Moon, Mars, Phobos and Deimos, Ceres, Jupiter and its four large moons, and on to Sedna).
|
|
15
|
+
* Every body the package knows, in the order a hopper goes: the Sun, then each planet, dwarf planet and minor body from the Sun outwards, each followed by its moons nearest first (Mercury, Venus, the Earth and the
|
|
16
|
+
* Moon, Mars, Phobos and Deimos, Vesta, Ceres, Pallas, Jupiter and its four large moons, and on to Sedna).
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```ts
|
|
@@ -27,13 +27,13 @@ export declare const HOP_ORDER: readonly BodyId[];
|
|
|
27
27
|
* What kind of body a name is.
|
|
28
28
|
*
|
|
29
29
|
* @param id - A body's name.
|
|
30
|
-
* @returns `star` for the Sun, `planet` for the eight planets, `dwarf-planet` for Pluto and the others, or `
|
|
30
|
+
* @returns `star` for the Sun, `planet` for the eight planets, `dwarf-planet` for Pluto and the others, `moon`, or `asteroid`, `centaur` or `comet` for a minor body.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
34
34
|
* import { bodyKindOf } from "@johnmorrisdotca/wakusei-planets/space";
|
|
35
35
|
*
|
|
36
|
-
* console.log(bodyKindOf("ceres"), bodyKindOf("moon"));
|
|
36
|
+
* console.log(bodyKindOf("ceres"), bodyKindOf("moon"), bodyKindOf("halley"));
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
export declare function bodyKindOf(id: BodyId): SpaceKind;
|
package/dist/space/bodies.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Which bodies the space view can put at the middle of its view, and in what order a reader hops from one to the next. Pure: names in, names out.
|
|
2
2
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
3
|
-
/** Planets,
|
|
4
|
-
const SUN_ORDER = ["mercury", "venus", "earth", "mars", "ceres", "jupiter", "saturn", "uranus", "neptune", "pluto", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna"];
|
|
3
|
+
/** Planets, dwarf planets and minor bodies, ordered by the size of their orbits (the semi-major axis), each followed by its moons nearest first. */
|
|
4
|
+
const SUN_ORDER = ["mercury", "venus", "earth", "mars", "vesta", "ceres", "pallas", "jupiter", "saturn", "chiron", "halley", "uranus", "pholus", "neptune", "pluto", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna"];
|
|
5
5
|
/**
|
|
6
|
-
* Every body the package knows, in the order a hopper goes: the Sun, then each planet
|
|
7
|
-
* Moon, Mars, Phobos and Deimos, Ceres, Jupiter and its four large moons, and on to Sedna).
|
|
6
|
+
* Every body the package knows, in the order a hopper goes: the Sun, then each planet, dwarf planet and minor body from the Sun outwards, each followed by its moons nearest first (Mercury, Venus, the Earth and the
|
|
7
|
+
* Moon, Mars, Phobos and Deimos, Vesta, Ceres, Pallas, Jupiter and its four large moons, and on to Sedna).
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```ts
|
|
@@ -18,13 +18,13 @@ export const HOP_ORDER = ["sun", ...SUN_ORDER.flatMap((id) => [id, ...(MOONS_OF[
|
|
|
18
18
|
* What kind of body a name is.
|
|
19
19
|
*
|
|
20
20
|
* @param id - A body's name.
|
|
21
|
-
* @returns `star` for the Sun, `planet` for the eight planets, `dwarf-planet` for Pluto and the others, or `
|
|
21
|
+
* @returns `star` for the Sun, `planet` for the eight planets, `dwarf-planet` for Pluto and the others, `moon`, or `asteroid`, `centaur` or `comet` for a minor body.
|
|
22
22
|
*
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { bodyKindOf } from "@johnmorrisdotca/wakusei-planets/space";
|
|
26
26
|
*
|
|
27
|
-
* console.log(bodyKindOf("ceres"), bodyKindOf("moon"));
|
|
27
|
+
* console.log(bodyKindOf("ceres"), bodyKindOf("moon"), bodyKindOf("halley"));
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export function bodyKindOf(id) {
|
package/dist/space/element.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
|
+
import "../tables/minor.ts";
|
|
2
3
|
import { type BodyId } from "../facts.ts";
|
|
3
4
|
import { type SpaceKind } from "./bodies.ts";
|
|
4
5
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
@@ -152,6 +153,9 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
152
153
|
set labels(value: boolean);
|
|
153
154
|
get orbits(): boolean;
|
|
154
155
|
set orbits(value: boolean);
|
|
156
|
+
/** How many small arrowheads each orbit line carries to show which way the body goes: 2 by default, at most 4, 0 for none (the attribute `arrows` says the same). Anything else is made a whole number in that range. */
|
|
157
|
+
get arrows(): number;
|
|
158
|
+
set arrows(value: number);
|
|
155
159
|
/**
|
|
156
160
|
* Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
|
|
157
161
|
* right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
|
package/dist/space/element.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
|
+
import "../tables/minor.js";
|
|
2
3
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
3
4
|
import { createGate, frameCap } from "../gate.js";
|
|
5
|
+
import { arrowCount } from "./arrows.js";
|
|
4
6
|
import { createGameClock } from "./clock.js";
|
|
5
7
|
import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER } from "./bodies.js";
|
|
6
8
|
import { chooseLabels } from "./labels.js";
|
|
@@ -9,7 +11,7 @@ import { createDoorHost } from "../door/host.js";
|
|
|
9
11
|
import { ownCredit } from "../door/own.js";
|
|
10
12
|
import { setThreeLoader, takeRenderer } from "../scene/shared.js";
|
|
11
13
|
import { texturePaths, tilesBase } from "../scene/textures.js";
|
|
12
|
-
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
14
|
+
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
13
15
|
import { moonOffset } from "../scene/orient.js";
|
|
14
16
|
import { moonDistance, placeBodies, radiusIn } from "./scale.js";
|
|
15
17
|
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
@@ -83,7 +85,7 @@ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;ove
|
|
|
83
85
|
* ```
|
|
84
86
|
*/
|
|
85
87
|
export class WakuseiSpace extends HTMLElement {
|
|
86
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data"];
|
|
88
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data", "arrows"];
|
|
87
89
|
#model = newSpaceModel();
|
|
88
90
|
#clock = createGameClock("now", 1);
|
|
89
91
|
#view;
|
|
@@ -131,6 +133,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
131
133
|
this.#model.mode = this.getAttribute("scale") === "compressed" ? "compressed" : "true";
|
|
132
134
|
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
133
135
|
this.#model.orbits = this.getAttribute("orbits") !== "off";
|
|
136
|
+
this.#model.arrowCount = arrowCount(this.getAttribute("arrows"));
|
|
134
137
|
this.#model.help = this.hasAttribute("help") && this.getAttribute("help") !== "off";
|
|
135
138
|
this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
|
|
136
139
|
this.#model.light = readLight(this.getAttribute("light"));
|
|
@@ -218,6 +221,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
218
221
|
this.labels = value !== "off";
|
|
219
222
|
else if (name === "orbits")
|
|
220
223
|
this.orbits = value !== "off";
|
|
224
|
+
else if (name === "arrows")
|
|
225
|
+
this.arrows = arrowCount(value);
|
|
221
226
|
else if (name === "help")
|
|
222
227
|
this.help = value !== null && value !== "off";
|
|
223
228
|
else if (name === "look")
|
|
@@ -302,6 +307,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
302
307
|
this.#model.orbits = value;
|
|
303
308
|
this.#gate?.request();
|
|
304
309
|
}
|
|
310
|
+
/** How many small arrowheads each orbit line carries to show which way the body goes: 2 by default, at most 4, 0 for none (the attribute `arrows` says the same). Anything else is made a whole number in that range. */
|
|
311
|
+
get arrows() {
|
|
312
|
+
return this.#model.arrowCount;
|
|
313
|
+
}
|
|
314
|
+
set arrows(value) {
|
|
315
|
+
this.#model.arrowCount = arrowCount(value);
|
|
316
|
+
this.#gate?.request();
|
|
317
|
+
}
|
|
305
318
|
/**
|
|
306
319
|
* Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
|
|
307
320
|
* right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
|
|
@@ -463,6 +476,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
463
476
|
geo = frame.planets[id];
|
|
464
477
|
else if (SPACE_DWARFS.includes(id))
|
|
465
478
|
geo = frame.dwarfs[id];
|
|
479
|
+
else if (SPACE_MINORS.includes(id))
|
|
480
|
+
geo = frame.minors[id];
|
|
466
481
|
else if (host !== undefined && (SPACE_PLANETS.includes(host) || SPACE_DWARFS.includes(host))) {
|
|
467
482
|
// a moon: its planet's place and its offset in the planet's radii
|
|
468
483
|
const at = SPACE_DWARFS.includes(host) ? frame.dwarfs[host] : frame.planets[host];
|
|
@@ -738,14 +753,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
738
753
|
ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
|
|
739
754
|
}
|
|
740
755
|
}
|
|
741
|
-
/** How sure a body's name is of its place: the body looked at first, then the Sun, the planets, the dwarf planets and the moons. */
|
|
756
|
+
/** How sure a body's name is of its place: the body looked at first, then the Sun, the planets, the dwarf planets and minor bodies, and the moons. */
|
|
742
757
|
#rank(id) {
|
|
743
758
|
if (id === this.#model.focus)
|
|
744
759
|
return 0;
|
|
745
760
|
if (id === "sun")
|
|
746
761
|
return 1;
|
|
747
762
|
const kind = bodyKindOf(id);
|
|
748
|
-
return kind === "moon" ? 4 : kind === "
|
|
763
|
+
return kind === "moon" ? 4 : kind === "planet" || kind === "star" ? 2 : 3;
|
|
749
764
|
}
|
|
750
765
|
#widths = new WeakMap();
|
|
751
766
|
/** The width of a name's box on the screen, measured when its words change and not at every frame. */
|
package/dist/space/frame.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DwarfId } from "../facts.ts";
|
|
1
|
+
import { type DwarfId, type MinorId } from "../facts.ts";
|
|
2
2
|
import { type Vec3 } from "../vec.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A position or direction as `[x, y, z]` in the scene's axes: J2000 equatorial, x to the vernal equinox, y north.
|
|
@@ -68,6 +68,29 @@ export declare const SPACE_DWARFS: readonly ["ceres", "orcus", "haumea", "quaoar
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
export type SpaceDwarf = DwarfId;
|
|
71
|
+
/**
|
|
72
|
+
* The minor bodies the space view places: the asteroids Vesta and Pallas, the centaurs Chiron and Pholus and Halley's comet.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { SPACE_MINORS } from "@johnmorrisdotca/wakusei-planets/space";
|
|
77
|
+
*
|
|
78
|
+
* console.log(SPACE_MINORS.join(", "));
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const SPACE_MINORS: readonly ["vesta", "pallas", "chiron", "pholus", "halley"];
|
|
82
|
+
/**
|
|
83
|
+
* One of the minor bodies in `SPACE_MINORS`.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { planetOrbit, type SpaceMinor } from "@johnmorrisdotca/wakusei-planets/space";
|
|
88
|
+
*
|
|
89
|
+
* const minor: SpaceMinor = "halley";
|
|
90
|
+
* console.log(planetOrbit(minor, Date.UTC(2026, 10, 2), 8).length);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export type SpaceMinor = MinorId;
|
|
71
94
|
/**
|
|
72
95
|
* One of the planets in `SPACE_PLANETS`.
|
|
73
96
|
*
|
|
@@ -98,6 +121,8 @@ export interface SpaceFrame {
|
|
|
98
121
|
planets: Record<SpacePlanet, Vec3>;
|
|
99
122
|
/** The dwarf planets besides Pluto, from their osculating elements (good for a few years either side of 2026). */
|
|
100
123
|
dwarfs: Record<SpaceDwarf, Vec3>;
|
|
124
|
+
/** The minor bodies: Vesta, Pallas, Chiron, Pholus and Halley's comet, from tables fitted to Horizons (outside their years, from osculating elements). */
|
|
125
|
+
minors: Record<SpaceMinor, Vec3>;
|
|
101
126
|
}
|
|
102
127
|
/**
|
|
103
128
|
* The state of the sky at `ms`: the Sun, the Moon and eight planets as seen from the Earth's centre, worked out by this package's own models in a fraction of a millisecond.
|
|
@@ -162,7 +187,7 @@ export declare function createTrack(initialStepMs?: number): {
|
|
|
162
187
|
/**
|
|
163
188
|
* The path a planet or the Earth takes round the Sun, as `count + 1` points round one trip from where the planet is at `ms`, from the Sun, in astronomical units and the scene's axes.
|
|
164
189
|
*
|
|
165
|
-
* @param id - The planet, the dwarf planet or `earth`.
|
|
190
|
+
* @param id - The planet, the dwarf planet, the minor body or `earth`.
|
|
166
191
|
* @param ms - The moment the path starts at, in milliseconds since the Unix epoch.
|
|
167
192
|
* @param count - How many segments to cut the trip into.
|
|
168
193
|
* @returns `count + 1` points; the last is near the first.
|
|
@@ -175,7 +200,7 @@ export declare function createTrack(initialStepMs?: number): {
|
|
|
175
200
|
* console.log(points.length);
|
|
176
201
|
* ```
|
|
177
202
|
*/
|
|
178
|
-
export declare function planetOrbit(id: SpacePlanet | SpaceDwarf | "earth", ms: number, count?: number): Vec3[];
|
|
203
|
+
export declare function planetOrbit(id: SpacePlanet | SpaceDwarf | SpaceMinor | "earth", ms: number, count?: number): Vec3[];
|
|
179
204
|
/**
|
|
180
205
|
* The path the Moon takes round the Earth, as `count + 1` points round one sidereal month from where the Moon is at `ms`, from the Earth's centre, in astronomical units and the scene's axes. The first
|
|
181
206
|
* point is the Moon's own place at `ms` and the last is the first again, so the line is closed and passes through the Moon.
|
package/dist/space/frame.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Where the Sun, the Moon and the planets are, as seen from the centre of the Earth, for any date, from this package's own models (VSOP87B planets, the Pluto table, ELP2000 Moon).
|
|
2
2
|
// Positions are geometric (no aberration or nutation, about 20 arc-seconds), in the painter's axes: J2000 equatorial, x to the vernal equinox, y north. Pure: no DOM, no three.js.
|
|
3
3
|
import { heliocentric, moonGeocentric } from "../ephemeris.js";
|
|
4
|
-
import { DWARF_IDS } from "../facts.js";
|
|
4
|
+
import { DWARF_IDS, MINOR_IDS } from "../facts.js";
|
|
5
5
|
import { DWARF_ELEMENTS } from "../data/dwarf.js";
|
|
6
|
+
import { MINOR_ELEMENTS } from "../data/minor.js";
|
|
6
7
|
import { OBLIQUITY, RAD } from "../vec.js";
|
|
7
8
|
import { earthPosition } from "../theory.js";
|
|
8
9
|
import { DAY_MS } from "../clock.js";
|
|
@@ -52,6 +53,17 @@ export const SPACE_PLANETS = ["mercury", "venus", "mars", "jupiter", "saturn", "
|
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
55
|
export const SPACE_DWARFS = DWARF_IDS;
|
|
56
|
+
/**
|
|
57
|
+
* The minor bodies the space view places: the asteroids Vesta and Pallas, the centaurs Chiron and Pholus and Halley's comet.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { SPACE_MINORS } from "@johnmorrisdotca/wakusei-planets/space";
|
|
62
|
+
*
|
|
63
|
+
* console.log(SPACE_MINORS.join(", "));
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export const SPACE_MINORS = MINOR_IDS;
|
|
55
67
|
/** An ecliptic J2000 vector in the scene's axes (equatorial J2000, y north). */
|
|
56
68
|
const scene = (v) => {
|
|
57
69
|
const c = Math.cos(OBLIQUITY * RAD);
|
|
@@ -84,8 +96,13 @@ export function frameAt(ms) {
|
|
|
84
96
|
const h = heliocentric(id, ms);
|
|
85
97
|
dwarfs[id] = scene([h[0] - earth[0], h[1] - earth[1], h[2] - earth[2]]);
|
|
86
98
|
}
|
|
99
|
+
const minors = {};
|
|
100
|
+
for (const id of SPACE_MINORS) {
|
|
101
|
+
const h = heliocentric(id, ms);
|
|
102
|
+
minors[id] = scene([h[0] - earth[0], h[1] - earth[1], h[2] - earth[2]]);
|
|
103
|
+
}
|
|
87
104
|
const moon = moonGeocentric(ms);
|
|
88
|
-
return { ms, sun: scene([-earth[0], -earth[1], -earth[2]]), moon: scene([moon[0] / AU_KM, moon[1] / AU_KM, moon[2] / AU_KM]), planets, dwarfs };
|
|
105
|
+
return { ms, sun: scene([-earth[0], -earth[1], -earth[2]]), moon: scene([moon[0] / AU_KM, moon[1] / AU_KM, moon[2] / AU_KM]), planets, dwarfs, minors };
|
|
89
106
|
}
|
|
90
107
|
const lerp3 = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
91
108
|
/**
|
|
@@ -112,7 +129,10 @@ export function blend(a, b, t) {
|
|
|
112
129
|
const dwarfs = {};
|
|
113
130
|
for (const id of SPACE_DWARFS)
|
|
114
131
|
dwarfs[id] = lerp3(a.dwarfs[id], b.dwarfs[id], t);
|
|
115
|
-
|
|
132
|
+
const minors = {};
|
|
133
|
+
for (const id of SPACE_MINORS)
|
|
134
|
+
minors[id] = lerp3(a.minors[id], b.minors[id], t);
|
|
135
|
+
return { ms: a.ms + (b.ms - a.ms) * t, sun: lerp3(a.sun, b.sun, t), moon: lerp3(a.moon, b.moon, t), planets, dwarfs, minors };
|
|
116
136
|
}
|
|
117
137
|
/**
|
|
118
138
|
* Answers for any moment from two real ones: `at(ms)` works out a frame only when `ms` leaves the span the last two answers cover, and then looks `stepMs` ahead, so playing
|
|
@@ -169,11 +189,12 @@ const PERIOD_DAYS = {
|
|
|
169
189
|
mercury: 87.97, venus: 224.7, earth: 365.256, mars: 686.98, jupiter: 4332.6, saturn: 10_759, uranus: 30_688, neptune: 60_182, pluto: 90_560,
|
|
170
190
|
// a dwarf planet's own: a full turn of its mean motion
|
|
171
191
|
...Object.fromEntries(SPACE_DWARFS.map((id) => [id, 360 / DWARF_ELEMENTS[id].n])),
|
|
192
|
+
...Object.fromEntries(SPACE_MINORS.map((id) => [id, 360 / MINOR_ELEMENTS[id].n])),
|
|
172
193
|
};
|
|
173
194
|
/**
|
|
174
195
|
* The path a planet or the Earth takes round the Sun, as `count + 1` points round one trip from where the planet is at `ms`, from the Sun, in astronomical units and the scene's axes.
|
|
175
196
|
*
|
|
176
|
-
* @param id - The planet, the dwarf planet or `earth`.
|
|
197
|
+
* @param id - The planet, the dwarf planet, the minor body or `earth`.
|
|
177
198
|
* @param ms - The moment the path starts at, in milliseconds since the Unix epoch.
|
|
178
199
|
* @param count - How many segments to cut the trip into.
|
|
179
200
|
* @returns `count + 1` points; the last is near the first.
|
|
@@ -188,6 +209,21 @@ const PERIOD_DAYS = {
|
|
|
188
209
|
*/
|
|
189
210
|
export function planetOrbit(id, ms, count = 96) {
|
|
190
211
|
const points = [];
|
|
212
|
+
const minor = SPACE_MINORS.includes(id) ? MINOR_ELEMENTS[id] : SPACE_DWARFS.includes(id) ? DWARF_ELEMENTS[id] : undefined;
|
|
213
|
+
if (minor !== undefined && minor.e > 0.15) {
|
|
214
|
+
// a long ellipse (Halley's, Pholus's, Sedna's, Eris's) is cut at equal steps of the eccentric anomaly, not of time: cut in time, the sharp turn near the Sun is one straight stroke with corners, and the slow far side most of the points
|
|
215
|
+
const e = minor.e;
|
|
216
|
+
const m0 = ((minor.m + (minor.n * (ms - minor.epoch)) / DAY_MS) * Math.PI) / 180;
|
|
217
|
+
let e0 = m0;
|
|
218
|
+
for (let k = 0; k < 40; k += 1)
|
|
219
|
+
e0 -= (e0 - e * Math.sin(e0) - m0) / (1 - e * Math.cos(e0));
|
|
220
|
+
const mean = (anomaly) => anomaly - e * Math.sin(anomaly);
|
|
221
|
+
for (let i = 0; i <= count; i += 1) {
|
|
222
|
+
const anomaly = e0 + (i / count) * 2 * Math.PI;
|
|
223
|
+
points.push(scene(heliocentric(id, ms + ((mean(anomaly) - mean(e0)) / ((minor.n * Math.PI) / 180)) * DAY_MS)));
|
|
224
|
+
}
|
|
225
|
+
return points;
|
|
226
|
+
}
|
|
191
227
|
for (let i = 0; i <= count; i += 1)
|
|
192
228
|
points.push(scene(heliocentric(id, ms + (i / count) * PERIOD_DAYS[id] * DAY_MS)));
|
|
193
229
|
return points;
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_PLANETS, type SpaceDwarf, type SpaceFrame, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
1
|
+
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS, type SpaceDwarf, type SpaceFrame, type SpaceMinor, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
2
2
|
export { compress, MOON_COMPRESSED, moonDistance, 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, type LabelBox } from "./labels.ts";
|
|
6
6
|
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, type SpaceKind } from "./bodies.ts";
|
|
7
7
|
export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from "./beside.ts";
|
|
8
|
-
export { ARROWS_PER_ORBIT, arrowSites, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
|
|
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";
|
package/dist/space/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
2
|
+
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
3
3
|
export { compress, MOON_COMPRESSED, moonDistance, 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 } from "./labels.js";
|
|
7
7
|
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf } from "./bodies.js";
|
|
8
8
|
export { besideMoon, BESIDE_RADII } from "./beside.js";
|
|
9
|
-
export { ARROWS_PER_ORBIT, arrowSites, chevron, spinArrow } from "./arrows.js";
|
|
9
|
+
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
|
|
10
10
|
export { spinAxis } from "./spin.js";
|
package/dist/space/scale.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Vec3 } from "../vec.ts";
|
|
2
|
-
import { type SpaceDwarf, type SpaceFrame, type SpacePlanet } from "./frame.ts";
|
|
2
|
+
import { type SpaceDwarf, type SpaceFrame, type SpaceMinor, type SpacePlanet } from "./frame.ts";
|
|
3
3
|
/**
|
|
4
4
|
* The scale the space view is drawn in: `compressed` squeezes the distances so the Moon, the Sun and Neptune fit one view, and `true` keeps the real ones.
|
|
5
5
|
*
|
|
@@ -109,11 +109,11 @@ export declare function placeSun(mode: ScaleMode, geo: Vec3): Vec3;
|
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
111
|
export declare function placeAround(mode: ScaleMode, sun: Vec3, helio: Vec3): Vec3;
|
|
112
|
-
type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf;
|
|
112
|
+
type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor;
|
|
113
113
|
/**
|
|
114
114
|
* A body's radius in Earth radii: the real one, or one large enough to see in a compressed view.
|
|
115
115
|
*
|
|
116
|
-
* @param id - The Sun, the Earth, the Moon, a planet or a
|
|
116
|
+
* @param id - The Sun, the Earth, the Moon, a planet, a dwarf planet or a minor body.
|
|
117
117
|
* @param mode - The scale.
|
|
118
118
|
* @returns The radius to draw it at, in Earth radii.
|
|
119
119
|
*
|
|
@@ -124,7 +124,7 @@ type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf;
|
|
|
124
124
|
* console.log(radiusIn("moon", "true").toFixed(3), radiusIn("moon", "compressed"));
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
|
-
export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf, mode: ScaleMode): number;
|
|
127
|
+
export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor, mode: ScaleMode): number;
|
|
128
128
|
/**
|
|
129
129
|
* How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
|
|
130
130
|
* reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's.
|
package/dist/space/scale.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
4
4
|
import { meanSunAu } from "../ephemeris.js";
|
|
5
5
|
import { moonOffset } from "../scene/orient.js";
|
|
6
|
-
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, SPACE_DWARFS } from "./frame.js";
|
|
6
|
+
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, SPACE_DWARFS, SPACE_MINORS } from "./frame.js";
|
|
7
7
|
const MOON_AU = 0.00257;
|
|
8
8
|
/**
|
|
9
9
|
* The Moon's distance in a compressed view, in Earth radii (the true one is about 60). It is well inside the gap between the Earth's orbit and the next one in.
|
|
@@ -125,10 +125,12 @@ export function placeAround(mode, sun, helio) {
|
|
|
125
125
|
const COMPRESSED_RADIUS = { sun: 5, earth: 1, moon: 0.273, mercury: 0.5, venus: 0.8, mars: 0.6, jupiter: 1.8, saturn: 1.6, uranus: 1.0, neptune: 1.0, pluto: 0.4 };
|
|
126
126
|
/** A dwarf planet in a compressed view: its true size or this, whichever is the larger, in Earth radii. */
|
|
127
127
|
const COMPRESSED_DWARF = 0.3;
|
|
128
|
+
/** A minor body in a compressed view: its true size or this, whichever is the larger, in Earth radii (a speck beside a dwarf planet). */
|
|
129
|
+
const COMPRESSED_MINOR = 0.2;
|
|
128
130
|
/**
|
|
129
131
|
* A body's radius in Earth radii: the real one, or one large enough to see in a compressed view.
|
|
130
132
|
*
|
|
131
|
-
* @param id - The Sun, the Earth, the Moon, a planet or a
|
|
133
|
+
* @param id - The Sun, the Earth, the Moon, a planet, a dwarf planet or a minor body.
|
|
132
134
|
* @param mode - The scale.
|
|
133
135
|
* @returns The radius to draw it at, in Earth radii.
|
|
134
136
|
*
|
|
@@ -140,6 +142,8 @@ const COMPRESSED_DWARF = 0.3;
|
|
|
140
142
|
* ```
|
|
141
143
|
*/
|
|
142
144
|
export function radiusIn(id, mode) {
|
|
145
|
+
if (SPACE_MINORS.includes(id))
|
|
146
|
+
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : Math.max(COMPRESSED_MINOR, BODIES[id].radiusKm / EARTH_RADIUS_KM);
|
|
143
147
|
if (SPACE_DWARFS.includes(id))
|
|
144
148
|
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : Math.max(COMPRESSED_DWARF, BODIES[id].radiusKm / EARTH_RADIUS_KM);
|
|
145
149
|
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : COMPRESSED_RADIUS[id];
|
|
@@ -220,6 +224,8 @@ export function placeBodies(mode, frame) {
|
|
|
220
224
|
all[id] = placeAround(mode, sun, helio(geo));
|
|
221
225
|
for (const [id, geo] of Object.entries(frame.dwarfs))
|
|
222
226
|
all[id] = placeAround(mode, sun, helio(geo));
|
|
227
|
+
for (const [id, geo] of Object.entries(frame.minors))
|
|
228
|
+
all[id] = placeAround(mode, sun, helio(geo));
|
|
223
229
|
return all;
|
|
224
230
|
}
|
|
225
231
|
/**
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type SpaceThree = ThreeParts & Pick<typeof THREE, "PerspectiveCamera">;
|
|
|
15
15
|
/** The camera's distance, in radii of the body it looks at, at which that body fills the view at zoom 1. */
|
|
16
16
|
export declare const FIT_DISTANCE = 4.1;
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
18
|
+
* The twenty-four bodies the space view places, names and lets a reader choose: the Earth, the Sun, the Moon, the seven other planets, Pluto, the eight other dwarf planets and the five minor bodies (Vesta, Pallas, Chiron, Pholus and Halley). The moons of the planets and of the dwarf planets are placed round their hosts.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts no-run
|
|
@@ -24,7 +24,7 @@ export declare const FIT_DISTANCE = 4.1;
|
|
|
24
24
|
* console.log(SPACE_BODIES.join(", "));
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare const SPACE_BODIES: readonly ["earth", "sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "ceres", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna"];
|
|
27
|
+
export declare const SPACE_BODIES: readonly ["earth", "sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "ceres", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna", "vesta", "pallas", "chiron", "pholus", "halley"];
|
|
28
28
|
/**
|
|
29
29
|
* One of the bodies in `SPACE_BODIES`, by the package's usual lower-case name.
|
|
30
30
|
*
|
|
@@ -155,6 +155,8 @@ export interface SpaceModel {
|
|
|
155
155
|
arrows: Record<string, OrbitArrow[]>;
|
|
156
156
|
/** Help mode: draw, on the body looked at, the axis it turns about and a curved arrow showing which way it turns. */
|
|
157
157
|
help: boolean;
|
|
158
|
+
/** How many arrowheads each orbit line carries: 0 to `MAX_ARROWS_PER_ORBIT`, two by default. */
|
|
159
|
+
arrowCount: number;
|
|
158
160
|
/** How long an arrowhead drawn at the last draw is on the screen, in CSS pixels (measured from its own points), or 0 when none was drawn. */
|
|
159
161
|
arrowPx: number;
|
|
160
162
|
/** What the help arrow drew at the last draw, or null: the body, the axis it spins about (right-hand rule), the north pole, and the axis the drawn arc itself turns about (measured from its points). */
|