@johnmorrisdotca/wakusei-planets 0.67.0 → 0.69.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 +23 -2
- package/NOTICE.md +10 -0
- package/README.md +3 -3
- package/dist/data/moon-catalogue.d.ts +1 -1
- package/dist/data/moon-catalogue.js +1 -1
- package/dist/data/places-added.d.ts +2 -0
- package/dist/data/places-added.js +2 -0
- package/dist/data/places-aliases.d.ts +1 -0
- package/dist/data/places-aliases.js +14 -0
- package/dist/data/places-planned.js +1 -1
- package/dist/data/places-search-67p.d.ts +1 -0
- package/dist/data/places-search-67p.js +3 -0
- package/dist/data/places-search-amalthea.d.ts +1 -0
- package/dist/data/places-search-amalthea.js +3 -0
- package/dist/data/places-search-ariel.d.ts +1 -0
- package/dist/data/places-search-ariel.js +3 -0
- package/dist/data/places-search-bennu.d.ts +1 -0
- package/dist/data/places-search-bennu.js +3 -0
- package/dist/data/places-search-bodies.d.ts +25 -0
- package/dist/data/places-search-bodies.js +125 -0
- package/dist/data/places-search-callisto.d.ts +1 -0
- package/dist/data/places-search-callisto.js +3 -0
- package/dist/data/places-search-ceres.d.ts +1 -0
- package/dist/data/places-search-ceres.js +3 -0
- package/dist/data/places-search-charon.d.ts +1 -0
- package/dist/data/places-search-charon.js +3 -0
- package/dist/data/places-search-dactyl.d.ts +1 -0
- package/dist/data/places-search-dactyl.js +3 -0
- package/dist/data/places-search-deimos.d.ts +1 -0
- package/dist/data/places-search-deimos.js +3 -0
- package/dist/data/places-search-didymos.d.ts +1 -0
- package/dist/data/places-search-didymos.js +3 -0
- package/dist/data/places-search-dimorphos.d.ts +1 -0
- package/dist/data/places-search-dimorphos.js +3 -0
- package/dist/data/places-search-dinkinesh.d.ts +1 -0
- package/dist/data/places-search-dinkinesh.js +3 -0
- package/dist/data/places-search-dione.d.ts +1 -0
- package/dist/data/places-search-dione.js +3 -0
- package/dist/data/places-search-donaldjohanson.d.ts +1 -0
- package/dist/data/places-search-donaldjohanson.js +3 -0
- package/dist/data/places-search-enceladus.d.ts +1 -0
- package/dist/data/places-search-enceladus.js +3 -0
- package/dist/data/places-search-epimetheus.d.ts +1 -0
- package/dist/data/places-search-epimetheus.js +3 -0
- package/dist/data/places-search-eros.d.ts +1 -0
- package/dist/data/places-search-eros.js +3 -0
- package/dist/data/places-search-europa.d.ts +1 -0
- package/dist/data/places-search-europa.js +3 -0
- package/dist/data/places-search-ganymede.d.ts +1 -0
- package/dist/data/places-search-ganymede.js +3 -0
- package/dist/data/places-search-gaspra.d.ts +1 -0
- package/dist/data/places-search-gaspra.js +3 -0
- package/dist/data/places-search-hyperion.d.ts +1 -0
- package/dist/data/places-search-hyperion.js +3 -0
- package/dist/data/places-search-iapetus.d.ts +1 -0
- package/dist/data/places-search-iapetus.js +3 -0
- package/dist/data/places-search-ida.d.ts +1 -0
- package/dist/data/places-search-ida.js +3 -0
- package/dist/data/places-search-io.d.ts +1 -0
- package/dist/data/places-search-io.js +3 -0
- package/dist/data/places-search-itokawa.d.ts +1 -0
- package/dist/data/places-search-itokawa.js +3 -0
- package/dist/data/places-search-janus.d.ts +1 -0
- package/dist/data/places-search-janus.js +3 -0
- package/dist/data/places-search-jupiter.d.ts +1 -0
- package/dist/data/places-search-jupiter.js +3 -0
- package/dist/data/places-search-lutetia.d.ts +1 -0
- package/dist/data/places-search-lutetia.js +3 -0
- package/dist/data/places-search-mars.d.ts +1 -0
- package/dist/data/places-search-mars.js +3 -0
- package/dist/data/places-search-mathilde.d.ts +1 -0
- package/dist/data/places-search-mathilde.js +3 -0
- package/dist/data/places-search-mercury.d.ts +1 -0
- package/dist/data/places-search-mercury.js +3 -0
- package/dist/data/places-search-mimas.d.ts +1 -0
- package/dist/data/places-search-mimas.js +3 -0
- package/dist/data/places-search-miranda.d.ts +1 -0
- package/dist/data/places-search-miranda.js +3 -0
- package/dist/data/places-search-moon-satellites.d.ts +1 -0
- package/dist/data/places-search-moon-satellites.js +3 -0
- package/dist/data/places-search-moon.d.ts +1 -0
- package/dist/data/places-search-moon.js +3 -0
- package/dist/data/places-search-oberon.d.ts +1 -0
- package/dist/data/places-search-oberon.js +3 -0
- package/dist/data/places-search-phobos.d.ts +1 -0
- package/dist/data/places-search-phobos.js +3 -0
- package/dist/data/places-search-phoebe.d.ts +1 -0
- package/dist/data/places-search-phoebe.js +3 -0
- package/dist/data/places-search-pluto.d.ts +1 -0
- package/dist/data/places-search-pluto.js +3 -0
- package/dist/data/places-search-proteus.d.ts +1 -0
- package/dist/data/places-search-proteus.js +3 -0
- package/dist/data/places-search-rhea.d.ts +1 -0
- package/dist/data/places-search-rhea.js +3 -0
- package/dist/data/places-search-ryugu.d.ts +1 -0
- package/dist/data/places-search-ryugu.js +3 -0
- package/dist/data/places-search-saturn.d.ts +1 -0
- package/dist/data/places-search-saturn.js +3 -0
- package/dist/data/places-search-steins.d.ts +1 -0
- package/dist/data/places-search-steins.js +3 -0
- package/dist/data/places-search-tempel-1.d.ts +1 -0
- package/dist/data/places-search-tempel-1.js +3 -0
- package/dist/data/places-search-tethys.d.ts +1 -0
- package/dist/data/places-search-tethys.js +3 -0
- package/dist/data/places-search-thebe.d.ts +1 -0
- package/dist/data/places-search-thebe.js +3 -0
- package/dist/data/places-search-titan.d.ts +1 -0
- package/dist/data/places-search-titan.js +3 -0
- package/dist/data/places-search-titania.d.ts +1 -0
- package/dist/data/places-search-titania.js +3 -0
- package/dist/data/places-search-triton.d.ts +1 -0
- package/dist/data/places-search-triton.js +3 -0
- package/dist/data/places-search-types.d.ts +1 -0
- package/dist/data/places-search-types.js +59 -0
- package/dist/data/places-search-umbriel.d.ts +1 -0
- package/dist/data/places-search-umbriel.js +3 -0
- package/dist/data/places-search-venus.d.ts +1 -0
- package/dist/data/places-search-venus.js +3 -0
- package/dist/data/places-search-vesta.d.ts +1 -0
- package/dist/data/places-search-vesta.js +3 -0
- package/dist/earth-places.d.ts +17 -1
- package/dist/earth-places.js +18 -0
- package/dist/fact-sheets.d.ts +1 -1
- package/dist/fact-sheets.js +1 -1
- package/dist/flat/words.js +2 -0
- package/dist/moon-catalogue.d.ts +190 -0
- package/dist/moon-catalogue.js +189 -3
- package/dist/place-marks.js +1 -1
- package/dist/place-search.d.ts +179 -0
- package/dist/place-search.js +223 -0
- package/dist/places/moon.js +4 -1
- package/dist/places/search/67p.d.ts +12 -0
- package/dist/places/search/67p.js +14 -0
- package/dist/places/search/amalthea.d.ts +12 -0
- package/dist/places/search/amalthea.js +14 -0
- package/dist/places/search/ariel.d.ts +12 -0
- package/dist/places/search/ariel.js +14 -0
- package/dist/places/search/bennu.d.ts +12 -0
- package/dist/places/search/bennu.js +14 -0
- package/dist/places/search/callisto.d.ts +12 -0
- package/dist/places/search/callisto.js +14 -0
- package/dist/places/search/ceres.d.ts +12 -0
- package/dist/places/search/ceres.js +14 -0
- package/dist/places/search/charon.d.ts +12 -0
- package/dist/places/search/charon.js +14 -0
- package/dist/places/search/dactyl.d.ts +12 -0
- package/dist/places/search/dactyl.js +14 -0
- package/dist/places/search/deimos.d.ts +12 -0
- package/dist/places/search/deimos.js +14 -0
- package/dist/places/search/didymos.d.ts +12 -0
- package/dist/places/search/didymos.js +14 -0
- package/dist/places/search/dimorphos.d.ts +12 -0
- package/dist/places/search/dimorphos.js +14 -0
- package/dist/places/search/dinkinesh.d.ts +12 -0
- package/dist/places/search/dinkinesh.js +14 -0
- package/dist/places/search/dione.d.ts +12 -0
- package/dist/places/search/dione.js +14 -0
- package/dist/places/search/donaldjohanson.d.ts +12 -0
- package/dist/places/search/donaldjohanson.js +14 -0
- package/dist/places/search/enceladus.d.ts +12 -0
- package/dist/places/search/enceladus.js +14 -0
- package/dist/places/search/epimetheus.d.ts +12 -0
- package/dist/places/search/epimetheus.js +14 -0
- package/dist/places/search/eros.d.ts +12 -0
- package/dist/places/search/eros.js +14 -0
- package/dist/places/search/europa.d.ts +12 -0
- package/dist/places/search/europa.js +14 -0
- package/dist/places/search/ganymede.d.ts +12 -0
- package/dist/places/search/ganymede.js +14 -0
- package/dist/places/search/gaspra.d.ts +12 -0
- package/dist/places/search/gaspra.js +14 -0
- package/dist/places/search/hyperion.d.ts +12 -0
- package/dist/places/search/hyperion.js +14 -0
- package/dist/places/search/iapetus.d.ts +12 -0
- package/dist/places/search/iapetus.js +14 -0
- package/dist/places/search/ida.d.ts +12 -0
- package/dist/places/search/ida.js +14 -0
- package/dist/places/search/io.d.ts +12 -0
- package/dist/places/search/io.js +14 -0
- package/dist/places/search/itokawa.d.ts +12 -0
- package/dist/places/search/itokawa.js +14 -0
- package/dist/places/search/janus.d.ts +12 -0
- package/dist/places/search/janus.js +14 -0
- package/dist/places/search/jupiter.d.ts +12 -0
- package/dist/places/search/jupiter.js +14 -0
- package/dist/places/search/lutetia.d.ts +12 -0
- package/dist/places/search/lutetia.js +14 -0
- package/dist/places/search/mars.d.ts +12 -0
- package/dist/places/search/mars.js +14 -0
- package/dist/places/search/mathilde.d.ts +12 -0
- package/dist/places/search/mathilde.js +14 -0
- package/dist/places/search/mercury.d.ts +12 -0
- package/dist/places/search/mercury.js +14 -0
- package/dist/places/search/mimas.d.ts +12 -0
- package/dist/places/search/mimas.js +14 -0
- package/dist/places/search/miranda.d.ts +12 -0
- package/dist/places/search/miranda.js +14 -0
- package/dist/places/search/moon-satellites.d.ts +12 -0
- package/dist/places/search/moon-satellites.js +14 -0
- package/dist/places/search/moon.d.ts +12 -0
- package/dist/places/search/moon.js +14 -0
- package/dist/places/search/oberon.d.ts +12 -0
- package/dist/places/search/oberon.js +14 -0
- package/dist/places/search/phobos.d.ts +12 -0
- package/dist/places/search/phobos.js +14 -0
- package/dist/places/search/phoebe.d.ts +12 -0
- package/dist/places/search/phoebe.js +14 -0
- package/dist/places/search/pluto.d.ts +12 -0
- package/dist/places/search/pluto.js +14 -0
- package/dist/places/search/proteus.d.ts +12 -0
- package/dist/places/search/proteus.js +14 -0
- package/dist/places/search/rhea.d.ts +12 -0
- package/dist/places/search/rhea.js +14 -0
- package/dist/places/search/ryugu.d.ts +12 -0
- package/dist/places/search/ryugu.js +14 -0
- package/dist/places/search/saturn.d.ts +12 -0
- package/dist/places/search/saturn.js +14 -0
- package/dist/places/search/steins.d.ts +12 -0
- package/dist/places/search/steins.js +14 -0
- package/dist/places/search/tempel-1.d.ts +12 -0
- package/dist/places/search/tempel-1.js +14 -0
- package/dist/places/search/tethys.d.ts +12 -0
- package/dist/places/search/tethys.js +14 -0
- package/dist/places/search/thebe.d.ts +12 -0
- package/dist/places/search/thebe.js +14 -0
- package/dist/places/search/titan.d.ts +12 -0
- package/dist/places/search/titan.js +14 -0
- package/dist/places/search/titania.d.ts +12 -0
- package/dist/places/search/titania.js +14 -0
- package/dist/places/search/triton.d.ts +12 -0
- package/dist/places/search/triton.js +14 -0
- package/dist/places/search/umbriel.d.ts +12 -0
- package/dist/places/search/umbriel.js +14 -0
- package/dist/places/search/venus.d.ts +12 -0
- package/dist/places/search/venus.js +14 -0
- package/dist/places/search/vesta.d.ts +12 -0
- package/dist/places/search/vesta.js +14 -0
- package/dist/places/search.d.ts +42 -0
- package/dist/places/search.js +77 -0
- package/dist/places.d.ts +4 -3
- package/dist/scene/body-places.d.ts +98 -0
- package/dist/scene/body-places.js +113 -0
- package/dist/scene/earth-places.d.ts +6 -1
- package/dist/scene/earth-places.js +55 -2
- package/dist/scene/place-layer.js +1 -0
- package/dist/space/all-moons.d.ts +81 -10
- package/dist/space/all-moons.js +132 -27
- package/dist/space/element.d.ts +56 -5
- package/dist/space/element.js +240 -24
- package/dist/space/moon-settings.d.ts +25 -0
- package/dist/space/moon-settings.js +43 -0
- package/dist/space/orbit-rules.d.ts +25 -0
- package/dist/space/orbit-rules.js +36 -0
- package/dist/space/scene.d.ts +14 -3
- package/dist/space/scene.js +48 -17
- package/package.json +271 -1
package/dist/space/element.d.ts
CHANGED
|
@@ -16,14 +16,17 @@ import type { RideLook } from "./ride.ts";
|
|
|
16
16
|
import { type SunRegion } from "./regions.ts";
|
|
17
17
|
import { type TravelKind } from "./travel.ts";
|
|
18
18
|
import { type FrameKind } from "./hold.ts";
|
|
19
|
+
import { type MoonsChoice } from "./moon-settings.ts";
|
|
19
20
|
import { type Place } from "../places.ts";
|
|
20
21
|
import { type PlaceLayer } from "../place-marks.ts";
|
|
21
22
|
import { type EarthPlace, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
23
|
+
import { type PlaceOnBody, type PlaceOnBodyMark } from "../scene/body-places.ts";
|
|
22
24
|
import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
23
25
|
import { type PaintSpec } from "../paint/trail.ts";
|
|
24
26
|
export type { PaintSpec };
|
|
25
27
|
export { setPlacesLoader } from "../scene/place-layer.ts";
|
|
26
28
|
export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceKind, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
|
|
29
|
+
export type { PlaceOnBody, PlaceOnBodyMark } from "../scene/body-places.ts";
|
|
27
30
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
|
|
28
31
|
/** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
|
|
29
32
|
export type { BodyPlace };
|
|
@@ -167,7 +170,7 @@ export type Riding = RideState;
|
|
|
167
170
|
/**
|
|
168
171
|
* 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`
|
|
169
172
|
* (`"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`),
|
|
170
|
-
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `
|
|
173
|
+
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `moons` (`major`, the default, or `all`: every known moon of every planet as a pressable dot with its orbit, from `/moon-catalogue`, fetched when first asked for), `moons-of` (`"jupiter=all saturn=major"`: a planet's own choice) and `moon-colors` (`group` or `direction`: what the orbits' colours say), 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
|
|
171
174
|
* only when something changes, and nothing while it is out of sight.
|
|
172
175
|
*
|
|
173
176
|
* 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
|
|
@@ -260,6 +263,29 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
260
263
|
marks: readonly EarthPlaceMark[];
|
|
261
264
|
omitted: number;
|
|
262
265
|
};
|
|
266
|
+
/**
|
|
267
|
+
* The places laid on the bodies other than the Earth wherever the camera looks, drawn as the Earth's are (`earthPlaces`): a list of `{ body, id, lon, lat, label, kind, color }`, `body` being `moon`, `mars`, `ceres` and so on (an entry for `earth` is not drawn:
|
|
268
|
+
* the Earth has `earthPlaces`). Each is a beam, a pin or a ring (`earthPlacesLook`) on the ground of its body, hidden on the far side, named beside it when there is room, never over a body's name. A body smaller than 40 CSS pixels of radius carries none, and at most
|
|
269
|
+
* `EARTH_PLACE_MARKS` stand up in all, the reader's `here` places first. `loadPlaceHits` and `hitToBodyPlace` from `@johnmorrisdotca/wakusei-planets/places/search` make the list from saved ids. Like the Earth's, it needs
|
|
270
|
+
* `@johnmorrisdotca/wakusei-planets/earth-places` imported (chikyu-earth's layout, an optional peer). A press that did not move on a drawn name or a foot ring is the event `wakusei-body-place`. Setting it writes the attribute `body-places`.
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```ts no-run
|
|
274
|
+
* import "@johnmorrisdotca/wakusei-planets/space/element";
|
|
275
|
+
* import "@johnmorrisdotca/wakusei-planets/earth-places";
|
|
276
|
+
*
|
|
277
|
+
* const space = document.querySelector("wakusei-space")!;
|
|
278
|
+
* space.bodyPlaces = [{ body: "moon", id: "moon/apollo-11-lunar-module", lon: 23.4731, lat: 0.6742, label: "Apollo 11 lunar module" }];
|
|
279
|
+
* space.addEventListener("wakusei-body-place", (event) => console.log((event as CustomEvent).detail));
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
get bodyPlaces(): PlaceOnBody[];
|
|
283
|
+
set bodyPlaces(list: readonly PlaceOnBody[] | null);
|
|
284
|
+
/** The markers laid on the other bodies now, as the last draw left them: each place's body, 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`. */
|
|
285
|
+
get bodyPlacesShown(): {
|
|
286
|
+
marks: readonly PlaceOnBodyMark[];
|
|
287
|
+
omitted: number;
|
|
288
|
+
};
|
|
263
289
|
/**
|
|
264
290
|
* 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
|
|
265
291
|
* 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.
|
|
@@ -477,8 +503,30 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
477
503
|
get orbits(): boolean;
|
|
478
504
|
set orbits(value: boolean);
|
|
479
505
|
/**
|
|
480
|
-
*
|
|
481
|
-
* as a chunk of its own, the first time
|
|
506
|
+
* What every planet shows by default (the attribute `moons`): `"major"`, the moons the view draws in full (today's default), or `"all"`, every moon of `/moon-catalogue` as a small pressable dot round its planet, with
|
|
507
|
+
* its orbit. A planet with a choice of its own (`moonsOf`, `setMoons`) keeps it. The catalogue is fetched, as a chunk of its own, the first time a planet is set to `all`; a view that never does never loads it.
|
|
508
|
+
*/
|
|
509
|
+
get moons(): MoonsChoice;
|
|
510
|
+
set moons(value: MoonsChoice);
|
|
511
|
+
/** The choices of single planets (the attribute `moons-of`, `"jupiter=all saturn=major"`): a planet named here shows what it says whatever `moons` says. A planet not named follows `moons`. */
|
|
512
|
+
get moonsOf(): Readonly<Partial<Record<string, MoonsChoice>>>;
|
|
513
|
+
set moonsOf(value: Readonly<Partial<Record<string, MoonsChoice>>>);
|
|
514
|
+
/** What a planet shows now: its own choice, else the default. */
|
|
515
|
+
moonsFor(host: string): MoonsChoice;
|
|
516
|
+
/**
|
|
517
|
+
* Sets what one planet shows (`setMoons("all", "saturn")`), or, with no planet, every planet at once: the default is set and every choice of a single planet is cleared, so the whole view is `major` or `all`.
|
|
518
|
+
*
|
|
519
|
+
* @param choice - `major` or `all`.
|
|
520
|
+
* @param host - A planet or dwarf planet of the view: `jupiter`, `pluto`.
|
|
521
|
+
*/
|
|
522
|
+
setMoons(choice: MoonsChoice, host?: string): void;
|
|
523
|
+
/** What the orbits' colours say (the attribute `moon-colors`): `group` (the moon's family, the default) or `direction` (blue with the planet's turn, red against it). `moonOrbitKey` from `/moon-catalogue` is the key. */
|
|
524
|
+
get moonColors(): "group" | "direction";
|
|
525
|
+
set moonColors(value: "group" | "direction");
|
|
526
|
+
/** The planets showing every moon now, in the view's order. */
|
|
527
|
+
get moonHosts(): readonly string[];
|
|
528
|
+
/**
|
|
529
|
+
* Whether every moon of every planet is shown, the old switch: the attribute `all-moons`, now `moons="all"` with a different name. Setting it is `setMoons`.
|
|
482
530
|
*/
|
|
483
531
|
get allMoons(): boolean;
|
|
484
532
|
set allMoons(value: boolean);
|
|
@@ -801,17 +849,20 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
801
849
|
draws: number;
|
|
802
850
|
sources: ReturnType<DoorHost["book"]["stats"]>;
|
|
803
851
|
};
|
|
804
|
-
/** The catalogue's
|
|
852
|
+
/** The catalogue's moons of the planets set to `all` (`moons`): whether any is asked for, whether the catalogue has loaded, how many dots and orbits the last draw drew, and the planets showing them. */
|
|
805
853
|
allMoons: {
|
|
806
854
|
on: boolean;
|
|
807
855
|
loaded: boolean;
|
|
808
856
|
dots: number;
|
|
857
|
+
orbits: number;
|
|
858
|
+
hosts: readonly string[];
|
|
809
859
|
};
|
|
810
|
-
/** 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. */
|
|
860
|
+
/** 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. `hidden` are the lines left out because a body is close, and `faded` the lines whose part near the close body is let go (only a line that passes through it). */
|
|
811
861
|
orbits: {
|
|
812
862
|
drawn: string[];
|
|
813
863
|
miss: Record<string, number>;
|
|
814
864
|
hidden: string[];
|
|
865
|
+
faded: string[];
|
|
815
866
|
};
|
|
816
867
|
/** The arrowheads on the orbit lines at the last draw, by line (`earth`, the planets, `moon`): where each is and the way it points, the way the body goes (not the way the clock runs). */
|
|
817
868
|
arrows: Record<string, {
|
package/dist/space/element.js
CHANGED
|
@@ -25,10 +25,12 @@ import { besideMoon } from "./beside.js";
|
|
|
25
25
|
import { SUN_REGIONS } from "./regions.js";
|
|
26
26
|
import { travelArrival } from "./travel.js";
|
|
27
27
|
import { controlsFor, readFrame } from "./hold.js";
|
|
28
|
+
import { catalogueMoonIdOf, catalogueMoonKey, hostsShowingAll, MOON_HOSTS, moonSourceOf, readMoonColors, readMoonsChoice, readMoonsOf } from "./moon-settings.js";
|
|
28
29
|
import { findPlace, PLACE_BODIES } from "../places.js";
|
|
29
30
|
import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView } from "../place-marks.js";
|
|
30
31
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
31
32
|
import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
|
|
33
|
+
import { layBodyPlaces, bodiesOf, readBodyPlacesWith } from "../scene/body-places.js";
|
|
32
34
|
import { cross, dot, length, sub, unit } from "../vec.js";
|
|
33
35
|
import { createSpaceItem, FIT_DISTANCE, framedOf, heldAim, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
34
36
|
import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
|
|
@@ -110,11 +112,13 @@ const readBody = (value) => {
|
|
|
110
112
|
*/
|
|
111
113
|
const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
|
|
112
114
|
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[data-flip]{display:flex;flex-direction:row-reverse}.sp-label[data-flip]::before{margin:0 -2px 1px 5px}.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}}.sp-note{position:absolute;left:10px;right:10px;top:28px;max-width:44em;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.92;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-note[hidden],.sp-oort[hidden]{display:none}.sp-oort{position:absolute;left:0;top:0;margin:0;padding:0;font:italic 12px/16px system-ui,-apple-system,sans-serif;color:#aeb8e6;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none;transition:opacity .35s ease}.sp-oort[data-covered]{opacity:0}@media (prefers-reduced-motion:reduce){.sp-oort{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><p class="sp-note" part="note" role="status" hidden></p><p class="sp-oort" part="oort" hidden></p>`;
|
|
115
|
+
/** A dot of a moon of the catalogue answers a press within this many CSS pixels: smaller than a body's, so a crowd of dots can be told apart, and more than the dot is wide. */
|
|
116
|
+
const MOON_DOT_HIT_PX = 9;
|
|
113
117
|
const orbiterLines = (value) => (value === "chosen" || value === "none" ? value : "all");
|
|
114
118
|
/**
|
|
115
119
|
* 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`
|
|
116
120
|
* (`"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`),
|
|
117
|
-
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `
|
|
121
|
+
* `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `moons` (`major`, the default, or `all`: every known moon of every planet as a pressable dot with its orbit, from `/moon-catalogue`, fetched when first asked for), `moons-of` (`"jupiter=all saturn=major"`: a planet's own choice) and `moon-colors` (`group` or `direction`: what the orbits' colours say), 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
|
|
118
122
|
* only when something changes, and nothing while it is out of sight.
|
|
119
123
|
*
|
|
120
124
|
* 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
|
|
@@ -144,9 +148,10 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
|
|
|
144
148
|
* ```
|
|
145
149
|
*/
|
|
146
150
|
export class WakuseiSpace extends HTMLElement {
|
|
147
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "asteroids", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "site-flags", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
151
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "asteroids", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "help-place", "places", "surface-names", "site-flags", "earth-places", "earth-places-look", "body-places", "all-moons", "moons", "moons-of", "moon-colors", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
148
152
|
#model = newSpaceModel();
|
|
149
|
-
#
|
|
153
|
+
#moons = "major";
|
|
154
|
+
#moonsOf = {};
|
|
150
155
|
#catalogue;
|
|
151
156
|
#clock = createGameClock("now", 1);
|
|
152
157
|
#view;
|
|
@@ -201,6 +206,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
201
206
|
#earthHeard;
|
|
202
207
|
#earthList;
|
|
203
208
|
#earthOmitted = 0;
|
|
209
|
+
#bodyLayer;
|
|
210
|
+
#bodySurfaces = [];
|
|
211
|
+
#bodyList;
|
|
212
|
+
#bodyOmitted = 0;
|
|
213
|
+
// the pointer event of the last press a beam took, so the body under it is not pressed as well
|
|
214
|
+
#beamPress;
|
|
204
215
|
#surface = null;
|
|
205
216
|
/** 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. */
|
|
206
217
|
get controller() {
|
|
@@ -296,6 +307,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
296
307
|
this.#earthSurface = surface;
|
|
297
308
|
this.#layEarthPlaces();
|
|
298
309
|
},
|
|
310
|
+
wantBodyPlaces: () => this.#bodyWanted(),
|
|
311
|
+
onBodyPlaces: (surfaces) => {
|
|
312
|
+
this.#bodySurfaces = surfaces;
|
|
313
|
+
this.#layBodyPlaces();
|
|
314
|
+
},
|
|
299
315
|
onMoving: () => this.#gate?.request(),
|
|
300
316
|
onRideLost: () => this.#rideLost(),
|
|
301
317
|
onPainterError: (error) => this.dispatchEvent(new CustomEvent("wakusei-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
@@ -323,7 +339,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
323
339
|
});
|
|
324
340
|
this.#earthHeard = onEarthPlacesLayout(() => {
|
|
325
341
|
this.#earthList = undefined;
|
|
342
|
+
this.#bodyList = undefined;
|
|
326
343
|
this.#askEarthPlaces();
|
|
344
|
+
this.#askBodyPlaces();
|
|
327
345
|
});
|
|
328
346
|
this.#labelBox.addEventListener("click", this.#labelClick);
|
|
329
347
|
this.#labelBox.addEventListener("focusin", this.#labelFocus);
|
|
@@ -355,6 +373,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
355
373
|
this.#markLayer = undefined;
|
|
356
374
|
this.#markHeard?.();
|
|
357
375
|
this.#markHeard = undefined;
|
|
376
|
+
this.#bodyLayer?.dispose();
|
|
377
|
+
this.#bodyLayer = undefined;
|
|
378
|
+
this.#bodySurfaces = [];
|
|
358
379
|
this.#earthLayer?.dispose();
|
|
359
380
|
this.#earthLayer = undefined;
|
|
360
381
|
this.#earthSurface = null;
|
|
@@ -396,6 +417,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
396
417
|
this.orbits = value !== "off";
|
|
397
418
|
else if (name === "all-moons")
|
|
398
419
|
this.allMoons = value !== null && value !== "off";
|
|
420
|
+
else if (name === "moons")
|
|
421
|
+
this.moons = readMoonsChoice(value);
|
|
422
|
+
else if (name === "moons-of")
|
|
423
|
+
this.moonsOf = readMoonsOf(value);
|
|
424
|
+
else if (name === "moon-colors")
|
|
425
|
+
this.moonColors = readMoonColors(value);
|
|
399
426
|
else if (name === "arrows")
|
|
400
427
|
this.arrows = arrowCount(value);
|
|
401
428
|
else if (name === "help")
|
|
@@ -436,6 +463,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
436
463
|
this.#markSurface();
|
|
437
464
|
if (name === "earth-places" || name === "earth-places-look")
|
|
438
465
|
this.#askEarthPlaces();
|
|
466
|
+
if (name === "body-places" || name === "earth-places-look")
|
|
467
|
+
this.#askBodyPlaces();
|
|
439
468
|
}
|
|
440
469
|
/**
|
|
441
470
|
* 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
|
|
@@ -524,6 +553,35 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
524
553
|
get earthPlacesShown() {
|
|
525
554
|
return { marks: this.#earthLayer?.shown ?? [], omitted: this.#earthOmitted };
|
|
526
555
|
}
|
|
556
|
+
/**
|
|
557
|
+
* The places laid on the bodies other than the Earth wherever the camera looks, drawn as the Earth's are (`earthPlaces`): a list of `{ body, id, lon, lat, label, kind, color }`, `body` being `moon`, `mars`, `ceres` and so on (an entry for `earth` is not drawn:
|
|
558
|
+
* the Earth has `earthPlaces`). Each is a beam, a pin or a ring (`earthPlacesLook`) on the ground of its body, hidden on the far side, named beside it when there is room, never over a body's name. A body smaller than 40 CSS pixels of radius carries none, and at most
|
|
559
|
+
* `EARTH_PLACE_MARKS` stand up in all, the reader's `here` places first. `loadPlaceHits` and `hitToBodyPlace` from `@johnmorrisdotca/wakusei-planets/places/search` make the list from saved ids. Like the Earth's, it needs
|
|
560
|
+
* `@johnmorrisdotca/wakusei-planets/earth-places` imported (chikyu-earth's layout, an optional peer). A press that did not move on a drawn name or a foot ring is the event `wakusei-body-place`. Setting it writes the attribute `body-places`.
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* ```ts no-run
|
|
564
|
+
* import "@johnmorrisdotca/wakusei-planets/space/element";
|
|
565
|
+
* import "@johnmorrisdotca/wakusei-planets/earth-places";
|
|
566
|
+
*
|
|
567
|
+
* const space = document.querySelector("wakusei-space")!;
|
|
568
|
+
* space.bodyPlaces = [{ body: "moon", id: "moon/apollo-11-lunar-module", lon: 23.4731, lat: 0.6742, label: "Apollo 11 lunar module" }];
|
|
569
|
+
* space.addEventListener("wakusei-body-place", (event) => console.log((event as CustomEvent).detail));
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
get bodyPlaces() {
|
|
573
|
+
return [...this.#readBodyPlaces()];
|
|
574
|
+
}
|
|
575
|
+
set bodyPlaces(list) {
|
|
576
|
+
if (list === null || list.length === 0)
|
|
577
|
+
this.removeAttribute("body-places");
|
|
578
|
+
else
|
|
579
|
+
this.setAttribute("body-places", JSON.stringify(list));
|
|
580
|
+
}
|
|
581
|
+
/** The markers laid on the other bodies now, as the last draw left them: each place's body, 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`. */
|
|
582
|
+
get bodyPlacesShown() {
|
|
583
|
+
return { marks: (this.#bodyLayer?.shown ?? []), omitted: this.#bodyOmitted };
|
|
584
|
+
}
|
|
527
585
|
/**
|
|
528
586
|
* 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
|
|
529
587
|
* 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.
|
|
@@ -730,7 +788,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
730
788
|
const places = this.#readEarthPlaces();
|
|
731
789
|
if (places.length === 0)
|
|
732
790
|
return clear();
|
|
733
|
-
this.#earthLayer ??= createEarthPlaceLayer(root);
|
|
791
|
+
this.#earthLayer ??= createEarthPlaceLayer(root, { press: (mark, event) => this.#pressBeam("earth", mark, event) });
|
|
734
792
|
const layer = this.#earthLayer;
|
|
735
793
|
const facts = BODIES.earth;
|
|
736
794
|
const scale = [1, 1 - facts.flattening, 1];
|
|
@@ -748,6 +806,67 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
748
806
|
this.#earthOmitted = laid.shapes.length - marks.shapes.length;
|
|
749
807
|
layer.set(places, marks, look);
|
|
750
808
|
}
|
|
809
|
+
/** The bodies the page has places on (the scene lays their surfaces at each draw), none without the layout, or the Earth's, which `earth-places` draws. */
|
|
810
|
+
#bodyWanted() {
|
|
811
|
+
if (!this.hasAttribute("body-places") || earthPlacesLayout() === undefined)
|
|
812
|
+
return [];
|
|
813
|
+
this.#readBodyPlaces();
|
|
814
|
+
return this.#bodyList?.bodies ?? [];
|
|
815
|
+
}
|
|
816
|
+
#readBodyPlaces() {
|
|
817
|
+
const text = this.getAttribute("body-places");
|
|
818
|
+
const using = earthPlacesLayout();
|
|
819
|
+
if (text === null || using === undefined)
|
|
820
|
+
return [];
|
|
821
|
+
if (this.#bodyList?.text === text)
|
|
822
|
+
return this.#bodyList.list;
|
|
823
|
+
const list = readBodyPlacesWith(text, using.read);
|
|
824
|
+
this.#bodyList = { text, list, bodies: bodiesOf(list) };
|
|
825
|
+
return list;
|
|
826
|
+
}
|
|
827
|
+
/** The places, the look or the layout changed: lay them from the last draw's bodies, or ask for one draw to learn them. */
|
|
828
|
+
#askBodyPlaces() {
|
|
829
|
+
if (!this.hasAttribute("body-places")) {
|
|
830
|
+
this.#bodyLayer?.dispose();
|
|
831
|
+
this.#bodyLayer = undefined;
|
|
832
|
+
this.#bodySurfaces = [];
|
|
833
|
+
this.#bodyOmitted = 0;
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
if (this.#bodySurfaces.length > 0)
|
|
837
|
+
this.#layBodyPlaces();
|
|
838
|
+
this.#gate?.request();
|
|
839
|
+
}
|
|
840
|
+
/** Lay the places over the bodies as the last draw left them, or take them away. Draws nothing: it runs inside the draw the view makes anyway. */
|
|
841
|
+
#layBodyPlaces() {
|
|
842
|
+
const root = this.shadowRoot;
|
|
843
|
+
const using = earthPlacesLayout();
|
|
844
|
+
const clear = () => {
|
|
845
|
+
this.#bodyLayer?.clear();
|
|
846
|
+
this.#bodyOmitted = 0;
|
|
847
|
+
};
|
|
848
|
+
if (root === null || using === undefined || !this.hasAttribute("body-places") || this.#bodySurfaces.length === 0)
|
|
849
|
+
return clear();
|
|
850
|
+
const places = this.#readBodyPlaces();
|
|
851
|
+
if (places.length === 0)
|
|
852
|
+
return clear();
|
|
853
|
+
this.#bodyLayer ??= createEarthPlaceLayer(root, { press: (mark, event) => this.#pressBeam(mark.body ?? "", mark, event) });
|
|
854
|
+
const layer = this.#bodyLayer;
|
|
855
|
+
const look = this.earthPlacesLook;
|
|
856
|
+
const laid = layBodyPlaces(places, this.#bodySurfaces, using, look, {
|
|
857
|
+
width: (text) => layer.width(text),
|
|
858
|
+
taken: this.#nameBoxes.map((one) => ({ left: one.x, top: one.y, width: one.width, height: one.height })),
|
|
859
|
+
// a body under another's disc carries none of its places, as the surface marks and the Earth's places
|
|
860
|
+
covered: (id) => this.#covered !== "name" && this.#places?.[id]?.behind !== undefined,
|
|
861
|
+
});
|
|
862
|
+
this.#bodyOmitted = laid.omitted;
|
|
863
|
+
layer.set(laid.places, laid.layout, look);
|
|
864
|
+
}
|
|
865
|
+
/** A press on a beam's name or foot ring: the event `wakusei-body-place`, `{ body, id, kind, x, y }` (the same for the Earth's places, `body: "earth"`). The page decides what it does; the body under the press is not pressed as well. */
|
|
866
|
+
#pressBeam(body, mark, event) {
|
|
867
|
+
this.#beamPress = event;
|
|
868
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-place", { detail: { body, id: mark.id, kind: mark.kind, x: mark.x, y: mark.y }, bubbles: true, composed: true }));
|
|
869
|
+
}
|
|
751
870
|
async #loadMarks(body) {
|
|
752
871
|
if (this.#markList?.body === body)
|
|
753
872
|
return this.#markList.list;
|
|
@@ -1336,30 +1455,79 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1336
1455
|
this.#gate?.request();
|
|
1337
1456
|
}
|
|
1338
1457
|
/**
|
|
1339
|
-
*
|
|
1340
|
-
* as a chunk of its own, the first time
|
|
1458
|
+
* What every planet shows by default (the attribute `moons`): `"major"`, the moons the view draws in full (today's default), or `"all"`, every moon of `/moon-catalogue` as a small pressable dot round its planet, with
|
|
1459
|
+
* its orbit. A planet with a choice of its own (`moonsOf`, `setMoons`) keeps it. The catalogue is fetched, as a chunk of its own, the first time a planet is set to `all`; a view that never does never loads it.
|
|
1460
|
+
*/
|
|
1461
|
+
get moons() {
|
|
1462
|
+
return this.#moons;
|
|
1463
|
+
}
|
|
1464
|
+
set moons(value) {
|
|
1465
|
+
this.#moons = value === "all" ? "all" : "major";
|
|
1466
|
+
this.#moonsChanged();
|
|
1467
|
+
}
|
|
1468
|
+
/** The choices of single planets (the attribute `moons-of`, `"jupiter=all saturn=major"`): a planet named here shows what it says whatever `moons` says. A planet not named follows `moons`. */
|
|
1469
|
+
get moonsOf() {
|
|
1470
|
+
return { ...this.#moonsOf };
|
|
1471
|
+
}
|
|
1472
|
+
set moonsOf(value) {
|
|
1473
|
+
this.#moonsOf = readMoonsOf(Object.entries(value).map(([host, choice]) => `${host}=${choice}`).join(" "));
|
|
1474
|
+
this.#moonsChanged();
|
|
1475
|
+
}
|
|
1476
|
+
/** What a planet shows now: its own choice, else the default. */
|
|
1477
|
+
moonsFor(host) {
|
|
1478
|
+
return this.#moonsOf[host] ?? this.#moons;
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* Sets what one planet shows (`setMoons("all", "saturn")`), or, with no planet, every planet at once: the default is set and every choice of a single planet is cleared, so the whole view is `major` or `all`.
|
|
1482
|
+
*
|
|
1483
|
+
* @param choice - `major` or `all`.
|
|
1484
|
+
* @param host - A planet or dwarf planet of the view: `jupiter`, `pluto`.
|
|
1485
|
+
*/
|
|
1486
|
+
setMoons(choice, host) {
|
|
1487
|
+
if (host === undefined) {
|
|
1488
|
+
this.#moons = choice === "all" ? "all" : "major";
|
|
1489
|
+
this.#moonsOf = {};
|
|
1490
|
+
}
|
|
1491
|
+
else if (MOON_HOSTS.includes(host))
|
|
1492
|
+
this.#moonsOf = { ...this.#moonsOf, [host]: choice === "all" ? "all" : "major" };
|
|
1493
|
+
else
|
|
1494
|
+
throw new RangeError(`unknown planet ${JSON.stringify(host)}; the view places ${MOON_HOSTS.join(", ")}`);
|
|
1495
|
+
this.#moonsChanged();
|
|
1496
|
+
}
|
|
1497
|
+
/** What the orbits' colours say (the attribute `moon-colors`): `group` (the moon's family, the default) or `direction` (blue with the planet's turn, red against it). `moonOrbitKey` from `/moon-catalogue` is the key. */
|
|
1498
|
+
get moonColors() {
|
|
1499
|
+
return this.#model.moonColors;
|
|
1500
|
+
}
|
|
1501
|
+
set moonColors(value) {
|
|
1502
|
+
this.#model.moonColors = value === "direction" ? "direction" : "group";
|
|
1503
|
+
this.#gate?.request();
|
|
1504
|
+
}
|
|
1505
|
+
/** The planets showing every moon now, in the view's order. */
|
|
1506
|
+
get moonHosts() {
|
|
1507
|
+
return MOON_HOSTS.filter((host) => this.#model.moonHosts.has(host));
|
|
1508
|
+
}
|
|
1509
|
+
/**
|
|
1510
|
+
* Whether every moon of every planet is shown, the old switch: the attribute `all-moons`, now `moons="all"` with a different name. Setting it is `setMoons`.
|
|
1341
1511
|
*/
|
|
1342
1512
|
get allMoons() {
|
|
1343
|
-
return this.#
|
|
1513
|
+
return this.#moons === "all" && Object.keys(this.#moonsOf).length === 0;
|
|
1344
1514
|
}
|
|
1345
1515
|
set allMoons(value) {
|
|
1346
|
-
this
|
|
1347
|
-
|
|
1348
|
-
|
|
1516
|
+
this.setMoons(value ? "all" : "major");
|
|
1517
|
+
}
|
|
1518
|
+
#moonsChanged() {
|
|
1519
|
+
const hosts = hostsShowingAll(this.#moons, this.#moonsOf);
|
|
1520
|
+
this.#model.moonHosts = hosts;
|
|
1521
|
+
if (hosts.size === 0) {
|
|
1349
1522
|
this.#gate?.request();
|
|
1350
1523
|
return;
|
|
1351
1524
|
}
|
|
1352
|
-
this.#catalogue ??= import("../moon-catalogue.js").then((
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
return (ms) => shown.map((m) => ({ host: m.host, km: catalogueMoonPosition(m, ms) }));
|
|
1356
|
-
});
|
|
1357
|
-
void this.#catalogue.then((dots) => {
|
|
1358
|
-
if (!this.#allMoons)
|
|
1359
|
-
return;
|
|
1360
|
-
this.#model.allMoons = dots;
|
|
1525
|
+
this.#catalogue ??= import("../moon-catalogue.js").then((catalogue) => moonSourceOf(catalogue));
|
|
1526
|
+
void this.#catalogue.then((source) => {
|
|
1527
|
+
this.#model.moonSource = source;
|
|
1361
1528
|
this.#gate?.request();
|
|
1362
1529
|
});
|
|
1530
|
+
this.#gate?.request();
|
|
1363
1531
|
}
|
|
1364
1532
|
/** 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. */
|
|
1365
1533
|
get arrows() {
|
|
@@ -2319,11 +2487,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2319
2487
|
bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
|
|
2320
2488
|
tiles: { ...this.#model.tiles },
|
|
2321
2489
|
door: { points: this.#model.door.points, belts: this.#model.door.belts, draws: this.#model.door.draws, sources: this.#door.book.stats() },
|
|
2322
|
-
allMoons: { on: this.#
|
|
2490
|
+
allMoons: { on: this.#model.moonHosts.size > 0, loaded: this.#model.moonSource !== null, dots: this.#model.moonDots, orbits: this.#model.moonOrbits, hosts: this.moonHosts },
|
|
2323
2491
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
2324
2492
|
travelling: this.#model.travelling === null ? null : { ...this.#model.travelling },
|
|
2325
2493
|
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 },
|
|
2326
|
-
orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden] },
|
|
2494
|
+
orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden], faded: [...this.#model.rings.faded] },
|
|
2327
2495
|
arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
|
|
2328
2496
|
arrowPx: this.#model.arrowPx,
|
|
2329
2497
|
help: this.#model.helpDrawn ? { body: this.#model.helpDrawn.body, axis: [...this.#model.helpDrawn.axis], pole: [...this.#model.helpDrawn.pole], retrograde: this.#model.helpDrawn.retrograde, arcTurn: [...this.#model.helpDrawn.arcTurn] } : null,
|
|
@@ -2389,6 +2557,9 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2389
2557
|
return this.#names[id] ?? this.#model.orbiterSet.name(id)[lang];
|
|
2390
2558
|
if (this.#isAsteroid(id))
|
|
2391
2559
|
return this.#names[asteroidIdOf(id)] ?? this.#model.asteroidSet.name(asteroidIdOf(id))[lang];
|
|
2560
|
+
const found = this.#catalogueMoon(id);
|
|
2561
|
+
if (found !== undefined)
|
|
2562
|
+
return this.#names[found.id] ?? (lang === "ja" ? (found.ja ?? found.label) : found.label);
|
|
2392
2563
|
return this.#names[id] ?? BODIES[id].name[lang];
|
|
2393
2564
|
}
|
|
2394
2565
|
#placeLabels(places) {
|
|
@@ -2534,6 +2705,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2534
2705
|
for (const arrow of this.#arrows.values())
|
|
2535
2706
|
mark(arrow, arrow.dataset["body"]);
|
|
2536
2707
|
}
|
|
2708
|
+
/** The moon of the catalogue a view key names (`moon:dia`), where the planet is showing every moon and the catalogue has loaded. */
|
|
2709
|
+
#catalogueMoon(key) {
|
|
2710
|
+
const id = catalogueMoonIdOf(key);
|
|
2711
|
+
return id === undefined ? undefined : this.#model.moonSource?.moons.find((m) => m.id === id && this.#model.moonHosts.has(m.host));
|
|
2712
|
+
}
|
|
2713
|
+
/** The event detail for a moon of the catalogue. */
|
|
2714
|
+
#moonDetail(key) {
|
|
2715
|
+
const moon = this.#catalogueMoon(key);
|
|
2716
|
+
return { id: moon.id, name: this.#nameOf(key), kind: "catalogue-moon", host: moon.host };
|
|
2717
|
+
}
|
|
2537
2718
|
/** 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`). */
|
|
2538
2719
|
#hover(id, by) {
|
|
2539
2720
|
if (id === this.#hovered) {
|
|
@@ -2545,14 +2726,16 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2545
2726
|
this.#hovered = id;
|
|
2546
2727
|
this.#hoverBy = by;
|
|
2547
2728
|
this.#markFar();
|
|
2548
|
-
if (id !== null && this.#
|
|
2729
|
+
if (id !== null && this.#catalogueMoon(id) !== undefined)
|
|
2730
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: this.#moonDetail(id), bubbles: true, composed: true }));
|
|
2731
|
+
else if (id !== null && this.#isAsteroid(id))
|
|
2549
2732
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id: asteroidIdOf(id), name: this.#nameOf(id), kind: "small-body" }, bubbles: true, composed: true }));
|
|
2550
2733
|
else if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id)))
|
|
2551
2734
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
|
|
2552
2735
|
else if (id !== null)
|
|
2553
2736
|
this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
|
|
2554
2737
|
else if (was !== null)
|
|
2555
|
-
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: was }, bubbles: true, composed: true }));
|
|
2738
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-hover-end", { detail: { id: catalogueMoonIdOf(was) ?? was }, bubbles: true, composed: true }));
|
|
2556
2739
|
}
|
|
2557
2740
|
/** 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. A press (`#up`) and the hover (`#pointAt`) both ask this, so what lights up under the pointer is what a press picks. */
|
|
2558
2741
|
#bodyAt(x, y, pressing = false) {
|
|
@@ -2575,7 +2758,17 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2575
2758
|
for (const box of this.#nameBoxes)
|
|
2576
2759
|
if (x >= box.x && x <= box.x + box.width && y >= box.y && y <= box.y + box.height)
|
|
2577
2760
|
return box.id;
|
|
2578
|
-
|
|
2761
|
+
// a dot of a moon of the catalogue (a planet set to `all`): the nearest within a finger's reach, after everything with a name
|
|
2762
|
+
let dot = null;
|
|
2763
|
+
let dotD = MOON_DOT_HIT_PX;
|
|
2764
|
+
for (const spot of this.#model.moonSpots) {
|
|
2765
|
+
const d = Math.hypot(x - spot.x, y - spot.y);
|
|
2766
|
+
if (d <= dotD) {
|
|
2767
|
+
dot = spot;
|
|
2768
|
+
dotD = d;
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
return dot === null ? null : catalogueMoonKey(dot.id);
|
|
2579
2772
|
}
|
|
2580
2773
|
#pointAt(event) {
|
|
2581
2774
|
const rect = this.getBoundingClientRect();
|
|
@@ -2628,6 +2821,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2628
2821
|
#sightTimer;
|
|
2629
2822
|
#tellSight = () => {
|
|
2630
2823
|
this.#sightTimer = undefined;
|
|
2824
|
+
// a timer can fire a few milliseconds early (CI heard two events 244 ms apart): the wait is made good, so the least time between two events is the one the property promises
|
|
2825
|
+
const early = this.#sightSent + SIGHT_EVENT_MS - performance.now();
|
|
2826
|
+
if (early > 0.5 && this.isConnected) {
|
|
2827
|
+
this.#sightTimer = setTimeout(this.#tellSight, early);
|
|
2828
|
+
return;
|
|
2829
|
+
}
|
|
2631
2830
|
if (!this.isConnected || !sightChanged(this.#told, this.#sight))
|
|
2632
2831
|
return;
|
|
2633
2832
|
this.#told = this.#sight;
|
|
@@ -2783,6 +2982,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2783
2982
|
this.#hover(null, "pointer");
|
|
2784
2983
|
};
|
|
2785
2984
|
#up = (event) => {
|
|
2985
|
+
if (this.#beamPress === event)
|
|
2986
|
+
return;
|
|
2786
2987
|
if (Math.hypot(event.clientX - this.#downX, event.clientY - this.#downY) > 6)
|
|
2787
2988
|
return;
|
|
2788
2989
|
if (!this.#places)
|
|
@@ -2813,6 +3014,21 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2813
3014
|
* the middle of the view (`goTo`), unless it already is, so a press never sends the view anywhere else.
|
|
2814
3015
|
*/
|
|
2815
3016
|
#press(id) {
|
|
3017
|
+
if (this.#catalogueMoon(id) !== undefined) {
|
|
3018
|
+
// a moon of the catalogue is no body of the package: the press says which one, in the body event and in an event of its own; the first press selects it, and a second makes its planet the middle of the view
|
|
3019
|
+
const detail = this.#moonDetail(id);
|
|
3020
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail, bubbles: true, composed: true }));
|
|
3021
|
+
this.dispatchEvent(new CustomEvent("wakusei-moon-click", { detail, bubbles: true, composed: true }));
|
|
3022
|
+
if (this.#selected === id) {
|
|
3023
|
+
const host = detail.host;
|
|
3024
|
+
if (canCentre(host) && this.#model.focus !== host)
|
|
3025
|
+
this.goTo(host);
|
|
3026
|
+
return;
|
|
3027
|
+
}
|
|
3028
|
+
this.#selected = id;
|
|
3029
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail, bubbles: true, composed: true }));
|
|
3030
|
+
return;
|
|
3031
|
+
}
|
|
2816
3032
|
// the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
|
|
2817
3033
|
if (this.#isAsteroid(id)) {
|
|
2818
3034
|
// an asteroid is no body of the package: the press says which one, in the body event and in an event of its own, and goes nowhere
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type SpaceDwarf, type SpacePlanet } from "./frame.ts";
|
|
2
|
+
import type { MoonColorChoice, MoonSource } from "./all-moons.ts";
|
|
3
|
+
/** What a planet shows: its `major` moons (the ones the view draws in full: today's default) or `all` of them (every moon of the catalogue as a pressable dot with its orbit). */
|
|
4
|
+
export type MoonsChoice = "major" | "all";
|
|
5
|
+
/** The planets and dwarf planets that can show every moon: those the view places. */
|
|
6
|
+
export declare const MOON_HOSTS: readonly (SpacePlanet | SpaceDwarf)[];
|
|
7
|
+
/** `moons="all"` is all; anything else is the major moons. */
|
|
8
|
+
export declare const readMoonsChoice: (value: string | null | undefined) => MoonsChoice;
|
|
9
|
+
/** What `moon-colors` says: `direction`, else `group`. */
|
|
10
|
+
export declare const readMoonColors: (value: string | null | undefined) => MoonColorChoice;
|
|
11
|
+
/** The per-planet choices of `moons-of` (`"jupiter=all saturn=major"`, spaces or commas between): a planet the view does not place, or a choice that is neither word, is left out. */
|
|
12
|
+
export declare function readMoonsOf(text: string | null | undefined): Partial<Record<string, MoonsChoice>>;
|
|
13
|
+
/** The planets showing every moon: each one's own choice, else the global one. */
|
|
14
|
+
export declare function hostsShowingAll(global: MoonsChoice, own: Readonly<Partial<Record<string, MoonsChoice>>>): ReadonlySet<string>;
|
|
15
|
+
/** The prefix of a moon of the catalogue's key in the view: the catalogue's `io` or `dia` would meet a body's id, so the view keeps its own names for them apart by it. A page never sees it: events say the plain id. */
|
|
16
|
+
export declare const CATALOGUE_MOON_PREFIX = "moon:";
|
|
17
|
+
/** The view's key of a moon of the catalogue. */
|
|
18
|
+
export declare const catalogueMoonKey: (id: string) => string;
|
|
19
|
+
/** The catalogue's id from the view's key, or `undefined` for a key that is not a moon of the catalogue's. */
|
|
20
|
+
export declare const catalogueMoonIdOf: (key: string) => string | undefined;
|
|
21
|
+
/** The catalogue module's parts the source is made from. */
|
|
22
|
+
type CatalogueModule = Pick<typeof import("../moon-catalogue.ts"), "MOON_CATALOGUE" | "catalogueMoonPosition" | "catalogueMoonOrbit" | "moonOrbitColor">;
|
|
23
|
+
/** The catalogue as the layer's source: the moons with an orbit that go round a planet the view places. */
|
|
24
|
+
export declare function moonSourceOf(catalogue: CatalogueModule): MoonSource;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Which planets of the space view show every moon of the catalogue (`moons`, `moons-of`), and how a moon of the catalogue is keyed among the view's own names. Pure; the catalogue itself is imported by the element only when
|
|
2
|
+
// a planet is first set to `all`.
|
|
3
|
+
import { SPACE_DWARFS, SPACE_PLANETS } from "./frame.js";
|
|
4
|
+
/** The planets and dwarf planets that can show every moon: those the view places. */
|
|
5
|
+
export const MOON_HOSTS = [...SPACE_PLANETS, ...SPACE_DWARFS];
|
|
6
|
+
/** `moons="all"` is all; anything else is the major moons. */
|
|
7
|
+
export const readMoonsChoice = (value) => (value?.trim().toLowerCase() === "all" ? "all" : "major");
|
|
8
|
+
/** What `moon-colors` says: `direction`, else `group`. */
|
|
9
|
+
export const readMoonColors = (value) => (value?.trim().toLowerCase() === "direction" ? "direction" : "group");
|
|
10
|
+
/** The per-planet choices of `moons-of` (`"jupiter=all saturn=major"`, spaces or commas between): a planet the view does not place, or a choice that is neither word, is left out. */
|
|
11
|
+
export function readMoonsOf(text) {
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const part of (text ?? "").split(/[\s,]+/)) {
|
|
14
|
+
const [host, choice] = part.split("=");
|
|
15
|
+
if (host === undefined || choice === undefined)
|
|
16
|
+
continue;
|
|
17
|
+
const id = host.trim().toLowerCase();
|
|
18
|
+
const word = choice.trim().toLowerCase();
|
|
19
|
+
if (MOON_HOSTS.includes(id) && (word === "all" || word === "major"))
|
|
20
|
+
out[id] = word;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
/** The planets showing every moon: each one's own choice, else the global one. */
|
|
25
|
+
export function hostsShowingAll(global, own) {
|
|
26
|
+
return new Set(MOON_HOSTS.filter((host) => (own[host] ?? global) === "all"));
|
|
27
|
+
}
|
|
28
|
+
/** The prefix of a moon of the catalogue's key in the view: the catalogue's `io` or `dia` would meet a body's id, so the view keeps its own names for them apart by it. A page never sees it: events say the plain id. */
|
|
29
|
+
export const CATALOGUE_MOON_PREFIX = "moon:";
|
|
30
|
+
/** The view's key of a moon of the catalogue. */
|
|
31
|
+
export const catalogueMoonKey = (id) => CATALOGUE_MOON_PREFIX + id;
|
|
32
|
+
/** The catalogue's id from the view's key, or `undefined` for a key that is not a moon of the catalogue's. */
|
|
33
|
+
export const catalogueMoonIdOf = (key) => (key.startsWith(CATALOGUE_MOON_PREFIX) ? key.slice(CATALOGUE_MOON_PREFIX.length) : undefined);
|
|
34
|
+
/** The catalogue as the layer's source: the moons with an orbit that go round a planet the view places. */
|
|
35
|
+
export function moonSourceOf(catalogue) {
|
|
36
|
+
const moons = catalogue.MOON_CATALOGUE.filter((m) => m.orbit !== null && MOON_HOSTS.includes(m.host));
|
|
37
|
+
const byId = new Map(moons.map((m) => [m.id, m]));
|
|
38
|
+
return {
|
|
39
|
+
moons: moons.map((m) => ({ id: m.id, label: m.label, ja: m.ja, host: m.host, full: m.full, colors: { group: catalogue.moonOrbitColor(m, "group"), direction: catalogue.moonOrbitColor(m, "direction") } })),
|
|
40
|
+
position: (moon, ms) => catalogue.catalogueMoonPosition(byId.get(moon.id), ms),
|
|
41
|
+
orbit: (moon, ms, points) => catalogue.catalogueMoonOrbit(byId.get(moon.id), ms, points),
|
|
42
|
+
};
|
|
43
|
+
}
|