@johnmorrisdotca/wakusei-planets 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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE.md +31 -1
  3. package/README.md +5 -4
  4. package/dist/data/moon-catalogue.d.ts +31 -0
  5. package/dist/data/moon-catalogue.js +471 -0
  6. package/dist/data/orbiters.d.ts +368 -0
  7. package/dist/data/orbiters.js +370 -0
  8. package/dist/data/places-planned.d.ts +3 -0
  9. package/dist/data/places-planned.js +51 -0
  10. package/dist/element.d.ts +28 -0
  11. package/dist/element.js +172 -1
  12. package/dist/moon-catalogue.d.ts +296 -0
  13. package/dist/moon-catalogue.js +234 -0
  14. package/dist/orbiter-facts.d.ts +480 -0
  15. package/dist/orbiter-facts.js +189 -0
  16. package/dist/orbiters.d.ts +256 -0
  17. package/dist/orbiters.js +275 -0
  18. package/dist/place-marks.d.ts +182 -0
  19. package/dist/place-marks.js +194 -0
  20. package/dist/places/mars.d.ts +1 -1
  21. package/dist/places/mars.js +4 -2
  22. package/dist/places/moon.d.ts +1 -1
  23. package/dist/places/moon.js +4 -2
  24. package/dist/places.d.ts +4 -2
  25. package/dist/places.js +2 -0
  26. package/dist/scene/place-layer.d.ts +68 -0
  27. package/dist/scene/place-layer.js +213 -0
  28. package/dist/scene/textures.d.ts +2 -2
  29. package/dist/space/all-moons.d.ts +30 -0
  30. package/dist/space/all-moons.js +61 -0
  31. package/dist/space/bodies.d.ts +18 -0
  32. package/dist/space/bodies.js +18 -0
  33. package/dist/space/element.d.ts +182 -6
  34. package/dist/space/element.js +763 -26
  35. package/dist/space/frame.d.ts +14 -0
  36. package/dist/space/frame.js +16 -0
  37. package/dist/space/index.d.ts +5 -2
  38. package/dist/space/index.js +5 -2
  39. package/dist/space/regions.d.ts +111 -0
  40. package/dist/space/regions.js +84 -0
  41. package/dist/space/scene.d.ts +131 -8
  42. package/dist/space/scene.js +312 -15
  43. package/dist/space/sight.d.ts +106 -0
  44. package/dist/space/sight.js +84 -0
  45. package/dist/space/travel.d.ts +256 -0
  46. package/dist/space/travel.js +597 -0
  47. package/dist/version.d.ts +1 -1
  48. package/dist/version.js +1 -1
  49. package/package.json +13 -2
@@ -2,6 +2,7 @@ import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
2
  import "../tables/minor.ts";
3
3
  import { type BodyId } from "../facts.ts";
4
4
  import { type SpaceKind } from "./bodies.ts";
5
+ import { type Sight, type SightEdge } from "./sight.ts";
5
6
  import { type NameLabelOptions } from "../scene/name-label.ts";
6
7
  import type { Credit, DataSource } from "../data-door.ts";
7
8
  import { type DoorHost } from "../door/host.ts";
@@ -9,8 +10,13 @@ import { setThreeLoader } from "../scene/shared.ts";
9
10
  import { type SpacePlanet } from "./frame.ts";
10
11
  import { type ScaleMode } from "./scale.ts";
11
12
  import type { RideLook } from "./ride.ts";
13
+ import { type SunRegion } from "./regions.ts";
14
+ import { type TravelKind } from "./travel.ts";
15
+ import { type Place } from "../places.ts";
16
+ import { type PlaceLayer } from "../place-marks.ts";
12
17
  import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
13
- export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type SpaceBody, type SpaceLight };
18
+ export { setPlacesLoader } from "../scene/place-layer.ts";
19
+ export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
14
20
  /** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
15
21
  export type { BodyPlace };
16
22
  /**
@@ -37,6 +43,40 @@ export interface BodyInfo {
37
43
  /** Distance from the Earth's centre now, kilometres (0 for the Earth). */
38
44
  distanceKm: number;
39
45
  }
