@johnmorrisdotca/chikyu-earth 0.52.0 → 0.54.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +4 -2
  3. package/dist/flat/colours.d.ts +55 -0
  4. package/dist/flat/colours.js +71 -0
  5. package/dist/flat/define.d.ts +3 -0
  6. package/dist/flat/define.js +6 -0
  7. package/dist/flat/element.d.ts +188 -0
  8. package/dist/flat/element.js +1541 -0
  9. package/dist/flat/facts.d.ts +172 -0
  10. package/dist/flat/facts.js +168 -0
  11. package/dist/flat/geometry.d.ts +160 -0
  12. package/dist/flat/geometry.js +156 -0
  13. package/dist/flat/index.d.ts +6 -0
  14. package/dist/flat/index.js +7 -0
  15. package/dist/flat/track-state.d.ts +174 -0
  16. package/dist/flat/track-state.js +223 -0
  17. package/dist/flat/words.d.ts +25 -0
  18. package/dist/flat/words.js +78 -0
  19. package/dist/passes/index.d.ts +2 -1
  20. package/dist/passes/index.js +1 -1
  21. package/dist/passes/passes.d.ts +34 -0
  22. package/dist/passes/passes.js +43 -2
  23. package/dist/realistic/element-base.d.ts +6 -0
  24. package/dist/realistic/element-base.js +15 -2
  25. package/dist/space/compass.d.ts +36 -0
  26. package/dist/space/compass.js +72 -0
  27. package/dist/space/element-base.d.ts +48 -1
  28. package/dist/space/element-base.js +95 -6
  29. package/dist/space/index.d.ts +2 -1
  30. package/dist/space/index.js +1 -0
  31. package/dist/space/north-up.d.ts +86 -0
  32. package/dist/space/north-up.js +104 -0
  33. package/dist/space/path-controls.d.ts +1 -1
  34. package/dist/space/path-controls.js +13 -2
  35. package/dist/space/path-ribbons.d.ts +4 -0
  36. package/dist/space/path-ribbons.js +8 -4
  37. package/dist/space/satellite-layer.d.ts +5 -0
  38. package/dist/space/satellite-layer.js +16 -4
  39. package/dist/space/scene.d.ts +23 -0
  40. package/dist/space/scene.js +18 -1
  41. package/package.json +13 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.54.0 - 2026-11-17
