@johnmorrisdotca/chikyu-earth 0.53.0 → 0.54.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 +9 -0
- package/README.md +2 -2
- package/dist/flat/colours.d.ts +22 -0
- package/dist/flat/colours.js +22 -0
- package/dist/flat/element.d.ts +18 -1
- package/dist/flat/element.js +111 -22
- package/dist/flat/index.d.ts +2 -1
- package/dist/flat/index.js +2 -1
- package/dist/flat/track-state.d.ts +174 -0
- package/dist/flat/track-state.js +223 -0
- package/dist/flat/words.js +10 -0
- package/dist/passes/index.d.ts +2 -1
- package/dist/passes/index.js +1 -1
- package/dist/passes/passes.d.ts +34 -0
- package/dist/passes/passes.js +43 -2
- package/dist/realistic/element-base.d.ts +6 -0
- package/dist/realistic/element-base.js +15 -2
- package/dist/space/compass.d.ts +36 -0
- package/dist/space/compass.js +72 -0
- package/dist/space/element-base.d.ts +48 -1
- package/dist/space/element-base.js +95 -6
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +1 -0
- package/dist/space/north-up.d.ts +86 -0
- package/dist/space/north-up.js +104 -0
- package/dist/space/path-controls.d.ts +1 -1
- package/dist/space/path-controls.js +13 -2
- package/dist/space/path-ribbons.d.ts +4 -0
- package/dist/space/path-ribbons.js +8 -4
- package/dist/space/satellite-layer.d.ts +5 -0
- package/dist/space/satellite-layer.js +16 -4
- package/dist/space/scene.d.ts +23 -0
- package/dist/space/scene.js +18 -1
- package/package.json +1 -1
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Which way a satellite is going over the ground, and whether the Sun lights it: from its place and velocity alone. Pure: no DOM, no clock and no dependency (not even satellite.js), so a page, a build step or a server can write "heading SE 128 degrees, in sunlight" from numbers it already has.
|
|
2
|
+
// `groundTrackState(elements, ms)` in `@johnmorrisdotca/chikyu-earth/passes` runs SGP4 for you and hands the result here.
|
|
3
|
+
import { greenwichSidereal, subsolarPoint } from "../realistic/sun.js";
|
|
4
|
+
const RAD = Math.PI / 180;
|
|
5
|
+
/** The Earth's equatorial radius, kilometres (WGS84). */
|
|
6
|
+
const A = 6378.137;
|
|
7
|
+
/** The Earth's flattening (WGS84). */
|
|
8
|
+
const F = 1 / 298.257223563;
|
|
9
|
+
const E2 = F * (2 - F);
|
|
10
|
+
/** The Earth's turn, radians a second. */
|
|
11
|
+
const OMEGA = 7.292115e-5;
|
|
12
|
+
/** One Earth radius of the package's scene units, kilometres (the satellites' places are in these). */
|
|
13
|
+
const SCENE_KM = 6371;
|
|
14
|
+
/**
|
|
15
|
+
* The radius of the Earth's shadow, kilometres: the Earth's equatorial radius (6,378.137 km). The shadow is a cylinder of this radius along the line from the Sun through the Earth's centre (the cylindrical model: the edge of a conical umbra
|
|
16
|
+
* leans in by about 0.26 degrees, so where a satellite at 400 km enters the shadow the cylinder's edge is about 11 km outside the cone's, a few seconds of an orbit, and no penumbra is drawn). A satellite is in shadow when it is on the night side of the centre and inside the cylinder.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { SHADOW_RADIUS_KM } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
21
|
+
*
|
|
22
|
+
* console.log(SHADOW_RADIUS_KM);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const SHADOW_RADIUS_KM = A;
|
|
26
|
+
/**
|
|
27
|
+
* The Sun as a unit vector in the Earth-fixed axes (x through longitude 0 on the equator, y east, z north) at `ms`, from the same low-precision Sun as the night side of the maps.
|
|
28
|
+
*
|
|
29
|
+
* @param ms - A moment, in milliseconds since the Unix epoch.
|
|
30
|
+
* @returns The unit vector from the Earth's centre towards the Sun.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { sunDirection } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
35
|
+
*
|
|
36
|
+
* const sun = sunDirection(Date.UTC(2026, 5, 21, 12));
|
|
37
|
+
* console.log(sun.map((n) => n.toFixed(2)));
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function sunDirection(ms) {
|
|
41
|
+
const sun = subsolarPoint(ms);
|
|
42
|
+
const lat = sun.lat * RAD;
|
|
43
|
+
const lon = sun.lon * RAD;
|
|
44
|
+
return [Math.cos(lat) * Math.cos(lon), Math.cos(lat) * Math.sin(lon), Math.sin(lat)];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Is a point in the Earth's shadow? Cylindrical model: behind the Earth's centre from the Sun and nearer the Sun-Earth line than {@link SHADOW_RADIUS_KM}.
|
|
48
|
+
*
|
|
49
|
+
* @param position - The point, kilometres from the Earth's centre, in any axes.
|
|
50
|
+
* @param sun - The unit vector towards the Sun, in the same axes.
|
|
51
|
+
* @returns True in shadow, false in sunlight (a point exactly on the terminator plane is sunlit).
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { inEarthShadow } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
56
|
+
*
|
|
57
|
+
* // the Sun along +x: a satellite 7,000 km out on the far side is in shadow, one at the same distance beside the Earth is not
|
|
58
|
+
* console.log(inEarthShadow([-7000, 0, 0], [1, 0, 0]), inEarthShadow([0, 7000, 0], [1, 0, 0]));
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export function inEarthShadow(position, sun) {
|
|
62
|
+
const along = position[0] * sun[0] + position[1] * sun[1] + position[2] * sun[2];
|
|
63
|
+
if (along >= 0)
|
|
64
|
+
return false;
|
|
65
|
+
const r2 = position[0] * position[0] + position[1] * position[1] + position[2] * position[2];
|
|
66
|
+
return r2 - along * along < A * A;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Where a satellite is over the ground, how it is going and whether the Sun lights it, from its place and velocity in the axes SGP4 uses (TEME: x to the vernal equinox, z north, y a quarter turn east of x) and the moment. The
|
|
70
|
+
* velocity is turned into the ground's frame by taking the Earth's turn out of it, so the bearing is the way the ground track runs, as a map draws it.
|
|
71
|
+
*
|
|
72
|
+
* @param position - Kilometres from the Earth's centre, TEME.
|
|
73
|
+
* @param velocity - Kilometres a second, TEME.
|
|
74
|
+
* @param ms - The moment, in milliseconds since the Unix epoch.
|
|
75
|
+
* @returns Latitude, longitude, height, bearing, ascending or descending, and sunlit.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { trackStateOf } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
80
|
+
*
|
|
81
|
+
* // 420 km over the equator going north at 7.66 km a second
|
|
82
|
+
* const at = Date.UTC(2026, 10, 3, 12);
|
|
83
|
+
* const state = trackStateOf([6798, 0, 0], [0, 0, 7.66], at);
|
|
84
|
+
* console.log(state.ascending, Math.round(state.heightKm));
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export function trackStateOf(position, velocity, ms) {
|
|
88
|
+
const theta = greenwichSidereal(ms) * RAD;
|
|
89
|
+
const c = Math.cos(theta);
|
|
90
|
+
const s = Math.sin(theta);
|
|
91
|
+
// the Earth-fixed axes: turn by the sidereal angle about the pole
|
|
92
|
+
const x = c * position[0] + s * position[1];
|
|
93
|
+
const y = -s * position[0] + c * position[1];
|
|
94
|
+
const z = position[2];
|
|
95
|
+
// the velocity as the ground sees it: turned the same way, less the ground's own motion (omega x r)
|
|
96
|
+
const vx = c * velocity[0] + s * velocity[1] + OMEGA * y;
|
|
97
|
+
const vy = -s * velocity[0] + c * velocity[1] - OMEGA * x;
|
|
98
|
+
const vz = velocity[2];
|
|
99
|
+
const lon = Math.atan2(y, x);
|
|
100
|
+
const p = Math.hypot(x, y);
|
|
101
|
+
// the geodetic latitude and height, by iteration (a few steps settle it to well under a metre)
|
|
102
|
+
let lat = Math.atan2(z, p * (1 - E2));
|
|
103
|
+
let n = A;
|
|
104
|
+
for (let i = 0; i < 6; i += 1) {
|
|
105
|
+
const sin = Math.sin(lat);
|
|
106
|
+
n = A / Math.sqrt(1 - E2 * sin * sin);
|
|
107
|
+
lat = Math.atan2(z + E2 * n * sin, p);
|
|
108
|
+
}
|
|
109
|
+
const cosLat = Math.cos(lat);
|
|
110
|
+
const sinLat = Math.sin(lat);
|
|
111
|
+
const heightKm = Math.abs(cosLat) > 1e-9 ? p / cosLat - n : Math.abs(z) / Math.abs(sinLat) - n * (1 - E2);
|
|
112
|
+
const cosLon = Math.cos(lon);
|
|
113
|
+
const sinLon = Math.sin(lon);
|
|
114
|
+
const east = -sinLon * vx + cosLon * vy;
|
|
115
|
+
const north = -sinLat * cosLon * vx - sinLat * sinLon * vy + cosLat * vz;
|
|
116
|
+
const moving = Math.hypot(east, north) > 1e-9;
|
|
117
|
+
const bearing = moving ? ((Math.atan2(east, north) / RAD) % 360 + 360) % 360 : 0;
|
|
118
|
+
return {
|
|
119
|
+
lat: lat / RAD,
|
|
120
|
+
lon: ((((lon / RAD) % 360) + 540) % 360) - 180,
|
|
121
|
+
heightKm,
|
|
122
|
+
bearingDeg: bearing,
|
|
123
|
+
ascending: north > 0,
|
|
124
|
+
sunlit: !inEarthShadow([x, y, z], sunDirection(ms)),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The same as {@link trackStateOf}, for a place and velocity in the package's own satellite axes (what `createSatellites(...).exact` and the space view give): Earth radii of 6,371 km, x to the vernal equinox, y north, z the other way from TEME's y; the velocity in kilometres a second in the same axes.
|
|
129
|
+
*
|
|
130
|
+
* @param place - Earth radii from the Earth's centre.
|
|
131
|
+
* @param velocity - Kilometres a second.
|
|
132
|
+
* @param ms - The moment, in milliseconds since the Unix epoch.
|
|
133
|
+
* @returns Latitude, longitude, height, bearing, ascending or descending, and sunlit.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { trackStateOfScene } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
138
|
+
*
|
|
139
|
+
* const state = trackStateOfScene([1.0665, 0, 0], [0, 7.66, 0], Date.UTC(2026, 10, 3, 12));
|
|
140
|
+
* console.log(state.ascending);
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export function trackStateOfScene(place, velocity, ms) {
|
|
144
|
+
return trackStateOf([place[0] * SCENE_KM, -place[2] * SCENE_KM, place[1] * SCENE_KM], [velocity[0], -velocity[2], velocity[1]], ms);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The eight points of the compass, from north clockwise.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```ts
|
|
151
|
+
* import { COMPASS_POINTS } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
152
|
+
*
|
|
153
|
+
* console.log(COMPASS_POINTS.join(" "));
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export const COMPASS_POINTS = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
|
|
157
|
+
/**
|
|
158
|
+
* The point of the compass a bearing is nearest to: 0 is N, 45 NE, 90 E, 135 SE, 180 S and so on, each point taking 45 degrees (22.5 either side).
|
|
159
|
+
*
|
|
160
|
+
* @param bearingDeg - Degrees clockwise from north.
|
|
161
|
+
* @returns N, NE, E, SE, S, SW, W or NW.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { compassPoint } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
166
|
+
*
|
|
167
|
+
* console.log(compassPoint(128), compassPoint(350));
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
export function compassPoint(bearingDeg) {
|
|
171
|
+
return COMPASS_POINTS[Math.round((((bearingDeg % 360) + 360) % 360) / 45) % 8];
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The Sun as a unit vector in the satellites' own axes (x to the vernal equinox, y north, z the other way from TEME's y: what `createSatellites` and the space view use) at `ms`.
|
|
175
|
+
*
|
|
176
|
+
* @param ms - A moment, in milliseconds since the Unix epoch.
|
|
177
|
+
* @returns The unit vector from the Earth's centre towards the Sun.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* ```ts
|
|
181
|
+
* import { sunDirectionScene } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
182
|
+
*
|
|
183
|
+
* console.log(sunDirectionScene(Date.UTC(2026, 2, 20, 9)).map((n) => n.toFixed(2)));
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export function sunDirectionScene(ms) {
|
|
187
|
+
const fixed = sunDirection(ms);
|
|
188
|
+
const theta = greenwichSidereal(ms) * RAD;
|
|
189
|
+
const c = Math.cos(theta);
|
|
190
|
+
const s = Math.sin(theta);
|
|
191
|
+
// Earth-fixed back to the stars (TEME), then into the satellites' axes
|
|
192
|
+
const x = c * fixed[0] - s * fixed[1];
|
|
193
|
+
const y = s * fixed[0] + c * fixed[1];
|
|
194
|
+
return [x, fixed[2], -y];
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Which points of a path are in the Earth's shadow: 1 for in shadow, 0 for in sunlight (the cylindrical model, {@link SHADOW_RADIUS_KM}), for places in the satellites' own axes in Earth radii of 6,371 km. The Sun is taken as fixed over the path, which holds for the one revolution a path is (the Sun moves a quarter of a degree in that time).
|
|
198
|
+
*
|
|
199
|
+
* @param positions - Three numbers a point, Earth radii.
|
|
200
|
+
* @param count - How many points.
|
|
201
|
+
* @param sun - The unit vector towards the Sun in the same axes (`sunDirectionScene`).
|
|
202
|
+
* @param out - Where to put the flags, one a point.
|
|
203
|
+
* @returns `out`.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { shadowFlags } from "@johnmorrisdotca/chikyu-earth/flat";
|
|
208
|
+
*
|
|
209
|
+
* // the Sun along +x: the point behind the Earth is in shadow, the one in front of it is not
|
|
210
|
+
* console.log(shadowFlags(new Float32Array([-1.1, 0, 0, 1.1, 0, 0]), 2, [1, 0, 0], new Uint8Array(2)));
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export function shadowFlags(positions, count, sun, out) {
|
|
214
|
+
const radius = SHADOW_RADIUS_KM / SCENE_KM;
|
|
215
|
+
for (let i = 0; i < count; i += 1) {
|
|
216
|
+
const x = positions[i * 3];
|
|
217
|
+
const y = positions[i * 3 + 1];
|
|
218
|
+
const z = positions[i * 3 + 2];
|
|
219
|
+
const along = x * sun[0] + y * sun[1] + z * sun[2];
|
|
220
|
+
out[i] = along < 0 && x * x + y * y + z * z - along * along < radius * radius ? 1 : 0;
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
package/dist/flat/words.js
CHANGED
|
@@ -35,6 +35,11 @@ export const FLAT_WORDS = {
|
|
|
35
35
|
nothing: "No satellite to show.",
|
|
36
36
|
help: "Arrow keys move from one satellite to the next, Enter chooses it, plus and minus zoom.",
|
|
37
37
|
shown: "{count} satellites shown",
|
|
38
|
+
trackSunlit: "In sunlight",
|
|
39
|
+
trackShadow: "In the Earth's shadow",
|
|
40
|
+
trackKey: "Ground track colours",
|
|
41
|
+
sunlitNow: ", in sunlight",
|
|
42
|
+
shadowNow: ", in the Earth's shadow",
|
|
38
43
|
},
|
|
39
44
|
ja: {
|
|
40
45
|
map: "世界の平面地図の上の衛星",
|
|
@@ -62,6 +67,11 @@ export const FLAT_WORDS = {
|
|
|
62
67
|
nothing: "表示する衛星がありません。",
|
|
63
68
|
help: "矢印キーで次の衛星へ移り、Enter キーで選びます。プラスとマイナスで拡大・縮小します。",
|
|
64
69
|
shown: "{count} 機を表示中",
|
|
70
|
+
trackSunlit: "日なた",
|
|
71
|
+
trackShadow: "地球の影の中",
|
|
72
|
+
trackKey: "地上軌跡の色",
|
|
73
|
+
sunlitNow: "、日なた",
|
|
74
|
+
shadowNow: "、地球の影の中",
|
|
65
75
|
},
|
|
66
76
|
};
|
|
67
77
|
/** The words with their `{name}` places filled in. */
|
package/dist/passes/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { compassOf, findPasses, groundTrack, passPath, satelliteAt, skyAt, sunAltitude, type Compass, type GroundPoint, type Observer, type PassOptions, type PassPoint, type PassReason, type PassWindow, type PathPoint, type SatellitePass, type SkyName, type VisiblePart, } from "./passes.ts";
|
|
1
|
+
export { compassOf, findPasses, groundTrack, groundTrackState, passPath, satelliteAt, skyAt, sunAltitude, type Compass, type GroundPoint, type Observer, type PassOptions, type PassPoint, type PassReason, type PassWindow, type PathPoint, type SatellitePass, type SkyName, type VisiblePart, } from "./passes.ts";
|
|
2
2
|
export { ESTIMATED_CROSS_SECTIONS, magnitude, standardMagnitude, STANDARD_MAGNITUDES } from "./magnitudes.ts";
|
|
3
3
|
export { skySvg, type SkyLabels, type SkyOptions } from "./sky.ts";
|
|
4
|
+
export type { GroundTrackState } from "../flat/track-state.ts";
|
package/dist/passes/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// The passes' pure parts: when a satellite crosses the sky over a place, how it looks, and the sky dome that draws it. They need satellite.js (an optional peer) and import in a browser or on a server.
|
|
2
|
-
export { compassOf, findPasses, groundTrack, passPath, satelliteAt, skyAt, sunAltitude, } from "./passes.js";
|
|
2
|
+
export { compassOf, findPasses, groundTrack, groundTrackState, passPath, satelliteAt, skyAt, sunAltitude, } from "./passes.js";
|
|
3
3
|
export { ESTIMATED_CROSS_SECTIONS, magnitude, standardMagnitude, STANDARD_MAGNITUDES } from "./magnitudes.js";
|
|
4
4
|
export { skySvg } from "./sky.js";
|
package/dist/passes/passes.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type GroundTrackState } from "../flat/track-state.ts";
|
|
1
2
|
import type { ElementSet } from "../satellites/types.ts";
|
|
2
3
|
/**
|
|
3
4
|
* Where the watcher stands: degrees of latitude (north is positive) and longitude (east is positive), and the height above sea level in metres (0 by default).
|
|
@@ -363,6 +364,8 @@ export interface GroundPoint {
|
|
|
363
364
|
lon: number;
|
|
364
365
|
/** Height above the Earth's surface, kilometres. */
|
|
365
366
|
altitudeKm: number;
|
|
367
|
+
/** True when the Sun lights the satellite there, false when it is in the Earth's shadow (the cylindrical model, as `satelliteAt` and `passPath` use). */
|
|
368
|
+
sunlit: boolean;
|
|
366
369
|
}
|
|
367
370
|
/**
|
|
368
371
|
* The places straight under a satellite from one moment to another: its ground track. Use a pass's `start.ms` and `end.ms` for the track of one pass, to draw on a globe.
|
|
@@ -397,3 +400,34 @@ export interface GroundPoint {
|
|
|
397
400
|
* ```
|
|
398
401
|
*/
|
|
399
402
|
export declare function groundTrack(set: ElementSet, fromMs: number, toMs: number, stepSeconds?: number): GroundPoint[];
|
|
403
|
+
/**
|
|
404
|
+
* Where one satellite is over the ground at one moment, which way it is going and whether the Sun lights it: latitude, longitude, height, the bearing of its ground track (degrees clockwise from north, with the Earth's turn taken out), ascending or descending, and sunlit
|
|
405
|
+
* (the cylindrical shadow model). SGP4 places it; the rest is {@link trackStateOf}, which does the same from a place and a velocity you already have. Undefined where SGP4 gives no place.
|
|
406
|
+
*
|
|
407
|
+
* @param set - The satellite's elements.
|
|
408
|
+
* @param ms - The moment, milliseconds since the Unix epoch.
|
|
409
|
+
* @returns The state, or undefined.
|
|
410
|
+
*
|
|
411
|
+
* @example
|
|
412
|
+
* ```ts
|
|
413
|
+
* import { groundTrackState } from "@johnmorrisdotca/chikyu-earth/passes";
|
|
414
|
+
*
|
|
415
|
+
* const iss = {
|
|
416
|
+
* OBJECT_NAME: "ISS (ZARYA)",
|
|
417
|
+
* EPOCH: "2026-11-02T10:25:21.580320",
|
|
418
|
+
* MEAN_MOTION: 15.49150046,
|
|
419
|
+
* ECCENTRICITY: 0.0007139,
|
|
420
|
+
* INCLINATION: 51.6332,
|
|
421
|
+
* RA_OF_ASC_NODE: 335.9757,
|
|
422
|
+
* ARG_OF_PERICENTER: 339.3739,
|
|
423
|
+
* MEAN_ANOMALY: 20.6961,
|
|
424
|
+
* NORAD_CAT_ID: 25544,
|
|
425
|
+
* BSTAR: 0.00012,
|
|
426
|
+
* MEAN_MOTION_DOT: 0.0001,
|
|
427
|
+
* MEAN_MOTION_DDOT: 0,
|
|
428
|
+
* };
|
|
429
|
+
* const state = groundTrackState(iss, Date.UTC(2026, 10, 3, 12));
|
|
430
|
+
* console.log(state && `${state.bearingDeg.toFixed(0)} degrees, ${state.ascending ? "ascending" : "descending"}, ${state.sunlit ? "sunlit" : "in shadow"}`);
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
export declare function groundTrackState(set: ElementSet, ms: number): GroundTrackState | undefined;
|
package/dist/passes/passes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// When a satellite crosses the sky over a place. SGP4 (satellite.js, an optional peer) puts the satellite in the sky, this package's own Sun position says whether the watcher's sky is dark and whether
|
|
2
2
|
// the satellite is in sunlight, and the brightness follows from the standard magnitude. Pure: no DOM, no clock (the window is given), no state; it imports on a server.
|
|
3
3
|
import { ecfToLookAngles, eciToEcf, eciToGeodetic, geodeticToEcf, gstime, json2satrec, sgp4 } from "satellite.js";
|
|
4
|
+
import { inEarthShadow, trackStateOf } from "../flat/track-state.js";
|
|
4
5
|
import { subsolarPoint } from "../realistic/sun.js";
|
|
5
6
|
import { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS } from "../satellites/limits.js";
|
|
6
7
|
import { magnitude, STANDARD_MAGNITUDES } from "./magnitudes.js";
|
|
@@ -459,11 +460,51 @@ export function groundTrack(set, fromMs, toMs, stepSeconds = 10) {
|
|
|
459
460
|
const t = Math.min(ms, toMs);
|
|
460
461
|
const sample = sgp4(rec, (t - epoch) / 60_000);
|
|
461
462
|
if (sample && sample.position && Number.isFinite(sample.position.x)) {
|
|
462
|
-
const
|
|
463
|
-
|
|
463
|
+
const gmst = gstime(new Date(t));
|
|
464
|
+
const place = eciToGeodetic(sample.position, gmst);
|
|
465
|
+
const ecf = eciToEcf(sample.position, gmst);
|
|
466
|
+
out.push({ ms: t, lat: place.latitude / RAD, lon: ((((place.longitude / RAD) % 360) + 540) % 360) - 180, altitudeKm: place.height, sunlit: !inEarthShadow([ecf.x, ecf.y, ecf.z], sunVector(t)) });
|
|
464
467
|
}
|
|
465
468
|
if (t >= toMs)
|
|
466
469
|
break;
|
|
467
470
|
}
|
|
468
471
|
return out;
|
|
469
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* Where one satellite is over the ground at one moment, which way it is going and whether the Sun lights it: latitude, longitude, height, the bearing of its ground track (degrees clockwise from north, with the Earth's turn taken out), ascending or descending, and sunlit
|
|
475
|
+
* (the cylindrical shadow model). SGP4 places it; the rest is {@link trackStateOf}, which does the same from a place and a velocity you already have. Undefined where SGP4 gives no place.
|
|
476
|
+
*
|
|
477
|
+
* @param set - The satellite's elements.
|
|
478
|
+
* @param ms - The moment, milliseconds since the Unix epoch.
|
|
479
|
+
* @returns The state, or undefined.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```ts
|
|
483
|
+
* import { groundTrackState } from "@johnmorrisdotca/chikyu-earth/passes";
|
|
484
|
+
*
|
|
485
|
+
* const iss = {
|
|
486
|
+
* OBJECT_NAME: "ISS (ZARYA)",
|
|
487
|
+
* EPOCH: "2026-11-02T10:25:21.580320",
|
|
488
|
+
* MEAN_MOTION: 15.49150046,
|
|
489
|
+
* ECCENTRICITY: 0.0007139,
|
|
490
|
+
* INCLINATION: 51.6332,
|
|
491
|
+
* RA_OF_ASC_NODE: 335.9757,
|
|
492
|
+
* ARG_OF_PERICENTER: 339.3739,
|
|
493
|
+
* MEAN_ANOMALY: 20.6961,
|
|
494
|
+
* NORAD_CAT_ID: 25544,
|
|
495
|
+
* BSTAR: 0.00012,
|
|
496
|
+
* MEAN_MOTION_DOT: 0.0001,
|
|
497
|
+
* MEAN_MOTION_DDOT: 0,
|
|
498
|
+
* };
|
|
499
|
+
* const state = groundTrackState(iss, Date.UTC(2026, 10, 3, 12));
|
|
500
|
+
* console.log(state && `${state.bearingDeg.toFixed(0)} degrees, ${state.ascending ? "ascending" : "descending"}, ${state.sunlit ? "sunlit" : "in shadow"}`);
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
export function groundTrackState(set, ms) {
|
|
504
|
+
const rec = json2satrec(set);
|
|
505
|
+
const sample = sgp4(rec, (ms - epochOf(set.EPOCH)) / 60_000);
|
|
506
|
+
if (!sample || !sample.position || !sample.velocity || !Number.isFinite(sample.position.x))
|
|
507
|
+
return undefined;
|
|
508
|
+
const { position: p, velocity: v } = sample;
|
|
509
|
+
return trackStateOf([p.x, p.y, p.z], [v.x, v.y, v.z], ms);
|
|
510
|
+
}
|
|
@@ -636,6 +636,12 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
636
636
|
*/
|
|
637
637
|
get selectedPath(): boolean;
|
|
638
638
|
set selectedPath(value: boolean);
|
|
639
|
+
/**
|
|
640
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
641
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
642
|
+
*/
|
|
643
|
+
get pathLight(): boolean;
|
|
644
|
+
set pathLight(value: boolean);
|
|
639
645
|
/**
|
|
640
646
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
641
647
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -165,7 +165,7 @@ export const readTime = (value) => {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
168
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far"];
|
|
168
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far"];
|
|
169
169
|
#model = newModel();
|
|
170
170
|
#paint = createPaintState();
|
|
171
171
|
#mode = "now";
|
|
@@ -556,7 +556,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
556
556
|
}
|
|
557
557
|
else if (name === "hover-path" || name === "names-on-hover")
|
|
558
558
|
this.#hover?.sync();
|
|
559
|
-
else if (name === "selected-path")
|
|
559
|
+
else if (name === "selected-path" || name === "path-light")
|
|
560
560
|
this.#pathControls?.sync();
|
|
561
561
|
else if (name === "estimate-far")
|
|
562
562
|
this.#applyEstimate();
|
|
@@ -1562,6 +1562,19 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1562
1562
|
else
|
|
1563
1563
|
this.setAttribute("selected-path", "off");
|
|
1564
1564
|
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
1567
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
1568
|
+
*/
|
|
1569
|
+
get pathLight() {
|
|
1570
|
+
return !/^(off|false|no|0)$/i.test((this.getAttribute("path-light") ?? "").trim());
|
|
1571
|
+
}
|
|
1572
|
+
set pathLight(value) {
|
|
1573
|
+
if (value)
|
|
1574
|
+
this.removeAttribute("path-light");
|
|
1575
|
+
else
|
|
1576
|
+
this.setAttribute("path-light", "off");
|
|
1577
|
+
}
|
|
1565
1578
|
/**
|
|
1566
1579
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
1567
1580
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CompassPoint } from "../flat/track-state.ts";
|
|
2
|
+
import type { RideTrack } from "./scene.ts";
|
|
3
|
+
/** The two languages' words of the compass. `{point}` is the point of the compass and `{deg}` the bearing in whole degrees. */
|
|
4
|
+
export declare const COMPASS_WORDS: {
|
|
5
|
+
readonly en: {
|
|
6
|
+
readonly north: "N";
|
|
7
|
+
readonly heading: "Heading {point} {deg}°";
|
|
8
|
+
readonly label: "Compass: north is shown by the arrow. Heading {point}, {deg} degrees.";
|
|
9
|
+
readonly points: Record<CompassPoint, string>;
|
|
10
|
+
};
|
|
11
|
+
readonly ja: {
|
|
12
|
+
readonly north: "北";
|
|
13
|
+
readonly heading: "進行方向 {point} {deg}°";
|
|
14
|
+
readonly label: "方位磁針:矢印が北を指します。進行方向は{point}、{deg}度。";
|
|
15
|
+
readonly points: Record<CompassPoint, string>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** The styles of the compass (`#compass`) in an element's shadow root. The dial is white lines on a dark disc, the way-it-goes dot yellow, so it reads on the sea, the land, the night and the day alike; `--chikyu-compass-colour` and `--chikyu-compass-travel` change them. */
|
|
19
|
+
export declare const COMPASS_STYLE = "#compass{position:absolute;left:8px;top:8px;display:flex;flex-direction:column;align-items:center;gap:2px;pointer-events:none;color:var(--chikyu-compass-colour,#fff);font:11px/1.2 system-ui,-apple-system,sans-serif}#compass[hidden]{display:none}#compass svg{width:64px;height:64px;display:block;overflow:visible}#compass .disc{fill:#0b0e14b3;stroke:currentColor;stroke-opacity:.55;stroke-width:1}#compass .north{fill:currentColor}#compass .south{fill:currentColor;fill-opacity:.35}#compass .travel{fill:var(--chikyu-compass-travel,#ffd166);stroke:#0b0e14;stroke-width:1}#compass text{fill:currentColor;font:600 11px system-ui,-apple-system,sans-serif;text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#0b0e14;stroke-width:2.5px}#compass .words{background:#0b0e14b3;padding:1px 6px;border-radius:4px;white-space:nowrap}#compass .words[hidden]{display:none}";
|
|
20
|
+
/** The compass's markup: put it in the shadow root and hand it to `createCompass`. */
|
|
21
|
+
export declare const COMPASS_HTML = "<div id=\"compass\" role=\"img\" hidden><svg viewBox=\"-36 -36 72 72\" aria-hidden=\"true\"><circle class=\"disc\" r=\"25\"></circle><g class=\"arrow\"><path class=\"north\" d=\"M0 -21 L5 -3 L0 -7 L-5 -3 Z\"></path><path class=\"south\" d=\"M0 21 L4 4 L0 7 L-4 4 Z\"></path></g><text class=\"n\" x=\"0\" y=\"-31\">N</text><circle class=\"travel\" r=\"3.4\" cx=\"0\" cy=\"-25\"></circle></svg><span class=\"words\"></span></div>";
|
|
22
|
+
export type CompassMode = "full" | "north" | "off";
|
|
23
|
+
/** Read the attribute `compass`: `off` takes the compass away, `north` shows the arrow without the words, anything else (or nothing) shows both. */
|
|
24
|
+
export declare function readCompass(value: string | null): CompassMode;
|
|
25
|
+
export interface Compass {
|
|
26
|
+
/** Show what the last draw found (or hide the compass for `null`). Changes the page only when something it shows moved by half a degree (the words: a whole degree), the language or the mode changed, so a view at rest does nothing. */
|
|
27
|
+
update(track: RideTrack | null, lang: "en" | "ja", mode: CompassMode): void;
|
|
28
|
+
/** What the compass shows now, for a test: the angle of the arrow, the angle of the dot and the words; `null` when it is hidden. */
|
|
29
|
+
readonly shown: {
|
|
30
|
+
northDeg: number;
|
|
31
|
+
travelDeg: number | null;
|
|
32
|
+
text: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}
|
|
35
|
+
/** Take the markup the element put in its shadow root and make the compass of it. */
|
|
36
|
+
export declare function createCompass(root: ShadowRoot): Compass;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The compass mark on a ride's picture: a small dial in the element's shadow root with an arrow that points to north, a dot on its rim for the way the satellite is going, and the heading in words ("Heading SE 128°"). It is a few DOM nodes, not the graphics card's,
|
|
2
|
+
// and it is changed only by the draw that moves it, and only when what it shows has changed by half a degree: a picture at rest touches nothing.
|
|
3
|
+
import { compassPoint } from "../flat/track-state.js";
|
|
4
|
+
/** The two languages' words of the compass. `{point}` is the point of the compass and `{deg}` the bearing in whole degrees. */
|
|
5
|
+
export const COMPASS_WORDS = {
|
|
6
|
+
en: { north: "N", heading: "Heading {point} {deg}°", label: "Compass: north is shown by the arrow. Heading {point}, {deg} degrees.", points: { N: "N", NE: "NE", E: "E", SE: "SE", S: "S", SW: "SW", W: "W", NW: "NW" } },
|
|
7
|
+
ja: { north: "北", heading: "進行方向 {point} {deg}°", label: "方位磁針:矢印が北を指します。進行方向は{point}、{deg}度。", points: { N: "北", NE: "北東", E: "東", SE: "南東", S: "南", SW: "南西", W: "西", NW: "北西" } },
|
|
8
|
+
};
|
|
9
|
+
/** The styles of the compass (`#compass`) in an element's shadow root. The dial is white lines on a dark disc, the way-it-goes dot yellow, so it reads on the sea, the land, the night and the day alike; `--chikyu-compass-colour` and `--chikyu-compass-travel` change them. */
|
|
10
|
+
export const COMPASS_STYLE = "#compass{position:absolute;left:8px;top:8px;display:flex;flex-direction:column;align-items:center;gap:2px;pointer-events:none;color:var(--chikyu-compass-colour,#fff);font:11px/1.2 system-ui,-apple-system,sans-serif}#compass[hidden]{display:none}#compass svg{width:64px;height:64px;display:block;overflow:visible}#compass .disc{fill:#0b0e14b3;stroke:currentColor;stroke-opacity:.55;stroke-width:1}#compass .north{fill:currentColor}#compass .south{fill:currentColor;fill-opacity:.35}#compass .travel{fill:var(--chikyu-compass-travel,#ffd166);stroke:#0b0e14;stroke-width:1}#compass text{fill:currentColor;font:600 11px system-ui,-apple-system,sans-serif;text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#0b0e14;stroke-width:2.5px}#compass .words{background:#0b0e14b3;padding:1px 6px;border-radius:4px;white-space:nowrap}#compass .words[hidden]{display:none}";
|
|
11
|
+
/** The compass's markup: put it in the shadow root and hand it to `createCompass`. */
|
|
12
|
+
export const COMPASS_HTML = '<div id="compass" role="img" hidden><svg viewBox="-36 -36 72 72" aria-hidden="true"><circle class="disc" r="25"></circle><g class="arrow"><path class="north" d="M0 -21 L5 -3 L0 -7 L-5 -3 Z"></path><path class="south" d="M0 21 L4 4 L0 7 L-4 4 Z"></path></g><text class="n" x="0" y="-31">N</text><circle class="travel" r="3.4" cx="0" cy="-25"></circle></svg><span class="words"></span></div>';
|
|
13
|
+
/** Read the attribute `compass`: `off` takes the compass away, `north` shows the arrow without the words, anything else (or nothing) shows both. */
|
|
14
|
+
export function readCompass(value) {
|
|
15
|
+
const text = (value ?? "").trim().toLowerCase();
|
|
16
|
+
return text === "off" || text === "false" || text === "no" || text === "none" ? "off" : text === "north" ? "north" : "full";
|
|
17
|
+
}
|
|
18
|
+
/** Take the markup the element put in its shadow root and make the compass of it. */
|
|
19
|
+
export function createCompass(root) {
|
|
20
|
+
const box = root.getElementById("compass");
|
|
21
|
+
const arrow = box.querySelector(".arrow");
|
|
22
|
+
const letter = box.querySelector("text.n");
|
|
23
|
+
const dot = box.querySelector(".travel");
|
|
24
|
+
const words = box.querySelector(".words");
|
|
25
|
+
let key = "";
|
|
26
|
+
let shown = null;
|
|
27
|
+
return {
|
|
28
|
+
update(track, lang, mode) {
|
|
29
|
+
if (!track || mode === "off" || track.northDeg === null) {
|
|
30
|
+
if (!box.hidden)
|
|
31
|
+
box.hidden = true;
|
|
32
|
+
key = "";
|
|
33
|
+
shown = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const north = Math.round(track.northDeg * 2) / 2;
|
|
37
|
+
const travel = track.travelDeg === null ? null : Math.round(track.travelDeg * 2) / 2;
|
|
38
|
+
const bearing = Math.round(track.bearingDeg) % 360;
|
|
39
|
+
const next = `${north}|${travel}|${bearing}|${lang}|${mode}`;
|
|
40
|
+
if (next === key && !box.hidden)
|
|
41
|
+
return;
|
|
42
|
+
key = next;
|
|
43
|
+
const set = COMPASS_WORDS[lang];
|
|
44
|
+
const text = set.heading.replace("{point}", set.points[compassPoint(bearing)]).replace("{deg}", String(bearing));
|
|
45
|
+
arrow.setAttribute("transform", `rotate(${north})`);
|
|
46
|
+
// the letter stays upright, at the arrow's tip
|
|
47
|
+
const a = north * (Math.PI / 180);
|
|
48
|
+
letter.setAttribute("x", (31 * Math.sin(a)).toFixed(2));
|
|
49
|
+
letter.setAttribute("y", (-31 * Math.cos(a)).toFixed(2));
|
|
50
|
+
if (letter.textContent !== set.north)
|
|
51
|
+
letter.textContent = set.north;
|
|
52
|
+
if (travel === null)
|
|
53
|
+
dot.setAttribute("visibility", "hidden");
|
|
54
|
+
else {
|
|
55
|
+
dot.removeAttribute("visibility");
|
|
56
|
+
const t = travel * (Math.PI / 180);
|
|
57
|
+
dot.setAttribute("cx", (25 * Math.sin(t)).toFixed(2));
|
|
58
|
+
dot.setAttribute("cy", (-25 * Math.cos(t)).toFixed(2));
|
|
59
|
+
}
|
|
60
|
+
words.textContent = text;
|
|
61
|
+
words.hidden = mode === "north";
|
|
62
|
+
box.setAttribute("aria-label", set.label.replace("{point}", set.points[compassPoint(bearing)]).replace("{deg}", String(bearing)));
|
|
63
|
+
box.lang = lang;
|
|
64
|
+
if (box.hidden)
|
|
65
|
+
box.hidden = false;
|
|
66
|
+
shown = { northDeg: north, travelDeg: travel, text };
|
|
67
|
+
},
|
|
68
|
+
get shown() {
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -21,9 +21,10 @@ import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts"
|
|
|
21
21
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
22
22
|
import { type PathStats } from "./path-controls.ts";
|
|
23
23
|
import { type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
24
|
+
import type { RideUp } from "./north-up.ts";
|
|
24
25
|
import { type RideDrag, type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
25
26
|
import { type ScaleMode } from "./scale.ts";
|
|
26
|
-
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
27
|
+
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type RideTrack, type SatellitePainter } from "./scene.ts";
|
|
27
28
|
import { type PaintSpec } from "../paint/buffer.ts";
|
|
28
29
|
export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
29
30
|
/**
|
|
@@ -127,6 +128,8 @@ export interface RideOptions {
|
|
|
127
128
|
modelSize?: RideModelSize;
|
|
128
129
|
/** What a drag does in an outside ride from the satellite (`view: "from"`): `head` (the default, or the element's `ride-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it; `orbit` takes the camera round the satellite as it looks about, so the satellite stays in the same place in the picture and is seen from every side, as a ride did up to 0.51. */
|
|
129
130
|
drag?: RideDrag;
|
|
131
|
+
/** 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
|
+
up?: RideUp;
|
|
130
133
|
distanceKm?: number;
|
|
131
134
|
smooth?: boolean;
|
|
132
135
|
}
|
|
@@ -153,6 +156,8 @@ export interface Riding {
|
|
|
153
156
|
modelSize: RideModelSize;
|
|
154
157
|
/** `head` or `orbit` (see `RideOptions`). */
|
|
155
158
|
drag: RideDrag;
|
|
159
|
+
/** `travel` or `north` (see `RideOptions`). */
|
|
160
|
+
up: RideUp;
|
|
156
161
|
}
|
|
157
162
|
type SatelliteStats = {
|
|
158
163
|
groups: number;
|
|
@@ -606,6 +611,36 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
606
611
|
*/
|
|
607
612
|
get rideDrag(): RideDrag;
|
|
608
613
|
set rideDrag(value: RideDrag);
|
|
614
|
+
/**
|
|
615
|
+
* Which way is up in the picture of a ride above a satellite (the attribute `ride-up`): `travel` (the default) keeps the way the satellite is going at the top, so the picture turns as the heading does; `north` keeps north at the top, so the satellite is seen to go south-east, or whichever way
|
|
616
|
+
* it really goes over the ground. Within 3 degrees of a pole north-up gives way to travel-up (mixed in smoothly out to 6 degrees), because there north's direction swings round faster than a picture can follow. A drag turns the picture from the up it has, so with `north` a drag turns it away from north, and the compass shows where north has gone.
|
|
617
|
+
* It is the default for the next `ride` and, set while riding, turns the picture to the new up in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock. The other views (`from`, `follow`) keep the way it is going at the top. See `RideOptions.up`.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```ts
|
|
621
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
622
|
+
*
|
|
623
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
624
|
+
* space.rideUp = "north";
|
|
625
|
+
* console.log(space.rideUp);
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
get rideUp(): RideUp;
|
|
629
|
+
set rideUp(value: RideUp);
|
|
630
|
+
/**
|
|
631
|
+
* Where the ridden satellite is over the ground and how it is going, as of the last draw: `lat`, `lon`, `heightKm`, `bearingDeg` (the way its ground track runs, degrees clockwise from north, with the Earth's turn taken out), `ascending` (going north), `sunlit` (the Sun lights it; the Earth's shadow is a cylinder),
|
|
632
|
+
* and where north is in the picture: `northDeg` (degrees clockwise from the top; 0 means north is at the top) and `travelDeg` (the way it goes, in the picture). `null` when no satellite is ridden or followed. A page that prints "heading SE 128°" reads `bearingDeg` and needs no maths of its own;
|
|
633
|
+
* `chikyu-ride-track` is sent with the same object when the whole degree of the heading, `ascending` or `sunlit` changes, never on a timer. It is worked out by the draws the picture makes, so it is as new as the last draw.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
638
|
+
*
|
|
639
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
640
|
+
* console.log(space.rideTrack);
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
get rideTrack(): RideTrack | null;
|
|
609
644
|
/**
|
|
610
645
|
* The radius of the ridden satellite's model as a share of the picture's height, 0.02 to 1.2 (the attribute `ride-model-share`), or `null` for the ride's own: 0.22 along the way it goes, 0.17 above the satellite (its size at the lowest height; `ride-model-size="distance"` still shrinks it as the ride rises).
|
|
611
646
|
* Set while riding it glides in 0.4 s (at once for a reader who asked for less motion). `stats.followModel.share` is the share in use.
|
|
@@ -799,6 +834,12 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
799
834
|
*/
|
|
800
835
|
get selectedPath(): boolean;
|
|
801
836
|
set selectedPath(value: boolean);
|
|
837
|
+
/**
|
|
838
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
839
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
840
|
+
*/
|
|
841
|
+
get pathLight(): boolean;
|
|
842
|
+
set pathLight(value: boolean);
|
|
802
843
|
/**
|
|
803
844
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
804
845
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -894,6 +935,12 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
894
935
|
/** 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. */
|
|
895
936
|
paths: PathStats;
|
|
896
937
|
ride: {
|
|
938
|
+
track: RideTrack | null;
|
|
939
|
+
compass: {
|
|
940
|
+
northDeg: number;
|
|
941
|
+
travelDeg: number | null;
|
|
942
|
+
text: string;
|
|
943
|
+
} | null;
|
|
897
944
|
riding: boolean;
|
|
898
945
|
lost: boolean;
|
|
899
946
|
gliding: boolean;
|