@johnmorrisdotca/wakusei-planets 0.69.0 → 0.71.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/NOTICE.md +29 -1
  3. package/README.md +20 -8
  4. package/dist/bodies/moons-jupiter.js +2 -0
  5. package/dist/bodies/moons-mars.js +2 -2
  6. package/dist/bodies/moons-neptune.js +2 -1
  7. package/dist/bodies/moons-pluto.js +2 -2
  8. package/dist/bodies/moons-saturn.js +14 -2
  9. package/dist/data/discovery.js +225 -0
  10. package/dist/data/moon-catalogue.js +15 -15
  11. package/dist/data/orbits.js +15 -0
  12. package/dist/data/shapes/amalthea.d.ts +2 -0
  13. package/dist/data/shapes/amalthea.js +1 -0
  14. package/dist/data/shapes/atlas.d.ts +2 -0
  15. package/dist/data/shapes/atlas.js +1 -0
  16. package/dist/data/shapes/calypso.d.ts +2 -0
  17. package/dist/data/shapes/calypso.js +1 -0
  18. package/dist/data/shapes/daphnis.d.ts +2 -0
  19. package/dist/data/shapes/daphnis.js +1 -0
  20. package/dist/data/shapes/deimos.d.ts +2 -0
  21. package/dist/data/shapes/deimos.js +1 -0
  22. package/dist/data/shapes/epimetheus.d.ts +2 -0
  23. package/dist/data/shapes/epimetheus.js +1 -0
  24. package/dist/data/shapes/helene.d.ts +2 -0
  25. package/dist/data/shapes/helene.js +1 -0
  26. package/dist/data/shapes/hydra.d.ts +2 -0
  27. package/dist/data/shapes/hydra.js +1 -0
  28. package/dist/data/shapes/hyperion.d.ts +2 -0
  29. package/dist/data/shapes/hyperion.js +1 -0
  30. package/dist/data/shapes/janus.d.ts +2 -0
  31. package/dist/data/shapes/janus.js +1 -0
  32. package/dist/data/shapes/larissa.d.ts +2 -0
  33. package/dist/data/shapes/larissa.js +1 -0
  34. package/dist/data/shapes/nix.d.ts +2 -0
  35. package/dist/data/shapes/nix.js +1 -0
  36. package/dist/data/shapes/pan.d.ts +2 -0
  37. package/dist/data/shapes/pan.js +1 -0
  38. package/dist/data/shapes/pandora.d.ts +2 -0
  39. package/dist/data/shapes/pandora.js +1 -0
  40. package/dist/data/shapes/phobos.d.ts +2 -0
  41. package/dist/data/shapes/phobos.js +1 -0
  42. package/dist/data/shapes/phoebe.d.ts +2 -0
  43. package/dist/data/shapes/phoebe.js +1 -0
  44. package/dist/data/shapes/prometheus.d.ts +2 -0
  45. package/dist/data/shapes/prometheus.js +1 -0
  46. package/dist/data/shapes/proteus.d.ts +2 -0
  47. package/dist/data/shapes/proteus.js +1 -0
  48. package/dist/data/shapes/telesto.d.ts +2 -0
  49. package/dist/data/shapes/telesto.js +1 -0
  50. package/dist/data/shapes/thebe.d.ts +2 -0
  51. package/dist/data/shapes/thebe.js +1 -0
  52. package/dist/discovery.d.ts +1 -1
  53. package/dist/earth-places.d.ts +7 -6
  54. package/dist/earth-places.js +11 -8
  55. package/dist/facts.d.ts +21 -4
  56. package/dist/facts.js +71 -38
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.js +2 -1
  59. package/dist/moon-catalogue.d.ts +1 -1
  60. package/dist/moon-pages/data.d.ts +157 -0
  61. package/dist/moon-pages/data.js +138 -0
  62. package/dist/moon-pages/element.d.ts +82 -0
  63. package/dist/moon-pages/element.js +670 -0
  64. package/dist/moon-pages/index.d.ts +1 -0
  65. package/dist/moon-pages/index.js +2 -0
  66. package/dist/moon-pages/words.d.ts +115 -0
  67. package/dist/moon-pages/words.js +116 -0
  68. package/dist/nearest.js +2 -0
  69. package/dist/picture-credits.js +3 -0
  70. package/dist/scene/body-places.js +4 -5
  71. package/dist/scene/body.js +10 -5
  72. package/dist/scene/earth-places.d.ts +110 -2
  73. package/dist/scene/earth-places.js +149 -9
  74. package/dist/scene/glsl.d.ts +2 -2
  75. package/dist/scene/glsl.js +11 -0
  76. package/dist/scene/look.d.ts +7 -0
  77. package/dist/scene/look.js +1 -0
  78. package/dist/scene/painter.js +18 -3
  79. package/dist/scene/recipes.js +6 -2
  80. package/dist/scene/rings.js +11 -2
  81. package/dist/scene/shape.d.ts +50 -0
  82. package/dist/scene/shape.js +110 -0
  83. package/dist/shape-basis.d.ts +43 -0
  84. package/dist/shape-basis.js +45 -0
  85. package/dist/space/all-moons.d.ts +6 -1
  86. package/dist/space/all-moons.js +5 -1
  87. package/dist/space/element.d.ts +28 -3
  88. package/dist/space/element.js +169 -40
  89. package/dist/space/orbit-lines.d.ts +66 -0
  90. package/dist/space/orbit-lines.js +118 -0
  91. package/dist/space/scale.d.ts +1 -1
  92. package/dist/space/scale.js +20 -5
  93. package/dist/space/scene.d.ts +8 -0
  94. package/dist/space/scene.js +116 -9
  95. package/dist/stops.js +12 -0
  96. package/dist/surface/element.js +3 -3
  97. package/dist/surface/glsl.d.ts +2 -2
  98. package/dist/surface/glsl.js +15 -3
  99. package/dist/surface/height.d.ts +7 -0
  100. package/dist/surface/height.js +10 -0
  101. package/dist/textures/deimos-1024.webp +0 -0
  102. package/dist/textures/deimos-512.webp +0 -0
  103. package/dist/textures/phobos-1024.webp +0 -0
  104. package/dist/textures/phobos-512.webp +0 -0
  105. package/dist/textures/phoebe-1024.webp +0 -0
  106. package/dist/textures/phoebe-512.webp +0 -0
  107. package/package.json +13 -1
