@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
|
@@ -30,6 +30,7 @@ import { IMMERSIVE_STYLE, immersiveWheel } from "../realistic/immersive.js";
|
|
|
30
30
|
import { readMeteorStrength } from "../meteors/strength.js";
|
|
31
31
|
import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
|
|
32
32
|
import { MAX_TEXTURE } from "../realistic/tiers.js";
|
|
33
|
+
import { trailOrbits } from "./trail.js";
|
|
33
34
|
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
34
35
|
import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
|
|
35
36
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
|
|
@@ -39,7 +40,7 @@ import { styleTable } from "./paths.js";
|
|
|
39
40
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
|
|
40
41
|
import { clampFollow, retargetFollow } from "./follow.js";
|
|
41
42
|
import { COMPASS_HTML, COMPASS_STYLE, createCompass, readCompass } from "./compass.js";
|
|
42
|
-
import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
43
|
+
import { OUTSIDE_KM, RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
43
44
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
44
45
|
import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
|
|
45
46
|
import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.js";
|
|
@@ -115,6 +116,22 @@ function readFrame(value, min, max) {
|
|
|
115
116
|
const number = Number(value);
|
|
116
117
|
return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : null;
|
|
117
118
|
}
|
|
119
|
+
/** The distance an outside ride keeps, in kilometres, from an option or an attribute: a positive number, else `null`. */
|
|
120
|
+
function readOutsideKm(value) {
|
|
121
|
+
const number = typeof value === "string" ? (value.trim() === "" ? NaN : Number(value)) : value;
|
|
122
|
+
return typeof number === "number" && Number.isFinite(number) && number > 0 ? number : null;
|
|
123
|
+
}
|
|
124
|
+
/** The length of the glide to a ride: a number of milliseconds as given (0 to 20,000), or a length that follows the distance (the option's `minMs` and `maxMs`), with the length the glide has until the first draw knows the distance. */
|
|
125
|
+
function readGlide(value) {
|
|
126
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
127
|
+
return { duration: Math.min(20_000, Math.max(0, value)) };
|
|
128
|
+
if (value && typeof value === "object") {
|
|
129
|
+
const minMs = typeof value.minMs === "number" && Number.isFinite(value.minMs) ? Math.min(20_000, Math.max(0, value.minMs)) : 800;
|
|
130
|
+
const maxMs = typeof value.maxMs === "number" && Number.isFinite(value.maxMs) ? Math.min(20_000, Math.max(minMs, value.maxMs)) : Math.max(minMs, 4000);
|
|
131
|
+
return { duration: minMs, scaled: { minMs, maxMs } };
|
|
132
|
+
}
|
|
133
|
+
return { duration: 1200 };
|
|
134
|
+
}
|
|
118
135
|
/** An option's number held between `min` and `max`, or `undefined` when it is not given. */
|
|
119
136
|
function clampFrame(value, min, max) {
|
|
120
137
|
return typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : undefined;
|
|
@@ -179,7 +196,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
179
196
|
* ```
|
|
180
197
|
*/
|
|
181
198
|
export class ChikyuSpace extends HTMLElement {
|
|
182
|
-
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "ride-drag", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom", "ride-up", "compass", "smooth-fps"];
|
|
199
|
+
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-outside-km", "ride-model-size", "ride-drag", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom", "ride-up", "compass", "smooth-fps"];
|
|
183
200
|
#model = newSpaceModel();
|
|
184
201
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
185
202
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -236,6 +253,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
236
253
|
/** The ease of `follow` from one share to the next, if one is running. */
|
|
237
254
|
#followTimer;
|
|
238
255
|
#focusBeforeRide = "Earth";
|
|
256
|
+
#histories = new Map();
|
|
257
|
+
#observed = false;
|
|
239
258
|
/** The yaw, tilt and zoom from before a satellite group was framed, put back when the focus is cleared. */
|
|
240
259
|
#focusView = null;
|
|
241
260
|
#lostTold = false;
|
|
@@ -488,6 +507,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
488
507
|
this.#applyViewpoint();
|
|
489
508
|
else if (name === "ride-model-size")
|
|
490
509
|
this.#applyModelSize();
|
|
510
|
+
else if (name === "ride-outside-km")
|
|
511
|
+
this.#applyOutsideKm();
|
|
491
512
|
else if (name === "ride-drag")
|
|
492
513
|
this.#applyDrag();
|
|
493
514
|
else if (name === "ride-up")
|
|
@@ -1471,7 +1492,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1471
1492
|
model.rideTurn += rideTurnDegrees(wrapYaw(view.yaw - now.yaw), view.zoom);
|
|
1472
1493
|
// and the tilt is held to what does something in the look: past it a drag would have to come back before anything moved (the controls driving the view are handed the held tilt, the bar's own when one is bound)
|
|
1473
1494
|
let tilt = view.tilt;
|
|
1474
|
-
const limits = model.ride && model.ride.view === "from" && model.rideDistance !== null ? rideTiltLimits(model.rideDistance, model.ride.look, view.zoom) : null;
|
|
1495
|
+
const limits = model.ride && model.ride.view === "from" && model.rideDistance !== null ? rideTiltLimits(model.rideDistance, model.ride.look, view.zoom, model.ride.face) : null;
|
|
1475
1496
|
if (limits)
|
|
1476
1497
|
tilt = Math.max(limits.min, Math.min(limits.max, tilt));
|
|
1477
1498
|
this.#model.view = { yaw: view.yaw, tilt, zoom: view.zoom };
|
|
@@ -1548,7 +1569,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1548
1569
|
// a body followed (a planet, the Moon, the Earth) is looked at from round it as the view turns: it has no ways to face
|
|
1549
1570
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1550
1571
|
const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
|
|
1551
|
-
model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: face && view === "from" ? "horizon" : (options.look ?? "down"), face, distanceKm: Math.max(100, options.distanceKm ?? 3000), viewpoint: options.viewpoint === "inside" || options.viewpoint === "outside" ? options.viewpoint : this.rideViewpoint, modelSize: options.modelSize === "fixed" || options.modelSize === "distance" ? options.modelSize : this.rideModelSize, drag: options.drag === "head" || options.drag === "orbit" ? options.drag : this.rideDrag, up: options.up === "north" || options.up === "travel" ? options.up : this.rideUp };
|
|
1572
|
+
model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: face && view === "from" ? "horizon" : (options.look ?? "down"), face, distanceKm: Math.max(100, options.distanceKm ?? 3000), viewpoint: options.viewpoint === "inside" || options.viewpoint === "outside" ? options.viewpoint : this.rideViewpoint, outsideKm: readOutsideKm(options.outsideKm) ?? this.rideOutsideKm ?? OUTSIDE_KM, modelSize: options.modelSize === "fixed" || options.modelSize === "distance" ? options.modelSize : this.rideModelSize, drag: options.drag === "head" || options.drag === "orbit" ? options.drag : this.rideDrag, up: options.up === "north" || options.up === "travel" ? options.up : this.rideUp };
|
|
1552
1573
|
if (face) {
|
|
1553
1574
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1554
1575
|
model.rideTurn = 0;
|
|
@@ -1562,7 +1583,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1562
1583
|
this.#zoomRange(model.ride?.view === "from");
|
|
1563
1584
|
this.#lostTold = false;
|
|
1564
1585
|
const pose = model.pose;
|
|
1565
|
-
|
|
1586
|
+
const glide = readGlide(options.glide);
|
|
1587
|
+
model.transition = (options.smooth ?? true) && !reduced && pose.valid ? { start: performance.now(), duration: glide.duration, ...(glide.scaled ? { scaled: glide.scaled } : {}), from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
1566
1588
|
this.#last = performance.now();
|
|
1567
1589
|
this.#schedule();
|
|
1568
1590
|
this.#gate?.request();
|
|
@@ -1681,6 +1703,45 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1681
1703
|
this.ride(next.ref, { view: "follow" });
|
|
1682
1704
|
return next;
|
|
1683
1705
|
}
|
|
1706
|
+
/**
|
|
1707
|
+
* 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,
|
|
1708
|
+
* 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.
|
|
1709
|
+
*
|
|
1710
|
+
* @example
|
|
1711
|
+
* ```ts
|
|
1712
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1713
|
+
*
|
|
1714
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1715
|
+
* space.rideOutsideKm = 100;
|
|
1716
|
+
* console.log(space.rideOutsideKm);
|
|
1717
|
+
* ```
|
|
1718
|
+
*/
|
|
1719
|
+
get rideOutsideKm() {
|
|
1720
|
+
return readOutsideKm(this.getAttribute("ride-outside-km"));
|
|
1721
|
+
}
|
|
1722
|
+
set rideOutsideKm(value) {
|
|
1723
|
+
if (readOutsideKm(value) === null)
|
|
1724
|
+
this.removeAttribute("ride-outside-km");
|
|
1725
|
+
else
|
|
1726
|
+
this.setAttribute("ride-outside-km", String(value));
|
|
1727
|
+
}
|
|
1728
|
+
#applyOutsideKm() {
|
|
1729
|
+
const model = this.#model;
|
|
1730
|
+
const ride = model.ride;
|
|
1731
|
+
const next = this.rideOutsideKm ?? OUTSIDE_KM;
|
|
1732
|
+
if (!ride || ride.outsideKm === next)
|
|
1733
|
+
return;
|
|
1734
|
+
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1735
|
+
const pose = model.pose;
|
|
1736
|
+
model.ride = { ...ride, outsideKm: next };
|
|
1737
|
+
// only an outside ride from the satellite has a camera that far back: the others have nothing to glide
|
|
1738
|
+
const moves = ride.view === "from" && ride.viewpoint === "outside" && typeof ride.target !== "string";
|
|
1739
|
+
model.transition = moves && !reduced && pose.valid ? { start: performance.now(), duration: 800, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
1740
|
+
this.#last = performance.now();
|
|
1741
|
+
this.#schedule();
|
|
1742
|
+
this.#gate?.request();
|
|
1743
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1744
|
+
}
|
|
1684
1745
|
/**
|
|
1685
1746
|
* 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.
|
|
1686
1747
|
* See `RideOptions.viewpoint`.
|
|
@@ -2058,6 +2119,86 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2058
2119
|
this.#schedule();
|
|
2059
2120
|
this.#gate?.request();
|
|
2060
2121
|
}
|
|
2122
|
+
/**
|
|
2123
|
+
* 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).
|
|
2124
|
+
* 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
|
|
2125
|
+
* (a prediction, with its uncertainty stated by `history.describe(ms)`). `null` takes it away. The page brings the sets: nothing is fetched.
|
|
2126
|
+
*
|
|
2127
|
+
* @param id - The NORAD catalogue number.
|
|
2128
|
+
* @param history - What `createSatelliteHistory(sets, options)` returned, or `null` to remove it.
|
|
2129
|
+
* @returns `{ group, index }` of the satellite, for `ride`, `observe` and `selectSatellite`, or `null` when removed or the history has no usable set.
|
|
2130
|
+
*/
|
|
2131
|
+
setSatelliteHistory(id, history) {
|
|
2132
|
+
const name = `history:${id}`;
|
|
2133
|
+
if (history === null || history.sets.length === 0) {
|
|
2134
|
+
this.#histories.delete(id);
|
|
2135
|
+
this.setSatellites(name, null);
|
|
2136
|
+
return null;
|
|
2137
|
+
}
|
|
2138
|
+
this.#histories.set(id, history);
|
|
2139
|
+
this.setSatellites(name, history.group, { orbits: false });
|
|
2140
|
+
return { group: name, index: 0 };
|
|
2141
|
+
}
|
|
2142
|
+
/** The history given to `setSatelliteHistory` for a satellite, or `undefined`: its `describe(ms)` says whether it is launched, tracked, predicted or down, and when. */
|
|
2143
|
+
satelliteHistory(id) {
|
|
2144
|
+
return this.#histories.get(id);
|
|
2145
|
+
}
|
|
2146
|
+
/**
|
|
2147
|
+
* 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.
|
|
2148
|
+
* 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
|
|
2149
|
+
* 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`.
|
|
2150
|
+
*
|
|
2151
|
+
* @param target - `{ group, index }`, or a NORAD number: first the history set with `setSatelliteHistory`, else the first group that has it.
|
|
2152
|
+
* @param options - `orbits`, `colour`, `distanceKm`, `smooth`.
|
|
2153
|
+
* @returns False when the satellite is not set (nothing changes).
|
|
2154
|
+
*/
|
|
2155
|
+
observe(target, options = {}) {
|
|
2156
|
+
const state = this.#model.satellites;
|
|
2157
|
+
if (target === null) {
|
|
2158
|
+
state.trail.ref = null;
|
|
2159
|
+
state.trail.version += 1;
|
|
2160
|
+
if (this.observing)
|
|
2161
|
+
this.ride(null);
|
|
2162
|
+
this.#observed = false;
|
|
2163
|
+
// the trail comes off at the next draw
|
|
2164
|
+
this.#schedule();
|
|
2165
|
+
this.#gate?.request();
|
|
2166
|
+
return true;
|
|
2167
|
+
}
|
|
2168
|
+
let ref = null;
|
|
2169
|
+
if (typeof target === "number") {
|
|
2170
|
+
if (this.#histories.has(target))
|
|
2171
|
+
ref = { group: `history:${target}`, index: 0 };
|
|
2172
|
+
else {
|
|
2173
|
+
for (const [group, entry] of state.groups) {
|
|
2174
|
+
const index = entry.satellites.sets.findIndex((set) => set.NORAD_CAT_ID === target);
|
|
2175
|
+
if (index >= 0) {
|
|
2176
|
+
ref = { group, index };
|
|
2177
|
+
break;
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
else if (state.groups.get(target.group))
|
|
2183
|
+
ref = { group: target.group, index: target.index };
|
|
2184
|
+
if (!ref)
|
|
2185
|
+
return false;
|
|
2186
|
+
state.trail.ref = ref;
|
|
2187
|
+
state.trail.orbits = trailOrbits(options.orbits);
|
|
2188
|
+
if (typeof options.colour === "string" && options.colour !== "")
|
|
2189
|
+
state.trail.colour = options.colour;
|
|
2190
|
+
state.trail.version += 1;
|
|
2191
|
+
this.#observed = true;
|
|
2192
|
+
this.ride(ref, { view: "follow", distanceKm: options.distanceKm ?? 3000, ...(options.smooth === undefined ? {} : { smooth: options.smooth }) });
|
|
2193
|
+
return true;
|
|
2194
|
+
}
|
|
2195
|
+
/** What `observe` is showing now (`{ ref, orbits }`), or null. */
|
|
2196
|
+
get observing() {
|
|
2197
|
+
const t = this.#model.satellites.trail;
|
|
2198
|
+
const riding = this.riding;
|
|
2199
|
+
const on = t.ref !== null && this.#observed && riding !== null && typeof riding.target === "object" && riding.target.group === t.ref.group && riding.target.index === t.ref.index;
|
|
2200
|
+
return on && t.ref ? { ref: { ...t.ref }, orbits: t.orbits } : null;
|
|
2201
|
+
}
|
|
2061
2202
|
/** Show or hide a group without losing it. */
|
|
2062
2203
|
showSatellites(group, on) {
|
|
2063
2204
|
const found = this.#model.satellites.groups.get(group);
|
|
@@ -2164,6 +2305,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2164
2305
|
* 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
|
|
2165
2306
|
* 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);
|
|
2166
2307
|
* 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.
|
|
2308
|
+
* **`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.
|
|
2167
2309
|
* It applies to every group, those the page made with `createSatellites(sets, { estimateFar: true })` too.
|
|
2168
2310
|
*
|
|
2169
2311
|
* @example
|
|
@@ -2178,10 +2320,15 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2178
2320
|
* ```
|
|
2179
2321
|
*/
|
|
2180
2322
|
get estimateFar() {
|
|
2181
|
-
|
|
2323
|
+
const value = this.getAttribute("estimate-far");
|
|
2324
|
+
if (value === null || value === "off")
|
|
2325
|
+
return false;
|
|
2326
|
+
return value.trim().toLowerCase() === "steady" ? "steady" : true;
|
|
2182
2327
|
}
|
|
2183
2328
|
set estimateFar(value) {
|
|
2184
|
-
if (value)
|
|
2329
|
+
if (value === "steady")
|
|
2330
|
+
this.setAttribute("estimate-far", "steady");
|
|
2331
|
+
else if (value)
|
|
2185
2332
|
this.setAttribute("estimate-far", "");
|
|
2186
2333
|
else
|
|
2187
2334
|
this.removeAttribute("estimate-far");
|
|
@@ -2521,7 +2668,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2521
2668
|
let epochMs = 0;
|
|
2522
2669
|
for (const group of this.#model.satellites.groups.values())
|
|
2523
2670
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
2524
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, orbitLines: drawn.orbitLines, estimated: drawn.estimated };
|
|
2671
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity, orbitLines: drawn.orbitLines, estimated: drawn.estimated, trailPoints: drawn.trailPoints, trailBuilds: drawn.trailBuilds };
|
|
2525
2672
|
}
|
|
2526
2673
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
2527
2674
|
#readSpeed() {
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, orbitPath, PLANETS, type Frame, type PlanetName, type Vec3 } from "./ephemeris.ts";
|
|
2
2
|
export { compress, MOON_COMPRESSED, placeAround, placeMoon, placeSun, RADIUS, SUN_COMPRESSED, truePosition, type ScaleMode } from "./scale.ts";
|
|
3
3
|
export { fitDistance, plainPainter, type BodyDrawing, type RideTrack, type BodyMoon, type BodyPainter, type BodyView, type PaintContext, type SatellitePainter } from "./scene.ts";
|
|
4
|
-
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees, type RideDrag, type RideFace, type RideInput, type RideLook, type RidePose, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
4
|
+
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, rideGlideMs, ridePose, rideTiltLimits, rideTurnDegrees, type RideDrag, type RideFace, type RideInput, type RideLook, type RidePose, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
5
5
|
export { earthHides, type SatelliteScreen } from "./satellite-layer.ts";
|
|
6
6
|
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.ts";
|
|
7
7
|
export { localNorth, NORTH_UP_BLEND_DEG, NORTH_UP_POLE_DEG, northUpYaw, screenAngle, type RideUp } from "./north-up.ts";
|
|
@@ -9,3 +9,4 @@ export { genericSatellite, satelliteKind, type SatelliteKind } from "./generic-s
|
|
|
9
9
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam, type BeamCells, type BeamOptions } from "../beam/geometry.ts";
|
|
10
10
|
export type { BeamStats } from "../beam/layer.ts";
|
|
11
11
|
export { RIDE_PATH_FADE_KM } from "./path-ribbons.ts";
|
|
12
|
+
export { createTrailBuilder, TRAIL_DEFAULT_ORBITS, TRAIL_MAX_ORBITS, TRAIL_MAX_POINTS, TRAIL_POINTS_PER_ORBIT, trailOrbits, type PlaceAt, type TrailBuilder } from "./trail.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, orbitPath, PLANETS } from "./ephemeris.js";
|
|
4
4
|
export { compress, MOON_COMPRESSED, placeAround, placeMoon, placeSun, RADIUS, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
5
5
|
export { fitDistance, plainPainter } from "./scene.js";
|
|
6
|
-
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
6
|
+
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, rideGlideMs, ridePose, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
7
7
|
export { earthHides } from "./satellite-layer.js";
|
|
8
8
|
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
9
9
|
export { localNorth, NORTH_UP_BLEND_DEG, NORTH_UP_POLE_DEG, northUpYaw, screenAngle } from "./north-up.js";
|
|
10
10
|
export { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
11
11
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam } from "../beam/geometry.js";
|
|
12
12
|
export { RIDE_PATH_FADE_KM } from "./path-ribbons.js";
|
|
13
|
+
export { createTrailBuilder, TRAIL_DEFAULT_ORBITS, TRAIL_MAX_ORBITS, TRAIL_MAX_POINTS, TRAIL_POINTS_PER_ORBIT, trailOrbits } from "./trail.js";
|
|
@@ -27,6 +27,8 @@ export interface RibbonPath {
|
|
|
27
27
|
dark?: Uint8Array;
|
|
28
28
|
/** Any CSS colour: what the flagged segments are drawn in. Needed with `dark`. */
|
|
29
29
|
darkInk?: string;
|
|
30
|
+
/** An open line, not a loop: the last segment (from the last point back to the first) is not drawn. A line of more than {@link PATH_POINTS} points is laid in several slots that share their end points. */
|
|
31
|
+
open?: boolean;
|
|
30
32
|
}
|
|
31
33
|
export interface PathRibbons {
|
|
32
34
|
/** Write the paths into the buffers, none for an empty list. Costs nothing on the GPU until the next draw, and nothing is drawn while there are no paths. */
|
|
@@ -140,14 +140,14 @@ export function createPathRibbons(three, scene) {
|
|
|
140
140
|
set(paths) {
|
|
141
141
|
count = Math.min(PATH_SLOTS, paths.length);
|
|
142
142
|
for (let p = 0; p < count; p += 1) {
|
|
143
|
-
const { positions, style, fade = 0, dark, darkInk } = paths[p];
|
|
143
|
+
const { positions, style, fade = 0, dark, darkInk, open = false } = paths[p];
|
|
144
144
|
colour.set(style.color);
|
|
145
145
|
if (dark && darkInk)
|
|
146
146
|
shade.set(darkInk);
|
|
147
147
|
// the arc length at each point, in Earth radii, for the dashes
|
|
148
148
|
let along = 0;
|
|
149
149
|
for (let i = 0; i < PATH_POINTS; i += 1) {
|
|
150
|
-
const j = (i + 1) % PATH_POINTS;
|
|
150
|
+
const j = open && i === PATH_POINTS - 1 ? i : (i + 1) % PATH_POINTS;
|
|
151
151
|
const ax = positions[i * 3];
|
|
152
152
|
const ay = positions[i * 3 + 1];
|
|
153
153
|
const az = positions[i * 3 + 2];
|
package/dist/space/ride.d.ts
CHANGED
|
@@ -95,11 +95,13 @@ export declare function rideFov(zoom: number): number;
|
|
|
95
95
|
export declare function rideTurnDegrees(change: number, zoom: number): number;
|
|
96
96
|
/**
|
|
97
97
|
* The range of the controls' tilt that does something in the `horizon` look: from straight down to a little above the horizon. A tilt beyond it moves nothing, so a page holds the tilt to it, and a drag back starts moving at once instead of after the
|
|
98
|
-
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is) and the
|
|
98
|
+
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is), the zoom and the facing: the range is the one the facing opens in (`ridePose` rests the camera there), so looking `up` the camera can tip from straight away
|
|
99
|
+
* from the Earth to straight down, and looking `down` from straight down to a little above the horizon. Leave the facing out for a ride with none (the horizon a little above the middle). The `down` look has no such range.
|
|
99
100
|
*
|
|
100
101
|
* @param distance - The camera's distance from the Earth's centre, in Earth radii.
|
|
101
102
|
* @param look - The look.
|
|
102
103
|
* @param zoom - The shared controls' zoom.
|
|
104
|
+
* @param face - The facing the ride opened with (`RideFace`), or leave it out or `null` for none.
|
|
103
105
|
* @returns The lowest and highest tilt, or `null` for the `down` look.
|
|
104
106
|
*
|
|
105
107
|
* @example
|
|
@@ -107,10 +109,11 @@ export declare function rideTurnDegrees(change: number, zoom: number): number;
|
|
|
107
109
|
* import { rideTiltLimits } from "@johnmorrisdotca/chikyu-earth/space";
|
|
108
110
|
*
|
|
109
111
|
* const range = rideTiltLimits(1.066, "horizon", 1);
|
|
110
|
-
*
|
|
112
|
+
* const below = rideTiltLimits(1.066, "horizon", 1, "up");
|
|
113
|
+
* console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, below && `${below.min.toFixed(0)} to ${below.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
|
|
111
114
|
* ```
|
|
112
115
|
*/
|
|
113
|
-
export declare function rideTiltLimits(distance: number, look: RideLook, zoom: number): {
|
|
116
|
+
export declare function rideTiltLimits(distance: number, look: RideLook, zoom: number, face?: RideFace | null): {
|
|
114
117
|
min: number;
|
|
115
118
|
max: number;
|
|
116
119
|
} | null;
|
|
@@ -200,7 +203,7 @@ export type RideDrag = "head" | "orbit";
|
|
|
200
203
|
*/
|
|
201
204
|
export type RideModelSize = "distance" | "fixed";
|
|
202
205
|
/**
|
|
203
|
-
* How far an outside ride keeps the camera from the satellite, in kilometres. The satellite itself is a few metres across, so it is drawn far larger than life (a model about a fifth of the picture's height across): not to scale, and the page says so in its caption.
|
|
206
|
+
* How far an outside ride keeps the camera from the satellite by default, in kilometres (a ride's `outsideKm` and the element's `ride-outside-km` change it). The satellite itself is a few metres across, so it is drawn far larger than life (a model about a fifth of the picture's height across): not to scale, and the page says so in its caption.
|
|
204
207
|
*
|
|
205
208
|
* @example
|
|
206
209
|
* ```ts
|
|
@@ -210,6 +213,23 @@ export type RideModelSize = "distance" | "fixed";
|
|
|
210
213
|
* ```
|
|
211
214
|
*/
|
|
212
215
|
export declare const OUTSIDE_KM = 25;
|
|
216
|
+
/**
|
|
217
|
+
* How long a glide between two cameras lasts, in milliseconds, when it follows the distance the camera has to move: the shortest at a hop of 10 km or less, the longest at 30,000 km or more (a camera that goes to the Moon takes the longest),
|
|
218
|
+
* and in between the length grows with each tenfold of the distance (3,000 km is about 70 per cent of the way). A fixed 1.2 seconds is quick for a hop of thousands of kilometres and slow for one of tens. Pure.
|
|
219
|
+
*
|
|
220
|
+
* @param km - How far the camera moves, in kilometres.
|
|
221
|
+
* @param minMs - The shortest glide, in milliseconds; 800 by default.
|
|
222
|
+
* @param maxMs - The longest glide, in milliseconds; 4,000 by default (never below `minMs`).
|
|
223
|
+
* @returns The length of the glide in milliseconds, between `minMs` and `maxMs`.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { rideGlideMs } from "@johnmorrisdotca/chikyu-earth/space";
|
|
228
|
+
*
|
|
229
|
+
* console.log(rideGlideMs(25), rideGlideMs(3000), rideGlideMs(400_000));
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export declare function rideGlideMs(km: number, minMs?: number, maxMs?: number): number;
|
|
213
233
|
/**
|
|
214
234
|
* The camera of an outside ride: the pose `ridePose` works out for a camera at the satellite, moved to `OUTSIDE_KM` back along its own line of sight so the satellite is in front of it. Looking along the way it goes (`look: "horizon"`) the satellite sits a little below the middle of the picture, so the camera is behind and above it; looking
|
|
215
235
|
* down (`look: "down"`) it is at the middle, with the camera straight above it. Where the satellite sits in the picture does not change with the zoom. Which way the camera looks and which way is up are the pose's own. With no `rest`, the camera goes round the satellite as it looks about (`orbit`):
|
|
@@ -220,6 +240,7 @@ export declare const OUTSIDE_KM = 25;
|
|
|
220
240
|
* @param look - The look the pose was made with.
|
|
221
241
|
* @param low - How far below the middle of the picture the satellite is, as a share of half its height (0 the middle, 1 the bottom edge); by default 0.8 looking along and 0 looking down.
|
|
222
242
|
* @param rest - The pose from `ridePose` for the same camera with no drag (yaw, tilt and turn of 0): where the camera is kept. Leave it out for the camera to go round the satellite as it looks about.
|
|
243
|
+
* @param km - How far back the camera is kept, in kilometres: `OUTSIDE_KM` (25) by default. Never more than half the satellite's height.
|
|
223
244
|
* @returns The pose moved back from the satellite, with how far the camera is from it in Earth radii and how many degrees below the middle of the picture the satellite is.
|
|
224
245
|
*
|
|
225
246
|
* @example
|
|
@@ -233,7 +254,7 @@ export declare const OUTSIDE_KM = 25;
|
|
|
233
254
|
* console.log(out.distance.toFixed(4), out.below.toFixed(1), out.pose.position.map((n) => n.toFixed(4)).join(","), head.pose.position.map((n) => n.toFixed(4)).join(","));
|
|
234
255
|
* ```
|
|
235
256
|
*/
|
|
236
|
-
export declare function outsidePose(pose: RidePose, look: RideLook, low?: number, rest?: RidePose): {
|
|
257
|
+
export declare function outsidePose(pose: RidePose, look: RideLook, low?: number, rest?: RidePose, km?: number): {
|
|
237
258
|
pose: RidePose;
|
|
238
259
|
distance: number;
|
|
239
260
|
below: number;
|
package/dist/space/ride.js
CHANGED
|
@@ -27,6 +27,14 @@ export const RIDE_FOV = 60;
|
|
|
27
27
|
export const RIDE_FACES = ["ahead", "behind", "left", "right", "down", "up"];
|
|
28
28
|
/** How far each facing turns from the way it goes, in degrees, to the left, in the view from the body. */
|
|
29
29
|
const FACE_TURN = { ahead: 0, behind: 180, left: 90, right: -90, down: 0, up: 0 };
|
|
30
|
+
/** Where the horizon look rests, as an elevation in radians (0 the horizon, a quarter turn up or down at the ends): straight at the Earth for `down`, straight away from it for `up`, and for every other facing the horizon a little above the middle. */
|
|
31
|
+
function restElevation(earthRadiusDegrees, face) {
|
|
32
|
+
if (face === "down")
|
|
33
|
+
return -Math.PI / 2;
|
|
34
|
+
if (face === "up")
|
|
35
|
+
return Math.PI / 2;
|
|
36
|
+
return Math.max(0, earthRadiusDegrees - 12) * RAD - Math.PI / 2;
|
|
37
|
+
}
|
|
30
38
|
/**
|
|
31
39
|
* Yaw and tilt, in radians, that put a camera looking at a satellite on a facing. `down` is straight above it, looking down at it and the Earth. `ahead` looks along the way it goes.
|
|
32
40
|
*
|
|
@@ -89,11 +97,13 @@ export function rideTurnDegrees(change, zoom) {
|
|
|
89
97
|
}
|
|
90
98
|
/**
|
|
91
99
|
* The range of the controls' tilt that does something in the `horizon` look: from straight down to a little above the horizon. A tilt beyond it moves nothing, so a page holds the tilt to it, and a drag back starts moving at once instead of after the
|
|
92
|
-
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is) and the
|
|
100
|
+
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is), the zoom and the facing: the range is the one the facing opens in (`ridePose` rests the camera there), so looking `up` the camera can tip from straight away
|
|
101
|
+
* from the Earth to straight down, and looking `down` from straight down to a little above the horizon. Leave the facing out for a ride with none (the horizon a little above the middle). The `down` look has no such range.
|
|
93
102
|
*
|
|
94
103
|
* @param distance - The camera's distance from the Earth's centre, in Earth radii.
|
|
95
104
|
* @param look - The look.
|
|
96
105
|
* @param zoom - The shared controls' zoom.
|
|
106
|
+
* @param face - The facing the ride opened with (`RideFace`), or leave it out or `null` for none.
|
|
97
107
|
* @returns The lowest and highest tilt, or `null` for the `down` look.
|
|
98
108
|
*
|
|
99
109
|
* @example
|
|
@@ -101,16 +111,18 @@ export function rideTurnDegrees(change, zoom) {
|
|
|
101
111
|
* import { rideTiltLimits } from "@johnmorrisdotca/chikyu-earth/space";
|
|
102
112
|
*
|
|
103
113
|
* const range = rideTiltLimits(1.066, "horizon", 1);
|
|
104
|
-
*
|
|
114
|
+
* const below = rideTiltLimits(1.066, "horizon", 1, "up");
|
|
115
|
+
* console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, below && `${below.min.toFixed(0)} to ${below.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
|
|
105
116
|
* ```
|
|
106
117
|
*/
|
|
107
|
-
export function rideTiltLimits(distance, look, zoom) {
|
|
118
|
+
export function rideTiltLimits(distance, look, zoom, face) {
|
|
108
119
|
if (look !== "horizon")
|
|
109
120
|
return null;
|
|
110
121
|
const radius = distance <= 1 ? 90 : Math.asin(1 / distance) / RAD;
|
|
111
|
-
const
|
|
122
|
+
const rest = restElevation(radius, face);
|
|
123
|
+
const cap = Math.max(MAX_ABOVE_HORIZON * RAD, rest);
|
|
112
124
|
const perDegree = (GRAB * rideFov(zoom)) / 60;
|
|
113
|
-
return { min: (
|
|
125
|
+
return { min: (rest - cap) / RAD / perDegree, max: (rest + Math.PI / 2) / RAD / perDegree };
|
|
114
126
|
}
|
|
115
127
|
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
116
128
|
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
@@ -122,7 +134,7 @@ const unit = (a) => {
|
|
|
122
134
|
return n === 0 ? [0, 0, 0] : [a[0] / n, a[1] / n, a[2] / n];
|
|
123
135
|
};
|
|
124
136
|
/**
|
|
125
|
-
* How far an outside ride keeps the camera from the satellite, in kilometres. The satellite itself is a few metres across, so it is drawn far larger than life (a model about a fifth of the picture's height across): not to scale, and the page says so in its caption.
|
|
137
|
+
* How far an outside ride keeps the camera from the satellite by default, in kilometres (a ride's `outsideKm` and the element's `ride-outside-km` change it). The satellite itself is a few metres across, so it is drawn far larger than life (a model about a fifth of the picture's height across): not to scale, and the page says so in its caption.
|
|
126
138
|
*
|
|
127
139
|
* @example
|
|
128
140
|
* ```ts
|
|
@@ -132,6 +144,28 @@ const unit = (a) => {
|
|
|
132
144
|
* ```
|
|
133
145
|
*/
|
|
134
146
|
export const OUTSIDE_KM = 25;
|
|
147
|
+
/**
|
|
148
|
+
* How long a glide between two cameras lasts, in milliseconds, when it follows the distance the camera has to move: the shortest at a hop of 10 km or less, the longest at 30,000 km or more (a camera that goes to the Moon takes the longest),
|
|
149
|
+
* and in between the length grows with each tenfold of the distance (3,000 km is about 70 per cent of the way). A fixed 1.2 seconds is quick for a hop of thousands of kilometres and slow for one of tens. Pure.
|
|
150
|
+
*
|
|
151
|
+
* @param km - How far the camera moves, in kilometres.
|
|
152
|
+
* @param minMs - The shortest glide, in milliseconds; 800 by default.
|
|
153
|
+
* @param maxMs - The longest glide, in milliseconds; 4,000 by default (never below `minMs`).
|
|
154
|
+
* @returns The length of the glide in milliseconds, between `minMs` and `maxMs`.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { rideGlideMs } from "@johnmorrisdotca/chikyu-earth/space";
|
|
159
|
+
*
|
|
160
|
+
* console.log(rideGlideMs(25), rideGlideMs(3000), rideGlideMs(400_000));
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
export function rideGlideMs(km, minMs = 800, maxMs = 4000) {
|
|
164
|
+
const low = Math.max(0, Number.isFinite(minMs) ? minMs : 800);
|
|
165
|
+
const high = Math.max(low, Number.isFinite(maxMs) ? maxMs : 4000);
|
|
166
|
+
const share = Number.isFinite(km) && km > 10 ? Math.min(1, Math.log10(km / 10) / 3.5) : 0;
|
|
167
|
+
return Math.round(low + (high - low) * share);
|
|
168
|
+
}
|
|
135
169
|
/** How far below the middle of the picture the satellite's middle is drawn in an outside ride that looks along the way it goes, as a share of half the picture's height (0.8: at 90 per cent of the height, so with the model drawn 17 per cent of the height in radius it crosses the bottom edge). */
|
|
136
170
|
const OUTSIDE_LOW = 0.8;
|
|
137
171
|
/**
|
|
@@ -144,6 +178,7 @@ const OUTSIDE_LOW = 0.8;
|
|
|
144
178
|
* @param look - The look the pose was made with.
|
|
145
179
|
* @param low - How far below the middle of the picture the satellite is, as a share of half its height (0 the middle, 1 the bottom edge); by default 0.8 looking along and 0 looking down.
|
|
146
180
|
* @param rest - The pose from `ridePose` for the same camera with no drag (yaw, tilt and turn of 0): where the camera is kept. Leave it out for the camera to go round the satellite as it looks about.
|
|
181
|
+
* @param km - How far back the camera is kept, in kilometres: `OUTSIDE_KM` (25) by default. Never more than half the satellite's height.
|
|
147
182
|
* @returns The pose moved back from the satellite, with how far the camera is from it in Earth radii and how many degrees below the middle of the picture the satellite is.
|
|
148
183
|
*
|
|
149
184
|
* @example
|
|
@@ -157,10 +192,10 @@ const OUTSIDE_LOW = 0.8;
|
|
|
157
192
|
* console.log(out.distance.toFixed(4), out.below.toFixed(1), out.pose.position.map((n) => n.toFixed(4)).join(","), head.pose.position.map((n) => n.toFixed(4)).join(","));
|
|
158
193
|
* ```
|
|
159
194
|
*/
|
|
160
|
-
export function outsidePose(pose, look, low, rest) {
|
|
195
|
+
export function outsidePose(pose, look, low, rest, km = OUTSIDE_KM) {
|
|
161
196
|
const base = rest ?? pose;
|
|
162
197
|
const height = Math.max(0, norm(pose.position) - 1);
|
|
163
|
-
const distance = Math.max(1e-5, Math.min(OUTSIDE_KM / 6371, height * 0.5));
|
|
198
|
+
const distance = Math.max(1e-5, Math.min((Number.isFinite(km) && km > 0 ? km : OUTSIDE_KM) / 6371, height * 0.5));
|
|
164
199
|
const lowNow = low ?? (look === "horizon" ? OUTSIDE_LOW : 0);
|
|
165
200
|
const below = Math.atan(Math.max(0, lowNow) * Math.tan((base.fov / 2) * RAD));
|
|
166
201
|
// the satellite is along the line of sight turned `below` down (towards the bottom of the picture): the camera is back along that line. The line is the pose's own, so the camera goes round the satellite as it looks about, or the line of the pose with no drag (`rest`), so the camera keeps its place and only turns
|
|
@@ -202,7 +237,7 @@ export function ridePose(input) {
|
|
|
202
237
|
const fov = rideFov(input.zoom);
|
|
203
238
|
const turn = ((input.turn ?? input.yaw * (GRAB * fov / 180)) + faced) * RAD;
|
|
204
239
|
const lift = input.tilt * (GRAB * fov / 60) * RAD;
|
|
205
|
-
const rest =
|
|
240
|
+
const rest = restElevation(earthRadiusDegrees, input.face);
|
|
206
241
|
const cap = Math.max(MAX_ABOVE_HORIZON * RAD, rest);
|
|
207
242
|
if (input.look === "horizon") {
|
|
208
243
|
// looking round on the spot: a drag sideways turns the camera about the local vertical, all the way round, and a drag up or down tips it up or down in the vertical plane it faces, from straight down to a little above the horizon,
|
|
@@ -65,6 +65,13 @@ export interface SatelliteState {
|
|
|
65
65
|
* 0 draws the whole stretch one frame spans, however long that is.
|
|
66
66
|
*/
|
|
67
67
|
streakMax: number;
|
|
68
|
+
/** The Observe view's trail (`observe`): the satellite it follows, how many orbits it reaches back, its colour, and a number that goes up when the page changes any of them. `ref` null: no trail, and nothing made for one. */
|
|
69
|
+
trail: {
|
|
70
|
+
ref: SatelliteRef | null;
|
|
71
|
+
orbits: number;
|
|
72
|
+
colour: string;
|
|
73
|
+
version: number;
|
|
74
|
+
};
|
|
68
75
|
/** Set at each draw by the view: the satellite a ride shows as its model while the model is big enough to read. Its ring (the chosen marker) and name are left off while this is so; its orbit line stays. Clears with the ride, or when the model has handed over to the mark. */
|
|
69
76
|
modelOver: SatelliteRef | null;
|
|
70
77
|
drawn: {
|
|
@@ -89,6 +96,8 @@ export interface SatelliteState {
|
|
|
89
96
|
pathsDrawn: number;
|
|
90
97
|
pathDraws: number;
|
|
91
98
|
estimated: number;
|
|
99
|
+
trailPoints: number;
|
|
100
|
+
trailBuilds: number;
|
|
92
101
|
};
|
|
93
102
|
}
|
|
94
103
|
/**
|