@johnmorrisdotca/wakusei-planets 0.36.0 → 0.37.1

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.
@@ -0,0 +1,213 @@
1
+ const STYLE = `.wk-places{position:absolute;inset:0;pointer-events:none;overflow:hidden}
2
+ .wk-place{position:absolute;left:0;top:0;width:20px;height:20px;margin:-10px 0 0 -10px;padding:0;border:0;background:none;cursor:pointer;pointer-events:auto;will-change:transform;-webkit-tap-highlight-color:transparent}
3
+ .wk-place::before{content:"";position:absolute;left:50%;top:50%;width:6px;height:6px;margin:-3px 0 0 -3px;border-radius:50%;box-sizing:border-box;background:var(--wakusei-place-landing,#fff);box-shadow:0 0 0 1px rgba(0,0,0,.55);opacity:.85}
4
+ .wk-place[data-layer=crash]::before{background:var(--wakusei-place-crash,#ffa070)}
5
+ .wk-place[data-layer=planned]::before{background:none;border:1.5px solid var(--wakusei-place-planned,#8fd3ff);width:8px;height:8px;margin:-4px 0 0 -4px;box-shadow:0 0 2px rgba(0,0,0,.8)}
6
+ .wk-place[data-layer=feature]::before{width:4px;height:4px;margin:-2px 0 0 -2px;background:var(--wakusei-place-feature,rgba(255,255,255,.6));box-shadow:0 0 0 1px rgba(0,0,0,.35);opacity:.75}
7
+ .wk-place:hover::before,.wk-place:focus-visible::before{opacity:1;transform:scale(1.4)}
8
+ .wk-place:focus-visible{outline:2px solid #6cd0ff;outline-offset:-3px;border-radius:50%}
9
+ .wk-place-tip{position:absolute;left:0;top:0;max-width:min(260px,80%);padding:3px 7px;border-radius:5px;background:rgba(10,14,22,.86);color:#fff;font:12px/1.35 var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;visibility:hidden}
10
+ .wk-place-tip small{display:block;font-size:11px;opacity:.8}
11
+ .wk-place-tip[data-on]{visibility:visible}`;
12
+ const KIND_WORD = {
13
+ crewed: { en: "crewed landing", ja: "有人着陸" },
14
+ landing: { en: "lander", ja: "着陸機" },
15
+ rover: { en: "rover", ja: "探査車" },
16
+ crash: { en: "crash site", ja: "墜落地点" },
17
+ impact: { en: "impact site", ja: "衝突地点" },
18
+ entry: { en: "lost in the atmosphere", ja: "大気圏で消失" },
19
+ planned: { en: "planned landing", ja: "着陸予定" },
20
+ feature: { en: "feature", ja: "地形" },
21
+ };
22
+ /**
23
+ * The short line under a place's name: what it is and when (a site's year, a planned landing's announced year, a feature's kind and size), in English or Japanese.
24
+ *
25
+ * @param place - The place.
26
+ * @param lang - `en` or `ja`.
27
+ * @returns The line.
28
+ *
29
+ * @example
30
+ * ```ts no-run
31
+ * import { placeLine } from "@johnmorrisdotca/wakusei-planets/element";
32
+ *
33
+ * console.log(placeLine({ id: "moon/x", kind: "crewed", name: { en: "X", ja: "X" }, lat: 0, lon: 0, date: "1969-07-20T20:17Z", source: { id: "nssdca", read: "2026-11-11" } }, "en"));
34
+ * ```
35
+ */
36
+ export function placeLine(place, lang) {
37
+ const ja = lang === "ja";
38
+ if (place.kind === "feature") {
39
+ const word = place.feature?.typeWord[lang] ?? KIND_WORD.feature[lang];
40
+ const km = place.feature?.diameterKm ?? 0;
41
+ return km > 0 ? `${word}${ja ? "、" : ", "}${Math.round(km).toLocaleString(ja ? "ja-JP" : "en")} km` : word;
42
+ }
43
+ const word = KIND_WORD[place.kind][lang];
44
+ if (place.kind === "planned" && place.planned !== undefined) {
45
+ const { date, dateOf } = place.planned;
46
+ const year = date.slice(0, 4);
47
+ return ja ? `${word} (${dateOf === "launch" ? `${year}年打ち上げ` : `${year}年`})` : `${word}, ${dateOf === "launch" ? `launch ${year}` : year}`;
48
+ }
49
+ const year = place.date?.slice(0, 4);
50
+ return year === undefined ? word : ja ? `${word}、${year}年` : `${word}, ${year}`;
51
+ }
52
+ // on globalThis, so the separate copies a CDN can load share the one loader
53
+ const SLOT = Symbol.for("@johnmorrisdotca/wakusei-planets/places-loader");
54
+ const slot = (globalThis[SLOT] ??= { heard: new Set() });
55
+ /**
56
+ * Give the views the lists of places, for the marks of the `places` attribute: `loadPlaces` from `/places`, which fetches each body's table as a chunk of its own the first time it is asked for, or a function of your own
57
+ * that returns a body's list. The views hold no table themselves, so a page that never marks a place never carries one; until this is called a view marks nothing. Views already on the page lay their marks at once.
58
+ *
59
+ * @param load - A body's list of places, for a body of `PLACE_BODIES`.
60
+ *
61
+ * @example
62
+ * ```ts no-run
63
+ * import { setPlacesLoader } from "@johnmorrisdotca/wakusei-planets/element";
64
+ * import { loadPlaces } from "@johnmorrisdotca/wakusei-planets/places";
65
+ *
66
+ * setPlacesLoader(loadPlaces);
67
+ * document.querySelector("wakusei-body")!.setAttribute("places", "landing crash");
68
+ * ```
69
+ */
70
+ export function setPlacesLoader(load) {
71
+ slot.load = load;
72
+ for (const heard of slot.heard)
73
+ heard();
74
+ }
75
+ /** The loader `setPlacesLoader` was given, if any. */
76
+ export const placesLoader = () => slot.load;
77
+ /** Hear `setPlacesLoader`; returns the call that stops it. */
78
+ export function onPlacesLoader(heard) {
79
+ slot.heard.add(heard);
80
+ return () => slot.heard.delete(heard);
81
+ }
82
+ /**
83
+ * Make the layer of marks inside a view's shadow root, above its picture. `pick` is called for a click or Enter on a mark, with the place and where its mark is.
84
+ *
85
+ * @param root - The view's shadow root.
86
+ * @param options - `lang` reads the view's language at the time a tip is shown; `pick` hears a chosen place.
87
+ * @returns The layer.
88
+ */
89
+ export function createPlaceLayer(root, options) {
90
+ const style = document.createElement("style");
91
+ style.textContent = STYLE;
92
+ const box = document.createElement("div");
93
+ box.className = "wk-places";
94
+ box.setAttribute("part", "places");
95
+ const tip = document.createElement("div");
96
+ tip.className = "wk-place-tip";
97
+ tip.setAttribute("part", "place-tip");
98
+ tip.setAttribute("aria-hidden", "true");
99
+ box.append(tip);
100
+ root.append(style, box);
101
+ const held = new Map();
102
+ let shown = [];
103
+ let tipFor = null;
104
+ const showTip = (id) => {
105
+ const entry = held.get(id);
106
+ if (entry === undefined)
107
+ return;
108
+ const lang = options.lang();
109
+ const name = document.createElement("span");
110
+ name.textContent = entry.mark.place.name[lang];
111
+ const line = document.createElement("small");
112
+ line.textContent = placeLine(entry.mark.place, lang);
113
+ tip.replaceChildren(name, line);
114
+ tip.setAttribute("data-on", "");
115
+ tipFor = id;
116
+ placeTip();
117
+ };
118
+ // above the mark, inside the view: measured in the page's own font once its text is in
119
+ const placeTip = () => {
120
+ const entry = tipFor === null ? undefined : held.get(tipFor);
121
+ if (entry === undefined)
122
+ return;
123
+ const w = tip.offsetWidth;
124
+ const h = tip.offsetHeight;
125
+ const width = box.clientWidth;
126
+ const x = Math.max(2, Math.min(width - w - 2, entry.x - w / 2));
127
+ const y = entry.y - h - 10 >= 2 ? entry.y - h - 10 : entry.y + 12;
128
+ tip.style.transform = `translate(${x.toFixed(1)}px,${y.toFixed(1)}px)`;
129
+ };
130
+ const hideTip = (id) => {
131
+ if (id !== undefined && tipFor !== id)
132
+ return;
133
+ tip.removeAttribute("data-on");
134
+ tipFor = null;
135
+ };
136
+ const make = (mark) => {
137
+ const button = document.createElement("button");
138
+ button.type = "button";
139
+ button.className = "wk-place";
140
+ button.setAttribute("part", "place");
141
+ const id = mark.place.id;
142
+ button.dataset.place = id;
143
+ button.addEventListener("pointerenter", () => showTip(id));
144
+ button.addEventListener("pointerleave", () => hideTip(id));
145
+ button.addEventListener("focus", () => showTip(id));
146
+ button.addEventListener("blur", () => hideTip(id));
147
+ // a press on a mark is the mark's, not the start of a drag or a pick of the body under it; a touch shows the name as well
148
+ button.addEventListener("pointerdown", (event) => {
149
+ event.stopPropagation();
150
+ if (event.pointerType !== "mouse")
151
+ showTip(id);
152
+ });
153
+ button.addEventListener("click", (event) => {
154
+ event.stopPropagation();
155
+ const entry = held.get(id);
156
+ if (entry !== undefined)
157
+ options.pick(entry.mark.place, { x: entry.x, y: entry.y });
158
+ });
159
+ return button;
160
+ };
161
+ return {
162
+ set(marks) {
163
+ const lang = options.lang();
164
+ const next = new Set();
165
+ for (const mark of marks) {
166
+ const id = mark.place.id;
167
+ next.add(id);
168
+ let entry = held.get(id);
169
+ if (entry === undefined) {
170
+ const button = make(mark);
171
+ entry = { button, mark, x: Number.NaN, y: Number.NaN, lang: "" };
172
+ held.set(id, entry);
173
+ box.insertBefore(button, tip);
174
+ }
175
+ entry.mark = mark;
176
+ if (entry.lang !== lang) {
177
+ entry.lang = lang;
178
+ entry.button.dataset.layer = mark.layer;
179
+ entry.button.setAttribute("aria-label", `${mark.place.name[lang]}, ${placeLine(mark.place, lang)}`);
180
+ }
181
+ if (!(Math.abs(entry.x - mark.x) < 0.25 && Math.abs(entry.y - mark.y) < 0.25)) {
182
+ entry.x = mark.x;
183
+ entry.y = mark.y;
184
+ entry.button.style.transform = `translate(${mark.x.toFixed(1)}px,${mark.y.toFixed(1)}px)`;
185
+ }
186
+ }
187
+ for (const [id, entry] of held) {
188
+ if (next.has(id))
189
+ continue;
190
+ entry.button.remove();
191
+ held.delete(id);
192
+ hideTip(id);
193
+ }
194
+ shown = marks.map((mark) => ({ id: mark.place.id, layer: mark.layer, x: mark.x, y: mark.y }));
195
+ placeTip();
196
+ },
197
+ clear() {
198
+ for (const entry of held.values())
199
+ entry.button.remove();
200
+ held.clear();
201
+ shown = [];
202
+ hideTip();
203
+ },
204
+ get shown() {
205
+ return shown;
206
+ },
207
+ dispose() {
208
+ this.clear();
209
+ box.remove();
210
+ style.remove();
211
+ },
212
+ };
213
+ }
@@ -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.36.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.37.1/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.36.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.37.1/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.
@@ -0,0 +1,30 @@
1
+ import type * as THREE from "three";
2
+ import { type Vec3 } from "../vec.ts";
3
+ import type { SpaceDwarf, SpacePlanet } from "./frame.ts";
4
+ import { type ScaleMode } from "./scale.ts";
5
+ /** The parts of three.js the dots use, over and above the ones every body needs. */
6
+ export type DotsThree = Pick<typeof THREE, "BufferAttribute" | "BufferGeometry" | "Points" | "PointsMaterial">;
7
+ /** One moon to draw as a dot: its planet, and where it is from the planet's centre in kilometres, in the J2000 ecliptic frame (what `catalogueMoonPosition` gives). */
8
+ export interface MoonDot {
9
+ host: SpacePlanet | SpaceDwarf;
10
+ km: Vec3;
11
+ }
12
+ /** The dots of the view. */
13
+ export interface MoonDots {
14
+ object: THREE.Points;
15
+ /** Places the dots: `at(host)` is where the host is drawn and `radius(host)` its drawn radius, in the view's units. Returns how many are drawn. */
16
+ update(dots: readonly MoonDot[], mode: ScaleMode, at: (host: SpacePlanet | SpaceDwarf) => Vec3, radius: (host: SpacePlanet | SpaceDwarf) => number, ratio: number): number;
17
+ dispose(): void;
18
+ }
19
+ /** The most dots drawn: more than every known moon, with room for the years of finds to come. */
20
+ export declare const MAX_MOON_DOTS = 1024;
21
+ /**
22
+ * Where the view draws a moon of the catalogue: its place from the planet in the planet's radii, turned into the scene's axes and drawn nearer in a compressed view (the same mapping as the drawn moons).
23
+ *
24
+ * @param mode - The scale of the view.
25
+ * @param dot - The moon's host and its place in kilometres.
26
+ * @returns The offset from the planet's centre, in the planet's radii, in the scene's axes.
27
+ */
28
+ export declare function moonDotOffset(mode: ScaleMode, dot: MoonDot): Vec3;
29
+ /** The dots, in one `Points` draw that is hidden until it has something to show. */
30
+ export declare function createMoonDots(T: DotsThree): MoonDots;
@@ -0,0 +1,61 @@
1
+ import { BODIES } from "../facts.js";
2
+ import { OBLIQUITY, RAD } from "../vec.js";
3
+ import { moonDistance } from "./scale.js";
4
+ /** The most dots drawn: more than every known moon, with room for the years of finds to come. */
5
+ export const MAX_MOON_DOTS = 1024;
6
+ /** A dot's size, in CSS pixels across. */
7
+ const DOT_PX = 3;
8
+ const C = Math.cos(OBLIQUITY * RAD);
9
+ const S = Math.sin(OBLIQUITY * RAD);
10
+ /** An ecliptic J2000 vector in the scene's axes (equatorial, y to the celestial north pole), as `moonOffset` turns a moon's. */
11
+ const toScene = (v) => [v[0], v[1] * S + v[2] * C, -(v[1] * C - v[2] * S)];
12
+ /**
13
+ * Where the view draws a moon of the catalogue: its place from the planet in the planet's radii, turned into the scene's axes and drawn nearer in a compressed view (the same mapping as the drawn moons).
14
+ *
15
+ * @param mode - The scale of the view.
16
+ * @param dot - The moon's host and its place in kilometres.
17
+ * @returns The offset from the planet's centre, in the planet's radii, in the scene's axes.
18
+ */
19
+ export function moonDotOffset(mode, dot) {
20
+ const r = BODIES[dot.host].radiusKm;
21
+ const v = toScene([dot.km[0] / r, dot.km[1] / r, dot.km[2] / r]);
22
+ const d = Math.hypot(v[0], v[1], v[2]);
23
+ const k = d === 0 ? 1 : moonDistance(mode, dot.host, d) / d;
24
+ return [v[0] * k, v[1] * k, v[2] * k];
25
+ }
26
+ /** The dots, in one `Points` draw that is hidden until it has something to show. */
27
+ export function createMoonDots(T) {
28
+ const positions = new Float32Array(MAX_MOON_DOTS * 3);
29
+ const geometry = new T.BufferGeometry();
30
+ const attribute = new T.BufferAttribute(positions, 3);
31
+ geometry.setAttribute("position", attribute);
32
+ geometry.setDrawRange(0, 0);
33
+ const material = new T.PointsMaterial({ color: 0xc9cdd4, size: DOT_PX, sizeAttenuation: false, transparent: true, opacity: 0.85, depthWrite: false });
34
+ const object = new T.Points(geometry, material);
35
+ object.frustumCulled = false;
36
+ object.visible = false;
37
+ return {
38
+ object,
39
+ update(dots, mode, at, radius, ratio) {
40
+ const count = Math.min(MAX_MOON_DOTS, dots.length);
41
+ for (let k = 0; k < count; k += 1) {
42
+ const dot = dots[k];
43
+ const o = moonDotOffset(mode, dot);
44
+ const c = at(dot.host);
45
+ const r = radius(dot.host);
46
+ positions[k * 3] = c[0] + o[0] * r;
47
+ positions[k * 3 + 1] = c[1] + o[1] * r;
48
+ positions[k * 3 + 2] = c[2] + o[2] * r;
49
+ }
50
+ attribute.needsUpdate = true;
51
+ geometry.setDrawRange(0, count);
52
+ material.size = DOT_PX * ratio;
53
+ object.visible = count > 0;
54
+ return count;
55
+ },
56
+ dispose() {
57
+ geometry.dispose();
58
+ material.dispose();
59
+ },
60
+ };
61
+ }
@@ -81,3 +81,21 @@ export declare function findBody(text: string): BodyId | undefined;
81
81
  * ```
82
82
  */
83
83
  export declare function hopFrom(id: BodyId, step: 1 | -1, can?: (id: BodyId) => boolean): BodyId;
84
+ /**
85
+ * The system a body belongs to: the body a moon goes round (or the body itself), and that body's moons, nearest first. The Sun's system is the Sun alone, and a body with no moons is a system of one.
86
+ *
87
+ * @param id - A body's name.
88
+ * @returns `host`, the middle of the system, and `moons`, the moons that go round it.
89
+ *
90
+ * @example
91
+ * ```ts
92
+ * import { systemOf } from "@johnmorrisdotca/wakusei-planets/space";
93
+ *
94
+ * const { host, moons } = systemOf("titan");
95
+ * console.log(host, moons.join(", "));
96
+ * ```
97
+ */
98
+ export declare function systemOf(id: BodyId): {
99
+ host: BodyId;
100
+ moons: BodyId[];
101
+ };
@@ -91,3 +91,21 @@ export function hopFrom(id, step, can = () => true) {
91
91
  }
92
92
  return id;
93
93
  }
94
+ /**
95
+ * The system a body belongs to: the body a moon goes round (or the body itself), and that body's moons, nearest first. The Sun's system is the Sun alone, and a body with no moons is a system of one.
96
+ *
97
+ * @param id - A body's name.
98
+ * @returns `host`, the middle of the system, and `moons`, the moons that go round it.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * import { systemOf } from "@johnmorrisdotca/wakusei-planets/space";
103
+ *
104
+ * const { host, moons } = systemOf("titan");
105
+ * console.log(host, moons.join(", "));
106
+ * ```
107
+ */
108
+ export function systemOf(id) {
109
+ const host = hostOf(id) ?? id;
110
+ return { host, moons: [...(MOONS_OF[host] ?? [])] };
111
+ }
@@ -2,6 +2,7 @@ import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
2
  import "../tables/minor.ts";