@@ -73,11 +73,16 @@ export interface MoonLayerDrawn {
73
73
  /** The dots and the orbits of the view. */
74
74
  export interface MoonLayer {
75
75
  update(input: MoonLayerInput): MoonLayerDrawn;
76
- /** The moons whose orbits a planet's `LineSegments` holds, in order, each with how many segments it has: segment number n of the object belongs to the moon where the running total passes n. For a hover on a line. */
76
+ /** The moons whose orbits a planet's `LineSegments` holds, in order, each with how many segments it has and its orbit's `#rrggbb`: segment number n of the object belongs to the moon where the running total passes n. For a hover on a line. */
77
77
  orbitMoons(host: string): readonly {
78
78
  id: string;
79
79
  segments: number;
80
+ colour: string;
80
81
  }[];
82
+ /** The planet's orbits, in the planet's radii round its centre, moved and scaled with the planet; `undefined` before they are built. For a hover on a line. */
83
+ orbitObject(host: string): THREE.LineSegments | undefined;
84
+ /** The opacity every orbit is drawn at, from `MOON_ORBIT_OPACITY` made fainter as the view crowds and goes out. Nothing is drawn by it. */
85
+ setOrbitOpacity(opacity: number): void;
81
86
  dispose(): void;
82
87
  }
83
88
  /** The most dots drawn: more than every known moon, with room for the years of finds to come. */
@@ -96,7 +96,7 @@ export function createMoonLayer(T, parent) {
96
96
  entry.geometry.setAttribute("position", new T.BufferAttribute(array, 3));
97
97
  entry.geometry.setAttribute("color", new T.BufferAttribute(tint, 3));
98
98
  entry.count = rings.length;
99
- entry.moons = rings.map((ring) => ({ id: ring.moon.id, segments: ring.points.length - 1 }));
99
+ entry.moons = rings.map((ring) => ({ id: ring.moon.id, segments: ring.points.length - 1, colour: ring.moon.colors[input.by] }));
100
100
  total += rings.length;
101
101
  }
102
102
  built = { source: input.source, key: orbitsKey(input), time: input.time };
@@ -152,6 +152,10 @@ export function createMoonLayer(T, parent) {
152
152
  return { dots: count, orbits: orbitsDrawn, spots };
153
153
  },
154
154
  orbitMoons: (host) => lines.get(host)?.moons ?? [],
155
+ orbitObject: (host) => lines.get(host)?.object,
156
+ setOrbitOpacity(opacity) {
157
+ lineMaterial.opacity = opacity;
158
+ },
155
159
  dispose() {
156
160
  parent.remove(dots);
157
161
  for (const entry of lines.values())
@@ -25,7 +25,7 @@ import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type Ride
25
25
  import { type PaintSpec } from "../paint/trail.ts";
26
26
  export type { PaintSpec };
27
27
  export { setPlacesLoader } from "../scene/place-layer.ts";
28
- export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceKind, type EarthPlaceLook, type EarthPlaceMark } from "../scene/earth-places.ts";
28
+ export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceClickDetail, type EarthPlaceKind, type EarthPlaceLook, type EarthPlaceMark, type EarthPlaceNamePriority, type EarthPlaceSize } from "../scene/earth-places.ts";
29
29
  export type { PlaceOnBody, PlaceOnBodyMark } from "../scene/body-places.ts";
30
30
  export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
31
31
  /** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
@@ -258,10 +258,29 @@ export declare class WakuseiSpace extends HTMLElement {
258
258
  /** How the places on the Earth are drawn (the attribute `earth-places-look`): `beam` (the default), `pin` or `ring`. Setting it writes the attribute. */
259
259
  get earthPlacesLook(): EarthPlaceLook;
260
260
  set earthPlacesLook(look: EarthPlaceLook | null);
