@johnmorrisdotca/chikyu-earth 0.25.0 → 0.26.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 +4 -0
- package/README.md +3 -2
- package/dist/realistic/earth.d.ts +48 -2
- package/dist/realistic/earth.js +73 -9
- package/dist/realistic/element.d.ts +51 -1
- package/dist/realistic/element.js +168 -7
- package/dist/realistic/index.d.ts +2 -2
- package/dist/realistic/index.js +2 -2
- package/dist/realistic/shaders.d.ts +1 -1
- package/dist/realistic/shaders.js +61 -13
- package/dist/realistic/sun.d.ts +14 -0
- package/dist/realistic/sun.js +19 -1
- package/dist/realistic/tile-set.d.ts +2 -0
- package/dist/realistic/tile-set.js +1 -0
- package/dist/space/element.d.ts +18 -2
- package/dist/space/element.js +66 -4
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/satellite-layer.d.ts +3 -3
- package/dist/space/satellite-layer.js +26 -13
- package/dist/space/scene.d.ts +45 -3
- package/dist/space/scene.js +59 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.26.0 - 2026-11-10
|
|
6
|
+
|
|
7
|
+
- **The realistic Earth: a camera held in the stars, a full-screen mode, a better look and every satellite group** (MODULES-849, MODULES-843). `<chikyu-earth-realistic>` takes `camera="space"` (held in the stars, so the Earth turns beneath it as the clock runs, with the day and night line where the Sun really is) or `camera="sun"` (on the Sun's side, so the line keeps its place on the screen); `space` is now the default, so a view that opens playing shows the Earth turning (before, the camera rode the ground and only the clouds seemed to move); `ground`, the camera over a place on the ground, stays as the option. The cloud drift is one made-up eastward 1.5 degrees an hour that was always on, so it is now an attribute, `cloud-drift`, 0 by default (the cloud picture is one snapshot, not a forecast). `<chikyu-space>` takes `camera`, `earth-size`, `earth-x` and `earth-y` too, and its Earth is fitted to the shorter side of its box with the glow inside. `center` is where the camera looks when it is set (`sun`: the offset from the sub-solar point). New `cameraCentre`, `greenwichSidereal` and `CameraMode` in `/realistic`. `immersive` fills the element's box in any shape, makes a plain wheel zoom and a touch drag turn; Ctrl and the wheel, a pinch and the keys stay kazoku-ui's. The look: a thin bright limb with a faint halo, blue by day and orange along the terminator; a reddening Sun, a warm band and a blue hour at the terminator; a clear blue ocean with a hard glint, a broad sheen and the sky at grazing angles, hidden by cloud; cloud shadows on the ground; warm, softly spread city lights that cloud dims; all from the pictures the package already carries (NASA Blue Marble, Black Marble and cloud pictures: no new data, no code, art or data from any other site). The realistic Earth draws satellites with the space view's calls (`setSatellites`, `showSatellites`, `satelliteGroups`, `selectSatellite`, `selectedSatellite`, `satelliteInfo`, `chikyu-satellite-click`, `stats.satellites`): one draw call a group, so every group at once, at most 30 draws a second, nothing drawn while the clock holds, hidden behind the Earth. The 3D looks fill the demo's felt, Wide and the embed frame edge to edge (no square canvas inside the frame); Auto-turn opens on at a speed that can be seen (6 degrees a second) in them. The demo's Satellites row works on the realistic look and has a Camera row; a new page `fullscreen.html` shows the whole on a dark window (`?sats=all` for every group). The orthographic camera now sits 50 radii out (it was 5) so a geostationary satellite is never behind it. Guide in English and Japanese: `docs/guides/full-screen-and-camera.md`. Tests: `test/realistic.test.ts`, `e2e/camera.gl.ts`, `e2e/fullscreen.gl.ts`.
|
|
8
|
+
|
|
5
9
|
## 0.25.0 - 2026-11-10
|
|
6
10
|
|
|
7
11
|
- **The first screen says who it is for, and every demo page credits its sources** (MODULES-812). The README opens with a picture of the day and night Earth on a desk and the ISS passes on a phone, a sentence that it runs in the browser of a phone, a tablet or a computer with nothing to install, "Who it is for" for teachers and students, satellite spotters, researchers and developers, a "Try it now, nothing to install" row of links, "For teachers and families", a fuller "Limits" and "How to cite", with a new `CITATION.cff` (a test keeps its version and the README's equal to `package.json`'s: a release commit bumps all three). The footer of the home, sheets and passes pages names the sources and links NOTICE.md (English and Japanese), the code builder has the same line, and the two embed frames carry a credit (the globe frame in its top corner, naming only the sources its look uses; the passes frame under its list; `lang=ja` for Japanese). Tests: `e2e/credits.demo.ts`, `e2e/credits.gl.ts`, `test/frame-credit.test.ts`, `test/citation.test.ts`. NOTICE.md says that the demo's space view uses wakusei-planets' pictures.
|
package/README.md
CHANGED
|
@@ -176,7 +176,7 @@ atmosphere at the rim, drawn with three.js through kazoku-ui's shared renderer.
|
|
|
176
176
|
|
|
177
177
|
Needs `three` and `@johnmorrisdotca/kazoku-ui` (both optional peers) and the pictures (1.6 MB, from NASA, in `dist/textures/`). It draws nothing while nothing changes,
|
|
178
178
|
at most 30 times a second while it does, in one WebGL context, with textures that grow as you zoom and are freed after. With `tiles="/tiles/"` (a folder of NASA map
|
|
179
|
-
tiles, [how](docs/guides/earth-tiles.md)) it loads only the finer tiles in view, so you can zoom in to 20 times and stay sharp. With `speed="86400"` (a day a second; the name `<chikyu-space>` uses) its clock runs on from the date shown and the Sun, the night side and the clouds follow it ([guide](docs/guides/time-and-play.md)). All of it, the budget and the tests:
|
|
179
|
+
tiles, [how](docs/guides/earth-tiles.md)) it loads only the finer tiles in view, so you can zoom in to 20 times and stay sharp. With `speed="86400"` (a day a second; the name `<chikyu-space>` uses) its clock runs on from the date shown and the Sun, the night side and the clouds follow it ([guide](docs/guides/time-and-play.md)). `immersive` fills the window, `camera="space"` holds the camera in the stars so the Earth turns beneath it, and it draws every satellite group at once ([guide](docs/guides/full-screen-and-camera.md)). All of it, the budget and the tests:
|
|
180
180
|
[docs/realistic.md](docs/realistic.md).
|
|
181
181
|
|
|
182
182
|
## The Sun, the Moon and the planets
|
|
@@ -456,6 +456,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
456
456
|
| [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
|
|
457
457
|
| [The realistic Earth and markers](docs/guides/realistic-and-markers.md) | The Earth from space, markers |
|
|
458
458
|
| [Satellites](docs/guides/satellites.md) | SGP4 and the space view |
|
|
459
|
+
| [Full screen, the camera in the stars and every satellite](docs/guides/full-screen-and-camera.md) | `immersive`, `camera="space"`, the Earth's look, and every satellite group on the realistic Earth |
|
|
459
460
|
| [When can I see the ISS?](docs/guides/passes.md) | Passes over a place, the sky dome, how it was checked |
|
|
460
461
|
| [Ride along](docs/guides/ride-along.md) | A camera on a moving body |
|
|
461
462
|
| [The date follows the clock, and Play](docs/guides/time-and-play.md) | The `chikyu-timechange` event, a `speed` for the space view and the realistic Earth, Play, Pause and Back |
|
|
@@ -488,7 +489,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
488
489
|
|
|
489
490
|
## How to cite
|
|
490
491
|
|
|
491
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
492
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.26.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
492
493
|
|
|
493
494
|
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.
|
|
494
495
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type * as THREE from "three";
|
|
2
2
|
import type { AssetCache, Item3D } from "@johnmorrisdotca/kazoku-ui/renderer";
|
|
3
3
|
import type { GeoPoint, GlobeView } from "../types.ts";
|
|
4
|
+
import type { SatelliteRef } from "../satellites/types.ts";
|
|
4
5
|
import { lookAt } from "../view.ts";
|
|
6
|
+
import { type SatelliteState } from "../space/satellite-layer.ts";
|
|
5
7
|
import type { Layer } from "./tiers.ts";
|
|
6
8
|
import { type ThreeParts } from "./textures.ts";
|
|
7
9
|
import { type TileSet } from "./tile-set.ts";
|
|
@@ -33,6 +35,19 @@ export declare const ATMOSPHERE_OUTER = 1.08;
|
|
|
33
35
|
* ```
|
|
34
36
|
*/
|
|
35
37
|
export type LightMode = "sun" | "lit" | "boost";
|
|
38
|
+
/**
|
|
39
|
+
* How the camera is held: `ground` (the default) over a place on the ground, so the Earth keeps still and the clock moves the light across it; `space` held in the stars, so the Earth turns beneath it as the clock runs and the day and night line stays
|
|
40
|
+
* where the Sun really puts it; `sun` held on the Sun's side, so the day and night line keeps its place on the screen while the Earth turns beneath.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import type { CameraMode } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
45
|
+
*
|
|
46
|
+
* const modes: CameraMode[] = ["ground", "space", "sun"];
|
|
47
|
+
* console.log(modes.join(", "));
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export type CameraMode = "ground" | "space" | "sun";
|
|
36
51
|
export interface EarthModel {
|
|
37
52
|
/** The home centre; the shared controls' yaw and tilt are added to it as in the flat globe. */
|
|
38
53
|
centre: GeoPoint;
|
|
@@ -43,6 +58,16 @@ export interface EarthModel {
|
|
|
43
58
|
lights: boolean;
|
|
44
59
|
/** How the Earth is lit (see `LightMode`). */
|
|
45
60
|
light: LightMode;
|
|
61
|
+
/** How the camera is held (see `CameraMode`). */
|
|
62
|
+
camera: CameraMode;
|
|
63
|
+
/** How fast the cloud picture is made to move eastward against the ground, degrees an hour: 0 (the default) keeps the clouds where the picture has them. The picture is one snapshot, not a forecast; a drift is only for life. */
|
|
64
|
+
cloudDrift: number;
|
|
65
|
+
/** For the `space` camera: the Earth's turn against the stars (degrees) when the camera was set; null until the next draw sets it. */
|
|
66
|
+
cameraSpin: number | null;
|
|
67
|
+
/** Game seconds a second (the clock's speed): the satellites are placed from it. */
|
|
68
|
+
speed: number;
|
|
69
|
+
/** The satellites shown, the one chosen, and what the last draw did with them. */
|
|
70
|
+
satellites: SatelliteState;
|
|
46
71
|
/** Where the camera looked at the last draw (the element decides from it whether a new draw is worth it). */
|
|
47
72
|
drawn: {
|
|
48
73
|
view: GlobeView;
|
|
@@ -52,6 +77,8 @@ export interface EarthModel {
|
|
|
52
77
|
} | null;
|
|
53
78
|
/** The map tiles laid over the pictures while the scene is built: what they are doing, for a page or a test. */
|
|
54
79
|
tiles: TileSet | null;
|
|
80
|
+
/** The satellite at a point of the view (CSS pixels), within a radius, once a draw has been made and one is there. */
|
|
81
|
+
pick: ((x: number, y: number, radius: number) => SatelliteRef | null) | null;
|
|
55
82
|
/** The pixel ratio the textures are chosen for. */
|
|
56
83
|
ratio(): number;
|
|
57
84
|
/** Meteors seen from space (src/meteors/layer.ts): off unless the element switches them on. */
|
|
@@ -67,11 +94,11 @@ export interface EarthDeps {
|
|
|
67
94
|
tiles?: () => string | undefined;
|
|
68
95
|
/** Told once when the tile set has been read: the width in pixels of the finest level of each of its layers. */
|
|
69
96
|
onTiles?: (layers: Record<string, number>) => void;
|
|
70
|
-
/** Clouds' eastward drift against the ground, degrees an hour. */
|
|
71
|
-
drift: number;
|
|
72
97
|
invalidate: () => void;
|
|
73
98
|
onError?: (error: unknown) => void;
|
|
74
99
|
onTier?: (layer: Layer, width: number) => void;
|
|
100
|
+
/** The satellites could not be drawn (the three.js parts handed over lack `Points`). */
|
|
101
|
+
onSatellitesError?: (error: unknown) => void;
|
|
75
102
|
/** Told at the start of every draw, before anything is read for it. */
|
|
76
103
|
onDraw?: () => void;
|
|
77
104
|
/** Told at every draw where the disc is, for what is laid over it (markers). */
|
|
@@ -103,6 +130,25 @@ export declare const newModel: () => EarthModel;
|
|
|
103
130
|
*/
|
|
104
131
|
export declare const discRadius: (width: number, height: number, zoom: number) => number;
|
|
105
132
|
export { lookAt };
|
|
133
|
+
/**
|
|
134
|
+
* The place the camera looks at for a moment: the home centre as it is (`ground`), the home centre as it was when the camera was set, carried west by the Earth's turn since (`space`), or the home centre read from the Sun's own place (`sun`: `0,0` is straight at noon).
|
|
135
|
+
* It sets `cameraSpin` when the `space` camera has none yet. Pure apart from that.
|
|
136
|
+
*
|
|
137
|
+
* @param model - The model: its centre, camera, camera spin and the moment shown.
|
|
138
|
+
* @returns The longitude and latitude the view is turned from (yaw and tilt are added to it by `lookAt`).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { cameraCentre } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
143
|
+
*
|
|
144
|
+
* const start = Date.UTC(2026, 10, 2, 12);
|
|
145
|
+
* const model = { centre: { lon: 10, lat: 30 }, camera: "space" as const, cameraSpin: null, time: start };
|
|
146
|
+
* cameraCentre(model);
|
|
147
|
+
* model.time = start + 6 * 3_600_000;
|
|
148
|
+
* console.log(cameraCentre(model).lon.toFixed(1));
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function cameraCentre(model: Pick<EarthModel, "centre" | "camera" | "cameraSpin" | "time">): GeoPoint;
|
|
106
152
|
/** An equirectangular sphere: +z is longitude 0 on the equator, +x east, +y north; v is 0 at the north pole (the top row of the picture). */
|
|
107
153
|
export declare function sphere(three: Three, columns: number, rows: number): THREE.BufferGeometry;
|
|
108
154
|
export declare function createEarthItem(model: EarthModel, deps: EarthDeps): Item3D<Three>;
|
package/dist/realistic/earth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HOME_VIEW, lookAt } from "../view.js";
|
|
2
2
|
import { ATMOSPHERE_FRAG, ATMOSPHERE_VERT, CLOUD_FRAG, SURFACE_FRAG, SURFACE_VERT } from "./shaders.js";
|
|
3
|
-
import { subsolarPoint, unitVector } from "./sun.js";
|
|
3
|
+
import { greenwichSidereal, subsolarPoint, unitVector } from "./sun.js";
|
|
4
|
+
import { createSatelliteLayer, newSatelliteState } from "../space/satellite-layer.js";
|
|
4
5
|
import { createTextureSet } from "./textures.js";
|
|
5
6
|
import { createTileSet } from "./tile-set.js";
|
|
6
7
|
import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
|
|
@@ -25,8 +26,14 @@ export const newModel = () => ({
|
|
|
25
26
|
clouds: true,
|
|
26
27
|
lights: true,
|
|
27
28
|
light: "sun",
|
|
29
|
+
camera: "space",
|
|
30
|
+
cloudDrift: 0,
|
|
31
|
+
cameraSpin: null,
|
|
32
|
+
speed: 1,
|
|
33
|
+
satellites: newSatelliteState(),
|
|
28
34
|
drawn: null,
|
|
29
35
|
tiles: null,
|
|
36
|
+
pick: null,
|
|
30
37
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
31
38
|
meteors: newMeteorState(),
|
|
32
39
|
});
|
|
@@ -47,6 +54,36 @@ export const newModel = () => ({
|
|
|
47
54
|
*/
|
|
48
55
|
export const discRadius = (width, height, zoom) => Math.max(1, (Math.min(width, height) / 2 / ATMOSPHERE_OUTER - 1) * zoom);
|
|
49
56
|
export { lookAt };
|
|
57
|
+
/**
|
|
58
|
+
* The place the camera looks at for a moment: the home centre as it is (`ground`), the home centre as it was when the camera was set, carried west by the Earth's turn since (`space`), or the home centre read from the Sun's own place (`sun`: `0,0` is straight at noon).
|
|
59
|
+
* It sets `cameraSpin` when the `space` camera has none yet. Pure apart from that.
|
|
60
|
+
*
|
|
61
|
+
* @param model - The model: its centre, camera, camera spin and the moment shown.
|
|
62
|
+
* @returns The longitude and latitude the view is turned from (yaw and tilt are added to it by `lookAt`).
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { cameraCentre } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
67
|
+
*
|
|
68
|
+
* const start = Date.UTC(2026, 10, 2, 12);
|
|
69
|
+
* const model = { centre: { lon: 10, lat: 30 }, camera: "space" as const, cameraSpin: null, time: start };
|
|
70
|
+
* cameraCentre(model);
|
|
71
|
+
* model.time = start + 6 * 3_600_000;
|
|
72
|
+
* console.log(cameraCentre(model).lon.toFixed(1));
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export function cameraCentre(model) {
|
|
76
|
+
if (model.camera === "space") {
|
|
77
|
+
const spin = greenwichSidereal(model.time);
|
|
78
|
+
model.cameraSpin ??= spin;
|
|
79
|
+
return { lon: model.centre.lon - (spin - model.cameraSpin), lat: model.centre.lat };
|
|
80
|
+
}
|
|
81
|
+
if (model.camera === "sun") {
|
|
82
|
+
const sun = subsolarPoint(model.time);
|
|
83
|
+
return { lon: sun.lon + model.centre.lon, lat: Math.max(-90, Math.min(90, sun.lat + model.centre.lat)) };
|
|
84
|
+
}
|
|
85
|
+
return model.centre;
|
|
86
|
+
}
|
|
50
87
|
/** An equirectangular sphere: +z is longitude 0 on the equator, +x east, +y north; v is 0 at the north pole (the top row of the picture). */
|
|
51
88
|
export function sphere(three, columns, rows) {
|
|
52
89
|
const positions = new Float32Array((columns + 1) * (rows + 1) * 3);
|
|
@@ -93,13 +130,15 @@ export function createEarthItem(model, deps) {
|
|
|
93
130
|
});
|
|
94
131
|
const uniform = textures.uniforms;
|
|
95
132
|
const sunDir = { value: new three.Vector3(1, 0, 0) };
|
|
133
|
+
/** The Sun in the Earth's own axes (before the view turns it), which the surface needs to find where a cloud's shadow falls. */
|
|
134
|
+
const sunLocal = { value: new three.Vector3(1, 0, 0) };
|
|
135
|
+
const cloudShift = { value: 0 };
|
|
96
136
|
const grid = sphere(three, 128, 64);
|
|
97
137
|
const surface = new three.ShaderMaterial({
|
|
98
138
|
vertexShader: SURFACE_VERT,
|
|
99
139
|
fragmentShader: SURFACE_FRAG,
|
|
100
|
-
uniforms: { dayMap: uniform.day, nightMap: uniform.night, waterMap: uniform.water, sunDir, lights: { value: 1 }, boost: { value: 0 }, ortho: { value: 1 } },
|
|
140
|
+
uniforms: { dayMap: uniform.day, nightMap: uniform.night, waterMap: uniform.water, cloudMap: uniform.clouds, sunDir, sunLocal, cloudShift, lights: { value: 1 }, boost: { value: 0 }, ortho: { value: 1 } },
|
|
101
141
|
});
|
|
102
|
-
const cloudShift = { value: 0 };
|
|
103
142
|
const cloudMaterial = new three.ShaderMaterial({
|
|
104
143
|
vertexShader: SURFACE_VERT,
|
|
105
144
|
fragmentShader: CLOUD_FRAG,
|
|
@@ -117,7 +156,7 @@ export function createEarthItem(model, deps) {
|
|
|
117
156
|
});
|
|
118
157
|
const turned = new three.Group();
|
|
119
158
|
const earth = new three.Mesh(grid, surface);
|
|
120
|
-
const tiles = createTileSet(three, turned, { sunDir, lights: surface.uniforms["lights"], boost: surface.uniforms["boost"], ortho: surface.uniforms["ortho"], water: uniform.water, night: uniform.night }, { assets: deps.assets, base: () => deps.tiles?.(), cap: deps.cap, invalidate: deps.invalidate, ...(deps.onTiles ? { onManifest: deps.onTiles } : {}) });
|
|
159
|
+
const tiles = createTileSet(three, turned, { sunDir, lights: surface.uniforms["lights"], boost: surface.uniforms["boost"], ortho: surface.uniforms["ortho"], water: uniform.water, night: uniform.night, extra: { cloudMap: uniform.clouds, sunLocal, cloudShift } }, { assets: deps.assets, base: () => deps.tiles?.(), cap: deps.cap, invalidate: deps.invalidate, ...(deps.onTiles ? { onManifest: deps.onTiles } : {}) });
|
|
121
160
|
model.tiles = tiles;
|
|
122
161
|
const clouds = new three.Mesh(grid, cloudMaterial);
|
|
123
162
|
clouds.scale.setScalar(CLOUD_RADIUS);
|
|
@@ -129,8 +168,15 @@ export function createEarthItem(model, deps) {
|
|
|
129
168
|
glow.frustumCulled = false;
|
|
130
169
|
const scene = new three.Scene();
|
|
131
170
|
scene.add(turned, glow);
|
|
132
|
-
|
|
133
|
-
|
|
171
|
+
// the satellites are placed in space's own axes (x to the vernal equinox, y north); this group turns them into the Earth's axes (by the Earth's turn against the stars) and then as the Earth is turned in the view
|
|
172
|
+
const inertial = new three.Group();
|
|
173
|
+
const spun = new three.Group();
|
|
174
|
+
inertial.add(spun);
|
|
175
|
+
scene.add(inertial);
|
|
176
|
+
let layer;
|
|
177
|
+
// far enough in front that a geostationary satellite (6.6 radii out) is never behind the camera: an orthographic picture is the same from anywhere on the line
|
|
178
|
+
const camera = new three.OrthographicCamera(-1, 1, 1, -1, 1, 120);
|
|
179
|
+
camera.position.set(0, 0, 50);
|
|
134
180
|
// the meteors: made the first time they are switched on, and asking for their own next draw while a streak is alive or one is due
|
|
135
181
|
let meteors = null;
|
|
136
182
|
let meteorTimer;
|
|
@@ -140,13 +186,18 @@ export function createEarthItem(model, deps) {
|
|
|
140
186
|
update() {
|
|
141
187
|
deps.onDraw?.();
|
|
142
188
|
const view = model.view;
|
|
143
|
-
const
|
|
189
|
+
const centre = cameraCentre(model);
|
|
190
|
+
const look = lookAt(centre, view);
|
|
144
191
|
turned.rotation.set(look.lat * RAD, -look.lon * RAD, 0, "XYZ");
|
|
192
|
+
inertial.rotation.copy(turned.rotation);
|
|
193
|
+
const spin = greenwichSidereal(model.time);
|
|
194
|
+
spun.rotation.set(0, -(spin + 90) * RAD, 0);
|
|
145
195
|
const [sx, sy, sz] = unitVector(subsolarPoint(model.time));
|
|
196
|
+
sunLocal.value.set(sx, sy, sz);
|
|
146
197
|
sunDir.value.set(sx, sy, sz).applyEuler(turned.rotation);
|
|
147
198
|
if (model.light === "lit")
|
|
148
199
|
sunDir.value.set(0, 0, 1);
|
|
149
|
-
cloudShift.value = -(((model.time / 3_600_000) *
|
|
200
|
+
cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
|
|
150
201
|
clouds.visible = model.clouds;
|
|
151
202
|
surface.uniforms["lights"].value = model.lights && model.light !== "lit" ? 1 : 0;
|
|
152
203
|
surface.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
|
|
@@ -156,7 +207,18 @@ export function createEarthItem(model, deps) {
|
|
|
156
207
|
camera.top = (size.height / 2 + view.panY) / radius;
|
|
157
208
|
camera.bottom = (-size.height / 2 + view.panY) / radius;
|
|
158
209
|
camera.updateProjectionMatrix();
|
|
159
|
-
|
|
210
|
+
if (!layer && model.satellites.groups.size > 0) {
|
|
211
|
+
try {
|
|
212
|
+
layer = createSatelliteLayer(three, spun, model.satellites, model.ratio);
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
model.satellites.groups.clear();
|
|
216
|
+
deps.onSatellitesError?.(error);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
layer?.update(model.time, model.speed);
|
|
220
|
+
model.pick = layer ? (x, y, radius) => layer.pick(x, y, camera, size, radius) : null;
|
|
221
|
+
model.drawn = { view: { ...view }, time: model.time, radius, centre: { ...centre } };
|
|
160
222
|
textures.sync(radius * model.ratio());
|
|
161
223
|
tiles.sync({ lon: look.lon, lat: look.lat, width: size.width, height: size.height, panX: view.panX, panY: view.panY, radius }, [sunDir.value.x, sunDir.value.y, sunDir.value.z], true, model.ratio());
|
|
162
224
|
deps.onPose?.({ lon: look.lon, lat: look.lat, radius, cx: size.width / 2 + view.panX, cy: size.height / 2 + view.panY, width: size.width, height: size.height });
|
|
@@ -173,6 +235,8 @@ export function createEarthItem(model, deps) {
|
|
|
173
235
|
size = { width: next, height: nextHeight };
|
|
174
236
|
},
|
|
175
237
|
dispose() {
|
|
238
|
+
layer?.dispose();
|
|
239
|
+
model.pick = null;
|
|
176
240
|
clearTimeout(meteorTimer);
|
|
177
241
|
meteors?.dispose();
|
|
178
242
|
model.tiles = null;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
2
|
import type { GeoPoint, GlobeView } from "../types.ts";
|
|
3
|
-
import { type LightMode } from "./earth.ts";
|
|
3
|
+
import { type CameraMode, type LightMode } from "./earth.ts";
|
|
4
|
+
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
5
|
+
import { type SatelliteStyle } from "../space/satellite-layer.ts";
|
|
4
6
|
import { setSharedRenderer, setThreeLoader } from "./shared.ts";
|
|
5
7
|
export { setSharedRenderer, setThreeLoader };
|
|
8
|
+
export type { CameraMode };
|
|
6
9
|
import type { OverlayHost } from "../markers/layer.ts";
|
|
7
10
|
import { type Layer } from "./tiers.ts";
|
|
8
11
|
import type { TileStats } from "./tile-set.ts";
|
|
@@ -19,6 +22,18 @@ type EarthLayer = Extract<Layer, "day" | "night" | "clouds" | "water">;
|
|
|
19
22
|
* ```
|
|
20
23
|
*/
|
|
21
24
|
export type EarthState = "loading" | "live" | "unavailable" | "lost" | "idle";
|
|
25
|
+
type SatelliteStats = {
|
|
26
|
+
groups: number;
|
|
27
|
+
placed: number;
|
|
28
|
+
tooFast: boolean;
|
|
29
|
+
propagations: number;
|
|
30
|
+
lastBatchMs: number;
|
|
31
|
+
maxBatchMs: number;
|
|
32
|
+
updateMs: number;
|
|
33
|
+
maxUpdateMs: number;
|
|
34
|
+
averageUpdateMs: number;
|
|
35
|
+
updates: number;
|
|
36
|
+
};
|
|
22
37
|
/**
|
|
23
38
|
* A `speed` attribute: how many seconds pass for each real second.
|
|
24
39
|
*
|
|
@@ -103,6 +118,16 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
103
118
|
/** Where the view starts: longitude and latitude; the shared controls' yaw and tilt turn it from there. */
|
|
104
119
|
get centre(): GeoPoint;
|
|
105
120
|
set centre(value: GeoPoint);
|
|
121
|
+
/**
|
|
122
|
+
* How the camera is held (the `camera` attribute). `space` (the default): held in the stars, looking at the place `center` names as it is at the
|
|
123
|
+
* moment the camera is set (when the element opens, and again when `time` or `center` is set), so the Earth turns beneath it as the clock runs, with the day and night line where the Sun really is. `ground`: over the place `center` names on the ground, so the Earth keeps still and the clock moves the light across it. `sun`: held on the Sun's side, `center` being the longitude and
|
|
124
|
+
* latitude from the sub-solar point (`0,0` looks straight at the noon place and shows no night), so the day and night line keeps its place on the screen while the Earth turns beneath. A drag turns the view about the same body in any of them.
|
|
125
|
+
*/
|
|
126
|
+
get camera(): CameraMode;
|
|
127
|
+
set camera(value: CameraMode);
|
|
128
|
+
/** True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape, a plain wheel zooms instead of scrolling the page, and a touch drag turns the view instead of scrolling. */
|
|
129
|
+
get immersive(): boolean;
|
|
130
|
+
set immersive(value: boolean);
|
|
106
131
|
/** The moment shown: milliseconds since the epoch, or "now" while it follows the real clock. The clock runs from it at `speed`, so a number read while time runs is the moment it has reached. */
|
|
107
132
|
get time(): number | "now";
|
|
108
133
|
set time(value: number | Date | "now");
|
|
@@ -124,6 +149,7 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
124
149
|
state: EarthState;
|
|
125
150
|
tiers: Record<EarthLayer, number>;
|
|
126
151
|
tiles: TileStats;
|
|
152
|
+
satellites: SatelliteStats;
|
|
127
153
|
draws: number;
|
|
128
154
|
contexts: number;
|
|
129
155
|
canvas: {
|
|
@@ -150,6 +176,30 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
150
176
|
* and draws are at most 30 a second.
|
|
151
177
|
*/
|
|
152
178
|
setView(view: GlobeView, final?: boolean): void;
|
|
179
|
+
/**
|
|
180
|
+
* Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds, so every group of the catalogue can be shown at once. Giving the name of a group
|
|
181
|
+
* that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations). The groups are placed by SGP4 about once a second and interpolated
|
|
182
|
+
* between, are hidden while the clock runs faster than `MAX_SATELLITE_SPEED`, are hidden by the Earth when they are behind it, and draw at most 30 times a second and not at all while the clock holds.
|
|
183
|
+
*
|
|
184
|
+
* @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
|
|
185
|
+
* @param satellites - The group, or `null` to remove it.
|
|
186
|
+
* @param style - How to draw it.
|
|
187
|
+
*/
|
|
188
|
+
setSatellites(group: string, satellites: Satellites | null, style?: Partial<SatelliteStyle>): void;
|
|
189
|
+
/** Show or hide a group without losing it. */
|
|
190
|
+
showSatellites(group: string, on: boolean): void;
|
|
191
|
+
/** The groups now set, with how many satellites each holds and whether it is shown. */
|
|
192
|
+
get satelliteGroups(): {
|
|
193
|
+
name: string;
|
|
194
|
+
count: number;
|
|
195
|
+
visible: boolean;
|
|
196
|
+
}[];
|
|
197
|
+
/** Mark one satellite: a larger ring round it and its orbit drawn. `null` lets it go. */
|
|
198
|
+
selectSatellite(ref: SatelliteRef | null): void;
|
|
199
|
+
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
200
|
+
get selectedSatellite(): SatelliteRef | null;
|
|
201
|
+
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
|
|
202
|
+
satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
|
|
153
203
|
/** The view as it is (for a page that wants to read it back). */
|
|
154
204
|
get view(): GlobeView;
|
|
155
205
|
}
|