@johnmorrisdotca/wakusei-planets 0.31.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 +15 -0
- package/NOTICE.md +16 -1
- package/README.md +60 -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/data-door.d.ts +357 -0
- package/dist/data-door.js +393 -0
- package/dist/door/book.d.ts +133 -0
- package/dist/door/book.js +256 -0
- package/dist/door/host.d.ts +30 -0
- package/dist/door/host.js +44 -0
- package/dist/door/index.d.ts +6 -0
- package/dist/door/index.js +10 -0
- package/dist/door/map.d.ts +152 -0
- package/dist/door/map.js +162 -0
- package/dist/door/own.d.ts +36 -0
- package/dist/door/own.js +86 -0
- package/dist/door/points.d.ts +61 -0
- package/dist/door/points.js +175 -0
- package/dist/door/small-bodies.d.ts +157 -0
- package/dist/door/small-bodies.js +148 -0
- package/dist/element.d.ts +21 -0
- package/dist/element.js +85 -6
- 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/body.d.ts +4 -1
- package/dist/scene/body.js +2 -1
- package/dist/scene/detail.d.ts +29 -12
- package/dist/scene/detail.js +217 -135
- package/dist/scene/painter.d.ts +3 -0
- package/dist/scene/painter.js +7 -4
- package/dist/scene/textures.d.ts +9 -2
- package/dist/scene/textures.js +17 -0
- 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 +28 -0
- package/dist/space/element.js +74 -6
- 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 +12 -2
- package/dist/space/scene.js +43 -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 +17 -2
package/dist/scene/textures.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type * as THREE from "three";
|
|
2
|
+
import type { SourceBook } from "../door/book.ts";
|
|
3
|
+
import { type BodyMapSource } from "../door/map.ts";
|
|
2
4
|
/**
|
|
3
5
|
* The default home of the surface pictures: the files of this exact version on jsDelivr. Set `texture-base` on an element to serve them yourself.
|
|
4
6
|
*
|
|
@@ -9,7 +11,7 @@ import type * as THREE from "three";
|
|
|
9
11
|
* console.log(TEXTURE_BASE);
|
|
10
12
|
* ```
|
|
11
13
|
*/
|
|
12
|
-
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/";
|
|
13
15
|
/**
|
|
14
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
|
|
15
17
|
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
@@ -21,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
|
|
|
21
23
|
* console.log(TEXTURE_FAR_BASE);
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
24
|
-
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/";
|
|
25
27
|
/**
|
|
26
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:
|
|
27
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.
|
|
@@ -37,6 +39,11 @@ export declare const TILES_BASE = "https://johnmorrisdotca.github.io/wakusei-pla
|
|
|
37
39
|
export declare const slash: (base: string) => string;
|
|
38
40
|
/** The folder of finer map tiles for an element: its `tiles` attribute (`off` or `none` for none), else `TILES_BASE` unless the element names its own `texture-base`. */
|
|
39
41
|
export declare function tilesBase(element: Element): string | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* The map source a body is drawn from: the last colour source a page added for it (`addSource`), else the package's own folder of tiles at `base` (the `tiles` attribute), else `undefined`, and the body keeps its own
|
|
44
|
+
* 2048 pixel picture. One folder source is made for each address, so every element of a page shares it.
|
|
45
|
+
*/
|
|
46
|
+
export declare function mapSourceFor(book: SourceBook, base: string | undefined, body: string): BodyMapSource | undefined;
|
|
40
47
|
export declare function texturePaths(element: Element): {
|
|
41
48
|
textureBase(): string;
|
|
42
49
|
farBase(): string;
|
package/dist/scene/textures.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tilesSource } from "../door/map.js";
|
|
1
2
|
import { VERSION } from "../version.js";
|
|
2
3
|
/**
|
|
3
4
|
* The default home of the surface pictures: the files of this exact version on jsDelivr. Set `texture-base` on an element to serve them yourself.
|
|
@@ -44,6 +45,22 @@ export function tilesBase(element) {
|
|
|
44
45
|
return slash(own);
|
|
45
46
|
return element.hasAttribute("texture-base") ? undefined : TILES_BASE;
|
|
46
47
|
}
|
|
48
|
+
const folders = new Map();
|
|
49
|
+
/**
|
|
50
|
+
* The map source a body is drawn from: the last colour source a page added for it (`addSource`), else the package's own folder of tiles at `base` (the `tiles` attribute), else `undefined`, and the body keeps its own
|
|
51
|
+
* 2048 pixel picture. One folder source is made for each address, so every element of a page shares it.
|
|
52
|
+
*/
|
|
53
|
+
export function mapSourceFor(book, base, body) {
|
|
54
|
+
const added = book.mapSources(body, "colour")[0];
|
|
55
|
+
if (added !== undefined)
|
|
56
|
+
return added;
|
|
57
|
+
if (base === undefined)
|
|
58
|
+
return undefined;
|
|
59
|
+
let own = folders.get(base);
|
|
60
|
+
if (own === undefined)
|
|
61
|
+
folders.set(base, (own = tilesSource(base)));
|
|
62
|
+
return own;
|
|
63
|
+
}
|
|
47
64
|
export function texturePaths(element) {
|
|
48
65
|
const textureBase = () => {
|
|
49
66
|
const own = element.getAttribute("texture-base");
|
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,6 +1,9 @@
|
|
|
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";
|
|
5
|
+
import type { Credit, DataSource } from "../data-door.ts";
|
|
6
|
+
import { type DoorHost } from "../door/host.ts";
|
|
4
7
|
import { setThreeLoader } from "../scene/shared.ts";
|
|
5
8
|
import { type SpacePlanet } from "./frame.ts";
|
|
6
9
|
import { type ScaleMode } from "./scale.ts";
|
|
@@ -150,6 +153,9 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
150
153
|
set labels(value: boolean);
|
|
151
154
|
get orbits(): boolean;
|
|
152
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);
|
|
153
159
|
/**
|
|
154
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
|
|
155
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.
|
|
@@ -233,6 +239,23 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
233
239
|
get riding(): Riding | null;
|
|
234
240
|
/** The zoom that shows a part of the sky: the Earth alone, the Moon's orbit, the Sun, the planets out to Mars, all of them, or a planet's nearer moons, at this scale and moment. */
|
|
235
241
|
zoomFor(named: SpacePreset | string): number;
|
|
242
|
+
/**
|
|
243
|
+
* The outside sources of this view (the data door): maps of a body, which take the place of the folder of tiles for it, and records of small bodies, which are drawn as points in one instanced draw. Each carries its own
|
|
244
|
+
* licence and credit. Assign a list to replace them; a source `validateSource` refuses throws a `TypeError` and changes nothing. A property, not an attribute: data is not text.
|
|
245
|
+
*/
|
|
246
|
+
get sources(): readonly DataSource[];
|
|
247
|
+
set sources(list: readonly DataSource[]);
|
|
248
|
+
/** Adds one source (checked at once: a `TypeError` for an empty credit, no licence, a clashing id or a map source with no body). Returns the function that removes it. */
|
|
249
|
+
addSource(source: DataSource): () => void;
|
|
250
|
+
/** Removes a source by id: its loads are aborted, its tiles and records freed, its points and window taken off the picture, and its credit goes. Returns whether there was one. */
|
|
251
|
+
removeSource(id: string): boolean;
|
|
252
|
+
/** Switches a source off (`false`) or on, for a layers panel. */
|
|
253
|
+
enableSource(id: string, on: boolean): void;
|
|
254
|
+
/**
|
|
255
|
+
* The sources whose data was in the last drawn frame, the package's own first: the surface pictures and the positions of the bodies, the finer map tiles where a window of them is on a body, and each source of yours that
|
|
256
|
+
* gave points or tiles. `creditLine(credits, "en" | "ja")` from `@johnmorrisdotca/wakusei-planets/door` writes them with the licences. `wakusei-creditschange` fires when this set changes (not at each frame), with `detail: { credits }`.
|
|
257
|
+
*/
|
|
258
|
+
credits(): Credit[];
|
|
236
259
|
/** What the element is doing, for a page or a test. */
|
|
237
260
|
get stats(): {
|
|
238
261
|
state: SpaceState;
|
|
@@ -276,6 +299,11 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
276
299
|
lost: boolean;
|
|
277
300
|
gliding: boolean;
|
|
278
301
|
};
|
|
302
|
+
/** The data door: the small bodies in the one instanced draw, and what the sources have done (tile loads started, failed and refused, bytes held, records read). */
|
|
303
|
+
door: {
|
|
304
|
+
points: number;
|
|
305
|
+
sources: ReturnType<DoorHost["book"]["stats"]>;
|
|
306
|
+
};
|
|
279
307
|
/** The orbit lines drawn at the last draw (`earth`, the planets, `moon`), and how far each body is from its own line as a fraction of the line's radius: a body on its line reads under 0.01. */
|
|
280
308
|
orbits: {
|
|
281
309
|
drawn: string[];
|
package/dist/space/element.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
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";
|
|
7
9
|
import { createPainter } from "../scene/painter.js";
|
|
10
|
+
import { createDoorHost } from "../door/host.js";
|
|
11
|
+
import { ownCredit } from "../door/own.js";
|
|
8
12
|
import { setThreeLoader, takeRenderer } from "../scene/shared.js";
|
|
9
13
|
import { texturePaths, tilesBase } from "../scene/textures.js";
|
|
10
|
-
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";
|
|
11
15
|
import { moonOffset } from "../scene/orient.js";
|
|
12
16
|
import { moonDistance, placeBodies, radiusIn } from "./scale.js";
|
|
13
17
|
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
@@ -81,7 +85,7 @@ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;ove
|
|
|
81
85
|
* ```
|
|
82
86
|
*/
|
|
83
87
|
export class WakuseiSpace extends HTMLElement {
|
|
84
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang"];
|
|
88
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data", "arrows"];
|
|
85
89
|
#model = newSpaceModel();
|
|
86
90
|
#clock = createGameClock("now", 1);
|
|
87
91
|
#view;
|
|
@@ -101,6 +105,20 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
101
105
|
#scaleLine;
|
|
102
106
|
#hint = "choose to look at it";
|
|
103
107
|
#painter;
|
|
108
|
+
#door = createDoorHost(this, {
|
|
109
|
+
// the package's own: the pictures and the positions of the bodies drawn, and the finer tiles of a window on a body (the folder's: a source of a page's is counted by its id)
|
|
110
|
+
own: () => {
|
|
111
|
+
const own = [];
|
|
112
|
+
const drawn = this.#model.painted.bodies;
|
|
113
|
+
if (drawn > 0)
|
|
114
|
+
own.push(ownCredit("wakusei-pictures", drawn), ownCredit("wakusei-orbits", drawn));
|
|
115
|
+
for (const [id, used] of Object.entries(this.#model.door.used))
|
|
116
|
+
if (this.#door.book.get(id) === undefined)
|
|
117
|
+
own.push(ownCredit(id, used));
|
|
118
|
+
return own;
|
|
119
|
+
},
|
|
120
|
+
used: () => new Map(Object.entries(this.#model.door.used)),
|
|
121
|
+
}, { kinds: ["tiles", "records"] }, () => this.#gate?.request());
|
|
104
122
|
#focusBeforeRide = "earth";
|
|
105
123
|
#lostTold = false;
|
|
106
124
|
#hands;
|
|
@@ -115,9 +133,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
115
133
|
this.#model.mode = this.getAttribute("scale") === "compressed" ? "compressed" : "true";
|
|
116
134
|
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
117
135
|
this.#model.orbits = this.getAttribute("orbits") !== "off";
|
|
136
|
+
this.#model.arrowCount = arrowCount(this.getAttribute("arrows"));
|
|
118
137
|
this.#model.help = this.hasAttribute("help") && this.getAttribute("help") !== "off";
|
|
119
138
|
this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
|
|
120
139
|
this.#model.light = readLight(this.getAttribute("light"));
|
|
140
|
+
this.#door.book.ownOnly(this.getAttribute("data") === "own");
|
|
121
141
|
this.#model.stepMs = Math.max(1000, Math.abs(this.#clock.speed) * 1000);
|
|
122
142
|
if (!this.hasAttribute("role"))
|
|
123
143
|
this.setAttribute("role", "img");
|
|
@@ -144,10 +164,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
144
164
|
this.#taken = taken;
|
|
145
165
|
const item = createSpaceItem(this.#model, {
|
|
146
166
|
painter: () => this.#painterNow(),
|
|
167
|
+
book: this.#door.book,
|
|
147
168
|
cap: () => this.#textureCap(),
|
|
148
169
|
invalidate: () => this.#gate?.request(),
|
|
149
170
|
advance: () => this.#advance(),
|
|
150
|
-
onLabels: (places) =>
|
|
171
|
+
onLabels: (places) => {
|
|
172
|
+
this.#placeLabels(places);
|
|
173
|
+
this.#door.announce();
|
|
174
|
+
},
|
|
151
175
|
onMoving: () => this.#gate?.request(),
|
|
152
176
|
onRideLost: () => this.#rideLost(),
|
|
153
177
|
onPainterError: (error) => this.dispatchEvent(new CustomEvent("wakusei-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
@@ -197,12 +221,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
197
221
|
this.labels = value !== "off";
|
|
198
222
|
else if (name === "orbits")
|
|
199
223
|
this.orbits = value !== "off";
|
|
224
|
+
else if (name === "arrows")
|
|
225
|
+
this.arrows = arrowCount(value);
|
|
200
226
|
else if (name === "help")
|
|
201
227
|
this.help = value !== null && value !== "off";
|
|
202
228
|
else if (name === "look")
|
|
203
229
|
this.look = value === "painted" ? "painted" : "realistic";
|
|
204
230
|
else if (name === "light")
|
|
205
231
|
this.light = readLight(value);
|
|
232
|
+
else if (name === "data")
|
|
233
|
+
this.#door.book.ownOnly(value === "own");
|
|
206
234
|
else if (name === "lang") {
|
|
207
235
|
for (const [id, button] of this.#pool)
|
|
208
236
|
this.#nameLabel(button, id);
|
|
@@ -279,6 +307,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
279
307
|
this.#model.orbits = value;
|
|
280
308
|
this.#gate?.request();
|
|
281
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
|
+
}
|
|
282
318
|
/**
|
|
283
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
|
|
284
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.
|
|
@@ -440,6 +476,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
440
476
|
geo = frame.planets[id];
|
|
441
477
|
else if (SPACE_DWARFS.includes(id))
|
|
442
478
|
geo = frame.dwarfs[id];
|
|
479
|
+
else if (SPACE_MINORS.includes(id))
|
|
480
|
+
geo = frame.minors[id];
|
|
443
481
|
else if (host !== undefined && (SPACE_PLANETS.includes(host) || SPACE_DWARFS.includes(host))) {
|
|
444
482
|
// a moon: its planet's place and its offset in the planet's radii
|
|
445
483
|
const at = SPACE_DWARFS.includes(host) ? frame.dwarfs[host] : frame.planets[host];
|
|
@@ -555,6 +593,35 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
555
593
|
// the Moon's own picture is a quarter of the Earth's in the compressed scale (it was drawn as 0.9 of it): the view of its orbit is still the one that holds the Earth too, three Moon-distances out
|
|
556
594
|
return preset === "moon" && mode === "compressed" ? zoom * (radiusIn("moon", mode) / 0.9) : zoom;
|
|
557
595
|
}
|
|
596
|
+
/**
|
|
597
|
+
* The outside sources of this view (the data door): maps of a body, which take the place of the folder of tiles for it, and records of small bodies, which are drawn as points in one instanced draw. Each carries its own
|
|
598
|
+
* licence and credit. Assign a list to replace them; a source `validateSource` refuses throws a `TypeError` and changes nothing. A property, not an attribute: data is not text.
|
|
599
|
+
*/
|
|
600
|
+
get sources() {
|
|
601
|
+
return this.#door.sources();
|
|
602
|
+
}
|
|
603
|
+
set sources(list) {
|
|
604
|
+
this.#door.setSources(list);
|
|
605
|
+
}
|
|
606
|
+
/** Adds one source (checked at once: a `TypeError` for an empty credit, no licence, a clashing id or a map source with no body). Returns the function that removes it. */
|
|
607
|
+
addSource(source) {
|
|
608
|
+
return this.#door.book.addSource(source);
|
|
609
|
+
}
|
|
610
|
+
/** Removes a source by id: its loads are aborted, its tiles and records freed, its points and window taken off the picture, and its credit goes. Returns whether there was one. */
|
|
611
|
+
removeSource(id) {
|
|
612
|
+
return this.#door.book.removeSource(id);
|
|
613
|
+
}
|
|
614
|
+
/** Switches a source off (`false`) or on, for a layers panel. */
|
|
615
|
+
enableSource(id, on) {
|
|
616
|
+
this.#door.book.enableSource(id, on);
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* The sources whose data was in the last drawn frame, the package's own first: the surface pictures and the positions of the bodies, the finer map tiles where a window of them is on a body, and each source of yours that
|
|
620
|
+
* gave points or tiles. `creditLine(credits, "en" | "ja")` from `@johnmorrisdotca/wakusei-planets/door` writes them with the licences. `wakusei-creditschange` fires when this set changes (not at each frame), with `detail: { credits }`.
|
|
621
|
+
*/
|
|
622
|
+
credits() {
|
|
623
|
+
return this.#door.credits();
|
|
624
|
+
}
|
|
558
625
|
/** What the element is doing, for a page or a test. */
|
|
559
626
|
get stats() {
|
|
560
627
|
const stats = this.#taken?.renderer.stats;
|
|
@@ -570,6 +637,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
570
637
|
camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov },
|
|
571
638
|
bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
|
|
572
639
|
tiles: { ...this.#model.tiles },
|
|
640
|
+
door: { points: this.#model.door.points, sources: this.#door.book.stats() },
|
|
573
641
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
574
642
|
orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden] },
|
|
575
643
|
arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
|
|
@@ -685,14 +753,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
685
753
|
ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
|
|
686
754
|
}
|
|
687
755
|
}
|
|
688
|
-
/** 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. */
|
|
689
757
|
#rank(id) {
|
|
690
758
|
if (id === this.#model.focus)
|
|
691
759
|
return 0;
|
|
692
760
|
if (id === "sun")
|
|
693
761
|
return 1;
|
|
694
762
|
const kind = bodyKindOf(id);
|
|
695
|
-
return kind === "moon" ? 4 : kind === "
|
|
763
|
+
return kind === "moon" ? 4 : kind === "planet" || kind === "star" ? 2 : 3;
|
|
696
764
|
}
|
|
697
765
|
#widths = new WeakMap();
|
|
698
766
|
/** The width of a name's box on the screen, measured when its words change and not at every frame. */
|
|
@@ -803,7 +871,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
803
871
|
};
|
|
804
872
|
// --- the rest --------------------------------------------------------------------------------------------------------------------------------------
|
|
805
873
|
#painterNow() {
|
|
806
|
-
return (this.#painter ??= createPainter({ textureBase: texturePaths(this).textureBase(), farBase: texturePaths(this).farBase(), tiles: tilesBase(this) ?? "off" }));
|
|
874
|
+
return (this.#painter ??= createPainter({ textureBase: texturePaths(this).textureBase(), farBase: texturePaths(this).farBase(), tiles: tilesBase(this) ?? "off", book: this.#door.book }));
|
|
807
875
|
}
|
|
808
876
|
#textureCap() {
|
|
809
877
|
const given = Number(this.getAttribute("max-texture"));
|
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.
|