@johnmorrisdotca/chikyu-earth 0.37.0 → 0.39.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 (43) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/NOTICE.md +2 -1
  3. package/README.md +2 -1
  4. package/dist/markers/place-layer.d.ts +12 -1
  5. package/dist/markers/place-layer.js +88 -18
  6. package/dist/markers/place-sprites.d.ts +5 -0
  7. package/dist/markers/place-sprites.js +8 -0
  8. package/dist/paint/buffer.d.ts +58 -0
  9. package/dist/paint/buffer.js +321 -0
  10. package/dist/paint/math.d.ts +24 -0
  11. package/dist/paint/math.js +94 -0
  12. package/dist/paint/texture.d.ts +34 -0
  13. package/dist/paint/texture.js +52 -0
  14. package/dist/realistic/earth.d.ts +9 -0
  15. package/dist/realistic/earth.js +19 -10
  16. package/dist/realistic/element-base.d.ts +437 -0
  17. package/dist/realistic/element-base.js +1209 -0
  18. package/dist/realistic/element.d.ts +2 -406
  19. package/dist/realistic/element.js +3 -1151
  20. package/dist/realistic/index.d.ts +1 -1
  21. package/dist/realistic/no-cultures.d.ts +1 -0
  22. package/dist/realistic/no-cultures.js +2 -0
  23. package/dist/realistic/shaders.js +13 -0
  24. package/dist/realistic/tiles.d.ts +24 -0
  25. package/dist/realistic/tiles.js +30 -12
  26. package/dist/satellites/track.js +26 -11
  27. package/dist/satellites/types.d.ts +5 -2
  28. package/dist/sky/culture-source.d.ts +15 -0
  29. package/dist/sky/culture-source.js +15 -0
  30. package/dist/sky/cultures.d.ts +1 -0
  31. package/dist/sky/cultures.js +8 -0
  32. package/dist/sky/host.js +144 -18
  33. package/dist/space/element-base.d.ts +624 -0
  34. package/dist/space/element-base.js +1627 -0
  35. package/dist/space/element.d.ts +2 -587
  36. package/dist/space/element.js +3 -1546
  37. package/dist/space/no-cultures.d.ts +1 -0
  38. package/dist/space/no-cultures.js +2 -0
  39. package/dist/space/satellite-layer.d.ts +24 -0
  40. package/dist/space/satellite-layer.js +45 -5
  41. package/dist/space/scene.d.ts +16 -0
  42. package/dist/space/scene.js +56 -9
  43. package/package.json +23 -3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.39.0 - 2026-11-12
6
+
7
+ - **The painted trail follows the orbit at any clock, and costs nothing until it is used** (MODULES-1188). A month laid down at once, or a fast clock, took samples too far apart and drew chords across the map: samples are now at most a third of a trip apart. A clock run backwards laid down nothing for the older end, so the trail shrank: it now fills it in. A coverage swath over the date line was cut at the edge of the map: it now wraps. Switching to a satellite that paints nothing left the old picture on the globe: the cleared picture is sent. The trail's two megabytes and its picture on the graphics card were made in every view, painting or not: they are made when the first satellite is painted, and `clearPaint()` gives them back.
8
+ - **Sharp ground when riding above a satellite, and the model there** (MODULES-1184). `<chikyu-space>` takes `tiles` (attribute and property, as `<chikyu-earth-realistic>` does) and lays the finer map tiles over its Earth: the level is chosen from the pixels a unit of ground takes under the camera, so from 150 km above the ISS the ground is the finest level (4) and from 3,000 km it is level 3, where it was one blurred 4096 picture; only the tiles under the camera are loaded (at most 48, freed after four seconds), a view of the whole Earth asks for none, and nothing is drawn at rest. `stats.tiles` has the tile set's state and `chikyu-tiles` is sent once when a set has been read. `TileCamera` has an optional `perspective` (`TilePerspective`, new in `/realistic`) for a camera with a real place, which `tilesInView` and `pointOnEarth` use in place of the disc; a disc is read as before. The satellite's model (`setSatellitePainter`) was already drawn in the `above` view as in `follow`; the tests now say so at 150 km (`e2e/ride-above-model.gl.ts`, `e2e/ride-above-tiles.gl.ts`). The demo's space view uses its tiles.
9
+ - **A press on a named star or a constellation figure tells the page** (MODULES-1179). `chikyu-sky-pick` is sent on `<chikyu-space>` and `<chikyu-earth-realistic>` when a reader presses or taps one. A star's detail is `{ kind: "star", hr, name, designation, x, y, pointerType }` (`name` as drawn, `x` and `y` CSS pixels inside the element, `pointerType` `mouse`, `pen`, `touch` or `keyboard`). A figure's detail is `{ kind: "constellation", abbreviation, pointerType }`. Each named star and each figure in view is a button, so a keyboard reaches it and Enter picks it, and the pick is announced; the keys `C` and `Shift`+`C` (the next and the previous figure) send it too (`pointerType` `keyboard`). Nothing is drawn at rest.
10
+ - **A build without the sky cultures** (MODULES-1185). `@johnmorrisdotca/chikyu-earth/space/no-cultures` and `@johnmorrisdotca/chikyu-earth/realistic/no-cultures` are `<chikyu-space>` and `<chikyu-earth-realistic>` with no sky culture but the IAU's: nothing under `hoshi-stars/cultures` is imported, so a site's bundler no longer needs a stub for it, and `constellation-culture` is `iau` whatever a page sets (one warning). The default entries are unchanged: they bring in `western`, `japanese` and `chinese`, a dynamic import each. How: the elements' code moved to `element-base.ts` in each folder; `space/element` and `realistic/element` are now that code plus `sky/cultures.ts`, which sets the table the sky layer reads (`setCultureLoaders`). A test reads each entry's imports and finds no `hoshi-stars/cultures` in the two new ones and all three in the default ones, and the usage test bundles the new entries with every such import refused.
11
+ - **The demo takes every planet picture at the widest width again** (MODULES-1175). The demo's `wakusei-planets` is `^0.38.0`, which stops at the widest picture its package ships when a page gives a `textureBase` and no `farBase`, so the demo's cap of 1024 on the painter (and its 404s for 2048) is gone.
12
+
13
+ ## 0.38.0 - 2026-11-12
14
+
15
+ - **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.
16
+ - **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.
17
+ - **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.
18
+ - **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.
19
+
5
20
  ## 0.37.0 - 2026-11-12
