@johnmorrisdotca/chikyu-earth 0.35.0 → 0.37.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 (62) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/NOTICE.md +27 -1
  3. package/README.md +20 -2
  4. package/dist/borders/layer.d.ts +75 -0
  5. package/dist/borders/layer.js +136 -0
  6. package/dist/borders/lines.d.ts +138 -0
  7. package/dist/borders/lines.js +227 -0
  8. package/dist/catalogue/index.d.ts +1 -0
  9. package/dist/catalogue/index.js +3 -2
  10. package/dist/catalogue/pack.js +3 -0
  11. package/dist/cities/host.d.ts +9 -0
  12. package/dist/cities/host.js +51 -9
  13. package/dist/country-names/geometry.d.ts +264 -0
  14. package/dist/country-names/geometry.js +372 -0
  15. package/dist/country-names/host.d.ts +82 -0
  16. package/dist/country-names/host.js +212 -0
  17. package/dist/grid/layer.d.ts +45 -0
  18. package/dist/grid/layer.js +66 -0
  19. package/dist/grid/lines.d.ts +85 -0
  20. package/dist/grid/lines.js +113 -0
  21. package/dist/markers/go-to-place.d.ts +27 -0
  22. package/dist/markers/go-to-place.js +35 -0
  23. package/dist/markers/index.d.ts +2 -1
  24. package/dist/markers/index.js +2 -1
  25. package/dist/markers/layer.d.ts +7 -0
  26. package/dist/markers/layer.js +7 -0
  27. package/dist/markers/place-layer.d.ts +58 -7
  28. package/dist/markers/place-layer.js +326 -64
  29. package/dist/markers/place-sprites.d.ts +33 -0
  30. package/dist/markers/place-sprites.js +161 -0
  31. package/dist/markers/places.d.ts +91 -6
  32. package/dist/markers/places.js +135 -6
  33. package/dist/realistic/earth.d.ts +11 -0
  34. package/dist/realistic/earth.js +55 -1
  35. package/dist/realistic/element.d.ts +75 -6
  36. package/dist/realistic/element.js +221 -33
  37. package/dist/realistic/immersive.d.ts +7 -0
  38. package/dist/realistic/immersive.js +17 -0
  39. package/dist/realistic/index.d.ts +6 -0
  40. package/dist/realistic/index.js +3 -0
  41. package/dist/realistic/textures.d.ts +5 -0
  42. package/dist/satellites/index.d.ts +1 -0
  43. package/dist/satellites/index.js +1 -0
  44. package/dist/satellites/limits.d.ts +1 -1
  45. package/dist/satellites/limits.js +1 -1
  46. package/dist/satellites/owners.d.ts +26 -0
  47. package/dist/satellites/owners.js +164 -0
  48. package/dist/satellites/source.js +3 -0
  49. package/dist/satellites/track.d.ts +5 -0
  50. package/dist/satellites/track.js +128 -0
  51. package/dist/satellites/types.d.ts +19 -1
  52. package/dist/space/element.d.ts +111 -12
  53. package/dist/space/element.js +360 -26
  54. package/dist/space/index.d.ts +2 -2
  55. package/dist/space/index.js +1 -1
  56. package/dist/space/ride.d.ts +42 -0
  57. package/dist/space/ride.js +45 -3
  58. package/dist/space/satellite-layer.d.ts +8 -2
  59. package/dist/space/satellite-layer.js +138 -19
  60. package/dist/space/scene.d.ts +56 -6
  61. package/dist/space/scene.js +97 -15
  62. package/package.json +3 -3
@@ -5,12 +5,16 @@ import type { SkyKeepClear } from "../sky/keep-clear.ts";
5
5
  import type { SkyLabelStyle } from "../sky/style.ts";
6
6
  import { type Place, type PlaceLook } from "../markers/places.ts";
7
7
  import { type CityNamesStyle } from "../cities/host.ts";
8
+ import { type BorderSets } from "../borders/lines.ts";
9
+ import type { BorderData, BorderStats } from "../borders/layer.ts";
10
+ import type { GridStats } from "../grid/layer.ts";
11
+ import { type CountryNamesStats, type CountryNamesStyle } from "../country-names/host.ts";
8
12
  import { setThreeLoader } from "../realistic/shared.ts";
9
13
  import type { LightMode } from "../realistic/earth.ts";
10
14
  import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
