@johnmorrisdotca/chikyu-earth 0.61.0 → 0.63.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.
@@ -1,13 +1,14 @@
1
1
  import { carryControls, wrapYaw } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
2
  import { adoptStyles } from "../adopt.js";
3
3
  import { airFor, readAirThickness } from "../realistic/air.js";
4
+ import { readCloudFade } from "../realistic/cloud-fade.js";
4
5
  import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "../realistic/body-label.js";
5
6
  import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
6
7
  import { cleanPlaces, readPlaceGroups, readPlaceLayers, readPlaces } from "../markers/places.js";
7
8
  import { readHereCity } from "../markers/here-city.js";
8
9
  import { createHereCity } from "../markers/here-city-host.js";
9
10
  import { createPlaceLayer, PLACE_STYLE, placeClick, placesLostNotice, readPlaceLook } from "../markers/place-layer.js";
10
- import { aimAt, findPlace, glideView } from "../markers/go-to-place.js";
11
+ import { aimAt, findPlace, PLACE_GLIDE_MS } from "../markers/go-to-place.js";
11
12
  import { subsolarPoint } from "../realistic/sun.js";
12
13
  import { SHORT_NAMES } from "../satellites/names.js";
13
14
  import { CITY_NAMES_ATTRIBUTES, CITY_NAMES_STYLE, createCityHost } from "../cities/host.js";
@@ -31,6 +32,7 @@ import { readMeteorStrength } from "../meteors/strength.js";
31
32
  import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
32
33
  import { MAX_TEXTURE } from "../realistic/tiers.js";
33
34
  import { trailOrbits } from "./trail.js";
35
+ import { descentFloorKm, FLY_HEIGHT_KM, FLY_MIN_KM, flyAim, flyAt, flyDistance, flyLonLat, flyStateAt, flyStill, planFly } from "./fly.js";
34
36
  import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
35
37
  import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
36
38
  import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
@@ -109,6 +111,8 @@ const TIME_EVENT_MS = 250;
109
111
  * Riding at a body looking at the Earth, the zoom only narrows the camera's field a little either way: 0.5 to 6.
110
112
  */
111
113
  const LIMITS = { tiltMax: 90, zoomMin: 0.000001, zoomMax: 2.5 };
114
+ /** What the controls say a reader's own hand did: any of these ends a fly-to where it is. */
115
+ const HANDS = new Set(["drag", "pinch", "wheel", "key", "zoom", "pan", "front", "fit"]);
112
116
  /** A number from an attribute, held between `min` and `max`; `null` when it is absent or not a number. */