6
+
7
+ - **North up in the view above a satellite, a compass, and sunlit or in shadow on the ground track** (MODULES-1437). Riding above the ISS the way it is going was always at the top of the picture, so a reader could not tell its real direction (astroviewer shows it heading south-east).
8
+ - **North up.** `ride(ref, { view: "above", up: "north" })`, the attribute `ride-up="north"` and the property `rideUp` put north at the top of the picture, so the satellite is seen to move the way it really moves over the ground. `"travel"` is the default and today's look. Set while riding, the picture turns to the new up in a glide of 0.8 s (a jump for reduced motion). **Pole rule:** within 3 degrees of a pole north-up gives way to travel-up, mixed in by a smooth step out to 6 degrees, so the picture never jumps; `NORTH_UP_POLE_DEG`, `NORTH_UP_BLEND_DEG`, `northUpYaw`, `localNorth` and `screenAngle` are in `/space`. **A drag** turns the picture from north by the amount dragged, and the compass shows where north has gone.
9
+ - **Compass.** A DOM overlay in the shadow root (an arrow to north with an N, a dot on the rim for the way it is going, and "Heading SE 128°"), in English and Japanese, in every ride of a satellite. It is updated by the draw that moves it, only when it moved by half a degree (a degree for the words): nothing at rest, no timer. `compass="off"` hides it, `compass="north"` keeps the arrow only; `--chikyu-compass-colour` and `--chikyu-compass-travel`.
10
+ - **Heading as numbers.** `rideTrack` (and `stats.ride.track`) and the event `chikyu-ride-track` give `lat`, `lon`, `heightKm`, `bearingDeg` (the ground track's direction from north, the Earth's turn taken out), `ascending`, `sunlit`, `northDeg` and `travelDeg`; the event is sent only when the whole degree, `ascending` or `sunlit` changes. Pure: `trackStateOf(position, velocity, ms)` and `trackStateOfScene` in `/flat` (no dependency), `groundTrackState(elements, ms)` in `/passes` (SGP4), `compassPoint`, `sunDirection`, `inEarthShadow`.
11
+ - **Sunlit or in shadow.** The ground track of `<chikyu-flat>` is amber in sunlight and blue in the Earth's shadow (a key under the map; `--chikyu-flat-track-sun`, `--chikyu-flat-track-shadow`), and so is the chosen satellite's orbit on `<chikyu-space>` and `<chikyu-earth-realistic>` (`path-light="off"` for one colour; `--chikyu-path-sun`, `--chikyu-path-shadow`), a change of look for the `selected` path's white. **The shadow model is a cylinder** of the Earth's equatorial radius (6,378.137 km) along the line from the Sun: no umbra cone, no penumbra (the cone's edge is about 11 km inside the cylinder's where the ISS enters, a few seconds). `chikyu-flat-pick` carries `sunlit`, `bearingDeg` and `ascending`; `stateOf(id)` and `selectedState` on the flat element; `groundTrack` points have `sunlit`.
12
+ - **Tests and docs.** Unit tests of the bearing against the analytic polar orbit and the 51.6 degree equator crossing (35.4 degrees), ascending and descending, the cylinder, and the ISS's share of an orbit in shadow against `acos(sqrt(1 - (Re/r)^2) / cos beta) / pi` at four Sun angles (within 1 percentage point); the north-up rule and the pole rule; `e2e/north-up.demo.ts` (north at the top and the compass at 0, travel up, a drag, the switch, reduced motion, the heading event, the flat track's two colours), and the `north` look in the freeze test. English and Japanese guides (the Japanese read by the Japanese reviewer), a tested example `examples/node/track-state.mjs`, and a demo row "Up is".
13
+
14
+ ## 0.53.0 - 2026-11-16
15
+
16
+ - **`<chikyu-flat>`: satellites on a flat map of the world** (MODULES-1391). A new entry `@johnmorrisdotca/chikyu-earth/flat/define` registers the element, and `@johnmorrisdotca/chikyu-earth/flat` holds its pure parts (they import on a server, with no dependency, not even satellite.js).
17
+ - **Map.** Plate carree on two canvases (map and dots), with the country outlines, a graticule and the night side from the real Sun. `center` is the longitude in the middle (0, Greenwich, by default), wraps cleanly at the date line, and the built-in **Greenwich** and **My place** buttons switch; My place and a marker at the place appear only when the page gives `home-lon` and `home-lat` (the element never asks for a location). A box taller than 2 to 1 (a phone) is filled; touch pan, two-finger pinch zoom, + and - buttons and keys, Control or Command and the wheel zoom.
18
+ - **Satellites.** `setGroup(id, sets, style?)` for each group, `elements` for one, or `elements-src`; the `group` attribute names the groups shown and `off` those that start off (Starlink). Colour by group, or `colour-by="plane"` by orbital plane. Filter chips (groups, or planes) are built in and are the legend; `controls="none"` leaves the page to drive `group` and `plane`. `planes`, `facts(id)`, `groups`, `visibleGroups`, `selected`, `placeOf`. Optional `footprint` (the coverage circle) and `track` (the ground track of the chosen satellite, which follows the clock). Events `chikyu-flat-pick`, `chikyu-flat-filter`, `chikyu-flat-planes`, `chikyu-flat-view` and `chikyu-timechange`. Keyboard: arrow keys move from dot to dot, Enter chooses, Escape clears; hover and tap pick.
19
+ - **The clock is the 3D view's.** `time`, `speed` and `paused` as attributes and properties. The dots move every frame the motion needs (up to 60 a second) while time runs; a jump of `time` moves them at once; `paused` draws nothing. Up to 60 times real time every dot is placed by SGP4 with interpolation; faster, the dots are turned along their orbits and drawn as streaks (`trails="off"` for plain dots), so a day a second is a trail, not a flicker. Measured: 12,295 dots (all of Starlink and the other groups) at 600 times real time drew 60 frames a second at about 6 ms a frame, in streaks, in a browser drawing in software. The canvases are drawn by the processor (`willReadFrequently`), not the graphics card: the same draw ran 1 frame a second on the graphics card emulated in software. Nothing is drawn at rest, out of sight or in a hidden tab, and a reader who asked for reduced motion gets one frame a second.
20
+ - **Pure helpers, tested.** `groupFacts(sets)` (count, mean, lowest and highest height, inclination, period, speed, plane count and planes) and `clusterPlanes(sets)` (the right ascension of the ascending node, cut at gaps wider than 10 degrees: GPS 6 planes, Galileo and GLONASS 3, Iridium 6, OneWeb 12; Starlink is one blob and says `clustered: false`), with the map's geometry (`projectFlat`, `unprojectFlat`, `zoomAbout`, `clampView`, `groundPoint`), the colours and the English and Japanese words.
21
+ - **Docs and tests.** A demo page `flat.html` and a guide in English and Japanese (the Japanese read by the Japanese reviewer), two tested usage examples (`examples/node/flat.mjs`, `examples/flat.html`), unit tests, `e2e/flat.demo.ts` (desk, phone, Chromium and WebKit), and in the freeze test: nothing drawn at rest, a frame at a time at 600 times real time, nothing out of sight or in a hidden tab, canvases inside 6 million pixels.
22
+ - **Decision needed, not applied: one orbit-level definition.** The site's `levelOf` (hero-src/orbit-levels.ts) and this package's `classOfElements` disagree on 53 of the site's 16,903 satellites, and in their rules: the site has no eccentricity test (a low orbit is anything under 2,000 km at the top), keeps the geostationary band at 2,500 km (the package 1,500 km), takes Medium up to 32,000 km (the package 34,286 km), splits Medium at 8,000 km into Outer and Medium, and puts everything left in Far (the package says `heo` from an eccentricity of 0.25 and `other` for the rest). Its heights use 6,378.137 km, the package's 6,371 km. On the file: 46 are Far in the site and `heo` here (the same set, named differently); 5 are Far there and `other` here; 1 is Far there and `meo` here (apogee 32,000 to 34,286 km); 1 is Geostationary there and `other` here (outside 1,500 km, inside 2,500 km). Proposal: make `classOfElements` and `orbitClass` follow `levelOf` (2,500 km band, 32,000 km, no eccentricity rule, `outer` as a class) in a minor release with a note here, and have the census follow the same numbers. Nothing in the flat map reads a class.
23
+
5
24
  ## 0.52.0 - 2026-11-16