11
15
  import { type PlanetName } from "./ephemeris.ts";
12
16
  import { type SatelliteStyle } from "./satellite-layer.ts";
13
- import { type RideLook } from "./ride.ts";
17
+ import { type RideFace, type RideLook } from "./ride.ts";
14
18
  import { type ScaleMode } from "./scale.ts";
15
19
  import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
16
20
  export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
@@ -89,7 +93,7 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
89
93
  /**
90
94
  * How a ride along is done: `view` `from` (the default) puts the camera at the body looking at the Earth, `follow` keeps it a fixed distance from the body looking at it (`distanceKm`, 3000 by default,
91
95
  * for a satellite; a planet or the Moon is kept at the distance the zoom says); `above` (a satellite only; a body is followed) puts it on the line from the Earth's centre through the satellite, `distanceKm` (divided by the zoom) above it, looking straight down at it with the way it is going at the top
92
- * of the picture, the satellite held in the middle while the Earth turns beneath (a drag turns the picture about the satellite and tips the camera back or ahead of it); `look` `down` (the default) or `horizon` is where a camera at the body points; `smooth` (the default) glides
96
+ * of the picture, the satellite held in the middle while the Earth turns beneath (a drag turns the picture about the satellite and tips the camera back or ahead of it); `look` `down` (the default) or `horizon` is where a camera at the body points; `face` opens looking one way (see `face`); `smooth` (the default) glides
93
97
  * from the old camera to the new one in about a second and a bit, and jumps instead for a reader who asked for reduced motion.
94
98
  *
95
99
  * @example
@@ -103,11 +107,13 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
103
107
  export interface RideOptions {
104
108
  view?: "from" | "follow" | "above";
105
109
  look?: RideLook;
110
+ /** Face this way as the ride opens (`face`). */
111
+ face?: RideFace;
106
112
  distanceKm?: number;
107
113
  smooth?: boolean;
108
114
  }