3
3
  import { type BodyId } from "../facts.ts";
4
4
  import { type SpaceKind } from "./bodies.ts";
5
+ import { type Sight, type SightEdge } from "./sight.ts";
5
6
  import { type NameLabelOptions } from "../scene/name-label.ts";
6
7
  import type { Credit, DataSource } from "../data-door.ts";
7
8
  import { type DoorHost } from "../door/host.ts";
@@ -11,8 +12,11 @@ import { type ScaleMode } from "./scale.ts";
11
12
  import type { RideLook } from "./ride.ts";
12
13
  import { type SunRegion } from "./regions.ts";
13
14
  import { type TravelKind } from "./travel.ts";
15
+ import { type Place } from "../places.ts";
16
+ import { type PlaceLayer } from "../place-marks.ts";
14
17
  import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
15
- export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type SpaceBody, type SpaceLight };
18
+ export { setPlacesLoader } from "../scene/place-layer.ts";
19
+ export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
16
20
  /** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
17
21
  export type { BodyPlace };
18
22
  /**
@@ -39,6 +43,40 @@ export interface BodyInfo {
39
43
  /** Distance from the Earth's centre now, kilometres (0 for the Earth). */
40
44
  distanceKm: number;
41
45
  }
46
+ /**
47
+ * The body under the pointer, a finger or the keyboard's focus (`wakusei-body-hover`), with the system it belongs to: the body in its middle and that body's moons. The view draws their names and markers at full strength.
48
+ *
49
+ * @example
50
+ * ```ts no-run
51
+ * import type { BodyHover } from "@johnmorrisdotca/wakusei-planets/space/element";
52
+ *
53
+ * const hover: BodyHover = { id: "titan", name: "Titan", kind: "moon", host: "saturn", radiusKm: 2574.7, distanceKm: 1.4e9, system: { host: "saturn", moons: ["mimas", "titan"] } };
54
+ * console.log(`${hover.name} is in ${hover.system.host}'s system`);
55
+ * ```
56
+ */
57
+ export interface BodyHover extends BodyInfo {
58
+ system: {
59
+ host: BodyId;
60
+ moons: BodyId[];
61
+ };
62
+ }
63
+ /**
64
+ * Where a body is for the picture (`sight()` and `wakusei-sight`): whether it is in view, and if not, the edge it lies beyond and where along it, the way to it and whether it is behind the camera (`Sight`), with its id,
65
+ * its kind and, for a moon, the body it goes round.
66
+ *
67
+ * @example
68
+ * ```ts no-run
69
+ * import type { BodySight } from "@johnmorrisdotca/wakusei-planets/space/element";
70
+ *
71
+ * const mars: BodySight = { id: "mars", kind: "planet", inView: false, behind: false, edge: "right", x: 640, y: 210, along: 210, angle: 84 };
72
+ * console.log(mars.inView ? "in view" : `beyond the ${mars.edge} edge`);
73
+ * ```
74
+ */
75
+ export interface BodySight extends Sight {
76
+ id: BodyId;
77
+ kind: SpaceKind;
78
+ host?: BodyId;
79
+ }
42
80
  /**
43
81
  * What the space view is doing: `loading`, `live`, `unavailable` (no WebGL), `lost` (the GPU took the context; it comes back by itself).
44
82
  *
@@ -102,9 +140,13 @@ export type Riding = RideState;
102
140
  /**
103
141
  * The `<wakusei-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`
104
142
  * (`"lon,lat"`), `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `look` (`realistic` or `painted`),
105
- * `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
143
+ * `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `all-moons` (every other known moon as a dot round its planet, from `/moon-catalogue`, fetched when first asked for), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
106
144
  * only when something changes, and nothing while it is out of sight.
107
145
  *
146
+ * The names and markers of bodies outside the system in the middle of the view are drawn at half strength (`far-opacity`, 0 to 1). A body under the pointer, a finger or the keyboard's focus lights its own system instead and
147
+ * sends `wakusei-body-hover` with the body and its system (`wakusei-body-hover-end` when none is). `sight()` says which bodies are in view and, for the rest, the edge of the picture each lies beyond; `wakusei-sight`
148
+ * fires when that changes. None of these draws the picture again.
149
+ *
108
150
  * `immersive` makes it a full-screen view: it fills the box it is in, whatever the shape (the body looked at is framed by the shorter side), the plain wheel zooms and a drag anywhere on it turns it. Without it Ctrl, Command or Alt with the wheel zooms and the plain wheel scrolls the page.
109
151
  *
110
152
  * It carries the shared view controls itself: a drag turns the camera round the body, two fingers pinch, Ctrl, Command or Alt with the wheel zooms (the plain wheel scrolls the page), and the arrow keys, + and - and 0 work once it is
@@ -135,6 +177,32 @@ export declare class WakuseiSpace extends HTMLElement {
135
177
  connectedCallback(): void;
136
178
  disconnectedCallback(): void;
137
179
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
180
+ /**
181
+ * The layers of places marked on the body looked at: any of `landing` (crewed landings, landers and rovers), `crash` (crash, impact and atmospheric-entry sites), `planned` (announced landings) and `feature` (named features), from
182
+ * the `places` attribute (`places="landing crash"`; `places` alone or `all` for every layer). Only a body with places (`PLACE_BODIES` from `/places`) shows any, and only once it is big enough on the screen. Setting it writes the attribute.
183
+ */
184
+ get places(): PlaceLayer[];
185
+ set places(layers: readonly PlaceLayer[] | null);
186
+ /** The marks laid on the body looked at now: each place's id, its layer and where its mark is, in CSS pixels from the view's top left. */
187
+ get placesShown(): readonly {
188
+ id: string;
189
+ layer: PlaceLayer;
190
+ x: number;
191
+ y: number;
192
+ }[];
193
+ /**
194
+ * 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
+ * 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.
196
+ *
197
+ * @param text - The place's id or name.
198
+ * @param options - `body`, `smooth` (true by default) and `zoom`.
199
+ * @returns The place, once the move has started.
200
+ */
201
+ goToPlace(text: string, options?: {
202
+ body?: BodyId | string;
203
+ smooth?: boolean;
204
+ zoom?: number;
205
+ }): Promise<Place | undefined>;
138
206
  /**
139
207
  * The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
140
208
  * `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
@@ -201,8 +269,34 @@ export declare class WakuseiSpace extends HTMLElement {
201
269
  */
