@johnmorrisdotca/wakusei-planets 0.66.0 → 0.68.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 +23 -1
- package/NOTICE.md +11 -0
- package/README.md +3 -3
- package/dist/body-physics.d.ts +114 -0
- package/dist/body-physics.js +162 -0
- package/dist/data/moon-catalogue.d.ts +1 -1
- package/dist/data/moon-catalogue.js +1 -1
- package/dist/data/places-added.d.ts +2 -0
- package/dist/data/places-added.js +2 -0
- package/dist/data/places-aliases.d.ts +1 -0
- package/dist/data/places-aliases.js +14 -0
- package/dist/data/places-planned.js +1 -1
- package/dist/data/places-search-67p.d.ts +1 -0
- package/dist/data/places-search-67p.js +3 -0
- package/dist/data/places-search-amalthea.d.ts +1 -0
- package/dist/data/places-search-amalthea.js +3 -0
- package/dist/data/places-search-ariel.d.ts +1 -0
- package/dist/data/places-search-ariel.js +3 -0
- package/dist/data/places-search-bennu.d.ts +1 -0
- package/dist/data/places-search-bennu.js +3 -0
- package/dist/data/places-search-bodies.d.ts +25 -0
- package/dist/data/places-search-bodies.js +125 -0
- package/dist/data/places-search-callisto.d.ts +1 -0
- package/dist/data/places-search-callisto.js +3 -0
- package/dist/data/places-search-ceres.d.ts +1 -0
- package/dist/data/places-search-ceres.js +3 -0
- package/dist/data/places-search-charon.d.ts +1 -0
- package/dist/data/places-search-charon.js +3 -0
- package/dist/data/places-search-dactyl.d.ts +1 -0
- package/dist/data/places-search-dactyl.js +3 -0
- package/dist/data/places-search-deimos.d.ts +1 -0
- package/dist/data/places-search-deimos.js +3 -0
- package/dist/data/places-search-didymos.d.ts +1 -0
- package/dist/data/places-search-didymos.js +3 -0
- package/dist/data/places-search-dimorphos.d.ts +1 -0
- package/dist/data/places-search-dimorphos.js +3 -0
- package/dist/data/places-search-dinkinesh.d.ts +1 -0
- package/dist/data/places-search-dinkinesh.js +3 -0
- package/dist/data/places-search-dione.d.ts +1 -0
- package/dist/data/places-search-dione.js +3 -0
- package/dist/data/places-search-donaldjohanson.d.ts +1 -0
- package/dist/data/places-search-donaldjohanson.js +3 -0
- package/dist/data/places-search-enceladus.d.ts +1 -0
- package/dist/data/places-search-enceladus.js +3 -0
- package/dist/data/places-search-epimetheus.d.ts +1 -0
- package/dist/data/places-search-epimetheus.js +3 -0
- package/dist/data/places-search-eros.d.ts +1 -0
- package/dist/data/places-search-eros.js +3 -0
- package/dist/data/places-search-europa.d.ts +1 -0
- package/dist/data/places-search-europa.js +3 -0
- package/dist/data/places-search-ganymede.d.ts +1 -0
- package/dist/data/places-search-ganymede.js +3 -0
- package/dist/data/places-search-gaspra.d.ts +1 -0
- package/dist/data/places-search-gaspra.js +3 -0
- package/dist/data/places-search-hyperion.d.ts +1 -0
- package/dist/data/places-search-hyperion.js +3 -0
- package/dist/data/places-search-iapetus.d.ts +1 -0
- package/dist/data/places-search-iapetus.js +3 -0
- package/dist/data/places-search-ida.d.ts +1 -0
- package/dist/data/places-search-ida.js +3 -0
- package/dist/data/places-search-io.d.ts +1 -0
- package/dist/data/places-search-io.js +3 -0
- package/dist/data/places-search-itokawa.d.ts +1 -0
- package/dist/data/places-search-itokawa.js +3 -0
- package/dist/data/places-search-janus.d.ts +1 -0
- package/dist/data/places-search-janus.js +3 -0
- package/dist/data/places-search-jupiter.d.ts +1 -0
- package/dist/data/places-search-jupiter.js +3 -0
- package/dist/data/places-search-lutetia.d.ts +1 -0
- package/dist/data/places-search-lutetia.js +3 -0
- package/dist/data/places-search-mars.d.ts +1 -0
- package/dist/data/places-search-mars.js +3 -0
- package/dist/data/places-search-mathilde.d.ts +1 -0
- package/dist/data/places-search-mathilde.js +3 -0
- package/dist/data/places-search-mercury.d.ts +1 -0
- package/dist/data/places-search-mercury.js +3 -0
- package/dist/data/places-search-mimas.d.ts +1 -0
- package/dist/data/places-search-mimas.js +3 -0
- package/dist/data/places-search-miranda.d.ts +1 -0
- package/dist/data/places-search-miranda.js +3 -0
- package/dist/data/places-search-moon-satellites.d.ts +1 -0
- package/dist/data/places-search-moon-satellites.js +3 -0
- package/dist/data/places-search-moon.d.ts +1 -0
- package/dist/data/places-search-moon.js +3 -0
- package/dist/data/places-search-oberon.d.ts +1 -0
- package/dist/data/places-search-oberon.js +3 -0
- package/dist/data/places-search-phobos.d.ts +1 -0
- package/dist/data/places-search-phobos.js +3 -0
- package/dist/data/places-search-phoebe.d.ts +1 -0
- package/dist/data/places-search-phoebe.js +3 -0
- package/dist/data/places-search-pluto.d.ts +1 -0
- package/dist/data/places-search-pluto.js +3 -0
- package/dist/data/places-search-proteus.d.ts +1 -0
- package/dist/data/places-search-proteus.js +3 -0
- package/dist/data/places-search-rhea.d.ts +1 -0
- package/dist/data/places-search-rhea.js +3 -0
- package/dist/data/places-search-ryugu.d.ts +1 -0
- package/dist/data/places-search-ryugu.js +3 -0
- package/dist/data/places-search-saturn.d.ts +1 -0
- package/dist/data/places-search-saturn.js +3 -0
- package/dist/data/places-search-steins.d.ts +1 -0
- package/dist/data/places-search-steins.js +3 -0
- package/dist/data/places-search-tempel-1.d.ts +1 -0
- package/dist/data/places-search-tempel-1.js +3 -0
- package/dist/data/places-search-tethys.d.ts +1 -0
- package/dist/data/places-search-tethys.js +3 -0
- package/dist/data/places-search-thebe.d.ts +1 -0
- package/dist/data/places-search-thebe.js +3 -0
- package/dist/data/places-search-titan.d.ts +1 -0
- package/dist/data/places-search-titan.js +3 -0
- package/dist/data/places-search-titania.d.ts +1 -0
- package/dist/data/places-search-titania.js +3 -0
- package/dist/data/places-search-triton.d.ts +1 -0
- package/dist/data/places-search-triton.js +3 -0
- package/dist/data/places-search-types.d.ts +1 -0
- package/dist/data/places-search-types.js +59 -0
- package/dist/data/places-search-umbriel.d.ts +1 -0
- package/dist/data/places-search-umbriel.js +3 -0
- package/dist/data/places-search-venus.d.ts +1 -0
- package/dist/data/places-search-venus.js +3 -0
- package/dist/data/places-search-vesta.d.ts +1 -0
- package/dist/data/places-search-vesta.js +3 -0
- package/dist/fact-sheets.d.ts +1 -1
- package/dist/fact-sheets.js +1 -1
- package/dist/flat/words.js +2 -0
- package/dist/moon-catalogue.d.ts +190 -0
- package/dist/moon-catalogue.js +189 -3
- package/dist/place-marks.js +1 -1
- package/dist/place-search.d.ts +157 -0
- package/dist/place-search.js +198 -0
- package/dist/places/moon.js +4 -1
- package/dist/places/search/67p.d.ts +12 -0
- package/dist/places/search/67p.js +14 -0
- package/dist/places/search/amalthea.d.ts +12 -0
- package/dist/places/search/amalthea.js +14 -0
- package/dist/places/search/ariel.d.ts +12 -0
- package/dist/places/search/ariel.js +14 -0
- package/dist/places/search/bennu.d.ts +12 -0
- package/dist/places/search/bennu.js +14 -0
- package/dist/places/search/callisto.d.ts +12 -0
- package/dist/places/search/callisto.js +14 -0
- package/dist/places/search/ceres.d.ts +12 -0
- package/dist/places/search/ceres.js +14 -0
- package/dist/places/search/charon.d.ts +12 -0
- package/dist/places/search/charon.js +14 -0
- package/dist/places/search/dactyl.d.ts +12 -0
- package/dist/places/search/dactyl.js +14 -0
- package/dist/places/search/deimos.d.ts +12 -0
- package/dist/places/search/deimos.js +14 -0
- package/dist/places/search/didymos.d.ts +12 -0
- package/dist/places/search/didymos.js +14 -0
- package/dist/places/search/dimorphos.d.ts +12 -0
- package/dist/places/search/dimorphos.js +14 -0
- package/dist/places/search/dinkinesh.d.ts +12 -0
- package/dist/places/search/dinkinesh.js +14 -0
- package/dist/places/search/dione.d.ts +12 -0
- package/dist/places/search/dione.js +14 -0
- package/dist/places/search/donaldjohanson.d.ts +12 -0
- package/dist/places/search/donaldjohanson.js +14 -0
- package/dist/places/search/enceladus.d.ts +12 -0
- package/dist/places/search/enceladus.js +14 -0
- package/dist/places/search/epimetheus.d.ts +12 -0
- package/dist/places/search/epimetheus.js +14 -0
- package/dist/places/search/eros.d.ts +12 -0
- package/dist/places/search/eros.js +14 -0
- package/dist/places/search/europa.d.ts +12 -0
- package/dist/places/search/europa.js +14 -0
- package/dist/places/search/ganymede.d.ts +12 -0
- package/dist/places/search/ganymede.js +14 -0
- package/dist/places/search/gaspra.d.ts +12 -0
- package/dist/places/search/gaspra.js +14 -0
- package/dist/places/search/hyperion.d.ts +12 -0
- package/dist/places/search/hyperion.js +14 -0
- package/dist/places/search/iapetus.d.ts +12 -0
- package/dist/places/search/iapetus.js +14 -0
- package/dist/places/search/ida.d.ts +12 -0
- package/dist/places/search/ida.js +14 -0
- package/dist/places/search/io.d.ts +12 -0
- package/dist/places/search/io.js +14 -0
- package/dist/places/search/itokawa.d.ts +12 -0
- package/dist/places/search/itokawa.js +14 -0
- package/dist/places/search/janus.d.ts +12 -0
- package/dist/places/search/janus.js +14 -0
- package/dist/places/search/jupiter.d.ts +12 -0
- package/dist/places/search/jupiter.js +14 -0
- package/dist/places/search/lutetia.d.ts +12 -0
- package/dist/places/search/lutetia.js +14 -0
- package/dist/places/search/mars.d.ts +12 -0
- package/dist/places/search/mars.js +14 -0
- package/dist/places/search/mathilde.d.ts +12 -0
- package/dist/places/search/mathilde.js +14 -0
- package/dist/places/search/mercury.d.ts +12 -0
- package/dist/places/search/mercury.js +14 -0
- package/dist/places/search/mimas.d.ts +12 -0
- package/dist/places/search/mimas.js +14 -0
- package/dist/places/search/miranda.d.ts +12 -0
- package/dist/places/search/miranda.js +14 -0
- package/dist/places/search/moon-satellites.d.ts +12 -0
- package/dist/places/search/moon-satellites.js +14 -0
- package/dist/places/search/moon.d.ts +12 -0
- package/dist/places/search/moon.js +14 -0
- package/dist/places/search/oberon.d.ts +12 -0
- package/dist/places/search/oberon.js +14 -0
- package/dist/places/search/phobos.d.ts +12 -0
- package/dist/places/search/phobos.js +14 -0
- package/dist/places/search/phoebe.d.ts +12 -0
- package/dist/places/search/phoebe.js +14 -0
- package/dist/places/search/pluto.d.ts +12 -0
- package/dist/places/search/pluto.js +14 -0
- package/dist/places/search/proteus.d.ts +12 -0
- package/dist/places/search/proteus.js +14 -0
- package/dist/places/search/rhea.d.ts +12 -0
- package/dist/places/search/rhea.js +14 -0
- package/dist/places/search/ryugu.d.ts +12 -0
- package/dist/places/search/ryugu.js +14 -0
- package/dist/places/search/saturn.d.ts +12 -0
- package/dist/places/search/saturn.js +14 -0
- package/dist/places/search/steins.d.ts +12 -0
- package/dist/places/search/steins.js +14 -0
- package/dist/places/search/tempel-1.d.ts +12 -0
- package/dist/places/search/tempel-1.js +14 -0
- package/dist/places/search/tethys.d.ts +12 -0
- package/dist/places/search/tethys.js +14 -0
- package/dist/places/search/thebe.d.ts +12 -0
- package/dist/places/search/thebe.js +14 -0
- package/dist/places/search/titan.d.ts +12 -0
- package/dist/places/search/titan.js +14 -0
- package/dist/places/search/titania.d.ts +12 -0
- package/dist/places/search/titania.js +14 -0
- package/dist/places/search/triton.d.ts +12 -0
- package/dist/places/search/triton.js +14 -0
- package/dist/places/search/umbriel.d.ts +12 -0
- package/dist/places/search/umbriel.js +14 -0
- package/dist/places/search/venus.d.ts +12 -0
- package/dist/places/search/venus.js +14 -0
- package/dist/places/search/vesta.d.ts +12 -0
- package/dist/places/search/vesta.js +14 -0
- package/dist/places/search.d.ts +25 -0
- package/dist/places/search.js +28 -0
- package/dist/places.d.ts +4 -3
- package/dist/scene/place-layer.js +1 -0
- package/dist/space/all-moons.d.ts +81 -10
- package/dist/space/all-moons.js +132 -27
- package/dist/space/element.d.ts +31 -5
- package/dist/space/element.js +122 -23
- package/dist/space/moon-settings.d.ts +25 -0
- package/dist/space/moon-settings.js +43 -0
- package/dist/space/orbit-rules.d.ts +25 -0
- package/dist/space/orbit-rules.js +36 -0
- package/dist/space/scene.d.ts +9 -3
- package/dist/space/scene.js +27 -17
- package/dist/surface/element.d.ts +8 -0
- package/dist/surface/element.js +70 -15
- package/dist/surface/glide.d.ts +27 -0
- package/dist/surface/glide.js +43 -0
- package/dist/surface/glsl.d.ts +3 -3
- package/dist/surface/glsl.js +2 -1
- package/dist/surface/landing.d.ts +33 -0
- package/dist/surface/landing.js +26 -0
- package/package.json +276 -1
package/dist/space/all-moons.js
CHANGED
|
@@ -5,10 +5,21 @@ import { moonDistance } from "./scale.js";
|
|
|
5
5
|
export const MAX_MOON_DOTS = 1024;
|
|
6
6
|
/** A dot's size, in CSS pixels across. */
|
|
7
7
|
const DOT_PX = 3;
|
|
8
|
+
/** The opacity of every orbit line, set here and nowhere else. */
|
|
9
|
+
export const MOON_ORBIT_OPACITY = 0.6;
|
|
10
|
+
/** How many points go round an orbit. */
|
|
11
|
+
export const MOON_ORBIT_POINTS = 72;
|
|
12
|
+
/** An orbit is drawn again when the view's moment is this far from the one it was drawn for: the orbits of the irregular moons turn over years. */
|
|
13
|
+
export const MOON_ORBIT_KEEP_MS = 20 * 86_400_000;
|
|
8
14
|
const C = Math.cos(OBLIQUITY * RAD);
|
|
9
15
|
const S = Math.sin(OBLIQUITY * RAD);
|
|
10
16
|
/** An ecliptic J2000 vector in the scene's axes (equatorial, y to the celestial north pole), as `moonOffset` turns a moon's. */
|
|
11
17
|
const toScene = (v) => [v[0], v[1] * S + v[2] * C, -(v[1] * C - v[2] * S)];
|
|
18
|
+
/** `#rrggbb` as three numbers from 0 to 1. */
|
|
19
|
+
const rgb = (hex) => {
|
|
20
|
+
const n = Number.parseInt(hex.slice(1), 16);
|
|
21
|
+
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
|
|
22
|
+
};
|
|
12
23
|
/**
|
|
13
24
|
* Where the view draws a moon of the catalogue: its place from the planet in the planet's radii, turned into the scene's axes and drawn nearer in a compressed view (the same mapping as the drawn moons).
|
|
14
25
|
*
|
|
@@ -23,39 +34,133 @@ export function moonDotOffset(mode, dot) {
|
|
|
23
34
|
const k = d === 0 ? 1 : moonDistance(mode, dot.host, d) / d;
|
|
24
35
|
return [v[0] * k, v[1] * k, v[2] * k];
|
|
25
36
|
}
|
|
26
|
-
/** The dots,
|
|
27
|
-
export function
|
|
37
|
+
/** The dots and the orbits, each a draw that is hidden until it has something to show. */
|
|
38
|
+
export function createMoonLayer(T, parent) {
|
|
39
|
+
// the dots: one `Points` for every host
|
|
28
40
|
const positions = new Float32Array(MAX_MOON_DOTS * 3);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const colors = new Float32Array(MAX_MOON_DOTS * 3);
|
|
42
|
+
const dotGeometry = new T.BufferGeometry();
|
|
43
|
+
const dotPositions = new T.BufferAttribute(positions, 3);
|
|
44
|
+
const dotColors = new T.BufferAttribute(colors, 3);
|
|
45
|
+
dotGeometry.setAttribute("position", dotPositions);
|
|
46
|
+
dotGeometry.setAttribute("color", dotColors);
|
|
47
|
+
dotGeometry.setDrawRange(0, 0);
|
|
48
|
+
const dotMaterial = new T.PointsMaterial({ color: 0xffffff, vertexColors: true, size: DOT_PX, sizeAttenuation: false, transparent: true, opacity: 0.9, depthWrite: false });
|
|
49
|
+
const dots = new T.Points(dotGeometry, dotMaterial);
|
|
50
|
+
dots.frustumCulled = false;
|
|
51
|
+
dots.visible = false;
|
|
52
|
+
parent.add(dots);
|
|
53
|
+
// the orbits: one `LineSegments` for each host, in the planet's radii round the planet's centre, moved and scaled with it
|
|
54
|
+
const lineMaterial = new T.LineBasicMaterial({ vertexColors: true, transparent: true, opacity: MOON_ORBIT_OPACITY, depthWrite: false });
|
|
55
|
+
const lines = new Map();
|
|
56
|
+
let built = null;
|
|
57
|
+
const orbitsKey = (input) => `${input.mode}|${input.by}|${[...input.hosts].sort().join(",")}`;
|
|
58
|
+
// draws the orbits again: for the scale, the colours, the planets chosen or a month's turning
|
|
59
|
+
const build = (input) => {
|
|
60
|
+
let total = 0;
|
|
61
|
+
for (const entry of lines.values())
|
|
62
|
+
entry.object.visible = false;
|
|
63
|
+
for (const host of input.hosts) {
|
|
64
|
+
const rings = [];
|
|
65
|
+
for (const moon of input.source.moons) {
|
|
66
|
+
if (moon.host !== host || moon.id === "moon")
|
|
67
|
+
continue;
|
|
68
|
+
const points = input.source.orbit(moon, input.time, MOON_ORBIT_POINTS);
|
|
69
|
+
if (points.length > 1)
|
|
70
|
+
rings.push({ moon, points });
|
|
71
|
+
}
|
|
72
|
+
const segments = rings.reduce((sum, ring) => sum + ring.points.length - 1, 0);
|
|
73
|
+
const array = new Float32Array(segments * 6);
|
|
74
|
+
const tint = new Float32Array(segments * 6);
|
|
75
|
+
let k = 0;
|
|
76
|
+
for (const { moon, points } of rings) {
|
|
77
|
+
const c = rgb(moon.colors[input.by]);
|
|
78
|
+
const offsets = points.map((km) => moonDotOffset(input.mode, { host: moon.host, km }));
|
|
79
|
+
for (let i = 0; i + 1 < offsets.length; i += 1) {
|
|
80
|
+
for (const v of [offsets[i], offsets[i + 1]]) {
|
|
81
|
+
array.set(v, k * 3);
|
|
82
|
+
tint.set(c, k * 3);
|
|
83
|
+
k += 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
let entry = lines.get(host);
|
|
88
|
+
if (entry === undefined) {
|
|
89
|
+
const geometry = new T.BufferGeometry();
|
|
90
|
+
const object = new T.LineSegments(geometry, lineMaterial);
|
|
91
|
+
object.frustumCulled = false;
|
|
92
|
+
entry = { object, geometry, count: 0, moons: [] };
|
|
93
|
+
lines.set(host, entry);
|
|
94
|
+
parent.add(object);
|
|
95
|
+
}
|
|
96
|
+
entry.geometry.setAttribute("position", new T.BufferAttribute(array, 3));
|
|
97
|
+
entry.geometry.setAttribute("color", new T.BufferAttribute(tint, 3));
|
|
98
|
+
entry.count = rings.length;
|
|
99
|
+
entry.moons = rings.map((ring) => ({ id: ring.moon.id, segments: ring.points.length - 1 }));
|
|
100
|
+
total += rings.length;
|
|
101
|
+
}
|
|
102
|
+
built = { source: input.source, key: orbitsKey(input), time: input.time };
|
|
103
|
+
return total;
|
|
104
|
+
};
|
|
37
105
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
106
|
+
update(input) {
|
|
107
|
+
const wanted = input.orbits && input.hosts.size > 0;
|
|
108
|
+
// the orbits
|
|
109
|
+
let orbitsDrawn = 0;
|
|
110
|
+
if (wanted) {
|
|
111
|
+
if (built === null || built.source !== input.source || built.key !== orbitsKey(input) || Math.abs(input.time - built.time) > MOON_ORBIT_KEEP_MS)
|
|
112
|
+
build(input);
|
|
113
|
+
for (const [host, entry] of lines) {
|
|
114
|
+
const on = input.hosts.has(host);
|
|
115
|
+
entry.object.visible = on;
|
|
116
|
+
if (!on)
|
|
117
|
+
continue;
|
|
118
|
+
const c = input.at(host);
|
|
119
|
+
entry.object.position.set(c[0], c[1], c[2]);
|
|
120
|
+
entry.object.scale.setScalar(input.radius(host));
|
|
121
|
+
orbitsDrawn += entry.count;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else
|
|
125
|
+
for (const entry of lines.values())
|
|
126
|
+
entry.object.visible = false;
|
|
127
|
+
// the dots, of the moons the view does not draw in full, in the planets chosen
|
|
128
|
+
const shown = input.hosts.size === 0 ? [] : input.source.moons.filter((m) => !m.full && input.hosts.has(m.host));
|
|
129
|
+
const count = Math.min(MAX_MOON_DOTS, shown.length);
|
|
130
|
+
const spots = [];
|
|
41
131
|
for (let k = 0; k < count; k += 1) {
|
|
42
|
-
const
|
|
43
|
-
const o = moonDotOffset(mode,
|
|
44
|
-
const c = at(
|
|
45
|
-
const r = radius(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
132
|
+
const moon = shown[k];
|
|
133
|
+
const o = moonDotOffset(input.mode, { host: moon.host, km: input.source.position(moon, input.time) });
|
|
134
|
+
const c = input.at(moon.host);
|
|
135
|
+
const r = input.radius(moon.host);
|
|
136
|
+
const x = c[0] + o[0] * r;
|
|
137
|
+
const y = c[1] + o[1] * r;
|
|
138
|
+
const z = c[2] + o[2] * r;
|
|
139
|
+
positions[k * 3] = x;
|
|
140
|
+
positions[k * 3 + 1] = y;
|
|
141
|
+
positions[k * 3 + 2] = z;
|
|
142
|
+
colors.set(rgb(moon.colors[input.by]), k * 3);
|
|
143
|
+
const spot = input.spot([x, y, z]);
|
|
144
|
+
if (spot !== null)
|
|
145
|
+
spots.push({ id: moon.id, host: moon.host, x: spot.x, y: spot.y });
|
|
49
146
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
147
|
+
dotPositions.needsUpdate = true;
|
|
148
|
+
dotColors.needsUpdate = true;
|
|
149
|
+
dotGeometry.setDrawRange(0, count);
|
|
150
|
+
dotMaterial.size = DOT_PX * input.ratio;
|
|
151
|
+
dots.visible = count > 0;
|
|
152
|
+
return { dots: count, orbits: orbitsDrawn, spots };
|
|
55
153
|
},
|
|
154
|
+
orbitMoons: (host) => lines.get(host)?.moons ?? [],
|
|
56
155
|
dispose() {
|
|
57
|
-
|
|
58
|
-
|
|
156
|
+
parent.remove(dots);
|
|
157
|
+
for (const entry of lines.values())
|
|
158
|
+
parent.remove(entry.object);
|
|
159
|
+
dotGeometry.dispose();
|
|
160
|
+
dotMaterial.dispose();
|
|
161
|
+
lineMaterial.dispose();
|
|
162
|
+
for (const entry of lines.values())
|
|
163
|
+
entry.geometry.dispose();
|
|
59
164
|
},
|
|
60
165
|
};
|
|
61
166
|
}
|
package/dist/space/element.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import type { RideLook } from "./ride.ts";
|
|
|
16
16
|
import { type SunRegion } from "./regions.ts";
|
|
17
17
|
import { type TravelKind } from "./travel.ts";
|
|
18
18
|
import { type FrameKind } from "./hold.ts";
|
|
19
|
+
import { type MoonsChoice } from "./moon-settings.ts";
|
|
19
20
|
import { type Place } from "../places.ts";
|
|
20
21
|
import { type PlaceLayer } from "../place-marks.ts";
|
|
21
22
|
import { type EarthPlace, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
@@ -167,7 +168,7 @@ export type Riding = RideState;
|
|
|
167
168
|
/**
|
|
168
169
|
* The `<wakusei-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`
|
|
169
170
|
* (`"lon,lat"`), `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `look` (`realistic` or `painted`),
|
|
170
|
-
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `
|
|
171
|
+
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `moons` (`major`, the default, or `all`: every known moon of every planet as a pressable dot with its orbit, from `/moon-catalogue`, fetched when first asked for), `moons-of` (`"jupiter=all saturn=major"`: a planet's own choice) and `moon-colors` (`group` or `direction`: what the orbits' colours say), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
|
|
171
172
|
* only when something changes, and nothing while it is out of sight.
|
|
172
173
|
*
|
|
173
174
|
* The names and markers of bodies outside the system in the middle of the view are drawn at half strength (`far-opacity`, 0 to 1). A body under the pointer, a finger or the keyboard's focus lights its own system instead and
|
|
@@ -477,8 +478,30 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
477
478
|
get orbits(): boolean;
|
|
478
479
|
set orbits(value: boolean);
|
|
479
480
|
/**
|
|
480
|
-
*
|
|
481
|
-
* as a chunk of its own, the first time
|
|
481
|
+
* What every planet shows by default (the attribute `moons`): `"major"`, the moons the view draws in full (today's default), or `"all"`, every moon of `/moon-catalogue` as a small pressable dot round its planet, with
|
|
482
|
+
* its orbit. A planet with a choice of its own (`moonsOf`, `setMoons`) keeps it. The catalogue is fetched, as a chunk of its own, the first time a planet is set to `all`; a view that never does never loads it.
|
|
483
|
+
*/
|
|
484
|
+
get moons(): MoonsChoice;
|
|
485
|
+
set moons(value: MoonsChoice);
|
|
486
|
+
/** The choices of single planets (the attribute `moons-of`, `"jupiter=all saturn=major"`): a planet named here shows what it says whatever `moons` says. A planet not named follows `moons`. */
|
|
487
|
+
get moonsOf(): Readonly<Partial<Record<string, MoonsChoice>>>;
|
|
488
|
+
set moonsOf(value: Readonly<Partial<Record<string, MoonsChoice>>>);
|
|
489
|
+
/** What a planet shows now: its own choice, else the default. */
|
|
490
|
+
moonsFor(host: string): MoonsChoice;
|
|
491
|
+
/**
|
|
492
|
+
* Sets what one planet shows (`setMoons("all", "saturn")`), or, with no planet, every planet at once: the default is set and every choice of a single planet is cleared, so the whole view is `major` or `all`.
|
|
493
|
+
*
|
|
494
|
+
* @param choice - `major` or `all`.
|
|
495
|
+
* @param host - A planet or dwarf planet of the view: `jupiter`, `pluto`.
|
|
496
|
+
*/
|
|
497
|
+
setMoons(choice: MoonsChoice, host?: string): void;
|
|
498
|
+
/** What the orbits' colours say (the attribute `moon-colors`): `group` (the moon's family, the default) or `direction` (blue with the planet's turn, red against it). `moonOrbitKey` from `/moon-catalogue` is the key. */
|
|
499
|
+
get moonColors(): "group" | "direction";
|
|
500
|
+
set moonColors(value: "group" | "direction");
|
|
501
|
+
/** The planets showing every moon now, in the view's order. */
|
|
502
|
+
get moonHosts(): readonly string[];
|
|
503
|
+
/**
|
|
504
|
+
* Whether every moon of every planet is shown, the old switch: the attribute `all-moons`, now `moons="all"` with a different name. Setting it is `setMoons`.
|
|
482
505
|
*/
|
|
483
506
|
get allMoons(): boolean;
|
|
484
507
|
set allMoons(value: boolean);
|
|
@@ -801,17 +824,20 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
801
824
|
draws: number;
|
|
802
825
|
sources: ReturnType<DoorHost["book"]["stats"]>;
|
|
803
826
|
};
|
|
804
|
-
/** The catalogue's
|
|
827
|
+
/** The catalogue's moons of the planets set to `all` (`moons`): whether any is asked for, whether the catalogue has loaded, how many dots and orbits the last draw drew, and the planets showing them. */
|
|
805
828
|
allMoons: {
|
|
806
829
|
on: boolean;
|
|
807
830
|
loaded: boolean;
|
|
808
831
|
dots: number;
|
|
832
|
+
orbits: number;
|
|
833
|
+
hosts: readonly string[];
|
|
809
834
|
};
|
|
810
|
-
/** 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. */
|
|
835
|
+
/** 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. `hidden` are the lines left out because a body is close, and `faded` the lines whose part near the close body is let go (only a line that passes through it). */
|
|
811
836
|
orbits: {
|
|
812
837
|
drawn: string[];
|
|
813
838
|
miss: Record<string, number>;
|
|
814
839
|
hidden: string[];
|
|
840
|
+
faded: string[];
|
|
815
841
|
};
|
|
816
842
|
/** The arrowheads on the orbit lines at the last draw, by line (`earth`, the planets, `moon`): where each is and the way it points, the way the body goes (not the way the clock runs). */
|
|
817
843
|
arrows: Record<string, {
|
package/dist/space/element.js
CHANGED
|
@@ -25,6 +25,7 @@ import { besideMoon } from "./beside.js";
|
|
|
25
25
|
import { SUN_REGIONS } from "./regions.js";
|
|
26
26
|
import { travelArrival } from "./travel.js";
|
|
27
27
|
import { controlsFor, readFrame } from "./hold.js";
|
|
28
|
+
import { catalogueMoonIdOf, catalogueMoonKey, hostsShowingAll, MOON_HOSTS, moonSourceOf, readMoonColors, readMoonsChoice, readMoonsOf } from "./moon-settings.js";
|
|
28
29
|
import { findPlace, PLACE_BODIES } from "../places.js";
|
|
29
30
|
import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView } from "../place-marks.js";
|
|
30
31
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
@@ -110,11 +111,13 @@ const readBody = (value) => {
|
|
|
110
111
|
*/
|
|
111
112
|
const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
|
|
112
113
|
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[data-flip]{display:flex;flex-direction:row-reverse}.sp-label[data-flip]::before{margin:0 -2px 1px 5px}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label[data-far]:not([data-carried]),.sp-ring[data-far]:not([data-carried]){opacity:var(--wakusei-far-opacity,.5)}.sp-arrow[data-far]{opacity:calc(.8*var(--wakusei-far-opacity,.5))}.sp-label,.sp-ring,.sp-arrow{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring,.sp-arrow{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-region{position:absolute;left:10px;bottom:8px;margin:0;padding:0;font:600 15px/20px system-ui,-apple-system,sans-serif;color:#fff;opacity:.95;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:none;transition:opacity .35s}.sp-region[hidden]{display:block;opacity:0}@media (prefers-reduced-motion:reduce){.sp-region{transition:none}}.sp-note{position:absolute;left:10px;right:10px;top:28px;max-width:44em;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.92;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-note[hidden],.sp-oort[hidden]{display:none}.sp-oort{position:absolute;left:0;top:0;margin:0;padding:0;font:italic 12px/16px system-ui,-apple-system,sans-serif;color:#aeb8e6;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none;transition:opacity .35s ease}.sp-oort[data-covered]{opacity:0}@media (prefers-reduced-motion:reduce){.sp-oort{transition:none}}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p><p class="sp-region" id="region" part="region" role="status" hidden></p><p class="sp-note" part="note" role="status" hidden></p><p class="sp-oort" part="oort" hidden></p>`;
|
|
114
|
+
/** A dot of a moon of the catalogue answers a press within this many CSS pixels: smaller than a body's, so a crowd of dots can be told apart, and more than the dot is wide. */
|
|
115
|
+
const MOON_DOT_HIT_PX = 9;
|
|
113
116
|
const orbiterLines = (value) => (value === "chosen" || value === "none" ? value : "all");
|
|
114
117
|
/**
|
|
115
118
|
* The `<wakusei-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`
|
|
116
119
|
* (`"lon,lat"`), `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `look` (`realistic` or `painted`),
|
|
117
|
-
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `
|
|
120
|
+
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `moons` (`major`, the default, or `all`: every known moon of every planet as a pressable dot with its orbit, from `/moon-catalogue`, fetched when first asked for), `moons-of` (`"jupiter=all saturn=major"`: a planet's own choice) and `moon-colors` (`group` or `direction`: what the orbits' colours say), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
|
|
118
121
|
* only when something changes, and nothing while it is out of sight.
|
|
119
122
|
*
|
|
120
123
|
* The names and markers of bodies outside the system in the middle of the view are drawn at half strength (`far-opacity`, 0 to 1). A body under the pointer, a finger or the keyboard's focus lights its own system instead and
|
|
@@ -144,9 +147,10 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
|
|
|
144
147
|
* ```
|
|
145
148
|
*/
|
|
146
149
|
export class WakuseiSpace extends HTMLElement {
|
|
147
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "asteroids", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "site-flags", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
150
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "asteroids", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "site-flags", "earth-places", "earth-places-look", "all-moons", "moons", "moons-of", "moon-colors", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
148
151
|
#model = newSpaceModel();
|
|
149
|
-
#
|
|
152
|
+
#moons = "major";
|
|
153
|
+
#moonsOf = {};
|
|
150
154
|
#catalogue;
|
|
151
155
|
#clock = createGameClock("now", 1);
|
|
152
156
|
#view;
|
|
@@ -396,6 +400,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
396
400
|
this.orbits = value !== "off";
|
|
397
401
|
else if (name === "all-moons")
|
|
398
402
|
this.allMoons = value !== null && value !== "off";
|
|
403
|
+
else if (name === "moons")
|
|
404
|
+
this.moons = readMoonsChoice(value);
|
|
405
|
+
else if (name === "moons-of")
|
|
406
|
+
this.moonsOf = readMoonsOf(value);
|
|
407
|
+
else if (name === "moon-colors")
|
|
408
|
+
this.moonColors = readMoonColors(value);
|
|
399
409
|
else if (name === "arrows")
|
|
400
410
|
this.arrows = arrowCount(value);
|
|
401
411
|
else if (name === "help")
|
|
@@ -1336,30 +1346,79 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1336
1346
|
this.#gate?.request();
|
|
1337
1347
|
}
|
|
1338
1348
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
* as a chunk of its own, the first time
|
|
1349
|
+
* What every planet shows by default (the attribute `moons`): `"major"`, the moons the view draws in full (today's default), or `"all"`, every moon of `/moon-catalogue` as a small pressable dot round its planet, with
|
|
1350
|
+
* its orbit. A planet with a choice of its own (`moonsOf`, `setMoons`) keeps it. The catalogue is fetched, as a chunk of its own, the first time a planet is set to `all`; a view that never does never loads it.
|
|
1351
|
+
*/
|
|
1352
|
+
get moons() {
|
|
1353
|
+
return this.#moons;
|
|
1354
|
+
}
|
|
1355
|
+
set moons(value) {
|
|
1356
|
+
this.#moons = value === "all" ? "all" : "major";
|
|
1357
|
+
this.#moonsChanged();
|
|
1358
|
+
}
|
|
1359
|
+
/** The choices of single planets (the attribute `moons-of`, `"jupiter=all saturn=major"`): a planet named here shows what it says whatever `moons` says. A planet not named follows `moons`. */
|
|
1360
|
+
get moonsOf() {
|
|
1361
|
+
return { ...this.#moonsOf };
|
|
1362
|
+
}
|
|
1363
|
+
set moonsOf(value) {
|
|
1364
|
+
this.#moonsOf = readMoonsOf(Object.entries(value).map(([host, choice]) => `${host}=${choice}`).join(" "));
|
|
1365
|
+
this.#moonsChanged();
|
|
1366
|
+
}
|
|
1367
|
+
/** What a planet shows now: its own choice, else the default. */
|
|
1368
|
+
moonsFor(host) {
|
|
1369
|
+
return this.#moonsOf[host] ?? this.#moons;
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Sets what one planet shows (`setMoons("all", "saturn")`), or, with no planet, every planet at once: the default is set and every choice of a single planet is cleared, so the whole view is `major` or `all`.
|
|
1373
|
+
*
|
|
1374
|
+
* @param choice - `major` or `all`.
|
|
1375
|
+
* @param host - A planet or dwarf planet of the view: `jupiter`, `pluto`.
|
|
1376
|
+
*/
|
|
1377
|
+
setMoons(choice, host) {
|
|
1378
|
+
if (host === undefined) {
|
|
1379
|
+
this.#moons = choice === "all" ? "all" : "major";
|
|
1380
|
+
this.#moonsOf = {};
|
|
1381
|
+
}
|
|
1382
|
+
else if (MOON_HOSTS.includes(host))
|
|
1383
|
+
this.#moonsOf = { ...this.#moonsOf, [host]: choice === "all" ? "all" : "major" };
|
|
1384
|
+
else
|
|
1385
|
+
throw new RangeError(`unknown planet ${JSON.stringify(host)}; the view places ${MOON_HOSTS.join(", ")}`);
|
|
1386
|
+
this.#moonsChanged();
|
|
1387
|
+
}
|
|
1388
|
+
/** What the orbits' colours say (the attribute `moon-colors`): `group` (the moon's family, the default) or `direction` (blue with the planet's turn, red against it). `moonOrbitKey` from `/moon-catalogue` is the key. */
|
|
1389
|
+
get moonColors() {
|
|
1390
|
+
return this.#model.moonColors;
|
|
1391
|
+
}
|
|
1392
|
+
set moonColors(value) {
|
|
1393
|
+
this.#model.moonColors = value === "direction" ? "direction" : "group";
|
|
1394
|
+
this.#gate?.request();
|
|
1395
|
+
}
|
|
1396
|
+
/** The planets showing every moon now, in the view's order. */
|
|
1397
|
+
get moonHosts() {
|
|
1398
|
+
return MOON_HOSTS.filter((host) => this.#model.moonHosts.has(host));
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Whether every moon of every planet is shown, the old switch: the attribute `all-moons`, now `moons="all"` with a different name. Setting it is `setMoons`.
|
|
1341
1402
|
*/
|
|
1342
1403
|
get allMoons() {
|
|
1343
|
-
return this.#
|
|
1404
|
+
return this.#moons === "all" && Object.keys(this.#moonsOf).length === 0;
|
|
1344
1405
|
}
|
|
1345
1406
|
set allMoons(value) {
|
|
1346
|
-
this
|
|
1347
|
-
|
|
1348
|
-
|
|
1407
|
+
this.setMoons(value ? "all" : "major");
|
|
1408
|
+
}
|
|
1409
|
+
#moonsChanged() {
|
|
1410
|
+
const hosts = hostsShowingAll(this.#moons, this.#moonsOf);
|
|
1411
|
+
this.#model.moonHosts = hosts;
|
|
1412
|
+
if (hosts.size === 0) {
|
|
1349
1413
|
this.#gate?.request();
|
|
1350
1414
|
return;
|
|
1351
1415
|
}
|
|
1352
|
-
this.#catalogue ??= import("../moon-catalogue.js").then((
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
return (ms) => shown.map((m) => ({ host: m.host, km: catalogueMoonPosition(m, ms) }));
|
|
1356
|
-
});
|
|
1357
|
-
void this.#catalogue.then((dots) => {
|
|
1358
|
-
if (!this.#allMoons)
|
|
1359
|
-
return;
|
|
1360
|
-
this.#model.allMoons = dots;
|
|
1416
|
+
this.#catalogue ??= import("../moon-catalogue.js").then((catalogue) => moonSourceOf(catalogue));
|
|
1417
|
+
void this.#catalogue.then((source) => {
|
|
1418
|
+
this.#model.moonSource = source;
|
|
1361
1419
|
this.#gate?.request();
|
|
1362
1420
|
});
|
|
1421
|
+
this.#gate?.request();
|
|
1363
1422
|
}
|
|
1364
1423
|
/** 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. */
|
|
1365
1424
|
get arrows() {
|
|
@@ -2319,11 +2378,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2319
2378
|
bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
|
|
2320
2379
|
tiles: { ...this.#model.tiles },
|
|
2321
2380
|
door: { points: this.#model.door.points, belts: this.#model.door.belts, draws: this.#model.door.draws, sources: this.#door.book.stats() },
|
|
2322
|
-
allMoons: { on: this.#
|
|
2381
|
+
allMoons: { on: this.#model.moonHosts.size > 0, loaded: this.#model.moonSource !== null, dots: this.#model.moonDots, orbits: this.#model.moonOrbits, hosts: this.moonHosts },
|
|
2323
2382
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
2324
2383
|
travelling: this.#model.travelling === null ? null : { ...this.#model.travelling },
|
|
2325
2384
|
region: this.#model.region === null ? null : { id: this.#model.region, name: this.#regionName(this.#model.region), reach: this.#model.regionDrawn?.reach ?? 0, distance: this.#model.regionDrawn?.distance ?? 0 },
|
|
2326
|
-
orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden] },
|
|
2385
|
+
orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden], faded: [...this.#model.rings.faded] },
|
|
2327
2386
|
arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
|
|
2328
2387
|
arrowPx: this.#model.arrowPx,
|
|
2329
2388
|
help: this.#model.helpDrawn ? { body: this.#model.helpDrawn.body, axis: [...this.#model.helpDrawn.axis], pole: [...this.#model.helpDrawn.pole], retrograde: this.#model.helpDrawn.retrograde, arcTurn: [...this.#model.helpDrawn.arcTurn] } : null,
|
|
@@ -2389,6 +2448,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2389
2448
|
return this.#names[id] ?? this.#model.orbiterSet.name(id)[lang];
|
|
2390
2449
|
if (this.#isAsteroid(id))
|
|
2391
2450
|
return this.#names[asteroidIdOf(id)] ?? this.#model.asteroidSet.name(asteroidIdOf(id))[lang];
|
|
2451
|
+
const found = this.#catalogueMoon(id);
|
|
2452
|
+
if (found !== undefined)
|
|
2453
|
+
return this.#names[found.id] ?? (lang === "ja" ? (found.ja ?? found.label) : found.label);
|
|
2392
2454
|
return this.#names[id] ?? BODIES[id].name[lang];
|
|
2393
2455
|
}
|
|
2394
2456
|
#placeLabels(places) {
|
|
@@ -2534,6 +2596,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2534
2596
|
for (const arrow of this.#arrows.values())
|
|
2535
2597
|
mark(arrow, arrow.dataset["body"]);
|
|
2536
2598
|
}
|
|
2599
|
+
/** The moon of the catalogue a view key names (`moon:dia`), where the planet is showing every moon and the catalogue has loaded. */
|
|
2600
|
+
#catalogueMoon(key) {
|
|
2601
|
+
const id = catalogueMoonIdOf(key);
|
|
2602
|
+
return id === undefined ? undefined : this.#model.moonSource?.moons.find((m) => m.id === id && this.#model.moonHosts.has(m.host));
|
|
2603
|
+
}
|
|
2604
|
+
/** The event detail for a moon of the catalogue. */
|
|
2605
|
+
#moonDetail(key) {
|
|
2606
|
+
const moon = this.#catalogueMoon(key);
|
|
2607
|
+
return { id: moon.id, name: this.#nameOf(key), kind: "catalogue-moon", host: moon.host };
|
|
2608
|
+
}
|
|
2537
2609
|
/** A body comes under the pointer, a finger or the keyboard's focus (`wakusei-body-hover`, with its system), or none does (`wakusei-body-hover-end`). */
|
|
2538
2610
|
#hover(id, by) {
|
|
2539
2611
|
if (id === this.#hovered) {
|
|
@@ -2545,14 +2617,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2545
2617
|
this.#hovered = id;
|
|
2546
2618
|
this.#hoverBy = by;
|
|
2547
2619
|
this.#markFar();
|
|
2548
|
-
if (id !== null && this.#
|
|
2620
|
+
if (id !== null && this.#catalogueMoon(id) !== undefined)
|
|
2621
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: this.#moonDetail(id), bubbles: true, composed: true }));
|
|
2622
|
+
else if (id !== null && this.#isAsteroid(id))
|
|
2549
2623
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id: asteroidIdOf(id), name: this.#nameOf(id), kind: "small-body" }, bubbles: true, composed: true }));
|
|
2550
2624
|
else if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id)))
|
|
2551
2625
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
|
|
2552
2626
|
else if (id !== null)
|
|
2553
2627
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
|
|
2554
2628
|
else if (was !== null)
|
|
2555
|
-
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: was }, bubbles: true, composed: true }));
|
|
2629
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: catalogueMoonIdOf(was) ?? was }, bubbles: true, composed: true }));
|
|
2556
2630
|
}
|
|
2557
2631
|
/** The body at a point of the element, in CSS pixels: on its disc (at least 14 pixels round its place) or on its name. A press (`#up`) and the hover (`#pointAt`) both ask this, so what lights up under the pointer is what a press picks. */
|
|
2558
2632
|
#bodyAt(x, y, pressing = false) {
|
|
@@ -2575,7 +2649,17 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2575
2649
|
for (const box of this.#nameBoxes)
|
|
2576
2650
|
if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height)
|
|
2577
2651
|
return box.id;
|
|
2578
|
-
|
|
2652
|
+
// a dot of a moon of the catalogue (a planet set to `all`): the nearest within a finger's reach, after everything with a name
|
|
2653
|
+
let dot = null;
|
|
2654
|
+
let dotD = MOON_DOT_HIT_PX;
|
|
2655
|
+
for (const spot of this.#model.moonSpots) {
|
|
2656
|
+
const d = Math.hypot(x - spot.x, y - spot.y);
|
|
2657
|
+
if (d <= dotD) {
|
|
2658
|
+
dot = spot;
|
|
2659
|
+
dotD = d;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
return dot === null ? null : catalogueMoonKey(dot.id);
|
|
2579
2663
|
}
|
|
2580
2664
|
#pointAt(event) {
|
|
2581
2665
|
const rect = this.getBoundingClientRect();
|
|
@@ -2813,6 +2897,21 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2813
2897
|
* the middle of the view (`goTo`), unless it already is, so a press never sends the view anywhere else.
|
|
2814
2898
|
*/
|
|
2815
2899
|
#press(id) {
|
|
2900
|
+
if (this.#catalogueMoon(id) !== undefined) {
|
|
2901
|
+
// a moon of the catalogue is no body of the package: the press says which one, in the body event and in an event of its own; the first press selects it, and a second makes its planet the middle of the view
|
|
2902
|
+
const detail = this.#moonDetail(id);
|
|
2903
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail, bubbles: true, composed: true }));
|
|
2904
|
+
this.dispatchEvent(new CustomEvent("wakusei-moon-click", { detail, bubbles: true, composed: true }));
|
|
2905
|
+
if (this.#selected === id) {
|
|
2906
|
+
const host = detail.host;
|
|
2907
|
+
if (canCentre(host) && this.#model.focus !== host)
|
|
2908
|
+
this.goTo(host);
|
|
2909
|
+
return;
|
|
2910
|
+
}
|
|
2911
|
+
this.#selected = id;
|
|
2912
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail, bubbles: true, composed: true }));
|
|
2913
|
+
return;
|
|
2914
|
+
}
|
|
2816
2915
|
// the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
|
|
2817
2916
|
if (this.#isAsteroid(id)) {
|
|
2818
2917
|
// an asteroid is no body of the package: the press says which one, in the body event and in an event of its own, and goes nowhere
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SpaceDwarf, type SpacePlanet } from "./frame.ts";
|
|
2
|
+
import type { MoonColorChoice, MoonSource } from "./all-moons.ts";
|
|
3
|
+
/** What a planet shows: its `major` moons (the ones the view draws in full: today's default) or `all` of them (every moon of the catalogue as a pressable dot with its orbit). */
|
|
4
|
+
export type MoonsChoice = "major" | "all";
|
|
5
|
+
/** The planets and dwarf planets that can show every moon: those the view places. */
|
|
6
|
+
export declare const MOON_HOSTS: readonly (SpacePlanet | SpaceDwarf)[];
|
|
7
|
+
/** `moons="all"` is all; anything else is the major moons. */
|
|
8
|
+
export declare const readMoonsChoice: (value: string | null | undefined) => MoonsChoice;
|
|
9
|
+
/** What `moon-colors` says: `direction`, else `group`. */
|
|
10
|
+
export declare const readMoonColors: (value: string | null | undefined) => MoonColorChoice;
|
|
11
|
+
/** The per-planet choices of `moons-of` (`"jupiter=all saturn=major"`, spaces or commas between): a planet the view does not place, or a choice that is neither word, is left out. */
|
|
12
|
+
export declare function readMoonsOf(text: string | null | undefined): Partial<Record<string, MoonsChoice>>;
|
|
13
|
+
/** The planets showing every moon: each one's own choice, else the global one. */
|
|
14
|
+
export declare function hostsShowingAll(global: MoonsChoice, own: Readonly<Partial<Record<string, MoonsChoice>>>): ReadonlySet<string>;
|
|
15
|
+
/** The prefix of a moon of the catalogue's key in the view: the catalogue's `io` or `dia` would meet a body's id, so the view keeps its own names for them apart by it. A page never sees it: events say the plain id. */
|
|
16
|
+
export declare const CATALOGUE_MOON_PREFIX = "moon:";
|
|
17
|
+
/** The view's key of a moon of the catalogue. */
|
|
18
|
+
export declare const catalogueMoonKey: (id: string) => string;
|
|
19
|
+
/** The catalogue's id from the view's key, or `undefined` for a key that is not a moon of the catalogue's. */
|
|
20
|
+
export declare const catalogueMoonIdOf: (key: string) => string | undefined;
|
|
21
|
+
/** The catalogue module's parts the source is made from. */
|
|
22
|
+
type CatalogueModule = Pick<typeof import("../moon-catalogue.ts"), "MOON_CATALOGUE" | "catalogueMoonPosition" | "catalogueMoonOrbit" | "moonOrbitColor">;
|
|
23
|
+
/** The catalogue as the layer's source: the moons with an orbit that go round a planet the view places. */
|
|
24
|
+
export declare function moonSourceOf(catalogue: CatalogueModule): MoonSource;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Which planets of the space view show every moon of the catalogue (`moons`, `moons-of`), and how a moon of the catalogue is keyed among the view's own names. Pure; the catalogue itself is imported by the element only when
|
|
2
|
+
// a planet is first set to `all`.
|
|
3
|
+
import { SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
4
|
+
/** The planets and dwarf planets that can show every moon: those the view places. */
|
|
5
|
+
export const MOON_HOSTS = [...SPACE_PLANETS, ...SPACE_DWARFS];
|
|
6
|
+
/** `moons="all"` is all; anything else is the major moons. */
|
|
7
|
+
export const readMoonsChoice = (value) => (value?.trim().toLowerCase() === "all" ? "all" : "major");
|
|
8
|
+
/** What `moon-colors` says: `direction`, else `group`. */
|
|
9
|
+
export const readMoonColors = (value) => (value?.trim().toLowerCase() === "direction" ? "direction" : "group");
|
|
10
|
+
/** The per-planet choices of `moons-of` (`"jupiter=all saturn=major"`, spaces or commas between): a planet the view does not place, or a choice that is neither word, is left out. */
|
|
11
|
+
export function readMoonsOf(text) {
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const part of (text ?? "").split(/[\s,]+/)) {
|
|
14
|
+
const [host, choice] = part.split("=");
|
|
15
|
+
if (host === undefined || choice === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
const id = host.trim().toLowerCase();
|
|
18
|
+
const word = choice.trim().toLowerCase();
|
|
19
|
+
if (MOON_HOSTS.includes(id) && (word === "all" || word === "major"))
|
|
20
|
+
out[id] = word;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/** The planets showing every moon: each one's own choice, else the global one. */
|
|
25
|
+
export function hostsShowingAll(global, own) {
|
|
26
|
+
return new Set(MOON_HOSTS.filter((host) => (own[host] ?? global) === "all"));
|
|
27
|
+
}
|
|
28
|
+
/** The prefix of a moon of the catalogue's key in the view: the catalogue's `io` or `dia` would meet a body's id, so the view keeps its own names for them apart by it. A page never sees it: events say the plain id. */
|
|
29
|
+
export const CATALOGUE_MOON_PREFIX = "moon:";
|
|
30
|
+
/** The view's key of a moon of the catalogue. */
|
|
31
|
+
export const catalogueMoonKey = (id) => CATALOGUE_MOON_PREFIX + id;
|
|
32
|
+
/** The catalogue's id from the view's key, or `undefined` for a key that is not a moon of the catalogue's. */
|
|
33
|
+
export const catalogueMoonIdOf = (key) => (key.startsWith(CATALOGUE_MOON_PREFIX) ? key.slice(CATALOGUE_MOON_PREFIX.length) : undefined);
|
|
34
|
+
/** The catalogue as the layer's source: the moons with an orbit that go round a planet the view places. */
|
|
35
|
+
export function moonSourceOf(catalogue) {
|
|
36
|
+
const moons = catalogue.MOON_CATALOGUE.filter((m) => m.orbit !== null && MOON_HOSTS.includes(m.host));
|
|
37
|
+
const byId = new Map(moons.map((m) => [m.id, m]));
|
|
38
|
+
return {
|
|
39
|
+
moons: moons.map((m) => ({ id: m.id, label: m.label, ja: m.ja, host: m.host, full: m.full, colors: { group: catalogue.moonOrbitColor(m, "group"), direction: catalogue.moonOrbitColor(m, "direction") } })),
|
|
40
|
+
position: (moon, ms) => catalogue.catalogueMoonPosition(byId.get(moon.id), ms),
|
|
41
|
+
orbit: (moon, ms, points) => catalogue.catalogueMoonOrbit(byId.get(moon.id), ms, points),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an orbit line belongs to the nearest body's own system, so that it is kept when that body is close: the body's own line (the Earth's, round the Sun, passes through the Earth) and, for the Earth and the Moon, the Moon's ring round the Earth.
|
|
3
|
+
*
|
|
4
|
+
* @param id - The body whose orbit line it is.
|
|
5
|
+
* @param nearId - The body that is close, the one the view is about.
|
|
6
|
+
* @returns True when the line is kept in a close view.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isOwnLine(id: string, nearId: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the part of an orbit line near the close body is let go (faded out from 3 radii to 12), so that no line is drawn across the disc. Only a line that passes through the body needs it: a body's own line round the Sun, and the Moon's ring when it is the Moon that is close (the Moon
|
|
11
|
+
* is on it). The Moon's ring round the Earth does not pass through the Earth, and in the squeezed scale it lies 4 to 5 Earth radii out, inside the band, so fading it took the whole ring away when the Earth was close.
|
|
12
|
+
*
|
|
13
|
+
* @param id - The body whose orbit line it is.
|
|
14
|
+
* @param nearId - The body that is close.
|
|
15
|
+
* @param closeUp - Whether the close body's disc is big enough on the screen for the close view.
|
|
16
|
+
* @returns True when the line is faded near the body.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fadesNearBody(id: string, nearId: string, closeUp: boolean): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* How much of an orbit line's colour is kept at a point of it that is `away` radii of the close body from the body's middle: none within 3 radii and all from 12, a smooth step between.
|
|
21
|
+
*
|
|
22
|
+
* @param away - The distance from the body's middle, in the body's radii.
|
|
23
|
+
* @returns The share of the line's alpha, 0 to 1.
|
|
24
|
+
*/
|
|
25
|
+
export declare function nearBodyKeep(away: number): number;
|