261
- /** The markers laid on the Earth now, as the last draw left them: each place's id and kind, where its foot is in CSS pixels from the view's top left and whether its name is drawn; `omitted` counts the places in sight beyond the first `EARTH_PLACE_MARKS`. */
261
+ /**
262
+ * Which layers of places are shown (the attribute `earth-place-layers`, a JSON object of a layer's name to true or false), for `earthPlaces` and `bodyPlaces` alike: a place whose `layer` is named `false` is left out, with its name, and cannot be pressed; any other place,
263
+ * and any layer not named, is shown. The page hands over every place once and switches the layers, instead of building a list for each switch. Setting the property writes the attribute; an empty object takes it away. `earthPlacesShown.hidden` counts the places left out.
264
+ *
265
+ * @example
266
+ * ```ts no-run
267
+ * import "@johnmorrisdotca/wakusei-planets/earth-places";
268
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
269
+ *
270
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
271
+ * space.earthPlaceLayers = { harbours: false };
272
+ * space.setEarthPlaceLayer("harbours", true);
273
+ * ```
274
+ */
275
+ get earthPlaceLayers(): Record<string, boolean>;
276
+ set earthPlaceLayers(layers: Readonly<Record<string, boolean>> | null);
277
+ /** Show or hide one layer of places and leave the others as they are: `earthPlaceLayers` with that layer changed. */
278
+ setEarthPlaceLayer(name: string, shown: boolean): void;
279
+ /** The markers laid on the Earth now, as the last draw left them: each place's id and kind, where its foot is in CSS pixels from the view's top left and whether its name is drawn; `omitted` counts the places in sight beyond the first `EARTH_PLACE_MARKS`, and `hidden` the places left out because their layer is off. */
262
280
  get earthPlacesShown(): {
263
281
  marks: readonly EarthPlaceMark[];
264
282
  omitted: number;
283
+ hidden: number;
265
284
  };
266
285
  /**
267
286
  * 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:
@@ -281,10 +300,11 @@ export declare class WakuseiSpace extends HTMLElement {
281
300
  */
282
301
  get bodyPlaces(): PlaceOnBody[];
283
302
  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`. */
303
+ /** 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`, and `hidden` the places left out because their layer is off. */
285
304
  get bodyPlacesShown(): {
286
305
  marks: readonly PlaceOnBodyMark[];
287
306
  omitted: number;
307
+ hidden: number;
288
308
  };
289
309
  /**
290
310
  * 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
@@ -863,6 +883,11 @@ export declare class WakuseiSpace extends HTMLElement {
863
883
  miss: Record<string, number>;
864
884
  hidden: string[];
865
885
  faded: string[];
886
+ fade: {
887
+ crowd: number;
888
+ outness: number;
889
+ opacity: number;
890
+ };
866
891
  };
867
892
  /** 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). */
868
893
  arrows: Record<string, {
@@ -25,11 +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 { nearestLine } from "./orbit-lines.js";
28
29
  import { catalogueMoonIdOf, catalogueMoonKey, hostsShowingAll, MOON_HOSTS, moonSourceOf, readMoonColors, readMoonsChoice, readMoonsOf } from "./moon-settings.js";
29
30
  import { findPlace, PLACE_BODIES } from "../places.js";
30
31
  import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView } from "../place-marks.js";
31
32
  import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
32
- import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
33
+ import { createEarthPlaceLayer, earthPlaceClick, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, inMarkOrder, onEarthPlacesLayout, readEarthPlaceLayers, readEarthPlaceLook, shownEarthPlaces } from "../scene/earth-places.js";
33
34
  import { layBodyPlaces, bodiesOf, readBodyPlacesWith } from "../scene/body-places.js";
34
35
  import { cross, dot, length, sub, unit } from "../vec.js";
35
36
  import { createSpaceItem, FIT_DISTANCE, framedOf, heldAim, moonScaleFor, newSpaceModel, SPACE_BODIES } from "./scene.js";
@@ -37,6 +38,8 @@ import { paintLengthOf, paintSwathOf } from "../paint/trail.js";
37
38
  export { setPlacesLoader } from "../scene/place-layer.js";
38
39
  export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "../scene/earth-places.js";
39
40
  export { setThreeLoader, SPACE_BODIES };
41
+ /** The small moons that came with their real shapes (Amalthea, Thebe, Saturn's small moons, Hyperion, Phoebe, Larissa): too small to be a companion that frames a move to their planet, so a move to Jupiter still keeps Io or another of the four and takes the side it always took. */
42
+ const SMALL_MOONS = new Set(["amalthea", "thebe", "pan", "daphnis", "atlas", "prometheus", "pandora", "epimetheus", "janus", "telesto", "calypso", "helene", "hyperion", "phoebe", "larissa"]);
40
43
  /** The words the view says on itself for the scale in use. A page in another language gives its own with `scaleNames`. */