6
25
 
7
26
  - **A drag in a ride turns the view from where the vehicle is, not the vehicle round the camera** (MODULES-1374). In a ride of a satellite with the `outside` viewpoint (the default), dragging looked about but took the camera round the satellite as it looked, so the satellite was seen from every side and the whole vehicle seemed to be moved. A drag now turns the view where the camera is, like turning your head, in both looks (`horizon`, Ride along, and `down`, Ride above): the camera keeps its place 25 km behind and above the satellite and the scene turns round it; the satellite is at its share and seat of the picture while you do not drag and leaves it as you look away. **A change of behaviour**: `ride-drag="orbit"` (property `rideDrag`, option `drag` of `ride`, field `drag` of `Riding`) brings the old look-around back; the default is `head`. `outsidePose` takes an optional `rest` (the pose with no drag) and keeps the camera where that puts it; without it, it works as before. Inside the satellite, the `follow` and `above` views and riding a body are unchanged. Tests: unit tests of the pose maths (the camera does not move under any drag in `head`, the satellite holds its place in `orbit`, the pace of the ground), and `e2e/ride-outside.gl.ts` for both looks and both modes. English and Japanese guides and the upgrading page.
package/README.md CHANGED
@@ -359,7 +359,7 @@ Passes are only as good as the orbit data are new: each pass says how old its el
359
359
  <p align="center"><img alt="Riding along with the ISS, tipped towards the horizon: the Earth's curve and atmosphere, and the orbits of the other stations in the sky" src="docs/images/space-ride-horizon.png" width="420"></p>
360
360
 
361
361
  `space.ride({ group: "stations", index: 0 }, { look: "horizon" })` puts the camera on the ISS (or a Starlink satellite, the Moon, a planet) at its real place for the moment shown and looks at the Earth, which goes by beneath