202
270
  get labelsAlways(): boolean;
203
271
  set labelsAlways(value: boolean);
272
+ /**
273
+ * How strongly the names and markers of bodies outside the system in the middle of the view are drawn, from 0 (not at all) to 1 (as strongly as the others): the attribute `far-opacity`, 0.5 when it is not set
274
+ * (a page may set the CSS property `--wakusei-far-opacity` instead). The system in the middle is the body looked at, the body it goes round, and that body's moons; while a body is under the pointer, a finger or the
275
+ * keyboard's focus, its own system is drawn at full strength instead, and the rest at this strength.
276
+ */
277
+ get farOpacity(): number;
278
+ set farOpacity(value: number);
279
+ /** The body under the pointer, a finger or the keyboard's focus now, or null: its system's names are drawn at full strength. */
280
+ get hovered(): BodyId | null;
281
+ /**
282
+ * Where each body is for the picture at the last draw: in view or not, and for one out of view the edge of the picture it lies beyond, the point on that edge, the way to it, and whether it is behind the camera. It
283
+ * covers the Sun, the planets, the dwarf planets and the minor bodies, the moons of the body looked at and any other moon drawn; not the body the camera rides on. `wakusei-sight` fires with the same list whenever a
284
+ * body comes into view or leaves it, changes edge, or moves 8 CSS pixels along its edge, at most four times a second with a last one when the view settles, and never at rest: a page draws its own tabs at the edges
285
+ * from it. The view works it out only once it is asked: the first call (or the first `wakusei-sight` listener) asks for one draw, and the list is there from that draw on.
286
+ */
287
+ sight(): BodySight[];
288
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
289
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
290
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
291
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
204
292
  get orbits(): boolean;
