@johnmorrisdotca/chikyu-earth 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +1 -1
- package/dist/realistic/earth.d.ts +3 -0
- package/dist/realistic/earth.js +19 -3
- package/dist/realistic/element-base.d.ts +12 -0
- package/dist/realistic/element-base.js +22 -5
- package/dist/realistic/light-fade.d.ts +22 -0
- package/dist/realistic/light-fade.js +36 -0
- package/dist/satellites/catalogue.d.ts +1 -1
- package/dist/satellites/catalogue.js +5 -4
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/kana.d.ts +16 -0
- package/dist/satellites/kana.js +24 -0
- package/dist/space/element-base.d.ts +12 -0
- package/dist/space/element-base.js +22 -6
- package/dist/space/generic-satellite.d.ts +6 -1
- package/dist/space/generic-satellite.js +16 -4
- package/dist/space/model-lights.d.ts +14 -0
- package/dist/space/model-lights.js +19 -0
- package/dist/space/path-controls.d.ts +4 -1
- package/dist/space/path-controls.js +13 -6
- package/dist/space/scene.d.ts +3 -0
- package/dist/space/scene.js +33 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.50.0 - 2026-11-13
|
|
4
|
+
|
|
5
|
+
- **The catalogue search folds kana** (MODULES-1268). `findInCatalogue` folds hiragana to katakana and small kana to full-size on both sides of the comparison (and half-width katakana by NFKC), so `はっぶる` finds `ハッブル`, in satellite names and group labels; the long-vowel mark is left alone. `foldKana(text)` is the same fold, exported from `@johnmorrisdotca/chikyu-earth/satellites` for a page's own search box.
|
|
6
|
+
- **A painter's model no longer adds a program to every lit material** (MODULES-1293). The scene now owns one Sun light, always there, and a satellite model made by `setSatellitePainter` is lit by it: a light the model carries (directional, point, spot, hemisphere, area) is switched off when the model is added, and its colour and strength are worn by the scene's Sun while the model is shown (an ambient light is left). Before, a model with its own light changed the number of lights in the scene the first time a ride showed it, and three kept a second program of the same code for each lit material (the clouds, the plain bodies) until it was let go: one more program at the end of a long run than at the start. The ride-along guide says a painter must not add lights and what to do to keep its look. The soak's warm-up now rides the ISS outside until its model is drawn, runs a clock past the satellites' speed limit and shows the package's own drawing once.
|
|
7
|
+
- **A short cross-fade when `light` changes to or from `lit`.** The Earth's night lights, and in the realistic view the direction of its light, move between the two looks over 300 ms instead of cutting, in the frames of one loop that ends by itself (nothing is drawn at rest). A reader who asked for reduced motion gets the cut. `stats.lightFade` is `{ mix, fading }`.
|
|
8
|
+
- **`path-priority` says whether a dot or a path is heard first** (MODULES-1332). Where a satellite's dot and a path lie under the pointer, `dots` (the default, as before) is the dot's, which at the Low level, with thousands of dots crowding a line, can leave a path unheard. `path-priority="paths"` (the property `pathPriority`) hears a path of the page's before a dot, except a dot of a satellite whose path is listed or that is chosen or ridden, which still wins. Press and hover follow the same order, and one press still has one meaning. On both elements.
|
|
9
|
+
|
|
3
10
|
## 0.49.0 - 2026-11-13
|
|
4
11
|
|
|
5
12
|
- **Satellites far from today, as an estimate** (MODULES-1296). `estimate-far` (the property `estimateFar`, or `createSatellites(sets, { estimateFar: true })`; off by default) keeps placing a satellite beyond 30 days from its elements: the same elements carried forward or back by the same SGP4 code, drawn lighter than a dimmed one, with `estimated: true` and `estimatedDays` (how far the moment is from the elements', in days) in `placeSatellite`, `satelliteInfo` and the details of `chikyu-satellite-click` and `chikyu-satellite-visibility`, and `stats.satellites.estimated`. The docs say what an estimate is (where it would be had its orbit not changed) and where it is worst (low orbits, months away). Never before an element set's `LAUNCH_DATE` (else the year of its `OBJECT_ID`) or after its `DECAY_DATE`, both new optional fields that `parseElements` keeps; a satellite SGP4 cannot carry that far, or brings below about 120 km, is left out and not counted as placed.
|
package/README.md
CHANGED
|
@@ -612,7 +612,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
612
612
|
|
|
613
613
|
## How to cite
|
|
614
614
|
|
|
615
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.
|
|
615
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.50.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
616
616
|
|
|
617
617
|
GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
|
|
618
618
|
|
|
@@ -3,6 +3,7 @@ import type { AssetCache, Item3D } from "@johnmorrisdotca/kazoku-ui/renderer";
|
|
|
3
3
|
import type { GeoPoint, GlobeView } from "../types.ts";
|
|
4
4
|
import type { SatelliteRef } from "../satellites/types.ts";
|
|
5
5
|
import { lookAt } from "../view.ts";
|
|
6
|
+
import { type LightFade } from "./light-fade.ts";
|
|
6
7
|
import type { PathHit } from "../space/paths.ts";
|
|
7
8
|
import { type SatelliteScreen, type SatelliteState } from "../space/satellite-layer.ts";
|
|
8
9
|
import type { Layer } from "./tiers.ts";
|
|
@@ -65,6 +66,8 @@ export interface EarthModel {
|
|
|
65
66
|
lights: boolean;
|
|
66
67
|
/** How the Earth is lit (see `LightMode`). */
|
|
67
68
|
light: LightMode;
|
|
69
|
+
/** The cross-fade between the true light and `lit`, stepped at each draw (src/realistic/light-fade.ts). */
|
|
70
|
+
lightFade: LightFade;
|
|
68
71
|
/** How the camera is held (see `CameraMode`). */
|
|
69
72
|
camera: CameraMode;
|
|
70
73
|
/** How many times its real thickness the air is drawn, 1 to 5 (`AIR_THICKNESS_DEFAULT` until the element says otherwise); read at every draw. */
|
package/dist/realistic/earth.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { HOME_VIEW, lookAt } from "../view.js";
|
|
2
2
|
import { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_VERT, airFrag, airTop } from "./air.js";
|
|
3
3
|
import { CLOUD_FRAG, SURFACE_FRAG, SURFACE_VERT } from "./shaders.js";
|
|
4
|
+
import { newLightFade, stepLightFade } from "./light-fade.js";
|
|
5
|
+
import { prefersLessMotion } from "../meteors/note.js";
|
|
4
6
|
import { greenwichSidereal, subsolarPoint, unitVector } from "./sun.js";
|
|
5
7
|
import { createSatelliteLayer, newSatelliteState } from "../space/satellite-layer.js";
|
|
6
8
|
import { createTextureSet } from "./textures.js";
|
|
@@ -35,6 +37,7 @@ export const newModel = () => ({
|
|
|
35
37
|
clouds: true,
|
|
36
38
|
lights: true,
|
|
37
39
|
light: "sun",
|
|
40
|
+
lightFade: newLightFade(),
|
|
38
41
|
camera: "space",
|
|
39
42
|
airThickness: AIR_THICKNESS_DEFAULT,
|
|
40
43
|
cloudDrift: 0,
|
|
@@ -220,13 +223,26 @@ export function createEarthItem(model, deps) {
|
|
|
220
223
|
const [sx, sy, sz] = unitVector(subsolarPoint(model.time));
|
|
221
224
|
sunLocal.value.set(sx, sy, sz);
|
|
222
225
|
sunDir.value.set(sx, sy, sz).applyEuler(turned.rotation);
|
|
223
|
-
|
|
224
|
-
|
|
226
|
+
const fade = stepLightFade(model.lightFade, model.light === "lit", performance.now(), prefersLessMotion());
|
|
227
|
+
// one more frame while it moves, and none once it has arrived
|
|
228
|
+
if (fade.fading)
|
|
229
|
+
deps.invalidate();
|
|
230
|
+
if (fade.mix > 0) {
|
|
231
|
+
// between the true light and daylight from the camera's side: the direction is mixed, and a mix that cancels (the Sun straight behind) is the camera's side
|
|
232
|
+
const x = sunDir.value.x * (1 - fade.mix);
|
|
233
|
+
const y = sunDir.value.y * (1 - fade.mix);
|
|
234
|
+
const z = sunDir.value.z * (1 - fade.mix) + fade.mix;
|
|
235
|
+
const length = Math.hypot(x, y, z);
|
|
236
|
+
if (length > 1e-6)
|
|
237
|
+
sunDir.value.set(x / length, y / length, z / length);
|
|
238
|
+
else
|
|
239
|
+
sunDir.value.set(0, 0, 1);
|
|
240
|
+
}
|
|
225
241
|
cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
|
|
226
242
|
clouds.visible = model.clouds;
|
|
227
243
|
atmosphere.uniforms["thick"].value = model.airThickness;
|
|
228
244
|
glow.scale.setScalar(airTop(model.airThickness));
|
|
229
|
-
surface.uniforms["lights"].value = model.lights
|
|
245
|
+
surface.uniforms["lights"].value = model.lights ? 1 - fade.mix : 0;
|
|
230
246
|
surface.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
|
|
231
247
|
const radius = discRadius(size.width, size.height, view.zoom);
|
|
232
248
|
camera.left = (-size.width / 2 - view.panX) / radius;
|
|
@@ -376,6 +376,11 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
376
376
|
tiers: Record<EarthLayer, number>;
|
|
377
377
|
tiles: TileStats;
|
|
378
378
|
satellites: SatelliteStats;
|
|
379
|
+
/** The cross-fade when `light` changes to or from `lit` (300 ms, a cut under reduced motion): `mix` is 0 for the true light and 1 for `lit`, and `fading` is true while it moves and another frame is wanted. */
|
|
380
|
+
lightFade: {
|
|
381
|
+
mix: number;
|
|
382
|
+
fading: boolean;
|
|
383
|
+
};
|
|
379
384
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
380
385
|
paths: PathStats;
|
|
381
386
|
draws: number;
|
|
@@ -636,6 +641,13 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
636
641
|
*/
|
|
637
642
|
get pathHit(): number;
|
|
638
643
|
set pathHit(value: number);
|
|
644
|
+
/**
|
|
645
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
646
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
647
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
648
|
+
*/
|
|
649
|
+
get pathPriority(): "dots" | "paths";
|
|
650
|
+
set pathPriority(value: "dots" | "paths");
|
|
639
651
|
/**
|
|
640
652
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
641
653
|
*
|
|
@@ -11,7 +11,7 @@ import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.
|
|
|
11
11
|
import { MAX_ORBIT_GROUP, readStreakMax } from "../space/satellite-layer.js";
|
|
12
12
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForOrthographicShell } from "../space/satellite-focus.js";
|
|
13
13
|
import { claimPress } from "../sky/claim.js";
|
|
14
|
-
import { bindPaths, emptyPathStats, pointerOf } from "../space/path-controls.js";
|
|
14
|
+
import { bindPaths, emptyPathStats, pointerOf, readPathPriority } from "../space/path-controls.js";
|
|
15
15
|
import { styleTable } from "../space/paths.js";
|
|
16
16
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "../space/satellite-hover.js";
|
|
17
17
|
import { readMeteorStrength } from "../meteors/strength.js";
|
|
@@ -165,7 +165,7 @@ export const readTime = (value) => {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
168
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-hit", "estimate-far"];
|
|
168
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far"];
|
|
169
169
|
#model = newModel();
|
|
170
170
|
#paint = createPaintState();
|
|
171
171
|
#mode = "now";
|
|
@@ -1219,6 +1219,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1219
1219
|
state: this.#state,
|
|
1220
1220
|
tiers: { ...this.#tiers },
|
|
1221
1221
|
satellites: this.#satelliteStats(),
|
|
1222
|
+
lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
|
|
1222
1223
|
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
1223
1224
|
tiles: this.#model.tiles?.stats ?? { ready: false, level: null, held: 0, shown: 0, loading: 0, failed: 0, requested: 0, heldBytes: 0, refused: 0, used: {}, finer: null, fading: false },
|
|
1224
1225
|
draws: stats?.draws ?? 0,
|
|
@@ -1574,6 +1575,20 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1574
1575
|
else
|
|
1575
1576
|
this.removeAttribute("path-hit");
|
|
1576
1577
|
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
1580
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
1581
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
1582
|
+
*/
|
|
1583
|
+
get pathPriority() {
|
|
1584
|
+
return readPathPriority(this.getAttribute("path-priority"));
|
|
1585
|
+
}
|
|
1586
|
+
set pathPriority(value) {
|
|
1587
|
+
if (value === "paths")
|
|
1588
|
+
this.setAttribute("path-priority", "paths");
|
|
1589
|
+
else
|
|
1590
|
+
this.removeAttribute("path-priority");
|
|
1591
|
+
}
|
|
1577
1592
|
/**
|
|
1578
1593
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
1579
1594
|
*
|
|
@@ -1626,14 +1641,16 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1626
1641
|
if (Math.hypot(event.clientX - this.#downX, event.clientY - this.#downY) > 6)
|
|
1627
1642
|
return;
|
|
1628
1643
|
const rect = this.getBoundingClientRect();
|
|
1644
|
+
// one press, one meaning: the paths decide first, since which of a dot and a path wins depends on `path-priority` (a dot wins in the default, and the paths say so by answering no)
|
|
1645
|
+
if (this.#pathControls?.press(event.clientX - rect.left, event.clientY - rect.top, pointerOf(event))) {
|
|
1646
|
+
claimPress(event);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1629
1649
|
const satellite = this.#model.pick?.(event.clientX - rect.left, event.clientY - rect.top, 12);
|
|
1630
1650
|
if (satellite) {
|
|
1631
1651
|
claimPress(event);
|
|
1632
1652
|
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite), ...this.#estimateOf(satellite) }, bubbles: true, composed: true }));
|
|
1633
|
-
return;
|
|
1634
1653
|
}
|
|
1635
|
-
if (this.#pathControls?.press(event.clientX - rect.left, event.clientY - rect.top, pointerOf(event)))
|
|
1636
|
-
claimPress(event);
|
|
1637
1654
|
};
|
|
1638
1655
|
#wheel = (event) => immersiveWheel(this, event);
|
|
1639
1656
|
/** The view as it is (for a page that wants to read it back). */
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** How long the cross-fade takes, in milliseconds. */
|
|
2
|
+
export declare const LIGHT_FADE_MS = 300;
|
|
3
|
+
/** Where the fade is: `mix` is 0 for the true light and 1 for `lit`. */
|
|
4
|
+
export interface LightFade {
|
|
5
|
+
mix: number;
|
|
6
|
+
target: number;
|
|
7
|
+
from: number;
|
|
8
|
+
started: number;
|
|
9
|
+
/** Whether the last step left it still moving, so another draw is wanted. */
|
|
10
|
+
fading: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const newLightFade: (lit?: boolean) => LightFade;
|
|
13
|
+
/**
|
|
14
|
+
* Step the fade to `now`. `lit` is where it is going. A change of `lit` starts a fade from where the mix is now (a fade turned round half way goes back from there); with `reduced` it jumps. Returns the same object, updated.
|
|
15
|
+
*
|
|
16
|
+
* @param fade - The fade to step.
|
|
17
|
+
* @param lit - Whether the light is `lit` now.
|
|
18
|
+
* @param now - The clock, in milliseconds.
|
|
19
|
+
* @param reduced - Whether the reader asked for less motion.
|
|
20
|
+
* @returns The fade: `mix` for this frame and `fading` true while another frame is wanted.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stepLightFade(fade: LightFade, lit: boolean, now: number, reduced: boolean): LightFade;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// A short cross-fade when `light` changes to or from `lit`: the Earth's night lights and (in the realistic view) the direction of its light move from one look to the other over 300 ms instead of cutting. A reader who asked for reduced motion
|
|
2
|
+
// gets the cut. The fade is a state the draw steps: each draw asks for the next while it moves, and when it has arrived nothing is asked for, so at rest nothing is drawn.
|
|
3
|
+
/** How long the cross-fade takes, in milliseconds. */
|
|
4
|
+
export const LIGHT_FADE_MS = 300;
|
|
5
|
+
export const newLightFade = (lit = false) => ({ mix: lit ? 1 : 0, target: lit ? 1 : 0, from: lit ? 1 : 0, started: 0, fading: false });
|
|
6
|
+
/** A smooth start and end: 0 to 1 over `t` from 0 to 1. */
|
|
7
|
+
const ease = (t) => t * t * (3 - 2 * t);
|
|
8
|
+
/**
|
|
9
|
+
* Step the fade to `now`. `lit` is where it is going. A change of `lit` starts a fade from where the mix is now (a fade turned round half way goes back from there); with `reduced` it jumps. Returns the same object, updated.
|
|
10
|
+
*
|
|
11
|
+
* @param fade - The fade to step.
|
|
12
|
+
* @param lit - Whether the light is `lit` now.
|
|
13
|
+
* @param now - The clock, in milliseconds.
|
|
14
|
+
* @param reduced - Whether the reader asked for less motion.
|
|
15
|
+
* @returns The fade: `mix` for this frame and `fading` true while another frame is wanted.
|
|
16
|
+
*/
|
|
17
|
+
export function stepLightFade(fade, lit, now, reduced) {
|
|
18
|
+
const target = lit ? 1 : 0;
|
|
19
|
+
if (target !== fade.target) {
|
|
20
|
+
fade.target = target;
|
|
21
|
+
fade.from = fade.mix;
|
|
22
|
+
fade.started = now;
|
|
23
|
+
}
|
|
24
|
+
if (reduced || fade.mix === target) {
|
|
25
|
+
fade.mix = target;
|
|
26
|
+
fade.from = target;
|
|
27
|
+
fade.fading = false;
|
|
28
|
+
return fade;
|
|
29
|
+
}
|
|
30
|
+
const t = Math.min(1, Math.max(0, (now - fade.started) / LIGHT_FADE_MS));
|
|
31
|
+
fade.mix = fade.from + (target - fade.from) * ease(t);
|
|
32
|
+
if (t >= 1)
|
|
33
|
+
fade.mix = target;
|
|
34
|
+
fade.fading = fade.mix !== target;
|
|
35
|
+
return fade;
|
|
36
|
+
}
|
|
@@ -130,7 +130,7 @@ export interface CatalogueRow {
|
|
|
130
130
|
export declare function catalogueRows(lang?: "en" | "ja"): CatalogueRow[];
|
|
131
131
|
/**
|
|
132
132
|
* Find catalogue entries by name, group name, NORAD number, Japanese name or a group's Japanese label: "hubble", "hst", "25544", "weather" or "ハッブル".
|
|
133
|
-
* An English or numeric query ignores case, spaces and punctuation, as before.
|
|
133
|
+
* An English or numeric query ignores case, spaces and punctuation, as before. Japanese is folded on both sides: letter case, character width (NFKC) and kana (`foldKana`: hiragana to katakana, small kana to full-size, the long-vowel mark left alone), so `はっぶる` finds `ハッブル`; kanji are matched as typed. The width fold is applied before the English comparison too.
|
|
134
134
|
* A name that starts with the text comes before one that only has it inside.
|
|
135
135
|
*
|
|
136
136
|
* @param text - What the reader typed.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// A small curated catalogue of satellites worth following: the groups the demo offers as buttons and the famous ones by name. Facts (names, NORAD numbers, orbit types) and our own words;
|
|
2
2
|
// no orbital elements are here, and nothing is fetched. The elements come from the page (see docs/satellite-sources.md for the sources and their terms).
|
|
3
|
+
import { foldKana } from "./kana.js";
|
|
3
4
|
import { SHORT_NAMES } from "./names.js";
|
|
4
5
|
/**
|
|
5
6
|
* The groups, in the order the demo shows them. Each one is a CelesTrak list or a few single numbers; the elements are fetched by the page (or the demo's scheduled build), never by the package.
|
|
@@ -285,7 +286,7 @@ export function catalogueRows(lang) {
|
|
|
285
286
|
}
|
|
286
287
|
/**
|
|
287
288
|
* Find catalogue entries by name, group name, NORAD number, Japanese name or a group's Japanese label: "hubble", "hst", "25544", "weather" or "ハッブル".
|
|
288
|
-
* An English or numeric query ignores case, spaces and punctuation, as before.
|
|
289
|
+
* An English or numeric query ignores case, spaces and punctuation, as before. Japanese is folded on both sides: letter case, character width (NFKC) and kana (`foldKana`: hiragana to katakana, small kana to full-size, the long-vowel mark left alone), so `はっぶる` finds `ハッブル`; kanji are matched as typed. The width fold is applied before the English comparison too.
|
|
289
290
|
* A name that starts with the text comes before one that only has it inside.
|
|
290
291
|
*
|
|
291
292
|
* @param text - What the reader typed.
|
|
@@ -302,7 +303,7 @@ export function catalogueRows(lang) {
|
|
|
302
303
|
export function findInCatalogue(text, limit = 8) {
|
|
303
304
|
const source = text.normalize("NFKC");
|
|
304
305
|
const wanted = squash(source);
|
|
305
|
-
const folded = source.toLowerCase().trim();
|
|
306
|
+
const folded = foldKana(source).toLowerCase().trim();
|
|
306
307
|
const japanese = /[-ヿ一-鿿]/.test(source);
|
|
307
308
|
if (!wanted && !japanese)
|
|
308
309
|
return [];
|
|
@@ -312,8 +313,8 @@ export function findInCatalogue(text, limit = 8) {
|
|
|
312
313
|
const name = squash(entry.name);
|
|
313
314
|
const englishStart = wanted !== "" && (String(entry.noradId) === wanted || name.startsWith(wanted));
|
|
314
315
|
const englishInside = wanted !== "" && (name.includes(wanted) || squash(entry.group).includes(wanted) || squash(entry.about).includes(wanted));
|
|
315
|
-
const jaName = japanese ? (SHORT_NAMES[entry.noradId]?.ja ?? entry.name).
|
|
316
|
-
const labelJa = japanese ? (GROUPS_BY_ID.get(entry.group)?.labelJa ?? "").
|
|
316
|
+
const jaName = japanese ? foldKana(SHORT_NAMES[entry.noradId]?.ja ?? entry.name).toLowerCase() : "";
|
|
317
|
+
const labelJa = japanese ? foldKana(GROUPS_BY_ID.get(entry.group)?.labelJa ?? "").toLowerCase() : "";
|
|
317
318
|
const jaStart = japanese && folded !== "" && jaName.startsWith(folded);
|
|
318
319
|
const jaInside = japanese && folded !== "" && (jaName.includes(folded) || labelJa.includes(folded));
|
|
319
320
|
if (englishStart || jaStart)
|
|
@@ -3,6 +3,7 @@ export { NEAREST_COUNT, closeApproach, nearest, overheadKm, within, type Neighbo
|
|
|
3
3
|
export { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS, MAX_SATELLITE_SPEED } from "./limits.ts";
|
|
4
4
|
export type { ElementSet, RefusedElementSet, SatelliteInfo, SatelliteRef, Satellites } from "./types.ts";
|
|
5
5
|
export { SHORT_NAMES } from "./names.ts";
|
|
6
|
+
export { foldKana } from "./kana.ts";
|
|
6
7
|
export { OWNER_COUNTRIES, ownerCountry } from "./owners.ts";
|
|
7
8
|
export { CATALOGUE, SATELLITE_GROUPS, catalogueEntry, catalogueRows, findInCatalogue, type CatalogueEntry, type CatalogueRow, type OrbitKind, type SatelliteGroupInfo } from "./catalogue.ts";
|
|
8
9
|
export { ElementSourceError, fetchElements, forgetElements, parseElements, type ElementFormat, type ElementSource, type FetchElementsOptions, type ParsedElements } from "./source.ts";
|
package/dist/satellites/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { createSatellites } from "./track.js";
|
|
|
3
3
|
export { NEAREST_COUNT, closeApproach, nearest, overheadKm, within } from "./nearest.js";
|
|
4
4
|
export { DEFAULT_DIM_AFTER_DAYS, DEFAULT_MAX_AGE_DAYS, MAX_SATELLITE_SPEED } from "./limits.js";
|
|
5
5
|
export { SHORT_NAMES } from "./names.js";
|
|
6
|
+
export { foldKana } from "./kana.js";
|
|
6
7
|
export { OWNER_COUNTRIES, ownerCountry } from "./owners.js";
|
|
7
8
|
export { CATALOGUE, SATELLITE_GROUPS, catalogueEntry, catalogueRows, findInCatalogue } from "./catalogue.js";
|
|
8
9
|
export { ElementSourceError, fetchElements, forgetElements, parseElements } from "./source.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fold text for a Japanese search: width and compatibility forms (NFKC: half-width katakana becomes full-width), hiragana to katakana, and a small kana (`ッ`, `ャ`, `ァ`) to its full-size one. The long-vowel mark `ー` is left as it is, and so is everything that is not kana
|
|
3
|
+
* (letter case is the caller's, as it is for any search). Put it on both sides of a comparison: `foldKana("はっぶる") === foldKana("ハッブル")`, and `ハッブル` is also `ハツブル` after it, so a reader who types a small kana as a full-size one still finds it.
|
|
4
|
+
*
|
|
5
|
+
* @param text - What was typed, or a name to compare it with.
|
|
6
|
+
* @returns The folded text.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { foldKana } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
11
|
+
*
|
|
12
|
+
* console.log(foldKana("はっぶる") === foldKana("ハッブル"));
|
|
13
|
+
* console.log(foldKana("ほし ー"));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function foldKana(text: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Kana folding for a search: hiragana and katakana are the same sounds, so a name typed in one is found in the other. Pure text, no dependency; imports on a server.
|
|
2
|
+
/** The small kana and the full-size kana they fold to. */
|
|
3
|
+
const SMALL = { ァ: "ア", ィ: "イ", ゥ: "ウ", ェ: "エ", ォ: "オ", ッ: "ツ", ャ: "ヤ", ュ: "ユ", ョ: "ヨ", ヮ: "ワ", ヵ: "カ", ヶ: "ケ" };
|
|
4
|
+
/**
|
|
5
|
+
* Fold text for a Japanese search: width and compatibility forms (NFKC: half-width katakana becomes full-width), hiragana to katakana, and a small kana (`ッ`, `ャ`, `ァ`) to its full-size one. The long-vowel mark `ー` is left as it is, and so is everything that is not kana
|
|
6
|
+
* (letter case is the caller's, as it is for any search). Put it on both sides of a comparison: `foldKana("はっぶる") === foldKana("ハッブル")`, and `ハッブル` is also `ハツブル` after it, so a reader who types a small kana as a full-size one still finds it.
|
|
7
|
+
*
|
|
8
|
+
* @param text - What was typed, or a name to compare it with.
|
|
9
|
+
* @returns The folded text.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { foldKana } from "@johnmorrisdotca/chikyu-earth/satellites";
|
|
14
|
+
*
|
|
15
|
+
* console.log(foldKana("はっぶる") === foldKana("ハッブル"));
|
|
16
|
+
* console.log(foldKana("ほし ー"));
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function foldKana(text) {
|
|
20
|
+
return text
|
|
21
|
+
.normalize("NFKC")
|
|
22
|
+
.replace(/[ぁ-ゖゝゞ]/g, (ch) => String.fromCharCode(ch.charCodeAt(0) + 0x60))
|
|
23
|
+
.replace(/[ァィゥェォッャュョヮヵヶ]/g, (ch) => SMALL[ch] ?? ch);
|
|
24
|
+
}
|
|
@@ -784,6 +784,13 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
784
784
|
*/
|
|
785
785
|
get pathHit(): number;
|
|
786
786
|
set pathHit(value: number);
|
|
787
|
+
/**
|
|
788
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
789
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
790
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
791
|
+
*/
|
|
792
|
+
get pathPriority(): "dots" | "paths";
|
|
793
|
+
set pathPriority(value: "dots" | "paths");
|
|
787
794
|
/**
|
|
788
795
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
789
796
|
*
|
|
@@ -858,6 +865,11 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
858
865
|
time: number;
|
|
859
866
|
lookups: number;
|
|
860
867
|
satellites: SatelliteStats;
|
|
868
|
+
/** The cross-fade when `light` changes to or from `lit` (300 ms, a cut under reduced motion): `mix` is 0 for the true light and 1 for `lit`, and `fading` is true while it moves and another frame is wanted. */
|
|
869
|
+
lightFade: {
|
|
870
|
+
mix: number;
|
|
871
|
+
fading: boolean;
|
|
872
|
+
};
|
|
861
873
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
862
874
|
paths: PathStats;
|
|
863
875
|
ride: {
|
|
@@ -33,7 +33,7 @@ import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
|
33
33
|
import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
|
|
34
34
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
|
|
35
35
|
import { claimPress } from "../sky/claim.js";
|
|
36
|
-
import { bindPaths, emptyPathStats, pointerOf } from "./path-controls.js";
|
|
36
|
+
import { bindPaths, emptyPathStats, pointerOf, readPathPriority } from "./path-controls.js";
|
|
37
37
|
import { styleTable } from "./paths.js";
|
|
38
38
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
|
|
39
39
|
import { clampFollow, retargetFollow } from "./follow.js";
|
|
@@ -177,7 +177,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
export class ChikyuSpace extends HTMLElement {
|
|
180
|
-
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", "hover-path", "names-on-hover", "selected-path", "path-hit", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
180
|
+
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", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
181
181
|
#model = newSpaceModel();
|
|
182
182
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
183
183
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -2131,6 +2131,20 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2131
2131
|
else
|
|
2132
2132
|
this.removeAttribute("path-hit");
|
|
2133
2133
|
}
|
|
2134
|
+
/**
|
|
2135
|
+
* Which is heard first where a satellite's dot and a path lie under the pointer (the attribute `path-priority`): `dots`, the default, or `paths`. With `dots` a press or a hover is the dot's, and a path is heard only where no dot is within 12 px: at the Low level, with thousands of dots crowding a line, a path can go unheard.
|
|
2136
|
+
* With `paths` a path of the page's (`setPaths`, or the chosen satellite's own orbit) is heard before a dot, **except** a dot of a satellite that is itself one of the paths' satellites or the chosen or ridden one: that satellite's own dot still wins, and a press on it is `chikyu-satellite-click`.
|
|
2137
|
+
* Either way one press has one meaning, in this order. `dots`: any dot, then a path, then the sky. `paths`: a listed or chosen satellite's dot, then a path, then any other dot, then the sky. Anything but `paths` reads as `dots`.
|
|
2138
|
+
*/
|
|
2139
|
+
get pathPriority() {
|
|
2140
|
+
return readPathPriority(this.getAttribute("path-priority"));
|
|
2141
|
+
}
|
|
2142
|
+
set pathPriority(value) {
|
|
2143
|
+
if (value === "paths")
|
|
2144
|
+
this.setAttribute("path-priority", "paths");
|
|
2145
|
+
else
|
|
2146
|
+
this.removeAttribute("path-priority");
|
|
2147
|
+
}
|
|
2134
2148
|
/**
|
|
2135
2149
|
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
2136
2150
|
*
|
|
@@ -2311,6 +2325,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2311
2325
|
time: this.#model.time,
|
|
2312
2326
|
lookups: this.#model.lookups,
|
|
2313
2327
|
satellites: this.#satelliteStats(),
|
|
2328
|
+
lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
|
|
2314
2329
|
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
2315
2330
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
|
|
2316
2331
|
camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], quaternion: [this.#model.pose.q[0], this.#model.pose.q[1], this.#model.pose.q[2], this.#model.pose.q[3]], fov: this.#model.pose.fov },
|
|
@@ -2471,14 +2486,15 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2471
2486
|
const rect = this.getBoundingClientRect();
|
|
2472
2487
|
const x = event.clientX - rect.left;
|
|
2473
2488
|
const y = event.clientY - rect.top;
|
|
2474
|
-
|
|
2475
|
-
if (
|
|
2489
|
+
// one press, one meaning: the paths decide first, since which of a dot and a path wins depends on `path-priority` (a dot wins in the default, and the paths say so by answering no)
|
|
2490
|
+
if (this.#pathControls?.press(x, y, pointerOf(event))) {
|
|
2476
2491
|
claimPress(event);
|
|
2477
|
-
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite), ...this.#estimateOf(satellite) }, bubbles: true, composed: true }));
|
|
2478
2492
|
return;
|
|
2479
2493
|
}
|
|
2480
|
-
|
|
2494
|
+
const satellite = this.#model.pick?.(x, y, 12);
|
|
2495
|
+
if (satellite) {
|
|
2481
2496
|
claimPress(event);
|
|
2497
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite), ...this.#estimateOf(satellite) }, bubbles: true, composed: true }));
|
|
2482
2498
|
return;
|
|
2483
2499
|
}
|
|
2484
2500
|
if (!this.#places)
|
|
@@ -26,11 +26,14 @@ export type SatelliteKind = "bus" | "communications" | "flat" | "station" | "cub
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export declare function satelliteKind(name: string): SatelliteKind;
|
|
29
|
+
/** How bright the Sun is on a generic drawing. */
|
|
30
|
+
export declare const SUN_INTENSITY = 3.2;
|
|
29
31
|
/**
|
|
30
32
|
* A generic satellite as a drawing of radius 1 about the origin, its long axis along +x (the way it flies), its top along +z and its left along +y, the family's convention for a model, with its own light that `light(toSun)` turns to the Sun. One group of a few meshes, made once and disposed with `dispose`.
|
|
31
33
|
*
|
|
32
34
|
* @param three - three.js (the parts the demo's subset holds: `Group`, `Mesh`, `BoxGeometry`, `CylinderGeometry`, `MeshLambertMaterial`, `DirectionalLight`, `AmbientLight`).
|
|
33
35
|
* @param kind - What to draw.
|
|
36
|
+
* @param shared - A Sun light the scene owns (`{ sun }`), in the scene's own axes: the drawing then makes none of its own and `light` points that one. A scene with the light always in it keeps the same number of lights whether or not a drawing is shown, so three keeps one program for each material, not one for each state of the lights.
|
|
34
37
|
* @returns The drawing, with `light` and `dispose`.
|
|
35
38
|
*
|
|
36
39
|
* @example
|
|
@@ -43,4 +46,6 @@ export declare function satelliteKind(name: string): SatelliteKind;
|
|
|
43
46
|
* drawing.dispose();
|
|
44
47
|
* ```
|
|
45
48
|
*/
|
|
46
|
-
export declare function genericSatellite(three: typeof THREE, kind: SatelliteKind
|
|
49
|
+
export declare function genericSatellite(three: typeof THREE, kind: SatelliteKind, shared?: {
|
|
50
|
+
sun: THREE.DirectionalLight;
|
|
51
|
+
}): BodyDrawing;
|
|
@@ -23,11 +23,14 @@ export function satelliteKind(name) {
|
|
|
23
23
|
return "communications";
|
|
24
24
|
return "bus";
|
|
25
25
|
}
|
|
26
|
+
/** How bright the Sun is on a generic drawing. */
|
|
27
|
+
export const SUN_INTENSITY = 3.2;
|
|
26
28
|
/**
|
|
27
29
|
* A generic satellite as a drawing of radius 1 about the origin, its long axis along +x (the way it flies), its top along +z and its left along +y, the family's convention for a model, with its own light that `light(toSun)` turns to the Sun. One group of a few meshes, made once and disposed with `dispose`.
|
|
28
30
|
*
|
|
29
31
|
* @param three - three.js (the parts the demo's subset holds: `Group`, `Mesh`, `BoxGeometry`, `CylinderGeometry`, `MeshLambertMaterial`, `DirectionalLight`, `AmbientLight`).
|
|
30
32
|
* @param kind - What to draw.
|
|
33
|
+
* @param shared - A Sun light the scene owns (`{ sun }`), in the scene's own axes: the drawing then makes none of its own and `light` points that one. A scene with the light always in it keeps the same number of lights whether or not a drawing is shown, so three keeps one program for each material, not one for each state of the lights.
|
|
31
34
|
* @returns The drawing, with `light` and `dispose`.
|
|
32
35
|
*
|
|
33
36
|
* @example
|
|
@@ -40,7 +43,7 @@ export function satelliteKind(name) {
|
|
|
40
43
|
* drawing.dispose();
|
|
41
44
|
* ```
|
|
42
45
|
*/
|
|
43
|
-
export function genericSatellite(three, kind) {
|
|
46
|
+
export function genericSatellite(three, kind, shared) {
|
|
44
47
|
const group = new three.Group();
|
|
45
48
|
const materials = [];
|
|
46
49
|
const geometries = [];
|
|
@@ -115,11 +118,20 @@ export function genericSatellite(three, kind) {
|
|
|
115
118
|
add(box(0.06, 0.06, 0.1), 0xb4b9c2, [-0.2, 0, -0.26]);
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
|
-
const
|
|
119
|
-
|
|
121
|
+
const own = shared ? null : new three.DirectionalLight(0xfff4e0, SUN_INTENSITY);
|
|
122
|
+
const sun = shared?.sun ?? own;
|
|
123
|
+
group.add(new three.AmbientLight(0x6f86a8, 0.9));
|
|
124
|
+
if (own)
|
|
125
|
+
group.add(own);
|
|
120
126
|
return {
|
|
121
127
|
object: group,
|
|
122
128
|
light(toSun) {
|
|
129
|
+
if (shared) {
|
|
130
|
+
// the scene's light lives in the scene's axes, where the Sun's direction is already: point it and switch it on (the scene switches it off when no drawing is shown)
|
|
131
|
+
sun.position.set(toSun[0], toSun[1], toSun[2]);
|
|
132
|
+
sun.intensity = SUN_INTENSITY;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
123
135
|
// the model's axes are the columns of the matrix the view set: the direction to the Sun in them is the dot with each
|
|
124
136
|
const m = group.matrix.elements;
|
|
125
137
|
const length = Math.hypot(m[0], m[1], m[2]) || 1;
|
|
@@ -130,7 +142,7 @@ export function genericSatellite(three, kind) {
|
|
|
130
142
|
material.dispose();
|
|
131
143
|
for (const geometry of geometries)
|
|
132
144
|
geometry.dispose();
|
|
133
|
-
|
|
145
|
+
own?.dispose?.();
|
|
134
146
|
},
|
|
135
147
|
};
|
|
136
148
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type * as THREE from "three";
|
|
2
|
+
/** The look of the light a model brought: the colour (a number such as 0xfff4e0) and the strength, for the scene's Sun to take on while the model is shown. */
|
|
3
|
+
export interface ModelSun {
|
|
4
|
+
color: number;
|
|
5
|
+
intensity: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Switch off every light in a model that would count in the scene's lights (directional, point, spot, hemisphere and area lights; an ambient light does not change a program and is left), and say what the first directional one looked like.
|
|
9
|
+
* The lights are switched off, not taken out, so a painter that disposes of them or aims them in its `light` hook finds them where it left them.
|
|
10
|
+
*
|
|
11
|
+
* @param object - The model.
|
|
12
|
+
* @returns The first directional light's colour and strength, or `null` when the model had none.
|
|
13
|
+
*/
|
|
14
|
+
export declare function stripLights(object: THREE.Object3D): ModelSun | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switch off every light in a model that would count in the scene's lights (directional, point, spot, hemisphere and area lights; an ambient light does not change a program and is left), and say what the first directional one looked like.
|
|
3
|
+
* The lights are switched off, not taken out, so a painter that disposes of them or aims them in its `light` hook finds them where it left them.
|
|
4
|
+
*
|
|
5
|
+
* @param object - The model.
|
|
6
|
+
* @returns The first directional light's colour and strength, or `null` when the model had none.
|
|
7
|
+
*/
|
|
8
|
+
export function stripLights(object) {
|
|
9
|
+
let sun = null;
|
|
10
|
+
object.traverse((part) => {
|
|
11
|
+
const light = part;
|
|
12
|
+
if (!light.isLight || light.isAmbientLight === true || light.isLightProbe === true)
|
|
13
|
+
return;
|
|
14
|
+
if (light.isDirectionalLight === true && sun === null)
|
|
15
|
+
sun = { color: light.color.getHex(), intensity: light.intensity };
|
|
16
|
+
light.visible = false;
|
|
17
|
+
});
|
|
18
|
+
return sun;
|
|
19
|
+
}
|
|
@@ -2,7 +2,10 @@ import type { SatelliteRef } from "../satellites/types.ts";
|
|
|
2
2
|
import type { SatelliteState } from "./satellite-layer.ts";
|
|
3
3
|
import { MAX_PATHS, type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
4
4
|
/** The attributes the paths add to an element. */
|
|
5
|
-
export declare const PATH_ATTRIBUTES: readonly ["selected-path", "path-hit"];
|
|
5
|
+
export declare const PATH_ATTRIBUTES: readonly ["selected-path", "path-hit", "path-priority"];
|
|
6
|
+
/** Which comes first under a pointer: a satellite's `dots` (the default), or `paths` (a path of the page's, unless the dot is of a satellite whose path is listed or that is chosen). Anything else is `dots`. */
|
|
7
|
+
export type PathPriority = "dots" | "paths";
|
|
8
|
+
export declare const readPathPriority: (value: string | null) => PathPriority;
|
|
6
9
|
/** What the element hands the paths. */
|
|
7
10
|
export interface PathHost {
|
|
8
11
|
element: HTMLElement;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { capPaths, hitRadius, MAX_PATHS, readPathHit, styleTable } from "./paths.js";
|
|
2
2
|
/** The attributes the paths add to an element. */
|
|
3
|
-
export const PATH_ATTRIBUTES = ["selected-path", "path-hit"];
|
|
3
|
+
export const PATH_ATTRIBUTES = ["selected-path", "path-hit", "path-priority"];
|
|
4
|
+
export const readPathPriority = (value) => (value === "paths" ? "paths" : "dots");
|
|
4
5
|
export const pointerOf = (event) => (event.pointerType === "touch" ? "touch" : event.pointerType === "pen" ? "pen" : "mouse");
|
|
5
6
|
export function bindPaths(host) {
|
|
6
7
|
const { element, state } = host;
|
|
@@ -18,14 +19,22 @@ export function bindPaths(host) {
|
|
|
18
19
|
const found = host.pathAt(x, y, radius);
|
|
19
20
|
return found ? { ...found, pointer } : null;
|
|
20
21
|
};
|
|
22
|
+
/** Whether a dot belongs to a satellite the page has made much of: one whose path is drawn (listed, or the chosen or ridden one's own), or the chosen one. Its dot is its own under either priority. */
|
|
23
|
+
const listed = (ref) => state.paths.info.some((one) => one.ref.group === ref.group && one.ref.index === ref.index) || (state.selected?.group === ref.group && state.selected.index === ref.index) || (state.ridden?.group === ref.group && state.ridden.index === ref.index);
|
|
24
|
+
/** The path a pointer at a point is on, once the dots have had their say: under `dots` a dot hides the paths; under `paths` only a listed satellite's own dot does. */
|
|
25
|
+
const choose = (x, y, pointer) => {
|
|
26
|
+
const dot = host.pick(x, y);
|
|
27
|
+
if (dot && (readPathPriority(element.getAttribute("path-priority")) === "dots" || listed(dot)))
|
|
28
|
+
return null;
|
|
29
|
+
return at(x, y, undefined, pointer);
|
|
30
|
+
};
|
|
21
31
|
const detail = (hit) => ({ ...hit, ref: { ...hit.ref } });
|
|
22
32
|
const sameHit = (a, b) => (a === null && b === null) || (a !== null && b !== null && a.id === b.id && a.style === b.style && a.ref.group === b.ref.group && a.ref.index === b.ref.index);
|
|
23
33
|
const apply = () => {
|
|
24
34
|
queued = false;
|
|
25
35
|
if (!point)
|
|
26
36
|
return;
|
|
27
|
-
const
|
|
28
|
-
const hit = dot ? null : at(point.x, point.y, undefined, "mouse");
|
|
37
|
+
const hit = choose(point.x, point.y, "mouse");
|
|
29
38
|
if (sameHit(hit, hovered)) {
|
|
30
39
|
hovered = hit;
|
|
31
40
|
return;
|
|
@@ -95,9 +104,7 @@ export function bindPaths(host) {
|
|
|
95
104
|
},
|
|
96
105
|
at,
|
|
97
106
|
press(x, y, pointer) {
|
|
98
|
-
|
|
99
|
-
return false;
|
|
100
|
-
const hit = at(x, y, undefined, pointer);
|
|
107
|
+
const hit = choose(x, y, pointer);
|
|
101
108
|
if (!hit)
|
|
102
109
|
return false;
|
|
103
110
|
hits += 1;
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -8,6 +8,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
10
|
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
11
|
+
import { type LightFade } from "../realistic/light-fade.ts";
|
|
11
12
|
import type { SkyFrame } from "../sky/frame.ts";
|
|
12
13
|
import type { PlaceView } from "../markers/places.ts";
|
|
13
14
|
import { type PlaceSpriteData } from "../markers/place-sprites.ts";
|
|
@@ -170,6 +171,8 @@ export interface SpaceModel {
|
|
|
170
171
|
focus: BodyName;
|
|
171
172
|
/** How the Earth is lit (see `LightMode`); the Sun, the Moon and the planets keep their true places either way. */
|
|
172
173
|
light: LightMode;
|
|
174
|
+
/** The cross-fade of the Earth's night lights between the true light and `lit`, stepped at each draw (src/realistic/light-fade.ts). */
|
|
175
|
+
lightFade: LightFade;
|
|
173
176
|
/** How the painter draws the Sun, the planets and their moons (one of its `looks`, or `plain` for the sphere in the right colour); empty for its first. */
|
|
174
177
|
bodies: string;
|
|
175
178
|
/** Filled at each draw. */
|
package/dist/space/scene.js
CHANGED
|
@@ -6,6 +6,9 @@ import { createTileSet } from "../realistic/tile-set.js";
|
|
|
6
6
|
import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
|
|
7
7
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
8
8
|
import { faceOffset, outsidePose, ridePose } from "./ride.js";
|
|
9
|
+
import { stripLights } from "./model-lights.js";
|
|
10
|
+
import { newLightFade, stepLightFade } from "../realistic/light-fade.js";
|
|
11
|
+
import { prefersLessMotion } from "../meteors/note.js";
|
|
9
12
|
import { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
10
13
|
import { followSpin } from "./follow.js";
|
|
11
14
|
import { coverBody, covers } from "../sky/cover.js";
|
|
@@ -116,6 +119,7 @@ export const newSpaceModel = () => ({
|
|
|
116
119
|
focus: "Earth",
|
|
117
120
|
bodies: "",
|
|
118
121
|
light: "sun",
|
|
122
|
+
lightFade: newLightFade(),
|
|
119
123
|
drawn: null,
|
|
120
124
|
painted: { bodies: 0, moons: 0, held: 0, moon: false, tiles: 0, mapped: 0, pending: 0 },
|
|
121
125
|
lookups: 0,
|
|
@@ -401,8 +405,17 @@ export function createSpaceItem(model, deps) {
|
|
|
401
405
|
let routeLayer = null;
|
|
402
406
|
let marksTold = false;
|
|
403
407
|
// the followed satellite's model: which satellite it is for, the drawing once it is made, and a count so that a model made for a satellite no longer followed is let go
|
|
404
|
-
const modelSlot = { key: "", drawing: null, turn: 0, parts: 0, axes: null };
|
|
408
|
+
const modelSlot = { key: "", drawing: null, turn: 0, parts: 0, axes: null, sun: null };
|
|
409
|
+
// The Sun's light for a generic satellite drawing, in the scene for good and dark (intensity 0) while no drawing is shown. Three counts the lights in the scene into the key of every program, so a light that came and went with a ride
|
|
410
|
+
// made a second program of the same code for each shader that was drawn while it was there (the Moon's, MODULES-1293): with the light always in the scene there is one.
|
|
411
|
+
const SunLight = three.DirectionalLight;
|
|
412
|
+
const sceneSun = SunLight ? new SunLight(0xfff4e0, 0) : undefined;
|
|
413
|
+
if (sceneSun)
|
|
414
|
+
scene.add(sceneSun);
|
|
405
415
|
const dropModel = () => {
|
|
416
|
+
if (sceneSun)
|
|
417
|
+
sceneSun.intensity = 0;
|
|
418
|
+
modelSlot.sun = null;
|
|
406
419
|
if (!modelSlot.drawing)
|
|
407
420
|
return;
|
|
408
421
|
scene.remove(modelSlot.drawing.object);
|
|
@@ -463,7 +476,11 @@ export function createSpaceItem(model, deps) {
|
|
|
463
476
|
cloudShift.value = -(((model.time / 3_600_000) * model.cloudDrift) % 360) / 360;
|
|
464
477
|
atmosphereMaterial.uniforms["thick"].value = model.airThickness;
|
|
465
478
|
glow.scale.setScalar(airTop(model.airThickness));
|
|
466
|
-
|
|
479
|
+
const fade = stepLightFade(model.lightFade, model.light === "lit", performance.now(), prefersLessMotion());
|
|
480
|
+
// one more frame while it moves, and none once it has arrived
|
|
481
|
+
if (fade.fading)
|
|
482
|
+
deps.invalidate();
|
|
483
|
+
earthMaterial.uniforms["lights"].value = 1 - fade.mix;
|
|
467
484
|
earthMaterial.uniforms["boost"].value = model.light === "boost" ? 1 : 0;
|
|
468
485
|
if (deps.paint) {
|
|
469
486
|
const changed = deps.paint.step(model.time);
|
|
@@ -862,6 +879,8 @@ export function createSpaceItem(model, deps) {
|
|
|
862
879
|
const adopt = (made) => {
|
|
863
880
|
made.object.matrixAutoUpdate = false;
|
|
864
881
|
made.object.visible = false;
|
|
882
|
+
// the scene owns the Sun's light: a light the painter put in its model is switched off and its look taken for the scene's Sun to wear while the model is shown (a generic drawing has none of its own: it was given the scene's)
|
|
883
|
+
modelSlot.sun = stripLights(made.object);
|
|
865
884
|
scene.add(made.object);
|
|
866
885
|
modelSlot.drawing = made;
|
|
867
886
|
// how many meshes the model is made of: a draw call each, which a test of the draw budget adds to the scene's own
|
|
@@ -873,7 +892,7 @@ export function createSpaceItem(model, deps) {
|
|
|
873
892
|
deps.invalidate();
|
|
874
893
|
};
|
|
875
894
|
if (modelKey.startsWith("generic:"))
|
|
876
|
-
adopt(genericSatellite(three, modelKey.slice(8)));
|
|
895
|
+
adopt(genericSatellite(three, modelKey.slice(8), sceneSun ? { sun: sceneSun } : undefined));
|
|
877
896
|
else if (modelKey && satellitePainter && norad !== undefined) {
|
|
878
897
|
void Promise.resolve(satellitePainter.make(three, norad, { look: "", invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap() }))
|
|
879
898
|
.then((made) => {
|
|
@@ -910,6 +929,11 @@ export function createSpaceItem(model, deps) {
|
|
|
910
929
|
object.visible = true;
|
|
911
930
|
const toSunNow = unit(frame.sun);
|
|
912
931
|
modelSlot.drawing.light?.(toSunNow);
|
|
932
|
+
if (sceneSun && modelSlot.sun) {
|
|
933
|
+
sceneSun.color.setHex(modelSlot.sun.color);
|
|
934
|
+
sceneSun.intensity = modelSlot.sun.intensity;
|
|
935
|
+
sceneSun.position.set(toSunNow[0], toSunNow[1], toSunNow[2]);
|
|
936
|
+
}
|
|
913
937
|
modelSlot.drawing.update?.({ toSun: toSunNow, ms: model.time, radiusPx: size.height * share });
|
|
914
938
|
projected.set(shownSat.place[0], shownSat.place[1], shownSat.place[2]).project(camera);
|
|
915
939
|
const sx = ((projected.x + 1) / 2) * size.width;
|
|
@@ -920,6 +944,8 @@ export function createSpaceItem(model, deps) {
|
|
|
920
944
|
else {
|
|
921
945
|
if (modelSlot.drawing)
|
|
922
946
|
modelSlot.drawing.object.visible = false;
|
|
947
|
+
if (sceneSun)
|
|
948
|
+
sceneSun.intensity = 0;
|
|
923
949
|
model.followModel = null;
|
|
924
950
|
}
|
|
925
951
|
const sunToSun = unit([-frame.sun[0], -frame.sun[1], -frame.sun[2]]);
|
|
@@ -1249,6 +1275,10 @@ export function createSpaceItem(model, deps) {
|
|
|
1249
1275
|
routeLayer?.dispose();
|
|
1250
1276
|
modelSlot.turn += 1;
|
|
1251
1277
|
dropModel();
|
|
1278
|
+
if (sceneSun) {
|
|
1279
|
+
scene.remove(sceneSun);
|
|
1280
|
+
sceneSun.dispose?.();
|
|
1281
|
+
}
|
|
1252
1282
|
layer?.dispose();
|
|
1253
1283
|
model.pick = null;
|
|
1254
1284
|
model.pathAt = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
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",
|