@johnmorrisdotca/chikyu-earth 0.46.4 → 0.46.6
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 +8 -0
- package/README.md +3 -2
- package/dist/beam/geometry.d.ts +131 -0
- package/dist/beam/geometry.js +141 -0
- package/dist/beam/layer.d.ts +47 -0
- package/dist/beam/layer.js +308 -0
- package/dist/realistic/element-base.d.ts +1 -0
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.d.ts +60 -1
- package/dist/space/element-base.js +132 -7
- package/dist/space/generic-satellite.d.ts +4 -4
- package/dist/space/generic-satellite.js +51 -11
- package/dist/space/index.d.ts +4 -2
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +12 -0
- package/dist/space/satellite-layer.d.ts +3 -0
- package/dist/space/satellite-layer.js +5 -2
- package/dist/space/satellite-model.d.ts +72 -0
- package/dist/space/satellite-model.js +78 -0
- package/dist/space/scene.d.ts +6 -1
- package/dist/space/scene.js +36 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.46.6 - 2026-11-13
|
|
4
|
+
|
|
5
|
+
- **A beam from the chosen satellite to the ground below it** (MODULES-1309). `beam` on `<chikyu-space>` (off unless set; the property `beam`) draws a soft, additive cone of light from the satellite marked with `selectSatellite`, or the one ridden, down to its footprint on the ground: a lit ring and a faint fill, the circle from which the satellite is above `beam-elevation` degrees (25), worked from its height (`footprintAngle`, `footprintKm`), cut off by the limb, in Ride along and Ride above as well. `beam-cells` (up to 91) adds spot cells in a hexagonal pack, each with a thin shaft of light (an illustration, not any operator's plan), `beam-cell-size`, `beam-color` and `beam-strength` set the look; `stats.beam` says the footprint's radius in kilometres. It is part of the draw that moves the satellite: nothing at rest, nothing rebuilt on a clock step, no shimmer. Guide: `docs/guides/beam.md` (and its Japanese twin), and a "Satellite beam" button in the demo.
|
|
6
|
+
|
|
7
|
+
## 0.46.5 - 2026-11-13
|
|
8
|
+
|
|
9
|
+
- **The ridden satellite's model shrinks as a ride above it rises, and the package's drawings are better** (MODULES-1306). In a ride above (`view: "above"`) the model was a fixed 17 per cent of the picture at any height, so from 6,000 km it was a huge block. The new option `modelSize: "distance" | "fixed"` (attribute `ride-model-size`, property `rideModelSize`; `distance` is the default) keeps the model at that size up to 150 km, shrinks it as one over the height, lets it down smoothly from 1,000 km to nothing at 2,000 km, where the ordinary mark (ring and name) takes over (`aboveModelShare`, `MODEL_HANDOVER_PX`); `fixed` is the old size at every height. A page's painter is told the size through `update({ radiusPx })` and `stats.followModel` reports it. The chosen satellite's ring and name stay off its model in both modes while it is drawn and return at the hand-over or when the ride ends (`modelOver`, `stats.satellites.selectedRing`). The generic drawings are redrawn with framed thin panels, a bus with a radiator and a camera, a dish, a long panel for a constellation, and a new `cubesat` kind (FLOCK, DOVE, LEMUR, SPIRE and similar names); every part of every kind is inside the model's disc (the flat kind's panel was not, which was the stray slab), tested in `test/generic-satellite.test.ts` and, pixel by pixel outside the reported box, in `e2e/ride-size.gl.ts`. Names under the model: while the model is drawn the package's own names (places, cities, seas, countries, stars) keep clear of its box, and `chikyu-ride-model` (`detail: { box, radiusPx, x, y }`, `box` null when none) tells the page when the box has moved by more than a pixel or has come or gone, for its own labels. **Behaviour change:** `distance` is the default; set `ride-model-size="fixed"` for the old size (upgrading guide).
|
|
10
|
+
|
|
3
11
|
## 0.46.4 - 2026-11-13
|
|
4
12
|
|
|
5
13
|
- **Cloud-free ground from NASA's Landsat mosaic** (MODULES-1263). `tiles-finer="gibs"` now reads NASA's Landsat annual true-colour mosaic (`Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual`, 30 m, no cloud, land only, the year 2000) instead of a daily picture, which was often solid cloud over the ground. It is off unless a page sets it. Streets, fields and rivers show at 150 km where our level 5 is a blur. The daily MODIS Terra picture stays as `tiles-finer-layer="today"`; `landsat` is the default's short name. The mosaic has one picture a year, so no day is searched for; `tiles-finer-date` names another year it has (1984, 1985, 1988 to 1990, 1998, 1999). Where it has no data (the oceans, Antarctica, the far north, a tile that is all black) our own tiles stay, silently. Tiles now carry transparency: black and nearly black pixels (no data, and the mosaic's sea) are clear, so our blue sea and our picture show through, and a daily picture's black wedges between passes are no longer drawn black. The colours are brought to the look of our own pictures by a gain fitted over six places on land (0.76, 0.66, 0.55), so the finer land does not look like a sticker. The credit line adds the Landsat data's own line. The grid support takes the 31.25 m matrix (levels 0 to 11). It is old (2000) and made of separate scenes, so a straight scene edge shows here and there.
|
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. 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. 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. 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
|
|
@@ -578,6 +578,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
|
|
|
578
578
|
| [City names on the Earth](docs/guides/city-names.md) | Cities named from kuni's list, more as the Earth grows on the screen, in the page's language |
|
|
579
579
|
| [Borders on the Earth](docs/guides/borders.md) | The borders between countries, and a page's own regions once the Earth is large enough |
|
|
580
580
|
| [The grid and country names on the Earth](docs/guides/grid-and-country-names.md) | Meridians and parallels with the special lines picked out, and the countries in sight named in the page's language |
|
|
581
|
+
| [A beam from a satellite to the ground](docs/guides/beam.md) | A soft cone of light from the chosen satellite to a lit footprint, true to its height, with optional spot cells, in a ride too |
|
|
581
582
|
| [A name on the Earth](docs/guides/body-label.md) | The Earth's name written on the globe, in the family's plain attribute names |
|
|
582
583
|
| [You are here, and places on the Earth](docs/guides/places.md) | The reader's place and favourite places as markers standing out of the Earth, asked for only on a press, kept on the device |
|
|
583
584
|
| [Meteors seen from space](docs/guides/meteors.md) | Streaks over the night side, the shower table, what is real and what is illustration |
|
|
@@ -611,7 +612,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
611
612
|
|
|
612
613
|
## How to cite
|
|
613
614
|
|
|
614
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.46.
|
|
615
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.46.6) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
615
616
|
|
|
616
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.
|
|
617
618
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The elevation, in degrees, above which a satellite counts as seen from the ground: the footprint is the circle from which it stands at least this high.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { BEAM_ELEVATION } from "@johnmorrisdotca/chikyu-earth/space";
|
|
7
|
+
*
|
|
8
|
+
* console.log(BEAM_ELEVATION);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const BEAM_ELEVATION = 25;
|
|
12
|
+
/**
|
|
13
|
+
* The angle at the Earth's centre between the point below a satellite and the edge of its footprint, in radians: the ground circle from which the satellite is above `elevation`.
|
|
14
|
+
* It is `acos(R cos(e) / (R + h)) - e` for the Earth's radius R, the height h and the elevation e. A satellite on or under the ground, or an elevation of 90 degrees or more, has none.
|
|
15
|
+
*
|
|
16
|
+
* @param heightKm - The satellite's height above the ground, in kilometres.
|
|
17
|
+
* @param elevation - The least elevation, in degrees. 25 when left out.
|
|
18
|
+
* @returns The angle, in radians, from 0 up to a quarter of a turn.
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { footprintAngle } from "@johnmorrisdotca/chikyu-earth/space";
|
|
22
|
+
*
|
|
23
|
+
* console.log((footprintAngle(420) * 180) / Math.PI);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function footprintAngle(heightKm: number, elevation?: number): number;
|
|
27
|
+
/**
|
|
28
|
+
* The radius of a satellite's footprint along the ground, in kilometres: the Earth's radius times {@link footprintAngle}.
|
|
29
|
+
*
|
|
30
|
+
* @param heightKm - The satellite's height above the ground, in kilometres.
|
|
31
|
+
* @param elevation - The least elevation, in degrees. 25 when left out.
|
|
32
|
+
* @returns The radius in kilometres.
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* import { footprintKm } from "@johnmorrisdotca/chikyu-earth/space";
|
|
36
|
+
*
|
|
37
|
+
* console.log(Math.round(footprintKm(550)));
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare const footprintKm: (heightKm: number, elevation?: number) => number;
|
|
41
|
+
/**
|
|
42
|
+
* The spot cells inside a footprint: where each one's middle is, and how large they are, in the footprint's own units (the footprint's radius is 1).
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts no-run
|
|
46
|
+
* import type { BeamCells } from "@johnmorrisdotca/chikyu-earth/space";
|
|
47
|
+
*
|
|
48
|
+
* const none: BeamCells = { lattice: [], pitch: 0, radius: 0 };
|
|
49
|
+
* console.log(none.lattice.length);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export interface BeamCells {
|
|
53
|
+
/** Each cell's middle on the lattice, in units of the distance between neighbours (the hexagonal pack: one at the middle, then rings of six, twelve, eighteen). */
|
|
54
|
+
lattice: number[][];
|
|
55
|
+
/** The distance between neighbouring cells as a share of the footprint's radius. */
|
|
56
|
+
pitch: number;
|
|
57
|
+
/** A cell's radius as a share of the footprint's radius. */
|
|
58
|
+
radius: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The spot cells of a footprint: `count` circles in a hexagonal pack (the middle one, then the nearest to it), drawn to fit inside the footprint, or at most `cellKm` in radius when that is smaller.
|
|
62
|
+
* It is an illustration of a satellite that serves the ground in cells; it is not the pattern of any operator's beam plan.
|
|
63
|
+
*
|
|
64
|
+
* @param count - How many cells (0 for none; the most is 91, six rings).
|
|
65
|
+
* @param radiusKm - The footprint's radius along the ground, in kilometres.
|
|
66
|
+
* @param cellKm - A cell's radius in kilometres, when the page wants it smaller than the fit; 0 for the fit.
|
|
67
|
+
* @returns The cells.
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { beamCells } from "@johnmorrisdotca/chikyu-earth/space";
|
|
71
|
+
*
|
|
72
|
+
* console.log(beamCells(19, 2200, 0).lattice.length);
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function beamCells(count: number, radiusKm: number, cellKm?: number): BeamCells;
|
|
76
|
+
/**
|
|
77
|
+
* The attributes the beam reads: `beam`, `beam-elevation`, `beam-cells`, `beam-cell-size`, `beam-color` and `beam-strength`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { BEAM_ATTRIBUTES } from "@johnmorrisdotca/chikyu-earth/space";
|
|
82
|
+
*
|
|
83
|
+
* console.log(BEAM_ATTRIBUTES.join(" "));
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare const BEAM_ATTRIBUTES: readonly ["beam", "beam-elevation", "beam-cells", "beam-cell-size", "beam-color", "beam-strength"];
|
|
87
|
+
/**
|
|
88
|
+
* What the attributes say: whether the beam is on, and its options.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts no-run
|
|
92
|
+
* import type { BeamOptions } from "@johnmorrisdotca/chikyu-earth/space";
|
|
93
|
+
*
|
|
94
|
+
* const options: BeamOptions = { on: true, elevation: 25, cells: 19, cellSize: 0, colour: "#8fd1ff", strength: 0.6 };
|
|
95
|
+
* console.log(options.cells);
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export interface BeamOptions {
|
|
99
|
+
on: boolean;
|
|
100
|
+
elevation: number;
|
|
101
|
+
cells: number;
|
|
102
|
+
cellSize: number;
|
|
103
|
+
colour: string;
|
|
104
|
+
strength: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The beam's colour when the page names none: a pale blue that reads on the day side and the night side.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* import { BEAM_COLOUR } from "@johnmorrisdotca/chikyu-earth/space";
|
|
112
|
+
*
|
|
113
|
+
* console.log(BEAM_COLOUR);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const BEAM_COLOUR = "#8fd1ff";
|
|
117
|
+
/**
|
|
118
|
+
* What the beam's attributes say. `beam` is off when it is missing, `off` or `false`; a bare attribute, `selected` or `on` switches it on for the chosen satellite. The strength is from 0 to 1 (0.6 when left out),
|
|
119
|
+
* the elevation from 0 to 80 degrees (25), the cells from 0 to 91 (none) and the cell size in kilometres (0 for the fit).
|
|
120
|
+
*
|
|
121
|
+
* @param get - Reads an attribute by name, `null` when it is missing.
|
|
122
|
+
* @returns The options.
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { readBeam } from "@johnmorrisdotca/chikyu-earth/space";
|
|
126
|
+
*
|
|
127
|
+
* const read = readBeam((name) => ({ beam: "selected", "beam-cells": "19" })[name] ?? null);
|
|
128
|
+
* console.log(read.on, read.cells);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export declare function readBeam(get: (name: string) => string | null): BeamOptions;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// The beam from a satellite to the ground below it: the true size of the footprint, and the pattern of spot cells drawn inside it. Pure: numbers in, numbers out.
|
|
2
|
+
// The footprint is the circle on the ground from which the satellite stands above a stated elevation; the cells are an illustration, never an operator's beam plan.
|
|
3
|
+
const RAD = Math.PI / 180;
|
|
4
|
+
/** The Earth's mean radius in kilometres, as the space view measures: the same 6,371. */
|
|
5
|
+
const EARTH_KM = 6371;
|
|
6
|
+
/**
|
|
7
|
+
* The elevation, in degrees, above which a satellite counts as seen from the ground: the footprint is the circle from which it stands at least this high.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { BEAM_ELEVATION } from "@johnmorrisdotca/chikyu-earth/space";
|
|
12
|
+
*
|
|
13
|
+
* console.log(BEAM_ELEVATION);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export const BEAM_ELEVATION = 25;
|
|
17
|
+
/**
|
|
18
|
+
* The angle at the Earth's centre between the point below a satellite and the edge of its footprint, in radians: the ground circle from which the satellite is above `elevation`.
|
|
19
|
+
* It is `acos(R cos(e) / (R + h)) - e` for the Earth's radius R, the height h and the elevation e. A satellite on or under the ground, or an elevation of 90 degrees or more, has none.
|
|
20
|
+
*
|
|
21
|
+
* @param heightKm - The satellite's height above the ground, in kilometres.
|
|
22
|
+
* @param elevation - The least elevation, in degrees. 25 when left out.
|
|
23
|
+
* @returns The angle, in radians, from 0 up to a quarter of a turn.
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { footprintAngle } from "@johnmorrisdotca/chikyu-earth/space";
|
|
27
|
+
*
|
|
28
|
+
* console.log((footprintAngle(420) * 180) / Math.PI);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function footprintAngle(heightKm, elevation = BEAM_ELEVATION) {
|
|
32
|
+
if (!(heightKm > 0) || !(elevation < 90))
|
|
33
|
+
return 0;
|
|
34
|
+
const e = Math.max(0, elevation) * RAD;
|
|
35
|
+
const cosine = (EARTH_KM * Math.cos(e)) / (EARTH_KM + heightKm);
|
|
36
|
+
return Math.max(0, Math.acos(Math.min(1, cosine)) - e);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The radius of a satellite's footprint along the ground, in kilometres: the Earth's radius times {@link footprintAngle}.
|
|
40
|
+
*
|
|
41
|
+
* @param heightKm - The satellite's height above the ground, in kilometres.
|
|
42
|
+
* @param elevation - The least elevation, in degrees. 25 when left out.
|
|
43
|
+
* @returns The radius in kilometres.
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* import { footprintKm } from "@johnmorrisdotca/chikyu-earth/space";
|
|
47
|
+
*
|
|
48
|
+
* console.log(Math.round(footprintKm(550)));
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const footprintKm = (heightKm, elevation = BEAM_ELEVATION) => EARTH_KM * footprintAngle(heightKm, elevation);
|
|
52
|
+
/** A cell's radius as a share of the distance between neighbours: a little under a half, so the rings of neighbours do not touch. */
|
|
53
|
+
const CELL_SHARE = 0.46;
|
|
54
|
+
/** How far out the outer edge of the outermost cell may reach, as a share of the footprint's radius. */
|
|
55
|
+
const FIT = 0.97;
|
|
56
|
+
/**
|
|
57
|
+
* The spot cells of a footprint: `count` circles in a hexagonal pack (the middle one, then the nearest to it), drawn to fit inside the footprint, or at most `cellKm` in radius when that is smaller.
|
|
58
|
+
* It is an illustration of a satellite that serves the ground in cells; it is not the pattern of any operator's beam plan.
|
|
59
|
+
*
|
|
60
|
+
* @param count - How many cells (0 for none; the most is 91, six rings).
|
|
61
|
+
* @param radiusKm - The footprint's radius along the ground, in kilometres.
|
|
62
|
+
* @param cellKm - A cell's radius in kilometres, when the page wants it smaller than the fit; 0 for the fit.
|
|
63
|
+
* @returns The cells.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* import { beamCells } from "@johnmorrisdotca/chikyu-earth/space";
|
|
67
|
+
*
|
|
68
|
+
* console.log(beamCells(19, 2200, 0).lattice.length);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function beamCells(count, radiusKm, cellKm = 0) {
|
|
72
|
+
const wanted = Math.max(0, Math.min(91, Math.floor(Number.isFinite(count) ? count : 0)));
|
|
73
|
+
const lattice = [];
|
|
74
|
+
const reach = 6;
|
|
75
|
+
for (let j = -reach; j <= reach; j += 1)
|
|
76
|
+
for (let i = -reach; i <= reach; i += 1)
|
|
77
|
+
lattice.push([i + j / 2, (j * Math.sqrt(3)) / 2]);
|
|
78
|
+
lattice.sort((a, b) => Math.hypot(a[0], a[1]) - Math.hypot(b[0], b[1]) || Math.atan2(a[1], a[0]) - Math.atan2(b[1], b[0]));
|
|
79
|
+
const taken = lattice.slice(0, wanted);
|
|
80
|
+
const far = taken.reduce((most, point) => Math.max(most, Math.hypot(point[0], point[1])), 0);
|
|
81
|
+
let pitch = FIT / (far + CELL_SHARE);
|
|
82
|
+
let radius = CELL_SHARE * pitch;
|
|
83
|
+
if (cellKm > 0 && radiusKm > 0 && cellKm / radiusKm < radius) {
|
|
84
|
+
radius = cellKm / radiusKm;
|
|
85
|
+
pitch = radius / CELL_SHARE;
|
|
86
|
+
}
|
|
87
|
+
return { lattice: taken, pitch, radius };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The attributes the beam reads: `beam`, `beam-elevation`, `beam-cells`, `beam-cell-size`, `beam-color` and `beam-strength`.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* import { BEAM_ATTRIBUTES } from "@johnmorrisdotca/chikyu-earth/space";
|
|
95
|
+
*
|
|
96
|
+
* console.log(BEAM_ATTRIBUTES.join(" "));
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export const BEAM_ATTRIBUTES = ["beam", "beam-elevation", "beam-cells", "beam-cell-size", "beam-color", "beam-strength"];
|
|
100
|
+
/**
|
|
101
|
+
* The beam's colour when the page names none: a pale blue that reads on the day side and the night side.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* import { BEAM_COLOUR } from "@johnmorrisdotca/chikyu-earth/space";
|
|
106
|
+
*
|
|
107
|
+
* console.log(BEAM_COLOUR);
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export const BEAM_COLOUR = "#8fd1ff";
|
|
111
|
+
const number = (value, fallback, least, most) => {
|
|
112
|
+
const read = value === null || value.trim() === "" ? Number.NaN : Number(value);
|
|
113
|
+
return Number.isFinite(read) ? Math.min(most, Math.max(least, read)) : fallback;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* What the beam's attributes say. `beam` is off when it is missing, `off` or `false`; a bare attribute, `selected` or `on` switches it on for the chosen satellite. The strength is from 0 to 1 (0.6 when left out),
|
|
117
|
+
* the elevation from 0 to 80 degrees (25), the cells from 0 to 91 (none) and the cell size in kilometres (0 for the fit).
|
|
118
|
+
*
|
|
119
|
+
* @param get - Reads an attribute by name, `null` when it is missing.
|
|
120
|
+
* @returns The options.
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* import { readBeam } from "@johnmorrisdotca/chikyu-earth/space";
|
|
124
|
+
*
|
|
125
|
+
* const read = readBeam((name) => ({ beam: "selected", "beam-cells": "19" })[name] ?? null);
|
|
126
|
+
* console.log(read.on, read.cells);
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function readBeam(get) {
|
|
130
|
+
const word = get("beam");
|
|
131
|
+
const on = word !== null && !["off", "false", "none"].includes(word.trim().toLowerCase());
|
|
132
|
+
const colour = (get("beam-color") ?? "").trim();
|
|
133
|
+
return {
|
|
134
|
+
on,
|
|
135
|
+
elevation: number(get("beam-elevation"), BEAM_ELEVATION, 0, 80),
|
|
136
|
+
cells: Math.floor(number(get("beam-cells"), 0, 0, 91)),
|
|
137
|
+
cellSize: number(get("beam-cell-size"), 0, 0, 5000),
|
|
138
|
+
colour: /^#[0-9a-f]{3,8}$|^[a-z]+$|^(rgb|hsl)a?\(/i.test(colour) ? colour : BEAM_COLOUR,
|
|
139
|
+
strength: number(get("beam-strength"), 0.6, 0, 1),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
import type { ThreeParts } from "../realistic/textures.ts";
|
|
3
|
+
import { type BeamOptions } from "./geometry.ts";
|
|
4
|
+
/**
|
|
5
|
+
* What the beam has done: whether it is drawn, the chosen satellite's height, the footprint's radius along the ground in kilometres and its angle at the Earth's centre, the elevation it was worked for,
|
|
6
|
+
* the cells drawn and a cell's radius in kilometres, and how many times its geometry was made.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts no-run
|
|
10
|
+
* import type { BeamStats } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
11
|
+
*
|
|
12
|
+
* const none: BeamStats = { shown: false, heightKm: 0, radiusKm: 0, angleDegrees: 0, elevation: 25, cells: 0, cellRadiusKm: 0, builds: 0, failed: false };
|
|
13
|
+
* console.log(none);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export interface BeamStats {
|
|
17
|
+
shown: boolean;
|
|
18
|
+
heightKm: number;
|
|
19
|
+
radiusKm: number;
|
|
20
|
+
angleDegrees: number;
|
|
21
|
+
elevation: number;
|
|
22
|
+
cells: number;
|
|
23
|
+
cellRadiusKm: number;
|
|
24
|
+
builds: number;
|
|
25
|
+
failed: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** What the element and the scene share: the options the attributes give, and what the beam did. */
|
|
28
|
+
export interface BeamState extends BeamOptions {
|
|
29
|
+
onError?: (error: unknown) => void;
|
|
30
|
+
stats: BeamStats;
|
|
31
|
+
}
|
|
32
|
+
export declare const newBeamState: () => BeamState;
|
|
33
|
+
export interface BeamLayer {
|
|
34
|
+
/** Places the beam for this draw: the chosen satellite's place in Earth radii (the scene's axes), or `null` for none. */
|
|
35
|
+
sync(position: readonly [number, number, number] | null): void;
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Makes the beam in `scene` (the world the satellites are in, not the Earth's turning group: the footprint is worked out for the satellite's place now).
|
|
40
|
+
*
|
|
41
|
+
* @param three - The page's three.js; it must have `AdditiveBlending`.
|
|
42
|
+
* @param scene - The scene the satellites are in.
|
|
43
|
+
* @param state - The model's beam.
|
|
44
|
+
* @param order - The render order: after the satellites' dots.
|
|
45
|
+
* @returns The layer.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createBeamLayer(three: ThreeParts, scene: THREE.Object3D, state: BeamState, order: number): BeamLayer;
|