@johnmorrisdotca/chikyu-earth 0.56.0 → 0.58.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 +26 -0
- package/README.md +3 -2
- package/dist/flat/element.d.ts +1 -1
- package/dist/flat/element.js +4 -3
- package/dist/realistic/element-base.d.ts +3 -2
- package/dist/realistic/element-base.js +8 -2
- package/dist/satellites/history.d.ts +237 -0
- package/dist/satellites/history.js +441 -0
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/track.d.ts +4 -1
- package/dist/satellites/track.js +132 -24
- package/dist/satellites/types.d.ts +7 -4
- package/dist/space/element-base.d.ts +78 -2
- package/dist/space/element-base.js +155 -8
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/path-ribbons.d.ts +2 -0
- package/dist/space/path-ribbons.js +2 -2
- package/dist/space/ride.d.ts +26 -5
- package/dist/space/ride.js +44 -9
- package/dist/space/satellite-layer.d.ts +9 -0
- package/dist/space/satellite-layer.js +70 -2
- package/dist/space/scene.d.ts +6 -0
- package/dist/space/scene.js +8 -2
- package/dist/space/trail.d.ts +117 -0
- package/dist/space/trail.js +152 -0
- package/package.json +1 -1
package/dist/satellites/track.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SGP4 for a group of satellites, kept cheap: the whole group is run at two moments a step apart and every position in between is an interpolation, so the cost is one batch a step
|
|
2
2
|
// (about once a second), never one a frame. satellite.js (MIT) does the SGP4 itself; this file never touches the screen and imports on a server.
|
|
3
|
-
import { json2satrec, sgp4 } from "satellite.js";
|
|
3
|
+
import { constants, json2satrec, sgp4 } from "satellite.js";
|
|
4
4
|
import { CLASS_COLOURS } from "../catalogue/kinds.js";
|
|
5
5
|
import { classOfElements } from "../catalogue/orbit.js";
|
|
6
6
|
import { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS } from "./limits.js";
|
|
@@ -27,6 +27,32 @@ const dateOf = (text) => {
|
|
|
27
27
|
};
|
|
28
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
29
|
const LOWEST_ESTIMATE_KM = 120;
|
|
30
|
+
/** How long after the hand-over to a steady orbit what is left of the gap between the two records is faded out, so the place never jumps. The gap is nothing for a low orbit and a few kilometres for a high one that carries a drag term. */
|
|
31
|
+
const STEADY_FADE_MS = DAY_MS;
|
|
32
|
+
/**
|
|
33
|
+
* How far the mean motion SGP4 has reached at the hand-over may be from the elements' own, as a ratio either way, for a steady orbit to be made from it. Thirty days of real drag or of an engine raising an orbit change it by a few hundredths;
|
|
34
|
+
* a large drag term run that long can run away to an orbit many times higher, which is the arithmetic and not the satellite, and is never held.
|
|
35
|
+
*/
|
|
36
|
+
const STEADY_MOST_CHANGE = 1.25;
|
|
37
|
+
const DEGREES = 180 / Math.PI;
|
|
38
|
+
const wholeTurn = (radians) => (((radians * DEGREES) % 360) + 360) % 360;
|
|
39
|
+
/**
|
|
40
|
+
* The mean motion an element set must state (Kozai's, radians a minute) for SGP4 to start from the mean motion `nm` (Brouwer's, which is what SGP4 itself works in and gives back).
|
|
41
|
+
* SGP4 turns the first into the second when it starts; this is that step run backwards, and it settles in a few rounds because the difference is about a thousandth.
|
|
42
|
+
*/
|
|
43
|
+
const statedMeanMotion = (nm, eccentricity, inclination) => {
|
|
44
|
+
const flat = 1 - eccentricity * eccentricity;
|
|
45
|
+
const cos = Math.cos(inclination);
|
|
46
|
+
const d1 = (0.75 * constants.j2 * (3 * cos * cos - 1)) / (Math.sqrt(flat) * flat);
|
|
47
|
+
let stated = nm;
|
|
48
|
+
for (let round = 0; round < 6; round += 1) {
|
|
49
|
+
const ak = Math.pow(constants.xke / stated, 2 / 3);
|
|
50
|
+
const del = d1 / (ak * ak);
|
|
51
|
+
const adel = ak * (1 - del * del - del * (1 / 3 + (134 * del * del) / 81));
|
|
52
|
+
stated = nm * (1 + d1 / (adel * adel));
|
|
53
|
+
}
|
|
54
|
+
return stated;
|
|
55
|
+
};
|
|
30
56
|
const epochOf = (text) => Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(text) ? text : `${text}Z`);
|
|
31
57
|
/**
|
|
32
58
|
* 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.
|
|
@@ -101,7 +127,6 @@ export function createSatellites(sets, options = {}) {
|
|
|
101
127
|
}
|
|
102
128
|
}
|
|
103
129
|
const n = recs.length;
|
|
104
|
-
const normal = new Float32Array(n * 3);
|
|
105
130
|
const rate = new Float64Array(n);
|
|
106
131
|
const classColour = new Float32Array(n * 3);
|
|
107
132
|
const eccentric = [];
|
|
@@ -111,13 +136,6 @@ export function createSatellites(sets, options = {}) {
|
|
|
111
136
|
const epoch = epochs[i];
|
|
112
137
|
if (epoch > newestEpochMs)
|
|
113
138
|
newestEpochMs = epoch;
|
|
114
|
-
const iRad = (set.INCLINATION * Math.PI) / 180;
|
|
115
|
-
const oRad = (set.RA_OF_ASC_NODE * Math.PI) / 180;
|
|
116
|
-
const si = Math.sin(iRad);
|
|
117
|
-
const ci = Math.cos(iRad);
|
|
118
|
-
normal[i * 3] = Math.sin(oRad) * si;
|
|
119
|
-
normal[i * 3 + 1] = ci;
|
|
120
|
-
normal[i * 3 + 2] = Math.cos(oRad) * si;
|
|
121
139
|
rate[i] = (set.MEAN_MOTION * 2 * Math.PI) / DAY_MS;
|
|
122
140
|
if (set.ECCENTRICITY >= ECCENTRIC_FROM)
|
|
123
141
|
eccentric.push(i);
|
|
@@ -145,7 +163,8 @@ export function createSatellites(sets, options = {}) {
|
|
|
145
163
|
let propagations = 0;
|
|
146
164
|
let placed = 0;
|
|
147
165
|
const timing = { lastBatchMs: 0, maxBatchMs: 0 };
|
|
148
|
-
let
|
|
166
|
+
let steady = options.estimateFar === "steady";
|
|
167
|
+
let estimate = steady || options.estimateFar === true;
|
|
149
168
|
let estimatedCount = 0;
|
|
150
169
|
/** 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. */
|
|
151
170
|
const usableAt = (i, ms) => {
|
|
@@ -156,8 +175,73 @@ export function createSatellites(sets, options = {}) {
|
|
|
156
175
|
const isFar = (i, ms) => estimate && Math.abs(ms - epochs[i]) > maxAgeMs;
|
|
157
176
|
/** A carried-far position that is down in the air or inside the Earth is no estimate (Earth radii). */
|
|
158
177
|
const tooLow = (x, y, z) => Math.hypot(x, y, z) < 1 + LOWEST_ESTIMATE_KM / EARTH_RADIUS_KM;
|
|
178
|
+
// each satellite's steady orbit after and before its elements, made the first time it is asked for (null: it cannot be made)
|
|
179
|
+
const steadyAfter = [];
|
|
180
|
+
const steadyBefore = [];
|
|
181
|
+
/**
|
|
182
|
+
* The orbit satellite `i` keeps beyond `maxAgeDays` with the drag off. It starts at that day from the mean elements SGP4 itself has reached there, so the two records give the same place at the hand-over
|
|
183
|
+
* (far under a millimetre for a low orbit; a high orbit starts its Sun and Moon terms again, which leaves a few kilometres, faded out over `STEADY_FADE_MS`).
|
|
184
|
+
* Elements with no drag term are already steady and are used as they are. Null when the elements cannot be carried to that day, or have run away by then (`STEADY_MOST_CHANGE`).
|
|
185
|
+
*/
|
|
186
|
+
const makeSteady = (i, after) => {
|
|
187
|
+
const rec = recs[i];
|
|
188
|
+
const epoch = epochs[i];
|
|
189
|
+
if (rec.bstar === 0)
|
|
190
|
+
return { rec, startMs: epoch, dx: 0, dy: 0, dz: 0 };
|
|
191
|
+
const startMs = Math.round(epoch + (after ? maxAgeMs : -maxAgeMs));
|
|
192
|
+
const last = sgp4(rec, (startMs - epoch) / 60_000);
|
|
193
|
+
if (!last || !last.position || !Number.isFinite(last.position.x))
|
|
194
|
+
return null;
|
|
195
|
+
const mean = last.meanElements;
|
|
196
|
+
const change = mean.nm / rec.no;
|
|
197
|
+
if (!(change <= STEADY_MOST_CHANGE && change >= 1 / STEADY_MOST_CHANGE))
|
|
198
|
+
return null;
|
|
199
|
+
try {
|
|
200
|
+
const held = json2satrec({
|
|
201
|
+
...usable[i],
|
|
202
|
+
EPOCH: new Date(startMs).toISOString(),
|
|
203
|
+
MEAN_MOTION: statedMeanMotion(mean.nm, mean.em, mean.im) * constants.xpdotp,
|
|
204
|
+
ECCENTRICITY: mean.em,
|
|
205
|
+
INCLINATION: mean.im * DEGREES,
|
|
206
|
+
RA_OF_ASC_NODE: wholeTurn(mean.Om),
|
|
207
|
+
ARG_OF_PERICENTER: wholeTurn(mean.om),
|
|
208
|
+
MEAN_ANOMALY: wholeTurn(mean.mm),
|
|
209
|
+
BSTAR: 0,
|
|
210
|
+
MEAN_MOTION_DOT: 0,
|
|
211
|
+
MEAN_MOTION_DDOT: 0,
|
|
212
|
+
});
|
|
213
|
+
const first = sgp4(held, 0);
|
|
214
|
+
if (!first || !first.position || held.error !== 0 || !Number.isFinite(first.position.x))
|
|
215
|
+
return null;
|
|
216
|
+
return { rec: held, startMs, dx: last.position.x - first.position.x, dy: last.position.y - first.position.y, dz: last.position.z - first.position.z };
|
|
217
|
+
}
|
|
218
|
+
catch {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
/** SGP4 for satellite `i` at one moment: from its elements, or, beyond `maxAgeDays` with `estimateFar: "steady"`, from its steady orbit. Null, or no position, when it cannot be placed. */
|
|
223
|
+
const carried = (i, ms) => {
|
|
224
|
+
const away = ms - epochs[i];
|
|
225
|
+
if (!steady || Math.abs(away) <= maxAgeMs)
|
|
226
|
+
return sgp4(recs[i], away / 60_000);
|
|
227
|
+
const made = away > 0 ? steadyAfter : steadyBefore;
|
|
228
|
+
const held = made[i] === undefined ? (made[i] = makeSteady(i, away > 0)) : made[i];
|
|
229
|
+
if (held === null)
|
|
230
|
+
return null;
|
|
231
|
+
const result = sgp4(held.rec, (ms - held.startMs) / 60_000);
|
|
232
|
+
const fade = 1 - Math.abs(ms - held.startMs) / STEADY_FADE_MS;
|
|
233
|
+
if (fade > 0 && result && result.position) {
|
|
234
|
+
result.position.x += held.dx * fade;
|
|
235
|
+
result.position.y += held.dy * fade;
|
|
236
|
+
result.position.z += held.dz * fade;
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
239
|
+
};
|
|
159
240
|
const pinned = new Float32Array(n * 3);
|
|
160
241
|
const pinOk = new Uint8Array(n);
|
|
242
|
+
// the unit normal of the orbit plane at each satellite's pin, from the pinned place and SGP4's velocity there (the plane of the moment pinned, not the plane of the elements: a low orbit's plane turns about 5 degrees a day).
|
|
243
|
+
// Worked out once for each pin, in `sample`, and only read by `arc`.
|
|
244
|
+
const pinNormal = new Float32Array(n * 3);
|
|
161
245
|
// 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
|
|
162
246
|
const pinMsOf = new Float64Array(n).fill(Number.NaN);
|
|
163
247
|
let pinnedCount = 0;
|
|
@@ -176,19 +260,18 @@ export function createSatellites(sets, options = {}) {
|
|
|
176
260
|
for (const i of eccentric)
|
|
177
261
|
isEccentric[i] = 1;
|
|
178
262
|
/** SGP4 for satellites `from` up to (not including) `to` at one moment (the whole group by default), into `buffer` in the space view's axes (TEME x, z, -y: x to the vernal equinox, y north). */
|
|
179
|
-
const sample = (buffer, ok, ms, from = 0, to = n, skipEccentric = false) => {
|
|
263
|
+
const sample = (buffer, ok, ms, from = 0, to = n, skipEccentric = false, axis) => {
|
|
180
264
|
const started = performance.now();
|
|
181
265
|
for (let i = from; i < to; i += 1) {
|
|
182
266
|
// an eccentric orbit is placed by SGP4 at every frame by `arc` and never read from a pin
|
|
183
267
|
if (skipEccentric && isEccentric[i] === 1)
|
|
184
268
|
continue;
|
|
185
|
-
const epoch = epochs[i];
|
|
186
269
|
if (!usableAt(i, ms)) {
|
|
187
270
|
ok[i] = 0;
|
|
188
271
|
continue;
|
|
189
272
|
}
|
|
190
273
|
propagations += 1;
|
|
191
|
-
const result =
|
|
274
|
+
const result = carried(i, ms);
|
|
192
275
|
const p = result && result.position;
|
|
193
276
|
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))) {
|
|
194
277
|
ok[i] = 0;
|
|
@@ -198,17 +281,41 @@ export function createSatellites(sets, options = {}) {
|
|
|
198
281
|
buffer[i * 3] = p.x / EARTH_RADIUS_KM;
|
|
199
282
|
buffer[i * 3 + 1] = p.z / EARTH_RADIUS_KM;
|
|
200
283
|
buffer[i * 3 + 2] = -p.y / EARTH_RADIUS_KM;
|
|
284
|
+
if (axis) {
|
|
285
|
+
// the orbit's normal is the place crossed with the velocity (both in the scene's axes: x, z, -y)
|
|
286
|
+
const v = result.velocity;
|
|
287
|
+
if (!v) {
|
|
288
|
+
ok[i] = 0;
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
const rx = p.x;
|
|
292
|
+
const ry = p.z;
|
|
293
|
+
const rz = -p.y;
|
|
294
|
+
const vx = v.x;
|
|
295
|
+
const vy = v.z;
|
|
296
|
+
const vz = -v.y;
|
|
297
|
+
const cx = ry * vz - rz * vy;
|
|
298
|
+
const cy = rz * vx - rx * vz;
|
|
299
|
+
const cz = rx * vy - ry * vx;
|
|
300
|
+
const length = Math.hypot(cx, cy, cz);
|
|
301
|
+
if (!(length > 0)) {
|
|
302
|
+
ok[i] = 0;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
axis[i * 3] = cx / length;
|
|
306
|
+
axis[i * 3 + 1] = cy / length;
|
|
307
|
+
axis[i * 3 + 2] = cz / length;
|
|
308
|
+
}
|
|
201
309
|
}
|
|
202
310
|
timing.lastBatchMs = performance.now() - started;
|
|
203
311
|
if (timing.lastBatchMs > timing.maxBatchMs)
|
|
204
312
|
timing.maxBatchMs = timing.lastBatchMs;
|
|
205
313
|
};
|
|
206
314
|
const exactAt = (index, ms, out) => {
|
|
207
|
-
|
|
208
|
-
if (epoch === undefined || !usableAt(index, ms))
|
|
315
|
+
if (epochs[index] === undefined || !usableAt(index, ms))
|
|
209
316
|
return false;
|
|
210
317
|
propagations += 1;
|
|
211
|
-
const result =
|
|
318
|
+
const result = carried(index, ms);
|
|
212
319
|
if (!result || !result.position || !result.velocity || !Number.isFinite(result.position.x))
|
|
213
320
|
return false;
|
|
214
321
|
if (isFar(index, ms) && tooLow(result.position.x / EARTH_RADIUS_KM, result.position.y / EARTH_RADIUS_KM, result.position.z / EARTH_RADIUS_KM))
|
|
@@ -244,12 +351,13 @@ export function createSatellites(sets, options = {}) {
|
|
|
244
351
|
return fastest;
|
|
245
352
|
},
|
|
246
353
|
get estimateFar() {
|
|
247
|
-
return estimate;
|
|
354
|
+
return steady ? "steady" : estimate;
|
|
248
355
|
},
|
|
249
356
|
set estimateFar(value) {
|
|
250
|
-
if (value === estimate)
|
|
357
|
+
if (value === (steady ? "steady" : estimate))
|
|
251
358
|
return;
|
|
252
|
-
|
|
359
|
+
steady = value === "steady";
|
|
360
|
+
estimate = steady || value === true;
|
|
253
361
|
// what was placed was placed under the other rule: place everything again, and draw each satellite's look again
|
|
254
362
|
ready = false;
|
|
255
363
|
pinnedCount = 0;
|
|
@@ -268,7 +376,7 @@ export function createSatellites(sets, options = {}) {
|
|
|
268
376
|
const to = Math.max(from, Math.min(n, from + Math.floor(count)));
|
|
269
377
|
if (to === from)
|
|
270
378
|
return;
|
|
271
|
-
sample(pinned, pinOk, ms, from, to, true);
|
|
379
|
+
sample(pinned, pinOk, ms, from, to, true, pinNormal);
|
|
272
380
|
for (let i = from; i < to; i += 1) {
|
|
273
381
|
if (Number.isNaN(pinMsOf[i]))
|
|
274
382
|
pinnedCount += 1;
|
|
@@ -282,7 +390,7 @@ export function createSatellites(sets, options = {}) {
|
|
|
282
390
|
const cap = maxLength > 0 && Number.isFinite(maxLength) ? maxLength : 0;
|
|
283
391
|
// a satellite never pinned is pinned now, all together
|
|
284
392
|
if (pinnedCount < n) {
|
|
285
|
-
sample(pinned, pinOk, ms, 0, n, true);
|
|
393
|
+
sample(pinned, pinOk, ms, 0, n, true, pinNormal);
|
|
286
394
|
pinMsOf.fill(ms);
|
|
287
395
|
pinnedCount = n;
|
|
288
396
|
}
|
|
@@ -336,9 +444,9 @@ export function createSatellites(sets, options = {}) {
|
|
|
336
444
|
shown[i] = 0;
|
|
337
445
|
continue;
|
|
338
446
|
}
|
|
339
|
-
const nx =
|
|
340
|
-
const ny =
|
|
341
|
-
const nz =
|
|
447
|
+
const nx = pinNormal[k];
|
|
448
|
+
const ny = pinNormal[k + 1];
|
|
449
|
+
const nz = pinNormal[k + 2];
|
|
342
450
|
let sweep = Math.max(-Math.PI, Math.min(Math.PI, rate[i] * span));
|
|
343
451
|
if (cap > 0) {
|
|
344
452
|
// along the orbit a turn of `sweep` is `sweep` times the height in Earth radii, so the cap is a turn of cap / height
|
|
@@ -80,7 +80,7 @@ export interface SatelliteInfo {
|
|
|
80
80
|
epochMs: number;
|
|
81
81
|
/** Days between the elements' moment and the moment asked about (negative before it). */
|
|
82
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. */
|
|
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, or, with `estimateFar: "steady"`, on the orbit it had at `maxAgeDays` with the air drag off. */
|
|
84
84
|
estimated: boolean;
|
|
85
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
86
|
estimatedDays: number;
|
|
@@ -175,8 +175,11 @@ export interface Satellites {
|
|
|
175
175
|
* the places already held, so it costs nothing at a frame; the view uses it to draw a frame whenever the quickest dot has moved half a pixel. Multiply by the Earth's radius on the screen for pixels.
|
|
176
176
|
*/
|
|
177
177
|
readonly fastest: number;
|
|
178
|
-
/**
|
|
179
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Place satellites beyond `maxAgeDays` from their elements as an estimate (`estimateFar`, off by default): `true` with the elements' air drag left in, so a low satellite sinks and is left out in time, `"steady"` with the drag off beyond `maxAgeDays`, so it keeps its usual orbit.
|
|
180
|
+
* Setting it places everything again at the next draw.
|
|
181
|
+
*/
|
|
182
|
+
estimateFar: boolean | "steady";
|
|
180
183
|
/** How many satellites the last `at` or `arc` placed as an estimate. */
|
|
181
184
|
readonly estimatedCount: number;
|
|
182
185
|
/** True if satellite `index` was placed by the last `at` or `arc` as an estimate: its moment is beyond `maxAgeDays` from its elements. */
|
|
@@ -194,7 +197,7 @@ export interface Satellites {
|
|
|
194
197
|
pin(ms: number, first?: number, count?: number): void;
|
|
195
198
|
/**
|
|
196
199
|
* 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).
|
|
197
|
-
* The place is the last `pin`, turned about the orbit's
|
|
200
|
+
* The place is the last `pin`, turned by the mean motion about the axis of the orbit plane at that pin (worked out once for each pin from the pinned place and SGP4's velocity there, not from the elements, whose plane has turned by days away), 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.
|
|
198
201
|
* Returns how many were written.
|
|
199
202
|
*/
|
|
200
203
|
arc(ms: number, spanMs: number, positions: Float32Array, segments: Float32Array, maxLength?: number): number;
|
|
@@ -16,6 +16,7 @@ import type { TileStats } from "../realistic/tile-set.ts";
|
|
|
16
16
|
import { setThreeLoader } from "../realistic/shared.ts";
|
|
17
17
|
import type { LightMode } from "../realistic/earth.ts";
|
|
18
18
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
19
|
+
import type { SatelliteHistory } from "../satellites/history.ts";
|
|
19
20
|
import { type PlanetName } from "./ephemeris.ts";
|
|
20
21
|
import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts";
|
|
21
22
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
@@ -130,7 +131,35 @@ export interface RideOptions {
|
|
|
130
131
|
drag?: RideDrag;
|
|
131
132
|
/** Which way is up in the view above a satellite (`view: "above"`): `travel` (the default, or the element's `ride-up`) puts the way the satellite is going at the top of the picture, `north` puts north there, so the satellite is seen to go the way it really goes over the ground. Within 3 degrees of a pole it is `travel` (mixed in smoothly out to 6). A drag turns the picture from there. */
|
|
132
133
|
up?: RideUp;
|
|
134
|
+
/** How far back the camera is kept from the satellite in an outside ride, in kilometres (`view: "from"`; the element's `ride-outside-km` when not given, else 25). It is never more than half the satellite's height. */
|
|
135
|
+
outsideKm?: number;
|
|
136
|
+
/** How long the glide to this ride lasts: a number of milliseconds (1200 by default), or `{ minMs, maxMs }` for a length that follows how far the camera has to move (`rideGlideMs`: 800 to 4000 ms by default, about 1.2 s for a 25 km hop and 3 s for 3,000 km). */
|
|
137
|
+
glide?: number | {
|
|
138
|
+
minMs?: number;
|
|
139
|
+
maxMs?: number;
|
|
140
|
+
};
|
|
141
|
+
distanceKm?: number;
|
|
142
|
+
smooth?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* What `observe` can be told: how many orbits of trail, its colour, and the ride's own distance and smoothness.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts no-run
|
|
149
|
+
* import type { ObserveOptions } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
150
|
+
*
|
|
151
|
+
* const options: ObserveOptions = { orbits: 5, colour: "#ffd479", distanceKm: 2000 };
|
|
152
|
+
* console.log(options.orbits);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
export interface ObserveOptions {
|
|
156
|
+
/** How many orbits of the satellite's path before the moment shown are drawn as its trail: 0.25 to 20, 3 when left out. */
|
|
157
|
+
orbits?: number;
|
|
158
|
+
/** Any CSS colour for the trail (a light blue when left out). */
|
|
159
|
+
colour?: string;
|
|
160
|
+
/** How far back the camera keeps from the satellite, kilometres (3000 when left out, as a followed satellite). */
|
|
133
161
|
distanceKm?: number;
|
|
162
|
+
/** Glide to the view (true when left out); false, or a reader who asked for reduced motion, jumps. */
|
|
134
163
|
smooth?: boolean;
|
|
135
164
|
}
|
|
136
165
|
/**
|
|
@@ -152,6 +181,8 @@ export interface Riding {
|
|
|
152
181
|
distanceKm: number;
|
|
153
182
|
/** `outside` or `inside` (see `RideOptions`). */
|
|
154
183
|
viewpoint: RideViewpoint;
|
|
184
|
+
/** How far back an outside ride keeps the camera, in kilometres (see `RideOptions`). */
|
|
185
|
+
outsideKm: number;
|
|
155
186
|
/** `distance` or `fixed` (see `RideOptions`). */
|
|
156
187
|
modelSize: RideModelSize;
|
|
157
188
|
/** `head` or `orbit` (see `RideOptions`). */
|
|
@@ -184,6 +215,8 @@ type SatelliteStats = {
|
|
|
184
215
|
selectedOpacity: number;
|
|
185
216
|
orbitLines: number;
|
|
186
217
|
estimated: number;
|
|
218
|
+
trailPoints: number;
|
|
219
|
+
trailBuilds: number;
|
|
187
220
|
};
|
|
188
221
|
/**
|
|
189
222
|
* 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.
|
|
@@ -574,6 +607,21 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
574
607
|
noradId: number;
|
|
575
608
|
name: string;
|
|
576
609
|
} | null;
|
|
610
|
+
/**
|
|
611
|
+
* How far back an outside ride keeps the camera from the satellite, in kilometres (the attribute `ride-outside-km`), or `null` for the package's own, `OUTSIDE_KM` (25). It is the default for the next `ride` (`RideOptions.outsideKm`) and, set while riding,
|
|
612
|
+
* moves the camera there in a glide of 0.8 s (a jump for a reader who asked for less motion). The camera is never more than half the satellite's height back.
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```ts
|
|
616
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
617
|
+
*
|
|
618
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
619
|
+
* space.rideOutsideKm = 100;
|
|
620
|
+
* console.log(space.rideOutsideKm);
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
623
|
+
get rideOutsideKm(): number | null;
|
|
624
|
+
set rideOutsideKm(value: number | null);
|
|
577
625
|
/**
|
|
578
626
|
* Where a ride puts the camera: `outside` (the default; the attribute `ride-viewpoint`) shows the satellite, `inside` puts the camera at it. It is the default for the next `ride` and, set while riding, moves the ride there in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock.
|
|
579
627
|
* See `RideOptions.viewpoint`.
|
|
@@ -740,6 +788,33 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
740
788
|
/** Texels the trail has painted. 0 after `clearPaint`, and again when the painted satellite changes. */
|
|
741
789
|
get paintPixels(): number;
|
|
742
790
|
setSatellites(group: string, satellites: Satellites | null, style?: Partial<SatelliteStyle>): void;
|
|
791
|
+
/**
|
|
792
|
+
* Give a satellite its history: a series of element sets, with its launch and decay dates, made by `createSatelliteHistory` (from `@johnmorrisdotca/chikyu-earth/satellites`, which needs satellite.js; this element does not import it).
|
|
793
|
+
* The satellite is set as the group `history:<id>` (one satellite, index 0) and is placed at any moment from the set nearest that moment: not drawn before its launch or after it has come down, shaded after its newest set
|
|
794
|
+
* (a prediction, with its uncertainty stated by `history.describe(ms)`). `null` takes it away. The page brings the sets: nothing is fetched.
|
|
795
|
+
*
|
|
796
|
+
* @param id - The NORAD catalogue number.
|
|
797
|
+
* @param history - What `createSatelliteHistory(sets, options)` returned, or `null` to remove it.
|
|
798
|
+
* @returns `{ group, index }` of the satellite, for `ride`, `observe` and `selectSatellite`, or `null` when removed or the history has no usable set.
|
|
799
|
+
*/
|
|
800
|
+
setSatelliteHistory(id: number, history: SatelliteHistory | null): SatelliteRef | null;
|
|
801
|
+
/** The history given to `setSatelliteHistory` for a satellite, or `undefined`: its `describe(ms)` says whether it is launched, tracked, predicted or down, and when. */
|
|
802
|
+
satelliteHistory(id: number): SatelliteHistory | undefined;
|
|
803
|
+
/**
|
|
804
|
+
* The Observe view: the camera outside a satellite (the follow view, 3000 km back by default) with the Earth turning and sliding beneath, and the satellite's trail over its last `orbits` orbits drawn behind it as one line.
|
|
805
|
+
* The trail is the satellite's own path before the moment shown, placed by the same SGP4 (from the set nearest each moment, for a satellite with a history), so it runs back at any clock speed and is shorter where the satellite
|
|
806
|
+
* was not yet launched. It is drawn only while the view is on, rebuilt only when the clock moves, and never at rest or out of sight. `null` stops, and so does any other `ride`.
|
|
807
|
+
*
|
|
808
|
+
* @param target - `{ group, index }`, or a NORAD number: first the history set with `setSatelliteHistory`, else the first group that has it.
|
|
809
|
+
* @param options - `orbits`, `colour`, `distanceKm`, `smooth`.
|
|
810
|
+
* @returns False when the satellite is not set (nothing changes).
|
|
811
|
+
*/
|
|
812
|
+
observe(target: SatelliteRef | number | null, options?: ObserveOptions): boolean;
|
|
813
|
+
/** What `observe` is showing now (`{ ref, orbits }`), or null. */
|
|
814
|
+
get observing(): {
|
|
815
|
+
ref: SatelliteRef;
|
|
816
|
+
orbits: number;
|
|
817
|
+
} | null;
|
|
743
818
|
/** Show or hide a group without losing it. */
|
|
744
819
|
showSatellites(group: string, on: boolean): void;
|
|
745
820
|
/**
|
|
@@ -787,6 +862,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
787
862
|
* 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
|
|
788
863
|
* 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);
|
|
789
864
|
* 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.
|
|
865
|
+
* **`estimate-far="steady"`** (the property set to `"steady"`) switches the air drag off beyond `maxAgeDays`, so a satellite keeps its usual orbit for as long as the clock runs instead of sinking in the model and being left out; the place does not jump where the drag is switched off.
|
|
790
866
|
* It applies to every group, those the page made with `createSatellites(sets, { estimateFar: true })` too.
|
|
791
867
|
*
|
|
792
868
|
* @example
|
|
@@ -800,8 +876,8 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
800
876
|
* console.log(typeof farFromToday);
|
|
801
877
|
* ```
|
|
802
878
|
*/
|
|
803
|
-
get estimateFar(): boolean;
|
|
804
|
-
set estimateFar(value: boolean);
|
|
879
|
+
get estimateFar(): boolean | "steady";
|
|
880
|
+
set estimateFar(value: boolean | "steady");
|
|
805
881
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
806
882
|
get selectedSatellite(): SatelliteRef | null;
|
|
807
883
|
/**
|