@johnmorrisdotca/chikyu-earth 0.45.0 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.46.0 - 2026-11-13
4
+
5
+ - **A satellite's streak keeps its short look at any clock speed and any Earth size** (MODULES-1282). Above 60 times real time each satellite is a streak along its orbit for the stretch one frame spans; at 10 minutes a second that is a few millimetres, but at an hour a second it was a long straight line across the globe, the stretch also grew when frames came slowly, and on a small Earth the streaks and the dark rim of the dots stayed as long and heavy as on a large one, so thousands of them blackened it. Now a streak is never longer than the smaller of 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second, so it shrinks in proportion as the Earth is drawn smaller, down to a dot) and `satellite-streak-max`, new on `<chikyu-space>` and `<chikyu-earth-realistic>` (the property `satelliteStreakMax`), a ceiling in CSS pixels, 8 when the page says nothing; `off` or `0` draws the whole stretch, as before. It is a length on the screen and not seconds of travel, so a low and a high satellite are drawn equally long. A streak is also always one frame at 30 a second, whatever the frames really take, so its length does not depend on the frame rate; it ends at the satellite and points back along its orbit. The marks lose weight as the Earth is drawn smaller: from a drawn radius of 150 pixels down to 40 the streaks are fainter and the dark rim of the dots fades until it is gone, at normal speed too, and a crowd of satellites that would cover more of a small Earth's near side than a limit (6% for dots, 35% for streaks) is drawn fainter in proportion, so 16,000 satellites leave a small Earth no more washed than a whole one; a whole Earth is drawn as before. `stats.satellites` has `longestStreakPx`, `streakCapPx`, `weight`, `fade` and `earthPx`; `Satellites.arc` takes the cap, in Earth radii, as an optional last argument.
6
+
3
7
  ## 0.45.0 - 2026-11-13
4
8
 
5
9
  - **Sharper Earth tiles: day level 5 and night level 4, from NASA's 500 m maps** (MODULES-1263). `scripts/make-earth-tiles.py` builds the day map's level 5 (32768 × 16384, 2,048 tiles, 22.8 MB) from the full-resolution Blue Marble: Next Generation (86400 × 43200, eight 21600 × 21600 panels) and the night map's level 4 (16384 × 8192, 512 tiles, 2.3 MB) from the full-resolution Black Marble 2016 colour map, so the whole pyramid is 3,412 files and 35.4 MB (it was 852 and 10.3 MB). Levels 0 to 4 of the day map and 0 to 3 of the night map are unchanged (the same code and sources; tiles sampled from every level are identical to the published ones). The panels are resized one panel at a time with their neighbours' edges around them (the far panel across the antimeridian), so the 11 GB map is never in memory (about 4 GB at the most) and the tiles equal, to the pixel, a resize of the whole map; `selftest` checks that on a made-up map, joins, antimeridian and poles included. The build takes about 3 to 4 minutes and downloads 688 MB once; the sources and their SHA-256 are in `scripts/earth-tiles-sources.json`. A level is still never built from a source that does not fill it. The folder source (`earthTiles`, what the `tiles` attribute makes) named the keys of a tile from the package's levels 3 and 4 alone, so with a level 5 in the manifest the view chose level 5 and then asked for level 4 tiles: it now names them from the levels its manifest has (the package's 3 and 4 before the manifest is read or where there is none), and a test holds it. The zoom limit the element sets when it finds the tiles is no longer fixed: it is now as many times 5 as the finest day level is wider than 4096, so 40 for a set that reaches level 5 (it was fixed at 20; a set that stops at level 4 still gives 20); it is only raised, so a source with fewer levels added later does not lower it and send the view back to fit. The 48 tile and about 70 MB limits hold at the finest level (`e2e/tiles.gl.ts`). `pages.yml` keeps NASA's source files between runs while `scripts/earth-tiles-sources.json` is unchanged (a change to the script alone downloads nothing), and the built tiles while the script and the sources are unchanged. `earthTiles().need()` now names keys from the manifest's own levels (a detail of 4096 or less can name levels 0 to 2 where it named level 3 before). Without `EARTH_TILES_ALL=yes` the script (`pnpm tiles`) makes only day 0 to 4 and night 0 to 3 from the two whole pictures and does not download the panels, and its output is what was published before, byte for byte (the manifest and 80 sampled tiles compared); a download is tried three times (after 5 s and 20 s) before the script stops. The Pages site publishes day levels above 4 and night levels above 3 only when the repository variable `EARTH_TILES_ALL` is `yes` (`scripts/site.ts`): a loader up to 0.43 that reads a manifest with a level 5 wants it and fetches the level 4 tile for each quarter of it, a wrong picture on every page that reads the demo's tiles (the website's hero does), so the variable is set once those pages have the newer loader. Guide, its Japanese twin and NOTICE updated.
package/README.md CHANGED
@@ -611,7 +611,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
611
611
 
612
612
  ## How to cite
613
613
 