46
+ /**
47
+ * The body under the pointer, a finger or the keyboard's focus (`wakusei-body-hover`), with the system it belongs to: the body in its middle and that body's moons. The view draws their names and markers at full strength.
48
+ *
49
+ * @example
50
+ * ```ts no-run
51
+ * import type { BodyHover } from "@johnmorrisdotca/wakusei-planets/space/element";
52
+ *
53
+ * const hover: BodyHover = { id: "titan", name: "Titan", kind: "moon", host: "saturn", radiusKm: 2574.7, distanceKm: 1.4e9, system: { host: "saturn", moons: ["mimas", "titan"] } };
54
+ * console.log(`${hover.name} is in ${hover.system.host}'s system`);
55
+ * ```
56
+ */
57
+ export interface BodyHover extends BodyInfo {
58
+ system: {
59
+ host: BodyId;
60
+ moons: BodyId[];
61
+ };
62
+ }
63
+ /**
64
+ * Where a body is for the picture (`sight()` and `wakusei-sight`): whether it is in view, and if not, the edge it lies beyond and where along it, the way to it and whether it is behind the camera (`Sight`), with its id,
65
+ * its kind and, for a moon, the body it goes round.
66
+ *
67
+ * @example
68
+ * ```ts no-run
69
+ * import type { BodySight } from "@johnmorrisdotca/wakusei-planets/space/element";
70
+ *
71
+ * const mars: BodySight = { id: "mars", kind: "planet", inView: false, behind: false, edge: "right", x: 640, y: 210, along: 210, angle: 84 };
72
+ * console.log(mars.inView ? "in view" : `beyond the ${mars.edge} edge`);
73
+ * ```
74
+ */
75
+ export interface BodySight extends Sight {
76
+ id: BodyId;
77
+ kind: SpaceKind;
78
+ host?: BodyId;
79
+ }
40
80
  /**
41
81
  * What the space view is doing: `loading`, `live`, `unavailable` (no WebGL), `lost` (the GPU took the context; it comes back by itself).
42
82
  *
@@ -80,6 +120,10 @@ export interface RideOptions {
80
120
  distanceKm?: number;
81
121
  around?: SpaceBody;
82
122
  smooth?: boolean;
123
+ /** How the camera moves there: the view's `transition` by default. */
124
+ transition?: TravelKind;
125
+ /** How long the move takes, in milliseconds: the plan's own length by default. */
126
+ duration?: number;
83
127
  }
