@johnmorrisdotca/chikyu-earth 0.51.1 → 0.52.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 +6 -0
- package/README.md +2 -2
- package/dist/space/element-base.d.ts +21 -1
- package/dist/space/element-base.js +41 -2
- package/dist/space/index.d.ts +1 -1
- package/dist/space/ride.d.ts +21 -3
- package/dist/space/ride.js +12 -6
- package/dist/space/scene.d.ts +3 -1
- package/dist/space/scene.js +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.52.0 - 2026-11-16
|
|
6
|
+
|
|
7
|
+
- **A drag in a ride turns the view from where the vehicle is, not the vehicle round the camera** (MODULES-1374). In a ride of a satellite with the `outside` viewpoint (the default), dragging looked about but took the camera round the satellite as it looked, so the satellite was seen from every side and the whole vehicle seemed to be moved. A drag now turns the view where the camera is, like turning your head, in both looks (`horizon`, Ride along, and `down`, Ride above): the camera keeps its place 25 km behind and above the satellite and the scene turns round it; the satellite is at its share and seat of the picture while you do not drag and leaves it as you look away. **A change of behaviour**: `ride-drag="orbit"` (property `rideDrag`, option `drag` of `ride`, field `drag` of `Riding`) brings the old look-around back; the default is `head`. `outsidePose` takes an optional `rest` (the pose with no drag) and keeps the camera where that puts it; without it, it works as before. Inside the satellite, the `follow` and `above` views and riding a body are unchanged. Tests: unit tests of the pose maths (the camera does not move under any drag in `head`, the satellite holds its place in `orbit`, the pace of the ground), and `e2e/ride-outside.gl.ts` for both looks and both modes. English and Japanese guides and the upgrading page.
|
|
8
|
+
|
|
3
9
|
## 0.51.1 - 2026-11-13
|
|
4
10
|
|
|
5
11
|
Tests only: the package is unchanged by this release.
|
package/README.md
CHANGED
|
@@ -359,7 +359,7 @@ Passes are only as good as the orbit data are new: each pass says how old its el
|
|
|
359
359
|
<p align="center"><img alt="Riding along with the ISS, tipped towards the horizon: the Earth's curve and atmosphere, and the orbits of the other stations in the sky" src="docs/images/space-ride-horizon.png" width="420"></p>
|
|
360
360
|
|
|
361
361
|
`space.ride({ group: "stations", index: 0 }, { look: "horizon" })` puts the camera on the ISS (or a Starlink satellite, the Moon, a planet) at its real place for the moment shown and looks at the Earth, which goes by beneath
|
|
362
|
-
as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
|
|
362
|
+
as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. A drag turns the view where the camera is, like turning your head (the satellite leaves the picture as you look away); `ride-drag="orbit"` (property `rideDrag`, option `drag`) takes the camera round the satellite as before. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
|
|
363
363
|
same budget: at most 30 frames a second (one a second for reduced motion), nothing drawn while paused, out of sight or hidden. [Ride along guide](docs/guides/ride-along.md), [docs/ride-along.md](docs/ride-along.md).
|
|
364
364
|
|
|
365
365
|
## Printable sheets
|
|
@@ -612,7 +612,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
612
612
|
|
|
613
613
|
## How to cite
|
|
614
614
|
|
|
615
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
615
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.52.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
616
616
|
|
|
617
617
|
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.
|
|
618
618
|
|
|
@@ -21,7 +21,7 @@ import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts"
|
|
|
21
21
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
22
22
|
import { type PathStats } from "./path-controls.ts";
|
|
23
23
|
import { type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
24
|
-
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
24
|
+
import { type RideDrag, type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
25
25
|
import { type ScaleMode } from "./scale.ts";
|
|
26
26
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
27
27
|
import { type PaintSpec } from "../paint/buffer.ts";
|
|
@@ -125,6 +125,8 @@ export interface RideOptions {
|
|
|
125
125
|
viewpoint?: RideViewpoint;
|
|
126
126
|
/** `distance` (the default, or the element's `ride-model-size`) lets the model of a satellite seen from above shrink as the camera rises and hand over to the ordinary mark, ring and name, between 1,000 and 2,000 km; `fixed` keeps one share of the picture at every height. */
|
|
127
127
|
modelSize?: RideModelSize;
|
|
128
|
+
/** What a drag does in an outside ride from the satellite (`view: "from"`): `head` (the default, or the element's `ride-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it; `orbit` takes the camera round the satellite as it looks about, so the satellite stays in the same place in the picture and is seen from every side, as a ride did up to 0.51. */
|
|
129
|
+
drag?: RideDrag;
|
|
128
130
|
distanceKm?: number;
|
|
129
131
|
smooth?: boolean;
|
|
130
132
|
}
|
|
@@ -149,6 +151,8 @@ export interface Riding {
|
|
|
149
151
|
viewpoint: RideViewpoint;
|
|
150
152
|
/** `distance` or `fixed` (see `RideOptions`). */
|
|
151
153
|
modelSize: RideModelSize;
|
|
154
|
+
/** `head` or `orbit` (see `RideOptions`). */
|
|
155
|
+
drag: RideDrag;
|
|
152
156
|
}
|
|
153
157
|
type SatelliteStats = {
|
|
154
158
|
groups: number;
|
|
@@ -586,6 +590,22 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
586
590
|
*/
|
|
587
591
|
get rideModelSize(): RideModelSize;
|
|
588
592
|
set rideModelSize(value: RideModelSize);
|
|
593
|
+
/**
|
|
594
|
+
* What a drag does in an outside ride from the satellite: `head` (the default; the attribute `ride-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it (look away and the satellite
|
|
595
|
+
* leaves the picture); `orbit` takes the camera round the satellite as it looks about, as a ride did up to 0.51: the satellite stays where it is in the picture and is seen from every side. It makes no difference inside the satellite, above it or behind it, or riding a body.
|
|
596
|
+
* It is the default for the next `ride` and, set while riding, moves the camera in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock. See `RideOptions.drag`.
|
|
597
|
+
*
|
|
598
|
+
* @example
|
|
599
|
+
* ```ts
|
|
600
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
601
|
+
*
|
|
602
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
603
|
+
* space.rideDrag = "orbit";
|
|
604
|
+
* console.log(space.rideDrag);
|
|
605
|
+
* ```
|
|
606
|
+
*/
|
|
607
|
+
get rideDrag(): RideDrag;
|
|
608
|
+
set rideDrag(value: RideDrag);
|
|
589
609
|
/**
|
|
590
610
|
* The radius of the ridden satellite's model as a share of the picture's height, 0.02 to 1.2 (the attribute `ride-model-share`), or `null` for the ride's own: 0.22 along the way it goes, 0.17 above the satellite (its size at the lowest height; `ride-model-size="distance"` still shrinks it as the ride rises).
|
|
591
611
|
* Set while riding it glides in 0.4 s (at once for a reader who asked for less motion). `stats.followModel.share` is the share in use.
|
|
@@ -177,7 +177,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
export class ChikyuSpace extends HTMLElement {
|
|
180
|
-
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", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
180
|
+
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-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
181
181
|
#model = newSpaceModel();
|
|
182
182
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
183
183
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -472,6 +472,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
472
472
|
this.#applyViewpoint();
|
|
473
473
|
else if (name === "ride-model-size")
|
|
474
474
|
this.#applyModelSize();
|
|
475
|
+
else if (name === "ride-drag")
|
|
476
|
+
this.#applyDrag();
|
|
475
477
|
else if (name === "ride-model-share" || name === "ride-model-seat")
|
|
476
478
|
this.#applyFrame();
|
|
477
479
|
else if (name === "ride-zoom")
|
|
@@ -1523,7 +1525,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1523
1525
|
// 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
|
|
1524
1526
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1525
1527
|
const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
|
|
1526
|
-
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 };
|
|
1528
|
+
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 };
|
|
1527
1529
|
if (face) {
|
|
1528
1530
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1529
1531
|
model.rideTurn = 0;
|
|
@@ -1685,6 +1687,43 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1685
1687
|
set rideModelSize(value) {
|
|
1686
1688
|
this.setAttribute("ride-model-size", value === "fixed" ? "fixed" : "distance");
|
|
1687
1689
|
}
|
|
1690
|
+
/**
|
|
1691
|
+
* What a drag does in an outside ride from the satellite: `head` (the default; the attribute `ride-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it (look away and the satellite
|
|
1692
|
+
* leaves the picture); `orbit` takes the camera round the satellite as it looks about, as a ride did up to 0.51: the satellite stays where it is in the picture and is seen from every side. It makes no difference inside the satellite, above it or behind it, or riding a body.
|
|
1693
|
+
* It is the default for the next `ride` and, set while riding, moves the camera in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock. See `RideOptions.drag`.
|
|
1694
|
+
*
|
|
1695
|
+
* @example
|
|
1696
|
+
* ```ts
|
|
1697
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1698
|
+
*
|
|
1699
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1700
|
+
* space.rideDrag = "orbit";
|
|
1701
|
+
* console.log(space.rideDrag);
|
|
1702
|
+
* ```
|
|
1703
|
+
*/
|
|
1704
|
+
get rideDrag() {
|
|
1705
|
+
return this.getAttribute("ride-drag") === "orbit" ? "orbit" : "head";
|
|
1706
|
+
}
|
|
1707
|
+
set rideDrag(value) {
|
|
1708
|
+
this.setAttribute("ride-drag", value === "orbit" ? "orbit" : "head");
|
|
1709
|
+
}
|
|
1710
|
+
#applyDrag() {
|
|
1711
|
+
const model = this.#model;
|
|
1712
|
+
const ride = model.ride;
|
|
1713
|
+
const next = this.rideDrag;
|
|
1714
|
+
if (!ride || ride.drag === next)
|
|
1715
|
+
return;
|
|
1716
|
+
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1717
|
+
const pose = model.pose;
|
|
1718
|
+
model.ride = { ...ride, drag: next };
|
|
1719
|
+
// only an outside ride from the satellite looks different: the others have nothing to glide
|
|
1720
|
+
const moves = ride.view === "from" && ride.viewpoint === "outside" && typeof ride.target !== "string";
|
|
1721
|
+
model.transition = moves && !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;
|
|
1722
|
+
this.#last = performance.now();
|
|
1723
|
+
this.#schedule();
|
|
1724
|
+
this.#gate?.request();
|
|
1725
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1726
|
+
}
|
|
1688
1727
|
#applyModelSize() {
|
|
1689
1728
|
const ride = this.#model.ride;
|
|
1690
1729
|
const next = this.rideModelSize;
|
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 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 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, 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 { genericSatellite, satelliteKind, type SatelliteKind } from "./generic-satellite.ts";
|
package/dist/space/ride.d.ts
CHANGED
|
@@ -174,6 +174,19 @@ export interface RidePose {
|
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
176
|
export type RideViewpoint = "outside" | "inside";
|
|
177
|
+
/**
|
|
178
|
+
* What a drag does in an outside ride: `head` (the default) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it (look away and the satellite
|
|
179
|
+
* leaves the picture, as anything behind your shoulder does); `orbit` is what a ride did up to 0.51: the camera goes round the satellite as it looks about, so the satellite stays in the same place in the picture but is seen from every side.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* ```ts
|
|
183
|
+
* import type { RideDrag } from "@johnmorrisdotca/chikyu-earth/space";
|
|
184
|
+
*
|
|
185
|
+
* const drags: RideDrag[] = ["head", "orbit"];
|
|
186
|
+
* console.log(drags.join(" or "));
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
export type RideDrag = "head" | "orbit";
|
|
177
190
|
/**
|
|
178
191
|
* How big the model of the ridden satellite is drawn as the camera rises above it in a ride above: `distance` (the default) lets it shrink as one over the height and hand over to the ordinary mark between 1,000 and 2,000 km, `fixed` keeps the same share of the picture at every height, as 0.46.1 did.
|
|
179
192
|
*
|
|
@@ -199,11 +212,14 @@ export type RideModelSize = "distance" | "fixed";
|
|
|
199
212
|
export declare const OUTSIDE_KM = 25;
|
|
200
213
|
/**
|
|
201
214
|
* 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
|
|
202
|
-
* 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
|
|
215
|
+
* 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`):
|
|
216
|
+
* the satellite stays where it is in the picture and is seen from every side. With `rest`, the pose the same ride has with no drag, the camera is put where that pose puts it and only turns where it is, so a drag looks about from there like a turn of the head (`head`): the satellite is at its place in the picture
|
|
217
|
+
* at rest and leaves it as the view turns away. Pure. Never nearer the ground than half the satellite's height.
|
|
203
218
|
*
|
|
204
219
|
* @param pose - The pose from `ridePose` for the camera at the satellite.
|
|
205
220
|
* @param look - The look the pose was made with.
|
|
206
221
|
* @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
|
+
* @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.
|
|
207
223
|
* @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.
|
|
208
224
|
*
|
|
209
225
|
* @example
|
|
@@ -212,10 +228,12 @@ export declare const OUTSIDE_KM = 25;
|
|
|
212
228
|
*
|
|
213
229
|
* const at = ridePose({ position: [1.066, 0, 0], velocity: [0, 0, -7.66], look: "horizon", yaw: 0, tilt: 0, zoom: 1 });
|
|
214
230
|
* const out = outsidePose(at, "horizon");
|
|
215
|
-
*
|
|
231
|
+
* const turned = ridePose({ position: [1.066, 0, 0], velocity: [0, 0, -7.66], look: "horizon", yaw: 90, tilt: 0, zoom: 1 });
|
|
232
|
+
* const head = outsidePose(turned, "horizon", undefined, at);
|
|
233
|
+
* 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(","));
|
|
216
234
|
* ```
|
|
217
235
|
*/
|
|
218
|
-
export declare function outsidePose(pose: RidePose, look: RideLook, low?: number): {
|
|
236
|
+
export declare function outsidePose(pose: RidePose, look: RideLook, low?: number, rest?: RidePose): {
|
|
219
237
|
pose: RidePose;
|
|
220
238
|
distance: number;
|
|
221
239
|
below: number;
|
package/dist/space/ride.js
CHANGED
|
@@ -136,11 +136,14 @@ export const OUTSIDE_KM = 25;
|
|
|
136
136
|
const OUTSIDE_LOW = 0.8;
|
|
137
137
|
/**
|
|
138
138
|
* 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
|
|
139
|
-
* 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
|
|
139
|
+
* 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`):
|
|
140
|
+
* the satellite stays where it is in the picture and is seen from every side. With `rest`, the pose the same ride has with no drag, the camera is put where that pose puts it and only turns where it is, so a drag looks about from there like a turn of the head (`head`): the satellite is at its place in the picture
|
|
141
|
+
* at rest and leaves it as the view turns away. Pure. Never nearer the ground than half the satellite's height.
|
|
140
142
|
*
|
|
141
143
|
* @param pose - The pose from `ridePose` for the camera at the satellite.
|
|
142
144
|
* @param look - The look the pose was made with.
|
|
143
145
|
* @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
|
+
* @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.
|
|
144
147
|
* @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.
|
|
145
148
|
*
|
|
146
149
|
* @example
|
|
@@ -149,16 +152,19 @@ const OUTSIDE_LOW = 0.8;
|
|
|
149
152
|
*
|
|
150
153
|
* const at = ridePose({ position: [1.066, 0, 0], velocity: [0, 0, -7.66], look: "horizon", yaw: 0, tilt: 0, zoom: 1 });
|
|
151
154
|
* const out = outsidePose(at, "horizon");
|
|
152
|
-
*
|
|
155
|
+
* const turned = ridePose({ position: [1.066, 0, 0], velocity: [0, 0, -7.66], look: "horizon", yaw: 90, tilt: 0, zoom: 1 });
|
|
156
|
+
* const head = outsidePose(turned, "horizon", undefined, at);
|
|
157
|
+
* 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(","));
|
|
153
158
|
* ```
|
|
154
159
|
*/
|
|
155
|
-
export function outsidePose(pose, look, low) {
|
|
160
|
+
export function outsidePose(pose, look, low, rest) {
|
|
161
|
+
const base = rest ?? pose;
|
|
156
162
|
const height = Math.max(0, norm(pose.position) - 1);
|
|
157
163
|
const distance = Math.max(1e-5, Math.min(OUTSIDE_KM / 6371, height * 0.5));
|
|
158
164
|
const lowNow = low ?? (look === "horizon" ? OUTSIDE_LOW : 0);
|
|
159
|
-
const below = Math.atan(Math.max(0, lowNow) * Math.tan((
|
|
160
|
-
// the satellite is along the line of sight turned `below` down (towards the bottom of the picture): the camera is back along that line
|
|
161
|
-
const line = add(scale(
|
|
165
|
+
const below = Math.atan(Math.max(0, lowNow) * Math.tan((base.fov / 2) * RAD));
|
|
166
|
+
// 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
|
|
167
|
+
const line = add(scale(base.forward, Math.cos(below)), scale(base.up, -Math.sin(below)));
|
|
162
168
|
return { pose: { ...pose, position: add(pose.position, scale(line, -distance)) }, distance, below: below / RAD };
|
|
163
169
|
}
|
|
164
170
|
/**
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { LightMode } from "../realistic/earth.ts";
|
|
|
7
7
|
import { type Frame, type PlanetName, type Vec3 } from "./ephemeris.ts";
|
|
8
8
|
import { type ScaleMode } from "./scale.ts";
|
|
9
9
|
import type { SatelliteRef } from "../satellites/types.ts";
|
|
10
|
-
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
10
|
+
import { type RideDrag, type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
11
11
|
import { type LightFade } from "../realistic/light-fade.ts";
|
|
12
12
|
import type { SkyFrame } from "../sky/frame.ts";
|
|
13
13
|
import type { PlaceView } from "../markers/places.ts";
|
|
@@ -122,6 +122,8 @@ export interface RideState {
|
|
|
122
122
|
viewpoint: RideViewpoint;
|
|
123
123
|
/** 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. */
|
|
124
124
|
modelSize: RideModelSize;
|
|
125
|
+
/** 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. */
|
|
126
|
+
drag: RideDrag;
|
|
125
127
|
}
|
|
126
128
|
/** The camera as the last draw left it, for the next one to start from when the ride changes. */
|
|
127
129
|
export interface Pose {
|
package/dist/space/scene.js
CHANGED
|
@@ -656,7 +656,9 @@ export function createSpaceItem(model, deps) {
|
|
|
656
656
|
// an outside ride: the same look, from a little way back along it, so the satellite is in the picture
|
|
657
657
|
let outsideAway = Infinity;
|
|
658
658
|
if (ridden && ride.viewpoint === "outside") {
|
|
659
|
-
|
|
659
|
+
// 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`)
|
|
660
|
+
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 } : {}) });
|
|
661
|
+
const out = outsidePose(pose, ride.look, framing ? (framing.seat - 0.5) / 0.5 : undefined, rest);
|
|
660
662
|
pose = out.pose;
|
|
661
663
|
outsideAway = out.distance;
|
|
662
664
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.52.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",
|