@johnmorrisdotca/chikyu-earth 0.47.0 → 0.48.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 +5 -0
- package/README.md +1 -1
- package/dist/realistic/earth.d.ts +3 -0
- package/dist/realistic/earth.js +4 -1
- package/dist/realistic/element-base.d.ts +71 -0
- package/dist/realistic/element-base.js +122 -2
- package/dist/sky/claim.d.ts +4 -0
- package/dist/sky/claim.js +8 -0
- package/dist/sky/host.js +5 -0
- package/dist/space/element-base.d.ts +71 -0
- package/dist/space/element-base.js +123 -1
- package/dist/space/path-controls.d.ts +56 -0
- package/dist/space/path-controls.js +121 -0
- package/dist/space/path-ribbons.d.ts +25 -0
- package/dist/space/path-ribbons.js +165 -0
- package/dist/space/paths.d.ts +119 -0
- package/dist/space/paths.js +163 -0
- package/dist/space/satellite-layer.d.ts +28 -2
- package/dist/space/satellite-layer.js +145 -28
- package/dist/space/scene.d.ts +3 -0
- package/dist/space/scene.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.0 - 2026-11-13
|
|
4
|
+
|
|
5
|
+
- **Paths of a page's own, a quiet chosen orbit, and a hit test for a path line** (MODULES-1289). `selected-path="off"` (the property `selectedPath`) stops the package drawing the chosen satellite's own orbit; ring, name and ride stay. `setPaths(list)` (the property `paths`) draws up to 16 orbits at once, each `{ id, style }` (`id` a NORAD number or `group:index`, the last 16 kept), and `setPathStyles(table)` (the property `pathStyles`) changes the named looks `selected`, `hovered`, `favourite` and `path`, each a colour, a width of 0.5 to 8 px, an opacity and a dash: they differ by width and dash as well as colour. All the paths and the chosen orbit are one draw call, with a real width and dashes, and nothing is drawn at rest. `path-hit` (the property `pathHit`, 8 px, 0 to 40, off at 0; a touch has twice the reach, at least 16) makes `chikyu-path-hover` (a mouse) and `chikyu-path-click` (a press or a tap) say which path is under the pointer, `{ id, ref, style, x, y, distancePx, pointer }` with the same `ref` as `chikyu-satellite-click`; `pathAt(x, y, radiusPx?)` asks the same for any point. One press means one thing: a dot, then a path, then the sky. In a ride, the ridden satellite's own orbit is drawn in the `selected` look, and the hit test is off there unless `path-hit` is set. `stats.paths`. On both `<chikyu-space>` and `<chikyu-earth-realistic>`. The chosen satellite's orbit is now 2 px wide (the `selected` look; it was 1 px).
|
|
6
|
+
- **Three browser tests no longer fail on a saturated machine** (MODULES-1319). The full-screen at-rest and ride-look hidden-tab freeze tests wait for the page's own out-of-sight signal and count draws once they have held still; the ring test records the turn and its first draw in the page; the ride-size frame comparison holds everything that can arrive and leaves the stations' own orbit lines out. Tests only; the package is unchanged by them.
|
|
7
|
+
|
|
3
8
|
## 0.47.0 - 2026-11-13
|
|
4
9
|
|
|
5
10
|
- **The demo's Find box keeps a Japanese query.** A name in kana or kanji used to be dropped before the catalogue was asked, so `ハッブル` found nothing. It now asks the catalogue, and a satellite the package knows by a short name is listed by that name (Hubble, not only HST).
|
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.48.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 { PathHit } from "../space/paths.ts";
|
|
6
7
|
import { type SatelliteScreen, type SatelliteState } from "../space/satellite-layer.ts";
|
|
7
8
|
import type { Layer } from "./tiers.ts";
|
|
8
9
|
import { type ThreeParts } from "./textures.ts";
|
|
@@ -85,6 +86,8 @@ export interface EarthModel {
|
|
|
85
86
|
} | null;
|
|
86
87
|
/** The map tiles laid over the pictures while the scene is built: what they are doing, for a page or a test. */
|
|
87
88
|
tiles: TileSet | null;
|
|
89
|
+
/** The page's path under a point of the view (CSS pixels), within a radius, once a draw has been made and one is there. */
|
|
90
|
+
pathAt: ((x: number, y: number, radius: number) => Omit<PathHit, "pointer"> | null) | null;
|
|
88
91
|
/** The satellite at a point of the view (CSS pixels), within a radius, once a draw has been made and one is there. */
|
|
89
92
|
pick: ((x: number, y: number, radius: number) => SatelliteRef | null) | null;
|
|
90
93
|
/** Where a satellite of a shown group is on the screen as of the last draw, or `null`. */
|
package/dist/realistic/earth.js
CHANGED
|
@@ -44,6 +44,7 @@ export const newModel = () => ({
|
|
|
44
44
|
drawn: null,
|
|
45
45
|
tiles: null,
|
|
46
46
|
pick: null,
|
|
47
|
+
pathAt: null,
|
|
47
48
|
placeSatellite: null,
|
|
48
49
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
49
50
|
meteors: newMeteorState(),
|
|
@@ -242,8 +243,9 @@ export function createEarthItem(model, deps) {
|
|
|
242
243
|
deps.onSatellitesError?.(error);
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
|
-
layer?.update(model.time, model.speed, radius);
|
|
246
|
+
layer?.update(model.time, model.speed, radius, size);
|
|
246
247
|
model.pick = layer ? (x, y, radius) => layer.pick(x, y, camera, size, radius) : null;
|
|
248
|
+
model.pathAt = layer ? (x, y, radius) => layer.pathAt(x, y, camera, size, radius) : null;
|
|
247
249
|
model.placeSatellite = layer ? (ref) => layer.placeOf(ref, camera, size) : null;
|
|
248
250
|
if (layer && deps.onHover) {
|
|
249
251
|
const hover = model.satellites.hover;
|
|
@@ -356,6 +358,7 @@ export function createEarthItem(model, deps) {
|
|
|
356
358
|
dispose() {
|
|
357
359
|
layer?.dispose();
|
|
358
360
|
model.pick = null;
|
|
361
|
+
model.pathAt = null;
|
|
359
362
|
model.placeSatellite = null;
|
|
360
363
|
clearTimeout(meteorTimer);
|
|
361
364
|
meteors?.dispose();
|
|
@@ -5,6 +5,8 @@ import { type PaintSpec } from "../paint/buffer.ts";
|
|
|
5
5
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
6
6
|
import { type SatelliteStyle } from "../space/satellite-layer.ts";
|
|
7
7
|
import { type SatelliteOthers } from "../space/satellite-focus.ts";
|
|
8
|
+
import { type PathStats } from "../space/path-controls.ts";
|
|
9
|
+
import { type PathHit, type PathRequest, type PathStyle } from "../space/paths.ts";
|
|
8
10
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
9
11
|
import { type BodyLabelSettings } from "./body-label.ts";
|
|
10
12
|
import type { SkyKeepClear } from "../sky/keep-clear.ts";
|
|
@@ -373,6 +375,8 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
373
375
|
tiers: Record<EarthLayer, number>;
|
|
374
376
|
tiles: TileStats;
|
|
375
377
|
satellites: SatelliteStats;
|
|
378
|
+
/** 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. */
|
|
379
|
+
paths: PathStats;
|
|
376
380
|
draws: number;
|
|
377
381
|
contexts: number;
|
|
378
382
|
canvas: {
|
|
@@ -562,6 +566,73 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
562
566
|
} | null;
|
|
563
567
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
564
568
|
get selectedSatellite(): SatelliteRef | null;
|
|
569
|
+
/**
|
|
570
|
+
* Draw these satellites' orbits at once, each in a look from the table (`pathStyles`), without a satellite being chosen. One draw call for all of them and the chosen satellite's own orbit, and nothing is drawn at rest. At most 16 are kept, the last of the list.
|
|
571
|
+
* `id` is a NORAD catalogue number or `group:index` (`stations:0`); an id that matches no satellite is skipped (`stats.paths.unresolved`). A satellite asked for twice is drawn once, in the later look. `style` is the name of a look (`selected`, `hovered`, `favourite`, `path`, or one of the page's own)
|
|
572
|
+
* or a partial look over `path`. `[]` takes them all away. Where the pointer is on one, `chikyu-path-hover` and `chikyu-path-click` say which (`path-hit`).
|
|
573
|
+
*
|
|
574
|
+
* @param list - The paths, oldest first.
|
|
575
|
+
*
|
|
576
|
+
* @example
|
|
577
|
+
* ```ts
|
|
578
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
579
|
+
*
|
|
580
|
+
* const show = (space: ChikyuSpace): void => space.setPaths([{ id: 25544, style: "favourite" }, { id: "stations:1", style: { color: "#7fdbff", dash: [8, 4] } }]);
|
|
581
|
+
* console.log(typeof show);
|
|
582
|
+
* ```
|
|
583
|
+
*/
|
|
584
|
+
setPaths(list: readonly PathRequest[]): void;
|
|
585
|
+
/** The paths in use, as set (the last 16). Setting it is `setPaths`. */
|
|
586
|
+
get paths(): PathRequest[];
|
|
587
|
+
set paths(list: readonly PathRequest[]);
|
|
588
|
+
/**
|
|
589
|
+
* Change the looks the paths are drawn in, by name. Each entry is a partial look over the built-in one of that name (or over `path`, for a name of the page's own); `null` takes the page's entry away. Without `replace` the entries are added to those already set.
|
|
590
|
+
* The built-in looks differ by width and dash as well as colour: `selected` (white, 2 px, solid, also the look of the chosen satellite's own orbit), `hovered` (white, 1.5 px, dashed), `favourite` (amber, 1.75 px, dotted) and `path` (white, 1.5 px, solid).
|
|
591
|
+
* A look is `{ color, width (0.5 to 8 CSS pixels), opacity (0 to 1), dash ([dash, gap] in CSS pixels, or null) }`.
|
|
592
|
+
*
|
|
593
|
+
* @param table - The entries by name.
|
|
594
|
+
* @param replace - `true` to drop the entries set before.
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
* ```ts
|
|
598
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
599
|
+
*
|
|
600
|
+
* const quiet = (space: ChikyuSpace): void => space.setPathStyles({ selected: { color: "#ffd166", width: 3, dash: null } });
|
|
601
|
+
* console.log(typeof quiet);
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
setPathStyles(table: Readonly<Record<string, Partial<PathStyle> | null>>, replace?: boolean): void;
|
|
605
|
+
/** The table of looks in use, whole: the built-in ones with the page's own over them. A copy. */
|
|
606
|
+
get pathStyles(): Record<string, PathStyle>;
|
|
607
|
+
set pathStyles(table: Readonly<Record<string, Partial<PathStyle> | null>>);
|
|
608
|
+
/**
|
|
609
|
+
* Draw the chosen satellite's own orbit (the attribute `selected-path`; on unless `off`). Off, `selectSatellite` still rings and names the satellite and a ride still follows it, but no line is drawn: the page draws it, with `setPaths` and the `selected` look, or its own. The look of the line when it is on is the `selected` entry of `pathStyles`.
|
|
610
|
+
*/
|
|
611
|
+
get selectedPath(): boolean;
|
|
612
|
+
set selectedPath(value: boolean);
|
|
613
|
+
/**
|
|
614
|
+
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
615
|
+
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
616
|
+
*/
|
|
617
|
+
get pathHit(): number;
|
|
618
|
+
set pathHit(value: number);
|
|
619
|
+
/**
|
|
620
|
+
* 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`.
|
|
621
|
+
*
|
|
622
|
+
* @param x - CSS pixels from the element's left.
|
|
623
|
+
* @param y - CSS pixels from its top.
|
|
624
|
+
* @param radiusPx - How near the point must be, 0 to 200; `path-hit` when left out.
|
|
625
|
+
* @returns The path, or `null` when none is within reach.
|
|
626
|
+
*
|
|
627
|
+
* @example
|
|
628
|
+
* ```ts
|
|
629
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
630
|
+
*
|
|
631
|
+
* const name = (space: ChikyuSpace, x: number, y: number): string => space.pathAt(x, y, 10)?.style ?? "none";
|
|
632
|
+
* console.log(typeof name);
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
pathAt(x: number, y: number, radiusPx?: number): PathHit | null;
|
|
565
636
|
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period, and `ownerCountry` when the owner is one country); undefined if it cannot be placed then. */
|
|
566
637
|
satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
|
|
567
638
|
/** The view as it is (for a page that wants to read it back). */
|
|
@@ -10,6 +10,9 @@ import { cameraCentre, createEarthItem, discRadius, lookAt, newModel } from "./e
|
|
|
10
10
|
import { createPaintState, paintedGround, paintedPeriod } from "../paint/buffer.js";
|
|
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
|
+
import { claimPress } from "../sky/claim.js";
|
|
14
|
+
import { bindPaths, emptyPathStats, pointerOf } from "../space/path-controls.js";
|
|
15
|
+
import { styleTable } from "../space/paths.js";
|
|
13
16
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "../space/satellite-hover.js";
|
|
14
17
|
import { readMeteorStrength } from "../meteors/strength.js";
|
|
15
18
|
import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/note.js";
|
|
@@ -162,7 +165,7 @@ export const readTime = (value) => {
|
|
|
162
165
|
* ```
|
|
163
166
|
*/
|
|
164
167
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
165
|
-
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"];
|
|
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"];
|
|
166
169
|
#model = newModel();
|
|
167
170
|
#paint = createPaintState();
|
|
168
171
|
#mode = "now";
|
|
@@ -211,6 +214,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
211
214
|
#focusView = null;
|
|
212
215
|
/** The name and the faint orbit while the pointer rests on a satellite. */
|
|
213
216
|
#hover;
|
|
217
|
+
#pathControls;
|
|
214
218
|
#reach = null;
|
|
215
219
|
/** The page has set a `speed` since the element came into the page: for a reader who prefers reduced motion, that is the Play that lets meteors start. */
|
|
216
220
|
#played = false;
|
|
@@ -407,12 +411,23 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
407
411
|
style: () => hoverStyleOf(this),
|
|
408
412
|
});
|
|
409
413
|
this.#hover.sync();
|
|
414
|
+
this.#pathControls = bindPaths({
|
|
415
|
+
element: this,
|
|
416
|
+
state: this.#model.satellites,
|
|
417
|
+
request: () => this.#gate?.soon(),
|
|
418
|
+
pathAt: (x, y, radius) => this.#model.pathAt?.(x, y, radius) ?? null,
|
|
419
|
+
pick: (x, y) => this.#model.pick?.(x, y, 12) ?? null,
|
|
420
|
+
riding: () => false,
|
|
421
|
+
});
|
|
422
|
+
this.#pathControls.sync();
|
|
410
423
|
this.#startTick();
|
|
411
424
|
document.addEventListener("visibilitychange", this.#onVisible);
|
|
412
425
|
}
|
|
413
426
|
disconnectedCallback() {
|
|
414
427
|
this.#hover?.stop();
|
|
415
428
|
this.#hover = undefined;
|
|
429
|
+
this.#pathControls?.stop();
|
|
430
|
+
this.#pathControls = undefined;
|
|
416
431
|
this.removeEventListener("pointerdown", this.#take);
|
|
417
432
|
this.removeEventListener("pointerdown", this.#down);
|
|
418
433
|
this.removeEventListener("wheel", this.#wheel, { capture: true });
|
|
@@ -541,6 +556,9 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
541
556
|
}
|
|
542
557
|
else if (name === "hover-path" || name === "names-on-hover")
|
|
543
558
|
this.#hover?.sync();
|
|
559
|
+
else if (name === "selected-path")
|
|
560
|
+
this.#pathControls?.sync();
|
|
561
|
+
else if (name === "path-hit") { /* read at each press and move */ }
|
|
544
562
|
else if (name === "satellite-streak-max") {
|
|
545
563
|
this.#model.satellites.streakMax = readStreakMax(value);
|
|
546
564
|
this.#gate?.soon();
|
|
@@ -1199,6 +1217,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1199
1217
|
state: this.#state,
|
|
1200
1218
|
tiers: { ...this.#tiers },
|
|
1201
1219
|
satellites: this.#satelliteStats(),
|
|
1220
|
+
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
1202
1221
|
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 },
|
|
1203
1222
|
draws: stats?.draws ?? 0,
|
|
1204
1223
|
contexts: stats?.contexts ?? 0,
|
|
@@ -1437,6 +1456,102 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1437
1456
|
const chosen = this.#model.satellites.selected;
|
|
1438
1457
|
return chosen ? { ...chosen } : null;
|
|
1439
1458
|
}
|
|
1459
|
+
// --- paths -------------------------------------------------------------------------------------------------------------------------------------
|
|
1460
|
+
/**
|
|
1461
|
+
* Draw these satellites' orbits at once, each in a look from the table (`pathStyles`), without a satellite being chosen. One draw call for all of them and the chosen satellite's own orbit, and nothing is drawn at rest. At most 16 are kept, the last of the list.
|
|
1462
|
+
* `id` is a NORAD catalogue number or `group:index` (`stations:0`); an id that matches no satellite is skipped (`stats.paths.unresolved`). A satellite asked for twice is drawn once, in the later look. `style` is the name of a look (`selected`, `hovered`, `favourite`, `path`, or one of the page's own)
|
|
1463
|
+
* or a partial look over `path`. `[]` takes them all away. Where the pointer is on one, `chikyu-path-hover` and `chikyu-path-click` say which (`path-hit`).
|
|
1464
|
+
*
|
|
1465
|
+
* @param list - The paths, oldest first.
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```ts
|
|
1469
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
1470
|
+
*
|
|
1471
|
+
* const show = (space: ChikyuSpace): void => space.setPaths([{ id: 25544, style: "favourite" }, { id: "stations:1", style: { color: "#7fdbff", dash: [8, 4] } }]);
|
|
1472
|
+
* console.log(typeof show);
|
|
1473
|
+
* ```
|
|
1474
|
+
*/
|
|
1475
|
+
setPaths(list) {
|
|
1476
|
+
this.#pathControls?.setPaths(list);
|
|
1477
|
+
}
|
|
1478
|
+
/** The paths in use, as set (the last 16). Setting it is `setPaths`. */
|
|
1479
|
+
get paths() {
|
|
1480
|
+
return this.#pathControls?.paths ?? [];
|
|
1481
|
+
}
|
|
1482
|
+
set paths(list) {
|
|
1483
|
+
this.setPaths(list);
|
|
1484
|
+
}
|
|
1485
|
+
/**
|
|
1486
|
+
* Change the looks the paths are drawn in, by name. Each entry is a partial look over the built-in one of that name (or over `path`, for a name of the page's own); `null` takes the page's entry away. Without `replace` the entries are added to those already set.
|
|
1487
|
+
* The built-in looks differ by width and dash as well as colour: `selected` (white, 2 px, solid, also the look of the chosen satellite's own orbit), `hovered` (white, 1.5 px, dashed), `favourite` (amber, 1.75 px, dotted) and `path` (white, 1.5 px, solid).
|
|
1488
|
+
* A look is `{ color, width (0.5 to 8 CSS pixels), opacity (0 to 1), dash ([dash, gap] in CSS pixels, or null) }`.
|
|
1489
|
+
*
|
|
1490
|
+
* @param table - The entries by name.
|
|
1491
|
+
* @param replace - `true` to drop the entries set before.
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```ts
|
|
1495
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
1496
|
+
*
|
|
1497
|
+
* const quiet = (space: ChikyuSpace): void => space.setPathStyles({ selected: { color: "#ffd166", width: 3, dash: null } });
|
|
1498
|
+
* console.log(typeof quiet);
|
|
1499
|
+
* ```
|
|
1500
|
+
*/
|
|
1501
|
+
setPathStyles(table, replace = false) {
|
|
1502
|
+
this.#pathControls?.setStyles(table, replace);
|
|
1503
|
+
}
|
|
1504
|
+
/** The table of looks in use, whole: the built-in ones with the page's own over them. A copy. */
|
|
1505
|
+
get pathStyles() {
|
|
1506
|
+
return this.#pathControls?.styles ?? styleTable({});
|
|
1507
|
+
}
|
|
1508
|
+
set pathStyles(table) {
|
|
1509
|
+
this.setPathStyles(table, true);
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Draw the chosen satellite's own orbit (the attribute `selected-path`; on unless `off`). Off, `selectSatellite` still rings and names the satellite and a ride still follows it, but no line is drawn: the page draws it, with `setPaths` and the `selected` look, or its own. The look of the line when it is on is the `selected` entry of `pathStyles`.
|
|
1513
|
+
*/
|
|
1514
|
+
get selectedPath() {
|
|
1515
|
+
return this.getAttribute("selected-path") !== "off";
|
|
1516
|
+
}
|
|
1517
|
+
set selectedPath(value) {
|
|
1518
|
+
if (value)
|
|
1519
|
+
this.removeAttribute("selected-path");
|
|
1520
|
+
else
|
|
1521
|
+
this.setAttribute("selected-path", "off");
|
|
1522
|
+
}
|
|
1523
|
+
/**
|
|
1524
|
+
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
1525
|
+
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
1526
|
+
*/
|
|
1527
|
+
get pathHit() {
|
|
1528
|
+
return this.#pathControls?.hit ?? 8;
|
|
1529
|
+
}
|
|
1530
|
+
set pathHit(value) {
|
|
1531
|
+
if (Number.isFinite(value) && value >= 0)
|
|
1532
|
+
this.setAttribute("path-hit", String(value));
|
|
1533
|
+
else
|
|
1534
|
+
this.removeAttribute("path-hit");
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* 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`.
|
|
1538
|
+
*
|
|
1539
|
+
* @param x - CSS pixels from the element's left.
|
|
1540
|
+
* @param y - CSS pixels from its top.
|
|
1541
|
+
* @param radiusPx - How near the point must be, 0 to 200; `path-hit` when left out.
|
|
1542
|
+
* @returns The path, or `null` when none is within reach.
|
|
1543
|
+
*
|
|
1544
|
+
* @example
|
|
1545
|
+
* ```ts
|
|
1546
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
1547
|
+
*
|
|
1548
|
+
* const name = (space: ChikyuSpace, x: number, y: number): string => space.pathAt(x, y, 10)?.style ?? "none";
|
|
1549
|
+
* console.log(typeof name);
|
|
1550
|
+
* ```
|
|
1551
|
+
*/
|
|
1552
|
+
pathAt(x, y, radiusPx) {
|
|
1553
|
+
return this.#pathControls?.at(x, y, radiusPx) ?? null;
|
|
1554
|
+
}
|
|
1440
1555
|
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period, and `ownerCountry` when the owner is one country); undefined if it cannot be placed then. */
|
|
1441
1556
|
satelliteInfo(ref) {
|
|
1442
1557
|
return this.#model.satellites.groups.get(ref.group)?.satellites.info(ref.index, this.#model.time);
|
|
@@ -1471,8 +1586,13 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1471
1586
|
return;
|
|
1472
1587
|
const rect = this.getBoundingClientRect();
|
|
1473
1588
|
const satellite = this.#model.pick?.(event.clientX - rect.left, event.clientY - rect.top, 12);
|
|
1474
|
-
if (satellite)
|
|
1589
|
+
if (satellite) {
|
|
1590
|
+
claimPress(event);
|
|
1475
1591
|
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite) }, bubbles: true, composed: true }));
|
|
1592
|
+
return;
|
|
1593
|
+
}
|
|
1594
|
+
if (this.#pathControls?.press(event.clientX - rect.left, event.clientY - rect.top, pointerOf(event)))
|
|
1595
|
+
claimPress(event);
|
|
1476
1596
|
};
|
|
1477
1597
|
#wheel = (event) => immersiveWheel(this, event);
|
|
1478
1598
|
/** The view as it is (for a page that wants to read it back). */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// One press means one thing. A press that a satellite's dot or a path took (see space/path-controls.ts) is marked here, and the sky does not pick a star or a figure from it.
|
|
2
|
+
const claimed = new WeakSet();
|
|
3
|
+
/** Mark a press as taken. */
|
|
4
|
+
export const claimPress = (event) => {
|
|
5
|
+
claimed.add(event);
|
|
6
|
+
};
|
|
7
|
+
/** Whether a press was taken by a dot or a path. */
|
|
8
|
+
export const pressClaimed = (event) => claimed.has(event);
|
package/dist/sky/host.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// The names of the brightest stars and the constellations as faint lines, over the sky an element's page draws (hoshi-stars' `sky-labels`, loaded only when an attribute asks for it). The element tells this where the camera looks and what covers the sky at each draw
|
|
2
|
+
// (`frame`); it draws the names and lines on a canvas and a few labels over the picture, never redraws at rest, and lights the figure under the pointer. Stars are directions, so only the camera's turn matters, never its distance.
|
|
3
|
+
import { pressClaimed } from "./claim.js";
|
|
1
4
|
import { canvasRatio } from "../markers/project.js";
|
|
2
5
|
import { boxCovered, pathOutside, touches } from "./cover.js";
|
|
3
6
|
import { cultureLoaders } from "./culture-source.js";
|
|
@@ -260,6 +263,8 @@ export function createSkyHost(options) {
|
|
|
260
263
|
down = undefined;
|
|
261
264
|
if (!start || start.id !== event.pointerId)
|
|
262
265
|
return;
|
|
266
|
+
if (pressClaimed(event))
|
|
267
|
+
return;
|
|
263
268
|
const here = place(event);
|
|
264
269
|
// a press that did not move, and was not held: a click or a tap, not the start of a turn
|
|
265
270
|
if (Math.hypot(here.x - start.x, here.y - start.y) > 6 || event.timeStamp - start.at > 600)
|
|
@@ -19,6 +19,8 @@ import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/type
|
|
|
19
19
|
import { type PlanetName } from "./ephemeris.ts";
|
|
20
20
|
import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts";
|
|
21
21
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
22
|
+
import { type PathStats } from "./path-controls.ts";
|
|
23
|
+
import { type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
22
24
|
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
23
25
|
import { type ScaleMode } from "./scale.ts";
|
|
24
26
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
@@ -712,6 +714,73 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
712
714
|
selectSatellite(ref: SatelliteRef | null): void;
|
|
713
715
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
714
716
|
get selectedSatellite(): SatelliteRef | null;
|
|
717
|
+
/**
|
|
718
|
+
* Draw these satellites' orbits at once, each in a look from the table (`pathStyles`), without a satellite being chosen. One draw call for all of them and the chosen satellite's own orbit, and nothing is drawn at rest. At most 16 are kept, the last of the list.
|
|
719
|
+
* `id` is a NORAD catalogue number or `group:index` (`stations:0`); an id that matches no satellite is skipped (`stats.paths.unresolved`). A satellite asked for twice is drawn once, in the later look. `style` is the name of a look (`selected`, `hovered`, `favourite`, `path`, or one of the page's own)
|
|
720
|
+
* or a partial look over `path`. `[]` takes them all away. Where the pointer is on one, `chikyu-path-hover` and `chikyu-path-click` say which (`path-hit`).
|
|
721
|
+
*
|
|
722
|
+
* @param list - The paths, oldest first.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* ```ts
|
|
726
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
727
|
+
*
|
|
728
|
+
* const show = (space: ChikyuSpace): void => space.setPaths([{ id: 25544, style: "favourite" }, { id: "stations:1", style: { color: "#7fdbff", dash: [8, 4] } }]);
|
|
729
|
+
* console.log(typeof show);
|
|
730
|
+
* ```
|
|
731
|
+
*/
|
|
732
|
+
setPaths(list: readonly PathRequest[]): void;
|
|
733
|
+
/** The paths in use, as set (the last 16). Setting it is `setPaths`. */
|
|
734
|
+
get paths(): PathRequest[];
|
|
735
|
+
set paths(list: readonly PathRequest[]);
|
|
736
|
+
/**
|
|
737
|
+
* Change the looks the paths are drawn in, by name. Each entry is a partial look over the built-in one of that name (or over `path`, for a name of the page's own); `null` takes the page's entry away. Without `replace` the entries are added to those already set.
|
|
738
|
+
* The built-in looks differ by width and dash as well as colour: `selected` (white, 2 px, solid, also the look of the chosen satellite's own orbit), `hovered` (white, 1.5 px, dashed), `favourite` (amber, 1.75 px, dotted) and `path` (white, 1.5 px, solid).
|
|
739
|
+
* A look is `{ color, width (0.5 to 8 CSS pixels), opacity (0 to 1), dash ([dash, gap] in CSS pixels, or null) }`.
|
|
740
|
+
*
|
|
741
|
+
* @param table - The entries by name.
|
|
742
|
+
* @param replace - `true` to drop the entries set before.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```ts
|
|
746
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
747
|
+
*
|
|
748
|
+
* const quiet = (space: ChikyuSpace): void => space.setPathStyles({ selected: { color: "#ffd166", width: 3, dash: null } });
|
|
749
|
+
* console.log(typeof quiet);
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
setPathStyles(table: Readonly<Record<string, Partial<PathStyle> | null>>, replace?: boolean): void;
|
|
753
|
+
/** The table of looks in use, whole: the built-in ones with the page's own over them. A copy. */
|
|
754
|
+
get pathStyles(): Record<string, PathStyle>;
|
|
755
|
+
set pathStyles(table: Readonly<Record<string, Partial<PathStyle> | null>>);
|
|
756
|
+
/**
|
|
757
|
+
* Draw the chosen satellite's own orbit (the attribute `selected-path`; on unless `off`). Off, `selectSatellite` still rings and names the satellite and a ride still follows it, but no line is drawn: the page draws it, with `setPaths` and the `selected` look, or its own. The look of the line when it is on is the `selected` entry of `pathStyles`.
|
|
758
|
+
*/
|
|
759
|
+
get selectedPath(): boolean;
|
|
760
|
+
set selectedPath(value: boolean);
|
|
761
|
+
/**
|
|
762
|
+
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
763
|
+
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
764
|
+
*/
|
|
765
|
+
get pathHit(): number;
|
|
766
|
+
set pathHit(value: number);
|
|
767
|
+
/**
|
|
768
|
+
* 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`.
|
|
769
|
+
*
|
|
770
|
+
* @param x - CSS pixels from the element's left.
|
|
771
|
+
* @param y - CSS pixels from its top.
|
|
772
|
+
* @param radiusPx - How near the point must be, 0 to 200; `path-hit` when left out.
|
|
773
|
+
* @returns The path, or `null` when none is within reach.
|
|
774
|
+
*
|
|
775
|
+
* @example
|
|
776
|
+
* ```ts
|
|
777
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
778
|
+
*
|
|
779
|
+
* const name = (space: ChikyuSpace, x: number, y: number): string => space.pathAt(x, y, 10)?.style ?? "none";
|
|
780
|
+
* console.log(typeof name);
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
pathAt(x: number, y: number, radiusPx?: number): PathHit | null;
|
|
715
784
|
/**
|
|
716
785
|
* Ring and name every satellite of a group (or stop): a ring round each and its name beside it, in the page's language (the ISS, Tiangong and Hubble by their short names, the rest as their elements name them, or as `satelliteNames` says), never over another name, a place's or a ring's.
|
|
717
786
|
* Names and rings are drawn with the places, only for satellites that are in the picture and not behind the Earth, and nothing is drawn at rest. `chikyu-satellite-visibility` is sent with `detail: { ref, visible }` when a labelled satellite comes into view or goes out of it (not at every frame).
|
|
@@ -769,6 +838,8 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
769
838
|
time: number;
|
|
770
839
|
lookups: number;
|
|
771
840
|
satellites: SatelliteStats;
|
|
841
|
+
/** 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. */
|
|
842
|
+
paths: PathStats;
|
|
772
843
|
ride: {
|
|
773
844
|
riding: boolean;
|
|
774
845
|
lost: boolean;
|