@johnmorrisdotca/chikyu-earth 0.36.0 → 0.38.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 (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/NOTICE.md +6 -1
  3. package/README.md +1 -1
  4. package/dist/catalogue/index.d.ts +1 -0
  5. package/dist/catalogue/index.js +3 -2
  6. package/dist/catalogue/pack.js +3 -0
  7. package/dist/cities/host.js +38 -8
  8. package/dist/markers/place-layer.d.ts +12 -1
  9. package/dist/markers/place-layer.js +88 -18
  10. package/dist/markers/place-sprites.d.ts +5 -0
  11. package/dist/markers/place-sprites.js +8 -0
  12. package/dist/paint/buffer.d.ts +53 -0
  13. package/dist/paint/buffer.js +238 -0
  14. package/dist/paint/math.d.ts +24 -0
  15. package/dist/paint/math.js +94 -0
  16. package/dist/paint/texture.d.ts +24 -0
  17. package/dist/paint/texture.js +33 -0
  18. package/dist/realistic/earth.d.ts +9 -0
  19. package/dist/realistic/earth.js +20 -11
  20. package/dist/realistic/element.d.ts +36 -3
  21. package/dist/realistic/element.js +82 -14
  22. package/dist/realistic/shaders.js +13 -0
  23. package/dist/realistic/textures.d.ts +2 -0
  24. package/dist/satellites/index.d.ts +1 -0
  25. package/dist/satellites/index.js +1 -0
  26. package/dist/satellites/limits.d.ts +1 -1
  27. package/dist/satellites/limits.js +1 -1
  28. package/dist/satellites/owners.d.ts +26 -0
  29. package/dist/satellites/owners.js +164 -0
  30. package/dist/satellites/source.js +3 -0
  31. package/dist/satellites/track.d.ts +5 -0
  32. package/dist/satellites/track.js +146 -3
  33. package/dist/satellites/types.d.ts +22 -1
  34. package/dist/space/element.d.ts +56 -6
  35. package/dist/space/element.js +171 -16
  36. package/dist/space/index.d.ts +1 -1
  37. package/dist/space/index.js +1 -1
  38. package/dist/space/ride.d.ts +42 -0
  39. package/dist/space/ride.js +45 -3
  40. package/dist/space/satellite-layer.d.ts +32 -2
  41. package/dist/space/satellite-layer.js +178 -19
  42. package/dist/space/scene.d.ts +12 -1
  43. package/dist/space/scene.js +27 -16
  44. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.38.0 - 2026-11-12
6
+
7
+ - **Paint a satellite's path on the Earth** (MODULES-1167). `paint` on `<chikyu-space>` and `<chikyu-earth-realistic>` is `{ id, length, swath }`. `id` is a NORAD catalogue number or `group:index`. `length` is `1d` (the default), `1w` or `1m` of simulated time. `swath` is `track` (the point under the satellite, the default) or `coverage` (the ground where the satellite is at least 10° above the horizon, from its height). `clearPaint()` takes the trail off. Changing the satellite clears it. The trail is one equirectangular texture on the globe. It is stamped only while simulated time moves, one upload a frame, and nothing at rest or while painting is off. A part older than `length` fades out. The date line and the poles are split so the line does not cross the map. The demo's satellite card has Paint, Clear, and 1 day, 1 week, 1 month.
8
+ - **No hitch from the once-a-second satellite pin** (MODULES-1171). Above 60 times real time each satellite's place is placed by SGP4 about once a second; that ran for the whole group in one frame (about 1.6 ms for 2,251 satellites, about 12 ms for 17,000). It is now spread over the frames: a slice of the group each frame, in proportion to the time the frame took (a thirtieth at 30 frames a second), each satellite turned from its own pin time, so every satellite is still pinned about once a second and no frame runs SGP4 for the whole group. A jump of the clock (a date typed in, a scrub) still pins the whole group at once, so a place is never turned across days. `Satellites.pin(ms, first?, count?)` takes a range (the whole group by default, as before) and keeps each satellite's pin time; an eccentric orbit, which `arc` places by SGP4 itself, is no longer pinned too. Measured on the update of a satellite group at a steady 60 and 30 frames a second, 17,000 made-up satellites, three runs each, before and after: at 600 times the 99th percentile of the update fell from 8.6 ms to 4.4 to 5.2 ms and the longest from 12.7 to 15.5 ms to 6.3 to 8.4 ms; at 3600 times from 8.4 to 9.0 ms to 5.9 to 6.1 ms and from 9.5 to 17.8 ms to 6.4 to 7.9 ms. The 90th percentile rose by about 0.5 to 0.8 ms (2.3 to 3.8 ms to 3.1 to 4.4 ms), since the same work is now done a little every frame. The demo's own catalogue, all 14 groups, is 4,084 satellites.
9
+ - **Place dots cost less, and a missing ring is told only when a place is left out** (MODULES-1165). The fallback circles (when the three.js parts have no `Points`) no longer ask for a compositor layer each, skip a move that did not change, and are projected once a frame. They fade at the Earth's edge and are dimmer at night, as the rings in the picture are. `stats.places.sprites` counts only the rings in the one draw call (0 in the fallback); `stats.places.dots` counts the circles drawn in the page instead. `chikyu-places-unavailable` is sent once, and only when places in sight had no room (`omitted`), not merely because `Points` is missing; its `detail.reason` names `PLACE_DOTS` and `detail.omitted` says how many places had no room. A browser test checks that `place-groups` and `placeGroups` turn the gathering off and on as each other's mirror, in both views.
10
+ - **The passes page's world map has half the points** (MODULES-807). Its 720 by 360 map drew all 10,000 points of the country outlines, more than it can show, and in Chromium drawing on a software GPU the map held up the page's frames after it opened. Each ring is now thinned in the browser to within half a map unit of the original (Douglas-Peucker, less than a pixel at the size the map is shown), and the path is written to one decimal: about 5,300 points and 58 KB, from 10,371 and 112 KB. Measured on the Mac in Chromium with SwiftShader and GPU rasterization (three opens each, the longest time with no frame after the page opened): desk 1.4, 2.2 and 0.36 s with the full outline, 0.29 s each with the thinned one, 0.16 to 0.19 s with no map at all; phone 0.43 s once with the full outline, under 0.07 s otherwise. NOTICE.md says the map is a derived drawing of Natural Earth's outlines.
11
+
12
+ ## 0.37.0 - 2026-11-12
13
+
14
+ - **A satellite's owner country as an ISO code** (MODULES-1112), for a page that puts a flag on a satellite card. `satelliteInfo` and the click event's `info` have `ownerCountry`, an ISO 3166-1 alpha-2 code (`CN`, `US`, `PK`), when the elements carry an owner code (`COUNTRY_CODE` or `OWNER`) and the owner is one country. An organisation (`ESA`, `ISS`, `ITSO`, `SES`, `GLOB`, `EUME`, `NATO`, `AB` and the like), several countries, an unknown owner, or a code the list does not give to one country (`CIS`, the former Soviet registration) has none, and the field is left off. New in `@johnmorrisdotca/chikyu-earth/satellites` and `/catalogue`: `ownerCountry(code)` and `OWNER_COUNTRIES`, every code of the catalogue's owner list, each row checked. Data only: no flag, no new dependency.
15
+ - **City names can be taken off and put back, and a font is measured once** (MODULES-1097). Removing `<chikyu-space>` or `<chikyu-earth-realistic>` while a tier of city names is still loading no longer leaves a second canvas and a second names box when it is put back: a load that arrives after the layer is gone does nothing, and neither does its error. The font used to measure the names is read again only when the style, the size or the language changes, not on every draw. A font that finishes loading after the space view has measured its body-name boxes is measured again.
16
+ - **Satellites stay on the picture when the clock runs faster than a minute a second** (MODULES-860). Above 60 times real time they were hidden, because two SGP4 samples would be too far apart to interpolate. Each satellite is now a short streak along its orbit for the stretch one frame spans: one SGP4 sample about once a second, then turned by its mean motion, on `<chikyu-space>` and `<chikyu-earth-realistic>`. `satellite-tint="orbit"` (off by default) colours them by orbit class. Dots grow as the Earth is drawn larger and shrink as it is drawn smaller, and a dark rim keeps a pale dot readable on the bright ground. `stats.satellites.placed` is how many are drawn, `segments` how many streaks, and `epochMs` the newest element set's moment. New on `Satellites`: `pin`, `arc`, `classColour` and `newestEpochMs`; `tooFast` stays true above 60 times, so a page that read it as "hidden" should read `placed` or `segments` instead. **A page that hands over its own three.js parts (`setThreeLoader`) should add `LineSegments`** for the streaks (the demo's `three-subset.ts` has it); without it the satellites above 60 times are dots alone, with one console warning, and nothing else changes. An orbit with an eccentricity of 0.02 or more (a Molniya, a transfer orbit) is placed by SGP4 itself on every frame there, because turning it at the mean motion put it kilometres off its path.
17
+ - **Face a way again while riding** (MODULES-1105). `face("ahead" | "behind" | "left" | "right" | "down" | "up")` turns the camera there in half a second (at once when the reader asked for less motion) and keeps the zoom. Ahead is along the way it goes, behind is the opposite, left and right are across that way, down is straight at the Earth and up is straight away from it. In the above view, down looks straight down at the satellite. `facing` is that way until the view is turned or tipped, and `chikyu-ride-face` is sent when it changes. Keys, while the element is focused: W, S, A, D, R and F. The arrow keys stay with the view controls. The demo has a Face row and the address keeps `face`.
18
+ - **Facing, made safe** (MODULES-1105 review): following a planet or the Moon there is no way to face, so `face()` answers `false` and nothing is told; a held key's repeats do not start the glide again; a key typed in a field inside the element, or in editable text, is left to it.
19
+
5
20
  ## 0.36.0 - 2026-11-12