614
- > Morris, J. (2026). *Chikyu Earth* (version 0.45.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
614
+ > Morris, J. (2026). *Chikyu Earth* (version 0.46.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
615
615
 
616
616
  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.
617
617
 
@@ -42,6 +42,11 @@ type SatelliteStats = {
42
42
  segments: number;
43
43
  tooFast: boolean;
44
44
  dotScale: number;
45
+ longestStreakPx: number;
46
+ streakCapPx: number;
47
+ weight: number;
48
+ fade: number;
49
+ earthPx: number;
45
50
  epochMs: number;
46
51
  propagations: number;
47
52
  lastBatchMs: number;
@@ -460,6 +465,20 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
460
465
  */
461
466
  get satelliteTint(): "off" | "orbit";
462
467
  set satelliteTint(value: "off" | "orbit");
468
+ /**
469
+ * The longest a satellite's streak may be on the screen, in CSS pixels (the attribute `satellite-streak-max`; 8 when the page says nothing; `0` or `off` for no cap). Above 60 times real time each satellite is drawn as a streak along its orbit
470
+ * for the stretch one frame spans, and at a fast clock that stretch is long: at an hour a second a low satellite would cross a tenth of the Earth in one frame. The cap is a length on the screen, so a low and a high satellite are drawn equally long, and the streak keeps the look it has at 10 minutes a second at any speed. It is the smaller of this number of pixels and 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second), so as the Earth is drawn smaller the streak shrinks in proportion, to a dot, instead of staying as long on a small Earth as on a large one. The marks also lose weight on a small Earth: below a drawn radius of 150 pixels the streaks are fainter and the dark rim of the dots fades, gone at 40 pixels, and a crowd of satellites on a small Earth is drawn fainter in proportion so thousands of them do not wash it. Pointing along the orbit and ending at the satellite, it is the same length at any frame rate. Off restores the whole stretch.
471
+ *
472
+ * @example
473
+ * ```ts
474
+ * import "@johnmorrisdotca/chikyu-earth/realistic/element";
475
+ *
476
+ * const earth = document.querySelector("chikyu-earth-realistic")!;
477
+ * earth.satelliteStreakMax = 12;
478
+ * ```
479
+ */
480
+ get satelliteStreakMax(): number;
481
+ set satelliteStreakMax(value: number);
463
482
  /**
464
483
  * 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, so every group of the catalogue can be shown at once. Giving the name of a group
465
484
  * 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). The groups are placed by SGP4 about once a second and interpolated
@@ -8,7 +8,7 @@ import { IMMERSIVE_STYLE, immersiveWheel } from "./immersive.js";
8
8
  import { NOTES_STYLE, setAirNote } from "./air-note.js";
9
9
  import { cameraCentre, createEarthItem, discRadius, lookAt, newModel } from "./earth.js";
10
10
  import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.js";
11
- import { MAX_ORBIT_GROUP } from "../space/satellite-layer.js";
11
+ import { MAX_ORBIT_GROUP, readStreakMax } from "../space/satellite-layer.js";
12
12
  import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForOrthographicShell } from "../space/satellite-focus.js";
13
13
  import { readMeteorStrength } from "../meteors/strength.js";
14
14
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
@@ -160,7 +160,7 @@ export const readTime = (value) => {
160
160
  * ```
161
161
  */
162
162
  export class ChikyuEarthRealistic extends HTMLElement {
163
- static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint"];
163
+ static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max"];
164
164
  #model = newModel();
165
165
  #paint = createPaintState();
166
166
  #mode = "now";
@@ -508,6 +508,10 @@ export class ChikyuEarthRealistic extends HTMLElement {
508
508
  this.#model.satellites.orbitTint = value === "orbit";
509
509
  this.#gate?.soon();
510
510
  }
511
+ else if (name === "satellite-streak-max") {
512
+ this.#model.satellites.streakMax = readStreakMax(value);
513
+ this.#gate?.soon();
514
+ }
511
515
  if (name === "air-thickness" || name === "air-label" || name === "lang")
512
516
  setAirNote(this.#airNote, this, this.#model.airThickness);
513
517
  }
@@ -1177,6 +1181,27 @@ export class ChikyuEarthRealistic extends HTMLElement {
1177
1181
  else
1178
1182
  this.removeAttribute("satellite-tint");
1179
1183
  }
1184
+ /**
1185
+ * The longest a satellite's streak may be on the screen, in CSS pixels (the attribute `satellite-streak-max`; 8 when the page says nothing; `0` or `off` for no cap). Above 60 times real time each satellite is drawn as a streak along its orbit
1186
+ * for the stretch one frame spans, and at a fast clock that stretch is long: at an hour a second a low satellite would cross a tenth of the Earth in one frame. The cap is a length on the screen, so a low and a high satellite are drawn equally long, and the streak keeps the look it has at 10 minutes a second at any speed. It is the smaller of this number of pixels and 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second), so as the Earth is drawn smaller the streak shrinks in proportion, to a dot, instead of staying as long on a small Earth as on a large one. The marks also lose weight on a small Earth: below a drawn radius of 150 pixels the streaks are fainter and the dark rim of the dots fades, gone at 40 pixels, and a crowd of satellites on a small Earth is drawn fainter in proportion so thousands of them do not wash it. Pointing along the orbit and ending at the satellite, it is the same length at any frame rate. Off restores the whole stretch.
1187
+ *
1188
+ * @example
1189
+ * ```ts
1190
+ * import "@johnmorrisdotca/chikyu-earth/realistic/element";
1191
+ *
1192
+ * const earth = document.querySelector("chikyu-earth-realistic")!;
1193
+ * earth.satelliteStreakMax = 12;
1194
+ * ```
1195
+ */
1196
+ get satelliteStreakMax() {
1197
+ return this.#model.satellites.streakMax;
1198
+ }
1199
+ set satelliteStreakMax(value) {
1200
+ if (Number.isFinite(value) && value >= 0)
1201
+ this.setAttribute("satellite-streak-max", String(value));
1202
+ else
1203
+ this.removeAttribute("satellite-streak-max");
1204
+ }
1180
1205
  /**
1181
1206
  * 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, so every group of the catalogue can be shown at once. Giving the name of a group
1182
1207
  * 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). The groups are placed by SGP4 about once a second and interpolated
@@ -1329,7 +1354,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
1329
1354
  let epochMs = 0;
1330
1355
  for (const group of this.#model.satellites.groups.values())
1331
1356
  epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
1332
- 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 };
1357
+ return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
1333
1358
  }
1334
1359
  // A press that does not turn the view (under 6 pixels) on a satellite tells the page, which chooses it with `selectSatellite` if it likes.
1335
1360
  #downX = 0;
@@ -217,9 +217,11 @@ export function createSatellites(sets, options = {}) {
217
217
  pinMsOf[i] = ms;
218
218
  }
219
219
  },
220
- arc(ms, spanMs, positions, segments) {
220
+ arc(ms, spanMs, positions, segments, maxLength = 0) {
221
221
  if (n === 0)
222
222
  return 0;
223
+ // the longest a streak may be, in Earth radii along the orbit; 0, or anything that is not a positive number, leaves the stretch as long as the span makes it
224
+ const cap = maxLength > 0 && Number.isFinite(maxLength) ? maxLength : 0;
223
225
  // a satellite never pinned is pinned now, all together
224
226
  if (pinnedCount < n) {
225
227
  sample(pinned, pinOk, ms, 0, n, true);
@@ -249,7 +251,14 @@ export function createSatellites(sets, options = {}) {
249
251
  segments[w + 3] = place[0];
250
252
  segments[w + 4] = place[1];
251
253
  segments[w + 5] = place[2];
252
- if (exactAt(i, ms - span, place)) {
254
+ // SGP4 gave the speed here (km/s), so the cap in Earth radii becomes a stretch of time for this satellite and the start is placed by SGP4 that much earlier
255
+ let own = span;
256
+ if (cap > 0) {
257
+ const reach = (Math.hypot(place[3], place[4], place[5]) / EARTH_RADIUS_KM) * (Math.abs(span) / 1000);
258
+ if (reach > cap)
259
+ own = (span * cap) / reach;
260
+ }
261
+ if (exactAt(i, ms - own, place)) {
253
262
  segments[w] = place[0];
254
263
  segments[w + 1] = place[1];
255
264
  segments[w + 2] = place[2];
@@ -272,7 +281,13 @@ export function createSatellites(sets, options = {}) {
272
281
  const nx = normal[k];
273
282
  const ny = normal[k + 1];
274
283
  const nz = normal[k + 2];
275
- const sweep = Math.max(-Math.PI, Math.min(Math.PI, rate[i] * span));
284
+ let sweep = Math.max(-Math.PI, Math.min(Math.PI, rate[i] * span));
285
+ if (cap > 0) {
286
+ // along the orbit a turn of `sweep` is `sweep` times the height in Earth radii, so the cap is a turn of cap / height
287
+ const height = Math.hypot(pinned[k], pinned[k + 1], pinned[k + 2]);
288
+ if (height > 0 && Math.abs(sweep) * height > cap)
289
+ sweep = Math.sign(sweep) * (cap / height);
290
+ }
276
291
  const along = rate[i] * (ms - pinMsOf[i]);
277
292
  turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along, positions, k);
278
293
  turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along - sweep, segments, w);
@@ -175,10 +175,10 @@ export interface Satellites {
175
175
  pin(ms: number, first?: number, count?: number): void;
176
176
  /**
177
177
  * The place of each satellite at `ms` into `positions` (3 numbers each) and the stretch of orbit it travels over `spanMs` of game time into `segments` (6 numbers each: where it was `spanMs` earlier, then where it is).
178
- * The place is the last `pin`, turned about the orbit's axis by the mean motion, so a fast clock does not run SGP4 for every satellite on every frame. A `spanMs` that would turn it more than half a revolution is cut there. An orbit with an eccentricity of 0.02 or more is placed by SGP4 itself instead (two calls a frame), because a turn at the mean motion would put it off its path.
178
+ * The place is the last `pin`, turned about the orbit's axis by the mean motion, so a fast clock does not run SGP4 for every satellite on every frame. A `spanMs` that would turn it more than half a revolution is cut there. `maxLength` (Earth radii, 0 or left out for none) is the longest a streak may be along the orbit: a satellite whose span would carry it further is drawn that long, ending at its place, so the length does not grow with a faster clock. For an orbit placed by SGP4 itself the cap is applied as a shorter span of time, from the speed SGP4 gives there. An orbit with an eccentricity of 0.02 or more is placed by SGP4 itself instead (two calls a frame), because a turn at the mean motion would put it off its path.
179
179
  * Returns how many were written.
180
180
  */
181
- arc(ms: number, spanMs: number, positions: Float32Array, segments: Float32Array): number;
181
+ arc(ms: number, spanMs: number, positions: Float32Array, segments: Float32Array, maxLength?: number): number;
182
182
  /** One satellite at exactly `ms` (no interpolation): position in Earth radii and velocity in km/s into `out` (6 numbers). False if its elements are too old or SGP4 gave up. */
183
183
  exact(index: number, ms: number, out: Float64Array): boolean;
184
184
  /** The path of satellite `index` for one revolution from `ms`, `points` + 1 points in order along it (the last on the first), into a new array of Earth radii. */
@@ -145,6 +145,11 @@ type SatelliteStats = {
145
145
  segments: number;
146
146
  tooFast: boolean;
147
147
  dotScale: number;
148
+ longestStreakPx: number;
149
+ streakCapPx: number;
150
+ weight: number;
151
+ fade: number;
152
+ earthPx: number;
148
153
  epochMs: number;
149
154
  propagations: number;
150
155
  lastBatchMs: number;
@@ -488,6 +493,20 @@ export declare class ChikyuSpace extends HTMLElement {
488
493
  */
489
494
  get satelliteTint(): "off" | "orbit";
490
495
  set satelliteTint(value: "off" | "orbit");
496
+ /**
497
+ * The longest a satellite's streak may be on the screen, in CSS pixels (the attribute `satellite-streak-max`; 8 when the page says nothing; `0` or `off` for no cap). Above 60 times real time each satellite is drawn as a streak along its orbit
498
+ * for the stretch one frame spans, and at a fast clock that stretch is long: at an hour a second a low satellite would cross a tenth of the Earth in one frame. The cap is a length on the screen, so a low and a high satellite are drawn equally long, and the streak keeps the look it has at 10 minutes a second at any speed. It is the smaller of this number of pixels and 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second), so as the Earth is drawn smaller the streak shrinks in proportion, to a dot, instead of staying as long on a small Earth as on a large one. The marks also lose weight on a small Earth: below a drawn radius of 150 pixels the streaks are fainter and the dark rim of the dots fades, gone at 40 pixels, and a crowd of satellites on a small Earth is drawn fainter in proportion so thousands of them do not wash it. Pointing along the orbit and ending at the satellite, it is the same length at any frame rate. Off restores the whole stretch.
499
+ *
500
+ * @example
501
+ * ```ts
502
+ * import "@johnmorrisdotca/chikyu-earth/space/element";
503
+ *
504
+ * const space = document.querySelector("chikyu-space")!;
505
+ * space.satelliteStreakMax = 12;
506
+ * ```
507
+ */
508
+ get satelliteStreakMax(): number;
509
+ set satelliteStreakMax(value: number);
491
510
  /**
492
511
  * 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
493
512
  * 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).
@@ -28,7 +28,7 @@ import { readMeteorStrength } from "../meteors/strength.js";
28
28
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
29
29
  import { MAX_TEXTURE } from "../realistic/tiers.js";
30
30
  import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
31
- import { MAX_ORBIT_GROUP } from "./satellite-layer.js";
31
+ import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
32
32
  import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
33
33
  import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
34
34
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
@@ -156,7 +156,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
156
156
  * ```
157
157
  */
158
158
  export class ChikyuSpace extends HTMLElement {
159
- 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, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "tiles", "ride-viewpoint"];
159
+ 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, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "ride-viewpoint"];
160
160
  #model = newSpaceModel();
161
161
  #paint = createPaintState();
162
162
  #mode = "now";
@@ -499,6 +499,10 @@ export class ChikyuSpace extends HTMLElement {
499
499
  this.#model.satellites.orbitTint = value === "orbit";
500
500
  this.#gate?.request();
501
501
  }
502
+ else if (name === "satellite-streak-max") {
503
+ this.#model.satellites.streakMax = readStreakMax(value);
504
+ this.#gate?.request();
505
+ }
502
506
  else if (name === "tiles")
503
507
  this.#gate?.request();
504
508
  if (name === "air-thickness" || name === "air-label" || name === "lang")
@@ -1395,6 +1399,27 @@ export class ChikyuSpace extends HTMLElement {
1395
1399
  else
1396
1400
  this.removeAttribute("satellite-tint");
1397
1401
  }
1402
+ /**
1403
+ * The longest a satellite's streak may be on the screen, in CSS pixels (the attribute `satellite-streak-max`; 8 when the page says nothing; `0` or `off` for no cap). Above 60 times real time each satellite is drawn as a streak along its orbit
1404
+ * for the stretch one frame spans, and at a fast clock that stretch is long: at an hour a second a low satellite would cross a tenth of the Earth in one frame. The cap is a length on the screen, so a low and a high satellite are drawn equally long, and the streak keeps the look it has at 10 minutes a second at any speed. It is the smaller of this number of pixels and 0.025 of the Earth's drawn radius (about 160 km of orbit, what a low satellite covers in a frame at 10 minutes a second), so as the Earth is drawn smaller the streak shrinks in proportion, to a dot, instead of staying as long on a small Earth as on a large one. The marks also lose weight on a small Earth: below a drawn radius of 150 pixels the streaks are fainter and the dark rim of the dots fades, gone at 40 pixels, and a crowd of satellites on a small Earth is drawn fainter in proportion so thousands of them do not wash it. Pointing along the orbit and ending at the satellite, it is the same length at any frame rate. Off restores the whole stretch.
1405
+ *
1406
+ * @example
1407
+ * ```ts
1408
+ * import "@johnmorrisdotca/chikyu-earth/space/element";
1409
+ *
1410
+ * const space = document.querySelector("chikyu-space")!;
1411
+ * space.satelliteStreakMax = 12;
1412
+ * ```
1413
+ */
1414
+ get satelliteStreakMax() {
1415
+ return this.#model.satellites.streakMax;
1416
+ }
1417
+ set satelliteStreakMax(value) {
1418
+ if (Number.isFinite(value) && value >= 0)
1419
+ this.setAttribute("satellite-streak-max", String(value));
1420
+ else
1421
+ this.removeAttribute("satellite-streak-max");
1422
+ }
1398
1423
  /**
1399
1424
  * 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
1400
1425
  * 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).
@@ -1723,7 +1748,7 @@ export class ChikyuSpace extends HTMLElement {
1723
1748
  let epochMs = 0;
1724
1749
  for (const group of this.#model.satellites.groups.values())
1725
1750
  epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
1726
- 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 };
1751
+ return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
1727
1752
  }
1728
1753
  // --- the game clock ----------------------------------------------------------------------------------------------------------------------------
1729
1754
  #readSpeed() {
@@ -28,17 +28,54 @@ export interface SatelliteState {
28
28
  orbitTint: boolean;
29
29
  /** One group shown on its own. `null` leaves every group as the page set it. */
30
30
  focus: SatelliteFocus | null;
31
+ /**
32
+ * The pixel ceiling of a streak's length on the screen above the interpolation limit, in CSS pixels at the Earth's own distance (`satellite-streak-max`). A streak is also never longer than {@link STREAK_REACH} Earth radii, so it shrinks with the Earth.
33
+ * 0 draws the whole stretch one frame spans, however long that is.
34
+ */
35
+ streakMax: number;
31
36
  drawn: {
32
37
  placed: number;
33
38
  segments: number;
34
39
  tooFast: boolean;
35
40
  dotScale: number;
41
+ longestStreakPx: number;
42
+ streakCapPx: number;
43
+ weight: number;
44
+ fade: number;
45
+ earthPx: number;
36
46
  updateMs: number;
37
47
  maxUpdateMs: number;
38
48
  updates: number;
39
49
  totalMs: number;
40
50
  };
41
51
  }
52
+ /**
53
+ * The longest a streak may be along its orbit, in Earth radii: 0.025, about 160 km, which is what a low satellite covers in a frame at 10 minutes a second (150 km). On the screen that is a share of the Earth's drawn radius, so a streak
54
+ * is a few millimetres when the Earth fills the view, half as long when the Earth is half as large, and a dot when the Earth is tiny. A cap of so many pixels alone would leave the same length on a small Earth, where it looks long.
55
+ */
56
+ export declare const STREAK_REACH = 0.025;
57
+ /** The Earth's drawn radius, in CSS pixels, below which the satellites' dark rims and streaks are faded out (no weight at 40) and from which they have their whole weight (150). */
58
+ export declare const WEIGHT_FROM = 40;
59
+ export declare const WEIGHT_FULL = 150;
60
+ /** How much of its weight a mark has at an Earth `radiusPx` on the screen, from 0 to 1: a smooth step from {@link WEIGHT_FROM} to {@link WEIGHT_FULL}. Many small dark marks on a small Earth would blacken it. */
61
+ export declare function markWeight(radiusPx: number): number;
62
+ /**
63
+ * The share of the near side of a small Earth that the marks may cover at full strength before they are drawn fainter in proportion: a crowd of marks on a small Earth is a haze over it, not a set of satellites. Dots are lighter ink
64
+ * than streaks are (a dot is opaque and a streak a pixel wide), so they get the smaller share.
65
+ */
66
+ export declare const CROWD_COVER_DOTS = 0.06;
67
+ export declare const CROWD_COVER_STREAKS = 0.35;
68
+ /**
69
+ * How strongly each mark is drawn so a crowd does not wash a small Earth, from 0 to 1: the share of the near side they would cover (`marks`, half of them on this side, each `area` square pixels, over the disc of an Earth `radiusPx` in radius),
70
+ * and `limit` over that when it is more. With `byWeight` (the default, for dots) it acts only as the Earth gets small (see {@link markWeight}): none at all from 150 pixels, so a whole Earth is drawn as it was however many satellites there are. Without it (streaks) the limit holds at every size: a streak is as wide as it is long, so the same number of satellites covers a half Earth twice over, and 16,000 of them leave a small Earth no more washed than a whole one.
71
+ */
72
+ export declare function crowdFade(marks: number, area: number, radiusPx: number, limit: number, byWeight?: boolean): number;
73
+ /** The longest a streak is by default: the stretch a low satellite covers in one frame at 10 minutes a second, on a whole Earth with a radius of about 300 pixels: a few millimetres on the screen. */
74
+ export declare const DEFAULT_STREAK_MAX = 8;
75
+ /** Read `satellite-streak-max`: a number of CSS pixels, `off` or 0 for no cap, and the default for nothing, a negative number or anything else. */
76
+ export declare function readStreakMax(value: string | null): number;
77
+ /** The longest streak, in CSS pixels, among the first `count` of `segments` (6 numbers each), with the Earth's radius `earthPx` on the screen: a length in Earth radii times the radius. */
78
+ export declare function longestStreak(segments: Float32Array, count: number, earthPx: number): number;
42
79
  export declare const newSatelliteState: () => SatelliteState;
43
80
  /** The most orbits a group may draw all at once, one line each. */
44
81
  export declare const MAX_ORBIT_GROUP = 40;
@@ -1,6 +1,60 @@
1
1
  import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
2
2
  import { satelliteEmphasis } from "./satellite-focus.js";
3
- export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0 } });
3
+ /**
4
+ * The longest a streak may be along its orbit, in Earth radii: 0.025, about 160 km, which is what a low satellite covers in a frame at 10 minutes a second (150 km). On the screen that is a share of the Earth's drawn radius, so a streak
5
+ * is a few millimetres when the Earth fills the view, half as long when the Earth is half as large, and a dot when the Earth is tiny. A cap of so many pixels alone would leave the same length on a small Earth, where it looks long.
6
+ */
7
+ export const STREAK_REACH = 0.025;
8
+ /** The Earth's drawn radius, in CSS pixels, below which the satellites' dark rims and streaks are faded out (no weight at 40) and from which they have their whole weight (150). */
9
+ export const WEIGHT_FROM = 40;
10
+ export const WEIGHT_FULL = 150;
11
+ /** How much of its weight a mark has at an Earth `radiusPx` on the screen, from 0 to 1: a smooth step from {@link WEIGHT_FROM} to {@link WEIGHT_FULL}. Many small dark marks on a small Earth would blacken it. */
12
+ export function markWeight(radiusPx) {
13
+ const t = Math.min(1, Math.max(0, (radiusPx - WEIGHT_FROM) / (WEIGHT_FULL - WEIGHT_FROM)));
14
+ return t * t * (3 - 2 * t);
15
+ }
16
+ /**
17
+ * The share of the near side of a small Earth that the marks may cover at full strength before they are drawn fainter in proportion: a crowd of marks on a small Earth is a haze over it, not a set of satellites. Dots are lighter ink
18
+ * than streaks are (a dot is opaque and a streak a pixel wide), so they get the smaller share.
19
+ */
20
+ export const CROWD_COVER_DOTS = 0.06;
21
+ export const CROWD_COVER_STREAKS = 0.35;
22
+ /**
23
+ * How strongly each mark is drawn so a crowd does not wash a small Earth, from 0 to 1: the share of the near side they would cover (`marks`, half of them on this side, each `area` square pixels, over the disc of an Earth `radiusPx` in radius),
24
+ * and `limit` over that when it is more. With `byWeight` (the default, for dots) it acts only as the Earth gets small (see {@link markWeight}): none at all from 150 pixels, so a whole Earth is drawn as it was however many satellites there are. Without it (streaks) the limit holds at every size: a streak is as wide as it is long, so the same number of satellites covers a half Earth twice over, and 16,000 of them leave a small Earth no more washed than a whole one.
25
+ */
26
+ export function crowdFade(marks, area, radiusPx, limit, byWeight = true) {
27
+ const disc = Math.PI * radiusPx * radiusPx;
28
+ if (!(disc > 0) || !(marks > 0))
29
+ return 1;
30
+ const cover = (0.5 * marks * area) / disc;
31
+ const crowd = cover <= limit ? 1 : limit / cover;
32
+ return byWeight ? 1 - (1 - crowd) * (1 - markWeight(radiusPx)) : crowd;
33
+ }
34
+ /** The longest a streak is by default: the stretch a low satellite covers in one frame at 10 minutes a second, on a whole Earth with a radius of about 300 pixels: a few millimetres on the screen. */
35
+ export const DEFAULT_STREAK_MAX = 8;
36
+ /** Read `satellite-streak-max`: a number of CSS pixels, `off` or 0 for no cap, and the default for nothing, a negative number or anything else. */
37
+ export function readStreakMax(value) {
38
+ if (value === null || value.trim() === "")
39
+ return DEFAULT_STREAK_MAX;
40
+ const text = value.trim().toLowerCase();
41
+ if (text === "off")
42
+ return 0;
43
+ const number = Number(text);
44
+ return Number.isFinite(number) && number >= 0 ? number : DEFAULT_STREAK_MAX;
45
+ }
46
+ /** The longest streak, in CSS pixels, among the first `count` of `segments` (6 numbers each), with the Earth's radius `earthPx` on the screen: a length in Earth radii times the radius. */
47
+ export function longestStreak(segments, count, earthPx) {
48
+ let longest = 0;
49
+ for (let i = 0; i < count; i += 1) {
50
+ const w = i * 6;
51
+ const length = Math.hypot(segments[w + 3] - segments[w], segments[w + 4] - segments[w + 1], segments[w + 5] - segments[w + 2]);
52
+ if (length > longest)
53
+ longest = length;
54
+ }
55
+ return longest * earthPx;
56
+ }
57
+ export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, streakMax: DEFAULT_STREAK_MAX, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, longestStreakPx: 0, streakCapPx: 0, weight: 1, fade: 1, earthPx: 0, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0 } });
4
58
  /** The most orbits a group may draw all at once, one line each. */