362
- as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. A drag turns the view where the camera is, like turning your head (the satellite leaves the picture as you look away); `ride-drag="orbit"` (property `rideDrag`, option `drag`) takes the camera round the satellite as before. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
362
+ as the body moves along its orbit; switch to another body and the camera glides there. Straight down or toward the horizon, from the body or following it at a distance, time faster or slower. A ridden satellite is in the picture by default (the camera a little behind and above it, a small drawing of it where the page has no model, not to scale); `ride-viewpoint="inside"` (property `rideViewpoint`, option `viewpoint`) puts the camera at the satellite instead. A drag turns the view where the camera is, like turning your head (the satellite leaves the picture as you look away); `ride-drag="orbit"` (property `rideDrag`, option `drag`) takes the camera round the satellite as before. Seen from above, the model shrinks as the ride rises and hands over to the ordinary mark by 2,000 km; `ride-model-size="fixed"` (property `rideModelSize`, option `modelSize`) keeps one size at every height. `ride-up="north"` (property `rideUp`, option `up`) puts north at the top of the view above a satellite, so it is seen to go the way it really goes; a small compass on a ride shows north and the heading (`compass="off"` hides it), `rideTrack` and `chikyu-ride-track` give the heading, ground point and whether the Sun lights it, and the chosen orbit is amber in sunlight and blue in the Earth's shadow (`path-light="off"` for one colour). `ride-model-share`, `ride-model-seat` and `ride-zoom` frame and zoom the ridden satellite (properties `rideModelShare`, `rideModelSeat`, `rideZoom`). It animates continuously, so it keeps to the
363
363
  same budget: at most 30 frames a second (one a second for reduced motion), nothing drawn while paused, out of sight or hidden. [Ride along guide](docs/guides/ride-along.md), [docs/ride-along.md](docs/ride-along.md).
364
364
 
365
365
  ## Printable sheets
@@ -554,6 +554,7 @@ The reference is a site, made from the source's own doc comments: every export h
554
554
  | `.../meteors` | The year's meteor showers, and when and where their meteors fall. No DOM, no dependency. |
555
555
  | `.../door` | The data door: sources of your own maps and orbit data with their licence and credit, `creditLine`, the package's own sources. No DOM, no dependency. |
556
556
  | `.../passes`, `.../passes/element` | Passes of a satellite over a place, the sky dome, `<chikyu-passes>`; `satellite.js`. |
557
+ | `.../flat`, `.../flat/define` | The facts and orbital planes of a group of satellites (no dependency), and `<chikyu-flat>`, satellites on a flat world map; `satellite.js` for the element. |
557
558
  | `.../catalogue` | The Earth-orbit catalogue's pure parts: the class of an orbit from its elements, the kind of an object, colours, legend, fleets, and the packed file of up to 200,000 objects. No data, no DOM, no dependency. |
558
559
 
559
560
  ## Guides
@@ -572,6 +573,7 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
572
573
  | [Satellites](docs/guides/satellites.md) | SGP4 and the space view |
573
574
  | [Full screen, the camera in the stars and every satellite](docs/guides/full-screen-and-camera.md) | `immersive`, `camera="space"`, the Earth's look, and every satellite group on the realistic Earth |
574
575
  | [When can I see the ISS?](docs/guides/passes.md) | Passes over a place, the sky dome, how it was checked |
576
+ | [Satellites on a flat map](docs/guides/flat-map.md) | `<chikyu-flat>`: groups, orbital planes, footprints, the ground track, the clock; the facts of a group |
575
577
  | [Ride along](docs/guides/ride-along.md) | A camera on a moving body |
576
578
  | [The date follows the clock, and Play](docs/guides/time-and-play.md) | The `chikyu-timechange` event, a `speed` for the space view and the realistic Earth, Play, Pause and Back |
577
579
  | [Names on the stars and faint constellation lines](docs/guides/sky-names.md) | The brightest stars named and the constellations as faint lines over the sky, in hoshi-stars' attribute names |
@@ -612,7 +614,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
612
614
 
613
615
  ## How to cite
614
616
 