205
293
  set orbits(value: boolean);
294
+ /**
295
+ * Whether every other known moon is drawn as a small dot round its planet (the attribute `all-moons`): the moons of `/moon-catalogue` the view does not draw in full, each at its mean-orbit place. The catalogue is fetched,
296
+ * as a chunk of its own, the first time they are turned on; a view that never turns them on never loads it.
297
+ */
298
+ get allMoons(): boolean;
299
+ set allMoons(value: boolean);
206
300
  /** How many small arrowheads each orbit line carries to show which way the body goes: 2 by default, at most 4, 0 for none (the attribute `arrows` says the same). Anything else is made a whole number in that range. */
207
301
  get arrows(): number;
208
302
  set arrows(value: number);
@@ -396,6 +490,12 @@ export declare class WakuseiSpace extends HTMLElement {
396
490
  points: number;
397
491
  sources: ReturnType<DoorHost["book"]["stats"]>;
398
492
  };
493
+ /** 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. */
494
+ allMoons: {
495
+ on: boolean;
496
+ loaded: boolean;
497
+ dots: number;
498
+ };
399
499
  /** The orbit lines drawn at the last draw (`earth`, the planets, `moon`), and how far each body is from its own line as a fraction of the line's radius: a body on its line reads under 0.01. */
400
500
  orbits: {
401
501
  drawn: string[];