@johnmorrisdotca/chikyu-earth 0.35.0 → 0.37.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 (62) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/NOTICE.md +27 -1
  3. package/README.md +20 -2
  4. package/dist/borders/layer.d.ts +75 -0
  5. package/dist/borders/layer.js +136 -0
  6. package/dist/borders/lines.d.ts +138 -0
  7. package/dist/borders/lines.js +227 -0
  8. package/dist/catalogue/index.d.ts +1 -0
  9. package/dist/catalogue/index.js +3 -2
  10. package/dist/catalogue/pack.js +3 -0
  11. package/dist/cities/host.d.ts +9 -0
  12. package/dist/cities/host.js +51 -9
  13. package/dist/country-names/geometry.d.ts +264 -0
  14. package/dist/country-names/geometry.js +372 -0
  15. package/dist/country-names/host.d.ts +82 -0
  16. package/dist/country-names/host.js +212 -0
  17. package/dist/grid/layer.d.ts +45 -0
  18. package/dist/grid/layer.js +66 -0
  19. package/dist/grid/lines.d.ts +85 -0
  20. package/dist/grid/lines.js +113 -0
  21. package/dist/markers/go-to-place.d.ts +27 -0
  22. package/dist/markers/go-to-place.js +35 -0
  23. package/dist/markers/index.d.ts +2 -1
  24. package/dist/markers/index.js +2 -1
  25. package/dist/markers/layer.d.ts +7 -0
  26. package/dist/markers/layer.js +7 -0
  27. package/dist/markers/place-layer.d.ts +58 -7
  28. package/dist/markers/place-layer.js +326 -64
  29. package/dist/markers/place-sprites.d.ts +33 -0
  30. package/dist/markers/place-sprites.js +161 -0
  31. package/dist/markers/places.d.ts +91 -6
  32. package/dist/markers/places.js +135 -6
  33. package/dist/realistic/earth.d.ts +11 -0
  34. package/dist/realistic/earth.js +55 -1
  35. package/dist/realistic/element.d.ts +75 -6
  36. package/dist/realistic/element.js +221 -33
  37. package/dist/realistic/immersive.d.ts +7 -0
  38. package/dist/realistic/immersive.js +17 -0
  39. package/dist/realistic/index.d.ts +6 -0
  40. package/dist/realistic/index.js +3 -0
  41. package/dist/realistic/textures.d.ts +5 -0
  42. package/dist/satellites/index.d.ts +1 -0
  43. package/dist/satellites/index.js +1 -0
  44. package/dist/satellites/limits.d.ts +1 -1
  45. package/dist/satellites/limits.js +1 -1
  46. package/dist/satellites/owners.d.ts +26 -0
  47. package/dist/satellites/owners.js +164 -0
  48. package/dist/satellites/source.js +3 -0
  49. package/dist/satellites/track.d.ts +5 -0
  50. package/dist/satellites/track.js +128 -0
  51. package/dist/satellites/types.d.ts +19 -1
  52. package/dist/space/element.d.ts +111 -12
  53. package/dist/space/element.js +360 -26
  54. package/dist/space/index.d.ts +2 -2
  55. package/dist/space/index.js +1 -1
  56. package/dist/space/ride.d.ts +42 -0
  57. package/dist/space/ride.js +45 -3
  58. package/dist/space/satellite-layer.d.ts +8 -2
  59. package/dist/space/satellite-layer.js +138 -19
  60. package/dist/space/scene.d.ts +56 -6
  61. package/dist/space/scene.js +97 -15
  62. package/package.json +3 -3
@@ -3,20 +3,26 @@ import { adoptStyles } from "../adopt.js";
3
3
  import { airFor, readAirThickness } from "../realistic/air.js";
4
4
  import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "../realistic/body-label.js";
5
5
  import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
6
- import { cleanPlaces, readPlaces } from "../markers/places.js";
6
+ import { cleanPlaces, readPlaceGroups, readPlaces } from "../markers/places.js";
7
7
  import { createPlaceLayer, PLACE_STYLE, readPlaceLook } from "../markers/place-layer.js";
8
+ import { aimAt, findPlace, glideView } from "../markers/go-to-place.js";
9
+ import { subsolarPoint } from "../realistic/sun.js";
8
10
  import { SHORT_NAMES } from "../satellites/names.js";
9
11
  import { CITY_NAMES_ATTRIBUTES, CITY_NAMES_STYLE, createCityHost } from "../cities/host.js";
12
+ import { BORDER_ATTRIBUTES, readBorders } from "../borders/lines.js";
13
+ import { GRID_ATTRIBUTES, readGrid } from "../grid/lines.js";
14
+ import { COUNTRY_NAMES_ATTRIBUTES } from "../country-names/geometry.js";
15
+ import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js";
10
16
  import { createGate, frameCap } from "../realistic/gate.js";
11
17
  import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
12
18
  import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
19
+ import { IMMERSIVE_STYLE, immersiveWheel } from "../realistic/immersive.js";
13
20
  import { readMeteorStrength } from "../meteors/strength.js";
14
21
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
15
22
  import { MAX_TEXTURE } from "../realistic/tiers.js";
16
- import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
17
23
  import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
18
24
  import { MAX_ORBIT_GROUP } from "./satellite-layer.js";
19
- import { rideTiltLimits, rideTurnDegrees } from "./ride.js";
25
+ import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
20
26
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
21
27
  import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
22
28
  export { BODY_NAMES };