109
115
  /**
110
- * What the camera is riding along with now: the body or satellite, how (`from` or `follow`), where it looks, and the distance kept for a satellite.
116
+ * What the camera is riding along with now: the body or satellite, how (`from`, `follow` or `above`), where it looks, the facing it looks round from (`null` when none was chosen), and the distance kept for a satellite.
111
117
  *
112
118
  * @example
113
119
  * ```ts no-run
@@ -121,12 +127,16 @@ export interface Riding {
121
127
  target: RideTarget;
122
128
  view: "from" | "follow" | "above";
123
129
  look: RideLook;
130
+ face: RideFace | null;
124
131
  distanceKm: number;
125
132
  }
126
133
  type SatelliteStats = {
127
134
  groups: number;
128
135
  placed: number;
136
+ segments: number;
129
137
  tooFast: boolean;
138
+ dotScale: number;
139
+ epochMs: number;
130
140
  propagations: number;
131
141
  lastBatchMs: number;
132
142
  maxBatchMs: number;
@@ -138,13 +148,21 @@ type SatelliteStats = {
138
148
  /**
139
149
  * The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
140
150
  *
141
- * It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`.
151
+ * It carries kazoku-ui's controls itself: a drag turns the view, two fingers pinch, Ctrl and the wheel zoom (a plain wheel at Fit scrolls the page) and the arrow keys, + and - work once it is focused. The zoom runs from a millionth of Fit (the whole solar system) to 2.5 times, and from 0.5 to 6 times while riding from a body. `controls="none"` turns the hands off; `zoom-min` and `zoom-max` change the range. A `<kazoku-view-controls for="...">` on the element takes the hands over, and the page applies its events with `setView`. `immersive` is the full-screen mode: any shape of box, a plain wheel zooms and a drag anywhere turns.
152
+ *
153
+ * With a body painter that carries a `credit` (`setBodyPainter`), the credit of its pictures is written under the picture while it draws the bodies; `bodies-credit="off"` takes the line away.
142
154
  *
143
155
  * While time runs (`speed` is not 0) it sends `chikyu-timechange` with `detail: { time, running: true }`, `time` being the moment shown in milliseconds since 1970, at most four times a second however fast the picture is
144
156
  * drawn (and, with the clock at real time, as often as it steps: once a minute, or once a second with satellites or a ride on show), only while the tab is shown, and once with `running: false` when the clock holds
145
157
  * (`speed` set to 0): a page writes the date into its date box from it. It is not sent for a `time` the page sets itself. `chikyu-time` is the older event of every step the clock takes (up to thirty a second):
146
158
  * it is kept for pages that use it, but a page that shows the date wants `chikyu-timechange`.
147
159
  *
160
+ * `borders` draws the borders on the Earth's land as thin lines that turn with it, as on `<chikyu-earth-realistic>`: `countries`, `regions` (from the page's `borderData.regions`, once the Earth is
161
+ * large enough), or both with a bare attribute; `chikyu-borders-unavailable` is sent when the shapes cannot be loaded.
162
+ *
163
+ * `grid` draws the meridians and parallels on the Earth, and `country-names` names its countries, as on `<chikyu-earth-realistic>`: the names keep clear of the bodies', the places' and the
164
+ * cities' names and stay on the Earth's disc; `chikyu-country-names-unavailable` is sent when the outlines cannot be loaded.
165
+ *
148
166
  * @example
149
167
  * ```ts no-run
150
168
  * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
@@ -167,6 +185,12 @@ export declare class ChikyuSpace extends HTMLElement {
167
185
  connectedCallback(): void;
168
186
  disconnectedCallback(): void;
169
187
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
188
+ /**
189
+ * True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape (the Earth fits the shorter side with its glow inside it, `earth-size`), a plain wheel zooms instead of scrolling
190
+ * the page, a drag anywhere on it turns the view, and a touch drag turns it instead of scrolling. A notch of the wheel is about 1.2 times; out far enough the Moon, the Sun and the planets come into view.
191
+ */
192
+ get immersive(): boolean;
193
+ set immersive(value: boolean);
170
194
  /**
171
195
  * Meteors seen from space, on or off (the attribute `meteors`): short streaks where meteors burn, on the dark side of the Earth and in its twilight, more of them under an active shower, only while the
172
196
  * clock runs, and for a reader who prefers reduced motion only once the page has set a `speed` (a Play). Each streak's place and moment are drawn at random, and a line under the picture says so
@@ -213,13 +237,32 @@ export declare class ChikyuSpace extends HTMLElement {
213
237
  get keepClear(): SkyKeepClear[];
214
238
  set keepClear(value: readonly SkyKeepClear[] | null);
215
239
  /**
216
- * Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
217
- * (the default: quieter). Each stands up out of the ground, turns with the Earth, is hidden on its far side and keeps its size in pixels at any zoom. Names go at the top, `here` first, and never overlap
218
- * one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where it likes. Setting the property writes
219
- * the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked for less motion.
240
+ * Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind, color }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
241
+ * (the default: quieter), and `color` an optional CSS colour of its own. The first `PLACE_MARKS` in sight (`here` first, then in the order given) stand up out of the ground with their names; every other place
242
+ * is a ring on the ground, all of them one draw call, and places that crowd are gathered into one ring with their count. They turn with the Earth, are hidden on its far side, are dimmer on its night side
243
+ * and keep their size in pixels at any zoom. Names never overlap one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places
244
+ * over and keeps them where it likes. Setting the property writes the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight
245
+ * and for a reader who asked for less motion.
220
246
  */
221
247
  get places(): Place[];
222
248
  set places(value: readonly Place[]);
249
+ /**
250
+ * Turn the view so a place of `places` is in the middle, at a pace a reader can follow (at once with `smooth: false`, for a reader who asked for less motion, or before the picture is live); the zoom stays.
251
+ * The place is named by its `id`, or by its label in any case. The camera must be looking at the Earth: while it rides along or looks at another body nothing moves. The tilt is held to 90 degrees either
252
+ * way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows.
253
+ *
254
+ * @param text - The place's id or label.
255
+ * @param options - `smooth` (true by default).
256
+ * @returns The place, once the turn has started; `undefined` when there is no such place or the camera is not looking at the Earth.
257
+ */
258
+ goToPlace(text: string, options?: {
259
+ smooth?: boolean;
260
+ }): Promise<Place | undefined>;
261
+ /**
262
+ * Whether places that crowd are gathered into one ring with their count (the attribute `place-groups`): on by default, `off` leaves every place its own ring. Setting the property writes the attribute.
263
+ */
264
+ get placeGroups(): boolean;
265
+ set placeGroups(value: boolean);
223
266
  /** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
224
267
  get placesLook(): PlaceLook;
225
268
  set placesLook(value: PlaceLook);
@@ -228,6 +271,27 @@ export declare class ChikyuSpace extends HTMLElement {
228
271
  */
