@johnmorrisdotca/wakusei-planets 0.37.2 → 0.39.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 +20 -0
- package/NOTICE.md +14 -3
- package/README.md +6 -4
- package/dist/belts/data.d.ts +2 -0
- package/dist/belts/data.js +12 -0
- package/dist/belts/index.d.ts +270 -0
- package/dist/belts/index.js +308 -0
- package/dist/belts/totals.d.ts +43 -0
- package/dist/belts/totals.js +25 -0
- package/dist/data/orbiters.d.ts +221 -199
- package/dist/data/orbiters.js +288 -200
- package/dist/data-door.d.ts +2 -0
- package/dist/data-door.js +4 -2
- package/dist/door/own.js +4 -2
- package/dist/door/points.d.ts +14 -5
- package/dist/door/points.js +78 -27
- package/dist/earth-places.d.ts +40 -0
- package/dist/earth-places.js +47 -0
- package/dist/embed.d.ts +4 -1
- package/dist/embed.js +21 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/orbiter-facts.d.ts +61 -4
- package/dist/orbiter-facts.js +17 -3
- package/dist/orbiters.d.ts +122 -2
- package/dist/orbiters.js +205 -3
- package/dist/picture-credits.d.ts +78 -0
- package/dist/picture-credits.js +120 -0
- package/dist/place-marks.d.ts +76 -0
- package/dist/place-marks.js +66 -0
- package/dist/places.d.ts +1 -1
- package/dist/places.js +1 -1
- package/dist/scene/earth-places.d.ts +190 -0
- package/dist/scene/earth-places.js +190 -0
- package/dist/scene/painter.d.ts +11 -0
- package/dist/scene/painter.js +30 -2
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +74 -3
- package/dist/space/element.js +293 -8
- package/dist/space/ride.d.ts +4 -4
- package/dist/space/ride.js +10 -3
- package/dist/space/scene.d.ts +44 -2
- package/dist/space/scene.js +139 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +15 -2
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every look a place can have, the default first.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { EARTH_PLACE_LOOKS } from "@johnmorrisdotca/wakusei-planets/earth-places";
|
|
7
|
+
*
|
|
8
|
+
* console.log(EARTH_PLACE_LOOKS.join(", "));
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export const EARTH_PLACE_LOOKS = ["beam", "pin", "ring"];
|
|
12
|
+
/**
|
|
13
|
+
* The most markers the Earth carries at once: the first this many places in sight, `here` first and then in the order given. The rest are counted in `earthPlacesShown().omitted`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { EARTH_PLACE_MARKS } from "@johnmorrisdotca/wakusei-planets/earth-places";
|
|
18
|
+
*
|
|
19
|
+
* console.log(EARTH_PLACE_MARKS); // 32
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const EARTH_PLACE_MARKS = 32;
|
|
23
|
+
/** Nothing is laid on an Earth under this many CSS pixels of radius: a marker the size of the planet is not a marker. */
|
|
24
|
+
export const EARTH_PLACES_FROM_PX = 40;
|
|
25
|
+
// on globalThis, so the separate copies a CDN can load share the one layout
|
|
26
|
+
const SLOT = Symbol.for("@johnmorrisdotca/wakusei-planets/earth-places");
|
|
27
|
+
const slot = (globalThis[SLOT] ??= { heard: new Set() });
|
|
28
|
+
/** Give the views the layout of places (what importing `@johnmorrisdotca/wakusei-planets/earth-places` does). Views already on the page lay their places at once. */
|
|
29
|
+
export function setEarthPlacesLayout(using) {
|
|
30
|
+
slot.using = using;
|
|
31
|
+
for (const heard of slot.heard)
|
|
32
|
+
heard();
|
|
33
|
+
}
|
|
34
|
+
/** The layout `setEarthPlacesLayout` was given, if any. */
|
|
35
|
+
export const earthPlacesLayout = () => slot.using;
|
|
36
|
+
/** Hear `setEarthPlacesLayout`; returns the call that stops it. */
|
|
37
|
+
export function onEarthPlacesLayout(heard) {
|
|
38
|
+
slot.heard.add(heard);
|
|
39
|
+
return () => slot.heard.delete(heard);
|
|
40
|
+
}
|
|
41
|
+
/** The look an attribute asks for: `beam`, `pin` or `ring`; anything else is `beam`. */
|
|
42
|
+
export const readEarthPlaceLook = (value) => EARTH_PLACE_LOOKS.includes(value ?? "") ? value : "beam";
|
|
43
|
+
const SVG = "http://www.w3.org/2000/svg";
|
|
44
|
+
const STYLE = `.wk-eplaces{position:absolute;inset:0;pointer-events:none;overflow:hidden;--wk-here:var(--wakusei-place-here,#ffd34d);--wk-fav:var(--wakusei-place-favourite,#7fd6ff)}
|
|
45
|
+
.wk-eplaces svg{position:absolute;inset:0;width:100%;height:100%;overflow:visible}
|
|
46
|
+
.wk-eplace{color:var(--wk-fav)}
|
|
47
|
+
.wk-eplace[data-kind=here]{color:var(--wk-here)}
|
|
48
|
+
.wk-eplace line,.wk-eplace ellipse,.wk-eplace circle{vector-effect:non-scaling-stroke}
|
|
49
|
+
.wk-eplace-name{position:absolute;left:0;top:0;padding:0 5px;box-sizing:border-box;border-radius:4px;background:rgba(10,14,22,.78);color:#fff;font:12px/18px var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;height:18px}
|
|
50
|
+
.wk-eplace-name[data-kind=here]{font-weight:600}`;
|
|
51
|
+
/**
|
|
52
|
+
* Make the layer of markers inside a view's shadow root, above its picture. It holds a handful of elements made once and kept; a draw only writes the numbers that changed.
|
|
53
|
+
*
|
|
54
|
+
* @param root - The view's shadow root.
|
|
55
|
+
* @returns The layer.
|
|
56
|
+
*/
|
|
57
|
+
export function createEarthPlaceLayer(root) {
|
|
58
|
+
const style = document.createElement("style");
|
|
59
|
+
style.textContent = STYLE;
|
|
60
|
+
const box = document.createElement("div");
|
|
61
|
+
box.className = "wk-eplaces";
|
|
62
|
+
box.setAttribute("part", "earth-places");
|
|
63
|
+
box.setAttribute("aria-hidden", "true");
|
|
64
|
+
const svg = document.createElementNS(SVG, "svg");
|
|
65
|
+
box.append(svg);
|
|
66
|
+
root.append(style, box);
|
|
67
|
+
// a name that is never shown, only to read the font the CSS gives a name; names are measured with it once and kept
|
|
68
|
+
const probe = document.createElement("span");
|
|
69
|
+
probe.className = "wk-eplace-name";
|
|
70
|
+
probe.hidden = true;
|
|
71
|
+
box.append(probe);
|
|
72
|
+
const widths = new Map();
|
|
73
|
+
let context;
|
|
74
|
+
const pool = [];
|
|
75
|
+
let shown = [];
|
|
76
|
+
const item = (i) => {
|
|
77
|
+
let it = pool[i];
|
|
78
|
+
if (it === undefined) {
|
|
79
|
+
const g = document.createElementNS(SVG, "g");
|
|
80
|
+
g.setAttribute("class", "wk-eplace");
|
|
81
|
+
const stick = document.createElementNS(SVG, "line");
|
|
82
|
+
stick.setAttribute("stroke", "currentColor");
|
|
83
|
+
stick.setAttribute("stroke-linecap", "round");
|
|
84
|
+
const ring = document.createElementNS(SVG, "ellipse");
|
|
85
|
+
ring.setAttribute("fill", "none");
|
|
86
|
+
ring.setAttribute("stroke", "currentColor");
|
|
87
|
+
const head = document.createElementNS(SVG, "circle");
|
|
88
|
+
head.setAttribute("fill", "currentColor");
|
|
89
|
+
g.append(stick, ring, head);
|
|
90
|
+
svg.append(g);
|
|
91
|
+
const name = document.createElement("span");
|
|
92
|
+
name.className = "wk-eplace-name";
|
|
93
|
+
box.append(name);
|
|
94
|
+
it = { g, stick, ring, head, name };
|
|
95
|
+
pool[i] = it;
|
|
96
|
+
}
|
|
97
|
+
return it;
|
|
98
|
+
};
|
|
99
|
+
const set = (el, name, value) => {
|
|
100
|
+
if (el.getAttribute(name) !== value)
|
|
101
|
+
el.setAttribute(name, value);
|
|
102
|
+
};
|
|
103
|
+
const n = (value) => String(Math.round(value * 10) / 10);
|
|
104
|
+
return {
|
|
105
|
+
set(places, layout, look) {
|
|
106
|
+
const named = new Map(layout.labels.map((spot) => [spot.index, spot]));
|
|
107
|
+
shown = [];
|
|
108
|
+
for (const [i, shape] of layout.shapes.entries()) {
|
|
109
|
+
const place = places[shape.index];
|
|
110
|
+
const it = item(i);
|
|
111
|
+
const here = place.kind === "here";
|
|
112
|
+
const dim = 1 - 0.5 * shape.night;
|
|
113
|
+
set(it.g, "data-kind", here ? "here" : "favourite");
|
|
114
|
+
if (place.color !== undefined)
|
|
115
|
+
it.g.style.color = place.color;
|
|
116
|
+
else if (it.g.style.color !== "")
|
|
117
|
+
it.g.style.color = "";
|
|
118
|
+
it.g.style.display = "";
|
|
119
|
+
it.g.setAttribute("opacity", n(shape.opacity * dim));
|
|
120
|
+
it.g.setAttribute("transform", `translate(${n(shape.x)} ${n(shape.y)})`);
|
|
121
|
+
set(it.ring, "rx", n(shape.ring));
|
|
122
|
+
set(it.ring, "ry", n(shape.ring * shape.squash));
|
|
123
|
+
set(it.ring, "transform", `rotate(${n(shape.ringAngle)})`);
|
|
124
|
+
set(it.ring, "stroke-width", here ? "2" : "1.5");
|
|
125
|
+
const stick = look !== "ring";
|
|
126
|
+
it.stick.style.display = stick ? "" : "none";
|
|
127
|
+
it.head.style.display = look === "pin" ? "" : "none";
|
|
128
|
+
if (stick) {
|
|
129
|
+
set(it.stick, "x2", n(shape.tipX - shape.x));
|
|
130
|
+
set(it.stick, "y2", n(shape.tipY - shape.y));
|
|
131
|
+
set(it.stick, "stroke-width", look === "beam" ? (here ? "3" : "2") : here ? "2" : "1.5");
|
|
132
|
+
set(it.stick, "stroke-opacity", look === "beam" ? "0.85" : "1");
|
|
133
|
+
}
|
|
134
|
+
if (look === "pin") {
|
|
135
|
+
set(it.head, "cx", n(shape.tipX - shape.x));
|
|
136
|
+
set(it.head, "cy", n(shape.tipY - shape.y));
|
|
137
|
+
set(it.head, "r", here ? "5" : "3.5");
|
|
138
|
+
}
|
|
139
|
+
const spot = named.get(shape.index);
|
|
140
|
+
if (spot !== undefined) {
|
|
141
|
+
it.name.hidden = false;
|
|
142
|
+
if (it.name.textContent !== place.label)
|
|
143
|
+
it.name.textContent = place.label ?? "";
|
|
144
|
+
set(it.name, "data-kind", here ? "here" : "favourite");
|
|
145
|
+
it.name.style.opacity = n(shape.opacity * (1 - 0.3 * shape.night));
|
|
146
|
+
it.name.style.transform = `translate(${n(spot.left)}px,${n(spot.top)}px)`;
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
it.name.hidden = true;
|
|
150
|
+
shown.push({ id: place.id, kind: here ? "here" : "favourite", x: shape.x, y: shape.y, named: spot !== undefined });
|
|
151
|
+
}
|
|
152
|
+
for (let i = layout.shapes.length; i < pool.length; i += 1) {
|
|
153
|
+
const it = pool[i];
|
|
154
|
+
it.g.style.display = "none";
|
|
155
|
+
it.name.hidden = true;
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
clear() {
|
|
159
|
+
for (const it of pool) {
|
|
160
|
+
it.g.style.display = "none";
|
|
161
|
+
it.name.hidden = true;
|
|
162
|
+
}
|
|
163
|
+
shown = [];
|
|
164
|
+
},
|
|
165
|
+
width(text) {
|
|
166
|
+
const known = widths.get(text);
|
|
167
|
+
if (known !== undefined)
|
|
168
|
+
return known;
|
|
169
|
+
if (context === undefined) {
|
|
170
|
+
context = document.createElement("canvas").getContext("2d");
|
|
171
|
+
if (context !== null)
|
|
172
|
+
context.font = getComputedStyle(probe).font;
|
|
173
|
+
}
|
|
174
|
+
if (widths.size > 2000)
|
|
175
|
+
widths.clear();
|
|
176
|
+
const width = Math.ceil((context?.measureText(text).width ?? text.length * 7) + 10);
|
|
177
|
+
widths.set(text, width);
|
|
178
|
+
return width;
|
|
179
|
+
},
|
|
180
|
+
get shown() {
|
|
181
|
+
return shown;
|
|
182
|
+
},
|
|
183
|
+
dispose() {
|
|
184
|
+
box.remove();
|
|
185
|
+
style.remove();
|
|
186
|
+
pool.length = 0;
|
|
187
|
+
shown = [];
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
package/dist/scene/painter.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { moonOffset, orientation } from "./orient.ts";
|
|
|
8
8
|
import { type NameLabelOptions } from "./name-label.ts";
|
|
9
9
|
export { moonOffset, orientation };
|
|
10
10
|
export { nameLabelText, readNameLabel, setBodyLabelFontUrl, type NameLabelOptions } from "./name-label.ts";
|
|
11
|
+
export { mercuryTilesCredit, PICTURE_CREDITS, picturesCredit, type PictureCredit } from "../picture-credits.ts";
|
|
11
12
|
/**
|
|
12
13
|
* The looks the painter draws: `realistic` (shaded from the body's real colours and features) and `painted` (a public-domain surface map, with the shaded look until it arrives).
|
|
13
14
|
*
|
|
@@ -201,6 +202,16 @@ export interface PainterOptions {
|
|
|
201
202
|
export interface WakuseiPainter {
|
|
202
203
|
/** The looks `make` takes in `context.look`. */
|
|
203
204
|
readonly looks: readonly PainterLook[];
|
|
205
|
+
/**
|
|
206
|
+
* The credit for the pictures this painter is drawing, in English and Japanese, written from `PICTURE_CREDITS` and from `OWN_SOURCES`.
|
|
207
|
+
* Until `make` has been called it names every surface picture the painter can draw, because it does not yet know which a page will show. After `make` it names only the bodies it has made in a look that draws the map
|
|
208
|
+
* (`painted`, or a body whose look is mapped). A shaded body with no map is left out, so the Moon and Mars name no CC BY 4.0 source. While a window of finer map tiles is on a body, the `wakusei-tiles` credit is added;
|
|
209
|
+
* Mercury's tiles also say that their colour is the CC BY 4.0 map.
|
|
210
|
+
*/
|
|
211
|
+
readonly credit: {
|
|
212
|
+
readonly en: string;
|
|
213
|
+
readonly ja: string;
|
|
214
|
+
};
|
|
204
215
|
/** Make a body: `Sun`, a planet, `Pluto` or a moon, in any case. Throws for a name it does not know. */
|
|
205
216
|
/** `three` is the three.js module (or a subset of it holding the parts `PainterThree` names); it is typed loosely so that another package can hand over its own subset. */
|
|
206
217
|
make(three: object, name: string, context?: PaintContext): Painting;
|
package/dist/scene/painter.js
CHANGED
|
@@ -3,6 +3,8 @@ import { BODIES, MOONS_OF } from "../facts.js";
|
|
|
3
3
|
import { writeBasis } from "./basis.js";
|
|
4
4
|
import { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE, slash, loadImage, mapSourceFor, tilesAllowed } from "./textures.js";
|
|
5
5
|
import { createSourceBook } from "../door/book.js";
|
|
6
|
+
import { OWN_BY_ID } from "../door/own.js";
|
|
7
|
+
import { mercuryTilesCredit, PICTURE_CREDITS, picturesCredit } from "../picture-credits.js";
|
|
6
8
|
import { cross } from "../vec.js";
|
|
7
9
|
import { bodyFragment, GLOW_FRAGMENT, GLOW_VERTEX, PAINTED_SURFACE, PAINTED_SURFACE_WINDOWED, RING_FRAGMENT_WORLD, RING_VERTEX_WORLD, VERTEX_WORLD } from "./glsl.js";
|
|
8
10
|
import { fallbackLook } from "./fallback.js";
|
|
@@ -14,6 +16,7 @@ import { ringStrip } from "./rings.js";
|
|
|
14
16
|
import { createNameLabel, nameLabelText } from "./name-label.js";
|
|
15
17
|
export { moonOffset, orientation };
|
|
16
18
|
export { nameLabelText, readNameLabel, setBodyLabelFontUrl } from "./name-label.js";
|
|
19
|
+
export { mercuryTilesCredit, PICTURE_CREDITS, picturesCredit } from "../picture-credits.js";
|
|
17
20
|
/**
|
|
18
21
|
* The looks the painter draws: `realistic` (shaded from the body's real colours and features) and `painted` (a public-domain surface map, with the shaded look until it arrives).
|
|
19
22
|
*
|
|
@@ -92,7 +95,7 @@ function sightOf(T, view) {
|
|
|
92
95
|
},
|
|
93
96
|
};
|
|
94
97
|
}
|
|
95
|
-
function paint(T, id, context, bases) {
|
|
98
|
+
function paint(T, id, context, bases, hold) {
|
|
96
99
|
const facts = BODIES[id];
|
|
97
100
|
const look = lookOf(id) ?? fallbackLook(facts);
|
|
98
101
|
const wantPainted = (context.look === "painted" || look.mapped === true || context.mapped === true) && look.painted !== undefined;
|
|
@@ -373,6 +376,7 @@ function paint(T, id, context, bases) {
|
|
|
373
376
|
};
|
|
374
377
|
if (context.label)
|
|
375
378
|
setLabel(context.label);
|
|
379
|
+
const drop = hold?.({ id, picture: wantPainted, tiles: () => detail?.stats.shown != null });
|
|
376
380
|
return {
|
|
377
381
|
object: group,
|
|
378
382
|
setLabel,
|
|
@@ -433,6 +437,7 @@ function paint(T, id, context, bases) {
|
|
|
433
437
|
},
|
|
434
438
|
dispose() {
|
|
435
439
|
gone = true;
|
|
440
|
+
drop?.();
|
|
436
441
|
setLabel(null);
|
|
437
442
|
if (windowUniforms !== undefined) {
|
|
438
443
|
windowUniforms.uDetailOn.value = 0;
|
|
@@ -471,9 +476,32 @@ export function createPainter(options = {}) {
|
|
|
471
476
|
const own = options.tiles;
|
|
472
477
|
const tiles = own === "off" || own === "none" || own === "" ? undefined : own !== undefined ? slash(own) : options.textureBase !== undefined ? undefined : TILES_BASE;
|
|
473
478
|
const book = options.book ?? createSourceBook({ kinds: ["tiles"] });
|
|
479
|
+
let made = false;
|
|
480
|
+
const live = new Set();
|
|
481
|
+
const creditLine = (lang) => {
|
|
482
|
+
const ids = made ? [...live].filter((body) => body.picture).map((body) => body.id) : PICTURE_CREDITS.map((row) => row.id);
|
|
483
|
+
const parts = [picturesCredit(ids, lang)];
|
|
484
|
+
const tiled = [...live].filter((body) => body.tiles());
|
|
485
|
+
if (tiled.length > 0) {
|
|
486
|
+
parts.push(OWN_BY_ID.get("wakusei-tiles").credit[lang]);
|
|
487
|
+
if (tiled.some((body) => body.id === "mercury"))
|
|
488
|
+
parts.push(mercuryTilesCredit(lang));
|
|
489
|
+
}
|
|
490
|
+
return parts.filter((part) => part !== "").join(" ");
|
|
491
|
+
};
|
|
474
492
|
return {
|
|
475
493
|
looks: LOOKS,
|
|
476
|
-
|
|
494
|
+
get credit() {
|
|
495
|
+
return { en: creditLine("en"), ja: creditLine("ja") };
|
|
496
|
+
},
|
|
497
|
+
make: (three, name, context = {}) => {
|
|
498
|
+
const id = idOf(name);
|
|
499
|
+
made = true;
|
|
500
|
+
return paint(three, id, context, { near, far, tiles, book, shared: options.book !== undefined }, (body) => {
|
|
501
|
+
live.add(body);
|
|
502
|
+
return () => live.delete(body);
|
|
503
|
+
});
|
|
504
|
+
},
|
|
477
505
|
moons(planet, ms) {
|
|
478
506
|
const radius = BODIES[idOf(planet)]?.radiusKm;
|
|
479
507
|
if (radius === undefined)
|
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.39.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.39.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
|
@@ -6,6 +6,7 @@ import { type Sight, type SightEdge } from "./sight.ts";
|
|
|
6
6
|
import { type NameLabelOptions } from "../scene/name-label.ts";
|
|
7
7
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
8
8
|
import { type DoorHost } from "../door/host.ts";
|
|
9
|
+
import { type BeltId } from "../belts/index.ts";
|
|
9
10
|
import { setThreeLoader } from "../scene/shared.ts";
|
|
10
11
|
import { type SpacePlanet } from "./frame.ts";
|
|
11
12
|
import { type ScaleMode } from "./scale.ts";
|
|
@@ -14,8 +15,10 @@ import { type SunRegion } from "./regions.ts";
|
|
|
14
15
|
import { type TravelKind } from "./travel.ts";
|
|
15
16
|
import { type Place } from "../places.ts";
|
|
16
17
|
import { type PlaceLayer } from "../place-marks.ts";
|
|
18
|
+
import { type EarthPlace, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
17
19
|
import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
18
20
|
export { setPlacesLoader } from "../scene/place-layer.ts";
|
|
21
|
+
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceKind, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
19
22
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
|
|
20
23
|
/** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
|
|
21
24
|
export type { BodyPlace };
|
|
@@ -190,6 +193,31 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
190
193
|
x: number;
|
|
191
194
|
y: number;
|
|
192
195
|
}[];
|
|
196
|
+
/**
|
|
197
|
+
* The reader's own place and the places they keep, drawn on the Earth wherever the camera looks: a list of `{ id, lon, lat, label, kind, color }` (`kind` is `here` or `favourite`), as JSON in the attribute `earth-places`.
|
|
198
|
+
* Each is a marker standing out of the ground that turns with the Earth, is hidden on the far side, fades at the edge and keeps its size in pixels; a name shows beside it when there is room, never over another name. Setting the property
|
|
199
|
+
* writes the attribute, and an empty list takes it away. It reads as the list chikyu-earth cleaned (a place with a longitude or latitude out of range is left out, at most 5,000). It draws nothing, and reads as empty, until the page has
|
|
200
|
+
* imported `@johnmorrisdotca/wakusei-planets/earth-places`, which brings chikyu-earth's layout (an optional peer).
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```ts no-run
|
|
204
|
+
* import "@johnmorrisdotca/wakusei-planets/earth-places";
|
|
205
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
206
|
+
*
|
|
207
|
+
* const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
|
|
208
|
+
* space.earthPlaces = [{ id: "me", lon: -79.4, lat: 43.7, label: "You are here", kind: "here" }];
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
get earthPlaces(): EarthPlace[];
|
|
212
|
+
set earthPlaces(list: readonly EarthPlace[] | null);
|
|
213
|
+
/** How the places on the Earth are drawn (the attribute `earth-places-look`): `beam` (the default), `pin` or `ring`. Setting it writes the attribute. */
|
|
214
|
+
get earthPlacesLook(): EarthPlaceLook;
|
|
215
|
+
set earthPlacesLook(look: EarthPlaceLook | null);
|
|
216
|
+
/** The markers laid on the Earth now, as the last draw left them: each place's id and kind, where its foot is in CSS pixels from the view's top left and whether its name is drawn; `omitted` counts the places in sight beyond the first `EARTH_PLACE_MARKS`. */
|
|
217
|
+
get earthPlacesShown(): {
|
|
218
|
+
marks: readonly EarthPlaceMark[];
|
|
219
|
+
omitted: number;
|
|
220
|
+
};
|
|
193
221
|
/**
|
|
194
222
|
* Go to a place on a body: the view glides to the body (as `goTo` does), or on the body looked at turns round it, and the camera comes to rest straight above the place. The place is an id (`mars/perseverance`) or an English or Japanese name, on the body looked at
|
|
195
223
|
* unless `body` names another. The zoom stays on the same body and is 1 (the whole body) on another, unless `zoom` is given. Resolves the place, or `undefined` when the body has no place by that name or cannot be looked at.
|
|
@@ -246,7 +274,7 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
246
274
|
get region(): SunRegion | null;
|
|
247
275
|
/**
|
|
248
276
|
* 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
|
|
249
|
-
* name beside it in the page's language, once the body is at least 24 CSS pixels in radius on the screen. A modelled
|
|
277
|
+
* name beside it in the page's language, once the body is at least 24 CSS pixels in radius on the screen. A modelled path is drawn dim, and a predicted one whose measured error is more than 2 per cent of its body's radius (`orbiterDim`); a craft with no path is not drawn. The paths (a 9 kB module)
|
|
250
278
|
* are loaded the first time they are shown. `stats.orbiters` says what was drawn and each one's status.
|
|
251
279
|
*/
|
|
252
280
|
get orbiters(): boolean;
|
|
@@ -257,6 +285,21 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
257
285
|
*/
|
|
258
286
|
get roadster(): boolean;
|
|
259
287
|
set roadster(value: boolean);
|
|
288
|
+
/**
|
|
289
|
+
* The orbiter picked out (the attribute `orbiter`, an id from `/orbiters` such as `lro`; none by default): its orbit line is drawn brighter, it alone keeps its line when `orbiterLines` is
|
|
290
|
+
* `chosen`, and its ground track is drawn when `orbiterTrack` is on.
|
|
291
|
+
*/
|
|
292
|
+
get orbiter(): string | null;
|
|
293
|
+
set orbiter(value: string | null);
|
|
294
|
+
/** Which orbiters' orbit lines are drawn (the attribute `orbiter-lines`): `all` (the default), `chosen` (the one `orbiter` names) or `none`. Apart from the planets' and moons' lines (`orbits`). */
|
|
295
|
+
get orbiterLines(): "all" | "chosen" | "none";
|
|
296
|
+
set orbiterLines(value: "all" | "chosen" | "none");
|
|
297
|
+
/**
|
|
298
|
+
* Draw the chosen orbiter's ground track (the attribute `orbiter-track`; off by default): the line on its body under the craft from one trip before the moment shown to one trip after, the body
|
|
299
|
+
* turning beneath it, so each trip crosses the equator further west.
|
|
300
|
+
*/
|
|
301
|
+
get orbiterTrack(): boolean;
|
|
302
|
+
set orbiterTrack(value: boolean);
|
|
260
303
|
/**
|
|
261
304
|
* 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
|
|
262
305
|
* 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.
|
|
@@ -402,6 +445,29 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
402
445
|
* @param options - `view`, `look`, `distanceKm`, `around`, `smooth` (see `RideOptions`).
|
|
403
446
|
*/
|
|
404
447
|
ride(target: RideTarget | null, options?: RideOptions): void;
|
|
448
|
+
/**
|
|
449
|
+
* The belts drawn, by name (`main`, `hilda`, `trojan`, `centaur`, `classical`, `resonant`, `scattered`): all seven by default, `[]` for none. The attribute `belts` says the same (`belts="off"`, `belts="main trojan"`). Each belt is one instanced draw of its own
|
|
450
|
+
* colour, from the package's own source of NASA/JPL's Small-Body Database (`@johnmorrisdotca/wakusei-planets/belts`), fetched when the view first draws it.
|
|
451
|
+
*/
|
|
452
|
+
get belts(): readonly BeltId[];
|
|
453
|
+
set belts(list: readonly BeltId[]);
|
|
454
|
+
/**
|
|
455
|
+
* Fly into a belt: the camera goes to a point on a circular orbit in the middle of the belt, tilted a few degrees to the ecliptic so that it passes through the belt's thickness, looking the way it goes with the ecliptic's north at the top, at true
|
|
456
|
+
* distances (the squeezed scale is left), and a drag looks about. The dots round it are the belt's bodies; a line on the view says how many bodies there really are, and that neighbours are millions of kilometres apart, which is why the picture is
|
|
457
|
+
* mostly empty. Time runs as the clock says (`speed`). `leaveBelt()` goes back.
|
|
458
|
+
*
|
|
459
|
+
* @param belt - The belt, `main` by default.
|
|
460
|
+
* @param options - `smooth` (a glide, true by default).
|
|
461
|
+
*/
|
|
462
|
+
enterBelt(belt?: BeltId, options?: {
|
|
463
|
+
smooth?: boolean;
|
|
464
|
+
}): void;
|
|
465
|
+
/** Come out of a belt: the camera goes back to the body it looked at before. */
|
|
466
|
+
leaveBelt(options?: {
|
|
467
|
+
smooth?: boolean;
|
|
468
|
+
}): void;
|
|
469
|
+
/** The belt the camera is flying through, or null. */
|
|
470
|
+
get flyingThrough(): BeltId | null;
|
|
405
471
|
/** What the camera is riding along with now, or null. */
|
|
406
472
|
get riding(): Riding | null;
|
|
407
473
|
/** The zoom that shows a part of the sky: the Earth alone, the Moon's orbit, the Sun, the planets out to Mars, all of them, or a planet's nearer moons, at this scale and moment. */
|
|
@@ -485,9 +551,11 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
485
551
|
reach: number;
|
|
486
552
|
distance: number;
|
|
487
553
|
} | null;
|
|
488
|
-
/** 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). */
|
|
554
|
+
/** The data door: the small bodies of a page's own sources in the one instanced draw (`points`), the package's own belts (`belts` bodies in `draws` instanced draws, one for each belt), and what the sources have done (tile loads started, failed and refused, bytes held, records read). */
|
|
489
555
|
door: {
|
|
490
556
|
points: number;
|
|
557
|
+
belts: number;
|
|
558
|
+
draws: number;
|
|
491
559
|
sources: ReturnType<DoorHost["book"]["stats"]>;
|
|
492
560
|
};
|
|
493
561
|
/** The catalogue's other moons (`all-moons`): whether they are asked for, whether the catalogue has loaded, and how many dots the last draw drew. */
|
|
@@ -532,10 +600,13 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
532
600
|
position: [number, number, number] | null;
|
|
533
601
|
radiusPx: number;
|
|
534
602
|
};
|
|
535
|
-
/** The orbiters at the last draw: how many dots were drawn (their body big enough on the screen),
|
|
603
|
+
/** The orbiters at the last draw: how many dots were drawn (their body big enough on the screen), each drawn craft's status (`tracked`, `predicted`, `modelled`); `dim` lists the craft drawn dim (`orbiterDim` from `/orbiters`); `lines` how many orbit lines and `track` how many points of ground track were drawn. */
|
|
536
604
|
orbiters: {
|
|
537
605
|
count: number;
|
|
538
606
|
status: Record<string, "tracked" | "predicted" | "modelled" | "none">;
|
|
607
|
+
dim: string[];
|
|
608
|
+
lines: number;
|
|
609
|
+
track: number;
|
|
539
610
|
};
|
|
540
611
|
};
|
|
541
612
|
/** 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. */
|