@johnmorrisdotca/wakusei-planets 0.20.0 → 0.22.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 +17 -0
- package/NOTICE.md +27 -1
- package/README.md +36 -6
- package/dist/bodies/earth.js +13 -5
- package/dist/calendar.js +7 -6
- package/dist/clock.js +5 -6
- package/dist/coordinates.d.ts +7 -12
- package/dist/coordinates.js +19 -18
- package/dist/craft/cassini.d.ts +1 -0
- package/dist/craft/cassini.js +1131 -0
- package/dist/craft/galileo.d.ts +1 -0
- package/dist/craft/galileo.js +224 -0
- package/dist/craft/juno.d.ts +1 -0
- package/dist/craft/juno.js +640 -0
- package/dist/craft/newhorizons.d.ts +1 -0
- package/dist/craft/newhorizons.js +18 -0
- package/dist/craft/parker.d.ts +1 -0
- package/dist/craft/parker.js +221 -0
- package/dist/craft/pioneer10.d.ts +1 -0
- package/dist/craft/pioneer10.js +24 -0
- package/dist/craft/pioneer11.d.ts +1 -0
- package/dist/craft/pioneer11.js +34 -0
- package/dist/craft/voyager1.d.ts +1 -0
- package/dist/craft/voyager1.js +28 -0
- package/dist/craft/voyager2.d.ts +1 -0
- package/dist/craft/voyager2.js +43 -0
- package/dist/craft/webb.d.ts +1 -0
- package/dist/craft/webb.js +28 -0
- package/dist/data/craft.d.ts +23 -0
- package/dist/data/craft.js +53 -0
- package/dist/data/galilean.d.ts +15 -0
- package/dist/data/galilean.js +7 -0
- package/dist/data/orbits.js +25 -25
- package/dist/data/stars.d.ts +4 -0
- package/dist/data/stars.js +5088 -0
- package/dist/data/tass17.d.ts +17 -0
- package/dist/data/tass17.js +10 -0
- package/dist/data/theories.d.ts +64 -0
- package/dist/data/theories.js +70 -0
- package/dist/data/vsop.js +2 -2
- package/dist/element.d.ts +3 -24
- package/dist/element.js +92 -112
- package/dist/ephemeris.d.ts +20 -0
- package/dist/ephemeris.js +57 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/portrait/element.d.ts +1 -0
- package/dist/portrait/element.js +27 -39
- package/dist/scene/basis.d.ts +3 -0
- package/dist/scene/basis.js +4 -0
- package/dist/scene/body.d.ts +2 -4
- package/dist/scene/body.js +55 -67
- package/dist/scene/fallback.d.ts +4 -0
- package/dist/scene/fallback.js +5 -0
- package/dist/scene/painter.js +10 -23
- package/dist/scene/store.d.ts +2 -2
- package/dist/scene/textures.d.ts +30 -0
- package/dist/scene/textures.js +47 -0
- package/dist/sidereal.d.ts +4 -0
- package/dist/sidereal.js +15 -9
- package/dist/sky/engine.d.ts +6 -15
- package/dist/sky/engine.js +9 -38
- package/dist/sky/frames.d.ts +3 -0
- package/dist/sky/frames.js +26 -0
- package/dist/sky/types.d.ts +20 -0
- package/dist/sky/types.js +1 -0
- package/dist/space/aim.d.ts +18 -0
- package/dist/space/aim.js +28 -0
- package/dist/space/element.d.ts +212 -0
- package/dist/space/element.js +524 -0
- package/dist/space/frame.d.ts +152 -0
- package/dist/space/frame.js +169 -0
- package/dist/space/index.d.ts +4 -0
- package/dist/space/index.js +5 -0
- package/dist/space/ride.d.ts +89 -0
- package/dist/space/ride.js +58 -0
- package/dist/space/scale.d.ts +126 -0
- package/dist/space/scale.js +139 -0
- package/dist/space/scene.d.ts +189 -0
- package/dist/space/scene.js +422 -0
- package/dist/spacecraft-facts.d.ts +114 -0
- package/dist/spacecraft-facts.js +215 -0
- package/dist/spacecraft.d.ts +134 -0
- package/dist/spacecraft.js +198 -0
- package/dist/stars.d.ts +160 -0
- package/dist/stars.js +193 -0
- package/dist/suncalc.js +4 -10
- package/dist/tables/all.d.ts +2 -0
- package/dist/tables/all.js +2 -0
- package/dist/tables/galilean.d.ts +1 -0
- package/dist/tables/galilean.js +4 -0
- package/dist/tables/lazy.d.ts +2 -0
- package/dist/tables/lazy.js +15 -0
- package/dist/tables/saturn-moons.d.ts +1 -0
- package/dist/tables/saturn-moons.js +4 -0
- package/dist/tables/vsop.d.ts +1 -0
- package/dist/tables/vsop.js +11 -0
- package/dist/theories/galilean.d.ts +7 -0
- package/dist/theories/galilean.js +78 -0
- package/dist/theories/tass17.d.ts +7 -0
- package/dist/theories/tass17.js +90 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/when.js +6 -11
- package/package.json +68 -4
package/dist/element.js
CHANGED
|
@@ -1,38 +1,18 @@
|
|
|
1
|
-
import "./tables/
|
|
1
|
+
import "./tables/ceres.js";
|
|
2
|
+
import "./tables/dwarfs.js";
|
|
3
|
+
import { loadMoonTheory } from "./tables/lazy.js";
|
|
2
4
|
import { orbitPath, nearMoons } from "./ephemeris.js";
|
|
3
5
|
import { BODIES, ringReach } from "./facts.js";
|
|
4
6
|
import { createGate, frameCap } from "./gate.js";
|
|
5
7
|
import { lineSvg } from "./line.js";
|
|
6
8
|
import { createLive, defaultTurn, REDUCED_TURN } from "./live.js";
|
|
7
|
-
import {
|
|
9
|
+
import { texturePaths } from "./scene/textures.js";
|
|
10
|
+
export { TEXTURE_BASE, TEXTURE_FAR_BASE } from "./scene/textures.js";
|
|
8
11
|
import { createBodyItem } from "./scene/body.js";
|
|
9
12
|
import { delegates, onRegister } from "./scene/store.js";
|
|
10
13
|
import { setThreeLoader, takeRenderer } from "./scene/shared.js";
|
|
11
14
|
import { turn as turnVec } from "./vec.js";
|
|
12
15
|
export { setThreeLoader };
|
|
13
|
-
/**
|
|
14
|
-
* The default home of the surface pictures: the files of this exact version on jsDelivr. Set `texture-base` on an element to serve them yourself.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts no-run
|
|
18
|
-
* import { TEXTURE_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
19
|
-
*
|
|
20
|
-
* console.log(TEXTURE_BASE);
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export const TEXTURE_BASE = `https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@${VERSION}/dist/textures/`;
|
|
24
|
-
/**
|
|
25
|
-
* 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
|
|
26
|
-
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts no-run
|
|
30
|
-
* import { TEXTURE_FAR_BASE } from "@johnmorrisdotca/wakusei-planets/element";
|
|
31
|
-
*
|
|
32
|
-
* console.log(TEXTURE_FAR_BASE);
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export const TEXTURE_FAR_BASE = `https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v${VERSION}/textures/`;
|
|
36
16
|
const num = (value, fallback) => {
|
|
37
17
|
if (value === null || value.trim() === "")
|
|
38
18
|
return fallback;
|
|
@@ -48,7 +28,12 @@ const readTime = (value) => {
|
|
|
48
28
|
const ms = Date.parse(value);
|
|
49
29
|
return Number.isFinite(ms) ? ms : undefined;
|
|
50
30
|
};
|
|
51
|
-
|
|
31
|
+
const vectorKey = (v) => `${v[0].toFixed(2)},${v[1].toFixed(2)},${v[2].toFixed(2)}`;
|
|
32
|
+
function turnPose(pose, axis, degrees) {
|
|
33
|
+
pose.pole = turnVec(pose.pole, axis, degrees);
|
|
34
|
+
pose.meridian = turnVec(pose.meridian, axis, degrees);
|
|
35
|
+
pose.light = turnVec(pose.light, axis, degrees);
|
|
36
|
+
}
|
|
52
37
|
/** The half-width of a body's picture, in its radii, when it has no scale of its own: the globe takes a little under half the height, so its rings, glow and haze have room round it. */
|
|
53
38
|
const ROOM = 2.2;
|
|
54
39
|
function extentOf(id, options) {
|
|
@@ -204,15 +189,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
204
189
|
this.#io?.disconnect();
|
|
205
190
|
document.removeEventListener("visibilitychange", this.#onHidden);
|
|
206
191
|
this.#unsub?.();
|
|
207
|
-
this
|
|
208
|
-
this
|
|
209
|
-
this.removeEventListener("pointerdown", this.#hover);
|
|
210
|
-
this.#view?.dispose();
|
|
211
|
-
this.#view = undefined;
|
|
212
|
-
this.#viewKey = "";
|
|
213
|
-
this.#release?.();
|
|
214
|
-
this.#release = undefined;
|
|
215
|
-
this.#renderer = undefined;
|
|
192
|
+
this.#applyHover(false);
|
|
193
|
+
this.#disposeView(true);
|
|
216
194
|
}
|
|
217
195
|
attributeChangedCallback(name) {
|
|
218
196
|
if (!this.isConnected)
|
|
@@ -278,10 +256,10 @@ export class WakuseiBody extends HTMLElement {
|
|
|
278
256
|
rate: Math.max(-1e7, Math.min(1e7, num(this.getAttribute("rate"), 1))),
|
|
279
257
|
moons,
|
|
280
258
|
portrait: {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
259
|
+
tilt: this.hasAttribute("tilt") ? num(this.getAttribute("tilt"), 0) : undefined,
|
|
260
|
+
pitch: this.hasAttribute("pitch") ? num(this.getAttribute("pitch"), 0) : undefined,
|
|
261
|
+
phase: this.hasAttribute("phase") ? num(this.getAttribute("phase"), 0) : undefined,
|
|
262
|
+
spin: this.hasAttribute("meridian") ? num(this.getAttribute("meridian"), 0) : undefined,
|
|
285
263
|
},
|
|
286
264
|
turn: (this.hasAttribute("turn") ? num(this.getAttribute("turn"), 0) : this.getAttribute("live") === "off" ? 0 : defaultTurn(this.body)) * (this.#reduce ? REDUCED_TURN : 1),
|
|
287
265
|
};
|
|
@@ -294,39 +272,40 @@ export class WakuseiBody extends HTMLElement {
|
|
|
294
272
|
}
|
|
295
273
|
// --- the state of the scene --------------------------------------------------------------------------------------------------------------------
|
|
296
274
|
#sceneOf(frame) {
|
|
297
|
-
|
|
275
|
+
const pose = { pole: frame.pose.pole, meridian: frame.pose.meridian, light: frame.pose.light };
|
|
298
276
|
const tiltBy = this.#pitchDelta - this.#tilt;
|
|
299
277
|
if (this.#yaw !== 0)
|
|
300
|
-
meridian = turnVec(meridian, pole, this.#yaw);
|
|
301
|
-
if (tiltBy !== 0)
|
|
302
|
-
|
|
303
|
-
pole = turnVec(pole, x, tiltBy);
|
|
304
|
-
meridian = turnVec(meridian, x, tiltBy);
|
|
305
|
-
light = turnVec(light, x, tiltBy);
|
|
306
|
-
}
|
|
278
|
+
pose.meridian = turnVec(pose.meridian, pose.pole, this.#yaw);
|
|
279
|
+
if (tiltBy !== 0)
|
|
280
|
+
turnPose(pose, [1, 0, 0], tiltBy);
|
|
307
281
|
const roll = -this.#roll;
|
|
308
|
-
if (roll !== 0)
|
|
309
|
-
|
|
310
|
-
pole = turnVec(pole, z, roll);
|
|
311
|
-
meridian = turnVec(meridian, z, roll);
|
|
312
|
-
light = turnVec(light, z, roll);
|
|
313
|
-
}
|
|
282
|
+
if (roll !== 0)
|
|
283
|
+
turnPose(pose, [0, 0, 1], roll);
|
|
314
284
|
const r = this.#request();
|
|
315
285
|
const scaleTo = this.getAttribute("scale-to");
|
|
316
286
|
const range = this.hasAttribute("range") ? num(this.getAttribute("range"), 0) : undefined;
|
|
317
287
|
const span = num(this.getAttribute("span-km"), 0);
|
|
318
|
-
const extent = extentOf(this.body, {
|
|
319
|
-
|
|
320
|
-
?
|
|
321
|
-
|
|
322
|
-
|
|
288
|
+
const extent = extentOf(this.body, {
|
|
289
|
+
tight: this.getAttribute("fit") === "tight",
|
|
290
|
+
spanKm: span > 0 ? span : undefined,
|
|
291
|
+
scaleTo: scaleTo !== null && scaleTo in BODIES ? scaleTo : undefined,
|
|
292
|
+
moons: r.moons,
|
|
293
|
+
range: range !== undefined && range > 0 ? range : undefined,
|
|
294
|
+
});
|
|
295
|
+
const moons = r.moons ? this.#moonsOf(frame, extent, tiltBy, roll) : undefined;
|
|
296
|
+
return { pose, extent, sky: frame.time !== undefined, zoom: this.#zoom, panX: clampPan(this.#panX, extent, this.#zoom), panY: clampPan(this.#panY, extent, this.#zoom), moons };
|
|
297
|
+
}
|
|
298
|
+
#moonsOf(frame, extent, tilt, roll) {
|
|
299
|
+
const moons = [];
|
|
300
|
+
for (const m of frame.moons) {
|
|
301
|
+
if (m.distance <= extent * 1.05) {
|
|
323
302
|
const orbit = this.#orbits.get(m.id);
|
|
324
|
-
const tipped =
|
|
303
|
+
const tipped = tilt === 0 ? [m.x, m.y, m.z] : turnVec([m.x, m.y, m.z], [1, 0, 0], tilt);
|
|
325
304
|
const rotated = roll === 0 ? tipped : turnVec(tipped, [0, 0, 1], roll);
|
|
326
|
-
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return
|
|
305
|
+
moons.push({ id: m.id, x: rotated[0], y: rotated[1], z: rotated[2], orbit: orbit === undefined || (tilt === 0 && roll === 0) ? orbit : this.#tiltedOrbit(m.id, orbit, tilt, roll) });
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return moons;
|
|
330
309
|
}
|
|
331
310
|
#tilted = new Map();
|
|
332
311
|
#tiltedOrbit(id, orbit, tilt, roll) {
|
|
@@ -344,6 +323,17 @@ export class WakuseiBody extends HTMLElement {
|
|
|
344
323
|
this.#tilted.set(id, { source: orbit, tilt, roll, out });
|
|
345
324
|
return out;
|
|
346
325
|
}
|
|
326
|
+
/** The moons of Jupiter and Saturn follow their theories once those are fetched; until then the fitted orbits answer. */
|
|
327
|
+
#wantTheory(id) {
|
|
328
|
+
const planet = BODIES[id].parent ?? id;
|
|
329
|
+
void loadMoonTheory(planet).then((loaded) => {
|
|
330
|
+
if (!loaded)
|
|
331
|
+
return;
|
|
332
|
+
this.#live = createLive();
|
|
333
|
+
this.#orbitKey = "";
|
|
334
|
+
this.#queue(true);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
347
337
|
#ensureOrbits(frame) {
|
|
348
338
|
const r = this.#request();
|
|
349
339
|
if (!r.moons || frame.time === undefined)
|
|
@@ -357,7 +347,10 @@ export class WakuseiBody extends HTMLElement {
|
|
|
357
347
|
this.#orbits.set(m.id, orbitPath(m.id, frame.time));
|
|
358
348
|
}
|
|
359
349
|
#frameNow() {
|
|
360
|
-
const
|
|
350
|
+
const request = this.#request();
|
|
351
|
+
if (request.moons)
|
|
352
|
+
this.#wantTheory(request.id);
|
|
353
|
+
const frame = this.#live.at(request, performance.now());
|
|
361
354
|
if (frame.anchors !== this.#lastAnchors) {
|
|
362
355
|
this.#lastAnchors = frame.anchors;
|
|
363
356
|
const b = (Math.asin(Math.max(-1, Math.min(1, frame.pose.pole[2]))) * 180) / Math.PI;
|
|
@@ -380,15 +373,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
380
373
|
async #refresh() {
|
|
381
374
|
if (!this.isConnected)
|
|
382
375
|
return;
|
|
383
|
-
const stage = this.#stage;
|
|
384
376
|
this.setAttribute("aria-label", this.#label());
|
|
385
377
|
if (this.hasAttribute("size"))
|
|
386
378
|
this.style.setProperty("--wakusei-size", `${num(this.getAttribute("size"), 320)}px`);
|
|
387
379
|
const delegate = this.look === "line" ? delegates.get(this.body) : undefined;
|
|
388
|
-
if (delegate !== undefined)
|
|
389
|
-
await this.#delegated(delegate);
|
|
380
|
+
if (delegate !== undefined && (await this.#delegated(delegate)))
|
|
390
381
|
return;
|
|
391
|
-
}
|
|
392
382
|
if (this.#delegateEl !== undefined) {
|
|
393
383
|
this.#delegateEl.remove();
|
|
394
384
|
this.#delegateEl = undefined;
|
|
@@ -396,14 +386,8 @@ export class WakuseiBody extends HTMLElement {
|
|
|
396
386
|
}
|
|
397
387
|
const wants3d = this.look !== "line" && this.#state !== "unavailable";
|
|
398
388
|
if (!wants3d) {
|
|
399
|
-
if (this.#view !== undefined)
|
|
400
|
-
this.#
|
|
401
|
-
this.#view = undefined;
|
|
402
|
-
this.#viewKey = "";
|
|
403
|
-
this.#release?.();
|
|
404
|
-
this.#release = undefined;
|
|
405
|
-
this.#renderer = undefined;
|
|
406
|
-
}
|
|
389
|
+
if (this.#view !== undefined)
|
|
390
|
+
this.#disposeView(true);
|
|
407
391
|
this.#drawLine();
|
|
408
392
|
if (this.look === "line")
|
|
409
393
|
this.#set("line");
|
|
@@ -413,9 +397,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
413
397
|
if (this.#view !== undefined && this.#viewSig !== sig) {
|
|
414
398
|
if (this.#view.live)
|
|
415
399
|
this.#wantLive = true;
|
|
416
|
-
this.#
|
|
417
|
-
this.#view = undefined;
|
|
418
|
-
this.#viewKey = "";
|
|
400
|
+
this.#disposeView();
|
|
419
401
|
}
|
|
420
402
|
if (this.#view === undefined || this.#viewKey === "")
|
|
421
403
|
await this.#ensureView();
|
|
@@ -432,20 +414,18 @@ export class WakuseiBody extends HTMLElement {
|
|
|
432
414
|
if (this.#wantLive || this.#hasPriority())
|
|
433
415
|
void this.goLive();
|
|
434
416
|
}
|
|
435
|
-
void stage;
|
|
436
417
|
}
|
|
437
418
|
#hasPriority() {
|
|
438
419
|
const mode = this.getAttribute("live") ?? "always";
|
|
439
420
|
return mode === "always" && this.#visible;
|
|
440
421
|
}
|
|
441
|
-
#applyHover() {
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
if ((this.getAttribute("live") ?? "always") === "hover") {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
this.addEventListener("pointerdown", this.#hover);
|
|
422
|
+
#applyHover(allow = true) {
|
|
423
|
+
const events = ["pointerenter", "focusin", "pointerdown"];
|
|
424
|
+
for (const name of events)
|
|
425
|
+
this.removeEventListener(name, this.#hover);
|
|
426
|
+
if (allow && (this.getAttribute("live") ?? "always") === "hover") {
|
|
427
|
+
for (const name of events)
|
|
428
|
+
this.addEventListener(name, this.#hover);
|
|
449
429
|
}
|
|
450
430
|
}
|
|
451
431
|
#label() {
|
|
@@ -466,19 +446,29 @@ export class WakuseiBody extends HTMLElement {
|
|
|
466
446
|
size,
|
|
467
447
|
pose: scene.pose,
|
|
468
448
|
...(r.moons ? { moons: true, ...(frame.time !== undefined ? { time: frame.time } : {}), range: scene.extent, moonsAt: (scene.moons ?? []).map((m) => ({ id: m.id, x: m.x, y: m.y, z: m.z, distance: Math.hypot(m.x, m.y, m.z) })), orbits: new Map((scene.moons ?? []).filter((m) => m.orbit !== undefined).map((m) => [m.id, m.orbit])) } : {}),
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
449
|
+
fill: scaleTo !== null || this.hasAttribute("span-km") || this.getAttribute("fit") !== "tight" ? this.#fill() : undefined,
|
|
450
|
+
lang: this.getAttribute("lang") === "ja" ? "ja" : undefined,
|
|
451
|
+
labels: this.getAttribute("labels") === "off" ? false : undefined,
|
|
452
|
+
stroke: stroke || undefined,
|
|
453
|
+
paper: paper || undefined,
|
|
474
454
|
...(this.#zoom !== 1 ? { zoom: this.#zoom, panX: scene.panX, panY: scene.panY } : {}),
|
|
475
455
|
});
|
|
476
456
|
this.#stage.innerHTML = html;
|
|
477
457
|
}
|
|
478
458
|
#key(state) {
|
|
479
|
-
const q = (v) => v.map((n) => n.toFixed(2)).join(",");
|
|
480
459
|
const moons = (state.moons ?? []).map((m) => `${m.id}:${m.x.toFixed(1)},${m.y.toFixed(1)}`).join(";");
|
|
481
|
-
return `${this.body}|${this.look}|${
|
|
460
|
+
return `${this.body}|${this.look}|${vectorKey(state.pose.pole)}|${vectorKey(state.pose.meridian)}|${vectorKey(state.pose.light)}|${state.extent.toFixed(2)}|${state.zoom.toFixed(2)}|${state.panX.toFixed(2)},${state.panY.toFixed(2)}|${moons}`;
|
|
461
|
+
}
|
|
462
|
+
// Replacing a view keeps the renderer lease; leaving 3D gives it back.
|
|
463
|
+
#disposeView(releaseRenderer = false) {
|
|
464
|
+
this.#view?.dispose();
|
|
465
|
+
this.#view = undefined;
|
|
466
|
+
this.#viewKey = "";
|
|
467
|
+
if (releaseRenderer) {
|
|
468
|
+
this.#release?.();
|
|
469
|
+
this.#release = undefined;
|
|
470
|
+
this.#renderer = undefined;
|
|
471
|
+
}
|
|
482
472
|
}
|
|
483
473
|
/** The renderer, the view and its first still. */
|
|
484
474
|
async #ensureView() {
|
|
@@ -498,22 +488,12 @@ export class WakuseiBody extends HTMLElement {
|
|
|
498
488
|
this.#viewSig = `${this.body}|${this.look}`;
|
|
499
489
|
this.#stilled = false;
|
|
500
490
|
this.#stage.innerHTML = "";
|
|
501
|
-
const base = () => {
|
|
502
|
-
const own = this.getAttribute("texture-base");
|
|
503
|
-
return own === null || own === "" ? TEXTURE_BASE : own.endsWith("/") ? own : `${own}/`;
|
|
504
|
-
};
|
|
505
491
|
const item = createBodyItem({
|
|
506
492
|
id: this.body,
|
|
507
493
|
look: this.look === "illustrated" ? "realistic" : "painted",
|
|
508
494
|
key: this.#viewKey,
|
|
509
495
|
state: () => this.#sceneState ?? state,
|
|
510
|
-
|
|
511
|
-
farBase: () => {
|
|
512
|
-
const own = this.getAttribute("texture-far-base");
|
|
513
|
-
if (own !== null && own !== "")
|
|
514
|
-
return own.endsWith("/") ? own : `${own}/`;
|
|
515
|
-
return this.hasAttribute("texture-base") ? base() : TEXTURE_FAR_BASE;
|
|
516
|
-
},
|
|
496
|
+
...texturePaths(this),
|
|
517
497
|
wantedWidth: (discPx) => discPx * Math.min(2, window.devicePixelRatio || 1) * 1.6,
|
|
518
498
|
redraw: () => this.#view?.invalidate(),
|
|
519
499
|
report: (note) => {
|
|
@@ -532,17 +512,17 @@ export class WakuseiBody extends HTMLElement {
|
|
|
532
512
|
/** A body whose line look another package draws (the Earth's globe with its countries). It is drawn at the body's size in a scale picture, never larger than the picture. */
|
|
533
513
|
async #delegated(delegate) {
|
|
534
514
|
if (this.#view !== undefined) {
|
|
535
|
-
this.#
|
|
536
|
-
this.#view = undefined;
|
|
537
|
-
this.#viewKey = "";
|
|
515
|
+
this.#disposeView();
|
|
538
516
|
}
|
|
539
517
|
const center = this.hasAttribute("meridian") ? `${num(this.getAttribute("meridian"), 10)},20` : "10,20";
|
|
540
518
|
const size = Math.round(this.clientWidth || 320);
|
|
541
519
|
const fill = this.#fill();
|
|
542
520
|
const key = `line|${center}|${fill}`;
|
|
543
521
|
if (this.#delegateEl !== undefined && this.#delegateKind === key)
|
|
544
|
-
return;
|
|
522
|
+
return true;
|
|
545
523
|
const el = await delegate.line({ center, size });
|
|
524
|
+
if (el === null)
|
|
525
|
+
return false;
|
|
546
526
|
this.#delegateEl?.remove();
|
|
547
527
|
this.#stage.innerHTML = "";
|
|
548
528
|
el.style.cssText = `display:block;width:${fill * 100}%;height:${fill * 100}%;aspect-ratio:1;position:absolute;left:${(1 - fill) * 50}%;top:${(1 - fill) * 50}%`;
|
|
@@ -550,6 +530,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
550
530
|
this.#delegateEl = el;
|
|
551
531
|
this.#delegateKind = key;
|
|
552
532
|
this.#set("line");
|
|
533
|
+
return true;
|
|
553
534
|
}
|
|
554
535
|
/** How much of the picture's width the body's disc takes: 1 alone, less in a scale picture (`scale-to`, `span-km`). */
|
|
555
536
|
#fill() {
|
|
@@ -576,8 +557,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
576
557
|
const key = this.#key(state);
|
|
577
558
|
if (key === this.#viewKey && this.#view.item !== undefined)
|
|
578
559
|
return;
|
|
579
|
-
this.#
|
|
580
|
-
this.#view = undefined;
|
|
560
|
+
this.#disposeView();
|
|
581
561
|
this.#makeView();
|
|
582
562
|
}
|
|
583
563
|
/** Hand the live scene the current state. */
|
package/dist/ephemeris.d.ts
CHANGED
|
@@ -19,6 +19,26 @@ export declare function kepler(meanAnomaly: number, e: number): number;
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export declare function heliocentric(planet: HostId, ms: number): Vec3;
|
|
22
|
+
/**
|
|
23
|
+
* The theory that `heliocentric(planet, ms)` answers with, given the tables loaded now: VSOP87B for Mercury to Neptune, a fitted Chebyshev table where one covers the moment, else
|
|
24
|
+
* osculating elements (a dwarf planet) or JPL's approximate elements (Pluto outside its table). `worstArcseconds` is the fitted table's measured worst on samples held back from
|
|
25
|
+
* the fit, not a bound for every date; `null` where no such measurement exists. Ask again after importing a table or for another moment.
|
|
26
|
+
*
|
|
27
|
+
* @param planet - A planet or dwarf planet.
|
|
28
|
+
* @param ms - The moment in milliseconds since 1970 (UTC).
|
|
29
|
+
* @returns The theory's name and its measured worst error in arc-seconds, or `null`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { heliocentricModel } from "@johnmorrisdotca/wakusei-planets";
|
|
34
|
+
*
|
|
35
|
+
* console.log(heliocentricModel("pluto", Date.UTC(2026, 0, 1)));
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function heliocentricModel(planet: HostId, ms: number): {
|
|
39
|
+
theory: "vsop87b" | "chebyshev" | "osculating-elements" | "approximate-elements";
|
|
40
|
+
worstArcseconds: number | null;
|
|
41
|
+
};
|
|
22
42
|
/**
|
|
23
43
|
* Mean distance from the Sun, in astronomical units: a planet's semi-major axis at J2000, or a dwarf planet's semi-major axis at the epoch of its elements.
|
|
24
44
|
* @param id - A planet or a dwarf planet.
|
package/dist/ephemeris.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// and outside those years JPL's "Keplerian Elements for Approximate Positions of the Major Planets", Table 1 (https://ssd.jpl.nasa.gov/planets/approx_pos.html). The Moon: the lunar solution ELP2000-82B (Chapront-Touze and Chapront, IMCCE) cut to its largest terms (data/lunar.ts). Other moons: fitted to JPL Horizons (data/orbits.ts).
|
|
4
4
|
// Light travel time is allowed for, so a turning planet shows the face it really showed when the light left. Pure: no DOM, no three.js.
|
|
5
5
|
import { ORBITS } from "./data/orbits.js";
|
|
6
|
+
import { moonTheoryOf, planetSeriesOf } from "./data/theories.js";
|
|
6
7
|
import { DWARF_ELEMENTS } from "./data/dwarf.js";
|
|
7
8
|
import { tableOf } from "./data/tables.js";
|
|
8
9
|
import { PLUTO, PLUTO_SEGMENT_MS, PLUTO_START } from "./data/pluto.js";
|
|
@@ -18,16 +19,17 @@ const DAY = 86_400_000;
|
|
|
18
19
|
const AU_KM = 149_597_870.7;
|
|
19
20
|
/** Light takes this many seconds to cross one astronomical unit. */
|
|
20
21
|
const LIGHT_SECONDS_PER_AU = 499.004784;
|
|
21
|
-
//
|
|
22
|
+
// Semi-major axes for meanSunAu. Only Pluto needs the remaining elements and rates:
|
|
23
|
+
// Mercury to Neptune always use VSOP87B before reaching the approximate fallback.
|
|
22
24
|
const ELEMENTS = {
|
|
23
|
-
mercury: [0.38709927
|
|
24
|
-
venus: [0.72333566
|
|
25
|
-
earth: [1.00000261
|
|
26
|
-
mars: [1.52371034
|
|
27
|
-
jupiter: [5.202887
|
|
28
|
-
saturn: [9.53667594
|
|
29
|
-
uranus: [19.18916464
|
|
30
|
-
neptune: [30.06992276
|
|
25
|
+
mercury: [0.38709927],
|
|
26
|
+
venus: [0.72333566],
|
|
27
|
+
earth: [1.00000261],
|
|
28
|
+
mars: [1.52371034],
|
|
29
|
+
jupiter: [5.202887],
|
|
30
|
+
saturn: [9.53667594],
|
|
31
|
+
uranus: [19.18916464],
|
|
32
|
+
neptune: [30.06992276],
|
|
31
33
|
pluto: [39.48211675, 0.2488273, 17.14001206, 238.92903833, 224.06891629, 110.30393684, -0.00031596, 0.0000517, 0.00004818, 145.20780515, -0.04062942, -0.01183482],
|
|
32
34
|
};
|
|
33
35
|
const centuries = (ms) => (ms - J2000) / (DAY * 36525);
|
|
@@ -48,7 +50,7 @@ export function kepler(meanAnomaly, e) {
|
|
|
48
50
|
}
|
|
49
51
|
return E;
|
|
50
52
|
}
|
|
51
|
-
const PLUTO_TABLE = { start: PLUTO_START, segment: PLUTO_SEGMENT_MS, worst: 0, segments: PLUTO };
|
|
53
|
+
const PLUTO_TABLE = { start: PLUTO_START, segment: PLUTO_SEGMENT_MS, worst: 0.14637, segments: PLUTO };
|
|
52
54
|
/** A position from a Chebyshev table, as x, y, z in au, or undefined outside the years it covers. */
|
|
53
55
|
function fittedPosition(table, terrestrialMs) {
|
|
54
56
|
const segment = Math.floor((terrestrialMs - table.start) / table.segment);
|
|
@@ -68,6 +70,14 @@ function fittedPosition(table, terrestrialMs) {
|
|
|
68
70
|
};
|
|
69
71
|
return [at(coefficients[0]), at(coefficients[1]), at(coefficients[2])];
|
|
70
72
|
}
|
|
73
|
+
/** Same table priority and TT segment coverage for positions and model information. */
|
|
74
|
+
function fittedTableAt(planet, tt) {
|
|
75
|
+
const covers = (table) => table.segments[Math.floor((tt - table.start) / table.segment)] !== undefined;
|
|
76
|
+
if (planet === "pluto" && covers(PLUTO_TABLE))
|
|
77
|
+
return PLUTO_TABLE;
|
|
78
|
+
const registered = tableOf(planet);
|
|
79
|
+
return registered !== undefined && covers(registered) ? registered : undefined;
|
|
80
|
+
}
|
|
71
81
|
/** Each planet's mass as a fraction of the Sun's (IAU 2012 and JPL DE440 values; the Earth with its Moon), to find the Sun's place among the planets. */
|
|
72
82
|
const MASS_OVER_SUN = {
|
|
73
83
|
mercury: 1 / 6023657.33,
|
|
@@ -87,7 +97,7 @@ function barycentreFromSun(terrestrialMs) {
|
|
|
87
97
|
let total = 1;
|
|
88
98
|
for (const id of Object.keys(MASS_OVER_SUN)) {
|
|
89
99
|
const m = MASS_OVER_SUN[id];
|
|
90
|
-
const p = vsopPosition(VSOP87[id], terrestrialMs);
|
|
100
|
+
const p = vsopPosition(planetSeriesOf(id) ?? VSOP87[id], terrestrialMs);
|
|
91
101
|
x += m * p[0];
|
|
92
102
|
y += m * p[1];
|
|
93
103
|
z += m * p[2];
|
|
@@ -110,21 +120,18 @@ function barycentreFromSun(terrestrialMs) {
|
|
|
110
120
|
* ```
|
|
111
121
|
*/
|
|
112
122
|
export function heliocentric(planet, ms) {
|
|
113
|
-
const vsop = VSOP87[planet];
|
|
123
|
+
const vsop = planetSeriesOf(planet) ?? VSOP87[planet];
|
|
114
124
|
if (vsop !== undefined)
|
|
115
125
|
return vsopPosition(vsop, toTerrestrialTime(ms));
|
|
116
|
-
if (planet === "pluto") {
|
|
117
|
-
const table = fittedPosition(PLUTO_TABLE, toTerrestrialTime(ms));
|
|
118
|
-
if (table !== undefined)
|
|
119
|
-
return table;
|
|
120
|
-
}
|
|
121
|
-
const fitted = tableOf(planet);
|
|
122
|
-
if (fitted !== undefined) {
|
|
126
|
+
if (planet === "pluto" || tableOf(planet) !== undefined) {
|
|
123
127
|
const tt = toTerrestrialTime(ms);
|
|
124
|
-
const
|
|
125
|
-
if (
|
|
128
|
+
const fitted = fittedTableAt(planet, tt);
|
|
129
|
+
if (fitted !== undefined) {
|
|
130
|
+
const position = fittedPosition(fitted, tt);
|
|
131
|
+
if (fitted === PLUTO_TABLE)
|
|
132
|
+
return position;
|
|
126
133
|
const sun = barycentreFromSun(tt);
|
|
127
|
-
return [
|
|
134
|
+
return [position[0] + sun[0], position[1] + sun[1], position[2] + sun[2]];
|
|
128
135
|
}
|
|
129
136
|
}
|
|
130
137
|
let a;
|
|
@@ -165,6 +172,31 @@ export function heliocentric(planet, ms) {
|
|
|
165
172
|
const si = Math.sin(I);
|
|
166
173
|
return [(cw * cn - sw * sn * ci) * x + (-sw * cn - cw * sn * ci) * y, (cw * sn + sw * cn * ci) * x + (-sw * sn + cw * cn * ci) * y, sw * si * x + cw * si * y];
|
|
167
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* The theory that `heliocentric(planet, ms)` answers with, given the tables loaded now: VSOP87B for Mercury to Neptune, a fitted Chebyshev table where one covers the moment, else
|
|
177
|
+
* osculating elements (a dwarf planet) or JPL's approximate elements (Pluto outside its table). `worstArcseconds` is the fitted table's measured worst on samples held back from
|
|
178
|
+
* the fit, not a bound for every date; `null` where no such measurement exists. Ask again after importing a table or for another moment.
|
|
179
|
+
*
|
|
180
|
+
* @param planet - A planet or dwarf planet.
|
|
181
|
+
* @param ms - The moment in milliseconds since 1970 (UTC).
|
|
182
|
+
* @returns The theory's name and its measured worst error in arc-seconds, or `null`.
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { heliocentricModel } from "@johnmorrisdotca/wakusei-planets";
|
|
187
|
+
*
|
|
188
|
+
* console.log(heliocentricModel("pluto", Date.UTC(2026, 0, 1)));
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export function heliocentricModel(planet, ms) {
|
|
192
|
+
const tt = toTerrestrialTime(ms);
|
|
193
|
+
if (VSOP87[planet] !== undefined)
|
|
194
|
+
return { theory: "vsop87b", worstArcseconds: null };
|
|
195
|
+
const table = fittedTableAt(planet, tt);
|
|
196
|
+
return table !== undefined
|
|
197
|
+
? { theory: "chebyshev", worstArcseconds: table.worst }
|
|
198
|
+
: { theory: planet in DWARF_ELEMENTS ? "osculating-elements" : "approximate-elements", worstArcseconds: null };
|
|
199
|
+
}
|
|
168
200
|
/**
|
|
169
201
|
* Mean distance from the Sun, in astronomical units: a planet's semi-major axis at J2000, or a dwarf planet's semi-major axis at the epoch of its elements.
|
|
170
202
|
* @param id - A planet or a dwarf planet.
|
|
@@ -300,6 +332,9 @@ export function apparent(id, time) {
|
|
|
300
332
|
export function moonVector(id, ms) {
|
|
301
333
|
if (id === "moon")
|
|
302
334
|
return moonGeocentric(ms);
|
|
335
|
+
const theory = moonTheoryOf(id);
|
|
336
|
+
if (theory !== undefined)
|
|
337
|
+
return theory(toTerrestrialTime(ms));
|
|
303
338
|
const orbit = ORBITS[id];
|
|
304
339
|
if (orbit === undefined)
|
|
305
340
|
throw new Error(`no orbit for ${id}`);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BODIES, BODY_IDS, DWARF_IDS, MOONS_OF, PLANET_IDS, ringReach, type BodyFacts, type BodyId, type DwarfId, type Feature, type HostId, type Look, type MoonId, type PlanetId, type RingBand } from "./facts.ts";
|
|
2
|
-
export { apparent, heliocentric, meanSunAu, moonGeocentric, orbitPath, system, type Apparent, type MoonPlace, type Pose, type System } from "./ephemeris.ts";
|
|
2
|
+
export { apparent, heliocentric, heliocentricModel, meanSunAu, moonGeocentric, orbitPath, system, type Apparent, type MoonPlace, type Pose, type System } from "./ephemeris.ts";
|
|
3
3
|
export { JOURNEY_STOPS, journeyStop, stopPlaceAu, type JourneyStop } from "./stops.ts";
|
|
4
4
|
export { drawnTilt, portrait, type PortraitOptions } from "./pose.ts";
|
|
5
5
|
export { lineSvg, mix, type LineOptions } from "./line.ts";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BODIES, BODY_IDS, DWARF_IDS, MOONS_OF, PLANET_IDS, ringReach } from "./facts.js";
|
|
2
|
-
export { apparent, heliocentric, meanSunAu, moonGeocentric, orbitPath, system } from "./ephemeris.js";
|
|
2
|
+
export { apparent, heliocentric, heliocentricModel, meanSunAu, moonGeocentric, orbitPath, system } from "./ephemeris.js";
|
|
3
3
|
export { JOURNEY_STOPS, journeyStop, stopPlaceAu } from "./stops.js";
|
|
4
4
|
export { drawnTilt, portrait } from "./pose.js";
|
|
5
5
|
export { lineSvg, mix } from "./line.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SharedRenderer } from "@johnmorrisdotca/kazoku-ui/renderer";
|
|
2
2
|
import type { ThreeParts } from "../scene/body.ts";
|
|
3
3
|
import { setThreeLoader } from "../scene/shared.ts";
|
|
4
|
+
import "../element.ts";
|
|
4
5
|
import { type Guide, type Placed, type Portrait, type Resolved } from "./model.ts";
|
|
5
6
|
export { setThreeLoader };
|
|
6
7
|
/**
|