84
128
  /**
85
129
  * What the camera is riding along with now: the target, the body it goes round, how (`from` or `follow`), where it looks, and the distance kept for a point.
@@ -96,9 +140,13 @@ export type Riding = RideState;
96
140
  /**
97
141
  * The `<wakusei-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`
98
142
  * (`"lon,lat"`), `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`), `look` (`realistic` or `painted`),
99
- * `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
143
+ * `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), `all-moons` (every other known moon as a dot round its planet, from `/moon-catalogue`, fetched when first asked for), and `texture-base`, `texture-far-base`, `max-texture` and `tiles` (where the finer map tiles are, for a close zoom; `off` for none). Positions come from this package's own models. It draws
100
144
  * only when something changes, and nothing while it is out of sight.
101
145
  *
146
+ * The names and markers of bodies outside the system in the middle of the view are drawn at half strength (`far-opacity`, 0 to 1). A body under the pointer, a finger or the keyboard's focus lights its own system instead and
147
+ * sends `wakusei-body-hover` with the body and its system (`wakusei-body-hover-end` when none is). `sight()` says which bodies are in view and, for the rest, the edge of the picture each lies beyond; `wakusei-sight`
148
+ * fires when that changes. None of these draws the picture again.
149
+ *
102
150
  * `immersive` makes it a full-screen view: it fills the box it is in, whatever the shape (the body looked at is framed by the shorter side), the plain wheel zooms and a drag anywhere on it turns it. Without it Ctrl, Command or Alt with the wheel zooms and the plain wheel scrolls the page.
103
151
  *
104
152
  * It carries the shared view controls itself: a drag turns the camera round the body, two fingers pinch, Ctrl, Command or Alt with the wheel zooms (the plain wheel scrolls the page), and the arrow keys, + and - and 0 work once it is
@@ -129,6 +177,32 @@ export declare class WakuseiSpace extends HTMLElement {
129
177
  connectedCallback(): void;
130
178
  disconnectedCallback(): void;
131
179
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
180
+ /**
181
+ * The layers of places marked on the body looked at: any of `landing` (crewed landings, landers and rovers), `crash` (crash, impact and atmospheric-entry sites), `planned` (announced landings) and `feature` (named features), from
182
+ * the `places` attribute (`places="landing crash"`; `places` alone or `all` for every layer). Only a body with places (`PLACE_BODIES` from `/places`) shows any, and only once it is big enough on the screen. Setting it writes the attribute.
183
+ */
184
+ get places(): PlaceLayer[];
185
+ set places(layers: readonly PlaceLayer[] | null);
186
+ /** The marks laid on the body looked at now: each place's id, its layer and where its mark is, in CSS pixels from the view's top left. */
187
+ get placesShown(): readonly {
188
+ id: string;
189
+ layer: PlaceLayer;
190
+ x: number;
191
+ y: number;
192
+ }[];
193
+ /**
194
+ * Go to a place on a body: the view glides to the body (as `goTo` does), or on the body looked at turns round it, and the camera comes to rest straight above the place. The place is an id (`mars/perseverance`) or an English or Japanese name, on the body looked at
195
+ * unless `body` names another. The zoom stays on the same body and is 1 (the whole body) on another, unless `zoom` is given. Resolves the place, or `undefined` when the body has no place by that name or cannot be looked at.
196
+ *
197
+ * @param text - The place's id or name.
198
+ * @param options - `body`, `smooth` (true by default) and `zoom`.
199
+ * @returns The place, once the move has started.
200
+ */
201
+ goToPlace(text: string, options?: {
202
+ body?: BodyId | string;
203
+ smooth?: boolean;
204
+ zoom?: number;
205
+ }): Promise<Place | undefined>;
132
206
  /**
133
207
  * The name written on each body's globe (`{ look: "painted", strength: 0.5, repeat: "once", latitude: 0, facing: false, font: "Michroma", fallbackFont: "" }`), or `null` for none. Set, it takes the place of the
134
208
  * `body-label` attributes; set to `undefined` the attributes are read again. The text is each body's own name in the element's `lang` (capitals in English). A body too small on the screen (24 CSS pixels of radius by default) carries none.
@@ -158,6 +232,31 @@ export declare class WakuseiSpace extends HTMLElement {
158
232
  set scaleNames(value: Partial<Record<ScaleMode, string>>);
159
233
  get labels(): boolean;
160
234
  set labels(value: boolean);
235
+ /**
236
+ * How the camera moves from one view to the next: `turn-travel` (the default: turn beside the body being left until the next is in the picture, then travel to it, never an empty frame), `direct` (a straight
237
+ * eased glide), `look-back` (straight, watching the body left until the end), `auto` (`turn-travel`), `cut` (no move). The attribute `transition` says the same; `goTo` and `ride` take one for a single move. A
238
+ * reader who asked for reduced motion always gets `cut`.
239
+ */
240
+ get transition(): TravelKind;
241
+ set transition(value: TravelKind);
242
+ /** How slow the moves are: the plan's own length times this (1 by default; 2 is twice as slow). The attribute `pace` says the same; `goTo` and `ride` take `duration` in milliseconds for a single move instead. */
243
+ get pace(): number;
244
+ set pace(value: number);
245
+ /** The stage out from the Sun the view is framed on (`inner-planets`, `asteroid-belt`, `outer-planets`, `kuiper-belt`, `whole-system`), or null for a view of a body. */
246
+ get region(): SunRegion | null;
247
+ /**
248
+ * Show the spacecraft in orbit round the Moon and Mars (the attribute `orbiters`; off by default): each a small dot where `/orbiters` puts it on the date shown, scaled with its body, on its orbit line, with its
249
+ * name beside it in the page's language, once the body is at least 24 CSS pixels in radius on the screen. A modelled or predicted path is drawn dim; a craft with no path is not drawn. The paths (a 9 kB module)
250
+ * are loaded the first time they are shown. `stats.orbiters` says what was drawn and each one's status.
251
+ */
252
+ get orbiters(): boolean;
253
+ set orbiters(value: boolean);
254
+ /**
255
+ * Show Starman and the Tesla Roadster (the attribute `roadster`; off by default): a small marked body where `/roadster` puts the car on the date shown, on its orbit line (about one trip round the Sun), with its name
256
+ * (`Starman`, `スターマン`) beside it, from the launch in 2018 to the end of 2035. Its path (a 20 kB table) is loaded the first time it is shown, and never when it is not. `stats.roadster` says what was drawn.
257
+ */
258
+ get roadster(): boolean;
259
+ set roadster(value: boolean);
161
260
  /**
162
261
  * What a body behind another gets (the attribute `covered`): `name` (the default) draws its floating name and ring over the nearer body's disc as always; `arrow` draws instead one small quiet arrow just outside the
163
262
  * disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out.
@@ -170,8 +269,34 @@ export declare class WakuseiSpace extends HTMLElement {
170
269
  */