615
- > Morris, J. (2026). *Chikyu Earth* (version 0.52.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
617
+ > Morris, J. (2026). *Chikyu Earth* (version 0.54.0) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
616
618
 
617
619
  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
620
 
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The colour of each of the package's satellite groups, the same as the demo draws them, for a dark map.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { GROUP_COLOURS } from "@johnmorrisdotca/chikyu-earth/flat";
7
+ *
8
+ * console.log(GROUP_COLOURS["gps"]);
9
+ * ```
10
+ */
11
+ export declare const GROUP_COLOURS: Readonly<Record<string, string>>;
12
+ /**
13
+ * The colours of the planes of a group, in order: `A` is the first, and the twelfth is followed by the first again.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { PLANE_COLOURS } from "@johnmorrisdotca/chikyu-earth/flat";
18
+ *
19
+ * console.log(PLANE_COLOURS.length, PLANE_COLOURS[0]);
20
+ * ```
21
+ */
22
+ export declare const PLANE_COLOURS: readonly string[];
23
+ /**
24
+ * The grey of the satellites that are in no plane.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { SPARE_COLOUR } from "@johnmorrisdotca/chikyu-earth/flat";
29
+ *
30
+ * console.log(SPARE_COLOUR);
31
+ * ```
32
+ */
33
+ export declare const SPARE_COLOUR = "#9aa5b1";
34
+ /**
35
+ * The colour of a ground track where the satellite is in sunlight: a warm amber. It is one half of a pair chosen to be told apart by a reader who cannot tell red from green (amber and blue differ in lightness as well as in hue), and each stretch is drawn over a dark edge so it reads on a dark sea and on a light one. The element's `--chikyu-flat-track-sun` overrides it.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { TRACK_SUNLIT } from "@johnmorrisdotca/chikyu-earth/flat";
40
+ *
41
+ * console.log(TRACK_SUNLIT);
42
+ * ```
43
+ */
44
+ export declare const TRACK_SUNLIT = "#ffb02e";
45
+ /**
46
+ * The colour of a ground track where the satellite is in the Earth's shadow: a cool blue. The element's `--chikyu-flat-track-shadow` overrides it.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * import { TRACK_SHADOW } from "@johnmorrisdotca/chikyu-earth/flat";
51
+ *
52
+ * console.log(TRACK_SHADOW);
53
+ * ```
54
+ */
55
+ export declare const TRACK_SHADOW = "#5aa9ff";
@@ -0,0 +1,71 @@
1
+ // The colours of the flat map: one for each group of the package, and twelve for the orbital planes of a group. Chosen for a dark sea; each is read against the map's own colours.
2
+ /**
3
+ * The colour of each of the package's satellite groups, the same as the demo draws them, for a dark map.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { GROUP_COLOURS } from "@johnmorrisdotca/chikyu-earth/flat";
8
+ *
9
+ * console.log(GROUP_COLOURS["gps"]);
10
+ * ```
11
+ */
12
+ export const GROUP_COLOURS = {
13
+ stations: "#ffd54f",
14
+ famous: "#ff8a65",
15
+ science: "#b39ddb",
16
+ "earth-observation": "#69f0ae",
17
+ weather: "#4dd0e1",
18
+ geostationary: "#f48fb1",
19
+ gps: "#ffb74d",
20
+ glonass: "#ef5350",
21
+ galileo: "#64b5f6",
22
+ beidou: "#fff176",
23
+ amateur: "#aed581",
24
+ oneweb: "#ce93d8",
25
+ iridium: "#80cbc4",
26
+ starlink: "#7fd4ff",
27
+ };
28
+ /**
29
+ * The colours of the planes of a group, in order: `A` is the first, and the twelfth is followed by the first again.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { PLANE_COLOURS } from "@johnmorrisdotca/chikyu-earth/flat";
34
+ *
35
+ * console.log(PLANE_COLOURS.length, PLANE_COLOURS[0]);
36
+ * ```
37
+ */
38
+ export const PLANE_COLOURS = ["#ff7a59", "#ffd23f", "#6ee7a0", "#4cc9f0", "#a78bfa", "#ff9ecb", "#f4a261", "#b8e986", "#5eead4", "#7aa2ff", "#e879f9", "#fde68a"];
39
+ /**
40
+ * The grey of the satellites that are in no plane.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { SPARE_COLOUR } from "@johnmorrisdotca/chikyu-earth/flat";
45
+ *
46
+ * console.log(SPARE_COLOUR);
47
+ * ```
48
+ */
49
+ export const SPARE_COLOUR = "#9aa5b1";
50
+ /**
51
+ * The colour of a ground track where the satellite is in sunlight: a warm amber. It is one half of a pair chosen to be told apart by a reader who cannot tell red from green (amber and blue differ in lightness as well as in hue), and each stretch is drawn over a dark edge so it reads on a dark sea and on a light one. The element's `--chikyu-flat-track-sun` overrides it.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * import { TRACK_SUNLIT } from "@johnmorrisdotca/chikyu-earth/flat";
56
+ *
57
+ * console.log(TRACK_SUNLIT);
58
+ * ```
59
+ */
60
+ export const TRACK_SUNLIT = "#ffb02e";
61
+ /**
62
+ * The colour of a ground track where the satellite is in the Earth's shadow: a cool blue. The element's `--chikyu-flat-track-shadow` overrides it.
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import { TRACK_SHADOW } from "@johnmorrisdotca/chikyu-earth/flat";
67
+ *
68
+ * console.log(TRACK_SHADOW);
69
+ * ```
70
+ */
71
+ export const TRACK_SHADOW = "#5aa9ff";
@@ -0,0 +1,3 @@
1
+ import { ChikyuFlat } from "./element.ts";
2
+ export { ChikyuFlat };
3
+ export type { FlatPick, FlatPlane, GroupStyle } from "./element.ts";
@@ -0,0 +1,6 @@
1
+ // Registers <chikyu-flat>. Importing this entry point (`@johnmorrisdotca/chikyu-earth/flat/define`) defines the tag once; it needs satellite.js (an optional peer).
2
+ import { ChikyuFlat } from "./element.js";
3
+ export { ChikyuFlat };
4
+ if (typeof customElements !== "undefined" && !customElements.get("chikyu-flat")) {
5
+ customElements.define("chikyu-flat", ChikyuFlat);
6
+ }
@@ -0,0 +1,188 @@
1
+ import type { ElementSet } from "../satellites/types.ts";
2
+ import { type GroupFacts, type Plane } from "./facts.ts";
3
+ import { type GroundTrackState } from "./track-state.ts";
4
+ import { type FlatLang } from "./words.ts";
5
+ /**
6
+ * One satellite of a group, as a page is told of it: what `chikyu-flat-pick` carries.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import type { FlatPick } from "@johnmorrisdotca/chikyu-earth/flat";
11
+ *
12
+ * const show = (pick: FlatPick): string => `${pick.name} (${pick.id}) in ${pick.group}`;
13
+ * console.log(typeof show);
14
+ * ```
15
+ */
16
+ export interface FlatPick {
17
+ /** The NORAD catalogue number. */
18
+ id: number;
19
+ /** Where it is in its group's element sets. */
20
+ index: number;
21
+ group: string;
22
+ name: string;
23
+ /** The letter of its orbital plane (`A`), or null when it is in none. */
24
+ plane: string | null;
25
+ altitudeKm: number;
26
+ /** True when the Sun lights it, false when it is in the Earth's shadow (the cylindrical model of `inEarthShadow`), at the moment shown. Null when it cannot be placed exactly then. */
27
+ sunlit: boolean | null;
28
+ /** The way its ground track runs, degrees clockwise from north (0 to 360), at the moment shown; null when it cannot be placed exactly. */
29
+ bearingDeg: number | null;
30
+ /** True going north, false going south; null when it cannot be placed exactly. */
31
+ ascending: boolean | null;
32
+ /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
33
+ via: "hover" | "tap" | "key";
34
+ }
35
+ /**
36
+ * An orbital plane of a loaded group, with the group's id and the colour the map gives it: what the element's `planes` lists.
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * import type { FlatPlane } from "@johnmorrisdotca/chikyu-earth/flat";
41
+ *
42
+ * const chip = (plane: FlatPlane): string => `${plane.group} ${plane.id} (${plane.count})`;
43
+ * console.log(typeof chip);
44
+ * ```
45
+ */
46
+ export interface FlatPlane extends Plane {
47
+ group: string;
48
+ colour: string;
49
+ }
50
+ /**
51
+ * How a group looks and is called, when the package does not already know it (`SATELLITE_GROUPS` names the 14 it knows).
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * import type { GroupStyle } from "@johnmorrisdotca/chikyu-earth/flat";
56
+ *
57
+ * const style: GroupStyle = { colour: "#ffffff", label: "My satellites", labelJa: "私の衛星" };
58
+ * console.log(style.label);
59
+ * ```
60
+ */
61
+ export interface GroupStyle {
62
+ colour?: string;
63
+ label?: string;
64
+ labelJa?: string;
65
+ }
66
+ /**
67
+ * The `<chikyu-flat>` custom element: satellites on a flat map of the world, at the places SGP4 puts them for the time shown. Import `@johnmorrisdotca/chikyu-earth/flat/define` to register the tag; it needs `satellite.js` (an optional peer).
68
+ *
69
+ * The page gives it orbital elements: `setGroup(id, sets)` for each group (the ids of `SATELLITE_GROUPS` are known by name and colour), or the `elements` property for one, or `elements-src` (an address, read once, through `fetchElements`' rules). The package fetches nothing of its own.
70
+ * Attributes: `center` (the longitude in the middle, degrees; 0, Greenwich, by default; the map wraps round the date line), `home-lon` and `home-lat` (the reader's place: a marker, and the "My place" button, which appear only when given; the element never asks the browser for a place),
71
+ * `group` (which groups to show: `all`, one id, or several with commas), `off` (groups that are loaded but start off when `group` names none, such as `starlink`: the filter chip turns one on), `colour-by` (`group`, or `plane` to colour by orbital plane), `plane` (a plane letter: show that plane only), `footprint` and `track` (draw the coverage circle and the ground track, which is amber in sunlight and blue in the Earth's shadow, a cylinder, with a key: `--chikyu-flat-track-sun` and `--chikyu-flat-track-shadow` change the colours; the footprint is of the chosen satellite, or of every one shown when there are 80 or fewer),
72
+ * `paused` (hold the clock and keep the speed; nothing is drawn while it is held), `trails` (`off` for no streaks at a fast clock), `footprint-elevation` (degrees above the horizon the circle is drawn for; 25 like the 3D beam), `selected` (a NORAD number: the chosen satellite), `time` (`now` or an ISO date; live when absent), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `estimate-far`, `shade` (`off` for no night),
73
+ * `dot-size` (pixels), `controls` (`none`, or any of `centre zoom footprint track chips`: the built-in buttons and filter chips shown; all by default) and `lang` (`en` or `ja`; the page's language by default).
74
+ *
75
+ * Events: `chikyu-flat-pick` (a satellite under the pointer, tapped, or reached by the keyboard: a `FlatPick`; `detail.id` is null when a tap lands on nothing and clears the choice), `chikyu-flat-filter` (a chip changed which groups or plane are shown: `{ groups, plane }`),
76
+ * `chikyu-flat-planes` (the planes were worked out: `{ planes }`), `chikyu-flat-view` (the reader panned or zoomed: `{ center, zoom }`) and `chikyu-timechange` (`{ time, running }`, at most four a second while time runs).
77
+ * Style it with the custom properties `--chikyu-flat-sea`, `--chikyu-flat-land`, `--chikyu-flat-line`, `--chikyu-flat-night`, `--chikyu-flat-aspect`, `--chikyu-flat-aspect-narrow` and `--chikyu-flat-radius`.
78
+ *
79
+ * @example
80
+ * ```ts no-run
81
+ * import "@johnmorrisdotca/chikyu-earth/flat/define";
82
+ * import type { ChikyuFlat } from "@johnmorrisdotca/chikyu-earth/flat/define";
83
+ * import type { ElementSet } from "@johnmorrisdotca/chikyu-earth/satellites";
84
+ *
85
+ * declare const gpsElements: ElementSet[]; // your page's own element sets
86
+ * const flat = document.createElement("chikyu-flat") as ChikyuFlat;
87
+ * flat.setAttribute("center", "139.7");
88
+ * flat.setAttribute("colour-by", "plane");
89
+ * flat.setGroup("gps", gpsElements);
90
+ * document.body.append(flat);
91
+ * flat.addEventListener("chikyu-flat-pick", (event) => console.log((event as CustomEvent).detail.name));
92
+ * ```
93
+ */
94
+ export declare class ChikyuFlat extends HTMLElement {
95
+ #private;
96
+ static observedAttributes: string[];
97
+ /**
98
+ * Hand over a group's orbital elements, or take the group away with `null`. The satellites start SGP4 here (a Starlink-sized group takes a fraction of a second), the facts and orbital planes are worked out, and the next draw shows them.
99
+ * `id` is a name of `SATELLITE_GROUPS` (`gps`, `starlink`: its words and colour are known) or any name of the page's own, with `style` for its colour and words.
100
+ *
101
+ * @param id - The group's name.
102
+ * @param sets - Its element sets, as `createSatellites` takes them; `null` removes the group.
103
+ * @param style - The colour and the English and Japanese names of a group the package does not know.
104
+ */
105
+ setGroup(id: string, sets: readonly ElementSet[] | null, style?: GroupStyle): void;
106
+ /** The element sets of the group the attributes name (`group`, else `satellites`): a shorthand for one group. Setting it calls `setGroup`. */
107
+ get elements(): readonly ElementSet[];
108
+ set elements(sets: readonly ElementSet[]);
109
+ /** The groups loaded, in the order they were given: their name, words, colour and how many satellites started SGP4. */
110
+ get groups(): readonly {
111
+ id: string;
112
+ label: string;
113
+ labelJa: string;
114
+ colour: string;
115
+ count: number;
116
+ }[];
117
+ /** The facts (`groupFacts`) of a loaded group, or undefined. */
118
+ facts(id: string): GroupFacts | undefined;
119
+ /** The orbital planes of every loaded group (by right ascension of the ascending node; see `clusterPlanes`): the letter, how many satellites, the colour the map gives it. A group with no planes to show has none here. */
120
+ get planes(): readonly FlatPlane[];
121
+ /** The groups on show: those the `group` attribute names, or the ones a chip chose; every loaded group when none is chosen. Set to a list of ids, or `null` for all. */
122
+ get visibleGroups(): readonly string[];
123
+ set visibleGroups(ids: readonly string[] | null);
124
+ /** The NORAD number of the chosen satellite, or null. Set it to choose one from code (no `chikyu-flat-pick` is sent), `null` to clear. */
125
+ get selected(): number | null;
126
+ set selected(id: number | null);
127
+ /** The longitude in the middle, degrees. Set it to centre the map there; a reader's pan changes it, and `chikyu-flat-view` tells the page. */
128
+ get center(): number;
129
+ set center(lon: number);
130
+ /** The zoom: 1 shows the whole world, up to 8. */
131
+ get zoom(): number;
132
+ set zoom(value: number);
133
+ /** The moment shown, in milliseconds since the Unix epoch. Set it to a number (or a `Date`) to move the clock, or "now" to go live. */
134
+ get time(): number;
135
+ set time(value: number | Date | "now");
136
+ /** How fast the clock runs: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards. */
137
+ get speed(): number;
138
+ set speed(value: number);
139
+ /** True while the clock is held with its speed kept (the page's Pause): nothing is drawn but what the reader changes. Setting it false carries on from the moment shown at the same speed. */
140
+ get paused(): boolean;
141
+ set paused(value: boolean);
142
+ /** The language of the words: the `lang` attribute, else the page's. */
143
+ get language(): FlatLang;
144
+ /** Counters for a test or a page: draws of the dots, draws of the map, the dots drawn at the last draw, the milliseconds the last draw and the slowest took, and the canvases' size in pixels. */
145
+ get stats(): {
146
+ draws: number;
147
+ mapDraws: number;
148
+ dots: number;
149
+ lastDrawMs: number;
150
+ maxDrawMs: number;
151
+ running: boolean;
152
+ paused: boolean;
153
+ fast: boolean;
154
+ averageDrawMs: number;
155
+ canvases: {
156
+ width: number;
157
+ height: number;
158
+ }[];
159
+ };
160
+ /** Where a satellite is on the screen as of the last draw, in CSS pixels from the map's top left, or null when it is not drawn (not loaded, filtered out, off the map or too old). */
161
+ placeOf(id: number): {
162
+ x: number;
163
+ y: number;
164
+ lon: number;
165
+ lat: number;
166
+ altitudeKm: number;
167
+ } | null;
168
+ connectedCallback(): void;
169
+ disconnectedCallback(): void;
170
+ attributeChangedCallback(name: string): void;
171
+ /**
172
+ * Where a loaded satellite is over the ground at the moment shown, which way its ground track runs and whether the Sun lights it: `{ lat, lon, heightKm, bearingDeg, ascending, sunlit }` (see `GroundTrackState`), placed exactly by SGP4. Null when the number names no loaded satellite
173
+ * or it cannot be placed at that moment. It is the same state that `chikyu-flat-pick` carries (`sunlit`, `bearingDeg`, `ascending`).
174
+ *
175
+ * @param id - The NORAD catalogue number.
176
+ * @returns The state, or null.
177
+ */
178
+ stateOf(id: number): GroundTrackState | null;
179
+ /** The state (`stateOf`) of the chosen satellite, or null when none is chosen. */
180
+ get selectedState(): GroundTrackState | null;
181
+ /** Choose a satellite from code, as a reader's tap would, without sending `chikyu-flat-pick`. A NORAD number the groups do not hold, or `null`, clears the choice. */
182
+ pick(id: number | null): void;
183
+ }
184
+ declare global {
185
+ interface HTMLElementTagNameMap {
186
+ "chikyu-flat": ChikyuFlat;
187
+ }
188
+ }