@johnmorrisdotca/chikyu-earth 0.9.0 → 0.9.1
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 +10 -0
- package/README.md +1 -1
- package/dist/space/element.d.ts +2 -2
- package/dist/space/element.js +2 -2
- package/dist/space/ride.d.ts +4 -3
- package/dist/space/ride.js +14 -8
- package/dist/space/scene.js +4 -2
- package/dist/view.d.ts +1 -1
- package/dist/view.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
The ground now follows the pointer, in every look and when riding.
|
|
6
|
+
|
|
7
|
+
- **The Earth turned the wrong way up and down** (MODULES-200). A drag up made the ground go down in the line, thick, realistic and space looks, and the up arrow did the same: the controls' tilt was added to the latitude of the view, and it should be subtracted (the top of the globe tips away as the tilt grows, as the controls say). It is now one sign in `lookAt` and `projectionView` (`src/view.ts`) and one in the space view, so the flat globe, the realistic Earth and the space view agree. **A tilt in an address or a call now tips the other way.**
|
|
8
|
+
Left and right were right already. Auto-turn turns the real way: the Earth goes round west to east, so with north up the ground moves from left to right, the same way as a drag right and the right arrow.
|
|
9
|
+
- **A ride could not be dragged** (MODULES-199). Riding at a body, a drag turned the camera's head round the straight-down line, which from the ISS only spun the picture, and tilt could not go the other way past the straight-down look, so a drag seemed to do nothing. `ridePose` now looks about from the base look as a head on a pivot does: yaw turns the camera to its left and tilt tips it towards the bottom of its picture, so a drag right moves the ground right and a drag up moves it up, about one and a half pixels a pixel, the pace of the line globe and the Earth from space. The angle for a pixel follows the field of view, so zooming in does not make the ground race. Behind a satellite (`view: "follow"`) the drag is mirrored, because the Earth is behind what the camera looks at, and the Earth follows the pointer.
|
|
10
|
+
- **The demo keeps the address's yaw and tilt when it opens on a ride** (it set both to 0 as the ride began), and **an address with `ride` and no `look` opens the space look**, so the reported address rides the ISS.
|
|
11
|
+
- **Tests**: `e2e/drag.gl.ts` drags with a real pointer, presses the arrow keys and runs Auto-turn in the line, thick, realistic and space looks, riding the ISS (down and at the horizon) and the Moon, and behind the ISS and the Moon, and checks which way the ground moved by sliding the first picture over the second; and that a ride opens with the address's turn, a drag writes it back and the address brings the same picture back; and the reported address. All fail on 0.9.0. Unit tests for `ridePose` and the view's signs.
|
|
12
|
+
|
|
3
13
|
## 0.9.0
|
|
4
14
|
|
|
5
15
|
Ride along: the camera on the ISS, a Starlink satellite, the Moon or a planet, looking at the Earth.
|
package/README.md
CHANGED
|
@@ -193,7 +193,7 @@ document.getElementById("controls")!.addEventListener("kazoku-viewchange", (even
|
|
|
193
193
|
});
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
The mapping is `rotate([lambda0 + yaw, phi0
|
|
196
|
+
The mapping is `rotate([lambda0 + yaw, phi0 + tilt])`, `scale(baseScale * zoom)` and
|
|
197
197
|
`translate([cx + panX, cy + panY])`, where `lambda0` and `phi0` are the home centre. Front returns to that home
|
|
198
198
|
view. Auto-turn's `0.004178` degrees a second is 360° per sidereal day; kazoku-ui leaves it still for a reader who
|
|
199
199
|
prefers reduced motion, and a drag or zoom never stops or resets it.
|
package/dist/space/element.d.ts
CHANGED
|
@@ -146,7 +146,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
146
146
|
get orbits(): boolean;
|
|
147
147
|
set orbits(value: boolean);
|
|
148
148
|
/**
|
|
149
|
-
* The shared controls' camera: yaw and tilt turn the view, zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. A turn that moves nothing on the screen by half a pixel is kept
|
|
149
|
+
* The shared controls' camera: yaw and tilt turn the view (the Earth's surface moves right for a drag right and up for a drag up), zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. A turn that moves nothing on the screen by half a pixel is kept
|
|
150
150
|
* for the next draw but does not cause one unless `final` is true (the default), so an Auto-turn at the Earth's own rate costs a draw every half minute, not thirty a second.
|
|
151
151
|
*
|
|
152
152
|
* @param view - The controls' yaw and tilt in degrees and zoom.
|
|
@@ -162,7 +162,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
162
162
|
set body(name: BodyName);
|
|
163
163
|
/**
|
|
164
164
|
* Ride along with a body or a satellite. By default the camera sits at it and looks at the Earth, with the way it is going at the top of the picture, at its real place for the moment shown, so the
|
|
165
|
-
* Earth turns and slides beneath as it moves along its orbit (an ISS view goes round about every 90 minutes).
|
|
165
|
+
* 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.
|
|
166
166
|
* 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
|
|
167
167
|
* 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.
|
|
168
168
|
*
|
package/dist/space/element.js
CHANGED
|
@@ -224,7 +224,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
224
224
|
this.#gate?.request();
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
227
|
-
* The shared controls' camera: yaw and tilt turn the view, zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. A turn that moves nothing on the screen by half a pixel is kept
|
|
227
|
+
* The shared controls' camera: yaw and tilt turn the view (the Earth's surface moves right for a drag right and up for a drag up), zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. A turn that moves nothing on the screen by half a pixel is kept
|
|
228
228
|
* for the next draw but does not cause one unless `final` is true (the default), so an Auto-turn at the Earth's own rate costs a draw every half minute, not thirty a second.
|
|
229
229
|
*
|
|
230
230
|
* @param view - The controls' yaw and tilt in degrees and zoom.
|
|
@@ -256,7 +256,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
256
256
|
// --- riding along -------------------------------------------------------------------------------------------------------------------------------
|
|
257
257
|
/**
|
|
258
258
|
* Ride along with a body or a satellite. By default the camera sits at it and looks at the Earth, with the way it is going at the top of the picture, at its real place for the moment shown, so the
|
|
259
|
-
* Earth turns and slides beneath as it moves along its orbit (an ISS view goes round about every 90 minutes).
|
|
259
|
+
* 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.
|
|
260
260
|
* 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
|
|
261
261
|
* 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.
|
|
262
262
|
*
|
package/dist/space/ride.d.ts
CHANGED
|
@@ -40,9 +40,9 @@ export interface RideInput {
|
|
|
40
40
|
/** Its direction of travel, in any unit: only the direction is used. */
|
|
41
41
|
velocity: Vec3;
|
|
42
42
|
look: RideLook;
|
|
43
|
-
/**
|
|
43
|
+
/** The shared controls' yaw in degrees (a drag across the view is 180): turns the camera to look along its picture's left, so the ground moves right. 0 has the way it is going at the top of the picture. */
|
|
44
44
|
yaw: number;
|
|
45
|
-
/**
|
|
45
|
+
/** The shared controls' tilt in degrees (a drag down the view is 60): tips the camera to look towards the bottom of its picture, so the ground moves up. */
|
|
46
46
|
tilt: number;
|
|
47
47
|
/** 1 is the natural view; more narrows the field of view. */
|
|
48
48
|
zoom: number;
|
|
@@ -67,7 +67,8 @@ export interface RidePose {
|
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
69
|
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the
|
|
70
|
-
* horizon is a little above the middle
|
|
70
|
+
* horizon is a little above the middle. A drag looks about from there, as a head on a pivot does: `yaw` turns the camera to its left and `tilt` tips it towards the bottom of its picture, so the
|
|
71
|
+
* ground follows the pointer (right for a drag right, up for a drag up); the angle for each pixel of the drag is the field of view's, so the pace is the same at any zoom. `zoom` narrows the field of view.
|
|
71
72
|
*
|
|
72
73
|
* @param input - The camera's place, its way of travel, the look, and the shared controls' yaw, tilt and zoom.
|
|
73
74
|
* @returns The camera's place, forward and up directions (unit vectors), its field of view, and the Earth's angular radius from there.
|
package/dist/space/ride.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const RAD = Math.PI / 180;
|
|
2
|
+
/** How far the ground moves in the picture for each pixel of a drag at the middle of it: the same pace as the line globe and the Earth from space (about one and a half). */
|
|
3
|
+
const GRAB = 1.5;
|
|
2
4
|
/**
|
|
3
5
|
* The field of view, in degrees, of a camera riding along at zoom 1 (the Earth's view from outside is 35).
|
|
4
6
|
*
|
|
@@ -21,7 +23,8 @@ const unit = (a) => {
|
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
25
|
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the
|
|
24
|
-
* horizon is a little above the middle
|
|
26
|
+
* horizon is a little above the middle. A drag looks about from there, as a head on a pivot does: `yaw` turns the camera to its left and `tilt` tips it towards the bottom of its picture, so the
|
|
27
|
+
* ground follows the pointer (right for a drag right, up for a drag up); the angle for each pixel of the drag is the field of view's, so the pace is the same at any zoom. `zoom` narrows the field of view.
|
|
25
28
|
*
|
|
26
29
|
* @param input - The camera's place, its way of travel, the look, and the shared controls' yaw, tilt and zoom.
|
|
27
30
|
* @returns The camera's place, forward and up directions (unit vectors), its field of view, and the Earth's angular radius from there.
|
|
@@ -46,12 +49,15 @@ export function ridePose(input) {
|
|
|
46
49
|
ahead = cross([1, 0, 0], nadir);
|
|
47
50
|
}
|
|
48
51
|
ahead = unit(ahead);
|
|
49
|
-
const turn = input.yaw * RAD;
|
|
50
|
-
ahead = add(scale(ahead, Math.cos(turn)), scale(cross(nadir, ahead), Math.sin(turn)));
|
|
51
52
|
const earthRadiusDegrees = distance <= 1 ? 90 : Math.asin(1 / distance) / RAD;
|
|
52
|
-
const base = input.look === "horizon" ? Math.max(0, earthRadiusDegrees - 12) : 0;
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
53
|
+
const base = input.look === "horizon" ? Math.max(0, earthRadiusDegrees - 12) * RAD : 0;
|
|
54
|
+
const forward0 = add(scale(nadir, Math.cos(base)), scale(ahead, Math.sin(base)));
|
|
55
|
+
const up0 = add(scale(ahead, Math.cos(base)), scale(nadir, -Math.sin(base)));
|
|
56
|
+
const fov = Math.min(100, Math.max(5, RIDE_FOV / Math.max(0.05, input.zoom)));
|
|
57
|
+
const turn = input.yaw * (GRAB * fov / 180) * RAD;
|
|
58
|
+
const lift = input.tilt * (GRAB * fov / 60) * RAD;
|
|
59
|
+
const turned = add(scale(forward0, Math.cos(turn)), scale(cross(up0, forward0), Math.sin(turn)));
|
|
60
|
+
const forward = add(scale(turned, Math.cos(lift)), scale(up0, -Math.sin(lift)));
|
|
61
|
+
const up = add(scale(up0, Math.cos(lift)), scale(turned, Math.sin(lift)));
|
|
62
|
+
return { position: [input.position[0], input.position[1], input.position[2]], forward, up, fov, earthRadiusDegrees };
|
|
57
63
|
}
|
package/dist/space/scene.js
CHANGED
|
@@ -323,8 +323,10 @@ export function createSpaceItem(model, deps) {
|
|
|
323
323
|
}
|
|
324
324
|
else {
|
|
325
325
|
const spin = model.cameraSpin ?? frame.spin;
|
|
326
|
-
|
|
327
|
-
const
|
|
326
|
+
// behind a satellite the Earth is the far side of what the camera looks at, so it moves with the camera's side-step; the view is mirrored for the ground to follow the pointer
|
|
327
|
+
const way = ride && ride.view === "follow" && typeof ride.target !== "string" ? -1 : 1;
|
|
328
|
+
const lon = model.centre.lon - way * model.view.yaw;
|
|
329
|
+
const lat = Math.max(-90, Math.min(90, model.centre.lat - way * model.view.tilt));
|
|
328
330
|
const aim = direction(spin + lon, lat);
|
|
329
331
|
distance = Math.max(1.05 * focusRadius, (FIT_DISTANCE * focusRadius) / Math.max(1e-9, model.view.zoom));
|
|
330
332
|
target.set(focusPos[0], focusPos[1], focusPos[2]);
|
package/dist/view.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export interface ProjectionView {
|
|
|
41
41
|
*/
|
|
42
42
|
export declare const globeBaseScale: (size: number) => number;
|
|
43
43
|
/**
|
|
44
|
-
* Where the view is centred on the globe: the home centre, turned by yaw (west) and tipped by tilt (
|
|
44
|
+
* Where the view is centred on the globe: the home centre, turned by yaw (west) and tipped by tilt (south), held to the poles; a drag right is yaw and a drag up is tilt, and the ground follows the pointer.
|
|
45
45
|
*
|
|
46
46
|
* @param centre - The home centre.
|
|
47
47
|
* @param view - The turn, tip, zoom and pan from the view controls.
|
package/dist/view.js
CHANGED
|
@@ -24,7 +24,7 @@ export const HOME_VIEW = Object.freeze({ yaw: 0, tilt: 0, zoom: 1, panX: 0, panY
|
|
|
24
24
|
*/
|
|
25
25
|
export const globeBaseScale = (size) => size / 2 - 1;
|
|
26
26
|
/**
|
|
27
|
-
* Where the view is centred on the globe: the home centre, turned by yaw (west) and tipped by tilt (
|
|
27
|
+
* Where the view is centred on the globe: the home centre, turned by yaw (west) and tipped by tilt (south), held to the poles; a drag right is yaw and a drag up is tilt, and the ground follows the pointer.
|
|
28
28
|
*
|
|
29
29
|
* @param centre - The home centre.
|
|
30
30
|
* @param view - The turn, tip, zoom and pan from the view controls.
|
|
@@ -39,7 +39,7 @@ export const globeBaseScale = (size) => size / 2 - 1;
|
|
|
39
39
|
*/
|
|
40
40
|
export const lookAt = (centre, view) => ({
|
|
41
41
|
lon: centre.lon - view.yaw,
|
|
42
|
-
lat: Math.max(-90, Math.min(90, centre.lat
|
|
42
|
+
lat: Math.max(-90, Math.min(90, centre.lat - view.tilt)),
|
|
43
43
|
});
|
|
44
44
|
/**
|
|
45
45
|
* What the projection is given for a view: yaw turns longitude, tilt tips latitude, zoom scales and pan moves the disc in CSS pixels.
|
|
@@ -58,7 +58,7 @@ export const lookAt = (centre, view) => ({
|
|
|
58
58
|
*/
|
|
59
59
|
export function projectionView(centre, size, view = HOME_VIEW) {
|
|
60
60
|
return {
|
|
61
|
-
rotation: [-centre.lon + view.yaw, -centre.lat
|
|
61
|
+
rotation: [-centre.lon + view.yaw, -centre.lat + view.tilt],
|
|
62
62
|
scale: globeBaseScale(size) * view.zoom,
|
|
63
63
|
translate: [size / 2 + view.panX, size / 2 + view.panY],
|
|
64
64
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on where you are, 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",
|