6
21
 
7
22
  - **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.
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
 
package/README.md CHANGED
@@ -547,6 +547,7 @@ The reference is a site, made from the source's own doc comments: every export h
547
547
  | `.../realistic`, `.../realistic/element` | The Earth from space; `three` for the element. |
548
548
  | `.../markers` | `attachMarkers` and the pure projection, clusters and labels. |
549
549
  | `.../space`, `.../space/element` | The Sun, the Moon and the planets; `astronomy-engine` and `three`. |
550
+ | `.../space/no-cultures`, `.../realistic/no-cultures` | The same two elements with no sky culture but the IAU's: nothing under `hoshi-stars/cultures` is in the build ([guide](docs/guides/sky-names.md)). |
550
551
  | `.../satellites` | SGP4 for a group of satellites; `satellite.js`. |
551
552
  | `.../meteors` | The year's meteor showers, and when and where their meteors fall. No DOM, no dependency. |
552
553
  | `.../door` | The data door: sources of your own maps and orbit data with their licence and credit, `creditLine`, the package's own sources. No DOM, no dependency. |
@@ -608,7 +609,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
608
609
 
609
610
  ## How to cite
610
611
 
611
- > Morris, J. (2026). *Chikyu Earth* (version 0.37.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
612
+ > Morris, J. (2026). *Chikyu Earth* (version 0.39.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
612
613
 
613
614
  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
615
 
@@ -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,58 @@
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
+ * `periodMs` is one trip of the satellite round the Earth: samples are taken often enough that the line between two follows the orbit, however fast the clock. A clock run backwards lays down the older end of the length that it uncovers.
36
+ */
37
+ step(ms: number, sample: (ms: number) => (LonLat & {
38
+ heightKm: number;
39
+ }) | null, periodMs?: number): boolean;
40
+ }
41
+ export declare function createPaintState(): PaintState;
42
+ /** The satellite `id` names, in the groups now set: a NORAD number, or `group:index`. */
43
+ export declare function findPainted(groups: Iterable<[string, {
44
+ satellites: Satellites;
45
+ }]>, id: string): {
46
+ satellites: Satellites;
47
+ index: number;
48
+ } | null;
49
+ /** The ground under the painted satellite at `ms`, or null when it cannot be placed. */
50
+ export declare function paintedGround(groups: Iterable<[string, {
51
+ satellites: Satellites;
52
+ }]>, id: string, ms: number): (LonLat & {
53
+ heightKm: number;
54
+ }) | null;
55
+ /** One trip of the painted satellite round the Earth, in milliseconds, from its mean motion; undefined when it is not found. */
56
+ export declare function paintedPeriod(groups: Iterable<[string, {
57
+ satellites: Satellites;
58
+ }]>, id: string): number | undefined;