@johnmorrisdotca/chikyu-earth 0.38.0 → 0.40.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 (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -1
  3. package/dist/cities/geometry.d.ts +7 -0
  4. package/dist/cities/geometry.js +1 -1
  5. package/dist/cities/host.d.ts +10 -2
  6. package/dist/cities/host.js +4 -2
  7. package/dist/markers/layer.d.ts +16 -1
  8. package/dist/markers/layer.js +3 -2
  9. package/dist/markers/place-layer.js +3 -0
  10. package/dist/paint/buffer.d.ts +6 -1
  11. package/dist/paint/buffer.js +151 -68
  12. package/dist/paint/texture.d.ts +16 -6
  13. package/dist/paint/texture.js +46 -27
  14. package/dist/realistic/earth.d.ts +1 -1
  15. package/dist/realistic/earth.js +5 -4
  16. package/dist/realistic/element-base.d.ts +437 -0
  17. package/dist/realistic/element-base.js +1249 -0
  18. package/dist/realistic/element.d.ts +2 -431
  19. package/dist/realistic/element.js +3 -1203
  20. package/dist/realistic/index.d.ts +1 -1
  21. package/dist/realistic/no-cultures.d.ts +1 -0
  22. package/dist/realistic/no-cultures.js +2 -0
  23. package/dist/realistic/tiles.d.ts +24 -0
  24. package/dist/realistic/tiles.js +30 -12
  25. package/dist/sky/culture-source.d.ts +15 -0
  26. package/dist/sky/culture-source.js +15 -0
  27. package/dist/sky/cultures.d.ts +1 -0
  28. package/dist/sky/cultures.js +8 -0
  29. package/dist/sky/host.d.ts +12 -0
  30. package/dist/sky/host.js +174 -22
  31. package/dist/space/element-base.d.ts +624 -0
  32. package/dist/space/element-base.js +1656 -0
  33. package/dist/space/element.d.ts +2 -612
  34. package/dist/space/element.js +3 -1597
  35. package/dist/space/no-cultures.d.ts +1 -0
  36. package/dist/space/no-cultures.js +2 -0
  37. package/dist/space/scene.d.ts +8 -1
  38. package/dist/space/scene.js +73 -34
  39. package/package.json +23 -3
@@ -1,612 +1,2 @@
1
- import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
- import type { GeoPoint } from "../types.ts";
3
- import { type BodyLabelSettings } from "../realistic/body-label.ts";
4
- import type { SkyKeepClear } from "../sky/keep-clear.ts";
5
- import type { SkyLabelStyle } from "../sky/style.ts";
6
- import { type Place, type PlaceLook } from "../markers/places.ts";
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";
12
- import { setThreeLoader } from "../realistic/shared.ts";
13
- import type { LightMode } from "../realistic/earth.ts";
14
- import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
15
- import { type PlanetName } from "./ephemeris.ts";
16
- import { type SatelliteStyle } from "./satellite-layer.ts";
17
- import { type RideFace, type RideLook } from "./ride.ts";
18
- import { type ScaleMode } from "./scale.ts";
19
- import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
20
- import { type PaintSpec } from "../paint/buffer.ts";
21
- export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
22
- /**
23
- * Change how the Sun and the planets are drawn (before the first element connects): the space view keeps their places, sizes, light, names and orbits and asks
24
- * the painter only for what to draw at each place (see `BodyPainter`). Left alone, they are plain spheres in the right colours.
25
- *
26
- * @param next - The painter to use, or `undefined` for the plain one.
27
- *
28
- * @example
29
- * ```ts no-run
30
- * import { plainPainter } from "@johnmorrisdotca/chikyu-earth/space";
31
- * import { setBodyPainter } from "@johnmorrisdotca/chikyu-earth/space/element";
32
- *
33
- * setBodyPainter({ make: (three, name) => plainPainter.make(three, name) });
34
- * ```
35
- */
36
- export declare function setBodyPainter(next: BodyPainter | undefined): void;
37
- /**
38
- * Where the 3D models of large satellites come from if the page has any: the package ships none. With a painter set, a satellite followed (`ride(ref, { view: "follow" })`) that the painter has a model for is drawn as that model, in the middle
39
- * of the picture at a size that reads, pointed the way it flies, lit by the Sun; a satellite it has none for stays a dot. See `SatellitePainter`.
40
- *
41
- * @param next - The painter, or `undefined` for none.
42
- *
43
- * @example
44
- * ```ts no-run
45
- * import { setSatellitePainter } from "@johnmorrisdotca/chikyu-earth/space/element";
46
- *
47
- * setSatellitePainter({ has: (norad) => norad === 25544, make: async () => null });
48
- * ```
49
- */
50
- export declare function setSatellitePainter(next: SatellitePainter | undefined): void;
51
- /**
52
- * What a page can tell a reader about a body now.
53
- *
54
- * @example
55
- * ```ts no-run
56
- * import type { BodyInfo } from "@johnmorrisdotca/chikyu-earth/space/element";
57
- *
58
- * const info: BodyInfo = { name: "Mars", radiusKm: 3389.5, distanceKm: 225_000_000 };
59
- * console.log(`${info.name}: ${info.radiusKm} km`);
60
- * ```
61
- */
62
- export interface BodyInfo {
63
- name: BodyName;
64
- /** Mean radius, kilometres. */
65
- radiusKm: number;
66
- /** Distance from the Earth's centre now, kilometres (0 for the Earth). */
67
- distanceKm: number;
68
- }
69
- export { setThreeLoader };
70
- /**
71
- * What the space view is doing: `loading`, `live`, `unavailable` (no WebGL), `lost` (the GPU took the context; it comes back by itself) or `idle` (another view has the page's one context).
72
- *
73
- * @example
74
- * ```ts no-run
75
- * import type { ChikyuSpace, SpaceState } from "@johnmorrisdotca/chikyu-earth/space/element";
76
- *
77
- * const stateOf = (space: ChikyuSpace): SpaceState => space.stats.state;
78
- * console.log(typeof stateOf);
79
- * ```
80
- */
81
- export type SpaceState = "loading" | "live" | "unavailable" | "lost" | "idle";
82
- /**
83
- * A named distance for `zoomFor`: the Earth, the Moon, the Sun, the inner planets, the whole solar system, or a planet with its nearer moons (`Jupiter-moons`: the zoom that shows them, when a body painter that draws moons is set).
84
- *
85
- * @example
86
- * ```ts no-run
87
- * import type { ChikyuSpace, SpacePreset } from "@johnmorrisdotca/chikyu-earth/space/element";
88
- *
89
- * const zoomTo = (space: ChikyuSpace, preset: SpacePreset): number => space.zoomFor(preset);
90
- * console.log(typeof zoomTo);
91
- * ```
92
- */
93
- export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" | `${Exclude<PlanetName, "Mercury" | "Venus">}-moons`;
94
- /**
95
- * 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,
96
- * 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
97
- * 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
98
- * 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.
99
- *
100
- * @example
101
- * ```ts no-run
102
- * import type { RideOptions } from "@johnmorrisdotca/chikyu-earth/space/element";
103
- *
104
- * const options: RideOptions = { view: "from", look: "horizon" };
105
- * console.log(options.look);
106
- * ```
107
- */
108
- export interface RideOptions {
109
- view?: "from" | "follow" | "above";
110
- look?: RideLook;
111
- /** Face this way as the ride opens (`face`). */
112
- face?: RideFace;
113
- distanceKm?: number;
114
- smooth?: boolean;
115
- }
116
- /**
117
- * 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.
118
- *
119
- * @example
120
- * ```ts no-run
121
- * import type { Riding } from "@johnmorrisdotca/chikyu-earth/space/element";
122
- *
123
- * const describe = (ride: Riding | null): string => (ride ? `${ride.view} ${typeof ride.target === "string" ? ride.target : ride.target.group}` : "not riding");
124
- * console.log(typeof describe);
125
- * ```
126
- */
127
- export interface Riding {
128
- target: RideTarget;
129
- view: "from" | "follow" | "above";
130
- look: RideLook;
131
- face: RideFace | null;
132
- distanceKm: number;
133
- }
134
- type SatelliteStats = {
135
- groups: number;
136
- placed: number;
137
- segments: number;
138
- tooFast: boolean;
139
- dotScale: number;
140
- epochMs: number;
141
- propagations: number;
142
- lastBatchMs: number;
143
- maxBatchMs: number;
144
- updateMs: number;
145
- maxUpdateMs: number;
146
- averageUpdateMs: number;
147
- updates: number;
148
- };
149
- /**
150
- * 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.
151
- *
152
- * 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.
153
- *
154
- * 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.
155
- *
156
- * 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
157
- * 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
158
- * (`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):
159
- * it is kept for pages that use it, but a page that shows the date wants `chikyu-timechange`.
160
- *
161
- * `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
162
- * large enough), or both with a bare attribute; `chikyu-borders-unavailable` is sent when the shapes cannot be loaded.
163
- *
164
- * `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
165
- * cities' names and stay on the Earth's disc; `chikyu-country-names-unavailable` is sent when the outlines cannot be loaded.
166
- *
167
- * @example
168
- * ```ts no-run
169
- * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
170
- *
171
- * const space = document.createElement("chikyu-space") as ChikyuSpace;
172
- * space.setAttribute("time", "2026-11-02T12:00Z");
173
- * space.setAttribute("speed", "86400");
174
- * space.placeGroups = false; // place-groups="off": every place keeps its own ring
175
- * space.paint = { id: "25544", length: "1w", swath: "coverage" };
176
- * space.clearPaint();
177
- * space.addEventListener("chikyu-timechange", (event) => {
178
- * const { time, running } = (event as CustomEvent<{ time: number; running: boolean }>).detail;
179
- * console.log(new Date(time).toISOString(), running ? "running" : "held");
180
- * });
181
- * document.body.append(space);
182
- * ```
183
- */
184
- export declare class ChikyuSpace extends HTMLElement {
185
- #private;
186
- static observedAttributes: string[];
187
- /** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
188
- get controller(): ViewController | undefined;
189
- connectedCallback(): void;
190
- disconnectedCallback(): void;
191
- attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
192
- /**
193
- * 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
194
- * 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.
195
- */
196
- get immersive(): boolean;
197
- set immersive(value: boolean);
198
- /**
199
- * 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
200
- * 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
201
- * (`meteors-label="off"` takes it away); how often they appear, where, how high and when follow real data (`@johnmorrisdotca/chikyu-earth/meteors`). None are drawn while the Earth is under 40 pixels in radius.
202
- * `chikyu-meteors` is sent when the strongest active shower changes, with `detail: { shower, zhr }`. Off by default, and nothing of theirs is made until they are first switched on.
203
- */
204
- get meteors(): boolean;
205
- set meteors(value: boolean);
206
- /**
207
- * How strongly the meteors are drawn, from 0 to 1 (the attribute `meteors-strength`; 1, the full look, when the page says nothing): it scales how bright each streak is and how many are drawn, so 0.3 is
208
- * fewer and fainter and 0 draws none. It changes nothing that is real: the rates, the showers and `chikyu-meteors` are the same at every strength, and the line under the picture still says the streaks are an illustration.
209
- * A number outside the range is brought to its nearest end; setting the property writes the attribute.
210
- */
211
- get meteorsStrength(): number;
212
- set meteorsStrength(value: number);
213
- /**
214
- * The name written on the Earth, as the family's body label: `EARTH` (`地球` on a Japanese page) laid on the globe so it turns with it, the surface showing through the letters. Off (`null`) unless the page sets it. The plain attributes are the family's:
215
- * `body-label` (`painted`, `etched`, `outline` or `burned`; absent, no label), `body-label-strength` (0 to 1, 0.5), `body-label-repeat` (`once`, `both` or `around`), `body-label-latitude` (degrees), `body-label-facing` (present: always facing the reader),
216
- * `body-label-font` (a CSS font family the page has loaded; Michroma, fetched once, when left out) and `body-label-fallback-font` (for letters the font has none of, such as Japanese). The property is the same options as an object, or `null`; setting it writes the attributes.
217
- * Nothing of it is fetched or made until it is first set, it is not drawn while the Earth is under 24 pixels in radius, and nothing is drawn at rest. A three.js handed over with `setThreeLoader` must include `CanvasTexture`, `SphereGeometry`, `MeshLambertMaterial`, `SRGBColorSpace`, `NormalBlending`
218
- * and `AdditiveBlending`; without them `chikyu-body-label-unavailable` is sent and the name is not drawn.
219
- */
220
- get bodyLabel(): BodyLabelSettings | null;
221
- set bodyLabel(value: Partial<BodyLabelSettings> | null);
222
- /**
223
- * The names of the brightest stars and the constellations as faint lines, laid over the sky the page draws (hoshi-stars' `sky-labels`, an optional peer loaded only when one of these is set). The plain attributes are hoshi's: `star-names` (a count of the brightest stars in view and not covered by the
224
- * Earth, the Moon or the Sun; bare is 10), `star-names-magnitude` (only stars at least that bright) and `constellation-lines` (the 88 figures as lines at this strength, 0 to 1; bare is 0.16): none of them, and nothing is loaded. The figure under the pointer or touched is at full strength and shows its name. Names are in the
225
- * page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial `SkyLabelStyle` (font, size, case, ring, leader and the rest).
226
- */
227
- get skyStyle(): Partial<SkyLabelStyle>;
228
- set skyStyle(value: Partial<SkyLabelStyle>);
229
- /**
230
- * The constellation that is picked, by its IAU abbreviation (`Ori`), or `null`. A reader picks one by a click or a tap on its lines or inside its figure (and with the key `C`, or `Shift`+`C` for the previous, while the element has the focus); a click on empty sky, or `Escape`, lets it go. The picked figure's lines are lit and its name is
231
- * shown at the middle of the part of it in view, until another is picked or it is let go. A page sets the property to pick one itself, which sends no event. `chikyu-constellation-pick` is sent at each pick of the reader's, with `detail` `{ abbreviation, id, name, english, japanese, kind, culture }` (`culture` is `iau` unless `constellation-culture` names another), and `null` when it is let go; `chikyu-constellation-hover` is sent the same way as a mouse rests on a figure and leaves it.
232
- * Needs `constellation-lines` set. `constellation-culture` (`iau` by default, `western`, `japanese` or `chinese`; each is fetched only when asked for, and the value is exactly what the page sets) makes the figures, the pick and the names those of that sky culture. The attribute `constellation-names` (off by default) writes the name of every figure in view at the middle of the part of it that is on the picture, quieter than the star names and clear of them, of the Earth, the Moon, the Sun, the places and satellites named, and of the places kept clear (`keepClear`).
233
- */
234
- get constellation(): string | null;
235
- set constellation(value: string | null);
236
- /**
237
- * Places on the picture where the sky's names must not go: a page's own text laid over the element, say. Each is a rectangle in the element's own CSS pixels from its top left (`{ x, y, width, height }`), or an element of the page whose box is read. A star name whose box touches
238
- * one is left out, and so is a star whose point is in one (the next star is named instead); the picked constellation's name is moved clear of it. The lines are still drawn. The boxes are read when the list changes, when the page or an element is resized or scrolled, and not at each frame: a
239
- * page that moves its text without resizing it sets the property again. The attribute `keep-clear` takes a CSS selector for the same (`keep-clear=".hero h1, .hero .lead"`). Nothing is redrawn at rest.
240
- */
241
- get keepClear(): SkyKeepClear[];
242
- set keepClear(value: readonly SkyKeepClear[] | null);
243
- /**
244
- * 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`
245
- * (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
246
- * 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
247
- * 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
248
- * 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
249
- * and for a reader who asked for less motion.
250
- */
251
- get places(): Place[];
252
- set places(value: readonly Place[]);
253
- /**
254
- * 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.
255
- * 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
256
- * way, so a place more than 90 degrees of latitude from `center` comes as near the middle as that allows.
257
- *
258
- * @param text - The place's id or label.
259
- * @param options - `smooth` (true by default).
260
- * @returns The place, once the turn has started; `undefined` when there is no such place or the camera is not looking at the Earth.
261
- */
262
- goToPlace(text: string, options?: {
263
- smooth?: boolean;
264
- }): Promise<Place | undefined>;
265
- /**
266
- * 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.
267
- *
268
- * @example
269
- * ```ts no-run
270
- * import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
271
- *
272
- * const space = document.querySelector("chikyu-space") as ChikyuSpace;
273
- * space.placeGroups = false;
274
- * space.getAttribute("place-groups"); // "off"
275
- * space.placeGroups = true;
276
- * space.hasAttribute("place-groups"); // false
277
- * ```
278
- */
279
- get placeGroups(): boolean;
280
- set placeGroups(value: boolean);
281
- /** 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). */
282
- get placesLook(): PlaceLook;
283
- set placesLook(value: PlaceLook);
284
- /**
285
- * The look of the names of cities (`city-names`): font, size, weight, colour, the outline round the text, and the dot's colour and size. Any of them may be left out; the Earth's size, the language and the data are not set here.
286
- */
287
- get cityNamesStyle(): CityNamesStyle;
288
- set cityNamesStyle(value: CityNamesStyle);
289
- /** Whether the meridians and parallels are drawn on the Earth (the attribute `grid`). Setting it writes the attribute, or takes it away. */
290
- get grid(): boolean;
291
- set grid(value: boolean);
292
- /**
293
- * 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
294
- * language and the data are not set here.
295
- */
296
- get countryNamesStyle(): CountryNamesStyle;
297
- set countryNamesStyle(value: CountryNamesStyle);
298
- /**
299
- * 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.
300
- * Setting it writes the attribute: both sets as `borders="countries regions"`, one as its own word, none takes the attribute away.
301
- */
302
- get borders(): BorderSets;
303
- set borders(value: BorderSets);
304
- /**
305
- * 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.
306
- * Set it before `borders` is switched on: shapes already loaded are kept.
307
- */
308
- get borderData(): BorderData;
309
- set borderData(value: BorderData);
310
- /**
311
- * 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
312
- * under the picture (`air-label="off"` takes the line away, for a page that says it itself).
313
- */
314
- get airThickness(): number;
315
- set airThickness(value: number);
316
- get centre(): GeoPoint;
317
- set centre(value: GeoPoint);
318
- /**
319
- * How the camera is held (the `camera` attribute). `space` (the default): held in the stars, looking at the place `center` names as it is at the moment the camera is set (when the element opens, and again when `time` or `center` is set), so the Earth
320
- * turns beneath it as the clock runs, with the day and night line where the Sun really is. `ground`: held over `center` on the ground, so the Earth keeps still and the clock moves the light across it. `sun`: held on the Sun's side, `center` being the
321
- * longitude and latitude from the sub-solar point (`0,0` looks straight at the noon place), so the day and night line keeps its place on the screen while the Earth turns beneath.
322
- */
323
- get camera(): CameraMode;
324
- set camera(value: CameraMode);
325
- /** The share of the view's shorter side the Earth's disc fills at zoom 1 (the `earth-size` attribute): 0.9 by default, so the atmosphere's glow is never cut at any shape of box. Above 1 the Earth is larger than the view. */
326
- get earthSize(): number;
327
- set earthSize(value: number);
328
- /** Where the Earth's centre is across the view (the `earth-x` attribute): 0 at the left edge, 0.5 in the middle (the default), 1 at the right edge. */
329
- get earthX(): number;
330
- set earthX(value: number);
331
- /** Where the Earth's centre is down the view (the `earth-y` attribute): 0 at the top, 0.5 in the middle (the default), 1 at the bottom. */
332
- get earthY(): number;
333
- set earthY(value: number);
334
- /** The moment shown: milliseconds since the epoch, or "now" to follow the clock. Setting it points the camera at the same place on the ground again. */
335
- get time(): number;
336
- set time(value: number | Date | "now");
337
- /** Seconds of game time per second: 1 is real time, 0 holds still, negative runs backwards. */
338
- get speed(): number;
339
- set speed(value: number);
340
- get scale(): ScaleMode;
341
- set scale(value: ScaleMode);
342
- get labels(): boolean;
343
- set labels(value: boolean);
344
- /**
345
- * How the Sun, the planets, Pluto and their moons are drawn: one of the `looks` of the body painter set with `setBodyPainter` (wakusei-planets has `realistic` and `painted`), or `plain` (the sphere in the right colour, no moons); empty for the painter's first.
346
- * With no painter they are plain spheres and this does nothing. Changing it draws the bodies again with the new look.
347
- */
348
- get bodies(): string;
349
- set bodies(value: string);
350
- /** How the Earth is lit: `sun` (true, the default), `lit` (always lit, as if by daylight from the camera's side, so a ride on the night side is never a black frame) or `boost` (the true terminator, with the night side raised). The Sun, the Moon and the planets keep their true places. */
351
- get light(): LightMode;
352
- set light(value: LightMode);
353
- /** The looks the body painter offers (empty with no painter), for a page to build its choice from. */
354
- get bodyLooks(): readonly string[];
355
- get orbits(): boolean;
356
- set orbits(value: boolean);
357
- /**
358
- * The shared controls' camera: yaw and tilt turn the view (the Earth's surface moves right for a drag right and up for a drag up), zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. A turn that moves nothing on the screen by half a pixel is kept
359
- * for the next draw but does not cause one unless `final` is true (the default), so an Auto-turn at the Earth's own rate costs a draw every half minute, not thirty a second.
360
- *
361
- * @param view - The controls' yaw and tilt in degrees and zoom.
362
- * @param final - False for the frames of a turn that is still going on (Auto-turn, a drag); true when it has settled.
363
- */
364
- setView(view: {
365
- yaw: number;
366
- tilt: number;
367
- zoom: number;
368
- }, final?: boolean): void;
369
- /** The body the camera looks at: at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
370
- get body(): BodyName;
371
- set body(name: BodyName);
372
- /**
373
- * Ride along with a body or a satellite. By default the camera sits at it and looks at the Earth, with the way it is going at the top of the picture, at its real place for the moment shown, so the
374
- * Earth turns and slides beneath as it moves along its orbit (an ISS view goes round about every 90 minutes). A drag looks about from there (a drag right turns the camera to its left and a drag up tips it towards the bottom of its picture, so the ground follows the pointer), the shared controls' zoom narrows the view.
375
- * A satellite is `{ group, index }` of a group set with `setSatellites`; it is placed exactly, one SGP4 call a frame, at any speed. Another call switches smoothly; `null` stops. The draw rate follows how
376
- * fast the picture moves, never more than 30 a second (one a second for a reader who asked for reduced motion), and nothing is drawn out of sight.
377
- *
378
- * @param target - A body name (`"Moon"`, `"Mars"`, ...) or a satellite `{ group, index }`, or `null` to stop.
379
- * @param options - `view`, `look`, `distanceKm`, `smooth` (see `RideOptions`).
380
- */
381
- ride(target: RideTarget | null, options?: RideOptions): void;
382
- /**
383
- * 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.
384
- * 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.
385
- * 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.
386
- *
387
- * @param face - The way to face.
388
- * 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.
389
- *
390
- * @returns Whether the camera faces that way now (`true` too when it already did, and nothing moves).
391
- */
392
- face(face: RideFace): boolean;
393
- /** The facing (`face`), while the view has not been turned or tipped from it; `null` otherwise. */
394
- get facing(): RideFace | null;
395
- /**
396
- * 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.
397
- */
398
- largeSatellites(): {
399
- ref: SatelliteRef;
400
- noradId: number;
401
- name: string;
402
- }[];
403
- /**
404
- * Follow the next (or, with a negative `step`, the previous) of the large satellites in `largeSatellites()`, going round: the first when none is followed yet. The followed satellite stays in the middle of the picture, as a model where the page has one,
405
- * with the Earth turning and sliding beneath. Returns the satellite now followed, or `null` when there is none to follow.
406
- *
407
- * @param step - How many places to hop: 1 (the default) is the next.
408
- */
409
- followNext(step?: number): {
410
- ref: SatelliteRef;
411
- noradId: number;
412
- name: string;
413
- } | null;
414
- /** What the camera is riding along with now, or null. */
415
- get riding(): Riding | null;
416
- /**
417
- * 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"`.
418
- */
419
- get satelliteTint(): "off" | "orbit";
420
- set satelliteTint(value: "off" | "orbit");
421
- /**
422
- * 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
423
- * 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).
424
- * 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.
425
- *
426
- * @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
427
- * @param satellites - The group, or `null` to remove it.
428
- * @param style - How to draw it.
429
- */
430
- /**
431
- * Paint one satellite's path on the Earth. `id` is a NORAD catalogue number or `group:index`. `length` is how long the trail is kept, in simulated time (`1d` when left out, or `1w`, `1m`). `swath` is `track` (the point under the satellite, the default) or `coverage` (where it is at least 10° above the horizon). Setting another satellite clears the trail. `null` clears it.
432
- */
433
- get paint(): PaintSpec | null;
434
- set paint(value: PaintSpec | null);
435
- /** Take the painted trail off the Earth. */
436
- clearPaint(): void;
437
- /** Texels the trail has painted. 0 after `clearPaint`, and again when the painted satellite changes. */
438
- get paintPixels(): number;
439
- setSatellites(group: string, satellites: Satellites | null, style?: Partial<SatelliteStyle>): void;
440
- /** Show or hide a group without losing it. */
441
- showSatellites(group: string, on: boolean): void;
442
- /** The groups now set, with how many satellites each holds and whether it is shown. */
443
- get satelliteGroups(): {
444
- name: string;
445
- count: number;
446
- visible: boolean;
447
- }[];
448
- /** Mark one satellite: a larger ring round it, its orbit drawn, and its name beside it. `null` lets it go. */
449
- selectSatellite(ref: SatelliteRef | null): void;
450
- /** The satellite marked by `selectSatellite` or by a press on it, if any. */
451
- get selectedSatellite(): SatelliteRef | null;
452
- /**
453
- * 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.
454
- * 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).
455
- * At most 80 satellites are ringed, over all the groups. A group that is not set, or is not shown, has none.
456
- *
457
- * @param group - The group's name, as given to `setSatellites`.
458
- * @param on - `true` to ring and name its members (the default), `false` to stop.
459
- */
460
- labelSatellites(group: string, on?: boolean): void;
461
- /** The groups whose satellites are ringed and named now (`labelSatellites`). */
462
- get labelledSatellites(): string[];
463
- /**
464
- * The names written beside the ringed satellites, by NORAD number, for a page in another language or with names of its own (`{ 25544: "Space Station" }`). One left out keeps its short name (the ISS, Tiangong and Hubble) or the name in its elements.
465
- */
466
- get satelliteNames(): Record<number, string>;
467
- set satelliteNames(value: Record<number, string>);
468
- /**
469
- * Where a satellite is on the screen as of the last draw: `{ x, y, visible, heightKm }` in CSS pixels from the view's top left, `visible` meaning it is inside the box and not behind the Earth. `null` when its group is not set or not shown, it cannot be
470
- * placed (its elements are too old), or it is behind the camera. It is the picture's own camera maths and its own test for the Earth in the way, so a page that draws its own rings need not repeat either.
471
- */
472
- placeSatellite(ref: SatelliteRef): {
473
- x: number;
474
- y: number;
475
- visible: boolean;
476
- heightKm: number;
477
- } | null;
478
- /** 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. */
479
- satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
480
- /** The words shown beside each body, for a page in another language (`{ Mars: "火星" }`). A body left out keeps its English name. */
481
- get bodyNames(): Partial<Record<BodyName, string>>;
482
- set bodyNames(value: Partial<Record<BodyName, string>>);
483
- /** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
484
- get bodyHint(): string;
485
- set bodyHint(value: string);
486
- /** The radius and the distance from the Earth of a body now, for a page's own caption. */
487
- bodyInfo(name: BodyName): BodyInfo;
488
- /** The zoom that shows a part of the sky: the Earth alone, the Moon's orbit, the Sun, the planets out to Mars, or all of them, at this scale and moment. */
489
- zoomFor(preset: SpacePreset): number;
490
- /** What the element is doing, for a page or a test. */
491
- get stats(): {
492
- state: SpaceState;
493
- draws: number;
494
- contexts: number;
495
- canvas: {
496
- width: number;
497
- height: number;
498
- pixels: number;
499
- };
500
- tiers: Record<string, number>;
501
- distance: number;
502
- assets: {
503
- entries: number;
504
- refs: number;
505
- };
506
- time: number;
507
- lookups: number;
508
- satellites: SatelliteStats;
509
- ride: {
510
- riding: boolean;
511
- lost: boolean;
512
- gliding: boolean;
513
- facing: RideFace | null;
514
- };
515
- /** 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. */
516
- camera: {
517
- position: [number, number, number];
518
- quaternion: [number, number, number, number];
519
- fov: number;
520
- };
521
- /** 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`). */
522
- bodies: {
523
- look: string;
524
- painted: number;
525
- moons: number;
526
- held: number;
527
- moon: boolean;
528
- tiles: number;
529
- };
530
- /** 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. */
531
- meteors: {
532
- on: boolean;
533
- strength: number;
534
- alive: number;
535
- spawned: number;
536
- perSecond: number;
537
- shower: string | null;
538
- zhr: number;
539
- };
540
- /** The name written on the Earth: whether `body-label` is set, its text, the label is made, and it is showing (it is hidden while the Earth is small). */
541
- bodyLabel: {
542
- on: boolean;
543
- text: string;
544
- made: boolean;
545
- showing: boolean;
546
- };
547
- /** The names of the stars and the constellation lines: whether one is asked for, whether hoshi-stars is loaded, the names and figures laid out at the last draw, the figure picked, how many times the layer was drawn, the language its names were last laid out in, and the named stars' own points on the screen (`stars`). */
548
- sky: {
549
- on: boolean;
550
- loaded: boolean;
551
- names: number;
552
- figures: number;
553
- picked: string | null;
554
- pick: string | null;
555
- hover: string | null;
556
- constellations: number;
557
- culture: string;
558
- renders: number;
559
- lang: string;
560
- stars: {
561
- text: string;
562
- x: number;
563
- y: number;
564
- }[];
565
- };
566
- /** The followed satellite's model (`setSatellitePainter`), when one is drawn: where its middle is on the screen, in CSS pixels, as of the last draw; `null` otherwise. */
567
- followModel: {
568
- x: number;
569
- y: number;
570
- shown: boolean;
571
- parts: number;
572
- } | null;
573
- /**
574
- * 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`),
575
- * how many rings the one draw call draws (`sprites`; 0 when the picture cannot draw them), how many circles the page draws instead (`dots`) and how many of the rings are groups (`groups`), the satellites ringed and named, and how many times they were laid out.
576
- */
577
- places: {
578
- places: number;
579
- shown: number;
580
- labels: number;
581
- renders: number;
582
- rings: number;
583
- satelliteNames: number;
584
- marks: number;
585
- groups: number;
586
- sprites: number;
587
- dots: number;
588
- omitted: number;
589
- };
590
- /** 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. */
591
- cityNames: {
592
- on: boolean;
593
- max: number;
594
- radius: number;
595
- tiers: string[];
596
- cities: number;
597
- names: number;
598
- renders: number;
599
- };
600
- /** 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. */
601
- borders: BorderStats;
602
- /** 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. */
603
- grid: GridStats;
604
- /** 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. */
605
- countryNames: CountryNamesStats;
606
- };
607
- }
608
- declare global {
609
- interface HTMLElementTagNameMap {
610
- "chikyu-space": ChikyuSpace;
611
- }
612
- }
1
+ import "../sky/cultures.ts";
2
+ export * from "./element-base.ts";