@johnmorrisdotca/chikyu-earth 0.46.4 → 0.46.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +3 -2
- package/dist/beam/geometry.d.ts +131 -0
- package/dist/beam/geometry.js +141 -0
- package/dist/beam/layer.d.ts +47 -0
- package/dist/beam/layer.js +308 -0
- package/dist/realistic/element-base.d.ts +1 -0
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.d.ts +60 -1
- package/dist/space/element-base.js +132 -7
- package/dist/space/generic-satellite.d.ts +4 -4
- package/dist/space/generic-satellite.js +51 -11
- package/dist/space/index.d.ts +4 -2
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +12 -0
- package/dist/space/satellite-layer.d.ts +3 -0
- package/dist/space/satellite-layer.js +5 -2
- package/dist/space/satellite-model.d.ts +72 -0
- package/dist/space/satellite-model.js +78 -0
- package/dist/space/scene.d.ts +6 -1
- package/dist/space/scene.js +36 -3
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ import { BORDER_ATTRIBUTES, readBorders } from "../borders/lines.js";
|
|
|
15
15
|
import { GRID_ATTRIBUTES, readGrid } from "../grid/lines.js";
|
|
16
16
|
import { readRoute, routeLeg, routeText } from "../route.js";
|
|
17
17
|
import { applyRoute } from "../route/layer.js";
|
|
18
|
+
import { BEAM_ATTRIBUTES, readBeam } from "../beam/geometry.js";
|
|
18
19
|
import { COUNTRY_NAMES_ATTRIBUTES } from "../country-names/geometry.js";
|
|
19
20
|
import { COUNTRY_NAMES_STYLE, createCountryHost } from "../country-names/host.js";
|
|
20
21
|
import { SEA_NAMES_ATTRIBUTES, readSeaNames } from "../sea-names/geometry.js";
|
|
@@ -131,6 +132,9 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
131
132
|
* `borders` draws the borders on the Earth's land as thin lines that turn with it, as on `<chikyu-earth-realistic>`: `countries`, `regions` (from the page's `borderData.regions`, once the Earth is
|
|
132
133
|
* large enough), or both with a bare attribute; `chikyu-borders-unavailable` is sent when the shapes cannot be loaded.
|
|
133
134
|
*
|
|
135
|
+
* `beam` draws a beam of light from the chosen satellite (the one marked, or the one ridden) down to the ground below it: a soft cone ending in a lit footprint, the circle from which the satellite is above
|
|
136
|
+
* `beam-elevation` degrees (25), with `beam-cells` spot cells inside it (an illustration, never an operator's plan), `beam-cell-size`, `beam-color` and `beam-strength` (the property `beam` and its siblings, and `stats.beam`).
|
|
137
|
+
*
|
|
134
138
|
* `grid` draws the meridians and parallels on the Earth, and `country-names` names its countries, as on `<chikyu-earth-realistic>`: the names keep clear of the bodies', the places' and the
|
|
135
139
|
* cities' names and stay on the Earth's disc; `chikyu-country-names-unavailable` is sent when the outlines cannot be loaded.
|
|
136
140
|
*
|
|
@@ -157,7 +161,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
157
161
|
* ```
|
|
158
162
|
*/
|
|
159
163
|
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"];
|
|
164
|
+
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, ...BEAM_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
165
|
#model = newSpaceModel();
|
|
162
166
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
163
167
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -283,6 +287,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
283
287
|
Object.assign(this.#model.borders, readBorders(this.getAttribute("borders")));
|
|
284
288
|
this.#model.borders.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-borders-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
|
|
285
289
|
this.#model.grid.on = readGrid(this.getAttribute("grid"));
|
|
290
|
+
this.#applyBeam();
|
|
291
|
+
this.#model.beam.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-beam-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
|
|
286
292
|
this.#model.grid.onError = (error) => this.dispatchEvent(new CustomEvent("chikyu-grid-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } }));
|
|
287
293
|
this.#countries = createCountryHost({
|
|
288
294
|
root,
|
|
@@ -411,6 +417,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
411
417
|
attributeChangedCallback(name, _old, value) {
|
|
412
418
|
if (name === "ride-viewpoint")
|
|
413
419
|
this.#applyViewpoint();
|
|
420
|
+
else if (name === "ride-model-size")
|
|
421
|
+
this.#applyModelSize();
|
|
414
422
|
else if (name === "center")
|
|
415
423
|
this.centre = readCentre(value) ?? { lon: 0, lat: 0 };
|
|
416
424
|
else if (name === "time")
|
|
@@ -499,6 +507,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
499
507
|
this.#model.grid.on = readGrid(value);
|
|
500
508
|
this.#gate?.request();
|
|
501
509
|
}
|
|
510
|
+
else if (BEAM_ATTRIBUTES.includes(name)) {
|
|
511
|
+
this.#applyBeam();
|
|
512
|
+
this.#gate?.request();
|
|
513
|
+
}
|
|
502
514
|
else if (COUNTRY_NAMES_ATTRIBUTES.includes(name))
|
|
503
515
|
this.#countries?.refresh();
|
|
504
516
|
else if (name === "satellite-tint") {
|
|
@@ -872,6 +884,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
872
884
|
/** 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
885
|
#nameFrame(frame) {
|
|
874
886
|
this.#lastNameFrame = frame;
|
|
887
|
+
this.#tellModel();
|
|
875
888
|
this.#relayNames(true, false);
|
|
876
889
|
}
|
|
877
890
|
/**
|
|
@@ -922,9 +935,28 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
922
935
|
const frame = this.#lastNameFrame;
|
|
923
936
|
countries.frame(frame, countries.stats.on && frame ? [...this.#bodyNameBoxes(), ...(this.#placeLayer?.boxes ?? []), ...(this.#cities?.boxes ?? []), ...(this.#seas?.boxes ?? [])] : []);
|
|
924
937
|
}
|
|
925
|
-
/** The
|
|
938
|
+
/** 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. */
|
|
939
|
+
#toldModel = null;
|
|
940
|
+
/**
|
|
941
|
+
* 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),
|
|
942
|
+
* 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.
|
|
943
|
+
*/
|
|
944
|
+
#tellModel() {
|
|
945
|
+
const now = this.#model.followModel;
|
|
946
|
+
const was = this.#toldModel;
|
|
947
|
+
const box = now ? now.box : null;
|
|
948
|
+
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;
|
|
949
|
+
if (!moved)
|
|
950
|
+
return;
|
|
951
|
+
this.#toldModel = box ? { ...box } : null;
|
|
952
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride-model", { detail: { box, radiusPx: now?.radiusPx ?? 0, x: now?.x ?? 0, y: now?.y ?? 0 } }));
|
|
953
|
+
}
|
|
954
|
+
/** 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
955
|
#bodyNameBoxes() {
|
|
927
956
|
const taken = [];
|
|
957
|
+
const modelBox = this.#model.followModel?.box;
|
|
958
|
+
if (modelBox)
|
|
959
|
+
taken.push({ left: modelBox.left, top: modelBox.top, width: modelBox.right - modelBox.left, height: modelBox.bottom - modelBox.top });
|
|
928
960
|
if (this.#model.labels && this.#places) {
|
|
929
961
|
for (const name of BODY_NAMES) {
|
|
930
962
|
const at = this.#places[name];
|
|
@@ -954,6 +986,71 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
954
986
|
this.#citiesStyle = { ...value };
|
|
955
987
|
this.#cities?.setStyle(this.#citiesStyle);
|
|
956
988
|
}
|
|
989
|
+
/** Read the beam's attributes into the model. */
|
|
990
|
+
#applyBeam() {
|
|
991
|
+
const { on, elevation, cells, cellSize, colour, strength } = readBeam((name) => this.getAttribute(name));
|
|
992
|
+
Object.assign(this.#model.beam, { on, elevation, cells, cellSize, colour, strength });
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Whether a beam of light is drawn from the chosen satellite down to the ground below it (the attribute `beam`, off unless set). The chosen satellite is the one marked with `selectSatellite` or a press,
|
|
996
|
+
* or the one ridden (Ride along and Ride above, where the camera looks down the beam). The beam is a soft cone, brighter at the satellite and fading towards the ground, ending in a lit ring on the
|
|
997
|
+
* surface: the footprint, the circle from which the satellite stands above `beamElevation` degrees (25), true to its height. Behind the Earth it is cut off by the limb. It is drawn with the draw that
|
|
998
|
+
* moves the satellite, and nothing is drawn at rest. Setting it writes the attribute, or takes it away; `stats.beam` says the footprint's radius in kilometres.
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
* ```ts no-run
|
|
1002
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1003
|
+
*
|
|
1004
|
+
* const space = document.querySelector<ChikyuSpace>("chikyu-space")!;
|
|
1005
|
+
* space.beam = true;
|
|
1006
|
+
* space.beamElevation = 30;
|
|
1007
|
+
* console.log(space.stats.beam.radiusKm);
|
|
1008
|
+
* ```
|
|
1009
|
+
*/
|
|
1010
|
+
get beam() {
|
|
1011
|
+
return readBeam((name) => this.getAttribute(name)).on;
|
|
1012
|
+
}
|
|
1013
|
+
set beam(value) {
|
|
1014
|
+
if (value)
|
|
1015
|
+
this.setAttribute("beam", "selected");
|
|
1016
|
+
else
|
|
1017
|
+
this.removeAttribute("beam");
|
|
1018
|
+
}
|
|
1019
|
+
/** The least elevation, in degrees, from which the footprint counts the satellite as seen (the attribute `beam-elevation`, 25). Setting it writes the attribute. */
|
|
1020
|
+
get beamElevation() {
|
|
1021
|
+
return readBeam((name) => this.getAttribute(name)).elevation;
|
|
1022
|
+
}
|
|
1023
|
+
set beamElevation(value) {
|
|
1024
|
+
this.setAttribute("beam-elevation", String(value));
|
|
1025
|
+
}
|
|
1026
|
+
/** How many spot cells are drawn inside the footprint, 0 for none (the attribute `beam-cells`, up to 91). They are an illustration of a satellite that serves the ground in cells, not any operator's plan. */
|
|
1027
|
+
get beamCells() {
|
|
1028
|
+
return readBeam((name) => this.getAttribute(name)).cells;
|
|
1029
|
+
}
|
|
1030
|
+
set beamCells(value) {
|
|
1031
|
+
this.setAttribute("beam-cells", String(value));
|
|
1032
|
+
}
|
|
1033
|
+
/** A spot cell's radius on the ground in kilometres, at most what fits (the attribute `beam-cell-size`, 0 for the fit). */
|
|
1034
|
+
get beamCellSize() {
|
|
1035
|
+
return readBeam((name) => this.getAttribute(name)).cellSize;
|
|
1036
|
+
}
|
|
1037
|
+
set beamCellSize(value) {
|
|
1038
|
+
this.setAttribute("beam-cell-size", String(value));
|
|
1039
|
+
}
|
|
1040
|
+
/** The beam's colour, any CSS colour (the attribute `beam-color`, a pale blue). */
|
|
1041
|
+
get beamColor() {
|
|
1042
|
+
return readBeam((name) => this.getAttribute(name)).colour;
|
|
1043
|
+
}
|
|
1044
|
+
set beamColor(value) {
|
|
1045
|
+
this.setAttribute("beam-color", value);
|
|
1046
|
+
}
|
|
1047
|
+
/** How strong the beam is, from 0 to 1 (the attribute `beam-strength`, 0.6). */
|
|
1048
|
+
get beamStrength() {
|
|
1049
|
+
return readBeam((name) => this.getAttribute(name)).strength;
|
|
1050
|
+
}
|
|
1051
|
+
set beamStrength(value) {
|
|
1052
|
+
this.setAttribute("beam-strength", String(value));
|
|
1053
|
+
}
|
|
957
1054
|
/** Whether the meridians and parallels are drawn on the Earth (the attribute `grid`). Setting it writes the attribute, or takes it away. */
|
|
958
1055
|
get grid() {
|
|
959
1056
|
return readGrid(this.getAttribute("grid"));
|
|
@@ -1253,7 +1350,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1253
1350
|
// 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
1351
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1255
1352
|
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 };
|
|
1353
|
+
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
1354
|
if (face) {
|
|
1258
1355
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1259
1356
|
model.rideTurn = 0;
|
|
@@ -1396,6 +1493,34 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1396
1493
|
set rideViewpoint(value) {
|
|
1397
1494
|
this.setAttribute("ride-viewpoint", value === "inside" ? "inside" : "outside");
|
|
1398
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* 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.
|
|
1498
|
+
* It is the default for the next `ride` and, set while riding, changes the one ridden at the next draw. See `RideOptions.modelSize`.
|
|
1499
|
+
*
|
|
1500
|
+
* @example
|
|
1501
|
+
* ```ts
|
|
1502
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1503
|
+
*
|
|
1504
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1505
|
+
* space.rideModelSize = "fixed";
|
|
1506
|
+
* console.log(space.rideModelSize);
|
|
1507
|
+
* ```
|
|
1508
|
+
*/
|
|
1509
|
+
get rideModelSize() {
|
|
1510
|
+
return this.getAttribute("ride-model-size") === "fixed" ? "fixed" : "distance";
|
|
1511
|
+
}
|
|
1512
|
+
set rideModelSize(value) {
|
|
1513
|
+
this.setAttribute("ride-model-size", value === "fixed" ? "fixed" : "distance");
|
|
1514
|
+
}
|
|
1515
|
+
#applyModelSize() {
|
|
1516
|
+
const ride = this.#model.ride;
|
|
1517
|
+
const next = this.rideModelSize;
|
|
1518
|
+
if (!ride || ride.modelSize === next)
|
|
1519
|
+
return;
|
|
1520
|
+
this.#model.ride = { ...ride, modelSize: next };
|
|
1521
|
+
this.#gate?.request();
|
|
1522
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1523
|
+
}
|
|
1399
1524
|
#applyViewpoint() {
|
|
1400
1525
|
const model = this.#model;
|
|
1401
1526
|
const ride = model.ride;
|
|
@@ -1673,9 +1798,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1673
1798
|
#showMarks(marks) {
|
|
1674
1799
|
if (marks.length > 0)
|
|
1675
1800
|
this.#prepareSatLabelLang();
|
|
1676
|
-
// a satellite
|
|
1677
|
-
const
|
|
1678
|
-
const ridden = ride && ride.viewpoint === "outside" && typeof ride.target !== "string" ? ride.target : null;
|
|
1801
|
+
// 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)
|
|
1802
|
+
const ridden = this.#model.satellites.modelOver;
|
|
1679
1803
|
if (ridden)
|
|
1680
1804
|
marks = marks.filter((m) => !(m.ref.group === ridden.group && m.ref.index === ridden.index));
|
|
1681
1805
|
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 }));
|
|
@@ -1771,6 +1895,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1771
1895
|
cityNames: this.#cities?.stats ?? { on: false, max: 0, radius: 0, tiers: [], cities: 0, names: 0, renders: 0 },
|
|
1772
1896
|
borders: { ...this.#model.borders.stats, shown: { ...this.#model.borders.stats.shown }, loaded: [...this.#model.borders.stats.loaded] },
|
|
1773
1897
|
grid: { ...this.#model.grid.stats },
|
|
1898
|
+
beam: { ...this.#model.beam.stats },
|
|
1774
1899
|
route: { ...this.#model.route.stats },
|
|
1775
1900
|
countryNames: this.#countries?.stats ?? { on: false, max: 0, countries: 0, names: 0, renders: 0, failed: false },
|
|
1776
1901
|
seaNames: this.#seas?.stats ?? { on: false, radius: 0, names: 0, renders: 0 },
|
|
@@ -1789,7 +1914,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1789
1914
|
let epochMs = 0;
|
|
1790
1915
|
for (const group of this.#model.satellites.groups.values())
|
|
1791
1916
|
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 };
|
|
1917
|
+
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
1918
|
}
|
|
1794
1919
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
1795
1920
|
#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,9 @@
|
|
|
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";
|
|
8
|
+
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam, type BeamCells, type BeamOptions } from "../beam/geometry.ts";
|
|
9
|
+
export type { BeamStats } from "../beam/layer.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -4,5 +4,6 @@ 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";
|
|
9
|
+
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam } from "../beam/geometry.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";
|
|
@@ -18,6 +18,7 @@ import { type BodyLabelState } from "../realistic/body-label.ts";
|
|
|
18
18
|
import { type MeteorState } from "../meteors/layer.ts";
|
|
19
19
|
import { type BorderState } from "../borders/layer.ts";
|
|
20
20
|
import { type GridState } from "../grid/layer.ts";
|
|
21
|
+
import { type BeamState } from "../beam/layer.ts";
|
|
21
22
|
import { type RouteState } from "../route/layer.ts";
|
|
22
23
|
type Three = ThreeParts;
|
|
23
24
|
/** How much of the view's shorter side the Earth's disc fills at zoom 1 when the page does not say: 0.9, so the atmosphere's glow (8% beyond the disc) is inside the view and never cut. */
|
|
@@ -109,6 +110,8 @@ export interface RideState {
|
|
|
109
110
|
distanceKm: number;
|
|
110
111
|
/** `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
112
|
viewpoint: RideViewpoint;
|
|
113
|
+
/** 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. */
|
|
114
|
+
modelSize: RideModelSize;
|
|
112
115
|
}
|
|
113
116
|
/** The camera as the last draw left it, for the next one to start from when the ride changes. */
|
|
114
117
|
export interface Pose {
|
|
@@ -188,6 +191,8 @@ export interface SpaceModel {
|
|
|
188
191
|
borders: BorderState;
|
|
189
192
|
/** The meridians and parallels on the Earth (src/grid/layer.ts): off unless the element switches them on. */
|
|
190
193
|
grid: GridState;
|
|
194
|
+
/** The beam of light from the chosen satellite to the ground below it (src/beam/layer.ts): off unless the element switches it on. */
|
|
195
|
+
beam: BeamState;
|
|
191
196
|
/** A route between two places, on the Earth (src/route/layer.ts): off unless the element sets it. */
|
|
192
197
|
route: RouteState;
|
|
193
198
|
/** The body or satellite the camera rides along with, or null. */
|