@johnmorrisdotca/wakusei-planets 0.59.0 → 0.61.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 (43) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/NOTICE.md +9 -0
  3. package/README.md +31 -3
  4. package/dist/bodies/earth.js +22 -1
  5. package/dist/data/places-moon.d.ts +12 -9
  6. package/dist/data/places-moon.js +3 -3
  7. package/dist/element.d.ts +1 -1
  8. package/dist/flat/bodies.d.ts +122 -0
  9. package/dist/flat/bodies.js +115 -0
  10. package/dist/flat/define.d.ts +3 -0
  11. package/dist/flat/define.js +6 -0
  12. package/dist/flat/element.d.ts +145 -0
  13. package/dist/flat/element.js +1614 -0
  14. package/dist/flat/geometry.d.ts +127 -0
  15. package/dist/flat/geometry.js +121 -0
  16. package/dist/flat/index.d.ts +5 -0
  17. package/dist/flat/index.js +6 -0
  18. package/dist/flat/scene.d.ts +152 -0
  19. package/dist/flat/scene.js +195 -0
  20. package/dist/flat/system-define.d.ts +3 -0
  21. package/dist/flat/system-define.js +6 -0
  22. package/dist/flat/system-element.d.ts +133 -0
  23. package/dist/flat/system-element.js +1435 -0
  24. package/dist/flat/system-words.d.ts +28 -0
  25. package/dist/flat/system-words.js +102 -0
  26. package/dist/flat/system.d.ts +440 -0
  27. package/dist/flat/system.js +521 -0
  28. package/dist/flat/words.d.ts +55 -0
  29. package/dist/flat/words.js +133 -0
  30. package/dist/space/travel.js +36 -5
  31. package/dist/surface/drive.d.ts +5 -2
  32. package/dist/surface/drive.js +13 -15
  33. package/dist/surface/element.d.ts +38 -1
  34. package/dist/surface/element.js +144 -14
  35. package/dist/surface/index.d.ts +1 -0
  36. package/dist/surface/index.js +1 -0
  37. package/dist/surface/model.d.ts +54 -0
  38. package/dist/surface/model.js +147 -0
  39. package/dist/surface/rig.d.ts +125 -0
  40. package/dist/surface/rig.js +107 -0
  41. package/dist/surface/scene.d.ts +3 -0
  42. package/dist/surface/scene.js +22 -1
  43. package/package.json +38 -2