171
270
  get labelsAlways(): boolean;
172
271
  set labelsAlways(value: boolean);
272
+ /**
273
+ * How strongly the names and markers of bodies outside the system in the middle of the view are drawn, from 0 (not at all) to 1 (as strongly as the others): the attribute `far-opacity`, 0.5 when it is not set
274
+ * (a page may set the CSS property `--wakusei-far-opacity` instead). The system in the middle is the body looked at, the body it goes round, and that body's moons; while a body is under the pointer, a finger or the
275
+ * keyboard's focus, its own system is drawn at full strength instead, and the rest at this strength.
276
+ */
277
+ get farOpacity(): number;
278
+ set farOpacity(value: number);
279
+ /** The body under the pointer, a finger or the keyboard's focus now, or null: its system's names are drawn at full strength. */
280
+ get hovered(): BodyId | null;
281
+ /**
282
+ * Where each body is for the picture at the last draw: in view or not, and for one out of view the edge of the picture it lies beyond, the point on that edge, the way to it, and whether it is behind the camera. It
283
+ * covers the Sun, the planets, the dwarf planets and the minor bodies, the moons of the body looked at and any other moon drawn; not the body the camera rides on. `wakusei-sight` fires with the same list whenever a
284
+ * body comes into view or leaves it, changes edge, or moves 8 CSS pixels along its edge, at most four times a second with a last one when the view settles, and never at rest: a page draws its own tabs at the edges
285
+ * from it. The view works it out only once it is asked: the first call (or the first `wakusei-sight` listener) asks for one draw, and the list is there from that draw on.
286
+ */
287
+ sight(): BodySight[];
288
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void;
289
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
290
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
291
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void;
173
292
  get orbits(): boolean;
174
293
  set orbits(value: boolean);
294
+ /**
295
+ * Whether every other known moon is drawn as a small dot round its planet (the attribute `all-moons`): the moons of `/moon-catalogue` the view does not draw in full, each at its mean-orbit place. The catalogue is fetched,
296
+ * as a chunk of its own, the first time they are turned on; a view that never turns them on never loads it.
297
+ */
298
+ get allMoons(): boolean;
299
+ set allMoons(value: boolean);
175
300
  /** How many small arrowheads each orbit line carries to show which way the body goes: 2 by default, at most 4, 0 for none (the attribute `arrows` says the same). Anything else is made a whole number in that range. */
176
301
  get arrows(): number;
177
302
  set arrows(value: number);
@@ -218,17 +343,34 @@ export declare class WakuseiSpace extends HTMLElement {
218
343
  next: BodyInfo;
219
344
  };
220
345
  /**
221
- * Go to a body: it becomes the middle of the view and the zoom brings it whole into view (`zoom`, 1 by default; a planet's `-moons` preset for its system), gliding there from where the camera is unless `smooth` is
222
- * false or the reader asked for reduced motion. `wakusei-hop` tells the page where it went and where the next and previous hops lead. A name in any case, in English or Japanese, works.
346
+ * Go to a body: it becomes the middle of the view and the zoom brings it whole into view (`zoom`, 1 by default; a planet's `-moons` preset for its system), travelling there from where the camera is (`transition`,
347
+ * the view's own by default; `duration` in milliseconds, the plan's own by default) unless `smooth` is false or the reader asked for reduced motion. The travel arrives from the side it comes from, moved round
348
+ * towards the Sun where that side would show the body mostly dark, so the way in is straight: the controls' yaw and tilt are set to that side. A stage out from the Sun (`inner-planets`, `asteroid-belt`,
349
+ * `outer-planets`, `kuiper-belt`, `whole-system`) is a target too: the Sun is looked at and the camera stands back until the stage's orbits are all in the picture, with the stage's name shown. `wakusei-hop`
350
+ * tells the page where it went and where the next and previous hops lead. A name in any case, in English or Japanese, works.
223
351
  *
224
- * @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`).
225
- * @param options - `smooth` (true by default) and `zoom` (1 by default).
352
+ * @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`) or a stage's id.
353
+ * @param options - `smooth` (true by default), `zoom` (1 by default), `transition` and `duration`.
226
354
  * @returns Whether the view can go there.
227
355
  */