5
59
  export const MAX_ORBIT_GROUP = 40;
6
60
  const ORBIT_POINTS = 120;
@@ -23,6 +77,8 @@ const POINT_FRAG = /* glsl */ `
23
77
  uniform vec3 tint;
24
78
  uniform float ring;
25
79
  uniform float byClass;
80
+ uniform float rim;
81
+ uniform float fade;
26
82
  varying float vDim;
27
83
  varying vec3 vCls;
28
84
  void main() {
@@ -33,10 +89,10 @@ void main() {
33
89
  float a = smoothstep(0.30, 0.38, d) * (1.0 - smoothstep(0.44, 0.5, d));
34
90
  gl_FragColor = vec4(ink, a * (1.0 - 0.7 * vDim));
35
91
  } else {
36
- float rim = smoothstep(0.28, 0.42, d);
37
- vec3 colour = mix(ink, vec3(0.04, 0.05, 0.08), rim);
92
+ float rimEdge = smoothstep(0.28, 0.42, d);
93
+ vec3 colour = mix(ink, vec3(0.04, 0.05, 0.08), rimEdge * rim);
38
94
  float a = smoothstep(0.50, 0.40, d);
39
- gl_FragColor = vec4(colour, a * (1.0 - 0.7 * vDim));
95
+ gl_FragColor = vec4(colour, a * (1.0 - 0.7 * vDim) * fade);
40
96
  }
41
97
  }`;