41
44
  const SCALE_WORDS = {
42
45
  en: { true: "True distances", compressed: "Distances squeezed to fit" },
@@ -111,9 +114,12 @@ const readBody = (value) => {
111
114
  * 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.
112
115
  */
113
116
  const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
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>`;
117
+ 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}}.sp-line{position:absolute;inset:0;width:100%;height:100%;overflow:hidden;pointer-events:none}.sp-line[hidden],.sp-linename[hidden]{display:none}.sp-line path{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.sp-linename{position:absolute;left:0;top:0;margin:0;padding:0;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}</style><div id="stage"></div><svg class="sp-line" part="line" aria-hidden="true" hidden><path/></svg><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><p class="sp-linename" part="line-name" hidden></p>`;
115
118
  /** 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
119
  const MOON_DOT_HIT_PX = 9;
120
+ /** How near an orbit line must be to the pointer to be lit by it, and to a press (a finger is less exact), in CSS pixels. */
121
+ const LINE_HIT_PX = 6;
122
+ const LINE_TOUCH_PX = 8;
117
123
  const orbiterLines = (value) => (value === "chosen" || value === "none" ? value : "all");
118
124
  /**
119
125
  * 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`
@@ -148,7 +154,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
148
154
  * ```
149
155
  */
150
156
  export class WakuseiSpace extends HTMLElement {
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];
157
+ 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", "earth-place-layers", "body-places", "all-moons", "moons", "moons-of", "moon-colors", "far-opacity", "transition", "pace", "frame", "pair-with", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
152
158
  #model = newSpaceModel();
153
159
  #moons = "major";
154
160
  #moonsOf = {};
@@ -174,6 +180,8 @@ export class WakuseiSpace extends HTMLElement {
174
180
  #scaleLine;
175
181
  #noteLine;
176
182
  #oortLabel;
183
+ #lineLayer;
184
+ #lineName;
177
185
  /** The belt the camera is flying through, and the point it flies on (the ride's target, to know the ride is still this one). */
178
186
  #flight = null;
179
187
  #spacing = new Map();
@@ -267,6 +275,8 @@ export class WakuseiSpace extends HTMLElement {
267
275
  this.#regionLine = root.getElementById("region");
268
276
  this.#noteLine = root.querySelector(".sp-note");
269
277
  this.#oortLabel = root.querySelector(".sp-oort");
278
+ this.#lineLayer = root.querySelector(".sp-line");
279
+ this.#lineName = root.querySelector(".sp-linename");
270
280
  this.#nameScale();
271
281
  this.#showRegion();
272
282
  this.#pool.clear();
@@ -358,6 +368,7 @@ export class WakuseiSpace extends HTMLElement {
358
368
  window.removeEventListener("pointercancel", this.#lift, true);
359
369
  if (this.#hovered !== null)
360
370
  this.#hover(null, this.#hoverBy);
371
+ this.#lineKey = null;
361
372
  clearTimeout(this.#sightTimer);
362
373
  this.#sightTimer = undefined;
363
374
  this.removeEventListener("wheel", this.#wheel, { capture: true });
@@ -461,9 +472,9 @@ export class WakuseiSpace extends HTMLElement {
461
472
  this.#relabel();
462
473
  if (name === "places" || name === "site-flags" || name === "lang" || name === "surface-names")
463
474
  this.#markSurface();
464
- if (name === "earth-places" || name === "earth-places-look")
475
+ if (name === "earth-places" || name === "earth-places-look" || name === "earth-place-layers")
465
476
  this.#askEarthPlaces();
466
- if (name === "body-places" || name === "earth-places-look")
477
+ if (name === "body-places" || name === "earth-places-look" || name === "earth-place-layers")
467
478
  this.#askBodyPlaces();
468
479
  }
469
480
  /**
@@ -549,9 +560,37 @@ export class WakuseiSpace extends HTMLElement {
549
560
  else
550
561
  this.setAttribute("earth-places-look", look);
551
562
  }
552
- /** The markers laid on the Earth now, as the last draw left them: each place's id and kind, where its foot is in CSS pixels from the view's top left and whether its name is drawn; `omitted` counts the places in sight beyond the first `EARTH_PLACE_MARKS`. */
563
+ /**
564
+ * Which layers of places are shown (the attribute `earth-place-layers`, a JSON object of a layer's name to true or false), for `earthPlaces` and `bodyPlaces` alike: a place whose `layer` is named `false` is left out, with its name, and cannot be pressed; any other place,
565
+ * and any layer not named, is shown. The page hands over every place once and switches the layers, instead of building a list for each switch. Setting the property writes the attribute; an empty object takes it away. `earthPlacesShown.hidden` counts the places left out.
566
+ *
567
+ * @example
568
+ * ```ts no-run
569
+ * import "@johnmorrisdotca/wakusei-planets/earth-places";
570
+ * import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
571
+ *
572
+ * const space = document.querySelector<WakuseiSpace>("wakusei-space")!;
573
+ * space.earthPlaceLayers = { harbours: false };
574
+ * space.setEarthPlaceLayer("harbours", true);
575
+ * ```
576
+ */
577
+ get earthPlaceLayers() {
578
+ return readEarthPlaceLayers(this.getAttribute("earth-place-layers"));
579
+ }
580
+ set earthPlaceLayers(layers) {
581
+ if (layers === null || Object.keys(layers).length === 0)
582
+ this.removeAttribute("earth-place-layers");
583
+ else
584
+ this.setAttribute("earth-place-layers", JSON.stringify(layers));
585
+ }
586
+ /** Show or hide one layer of places and leave the others as they are: `earthPlaceLayers` with that layer changed. */
587
+ setEarthPlaceLayer(name, shown) {
588
+ this.earthPlaceLayers = { ...this.earthPlaceLayers, [name]: shown };
589
+ }
590
+ /** The markers laid on the Earth now, as the last draw left them: each place's id and kind, where its foot is in CSS pixels from the view's top left and whether its name is drawn; `omitted` counts the places in sight beyond the first `EARTH_PLACE_MARKS`, and `hidden` the places left out because their layer is off. */
553
591
  get earthPlacesShown() {
554
- return { marks: this.#earthLayer?.shown ?? [], omitted: this.#earthOmitted };
592
+ const all = this.#readEarthPlaces();
593
+ return { marks: this.#earthLayer?.shown ?? [], omitted: this.#earthOmitted, hidden: all.length - shownEarthPlaces(all, this.earthPlaceLayers).length };
555
594
  }
556
595
  /**
557
596
  * 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:
@@ -578,9 +617,10 @@ export class WakuseiSpace extends HTMLElement {
578
617
  else
579
618
  this.setAttribute("body-places", JSON.stringify(list));
580
619
  }
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`. */
620
+ /** 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`, and `hidden` the places left out because their layer is off. */
582
621
  get bodyPlacesShown() {
583
- return { marks: (this.#bodyLayer?.shown ?? []), omitted: this.#bodyOmitted };
622
+ const all = this.#readBodyPlaces();
623
+ return { marks: (this.#bodyLayer?.shown ?? []), omitted: this.#bodyOmitted, hidden: all.length - shownEarthPlaces(all, this.earthPlaceLayers).length };
584
624
  }
585
625
  /**
586
626
  * 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
@@ -752,9 +792,8 @@ export class WakuseiSpace extends HTMLElement {
752
792
  return [];
753
793
  if (this.#earthList?.text === text)
754
794
  return this.#earthList.list;
755
- // the places that matter most first: where the reader is, then the rest in the order given
756
- const list = using.read(text);
757
- const ordered = [...list.filter((place) => place.kind === "here"), ...list.filter((place) => place.kind !== "here")];
795
+ // the places that matter most first: where the reader is, then the rest in the order given, then those whose name is low
796
+ const ordered = inMarkOrder(using.read(text));
758
797
  this.#earthList = { text, list: ordered };
759
798
  return ordered;
760
799
  }
@@ -785,10 +824,10 @@ export class WakuseiSpace extends HTMLElement {
785
824
  return clear();
786
825
  if (surface === null || root === null || using === undefined || !this.hasAttribute("earth-places") || !(surface.radiusPx >= EARTH_PLACES_FROM_PX))
787
826
  return clear();
788
- const places = this.#readEarthPlaces();
827
+ const places = shownEarthPlaces(this.#readEarthPlaces(), this.earthPlaceLayers);
789
828
  if (places.length === 0)
790
829
  return clear();
791
- this.#earthLayer ??= createEarthPlaceLayer(root, { press: (mark, event) => this.#pressBeam("earth", mark, event) });
830
+ this.#earthLayer ??= createEarthPlaceLayer(root, { press: (mark, event, place) => this.#pressBeam("earth", mark, event, place) });
792
831
  const layer = this.#earthLayer;
793
832
  const facts = BODIES.earth;
794
833
  const scale = [1, 1 - facts.flattening, 1];
@@ -847,10 +886,10 @@ export class WakuseiSpace extends HTMLElement {
847
886
  };
848
887
  if (root === null || using === undefined || !this.hasAttribute("body-places") || this.#bodySurfaces.length === 0)
849
888
  return clear();
850
- const places = this.#readBodyPlaces();
889
+ const places = shownEarthPlaces(this.#readBodyPlaces(), this.earthPlaceLayers);
851
890
  if (places.length === 0)
852
891
  return clear();
853
- this.#bodyLayer ??= createEarthPlaceLayer(root, { press: (mark, event) => this.#pressBeam(mark.body ?? "", mark, event) });
892
+ this.#bodyLayer ??= createEarthPlaceLayer(root, { press: (mark, event, place) => this.#pressBeam(mark.body ?? "", mark, event, place) });
854
893
  const layer = this.#bodyLayer;
855
894
  const look = this.earthPlacesLook;
856
895
  const laid = layBodyPlaces(places, this.#bodySurfaces, using, look, {
@@ -862,9 +901,14 @@ export class WakuseiSpace extends HTMLElement {
862
901
  this.#bodyOmitted = laid.omitted;
863
902
  layer.set(laid.places, laid.layout, look);
864
903
  }
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) {
904
+ /**
905
+ * A press on a beam's name or foot ring: the event `wakusei-place-click`, `{ body, id, kind, layer, label, lon, lat, x, y }` (chikyu-earth's `chikyu-place-click` with the body; `x` and `y` are the press), and `wakusei-body-place`, `{ body, id, kind, x, y }` with the mark's foot
906
+ * (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.
907
+ */
908
+ #pressBeam(body, mark, event, place) {
867
909
  this.#beamPress = event;
910
+ const box = this.getBoundingClientRect();
911
+ this.dispatchEvent(new CustomEvent("wakusei-place-click", { detail: earthPlaceClick(body, place, event.clientX - box.left, event.clientY - box.top), bubbles: true, composed: true }));
868
912
  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
913
  }
870
914
  async #loadMarks(body) {
@@ -1955,7 +1999,8 @@ export class WakuseiSpace extends HTMLElement {
1955
1999
  if (host !== undefined)
1956
2000
  add(host, 1);
1957
2001
  for (const moon of MOONS_OF[id] ?? [])
1958
- add(moon, 1);
2002
+ if (!SMALL_MOONS.has(moon))
2003
+ add(moon, 1);
1959
2004
  if (this.#arrivedFrom !== null)
1960
2005
  add(this.#arrivedFrom, 2);
1961
2006
  const here = this.#site(id).at;
@@ -2491,7 +2536,7 @@ export class WakuseiSpace extends HTMLElement {
2491
2536
  ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
2492
2537
  travelling: this.#model.travelling === null ? null : { ...this.#model.travelling },
2493
2538
  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 },
2494
- orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden], faded: [...this.#model.rings.faded] },
2539
+ orbits: { drawn: [...this.#model.rings.drawn], miss: { ...this.#model.rings.miss }, hidden: [...this.#model.rings.hidden], faded: [...this.#model.rings.faded], fade: { ...this.#model.rings.fade } },
2495
2540
  arrows: Object.fromEntries(Object.entries(this.#model.arrows).map(([id, list]) => [id, list.map((a) => ({ position: [...a.position], direction: [...a.direction] }))])),
2496
2541
  arrowPx: this.#model.arrowPx,
2497
2542
  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,
@@ -2672,6 +2717,7 @@ export class WakuseiSpace extends HTMLElement {
2672
2717
  ring.style.transform = `translate(${Math.round(places[id].x)}px,${Math.round(places[id].y)}px)`;
2673
2718
  }
2674
2719
  this.#placeArrows(places);
2720
+ this.#followLine();
2675
2721
  this.#markFar();
2676
2722
  // the names written on the body keep off the names and dots just placed
2677
2723
  this.#markSurface();
@@ -2730,7 +2776,7 @@ export class WakuseiSpace extends HTMLElement {
2730
2776
  this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: this.#moonDetail(id), bubbles: true, composed: true }));
2731
2777
  else if (id !== null && this.#isAsteroid(id))
2732
2778
  this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id: asteroidIdOf(id), name: this.#nameOf(id), kind: "small-body" }, bubbles: true, composed: true }));
2733
- else if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id)))
2779
+ else if (id !== null && (id === "roadster" || this.#model.craftIds.includes(id) || this.#model.orbiterSet?.ids.includes(id) === true))
2734
2780
  this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { id, name: this.#nameOf(id), kind: "spacecraft" }, bubbles: true, composed: true }));
2735
2781
  else if (id !== null)
2736
2782
  this.dispatchEvent(new CustomEvent("wakusei-body-hover", { detail: { ...this.bodyInfo(id), system: systemOf(id) }, bubbles: true, composed: true }));
@@ -2780,12 +2826,87 @@ export class WakuseiSpace extends HTMLElement {
2780
2826
  return;
2781
2827
  if (this.#hoverBy === "focus" && this.#hovered !== null)
2782
2828
  return;
2783
- this.#hover(this.#pointAt(event), "pointer");
2829
+ const rect = this.getBoundingClientRect();
2830
+ const x = event.clientX - rect.left;
2831
+ const y = event.clientY - rect.top;
2832
+ // a body is under the pointer before a line is; with the names off nothing is lit
2833
+ const body = this.#bodyAt(x, y);
2834
+ const line = body === null && this.#model.labels && this.#model.orbits ? this.#lineAt(x, y, false) : null;
2835
+ this.#hover(body ?? line?.id ?? null, "pointer");
2836
+ this.#lightLine(line, x, y);
2784
2837
  };
2785
2838
  #leave = (event) => {
2786
- if (event.pointerType !== "touch" && this.#hoverBy === "pointer")
2839
+ if (event.pointerType !== "touch" && this.#hoverBy === "pointer") {
2787
2840
  this.#hover(null, "pointer");
2841
+ this.#lightLine(null);
2842
+ }
2788
2843
  };
2844
+ // --- the orbit line under the pointer ----------------------------------------------------------------------------------------------------------------
2845
+ /** The key of the orbit line lit by the pointer, which is the key of its body, or null. */
2846
+ #lineKey = null;
2847
+ #lineNameWidth = 0;
2848
+ /** The orbit line nearest a point of the element, in CSS pixels, within the reach of a pointer or of a finger. Worked out when asked, never at a draw. */
2849
+ #lineAt(x, y, touch) {
2850
+ return nearestLine(this.#model.orbitPaths(), { x, y }, touch ? LINE_TOUCH_PX : LINE_HIT_PX);
2851
+ }
2852
+ /**
2853
+ * Light an orbit line: its path in full strength over the picture, in a layer of the view's own, so that lighting a line draws nothing; and the name of its body beside the pointer. `null` puts both away.
2854
+ * The lit line is kept up with the pictures that follow (`#followLine`).
2855
+ */
2856
+ #lightLine(line, x = 0, y = 0) {
2857
+ const layer = this.#lineLayer;
2858
+ const name = this.#lineName;
2859
+ if (layer === undefined || name === undefined)
2860
+ return;
2861
+ if (line === null) {
2862
+ this.#lineKey = null;
2863
+ if (!layer.hasAttribute("hidden"))
2864
+ layer.setAttribute("hidden", "");
2865
+ if (!name.hidden)
2866
+ name.hidden = true;
2867
+ return;
2868
+ }
2869
+ if (line.id !== this.#lineKey) {
2870
+ this.#lineKey = line.id;
2871
+ layer.removeAttribute("hidden");
2872
+ layer.querySelector("path").setAttribute("stroke", line.colour);
2873
+ name.textContent = this.#nameOf(line.id);
2874
+ name.hidden = false;
2875
+ this.#lineNameWidth = name.offsetWidth;
2876
+ }
2877
+ this.#drawLine(line);
2878
+ // beside the pointer, on the side that stays inside the view
2879
+ const left = x + 14 + this.#lineNameWidth > this.clientWidth ? x - 14 - this.#lineNameWidth : x + 14;
2880
+ name.style.transform = `translate(${Math.round(Math.max(0, left))}px,${Math.round(Math.max(0, y - 20))}px)`;
2881
+ }
2882
+ /** The line's points as the path of the lit layer: a gap where the line is behind the camera. */
2883
+ #drawLine(line) {
2884
+ let d = "";
2885
+ let drawing = false;
2886
+ for (let i = 0; i + 1 < line.xy.length; i += 2) {
2887
+ const x = line.xy[i];
2888
+ if (x !== x) {
2889
+ drawing = false;
2890
+ continue;
2891
+ }
2892
+ d += `${drawing ? "L" : "M"}${x.toFixed(1)} ${line.xy[i + 1].toFixed(1)}`;
2893
+ drawing = true;
2894
+ }
2895
+ this.#lineLayer.querySelector("path").setAttribute("d", d);
2896
+ }
2897
+ /** After a draw: the lit line is where the draw put it, or gone (its body's line is no longer drawn). Only the lit line is worked out. */
2898
+ #followLine() {
2899
+ if (this.#lineKey === null)
2900
+ return;
2901
+ const line = this.#model.orbitPaths(this.#lineKey)[0];
2902
+ if (line === undefined) {
2903
+ if (this.#hovered === this.#lineKey)
2904
+ this.#hover(null, "pointer");
2905
+ this.#lightLine(null);
2906
+ }
2907
+ else
2908
+ this.#drawLine(line);
2909
+ }
2789
2910
  #labelBlur = (event) => {
2790
2911
  const next = event.relatedTarget;
2791
2912
  if (this.#hoverBy === "focus" && !(next && this.#labelBox?.contains(next)))
@@ -2990,9 +3111,17 @@ export class WakuseiSpace extends HTMLElement {
2990
3111
  return;
2991
3112
  const rect = this.getBoundingClientRect();
2992
3113
  // the one hit test the hover uses: a body's disc (14 pixels at least) or, failing that, a drawn name's box, so a press on a name picks its body
2993
- const best = this.#bodyAt(event.clientX - rect.left, event.clientY - rect.top, true);
2994
- if (best)
3114
+ const x = event.clientX - rect.left;
3115
+ const y = event.clientY - rect.top;
3116
+ const best = this.#bodyAt(x, y, true);
3117
+ if (best) {
2995
3118
  this.#press(best);
3119
+ return;
3120
+ }
3121
+ // failing a body, an orbit line is a press on its body; Ctrl or Command goes there at once
3122
+ const line = this.#model.orbits ? this.#lineAt(x, y, event.pointerType === "touch") : null;
3123
+ if (line !== null)
3124
+ this.#press(line.id, event.ctrlKey || event.metaKey);
2996
3125
  };
2997
3126
  #labelClick = (event) => {
2998
3127
  const target = event.target;
@@ -3011,22 +3140,22 @@ export class WakuseiSpace extends HTMLElement {
3011
3140
  };
3012
3141
  /**
3013
3142
  * A press on a body or its name. `wakusei-body-click` tells the page every time. The first press on a body selects it (`wakusei-body-select`, for the page's card); a second press on the body that is selected makes it
3014
- * the middle of the view (`goTo`), unless it already is, so a press never sends the view anywhere else.
3143
+ * the middle of the view (`goTo`), unless it already is, so a press never sends the view anywhere else. With `teleport` (Ctrl or Command held on an orbit line) the press selects and goes there at once, without the glide.
3015
3144
  */
3016
- #press(id) {
3145
+ #press(id, teleport = false) {
3017
3146
  if (this.#catalogueMoon(id) !== undefined) {
3018
3147
  // 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
3148
  const detail = this.#moonDetail(id);
3020
3149
  this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail, bubbles: true, composed: true }));
3021
3150
  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;
3151
+ const first = this.#selected !== id;
3152
+ if (first) {
3153
+ this.#selected = id;
3154
+ this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail, bubbles: true, composed: true }));
3027
3155
  }
3028
- this.#selected = id;
3029
- this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail, bubbles: true, composed: true }));
3156
+ const host = detail.host;
3157
+ if ((!first || teleport) && canCentre(host) && this.#model.focus !== host)
3158
+ this.goTo(host, teleport ? { smooth: false } : {});
3030
3159
  return;
3031
3160
  }
3032
3161
  // the Roadster and the orbiters are no bodies of the package: a press on such a name says so and goes nowhere
@@ -3044,13 +3173,13 @@ export class WakuseiSpace extends HTMLElement {
3044
3173
  return;
3045
3174
  }
3046
3175
  this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
3047
- if (this.#selected === id) {
3048
- if (canCentre(id) && this.#model.focus !== id)
3049
- this.goTo(id);
3050
- return;
3176
+ const first = this.#selected !== id;
3177
+ if (first) {
3178
+ this.#selected = id;
3179
+ this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
3051
3180
  }
3052
- this.#selected = id;
3053
- this.dispatchEvent(new CustomEvent("wakusei-body-select", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
3181
+ if ((!first || teleport) && canCentre(id) && this.#model.focus !== id)
3182
+ this.goTo(id, teleport ? { smooth: false } : {});
3054
3183
  }
3055
3184
  #labelFocus = (event) => {
3056
3185
  const id = event.target?.dataset?.["body"];
@@ -0,0 +1,66 @@
1
+ /** Up to this many lines drawn, none is made fainter for the crowd. */
2
+ export declare const FEW_LINES = 12;
3
+ /** The least share of its opacity a line keeps, however many are drawn and however far out the view is. */
4
+ export declare const LEAST_KEEP = 0.15;
5
+ /** The view is "near" at this many radii of the body it looks at, and "far out" at the second: the share of opacity falls between them on a log scale (the Earth and the Moon from a few hundred radii, the inner planets from the Sun a thousand, the whole system from the Earth a million). */
6
+ export declare const NEAR_RADII = 30;
7
+ export declare const FAR_RADII = 30000;
8
+ /** How much of a line's opacity the farthest view takes away. */
9
+ export declare const FAR_LOSS = 0.5;
10
+ /**
11
+ * How far out the view is: 0 within `NEAR_RADII` of the body it looks at, 1 from `FAR_RADII`, and the log of the distance between.
12
+ *
13
+ * @param radii - The camera's distance from the body looked at, in that body's radii.
14
+ * @returns A number from 0 to 1.
15
+ */
16
+ export declare function outnessOf(radii: number): number;
17
+ /**
18
+ * The share of its opacity an orbit line keeps: all of it while few lines are drawn and the view is near, less as more are drawn (by the square root of how many times over `FEW_LINES` they are) and as the view goes out, never under `LEAST_KEEP`.
19
+ *
20
+ * @param input - `crowd`, how many lines are drawn, and `outness`, from `outnessOf`.
21
+ * @returns The share, from `LEAST_KEEP` to 1.
22
+ */
23
+ export declare function lineKeep(input: {
24
+ crowd: number;
25
+ outness: number;
26
+ }): number;
27
+ /**
28
+ * The opacity to draw an orbit line at.
29
+ *
30
+ * @param input - `base`, the opacity the kind of line has when it is alone, and what `lineKeep` takes.
31
+ * @returns The opacity, from `base * LEAST_KEEP` to `base`.
32
+ */
33
+ export declare const lineAlpha: (input: {
34
+ base: number;
35
+ crowd: number;
36
+ outness: number;
37
+ }) => number;
38
+ /** An orbit line as the screen shows it: `xy` is its points as x, y, x, y in CSS pixels, with NaN, NaN where the line is behind the camera (the line is broken there). */
39
+ export interface ScreenLine {
40
+ /** The view's key of the body the line is of (`moon`, `mars`, a catalogue moon's key, a craft's id). */
41
+ id: string;
42
+ /** `#rrggbb`. */
43
+ colour: string;
44
+ xy: ArrayLike<number>;
45
+ }
46
+ /**
47
+ * How many lines have some of their length in the picture: a line counts when one of its segments has the box it lies in over the picture (a long segment that only crosses a corner counts too).
48
+ *
49
+ * @param lines - The lines, in CSS pixels.
50
+ * @param width - The picture's width, in CSS pixels.
51
+ * @param height - The picture's height.
52
+ * @returns The number of lines in the picture.
53
+ */
54
+ export declare function linesInView(lines: readonly ScreenLine[], width: number, height: number): number;
55
+ /**
56
+ * The line nearest a point of the screen, within a distance. Each line is first measured by the box its points lie in (the box grown by the distance), and only a line the point is in the box of has its segments measured.
57
+ *
58
+ * @param lines - The lines on the screen.
59
+ * @param pointer - The point, in CSS pixels.
60
+ * @param tolerance - The farthest a line may be from the point, in CSS pixels.
61
+ * @returns The nearest line, or `null` when none is within the distance.
62
+ */
63
+ export declare function nearestLine(lines: readonly ScreenLine[], pointer: {
64
+ x: number;
65
+ y: number;
66
+ }, tolerance: number): ScreenLine | null;