113
117
  function readFrame(value, min, max) {
114
118
  if (value === null || value.trim() === "")
@@ -196,7 +200,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
196
200
  * ```
197
201
  */
198
202
  export class ChikyuSpace extends HTMLElement {
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", "place-layers", "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"];
203
+ static observedAttributes = ["cloud-drift", "cloud-fade", "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", "place-layers", "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"];
200
204
  #model = newSpaceModel();
201
205
  /** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
202
206
  #finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
@@ -270,8 +274,15 @@ export class ChikyuSpace extends HTMLElement {
270
274
  /** Whether the page has been told that places in sight were left undrawn. */
271
275
  #placesLost = { told: false };
272
276
  #placeList = [];
273
- /** Counts the turns to a place, so a new one stops the one before. */
274
- #placeGlide = 0;
277
+ /** Counts the moves asked for (`flyTo`, `goToPlace`), so one still finding its floor gives way to a later one. */
278
+ #flyAsks = 0;
279
+ /** The move running (`flyTo`, `goToPlace`): its plan and how to end it. */
280
+ #flight = null;
281
+ #flyStats = { moves: 0, redirects: 0, held: null };
282
+ /** A frame of the move is asked for and not yet run. */
283
+ #flyAsked = false;
284
+ /** The zoom limit under the attributes: the controls' own, raised once a fly-to has come lower. */
285
+ #flyZoomMax = LIMITS.zoomMax;
275
286
  #nameBoxes = new Map();
276
287
  /** A font that arrives after the names were measured: the boxes are read again on the next layout. The satellites' marks are not touched, or the page would be told again about each one already in view. */
277
288
  #onFonts = () => {
@@ -294,6 +305,7 @@ export class ChikyuSpace extends HTMLElement {
294
305
  this.#model.light = readLight(this.getAttribute("light"));
295
306
  this.#model.camera = readCamera(this.getAttribute("camera"));
296
307
  this.#model.cloudDrift = Number.isFinite(Number(this.getAttribute("cloud-drift") ?? "0")) ? Number(this.getAttribute("cloud-drift") ?? "0") : 0;
308
+ this.#model.cloudFade = readCloudFade(this.getAttribute("cloud-fade"));
297
309
  this.#model.earth = { size: readNumber(this.getAttribute("earth-size"), DEFAULT_EARTH_SIZE, 0.02, 50), x: readNumber(this.getAttribute("earth-x"), 0.5, -2, 3), y: readNumber(this.getAttribute("earth-y"), 0.5, -2, 3) };
298
310
  this.#model.stepMs = Math.max(1000, Math.abs(this.#speed) * 1000);
299
311
  this.#model.speed = this.#speed;
@@ -461,7 +473,16 @@ export class ChikyuSpace extends HTMLElement {
461
473
  this.addEventListener("keydown", this.#faceKey);
462
474
  if (!this.hasAttribute("tabindex"))
463
475
  this.tabIndex = 0;
464
- this.#hands = carryControls(this, { initial: this.#model.view, limits: LIMITS, onChange: (state, info) => this.setView(state, info.final) });
476
+ this.#hands = carryControls(this, {
477
+ initial: this.#model.view,
478
+ limits: { ...LIMITS, zoomMax: this.#flyZoomMax },
479
+ onChange: (state, info) => {
480
+ // a hand on the view ends a fly-to where it is
481
+ if (HANDS.has(info.reason))
482
+ this.#flight?.finish("stopped");
483
+ this.setView(state, info.final);
484
+ },
485
+ });
465
486
  this.#labelBox.addEventListener("click", this.#labelClick);
466
487
  this.#labelBox.addEventListener("focusin", this.#labelFocus);
467
488
  }
@@ -544,6 +565,10 @@ export class ChikyuSpace extends HTMLElement {
544
565
  this.#model.cloudDrift = Number.isFinite(Number(value ?? "0")) ? Number(value ?? "0") : 0;
545
566
  this.#gate?.request();
546
567
  }
568
+ else if (name === "cloud-fade") {
569
+ this.#model.cloudFade = readCloudFade(value);
570
+ this.#gate?.request();
571
+ }
547
572
  else if (name === "earth-size")
548
573
  this.earthSize = readNumber(value, DEFAULT_EARTH_SIZE, 0.02, 50);
549
574
  else if (name === "earth-x")
@@ -926,7 +951,8 @@ export class ChikyuSpace extends HTMLElement {
926
951
  /**
927
952
  * Turn the view so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom stays.
928
953
  * The place is named by its `id`, or by its label in any case. The camera must be looking at the Earth: while it rides along or looks at another body nothing moves. The tilt is held to 90 degrees either
929
- * way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows.
954
+ * way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows. A new `goToPlace` or `flyTo` while it turns does not stop it: the turn keeps its speed and
955
+ * the way it is going and curves to the new place. A hand on the view ends it where it is.
930
956
  *
931
957
  * @param text - The place's id or label.
932
958
  * @param options - `smooth` (true by default).
@@ -934,22 +960,174 @@ export class ChikyuSpace extends HTMLElement {
934
960
  */
935
961
  async goToPlace(text, options = {}) {
936
962
  const place = findPlace(this.#placeList, text);
937
- const base = this.#model.lookBase;
938
- if (!place || !base || this.#model.ride)
963
+ if (!place || !this.#model.lookBase || this.#model.ride)
939
964
  return undefined;
940
- const controls = this.#controls();
941
- const from = { yaw: this.#model.view.yaw, tilt: this.#model.view.tilt };
942
- const to = aimAt(base, place, from);
943
- const glide = (this.#placeGlide += 1);
944
- const set = (yaw, tilt, final) => {
945
- if (controls)
946
- controls.set({ yaw, tilt, zoom: this.#model.view.zoom }, final, "place");
947
- else
948
- this.setView({ yaw, tilt, zoom: this.#model.view.zoom }, final);
949
- };
950
- glideView(set, from, to, options.smooth !== false && !prefersLessMotion() && this.#view?.live === true, () => glide === this.#placeGlide && this.isConnected);
965
+ this.#flyAsks += 1;
966
+ this.#startFlight(place, { phase: "across", heightKm: null, acrossMs: PLACE_GLIDE_MS, smooth: options.smooth !== false, held: null });
951
967
  return { ...place };
952
968
  }
969
+ /**
970
+ * Fly the camera to a place: across, the Earth turns under the camera at the height it has until the place is below (along a great circle, eased), then down, a descent to `height` kilometres over
971
+ * it (30 by default). `phase` asks for one part alone, so a page can take a reader there one press at a time. A new `flyTo` or `goToPlace` while one is moving does not stop it: the camera keeps its
972
+ * speed and the way it is going and curves smoothly into the new move, and a descent cut short slows to rest without turning back before the new move goes across. A hand on the view (a drag, a pinch,
973
+ * the wheel, a key) or `signal` ends it where it is; a reader who asked for reduced motion, `smooth: false` or a picture that is not live yet goes there at once. The controls' own turn (Auto-turn) is
974
+ * paused, so the place stays below.
975
+ *
976
+ * The descent comes all the way down only where finer pictures lie under the place (`tiles-finer`, over land from 60 degrees south to 80 degrees north); elsewhere it stops at `FLY_FLOOR_KM` (400 km), and
977
+ * at a `zoom-max` the page set, and says so in `held` and `stats.fly`. Once a fly-to has come below about 320 km the zoom reaches as low as it came. The camera must be looking at the Earth: while it
978
+ * rides along or looks at another body nothing moves. `chikyu-fly-start` is sent when it starts, with `{ lon, lat, phase, heightKm, held }`, and `chikyu-fly-end` when it ends, with what it resolves to.
979
+ *
980
+ * @param lat - Degrees north.
981
+ * @param lon - Degrees east.
982
+ * @param options - `height`, `phase`, `smooth` and `signal` (`FlyOptions`).
983
+ * @returns How it ended, once it has; `undefined` when it cannot fly (a latitude or longitude that is not a number, or the camera not looking at the Earth).
984
+ */
985
+ async flyTo(lat, lon, options = {}) {
986
+ if (!Number.isFinite(lat) || !Number.isFinite(lon) || Math.abs(lat) > 90)
987
+ return undefined;
988
+ const ask = (this.#flyAsks += 1);
989
+ const phase = options.phase ?? "both";
990
+ let heightKm = phase === "across" ? null : Math.max(FLY_MIN_KM, Number.isFinite(options.height) ? options.height : FLY_HEIGHT_KM);
991
+ let held = null;
992
+ if (heightKm !== null) {
993
+ const finer = this.tilesFiner !== null;
994
+ // only with finer pictures asked for is it worth knowing whether the place is on land: the outlines are loaded then, and once
995
+ const land = finer ? await import("../place/land.js").then(({ landAt }) => landAt(lon, lat)).then((answer) => answer.country !== null || answer.near !== null) : false;
996
+ const floor = descentFloorKm({ finer, land, lat });
997
+ if (floor !== null && floor > heightKm) {
998
+ heightKm = floor;
999
+ held = "no-finer";
1000
+ }
1001
+ }
1002
+ const where = { lon, lat, phase, heightKm: this.#model.lookBase ? this.#heightKm() : 0, held };
1003
+ // a later move was asked for while this one found its floor
1004
+ if (ask !== this.#flyAsks)
1005
+ return { ...where, reason: "redirected" };
1006
+ if (!this.#model.lookBase || this.#model.ride)
1007
+ return undefined;
1008
+ if (options.signal?.aborted)
1009
+ return { ...where, reason: "stopped" };
1010
+ return new Promise((resolve) => {
1011
+ this.#startFlight({ lon, lat }, {
1012
+ phase,
1013
+ heightKm,
1014
+ smooth: options.smooth !== false,
1015
+ held,
1016
+ ...(options.signal ? { signal: options.signal } : {}),
1017
+ pause: true,
1018
+ start: (detail) => this.dispatchEvent(new CustomEvent("chikyu-fly-start", { detail, bubbles: true, composed: true })),
1019
+ done: (end) => {
1020
+ this.dispatchEvent(new CustomEvent("chikyu-fly-end", { detail: end, bubbles: true, composed: true }));
1021
+ resolve(end);
1022
+ },
1023
+ });
1024
+ });
1025
+ }
1026
+ /** The camera's height above the ground in kilometres while it looks at the Earth, from the zoom and the box's fit. */
1027
+ #heightKm(zoom = this.#model.view.zoom) {
1028
+ return (Math.max(this.#model.nearest, this.#model.fit / Math.max(1e-9, zoom)) - 1) * EARTH_RADIUS_KM;
1029
+ }
1030
+ /**
1031
+ * Start a move to `to`: the one running hands its speed and turn on to it and ends `redirected`. A descent first lets the controls' zoom reach its height (under a `zoom-max` the page set, which holds it).
1032
+ */
1033
+ #startFlight(to, options) {
1034
+ const base = this.#model.lookBase;
1035
+ const at = performance.now();
1036
+ const view = this.#model.view;
1037
+ const now = this.#flight ? flyStateAt(this.#flight.plan, at) : flyStill(flyAim(base.lon - view.yaw, Math.max(-90, Math.min(90, base.lat - view.tilt))), this.#heightKm());
1038
+ if (this.#flight) {
1039
+ this.#flyStats.redirects += 1;
1040
+ this.#flight.finish("redirected");
1041
+ }
1042
+ let heightKm = options.heightKm;
1043
+ let held = options.held;
1044
+ if (heightKm !== null) {
1045
+ const zoom = this.#model.fit / flyDistance(heightKm);
1046
+ this.#model.nearest = Math.min(this.#model.nearest, flyDistance(heightKm));
1047
+ if (zoom > this.#flyZoomMax) {
1048
+ this.#flyZoomMax = zoom;
1049
+ this.#hands?.setLimits({ zoomMax: zoom });
1050
+ }
1051
+ const limit = this.#controls()?.limits?.zoomMax ?? zoom;
1052
+ if (zoom > limit * (1 + 1e-9)) {
1053
+ heightKm = (this.#model.fit / limit - 1) * EARTH_RADIUS_KM;
1054
+ held = "zoom-max";
1055
+ }
1056
+ }
1057
+ this.#flyStats.moves += 1;
1058
+ this.#flyStats.held = held;
1059
+ // the view's own turn would carry the place away from below the camera
1060
+ if (options.pause)
1061
+ this.#controls()?.pause?.();
1062
+ const plan = planFly(now, flyAim(to.lon, to.lat), { at, phase: options.phase, ...(heightKm !== null ? { heightKm } : {}), ...(options.acrossMs !== undefined ? { acrossMs: options.acrossMs } : {}) });
1063
+ const lifts = plan.lifts.length > 0;
1064
+ const abort = () => flight.finish("stopped");
1065
+ const flight = {
1066
+ plan,
1067
+ phase: options.phase,
1068
+ finish: (reason) => {
1069
+ if (this.#flight !== flight)
1070
+ return;
1071
+ this.#flight = null;
1072
+ options.signal?.removeEventListener("abort", abort);
1073
+ bar?.removeEventListener("kazoku-viewchange", hand);
1074
+ options.done?.({ reason, lon: to.lon, lat: to.lat, phase: options.phase, heightKm: this.#heightKm(), held });
1075
+ },
1076
+ };
1077
+ // a bar bound to the view has the hands: a change it makes for one ends the move too
1078
+ const bar = this.#bar();
1079
+ const hand = (event) => {
1080
+ if (HANDS.has(event.detail?.reason ?? ""))
1081
+ flight.finish("stopped");
1082
+ };
1083
+ this.#flight = flight;
1084
+ options.signal?.addEventListener("abort", abort, { once: true });
1085
+ bar?.addEventListener("kazoku-viewchange", hand);
1086
+ options.start?.({ lon: to.lon, lat: to.lat, phase: options.phase, heightKm: heightKm ?? this.#heightKm(), held });
1087
+ if (!options.smooth || prefersLessMotion() || this.#view?.live !== true) {
1088
+ this.#flyView(flyAt(plan, plan.end), true, base, lifts);
1089
+ flight.finish("arrived");
1090
+ return;
1091
+ }
1092
+ this.#askFlyFrame();
1093
+ }
1094
+ /** Ask for the next frame of the move running, once: a move that takes over another goes on in the frame already asked for. */
1095
+ #askFlyFrame() {
1096
+ if (this.#flyAsked)
1097
+ return;
1098
+ this.#flyAsked = true;
1099
+ requestAnimationFrame(this.#flyFrame);
1100
+ }
1101
+ /** One frame of the move running: the point it has now handed to the view, until it ends or the camera stops looking at the Earth. */
1102
+ #flyFrame = () => {
1103
+ this.#flyAsked = false;
1104
+ const flight = this.#flight;
1105
+ if (!flight)
1106
+ return;
1107
+ const looking = this.#model.lookBase;
1108
+ if (!looking || this.#model.ride || !this.isConnected) {
1109
+ flight.finish("stopped");
1110
+ return;
1111
+ }
1112
+ const now = performance.now();
1113
+ const last = now >= flight.plan.end;
1114
+ this.#flyView(flyAt(flight.plan, now), last, looking, flight.plan.lifts.length > 0);
1115
+ if (last)
1116
+ flight.finish("arrived");
1117
+ else
1118
+ this.#askFlyFrame();
1119
+ };
1120
+ /** Hand one point of a move to the controls (or the view, with none): the yaw and tilt that put it in the middle, and the zoom of its height when the move changes the height. */
1121
+ #flyView(point, final, base, lifts) {
1122
+ const view = this.#model.view;
1123
+ const turn = aimAt(base, flyLonLat(point.aim), view);
1124
+ const next = { yaw: turn.yaw, tilt: turn.tilt, zoom: lifts ? this.#model.fit / flyDistance(point.heightKm) : view.zoom };
1125
+ const controls = this.#controls();
1126
+ if (controls)
1127
+ controls.set(next, final, "fly");
1128
+ else
1129
+ this.setView(next, final);
1130
+ }
953
1131
  /**
954
1132
  * Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
955
1133
  *
@@ -1562,14 +1740,15 @@ export class ChikyuSpace extends HTMLElement {
1562
1740
  * The controls that are driving this view: a `<kazoku-view-controls for="...">` bound to it (its hands are then the only ones and its controller holds the yaw and tilt), else the element's own hands.
1563
1741
  */
1564
1742
  #controls() {
1565
- if (this.hasAttribute("data-kazoku-bar") && this.id) {
1566
- const root = this.getRootNode();
1567
- const bar = root.querySelector?.(`kazoku-view-controls[for="${CSS.escape(this.id)}"]`);
1568
- const held = bar ? Reflect.get(bar, "controller") : undefined;
1569
- if (held)
1570
- return held;
1571
- }
1572
- return this.#hands?.controller;
1743
+ const bar = this.#bar();
1744
+ const held = bar ? Reflect.get(bar, "controller") : undefined;
1745
+ return held ?? this.#hands?.controller;
1746
+ }
1747
+ /** The `<kazoku-view-controls for="...">` bound to this view, when there is one. */
1748
+ #bar() {
1749
+ if (!this.hasAttribute("data-kazoku-bar") || !this.id)
1750
+ return null;
1751
+ return this.getRootNode().querySelector?.(`kazoku-view-controls[for="${CSS.escape(this.id)}"]`) ?? null;
1573
1752
  }
1574
1753
  /** The body the camera looks at: at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
1575
1754
  get body() {
@@ -1587,6 +1766,7 @@ export class ChikyuSpace extends HTMLElement {
1587
1766
  * Earth turns and slides beneath as it moves along its orbit (an ISS view goes round about every 90 minutes). A drag looks about from there (a drag right turns the camera to its left and a drag up tips it towards the bottom of its picture, so the ground follows the pointer), the shared controls' zoom narrows the view.
1588
1767
  * A satellite is `{ group, index }` of a group set with `setSatellites`; it is placed exactly, one SGP4 call a frame, at any speed. Another call switches smoothly; `null` stops. The draw rate follows how
1589
1768
  * fast the picture moves, never more than 30 a second (one a second for a reader who asked for reduced motion), and nothing is drawn out of sight.
1769
+ * Whatever the view, facing, drag or glide, the camera is never under the ground: one that would be lower than 1 km above it is held there. A camera that looks at a satellite comes in towards it along its line of sight, so the satellite stays where it is in the picture; any other moves out along its line from the Earth's centre.
1590
1770
  *
1591
1771
  * @param target - A body name (`"Moon"`, `"Mars"`, ...) or a satellite `{ group, index }`, or `null` to stop.
1592
1772
  * @param options - `view`, `look`, `distanceKm`, `smooth` (see `RideOptions`).
@@ -1616,8 +1796,8 @@ export class ChikyuSpace extends HTMLElement {
1616
1796
  const asked = options.view ?? "from";
1617
1797
  // above a body is meant for a satellite: a body is followed
1618
1798
  const view = typeof target === "string" && (target === "Earth" || asked === "above") ? "follow" : asked;
1619
- // 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
1620
- const faceable = !(view === "follow" && typeof target === "string");
1799
+ // a body followed (a planet, the Moon, the Earth) is looked at from round it as the view turns, and the view above a satellite looks down on it: neither has ways to face
1800
+ const faceable = !(view === "follow" && typeof target === "string") && view !== "above";
1621
1801
  const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
1622
1802
  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 };
1623
1803
  if (face) {
@@ -1643,11 +1823,11 @@ export class ChikyuSpace extends HTMLElement {
1643
1823
  }
1644
1824
  /**
1645
1825
  * Face one way while riding: `ahead` along the way it goes, `behind`, `left` or `right` (as seen facing ahead), `down` straight at the Earth, `up` straight away from it.
1646
- * In the `above` view, `down` looks straight down at the satellite and the Earth below it. The camera glides there in half a second (at once for a reader who asked for reduced motion) and keeps the zoom.
1826
+ * The camera glides there in half a second (at once for a reader who asked for reduced motion) and keeps the zoom.
1647
1827
  * The facing stays pressed until the view is turned or tipped. `chikyu-ride-face` is sent with `{ face }` (`null` when it is let go). Keys, while the element is focused: W ahead, S behind, A left, D right, R up, F down. The arrow keys stay with the view controls.
1648
1828
  *
1649
1829
  * @param face - The way to face.
1650
- * Following a body (a planet, the Moon) there is no way to face: it returns `false`. Held keys do not repeat, and keys typed in a field or in editable text are left to it.
1830
+ * Following a body (a planet, the Moon) there is no way to face, and none in the view above a satellite (`view: "above"`, which looks down on it): it returns `false` and the camera stays as it was. Held keys do not repeat, and keys typed in a field or in editable text are left to it.
1651
1831
  *
1652
1832
  * @returns Whether the camera faces that way now (`true` too when it already did, and nothing moves).
1653
1833
  */
@@ -1656,8 +1836,8 @@ export class ChikyuSpace extends HTMLElement {
1656
1836
  const ride = model.ride;
1657
1837
  if (!ride || !RIDE_FACES.includes(face))
1658
1838
  return false;
1659
- // following a body there is no way to face: only from a body or a satellite, following a satellite, or above it
1660
- if (ride.view === "follow" && typeof ride.target === "string")
1839
+ // following a body there is no way to face, nor above a satellite (the view looks down on it): only from a body or a satellite, or following a satellite
1840
+ if ((ride.view === "follow" && typeof ride.target === "string") || ride.view === "above")
1661
1841
  return false;
1662
1842
  // already facing that way: nothing to turn, and no glide started again
1663
1843
  if (this.facing === face)
@@ -2685,6 +2865,7 @@ export class ChikyuSpace extends HTMLElement {
2685
2865
  satellites: this.#satelliteStats(),
2686
2866
  pace: { ...this.#pace },
2687
2867
  lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
2868
+ cloudFade: this.#model.cloudShown,
2688
2869
  paths: this.#pathControls?.stats() ?? emptyPathStats(),
2689
2870
  ride: { track: this.#model.rideTrack ? { ...this.#model.rideTrack } : null, compass: this.#compass?.shown ? { ...this.#compass.shown } : null, riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
2690
2871
  camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], quaternion: [this.#model.pose.q[0], this.#model.pose.q[1], this.#model.pose.q[2], this.#model.pose.q[3]], fov: this.#model.pose.fov },
@@ -2703,6 +2884,12 @@ export class ChikyuSpace extends HTMLElement {
2703
2884
  route: { ...this.#model.route.stats },
2704
2885
  countryNames: this.#countries?.stats ?? { on: false, max: 0, countries: 0, names: 0, renders: 0, failed: false },
2705
2886
  seaNames: this.#seas?.stats ?? { on: false, radius: 0, names: 0, renders: 0 },
2887
+ fly: {
2888
+ flying: this.#flight !== null,
2889
+ phase: this.#flight ? (this.#flight.phase === "across" || performance.now() < this.#flight.plan.across ? "across" : "down") : null,
2890
+ heightKm: this.#model.lookBase ? this.#heightKm() : null,
2891
+ ...this.#flyStats,
2892
+ },
2706
2893
  };
2707
2894
  }
2708
2895
  #satelliteStats() {