@johnmorrisdotca/wakusei-planets 0.35.0 → 0.36.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 +9 -0
- package/NOTICE.md +16 -0
- package/README.md +3 -3
- package/dist/data/orbiters.d.ts +368 -0
- package/dist/data/orbiters.js +370 -0
- package/dist/orbiter-facts.d.ts +480 -0
- package/dist/orbiter-facts.js +189 -0
- package/dist/orbiters.d.ts +256 -0
- package/dist/orbiters.js +275 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +80 -4
- package/dist/space/element.js +350 -21
- package/dist/space/frame.d.ts +14 -0
- package/dist/space/frame.js +16 -0
- package/dist/space/index.d.ts +3 -1
- package/dist/space/index.js +3 -1
- package/dist/space/regions.d.ts +111 -0
- package/dist/space/regions.js +84 -0
- package/dist/space/scene.d.ts +99 -8
- package/dist/space/scene.js +268 -15
- package/dist/space/travel.d.ts +256 -0
- package/dist/space/travel.js +597 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
package/dist/orbiters.js
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// The spacecraft in orbit round the Moon and Mars: where each is at a moment, from mean orbital elements with secular rates fitted to JPL Horizons' track (src/data/orbiters.ts, made by
|
|
2
|
+
// scripts/make-orbiter-data.py), and what is known about each (src/orbiter-facts.ts). Pure: no DOM, no clock reads. Positions are from the centre of the body, in kilometres, ecliptic and
|
|
3
|
+
// equinox J2000, the same axes as `/roadster` and the ten deep-space craft; `eclipticToScene` from `/space` turns them into the space view's axes.
|
|
4
|
+
import { ORBITER_FITS } from "./data/orbiters.js";
|
|
5
|
+
import { ORBITER_FACTS } from "./orbiter-facts.js";
|
|
6
|
+
export { ORBITER_FACTS } from "./orbiter-facts.js";
|
|
7
|
+
/**
|
|
8
|
+
* The orbiters the package knows: six round the Moon and seven round Mars.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { ORBITER_IDS } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
13
|
+
*
|
|
14
|
+
* console.log(ORBITER_IDS.join(", "));
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const ORBITER_IDS = Object.keys(ORBITER_FITS);
|
|
18
|
+
/** GM of the Moon and Mars in km^3/s^2 (JPL DE440). */
|
|
19
|
+
const GM = { moon: 4902.800118, mars: 42828.375816 };
|
|
20
|
+
const UNIX_EPOCH_JD = 2440587.5;
|
|
21
|
+
/**
|
|
22
|
+
* TDB minus UTC in seconds. The fitted epochs and Horizons' vectors are in TDB; a `Date` is UTC. TAI - UTC is 37 s (since 2017-01-01; a later leap second would add one) and TT - TAI is 32.184 s; TDB differs
|
|
23
|
+
* from TT by under 2 ms, which this package ignores. Left out, the craft would lag its true place by about 69 s of its motion: 110 km for LRO, 235 km for MRO.
|
|
24
|
+
*/
|
|
25
|
+
const TDB_MINUS_UTC_S = 37 + 32.184;
|
|
26
|
+
const RAD = Math.PI / 180;
|
|
27
|
+
const hasElements = (fit) => "a" in fit && typeof fit.a === "number";
|
|
28
|
+
function idOf(id) {
|
|
29
|
+
if (!(id in ORBITER_FITS))
|
|
30
|
+
throw new Error(`wakusei-planets: no orbiter called ${id}`);
|
|
31
|
+
return id;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The body an orbiter goes round.
|
|
35
|
+
*
|
|
36
|
+
* @param id - The orbiter.
|
|
37
|
+
* @returns `moon` or `mars`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { orbiterCentre } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
42
|
+
*
|
|
43
|
+
* console.log(orbiterCentre("hope"));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export function orbiterCentre(id) {
|
|
47
|
+
return ORBITER_FITS[idOf(id)].center;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The fitted elements of an orbiter, or `undefined` for one with no path (`orbiterStatus` says `none`).
|
|
51
|
+
*
|
|
52
|
+
* @param id - The orbiter.
|
|
53
|
+
* @returns The elements, or `undefined`.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* import { orbiterElements } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
58
|
+
*
|
|
59
|
+
* console.log(orbiterElements("capstone"), orbiterElements("mro")?.e.toFixed(4));
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function orbiterElements(id) {
|
|
63
|
+
const fit = ORBITER_FITS[idOf(id)];
|
|
64
|
+
if (!hasElements(fit))
|
|
65
|
+
return undefined;
|
|
66
|
+
const f = fit;
|
|
67
|
+
return { a: f.a, e: f.e, i: f.i, raan: f.raan, argp: f.argp, m0: f.m0, raanRate: f.raanRate, argpRate: f.argpRate, meanMotionCorrection: f.meanMotionCorrection, periodDays: f.periodDays, epochJd: f.epochJd, validFrom: f.validFrom, fitUntil: f.fitUntil, validUntil: f.validUntil, retrieved: f.retrieved, trackedUntil: f.trackedUntil, fitErrorKm: { ...f.fitErrorKm }, predictedErrorKm: f.predictedErrorKm === null ? null : { ...f.predictedErrorKm }, basis: f.basis };
|
|
68
|
+
}
|
|
69
|
+
const msOf = (when) => (when instanceof Date ? when.getTime() : when);
|
|
70
|
+
/** The Julian date in TDB of a moment given in UTC (see `TDB_MINUS_UTC_S`). */
|
|
71
|
+
const tdbJdOf = (when) => (msOf(when) / 1000 + TDB_MINUS_UTC_S) / 86_400 + UNIX_EPOCH_JD;
|
|
72
|
+
/**
|
|
73
|
+
* Where an orbiter's path comes from at a moment: see `OrbiterStatus`. `tracked` ends with the fit's window (`fitUntil`); after it, up to `validUntil`, a path is `predicted`. A moment before the window or after
|
|
74
|
+
* `validUntil` is `modelled` (the ellipse is extended, not measured there). `trackedUntil`, how far Horizons' own tracking data reached, is not used: where Horizons' track is itself an agency's prediction, "tracked" says the
|
|
75
|
+
* ellipse follows that track.
|
|
76
|
+
*
|
|
77
|
+
* @param id - The orbiter.
|
|
78
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
79
|
+
* @returns The status.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* import { orbiterStatus } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
84
|
+
*
|
|
85
|
+
* console.log(orbiterStatus("mro", Date.UTC(2026, 10, 1)), orbiterStatus("mro", Date.UTC(2030, 0, 1)));
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export function orbiterStatus(id, when) {
|
|
89
|
+
const fit = ORBITER_FITS[idOf(id)];
|
|
90
|
+
if (!hasElements(fit))
|
|
91
|
+
return "none";
|
|
92
|
+
const f = fit;
|
|
93
|
+
if (f.basis === "modelled")
|
|
94
|
+
return "modelled";
|
|
95
|
+
const ms = msOf(when);
|
|
96
|
+
if (ms < Date.parse(f.validFrom) || ms > Date.parse(f.validUntil))
|
|
97
|
+
return "modelled";
|
|
98
|
+
return ms > Date.parse(f.fitUntil) ? "predicted" : "tracked";
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Where an orbiter is at a moment, in kilometres from the centre of the body it goes round, ecliptic and equinox J2000. The mean ellipse is propagated with its drifting node and periapsis: good to the
|
|
102
|
+
* `fitErrorKm` of its elements within the fit's window and the larger `predictedErrorKm` in the days after it, rougher beyond (`orbiterStatus`). `when` is UTC; the elements' TDB epoch is allowed for (69.184 s). Throws for a craft with no path.
|
|
103
|
+
*
|
|
104
|
+
* @param id - The orbiter.
|
|
105
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
106
|
+
* @returns x, y, z in kilometres.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { orbiterPosition } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
111
|
+
*
|
|
112
|
+
* const [x, y, z] = orbiterPosition("lro", Date.UTC(2026, 10, 11));
|
|
113
|
+
* console.log(Math.hypot(x, y, z).toFixed(0), "km from the Moon's centre");
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function orbiterPosition(id, when) {
|
|
117
|
+
return stateOf(id, when).position;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* How fast an orbiter moves at a moment, in kilometres a second relative to the body it goes round (from the ellipse).
|
|
121
|
+
*
|
|
122
|
+
* @param id - The orbiter.
|
|
123
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
124
|
+
* @returns The speed in km/s.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* import { orbiterSpeed } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
129
|
+
*
|
|
130
|
+
* console.log(orbiterSpeed("lro", Date.UTC(2026, 10, 11)).toFixed(2), "km/s");
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export function orbiterSpeed(id, when) {
|
|
134
|
+
const { velocity } = stateOf(id, when);
|
|
135
|
+
return Math.hypot(velocity[0], velocity[1], velocity[2]);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The numbers a page shows for an orbiter at a moment: its height above the body's mean surface, its speed, its period and inclination, where its path comes from, and how far wrong it may be (`errorKm`: the worst error
|
|
139
|
+
* measured against Horizons for that status, `fitErrorKm.max` when `tracked`, `predictedErrorKm.max` when `predicted`; `null` when `modelled`).
|
|
140
|
+
*
|
|
141
|
+
* @param id - The orbiter.
|
|
142
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC).
|
|
143
|
+
* @returns The numbers, or `undefined` for a craft with no path.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```ts
|
|
147
|
+
* import { orbiterNumbers } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
148
|
+
*
|
|
149
|
+
* const mro = orbiterNumbers("mro", Date.UTC(2026, 10, 11))!;
|
|
150
|
+
* console.log(mro.altitudeKm.toFixed(0), "km up,", mro.speedKmS.toFixed(2), "km/s,", (mro.periodDays * 24 * 60).toFixed(0), "minutes round,", mro.status, "within", mro.errorKm, "km");
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export function orbiterNumbers(id, when) {
|
|
154
|
+
const elements = orbiterElements(id);
|
|
155
|
+
if (elements === undefined)
|
|
156
|
+
return undefined;
|
|
157
|
+
const { position, velocity } = stateOf(id, when);
|
|
158
|
+
const status = orbiterStatus(id, when);
|
|
159
|
+
const errorKm = status === "tracked" ? elements.fitErrorKm.max : status === "predicted" ? (elements.predictedErrorKm?.max ?? null) : null;
|
|
160
|
+
return { altitudeKm: Math.hypot(position[0], position[1], position[2]) - MEAN_RADIUS_KM[orbiterCentre(id)], speedKmS: Math.hypot(velocity[0], velocity[1], velocity[2]), periodDays: elements.periodDays, inclinationDeg: elements.i, status, errorKm };
|
|
161
|
+
}
|
|
162
|
+
/** The mean radius of the Moon and Mars in kilometres (IAU), for heights above the surface. */
|
|
163
|
+
const MEAN_RADIUS_KM = { moon: 1737.4, mars: 3389.5 };
|
|
164
|
+
/**
|
|
165
|
+
* The orbit as points round one trip, in kilometres from the body's centre, ecliptic J2000, at the moment's node and periapsis: for an orbit line.
|
|
166
|
+
*
|
|
167
|
+
* @param id - The orbiter.
|
|
168
|
+
* @param when - A `Date` or milliseconds since 1970 (UTC): the ellipse's orientation then.
|
|
169
|
+
* @param points - How many points round the trip (the first is repeated at the end).
|
|
170
|
+
* @returns The points, or an empty list for a craft with no path.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* import { orbiterPath } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
175
|
+
*
|
|
176
|
+
* console.log(orbiterPath("hope", Date.UTC(2026, 10, 11), 8).length);
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export function orbiterPath(id, when, points = 96) {
|
|
180
|
+
const elements = orbiterElements(id);
|
|
181
|
+
if (elements === undefined)
|
|
182
|
+
return [];
|
|
183
|
+
const dt = tdbJdOf(when) - elements.epochJd;
|
|
184
|
+
const out = [];
|
|
185
|
+
// evenly spaced in eccentric anomaly, not mean: a lopsided orbit (ARTEMIS P1, e about 0.8) is then sampled fastest where it bends least, and has no sharp corner at periapsis
|
|
186
|
+
for (let k = 0; k <= points; k += 1)
|
|
187
|
+
out.push(placeAt(elements, dt, (2 * Math.PI * k) / points));
|
|
188
|
+
return out;
|
|
189
|
+
}
|
|
190
|
+
function stateOf(id, when) {
|
|
191
|
+
const elements = orbiterElements(id);
|
|
192
|
+
if (elements === undefined)
|
|
193
|
+
throw new RangeError(`wakusei-planets: ${id} has no path to follow (${orbiterStatus(id, when)})`);
|
|
194
|
+
const centre = orbiterCentre(id);
|
|
195
|
+
const dt = tdbJdOf(when) - elements.epochJd;
|
|
196
|
+
const n = meanMotion(elements, centre);
|
|
197
|
+
const m = (elements.m0 + n * dt) % 360;
|
|
198
|
+
const position = placeOf(elements, centre, dt, undefined, m);
|
|
199
|
+
// the velocity from the ellipse: a small step along it in time
|
|
200
|
+
const later = placeOf(elements, centre, dt + 1 / 86_400, undefined, (elements.m0 + n * (dt + 1 / 86_400)) % 360);
|
|
201
|
+
return { position, velocity: [later[0] - position[0], later[1] - position[1], later[2] - position[2]] };
|
|
202
|
+
}
|
|
203
|
+
/** The mean motion in degrees a day: Kepler's for `a`, corrected by the fit. */
|
|
204
|
+
const meanMotion = (elements, centre) => (Math.sqrt(GM[centre] / elements.a ** 3) * 86_400) / RAD + elements.meanMotionCorrection;
|
|
205
|
+
/** A point of the ellipse `dt` days after the epoch: at the true anomaly of mean anomaly `meanAnomaly` (degrees), or at the given mean anomaly. */
|
|
206
|
+
function placeOf(elements, centre, dt, meanAnomalyDeg, mDeg) {
|
|
207
|
+
void centre;
|
|
208
|
+
const e = elements.e;
|
|
209
|
+
const m = ((meanAnomalyDeg ?? mDeg ?? 0) * RAD) % (2 * Math.PI);
|
|
210
|
+
let ea = m;
|
|
211
|
+
for (let k = 0; k < 30; k += 1)
|
|
212
|
+
ea -= (ea - e * Math.sin(ea) - m) / (1 - e * Math.cos(ea));
|
|
213
|
+
return placeAt(elements, dt, ea);
|
|
214
|
+
}
|
|
215
|
+
/** A point of the ellipse `dt` days after the epoch at the eccentric anomaly `ea` (radians). */
|
|
216
|
+
function placeAt(elements, dt, ea) {
|
|
217
|
+
const e = elements.e;
|
|
218
|
+
const nu = 2 * Math.atan2(Math.sqrt(1 + e) * Math.sin(ea / 2), Math.sqrt(1 - e) * Math.cos(ea / 2));
|
|
219
|
+
const r = elements.a * (1 - e * Math.cos(ea));
|
|
220
|
+
const raan = (elements.raan + elements.raanRate * dt) * RAD;
|
|
221
|
+
const argp = (elements.argp + elements.argpRate * dt) * RAD;
|
|
222
|
+
const inc = elements.i * RAD;
|
|
223
|
+
const u = argp + nu;
|
|
224
|
+
return [
|
|
225
|
+
r * (Math.cos(raan) * Math.cos(u) - Math.sin(raan) * Math.sin(u) * Math.cos(inc)),
|
|
226
|
+
r * (Math.sin(raan) * Math.cos(u) + Math.cos(raan) * Math.sin(u) * Math.cos(inc)),
|
|
227
|
+
r * Math.sin(u) * Math.sin(inc),
|
|
228
|
+
];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* What is known about an orbiter: names, operator, launch, instruments, a line about it, and the state of its path.
|
|
232
|
+
*
|
|
233
|
+
* @param id - The orbiter.
|
|
234
|
+
* @returns The facts.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* import { orbiterFacts } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
239
|
+
*
|
|
240
|
+
* const lro = orbiterFacts("lro");
|
|
241
|
+
* console.log(lro.name.en, lro.operator, lro.launch.date, lro.launch.vehicle);
|
|
242
|
+
* ```
|
|
243
|
+
*/
|
|
244
|
+
export function orbiterFacts(id) {
|
|
245
|
+
return ORBITER_FACTS[idOf(id)];
|
|
246
|
+
}
|
|
247
|
+
/** An ecliptic J2000 vector in the space view's axes (equatorial J2000, y north): the same turn `eclipticToScene` from `/space` makes, kept here so `/orbiters` imports nothing of the view. */
|
|
248
|
+
const OBLIQUITY = 23.4392911 * RAD;
|
|
249
|
+
const toScene = (v) => [v[0], v[1] * Math.sin(OBLIQUITY) + v[2] * Math.cos(OBLIQUITY), -(v[1] * Math.cos(OBLIQUITY) - v[2] * Math.sin(OBLIQUITY))];
|
|
250
|
+
/**
|
|
251
|
+
* An orbiter as a point the space view can ride along with (`space.ride(orbiterRidePoint("lro"), { around: "moon" })`): where it is and which way it goes at a moment, in kilometres and kilometres a
|
|
252
|
+
* second from the centre of the body it goes round, in the view's axes (equatorial J2000, y north). It answers `null` for a craft with no path.
|
|
253
|
+
*
|
|
254
|
+
* @param id - The orbiter.
|
|
255
|
+
* @returns The point: its `at` gives the place and velocity, or `null` for a craft with no path (`orbiterStatus` says `none`), which the view then does not ride.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```ts
|
|
259
|
+
* import { orbiterRidePoint } from "@johnmorrisdotca/wakusei-planets/orbiters";
|
|
260
|
+
*
|
|
261
|
+
* const point = orbiterRidePoint("mro").at(Date.UTC(2026, 10, 11));
|
|
262
|
+
* console.log(point === null ? "no path" : Math.hypot(...point.velocity).toFixed(2) + " km/s");
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export function orbiterRidePoint(id) {
|
|
266
|
+
idOf(id);
|
|
267
|
+
return {
|
|
268
|
+
at(ms) {
|
|
269
|
+
if (orbiterElements(id) === undefined)
|
|
270
|
+
return null;
|
|
271
|
+
const { position, velocity } = stateOf(id, ms);
|
|
272
|
+
return { position: toScene(position), velocity: toScene(velocity) };
|
|
273
|
+
},
|
|
274
|
+
};
|
|
275
|
+
}
|
package/dist/scene/textures.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
|
|
|
11
11
|
* console.log(TEXTURE_BASE);
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.
|
|
14
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.36.0/dist/textures/";
|
|
15
15
|
/**
|
|
16
16
|
* Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
|
|
17
17
|
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
|
|
|
23
23
|
* console.log(TEXTURE_FAR_BASE);
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.
|
|
26
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.36.0/textures/";
|
|
27
27
|
/**
|
|
28
28
|
* Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
|
|
29
29
|
* a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
|
package/dist/space/element.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ import { setThreeLoader } from "../scene/shared.ts";
|
|
|
9
9
|
import { type SpacePlanet } from "./frame.ts";
|
|
10
10
|
import { type ScaleMode } from "./scale.ts";
|
|
11
11
|
import type { RideLook } from "./ride.ts";
|
|
12
|
+
import { type SunRegion } from "./regions.ts";
|
|
13
|
+
import { type TravelKind } from "./travel.ts";
|
|
12
14
|
import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
13
15
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type SpaceBody, type SpaceLight };
|
|
14
16
|
/** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
|
|
@@ -80,6 +82,10 @@ export interface RideOptions {
|
|
|
80
82
|
distanceKm?: number;
|
|
81
83
|
around?: SpaceBody;
|
|
82
84
|
smooth?: boolean;
|
|
85
|
+
/** How the camera moves there: the view's `transition` by default. */
|
|
86
|
+
transition?: TravelKind;
|
|
87
|
+
/** How long the move takes, in milliseconds: the plan's own length by default. */
|
|
88
|
+
duration?: number;
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* What the camera is riding along with now: the target, the body it goes round, how (`from` or `follow`), where it looks, and the distance kept for a point.
|
|
@@ -158,6 +164,31 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
158
164
|
set scaleNames(value: Partial<Record<ScaleMode, string>>);
|
|
159
165
|
get labels(): boolean;
|
|
160
166
|
set labels(value: boolean);
|
|
167
|
+
/**
|
|
168
|
+
* How the camera moves from one view to the next: `turn-travel` (the default: turn beside the body being left until the next is in the picture, then travel to it, never an empty frame), `direct` (a straight
|
|
169
|
+
* eased glide), `look-back` (straight, watching the body left until the end), `auto` (`turn-travel`), `cut` (no move). The attribute `transition` says the same; `goTo` and `ride` take one for a single move. A
|
|
170
|
+
* reader who asked for reduced motion always gets `cut`.
|
|
171
|
+
*/
|
|
172
|
+
get transition(): TravelKind;
|
|
173
|
+
set transition(value: TravelKind);
|
|
174
|
+
/** How slow the moves are: the plan's own length times this (1 by default; 2 is twice as slow). The attribute `pace` says the same; `goTo` and `ride` take `duration` in milliseconds for a single move instead. */
|
|
175
|
+
get pace(): number;
|
|
176
|
+
set pace(value: number);
|
|
177
|
+
/** The stage out from the Sun the view is framed on (`inner-planets`, `asteroid-belt`, `outer-planets`, `kuiper-belt`, `whole-system`), or null for a view of a body. */
|
|
178
|
+
get region(): SunRegion | null;
|
|
179
|
+
/**
|
|
180
|
+
* Show the spacecraft in orbit round the Moon and Mars (the attribute `orbiters`; off by default): each a small dot where `/orbiters` puts it on the date shown, scaled with its body, on its orbit line, with its
|
|
181
|
+
* name beside it in the page's language, once the body is at least 24 CSS pixels in radius on the screen. A modelled or predicted path is drawn dim; a craft with no path is not drawn. The paths (a 9 kB module)
|
|
182
|
+
* are loaded the first time they are shown. `stats.orbiters` says what was drawn and each one's status.
|
|
183
|
+
*/
|
|
184
|
+
get orbiters(): boolean;
|
|
185
|
+
set orbiters(value: boolean);
|
|
186
|
+
/**
|
|
187
|
+
* Show Starman and the Tesla Roadster (the attribute `roadster`; off by default): a small marked body where `/roadster` puts the car on the date shown, on its orbit line (about one trip round the Sun), with its name
|
|
188
|
+
* (`Starman`, `スターマン`) beside it, from the launch in 2018 to the end of 2035. Its path (a 20 kB table) is loaded the first time it is shown, and never when it is not. `stats.roadster` says what was drawn.
|
|
189
|
+
*/
|
|
190
|
+
get roadster(): boolean;
|
|
191
|
+
set roadster(value: boolean);
|
|
161
192
|
/**
|
|
162
193
|
* What a body behind another gets (the attribute `covered`): `name` (the default) draws its floating name and ring over the nearer body's disc as always; `arrow` draws instead one small quiet arrow just outside the
|
|
163
194
|
* disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out.
|
|
@@ -218,17 +249,34 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
218
249
|
next: BodyInfo;
|
|
219
250
|
};
|
|
220
251
|
/**
|
|
221
|
-
* Go to a body: it becomes the middle of the view and the zoom brings it whole into view (`zoom`, 1 by default; a planet's `-moons` preset for its system),
|
|
222
|
-
*
|
|
252
|
+
* Go to a body: it becomes the middle of the view and the zoom brings it whole into view (`zoom`, 1 by default; a planet's `-moons` preset for its system), travelling there from where the camera is (`transition`,
|
|
253
|
+
* the view's own by default; `duration` in milliseconds, the plan's own by default) unless `smooth` is false or the reader asked for reduced motion. The travel arrives from the side it comes from, moved round
|
|
254
|
+
* towards the Sun where that side would show the body mostly dark, so the way in is straight: the controls' yaw and tilt are set to that side. A stage out from the Sun (`inner-planets`, `asteroid-belt`,
|
|
255
|
+
* `outer-planets`, `kuiper-belt`, `whole-system`) is a target too: the Sun is looked at and the camera stands back until the stage's orbits are all in the picture, with the stage's name shown. `wakusei-hop`
|
|
256
|
+
* tells the page where it went and where the next and previous hops lead. A name in any case, in English or Japanese, works.
|
|
223
257
|
*
|
|
224
|
-
* @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`).
|
|
225
|
-
* @param options - `smooth` (true by default)
|
|
258
|
+
* @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`) or a stage's id.
|
|
259
|
+
* @param options - `smooth` (true by default), `zoom` (1 by default), `transition` and `duration`.
|
|
226
260
|
* @returns Whether the view can go there.
|
|
227
261
|
*/
|
|
228
262
|
goTo(target: BodyId | string, options?: {
|
|
229
263
|
smooth?: boolean;
|
|
230
264
|
zoom?: number;
|
|
265
|
+
transition?: TravelKind;
|
|
266
|
+
duration?: number;
|
|
231
267
|
}): boolean;
|
|
268
|
+
/** The next stage out from the Sun from where the view is (the first stage from a body), with the same move as `goTo`; null, and nothing done, when the view is already at the widest stage. */
|
|
269
|
+
stepOut(options?: {
|
|
270
|
+
smooth?: boolean;
|
|
271
|
+
transition?: TravelKind;
|
|
272
|
+
duration?: number;
|
|
273
|
+
}): SunRegion | null;
|
|
274
|
+
/** The next stage in towards the Sun from the stage the view is at, or the Sun itself (`"sun"`, zoom 1) from the first stage; null, and nothing done, when the view is not at a stage. */
|
|
275
|
+
stepIn(options?: {
|
|
276
|
+
smooth?: boolean;
|
|
277
|
+
transition?: TravelKind;
|
|
278
|
+
duration?: number;
|
|
279
|
+
}): SunRegion | "sun" | null;
|
|
232
280
|
/** Go to the next body in the order of `bodyList()` (the Sun, Mercury, Venus, the Earth, the Moon, Mars, Phobos, Deimos, Ceres, Jupiter, its moons, and on), round to the Sun after the last. */
|
|
233
281
|
next(options?: {
|
|
234
282
|
smooth?: boolean;
|
|
@@ -326,6 +374,23 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
326
374
|
lost: boolean;
|
|
327
375
|
gliding: boolean;
|
|
328
376
|
};
|
|
377
|
+
/** The camera's move at the last draw, or null when it is still: its kind and path, its stage, how far along it is (0 to 1), its length in milliseconds, and whether the body left and the one gone to are in the picture. */
|
|
378
|
+
travelling: {
|
|
379
|
+
kind: string;
|
|
380
|
+
path: string;
|
|
381
|
+
stage: "turn" | "travel" | "arrive";
|
|
382
|
+
progress: number;
|
|
383
|
+
duration: number;
|
|
384
|
+
leaving: boolean;
|
|
385
|
+
destination: boolean;
|
|
386
|
+
} | null;
|
|
387
|
+
/** The stage out from the Sun the view is framed on, or null: its id and name, how far it reaches from the Sun and how far back the camera stands, in Earth radii. */
|
|
388
|
+
region: {
|
|
389
|
+
id: string;
|
|
390
|
+
name: string;
|
|
391
|
+
reach: number;
|
|
392
|
+
distance: number;
|
|
393
|
+
} | null;
|
|
329
394
|
/** The data door: the small bodies in the one instanced draw, and what the sources have done (tile loads started, failed and refused, bytes held, records read). */
|
|
330
395
|
door: {
|
|
331
396
|
points: number;
|
|
@@ -361,6 +426,17 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
361
426
|
turn: number;
|
|
362
427
|
} | null;
|
|
363
428
|
};
|
|
429
|
+
/** Starman and the Roadster at the last draw: whether the car was drawn (shown, its path in, the moment within 2018 to 2035), its place in Earth radii from the Earth's centre, and its radius on the screen in CSS pixels. */
|
|
430
|
+
roadster: {
|
|
431
|
+
shown: boolean;
|
|
432
|
+
position: [number, number, number] | null;
|
|
433
|
+
radiusPx: number;
|
|
434
|
+
};
|
|
435
|
+
/** The orbiters at the last draw: how many dots were drawn (their body big enough on the screen), and each drawn craft's status (`tracked`, `predicted`, `modelled`). */
|
|
436
|
+
orbiters: {
|
|
437
|
+
count: number;
|
|
438
|
+
status: Record<string, "tracked" | "predicted" | "modelled" | "none">;
|
|
439
|
+
};
|
|
364
440
|
};
|
|
365
441
|
/** Where a body is on the screen now: its centre and radius in CSS pixels in the element, or `null` when it is behind the camera or not drawn. */
|
|
366
442
|
placeOf(id: BodyId): BodyPlace | null;
|