@@ -58,6 +64,7 @@ export function setSatellitePainter(next) {
58
64
  /** Mean radii in kilometres (IAU), for what a click tells. */
59
65
  const RADIUS_KM = { Sun: 695_700, Mercury: 2439.7, Venus: 6051.8, Earth: 6371, Moon: 1737.4, Mars: 3389.5, Jupiter: 69_911, Saturn: 58_232, Uranus: 25_362, Neptune: 24_622, Pluto: 1188.3 };
60
66
  export { setThreeLoader };
67
+ const FACE_KEYS = { w: "ahead", s: "behind", a: "left", d: "right", r: "up", f: "down" };
61
68
  /** A `light` attribute: `lit` or `boost`, else the true sun. */
62
69
  const readLight = (value) => (value === "lit" || value === "boost" ? value : "sun");
63
70
  const RAD = Math.PI / 180;
@@ -98,17 +105,25 @@ const readTime = (value) => {
98
105
  const ms = Date.parse(value);
99
106
  return Number.isFinite(ms) ? ms : "now";
100
107
  };
101
- const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top: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}.sp-sat[hidden]{display:none}${PLACE_STYLE}${SKY_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
108
+ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}${IMMERSIVE_STYLE}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top: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}.sp-sat[hidden]{display:none}${PLACE_STYLE}${SKY_STYLE}${COUNTRY_NAMES_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
102
109
  /**
103
110
  * The `<chikyu-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`, `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`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
104
111
  *
105
- * It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`.
112
+ * It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`. `immersive` is the full-screen mode: any shape of box, a plain wheel zooms and a drag anywhere turns.
113
+ *
114
+ * With a body painter that carries a `credit` (`setBodyPainter`), the credit of its pictures is written under the picture while it draws the bodies; `bodies-credit="off"` takes the line away.
106
115
  *
107
116
  * While time runs (`speed` is not 0) it sends `chikyu-timechange` with `detail: { time, running: true }`, `time` being the moment shown in milliseconds since 1970, at most four times a second however fast the picture is
108
117
  * drawn (and, with the clock at real time, as often as it steps: once a minute, or once a second with satellites or a ride on show), only while the tab is shown, and once with `running: false` when the clock holds
109
118
  * (`speed` set to 0): a page writes the date into its date box from it. It is not sent for a `time` the page sets itself. `chikyu-time` is the older event of every step the clock takes (up to thirty a second):
110
119
  * it is kept for pages that use it, but a page that shows the date wants `chikyu-timechange`.
111
120
  *
121
+ * `borders` draws the borders on the Earth's land as thin lines that turn with it, as on `<chikyu-earth-realistic>`: `countries`, `regions` (from the page's `borderData.regions`, once the Earth is
122
+ * large enough), or both with a bare attribute; `chikyu-borders-unavailable` is sent when the shapes cannot be loaded.
123
+ *
124
+ * `grid` draws the meridians and parallels on the Earth, and `country-names` names its countries, as on `<chikyu-earth-realistic>`: the names keep clear of the bodies', the places' and the
125
+ * cities' names and stay on the Earth's disc; `chikyu-country-names-unavailable` is sent when the outlines cannot be loaded.
126
+ *
112
127
  * @example
113
128
  * ```ts no-run
114
129
  * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
@@ -124,7 +139,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
124
139
  * ```
125
140
  */
126
141
  export class ChikyuSpace extends HTMLElement {
127
- static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look"];
142
+ static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "bodies-credit", "satellite-tint"];
128
143
  #model = newSpaceModel();
129
144
  #mode = "now";
130
145
  #speed = 1;
@@ -139,10 +154,18 @@ export class ChikyuSpace extends HTMLElement {
139
154
  /** The names of cities on the Earth (`city-names`), and the look of the names. */
140
155
  #cities;
141
156
  #citiesStyle = {};
157
+ /** The names of the countries on the Earth (`country-names`), and the look of the names. */
158
+ #countries;
159
+ #countriesStyle = {};
142
160
  #satNames = {};
161
+ /** A ringed satellite's name, by `group:index`, for `#satLabelLang`. The name does not depend on the moment, so a frame reads it and does not propagate the orbit again. */
162
+ #satLabelCache = new Map();
163
+ /** `en` or `ja` once that language has been read for the cached names; empty until the first read. */
164
+ #satLabelLang = "";
143
165
  /** The ringed satellites of the last draw (`labelSatellites`), laid out with the places. */
144
166
  #marks = [];
145
167
  #airNote;
168
+ #bodiesNote;
146
169
  #gate;
147
170
  #taken;
148
171
  #stage;
@@ -161,14 +184,22 @@ export class ChikyuSpace extends HTMLElement {
161
184
  #tiers = {};
162
185
  #hands;
163
186
  #ridden = {};
187
+ #toldFacing = null;
164
188
  #placeLayer;
165
189
  #placeList = [];
190
+ /** Counts the turns to a place, so a new one stops the one before. */
191
+ #placeGlide = 0;
166
192
  #nameBoxes = new Map();
193
+ /** A font that arrives after the names were measured: the boxes are read again on the next layout. The satellites' marks are not touched, or the page would be told again about each one already in view. */
194
+ #onFonts = () => {
195
+ this.#nameBoxes.clear();
196
+ };
167
197
  /** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
168
198
  get controller() {
169
199
  return this.#hands?.controller;
170
200
  }
171
201
  connectedCallback() {
202
+ document.fonts?.addEventListener?.("loadingdone", this.#onFonts);
172
203
  this.#model.centre = readCentre(this.getAttribute("center")) ?? this.#model.centre;
173
204
  this.#mode = readTime(this.getAttribute("time"));
174
205
  this.#model.time = this.#mode === "now" ? Date.now() : this.#mode;
@@ -188,12 +219,13 @@ export class ChikyuSpace extends HTMLElement {
188
219
  if (!this.hasAttribute("aria-label"))
189
220
  this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
190
221
  const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
191
- root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p></div>`;
222
+ root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p><p id="bodies-note" hidden></p></div>`;
192
223
  adoptStyles(root, STYLE, this.nonce);
193
224
  this.#stage = root.getElementById("stage");
194
225
  this.#labelBox = root.getElementById("labels");
195
226
  this.#note = root.getElementById("meteor-note");
196
227
  this.#airNote = root.getElementById("air-note");
228
+ this.#bodiesNote = root.getElementById("bodies-note");
197
229
  this.#sky = createSkyHost({
198
230
  root,
199
231
  attribute: (name) => this.getAttribute(name),
@@ -207,16 +239,30 @@ export class ChikyuSpace extends HTMLElement {
207
239
  this.#placeList = readPlaces(this.getAttribute("places"));
208
240
  this.#placeLayer.set(this.#placeList);
209
241
  this.#placeLayer.look = readPlaceLook(this.getAttribute("places-look"));
242
+ this.#placeLayer.grouping = readPlaceGroups(this.getAttribute("place-groups"));
210
243
  this.#cities = createCityHost({
211
244
  root,
212
245
  attribute: (name) => this.getAttribute(name),
213
246
  language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
214
247
  onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-city-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
248
+ onLayout: () => this.#countryFrame(),
215
249
  });
216
250
  this.#cities.setStyle(this.#citiesStyle);
251
+ Object.assign(this.#model.borders, readBorders(this.getAttribute("borders")));
252
+ this.#model.borders.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-borders-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
253
+ this.#model.grid.on = readGrid(this.getAttribute("grid"));
254
+ this.#model.grid.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-grid-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
255
+ this.#countries = createCountryHost({
256
+ root,
257
+ attribute: (name) => this.getAttribute(name),
258
+ language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
259
+ onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-country-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
260
+ });
261
+ this.#countries.setStyle(this.#countriesStyle);
217
262
  this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
218
263
  this.#applyBodyLabel();
219
264
  setAirNote(this.#airNote, this, this.#model.airThickness);
265
+ this.#showBodiesCredit();
220
266
  this.#played = false;
221
267
  this.#model.meteors.on = this.#meteorsAsked();
222
268
  this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
@@ -246,12 +292,14 @@ export class ChikyuSpace extends HTMLElement {
246
292
  onLabels: (places) => this.#placeLabels(places),
247
293
  onSky: (sky) => this.#sky?.frame(sky),
248
294
  onPlaces: (view) => this.#drawPlaces(view),
249
- onCities: (frame) => this.#cities?.frame(frame),
295
+ placeSprites: () => this.#placeLayer?.sprites ?? null,
296
+ onCities: (frame) => this.#nameFrame(frame),
250
297
  onLabelError: (error) => this.dispatchEvent(new CustomEvent("chikyu-body-label-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
251
298
  onSatelliteMarks: (marks) => this.#showMarks(marks),
252
299
  onSelected: (place) => this.#placeChosen(place),
253
300
  onMoving: () => this.#gate?.request(),
254
301
  onRideLost: () => this.#rideLost(),
302
+ onPlaceRings: (drawn) => this.#ringsDrawn(drawn),
255
303
  onSatellitesError: (error) => this.dispatchEvent(new CustomEvent("chikyu-satellites-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
256
304
  ...(painter ? { painter } : {}),
257
305
  satellitePainter: () => satellitePainter,
@@ -270,15 +318,26 @@ export class ChikyuSpace extends HTMLElement {
270
318
  this.#last = performance.now();
271
319
  this.#schedule();
272
320
  this.addEventListener("pointerdown", this.#down);
321
+ // before the shared hands (which hear it after this): a plain wheel in an immersive view zooms
322
+ this.addEventListener("wheel", this.#wheel, { capture: true, passive: false });
323
+ this.addEventListener("keydown", this.#faceKey);
324
+ if (!this.hasAttribute("tabindex"))
325
+ this.tabIndex = 0;
273
326
  this.#hands = carryControls(this, { initial: this.#model.view, limits: LIMITS, onChange: (state, info) => this.setView(state, info.final) });
274
327
  this.#labelBox.addEventListener("click", this.#labelClick);
275
328
  this.#labelBox.addEventListener("focusin", this.#labelFocus);
276
329
  }
277
330
  disconnectedCallback() {
331
+ document.fonts?.removeEventListener?.("loadingdone", this.#onFonts);
332
+ this.#marks = [];
333
+ this.#markSeen.clear();
334
+ this.#nameBoxes.clear();
278
335
  this.#hands?.unbind();
279
336
  this.#hands = undefined;
280
337
  this.#zoomRange(false);
281
338
  this.removeEventListener("pointerdown", this.#down);
339
+ this.removeEventListener("wheel", this.#wheel, { capture: true });
340
+ this.removeEventListener("keydown", this.#faceKey);
282
341
  window.removeEventListener("pointerup", this.#up, true);
283
342
  clearTimeout(this.#timer);
284
343
  this.#timer = undefined;
@@ -292,6 +351,8 @@ export class ChikyuSpace extends HTMLElement {
292
351
  this.#placeLayer?.dispose();
293
352
  this.#placeLayer = undefined;
294
353
  this.#cities?.dispose();
354
+ this.#countries?.dispose();
355
+ this.#countries = undefined;
295
356
  this.#cities = undefined;
296
357
  }
297
358
  attributeChangedCallback(name, _old, value) {
@@ -339,6 +400,7 @@ export class ChikyuSpace extends HTMLElement {
339
400
  this.#applyBodyLabel();
340
401
  this.#sky?.refresh();
341
402
  this.#cities?.refresh();
403
+ this.#countries?.refresh();
342
404
  }
343
405
  }
344
406
  else if (BODY_LABEL_ATTRIBUTES.includes(name))
@@ -354,10 +416,52 @@ export class ChikyuSpace extends HTMLElement {
354
416
  this.#placeLayer.look = readPlaceLook(value);
355
417
  this.#gate?.request();
356
418
  }
419
+ else if (name === "place-groups" && this.#placeLayer) {
420
+ this.#placeLayer.grouping = readPlaceGroups(value);
421
+ this.#gate?.request();
422
+ }
357
423
  else if (CITY_NAMES_ATTRIBUTES.includes(name))
358
424
  this.#cities?.refresh();
425
+ else if (name === "borders") {
426
+ Object.assign(this.#model.borders, readBorders(value));
427
+ this.#gate?.request();
428
+ }
429
+ else if (name === "grid") {
430
+ this.#model.grid.on = readGrid(value);
431
+ this.#gate?.request();
432
+ }
433
+ else if (COUNTRY_NAMES_ATTRIBUTES.includes(name))
434
+ this.#countries?.refresh();
435
+ else if (name === "satellite-tint") {
436
+ this.#model.satellites.orbitTint = value === "orbit";
437
+ this.#gate?.request();
438
+ }
359
439
  if (name === "air-thickness" || name === "air-label" || name === "lang")
360
440
  setAirNote(this.#airNote, this, this.#model.airThickness);
441
+ if (name === "bodies-credit" || name === "lang")
442
+ this.#showBodiesCredit();
443
+ }
444
+ #wheel = (event) => immersiveWheel(this, event);
445
+ /** The body painter's credit under the picture, in the element's or the page's language: shown while the painter draws the bodies (not `plain`), unless `bodies-credit` is `off`. */
446
+ #showBodiesCredit() {
447
+ const note = this.#bodiesNote;
448
+ if (!note)
449
+ return;
450
+ const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
451
+ const credit = painter?.credit?.[lang] ?? "";
452
+ note.textContent = credit;
453
+ note.lang = lang;
454
+ note.hidden = credit === "" || this.bodies === "plain" || this.getAttribute("bodies-credit") === "off";
455
+ }
456
+ /**
457
+ * True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape (the Earth fits the shorter side with its glow inside it, `earth-size`), a plain wheel zooms instead of scrolling
458
+ * the page, a drag anywhere on it turns the view, and a touch drag turns it instead of scrolling. A notch of the wheel is about 1.2 times; out far enough the Moon, the Sun and the planets come into view.
459
+ */
460
+ get immersive() {
461
+ return this.hasAttribute("immersive");
462
+ }
463
+ set immersive(value) {
464
+ this.toggleAttribute("immersive", value);
361
465
  }
362
466
  #meteorsAsked() {
363
467
  return this.hasAttribute("meteors") && this.getAttribute("meteors") !== "off";
@@ -459,10 +563,12 @@ export class ChikyuSpace extends HTMLElement {
459
563
  this.#sky?.setKeepClear(this.#keepClear);
460
564
  }
461
565
  /**
462
- * Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
463
- * (the default: quieter). Each stands up out of the ground, turns with the Earth, is hidden on its far side and keeps its size in pixels at any zoom. Names go at the top, `here` first, and never overlap
464
- * one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where it likes. Setting the property writes
465
- * the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked for less motion.
566
+ * Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind, color }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
567
+ * (the default: quieter), and `color` an optional CSS colour of its own. The first `PLACE_MARKS` in sight (`here` first, then in the order given) stand up out of the ground with their names; every other place
568
+ * is a ring on the ground, all of them one draw call, and places that crowd are gathered into one ring with their count. They turn with the Earth, are hidden on its far side, are dimmer on its night side
569
+ * and keep their size in pixels at any zoom. Names never overlap one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places
570
+ * over and keeps them where it likes. Setting the property writes the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight
571
+ * and for a reader who asked for less motion.
466
572
  */
467
573
  get places() {
468
574
  return this.#placeList.map((place) => ({ ...place }));
@@ -474,6 +580,54 @@ export class ChikyuSpace extends HTMLElement {
474
580
  else
475
581
  this.setAttribute("places", JSON.stringify(clean));
476
582
  }
583
+ /**
584
+ * Turn the view so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom stays.
585
+ * The place is named by its `id`, or by its label in any case. The camera must be looking at the Earth: while it rides along or looks at another body nothing moves. The tilt is held to 90 degrees either
586
+ * way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows.
587
+ *
588
+ * @param text - The place's id or label.
589
+ * @param options - `smooth` (true by default).
590
+ * @returns The place, once the turn has started; `undefined` when there is no such place or the camera is not looking at the Earth.
591
+ */
592
+ async goToPlace(text, options = {}) {
593
+ const place = findPlace(this.#placeList, text);
594
+ const base = this.#model.lookBase;
595
+ if (!place || !base || this.#model.ride)
596
+ return undefined;
597
+ const controls = this.#controls();
598
+ const from = { yaw: this.#model.view.yaw, tilt: this.#model.view.tilt };
599
+ const to = aimAt(base, place, from);
600
+ const glide = (this.#placeGlide += 1);
601
+ const set = (yaw, tilt, final) => {
602
+ if (controls)
603
+ controls.set({ yaw, tilt, zoom: this.#model.view.zoom }, final, "place");
604
+ else
605
+ this.setView({ yaw, tilt, zoom: this.#model.view.zoom }, final);
606
+ };
607
+ glideView(set, from, to, options.smooth !== false && !prefersLessMotion() && this.#view?.live === true, () => glide === this.#placeGlide && this.isConnected);
608
+ return { ...place };
609
+ }
610
+ /**
611
+ * Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
612
+ */
613
+ get placeGroups() {
614
+ return this.#placeLayer?.grouping ?? readPlaceGroups(this.getAttribute("place-groups"));
615
+ }
616
+ set placeGroups(value) {
617
+ if (value)
618
+ this.removeAttribute("place-groups");
619
+ else
620
+ this.setAttribute("place-groups", "off");
621
+ }
622
+ /** The picture said whether it can draw the rings of the places that are not markers of their own. Without `Points` the places' layer draws them itself and the page is told once, so no place is lost without a word. */
623
+ #ringsDrawn(drawn) {
624
+ if (!this.#placeLayer || this.#placeLayer.ringsInPicture === drawn)
625
+ return;
626
+ this.#placeLayer.ringsInPicture = drawn;
627
+ if (!drawn)
628
+ this.dispatchEvent(new CustomEvent("chikyu-places-unavailable", { detail: { reason: "the three.js parts handed over lack Points: the places' rings are drawn as small circles in the page, at most 600, and stats.places.omitted counts the rest" } }));
629
+ this.#gate?.request();
630
+ }
477
631
  /** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
478
632
  get placesLook() {
479
633
  return this.#placeLayer?.look ?? readPlaceLook(this.getAttribute("places-look"));
@@ -486,6 +640,26 @@ export class ChikyuSpace extends HTMLElement {
486
640
  const layer = this.#placeLayer;
487
641
  if (!layer || (this.#placeList.length === 0 && this.#marks.length === 0 && layer.stats.shown === 0 && layer.stats.rings === 0))
488
642
  return;
643
+ layer.frame(view, this.#bodyNameBoxes(), this.#marks, this.#model.light === "lit" ? null : subsolarPoint(this.#model.time));
644
+ }
645
+ /** Tells the names of cities, then of countries, where the Earth is in the picture just drawn; the countries' names keep clear of the bodies', the places' and the cities'. */
646
+ #nameFrame(frame) {
647
+ this.#cities?.frame(frame);
648
+ this.#lastNameFrame = frame;
649
+ this.#countryFrame();
650
+ }
651
+ /** The frame the names were last laid out on. */
652
+ #lastNameFrame = null;
653
+ /** Lays the countries' names out on the last frame, clear of the bodies', the places' and the cities' names as they are now. */
654
+ #countryFrame() {
655
+ const countries = this.#countries;
656
+ if (!countries)
657
+ return;
658
+ const frame = this.#lastNameFrame;
659
+ countries.frame(frame, countries.stats.on && frame ? [...this.#bodyNameBoxes(), ...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? [])] : []);
660
+ }
661
+ /** The boxes the bodies' names take beside them in the picture just drawn. */
662
+ #bodyNameBoxes() {
489
663
  const taken = [];
490
664
  if (this.#model.labels && this.#places) {
491
665
  for (const name of BODY_NAMES) {
@@ -504,7 +678,7 @@ export class ChikyuSpace extends HTMLElement {
504
678
  taken.push({ left: at.x + Math.max(4, Math.min(at.r, 40)), top: at.y - 8, ...box });
505
679
  }
506
680
  }
507
- layer.frame(view, taken, this.#marks);
681
+ return taken;
508
682
  }
509
683
  /**
510
684
  * The look of the names of cities (`city-names`): font, size, weight, colour, the outline round the text, and the dot's colour and size. Any of them may be left out; the Earth's size, the language and the data are not set here.
@@ -516,6 +690,52 @@ export class ChikyuSpace extends HTMLElement {
516
690
  this.#citiesStyle = { ...value };
517
691
  this.#cities?.setStyle(this.#citiesStyle);
518
692
  }
693
+ /** Whether the meridians and parallels are drawn on the Earth (the attribute `grid`). Setting it writes the attribute, or takes it away. */
694
+ get grid() {
695
+ return readGrid(this.getAttribute("grid"));
696
+ }
697
+ set grid(value) {
698
+ if (value)
699
+ this.setAttribute("grid", "");
700
+ else
701
+ this.removeAttribute("grid");
702
+ }
703
+ /**
704
+ * The look of the names of countries (`country-names`): font, weight, colour, the outline round the text, and the smallest and largest text size. Any of them may be left out; the Earth's size, the
705
+ * language and the data are not set here.
706
+ */
707
+ get countryNamesStyle() {
708
+ return { ...this.#countriesStyle };
709
+ }
710
+ set countryNamesStyle(value) {
711
+ this.#countriesStyle = { ...value };
712
+ this.#countries?.setStyle(this.#countriesStyle);
713
+ }
714
+ /**
715
+ * Which borders are drawn on the Earth (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
716
+ * Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
717
+ */
718
+ get borders() {
719
+ return readBorders(this.getAttribute("borders"));
720
+ }
721
+ set borders(value) {
722
+ const words = [value.countries ? "countries" : "", value.regions ? "regions" : ""].filter(Boolean);
723
+ if (words.length === 0)
724
+ this.removeAttribute("borders");
725
+ else
726
+ this.setAttribute("borders", words.join(" "));
727
+ }
728
+ /**
729
+ * Where the borders' shapes come from (see `BorderData`): `countries` in place of chizu's `world-geo`, and `regions`, a country's regions by its code, which draws the regions; without it none are drawn.
730
+ * Set it before `borders` is switched on: shapes already loaded are kept.
731
+ */
732
+ get borderData() {
733
+ return { ...this.#model.borders.data };
734
+ }
735
+ set borderData(value) {
736
+ this.#model.borders.data = { ...value };
737
+ this.#gate?.request();
738
+ }
519
739
  /** Puts the name's settings and text right from the attributes (`body-label` and its family, `lang`). */
520
740
  #applyBodyLabel() {
521
741
  this.#model.bodyLabel.settings = readBodyLabel((name) => this.getAttribute(name));
@@ -635,6 +855,7 @@ export class ChikyuSpace extends HTMLElement {
635
855
  }
636
856
  set bodies(value) {
637
857
  this.#model.bodies = value;
858
+ this.#showBodiesCredit();
638
859
  this.#gate?.request();
639
860
  }
640
861
  /** How the Earth is lit: `sun` (true, the default), `lit` (always lit, as if by daylight from the camera's side, so a ride on the night side is never a black frame) or `boost` (the true terminator, with the night side raised). The Sun, the Moon and the planets keep their true places. */
@@ -687,6 +908,7 @@ export class ChikyuSpace extends HTMLElement {
687
908
  return;
688
909
  }
689
910
  this.#gate?.request();
911
+ this.#tellFacing();
690
912
  }
691
913
  /**
692
914
  * The controls that are driving this view: a `<kazoku-view-controls for="...">` bound to it (its hands are then the only ones and its controller holds the yaw and tilt), else the element's own hands.
@@ -742,7 +964,15 @@ export class ChikyuSpace extends HTMLElement {
742
964
  const asked = options.view ?? "from";
743
965
  // above a body is meant for a satellite: a body is followed
744
966
  const view = typeof target === "string" && (target === "Earth" || asked === "above") ? "follow" : asked;
745
- model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: options.look ?? "down", distanceKm: Math.max(100, options.distanceKm ?? 3000) };
967
+ // a body followed (a planet, the Moon, the Earth) is looked at from round it as the view turns: it has no ways to face
968
+ const faceable = !(view === "follow" && typeof target === "string");
969
+ const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
970
+ model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: face && view === "from" ? "horizon" : (options.look ?? "down"), face, distanceKm: Math.max(100, options.distanceKm ?? 3000) };
971
+ if (face) {
972
+ model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
973
+ model.rideTurn = 0;
974
+ this.#controls()?.set({ yaw: 0, tilt: 0, zoom: model.view.zoom }, true, "ride");
975
+ }
746
976
  if (typeof target === "string" && view === "follow")
747
977
  model.focus = target;
748
978
  else if (wasRiding)
@@ -756,7 +986,71 @@ export class ChikyuSpace extends HTMLElement {
756
986
  this.#schedule();
757
987
  this.#gate?.request();
758
988
  this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
989
+ this.#tellFacing();
759
990
  }
991
+ /**
992
+ * Face one way while riding: `ahead` along the way it goes, `behind`, `left` or `right` (as seen facing ahead), `down` straight at the Earth, `up` straight away from it.
993
+ * In the `above` view, `down` looks straight down at the satellite and the Earth below it. The camera glides there in half a second (at once for a reader who asked for reduced motion) and keeps the zoom.
994
+ * The facing stays pressed until the view is turned or tipped. `chikyu-ride-face` is sent with `{ face }` (`null` when it is let go). Keys, while the element is focused: W ahead, S behind, A left, D right, R up, F down. The arrow keys stay with the view controls.
995
+ *
996
+ * @param face - The way to face.
997
+ * Following a body (a planet, the Moon) there is no way to face: it returns `false`. Held keys do not repeat, and keys typed in a field or in editable text are left to it.
998
+ *
999
+ * @returns Whether the camera faces that way now (`true` too when it already did, and nothing moves).
1000
+ */
1001
+ face(face) {
1002
+ const model = this.#model;
1003
+ const ride = model.ride;
1004
+ if (!ride || !RIDE_FACES.includes(face))
1005
+ return false;
1006
+ // following a body there is no way to face: only from a body or a satellite, following a satellite, or above it
1007
+ if (ride.view === "follow" && typeof ride.target === "string")
1008
+ return false;
1009
+ // already facing that way: nothing to turn, and no glide started again
1010
+ if (this.facing === face)
1011
+ return true;
1012
+ const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
1013
+ const pose = model.pose;
1014
+ const zoom = model.view.zoom;
1015
+ model.ride = { ...ride, look: ride.view === "from" ? "horizon" : ride.look, face };
1016
+ model.view = { yaw: 0, tilt: 0, zoom };
1017
+ model.rideTurn = 0;
1018
+ this.#controls()?.set({ yaw: 0, tilt: 0, zoom }, true, "ride");
1019
+ model.rideTurn = 0;
1020
+ model.view = { yaw: 0, tilt: 0, zoom };
1021
+ model.transition = !reduced && pose.valid ? { start: performance.now(), duration: 500, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
1022
+ this.#last = performance.now();
1023
+ this.#schedule();
1024
+ this.#gate?.request();
1025
+ this.#tellFacing();
1026
+ return true;
1027
+ }
1028
+ /** The facing (`face`), while the view has not been turned or tipped from it; `null` otherwise. */
1029
+ get facing() {
1030
+ const ride = this.#model.ride;
1031
+ const view = this.#model.view;
1032
+ return ride?.face && view.yaw === 0 && view.tilt === 0 ? ride.face : null;
1033
+ }
1034
+ #tellFacing() {
1035
+ const now = this.facing;
1036
+ if (now === this.#toldFacing)
1037
+ return;
1038
+ this.#toldFacing = now;
1039
+ this.dispatchEvent(new CustomEvent("chikyu-ride-face", { detail: { face: now } }));
1040
+ }
1041
+ /** W ahead, S behind, A left, D right, R up, F down, while this element is focused and a ride is on. */
1042
+ #faceKey = (event) => {
1043
+ // a held key repeats: the first press turns, the repeats would only start the glide again and again
1044
+ if (event.ctrlKey || event.metaKey || event.altKey || event.defaultPrevented || event.repeat)
1045
+ return;
1046
+ // typing in a field anywhere on the way to this element (its own shadow root and slots included), or in editable text, is typing, not facing
1047
+ const typing = event.composedPath().some((node) => node instanceof HTMLElement && (node.matches("input, textarea, select") || node.isContentEditable));
1048
+ if (typing)
1049
+ return;
1050
+ const face = FACE_KEYS[event.key.toLowerCase()];
1051
+ if (face && this.face(face))
1052
+ event.preventDefault();
1053
+ };
760
1054
  /** From a body the zoom only narrows the field a little, so the range is 0.5 to 6: the `zoom-min` and `zoom-max` attributes, unless the page set them itself. */
761
1055
  #zoomRange(from) {
762
1056
  for (const name of ["zoom-min", "zoom-max"]) {
@@ -781,6 +1075,7 @@ export class ChikyuSpace extends HTMLElement {
781
1075
  const out = [];
782
1076
  if (!satellitePainter)
783
1077
  return out;
1078
+ this.#prepareSatLabelLang();
784
1079
  for (const [group, state] of this.#model.satellites.groups) {
785
1080
  state.satellites.sets.forEach((set, index) => {
786
1081
  if (satellitePainter.has(set.NORAD_CAT_ID))
@@ -817,10 +1112,22 @@ export class ChikyuSpace extends HTMLElement {
817
1112
  this.dispatchEvent(new CustomEvent("chikyu-ride-lost", { detail: this.riding }));
818
1113
  }
819
1114
  // --- satellites ---------------------------------------------------------------------------------------------------------------------------------
1115
+ /**
1116
+ * Colour each satellite by its orbit class (low, medium, geostationary, highly elliptical, other). Off by default, so a group keeps the colour it was given. The attribute is `satellite-tint="orbit"`.
1117
+ */
1118
+ get satelliteTint() {
1119
+ return this.#model.satellites.orbitTint ? "orbit" : "off";
1120
+ }
1121
+ set satelliteTint(value) {
1122
+ if (value === "orbit")
1123
+ this.setAttribute("satellite-tint", "orbit");
1124
+ else
1125
+ this.removeAttribute("satellite-tint");
1126
+ }
820
1127
  /**
821
1128
  * Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds. Giving the name of a group
822
1129
  * that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations).
823
- * The groups are placed by SGP4 about once a second and interpolated between, and are hidden while the clock runs faster than `MAX_SATELLITE_SPEED`.
1130
+ * The groups are placed by SGP4 about once a second and interpolated between. Above `MAX_SATELLITE_SPEED` each satellite is a short streak along its orbit instead of being hidden.
824
1131
  *
825
1132
  * @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
826
1133
  * @param satellites - The group, or `null` to remove it.
@@ -843,6 +1150,8 @@ export class ChikyuSpace extends HTMLElement {
843
1150
  visible: was?.visible ?? true,
844
1151
  });
845
1152
  }
1153
+ // a group's index may now be a different satellite, so a cached name for that ref is no longer its name
1154
+ this.#satLabelCache.clear();
846
1155
  this.#last = performance.now();
847
1156
  this.#schedule();
848
1157
  this.#gate?.request();
@@ -900,6 +1209,7 @@ export class ChikyuSpace extends HTMLElement {
900
1209
  }
901
1210
  set satelliteNames(value) {
902
1211
  this.#satNames = { ...value };
1212
+ this.#satLabelCache.clear();
903
1213
  this.#gate?.request();
904
1214
  }
905
1215
  /**
@@ -909,17 +1219,37 @@ export class ChikyuSpace extends HTMLElement {
909
1219
  placeSatellite(ref) {
910
1220
  return this.#model.placeSatellite?.(ref) ?? null;
911
1221
  }
912
- /** The name beside a ringed satellite: the page's own (`satelliteNames`), else the short one in the page's language, else the name in its elements. */
1222
+ /** The page's language for a satellite name: Japanese when the nearest `lang` starts with `ja`, otherwise English. Read once per pass, not once per satellite. */
1223
+ #readSatLabelLang() {
1224
+ return (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
1225
+ }
1226
+ /** Remember the page's language and drop cached names when it changes. One `closest("[lang]")` for the pass. */
1227
+ #prepareSatLabelLang() {
1228
+ const lang = this.#readSatLabelLang();
1229
+ if (lang !== this.#satLabelLang) {
1230
+ this.#satLabelCache.clear();
1231
+ this.#satLabelLang = lang;
1232
+ }
1233
+ }
1234
+ /** The name beside a ringed satellite: the page's own (`satelliteNames`), else the short one in the page's language, else the name in its elements. Cached per ref and language: the name is constant, and reading it does not propagate the orbit again. */
913
1235
  #satelliteName(ref) {
1236
+ const key = `${ref.group}:${ref.index}`;
1237
+ const cached = this.#satLabelCache.get(key);
1238
+ if (cached !== undefined)
1239
+ return cached;
914
1240
  const info = this.satelliteInfo(ref);
915
1241
  if (!info)
916
1242
  return "";
917
- const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
918
- return this.#satNames[info.noradId] ?? SHORT_NAMES[info.noradId]?.[lang] ?? info.name;
1243
+ const lang = this.#satLabelLang === "ja" ? "ja" : "en";
1244
+ const name = this.#satNames[info.noradId] ?? SHORT_NAMES[info.noradId]?.[lang] ?? info.name;
1245
+ this.#satLabelCache.set(key, name);
1246
+ return name;
919
1247
  }
920
1248
  #markSeen = new Map();
921
1249
  /** Hands the places layer the ringed satellites of this draw, and tells the page when one comes into view or goes out of it. */
922
1250
  #showMarks(marks) {
1251
+ if (marks.length > 0)
1252
+ this.#prepareSatLabelLang();
923
1253
  this.#marks = marks.map((m) => ({ id: `${m.ref.group}:${m.ref.index}`, label: this.#satelliteName(m.ref), x: m.x, y: m.y, visible: m.visible }));
924
1254
  const now = new Map();
925
1255
  for (const m of marks) {
@@ -936,7 +1266,7 @@ export class ChikyuSpace extends HTMLElement {
936
1266
  }
937
1267
  this.#markSeen = now;
938
1268
  }
939
- /** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
1269
+ /** Facts about one satellite at the moment shown (name, number, element age, height, speed, period, and `ownerCountry` when the owner is one country); undefined if it cannot be placed then. */
940
1270
  satelliteInfo(ref) {
941
1271
  return this.#model.satellites.groups.get(ref.group)?.satellites.info(ref.index, this.#model.time);
942
1272
  }
@@ -1000,15 +1330,18 @@ export class ChikyuSpace extends HTMLElement {
1000
1330
  time: this.#model.time,
1001
1331
  lookups: this.#model.lookups,
1002
1332
  satellites: this.#satelliteStats(),
1003
- ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
1333
+ ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null, facing: this.facing },
1004
1334
  camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], quaternion: [this.#model.pose.q[0], this.#model.pose.q[1], this.#model.pose.q[2], this.#model.pose.q[3]], fov: this.#model.pose.fov },
1005
- bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons },
1335
+ bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held, moon: this.#model.painted.moon, tiles: this.#model.painted.tiles },
1006
1336
  meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
1007
1337
  bodyLabel: { on: this.#model.bodyLabel.settings !== null, text: this.#model.bodyLabel.text, ...this.#model.bodyLabel.drawn },
1008
1338
  sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, pick: null, hover: null, constellations: 0, culture: "iau", renders: 0, lang: "", stars: [] },
1009
1339
  followModel: this.#model.followModel,
1010
- places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0 }) },
1340
+ places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0, marks: 0, groups: 0, sprites: 0, omitted: 0 }) },
1011
1341
  cityNames: this.#cities?.stats ?? { on: false, max: 0, radius: 0, tiers: [], cities: 0, names: 0, renders: 0 },
1342
+ borders: { ...this.#model.borders.stats, shown: { ...this.#model.borders.stats.shown }, loaded: [...this.#model.borders.stats.loaded] },
1343
+ grid: { ...this.#model.grid.stats },
1344
+ countryNames: this.#countries?.stats ?? { on: false, max: 0, countries: 0, names: 0, renders: 0, failed: false },
1012
1345
  };
1013
1346
  }
1014
1347
  #satelliteStats() {
@@ -1021,7 +1354,10 @@ export class ChikyuSpace extends HTMLElement {
1021
1354
  lastBatchMs = Math.max(lastBatchMs, group.satellites.timing.lastBatchMs);
1022
1355
  maxBatchMs = Math.max(maxBatchMs, group.satellites.timing.maxBatchMs);
1023
1356
  }
1024
- return { groups: this.#model.satellites.groups.size, placed: drawn.placed, tooFast: drawn.tooFast, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
1357
+ let epochMs = 0;
1358
+ for (const group of this.#model.satellites.groups.values())
1359
+ epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
1360
+ return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
1025
1361
  }
1026
1362
  // --- the game clock ----------------------------------------------------------------------------------------------------------------------------
1027
1363
  #readSpeed() {
@@ -1029,10 +1365,8 @@ export class ChikyuSpace extends HTMLElement {
1029
1365
  const value = raw === null || raw === "" ? 1 : Number(raw);
1030
1366
  return Number.isFinite(value) ? value : 1;
1031
1367
  }
1032
- /** Is anything on show that moves faster than the Earth turns: a group of satellites the clock is slow enough to place? */
1368
+ /** Is anything on show that moves faster than the Earth turns: a group of satellites, including above the interpolation limit where they are drawn as streaks? */
1033
1369
  #satellitesMoving() {
1034
- if (Math.abs(this.#speed) > MAX_SATELLITE_SPEED)
1035
- return false;
1036
1370
  for (const group of this.#model.satellites.groups.values())
1037
1371
  if (group.visible && group.satellites.count > 0)
1038
1372
  return true;