228
356
  goTo(target: BodyId | string, options?: {
229
357
  smooth?: boolean;
230
358
  zoom?: number;
359
+ transition?: TravelKind;
360
+ duration?: number;
231
361
  }): boolean;
362
+ /** The next stage out from the Sun from where the view is (the first stage from a body), with the same move as `goTo`; null, and nothing done, when the view is already at the widest stage. */
363
+ stepOut(options?: {
364
+ smooth?: boolean;
365
+ transition?: TravelKind;
366
+ duration?: number;
367
+ }): SunRegion | null;
368
+ /** The next stage in towards the Sun from the stage the view is at, or the Sun itself (`"sun"`, zoom 1) from the first stage; null, and nothing done, when the view is not at a stage. */
369
+ stepIn(options?: {
370
+ smooth?: boolean;
371
+ transition?: TravelKind;
372
+ duration?: number;
373
+ }): SunRegion | "sun" | null;
232
374
  /** Go to the next body in the order of `bodyList()` (the Sun, Mercury, Venus, the Earth, the Moon, Mars, Phobos, Deimos, Ceres, Jupiter, its moons, and on), round to the Sun after the last. */
233
375
  next(options?: {
234
376
  smooth?: boolean;
@@ -326,11 +468,34 @@ export declare class WakuseiSpace extends HTMLElement {
326
468
  lost: boolean;
327
469
  gliding: boolean;
328
470
  };
471
+ /** The camera's move at the last draw, or null when it is still: its kind and path, its stage, how far along it is (0 to 1), its length in milliseconds, and whether the body left and the one gone to are in the picture. */
472
+ travelling: {
473
+ kind: string;
474
+ path: string;
475
+ stage: "turn" | "travel" | "arrive";
476
+ progress: number;
477
+ duration: number;
478
+ leaving: boolean;
479
+ destination: boolean;
480
+ } | null;
481
+ /** The stage out from the Sun the view is framed on, or null: its id and name, how far it reaches from the Sun and how far back the camera stands, in Earth radii. */
482
+ region: {
483
+ id: string;
484
+ name: string;
485
+ reach: number;
486
+ distance: number;
487
+ } | null;
329
488
  /** The data door: the small bodies in the one instanced draw, and what the sources have done (tile loads started, failed and refused, bytes held, records read). */
330
489
  door: {
331
490
  points: number;
332
491
  sources: ReturnType<DoorHost["book"]["stats"]>;
333
492
  };
493
+ /** The catalogue's other moons (`all-moons`): whether they are asked for, whether the catalogue has loaded, and how many dots the last draw drew. */
494
+ allMoons: {
495
+ on: boolean;
496
+ loaded: boolean;
497
+ dots: number;
498
+ };
334
499
  /** The orbit lines drawn at the last draw (`earth`, the planets, `moon`), and how far each body is from its own line as a fraction of the line's radius: a body on its line reads under 0.01. */
335
500
  orbits: {
336
501
  drawn: string[];
@@ -361,6 +526,17 @@ export declare class WakuseiSpace extends HTMLElement {
361
526
  turn: number;
362
527
  } | null;
363
528
  };
529
+ /** Starman and the Roadster at the last draw: whether the car was drawn (shown, its path in, the moment within 2018 to 2035), its place in Earth radii from the Earth's centre, and its radius on the screen in CSS pixels. */
530
+ roadster: {
531
+ shown: boolean;
532
+ position: [number, number, number] | null;
533
+ radiusPx: number;
534
+ };
535
+ /** The orbiters at the last draw: how many dots were drawn (their body big enough on the screen), and each drawn craft's status (`tracked`, `predicted`, `modelled`). */
536
+ orbiters: {
537
+ count: number;
538
+ status: Record<string, "tracked" | "predicted" | "modelled" | "none">;
539
+ };
364
540
  };
365
541
  /** Where a body is on the screen now: its centre and radius in CSS pixels in the element, or `null` when it is behind the camera or not drawn. */
366
542
  placeOf(id: BodyId): BodyPlace | null;