@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.
- package/CHANGELOG.md +14 -0
- package/NOTICE.md +15 -1
- package/README.md +5 -4
- package/dist/data/moon-catalogue.d.ts +31 -0
- package/dist/data/moon-catalogue.js +471 -0
- package/dist/data/places-planned.d.ts +3 -0
- package/dist/data/places-planned.js +51 -0
- package/dist/element.d.ts +28 -0
- package/dist/element.js +178 -2
- package/dist/moon-catalogue.d.ts +296 -0
- package/dist/moon-catalogue.js +234 -0
- package/dist/place-marks.d.ts +182 -0
- package/dist/place-marks.js +194 -0
- package/dist/places/mars.d.ts +1 -1
- package/dist/places/mars.js +4 -2
- package/dist/places/moon.d.ts +1 -1
- package/dist/places/moon.js +4 -2
- package/dist/places.d.ts +4 -2
- package/dist/places.js +2 -0
- package/dist/scene/place-layer.d.ts +68 -0
- package/dist/scene/place-layer.js +213 -0
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/all-moons.d.ts +30 -0
- package/dist/space/all-moons.js +61 -0
- package/dist/space/bodies.d.ts +18 -0
- package/dist/space/bodies.js +18 -0
- package/dist/space/element.d.ts +102 -2
- package/dist/space/element.js +415 -7
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/scene.d.ts +32 -0
- package/dist/space/scene.js +44 -0
- package/dist/space/sight.d.ts +106 -0
- package/dist/space/sight.js +84 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -2
package/dist/space/element.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
2
|
import "../tables/minor.js";
|
|
3
|
-
import { BODIES, MOONS_OF } from "../facts.js";
|
|
3
|
+
import { BODIES, BODY_IDS, MOONS_OF } from "../facts.js";
|
|
4
4
|
import { createGate, frameCap } from "../gate.js";
|
|
5
5
|
import { arrowCount } from "./arrows.js";
|
|
6
6
|
import { createGameClock } from "./clock.js";
|
|
7
|
-
import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER } from "./bodies.js";
|
|
7
|
+
import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER, systemOf } from "./bodies.js";
|
|
8
|
+
import { sightChanged, sightOf } from "./sight.js";
|
|
8
9
|
import { chooseLabels } from "./labels.js";
|
|
9
10
|
import { coverArrows } from "./covered.js";
|
|
10
11
|
import { createPainter } from "../scene/painter.js";
|
|
@@ -20,7 +21,12 @@ import { groundDirection } from "./aim.js";
|
|
|
20
21
|
import { besideMoon } from "./beside.js";
|
|
21
22
|
import { SUN_REGIONS } from "./regions.js";
|
|
22
23
|
import { travelArrival } from "./travel.js";
|
|
24
|
+
import { findPlace, PLACE_BODIES } from "../places.js";
|
|
25
|
+
import { placeMarks, readPlaceLayers } from "../place-marks.js";
|
|
26
|
+
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
27
|
+
import { cross, dot } from "../vec.js";
|
|
23
28
|
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
29
|
+
export { setPlacesLoader } from "../scene/place-layer.js";
|
|
24
30
|
export { setThreeLoader, SPACE_BODIES };
|
|
25
31
|
/** The words the view says on itself for the scale in use. A page in another language gives its own with `scaleNames`. */
|
|
26
32
|
const SCALE_WORDS = {
|
|
@@ -44,12 +50,21 @@ const readPace = (value, fallback) => {
|
|
|
44
50
|
const GESTURE_GAP_MS = 300;
|
|
45
51
|
const REGION_IDS = SUN_REGIONS.map((region) => region.id);
|
|
46
52
|
const readRegion = (value) => (typeof value === "string" && REGION_IDS.includes(value.trim().toLowerCase()) ? value.trim().toLowerCase() : undefined);
|
|
53
|
+
/** The far names' strength from the attribute: a number from 0 to 1, or undefined when it is not set or not a number. */
|
|
54
|
+
const readFar = (value) => {
|
|
55
|
+
if (value === null || value.trim() === "")
|
|
56
|
+
return undefined;
|
|
57
|
+
const n = Number(value);
|
|
58
|
+
return Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : undefined;
|
|
59
|
+
};
|
|
47
60
|
const RAD = Math.PI / 180;
|
|
48
61
|
const REAL_TIME_TICK_MS = 60_000;
|
|
49
62
|
/** The plain wheel in an immersive view is passed on as a pinch of this share, so a notch (100) zooms about 1.2 times, as the family's mouse wheel does with Alt. */
|
|
50
63
|
const WHEEL_AS_PINCH = 0.2;
|
|
51
64
|
/** The least time between two `wakusei-timechange` events while time runs: a few a second at most, however fast the picture is drawn. */
|
|
52
65
|
const TIME_EVENT_MS = 250;
|
|
66
|
+
/** The least time between two `wakusei-sight` events while the view moves, in milliseconds. */
|
|
67
|
+
const SIGHT_EVENT_MS = 250;
|
|
53
68
|
const readCentre = (value) => {
|
|
54
69
|
if (!value)
|
|
55
70
|
return null;
|
|
@@ -75,13 +90,17 @@ const readBody = (value) => {
|
|
|
75
90
|
* 1.05 radii from the surface (`FIT_DISTANCE` over the zoom), so past a zoom of about 3.9 nothing moves; 3.6 is where the finest map tiles of the Earth, Mars and the Moon (16384 pixels round) run out of detail too, so it is the same ceiling for both.
|
|
76
91
|
*/
|
|
77
92
|
const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
|
|
78
|
-
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label,.sp-ring{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-region{position:absolute;left:10px;bottom:8px;margin:0;padding:0;font:600 15px/20px system-ui,-apple-system,sans-serif;color:#fff;opacity:.95;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:none;transition:opacity .35s}.sp-region[hidden]{display:block;opacity:0}@media (prefers-reduced-motion:reduce){.sp-region{transition:none}}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p><p class="sp-region" id="region" part="region" role="status" hidden></p>`;
|
|
93
|
+
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label[data-far]:not([data-carried]),.sp-ring[data-far]:not([data-carried]){opacity:var(--wakusei-far-opacity,.5)}.sp-arrow[data-far]{opacity:calc(.8*var(--wakusei-far-opacity,.5))}.sp-label,.sp-ring,.sp-arrow{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring,.sp-arrow{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-region{position:absolute;left:10px;bottom:8px;margin:0;padding:0;font:600 15px/20px system-ui,-apple-system,sans-serif;color:#fff;opacity:.95;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:none;transition:opacity .35s}.sp-region[hidden]{display:block;opacity:0}@media (prefers-reduced-motion:reduce){.sp-region{transition:none}}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p><p class="sp-region" id="region" part="region" role="status" hidden></p>`;
|
|
79
94
|
/**
|
|
80
95
|
* 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`
|
|
81
96
|
* (`"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`),
|
|
82
|
-
* `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
|
|
97
|
+
* `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
|
|
83
98
|
* only when something changes, and nothing while it is out of sight.
|
|
84
99
|
*
|
|
100
|
+
* 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
|
|
101
|
+
* 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`
|
|
102
|
+
* fires when that changes. None of these draws the picture again.
|
|
103
|
+
*
|
|
85
104
|
* `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.
|
|
86
105
|
*
|
|
87
106
|
* 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
|
|
@@ -105,8 +124,10 @@ const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;ove
|
|
|
105
124
|
* ```
|
|
106
125
|
*/
|
|
107
126
|
export class WakuseiSpace extends HTMLElement {
|
|
108
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "orbiters", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "transition", "pace", ...NAME_LABEL_ATTRIBUTES];
|
|
127
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "orbiters", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "all-moons", "far-opacity", "transition", "pace", ...NAME_LABEL_ATTRIBUTES];
|
|
109
128
|
#model = newSpaceModel();
|
|
129
|
+
#allMoons = false;
|
|
130
|
+
#catalogue;
|
|
110
131
|
#clock = createGameClock("now", 1);
|
|
111
132
|
#view;
|
|
112
133
|
#gate;
|
|
@@ -142,6 +163,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
142
163
|
#focusBeforeRide = "earth";
|
|
143
164
|
#lostTold = false;
|
|
144
165
|
#hands;
|
|
166
|
+
#markLayer;
|
|
167
|
+
#markList;
|
|
168
|
+
#markLoading;
|
|
169
|
+
#markHeard;
|
|
170
|
+
#placeGlide = 0;
|
|
171
|
+
#surface = null;
|
|
145
172
|
/** The shared controller behind the element's own hands: for a page that moves the view itself, such as `controller.set({ zoom: space.zoomFor("moon") })`. It is there while the element is connected, whether `controls` is `none` or not. */
|
|
146
173
|
get controller() {
|
|
147
174
|
return this.#hands?.controller;
|
|
@@ -203,6 +230,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
203
230
|
this.#placeLabels(places);
|
|
204
231
|
this.#door.announce();
|
|
205
232
|
},
|
|
233
|
+
onSight: (bodies, frame) => this.#see(bodies, frame),
|
|
234
|
+
wantSight: () => this.#sightAsked || this.#sightListeners.size > 0,
|
|
235
|
+
onSurface: (surface) => {
|
|
236
|
+
this.#surface = surface;
|
|
237
|
+
this.#markSurface();
|
|
238
|
+
},
|
|
206
239
|
onMoving: () => this.#gate?.request(),
|
|
207
240
|
onRideLost: () => this.#rideLost(),
|
|
208
241
|
onPainterError: (error) => this.dispatchEvent(new CustomEvent("wakusei-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
@@ -219,16 +252,32 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
219
252
|
});
|
|
220
253
|
this.#schedule();
|
|
221
254
|
this.addEventListener("pointerdown", this.#down);
|
|
255
|
+
this.addEventListener("pointermove", this.#move, { passive: true });
|
|
256
|
+
this.addEventListener("pointerleave", this.#leave);
|
|
222
257
|
// before the shared hands (which hear it after this): a plain wheel in an immersive view zooms
|
|
223
258
|
this.addEventListener("wheel", this.#wheel, { capture: true, passive: false });
|
|
224
259
|
this.#hands = carryControls(this, { limits: CARRIED_LIMITS, onChange: (view, info) => this.setView(view, info.final) });
|
|
260
|
+
this.#markHeard = onPlacesLoader(() => {
|
|
261
|
+
this.#markList = undefined;
|
|
262
|
+
this.#markSurface();
|
|
263
|
+
});
|
|
225
264
|
this.#labelBox.addEventListener("click", this.#labelClick);
|
|
226
265
|
this.#labelBox.addEventListener("focusin", this.#labelFocus);
|
|
266
|
+
this.#labelBox.addEventListener("focusout", this.#labelBlur);
|
|
267
|
+
this.#farStrength();
|
|
227
268
|
}
|
|
228
269
|
disconnectedCallback() {
|
|
229
270
|
this.#hands?.unbind();
|
|
230
271
|
this.#hands = undefined;
|
|
231
272
|
this.removeEventListener("pointerdown", this.#down);
|
|
273
|
+
this.removeEventListener("pointermove", this.#move);
|
|
274
|
+
this.removeEventListener("pointerleave", this.#leave);
|
|
275
|
+
window.removeEventListener("pointerup", this.#lift, true);
|
|
276
|
+
window.removeEventListener("pointercancel", this.#lift, true);
|
|
277
|
+
if (this.#hovered !== null)
|
|
278
|
+
this.#hover(null, this.#hoverBy);
|
|
279
|
+
clearTimeout(this.#sightTimer);
|
|
280
|
+
this.#sightTimer = undefined;
|
|
232
281
|
this.removeEventListener("wheel", this.#wheel, { capture: true });
|
|
233
282
|
window.removeEventListener("pointerup", this.#up, true);
|
|
234
283
|
clearTimeout(this.#timer);
|
|
@@ -238,6 +287,10 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
238
287
|
this.#view = undefined;
|
|
239
288
|
this.#taken?.release();
|
|
240
289
|
this.#taken = undefined;
|
|
290
|
+
this.#markLayer?.dispose();
|
|
291
|
+
this.#markLayer = undefined;
|
|
292
|
+
this.#markHeard?.();
|
|
293
|
+
this.#markHeard = undefined;
|
|
241
294
|
}
|
|
242
295
|
attributeChangedCallback(name, _old, value) {
|
|
243
296
|
if (name === "center")
|
|
@@ -260,10 +313,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
260
313
|
this.orbiters = value !== null && value !== "off";
|
|
261
314
|
else if (name === "orbits")
|
|
262
315
|
this.orbits = value !== "off";
|
|
316
|
+
else if (name === "all-moons")
|
|
317
|
+
this.allMoons = value !== null && value !== "off";
|
|
263
318
|
else if (name === "arrows")
|
|
264
319
|
this.arrows = arrowCount(value);
|
|
265
320
|
else if (name === "help")
|
|
266
321
|
this.help = value !== null && value !== "off";
|
|
322
|
+
else if (name === "far-opacity")
|
|
323
|
+
this.#farStrength();
|
|
267
324
|
else if (name === "help-through")
|
|
268
325
|
this.helpThrough = value !== null && value !== "off";
|
|
269
326
|
else if (name === "transition")
|
|
@@ -285,6 +342,138 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
285
342
|
}
|
|
286
343
|
else if (NAME_LABEL_ATTRIBUTES.includes(name))
|
|
287
344
|
this.#relabel();
|
|
345
|
+
if (name === "places" || name === "lang")
|
|
346
|
+
this.#markSurface();
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* 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
|
|
350
|
+
* 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.
|
|
351
|
+
*/
|
|
352
|
+
get places() {
|
|
353
|
+
return readPlaceLayers(this.getAttribute("places"));
|
|
354
|
+
}
|
|
355
|
+
set places(layers) {
|
|
356
|
+
if (layers === null || layers.length === 0)
|
|
357
|
+
this.removeAttribute("places");
|
|
358
|
+
else
|
|
359
|
+
this.setAttribute("places", layers.join(" "));
|
|
360
|
+
}
|
|
361
|
+
/** 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. */
|
|
362
|
+
get placesShown() {
|
|
363
|
+
return this.#markLayer?.shown ?? [];
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* 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
|
|
367
|
+
* 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.
|
|
368
|
+
*
|
|
369
|
+
* @param text - The place's id or name.
|
|
370
|
+
* @param options - `body`, `smooth` (true by default) and `zoom`.
|
|
371
|
+
* @returns The place, once the move has started.
|
|
372
|
+
*/
|
|
373
|
+
async goToPlace(text, options = {}) {
|
|
374
|
+
const body = options.body === undefined ? this.#model.focus : readBody(options.body);
|
|
375
|
+
if (body === undefined || !PLACE_BODIES.includes(body))
|
|
376
|
+
return undefined;
|
|
377
|
+
const list = await this.#loadMarks(body);
|
|
378
|
+
const place = findPlace(list, text);
|
|
379
|
+
if (place === undefined)
|
|
380
|
+
return undefined;
|
|
381
|
+
const model = this.#model;
|
|
382
|
+
const same = body === model.focus;
|
|
383
|
+
const zoom = options.zoom ?? (same ? model.view.zoom : 1);
|
|
384
|
+
// on another body the view glides there (as goTo does) and arrives over the place; on the same one it turns round the body to it, never through it
|
|
385
|
+
if (!same && !this.goTo(body, { smooth: options.smooth, zoom }))
|
|
386
|
+
return undefined;
|
|
387
|
+
// the camera sits along the place's outward direction, which the view's yaw and tilt give as a place on the Earth's globe at the moment the view was last pointed
|
|
388
|
+
const { pole, meridian } = orientation(body, model.time);
|
|
389
|
+
const east = cross(pole, meridian);
|
|
390
|
+
const c = Math.cos(place.lat * RAD);
|
|
391
|
+
const d = [0, 1, 2].map((i) => c * Math.cos(place.lon * RAD) * meridian[i] + c * Math.sin(place.lon * RAD) * east[i] + Math.sin(place.lat * RAD) * pole[i]);
|
|
392
|
+
model.anchor ??= model.time;
|
|
393
|
+
const earth = orientation("earth", model.anchor);
|
|
394
|
+
const lat = Math.asin(Math.max(-1, Math.min(1, dot(d, earth.pole)))) / RAD;
|
|
395
|
+
const lon = Math.atan2(dot(d, cross(earth.pole, earth.meridian)), dot(d, earth.meridian)) / RAD;
|
|
396
|
+
const from = { ...model.view };
|
|
397
|
+
const to = { yaw: model.centre.lon - lon, tilt: model.centre.lat - lat, zoom };
|
|
398
|
+
to.yaw = from.yaw + ((((to.yaw - from.yaw + 180) % 360) + 360) % 360) - 180;
|
|
399
|
+
const apply = (yaw, tilt, z, final) => {
|
|
400
|
+
if (this.#hands !== undefined && !this.hasAttribute("data-kazoku-bar"))
|
|
401
|
+
this.#hands.controller.set({ yaw, tilt, zoom: z }, final, "place");
|
|
402
|
+
else
|
|
403
|
+
this.setView({ yaw, tilt, zoom: z, roll: from.roll, panX: from.panX, panY: from.panY }, final);
|
|
404
|
+
};
|
|
405
|
+
const glide = (this.#placeGlide += 1);
|
|
406
|
+
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
407
|
+
if (!same || options.smooth === false || reduced || typeof requestAnimationFrame !== "function") {
|
|
408
|
+
apply(to.yaw, to.tilt, to.zoom, true);
|
|
409
|
+
return place;
|
|
410
|
+
}
|
|
411
|
+
const start = performance.now();
|
|
412
|
+
const step = () => {
|
|
413
|
+
if (glide !== this.#placeGlide || !this.isConnected)
|
|
414
|
+
return;
|
|
415
|
+
const k = Math.min(1, (performance.now() - start) / 900);
|
|
416
|
+
const ease = k * k * (3 - 2 * k);
|
|
417
|
+
apply(from.yaw + (to.yaw - from.yaw) * ease, from.tilt + (to.tilt - from.tilt) * ease, from.zoom + (to.zoom - from.zoom) * ease, k >= 1);
|
|
418
|
+
if (k < 1)
|
|
419
|
+
requestAnimationFrame(step);
|
|
420
|
+
};
|
|
421
|
+
requestAnimationFrame(step);
|
|
422
|
+
return place;
|
|
423
|
+
}
|
|
424
|
+
async #loadMarks(body) {
|
|
425
|
+
if (this.#markList?.body === body)
|
|
426
|
+
return this.#markList.list;
|
|
427
|
+
const load = placesLoader();
|
|
428
|
+
if (load === undefined)
|
|
429
|
+
return [];
|
|
430
|
+
const list = await load(body);
|
|
431
|
+
this.#markList = { body, list };
|
|
432
|
+
return list;
|
|
433
|
+
}
|
|
434
|
+
/** Lay the marks of the places over the body looked at, as the last draw left it, or take them away. Draws nothing. */
|
|
435
|
+
#markSurface() {
|
|
436
|
+
const layers = this.places;
|
|
437
|
+
const surface = this.#surface;
|
|
438
|
+
const root = this.shadowRoot;
|
|
439
|
+
if (layers.length === 0 || surface === null || root === null || !PLACE_BODIES.includes(surface.id)) {
|
|
440
|
+
if (layers.length === 0 && this.#markLayer !== undefined) {
|
|
441
|
+
this.#markLayer.dispose();
|
|
442
|
+
this.#markLayer = undefined;
|
|
443
|
+
if (this.getAttribute("role") === "group")
|
|
444
|
+
this.setAttribute("role", "img");
|
|
445
|
+
}
|
|
446
|
+
else
|
|
447
|
+
this.#markLayer?.clear();
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const id = surface.id;
|
|
451
|
+
if (this.#markList?.body !== id) {
|
|
452
|
+
this.#markLayer?.clear();
|
|
453
|
+
if (this.#markLoading !== id && placesLoader() !== undefined) {
|
|
454
|
+
this.#markLoading = id;
|
|
455
|
+
void this.#loadMarks(id).then(() => {
|
|
456
|
+
this.#markLoading = undefined;
|
|
457
|
+
if (this.#markList?.body === id)
|
|
458
|
+
this.#markSurface();
|
|
459
|
+
}, () => {
|
|
460
|
+
this.#markLoading = undefined;
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
if (this.#markLayer === undefined) {
|
|
466
|
+
this.#markLayer = createPlaceLayer(root, {
|
|
467
|
+
lang: () => (this.getAttribute("lang") === "ja" ? "ja" : "en"),
|
|
468
|
+
pick: (place, at) => this.dispatchEvent(new CustomEvent("wakusei-place", { detail: { body: id, place, x: at.x, y: at.y }, bubbles: true, composed: true })),
|
|
469
|
+
});
|
|
470
|
+
if (this.getAttribute("role") === "img")
|
|
471
|
+
this.setAttribute("role", "group");
|
|
472
|
+
}
|
|
473
|
+
const facts = BODIES[id];
|
|
474
|
+
const ax = facts.axesKm;
|
|
475
|
+
const scale = ax ? [ax[1] / facts.radiusKm, ax[2] / facts.radiusKm, ax[0] / facts.radiusKm] : [1, 1 - facts.flattening, 1];
|
|
476
|
+
this.#markLayer.set(placeMarks(this.#markList.list, layers, { ...surface, scale }, facts.radiusKm));
|
|
288
477
|
}
|
|
289
478
|
#bodyLabel;
|
|
290
479
|
/**
|
|
@@ -473,6 +662,61 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
473
662
|
if (this.#places)
|
|
474
663
|
this.#placeLabels(this.#places);
|
|
475
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* 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
|
|
667
|
+
* (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
|
|
668
|
+
* keyboard's focus, its own system is drawn at full strength instead, and the rest at this strength.
|
|
669
|
+
*/
|
|
670
|
+
get farOpacity() {
|
|
671
|
+
return readFar(this.getAttribute("far-opacity")) ?? 0.5;
|
|
672
|
+
}
|
|
673
|
+
set farOpacity(value) {
|
|
674
|
+
this.setAttribute("far-opacity", String(Math.min(1, Math.max(0, value))));
|
|
675
|
+
}
|
|
676
|
+
#farStrength() {
|
|
677
|
+
const far = readFar(this.getAttribute("far-opacity"));
|
|
678
|
+
if (far === undefined)
|
|
679
|
+
this.#labelBox?.style.removeProperty("--wakusei-far-opacity");
|
|
680
|
+
else
|
|
681
|
+
this.#labelBox?.style.setProperty("--wakusei-far-opacity", String(far));
|
|
682
|
+
}
|
|
683
|
+
/** The body under the pointer, a finger or the keyboard's focus now, or null: its system's names are drawn at full strength. */
|
|
684
|
+
get hovered() {
|
|
685
|
+
return this.#hovered;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* 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
|
|
689
|
+
* 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
|
|
690
|
+
* 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
|
|
691
|
+
* 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.
|
|
692
|
+
*/
|
|
693
|
+
sight() {
|
|
694
|
+
if (!this.#sightAsked) {
|
|
695
|
+
this.#sightAsked = true;
|
|
696
|
+
this.#gate?.request();
|
|
697
|
+
}
|
|
698
|
+
return Object.values(this.#sight).map((one) => ({ ...one }));
|
|
699
|
+
}
|
|
700
|
+
#sightAsked = false;
|
|
701
|
+
#sightListeners = new Set();
|
|
702
|
+
addEventListener(type, listener, options) {
|
|
703
|
+
if (listener === null)
|
|
704
|
+
return;
|
|
705
|
+
super.addEventListener(type, listener, options);
|
|
706
|
+
if (type !== "wakusei-sight")
|
|
707
|
+
return;
|
|
708
|
+
const first = this.#sightListeners.size === 0 && !this.#sightAsked;
|
|
709
|
+
this.#sightListeners.add(listener);
|
|
710
|
+
if (first)
|
|
711
|
+
this.#gate?.request();
|
|
712
|
+
}
|
|
713
|
+
removeEventListener(type, listener, options) {
|
|
714
|
+
if (listener === null)
|
|
715
|
+
return;
|
|
716
|
+
super.removeEventListener(type, listener, options);
|
|
717
|
+
if (type === "wakusei-sight")
|
|
718
|
+
this.#sightListeners.delete(listener);
|
|
719
|
+
}
|
|
476
720
|
get orbits() {
|
|
477
721
|
return this.#model.orbits;
|
|
478
722
|
}
|
|
@@ -480,6 +724,32 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
480
724
|
this.#model.orbits = value;
|
|
481
725
|
this.#gate?.request();
|
|
482
726
|
}
|
|
727
|
+
/**
|
|
728
|
+
* 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,
|
|
729
|
+
* as a chunk of its own, the first time they are turned on; a view that never turns them on never loads it.
|
|
730
|
+
*/
|
|
731
|
+
get allMoons() {
|
|
732
|
+
return this.#allMoons;
|
|
733
|
+
}
|
|
734
|
+
set allMoons(value) {
|
|
735
|
+
this.#allMoons = value;
|
|
736
|
+
if (!value) {
|
|
737
|
+
this.#model.allMoons = null;
|
|
738
|
+
this.#gate?.request();
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
this.#catalogue ??= import("../moon-catalogue.js").then(({ MOON_CATALOGUE, catalogueMoonPosition }) => {
|
|
742
|
+
const hosts = [...SPACE_PLANETS, ...SPACE_DWARFS];
|
|
743
|
+
const shown = MOON_CATALOGUE.filter((m) => !m.full && m.orbit !== null && hosts.includes(m.host));
|
|
744
|
+
return (ms) => shown.map((m) => ({ host: m.host, km: catalogueMoonPosition(m, ms) }));
|
|
745
|
+
});
|
|
746
|
+
void this.#catalogue.then((dots) => {
|
|
747
|
+
if (!this.#allMoons)
|
|
748
|
+
return;
|
|
749
|
+
this.#model.allMoons = dots;
|
|
750
|
+
this.#gate?.request();
|
|
751
|
+
});
|
|
752
|
+
}
|
|
483
753
|
/** 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. */
|
|
484
754
|
get arrows() {
|
|
485
755
|
return this.#model.arrowCount;
|
|
@@ -1022,6 +1292,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1022
1292
|
bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
|
|
1023
1293
|
tiles: { ...this.#model.tiles },
|
|
1024
1294
|
door: { points: this.#model.door.points, sources: this.#door.book.stats() },
|
|
1295
|
+
allMoons: { on: this.#allMoons, loaded: this.#model.allMoons !== null, dots: this.#model.moonDots },
|
|
1025
1296
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
1026
1297
|
travelling: this.#model.travelling === null ? null : { ...this.#model.travelling },
|
|
1027
1298
|
region: this.#model.region === null ? null : { id: this.#model.region, name: this.#regionName(this.#model.region), reach: this.#model.regionDrawn?.reach ?? 0, distance: this.#model.regionDrawn?.distance ?? 0 },
|
|
@@ -1130,6 +1401,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1130
1401
|
}
|
|
1131
1402
|
// no two names overlap: a moon gives way to its planet and a planet to the Sun
|
|
1132
1403
|
const shown = chooseLabels(wanted);
|
|
1404
|
+
this.#nameBoxes = wanted.filter((one) => shown.has(one.id));
|
|
1133
1405
|
for (const id of ids) {
|
|
1134
1406
|
const label = this.#pool.get(id);
|
|
1135
1407
|
const ring = this.#rings.get(id);
|
|
@@ -1166,7 +1438,127 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1166
1438
|
ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
|
|
1167
1439
|
}
|
|
1168
1440
|
this.#placeArrows(places);
|
|
1441
|
+
this.#markFar();
|
|
1442
|
+
}
|
|
1443
|
+
// --- far names, and the system under the pointer ---------------------------------------------------------------------------------------------------
|
|
1444
|
+
#hovered = null;
|
|
1445
|
+
#hoverBy = "pointer";
|
|
1446
|
+
#nameBoxes = [];
|
|
1447
|
+
/** The bodies drawn at full strength: the system of the body under the pointer, or else the one in the middle of the view. */
|
|
1448
|
+
#lit() {
|
|
1449
|
+
// the Sun in the middle lights the Sun and the eight planets; a body pointed at, the Sun too, lights its own system
|
|
1450
|
+
if (this.#hovered === null && this.#model.focus === "sun")
|
|
1451
|
+
return new Set(["sun", ...BODY_IDS.filter((id) => BODIES[id].kind === "planet")]);
|
|
1452
|
+
const { host, moons } = systemOf(this.#hovered ?? this.#model.focus);
|
|
1453
|
+
return new Set([host, ...moons]);
|
|
1454
|
+
}
|
|
1455
|
+
/** Mark the names, rings and arrows of the bodies outside the lit system: they are drawn at the far strength. Only what changed is touched, and nothing is drawn again. */
|
|
1456
|
+
#markFar() {
|
|
1457
|
+
const lit = this.#lit();
|
|
1458
|
+
const mark = (el, id) => {
|
|
1459
|
+
const far = id !== undefined && !lit.has(id);
|
|
1460
|
+
if (el.hasAttribute("data-far") !== far)
|
|
1461
|
+
el.toggleAttribute("data-far", far);
|
|
1462
|
+
};
|
|
1463
|
+
for (const [id, label] of this.#pool)
|
|
1464
|
+
mark(label, id);
|
|
1465
|
+
for (const [id, ring] of this.#rings)
|
|
1466
|
+
mark(ring, id);
|
|
1467
|
+
for (const arrow of this.#arrows.values())
|
|
1468
|
+
mark(arrow, arrow.dataset["body"]);
|
|
1469
|
+
}
|
|
1470
|
+
/** A body comes under the pointer, a finger or the keyboard's focus (`wakusei-body-hover`, with its system), or none does (`wakusei-body-hover-end`). */
|
|
1471
|
+
#hover(id, by) {
|
|
1472
|
+
if (id === this.#hovered) {
|
|
1473
|
+
if (id !== null)
|
|
1474
|
+
this.#hoverBy = by;
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
const was = this.#hovered;
|
|
1478
|
+
this.#hovered = id;
|
|
1479
|
+
this.#hoverBy = by;
|
|
1480
|
+
this.#markFar();
|
|
1481
|
+
if (id !== null)
|
|
1482
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
|
|
1483
|
+
else if (was !== null)
|
|
1484
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: was }, bubbles: true, composed: true }));
|
|
1485
|
+
}
|
|
1486
|
+
/** The body at a point of the element, in CSS pixels: on its disc (at least 14 pixels round its place) or on its name. */
|
|
1487
|
+
#bodyAt(x, y) {
|
|
1488
|
+
if (!this.#places || !this.#model.labels)
|
|
1489
|
+
return null;
|
|
1490
|
+
let best = null;
|
|
1491
|
+
let bestD = Infinity;
|
|
1492
|
+
for (const [id, at] of Object.entries(this.#places)) {
|
|
1493
|
+
if (!at)
|
|
1494
|
+
continue;
|
|
1495
|
+
const d = Math.hypot(x - at.x, y - at.y);
|
|
1496
|
+
if (d <= Math.max(at.r, 14) && d < bestD) {
|
|
1497
|
+
best = id;
|
|
1498
|
+
bestD = d;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
if (best !== null)
|
|
1502
|
+
return best;
|
|
1503
|
+
for (const box of this.#nameBoxes)
|
|
1504
|
+
if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height)
|
|
1505
|
+
return box.id;
|
|
1506
|
+
return null;
|
|
1169
1507
|
}
|
|
1508
|
+
#pointAt(event) {
|
|
1509
|
+
const rect = this.getBoundingClientRect();
|
|
1510
|
+
return this.#bodyAt(event.clientX - rect.left, event.clientY - rect.top);
|
|
1511
|
+
}
|
|
1512
|
+
// a mouse or a pen that moves over the view with no button down; a drag that turns the view leaves the lit system as it is
|
|
1513
|
+
#move = (event) => {
|
|
1514
|
+
if (event.pointerType === "touch" || event.buttons !== 0)
|
|
1515
|
+
return;
|
|
1516
|
+
if (this.#hoverBy === "focus" && this.#hovered !== null)
|
|
1517
|
+
return;
|
|
1518
|
+
this.#hover(this.#pointAt(event), "pointer");
|
|
1519
|
+
};
|
|
1520
|
+
#leave = (event) => {
|
|
1521
|
+
if (event.pointerType !== "touch" && this.#hoverBy === "pointer")
|
|
1522
|
+
this.#hover(null, "pointer");
|
|
1523
|
+
};
|
|
1524
|
+
#labelBlur = (event) => {
|
|
1525
|
+
const next = event.relatedTarget;
|
|
1526
|
+
if (this.#hoverBy === "focus" && !(next && this.#labelBox?.contains(next)))
|
|
1527
|
+
this.#hover(null, "focus");
|
|
1528
|
+
};
|
|
1529
|
+
/** Where each body is for the picture: kept for `sight()`, and told to the page when it changes enough to matter. */
|
|
1530
|
+
#sight = {};
|
|
1531
|
+
#told = {};
|
|
1532
|
+
#see(bodies, frame) {
|
|
1533
|
+
const now = {};
|
|
1534
|
+
for (const [id, input] of Object.entries(bodies)) {
|
|
1535
|
+
const body = id;
|
|
1536
|
+
const one = { id: body, kind: bodyKindOf(body), ...sightOf(input, frame.width, frame.height, frame.axis) };
|
|
1537
|
+
const host = hostOf(body);
|
|
1538
|
+
if (host !== undefined)
|
|
1539
|
+
one.host = host;
|
|
1540
|
+
now[id] = one;
|
|
1541
|
+
}
|
|
1542
|
+
this.#sight = now;
|
|
1543
|
+
if (this.#sightTimer !== undefined || !sightChanged(this.#told, now))
|
|
1544
|
+
return;
|
|
1545
|
+
// at most four times a second while the view moves; the last change is told when the wait is over
|
|
1546
|
+
const wait = this.#sightSent + SIGHT_EVENT_MS - performance.now();
|
|
1547
|
+
if (wait > 0)
|
|
1548
|
+
this.#sightTimer = setTimeout(this.#tellSight, wait);
|
|
1549
|
+
else
|
|
1550
|
+
this.#tellSight();
|
|
1551
|
+
}
|
|
1552
|
+
#sightSent = -Infinity;
|
|
1553
|
+
#sightTimer;
|
|
1554
|
+
#tellSight = () => {
|
|
1555
|
+
this.#sightTimer = undefined;
|
|
1556
|
+
if (!this.isConnected || !sightChanged(this.#told, this.#sight))
|
|
1557
|
+
return;
|
|
1558
|
+
this.#told = this.#sight;
|
|
1559
|
+
this.#sightSent = performance.now();
|
|
1560
|
+
this.dispatchEvent(new CustomEvent("wakusei-sight", { detail: { bodies: Object.values(this.#sight).map((one) => ({ ...one })) } }));
|
|
1561
|
+
};
|
|
1170
1562
|
/** The quiet arrows for the bodies behind others (`covered="arrow"`): one per covering disc, just outside its edge, named for the surest body behind and counting the rest. */
|
|
1171
1563
|
#placeArrows(places) {
|
|
1172
1564
|
const box = this.#labelBox;
|
|
@@ -1273,10 +1665,24 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1273
1665
|
#down = (event) => {
|
|
1274
1666
|
if (event.button !== 0)
|
|
1275
1667
|
return;
|
|
1668
|
+
if (event.pointerType === "touch") {
|
|
1669
|
+
// a finger lights the system it is on until it lifts
|
|
1670
|
+
this.#hover(this.#pointAt(event), "pointer");
|
|
1671
|
+
window.addEventListener("pointerup", this.#lift, { capture: true });
|
|
1672
|
+
window.addEventListener("pointercancel", this.#lift, { capture: true });
|
|
1673
|
+
}
|
|
1276
1674
|
this.#downX = event.clientX;
|
|
1277
1675
|
this.#downY = event.clientY;
|
|
1278
1676
|
window.addEventListener("pointerup", this.#up, { capture: true, once: true });
|
|
1279
1677
|
};
|
|
1678
|
+
#lift = (event) => {
|
|
1679
|
+
if (event.pointerType !== "touch")
|
|
1680
|
+
return;
|
|
1681
|
+
window.removeEventListener("pointerup", this.#lift, true);
|
|
1682
|
+
window.removeEventListener("pointercancel", this.#lift, true);
|
|
1683
|
+
if (this.#hoverBy === "pointer")
|
|
1684
|
+
this.#hover(null, "pointer");
|
|
1685
|
+
};
|
|
1280
1686
|
#up = (event) => {
|
|
1281
1687
|
if (Math.hypot(event.clientX - this.#downX, event.clientY - this.#downY) > 6)
|
|
1282
1688
|
return;
|
|
@@ -1335,8 +1741,10 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1335
1741
|
}
|
|
1336
1742
|
#labelFocus = (event) => {
|
|
1337
1743
|
const id = event.target?.dataset?.["body"];
|
|
1338
|
-
if (id)
|
|
1339
|
-
|
|
1744
|
+
if (!id)
|
|
1745
|
+
return;
|
|
1746
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-focus", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
|
|
1747
|
+
this.#hover(id, "focus");
|
|
1340
1748
|
};
|
|
1341
1749
|
// --- the rest --------------------------------------------------------------------------------------------------------------------------------------
|
|
1342
1750
|
#painterNow() {
|
package/dist/space/index.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeB
|
|
|
3
3
|
export { groundDirection } from "./aim.ts";
|
|
4
4
|
export { RIDE_FOV, ridePose, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
5
5
|
export { chooseLabels, LABEL_GAP, type LabelBox } from "./labels.ts";
|
|
6
|
-
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, type SpaceKind } from "./bodies.ts";
|
|
6
|
+
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, systemOf, type SpaceKind } from "./bodies.ts";
|
|
7
7
|
export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from "./beside.ts";
|
|
8
8
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow, type OrbitArrow } from "./arrows.ts";
|
|
9
9
|
export { spinAxis, type SpinAxis } from "./spin.ts";
|
|
10
10
|
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, type CoverArrow, type CoverEntry } from "./covered.ts";
|
|
11
11
|
export { TRAVEL_CLEARANCE, travelArrival, travelPlan, travelPose, type TravelBody, type TravelInput, type TravelKind, type TravelPlan, type TravelSample, type TravelSight, type TravelView } from "./travel.ts";
|
|
12
12
|
export { regionOrbits, regionView, SUN_REGIONS, type SunRegion } from "./regions.ts";
|
|
13
|
+
export { SIGHT_STEP_PX, sightChanged, sightOf, type Sight, type SightEdge, type SightInput } from "./sight.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -4,10 +4,11 @@ export { compress, MOON_COMPRESSED, moonDistance, orbitLine, placeAround, placeB
|
|
|
4
4
|
export { groundDirection } from "./aim.js";
|
|
5
5
|
export { RIDE_FOV, ridePose } from "./ride.js";
|
|
6
6
|
export { chooseLabels, LABEL_GAP } from "./labels.js";
|
|
7
|
-
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf } from "./bodies.js";
|
|
7
|
+
export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, systemOf } from "./bodies.js";
|
|
8
8
|
export { besideMoon, BESIDE_RADII } from "./beside.js";
|
|
9
9
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, spinArrow } from "./arrows.js";
|
|
10
10
|
export { spinAxis } from "./spin.js";
|
|
11
11
|
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy } from "./covered.js";
|
|
12
12
|
export { TRAVEL_CLEARANCE, travelArrival, travelPlan, travelPose } from "./travel.js";
|
|
13
13
|
export { regionOrbits, regionView, SUN_REGIONS } from "./regions.js";
|
|
14
|
+
export { SIGHT_STEP_PX, sightChanged, sightOf } from "./sight.js";
|