229
272
  get cityNamesStyle(): CityNamesStyle;
230
273
  set cityNamesStyle(value: CityNamesStyle);
274
+ /** Whether the meridians and parallels are drawn on the Earth (the attribute `grid`). Setting it writes the attribute, or takes it away. */
275
+ get grid(): boolean;
276
+ set grid(value: boolean);
277
+ /**
278
+ * The look of the names of countries (`country-names`): font, weight, colour, the outline round the text, and the smallest and largest text size. Any of them may be left out; the Earth's size, the
279
+ * language and the data are not set here.
280
+ */
281
+ get countryNamesStyle(): CountryNamesStyle;
282
+ set countryNamesStyle(value: CountryNamesStyle);
283
+ /**
284
+ * Which borders are drawn on the Earth (the attribute `borders`): the countries' at any size, and the regions' (provinces, states, prefectures) once the Earth is large enough on the screen to tell them apart.
285
+ * Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
286
+ */
287
+ get borders(): BorderSets;
288
+ set borders(value: BorderSets);
289
+ /**
290
+ * Where the borders' shapes come from (see `BorderData`): `countries` in place of chizu's `world-geo`, and `regions`, a country's regions by its code, which draws the regions; without it none are drawn.
291
+ * Set it before `borders` is switched on: shapes already loaded are kept.
292
+ */
293
+ get borderData(): BorderData;
294
+ set borderData(value: BorderData);
231
295
  /**
232
296
  * How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing): see `<chikyu-earth-realistic>`. While it is above 1 the element says so in a line
233
297
  * under the picture (`air-label="off"` takes the line away, for a page that says it itself).
@@ -300,6 +364,19 @@ export declare class ChikyuSpace extends HTMLElement {
300
364
  * @param options - `view`, `look`, `distanceKm`, `smooth` (see `RideOptions`).
301
365
  */
302
366
  ride(target: RideTarget | null, options?: RideOptions): void;
367
+ /**
368
+ * Face one way while riding: `ahead` along the way it goes, `behind`, `left` or `right` (as seen facing ahead), `down` straight at the Earth, `up` straight away from it.
369
+ * In the `above` view, `down` looks straight down at the satellite and the Earth below it. The camera glides there in half a second (at once for a reader who asked for reduced motion) and keeps the zoom.
370
+ * The facing stays pressed until the view is turned or tipped. `chikyu-ride-face` is sent with `{ face }` (`null` when it is let go). Keys, while the element is focused: W ahead, S behind, A left, D right, R up, F down. The arrow keys stay with the view controls.
371
+ *
372
+ * @param face - The way to face.
373
+ * Following a body (a planet, the Moon) there is no way to face: it returns `false`. Held keys do not repeat, and keys typed in a field or in editable text are left to it.
374
+ *
375
+ * @returns Whether the camera faces that way now (`true` too when it already did, and nothing moves).
376
+ */
377
+ face(face: RideFace): boolean;
378
+ /** The facing (`face`), while the view has not been turned or tipped from it; `null` otherwise. */
379
+ get facing(): RideFace | null;
303
380
  /**
304
381
  * The satellites the page has a model for (`setSatellitePainter`) in the groups now set, each with its name in the page's language: the large satellites that can be followed as a model. Empty with no painter.
305
382
  */
@@ -321,10 +398,15 @@ export declare class ChikyuSpace extends HTMLElement {
321
398
  } | null;
322
399
  /** What the camera is riding along with now, or null. */
323
400
  get riding(): Riding | null;
401
+ /**
402
+ * Colour each satellite by its orbit class (low, medium, geostationary, highly elliptical, other). Off by default, so a group keeps the colour it was given. The attribute is `satellite-tint="orbit"`.
403
+ */
404
+ get satelliteTint(): "off" | "orbit";
405
+ set satelliteTint(value: "off" | "orbit");
324
406
  /**
325
407
  * Show a group of satellites (made by `createSatellites`) under a name, or take the group away with `null`. A group is one draw call however many satellites it holds. Giving the name of a group
326
408
  * that is already shown replaces it. `style`: `color` and `size` (CSS pixels) of the dots, and `orbits` to draw every orbit (only for a group of 40 or fewer, such as the stations).
327
- * The groups are placed by SGP4 about once a second and interpolated between, and are hidden while the clock runs faster than `MAX_SATELLITE_SPEED`.
409
+ * The groups are placed by SGP4 about once a second and interpolated between. Above `MAX_SATELLITE_SPEED` each satellite is a short streak along its orbit instead of being hidden.
328
410
  *
329
411
  * @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
330
412
  * @param satellites - The group, or `null` to remove it.
@@ -369,7 +451,7 @@ export declare class ChikyuSpace extends HTMLElement {
369
451
  visible: boolean;
370
452
  heightKm: number;
371
453
  } | null;
372
- /** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
454
+ /** 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. */
373
455
  satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
