@johnmorrisdotca/wakusei-planets 0.32.0 → 0.34.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 +16 -0
- package/NOTICE.md +15 -1
- package/README.md +11 -5
- package/dist/bodies/all.d.ts +1 -0
- package/dist/bodies/all.js +1 -0
- package/dist/bodies/minor.d.ts +1 -0
- package/dist/bodies/minor.js +16 -0
- package/dist/data/minor.d.ts +3 -0
- package/dist/data/minor.js +7 -0
- package/dist/data/tables.d.ts +4 -2
- package/dist/data/tables.js +1 -1
- package/dist/element.d.ts +10 -1
- package/dist/element.js +36 -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 +13 -2
- package/dist/scene/body.js +35 -0
- package/dist/scene/name-label.d.ts +116 -0
- package/dist/scene/name-label.js +232 -0
- package/dist/scene/painter.d.ts +29 -0
- package/dist/scene/painter.js +36 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/arrows.d.ts +29 -3
- package/dist/space/arrows.js +38 -6
- package/dist/space/bodies.d.ts +6 -6
- package/dist/space/bodies.js +6 -6
- package/dist/space/element.d.ts +20 -0
- package/dist/space/element.js +44 -4
- package/dist/space/frame.d.ts +28 -3
- package/dist/space/frame.js +40 -4
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +2 -2
- package/dist/space/scale.d.ts +4 -4
- package/dist/space/scale.js +8 -2
- package/dist/space/scene.d.ts +17 -3
- package/dist/space/scene.js +36 -17
- package/dist/stops.d.ts +1 -1
- package/dist/stops.js +4 -1
- package/dist/tables/all.d.ts +1 -0
- package/dist/tables/all.js +1 -0
- package/dist/tables/lazy.d.ts +5 -0
- package/dist/tables/lazy.js +12 -0
- package/dist/tables/minor.d.ts +1 -0
- package/dist/tables/minor.js +317 -0
- package/dist/textures/vesta-1024.webp +0 -0
- package/dist/textures/vesta-512.webp +0 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +12 -2
package/dist/space/element.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
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 { NAME_LABEL_ATTRIBUTES, readNameLabel } from "../scene/name-label.js";
|
|
8
11
|
import { createDoorHost } from "../door/host.js";
|
|
9
12
|
import { ownCredit } from "../door/own.js";
|
|
10
13
|
import { setThreeLoader, takeRenderer } from "../scene/shared.js";
|
|
11
14
|
import { texturePaths, tilesBase } from "../scene/textures.js";
|
|
12
|
-
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
15
|
+
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
13
16
|
import { moonOffset } from "../scene/orient.js";
|
|
14
17
|
import { moonDistance, placeBodies, radiusIn } from "./scale.js";
|
|
15
18
|
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
@@ -83,7 +86,7 @@ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;ove
|
|
|
83
86
|
* ```
|
|
84
87
|
*/
|
|
85
88
|
export class WakuseiSpace extends HTMLElement {
|
|
86
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data"];
|
|
89
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "help", "look", "light", "lang", "data", "arrows", ...NAME_LABEL_ATTRIBUTES];
|
|
87
90
|
#model = newSpaceModel();
|
|
88
91
|
#clock = createGameClock("now", 1);
|
|
89
92
|
#view;
|
|
@@ -131,9 +134,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
131
134
|
this.#model.mode = this.getAttribute("scale") === "compressed" ? "compressed" : "true";
|
|
132
135
|
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
133
136
|
this.#model.orbits = this.getAttribute("orbits") !== "off";
|
|
137
|
+
this.#model.arrowCount = arrowCount(this.getAttribute("arrows"));
|
|
134
138
|
this.#model.help = this.hasAttribute("help") && this.getAttribute("help") !== "off";
|
|
135
139
|
this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
|
|
136
140
|
this.#model.light = readLight(this.getAttribute("light"));
|
|
141
|
+
this.#relabel();
|
|
137
142
|
this.#door.book.ownOnly(this.getAttribute("data") === "own");
|
|
138
143
|
this.#model.stepMs = Math.max(1000, Math.abs(this.#clock.speed) * 1000);
|
|
139
144
|
if (!this.hasAttribute("role"))
|
|
@@ -218,6 +223,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
218
223
|
this.labels = value !== "off";
|
|
219
224
|
else if (name === "orbits")
|
|
220
225
|
this.orbits = value !== "off";
|
|
226
|
+
else if (name === "arrows")
|
|
227
|
+
this.arrows = arrowCount(value);
|
|
221
228
|
else if (name === "help")
|
|
222
229
|
this.help = value !== null && value !== "off";
|
|
223
230
|
else if (name === "look")
|
|
@@ -230,7 +237,29 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
230
237
|
for (const [id, button] of this.#pool)
|
|
231
238
|
this.#nameLabel(button, id);
|
|
232
239
|
this.#nameScale();
|
|
240
|
+
this.#relabel();
|
|
233
241
|
}
|
|
242
|
+
else if (NAME_LABEL_ATTRIBUTES.includes(name))
|
|
243
|
+
this.#relabel();
|
|
244
|
+
}
|
|
245
|
+
#bodyLabel;
|
|
246
|
+
/**
|
|
247
|
+
* The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
|
|
248
|
+
* `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
|
|
249
|
+
*/
|
|
250
|
+
get bodyLabel() {
|
|
251
|
+
return this.#bodyLabel !== undefined ? this.#bodyLabel : readNameLabel(this);
|
|
252
|
+
}
|
|
253
|
+
set bodyLabel(value) {
|
|
254
|
+
this.#bodyLabel = value;
|
|
255
|
+
this.#relabel();
|
|
256
|
+
}
|
|
257
|
+
/** Tell the scene the name on the globes changed (the attributes, the property or the language): each body is told once at the next draw. */
|
|
258
|
+
#relabel() {
|
|
259
|
+
const options = this.bodyLabel;
|
|
260
|
+
this.#model.label = options === null ? null : { ...options, lang: this.getAttribute("lang") === "ja" ? "ja" : "en" };
|
|
261
|
+
this.#model.labelVersion += 1;
|
|
262
|
+
this.#gate?.request();
|
|
234
263
|
}
|
|
235
264
|
/** The home place the camera starts above, as longitude and latitude in degrees. */
|
|
236
265
|
get centre() {
|
|
@@ -302,6 +331,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
302
331
|
this.#model.orbits = value;
|
|
303
332
|
this.#gate?.request();
|
|
304
333
|
}
|
|
334
|
+
/** 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. */
|
|
335
|
+
get arrows() {
|
|
336
|
+
return this.#model.arrowCount;
|
|
337
|
+
}
|
|
338
|
+
set arrows(value) {
|
|
339
|
+
this.#model.arrowCount = arrowCount(value);
|
|
340
|
+
this.#gate?.request();
|
|
341
|
+
}
|
|
305
342
|
/**
|
|
306
343
|
* Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
|
|
307
344
|
* right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
|
|
@@ -463,6 +500,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
463
500
|
geo = frame.planets[id];
|
|
464
501
|
else if (SPACE_DWARFS.includes(id))
|
|
465
502
|
geo = frame.dwarfs[id];
|
|
503
|
+
else if (SPACE_MINORS.includes(id))
|
|
504
|
+
geo = frame.minors[id];
|
|
466
505
|
else if (host !== undefined && (SPACE_PLANETS.includes(host) || SPACE_DWARFS.includes(host))) {
|
|
467
506
|
// a moon: its planet's place and its offset in the planet's radii
|
|
468
507
|
const at = SPACE_DWARFS.includes(host) ? frame.dwarfs[host] : frame.planets[host];
|
|
@@ -628,6 +667,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
628
667
|
arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
|
|
629
668
|
arrowPx: this.#model.arrowPx,
|
|
630
669
|
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,
|
|
670
|
+
bodyLabels: { count: this.#model.labelsDrawn.count, focus: this.#model.labelsDrawn.focus === null ? null : { ...this.#model.labelsDrawn.focus } },
|
|
631
671
|
};
|
|
632
672
|
}
|
|
633
673
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
@@ -738,14 +778,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
738
778
|
ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
|
|
739
779
|
}
|
|
740
780
|
}
|
|
741
|
-
/** How sure a body's name is of its place: the body looked at first, then the Sun, the planets, the dwarf planets and the moons. */
|
|
781
|
+
/** How sure a body's name is of its place: the body looked at first, then the Sun, the planets, the dwarf planets and minor bodies, and the moons. */
|
|
742
782
|
#rank(id) {
|
|
743
783
|
if (id === this.#model.focus)
|
|
744
784
|
return 0;
|
|
745
785
|
if (id === "sun")
|
|
746
786
|
return 1;
|
|
747
787
|
const kind = bodyKindOf(id);
|
|
748
|
-
return kind === "moon" ? 4 : kind === "
|
|
788
|
+
return kind === "moon" ? 4 : kind === "planet" || kind === "star" ? 2 : 3;
|
|
749
789
|
}
|
|
750
790
|
#widths = new WeakMap();
|
|
751
791
|
/** The width of a name's box on the screen, measured when its words change and not at every frame. */
|
package/dist/space/frame.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DwarfId } from "../facts.ts";
|
|
1
|
+
import { type DwarfId, type MinorId } from "../facts.ts";
|
|
2
2
|
import { type Vec3 } from "../vec.ts";
|
|
3
3
|
/**
|
|
4
4
|
* A position or direction as `[x, y, z]` in the scene's axes: J2000 equatorial, x to the vernal equinox, y north.
|
|
@@ -68,6 +68,29 @@ export declare const SPACE_DWARFS: readonly ["ceres", "orcus", "haumea", "quaoar
|
|
|
68
68
|
* ```
|
|
69
69
|
*/
|
|
70
70
|
export type SpaceDwarf = DwarfId;
|
|
71
|
+
/**
|
|
72
|
+
* The minor bodies the space view places: the asteroids Vesta and Pallas, the centaurs Chiron and Pholus and Halley's comet.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { SPACE_MINORS } from "@johnmorrisdotca/wakusei-planets/space";
|
|
77
|
+
*
|
|
78
|
+
* console.log(SPACE_MINORS.join(", "));
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare const SPACE_MINORS: readonly ["vesta", "pallas", "chiron", "pholus", "halley"];
|
|
82
|
+
/**
|
|
83
|
+
* One of the minor bodies in `SPACE_MINORS`.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { planetOrbit, type SpaceMinor } from "@johnmorrisdotca/wakusei-planets/space";
|
|
88
|
+
*
|
|
89
|
+
* const minor: SpaceMinor = "halley";
|
|
90
|
+
* console.log(planetOrbit(minor, Date.UTC(2026, 10, 2), 8).length);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export type SpaceMinor = MinorId;
|
|
71
94
|
/**
|
|
72
95
|
* One of the planets in `SPACE_PLANETS`.
|
|
73
96
|
*
|
|
@@ -98,6 +121,8 @@ export interface SpaceFrame {
|
|
|
98
121
|
planets: Record<SpacePlanet, Vec3>;
|
|
99
122
|
/** The dwarf planets besides Pluto, from their osculating elements (good for a few years either side of 2026). */
|
|
100
123
|
dwarfs: Record<SpaceDwarf, Vec3>;
|
|
124
|
+
/** The minor bodies: Vesta, Pallas, Chiron, Pholus and Halley's comet, from tables fitted to Horizons (outside their years, from osculating elements). */
|
|
125
|
+
minors: Record<SpaceMinor, Vec3>;
|
|
101
126
|
}
|
|
102
127
|
/**
|
|
103
128
|
* The state of the sky at `ms`: the Sun, the Moon and eight planets as seen from the Earth's centre, worked out by this package's own models in a fraction of a millisecond.
|
|
@@ -162,7 +187,7 @@ export declare function createTrack(initialStepMs?: number): {
|
|
|
162
187
|
/**
|
|
163
188
|
* The path a planet or the Earth takes round the Sun, as `count + 1` points round one trip from where the planet is at `ms`, from the Sun, in astronomical units and the scene's axes.
|
|
164
189
|
*
|
|
165
|
-
* @param id - The planet, the dwarf planet or `earth`.
|
|
190
|
+
* @param id - The planet, the dwarf planet, the minor body or `earth`.
|
|
166
191
|
* @param ms - The moment the path starts at, in milliseconds since the Unix epoch.
|
|
167
192
|
* @param count - How many segments to cut the trip into.
|
|
168
193
|
* @returns `count + 1` points; the last is near the first.
|
|
@@ -175,7 +200,7 @@ export declare function createTrack(initialStepMs?: number): {
|
|
|
175
200
|
* console.log(points.length);
|
|
176
201
|
* ```
|
|
177
202
|
*/
|
|
178
|
-
export declare function planetOrbit(id: SpacePlanet | SpaceDwarf | "earth", ms: number, count?: number): Vec3[];
|
|
203
|
+
export declare function planetOrbit(id: SpacePlanet | SpaceDwarf | SpaceMinor | "earth", ms: number, count?: number): Vec3[];
|
|
179
204
|
/**
|
|
180
205
|
* The path the Moon takes round the Earth, as `count + 1` points round one sidereal month from where the Moon is at `ms`, from the Earth's centre, in astronomical units and the scene's axes. The first
|
|
181
206
|
* point is the Moon's own place at `ms` and the last is the first again, so the line is closed and passes through the Moon.
|
package/dist/space/frame.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Where the Sun, the Moon and the planets are, as seen from the centre of the Earth, for any date, from this package's own models (VSOP87B planets, the Pluto table, ELP2000 Moon).
|
|
2
2
|
// Positions are geometric (no aberration or nutation, about 20 arc-seconds), in the painter's axes: J2000 equatorial, x to the vernal equinox, y north. Pure: no DOM, no three.js.
|
|
3
3
|
import { heliocentric, moonGeocentric } from "../ephemeris.js";
|
|
4
|
-
import { DWARF_IDS } from "../facts.js";
|
|
4
|
+
import { DWARF_IDS, MINOR_IDS } from "../facts.js";
|
|
5
5
|
import { DWARF_ELEMENTS } from "../data/dwarf.js";
|
|
6
|
+
import { MINOR_ELEMENTS } from "../data/minor.js";
|
|
6
7
|
import { OBLIQUITY, RAD } from "../vec.js";
|
|
7
8
|
import { earthPosition } from "../theory.js";
|
|
8
9
|
import { DAY_MS } from "../clock.js";
|
|
@@ -52,6 +53,17 @@ export const SPACE_PLANETS = ["mercury", "venus", "mars", "jupiter", "saturn", "
|
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
55
|
export const SPACE_DWARFS = DWARF_IDS;
|
|
56
|
+
/**
|
|
57
|
+
* The minor bodies the space view places: the asteroids Vesta and Pallas, the centaurs Chiron and Pholus and Halley's comet.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* import { SPACE_MINORS } from "@johnmorrisdotca/wakusei-planets/space";
|
|
62
|
+
*
|
|
63
|
+
* console.log(SPACE_MINORS.join(", "));
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export const SPACE_MINORS = MINOR_IDS;
|
|
55
67
|
/** An ecliptic J2000 vector in the scene's axes (equatorial J2000, y north). */
|
|
56
68
|
const scene = (v) => {
|
|
57
69
|
const c = Math.cos(OBLIQUITY * RAD);
|
|
@@ -84,8 +96,13 @@ export function frameAt(ms) {
|
|
|
84
96
|
const h = heliocentric(id, ms);
|
|
85
97
|
dwarfs[id] = scene([h[0] - earth[0], h[1] - earth[1], h[2] - earth[2]]);
|
|
86
98
|
}
|
|
99
|
+
const minors = {};
|
|
100
|
+
for (const id of SPACE_MINORS) {
|
|
101
|
+
const h = heliocentric(id, ms);
|
|
102
|
+
minors[id] = scene([h[0] - earth[0], h[1] - earth[1], h[2] - earth[2]]);
|
|
103
|
+
}
|
|
87
104
|
const moon = moonGeocentric(ms);
|
|
88
|
-
return { ms, sun: scene([-earth[0], -earth[1], -earth[2]]), moon: scene([moon[0] / AU_KM, moon[1] / AU_KM, moon[2] / AU_KM]), planets, dwarfs };
|
|
105
|
+
return { ms, sun: scene([-earth[0], -earth[1], -earth[2]]), moon: scene([moon[0] / AU_KM, moon[1] / AU_KM, moon[2] / AU_KM]), planets, dwarfs, minors };
|
|
89
106
|
}
|
|
90
107
|
const lerp3 = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
91
108
|
/**
|
|
@@ -112,7 +129,10 @@ export function blend(a, b, t) {
|
|
|
112
129
|
const dwarfs = {};
|
|
113
130
|
for (const id of SPACE_DWARFS)
|
|
114
131
|
dwarfs[id] = lerp3(a.dwarfs[id], b.dwarfs[id], t);
|
|
115
|
-
|
|
132
|
+
const minors = {};
|
|
133
|
+
for (const id of SPACE_MINORS)
|
|
134
|
+
minors[id] = lerp3(a.minors[id], b.minors[id], t);
|
|
135
|
+
return { ms: a.ms + (b.ms - a.ms) * t, sun: lerp3(a.sun, b.sun, t), moon: lerp3(a.moon, b.moon, t), planets, dwarfs, minors };
|
|
116
136
|
}
|
|
117
137
|
/**
|
|
118
138
|
* Answers for any moment from two real ones: `at(ms)` works out a frame only when `ms` leaves the span the last two answers cover, and then looks `stepMs` ahead, so playing
|
|
@@ -169,11 +189,12 @@ const PERIOD_DAYS = {
|
|
|
169
189
|
mercury: 87.97, venus: 224.7, earth: 365.256, mars: 686.98, jupiter: 4332.6, saturn: 10_759, uranus: 30_688, neptune: 60_182, pluto: 90_560,
|
|
170
190
|
// a dwarf planet's own: a full turn of its mean motion
|
|
171
191
|
...Object.fromEntries(SPACE_DWARFS.map((id) => [id, 360 / DWARF_ELEMENTS[id].n])),
|
|
192
|
+
...Object.fromEntries(SPACE_MINORS.map((id) => [id, 360 / MINOR_ELEMENTS[id].n])),
|
|
172
193
|
};
|
|
173
194
|
/**
|
|
174
195
|
* The path a planet or the Earth takes round the Sun, as `count + 1` points round one trip from where the planet is at `ms`, from the Sun, in astronomical units and the scene's axes.
|
|
175
196
|
*
|
|
176
|
-
* @param id - The planet, the dwarf planet or `earth`.
|
|
197
|
+
* @param id - The planet, the dwarf planet, the minor body or `earth`.
|
|
177
198
|
* @param ms - The moment the path starts at, in milliseconds since the Unix epoch.
|
|
178
199
|
* @param count - How many segments to cut the trip into.
|
|
179
200
|
* @returns `count + 1` points; the last is near the first.
|
|
@@ -188,6 +209,21 @@ const PERIOD_DAYS = {
|
|
|
188
209
|
*/
|
|
189
210
|
export function planetOrbit(id, ms, count = 96) {
|
|
190
211
|
const points = [];
|
|
212
|
+
const minor = SPACE_MINORS.includes(id) ? MINOR_ELEMENTS[id] : SPACE_DWARFS.includes(id) ? DWARF_ELEMENTS[id] : undefined;
|
|
213
|
+
if (minor !== undefined && minor.e > 0.15) {
|
|
214
|
+
// a long ellipse (Halley's, Pholus's, Sedna's, Eris's) is cut at equal steps of the eccentric anomaly, not of time: cut in time, the sharp turn near the Sun is one straight stroke with corners, and the slow far side most of the points
|
|
215
|
+
const e = minor.e;
|
|
216
|
+
const m0 = ((minor.m + (minor.n * (ms - minor.epoch)) / DAY_MS) * Math.PI) / 180;
|
|
217
|
+
let e0 = m0;
|
|
218
|
+
for (let k = 0; k < 40; k += 1)
|
|
219
|
+
e0 -= (e0 - e * Math.sin(e0) - m0) / (1 - e * Math.cos(e0));
|
|
220
|
+
const mean = (anomaly) => anomaly - e * Math.sin(anomaly);
|
|
221
|
+
for (let i = 0; i <= count; i += 1) {
|
|
222
|
+
const anomaly = e0 + (i / count) * 2 * Math.PI;
|
|
223
|
+
points.push(scene(heliocentric(id, ms + ((mean(anomaly) - mean(e0)) / ((minor.n * Math.PI) / 180)) * DAY_MS)));
|
|
224
|
+
}
|
|
225
|
+
return points;
|
|
226
|
+
}
|
|
191
227
|
for (let i = 0; i <= count; i += 1)
|
|
192
228
|
points.push(scene(heliocentric(id, ms + (i / count) * PERIOD_DAYS[id] * DAY_MS)));
|
|
193
229
|
return points;
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_PLANETS, type SpaceDwarf, type SpaceFrame, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
1
|
+
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS, type SpaceDwarf, type SpaceFrame, type SpaceMinor, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
2
2
|
export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition, type ScaleMode } from "./scale.ts";
|
|
3
3
|
export { groundDirection } from "./aim.ts";
|
|
4
4
|
export { RIDE_FOV, ridePose, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
5
5
|
export { chooseLabels, LABEL_GAP, type LabelBox } from "./labels.ts";
|
|
6
6
|
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, type SpaceKind } from "./bodies.ts";
|
|
7
7
|
export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from "./beside.ts";
|
|
8
|
-
export { ARROWS_PER_ORBIT, arrowSites, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
|
|
8
|
+
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
|
|
9
9
|
export { spinAxis, type SpinAxis } from "./spin.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// The space view's pure parts: where the bodies are (this package's own models), the two scales and, for riding along, where a camera looks. They import on a server. The element is `@johnmorrisdotca/wakusei-planets/space/element`.
|
|
2
|
-
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
2
|
+
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
3
3
|
export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeBodies, placeMoon, placeSun, radiusIn, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
4
4
|
export { groundDirection } from "./aim.js";
|
|
5
5
|
export { RIDE_FOV, ridePose } from "./ride.js";
|
|
6
6
|
export { chooseLabels, LABEL_GAP } from "./labels.js";
|
|
7
7
|
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf } from "./bodies.js";
|
|
8
8
|
export { besideMoon, BESIDE_RADII } from "./beside.js";
|
|
9
|
-
export { ARROWS_PER_ORBIT, arrowSites, chevron, spinArrow } from "./arrows.js";
|
|
9
|
+
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
|
|
10
10
|
export { spinAxis } from "./spin.js";
|
package/dist/space/scale.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Vec3 } from "../vec.ts";
|
|
2
|
-
import { type SpaceDwarf, type SpaceFrame, type SpacePlanet } from "./frame.ts";
|
|
2
|
+
import { type SpaceDwarf, type SpaceFrame, type SpaceMinor, type SpacePlanet } from "./frame.ts";
|
|
3
3
|
/**
|
|
4
4
|
* The scale the space view is drawn in: `compressed` squeezes the distances so the Moon, the Sun and Neptune fit one view, and `true` keeps the real ones.
|
|
5
5
|
*
|
|
@@ -109,11 +109,11 @@ export declare function placeSun(mode: ScaleMode, geo: Vec3): Vec3;
|
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
111
|
export declare function placeAround(mode: ScaleMode, sun: Vec3, helio: Vec3): Vec3;
|
|
112
|
-
type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf;
|
|
112
|
+
type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor;
|
|
113
113
|
/**
|
|
114
114
|
* A body's radius in Earth radii: the real one, or one large enough to see in a compressed view.
|
|
115
115
|
*
|
|
116
|
-
* @param id - The Sun, the Earth, the Moon, a planet or a
|
|
116
|
+
* @param id - The Sun, the Earth, the Moon, a planet, a dwarf planet or a minor body.
|
|
117
117
|
* @param mode - The scale.
|
|
118
118
|
* @returns The radius to draw it at, in Earth radii.
|
|
119
119
|
*
|
|
@@ -124,7 +124,7 @@ type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf;
|
|
|
124
124
|
* console.log(radiusIn("moon", "true").toFixed(3), radiusIn("moon", "compressed"));
|
|
125
125
|
* ```
|
|
126
126
|
*/
|
|
127
|
-
export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf, mode: ScaleMode): number;
|
|
127
|
+
export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor, mode: ScaleMode): number;
|
|
128
128
|
/**
|
|
129
129
|
* How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
|
|
130
130
|
* reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's.
|
package/dist/space/scale.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { BODIES, MOONS_OF } from "../facts.js";
|
|
4
4
|
import { meanSunAu } from "../ephemeris.js";
|
|
5
5
|
import { moonOffset } from "../scene/orient.js";
|
|
6
|
-
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, SPACE_DWARFS } from "./frame.js";
|
|
6
|
+
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, SPACE_DWARFS, SPACE_MINORS } from "./frame.js";
|
|
7
7
|
const MOON_AU = 0.00257;
|
|
8
8
|
/**
|
|
9
9
|
* The Moon's distance in a compressed view, in Earth radii (the true one is about 60). It is well inside the gap between the Earth's orbit and the next one in.
|
|
@@ -125,10 +125,12 @@ export function placeAround(mode, sun, helio) {
|
|
|
125
125
|
const COMPRESSED_RADIUS = { sun: 5, earth: 1, moon: 0.273, mercury: 0.5, venus: 0.8, mars: 0.6, jupiter: 1.8, saturn: 1.6, uranus: 1.0, neptune: 1.0, pluto: 0.4 };
|
|
126
126
|
/** A dwarf planet in a compressed view: its true size or this, whichever is the larger, in Earth radii. */
|
|
127
127
|
const COMPRESSED_DWARF = 0.3;
|
|
128
|
+
/** A minor body in a compressed view: its true size or this, whichever is the larger, in Earth radii (a speck beside a dwarf planet). */
|
|
129
|
+
const COMPRESSED_MINOR = 0.2;
|
|
128
130
|
/**
|
|
129
131
|
* A body's radius in Earth radii: the real one, or one large enough to see in a compressed view.
|
|
130
132
|
*
|
|
131
|
-
* @param id - The Sun, the Earth, the Moon, a planet or a
|
|
133
|
+
* @param id - The Sun, the Earth, the Moon, a planet, a dwarf planet or a minor body.
|
|
132
134
|
* @param mode - The scale.
|
|
133
135
|
* @returns The radius to draw it at, in Earth radii.
|
|
134
136
|
*
|
|
@@ -140,6 +142,8 @@ const COMPRESSED_DWARF = 0.3;
|
|
|
140
142
|
* ```
|
|
141
143
|
*/
|
|
142
144
|
export function radiusIn(id, mode) {
|
|
145
|
+
if (SPACE_MINORS.includes(id))
|
|
146
|
+
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : Math.max(COMPRESSED_MINOR, BODIES[id].radiusKm / EARTH_RADIUS_KM);
|
|
143
147
|
if (SPACE_DWARFS.includes(id))
|
|
144
148
|
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : Math.max(COMPRESSED_DWARF, BODIES[id].radiusKm / EARTH_RADIUS_KM);
|
|
145
149
|
return mode === "true" ? BODIES[id].radiusKm / EARTH_RADIUS_KM : COMPRESSED_RADIUS[id];
|
|
@@ -220,6 +224,8 @@ export function placeBodies(mode, frame) {
|
|
|
220
224
|
all[id] = placeAround(mode, sun, helio(geo));
|
|
221
225
|
for (const [id, geo] of Object.entries(frame.dwarfs))
|
|
222
226
|
all[id] = placeAround(mode, sun, helio(geo));
|
|
227
|
+
for (const [id, geo] of Object.entries(frame.minors))
|
|
228
|
+
all[id] = placeAround(mode, sun, helio(geo));
|
|
223
229
|
return all;
|
|
224
230
|
}
|
|
225
231
|
/**
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Item3D } from "@johnmorrisdotca/kazoku-ui/renderer";
|
|
|
3
3
|
import { type BodyId, type MoonId } from "../facts.ts";
|
|
4
4
|
import type { ThreeParts } from "../scene/body.ts";
|
|
5
5
|
import type { SourceBook } from "../door/book.ts";
|
|
6
|
-
import { type WakuseiPainter } from "../scene/painter.ts";
|
|
6
|
+
import { type PaintLabel, type WakuseiPainter } from "../scene/painter.ts";
|
|
7
7
|
import "../bodies/all.ts";
|
|
8
8
|
import type { Vec3 } from "../vec.ts";
|
|
9
9
|
import { type OrbitArrow } from "./arrows.ts";
|
|
@@ -15,7 +15,7 @@ export type SpaceThree = ThreeParts & Pick<typeof THREE, "PerspectiveCamera">;
|
|
|
15
15
|
/** The camera's distance, in radii of the body it looks at, at which that body fills the view at zoom 1. */
|
|
16
16
|
export declare const FIT_DISTANCE = 4.1;
|
|
17
17
|
/**
|
|
18
|
-
* The
|
|
18
|
+
* The twenty-four bodies the space view places, names and lets a reader choose: the Earth, the Sun, the Moon, the seven other planets, Pluto, the eight other dwarf planets and the five minor bodies (Vesta, Pallas, Chiron, Pholus and Halley). The moons of the planets and of the dwarf planets are placed round their hosts.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts no-run
|
|
@@ -24,7 +24,7 @@ export declare const FIT_DISTANCE = 4.1;
|
|
|
24
24
|
* console.log(SPACE_BODIES.join(", "));
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export declare const SPACE_BODIES: readonly ["earth", "sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "ceres", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna"];
|
|
27
|
+
export declare const SPACE_BODIES: readonly ["earth", "sun", "moon", "mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "ceres", "orcus", "haumea", "quaoar", "makemake", "gonggong", "eris", "sedna", "vesta", "pallas", "chiron", "pholus", "halley"];
|
|
28
28
|
/**
|
|
29
29
|
* One of the bodies in `SPACE_BODIES`, by the package's usual lower-case name.
|
|
30
30
|
*
|
|
@@ -155,6 +155,20 @@ export interface SpaceModel {
|
|
|
155
155
|
arrows: Record<string, OrbitArrow[]>;
|
|
156
156
|
/** Help mode: draw, on the body looked at, the axis it turns about and a curved arrow showing which way it turns. */
|
|
157
157
|
help: boolean;
|
|
158
|
+
/** How many arrowheads each orbit line carries: 0 to `MAX_ARROWS_PER_ORBIT`, two by default. */
|
|
159
|
+
arrowCount: number;
|
|
160
|
+
/** The name written on each body's globe, or null for none; `labelVersion` goes up whenever it (or the language) changes, so each body is told once. */
|
|
161
|
+
label: PaintLabel | null;
|
|
162
|
+
labelVersion: number;
|
|
163
|
+
/** The names on the globes at the last draw: how many are drawn (made, their font in, and big enough on the screen), and the one on the body looked at, or null. */
|
|
164
|
+
labelsDrawn: {
|
|
165
|
+
count: number;
|
|
166
|
+
focus: {
|
|
167
|
+
shown: boolean;
|
|
168
|
+
text: string;
|
|
169
|
+
turn: number;
|
|
170
|
+
} | null;
|
|
171
|
+
};
|
|
158
172
|
/** How long an arrowhead drawn at the last draw is on the screen, in CSS pixels (measured from its own points), or 0 when none was drawn. */
|
|
159
173
|
arrowPx: number;
|
|
160
174
|
/** What the help arrow drew at the last draw, or null: the body, the axis it spins about (right-hand rule), the north pole, and the axis the drawn arc itself turns about (measured from its points). */
|
package/dist/space/scene.js
CHANGED
|
@@ -6,10 +6,10 @@ import {} from "../scene/painter.js";
|
|
|
6
6
|
import "../bodies/all.js";
|
|
7
7
|
import { groundDirection } from "./aim.js";
|
|
8
8
|
import { hostOf } from "./bodies.js";
|
|
9
|
-
import { arrowSites, ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
|
|
9
|
+
import { arrowSites, ARROWS_PER_ORBIT, chevron, MAX_ARROWS_PER_ORBIT, spinArrow } from "./arrows.js";
|
|
10
10
|
import { besideMoon } from "./beside.js";
|
|
11
11
|
import { spinAxis } from "./spin.js";
|
|
12
|
-
import { createTrack, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
12
|
+
import { createTrack, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
13
13
|
import { ridePose } from "./ride.js";
|
|
14
14
|
import { moonDistance, orbitLine, placeBodies, placeMoon, radiusIn } from "./scale.js";
|
|
15
15
|
const RAD = Math.PI / 180;
|
|
@@ -17,8 +17,8 @@ const RAD = Math.PI / 180;
|
|
|
17
17
|
export const FIT_DISTANCE = 4.1;
|
|
18
18
|
const FOV = 35;
|
|
19
19
|
const ORBIT_POINTS = 96;
|
|
20
|
-
const ORBIT_BODIES = ["earth", ...SPACE_PLANETS, ...SPACE_DWARFS, "moon"];
|
|
21
|
-
/** A dwarf planet is drawn once it is this many CSS pixels across its radius, or when it is the body looked at: Sedna at true scale is never anything but a speck, and its picture is not made for it. */
|
|
20
|
+
const ORBIT_BODIES = ["earth", ...SPACE_PLANETS, ...SPACE_DWARFS, ...SPACE_MINORS, "moon"];
|
|
21
|
+
/** A dwarf planet or a minor body is drawn once it is this many CSS pixels across its radius, or when it is the body looked at: Sedna at true scale is never anything but a speck, and its picture is not made for it. */
|
|
22
22
|
const DWARF_MIN_PX = 0.4;
|
|
23
23
|
/** A colour as three numbers from 0 to 1, from `#rrggbb`. */
|
|
24
24
|
const rgb = (hex) => [parseInt(hex.slice(1, 3), 16) / 255, parseInt(hex.slice(3, 5), 16) / 255, parseInt(hex.slice(5, 7), 16) / 255];
|
|
@@ -38,7 +38,7 @@ const MOON_MIN_SYSTEM_PX = 30;
|
|
|
38
38
|
/** A moon that has been out of sight this long is let go (its pictures too). */
|
|
39
39
|
const MOON_KEEP_MS = 4000;
|
|
40
40
|
/**
|
|
41
|
-
* The
|
|
41
|
+
* The twenty-four bodies the space view places, names and lets a reader choose: the Earth, the Sun, the Moon, the seven other planets, Pluto, the eight other dwarf planets and the five minor bodies (Vesta, Pallas, Chiron, Pholus and Halley). The moons of the planets and of the dwarf planets are placed round their hosts.
|
|
42
42
|
*
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts no-run
|
|
@@ -47,7 +47,7 @@ const MOON_KEEP_MS = 4000;
|
|
|
47
47
|
* console.log(SPACE_BODIES.join(", "));
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
|
-
export const SPACE_BODIES = ["earth", "sun", "moon", ...SPACE_PLANETS, ...SPACE_DWARFS];
|
|
50
|
+
export const SPACE_BODIES = ["earth", "sun", "moon", ...SPACE_PLANETS, ...SPACE_DWARFS, ...SPACE_MINORS];
|
|
51
51
|
export const newSpaceModel = () => ({
|
|
52
52
|
time: Date.now(),
|
|
53
53
|
mode: "true",
|
|
@@ -67,6 +67,10 @@ export const newSpaceModel = () => ({
|
|
|
67
67
|
arrows: {},
|
|
68
68
|
help: false,
|
|
69
69
|
arrowPx: 0,
|
|
70
|
+
arrowCount: ARROWS_PER_ORBIT,
|
|
71
|
+
label: null,
|
|
72
|
+
labelVersion: 0,
|
|
73
|
+
labelsDrawn: { count: 0, focus: null },
|
|
70
74
|
helpDrawn: null,
|
|
71
75
|
door: { points: 0, used: {} },
|
|
72
76
|
lookups: 0,
|
|
@@ -135,12 +139,13 @@ export function createSpaceItem(model, deps) {
|
|
|
135
139
|
empty(slot);
|
|
136
140
|
slot.look = model.look;
|
|
137
141
|
try {
|
|
138
|
-
const made = deps.painter().make(three, id, { look: model.look, mapped: true, invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap() });
|
|
142
|
+
const made = deps.painter().make(three, id, { look: model.look, mapped: true, invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap(), label: model.label });
|
|
139
143
|
if (ended) {
|
|
140
144
|
made.dispose();
|
|
141
145
|
return;
|
|
142
146
|
}
|
|
143
147
|
slot.drawing = made;
|
|
148
|
+
slot.labelled = model.labelVersion;
|
|
144
149
|
scene.add(made.object);
|
|
145
150
|
}
|
|
146
151
|
catch (error) {
|
|
@@ -151,9 +156,16 @@ export function createSpaceItem(model, deps) {
|
|
|
151
156
|
const slotOf = (id) => {
|
|
152
157
|
let slot = slots.get(id);
|
|
153
158
|
if (!slot)
|
|
154
|
-
slots.set(id, (slot = { drawing: undefined, look: null, failed: false }));
|
|
159
|
+
slots.set(id, (slot = { drawing: undefined, look: null, failed: false, labelled: -1 }));
|
|
155
160
|
return slot;
|
|
156
161
|
};
|
|
162
|
+
/** A body whose name setting changed since it was made is told the new one (once). */
|
|
163
|
+
const relabel = (slot) => {
|
|
164
|
+
if (slot.drawing === undefined || slot.labelled === model.labelVersion)
|
|
165
|
+
return;
|
|
166
|
+
slot.labelled = model.labelVersion;
|
|
167
|
+
slot.drawing.setLabel(model.label);
|
|
168
|
+
};
|
|
157
169
|
// each line has its colour and a fade (the fourth number of the colour) at every point, so that near the body looked at the part of a line that would cross it is let go
|
|
158
170
|
const orbits = new Map();
|
|
159
171
|
for (const id of ORBIT_BODIES) {
|
|
@@ -171,7 +183,7 @@ export function createSpaceItem(model, deps) {
|
|
|
171
183
|
orbits.set(id, { line, positions, colours, faded: false, samples: [], epoch: Number.NaN });
|
|
172
184
|
}
|
|
173
185
|
// the arrowheads of every orbit line: two strokes each, in the colour of the line, in one object; and the help mode's axis and curved arrow in another (drawn over the body, not hidden by it)
|
|
174
|
-
const ARROW_VERTICES = ORBIT_BODIES.length *
|
|
186
|
+
const ARROW_VERTICES = ORBIT_BODIES.length * MAX_ARROWS_PER_ORBIT * 4;
|
|
175
187
|
const arrowPositions = new Float32Array(ARROW_VERTICES * 3);
|
|
176
188
|
const arrowColours = new Float32Array(ARROW_VERTICES * 3);
|
|
177
189
|
const arrowGeometry = new three.BufferGeometry();
|
|
@@ -182,8 +194,8 @@ export function createSpaceItem(model, deps) {
|
|
|
182
194
|
scene.add(arrowLines);
|
|
183
195
|
ORBIT_BODIES.forEach((id, k) => {
|
|
184
196
|
const c = rgb(id === "earth" ? "#6aa8ff" : id === "moon" ? "#c5cdd9" : BODIES[id].colour);
|
|
185
|
-
for (let v = 0; v <
|
|
186
|
-
arrowColours.set(c, (k *
|
|
197
|
+
for (let v = 0; v < MAX_ARROWS_PER_ORBIT * 4; v += 1)
|
|
198
|
+
arrowColours.set(c, (k * MAX_ARROWS_PER_ORBIT * 4 + v) * 3);
|
|
187
199
|
});
|
|
188
200
|
const HELP_SEGMENTS = 28;
|
|
189
201
|
const HELP_VERTICES = (1 + HELP_SEGMENTS + 2) * 2;
|
|
@@ -254,7 +266,7 @@ export function createSpaceItem(model, deps) {
|
|
|
254
266
|
placed[id] = minus(placed[id], origin);
|
|
255
267
|
return placed;
|
|
256
268
|
};
|
|
257
|
-
const toSunOf = (id) => unit(minus(frame.sun, id === "earth" ? [0, 0, 0] : id === "moon" ? frame.moon : id === "sun" ? [0, 0, 0] : SPACE_DWARFS.includes(id) ? frame.dwarfs[id] : frame.planets[id]));
|
|
269
|
+
const toSunOf = (id) => unit(minus(frame.sun, id === "earth" ? [0, 0, 0] : id === "moon" ? frame.moon : id === "sun" ? [0, 0, 0] : SPACE_DWARFS.includes(id) ? frame.dwarfs[id] : SPACE_MINORS.includes(id) ? frame.minors[id] : frame.planets[id]));
|
|
258
270
|
// riding along: the camera sits at a moving point and looks at the body it goes round (a moon over its planet, a point over any body). The point's place and way of going are in radii of
|
|
259
271
|
// that body, from its centre; the body is drawn at `centre` with the radius `unitWorld`, so the same numbers place the camera in the scene.
|
|
260
272
|
model.rideLost = false;
|
|
@@ -452,14 +464,15 @@ export function createSpaceItem(model, deps) {
|
|
|
452
464
|
let paintedBodies = 0;
|
|
453
465
|
for (const id of SPACE_BODIES) {
|
|
454
466
|
const slot = slotOf(id);
|
|
455
|
-
// a dwarf planet too small to see is not made, and one that was made but has shrunk away is hidden
|
|
456
|
-
const unseen = SPACE_DWARFS.includes(id) && px[id] < DWARF_MIN_PX && focus !== id && model.focus !== id && hostOf(model.focus) !== id;
|
|
467
|
+
// a dwarf planet or minor body too small to see is not made, and one that was made but has shrunk away is hidden
|
|
468
|
+
const unseen = (SPACE_DWARFS.includes(id) || SPACE_MINORS.includes(id)) && px[id] < DWARF_MIN_PX && focus !== id && model.focus !== id && hostOf(model.focus) !== id;
|
|
457
469
|
if (unseen) {
|
|
458
470
|
if (slot.drawing)
|
|
459
471
|
slot.drawing.object.visible = false;
|
|
460
472
|
continue;
|
|
461
473
|
}
|
|
462
474
|
fill(id, slot);
|
|
475
|
+
relabel(slot);
|
|
463
476
|
const drawing = slot.drawing;
|
|
464
477
|
if (!drawing)
|
|
465
478
|
continue;
|
|
@@ -550,7 +563,7 @@ export function createSpaceItem(model, deps) {
|
|
|
550
563
|
const line = [];
|
|
551
564
|
for (let i = 0; i <= ORBIT_POINTS; i += 1)
|
|
552
565
|
line.push([o.positions[i * 3], o.positions[i * 3 + 1], o.positions[i * 3 + 2]]);
|
|
553
|
-
const sites = arrowSites(line);
|
|
566
|
+
const sites = arrowSites(line, model.arrowCount);
|
|
554
567
|
arrowsNow[id] = sites;
|
|
555
568
|
sites.forEach((site, j) => {
|
|
556
569
|
// an arrow on the faded part of a line goes with it
|
|
@@ -559,7 +572,7 @@ export function createSpaceItem(model, deps) {
|
|
|
559
572
|
const head = chevron(site.position, site.direction, camRight, camUp, ARROW_PX * pixel(site.position));
|
|
560
573
|
if (!head)
|
|
561
574
|
return;
|
|
562
|
-
const base = (k *
|
|
575
|
+
const base = (k * MAX_ARROWS_PER_ORBIT + j) * 4 * 3;
|
|
563
576
|
arrowPositions.set([...head[0], ...head[1], ...head[0], ...head[2]], base);
|
|
564
577
|
if (measured === 0) {
|
|
565
578
|
const tip = labelFor(head[0]);
|
|
@@ -629,10 +642,11 @@ export function createSpaceItem(model, deps) {
|
|
|
629
642
|
continue;
|
|
630
643
|
let held = moonSlots.get(key);
|
|
631
644
|
if (!held)
|
|
632
|
-
moonSlots.set(key, (held = { slot: { drawing: undefined, look: null, failed: false }, seen: now }));
|
|
645
|
+
moonSlots.set(key, (held = { slot: { drawing: undefined, look: null, failed: false, labelled: -1 }, seen: now }));
|
|
633
646
|
held.seen = now;
|
|
634
647
|
seen.add(key);
|
|
635
648
|
fill(key, held.slot);
|
|
649
|
+
relabel(held.slot);
|
|
636
650
|
const drawing = held.slot.drawing;
|
|
637
651
|
if (!drawing)
|
|
638
652
|
continue;
|
|
@@ -671,6 +685,11 @@ export function createSpaceItem(model, deps) {
|
|
|
671
685
|
paintedMoons += 1;
|
|
672
686
|
model.painted.moons = paintedMoons;
|
|
673
687
|
model.painted.held = moonSlots.size;
|
|
688
|
+
let labelsDrawn = 0;
|
|
689
|
+
for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)])
|
|
690
|
+
if (painting?.object.visible && painting.label?.shown)
|
|
691
|
+
labelsDrawn += 1;
|
|
692
|
+
model.labelsDrawn = { count: labelsDrawn, focus: (slots.get(focus)?.drawing ?? moonSlots.get(focus)?.slot.drawing)?.label ?? null };
|
|
674
693
|
const tiles = { requested: 0, loading: 0, failed: 0, shown: null };
|
|
675
694
|
for (const painting of [...[...slots.values()].map((slot) => slot.drawing), ...[...moonSlots.values()].map((held) => held.slot.drawing)]) {
|
|
676
695
|
const stats = painting?.tiles;
|
package/dist/stops.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export interface JourneyStop {
|
|
|
32
32
|
escapeKmS: number | null;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Every body, in the same order as `BODY_IDS`: the Sun, the planets, the dwarf planets, then the moons.
|
|
35
|
+
* Every body, in the same order as `BODY_IDS`: the Sun, the planets, the dwarf planets, the minor bodies, then the moons.
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
38
|
* ```ts
|
package/dist/stops.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// (https://nssdc.gsfc.nasa.gov/planetary/factsheet/) for the Sun (132,712 × 10^6), Mercury (0.022032 × 10^6) and Venus (0.32486 × 10^6).
|
|
5
5
|
// Ceres, Eris, Makemake and Haumea: the mass on JPL "Planetary Physical Parameters" (https://ssd.jpl.nasa.gov/planets/phys_par.html)
|
|
6
6
|
// times the CODATA 2018 G that page names. Escape speeds for the Sun and those planets are the speeds those pages print.
|
|
7
|
+
// Vesta (17.2882844) and Pallas (13.63): the GM of JPL's Small-Body Database (https://ssd-api.jpl.nasa.gov/sbdb.api, read 2026-11-10), from Park et al. 2025 and Vernazza et al. 2021.
|
|
7
8
|
// A moon's escape speed is sqrt(2 GM / radius) from this package's radius. Nereid, and the dwarf planets and moons
|
|
8
9
|
// whose pages do not print a mass, are left empty.
|
|
9
10
|
import { heliocentric, meanSunAu, moonVector } from "./ephemeris.js";
|
|
@@ -30,6 +31,8 @@ const GM = {
|
|
|
30
31
|
eris: mass(16_600e18),
|
|
31
32
|
makemake: mass(3_100e18),
|
|
32
33
|
haumea: mass(4_006e18),
|
|
34
|
+
vesta: 17.2882844,
|
|
35
|
+
pallas: 13.63,
|
|
33
36
|
moon: 4_902.8,
|
|
34
37
|
phobos: 0.0007087,
|
|
35
38
|
deimos: 0.0000962,
|
|
@@ -89,7 +92,7 @@ const stopOf = (id) => {
|
|
|
89
92
|
};
|
|
90
93
|
};
|
|
91
94
|
/**
|
|
92
|
-
* Every body, in the same order as `BODY_IDS`: the Sun, the planets, the dwarf planets, then the moons.
|
|
95
|
+
* Every body, in the same order as `BODY_IDS`: the Sun, the planets, the dwarf planets, the minor bodies, then the moons.
|
|
93
96
|
*
|
|
94
97
|
* @example
|
|
95
98
|
* ```ts
|