@johnmorrisdotca/chikyu-earth 0.48.0 → 0.50.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 +11 -0
- package/README.md +1 -1
- package/dist/realistic/earth.d.ts +3 -0
- package/dist/realistic/earth.js +19 -3
- package/dist/realistic/element-base.d.ts +32 -0
- package/dist/realistic/element-base.js +65 -7
- package/dist/realistic/light-fade.d.ts +22 -0
- package/dist/realistic/light-fade.js +36 -0
- package/dist/satellites/catalogue.d.ts +1 -1
- package/dist/satellites/catalogue.js +5 -4
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/kana.d.ts +16 -0
- package/dist/satellites/kana.js +24 -0
- package/dist/satellites/source.js +1 -1
- package/dist/satellites/track.d.ts +5 -0
- package/dist/satellites/track.js +66 -5
- package/dist/satellites/types.d.ts +14 -0
- package/dist/space/element-base.d.ts +32 -0
- package/dist/space/element-base.js +66 -9
- package/dist/space/generic-satellite.d.ts +6 -1
- package/dist/space/generic-satellite.js +16 -4
- package/dist/space/model-lights.d.ts +14 -0
- package/dist/space/model-lights.js +19 -0
- package/dist/space/path-controls.d.ts +4 -1
- package/dist/space/path-controls.js +13 -6
- package/dist/space/satellite-layer.d.ts +3 -0
- package/dist/space/satellite-layer.js +15 -5
- package/dist/space/scene.d.ts +3 -0
- package/dist/space/scene.js +33 -3
- package/package.json +1 -1
package/dist/satellites/track.js
CHANGED
|
@@ -15,6 +15,18 @@ const MAX_STEP_MS = 60_000;
|
|
|
15
15
|
* (a Molniya orbit is 10 times quicker at its lowest point than its mean): its place and its streak are SGP4 itself, two calls a frame, for the few that are this eccentric.
|
|
16
16
|
*/
|
|
17
17
|
export const ECCENTRIC_FROM = 0.02;
|
|
18
|
+
/** A date from the catalogue (`2026-11-02`, or with a time), in milliseconds, or NaN. A bare date is taken as the start of that day UTC. */
|
|
19
|
+
const dateOf = (text) => {
|
|
20
|
+
const t = typeof text === "string" ? text.trim() : "";
|
|
21
|
+
if (t === "")
|
|
22
|
+
return Number.NaN;
|
|
23
|
+
if (t.length <= 10)
|
|
24
|
+
return Date.parse(`${t}T00:00:00Z`);
|
|
25
|
+
const iso = t.replace(" ", "T");
|
|
26
|
+
return Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(iso) ? iso : `${iso}Z`);
|
|
27
|
+
};
|
|
28
|
+
/** The height, in kilometres above the mean Earth radius, below which a satellite carried far from its elements is taken to have come down: SGP4 has nothing true to say there, and it is never drawn inside the Earth. */
|
|
29
|
+
const LOWEST_ESTIMATE_KM = 120;
|
|
18
30
|
const epochOf = (text) => Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(text) ? text : `${text}Z`);
|
|
19
31
|
/**
|
|
20
32
|
* Make a group of satellites from their element sets. Each starts SGP4 once here; one that does not (bad numbers, decayed at its own epoch) is listed in `refused` and left out.
|
|
@@ -57,6 +69,8 @@ export function createSatellites(sets, options = {}) {
|
|
|
57
69
|
const recs = [];
|
|
58
70
|
const usable = [];
|
|
59
71
|
const epochs = [];
|
|
72
|
+
const launchOf = [];
|
|
73
|
+
const decayOf = [];
|
|
60
74
|
const refused = [];
|
|
61
75
|
for (const set of sets) {
|
|
62
76
|
const epoch = epochOf(set.EPOCH);
|
|
@@ -75,6 +89,12 @@ export function createSatellites(sets, options = {}) {
|
|
|
75
89
|
recs.push(rec);
|
|
76
90
|
usable.push(set);
|
|
77
91
|
epochs.push(epoch);
|
|
92
|
+
// the earliest moment it can have been in orbit: its launch date, else the start of the year in its international designator; the latest: the end of its decay day
|
|
93
|
+
const launch = dateOf(set.LAUNCH_DATE);
|
|
94
|
+
const year = /^(\d{4})-\d{3}/.exec(set.OBJECT_ID ?? "");
|
|
95
|
+
launchOf.push(Number.isFinite(launch) ? launch : year ? Date.UTC(Number(year[1]), 0, 1) : Number.NEGATIVE_INFINITY);
|
|
96
|
+
const decay = dateOf(set.DECAY_DATE);
|
|
97
|
+
decayOf.push(Number.isFinite(decay) ? decay + ((set.DECAY_DATE ?? "").trim().length <= 10 ? DAY_MS - 1 : 0) : Number.POSITIVE_INFINITY);
|
|
78
98
|
}
|
|
79
99
|
catch (error) {
|
|
80
100
|
refuse(error instanceof Error ? error.message : "SGP4 could not start from these elements");
|
|
@@ -121,6 +141,17 @@ export function createSatellites(sets, options = {}) {
|
|
|
121
141
|
let propagations = 0;
|
|
122
142
|
let placed = 0;
|
|
123
143
|
const timing = { lastBatchMs: 0, maxBatchMs: 0 };
|
|
144
|
+
let estimate = options.estimateFar === true;
|
|
145
|
+
let estimatedCount = 0;
|
|
146
|
+
/** Whether a satellite is placed at a moment: within `maxAgeDays` of its elements, or, when far moments are estimated, inside the time it was in orbit. */
|
|
147
|
+
const usableAt = (i, ms) => {
|
|
148
|
+
if (estimate)
|
|
149
|
+
return ms >= launchOf[i] && ms <= decayOf[i];
|
|
150
|
+
return Math.abs(ms - epochs[i]) <= maxAgeMs;
|
|
151
|
+
};
|
|
152
|
+
const isFar = (i, ms) => estimate && Math.abs(ms - epochs[i]) > maxAgeMs;
|
|
153
|
+
/** A carried-far position that is down in the air or inside the Earth is no estimate (Earth radii). */
|
|
154
|
+
const tooLow = (x, y, z) => Math.hypot(x, y, z) < 1 + LOWEST_ESTIMATE_KM / EARTH_RADIUS_KM;
|
|
124
155
|
const pinned = new Float32Array(n * 3);
|
|
125
156
|
const pinOk = new Uint8Array(n);
|
|
126
157
|
// when each satellite was last pinned (NaN: never), so a group can be pinned a slice at a time and `arc` turns each from its own pin
|
|
@@ -148,14 +179,14 @@ export function createSatellites(sets, options = {}) {
|
|
|
148
179
|
if (skipEccentric && isEccentric[i] === 1)
|
|
149
180
|
continue;
|
|
150
181
|
const epoch = epochs[i];
|
|
151
|
-
if (
|
|
182
|
+
if (!usableAt(i, ms)) {
|
|
152
183
|
ok[i] = 0;
|
|
153
184
|
continue;
|
|
154
185
|
}
|
|
155
186
|
propagations += 1;
|
|
156
187
|
const result = sgp4(recs[i], (ms - epoch) / 60_000);
|
|
157
188
|
const p = result && result.position;
|
|
158
|
-
if (!p || !Number.isFinite(p.x)) {
|
|
189
|
+
if (!p || !Number.isFinite(p.x) || (isFar(i, ms) && tooLow(p.x / EARTH_RADIUS_KM, p.y / EARTH_RADIUS_KM, p.z / EARTH_RADIUS_KM))) {
|
|
159
190
|
ok[i] = 0;
|
|
160
191
|
continue;
|
|
161
192
|
}
|
|
@@ -170,12 +201,14 @@ export function createSatellites(sets, options = {}) {
|
|
|
170
201
|
};
|
|
171
202
|
const exactAt = (index, ms, out) => {
|
|
172
203
|
const epoch = epochs[index];
|
|
173
|
-
if (epoch === undefined ||
|
|
204
|
+
if (epoch === undefined || !usableAt(index, ms))
|
|
174
205
|
return false;
|
|
175
206
|
propagations += 1;
|
|
176
207
|
const result = sgp4(recs[index], (ms - epoch) / 60_000);
|
|
177
208
|
if (!result || !result.position || !result.velocity || !Number.isFinite(result.position.x))
|
|
178
209
|
return false;
|
|
210
|
+
if (isFar(index, ms) && tooLow(result.position.x / EARTH_RADIUS_KM, result.position.y / EARTH_RADIUS_KM, result.position.z / EARTH_RADIUS_KM))
|
|
211
|
+
return false;
|
|
179
212
|
out[0] = result.position.x / EARTH_RADIUS_KM;
|
|
180
213
|
out[1] = result.position.z / EARTH_RADIUS_KM;
|
|
181
214
|
out[2] = -result.position.y / EARTH_RADIUS_KM;
|
|
@@ -203,6 +236,24 @@ export function createSatellites(sets, options = {}) {
|
|
|
203
236
|
get placed() {
|
|
204
237
|
return placed;
|
|
205
238
|
},
|
|
239
|
+
get estimateFar() {
|
|
240
|
+
return estimate;
|
|
241
|
+
},
|
|
242
|
+
set estimateFar(value) {
|
|
243
|
+
if (value === estimate)
|
|
244
|
+
return;
|
|
245
|
+
estimate = value;
|
|
246
|
+
// what was placed was placed under the other rule: place everything again, and draw each satellite's look again
|
|
247
|
+
ready = false;
|
|
248
|
+
pinnedCount = 0;
|
|
249
|
+
pinMsOf.fill(Number.NaN);
|
|
250
|
+
dimmed.fill(0);
|
|
251
|
+
dimVersion += 1;
|
|
252
|
+
},
|
|
253
|
+
get estimatedCount() {
|
|
254
|
+
return estimatedCount;
|
|
255
|
+
},
|
|
256
|
+
estimated: (index) => dimmed[index] === 2 && shown[index] === 1,
|
|
206
257
|
pin(ms, first = 0, count = n) {
|
|
207
258
|
if (n === 0)
|
|
208
259
|
return;
|
|
@@ -232,7 +283,7 @@ export function createSatellites(sets, options = {}) {
|
|
|
232
283
|
let count = 0;
|
|
233
284
|
for (let i = 0; i < n; i += 1) {
|
|
234
285
|
const k = i * 3;
|
|
235
|
-
const dim = Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
286
|
+
const dim = isFar(i, ms) ? 2 : Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
236
287
|
if (dim !== dimmed[i]) {
|
|
237
288
|
dimmed[i] = dim;
|
|
238
289
|
dimVersion += 1;
|
|
@@ -298,6 +349,10 @@ export function createSatellites(sets, options = {}) {
|
|
|
298
349
|
count += 1;
|
|
299
350
|
}
|
|
300
351
|
placed = count;
|
|
352
|
+
estimatedCount = 0;
|
|
353
|
+
for (let i = 0; i < n; i += 1)
|
|
354
|
+
if (dimmed[i] === 2 && shown[i] === 1)
|
|
355
|
+
estimatedCount += 1;
|
|
301
356
|
return count;
|
|
302
357
|
},
|
|
303
358
|
setStep(ms) {
|
|
@@ -337,7 +392,7 @@ export function createSatellites(sets, options = {}) {
|
|
|
337
392
|
let count = 0;
|
|
338
393
|
for (let i = 0; i < n; i += 1) {
|
|
339
394
|
const k = i * 3;
|
|
340
|
-
const dim = Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
395
|
+
const dim = isFar(i, ms) ? 2 : Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
341
396
|
if (dim !== dimmed[i]) {
|
|
342
397
|
dimmed[i] = dim;
|
|
343
398
|
dimVersion += 1;
|
|
@@ -357,6 +412,10 @@ export function createSatellites(sets, options = {}) {
|
|
|
357
412
|
}
|
|
358
413
|
}
|
|
359
414
|
placed = count;
|
|
415
|
+
estimatedCount = 0;
|
|
416
|
+
for (let i = 0; i < n; i += 1)
|
|
417
|
+
if (dimmed[i] === 2 && shown[i] === 1)
|
|
418
|
+
estimatedCount += 1;
|
|
360
419
|
},
|
|
361
420
|
visible: (index) => shown[index] === 1,
|
|
362
421
|
exact: exactAt,
|
|
@@ -385,6 +444,8 @@ export function createSatellites(sets, options = {}) {
|
|
|
385
444
|
objectId: set.OBJECT_ID,
|
|
386
445
|
epochMs: epochs[index],
|
|
387
446
|
ageDays: (ms - epochs[index]) / DAY_MS,
|
|
447
|
+
estimated: isFar(index, ms),
|
|
448
|
+
estimatedDays: Math.abs(ms - epochs[index]) / DAY_MS,
|
|
388
449
|
altitudeKm: Math.hypot(one[0], one[1], one[2]) * EARTH_RADIUS_KM - EARTH_RADIUS_KM,
|
|
389
450
|
speedKmS: Math.hypot(one[3], one[4], one[5]),
|
|
390
451
|
periodMinutes: 1440 / set.MEAN_MOTION,
|
|
@@ -52,6 +52,10 @@ export interface ElementSet {
|
|
|
52
52
|
COUNTRY_CODE?: string;
|
|
53
53
|
/** The owner's code, as the other catalogue writes it (the same codes), when the source carries it. */
|
|
54
54
|
OWNER?: string;
|
|
55
|
+
/** The day it was launched (`2026-11-02`), as CelesTrak's satellite catalogue writes it, when the source carries it: with `estimateFar` a satellite is never placed before it. */
|
|
56
|
+
LAUNCH_DATE?: string;
|
|
57
|
+
/** The day it decayed or re-entered, when it has: with `estimateFar` a satellite is never placed after it. */
|
|
58
|
+
DECAY_DATE?: string;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* What a page can tell a reader about one satellite at a moment: its name, its number, how old its elements are, how high and how fast it is.
|
|
@@ -76,6 +80,10 @@ export interface SatelliteInfo {
|
|
|
76
80
|
epochMs: number;
|
|
77
81
|
/** Days between the elements' moment and the moment asked about (negative before it). */
|
|
78
82
|
ageDays: number;
|
|
83
|
+
/** The moment asked about is beyond `maxAgeDays` from the elements, so the place is an estimate (`estimateFar`): where it would be had its orbit not changed. */
|
|
84
|
+
estimated: boolean;
|
|
85
|
+
/** How far the moment asked about is from the elements' own, in days, whichever way (0 or more): for a card that says "estimated, 36 days from its last tracking". */
|
|
86
|
+
estimatedDays: number;
|
|
79
87
|
/** Height above the mean Earth radius (6371 km) at that moment. */
|
|
80
88
|
altitudeKm: number;
|
|
81
89
|
/** Speed against the stars, kilometres a second. */
|
|
@@ -162,6 +170,12 @@ export interface Satellites {
|
|
|
162
170
|
visible(index: number): boolean;
|
|
163
171
|
/** How many of them the last `at` or `arc` placed. */
|
|
164
172
|
readonly placed: number;
|
|
173
|
+
/** Place satellites beyond `maxAgeDays` from their elements as an estimate (`estimateFar`, off by default). Setting it places everything again at the next draw. */
|
|
174
|
+
estimateFar: boolean;
|
|
175
|
+
/** How many satellites the last `at` or `arc` placed as an estimate. */
|
|
176
|
+
readonly estimatedCount: number;
|
|
177
|
+
/** True if satellite `index` was placed by the last `at` or `arc` as an estimate: its moment is beyond `maxAgeDays` from its elements. */
|
|
178
|
+
estimated(index: number): boolean;
|
|
165
179
|
/** The newest element epoch in the group, in milliseconds since the Unix epoch, or 0 when it is empty. The date of the data. */
|
|
166
180
|
readonly newestEpochMs: number;
|
|
167
181
|
/** Red, green and blue, from 0 to 1, of each satellite's orbit class, 3 numbers a satellite. It does not change. */
|
|
@@ -173,6 +173,7 @@ type SatelliteStats = {
|
|
|
173
173
|
hoverPath: boolean;
|
|
174
174
|
hoverOpacity: number;
|
|
175
175
|
selectedOpacity: number;
|
|
176
|
+
estimated: number;
|
|
176
177
|
};
|
|
177
178
|
/**
|
|
178
179
|
* The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
@@ -712,6 +713,25 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
712
713
|
set namesOnHover(value: boolean);
|
|
713
714
|
/** Mark one satellite: a larger ring round it, its orbit drawn, and its name beside it. `null` lets it go. */
|
|
714
715
|
selectSatellite(ref: SatelliteRef | null): void;
|
|
716
|
+
/**
|
|
717
|
+
* Keep placing satellites that are far from their element sets, as an estimate (the attribute `estimate-far`, off unless set; `estimate-far="off"` is off). A satellite is left out when the moment shown is more than `maxAgeDays` (30) from its elements; on, it is carried forward or back by the same SGP4 code
|
|
718
|
+
* instead, and drawn lighter than a dimmed one. **An estimate is where the satellite would be if its orbit had not changed since the elements were taken.** It is worst for low orbits (drag changes them within days, and a manoeuvre moves the satellite along its path, so after weeks the estimate can be far along the orbit from the truth, and a satellite that has re-entered is not there at all) and for a long time away; a high orbit changes slowly and is close for months. Never before a satellite's launch or after its decay when its elements carry `LAUNCH_DATE` and `DECAY_DATE` (else the year of its `OBJECT_ID` is the earliest);
|
|
719
|
+
* one SGP4 cannot carry that far, or brings down below about 120 km, is left out and is not counted as placed. Each estimated satellite is `estimated: true`, with `estimatedDays`, in `placeSatellite`, `satelliteInfo`, `chikyu-satellite-visibility` and `chikyu-satellite-click`, and `stats.satellites.estimated` counts them.
|
|
720
|
+
* It applies to every group, those the page made with `createSatellites(sets, { estimateFar: true })` too.
|
|
721
|
+
*
|
|
722
|
+
* @example
|
|
723
|
+
* ```ts
|
|
724
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
725
|
+
*
|
|
726
|
+
* const farFromToday = (space: ChikyuSpace): void => {
|
|
727
|
+
* space.estimateFar = true;
|
|
728
|
+
* space.addEventListener("chikyu-satellite-click", (event) => console.log((event as CustomEvent).detail.estimated, (event as CustomEvent).detail.estimatedDays));
|
|
729
|
+
* };
|
|
730
|
+
* console.log(typeof farFromToday);
|
|
731
|
+
* ```
|
|
732
|
+
*/
|
|
733
|
+
get estimateFar(): boolean;
|
|
734
|
+
set estimateFar(value: boolean);
|
|
715
735
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
716
736
|
get selectedSatellite(): SatelliteRef | null;
|
|
717
737
|
/**
|
|
@@ -764,6 +784,13 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
764
784
|
*/
|
|
765
785
|
get pathHit(): number;
|
|
766
786
|
set pathHit(value: number);
|
|
787
|
+
/**
|
|
788
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
789
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
790
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
791
|
+
*/
|
|
792
|
+
get pathPriority(): "dots" | "paths";
|
|
793
|
+
set pathPriority(value: "dots" | "paths");
|
|
767
794
|
/**
|
|
768
795
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
769
796
|
*
|
|
@@ -838,6 +865,11 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
838
865
|
time: number;
|
|
839
866
|
lookups: number;
|
|
840
867
|
satellites: SatelliteStats;
|
|
868
|
+
/** The cross-fade when `light` changes to or from `lit` (300 ms, a cut under reduced motion): `mix` is 0 for the true light and 1 for `lit`, and `fading` is true while it moves and another frame is wanted. */
|
|
869
|
+
lightFade: {
|
|
870
|
+
mix: number;
|
|
871
|
+
fading: boolean;
|
|
872
|
+
};
|
|
841
873
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
842
874
|
paths: PathStats;
|
|
843
875
|
ride: {
|
|
@@ -33,7 +33,7 @@ import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
|
33
33
|
import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
|
|
34
34
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
|
|
35
35
|
import { claimPress } from "../sky/claim.js";
|
|
36
|
-
import { bindPaths, emptyPathStats, pointerOf } from "./path-controls.js";
|
|
36
|
+
import { bindPaths, emptyPathStats, pointerOf, readPathPriority } from "./path-controls.js";
|
|
37
37
|
import { styleTable } from "./paths.js";
|
|
38
38
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
|
|
39
39
|
import { clampFollow, retargetFollow } from "./follow.js";
|
|
@@ -177,7 +177,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
export class ChikyuSpace extends HTMLElement {
|
|
180
|
-
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, ...BEAM_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", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "hover-path", "names-on-hover", "selected-path", "path-hit", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
180
|
+
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, ...BEAM_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", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
181
181
|
#model = newSpaceModel();
|
|
182
182
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
183
183
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -580,6 +580,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
580
580
|
this.#hover?.sync();
|
|
581
581
|
else if (name === "selected-path")
|
|
582
582
|
this.#pathControls?.sync();
|
|
583
|
+
else if (name === "estimate-far")
|
|
584
|
+
this.#applyEstimate();
|
|
583
585
|
else if (name === "path-hit") {
|
|
584
586
|
/* read at each press and move */
|
|
585
587
|
}
|
|
@@ -1899,6 +1901,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1899
1901
|
orbits: (style.orbits ?? was?.orbits ?? false) && satellites.count <= MAX_ORBIT_GROUP,
|
|
1900
1902
|
visible: was?.visible ?? true,
|
|
1901
1903
|
});
|
|
1904
|
+
if (typeof this.hasAttribute === "function" && this.hasAttribute("estimate-far"))
|
|
1905
|
+
satellites.estimateFar = this.estimateFar;
|
|
1902
1906
|
}
|
|
1903
1907
|
// a group's index may now be a different satellite, so a cached name for that ref is no longer its name
|
|
1904
1908
|
this.#satLabelCache.clear();
|
|
@@ -2008,6 +2012,43 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2008
2012
|
this.#chosenLabel.hidden = true;
|
|
2009
2013
|
this.#gate?.request();
|
|
2010
2014
|
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Keep placing satellites that are far from their element sets, as an estimate (the attribute `estimate-far`, off unless set; `estimate-far="off"` is off). A satellite is left out when the moment shown is more than `maxAgeDays` (30) from its elements; on, it is carried forward or back by the same SGP4 code
|
|
2017
|
+
* instead, and drawn lighter than a dimmed one. **An estimate is where the satellite would be if its orbit had not changed since the elements were taken.** It is worst for low orbits (drag changes them within days, and a manoeuvre moves the satellite along its path, so after weeks the estimate can be far along the orbit from the truth, and a satellite that has re-entered is not there at all) and for a long time away; a high orbit changes slowly and is close for months. Never before a satellite's launch or after its decay when its elements carry `LAUNCH_DATE` and `DECAY_DATE` (else the year of its `OBJECT_ID` is the earliest);
|
|
2018
|
+
* one SGP4 cannot carry that far, or brings down below about 120 km, is left out and is not counted as placed. Each estimated satellite is `estimated: true`, with `estimatedDays`, in `placeSatellite`, `satelliteInfo`, `chikyu-satellite-visibility` and `chikyu-satellite-click`, and `stats.satellites.estimated` counts them.
|
|
2019
|
+
* It applies to every group, those the page made with `createSatellites(sets, { estimateFar: true })` too.
|
|
2020
|
+
*
|
|
2021
|
+
* @example
|
|
2022
|
+
* ```ts
|
|
2023
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
2024
|
+
*
|
|
2025
|
+
* const farFromToday = (space: ChikyuSpace): void => {
|
|
2026
|
+
* space.estimateFar = true;
|
|
2027
|
+
* space.addEventListener("chikyu-satellite-click", (event) => console.log((event as CustomEvent).detail.estimated, (event as CustomEvent).detail.estimatedDays));
|
|
2028
|
+
* };
|
|
2029
|
+
* console.log(typeof farFromToday);
|
|
2030
|
+
* ```
|
|
2031
|
+
*/
|
|
2032
|
+
get estimateFar() {
|
|
2033
|
+
return this.hasAttribute("estimate-far") && this.getAttribute("estimate-far") !== "off";
|
|
2034
|
+
}
|
|
2035
|
+
set estimateFar(value) {
|
|
2036
|
+
if (value)
|
|
2037
|
+
this.setAttribute("estimate-far", "");
|
|
2038
|
+
else
|
|
2039
|
+
this.removeAttribute("estimate-far");
|
|
2040
|
+
}
|
|
2041
|
+
/** What an event says of a satellite's place: whether it is an estimate, and how far the moment shown is from its elements' own, in days. */
|
|
2042
|
+
#estimateOf(ref) {
|
|
2043
|
+
const info = this.#model.satellites.groups.get(ref.group)?.satellites.info(ref.index, this.#model.time);
|
|
2044
|
+
return { estimated: info?.estimated ?? false, estimatedDays: info?.estimatedDays ?? 0 };
|
|
2045
|
+
}
|
|
2046
|
+
#applyEstimate() {
|
|
2047
|
+
const on = this.estimateFar;
|
|
2048
|
+
for (const group of this.#model.satellites.groups.values())
|
|
2049
|
+
group.satellites.estimateFar = on;
|
|
2050
|
+
this.#gate?.request();
|
|
2051
|
+
}
|
|
2011
2052
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
2012
2053
|
get selectedSatellite() {
|
|
2013
2054
|
const chosen = this.#model.satellites.selected;
|
|
@@ -2090,6 +2131,20 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2090
2131
|
else
|
|
2091
2132
|
this.removeAttribute("path-hit");
|
|
2092
2133
|
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
2136
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
2137
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
2138
|
+
*/
|
|
2139
|
+
get pathPriority() {
|
|
2140
|
+
return readPathPriority(this.getAttribute("path-priority"));
|
|
2141
|
+
}
|
|
2142
|
+
set pathPriority(value) {
|
|
2143
|
+
if (value === "paths")
|
|
2144
|
+
this.setAttribute("path-priority", "paths");
|
|
2145
|
+
else
|
|
2146
|
+
this.removeAttribute("path-priority");
|
|
2147
|
+
}
|
|
2093
2148
|
/**
|
|
2094
2149
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
2095
2150
|
*
|
|
@@ -2196,12 +2251,12 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2196
2251
|
const key = `${m.ref.group}:${m.ref.index}`;
|
|
2197
2252
|
now.set(key, m.visible);
|
|
2198
2253
|
if (this.#markSeen.get(key) !== m.visible && (this.#markSeen.has(key) || m.visible))
|
|
2199
|
-
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: m.ref, visible: m.visible }, bubbles: true, composed: true }));
|
|
2254
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: m.ref, visible: m.visible, ...this.#estimateOf(m.ref) }, bubbles: true, composed: true }));
|
|
2200
2255
|
}
|
|
2201
2256
|
for (const [key, was] of this.#markSeen) {
|
|
2202
2257
|
if (!now.has(key) && was) {
|
|
2203
2258
|
const [group, index] = key.split(":");
|
|
2204
|
-
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: { group: group, index: Number(index) }, visible: false }, bubbles: true, composed: true }));
|
|
2259
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: { group: group, index: Number(index) }, visible: false, ...this.#estimateOf({ group: group, index: Number(index) }) }, bubbles: true, composed: true }));
|
|
2205
2260
|
}
|
|
2206
2261
|
}
|
|
2207
2262
|
this.#markSeen = now;
|
|
@@ -2270,6 +2325,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2270
2325
|
time: this.#model.time,
|
|
2271
2326
|
lookups: this.#model.lookups,
|
|
2272
2327
|
satellites: this.#satelliteStats(),
|
|
2328
|
+
lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
|
|
2273
2329
|
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
2274
2330
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
|
|
2275
2331
|
camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], quaternion: [this.#model.pose.q[0], this.#model.pose.q[1], this.#model.pose.q[2], this.#model.pose.q[3]], fov: this.#model.pose.fov },
|
|
@@ -2303,7 +2359,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2303
2359
|
let epochMs = 0;
|
|
2304
2360
|
for (const group of this.#model.satellites.groups.values())
|
|
2305
2361
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
2306
|
-
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, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity };
|
|
2362
|
+
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, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, estimated: drawn.estimated };
|
|
2307
2363
|
}
|
|
2308
2364
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
2309
2365
|
#readSpeed() {
|
|
@@ -2430,14 +2486,15 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2430
2486
|
const rect = this.getBoundingClientRect();
|
|
2431
2487
|
const x = event.clientX - rect.left;
|
|
2432
2488
|
const y = event.clientY - rect.top;
|
|
2433
|
-
|
|
2434
|
-
if (
|
|
2489
|
+
// one press, one meaning: the paths decide first, since which of a dot and a path wins depends on `path-priority` (a dot wins in the default, and the paths say so by answering no)
|
|
2490
|
+
if (this.#pathControls?.press(x, y, pointerOf(event))) {
|
|
2435
2491
|
claimPress(event);
|
|
2436
|
-
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite) }, bubbles: true, composed: true }));
|
|
2437
2492
|
return;
|
|
2438
2493
|
}
|
|
2439
|
-
|
|
2494
|
+
const satellite = this.#model.pick?.(x, y, 12);
|
|
2495
|
+
if (satellite) {
|
|
2440
2496
|
claimPress(event);
|
|
2497
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite), ...this.#estimateOf(satellite) }, bubbles: true, composed: true }));
|
|
2441
2498
|
return;
|
|
2442
2499
|
}
|
|
2443
2500
|
if (!this.#places)
|
|
@@ -26,11 +26,14 @@ export type SatelliteKind = "bus" | "communications" | "flat" | "station" | "cub
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare function satelliteKind(name: string): SatelliteKind;
|
|
29
|
+
/** How bright the Sun is on a generic drawing. */
|
|
30
|
+
export declare const SUN_INTENSITY = 3.2;
|
|
29
31
|
/**
|
|
30
32
|
* A generic satellite as a drawing of radius 1 about the origin, its long axis along +x (the way it flies), its top along +z and its left along +y, the family's convention for a model, with its own light that `light(toSun)` turns to the Sun. One group of a few meshes, made once and disposed with `dispose`.
|
|
31
33
|
*
|
|
32
34
|
* @param three - three.js (the parts the demo's subset holds: `Group`, `Mesh`, `BoxGeometry`, `CylinderGeometry`, `MeshLambertMaterial`, `DirectionalLight`, `AmbientLight`).
|
|
33
35
|
* @param kind - What to draw.
|
|
36
|
+
* @param shared - A Sun light the scene owns (`{ sun }`), in the scene's own axes: the drawing then makes none of its own and `light` points that one. A scene with the light always in it keeps the same number of lights whether or not a drawing is shown, so three keeps one program for each material, not one for each state of the lights.
|
|
34
37
|
* @returns The drawing, with `light` and `dispose`.
|
|
35
38
|
*
|
|
36
39
|
* @example
|
|
@@ -43,4 +46,6 @@ export declare function satelliteKind(name: string): SatelliteKind;
|
|
|
43
46
|
* drawing.dispose();
|
|
44
47
|
* ```
|
|
45
48
|
*/
|
|
46
|
-
export declare function genericSatellite(three: typeof THREE, kind: SatelliteKind
|
|
49
|
+
export declare function genericSatellite(three: typeof THREE, kind: SatelliteKind, shared?: {
|
|
50
|
+
sun: THREE.DirectionalLight;
|
|
51
|
+
}): BodyDrawing;
|
|
@@ -23,11 +23,14 @@ export function satelliteKind(name) {
|
|
|
23
23
|
return "communications";
|
|
24
24
|
return "bus";
|
|
25
25
|
}
|
|
26
|
+
/** How bright the Sun is on a generic drawing. */
|
|
27
|
+
export const SUN_INTENSITY = 3.2;
|
|
26
28
|
/**
|
|
27
29
|
* A generic satellite as a drawing of radius 1 about the origin, its long axis along +x (the way it flies), its top along +z and its left along +y, the family's convention for a model, with its own light that `light(toSun)` turns to the Sun. One group of a few meshes, made once and disposed with `dispose`.
|
|
28
30
|
*
|
|
29
31
|
* @param three - three.js (the parts the demo's subset holds: `Group`, `Mesh`, `BoxGeometry`, `CylinderGeometry`, `MeshLambertMaterial`, `DirectionalLight`, `AmbientLight`).
|
|
30
32
|
* @param kind - What to draw.
|
|
33
|
+
* @param shared - A Sun light the scene owns (`{ sun }`), in the scene's own axes: the drawing then makes none of its own and `light` points that one. A scene with the light always in it keeps the same number of lights whether or not a drawing is shown, so three keeps one program for each material, not one for each state of the lights.
|
|
31
34
|
* @returns The drawing, with `light` and `dispose`.
|
|
32
35
|
*
|
|
33
36
|
* @example
|
|
@@ -40,7 +43,7 @@ export function satelliteKind(name) {
|
|
|
40
43
|
* drawing.dispose();
|
|
41
44
|
* ```
|
|
42
45
|
*/
|
|
43
|
-
export function genericSatellite(three, kind) {
|
|
46
|
+
export function genericSatellite(three, kind, shared) {
|
|
44
47
|
const group = new three.Group();
|
|
45
48
|
const materials = [];
|
|
46
49
|
const geometries = [];
|
|
@@ -115,11 +118,20 @@ export function genericSatellite(three, kind) {
|
|
|
115
118
|
add(box(0.06, 0.06, 0.1), 0xb4b9c2, [-0.2, 0, -0.26]);
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
const
|
|
119
|
-
|
|
121
|
+
const own = shared ? null : new three.DirectionalLight(0xfff4e0, SUN_INTENSITY);
|
|
122
|
+
const sun = shared?.sun ?? own;
|
|
123
|
+
group.add(new three.AmbientLight(0x6f86a8, 0.9));
|
|
124
|
+
if (own)
|
|
125
|
+
group.add(own);
|
|
120
126
|
return {
|
|
121
127
|
object: group,
|
|
122
128
|
light(toSun) {
|
|
129
|
+
if (shared) {
|
|
130
|
+
// the scene's light lives in the scene's axes, where the Sun's direction is already: point it and switch it on (the scene switches it off when no drawing is shown)
|
|
131
|
+
sun.position.set(toSun[0], toSun[1], toSun[2]);
|
|
132
|
+
sun.intensity = SUN_INTENSITY;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
123
135
|
// the model's axes are the columns of the matrix the view set: the direction to the Sun in them is the dot with each
|
|
124
136
|
const m = group.matrix.elements;
|
|
125
137
|
const length = Math.hypot(m[0], m[1], m[2]) || 1;
|
|
@@ -130,7 +142,7 @@ export function genericSatellite(three, kind) {
|
|
|
130
142
|
material.dispose();
|
|
131
143
|
for (const geometry of geometries)
|
|
132
144
|
geometry.dispose();
|
|
133
|
-
|
|
145
|
+
own?.dispose?.();
|
|
134
146
|
},
|
|
135
147
|
};
|
|
136
148
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
/** The look of the light a model brought: the colour (a number such as 0xfff4e0) and the strength, for the scene's Sun to take on while the model is shown. */
|
|
3
|
+
export interface ModelSun {
|
|
4
|
+
color: number;
|
|
5
|
+
intensity: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Switch off every light in a model that would count in the scene's lights (directional, point, spot, hemisphere and area lights; an ambient light does not change a program and is left), and say what the first directional one looked like.
|
|
9
|
+
* The lights are switched off, not taken out, so a painter that disposes of them or aims them in its `light` hook finds them where it left them.
|
|
10
|
+
*
|
|
11
|
+
* @param object - The model.
|
|
12
|
+
* @returns The first directional light's colour and strength, or `null` when the model had none.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripLights(object: THREE.Object3D): ModelSun | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switch off every light in a model that would count in the scene's lights (directional, point, spot, hemisphere and area lights; an ambient light does not change a program and is left), and say what the first directional one looked like.
|
|
3
|
+
* The lights are switched off, not taken out, so a painter that disposes of them or aims them in its `light` hook finds them where it left them.
|
|
4
|
+
*
|
|
5
|
+
* @param object - The model.
|
|
6
|
+
* @returns The first directional light's colour and strength, or `null` when the model had none.
|
|
7
|
+
*/
|
|
8
|
+
export function stripLights(object) {
|
|
9
|
+
let sun = null;
|
|
10
|
+
object.traverse((part) => {
|
|
11
|
+
const light = part;
|
|
12
|
+
if (!light.isLight || light.isAmbientLight === true || light.isLightProbe === true)
|
|
13
|
+
return;
|
|
14
|
+
if (light.isDirectionalLight === true && sun === null)
|
|
15
|
+
sun = { color: light.color.getHex(), intensity: light.intensity };
|
|
16
|
+
light.visible = false;
|
|
17
|
+
});
|
|
18
|
+
return sun;
|
|
19
|
+
}
|
|
@@ -2,7 +2,10 @@ import type { SatelliteRef } from "../satellites/types.ts";
|
|
|
2
2
|
import type { SatelliteState } from "./satellite-layer.ts";
|
|
3
3
|
import { MAX_PATHS, type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
4
4
|
/** The attributes the paths add to an element. */
|
|
5
|
-
export declare const PATH_ATTRIBUTES: readonly ["selected-path", "path-hit"];
|
|
5
|
+
export declare const PATH_ATTRIBUTES: readonly ["selected-path", "path-hit", "path-priority"];
|
|
6
|
+
/** Which comes first under a pointer: a satellite's `dots` (the default), or `paths` (a path of the page's, unless the dot is of a satellite whose path is listed or that is chosen). Anything else is `dots`. */
|
|
7
|
+
export type PathPriority = "dots" | "paths";
|
|
8
|
+
export declare const readPathPriority: (value: string | null) => PathPriority;
|
|
6
9
|
/** What the element hands the paths. */
|
|
7
10
|
export interface PathHost {
|
|
8
11
|
element: HTMLElement;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { capPaths, hitRadius, MAX_PATHS, readPathHit, styleTable } from "./paths.js";
|
|
2
2
|
/** The attributes the paths add to an element. */
|
|
3
|
-
export const PATH_ATTRIBUTES = ["selected-path", "path-hit"];
|
|
3
|
+
export const PATH_ATTRIBUTES = ["selected-path", "path-hit", "path-priority"];
|
|
4
|
+
export const readPathPriority = (value) => (value === "paths" ? "paths" : "dots");
|
|
4
5
|
export const pointerOf = (event) => (event.pointerType === "touch" ? "touch" : event.pointerType === "pen" ? "pen" : "mouse");
|
|
5
6
|
export function bindPaths(host) {
|
|
6
7
|
const { element, state } = host;
|
|
@@ -18,14 +19,22 @@ export function bindPaths(host) {
|
|
|
18
19
|
const found = host.pathAt(x, y, radius);
|
|
19
20
|
return found ? { ...found, pointer } : null;
|
|
20
21
|
};
|
|
22
|
+
/** Whether a dot belongs to a satellite the page has made much of: one whose path is drawn (listed, or the chosen or ridden one's own), or the chosen one. Its dot is its own under either priority. */
|
|
23
|
+
const listed = (ref) => state.paths.info.some((one) => one.ref.group === ref.group && one.ref.index === ref.index) || (state.selected?.group === ref.group && state.selected.index === ref.index) || (state.ridden?.group === ref.group && state.ridden.index === ref.index);
|
|
24
|
+
/** The path a pointer at a point is on, once the dots have had their say: under `dots` a dot hides the paths; under `paths` only a listed satellite's own dot does. */
|
|
25
|
+
const choose = (x, y, pointer) => {
|
|
26
|
+
const dot = host.pick(x, y);
|
|
27
|
+
if (dot && (readPathPriority(element.getAttribute("path-priority")) === "dots" || listed(dot)))
|
|
28
|
+
return null;
|
|
29
|
+
return at(x, y, undefined, pointer);
|
|
30
|
+
};
|
|
21
31
|
const detail = (hit) => ({ ...hit, ref: { ...hit.ref } });
|
|
22
32
|
const sameHit = (a, b) => (a === null && b === null) || (a !== null && b !== null && a.id === b.id && a.style === b.style && a.ref.group === b.ref.group && a.ref.index === b.ref.index);
|
|
23
33
|
const apply = () => {
|
|
24
34
|
queued = false;
|
|
25
35
|
if (!point)
|
|
26
36
|
return;
|
|
27
|
-
const
|
|
28
|
-
const hit = dot ? null : at(point.x, point.y, undefined, "mouse");
|
|
37
|
+
const hit = choose(point.x, point.y, "mouse");
|
|
29
38
|
if (sameHit(hit, hovered)) {
|
|
30
39
|
hovered = hit;
|
|
31
40
|
return;
|
|
@@ -95,9 +104,7 @@ export function bindPaths(host) {
|
|
|
95
104
|
},
|
|
96
105
|
at,
|
|
97
106
|
press(x, y, pointer) {
|
|
98
|
-
|
|
99
|
-
return false;
|
|
100
|
-
const hit = at(x, y, undefined, pointer);
|
|
107
|
+
const hit = choose(x, y, pointer);
|
|
101
108
|
if (!hit)
|
|
102
109
|
return false;
|
|
103
110
|
hits += 1;
|
|
@@ -82,6 +82,7 @@ export interface SatelliteState {
|
|
|
82
82
|
selectedOpacity: number;
|
|
83
83
|
pathsDrawn: number;
|
|
84
84
|
pathDraws: number;
|
|
85
|
+
estimated: number;
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
@@ -221,6 +222,8 @@ export interface SatelliteScreen {
|
|
|
221
222
|
behind: boolean;
|
|
222
223
|
/** The Earth hides the satellite: the line from the camera meets the globe before the satellite. False at the limb, in front, and when the satellite is only behind the camera. */
|
|
223
224
|
occluded: boolean;
|
|
225
|
+
/** Its place is an estimate (`estimate-far`): the moment shown is beyond `maxAgeDays` from its elements. */
|
|
226
|
+
estimated: boolean;
|
|
224
227
|
}
|
|
225
228
|
export interface SatelliteLayer {
|
|
226
229
|
/** Where one satellite of a shown group is on the screen as of the last update, or `null` when its group is not shown or it is not placed (its elements are too old). A satellite outside the picture or behind the camera is still returned, with `visible` false. */
|