374
456
  /** The words shown beside each body, for a page in another language (`{ Mars: "火星" }`). A body left out keeps its English name. */
375
457
  get bodyNames(): Partial<Record<BodyName, string>>;
@@ -404,6 +486,7 @@ export declare class ChikyuSpace extends HTMLElement {
404
486
  riding: boolean;
405
487
  lost: boolean;
406
488
  gliding: boolean;
489
+ facing: RideFace | null;
407
490
  };
408
491
  /** The camera as the last draw left it: its place in Earth radii from the Earth's centre, the way it is turned (a unit quaternion, x y z w) and its field of view in degrees. */
409
492
  camera: {
@@ -411,11 +494,14 @@ export declare class ChikyuSpace extends HTMLElement {
411
494
  quaternion: [number, number, number, number];
412
495
  fov: number;
413
496
  };
414
- /** What the body painter has made at the last draw: the Sun and planets with a drawing, and the moons shown round a planet that is near. */
497
+ /** What the body painter has made at the last draw: the Sun and planets with a drawing, the moons shown round a planet that is near and the moons held (shown, or gone from the view for less than four seconds), whether the Moon is the painter's (`moon`), and the bodies with finer map tiles on them (`tiles`). */
415
498
  bodies: {
416
499
  look: string;
417
500
  painted: number;
418
501
  moons: number;
502
+ held: number;
503
+ moon: boolean;
504
+ tiles: number;
419
505
  };
420
506
  /** The meteors: whether they are on, the streaks alive now and started so far, the streaks a second being drawn, and the strongest active shower's code and rate. */
421
507
  meteors: {
@@ -460,7 +546,10 @@ export declare class ChikyuSpace extends HTMLElement {
460
546
  shown: boolean;
461
547
  parts: number;
462
548
  } | null;
463
- /** The places: how many were handed over, how many are drawn and named at the last draw, and how many times they were laid out. */
549
+ /**
550
+ * The places: how many were handed over, how many are in sight at the last draw (`shown`, those gathered into groups included), how many stand up as markers of their own (`marks`) and are named (`labels`),
551
+ * how many rings the one draw call draws (`sprites`) and how many of those are groups (`groups`), the satellites ringed and named, and how many times they were laid out.
552
+ */
464
553
  places: {
465
554
  places: number;
466
555
  shown: number;
@@ -468,6 +557,10 @@ export declare class ChikyuSpace extends HTMLElement {
468
557
  renders: number;
469
558
  rings: number;
470
559
  satelliteNames: number;
560
+ marks: number;
561
+ groups: number;
562
+ sprites: number;
563
+ omitted: number;
471
564
  };
472
565
  /** The names of cities: whether `city-names` is set and the most it asks for, the Earth's radius on the screen, the tiers of kuni's cities that have arrived and how many cities, the names shown at the last draw and how many times the layer was drawn. */
473
566
  cityNames: {
@@ -479,6 +572,12 @@ export declare class ChikyuSpace extends HTMLElement {
479
572
  names: number;
480
573
  renders: number;
481
574
  };
575
+ /** The borders: the segments of each set, whether each was drawn at the last draw, the countries whose regions have arrived, how many times a set's lines were made, and whether a set could not be loaded. */
576
+ borders: BorderStats;
577
+ /** The grid: whether it was drawn at the last draw, whether every 15 degrees (else 30), its segments then, how many times its lines were made, and whether it could not be made. */
578
+ grid: GridStats;
579
+ /** The names of countries: whether `country-names` is set and the most it asks for, the countries loaded, the names shown at the last draw, how many times they were laid out, and whether the outlines could not be loaded. */
580
+ countryNames: CountryNamesStats;
482
581
  };
483
582
  }
484
583
  declare global {