@johnmorrisdotca/chikyu-earth 0.46.4 → 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 +4 -0
- package/README.md +2 -2
- package/dist/realistic/element-base.d.ts +1 -0
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.d.ts +21 -1
- package/dist/space/element-base.js +56 -7
- 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,9 @@
|
|
|
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
|
+
|
|
3
7
|
## 0.46.4 - 2026-11-13
|
|
4
8
|
|
|
5
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.
|
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
|
|
|
@@ -1399,7 +1399,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1399
1399
|
let epochMs = 0;
|
|
1400
1400
|
for (const group of this.#model.satellites.groups.values())
|
|
1401
1401
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
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 };
|
|
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 };
|
|
1403
1403
|
}
|
|
1404
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.
|
|
1405
1405
|
#downX = 0;
|
|
@@ -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
|
/**
|
|
@@ -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", "tiles-finer-timeout", "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")
|
|
@@ -872,6 +874,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
872
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'. */
|
|
873
875
|
#nameFrame(frame) {
|
|
874
876
|
this.#lastNameFrame = frame;
|
|
877
|
+
this.#tellModel();
|
|
875
878
|
this.#relayNames(true, false);
|
|
876
879
|
}
|
|
877
880
|
/**
|
|
@@ -922,9 +925,28 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
922
925
|
const frame = this.#lastNameFrame;
|
|
923
926
|
countries.frame(frame, countries.stats.on && frame ? [...this.#bodyNameBoxes(), ...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...(this.#seas?.boxes ?? [])] : []);
|
|
924
927
|
}
|
|
925
|
-
/** 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. */
|
|
926
945
|
#bodyNameBoxes() {
|
|
927
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 });
|
|
928
950
|
if (this.#model.labels && this.#places) {
|
|
929
951
|
for (const name of BODY_NAMES) {
|
|
930
952
|
const at = this.#places[name];
|
|
@@ -1253,7 +1275,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1253
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
|
|
1254
1276
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1255
1277
|
const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
|
|
1256
|
-
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 };
|
|
1257
1279
|
if (face) {
|
|
1258
1280
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1259
1281
|
model.rideTurn = 0;
|
|
@@ -1396,6 +1418,34 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1396
1418
|
set rideViewpoint(value) {
|
|
1397
1419
|
this.setAttribute("ride-viewpoint", value === "inside" ? "inside" : "outside");
|
|
1398
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
|
+
}
|
|
1399
1449
|
#applyViewpoint() {
|
|
1400
1450
|
const model = this.#model;
|
|
1401
1451
|
const ride = model.ride;
|
|
@@ -1673,9 +1723,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1673
1723
|
#showMarks(marks) {
|
|
1674
1724
|
if (marks.length > 0)
|
|
1675
1725
|
this.#prepareSatLabelLang();
|
|
1676
|
-
// a satellite
|
|
1677
|
-
const
|
|
1678
|
-
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;
|
|
1679
1728
|
if (ridden)
|
|
1680
1729
|
marks = marks.filter((m) => !(m.ref.group === ridden.group && m.ref.index === ridden.index));
|
|
1681
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 }));
|
|
@@ -1789,7 +1838,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1789
1838
|
let epochMs = 0;
|
|
1790
1839
|
for (const group of this.#model.satellites.groups.values())
|
|
1791
1840
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1792
|
-
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 };
|
|
1793
1842
|
}
|
|
1794
1843
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
1795
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",
|