@johnmorrisdotca/chikyu-earth 0.37.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.
- package/CHANGELOG.md +7 -0
- package/NOTICE.md +2 -1
- package/README.md +1 -1
- package/dist/markers/place-layer.d.ts +12 -1
- package/dist/markers/place-layer.js +88 -18
- package/dist/markers/place-sprites.d.ts +5 -0
- package/dist/markers/place-sprites.js +8 -0
- package/dist/paint/buffer.d.ts +53 -0
- package/dist/paint/buffer.js +238 -0
- package/dist/paint/math.d.ts +24 -0
- package/dist/paint/math.js +94 -0
- package/dist/paint/texture.d.ts +24 -0
- package/dist/paint/texture.js +33 -0
- package/dist/realistic/earth.d.ts +9 -0
- package/dist/realistic/earth.js +19 -10
- package/dist/realistic/element.d.ts +26 -1
- package/dist/realistic/element.js +58 -6
- package/dist/realistic/shaders.js +13 -0
- package/dist/satellites/track.js +26 -11
- package/dist/satellites/types.d.ts +5 -2
- package/dist/space/element.d.ts +26 -1
- package/dist/space/element.js +56 -5
- package/dist/space/satellite-layer.d.ts +24 -0
- package/dist/space/satellite-layer.js +45 -5
- package/dist/space/scene.d.ts +9 -0
- package/dist/space/scene.js +18 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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
|
+
|
|
5
12
|
## 0.37.0 - 2026-11-12
|
|
6
13
|
|
|
7
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.
|
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
|
@@ -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.
|
|
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
|
|
|
@@ -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
|
|
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
|
-
|
|
196
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
387
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { coverageAngleRad, groundUnder, PAINT_H, PAINT_W, paintPixel, splitDateLine, trackSteps } from "./math.js";
|
|
2
|
+
const MINUTE = 60_000;
|
|
3
|
+
const DAY = 86_400_000;
|
|
4
|
+
const LENGTH_MS = { "1d": DAY, "1w": 7 * DAY, "1m": 30 * DAY };
|
|
5
|
+
export const paintLengthOf = (length) => (length === "1w" || length === "1m" ? length : "1d");
|
|
6
|
+
export const paintSwathOf = (swath) => (swath === "coverage" ? "coverage" : "track");
|
|
7
|
+
/** Minutes since the epoch, in 16 bits: the trail is at most a month, and 16 bits hold 45 days. */
|
|
8
|
+
export const paintMinute = (ms) => Math.round(ms / MINUTE) & 0xffff;
|
|
9
|
+
const write = (data, x, y, minute) => {
|
|
10
|
+
if (x < 0 || y < 0 || x >= PAINT_W || y >= PAINT_H)
|
|
11
|
+
return false;
|
|
12
|
+
const i = (y * PAINT_W + x) * 4;
|
|
13
|
+
const fresh = data[i + 3] === 0;
|
|
14
|
+
data[i] = (minute >> 8) & 255;
|
|
15
|
+
data[i + 1] = minute & 255;
|
|
16
|
+
data[i + 2] = 255;
|
|
17
|
+
data[i + 3] = 255;
|
|
18
|
+
return fresh;
|
|
19
|
+
};
|
|
20
|
+
const stampDot = (data, point, minute, radius) => {
|
|
21
|
+
const at = paintPixel(point.lon, point.lat);
|
|
22
|
+
let added = 0;
|
|
23
|
+
for (let dy = -radius; dy <= radius; dy += 1) {
|
|
24
|
+
for (let dx = -radius; dx <= radius; dx += 1) {
|
|
25
|
+
if (dx * dx + dy * dy > radius * radius)
|
|
26
|
+
continue;
|
|
27
|
+
if (write(data, at.x + dx, at.y + dy, minute))
|
|
28
|
+
added += 1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return added;
|
|
32
|
+
};
|
|
33
|
+
const stampLine = (data, a, b, minute) => {
|
|
34
|
+
const from = paintPixel(a.lon, a.lat);
|
|
35
|
+
const to = paintPixel(b.lon, b.lat);
|
|
36
|
+
if (Math.abs(to.x - from.x) > PAINT_W / 2)
|
|
37
|
+
return 0;
|
|
38
|
+
let added = 0;
|
|
39
|
+
let x = from.x;
|
|
40
|
+
let y = from.y;
|
|
41
|
+
const dx = Math.abs(to.x - x);
|
|
42
|
+
const dy = Math.abs(to.y - y);
|
|
43
|
+
const sx = x < to.x ? 1 : -1;
|
|
44
|
+
const sy = y < to.y ? 1 : -1;
|
|
45
|
+
let err = dx - dy;
|
|
46
|
+
for (;;) {
|
|
47
|
+
if (write(data, x, y, minute))
|
|
48
|
+
added += 1;
|
|
49
|
+
if (write(data, x + 1, y, minute))
|
|
50
|
+
added += 1;
|
|
51
|
+
if (x === to.x && y === to.y)
|
|
52
|
+
break;
|
|
53
|
+
const e2 = 2 * err;
|
|
54
|
+
if (e2 > -dy) {
|
|
55
|
+
err -= dy;
|
|
56
|
+
x += sx;
|
|
57
|
+
}
|
|
58
|
+
if (e2 < dx) {
|
|
59
|
+
err += dx;
|
|
60
|
+
y += sy;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return added;
|
|
64
|
+
};
|
|
65
|
+
const angular = (a, b) => {
|
|
66
|
+
const lat1 = a.lat * Math.PI / 180;
|
|
67
|
+
const lat2 = b.lat * Math.PI / 180;
|
|
68
|
+
const dLat = lat2 - lat1;
|
|
69
|
+
const dLon = (b.lon - a.lon) * Math.PI / 180;
|
|
70
|
+
const h = Math.sin(dLat / 2) ** 2 + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) ** 2;
|
|
71
|
+
return 2 * Math.atan2(Math.sqrt(h), Math.sqrt(Math.max(0, 1 - h)));
|
|
72
|
+
};
|
|
73
|
+
const stampCap = (data, point, theta, minute) => {
|
|
74
|
+
if (!(theta > 0))
|
|
75
|
+
return stampDot(data, point, minute, 1);
|
|
76
|
+
const deg = theta * 180 / Math.PI;
|
|
77
|
+
const cosLat = Math.max(0.15, Math.cos(point.lat * Math.PI / 180));
|
|
78
|
+
const dLon = Math.min(180, deg / cosLat);
|
|
79
|
+
const pole = Math.abs(point.lat) + deg >= 90;
|
|
80
|
+
const west = pole ? -180 : point.lon - dLon;
|
|
81
|
+
const east = pole ? 180 : point.lon + dLon;
|
|
82
|
+
const south = Math.max(-90, point.lat - deg);
|
|
83
|
+
const north = Math.min(90, point.lat + deg);
|
|
84
|
+
const a = paintPixel(west, north);
|
|
85
|
+
const b = paintPixel(east, south);
|
|
86
|
+
let added = 0;
|
|
87
|
+
const x0 = pole ? 0 : Math.max(0, Math.min(a.x, b.x));
|
|
88
|
+
const x1 = pole ? PAINT_W - 1 : Math.min(PAINT_W - 1, Math.max(a.x, b.x));
|
|
89
|
+
const y0 = Math.max(0, Math.min(a.y, b.y));
|
|
90
|
+
const y1 = Math.min(PAINT_H - 1, Math.max(a.y, b.y));
|
|
91
|
+
for (let y = y0; y <= y1; y += 1) {
|
|
92
|
+
const lat = 90 - (y + 0.5) / PAINT_H * 180;
|
|
93
|
+
for (let x = x0; x <= x1; x += 1) {
|
|
94
|
+
let lon = (x + 0.5) / PAINT_W * 360 - 180;
|
|
95
|
+
if (!pole && west < -180)
|
|
96
|
+
lon = lon > 0 ? lon - 360 : lon;
|
|
97
|
+
if (angular(point, { lon, lat }) <= theta && write(data, x, y, minute))
|
|
98
|
+
added += 1;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return added;
|
|
102
|
+
};
|
|
103
|
+
const stampGround = (data, swath, ground, previous, minute) => {
|
|
104
|
+
if (swath === "coverage")
|
|
105
|
+
return { added: stampCap(data, ground, coverageAngleRad(ground.heightKm), minute), at: ground };
|
|
106
|
+
if (!previous)
|
|
107
|
+
return { added: stampDot(data, ground, minute, 1), at: ground };
|
|
108
|
+
let added = 0;
|
|
109
|
+
let cursor = previous;
|
|
110
|
+
for (const point of trackSteps(previous, ground, 0.4)) {
|
|
111
|
+
for (const [from, to] of splitDateLine(cursor, point))
|
|
112
|
+
added += stampLine(data, from, to, minute);
|
|
113
|
+
cursor = point;
|
|
114
|
+
}
|
|
115
|
+
return { added, at: cursor };
|
|
116
|
+
};
|
|
117
|
+
export function createPaintState() {
|
|
118
|
+
const data = new Uint8Array(PAINT_W * PAINT_H * 4);
|
|
119
|
+
let spec = null;
|
|
120
|
+
let pixels = 0;
|
|
121
|
+
let lastMs = Number.NaN;
|
|
122
|
+
let previous = null;
|
|
123
|
+
let uploadClear = false;
|
|
124
|
+
const self = {
|
|
125
|
+
data,
|
|
126
|
+
width: PAINT_W,
|
|
127
|
+
height: PAINT_H,
|
|
128
|
+
get pixels() {
|
|
129
|
+
return pixels;
|
|
130
|
+
},
|
|
131
|
+
get on() {
|
|
132
|
+
return spec !== null;
|
|
133
|
+
},
|
|
134
|
+
get length() {
|
|
135
|
+
return spec?.length ?? "1d";
|
|
136
|
+
},
|
|
137
|
+
get swath() {
|
|
138
|
+
return spec?.swath ?? "track";
|
|
139
|
+
},
|
|
140
|
+
get id() {
|
|
141
|
+
return spec?.id ?? "";
|
|
142
|
+
},
|
|
143
|
+
get spanMinutes() {
|
|
144
|
+
return LENGTH_MS[spec?.length ?? "1d"] / MINUTE;
|
|
145
|
+
},
|
|
146
|
+
set(next) {
|
|
147
|
+
if (!next) {
|
|
148
|
+
self.clear();
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const id = String(next.id);
|
|
152
|
+
const length = paintLengthOf(next.length);
|
|
153
|
+
const swath = paintSwathOf(next.swath);
|
|
154
|
+
if (spec && spec.id === id && spec.length === length && spec.swath === swath)
|
|
155
|
+
return;
|
|
156
|
+
data.fill(0);
|
|
157
|
+
pixels = 0;
|
|
158
|
+
lastMs = Number.NaN;
|
|
159
|
+
previous = null;
|
|
160
|
+
spec = { id, length, swath };
|
|
161
|
+
},
|
|
162
|
+
clear() {
|
|
163
|
+
data.fill(0);
|
|
164
|
+
pixels = 0;
|
|
165
|
+
lastMs = Number.NaN;
|
|
166
|
+
previous = null;
|
|
167
|
+
spec = null;
|
|
168
|
+
uploadClear = true;
|
|
169
|
+
},
|
|
170
|
+
step(ms, sample) {
|
|
171
|
+
if (!spec) {
|
|
172
|
+
const upload = uploadClear;
|
|
173
|
+
uploadClear = false;
|
|
174
|
+
return upload;
|
|
175
|
+
}
|
|
176
|
+
if (!Number.isFinite(ms))
|
|
177
|
+
return false;
|
|
178
|
+
if (Number.isFinite(lastMs) && ms === lastMs)
|
|
179
|
+
return false;
|
|
180
|
+
const length = LENGTH_MS[spec.length];
|
|
181
|
+
let dirty = false;
|
|
182
|
+
const put = (at) => {
|
|
183
|
+
const ground = sample(at);
|
|
184
|
+
if (!ground)
|
|
185
|
+
return;
|
|
186
|
+
const stamped = stampGround(data, spec.swath, ground, previous, paintMinute(at));
|
|
187
|
+
pixels += stamped.added;
|
|
188
|
+
previous = stamped.at;
|
|
189
|
+
dirty = true;
|
|
190
|
+
};
|
|
191
|
+
if (!Number.isFinite(lastMs) || Math.abs(ms - lastMs) > length) {
|
|
192
|
+
data.fill(0);
|
|
193
|
+
pixels = 0;
|
|
194
|
+
previous = null;
|
|
195
|
+
const steps = Math.min(240, Math.max(1, Math.ceil(length / 60_000)));
|
|
196
|
+
for (let i = steps; i >= 0; i -= 1)
|
|
197
|
+
put(ms - (length * i) / steps);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
const span = ms - lastMs;
|
|
201
|
+
const steps = Math.min(96, Math.max(1, Math.ceil(Math.abs(span) / 20_000)));
|
|
202
|
+
for (let i = 1; i <= steps; i += 1)
|
|
203
|
+
put(lastMs + (span * i) / steps);
|
|
204
|
+
}
|
|
205
|
+
lastMs = ms;
|
|
206
|
+
return dirty;
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
return self;
|
|
210
|
+
}
|
|
211
|
+
/** The satellite `id` names, in the groups now set: a NORAD number, or `group:index`. */
|
|
212
|
+
export function findPainted(groups, id) {
|
|
213
|
+
const cut = id.indexOf(":");
|
|
214
|
+
if (cut > 0) {
|
|
215
|
+
for (const [name, group] of groups) {
|
|
216
|
+
const index = Number(id.slice(cut + 1));
|
|
217
|
+
if (name === id.slice(0, cut) && index >= 0 && index < group.satellites.count)
|
|
218
|
+
return { satellites: group.satellites, index };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const norad = Number(id);
|
|
222
|
+
if (!Number.isFinite(norad))
|
|
223
|
+
return null;
|
|
224
|
+
for (const [, group] of groups) {
|
|
225
|
+
const index = group.satellites.sets.findIndex((set) => set.NORAD_CAT_ID === norad);
|
|
226
|
+
if (index >= 0)
|
|
227
|
+
return { satellites: group.satellites, index };
|
|
228
|
+
}
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
const scratch = new Float64Array(6);
|
|
232
|
+
/** The ground under the painted satellite at `ms`, or null when it cannot be placed. */
|
|
233
|
+
export function paintedGround(groups, id, ms) {
|
|
234
|
+
const found = findPainted(groups, id);
|
|
235
|
+
if (!found || !found.satellites.exact(found.index, ms, scratch))
|
|
236
|
+
return null;
|
|
237
|
+
return groundUnder(scratch[0], scratch[1], scratch[2], ms);
|
|
238
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Mean Earth radius, kilometres, the same unit the satellite positions use. */
|
|
2
|
+
export declare const PAINT_EARTH_KM = 6371;
|
|
3
|
+
/** The painted texture: equirectangular, north at the first row, longitude −180 at the first column. */
|
|
4
|
+
export declare const PAINT_W = 1024;
|
|
5
|
+
export declare const PAINT_H = 512;
|
|
6
|
+
export interface LonLat {
|
|
7
|
+
lon: number;
|
|
8
|
+
lat: number;
|
|
9
|
+
}
|
|
10
|
+
/** Earth-central angle, in radians, where a satellite `heightKm` up is at least `elevationDeg` above the horizon (10 when left out). 0 when it never is. */
|
|
11
|
+
export declare function coverageAngleRad(heightKm: number, elevationDeg?: number): number;
|
|
12
|
+
/** The ground under a satellite. `x, y, z` are what `Satellites.exact` writes (Earth radii, x to the vernal equinox, y north). `ms` turns the Earth under that place. */
|
|
13
|
+
export declare function groundUnder(x: number, y: number, z: number, ms: number): LonLat & {
|
|
14
|
+
heightKm: number;
|
|
15
|
+
};
|
|
16
|
+
/** Points from `a` to `b` along the great circle, about `stepDeg` apart, including both ends. A fast clock stays a continuous line, and a pole or the date line is many short steps. */
|
|
17
|
+
export declare function trackSteps(a: LonLat, b: LonLat, stepDeg: number): LonLat[];
|
|
18
|
+
/** One segment, or two when the short way from `a` to `b` crosses the date line, so an equirectangular line does not cross the whole map. Longitude is degrees, −180 to 180. */
|
|
19
|
+
export declare function splitDateLine(a: LonLat, b: LonLat): [LonLat, LonLat][];
|
|
20
|
+
/** Where a longitude and latitude fall on the painted texture, column and row. */
|
|
21
|
+
export declare function paintPixel(lon: number, lat: number): {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
};
|