@johnmorrisdotca/chikyu-earth 0.36.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 +15 -0
- package/NOTICE.md +6 -1
- package/README.md +1 -1
- package/dist/catalogue/index.d.ts +1 -0
- package/dist/catalogue/index.js +3 -2
- package/dist/catalogue/pack.js +3 -0
- package/dist/cities/host.js +38 -8
- 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 +20 -11
- package/dist/realistic/element.d.ts +36 -3
- package/dist/realistic/element.js +82 -14
- package/dist/realistic/shaders.js +13 -0
- package/dist/realistic/textures.d.ts +2 -0
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/limits.d.ts +1 -1
- package/dist/satellites/limits.js +1 -1
- package/dist/satellites/owners.d.ts +26 -0
- package/dist/satellites/owners.js +164 -0
- package/dist/satellites/source.js +3 -0
- package/dist/satellites/track.d.ts +5 -0
- package/dist/satellites/track.js +146 -3
- package/dist/satellites/types.d.ts +22 -1
- package/dist/space/element.d.ts +56 -6
- package/dist/space/element.js +171 -16
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/ride.d.ts +42 -0
- package/dist/space/ride.js +45 -3
- package/dist/space/satellite-layer.d.ts +32 -2
- package/dist/space/satellite-layer.js +178 -19
- package/dist/space/scene.d.ts +12 -1
- package/dist/space/scene.js +27 -16
- package/package.json +1 -1
package/dist/satellites/track.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
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
3
|
import { json2satrec, sgp4 } from "satellite.js";
|
|
4
|
+
import { CLASS_COLOURS } from "../catalogue/kinds.js";
|
|
5
|
+
import { classOfElements } from "../catalogue/orbit.js";
|
|
4
6
|
import { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS } from "./limits.js";
|
|
7
|
+
import { ownerCountry } from "./owners.js";
|
|
5
8
|
/** The Earth's mean radius in kilometres: the unit of every position here (the same as the space view's). */
|
|
6
9
|
const EARTH_RADIUS_KM = 6371;
|
|
7
10
|
const DAY_MS = 86_400_000;
|
|
8
11
|
const MIN_STEP_MS = 1000;
|
|
9
12
|
const MAX_STEP_MS = 60_000;
|
|
13
|
+
/**
|
|
14
|
+
* From this eccentricity up, a satellite is not turned about its orbit's axis at the mean motion above the interpolation limit, because it does not go round at a steady rate or stay at one height
|
|
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
|
+
*/
|
|
17
|
+
export const ECCENTRIC_FROM = 0.02;
|
|
10
18
|
const epochOf = (text) => Date.parse(/[zZ]|[+-]\d\d:?\d\d$/.test(text) ? text : `${text}Z`);
|
|
11
19
|
/**
|
|
12
20
|
* 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.
|
|
@@ -73,6 +81,32 @@ export function createSatellites(sets, options = {}) {
|
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
const n = recs.length;
|
|
84
|
+
const normal = new Float32Array(n * 3);
|
|
85
|
+
const rate = new Float64Array(n);
|
|
86
|
+
const classColour = new Float32Array(n * 3);
|
|
87
|
+
const eccentric = [];
|
|
88
|
+
let newestEpochMs = 0;
|
|
89
|
+
for (let i = 0; i < n; i += 1) {
|
|
90
|
+
const set = usable[i];
|
|
91
|
+
const epoch = epochs[i];
|
|
92
|
+
if (epoch > newestEpochMs)
|
|
93
|
+
newestEpochMs = epoch;
|
|
94
|
+
const iRad = (set.INCLINATION * Math.PI) / 180;
|
|
95
|
+
const oRad = (set.RA_OF_ASC_NODE * Math.PI) / 180;
|
|
96
|
+
const si = Math.sin(iRad);
|
|
97
|
+
const ci = Math.cos(iRad);
|
|
98
|
+
normal[i * 3] = Math.sin(oRad) * si;
|
|
99
|
+
normal[i * 3 + 1] = ci;
|
|
100
|
+
normal[i * 3 + 2] = Math.cos(oRad) * si;
|
|
101
|
+
rate[i] = (set.MEAN_MOTION * 2 * Math.PI) / DAY_MS;
|
|
102
|
+
if (set.ECCENTRICITY >= ECCENTRIC_FROM)
|
|
103
|
+
eccentric.push(i);
|
|
104
|
+
const kind = classOfElements(set.MEAN_MOTION, set.ECCENTRICITY) ?? "other";
|
|
105
|
+
const hex = Number.parseInt(CLASS_COLOURS[kind].slice(1), 16);
|
|
106
|
+
classColour[i * 3] = ((hex >> 16) & 255) / 255;
|
|
107
|
+
classColour[i * 3 + 1] = ((hex >> 8) & 255) / 255;
|
|
108
|
+
classColour[i * 3 + 2] = (hex & 255) / 255;
|
|
109
|
+
}
|
|
76
110
|
let a = new Float32Array(n * 3);
|
|
77
111
|
let b = new Float32Array(n * 3);
|
|
78
112
|
let okA = new Uint8Array(n);
|
|
@@ -87,10 +121,32 @@ export function createSatellites(sets, options = {}) {
|
|
|
87
121
|
let propagations = 0;
|
|
88
122
|
let placed = 0;
|
|
89
123
|
const timing = { lastBatchMs: 0, maxBatchMs: 0 };
|
|
90
|
-
|
|
91
|
-
const
|
|
124
|
+
const pinned = new Float32Array(n * 3);
|
|
125
|
+
const pinOk = new Uint8Array(n);
|
|
126
|
+
// 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
|
|
127
|
+
const pinMsOf = new Float64Array(n).fill(Number.NaN);
|
|
128
|
+
let pinnedCount = 0;
|
|
129
|
+
/** Turn `x,y,z` about the unit axis `nx,ny,nz` by `ang` radians, into `out` at `at` (no allocation: it runs for every satellite on every frame). */
|
|
130
|
+
const turn = (x, y, z, nx, ny, nz, ang, out, at) => {
|
|
131
|
+
const c = Math.cos(ang);
|
|
132
|
+
const s = Math.sin(ang);
|
|
133
|
+
const dot = nx * x + ny * y + nz * z;
|
|
134
|
+
const k = 1 - c;
|
|
135
|
+
out[at] = x * c + (ny * z - nz * y) * s + nx * dot * k;
|
|
136
|
+
out[at + 1] = y * c + (nz * x - nx * z) * s + ny * dot * k;
|
|
137
|
+
out[at + 2] = z * c + (nx * y - ny * x) * s + nz * dot * k;
|
|
138
|
+
};
|
|
139
|
+
const place = new Float64Array(6);
|
|
140
|
+
const isEccentric = new Uint8Array(n);
|
|
141
|
+
for (const i of eccentric)
|
|
142
|
+
isEccentric[i] = 1;
|
|
143
|
+
/** 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). */
|
|
144
|
+
const sample = (buffer, ok, ms, from = 0, to = n, skipEccentric = false) => {
|
|
92
145
|
const started = performance.now();
|
|
93
|
-
for (let i =
|
|
146
|
+
for (let i = from; i < to; i += 1) {
|
|
147
|
+
// an eccentric orbit is placed by SGP4 at every frame by `arc` and never read from a pin
|
|
148
|
+
if (skipEccentric && isEccentric[i] === 1)
|
|
149
|
+
continue;
|
|
94
150
|
const epoch = epochs[i];
|
|
95
151
|
if (Math.abs(ms - epoch) > maxAgeMs) {
|
|
96
152
|
ok[i] = 0;
|
|
@@ -142,9 +198,93 @@ export function createSatellites(sets, options = {}) {
|
|
|
142
198
|
return propagations;
|
|
143
199
|
},
|
|
144
200
|
timing,
|
|
201
|
+
newestEpochMs,
|
|
202
|
+
classColour,
|
|
145
203
|
get placed() {
|
|
146
204
|
return placed;
|
|
147
205
|
},
|
|
206
|
+
pin(ms, first = 0, count = n) {
|
|
207
|
+
if (n === 0)
|
|
208
|
+
return;
|
|
209
|
+
const from = Math.max(0, Math.min(n, Math.floor(first)));
|
|
210
|
+
const to = Math.max(from, Math.min(n, from + Math.floor(count)));
|
|
211
|
+
if (to === from)
|
|
212
|
+
return;
|
|
213
|
+
sample(pinned, pinOk, ms, from, to, true);
|
|
214
|
+
for (let i = from; i < to; i += 1) {
|
|
215
|
+
if (Number.isNaN(pinMsOf[i]))
|
|
216
|
+
pinnedCount += 1;
|
|
217
|
+
pinMsOf[i] = ms;
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
arc(ms, spanMs, positions, segments) {
|
|
221
|
+
if (n === 0)
|
|
222
|
+
return 0;
|
|
223
|
+
// a satellite never pinned is pinned now, all together
|
|
224
|
+
if (pinnedCount < n) {
|
|
225
|
+
sample(pinned, pinOk, ms, 0, n, true);
|
|
226
|
+
pinMsOf.fill(ms);
|
|
227
|
+
pinnedCount = n;
|
|
228
|
+
}
|
|
229
|
+
const span = spanMs;
|
|
230
|
+
let count = 0;
|
|
231
|
+
for (let i = 0; i < n; i += 1) {
|
|
232
|
+
const k = i * 3;
|
|
233
|
+
const dim = Math.abs(ms - epochs[i]) > dimAfterMs ? 1 : 0;
|
|
234
|
+
if (dim !== dimmed[i]) {
|
|
235
|
+
dimmed[i] = dim;
|
|
236
|
+
dimVersion += 1;
|
|
237
|
+
}
|
|
238
|
+
const w = k * 2;
|
|
239
|
+
if (isEccentric[i] === 1) {
|
|
240
|
+
if (!exactAt(i, ms, place)) {
|
|
241
|
+
positions.fill(0, k, k + 3);
|
|
242
|
+
segments.fill(0, w, w + 6);
|
|
243
|
+
shown[i] = 0;
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
positions[k] = place[0];
|
|
247
|
+
positions[k + 1] = place[1];
|
|
248
|
+
positions[k + 2] = place[2];
|
|
249
|
+
segments[w + 3] = place[0];
|
|
250
|
+
segments[w + 4] = place[1];
|
|
251
|
+
segments[w + 5] = place[2];
|
|
252
|
+
if (exactAt(i, ms - span, place)) {
|
|
253
|
+
segments[w] = place[0];
|
|
254
|
+
segments[w + 1] = place[1];
|
|
255
|
+
segments[w + 2] = place[2];
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
segments[w] = positions[k];
|
|
259
|
+
segments[w + 1] = positions[k + 1];
|
|
260
|
+
segments[w + 2] = positions[k + 2];
|
|
261
|
+
}
|
|
262
|
+
shown[i] = 1;
|
|
263
|
+
count += 1;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (pinOk[i] !== 1) {
|
|
267
|
+
positions.fill(0, k, k + 3);
|
|
268
|
+
segments.fill(0, w, w + 6);
|
|
269
|
+
shown[i] = 0;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
const nx = normal[k];
|
|
273
|
+
const ny = normal[k + 1];
|
|
274
|
+
const nz = normal[k + 2];
|
|
275
|
+
const sweep = Math.max(-Math.PI, Math.min(Math.PI, rate[i] * span));
|
|
276
|
+
const along = rate[i] * (ms - pinMsOf[i]);
|
|
277
|
+
turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along, positions, k);
|
|
278
|
+
turn(pinned[k], pinned[k + 1], pinned[k + 2], nx, ny, nz, along - sweep, segments, w);
|
|
279
|
+
segments[w + 3] = positions[k];
|
|
280
|
+
segments[w + 4] = positions[k + 1];
|
|
281
|
+
segments[w + 5] = positions[k + 2];
|
|
282
|
+
shown[i] = 1;
|
|
283
|
+
count += 1;
|
|
284
|
+
}
|
|
285
|
+
placed = count;
|
|
286
|
+
return count;
|
|
287
|
+
},
|
|
148
288
|
setStep(ms) {
|
|
149
289
|
const next = Math.min(MAX_STEP_MS, Math.max(MIN_STEP_MS, Math.round(ms)));
|
|
150
290
|
if (next !== stepMs) {
|
|
@@ -235,6 +375,9 @@ export function createSatellites(sets, options = {}) {
|
|
|
235
375
|
periodMinutes: 1440 / set.MEAN_MOTION,
|
|
236
376
|
inclinationDeg: set.INCLINATION,
|
|
237
377
|
};
|
|
378
|
+
const country = ownerCountry(set.COUNTRY_CODE ?? set.OWNER);
|
|
379
|
+
if (country)
|
|
380
|
+
info.ownerCountry = country;
|
|
238
381
|
return info;
|
|
239
382
|
},
|
|
240
383
|
};
|
|
@@ -48,6 +48,10 @@ export interface ElementSet {
|
|
|
48
48
|
CLASSIFICATION_TYPE?: string;
|
|
49
49
|
ELEMENT_SET_NO?: number;
|
|
50
50
|
REV_AT_EPOCH?: number;
|
|
51
|
+
/** The owner's code, as one catalogue writes it (`US`, `PRC`, `ESA`), when the source carries it. */
|
|
52
|
+
COUNTRY_CODE?: string;
|
|
53
|
+
/** The owner's code, as the other catalogue writes it (the same codes), when the source carries it. */
|
|
54
|
+
OWNER?: string;
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* 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.
|
|
@@ -80,6 +84,8 @@ export interface SatelliteInfo {
|
|
|
80
84
|
periodMinutes: number;
|
|
81
85
|
/** Degrees. */
|
|
82
86
|
inclinationDeg: number;
|
|
87
|
+
/** The owner's country as an ISO 3166-1 alpha-2 code (`ownerCountry`), when the elements carry an owner code (`COUNTRY_CODE` or `OWNER`) and the owner is one country; absent for an organisation, several countries, an ambiguous owner or an unknown code. */
|
|
88
|
+
ownerCountry?: string;
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* A satellite chosen from a group: which group and which place in it.
|
|
@@ -154,10 +160,25 @@ export interface Satellites {
|
|
|
154
160
|
at(ms: number, out: Float32Array): void;
|
|
155
161
|
/** True if satellite `index` was placed by the last `at` (its elements are not too old at that moment). */
|
|
156
162
|
visible(index: number): boolean;
|
|
157
|
-
/** How many of them the last `at` placed. */
|
|
163
|
+
/** How many of them the last `at` or `arc` placed. */
|
|
158
164
|
readonly placed: number;
|
|
165
|
+
/** 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
|
+
readonly newestEpochMs: number;
|
|
167
|
+
/** Red, green and blue, from 0 to 1, of each satellite's orbit class, 3 numbers a satellite. It does not change. */
|
|
168
|
+
readonly classColour: Float32Array;
|
|
159
169
|
/** The game time between the two moments SGP4 is run at (1000 to 60000 ms); the space view sets it from the clock's speed. */
|
|
160
170
|
setStep(ms: number): void;
|
|
171
|
+
/**
|
|
172
|
+
* Place satellites with SGP4 at `ms` and keep that place, and the time it was kept at: every satellite, or `count` of them from index `first`, so a big group can be pinned a slice a frame instead of all in one.
|
|
173
|
+
* `arc` turns each satellite along its orbit from its own last pin. No interpolation. A satellite never pinned is pinned by the first `arc`.
|
|
174
|
+
*/
|
|
175
|
+
pin(ms: number, first?: number, count?: number): void;
|
|
176
|
+
/**
|
|
177
|
+
* The place of each satellite at `ms` into `positions` (3 numbers each) and the stretch of orbit it travels over `spanMs` of game time into `segments` (6 numbers each: where it was `spanMs` earlier, then where it is).
|
|
178
|
+
* The place is the last `pin`, turned about the orbit's axis by the mean motion, so a fast clock does not run SGP4 for every satellite on every frame. A `spanMs` that would turn it more than half a revolution is cut there. An orbit with an eccentricity of 0.02 or more is placed by SGP4 itself instead (two calls a frame), because a turn at the mean motion would put it off its path.
|
|
179
|
+
* Returns how many were written.
|
|
180
|
+
*/
|
|
181
|
+
arc(ms: number, spanMs: number, positions: Float32Array, segments: Float32Array): number;
|
|
161
182
|
/** One satellite at exactly `ms` (no interpolation): position in Earth radii and velocity in km/s into `out` (6 numbers). False if its elements are too old or SGP4 gave up. */
|
|
162
183
|
exact(index: number, ms: number, out: Float64Array): boolean;
|
|
163
184
|
/** The path of satellite `index` for one revolution from `ms`, `points` + 1 points in order along it (the last on the first), into a new array of Earth radii. */
|
package/dist/space/element.d.ts
CHANGED
|
@@ -14,9 +14,10 @@ import type { LightMode } from "../realistic/earth.ts";
|
|
|
14
14
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
15
15
|
import { type PlanetName } from "./ephemeris.ts";
|
|
16
16
|
import { type SatelliteStyle } from "./satellite-layer.ts";
|
|
17
|
-
import { type RideLook } from "./ride.ts";
|
|
17
|
+
import { type RideFace, type RideLook } from "./ride.ts";
|
|
18
18
|
import { type ScaleMode } from "./scale.ts";
|
|
19
19
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
20
|
+
import { type PaintSpec } from "../paint/buffer.ts";
|
|
20
21
|
export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
21
22
|
/**
|
|
22
23
|
* Change how the Sun and the planets are drawn (before the first element connects): the space view keeps their places, sizes, light, names and orbits and asks
|
|
@@ -93,7 +94,7 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
|
|
|
93
94
|
/**
|
|
94
95
|
* How a ride along is done: `view` `from` (the default) puts the camera at the body looking at the Earth, `follow` keeps it a fixed distance from the body looking at it (`distanceKm`, 3000 by default,
|
|
95
96
|
* for a satellite; a planet or the Moon is kept at the distance the zoom says); `above` (a satellite only; a body is followed) puts it on the line from the Earth's centre through the satellite, `distanceKm` (divided by the zoom) above it, looking straight down at it with the way it is going at the top
|
|
96
|
-
* of the picture, the satellite held in the middle while the Earth turns beneath (a drag turns the picture about the satellite and tips the camera back or ahead of it); `look` `down` (the default) or `horizon` is where a camera at the body points; `smooth` (the default) glides
|
|
97
|
+
* of the picture, the satellite held in the middle while the Earth turns beneath (a drag turns the picture about the satellite and tips the camera back or ahead of it); `look` `down` (the default) or `horizon` is where a camera at the body points; `face` opens looking one way (see `face`); `smooth` (the default) glides
|
|
97
98
|
* from the old camera to the new one in about a second and a bit, and jumps instead for a reader who asked for reduced motion.
|
|
98
99
|
*
|
|
99
100
|
* @example
|
|
@@ -107,11 +108,13 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
|
|
|
107
108
|
export interface RideOptions {
|
|
108
109
|
view?: "from" | "follow" | "above";
|
|
109
110
|
look?: RideLook;
|
|
111
|
+
/** Face this way as the ride opens (`face`). */
|
|
112
|
+
face?: RideFace;
|
|
110
113
|
distanceKm?: number;
|
|
111
114
|
smooth?: boolean;
|
|
112
115
|
}
|
|
113
116
|
/**
|
|
114
|
-
* What the camera is riding along with now: the body or satellite, how (`from` or `
|
|
117
|
+
* What the camera is riding along with now: the body or satellite, how (`from`, `follow` or `above`), where it looks, the facing it looks round from (`null` when none was chosen), and the distance kept for a satellite.
|
|
115
118
|
*
|
|
116
119
|
* @example
|
|
117
120
|
* ```ts no-run
|
|
@@ -125,12 +128,16 @@ export interface Riding {
|
|
|
125
128
|
target: RideTarget;
|
|
126
129
|
view: "from" | "follow" | "above";
|
|
127
130
|
look: RideLook;
|
|
131
|
+
face: RideFace | null;
|
|
128
132
|
distanceKm: number;
|
|
129
133
|
}
|
|
130
134
|
type SatelliteStats = {
|
|
131
135
|
groups: number;
|
|
132
136
|
placed: number;
|
|
137
|
+
segments: number;
|
|
133
138
|
tooFast: boolean;
|
|
139
|
+
dotScale: number;
|
|
140
|
+
epochMs: number;
|
|
134
141
|
propagations: number;
|
|
135
142
|
lastBatchMs: number;
|
|
136
143
|
maxBatchMs: number;
|
|
@@ -164,6 +171,9 @@ type SatelliteStats = {
|
|
|
164
171
|
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
165
172
|
* space.setAttribute("time", "2026-11-02T12:00Z");
|
|
166
173
|
* space.setAttribute("speed", "86400");
|
|
174
|
+
* space.placeGroups = false; // place-groups="off": every place keeps its own ring
|
|
175
|
+
* space.paint = { id: "25544", length: "1w", swath: "coverage" };
|
|
176
|
+
* space.clearPaint();
|
|
167
177
|
* space.addEventListener("chikyu-timechange", (event) => {
|
|
168
178
|
* const { time, running } = (event as CustomEvent<{ time: number; running: boolean }>).detail;
|
|
169
179
|
* console.log(new Date(time).toISOString(), running ? "running" : "held");
|
|
@@ -254,6 +264,17 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
254
264
|
}): Promise<Place | undefined>;
|
|
255
265
|
/**
|
|
256
266
|
* Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts no-run
|
|
270
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
271
|
+
*
|
|
272
|
+
* const space = document.querySelector("chikyu-space") as ChikyuSpace;
|
|
273
|
+
* space.placeGroups = false;
|
|
274
|
+
* space.getAttribute("place-groups"); // "off"
|
|
275
|
+
* space.placeGroups = true;
|
|
276
|
+
* space.hasAttribute("place-groups"); // false
|
|
277
|
+
* ```
|
|
257
278
|
*/
|
|
258
279
|
get placeGroups(): boolean;
|
|
259
280
|
set placeGroups(value: boolean);
|
|
@@ -358,6 +379,19 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
358
379
|
* @param options - `view`, `look`, `distanceKm`, `smooth` (see `RideOptions`).
|
|
359
380
|
*/
|
|
360
381
|
ride(target: RideTarget | null, options?: RideOptions): void;
|
|
382
|
+
/**
|
|
383
|
+
* Face one way while riding: `ahead` along the way it goes, `behind`, `left` or `right` (as seen facing ahead), `down` straight at the Earth, `up` straight away from it.
|
|
384
|
+
* In the `above` view, `down` looks straight down at the satellite and the Earth below it. The camera glides there in half a second (at once for a reader who asked for reduced motion) and keeps the zoom.
|
|
385
|
+
* The facing stays pressed until the view is turned or tipped. `chikyu-ride-face` is sent with `{ face }` (`null` when it is let go). Keys, while the element is focused: W ahead, S behind, A left, D right, R up, F down. The arrow keys stay with the view controls.
|
|
386
|
+
*
|
|
387
|
+
* @param face - The way to face.
|
|
388
|
+
* Following a body (a planet, the Moon) there is no way to face: it returns `false`. Held keys do not repeat, and keys typed in a field or in editable text are left to it.
|
|
389
|
+
*
|
|
390
|
+
* @returns Whether the camera faces that way now (`true` too when it already did, and nothing moves).
|
|
391
|
+
*/
|
|
392
|
+
face(face: RideFace): boolean;
|
|
393
|
+
/** The facing (`face`), while the view has not been turned or tipped from it; `null` otherwise. */
|
|
394
|
+
get facing(): RideFace | null;
|
|
361
395
|
/**
|
|
362
396
|
* The satellites the page has a model for (`setSatellitePainter`) in the groups now set, each with its name in the page's language: the large satellites that can be followed as a model. Empty with no painter.
|
|
363
397
|
*/
|
|
@@ -379,15 +413,29 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
379
413
|
} | null;
|
|
380
414
|
/** What the camera is riding along with now, or null. */
|
|
381
415
|
get riding(): Riding | null;
|
|
416
|
+
/**
|
|
417
|
+
* Colour each satellite by its orbit class (low, medium, geostationary, highly elliptical, other). Off by default, so a group keeps the colour it was given. The attribute is `satellite-tint="orbit"`.
|
|
418
|
+
*/
|
|
419
|
+
get satelliteTint(): "off" | "orbit";
|
|
420
|
+
set satelliteTint(value: "off" | "orbit");
|
|
382
421
|
/**
|
|
383
422
|
* Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds. Giving the name of a group
|
|
384
423
|
* that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations).
|
|
385
|
-
* The groups are placed by SGP4 about once a second and interpolated between
|
|
424
|
+
* The groups are placed by SGP4 about once a second and interpolated between. Above `MAX_SATELLITE_SPEED` each satellite is a short streak along its orbit instead of being hidden.
|
|
386
425
|
*
|
|
387
426
|
* @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
|
|
388
427
|
* @param satellites - The group, or `null` to remove it.
|
|
389
428
|
* @param style - How to draw it.
|
|
390
429
|
*/
|
|
430
|
+
/**
|
|
431
|
+
* Paint one satellite's path on the Earth. `id` is a NORAD catalogue number or `group:index`. `length` is how long the trail is kept, in simulated time (`1d` when left out, or `1w`, `1m`). `swath` is `track` (the point under the satellite, the default) or `coverage` (where it is at least 10° above the horizon). Setting another satellite clears the trail. `null` clears it.
|
|
432
|
+
*/
|
|
433
|
+
get paint(): PaintSpec | null;
|
|
434
|
+
set paint(value: PaintSpec | null);
|
|
435
|
+
/** Take the painted trail off the Earth. */
|
|
436
|
+
clearPaint(): void;
|
|
437
|
+
/** Texels the trail has painted. 0 after `clearPaint`, and again when the painted satellite changes. */
|
|
438
|
+
get paintPixels(): number;
|
|
391
439
|
setSatellites(group: string, satellites: Satellites | null, style?: Partial<SatelliteStyle>): void;
|
|
392
440
|
/** Show or hide a group without losing it. */
|
|
393
441
|
showSatellites(group: string, on: boolean): void;
|
|
@@ -427,7 +475,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
427
475
|
visible: boolean;
|
|
428
476
|
heightKm: number;
|
|
429
477
|
} | null;
|
|
430
|
-
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
|
|
478
|
+
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period, and `ownerCountry` when the owner is one country); undefined if it cannot be placed then. */
|
|
431
479
|
satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
|
|
432
480
|
/** The words shown beside each body, for a page in another language (`{ Mars: "火星" }`). A body left out keeps its English name. */
|
|
433
481
|
get bodyNames(): Partial<Record<BodyName, string>>;
|
|
@@ -462,6 +510,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
462
510
|
riding: boolean;
|
|
463
511
|
lost: boolean;
|
|
464
512
|
gliding: boolean;
|
|
513
|
+
facing: RideFace | null;
|
|
465
514
|
};
|
|
466
515
|
/** The camera as the last draw left it: its place in Earth radii from the Earth's centre, the way it is turned (a unit quaternion, x y z w) and its field of view in degrees. */
|
|
467
516
|
camera: {
|
|
@@ -523,7 +572,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
523
572
|
} | null;
|
|
524
573
|
/**
|
|
525
574
|
* The places: how many were handed over, how many are in sight at the last draw (`shown`, those gathered into groups included), how many stand up as markers of their own (`marks`) and are named (`labels`),
|
|
526
|
-
* how many rings the one draw call draws (`sprites`) and how many of
|
|
575
|
+
* how many rings the one draw call draws (`sprites`; 0 when the picture cannot draw them), how many circles the page draws instead (`dots`) and how many of the rings are groups (`groups`), the satellites ringed and named, and how many times they were laid out.
|
|
527
576
|
*/
|
|
528
577
|
places: {
|
|
529
578
|
places: number;
|
|
@@ -535,6 +584,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
535
584
|
marks: number;
|
|
536
585
|
groups: number;
|
|
537
586
|
sprites: number;
|
|
587
|
+
dots: number;
|
|
538
588
|
omitted: number;
|
|
539
589
|
};
|
|
540
590
|
/** The names of cities: whether `city-names` is set and the most it asks for, the Earth's radius on the screen, the tiers of kuni's cities that have arrived and how many cities, the names shown at the last draw and how many times the layer was drawn. */
|