@@ -0,0 +1,133 @@
1
+ import { type BeltId } from "../belts/index.ts";
2
+ import { type SystemKind, type SystemLayer } from "./system.ts";
3
+ import type { FlatLang } from "./words.ts";
4
+ /**
5
+ * What `wakusei-flat-pick` carries from the flat solar system: a body under the pointer, tapped, or reached by the keyboard. A tap on nothing sends `id: null` and clears the choice.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import type { SystemPick } from "@johnmorrisdotca/wakusei-planets/flat/system";
10
+ *
11
+ * const show = (pick: SystemPick): string => (pick.id === null ? "nothing" : `${pick.name} (${pick.kind}), ${pick.distanceAu?.toFixed(1)} au`);
12
+ * console.log(typeof show);
13
+ * ```
14
+ */
15
+ export interface SystemPick {
16
+ /** What was chosen: the Sun, a planet, a dwarf planet, an asteroid, a centaur, a comet, a spacecraft, or a `belt` body (one point of a belt). */
17
+ kind: SystemKind | "belt" | null;
18
+ /** The body's id (`earth`, `halley`, `roadster`), a belt body's name (`4 Vesta`), or null when a tap lands on nothing. */
19
+ id: string | null;
20
+ name: string | null;
21
+ /** The layer it is in. */
22
+ layer: SystemLayer | "sun" | null;
23
+ /** The belt a belt body is in. */
24
+ belt?: BeltId;
25
+ /** Its distance from the Sun in astronomical units, and its place in the ecliptic plane in au (x to the March equinox). */
26
+ distanceAu: number | null;
27
+ x: number | null;
28
+ y: number | null;
29
+ /** True for a craft whose place is a prediction (the Tesla Roadster, a craft whose mission is over). */
30
+ predicted: boolean | null;
31
+ /** What chose it: a pointer going over it (`hover`), a tap or click (`tap`), or the keyboard (`key`). */
32
+ via: "hover" | "tap" | "key";
33
+ }
34
+ /**
35
+ * The `<wakusei-flat-system>` custom element: the solar system as a flat, top-down map in the plane of the ecliptic, the planets at their places for the time shown, with their orbits, the dwarf planets and a few small bodies, the asteroid belts and the Kuiper belt as clouds of points,
36
+ * 34 comets (with a tail turned from the Sun when near it), and our spacecraft, the Tesla Roadster among them, each with its whole path to draw. Import `@johnmorrisdotca/wakusei-planets/flat/system/define` to register the tag. It needs no WebGL and no peer.
37
+ * Distances are squeezed by the plan's logarithm (`ln(1 + d / 0.1 au)`), so Mercury and Neptune both show, with rings at 1, 5, 10, 30 and 100 au, or `spacing="true"` for the real proportion. A body further out than the edge is left off; the edge is the smallest of 50, 100, 200, 500, 1,000 and 2,000 au that holds the planets, dwarf planets and craft shown.
38
+ *
39
+ * Attributes (the ones marked "same" are the names and meanings `<wakusei-flat>` has): `time` (same: `now`, an ISO date or milliseconds since 1970; live when absent), `speed` (same: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `paused` (same: hold the clock and keep the speed),
40
+ * `selected` (same: the chosen body's id such as `earth`, `halley` or `roadster`), `center` (a body to centre the map on and follow: `sun` by default; a drag lets go of it), `dot-size` (same: pixels), `controls` (same: `none`, or any of `centre zoom orbits track scale chips`; all by default), `lang` (same: `en` or `ja`; the page's language by default),
41
+ * `layers` (`planets dwarfs belts comets craft`: what is drawn; all by default, `off` for none), `craft`, `comets` and `belts` (`all`, `off` or ids with commas: which craft, comets or belts), `orbits` (`off` hides the orbit lines of the planets and dwarf planets), `track` (same: the whole path of the chosen craft and the orbit of the chosen comet, or of every one shown when none is chosen),
42
+ * `spacing` (`squeezed`, the default, or `true`), `extent` (the distance at the edge in au; `auto`, the default, is the smallest step that holds what is shown), `names` (same: `off` for no names beside the bodies, or the most names to show). `footprint`, `shade`, `home-lon` and `home-lat` belong to a map of a surface and are not read.
43
+ *
44
+ * Events (the names `<wakusei-flat>` sends): `wakusei-flat-pick` (a body or a belt body under the pointer, tapped, or reached by the keyboard: a `SystemPick`; `detail.id` is null when a tap lands on nothing and clears the choice), `wakusei-flat-filter` (a chip changed what is shown: `{ layers }`),
45
+ * `wakusei-flat-view` (the reader panned or zoomed: `{ center, x, y, zoom }`) and `wakusei-timechange` (`{ time, running, paused }`, at most four a second while time runs).
46
+ * Style it with the custom properties `--wakusei-flat-space`, `--wakusei-flat-aspect`, `--wakusei-flat-aspect-narrow` and `--wakusei-flat-radius`.
47
+ *
48
+ * @example
49
+ * ```ts no-run
50
+ * import "@johnmorrisdotca/wakusei-planets/flat/system/define";
51
+ * import type { WakuseiFlatSystem } from "@johnmorrisdotca/wakusei-planets/flat/system";
52
+ *
53
+ * const system = document.createElement("wakusei-flat-system") as WakuseiFlatSystem;
54
+ * system.setAttribute("selected", "roadster");
55
+ * system.setAttribute("track", "");
56
+ * document.body.append(system);
57
+ * system.addEventListener("wakusei-flat-pick", (event) => console.log((event as CustomEvent).detail.name));
58
+ * ```
59
+ */
60
+ export declare class WakuseiFlatSystem extends HTMLElement {
61
+ #private;
62
+ static observedAttributes: string[];
63
+ /** The id of the chosen body (or the name of a chosen belt body), or null. Set it to choose one from code (no `wakusei-flat-pick` is sent), `null` to clear. */
64
+ get selected(): string | null;
65
+ set selected(id: string | null);
66
+ /** The id of the body the map is centred on and follows, or null while it is centred on the Sun or the reader has dragged it away. Set it to a body's id to centre there, or to `sun` or null for the Sun. */
67
+ get center(): string | null;
68
+ set center(id: string | null);
69
+ /** The zoom: 1 shows the whole disc, up to 8. */
70
+ get zoom(): number;
71
+ set zoom(value: number);
72
+ /** The moment shown, in milliseconds since the Unix epoch. Set it to a number (or a `Date`) to move the clock, or "now" to go live. */
73
+ get time(): number;
74
+ set time(value: number | Date | "now");
75
+ /** How fast the clock runs: 1 is real time, 0 holds, 86400 is a day a second, negative runs backwards. */
76
+ get speed(): number;
77
+ set speed(value: number);
78
+ /** True while the clock is held with its speed kept: nothing is drawn but what the reader changes. Setting it false carries on from the moment shown at the same speed. */
79
+ get paused(): boolean;
80
+ set paused(value: boolean);
81
+ /** The language of the words: the `lang` attribute, else the page's. */
82
+ get language(): FlatLang;
83
+ /** The layers drawn now: `planets`, `dwarfs`, `belts`, `comets` and `craft`. */
84
+ get layers(): readonly SystemLayer[];
85
+ /** The distance at the edge of the map in au, as of the last draw. */
86
+ get extent(): number;
87
+ /** The bodies drawn at the last draw, with their place on the screen: their ids, names, kinds and layers, whether each is inside the box, and its distance from the Sun in au. */
88
+ get bodies(): readonly {
89
+ id: string;
90
+ name: string;
91
+ kind: SystemKind;
92
+ layer: SystemLayer | "sun";
93
+ shown: boolean;
94
+ distanceAu: number;
95
+ predicted: boolean;
96
+ }[];
97
+ /** Counters for a test or a page: draws of the bodies, draws of the disc, the bodies and belt points drawn at the last draw, the milliseconds the last draw and the slowest took, and the canvases' size in pixels. */
98
+ get stats(): {
99
+ draws: number;
100
+ mapDraws: number;
101
+ dots: number;
102
+ beltPoints: number;
103
+ lastDrawMs: number;
104
+ maxDrawMs: number;
105
+ averageDrawMs: number;
106
+ running: boolean;
107
+ paused: boolean;
108
+ extent: number;
109
+ canvases: {
110
+ width: number;
111
+ height: number;
112
+ }[];
113
+ };
114
+ /** Where a body is on the screen as of the last draw, in CSS pixels from the map's top left, or null when it is not drawn (a layer off, outside the edge, or a craft with no path at the moment shown). */
115
+ placeOf(id: string): {
116
+ x: number;
117
+ y: number;
118
+ au: readonly [number, number, number];
119
+ distanceAu: number;
120
+ } | null;
121
+ /** Choose a body from code, as a reader's tap would, without sending `wakusei-flat-pick`. An id the map does not hold, or `null`, clears the choice. */
122
+ pick(id: string | null): void;
123
+ connectedCallback(): void;
124
+ disconnectedCallback(): void;
125
+ attributeChangedCallback(name: string, old: string | null, value: string | null): void;
126
+ /** The distance in au under a point of the box, in the map's present scale: for a page that reads where a pointer is. */
127
+ auAt(x: number, y: number): number;
128
+ }
129
+ declare global {
130
+ interface HTMLElementTagNameMap {
131
+ "wakusei-flat-system": WakuseiFlatSystem;
132
+ }
133
+ }