6
21
 
7
22
  - **kazoku-ui 0.41.0, a dependency of this package** (`^0.38.1` to `^0.41.0`, for MacBook browser runs in CI's own Playwright image): a page that installs chikyu-earth now gets kazoku-ui 0.41. What it changes for this package's elements: in Safari a trackpad pinch over a view zooms the view and no longer the whole page (kazoku-ui 0.40.2); `<kazoku-view-controls>` writes a pace, direction or axis read from the address back to its attributes (0.40.0, 0.40.1), which matters only to a page that reads them. The elements' own attributes, events and defaults are unchanged.
package/NOTICE.md CHANGED
@@ -8,7 +8,8 @@ The country boundaries are **Natural Earth** (https://www.naturalearthdata.com),
8
8
  admin-0 countries, which Natural Earth places in the **public domain**
9
9
  (https://www.naturalearthdata.com/about/terms-of-use/). They reach this package through **chizu**
10
10
  (https://github.com/johnmorrisdotca/chizu, MIT, by John Morris), whose `world-geo` entry
11
- (`@johnmorrisdotca/chizu/world-geo`) holds them as longitude and latitude; nothing is fetched at runtime.
11
+ (`@johnmorrisdotca/chizu/world-geo`) holds them as longitude and latitude; nothing is fetched at runtime. The demo's passes page draws its small world map
12
+ from a simplified copy of the same outlines (each ring thinned in the browser to within half a map unit, about half the points): a derived drawing of the same public-domain data.
12
13
 
13
14
  ## Borders
14
15
 
@@ -93,6 +94,10 @@ terms: a snapshot with credit, never a live fetch. The catalogue (`src/satellite
93
94
 
94
95
  The same build may take a group's element sets from **Space-Track.org** (https://www.space-track.org, U.S. Space Command) when CelesTrak has left the group more than 12 hours old, at most once a day, through its API with John Morris's own account (the login is a repository secret, never in a file). The group's file and `manifest.json` say `"source": "spacetrack"` and the demo says so under the globe. The citation is **"Data from Space-Track.org (USSPACECOM)"**. Terms: the documentation page https://www.space-track.org/documentation, section "Redistribution of Basic SSA Information", read 2026-11-08: "USSPACECOM has provided express blanket approval for transfer/redistribution of basic SSA data and services accessed via www.Space-Track.org conditioned on appropriate citation." Basic SSA data are "Two-Line Elements (TLEs) and Orbital Mean-element Messages (OMMs); SATCAT; and Satellite Decay and Reentry Data." (The page needs a browser; the section was read through a page-reading tool, which returned each sentence in quoted pieces. TODO: John or a browser check of the section's wording.) The page gives no citation form, so this sentence is the package's own. The package ships none of these element sets.
95
96
 
97
+ ## Satellite owners' countries
98
+
99
+ `src/satellites/owners.ts` gives each owner code of the satellite catalogue the country it stands for, as an ISO 3166-1 alpha-2 code, or none for an organisation, several countries, an unknown owner, or a code the list does not give to one country. The codes and what each stands for were typed from CelesTrak's list of SATCAT sources (https://celestrak.org/satcat/sources.php, T.S. Kelso, read 2026-11-12, 132 codes); a code and the name of a country are facts. The two-letter codes are ISO 3166-1's, also facts. `CIS` is left unset: the list calls it "Commonwealth of Independent States (former USSR)" and does not name Russia. `ISRO` is India, that country's space agency. No flag is drawn or shipped.
100
+
96
101
  ## Meteor showers
97
102
 
98
103
  `src/data/meteor-showers.ts` (in the package, the `./meteors` entry point) is the **International Meteor Organization**'s Working List of Visual Meteor Showers: Table 5 of the *2026 Meteor Shower Calendar*, edited by Jürgen Rendtel (IMO INFO(3-25), https://www.imo.net/files/meteor-shower/cal2026.pdf, read 2026-11-10), typed by hand: each shower's code and number, dates of activity, date and solar longitude of the maximum, radiant, speed, population index and zenithal hourly rate. The table says its details "were correct according to the best information available in June 2025, with maximum dates accurate only for 2026". The Antihelion Source is left out. The Calendar states no licence or reuse terms; these are facts from a published list, credited here and in the guide, and will be removed on request. On 2026-11-11 every row was checked against the **IAU Meteor Data Center** (https://www.ta3.sk/IAUC22DB/MDC2022/, kept by the Astronomical Institute of the Slovak Academy of Sciences under Division F of the International Astronomical Union): its list of all showers and its list of established showers (`streamfulldata2026.txt` and `streamestablisheddata2026.txt`, last update 2026-11-10 20:00 UTC, read 2026-11-11). **The MDC states no licence or reuse terms**, on its pages or in its data files; the files ask, in their headers, that the shower database be cited as Jenniskens, Jopek, Janches, Hajdukova, Kokhirova and Rudawska (2020), *Planetary and Space Science* 182, 104821, and Jopek and Kanuchova (2017), *Planetary and Space Science* 143, 3-6, which is done here, in `IAU_MDC` and in the guide. What is taken is facts from a published list, credited and removed on request: each shower's IAU name, number and status, its parent body from the MDC's origin column (the 26 showers whose solutions name one; the delta-Aquariids' name two different bodies and are given none), and the check of the table's radiants and speeds against the MDC's solutions (rule and result in `src/data/meteor-iau.ts`; three rows took the MDC's figures: the April Lyrids' and alpha-Monocerotids' speeds and the eta-Eridanids' radiant). The MDC lists no maximum date and no zenithal hourly rate, so the dates and rates stay the IMO's. `test/recorded/iau-mdc-showers-2026-11-11.json` holds the MDC's solutions of the 37 showers as read, for the tests. The parent bodies agree with the ones the Calendar's own text names (Lyrids, June Bootids, Perseids, Draconids, Taurids, Leonids) and with **NASA**'s pages on the shower (Quadrantids, eta Aquariids, Orionids, Geminids; https://science.nasa.gov/solar-system/meteors-meteorites/, read 2026-11-10); the other 15 are the MDC's alone. The Japanese names are the names in use in Japan. The heights between which meteors shine (80 to 120 km) and the range of their speeds are as the American Meteor Society's FAQ gives them (https://www.amsmeteors.org/faq/, read 2026-11-10), as figures only; none of its text is copied.
package/README.md CHANGED
@@ -608,7 +608,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
608
608
 
609
609
  ## How to cite
610
610
 
611
- > Morris, J. (2026). *Chikyu Earth* (version 0.36.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
611
+ > Morris, J. (2026). *Chikyu Earth* (version 0.38.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
612
612
 
613
613
  GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
614
614
 
@@ -3,3 +3,4 @@ export { CLASS_LIMITS, GEO_ALTITUDE_KM, classOfElements, orbitClass, orbitShape,
3
3
  export { FLEETS, countFleets, fleetOf, type Fleet } from "./fleets.ts";
4
4
  export { MAX_PACKED, MAX_PACKED_BYTES, PackError, gzipBytes, packCatalogue, unpackAny, unpackCatalogue, type CatalogueRecord, type PackedCatalogue, type RadarSize } from "./pack.ts";
5
5
  export { readCatalogueRecords, type CatalogueRead } from "./omm.ts";
6
+ export { OWNER_COUNTRIES, ownerCountry } from "../satellites/owners.ts";
@@ -1,7 +1,8 @@
1
- // The Earth-orbit catalogue's pure parts (`@johnmorrisdotca/chikyu-earth/catalogue`): the class of an orbit from its elements, the kind of an object, a colour and a legend for each, the fleets, and the packed file a refresh script
2
- // writes and a page reads (up to 200,000 records, six-digit catalogue numbers held). No data is here: the elements come from a source you choose, through the data door (`packedElementsFrom`). No DOM, no dependency.
1
+ // The Earth-orbit catalogue's pure parts (`@johnmorrisdotca/chikyu-earth/catalogue`): the class of an orbit from its elements, the kind of an object, a colour and a legend for each, the fleets, the packed file a refresh script
2
+ // writes and a page reads (up to 200,000 records, six-digit catalogue numbers held), and the country of each owner code. No elements are here: they come from a source you choose, through the data door (`packedElementsFrom`). No DOM, no dependency.
3
3
  export { OBJECT_KINDS, KIND_LABELS, KIND_COLOURS, CLASS_COLOURS, CLASS_LABELS, ORBIT_CLASSES, legend, readKind } from "./kinds.js";
4
4
  export { CLASS_LIMITS, GEO_ALTITUDE_KM, classOfElements, orbitClass, orbitShape } from "./orbit.js";
5
5
  export { FLEETS, countFleets, fleetOf } from "./fleets.js";
6
6
  export { MAX_PACKED, MAX_PACKED_BYTES, PackError, gzipBytes, packCatalogue, unpackAny, unpackCatalogue } from "./pack.js";
7
7
  export { readCatalogueRecords } from "./omm.js";
8
+ export { OWNER_COUNTRIES, ownerCountry } from "../satellites/owners.js";
@@ -221,6 +221,9 @@ export function unpackCatalogue(bytes) {
221
221
  };
222
222
  if (id)
223
223
  set.OBJECT_ID = id;
224
+ const owner = part(i, 2);
225
+ if (owner)
226
+ set.COUNTRY_CODE = owner;
224
227
  return set;
225
228
  };
226
229
  const kindAt = (i) => KINDS[kind[i]] ?? "UNK";
@@ -43,10 +43,12 @@ export function createCityHost(options) {
43
43
  const pool = [];
44
44
  let max = readCityNames(options.attribute("city-names"));
45
45
  let drawnBefore = false;
46
+ /** Set in `dispose`: a tier that arrives later, or a font or language event already queued, must not attach again. */
47
+ let gone = false;
46
48
  /** The language the names were last laid out in: the page may change its language after the element was made, so it is read again at each draw. */
47
49
  let usedLang;
48
50
  const attach = () => {
49
- if (canvas)
51
+ if (gone || canvas)
50
52
  return;
51
53
  canvas = doc.createElement("canvas");
52
54
  canvas.id = "cn-canvas";
@@ -82,18 +84,26 @@ export function createCityHost(options) {
82
84
  set("--chikyu-city-halo", style.halo);
83
85
  set("--chikyu-city-halo-width", style.haloWidth);
84
86
  }
85
- /** The width of a name in the font it is drawn in: a canvas set to the layer's own font, size and weight (the page's `--chikyu-city-*` properties, or the style set), so a fallback font with wider letters is measured as it is. */
87
+ /** The width of a name in the font it is drawn in: a canvas set to the layer's own font, size and weight (the page's `--chikyu-city-*` properties, or the style set), so a fallback font with wider letters is measured as it is. The font string is read again only when the style, the size or the language changes, not on every draw. */
86
88
  let ruler;
89
+ let fontKey = "";
90
+ let fontValue = "";
87
91
  const measurer = (size) => {
88
92
  if (ruler === undefined)
89
93
  ruler = doc.createElement("canvas").getContext?.("2d") ?? null;
90
94
  const context = ruler;
91
95
  if (!context || typeof context.measureText !== "function")
92
96
  return undefined;
93
- const host = root.host ? getComputedStyle(root.host) : undefined;
94
- const family = style.font ?? (host?.getPropertyValue("--chikyu-city-font").trim() || "system-ui, -apple-system, 'Segoe UI', sans-serif");
95
- const weight = style.weight ?? (host?.getPropertyValue("--chikyu-city-weight").trim() || 500);
96
- context.font = `${weight} ${size}px ${family}`;
97
+ const lang = options.language();
98
+ const key = `${style.font ?? ""}\0${style.weight ?? ""}\0${size}\0${lang}`;
99
+ if (key !== fontKey) {
100
+ fontKey = key;
101
+ const host = root.host ? getComputedStyle(root.host) : undefined;
102
+ const family = style.font ?? (host?.getPropertyValue("--chikyu-city-font").trim() || "system-ui, -apple-system, 'Segoe UI', sans-serif");
103
+ const weight = style.weight ?? (host?.getPropertyValue("--chikyu-city-weight").trim() || 500);
104
+ fontValue = `${weight} ${size}px ${family}`;
105
+ }
106
+ context.font = fontValue;
97
107
  return (text) => context.measureText(text).width;
98
108
  };
99
109
  /** The cities of the tiers wanted that have arrived, the highest rank first; made again only when the tiers or the lists change. */
@@ -114,15 +124,23 @@ export function createCityHost(options) {
114
124
  asked.add(tier);
115
125
  void load(tier)
116
126
  .then((cities) => {
127
+ if (gone)
128
+ return;
117
129
  lists.set(tier, cities);
118
130
  version += 1;
119
131
  compute();
120
132
  options.onLayout?.();
121
133
  })
122
- .catch((error) => options.onError(error));
134
+ .catch((error) => {
135
+ if (gone)
136
+ return;
137
+ options.onError(error);
138
+ });
123
139
  }
124
140
  };
125
141
  function compute() {
142
+ if (gone)
143
+ return;
126
144
  const frame = last;
127
145
  if (max === null || !frame)
128
146
  return;
@@ -187,6 +205,8 @@ export function createCityHost(options) {
187
205
  }
188
206
  // the family's chooser tells the document when the page's language changes: the names are written again, though nothing else is drawn
189
207
  const onLanguage = () => queueMicrotask(() => {
208
+ if (gone)
209
+ return;
190
210
  if (max !== null && last && usedLang !== undefined && usedLang !== options.language()) {
191
211
  compute();
192
212
  options.onLayout?.();
@@ -195,7 +215,8 @@ export function createCityHost(options) {
195
215
  doc.addEventListener("kazoku-languagechange", onLanguage);
196
216
  // a font arrives: the names are measured in the font they are drawn in, so they are laid out again
197
217
  const onFonts = () => {
198
- if (max !== null && last) {
218
+ fontKey = "";
219
+ if (!gone && max !== null && last) {
199
220
  compute();
200
221
  options.onLayout?.();
201
222
  }
@@ -203,6 +224,8 @@ export function createCityHost(options) {
203
224
  doc.fonts?.addEventListener?.("loadingdone", onFonts);
204
225
  return {
205
226
  frame(next) {
227
+ if (gone)
228
+ return;
206
229
  last = next;
207
230
  if (max === null)
208
231
  return;
@@ -213,6 +236,8 @@ export function createCityHost(options) {
213
236
  compute();
214
237
  },
215
238
  refresh() {
239
+ if (gone)
240
+ return;
216
241
  max = readCityNames(options.attribute("city-names"));
217
242
  if (max === null) {
218
243
  clear();
@@ -221,6 +246,8 @@ export function createCityHost(options) {
221
246
  compute();
222
247
  },
223
248
  setStyle(next) {
249
+ if (gone)
250
+ return;
224
251
  style = { ...next };
225
252
  vars();
226
253
  compute();
@@ -236,6 +263,9 @@ export function createCityHost(options) {
236
263
  return { on: max !== null, max: max ?? 0, radius: last?.radius ?? 0, tiers: [...lists.keys()], cities: [...lists.values()].reduce((sum, list) => sum + list.length, 0), names: shown.length, renders };
237
264
  },
238
265
  dispose() {
266
+ gone = true;
267
+ last = null;
268
+ max = null;
239
269
  doc.removeEventListener("kazoku-languagechange", onLanguage);
240
270
  doc.fonts?.removeEventListener?.("loadingdone", onFonts);
241
271
  canvas?.remove();
@@ -35,6 +35,16 @@ export declare const PLACE_MARKS = 32;
35
35
  * ```
36
36
  */
37
37
  export declare const PLACE_DOTS = 600;
38
+ /**
39
+ * The page is told once, and only when places in sight had no room in the fallback circles. Missing `Points` alone is not a loss: the circles still draw, up to {@link PLACE_DOTS}. Returns null when nothing new was lost; otherwise
40
+ * the detail of `chikyu-places-unavailable`: `reason` says why and `omitted` how many places in sight had no room.
41
+ */
42
+ export declare function placesLostNotice(state: {
43
+ told: boolean;
44
+ }, omitted: number): {
45
+ reason: string;
46
+ omitted: number;
47
+ } | null;
38
48
  type Box = {
39
49
  left: number;
40
50
  top: number;
@@ -60,7 +70,7 @@ export interface PlaceLayer {
60
70
  grouping: boolean;
61
71
  /**
62
72
  * Whether the picture draws the rings that are not markers of their own (true by default). False when the three.js parts lack `Points`: the layer then draws those rings itself as small circles in the page, up to {@link PLACE_DOTS},
63
- * and `stats.omitted` counts the places in sight it had no room for.
73
+ * fading at the Earth's edge and dimmer at night, and `stats.omitted` counts the places in sight it had no room for. `stats.sprites` counts only the rings the picture draws; `stats.dots` counts the circles.
64
74
  */
65
75
  ringsInPicture: boolean;
66
76
  readonly stats: {
@@ -73,6 +83,7 @@ export interface PlaceLayer {
73
83
  marks: number;
74
84
  groups: number;
75
85
  sprites: number;
86
+ dots: number;
76
87
  omitted: number;
77
88
  };
78
89
  /** The boxes the names and the markers' heads take in the picture just drawn, for other names to keep clear of. */
@@ -30,7 +30,7 @@ export const PLACE_STYLE = "#places{position:absolute;inset:0;overflow:hidden;po
30
30
  ".pl-name[data-kind=satellite]{--c:#cfeaff;color:#cfeaff;font-weight:500;background:rgba(4,10,20,.5);border-color:transparent}" +
31
31
  ".pl-sat{position:absolute;left:-8px;top:-8px;width:16px;height:16px;box-sizing:border-box;border:1.2px solid #cfeaff;border-radius:50%;opacity:.85;will-change:transform}" +
32
32
  ".pl-sat[hidden]{display:none}" +
33
- ".pl-dot{position:absolute;left:0;top:0;box-sizing:border-box;border:1.5px solid var(--c);border-radius:50%;opacity:.9;will-change:transform}" +
33
+ ".pl-dot{position:absolute;left:0;top:0;box-sizing:border-box;border:1.5px solid var(--c);border-radius:50%;opacity:.9}" +
34
34
  ".pl-dot[hidden]{display:none}" +
35
35
  ".pl-name.pl-measure{visibility:hidden}";
36
36
  /** The ring round a named satellite, in CSS pixels. */
@@ -57,9 +57,21 @@ export const PLACE_MARKS = 32;
57
57
  * ```
58
58
  */
59
59
  export const PLACE_DOTS = 600;
60
+ /**
61
+ * The page is told once, and only when places in sight had no room in the fallback circles. Missing `Points` alone is not a loss: the circles still draw, up to {@link PLACE_DOTS}. Returns null when nothing new was lost; otherwise
62
+ * the detail of `chikyu-places-unavailable`: `reason` says why and `omitted` how many places in sight had no room.
63
+ */
64
+ export function placesLostNotice(state, omitted) {
65
+ if (state.told || !(omitted > 0))
66
+ return null;
67
+ state.told = true;
68
+ return { reason: `the three.js parts handed over lack Points: the places' rings are drawn as small circles in the page, at most ${PLACE_DOTS}, and ${omitted} places in sight had no room (stats.places.omitted counts them)`, omitted };
69
+ }
60
70
  /** The most names a group's count gets. */
61
71
  const GROUP_NAMES = 24;
62
72
  const EDGE = 0.02;
73
+ /** How far past the edge a ring fades in, the same span the picture's rings use. */
74
+ const LIMB = 0.12;
63
75
  const MARGIN = 60;
64
76
  const RING = { here: 9, favourite: 6 };
65
77
  const FALLBACK = { here: "#7df9ff", favourite: "#ffd27a" };
@@ -78,11 +90,15 @@ export function createPlaceLayer(box) {
78
90
  const marks = [];
79
91
  const names = [];
80
92
  const sizes = new Map();
81
- const stats = { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0, marks: 0, groups: 0, sprites: 0, omitted: 0 };
93
+ const stats = { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0, marks: 0, groups: 0, sprites: 0, dots: 0, omitted: 0 };
82
94
  let grouping = true;
83
95
  let ringsInPicture = true;
84
96
  // the small circles that stand in for the picture's rings when it cannot draw them: the element, and what it was last written with
85
97
  const dots = [];
98
+ // where each group fell on the screen the last time the picture could not draw the rings: x, y, facing. Grown when the groups grow, never one array a frame.
99
+ let projected = new Float32Array(0);
100
+ // the ring sizes written last, so a frame that changes none does not copy the buffer
101
+ let shapeHeld = new Float32Array(0);
86
102
  let boxes = [];
87
103
  const rings = [];
88
104
  const measures = [];
@@ -192,14 +208,28 @@ export function createPlaceLayer(box) {
192
208
  name.hidden = false;
193
209
  name.style.transform = `translate(${Math.round(left)}px,${Math.round(top)}px)`;
194
210
  };
195
- // a small circle standing in for a ring the picture cannot draw: `fill` is how much of it is solid (a group of several)
196
- const showDot = (i, x, y, r, fill, color) => {
211
+ const unitOf = (lon, lat) => {
212
+ const lonR = (lon * Math.PI) / 180;
213
+ const latR = (lat * Math.PI) / 180;
214
+ return [Math.cos(latR) * Math.sin(lonR), Math.sin(latR), Math.cos(latR) * Math.cos(lonR)];
215
+ };
216
+ // the same night as the picture's rings: 0 in daylight, 1 once the Sun is about 7 degrees below the horizon
217
+ const nightAt = (lon, lat, sun) => {
218
+ if (!sun)
219
+ return 0;
220
+ const u = unitOf(lon, lat);
221
+ const cosine = u[0] * sun[0] + u[1] * sun[1] + u[2] * sun[2];
222
+ const k = Math.max(0, Math.min(1, (0.05 - cosine) / 0.17));
223
+ return k * k * (3 - 2 * k);
224
+ };
225
+ // a small circle standing in for a ring the picture cannot draw: `fill` is how much of it is solid (a group of several). A place that has not moved is left as it was.
226
+ const showDot = (i, x, y, r, fill, color, facing, night) => {
197
227
  let dot = dots[i];
198
228
  if (!dot) {
199
229
  const root = doc.createElement("i");
200
230
  root.className = "pl-dot";
201
231
  box.append(root);
202
- dot = { root, r: -1, color: "", fill: -1 };
232
+ dot = { root, r: -1, color: "", fill: -1, x: "", y: "", opacity: "" };
203
233
  dots[i] = dot;
204
234
  }
205
235
  if (dot.r !== r) {
@@ -219,7 +249,23 @@ export function createPlaceLayer(box) {
219
249
  }
220
250
  if (dot.root.hidden)
221
251
  dot.root.hidden = false;
222
- dot.root.style.transform = `translate(${x.toFixed(1)}px,${y.toFixed(1)}px)`;
252
+ const xText = x.toFixed(1);
253
+ const yText = y.toFixed(1);
254
+ if (dot.x !== xText || dot.y !== yText) {
255
+ dot.x = xText;
256
+ dot.y = yText;
257
+ dot.root.style.transform = `translate(${xText}px,${yText}px)`;
258
+ }
259
+ const opacity = (Math.min(1, (facing - EDGE) / LIMB) * (1 - 0.5 * night) * 0.9).toFixed(2);
260
+ if (dot.opacity !== opacity) {
261
+ dot.opacity = opacity;
262
+ dot.root.style.opacity = opacity;
263
+ }
264
+ };
265
+ const hideDots = (from) => {
266
+ for (let i = from; i < dots.length; i += 1)
267
+ if (!dots[i].root.hidden)
268
+ dots[i].root.hidden = true;
223
269
  };
224
270
  /** Gather the places again for a new list or a new cell, and write the rings' places and colours. */
225
271
  const regroup = (cell) => {
@@ -254,8 +300,7 @@ export function createPlaceLayer(box) {
254
300
  hideFrom(marks.map((m) => m.root), 0);
255
301
  hideFrom(names, 0);
256
302
  hideFrom(rings, 0);
257
- if (dots.length > 0)
258
- hideFrom(dots.map((d) => d.root), 0);
303
+ hideDots(0);
259
304
  stats.omitted = 0;
260
305
  stats.shown = 0;
261
306
  stats.labels = 0;
@@ -264,6 +309,7 @@ export function createPlaceLayer(box) {
264
309
  stats.marks = 0;
265
310
  stats.groups = 0;
266
311
  stats.sprites = 0;
312
+ stats.dots = 0;
267
313
  if (sprites && sprites.shapes.some((v) => v !== 0)) {
268
314
  sprites.shapes.fill(0);
269
315
  sprites.shapesVersion += 1;
@@ -293,7 +339,6 @@ export function createPlaceLayer(box) {
293
339
  if (value === grouping)
294
340
  return;
295
341
  grouping = value;
296
- groupedFor = null;
297
342
  },
298
343
  get ringsInPicture() {
299
344
  return ringsInPicture;
@@ -316,7 +361,12 @@ export function createPlaceLayer(box) {
316
361
  const cell = grouping ? groupCell(view.radius ?? 0) : 0;
317
362
  if (groupedFor !== places || groupedCell !== cell)
318
363
  regroup(cell);
319
- // which groups are in sight, and the places that get markers of their own: `here` first, then in the order given
364
+ // which groups are in sight, and the places that get markers of their own: `here` first, then in the order given.
365
+ // without the picture's rings the screen place is kept, so each group is projected once
366
+ const fallback = !ringsInPicture;
367
+ if (fallback && projected.length < groups.length * 3)
368
+ projected = new Float32Array(groups.length * 3);
369
+ const sunUnit = sun ? unitOf(sun.lon, sun.lat) : null;
320
370
  const inSight = [];
321
371
  let shown = 0;
322
372
  for (const [g, group] of groups.entries()) {
@@ -324,6 +374,11 @@ export function createPlaceLayer(box) {
324
374
  continue;
325
375
  if (point.x < -MARGIN || point.y < -MARGIN || point.x > view.width + MARGIN || point.y > view.height + MARGIN)
326
376
  continue;
377
+ if (fallback) {
378
+ projected[g * 3] = point.x;
379
+ projected[g * 3 + 1] = point.y;
380
+ projected[g * 3 + 2] = point.facing;
381
+ }
327
382
  inSight.push(g);
328
383
  shown += group.members.length;
329
384
  }
@@ -383,8 +438,13 @@ export function createPlaceLayer(box) {
383
438
  let omitted = 0;
384
439
  if (sprites) {
385
440
  const shapes = sprites.shapes;
386
- const before = shapes.slice(0, groups.length * 2);
387
- shapes.fill(0, 0, groups.length * 2);
441
+ const span = groups.length * 2;
442
+ if (shapeHeld.length < span) {
443
+ const next = new Float32Array(span);
444
+ next.set(shapeHeld);
445
+ shapeHeld = next;
446
+ }
447
+ shapes.fill(0, 0, span);
388
448
  const marked = new Set(layout.shapes.map((shape) => chosen[shape.index]));
389
449
  const counts = [];
390
450
  const owners = [];
@@ -397,14 +457,18 @@ export function createPlaceLayer(box) {
397
457
  const ring = n > 1 ? Math.min(14, 6 + 2.2 * Math.log2(n)) : RING[first.kind === "here" ? "here" : "favourite"];
398
458
  shapes[g * 2] = ring;
399
459
  shapes[g * 2 + 1] = n > 1 ? 0.3 : 0;
400
- if (!ringsInPicture || n > 1)
460
+ if (fallback) {
461
+ point.x = projected[g * 3];
462
+ point.y = projected[g * 3 + 1];
463
+ point.facing = projected[g * 3 + 2];
464
+ }
465
+ else if (n > 1)
401
466
  view.at(group.lon, group.lat, point);
402
467
  if (ringsInPicture)
403
468
  drawnSprites += 1;
404
469
  else if (drawnDots < PLACE_DOTS) {
405
- showDot(drawnDots, point.x, point.y, ring, n > 1 ? 0.3 : 0, sprites.colors[g]);
470
+ showDot(drawnDots, point.x, point.y, ring, n > 1 ? 0.3 : 0, sprites.colors[g], point.facing, nightAt(group.lon, group.lat, sunUnit));
406
471
  drawnDots += 1;
407
- drawnSprites += 1;
408
472
  }
409
473
  else {
410
474
  omitted += n;
@@ -421,7 +485,13 @@ export function createPlaceLayer(box) {
421
485
  }
422
486
  }
423
487
  }
424
- if (shapes.some((v, i) => v !== before[i]))
488
+ let shapesChanged = false;
489
+ for (let i = 0; i < span; i += 1) {
490
+ if (shapes[i] !== shapeHeld[i])
491
+ shapesChanged = true;
492
+ shapeHeld[i] = shapes[i];
493
+ }
494
+ if (shapesChanged)
425
495
  sprites.shapesVersion += 1;
426
496
  const placed = placeLabels(counts, view.width, view.height, GROUP_NAMES, 64, busy);
427
497
  for (const spot of placed) {
@@ -435,8 +505,7 @@ export function createPlaceLayer(box) {
435
505
  used += 1;
436
506
  }
437
507
  }
438
- if (dots.length > 0)
439
- hideFrom(dots.map((d) => d.root), drawnDots);
508
+ hideDots(drawnDots);
440
509
  stats.omitted = omitted;
441
510
  // the ringed satellites: a ring round each that can be seen, and its name where it is free of the places' names and the boxes taken
442
511
  const seen = satellites.filter((mark) => mark.visible);
@@ -480,6 +549,7 @@ export function createPlaceLayer(box) {
480
549
  stats.labels = layout.labels.length;
481
550
  stats.groups = drawnGroups;
482
551
  stats.sprites = drawnSprites;
552
+ stats.dots = drawnDots;
483
553
  stats.rings = seen.length;
484
554
  stats.satelliteNames = placed.length;
485
555
  },
@@ -28,6 +28,11 @@ export interface PlaceSprites {
28
28
  * @param sun - The direction to the Sun in the scene's axes, the uniform the Earth's own surface uses.
29
29
  * @returns The rings, or null.
30
30
  */
31
+ /** Make the place rings the first time there is something to draw. One try: without `Points` the result stays null, and a later frame does not ask again. Null data does not count as the try. True when this call made the try. */
32
+ export declare function beginPlaceSprites(state: {
33
+ sprites: PlaceSprites | null;
34
+ tried: boolean;
35
+ }, data: PlaceSpriteData | null, create: () => PlaceSprites | null): boolean;
31
36
  export declare function createPlaceSprites(three: ThreeParts, parent: THREE.Object3D, sun: {
32
37
  value: THREE.Vector3;
33
38
  }): PlaceSprites | null;
@@ -70,6 +70,14 @@ void main() {
70
70
  * @param sun - The direction to the Sun in the scene's axes, the uniform the Earth's own surface uses.
71
71
  * @returns The rings, or null.
72
72
  */
73
+ /** Make the place rings the first time there is something to draw. One try: without `Points` the result stays null, and a later frame does not ask again. Null data does not count as the try. True when this call made the try. */
74
+ export function beginPlaceSprites(state, data, create) {
75
+ if (!data || state.sprites || state.tried)
76
+ return false;
77
+ state.sprites = create();
78
+ state.tried = true;
79
+ return true;
80
+ }
73
81
  export function createPlaceSprites(three, parent, sun) {
74
82
  const Points = three.Points;
75
83
  if (!Points)
@@ -0,0 +1,53 @@
1
+ import type { Satellites } from "../satellites/types.ts";
2
+ import { type LonLat } from "./math.ts";
3
+ export type PaintLength = "1d" | "1w" | "1m";
4
+ export type PaintSwath = "track" | "coverage";
5
+ export interface PaintSpec {
6
+ /** A NORAD catalogue number, or `group:index` of a group set on the element. */
7
+ id: string;
8
+ /** How long the trail is kept, in simulated time. `1d` when left out. */
9
+ length?: PaintLength;
10
+ /** `track` paints the point under the satellite (the default). `coverage` paints where it is at least 10° above the horizon. */
11
+ swath?: PaintSwath;
12
+ }
13
+ export declare const paintLengthOf: (length: PaintLength | undefined) => PaintLength;
14
+ export declare const paintSwathOf: (swath: PaintSwath | undefined) => PaintSwath;
15
+ /** Minutes since the epoch, in 16 bits: the trail is at most a month, and 16 bits hold 45 days. */
16
+ export declare const paintMinute: (ms: number) => number;
17
+ export interface PaintState {
18
+ readonly data: Uint8Array;
19
+ readonly width: number;
20
+ readonly height: number;
21
+ /** Stamps whose alpha is set. Clear puts it back to 0. */
22
+ readonly pixels: number;
23
+ readonly on: boolean;
24
+ readonly length: PaintLength;
25
+ readonly swath: PaintSwath;
26
+ /** The id now painted, or "" when painting is off. */
27
+ readonly id: string;
28
+ /** Minutes of simulated time the shader keeps. */
29
+ readonly spanMinutes: number;
30
+ set(spec: PaintSpec | null): void;
31
+ clear(): void;
32
+ /**
33
+ * Stamp the ground crossed since the last call. `sample` is the satellite at a moment, or null when it cannot be placed.
34
+ * Returns true when `data` changed and the picture should upload it. At rest, or with painting off, it returns false.
35
+ */
36
+ step(ms: number, sample: (ms: number) => (LonLat & {
37
+ heightKm: number;
38
+ }) | null): boolean;
39
+ }
40
+ export declare function createPaintState(): PaintState;
41
+ /** The satellite `id` names, in the groups now set: a NORAD number, or `group:index`. */
42
+ export declare function findPainted(groups: Iterable<[string, {
43
+ satellites: Satellites;
44
+ }]>, id: string): {
45
+ satellites: Satellites;
46
+ index: number;
47
+ } | null;
48
+ /** The ground under the painted satellite at `ms`, or null when it cannot be placed. */
49
+ export declare function paintedGround(groups: Iterable<[string, {
50
+ satellites: Satellites;
51
+ }]>, id: string, ms: number): (LonLat & {
52
+ heightKm: number;
53
+ }) | null;