@johnmorrisdotca/chikyu-earth 0.46.2 → 0.46.5
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/NOTICE.md +1 -1
- package/README.md +2 -2
- package/dist/door/gibs.d.ts +31 -4
- package/dist/door/gibs.js +50 -9
- package/dist/door/grid.d.ts +2 -2
- package/dist/door/grid.js +2 -2
- package/dist/door/map.d.ts +9 -0
- package/dist/realistic/element-base.d.ts +3 -2
- package/dist/realistic/element-base.js +8 -7
- package/dist/realistic/shaders.js +5 -3
- package/dist/realistic/tile-set.js +9 -4
- package/dist/space/element-base.d.ts +21 -1
- package/dist/space/element-base.js +60 -10
- package/dist/space/generic-satellite.d.ts +4 -4
- package/dist/space/generic-satellite.js +51 -11
- package/dist/space/index.d.ts +2 -2
- package/dist/space/index.js +1 -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 +3 -1
- package/dist/space/scene.js +17 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.46.5 - 2026-11-13
|
|
4
|
+
|
|
5
|
+
- **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).
|
|
6
|
+
|
|
7
|
+
## 0.46.4 - 2026-11-13
|
|
8
|
+
|
|
9
|
+
- **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.
|
|
10
|
+
|
|
3
11
|
## 0.46.2 - 2026-11-13
|
|
4
12
|
|
|
5
13
|
- **Finer than the package's own tiles, from NASA's imagery service** (MODULES-1263, step 2). `tiles-finer="gibs"` on `<chikyu-earth-realistic>` and `<chikyu-space>` (off unless set) reads a daily true-colour picture in the browser, and only when the view is closer than the tiles already underneath. The layer is MODIS Terra (the VIIRS layer has no days after 2026-11-02), and the day is the most recent one with a picture: the page asks for one tile, the one under the middle of the view, for each day in turn from the UTC day before the one on show back at most 10 days, one at a time, and keeps the answer for the session; if no day answers it says nothing and keeps the package's own tiles, and it never fetches the capabilities file. A day before the layer's first day asks nothing. The clouds are left in, and a daily picture has black wedges between satellite passes: a wholly black tile is not shown, a partly black one is. A page can name the layer and the day rule (`latest`, the default, `previous-day`, `shown` or one day). A tile that is missing, black, or still out after two seconds stays out, the coarser picture remains, and that tile is not asked for again while it is in view. The 48 tile and 72 MB limits, and six requests at a time, are unchanged. A tile fades in over a third of a second, or at once for a reader who asked for less motion, and then nothing is drawn for it. The credit line shows NASA's acknowledgement while those tiles are on screen. `gibsTiles` is the same source from `@johnmorrisdotca/chikyu-earth/door`. A map source may now name its own grid; the package's own folder is unchanged.
|
package/NOTICE.md
CHANGED
|
@@ -76,7 +76,7 @@ The service's page "Data Use Guidance and Acknowledgements" (https://www.earthda
|
|
|
76
76
|
|
|
77
77
|
The tile matrix was read the same day from `https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/1.0.0/WMTSCapabilities.xml`. Geographic tiles are 512 pixels, the corner of the matrix is longitude -180 and latitude 90, and a pixel is 0.5625/2^level degrees. Levels 0, 1 and 2 run past the Earth (2×1, 3×2 and 5×3 tiles); from level 3 the matrix covers the Earth in 10×5 tiles and doubles from there. A successful tile for the static shaded-relief layer answered `access-control-allow-origin: *` and `cache-control: public, max-age=259200`. A successful tile for a daily true-colour layer on the same day answered `access-control-allow-origin: *` and `cache-control: max-age=0, no-store`. No key is sent.
|
|
78
78
|
|
|
79
|
-
The default layer is `
|
|
79
|
+
The default layer is `Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual` (NASA GWELDYR, "NASA Global Web-Enabled Landsat Data Annual Global 30 m V031", LP DAAC, concept id C2763268459-LPCLOUD; 31.25m matrix, JPEG, levels 0 to 11, a picture a year: 1984 to 1985, 1988 to 1990 and 1998 to 2000, the page uses 2000-12-01). Checked against the live service on 2026-11-13, with a few requests each: tiles answer 200 with `content-type: image/jpeg`, `cache-control: public, max-age=2592000`, `access-control-allow-origin: *`, `layer-time-actual: 2000-12-01T00:00:00Z`; the tile addresses are the ones this package's grid names (Vancouver level 9 row 72 column 101, level 10 row 144 column 202, level 11 row 289 column 404; Tokyo 9/96/568; Paris 10/146/648; the Sahara 9/115/337). Coverage as seen: land at 49 N, 35 N, 25 N and in the Amazon; no data (a 200 with an all-black, 4,723-byte picture, the same as a daily layer's) over the Pacific, Antarctica, Greenland at 72 N, Svalbard at 78 N and at the pole. The picture is cloud-free and sharp (streets and fields at level 9) but of the year 2000, and straight scene edges show in places (for example west of Tokyo). The page treats a wholly black tile as no picture, clears black and nearly black pixels (luminance up to 20 clear, from 32 opaque: the sea in the mosaic is about (7, 25, 12) and a dark wooded slope (8, 39, 6) to (22, 54, 7)), and multiplies the colours by 0.76, 0.66 and 0.55: the median, over six land places (Paris, the Sahara, the Amazon, Kansas, Siberia, Australia), of the package's own level 5 over this layer's mean colour in the same 2.25 degree square (0.75 0.77 0.77 0.70 0.81 0.68 red, 0.65 0.71 0.70 0.61 0.61 0.56 green, 0.53 0.64 0.59 0.51 0.54 0.53 blue). Layer-specific credit: NASA's acknowledgement is the one the data-use page asks for; the layer's metadata names the product and its data centre only, so the credit line names the Global Web-Enabled Landsat Data and LP DAAC as well. Other layers checked and not used as the default: `ASTER_GDEM_Color_Shaded_Relief` (31.25m, colour-coded height, not true colour); `MODIS_Terra_L3_SurfaceReflectance_Bands143_8Day` (500 m, an 8-day true-colour composite, speckled with cloud); `HLS_S30_Nadir_BRDF_Adjusted_Reflectance` and the L30 twin (31.25m daily scenes, 600 KB PNG tiles, solid cloud over Paris on 2026-11-05); `BlueMarble_NextGeneration` (500 m, the package's own source); no Blue Marble at 250 m exists on the service. `MODIS_Terra_CorrectedReflectance_TrueColor` (250 m, JPEG, days 2000-02-24 to 2026-11-13 with gaps; the name `today`): the page looks for the most recent day that answers with a picture, from the day before the moment on show back at most 10 days, one tile a day (2026-11-13 answered 200 with an all-black picture, 2026-11-12 and 2026-11-11 with pictures; the daily tiles answer `cache-control: max-age=0, no-store, no-cache, must-revalidate` and `access-control-allow-origin: *`, and carry `layer-time-actual`). `VIIRS_SNPP_CorrectedReflectance_TrueColor` has days from 2015-11-24 to 2026-11-02 with gaps. `BlueMarble_ShadedRelief_Bathymetry` (500 m) has no day. A daily layer's day before its first day, or in a gap of the list that was read, is not requested; a day after the last listed day is, because a daily layer goes on growing. The daily layers are true colour with the clouds left in, and a day's picture has black gaps between passes, which the page clears.
|
|
80
80
|
|
|
81
81
|
The 500 m maps could fill one more level (65536 across for the day map); the pyramid stops at level 5 (day) and level 4 (night) for now. Where the pyramid is hosted: GitHub Pages of this public repository, which costs nothing (docs/guides/earth-tiles.md). It adds 3,412 files and 35.4 MB to the site (852 files and 10.3 MB before the 500 m levels; the levels above day 4 and night 3 go out only when the repository variable EARTH_TILES_ALL is yes, see docs/guides/earth-tiles.md). The source files are downloaded by the build (688 MB, once, kept by CI's cache) and are not part of the site.
|
|
82
82
|
|
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
|
|
@@ -611,7 +611,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
611
611
|
|
|
612
612
|
## How to cite
|
|
613
613
|
|
|
614
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.46.
|
|
614
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.46.5) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
615
615
|
|
|
616
616
|
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
617
|
|
package/dist/door/gibs.d.ts
CHANGED
|
@@ -44,19 +44,37 @@ interface DayRange {
|
|
|
44
44
|
}
|
|
45
45
|
interface GibsLayer {
|
|
46
46
|
id: string;
|
|
47
|
-
matrix: "250m" | "500m";
|
|
48
|
-
/** Empty for a picture that has no day (the shaded relief). */
|
|
47
|
+
matrix: "31.25m" | "250m" | "500m";
|
|
48
|
+
/** Empty for a picture that has no day (the shaded relief, and the annual Landsat mosaics, which have `years`). */
|
|
49
49
|
ranges: readonly DayRange[];
|
|
50
50
|
/** True when the picture is one day of the satellite and clouds are left in. */
|
|
51
51
|
clouds: boolean;
|
|
52
|
+
/** For a layer with one picture a year: the years' times, as the service names them (`yyyy-mm-dd`), oldest first. The newest is the one used unless a page names another of them. */
|
|
53
|
+
years?: readonly string[];
|
|
54
|
+
/**
|
|
55
|
+
* For a layer that shows water as nearly black (the Landsat mosaics): the luminance (0 to 255) below which a pixel is clear and from which it is opaque, so the sea is left to the package's blue ocean and the picture is a land picture. Left out, only the black of no data is cleared (`NODATA_BELOW` and `NODATA_FULL`).
|
|
56
|
+
*/
|
|
57
|
+
clear?: readonly [number, number];
|
|
58
|
+
/** Multiplies each colour, to bring the picture to the look of the package's own pictures (found by comparing them over land, see NOTICE.md). */
|
|
59
|
+
gain?: readonly [number, number, number];
|
|
60
|
+
/** A sentence about the layer's own data, added to NASA's acknowledgement while its tiles are on the screen. */
|
|
61
|
+
credit?: {
|
|
62
|
+
en: string;
|
|
63
|
+
ja: string;
|
|
64
|
+
};
|
|
52
65
|
}
|
|
53
66
|
/**
|
|
54
67
|
* The layers a page may ask for. The ranges are the days the capabilities document listed on 2026-11-13; a day outside them is not requested.
|
|
55
68
|
* The two daily layers are true colour with the clouds left in. The shaded relief is the same kind of picture as the package's own level 5, and is only a stand-in.
|
|
56
69
|
*/
|
|
57
70
|
export declare const GIBS_LAYERS: Readonly<Record<string, GibsLayer>>;
|
|
58
|
-
/**
|
|
59
|
-
|
|
71
|
+
/**
|
|
72
|
+
* The layer a page gets without naming one: the Landsat annual true-colour mosaic (30 m, no cloud, land only; the year 2000, the newest it has). The daily layers are a named choice: `today` for MODIS Terra.
|
|
73
|
+
* A layer id is taken as it is, and these short names stand for two of them.
|
|
74
|
+
*/
|
|
75
|
+
export declare const GIBS_DEFAULT_LAYER = "Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual";
|
|
76
|
+
/** The short names `tiles-finer-layer` takes besides a layer's own id: `landsat` (the default) and `today` (the daily picture of MODIS Terra, with its clouds). */
|
|
77
|
+
export declare const GIBS_NAMES: Readonly<Record<string, string>>;
|
|
60
78
|
/** How many days, counting the first, the default rule looks back for a day with imagery. */
|
|
61
79
|
export declare const GIBS_LOOKBACK_DAYS = 10;
|
|
62
80
|
/**
|
|
@@ -133,7 +151,16 @@ export interface GibsTilesOptions extends EarthTilesOptions {
|
|
|
133
151
|
date?: string;
|
|
134
152
|
/** Called when the default rule has found its day, so the view draws again and asks for the tiles. */
|
|
135
153
|
changed?: () => void;
|
|
154
|
+
/** How many milliseconds a tile is given to arrive (`GIBS_SLOW_MS`, 2000, when left out). A page on a slow link can give it longer. */
|
|
155
|
+
slowMs?: number;
|
|
136
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Where a tile's luminance (0 to 255) is at or below this, the picture has no data there (the service paints it black) and the loader draws it clear; from `NODATA_FULL` it is opaque, and between the two a share, so the edge of a gap is not a hard
|
|
159
|
+
* black line. A layer may set its own limits (`clear`).
|
|
160
|
+
*/
|
|
161
|
+
export declare const NODATA_BELOW = 3;
|
|
162
|
+
/** The luminance from which a pixel is wholly opaque (see `NODATA_BELOW`). */
|
|
163
|
+
export declare const NODATA_FULL = 14;
|
|
137
164
|
/**
|
|
138
165
|
* A map source that reads NASA's imagery service directly. It declares its own grid (512 pixel tiles, the Geographic matrix, which is not the package's pyramid). `need` names no tile for a day outside the layer's range.
|
|
139
166
|
* `load` gives a tile two seconds, and treats a 404 or an all-black tile as no imagery. The clouds are not taken out of the daily layers.
|
package/dist/door/gibs.js
CHANGED
|
@@ -53,6 +53,22 @@ const INFO = {
|
|
|
53
53
|
* The two daily layers are true colour with the clouds left in. The shaded relief is the same kind of picture as the package's own level 5, and is only a stand-in.
|
|
54
54
|
*/
|
|
55
55
|
export const GIBS_LAYERS = {
|
|
56
|
+
Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual: {
|
|
57
|
+
id: "Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual",
|
|
58
|
+
matrix: "31.25m",
|
|
59
|
+
clouds: false,
|
|
60
|
+
ranges: [],
|
|
61
|
+
// as the capabilities document listed them on 2026-11-13: 1983-12-01 to 1985-12-01, 1988-12-01 to 1990-12-01, 1998-12-01 to 2000-12-01, a picture a year
|
|
62
|
+
years: ["1983-12-01", "1984-12-01", "1985-12-01", "1988-12-01", "1989-12-01", "1990-12-01", "1998-12-01", "1999-12-01", "2000-12-01"],
|
|
63
|
+
// per channel, the median over six land places of our level 5 divided by this layer's mean (NOTICE.md): the package's pictures are darker and warmer
|
|
64
|
+
gain: [0.76, 0.66, 0.55],
|
|
65
|
+
// the sea is (7, 25, 12) there and a dark wooded slope (8, 39, 6) to (22, 54, 7): clear below a luminance of 20, opaque from 32
|
|
66
|
+
clear: [20, 32],
|
|
67
|
+
credit: {
|
|
68
|
+
en: "Landsat imagery: NASA Global Web-Enabled Landsat Data (GWELD), annual 30 m mosaic, distributed by NASA's LP DAAC.",
|
|
69
|
+
ja: "Landsat画像:NASAのGlobal Web-Enabled Landsat Data(GWELD)の年間30 mモザイク。NASAのLP DAACが配布しています。",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
56
72
|
VIIRS_SNPP_CorrectedReflectance_TrueColor: {
|
|
57
73
|
id: "VIIRS_SNPP_CorrectedReflectance_TrueColor",
|
|
58
74
|
matrix: "250m",
|
|
@@ -86,9 +102,17 @@ export const GIBS_LAYERS = {
|
|
|
86
102
|
},
|
|
87
103
|
BlueMarble_ShadedRelief_Bathymetry: { id: "BlueMarble_ShadedRelief_Bathymetry", matrix: "500m", clouds: false, ranges: [] },
|
|
88
104
|
};
|
|
89
|
-
/**
|
|
90
|
-
|
|
105
|
+
/**
|
|
106
|
+
* The layer a page gets without naming one: the Landsat annual true-colour mosaic (30 m, no cloud, land only; the year 2000, the newest it has). The daily layers are a named choice: `today` for MODIS Terra.
|
|
107
|
+
* A layer id is taken as it is, and these short names stand for two of them.
|
|
108
|
+
*/
|
|
109
|
+
export const GIBS_DEFAULT_LAYER = "Landsat_WELD_CorrectedReflectance_TrueColor_Global_Annual";
|
|
91
110
|
const DEFAULT_LAYER = GIBS_DEFAULT_LAYER;
|
|
111
|
+
/** The short names `tiles-finer-layer` takes besides a layer's own id: `landsat` (the default) and `today` (the daily picture of MODIS Terra, with its clouds). */
|
|
112
|
+
export const GIBS_NAMES = {
|
|
113
|
+
landsat: GIBS_DEFAULT_LAYER,
|
|
114
|
+
today: "MODIS_Terra_CorrectedReflectance_TrueColor",
|
|
115
|
+
};
|
|
92
116
|
/** How many days, counting the first, the default rule looks back for a day with imagery. */
|
|
93
117
|
export const GIBS_LOOKBACK_DAYS = 10;
|
|
94
118
|
/**
|
|
@@ -172,6 +196,11 @@ function fixedDay(rule, ms) {
|
|
|
172
196
|
}
|
|
173
197
|
/** A day the layer can serve for a fixed rule (`latest`, the default, starts at the day before `ms`), or `undefined` when it lands where the layer has no imagery (nothing is requested). */
|
|
174
198
|
export function gibsDay(layer, rule, ms) {
|
|
199
|
+
if (layer.years) {
|
|
200
|
+
// one picture a year: the year a page names if the layer has it (any day of that year), else the newest
|
|
201
|
+
const named = /^\d{4}/.test(rule) ? layer.years.find((time) => time.slice(0, 4) === rule.slice(0, 4)) : undefined;
|
|
202
|
+
return named ?? layer.years[layer.years.length - 1];
|
|
203
|
+
}
|
|
175
204
|
if (layer.ranges.length === 0)
|
|
176
205
|
return "default";
|
|
177
206
|
const named = fixedDay(rule, ms) ?? previousUtcDay(ms);
|
|
@@ -200,6 +229,13 @@ export function forgetGibsDays() {
|
|
|
200
229
|
settled.clear();
|
|
201
230
|
probing.clear();
|
|
202
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* Where a tile's luminance (0 to 255) is at or below this, the picture has no data there (the service paints it black) and the loader draws it clear; from `NODATA_FULL` it is opaque, and between the two a share, so the edge of a gap is not a hard
|
|
234
|
+
* black line. A layer may set its own limits (`clear`).
|
|
235
|
+
*/
|
|
236
|
+
export const NODATA_BELOW = 3;
|
|
237
|
+
/** The luminance from which a pixel is wholly opaque (see `NODATA_BELOW`). */
|
|
238
|
+
export const NODATA_FULL = 14;
|
|
203
239
|
const anySignal = (signals) => (typeof AbortSignal.any === "function" ? AbortSignal.any(signals) : signals[0]);
|
|
204
240
|
async function pictureIsBlank(image) {
|
|
205
241
|
const CanvasCtor = globalThis.OffscreenCanvas;
|
|
@@ -233,8 +269,9 @@ async function pictureIsBlank(image) {
|
|
|
233
269
|
* ```
|
|
234
270
|
*/
|
|
235
271
|
export function gibsTiles(options) {
|
|
236
|
-
const
|
|
237
|
-
const
|
|
272
|
+
const wanted = options.layer ? (GIBS_NAMES[options.layer] ?? options.layer) : DEFAULT_LAYER;
|
|
273
|
+
const known = GIBS_LAYERS[wanted];
|
|
274
|
+
const layer = known ?? { id: wanted, matrix: "250m", clouds: true, ranges: [] };
|
|
238
275
|
const grid = gibsGrid(layer.matrix);
|
|
239
276
|
const rule = options.date ?? "latest";
|
|
240
277
|
const get = options.fetch ?? ((url, init) => globalThis.fetch(url, init));
|
|
@@ -249,7 +286,7 @@ export function gibsTiles(options) {
|
|
|
249
286
|
if (!gridOnEarth(level, parts.col, parts.row, grid.extent))
|
|
250
287
|
throw new RangeError(`"${key}" is off the Earth`);
|
|
251
288
|
const url = `${TILE_URL}/${layer.id}/default/${day}/${layer.matrix}/${parts.level}/${parts.row}/${parts.col}.jpg`;
|
|
252
|
-
const timer = AbortSignal.timeout(GIBS_SLOW_MS);
|
|
289
|
+
const timer = AbortSignal.timeout(options.slowMs && options.slowMs > 0 ? options.slowMs : GIBS_SLOW_MS);
|
|
253
290
|
let response;
|
|
254
291
|
try {
|
|
255
292
|
response = await get(url, { mode: "cors", signal: anySignal([signal, timer]) });
|
|
@@ -296,7 +333,7 @@ export function gibsTiles(options) {
|
|
|
296
333
|
if (!known)
|
|
297
334
|
return undefined;
|
|
298
335
|
const ms = options.time().getTime();
|
|
299
|
-
if (fixedDay(rule, ms) !== undefined || layer.ranges.length === 0)
|
|
336
|
+
if (layer.years || fixedDay(rule, ms) !== undefined || layer.ranges.length === 0)
|
|
300
337
|
return gibsDay(layer, rule, ms);
|
|
301
338
|
const start = previousUtcDay(ms);
|
|
302
339
|
const settledKey = `${layer.id}|${start}`;
|
|
@@ -309,7 +346,10 @@ export function gibsTiles(options) {
|
|
|
309
346
|
const source = {
|
|
310
347
|
kind: "tiles",
|
|
311
348
|
layer: "day",
|
|
312
|
-
info: INFO,
|
|
349
|
+
info: layer.credit ? { ...INFO, credit: { en: `${GIBS_CREDIT.en} ${layer.credit.en}`, ja: `${GIBS_CREDIT.ja}${layer.credit.ja}` } } : INFO,
|
|
350
|
+
holes: true,
|
|
351
|
+
// the loader draws the tile with these on the graphics card: clear where it is dark, and each colour multiplied (nothing is done to the pixels on the processor)
|
|
352
|
+
look: { clear: layer.clear ?? [NODATA_BELOW, NODATA_FULL], ...(layer.gain ? { gain: layer.gain } : {}) },
|
|
313
353
|
grid,
|
|
314
354
|
need(place, detail) {
|
|
315
355
|
if (gridLevelFor(grid, detail, 0) === undefined)
|
|
@@ -349,13 +389,14 @@ export function createFinerHolder(time, changed) {
|
|
|
349
389
|
source(read, ownOnly) {
|
|
350
390
|
if (ownOnly || read("tiles-finer") !== "gibs")
|
|
351
391
|
return undefined;
|
|
352
|
-
const next = `${read("tiles-finer-layer") ?? ""}\n${read("tiles-finer-date") ?? ""}`;
|
|
392
|
+
const next = `${read("tiles-finer-layer") ?? ""}\n${read("tiles-finer-date") ?? ""}\n${read("tiles-finer-timeout") ?? ""}`;
|
|
353
393
|
if (held && key === next)
|
|
354
394
|
return held;
|
|
355
395
|
key = next;
|
|
356
396
|
const layer = read("tiles-finer-layer");
|
|
357
397
|
const date = read("tiles-finer-date");
|
|
358
|
-
|
|
398
|
+
const slow = Number(read("tiles-finer-timeout"));
|
|
399
|
+
held = gibsTiles({ time, ...(changed ? { changed } : {}), ...(slow > 0 ? { slowMs: slow } : {}), ...(layer ? { layer } : {}), ...(date ? { date } : {}) });
|
|
359
400
|
return held;
|
|
360
401
|
},
|
|
361
402
|
};
|
package/dist/door/grid.d.ts
CHANGED
|
@@ -188,7 +188,7 @@ export declare function gridKeys(grid: MapGrid, place: MapPlace, detail: number,
|
|
|
188
188
|
* The Geographic (EPSG:4326) tile matrix NASA's imagery service publishes, read from its capabilities on 2026-11-13.
|
|
189
189
|
* A pixel is `0.5625 / 2^level` degrees. Tiles are 512 pixels, the corner of column 0 and row 0 is longitude -180 and latitude 90, and a level has as many tiles as it takes to cover the Earth, so levels 0, 1 and 2 run past it.
|
|
190
190
|
*
|
|
191
|
-
* @param matrix - `250m` (levels 0 to 8)
|
|
191
|
+
* @param matrix - `250m` (levels 0 to 8), `500m` (levels 0 to 7) or `31.25m` (levels 0 to 11, the Landsat and shaded-relief layers).
|
|
192
192
|
* @returns The grid.
|
|
193
193
|
*
|
|
194
194
|
* @example
|
|
@@ -198,4 +198,4 @@ export declare function gridKeys(grid: MapGrid, place: MapPlace, detail: number,
|
|
|
198
198
|
* console.log(gibsGrid("250m").levels[3]);
|
|
199
199
|
* ```
|
|
200
200
|
*/
|
|
201
|
-
export declare function gibsGrid(matrix: "250m" | "500m"): MapGrid;
|
|
201
|
+
export declare function gibsGrid(matrix: "31.25m" | "250m" | "500m"): MapGrid;
|
package/dist/door/grid.js
CHANGED
|
@@ -220,7 +220,7 @@ export function gridKeys(grid, place, detail, prefix = "") {
|
|
|
220
220
|
* The Geographic (EPSG:4326) tile matrix NASA's imagery service publishes, read from its capabilities on 2026-11-13.
|
|
221
221
|
* A pixel is `0.5625 / 2^level` degrees. Tiles are 512 pixels, the corner of column 0 and row 0 is longitude -180 and latitude 90, and a level has as many tiles as it takes to cover the Earth, so levels 0, 1 and 2 run past it.
|
|
222
222
|
*
|
|
223
|
-
* @param matrix - `250m` (levels 0 to 8)
|
|
223
|
+
* @param matrix - `250m` (levels 0 to 8), `500m` (levels 0 to 7) or `31.25m` (levels 0 to 11, the Landsat and shaded-relief layers).
|
|
224
224
|
* @returns The grid.
|
|
225
225
|
*
|
|
226
226
|
* @example
|
|
@@ -231,7 +231,7 @@ export function gridKeys(grid, place, detail, prefix = "") {
|
|
|
231
231
|
* ```
|
|
232
232
|
*/
|
|
233
233
|
export function gibsGrid(matrix) {
|
|
234
|
-
const max = matrix === "250m" ? 8 : 7;
|
|
234
|
+
const max = matrix === "31.25m" ? 11 : matrix === "250m" ? 8 : 7;
|
|
235
235
|
const levels = [];
|
|
236
236
|
for (let level = 0; level <= max; level += 1) {
|
|
237
237
|
const pixel = 0.5625 / 2 ** level;
|
package/dist/door/map.d.ts
CHANGED
|
@@ -47,6 +47,15 @@ export type EarthMapSource = TileSource<EarthMapPlace, number, ImageTile> & {
|
|
|
47
47
|
* The source's own grid, when it is not the package's pyramid (`2^(L+1)` columns by `2^L` rows). The loader places tiles from this. Left out, the pyramid is unchanged.
|
|
48
48
|
*/
|
|
49
49
|
grid?: MapGrid;
|
|
50
|
+
/** True when the source's tiles may have transparent pixels (a place it has no data for), so the loader draws them blended and the picture underneath shows through. */
|
|
51
|
+
holes?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* How the loader draws this source's tiles, on the graphics card: `clear` is the luminance (0 to 255) at or below which a pixel is wholly transparent and from which it is wholly opaque, and `gain` multiplies each colour. Left out, tiles are drawn as they are.
|
|
54
|
+
*/
|
|
55
|
+
look?: {
|
|
56
|
+
clear: readonly [number, number];
|
|
57
|
+
gain?: readonly [number, number, number];
|
|
58
|
+
};
|
|
50
59
|
};
|
|
51
60
|
/**
|
|
52
61
|
* The levels a source has when it does not say: levels 3 and 4 (8192 and 16384 pixels across), the two the package's cutter makes beyond its own 4096 pixel picture.
|
|
@@ -55,6 +55,7 @@ type SatelliteStats = {
|
|
|
55
55
|
maxUpdateMs: number;
|
|
56
56
|
averageUpdateMs: number;
|
|
57
57
|
updates: number;
|
|
58
|
+
selectedRing: boolean;
|
|
58
59
|
};
|
|
59
60
|
/**
|
|
60
61
|
* A `speed` attribute: how many seconds pass for each real second.
|
|
@@ -327,8 +328,8 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
327
328
|
get tiles(): string | null;
|
|
328
329
|
set tiles(value: string | null);
|
|
329
330
|
/**
|
|
330
|
-
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on; anything else, or leaving it out, leaves it off. The
|
|
331
|
-
* `tiles-finer-layer`
|
|
331
|
+
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on; anything else, or leaving it out, leaves it off. The picture is NASA's Landsat annual true-colour mosaic (30 m, no cloud, land only, the year 2000), laid over the package's picture only where the view is closer than the package's own tiles; where it has no data (the sea, Antarctica, the far north) the package's picture stays. A tile that is slow or missing leaves the coarser picture in place.
|
|
332
|
+
* `tiles-finer-layer` is `landsat` (the default), `today` (the daily MODIS Terra picture, with its clouds, for the most recent day that has one, looked for from the day before the moment on show back at most 10 days, one tile a day) or another layer's id. `tiles-finer-date` names a year of the Landsat mosaic by its date (`1990-06-01`), or, for a daily layer, is `latest` (the default), `previous-day`, `shown` or one day `yyyy-mm-dd`. `tiles-finer-timeout` is how many milliseconds a tile is given to arrive before it is left (2000 when the page says nothing).
|
|
332
333
|
*/
|
|
333
334
|
get tilesFiner(): string | null;
|
|
334
335
|
set tilesFiner(value: string | null);
|
|
@@ -13,7 +13,7 @@ import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadius
|
|
|
13
13
|
import { readMeteorStrength } from "../meteors/strength.js";
|
|
14
14
|
import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
|
|
15
15
|
import { createDoorHost } from "../door/host.js";
|
|
16
|
-
import { createFinerHolder,
|
|
16
|
+
import { createFinerHolder, GIBS_ID } from "../door/gibs.js";
|
|
17
17
|
import { folderSource } from "../door/map.js";
|
|
18
18
|
import { ownCredit } from "../door/own.js";
|
|
19
19
|
import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "./body-label.js";
|
|
@@ -161,7 +161,7 @@ export const readTime = (value) => {
|
|
|
161
161
|
* ```
|
|
162
162
|
*/
|
|
163
163
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
164
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max"];
|
|
164
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max"];
|
|
165
165
|
#model = newModel();
|
|
166
166
|
#paint = createPaintState();
|
|
167
167
|
#mode = "now";
|
|
@@ -440,7 +440,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
440
440
|
this.light = readLight(value);
|
|
441
441
|
else if (name === "live-seconds")
|
|
442
442
|
this.#startTick();
|
|
443
|
-
else if (name === "tiles" || name === "tiles-finer" || name === "tiles-finer-layer" || name === "tiles-finer-date")
|
|
443
|
+
else if (name === "tiles" || name === "tiles-finer" || name === "tiles-finer-layer" || name === "tiles-finer-date" || name === "tiles-finer-timeout")
|
|
444
444
|
this.#gate?.soon();
|
|
445
445
|
else if (name === "data") {
|
|
446
446
|
this.#door.book.ownOnly(value === "own");
|
|
@@ -970,7 +970,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
970
970
|
return;
|
|
971
971
|
const count = this.#model.tiles?.stats.used[GIBS_ID] ?? 0;
|
|
972
972
|
const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
973
|
-
const
|
|
973
|
+
const finer = this.#finerHold.source((attr) => this.getAttribute(attr), this.getAttribute("data") === "own");
|
|
974
|
+
const text = count > 0 && finer ? finer.info.credit[lang] : "";
|
|
974
975
|
if (note.textContent !== text)
|
|
975
976
|
note.textContent = text;
|
|
976
977
|
if (note.lang !== lang)
|
|
@@ -1033,8 +1034,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1033
1034
|
this.setAttribute("tiles", value);
|
|
1034
1035
|
}
|
|
1035
1036
|
/**
|
|
1036
|
-
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on; anything else, or leaving it out, leaves it off. The
|
|
1037
|
-
* `tiles-finer-layer`
|
|
1037
|
+
* Finer imagery than the package's own tiles, read by the browser from NASA's imagery service. `gibs` turns it on; anything else, or leaving it out, leaves it off. The picture is NASA's Landsat annual true-colour mosaic (30 m, no cloud, land only, the year 2000), laid over the package's picture only where the view is closer than the package's own tiles; where it has no data (the sea, Antarctica, the far north) the package's picture stays. A tile that is slow or missing leaves the coarser picture in place.
|
|
1038
|
+
* `tiles-finer-layer` is `landsat` (the default), `today` (the daily MODIS Terra picture, with its clouds, for the most recent day that has one, looked for from the day before the moment on show back at most 10 days, one tile a day) or another layer's id. `tiles-finer-date` names a year of the Landsat mosaic by its date (`1990-06-01`), or, for a daily layer, is `latest` (the default), `previous-day`, `shown` or one day `yyyy-mm-dd`. `tiles-finer-timeout` is how many milliseconds a tile is given to arrive before it is left (2000 when the page says nothing).
|
|
1038
1039
|
*/
|
|
1039
1040
|
get tilesFiner() {
|
|
1040
1041
|
return this.getAttribute("tiles-finer") === "gibs" ? "gibs" : null;
|
|
@@ -1398,7 +1399,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1398
1399
|
let epochMs = 0;
|
|
1399
1400
|
for (const group of this.#model.satellites.groups.values())
|
|
1400
1401
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1401
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
|
|
1402
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing };
|
|
1402
1403
|
}
|
|
1403
1404
|
// A press that does not turn the view (under 6 pixels) on a satellite tells the page, which chooses it with `selectSatellite` if it likes.
|
|
1404
1405
|
#downX = 0;
|
|
@@ -35,7 +35,7 @@ uniform sampler2D paintMap;
|
|
|
35
35
|
uniform float paintNow;
|
|
36
36
|
uniform float paintSpan;
|
|
37
37
|
uniform float paintOn;
|
|
38
|
-
${tile ? "uniform vec4 nightRect;\nuniform float tileAlpha;\nvarying vec2 vUvG;" : ""}
|
|
38
|
+
${tile ? "uniform vec4 nightRect;\nuniform float tileAlpha;\nuniform vec3 tileGain;\nuniform vec2 tileClear;\nvarying vec2 vUvG;" : ""}
|
|
39
39
|
varying vec2 vUv;
|
|
40
40
|
varying vec3 vNormal;
|
|
41
41
|
varying vec3 vWorld;
|
|
@@ -47,7 +47,9 @@ void main() {
|
|
|
47
47
|
float ndv = clamp(dot(n, toEye), 0.0, 1.0);
|
|
48
48
|
float day = smoothstep(-0.10, 0.22, ndl);
|
|
49
49
|
vec2 g = ${tile ? "vUvG" : "vUv"};
|
|
50
|
-
|
|
50
|
+
vec4 texel = texture2D(dayMap, vUv);
|
|
51
|
+
${tile ? "float keep = clamp((dot(texel.rgb, vec3(0.299, 0.587, 0.114)) - tileClear.x) / (tileClear.y - tileClear.x), 0.0, 1.0);\n texel.rgb *= tileGain;" : "float keep = 1.0;"}
|
|
52
|
+
vec3 albedo = texel.rgb;
|
|
51
53
|
float water = texture2D(waterMap, g).r;
|
|
52
54
|
albedo = pow(albedo, vec3(0.86)) * 1.08;
|
|
53
55
|
albedo *= mix(vec3(1.0), vec3(1.05, 1.22, 1.55), water);
|
|
@@ -96,7 +98,7 @@ void main() {
|
|
|
96
98
|
col = mix(col, vec3(1.0, 0.55, 0.12), clamp(show, 0.0, 0.92));
|
|
97
99
|
}
|
|
98
100
|
|
|
99
|
-
gl_FragColor = vec4(col, ${tile ? "tileAlpha" : "1.0"});
|
|
101
|
+
gl_FragColor = vec4(col, ${tile ? "tileAlpha * keep * texel.a" : "1.0"});
|
|
100
102
|
}`;
|
|
101
103
|
export const SURFACE_FRAG = surfaceFrag(false);
|
|
102
104
|
/** The same surface for a map tile: the tile's own program. */
|
|
@@ -351,6 +351,9 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
351
351
|
...shared.extra,
|
|
352
352
|
nightRect,
|
|
353
353
|
tileAlpha: cover,
|
|
354
|
+
// the source's look: each colour multiplied, and clear below a luminance (the defaults leave a tile as it is: the clear range, in 0 to 1, lies below black)
|
|
355
|
+
tileGain: { value: entry.source.look?.gain ?? [1, 1, 1] },
|
|
356
|
+
tileClear: { value: entry.source.look ? [entry.source.look.clear[0] / 255, entry.source.look.clear[1] / 255] : [-2, -1] },
|
|
354
357
|
rect: { value: gridRect(entry) },
|
|
355
358
|
// a finer level sits a little higher, so two levels at once never fight for the same depth; a grid tile sits above the package's finest. All sit above the whole-Earth sphere's flat faces
|
|
356
359
|
radius: { value: entry.gridLevel ? 1.0008 : 1.0004 + 0.0001 * (entry.id.level - 3) },
|
|
@@ -358,8 +361,9 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
358
361
|
polygonOffset: true,
|
|
359
362
|
polygonOffsetFactor: -1,
|
|
360
363
|
polygonOffsetUnits: -1,
|
|
361
|
-
transparent
|
|
362
|
-
|
|
364
|
+
// a source whose tiles have holes (no data, which the source made transparent) is drawn blended, so the picture under it shows there
|
|
365
|
+
transparent: entry.source.holes === true,
|
|
366
|
+
depthWrite: entry.source.holes !== true,
|
|
363
367
|
});
|
|
364
368
|
entry.cover = cover;
|
|
365
369
|
const mesh = new three.Mesh(geometry, material);
|
|
@@ -612,8 +616,9 @@ export function createTileSet(three, parent, shared, deps) {
|
|
|
612
616
|
entry.cover.value = t;
|
|
613
617
|
const material = entry.mesh?.material;
|
|
614
618
|
if (material) {
|
|
615
|
-
|
|
616
|
-
material.
|
|
619
|
+
const holes = entry.source.holes === true;
|
|
620
|
+
material.transparent = t < 1 || holes;
|
|
621
|
+
material.depthWrite = t >= 1 && !holes;
|
|
617
622
|
}
|
|
618
623
|
if (t < 1)
|
|
619
624
|
fading = true;
|
|
@@ -18,7 +18,7 @@ import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/type
|
|
|
18
18
|
import { type PlanetName } from "./ephemeris.ts";
|
|
19
19
|
import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts";
|
|
20
20
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
21
|
-
import { type RideFace, type RideLook, type RideViewpoint } from "./ride.ts";
|
|
21
|
+
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
22
22
|
import { type ScaleMode } from "./scale.ts";
|
|
23
23
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
24
24
|
import { type PaintSpec } from "../paint/buffer.ts";
|
|
@@ -116,6 +116,8 @@ export interface RideOptions {
|
|
|
116
116
|
face?: RideFace;
|
|
117
117
|
/** `outside` (the default, or the element's `ride-viewpoint`) shows the satellite: with `view: "from"` the camera is a little behind and above it (straight above it with `look: "down"`), and a satellite the page has no model for is drawn small from the package's own sketch of its kind. `inside` is the camera at the satellite, as before, and no sketch. A body is always ridden from inside. */
|
|
118
118
|
viewpoint?: RideViewpoint;
|
|
119
|
+
/** `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. */
|
|
120
|
+
modelSize?: RideModelSize;
|
|
119
121
|
distanceKm?: number;
|
|
120
122
|
smooth?: boolean;
|
|
121
123
|
}
|
|
@@ -138,6 +140,8 @@ export interface Riding {
|
|
|
138
140
|
distanceKm: number;
|
|
139
141
|
/** `outside` or `inside` (see `RideOptions`). */
|
|
140
142
|
viewpoint: RideViewpoint;
|
|
143
|
+
/** `distance` or `fixed` (see `RideOptions`). */
|
|
144
|
+
modelSize: RideModelSize;
|
|
141
145
|
}
|
|
142
146
|
type SatelliteStats = {
|
|
143
147
|
groups: number;
|
|
@@ -158,6 +162,7 @@ type SatelliteStats = {
|
|
|
158
162
|
maxUpdateMs: number;
|
|
159
163
|
averageUpdateMs: number;
|
|
160
164
|
updates: number;
|
|
165
|
+
selectedRing: boolean;
|
|
161
166
|
};
|
|
162
167
|
/**
|
|
163
168
|
* The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
@@ -491,6 +496,21 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
491
496
|
*/
|
|
492
497
|
get rideViewpoint(): RideViewpoint;
|
|
493
498
|
set rideViewpoint(value: RideViewpoint);
|
|
499
|
+
/**
|
|
500
|
+
* How the model of a satellite seen from above is sized as the camera rises: `distance` (the default; the attribute `ride-model-size`) lets it shrink with the height and hand over to the ordinary mark (ring and name) between 1,000 and 2,000 km, `fixed` keeps the same share of the picture at every height, as 0.46.1 did.
|
|
501
|
+
* It is the default for the next `ride` and, set while riding, changes the one ridden at the next draw. See `RideOptions.modelSize`.
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* ```ts
|
|
505
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
506
|
+
*
|
|
507
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
508
|
+
* space.rideModelSize = "fixed";
|
|
509
|
+
* console.log(space.rideModelSize);
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
get rideModelSize(): RideModelSize;
|
|
513
|
+
set rideModelSize(value: RideModelSize);
|
|
494
514
|
/** What the camera is riding along with now, or null. */
|
|
495
515
|
get riding(): Riding | null;
|
|
496
516
|
/**
|
|
@@ -20,7 +20,7 @@ import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js
|
|
|
20
20
|
import { SEA_NAMES_ATTRIBUTES, readSeaNames } from "../sea-names/geometry.js";
|
|
21
21
|
import { SEA_NAMES_STYLE, createSeaHost } from "../sea-names/host.js";
|
|
22
22
|
import { createGate, frameCap } from "../realistic/gate.js";
|
|
23
|
-
import { createFinerHolder,
|
|
23
|
+
import { createFinerHolder, GIBS_ID } from "../door/gibs.js";
|
|
24
24
|
import { folderSource } from "../door/map.js";
|
|
25
25
|
import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
|
|
26
26
|
import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
|
|
@@ -157,7 +157,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
157
157
|
* ```
|
|
158
158
|
*/
|
|
159
159
|
export class ChikyuSpace extends HTMLElement {
|
|
160
|
-
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, ...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", "ride-viewpoint"];
|
|
160
|
+
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, ...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"];
|
|
161
161
|
#model = newSpaceModel();
|
|
162
162
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
163
163
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -411,6 +411,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
411
411
|
attributeChangedCallback(name, _old, value) {
|
|
412
412
|
if (name === "ride-viewpoint")
|
|
413
413
|
this.#applyViewpoint();
|
|
414
|
+
else if (name === "ride-model-size")
|
|
415
|
+
this.#applyModelSize();
|
|
414
416
|
else if (name === "center")
|
|
415
417
|
this.centre = readCentre(value) ?? { lon: 0, lat: 0 };
|
|
416
418
|
else if (name === "time")
|
|
@@ -509,7 +511,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
509
511
|
this.#model.satellites.streakMax = readStreakMax(value);
|
|
510
512
|
this.#gate?.request();
|
|
511
513
|
}
|
|
512
|
-
else if (name === "tiles" || name === "tiles-finer" || name === "tiles-finer-layer" || name === "tiles-finer-date")
|
|
514
|
+
else if (name === "tiles" || name === "tiles-finer" || name === "tiles-finer-layer" || name === "tiles-finer-date" || name === "tiles-finer-timeout")
|
|
513
515
|
this.#gate?.request();
|
|
514
516
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
515
517
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
@@ -526,7 +528,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
526
528
|
return;
|
|
527
529
|
const count = this.#model.tiles?.stats.used[GIBS_ID] ?? 0;
|
|
528
530
|
const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
529
|
-
const
|
|
531
|
+
const finer = this.#finerHold.source((attr) => this.getAttribute(attr), false);
|
|
532
|
+
const text = count > 0 && finer ? finer.info.credit[lang] : "";
|
|
530
533
|
if (note.textContent !== text)
|
|
531
534
|
note.textContent = text;
|
|
532
535
|
if (note.lang !== lang)
|
|
@@ -871,6 +874,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
871
874
|
/** Tells the names of cities, then of countries, where the Earth is in the picture just drawn; the countries' names keep clear of the bodies', the places' and the cities'. */
|
|
872
875
|
#nameFrame(frame) {
|
|
873
876
|
this.#lastNameFrame = frame;
|
|
877
|
+
this.#tellModel();
|
|
874
878
|
this.#relayNames(true, false);
|
|
875
879
|
}
|
|
876
880
|
/**
|
|
@@ -921,9 +925,28 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
921
925
|
const frame = this.#lastNameFrame;
|
|
922
926
|
countries.frame(frame, countries.stats.on && frame ? [...this.#bodyNameBoxes(), ...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...(this.#seas?.boxes ?? [])] : []);
|
|
923
927
|
}
|
|
924
|
-
/** The
|
|
928
|
+
/** The box of the ridden satellite's model as last told to the page (`chikyu-ride-model`), or null when none was told or it has gone. */
|
|
929
|
+
#toldModel = null;
|
|
930
|
+
/**
|
|
931
|
+
* Tells the page where the ridden satellite's model is, when that has changed by more than a pixel (or it has come or gone): `chikyu-ride-model` with `detail: { box, radiusPx, x, y }` (CSS pixels from the element's top left; `box` is `null` when no model is drawn),
|
|
932
|
+
* so a page can keep its own labels clear of it as the package keeps its own names clear. Nothing is sent while the box stands still, so a view at rest sends nothing.
|
|
933
|
+
*/
|
|
934
|
+
#tellModel() {
|
|
935
|
+
const now = this.#model.followModel;
|
|
936
|
+
const was = this.#toldModel;
|
|
937
|
+
const box = now ? now.box : null;
|
|
938
|
+
const moved = box === null || was === null ? box !== was : Math.abs(box.left - was.left) > 1 || Math.abs(box.top - was.top) > 1 || Math.abs(box.right - was.right) > 1 || Math.abs(box.bottom - was.bottom) > 1;
|
|
939
|
+
if (!moved)
|
|
940
|
+
return;
|
|
941
|
+
this.#toldModel = box ? { ...box } : null;
|
|
942
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride-model", { detail: { box, radiusPx: now?.radiusPx ?? 0, x: now?.x ?? 0, y: now?.y ?? 0 } }));
|
|
943
|
+
}
|
|
944
|
+
/** The boxes the bodies' names take beside them in the picture just drawn, and the box of the ridden satellite's model, which is nearer than anything on the ground and so keeps the names clear of it. */
|
|
925
945
|
#bodyNameBoxes() {
|
|
926
946
|
const taken = [];
|
|
947
|
+
const modelBox = this.#model.followModel?.box;
|
|
948
|
+
if (modelBox)
|
|
949
|
+
taken.push({ left: modelBox.left, top: modelBox.top, width: modelBox.right - modelBox.left, height: modelBox.bottom - modelBox.top });
|
|
927
950
|
if (this.#model.labels && this.#places) {
|
|
928
951
|
for (const name of BODY_NAMES) {
|
|
929
952
|
const at = this.#places[name];
|
|
@@ -1252,7 +1275,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1252
1275
|
// 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
|
|
1253
1276
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1254
1277
|
const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
|
|
1255
|
-
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 };
|
|
1278
|
+
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 };
|
|
1256
1279
|
if (face) {
|
|
1257
1280
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1258
1281
|
model.rideTurn = 0;
|
|
@@ -1395,6 +1418,34 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1395
1418
|
set rideViewpoint(value) {
|
|
1396
1419
|
this.setAttribute("ride-viewpoint", value === "inside" ? "inside" : "outside");
|
|
1397
1420
|
}
|
|
1421
|
+
/**
|
|
1422
|
+
* How the model of a satellite seen from above is sized as the camera rises: `distance` (the default; the attribute `ride-model-size`) lets it shrink with the height and hand over to the ordinary mark (ring and name) between 1,000 and 2,000 km, `fixed` keeps the same share of the picture at every height, as 0.46.1 did.
|
|
1423
|
+
* It is the default for the next `ride` and, set while riding, changes the one ridden at the next draw. See `RideOptions.modelSize`.
|
|
1424
|
+
*
|
|
1425
|
+
* @example
|
|
1426
|
+
* ```ts
|
|
1427
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1428
|
+
*
|
|
1429
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1430
|
+
* space.rideModelSize = "fixed";
|
|
1431
|
+
* console.log(space.rideModelSize);
|
|
1432
|
+
* ```
|
|
1433
|
+
*/
|
|
1434
|
+
get rideModelSize() {
|
|
1435
|
+
return this.getAttribute("ride-model-size") === "fixed" ? "fixed" : "distance";
|
|
1436
|
+
}
|
|
1437
|
+
set rideModelSize(value) {
|
|
1438
|
+
this.setAttribute("ride-model-size", value === "fixed" ? "fixed" : "distance");
|
|
1439
|
+
}
|
|
1440
|
+
#applyModelSize() {
|
|
1441
|
+
const ride = this.#model.ride;
|
|
1442
|
+
const next = this.rideModelSize;
|
|
1443
|
+
if (!ride || ride.modelSize === next)
|
|
1444
|
+
return;
|
|
1445
|
+
this.#model.ride = { ...ride, modelSize: next };
|
|
1446
|
+
this.#gate?.request();
|
|
1447
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1448
|
+
}
|
|
1398
1449
|
#applyViewpoint() {
|
|
1399
1450
|
const model = this.#model;
|
|
1400
1451
|
const ride = model.ride;
|
|
@@ -1672,9 +1723,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1672
1723
|
#showMarks(marks) {
|
|
1673
1724
|
if (marks.length > 0)
|
|
1674
1725
|
this.#prepareSatLabelLang();
|
|
1675
|
-
// a satellite
|
|
1676
|
-
const
|
|
1677
|
-
const ridden = ride && ride.viewpoint === "outside" && typeof ride.target !== "string" ? ride.target : null;
|
|
1726
|
+
// a satellite whose model is drawn (a ride from outside, while the model is big enough to read) has no ring and name on it: they would cover the model; they come back when it hands over to the mark (MODULES-1303, 1306)
|
|
1727
|
+
const ridden = this.#model.satellites.modelOver;
|
|
1678
1728
|
if (ridden)
|
|
1679
1729
|
marks = marks.filter((m) => !(m.ref.group === ridden.group && m.ref.index === ridden.index));
|
|
1680
1730
|
this.#marks = marks.map((m) => ({ id: `${m.ref.group}:${m.ref.index}`, label: this.#satelliteName(m.ref), x: m.x, y: m.y, visible: m.visible }));
|
|
@@ -1788,7 +1838,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1788
1838
|
let epochMs = 0;
|
|
1789
1839
|
for (const group of this.#model.satellites.groups.values())
|
|
1790
1840
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1791
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
|
|
1841
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing };
|
|
1792
1842
|
}
|
|
1793
1843
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
1794
1844
|
#readSpeed() {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type * as THREE from "three";
|
|
2
2
|
import type { BodyDrawing } from "./scene.ts";
|
|
3
3
|
/**
|
|
4
|
-
* What a generic drawing shows: `bus` a box with two solar panels, `communications` the same with a dish on its nadir face, `flat` a flat
|
|
4
|
+
* What a generic drawing shows: `bus` a box with two framed solar panels, `communications` the same with a dish on its nadir face, `flat` a flat body with one long framed panel (the shape of a large constellation's satellites), `station` a row of modules with a truss and panels, `cubesat` a slim box (a 3U, three times as long as it is wide) with short deployed panels.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
8
|
* import type { SatelliteKind } from "@johnmorrisdotca/chikyu-earth/space";
|
|
9
9
|
*
|
|
10
|
-
* const kinds: SatelliteKind[] = ["bus", "communications", "flat", "station"];
|
|
10
|
+
* const kinds: SatelliteKind[] = ["bus", "communications", "flat", "station", "cubesat"];
|
|
11
11
|
* console.log(kinds.length);
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export type SatelliteKind = "bus" | "communications" | "flat" | "station";
|
|
14
|
+
export type SatelliteKind = "bus" | "communications" | "flat" | "station" | "cubesat";
|
|
15
15
|
/**
|
|
16
|
-
* Which kind of drawing a satellite gets, from its name: a large constellation (`STARLINK`, `ONEWEB`, `KUIPER`) is `flat`, a station (`ISS`, `ZARYA`, `TIANGONG`, `CSS`) is `station`, a communications satellite (by the common operators' names) has a dish, and anything else is a plain `bus`.
|
|
16
|
+
* Which kind of drawing a satellite gets, from its name: a large constellation (`STARLINK`, `ONEWEB`, `KUIPER`) is `flat`, a cubesat (`FLOCK`, `DOVE`, `LEMUR`, `SPIRE` and similar names) is `cubesat`, a station (`ISS`, `ZARYA`, `TIANGONG`, `CSS`) is `station`, a communications satellite (by the common operators' names) has a dish, and anything else is a plain `bus`.
|
|
17
17
|
*
|
|
18
18
|
* @param name - The satellite's name (the element set's `OBJECT_NAME`).
|
|
19
19
|
* @returns The kind.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const COMMS = /(INTELSAT|SES-|EUTELSAT|ASTRA|ECHOSTAR|DIRECTV|TELSTAR|GALAXY|YAMAL|THURAYA|INMARSAT|IRIDIUM|GLOBALSTAR|ORBCOMM|TDRS|VIASAT|ANIK|SKYNET|MILSTAR|SAT-|SATCOM|COMSAT|OPTUS|JCSAT|SUPERBIRD|HISPASAT|ARABSAT|NILESAT|TURKSAT|KOREASAT|ASIASAT|APSTAR|EXPRESS|BADR)/i;
|
|
2
2
|
/**
|
|
3
|
-
* Which kind of drawing a satellite gets, from its name: a large constellation (`STARLINK`, `ONEWEB`, `KUIPER`) is `flat`, a station (`ISS`, `ZARYA`, `TIANGONG`, `CSS`) is `station`, a communications satellite (by the common operators' names) has a dish, and anything else is a plain `bus`.
|
|
3
|
+
* Which kind of drawing a satellite gets, from its name: a large constellation (`STARLINK`, `ONEWEB`, `KUIPER`) is `flat`, a cubesat (`FLOCK`, `DOVE`, `LEMUR`, `SPIRE` and similar names) is `cubesat`, a station (`ISS`, `ZARYA`, `TIANGONG`, `CSS`) is `station`, a communications satellite (by the common operators' names) has a dish, and anything else is a plain `bus`.
|
|
4
4
|
*
|
|
5
5
|
* @param name - The satellite's name (the element set's `OBJECT_NAME`).
|
|
6
6
|
* @returns The kind.
|
|
@@ -15,6 +15,8 @@ const COMMS = /(INTELSAT|SES-|EUTELSAT|ASTRA|ECHOSTAR|DIRECTV|TELSTAR|GALAXY|YAM
|
|
|
15
15
|
export function satelliteKind(name) {
|
|
16
16
|
if (/^(STARLINK|ONEWEB|KUIPER)/i.test(name))
|
|
17
17
|
return "flat";
|
|
18
|
+
if (/^(FLOCK|DOVE|LEMUR|SPIRE|SWARM|CUBESAT|ARKYD|CP-?\d|AAUSAT|UNISAT|GOMX|GOMSPACE)|CUBESAT|\b3U\b/i.test(name))
|
|
19
|
+
return "cubesat";
|
|
18
20
|
if (/(ISS|ZARYA|TIANGONG|CSS|TIANHE|WENTIAN|MENGTIAN)/i.test(name))
|
|
19
21
|
return "station";
|
|
20
22
|
if (COMMS.test(name))
|
|
@@ -54,25 +56,63 @@ export function genericSatellite(three, kind) {
|
|
|
54
56
|
};
|
|
55
57
|
const box = (x, y, z) => new three.BoxGeometry(x, y, z);
|
|
56
58
|
const tube = (radius, length) => new three.CylinderGeometry(radius, radius, length, 16);
|
|
59
|
+
/**
|
|
60
|
+
* A thin solar panel with a frame: `w` across (along x) and `l` long (along y) with its middle at `y`; a light frame round a darker plate of cells, a hair apart, so it reads as a panel and not a slab. Every part lies in the panel's own box.
|
|
61
|
+
*/
|
|
62
|
+
const panel = (w, l, y, x = 0, z = 0) => {
|
|
63
|
+
const edge = 0.022;
|
|
64
|
+
const thick = 0.014;
|
|
65
|
+
add(box(w, l - 2 * edge, 0.008), 0x1d3d78, [x, y, z]);
|
|
66
|
+
add(box(w, edge, thick), 0xb4b9c2, [x, y - (l - edge) / 2, z]);
|
|
67
|
+
add(box(w, edge, thick), 0xb4b9c2, [x, y + (l - edge) / 2, z]);
|
|
68
|
+
add(box(edge, l, thick), 0xb4b9c2, [x - (w - edge) / 2, y, z]);
|
|
69
|
+
add(box(edge, l, thick), 0xb4b9c2, [x + (w - edge) / 2, y, z]);
|
|
70
|
+
};
|
|
57
71
|
if (kind === "flat") {
|
|
58
|
-
|
|
59
|
-
add(box(0.
|
|
72
|
+
// a flat-pack body (a few metres across, a few centimetres thick) with its one long array and a small antenna panel
|
|
73
|
+
add(box(0.52, 0.34, 0.04), 0xcfd3d9, [0, 0, 0]);
|
|
74
|
+
add(box(0.3, 0.2, 0.012), 0x8e939b, [0.04, 0, -0.026]);
|
|
75
|
+
add(box(0.05, 0.05, 0.05), 0x4a4f58, [-0.18, 0, 0.045]);
|
|
76
|
+
add(box(0.03, 0.2, 0.015), 0xb4b9c2, [0, 0.27, 0]);
|
|
77
|
+
panel(0.4, 0.6, 0.57);
|
|
60
78
|
}
|
|
61
79
|
else if (kind === "station") {
|
|
80
|
+
// a row of modules, the truss across them and two panels at each end of it
|
|
62
81
|
add(tube(0.07, 0.8), 0xd9dde3, [0, 0, 0], [0, 0, half]);
|
|
82
|
+
add(tube(0.05, 0.4), 0xc8ccd2, [0.1, 0, 0.09], [0, 0, half]);
|
|
63
83
|
add(box(0.05, 1.7, 0.05), 0xb7bcc4, [-0.2, 0, 0]);
|
|
64
|
-
for (const y of [-0.
|
|
65
|
-
|
|
84
|
+
for (const y of [-0.78, 0.78]) {
|
|
85
|
+
panel(0.22, 0.24, y, -0.27);
|
|
86
|
+
panel(0.22, 0.24, y, -0.05);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else if (kind === "cubesat") {
|
|
90
|
+
// a 3U: three times as long as it is wide, with a short panel deployed on each side
|
|
91
|
+
add(box(0.78, 0.26, 0.26), 0xbfc3ca, [0, 0, 0]);
|
|
92
|
+
add(box(0.8, 0.28, 0.02), 0x2a2d33, [0, 0, 0.14]);
|
|
93
|
+
add(box(0.02, 0.28, 0.28), 0x2a2d33, [0.4, 0, 0]);
|
|
94
|
+
add(box(0.2, 0.2, 0.02), 0x5a606b, [-0.1, 0, -0.14]);
|
|
95
|
+
for (const side of [-1, 1]) {
|
|
96
|
+
add(box(0.03, 0.12, 0.012), 0xb4b9c2, [0, side * 0.19, 0]);
|
|
97
|
+
panel(0.5, 0.34, side * 0.4);
|
|
98
|
+
}
|
|
66
99
|
}
|
|
67
100
|
else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
101
|
+
// a bus: a body with a pale radiator plate on its top face, a camera on its nadir face, two booms and two framed panels
|
|
102
|
+
add(box(0.46, 0.36, 0.36), 0xc9a24a, [0, 0, 0]);
|
|
103
|
+
add(box(0.44, 0.34, 0.012), 0xe2e4e8, [0, 0, 0.186]);
|
|
104
|
+
add(box(0.47, 0.37, 0.07), 0x8a6d2a, [0, 0, -0.1]);
|
|
105
|
+
add(tube(0.06, 0.1), 0x30343b, [0.1, 0, -0.24], [half, 0, 0]);
|
|
106
|
+
add(box(0.06, 0.06, 0.06), 0x4a4f58, [-0.16, 0, 0.21]);
|
|
107
|
+
for (const side of [-1, 1]) {
|
|
108
|
+
add(box(0.03, 0.2, 0.02), 0xb4b9c2, [0, side * 0.28, 0]);
|
|
109
|
+
panel(0.38, 0.54, side * 0.67);
|
|
72
110
|
}
|
|
73
111
|
if (kind === "communications") {
|
|
74
|
-
|
|
75
|
-
add(
|
|
112
|
+
// the dish on the nadir face, on a short mast, and a small horn beside it
|
|
113
|
+
add(tube(0.025, 0.14), 0xb4b9c2, [0, 0, -0.25], [half, 0, 0]);
|
|
114
|
+
add(new three.CylinderGeometry(0.24, 0.03, 0.09, 24), 0xe8eaee, [0, 0, -0.34], [half, 0, 0]);
|
|
115
|
+
add(box(0.06, 0.06, 0.1), 0xb4b9c2, [-0.2, 0, -0.26]);
|
|
76
116
|
}
|
|
77
117
|
}
|
|
78
118
|
const sun = new three.DirectionalLight(0xfff4e0, 3.2);
|
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 RideViewpoint } from "./ride.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";
|
|
5
5
|
export type { SatelliteScreen } from "./satellite-layer.ts";
|
|
6
|
-
export { aboveAxes, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.ts";
|
|
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/index.js
CHANGED
|
@@ -4,5 +4,5 @@ export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, orbitP
|
|
|
4
4
|
export { compress, MOON_COMPRESSED, placeAround, placeMoon, placeSun, RADIUS, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
5
5
|
export { fitDistance, plainPainter } from "./scene.js";
|
|
6
6
|
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
7
|
-
export { aboveAxes, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
7
|
+
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
8
8
|
export { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
package/dist/space/ride.d.ts
CHANGED
|
@@ -174,6 +174,18 @@ export interface RidePose {
|
|
|
174
174
|
* ```
|
|
175
175
|
*/
|
|
176
176
|
export type RideViewpoint = "outside" | "inside";
|
|
177
|
+
/**
|
|
178
|
+
* 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
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* import type { RideModelSize } from "@johnmorrisdotca/chikyu-earth/space";
|
|
183
|
+
*
|
|
184
|
+
* const sizes: RideModelSize[] = ["distance", "fixed"];
|
|
185
|
+
* console.log(sizes.join(" or "));
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export type RideModelSize = "distance" | "fixed";
|
|
177
189
|
/**
|
|
178
190
|
* How far an outside ride keeps the camera from the satellite, in kilometres. The satellite itself is a few metres across, so it is drawn far larger than life (a model about a fifth of the picture's height across): not to scale, and the page says so in its caption.
|
|
179
191
|
*
|
|
@@ -33,6 +33,8 @@ export interface SatelliteState {
|
|
|
33
33
|
* 0 draws the whole stretch one frame spans, however long that is.
|
|
34
34
|
*/
|
|
35
35
|
streakMax: number;
|
|
36
|
+
/** Set at each draw by the view: the satellite a ride shows as its model while the model is big enough to read. Its ring (the chosen marker) and name are left off while this is so; its orbit line stays. Clears with the ride, or when the model has handed over to the mark. */
|
|
37
|
+
modelOver: SatelliteRef | null;
|
|
36
38
|
drawn: {
|
|
37
39
|
placed: number;
|
|
38
40
|
segments: number;
|
|
@@ -47,6 +49,7 @@ export interface SatelliteState {
|
|
|
47
49
|
maxUpdateMs: number;
|
|
48
50
|
updates: number;
|
|
49
51
|
totalMs: number;
|
|
52
|
+
selectedRing: boolean;
|
|
50
53
|
};
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
@@ -54,7 +54,7 @@ export function longestStreak(segments, count, earthPx) {
|
|
|
54
54
|
}
|
|
55
55
|
return longest * earthPx;
|
|
56
56
|
}
|
|
57
|
-
export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, streakMax: DEFAULT_STREAK_MAX, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, longestStreakPx: 0, streakCapPx: 0, weight: 1, fade: 1, earthPx: 0, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0 } });
|
|
57
|
+
export const newSatelliteState = () => ({ groups: new Map(), selected: null, marked: new Set(), pinned: [], orbitTint: false, focus: null, modelOver: null, streakMax: DEFAULT_STREAK_MAX, drawn: { placed: 0, segments: 0, tooFast: false, dotScale: 1, longestStreakPx: 0, streakCapPx: 0, weight: 1, fade: 1, earthPx: 0, updateMs: 0, maxUpdateMs: 0, updates: 0, totalMs: 0, selectedRing: false } });
|
|
58
58
|
/** The most orbits a group may draw all at once, one line each. */
|
|
59
59
|
export const MAX_ORBIT_GROUP = 40;
|
|
60
60
|
const ORBIT_POINTS = 120;
|
|
@@ -425,7 +425,9 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
425
425
|
selectedPosition[1] = tmp[1];
|
|
426
426
|
selectedPosition[2] = tmp[2];
|
|
427
427
|
selectedGeometry.getAttribute("position").needsUpdate = true;
|
|
428
|
-
|
|
428
|
+
const over = state.modelOver !== null && state.modelOver.group === chosen.group && state.modelOver.index === chosen.index;
|
|
429
|
+
selectedPoints.visible = !over;
|
|
430
|
+
state.drawn.selectedRing = !over;
|
|
429
431
|
const key = `${chosen.group}:${chosen.index}`;
|
|
430
432
|
if (key !== selectedKey || (Math.abs(time - selectedAt) > ORBIT_REFRESH_GAME_MS && started - selectedWall > ORBIT_REFRESH_WALL_MS)) {
|
|
431
433
|
selectedKey = key;
|
|
@@ -439,6 +441,7 @@ export function createSatelliteLayer(three, scene, state, ratio) {
|
|
|
439
441
|
}
|
|
440
442
|
else {
|
|
441
443
|
selectedPoints.visible = false;
|
|
444
|
+
state.drawn.selectedRing = false;
|
|
442
445
|
selectedLoop.visible = false;
|
|
443
446
|
selectedKey = "";
|
|
444
447
|
}
|
|
@@ -92,3 +92,75 @@ export declare function modelMatrix(place: Vec3, axes: {
|
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
export declare function modelRadius(away: number, half: number, share: number, real: number): number;
|
|
95
|
+
/**
|
|
96
|
+
* The lowest height of a ride above a satellite, in kilometres: the model keeps its full size from here down (MODULES-1306).
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { ABOVE_MODEL_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
101
|
+
*
|
|
102
|
+
* console.log(ABOVE_MODEL_KM);
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare const ABOVE_MODEL_KM = 150;
|
|
106
|
+
/**
|
|
107
|
+
* The share of the view's height the model's radius takes at the lowest height of a ride above a satellite (0.17): the size every page has seen since 0.46.1, and the size `ride-model-size="fixed"` keeps at every height.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* import { ABOVE_MODEL_SHARE } from "@johnmorrisdotca/chikyu-earth/space";
|
|
112
|
+
*
|
|
113
|
+
* console.log(ABOVE_MODEL_SHARE);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare const ABOVE_MODEL_SHARE = 0.17;
|
|
117
|
+
/**
|
|
118
|
+
* The height, in kilometres, from which the model is let shrink to nothing: below it the model follows one over the height, from it a smooth step takes the model down to nothing at `MODEL_FADE_TO_KM`.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { MODEL_FADE_FROM_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
123
|
+
*
|
|
124
|
+
* console.log(MODEL_FADE_FROM_KM);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare const MODEL_FADE_FROM_KM = 1000;
|
|
128
|
+
/**
|
|
129
|
+
* The height, in kilometres, by which the model has shrunk to nothing and the satellite is its ordinary mark (ring and name) again.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* import { MODEL_FADE_TO_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
134
|
+
*
|
|
135
|
+
* console.log(MODEL_FADE_TO_KM);
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const MODEL_FADE_TO_KM = 2000;
|
|
139
|
+
/**
|
|
140
|
+
* The model's drawn radius, in CSS pixels, below which the satellite's ring and name come back (the ring is about this big, so the two are not drawn over each other).
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import { MODEL_HANDOVER_PX } from "@johnmorrisdotca/chikyu-earth/space";
|
|
145
|
+
*
|
|
146
|
+
* console.log(MODEL_HANDOVER_PX);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export declare const MODEL_HANDOVER_PX = 10;
|
|
150
|
+
/**
|
|
151
|
+
* The share of the view's height that a model's radius takes when the camera is `distanceKm` above the satellite (a ride above it). A satellite is a few metres across, so the model is drawn larger than it is, but a
|
|
152
|
+
* model that stays a share of the picture at any height becomes a block thousands of kilometres across from far up. So the model keeps a fixed size in the world, about 16 km in radius, which is the share `ABOVE_MODEL_SHARE`
|
|
153
|
+
* at `ABOVE_MODEL_KM`: it is never larger than that, falls as one over the height above it, and from `MODEL_FADE_FROM_KM` is let down smoothly (a smooth step) to nothing at `MODEL_FADE_TO_KM`, where the satellite is its ordinary mark.
|
|
154
|
+
* Pure, so a test can ask it at any height.
|
|
155
|
+
*
|
|
156
|
+
* @param distanceKm - The camera's distance from the satellite, in kilometres.
|
|
157
|
+
* @returns The share, from 0 to 0.17.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* import { aboveModelShare } from "@johnmorrisdotca/chikyu-earth/space";
|
|
162
|
+
*
|
|
163
|
+
* console.log(aboveModelShare(150), aboveModelShare(1000) < aboveModelShare(150), aboveModelShare(6000));
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export declare function aboveModelShare(distanceKm: number): number;
|
|
@@ -118,3 +118,81 @@ export function modelMatrix(place, axes, scale) {
|
|
|
118
118
|
export function modelRadius(away, half, share, real) {
|
|
119
119
|
return Math.max(real, away * half * share * 2);
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* The lowest height of a ride above a satellite, in kilometres: the model keeps its full size from here down (MODULES-1306).
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { ABOVE_MODEL_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
127
|
+
*
|
|
128
|
+
* console.log(ABOVE_MODEL_KM);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export const ABOVE_MODEL_KM = 150;
|
|
132
|
+
/**
|
|
133
|
+
* The share of the view's height the model's radius takes at the lowest height of a ride above a satellite (0.17): the size every page has seen since 0.46.1, and the size `ride-model-size="fixed"` keeps at every height.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* import { ABOVE_MODEL_SHARE } from "@johnmorrisdotca/chikyu-earth/space";
|
|
138
|
+
*
|
|
139
|
+
* console.log(ABOVE_MODEL_SHARE);
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export const ABOVE_MODEL_SHARE = 0.17;
|
|
143
|
+
/**
|
|
144
|
+
* The height, in kilometres, from which the model is let shrink to nothing: below it the model follows one over the height, from it a smooth step takes the model down to nothing at `MODEL_FADE_TO_KM`.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* import { MODEL_FADE_FROM_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
149
|
+
*
|
|
150
|
+
* console.log(MODEL_FADE_FROM_KM);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export const MODEL_FADE_FROM_KM = 1000;
|
|
154
|
+
/**
|
|
155
|
+
* The height, in kilometres, by which the model has shrunk to nothing and the satellite is its ordinary mark (ring and name) again.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* import { MODEL_FADE_TO_KM } from "@johnmorrisdotca/chikyu-earth/space";
|
|
160
|
+
*
|
|
161
|
+
* console.log(MODEL_FADE_TO_KM);
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
export const MODEL_FADE_TO_KM = 2000;
|
|
165
|
+
/**
|
|
166
|
+
* The model's drawn radius, in CSS pixels, below which the satellite's ring and name come back (the ring is about this big, so the two are not drawn over each other).
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import { MODEL_HANDOVER_PX } from "@johnmorrisdotca/chikyu-earth/space";
|
|
171
|
+
*
|
|
172
|
+
* console.log(MODEL_HANDOVER_PX);
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export const MODEL_HANDOVER_PX = 10;
|
|
176
|
+
/**
|
|
177
|
+
* The share of the view's height that a model's radius takes when the camera is `distanceKm` above the satellite (a ride above it). A satellite is a few metres across, so the model is drawn larger than it is, but a
|
|
178
|
+
* model that stays a share of the picture at any height becomes a block thousands of kilometres across from far up. So the model keeps a fixed size in the world, about 16 km in radius, which is the share `ABOVE_MODEL_SHARE`
|
|
179
|
+
* at `ABOVE_MODEL_KM`: it is never larger than that, falls as one over the height above it, and from `MODEL_FADE_FROM_KM` is let down smoothly (a smooth step) to nothing at `MODEL_FADE_TO_KM`, where the satellite is its ordinary mark.
|
|
180
|
+
* Pure, so a test can ask it at any height.
|
|
181
|
+
*
|
|
182
|
+
* @param distanceKm - The camera's distance from the satellite, in kilometres.
|
|
183
|
+
* @returns The share, from 0 to 0.17.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* import { aboveModelShare } from "@johnmorrisdotca/chikyu-earth/space";
|
|
188
|
+
*
|
|
189
|
+
* console.log(aboveModelShare(150), aboveModelShare(1000) < aboveModelShare(150), aboveModelShare(6000));
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export function aboveModelShare(distanceKm) {
|
|
193
|
+
if (!(distanceKm > 0))
|
|
194
|
+
return ABOVE_MODEL_SHARE;
|
|
195
|
+
const base = ABOVE_MODEL_SHARE * Math.min(1, ABOVE_MODEL_KM / distanceKm);
|
|
196
|
+
const t = Math.min(1, Math.max(0, (distanceKm - MODEL_FADE_FROM_KM) / (MODEL_FADE_TO_KM - MODEL_FADE_FROM_KM)));
|
|
197
|
+
return base * (1 - t * t * (3 - 2 * t));
|
|
198
|
+
}
|
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 RideViewpoint } from "./ride.ts";
|
|
10
|
+
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
11
11
|
import type { SkyFrame } from "../sky/frame.ts";
|
|
12
12
|
import type { PlaceView } from "../markers/places.ts";
|
|
13
13
|
import { type PlaceSpriteData } from "../markers/place-sprites.ts";
|
|
@@ -109,6 +109,8 @@ export interface RideState {
|
|
|
109
109
|
distanceKm: number;
|
|
110
110
|
/** `outside`: a ridden satellite is in the picture (the camera a little behind and above it in `from`, a drawing of it where the page has no model); `inside`: as a ride was before, the camera at the satellite and no drawing of it where the page has no model. */
|
|
111
111
|
viewpoint: RideViewpoint;
|
|
112
|
+
/** 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. */
|
|
113
|
+
modelSize: RideModelSize;
|
|
112
114
|
}
|
|
113
115
|
/** The camera as the last draw left it, for the next one to start from when the ride changes. */
|
|
114
116
|
export interface Pose {
|
package/dist/space/scene.js
CHANGED
|
@@ -9,7 +9,7 @@ import { faceOffset, outsidePose, ridePose } from "./ride.js";
|
|
|
9
9
|
import { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
10
10
|
import { coverBody, covers } from "../sky/cover.js";
|
|
11
11
|
import { beginPlaceSprites, createPlaceSprites } from "../markers/place-sprites.js";
|
|
12
|
-
import { aboveAxes, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
12
|
+
import { ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
13
13
|
import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
|
|
14
14
|
import { paintMinute } from "../paint/buffer.js";
|
|
15
15
|
import { createPaintTexture } from "../paint/texture.js";
|
|
@@ -512,6 +512,18 @@ export function createSpaceItem(model, deps) {
|
|
|
512
512
|
deps.onSatellitesError?.(error);
|
|
513
513
|
}
|
|
514
514
|
}
|
|
515
|
+
// the ridden satellite is drawn as its model while the model is big enough to read; its ring and name (the page's choice of it, or the marks) are left off exactly then, and come back when the model has shrunk to the size of a ring (MODULES-1303, 1306)
|
|
516
|
+
{
|
|
517
|
+
const riding = model.ride;
|
|
518
|
+
let over = null;
|
|
519
|
+
if (riding && riding.viewpoint === "outside" && typeof riding.target !== "string") {
|
|
520
|
+
const kmAbove = riding.distanceKm / Math.max(1e-9, model.view.zoom);
|
|
521
|
+
const would = riding.view === "above" ? (riding.modelSize === "fixed" ? ABOVE_MODEL_SHARE : aboveModelShare(kmAbove)) : riding.view === "from" ? (riding.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE) : MODEL_RADIUS_SHARE;
|
|
522
|
+
if (would * size.height >= MODEL_HANDOVER_PX)
|
|
523
|
+
over = riding.target;
|
|
524
|
+
}
|
|
525
|
+
model.satellites.modelOver = over;
|
|
526
|
+
}
|
|
515
527
|
layer?.update(model.time, model.speed, model.drawn?.radiusPx ?? 0);
|
|
516
528
|
model.pick = layer ? (x, y, radius) => layer.pick(x, y, camera, size, radius) : null;
|
|
517
529
|
// the camera: looks at the focus body from the direction the sky was in when it was last moved, turned by yaw and tilt, as far as the zoom says; or, riding along, sits at the
|
|
@@ -824,10 +836,12 @@ export function createSpaceItem(model, deps) {
|
|
|
824
836
|
const axes = freshAxes ?? (shownSat ? modelSlot.axes : null);
|
|
825
837
|
// a generic drawing is for an outside ride only; a page's model is drawn wherever the camera is not at the satellite
|
|
826
838
|
const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (followed !== null && painted));
|
|
827
|
-
|
|
839
|
+
const aboveShare = followed && ride?.view === "above" && ride.modelSize !== "fixed" ? aboveModelShare(Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z) * 6371) : 1;
|
|
840
|
+
// from far above the satellite is a point: the model has shrunk to nothing and the ordinary mark is all there is
|
|
841
|
+
if (modelSlot.drawing && shownSat && axes && drawn && aboveShare * size.height >= 0.5) {
|
|
828
842
|
const object = modelSlot.drawing.object;
|
|
829
843
|
const away = Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z);
|
|
830
|
-
const share = followed ? MODEL_RADIUS_SHARE : ride?.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE;
|
|
844
|
+
const share = followed ? (ride?.view === "above" ? (ride.modelSize === "fixed" ? ABOVE_MODEL_SHARE : aboveModelShare(away * 6371)) : MODEL_RADIUS_SHARE) : ride?.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE;
|
|
831
845
|
object.matrix.set(...modelMatrix(shownSat.place, axes, modelRadius(away, half, share, 1e-9)));
|
|
832
846
|
object.matrixWorldNeedsUpdate = true;
|
|
833
847
|
object.visible = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.5",
|
|
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",
|