42
98
  /** How long, in milliseconds of wall time, a satellite's place is kept before SGP4 places it again when the clock is too fast to interpolate: about once a second. */
@@ -124,8 +180,8 @@ export function createSatelliteLayer(three, scene, state, ratio) {
124
180
  const view = new three.Vector3();
125
181
  const ink = new three.Color();
126
182
  let basis = 0;
127
- let lastGame = 0;
128
- const selectedMaterial = new three.ShaderMaterial({ vertexShader: POINT_VERT, fragmentShader: POINT_FRAG, uniforms: { size: { value: 14 }, tint: { value: new three.Color("#ffffff") }, ring: { value: 1 }, byClass: { value: 0 }, groupDim: { value: 0 } }, transparent: true, depthWrite: false });
183
+ let lastEarthPx = 0;
184
+ const selectedMaterial = new three.ShaderMaterial({ vertexShader: POINT_VERT, fragmentShader: POINT_FRAG, uniforms: { size: { value: 14 }, tint: { value: new three.Color("#ffffff") }, ring: { value: 1 }, byClass: { value: 0 }, rim: { value: 1 }, fade: { value: 1 }, groupDim: { value: 0 } }, transparent: true, depthWrite: false });
129
185
  const selectedPosition = new Float32Array(3);
130
186
  const selectedGeometry = new three.BufferGeometry();
131
187
  selectedGeometry.setAttribute("position", new three.BufferAttribute(selectedPosition, 3));
@@ -203,10 +259,26 @@ export function createSatelliteLayer(three, scene, state, ratio) {
203
259
  if (basis === 0 && earthPx > 0)
204
260
  basis = earthPx;
205
261
  const dotScale = basis > 0 && earthPx > 0 ? Math.min(2.5, Math.max(0.45, Math.sqrt(earthPx / basis))) : 1;
206
- const frameMs = speed * (1000 / 30);
207
- const since = lastGame === 0 ? frameMs : time - lastGame;
208
- const span = tooFast ? (Math.abs(since) > 0 && Math.abs(since) < Math.abs(frameMs) * 4 ? since : frameMs) : 0;
209
- lastGame = time;
262
+ // One frame at the pace the picture is held to (30 a second), whatever the frames really take: a streak that grew with a slow frame would grow with a slow computer
263
+ const span = tooFast ? speed * (1000 / 30) : 0;
264
+ if (earthPx > 0)
265
+ lastEarthPx = earthPx;
266
+ const radius = earthPx > 0 ? earthPx : lastEarthPx > 0 ? lastEarthPx : 150;
267
+ // the cap is a share of the Earth's drawn radius with a ceiling in pixels, so in Earth radii it is the pixels over the Earth's radius in pixels: a zoomed-out Earth allows a longer stretch of orbit than a zoomed-in one
268
+ const capLength = state.streakMax > 0 ? Math.min(STREAK_REACH, state.streakMax / radius) : 0;
269
+ const weight = markWeight(radius);
270
+ // how crowded the near side of the Earth is with marks: the dots at their size and, above the interpolation limit, the streaks (a pixel wide) at the longest they may be
271
+ let marks = 0;
272
+ let dotArea = 0;
273
+ for (const group of state.groups.values()) {
274
+ if (!group.visible)
275
+ continue;
276
+ marks += group.satellites.count;
277
+ dotArea += group.satellites.count * (group.size * dotScale) ** 2;
278
+ }
279
+ const dotFade = marks > 0 ? crowdFade(marks, dotArea / marks, radius, CROWD_COVER_DOTS) : 1;
280
+ const streakFade = tooFast && capLength > 0 ? crowdFade(marks, Math.max(1, capLength * radius), radius, CROWD_COVER_STREAKS, false) : 1;
281
+ let longest = 0;
210
282
  for (const [name, entry] of drawn) {
211
283
  if (state.groups.get(name)?.satellites !== entry.source) {
212
284
  drop(entry);
@@ -226,7 +298,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
226
298
  const dim = new three.BufferAttribute(group.satellites.dimmed, 1);
227
299
  geometry.setAttribute("dim", dim);
228
300
  geometry.setAttribute("cls", new three.BufferAttribute(group.satellites.classColour, 3));
229
- const material = new three.ShaderMaterial({ vertexShader: POINT_VERT, fragmentShader: POINT_FRAG, uniforms: { size: { value: group.size * ratio() }, tint: { value: new three.Color(group.color) }, ring: { value: 0 }, byClass: { value: 0 }, groupDim: { value: 0 } }, transparent: true, depthWrite: false });
301
+ const material = new three.ShaderMaterial({ vertexShader: POINT_VERT, fragmentShader: POINT_FRAG, uniforms: { size: { value: group.size * ratio() }, tint: { value: new three.Color(group.color) }, ring: { value: 0 }, byClass: { value: 0 }, rim: { value: 1 }, fade: { value: 1 }, groupDim: { value: 0 } }, transparent: true, depthWrite: false });
230
302
  const points = new Points(geometry, material);
231
303
  points.frustumCulled = false;
232
304
  points.renderOrder = 5;
@@ -283,8 +355,11 @@ export function createSatelliteLayer(three, scene, state, ratio) {
283
355
  continue;
284
356
  }
285
357
  const dimmed = choice.dim > 0;
358
+ // the streaks are fainter and the dark rims of the dots fade as the Earth is drawn smaller, so thousands of marks do not darken a small Earth
286
359
  if (entry.streak)
287
- entry.streak.material.opacity = dimmed ? 0.3 : 0.95;
360
+ entry.streak.material.opacity = (dimmed ? 0.3 : 0.95) * (0.4 + 0.6 * weight) * streakFade;
361
+ entry.material.uniforms["rim"].value = weight;
362
+ entry.material.uniforms["fade"].value = dotFade;
288
363
  if (tooFast) {
289
364
  // pinned whole at the first frame and when the time jumped (a date typed in, a scrub), so a place is never turned across days; after that a slice a frame, each satellite again about once a second,
290
365
  // so SGP4 never runs for the whole group (17,000 satellites take about 12 ms) in one frame
@@ -301,7 +376,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
301
376
  }
302
377
  entry.pinWall = started;
303
378
  entry.pinTime = time;
304
- const n = group.satellites.arc(time, span, entry.positions, entry.streakPositions);
379
+ const n = group.satellites.arc(time, span, entry.positions, entry.streakPositions, capLength);
305
380
  entry.attribute.needsUpdate = true;
306
381
  if (entry.streak) {
307
382
  entry.streakAttribute.needsUpdate = true;
@@ -317,8 +392,10 @@ export function createSatelliteLayer(three, scene, state, ratio) {
317
392
  line.loop.visible = false;
318
393
  placed += n;
319
394
  group.placed = n;
320
- if (entry.streak)
395
+ if (entry.streak) {
321
396
  segments += n;
397
+ longest = Math.max(longest, longestStreak(entry.streakPositions, total, radius));
398
+ }
322
399
  }
323
400
  else {
324
401
  if (entry.streak)
@@ -367,6 +444,11 @@ export function createSatelliteLayer(three, scene, state, ratio) {
367
444
  }
368
445
  state.drawn.placed = placed;
369
446
  state.drawn.segments = segments;
447
+ state.drawn.longestStreakPx = longest;
448
+ state.drawn.streakCapPx = capLength * radius;
449
+ state.drawn.weight = weight;
450
+ state.drawn.fade = Math.min(dotFade, streakFade);
451
+ state.drawn.earthPx = radius;
370
452
  state.drawn.dotScale = dotScale;
371
453
  state.drawn.tooFast = tooFast;
372
454
  state.drawn.updateMs = performance.now() - started;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on the place you give it, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
5
5
  "keywords": [
6
6
  "earth",