@johnmorrisdotca/chikyu-earth 0.56.0 → 0.57.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ - **A published accuracy table, and a test that holds it** (MODULES-523). The new guide "How accurate it is" (English and Japanese) gives the measured error of the Sun's overhead point and of the line between day and night against NASA/JPL Horizons (eight moments from 1950 to 2075; worst 0.0074 degree, 0.8 km on the ground), and of the SGP4 places that `createSatellites` gives against Vallado's published verification set ("Revisiting Spacetrack Report #3", AIAA 2006-6753; four element sets, near Earth, strong drag and deep space; worst 0.000000007 km, agreement to every published digit). Each reference value is copied into `test/accuracy/references.ts` with its source and the date it was read. `test/accuracy.test.ts` holds the errors under stated limits (0.010 degree for the Sun and the line, 1 millimetre for SGP4), each the worst measured plus a margin, and each shown to fail when the code or the limit is broken. Not covered, and said so in the guide: NOAA's calculator (a page to operate, no file of values), the paper's printed tables and `tcppver.out` (only in a zip), the sunrise line with refraction, and the Earth-fixed step. No code of the package changed.
6
+
7
+ ## 0.57.0 - 2026-11-17
8
+
9
+ - **A ride's tilt range follows its facing; the outside distance and the glide length are options** (MODULES-1471). `rideTiltLimits(distance, look, zoom)` ignored the facing, so a ride that opened facing up (the site's Below step, 25 km under the satellite) could look down only to about 40 degrees above the horizon.
10
+ - **Tilt range.** `rideTiltLimits` takes the facing as a fourth argument (`face`, left out or `null` for none) and gives the range from where the facing rests to straight down (`rest - cap` to `rest + 90` degrees, worked from the same resting elevation `ridePose` uses): facing `up` from straight up to straight down, facing `down` from straight down to 20 degrees above the horizon, the other facings as before. The element passes the ride's facing. Rides with no facing, and the `down` look, are unchanged.
11
+ - **Outside distance.** `outsideKm` in `ride()` options, the attribute `ride-outside-km` and the property `rideOutsideKm` set how far back an outside ride keeps the camera (25 km, `OUTSIDE_KM`, by default; never more than half the satellite's height). `outsidePose` takes it as a fifth argument, and `riding.outsideKm` reports it. Changed while riding it glides in 0.8 s.
12
+ - **Glide length.** `glide` in `ride()` options is a number of milliseconds (1200 by default, as before) or `{ minMs, maxMs }` for a length that follows how far the camera has to move. The new pure `rideGlideMs(km, minMs = 800, maxMs = 4000)` grows with each tenfold of the distance from 10 km to 30,000 km: about 1.2 s for 25 km and 3 s for 3,000 km. Nothing changes for a page that does not pass it.
13
+ - **Tests and docs.** Unit tests of the tilt range for every facing at 25 km and at 420 km (both ends of the range, nothing moving past them, something moving just inside), of `outsidePose`'s distance and of `rideGlideMs`; the ride guide in English and Japanese (the Japanese read by the Japanese reviewer) and `docs/ride-along.md`.
14
+
3
15
  ## 0.56.0 - 2026-11-17
4
16
 
5
17
 
package/README.md CHANGED
@@ -589,6 +589,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
589
589
  | [Printable sheets](docs/guides/printable-sheets.md) | The globe, a world map, my country, day and night and the seasons to print and colour |
590
590
  | [Why two packages](docs/guides/two-packages.md) | This package and wakusei-planets: which to install, alone and together |
591
591
  | [How it stays light](docs/guides/how-it-works.md) | The budget |
592
+ | [How accurate it is](docs/guides/accuracy.md) | The Sun's overhead point, the day and night line and SGP4, each measured against a published reference, with its source and limit |
592
593
  | [Architecture](docs/guides/architecture.md) | How the layers fit |
593
594
  | [Troubleshooting](docs/guides/troubleshooting.md) | Something does not appear |
594
595
  | [Upgrading](docs/guides/upgrading.md) | What to act on between versions |
@@ -614,7 +615,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
614
615
 
615
616
  ## How to cite
616
617
 
617
- > Morris, J. (2026). *Chikyu Earth* (version 0.56.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
618
+ > Morris, J. (2026). *Chikyu Earth* (version 0.57.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
618
619
 
619
620
  GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
620
621
 
@@ -130,6 +130,13 @@ export interface RideOptions {
130
130
  drag?: RideDrag;
131
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
132
  up?: RideUp;
133
+ /** How far back the camera is kept from the satellite in an outside ride, in kilometres (`view: "from"`; the element's `ride-outside-km` when not given, else 25). It is never more than half the satellite's height. */
134
+ outsideKm?: number;
135
+ /** How long the glide to this ride lasts: a number of milliseconds (1200 by default), or `{ minMs, maxMs }` for a length that follows how far the camera has to move (`rideGlideMs`: 800 to 4000 ms by default, about 1.2 s for a 25 km hop and 3 s for 3,000 km). */
136
+ glide?: number | {
137
+ minMs?: number;
138
+ maxMs?: number;
139
+ };
133
140
  distanceKm?: number;
134
141
  smooth?: boolean;
135
142
  }
@@ -152,6 +159,8 @@ export interface Riding {
152
159
  distanceKm: number;
153
160
  /** `outside` or `inside` (see `RideOptions`). */
154
161
  viewpoint: RideViewpoint;
162
+ /** How far back an outside ride keeps the camera, in kilometres (see `RideOptions`). */
163
+ outsideKm: number;
155
164
  /** `distance` or `fixed` (see `RideOptions`). */
156
165
  modelSize: RideModelSize;
157
166
  /** `head` or `orbit` (see `RideOptions`). */
@@ -574,6 +583,21 @@ export declare class ChikyuSpace extends HTMLElement {
574
583
  noradId: number;
575
584
  name: string;
576
585
  } | null;
586
+ /**
587
+ * 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,
588
+ * 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.
589
+ *
590
+ * @example
591
+ * ```ts
592
+ * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
593
+ *
594
+ * const space = document.createElement("chikyu-space") as ChikyuSpace;
595
+ * space.rideOutsideKm = 100;
596
+ * console.log(space.rideOutsideKm);
597
+ * ```
598
+ */
599
+ get rideOutsideKm(): number | null;
600
+ set rideOutsideKm(value: number | null);
577
601
  /**
578
602
  * Where a ride puts the camera: `outside` (the default; the attribute `ride-viewpoint`) shows the satellite, `inside` puts the camera at it. It is the default for the next `ride` and, set while riding, moves the ride there in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock.
579
603
  * See `RideOptions.viewpoint`.
@@ -39,7 +39,7 @@ import { styleTable } from "./paths.js";
39
39
  import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
40
40
  import { clampFollow, retargetFollow } from "./follow.js";
41
41
  import { COMPASS_HTML, COMPASS_STYLE, createCompass, readCompass } from "./compass.js";
42
- import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
42
+ import { OUTSIDE_KM, RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
43
43
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
44
44
  import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
45
45
  import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.js";
@@ -115,6 +115,22 @@ function readFrame(value, min, max) {
115
115
  const number = Number(value);
116
116
  return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : null;
117
117
  }
118
+ /** The distance an outside ride keeps, in kilometres, from an option or an attribute: a positive number, else `null`. */
119
+ function readOutsideKm(value) {
120
+ const number = typeof value === "string" ? (value.trim() === "" ? NaN : Number(value)) : value;
121
+ return typeof number === "number" && Number.isFinite(number) && number > 0 ? number : null;
122
+ }
123
+ /** 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. */
124
+ function readGlide(value) {
125
+ if (typeof value === "number" && Number.isFinite(value))
126
+ return { duration: Math.min(20_000, Math.max(0, value)) };
127
+ if (value && typeof value === "object") {
128
+ const minMs = typeof value.minMs === "number" && Number.isFinite(value.minMs) ? Math.min(20_000, Math.max(0, value.minMs)) : 800;
129
+ const maxMs = typeof value.maxMs === "number" && Number.isFinite(value.maxMs) ? Math.min(20_000, Math.max(minMs, value.maxMs)) : Math.max(minMs, 4000);
130
+ return { duration: minMs, scaled: { minMs, maxMs } };
131
+ }
132
+ return { duration: 1200 };
133
+ }
118
134
  /** An option's number held between `min` and `max`, or `undefined` when it is not given. */
119
135
  function clampFrame(value, min, max) {
120
136
  return typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : undefined;
@@ -179,7 +195,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
179
195
  * ```
180
196
  */
181
197
  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"];
198
+ 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
199
  #model = newSpaceModel();
184
200
  /** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
185
201
  #finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
@@ -488,6 +504,8 @@ export class ChikyuSpace extends HTMLElement {
488
504
  this.#applyViewpoint();
489
505
  else if (name === "ride-model-size")
490
506
  this.#applyModelSize();
507
+ else if (name === "ride-outside-km")
508
+ this.#applyOutsideKm();
491
509
  else if (name === "ride-drag")
492
510
  this.#applyDrag();
493
511
  else if (name === "ride-up")
@@ -1471,7 +1489,7 @@ export class ChikyuSpace extends HTMLElement {
1471
1489
  model.rideTurn += rideTurnDegrees(wrapYaw(view.yaw - now.yaw), view.zoom);
1472
1490
  // 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
1491
  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;
1492
+ const limits = model.ride && model.ride.view === "from" && model.rideDistance !== null ? rideTiltLimits(model.rideDistance, model.ride.look, view.zoom, model.ride.face) : null;
1475
1493
  if (limits)
1476
1494
  tilt = Math.max(limits.min, Math.min(limits.max, tilt));
1477
1495
  this.#model.view = { yaw: view.yaw, tilt, zoom: view.zoom };
@@ -1548,7 +1566,7 @@ export class ChikyuSpace extends HTMLElement {
1548
1566
  // 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
1567
  const faceable = !(view === "follow" && typeof target === "string");
1550
1568
  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 };
1569
+ 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
1570
  if (face) {
1553
1571
  model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
1554
1572
  model.rideTurn = 0;
@@ -1562,7 +1580,8 @@ export class ChikyuSpace extends HTMLElement {
1562
1580
  this.#zoomRange(model.ride?.view === "from");
1563
1581
  this.#lostTold = false;
1564
1582
  const pose = model.pose;
1565
- model.transition = (options.smooth ?? true) && !reduced && pose.valid ? { start: performance.now(), duration: 1200, 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;
1583
+ const glide = readGlide(options.glide);
1584
+ 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
1585
  this.#last = performance.now();
1567
1586
  this.#schedule();
1568
1587
  this.#gate?.request();
@@ -1681,6 +1700,45 @@ export class ChikyuSpace extends HTMLElement {
1681
1700
  this.ride(next.ref, { view: "follow" });
1682
1701
  return next;
1683
1702
  }
1703
+ /**
1704
+ * 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,
1705
+ * 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.
1706
+ *
1707
+ * @example
1708
+ * ```ts
1709
+ * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
1710
+ *
1711
+ * const space = document.createElement("chikyu-space") as ChikyuSpace;
1712
+ * space.rideOutsideKm = 100;
1713
+ * console.log(space.rideOutsideKm);
1714
+ * ```
1715
+ */
1716
+ get rideOutsideKm() {
1717
+ return readOutsideKm(this.getAttribute("ride-outside-km"));
1718
+ }
1719
+ set rideOutsideKm(value) {
1720
+ if (readOutsideKm(value) === null)
1721
+ this.removeAttribute("ride-outside-km");
1722
+ else
1723
+ this.setAttribute("ride-outside-km", String(value));
1724
+ }
1725
+ #applyOutsideKm() {
1726
+ const model = this.#model;
1727
+ const ride = model.ride;
1728
+ const next = this.rideOutsideKm ?? OUTSIDE_KM;
1729
+ if (!ride || ride.outsideKm === next)
1730
+ return;
1731
+ const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
1732
+ const pose = model.pose;
1733
+ model.ride = { ...ride, outsideKm: next };
1734
+ // only an outside ride from the satellite has a camera that far back: the others have nothing to glide
1735
+ const moves = ride.view === "from" && ride.viewpoint === "outside" && typeof ride.target !== "string";
1736
+ 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;
1737
+ this.#last = performance.now();
1738
+ this.#schedule();
1739
+ this.#gate?.request();
1740
+ this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
1741
+ }
1684
1742
  /**
1685
1743
  * 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
1744
  * See `RideOptions.viewpoint`.
@@ -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";
@@ -3,7 +3,7 @@
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";
@@ -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 zoom. The `down` look has no such range.
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
- * console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
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;
@@ -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 zoom. The `down` look has no such range.
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
- * console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
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 start = Math.max(0, radius - 12) * RAD - Math.PI / 2;
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: (start - (MAX_ABOVE_HORIZON * RAD)) / RAD / perDegree, max: (start + Math.PI / 2) / RAD / perDegree };
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 = input.face === "down" ? -Math.PI / 2 : input.face === "up" ? Math.PI / 2 : base - Math.PI / 2;
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,
@@ -122,6 +122,8 @@ export interface RideState {
122
122
  distanceKm: number;
123
123
  /** `outside`: a ridden satellite is in the picture (the camera a little behind and above it in `from`, a drawing of it where the page has no model); `inside`: as a ride was before, the camera at the satellite and no drawing of it where the page has no model. */
124
124
  viewpoint: RideViewpoint;
125
+ /** How far back an outside ride keeps the camera from the satellite, in kilometres. */
126
+ outsideKm: number;
125
127
  /** How the model of a satellite seen from above is sized as the camera rises: `distance` shrinks it and hands over to the mark, `fixed` keeps one share of the picture. */
126
128
  modelSize: RideModelSize;
127
129
  /** What a drag does in an outside ride from the satellite: `head` turns the view where the camera is, `orbit` takes the camera round the satellite. */
@@ -240,6 +242,10 @@ export interface SpaceModel {
240
242
  transition: {
241
243
  start: number;
242
244
  duration: number;
245
+ scaled?: {
246
+ minMs: number;
247
+ maxMs: number;
248
+ };
243
249
  from: {
244
250
  p: Vec3;
245
251
  q: [number, number, number, number];
@@ -5,7 +5,7 @@ import { createTextureSet } from "../realistic/textures.js";
5
5
  import { createTileSet } from "../realistic/tile-set.js";
6
6
  import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
7
7
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
8
- import { faceOffset, outsidePose, ridePose } from "./ride.js";
8
+ import { faceOffset, outsidePose, rideGlideMs, ridePose } from "./ride.js";
9
9
  import { stripLights } from "./model-lights.js";
10
10
  import { newLightFade, stepLightFade } from "../realistic/light-fade.js";
11
11
  import { prefersLessMotion } from "../meteors/note.js";
@@ -661,7 +661,7 @@ export function createSpaceItem(model, deps) {
661
661
  if (ridden && ride.viewpoint === "outside") {
662
662
  // a drag turns the view where the camera is (`head`: the camera's place is the one it has with no drag), or takes the camera round the satellite (`orbit`)
663
663
  const rest = ride.drag === "orbit" ? undefined : ridePose({ position: rideFrom.position, velocity: rideFrom.velocity, look: ride.look, yaw: 0, tilt: 0, zoom: model.view.zoom, turn: 0, ...(ride.face ? { face: ride.face } : {}) });
664
- const out = outsidePose(pose, ride.look, framing ? (framing.seat - 0.5) / 0.5 : undefined, rest);
664
+ const out = outsidePose(pose, ride.look, framing ? (framing.seat - 0.5) / 0.5 : undefined, rest, ride.outsideKm);
665
665
  pose = out.pose;
666
666
  outsideAway = out.distance;
667
667
  }
@@ -730,6 +730,12 @@ export function createSpaceItem(model, deps) {
730
730
  // a ride that changed: glide from where the last draw left the camera (a jump for a reader who asked for reduced motion; the element does not start one then)
731
731
  const glide = model.transition;
732
732
  if (glide) {
733
+ // a glide that follows the distance takes its length from how far the camera has to go, at its first frame
734
+ if (glide.scaled) {
735
+ const km = Math.hypot(camera.position.x - glide.from.p[0], camera.position.y - glide.from.p[1], camera.position.z - glide.from.p[2]) * 6371;
736
+ glide.duration = rideGlideMs(km, glide.scaled.minMs, glide.scaled.maxMs);
737
+ delete glide.scaled;
738
+ }
733
739
  const k = Math.min(1, (performance.now() - glide.start) / glide.duration);
734
740
  const ease = k * k * (3 - 2 * k);
735
741
  desiredQ.copy(camera.quaternion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.56.0",
3
+ "version": "0.57.0",
4
4
  "description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on the place you give it, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
5
5
  "keywords": [
6
6
  "earth",