@johnmorrisdotca/wakusei-planets 0.28.0 → 0.31.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 (56) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/NOTICE.md +20 -0
  3. package/README.md +61 -16
  4. package/dist/embed.d.ts +64 -0
  5. package/dist/embed.js +66 -0
  6. package/dist/index.d.ts +4 -1
  7. package/dist/index.js +4 -1
  8. package/dist/lineup/data.d.ts +160 -0
  9. package/dist/lineup/data.js +303 -0
  10. package/dist/lineup/element.d.ts +99 -0
  11. package/dist/lineup/element.js +782 -0
  12. package/dist/lineup/labels.d.ts +141 -0
  13. package/dist/lineup/labels.js +155 -0
  14. package/dist/lineup/layout.d.ts +174 -0
  15. package/dist/lineup/layout.js +162 -0
  16. package/dist/lineup/scene3d.d.ts +47 -0
  17. package/dist/lineup/scene3d.js +155 -0
  18. package/dist/portrait/element.d.ts +5 -2
  19. package/dist/portrait/element.js +57 -6
  20. package/dist/portrait/scene3d.d.ts +13 -0
  21. package/dist/portrait/scene3d.js +21 -2
  22. package/dist/scene/body.d.ts +3 -1
  23. package/dist/scene/body.js +2 -1
  24. package/dist/scene/detail.d.ts +8 -2
  25. package/dist/scene/detail.js +56 -28
  26. package/dist/scene/painter.d.ts +32 -0
  27. package/dist/scene/painter.js +94 -10
  28. package/dist/scene/textures.d.ts +4 -2
  29. package/dist/scene/textures.js +2 -0
  30. package/dist/scene/tiles.d.ts +46 -0
  31. package/dist/scene/tiles.js +165 -19
  32. package/dist/space/arrows.d.ts +87 -0
  33. package/dist/space/arrows.js +117 -0
  34. package/dist/space/beside.d.ts +74 -0
  35. package/dist/space/beside.js +76 -0
  36. package/dist/space/bodies.d.ts +83 -0
  37. package/dist/space/bodies.js +93 -0
  38. package/dist/space/clock.d.ts +31 -0
  39. package/dist/space/clock.js +45 -0
  40. package/dist/space/element.d.ts +98 -15
  41. package/dist/space/element.js +320 -63
  42. package/dist/space/frame.d.ts +45 -2
  43. package/dist/space/frame.js +56 -4
  44. package/dist/space/index.d.ts +6 -1
  45. package/dist/space/index.js +6 -1
  46. package/dist/space/labels.d.ts +52 -0
  47. package/dist/space/labels.js +40 -0
  48. package/dist/space/scale.d.ts +5 -5
  49. package/dist/space/scale.js +10 -4
  50. package/dist/space/scene.d.ts +50 -9
  51. package/dist/space/scene.js +313 -36
  52. package/dist/space/spin.d.ts +37 -0
  53. package/dist/space/spin.js +29 -0
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/package.json +8 -1
@@ -1,10 +1,14 @@
1
1
  import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
2
+ import { type BodyId } from "../facts.ts";
3
+ import { type SpaceKind } from "./bodies.ts";
2
4
  import { setThreeLoader } from "../scene/shared.ts";
3
5
  import { type SpacePlanet } from "./frame.ts";
4
6
  import { type ScaleMode } from "./scale.ts";
5
7
  import type { RideLook } from "./ride.ts";
6
- import { SPACE_BODIES, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
8
+ import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
7
9
  export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type SpaceBody, type SpaceLight };
10
+ /** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
11
+ export type { BodyPlace };
8
12
  /**
9
13
  * What a page can tell a reader about a body now.
10
14
  *
@@ -12,14 +16,18 @@ export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Spa
12
16
  * ```ts no-run
13
17
  * import type { BodyInfo } from "@johnmorrisdotca/wakusei-planets/space/element";
14
18
  *
15
- * const info: BodyInfo = { id: "mars", name: "Mars", radiusKm: 3389.5, distanceKm: 225_000_000 };
19
+ * const info: BodyInfo = { id: "mars", name: "Mars", kind: "planet", radiusKm: 3389.5, distanceKm: 225_000_000 };
16
20
  * console.log(`${info.name}: ${info.radiusKm} km`);
17
21
  * ```
18
22
  */
19
23
  export interface BodyInfo {
20
- id: SpaceBody;
24
+ id: BodyId;
21
25
  /** The name shown beside the body. */
22
26
  name: string;
27
+ /** The Sun, a planet, a dwarf planet or a moon. */
28
+ kind: SpaceKind;
29
+ /** For a moon, the planet it goes round. */
30
+ host?: BodyId;
23
31
  /** Mean radius, kilometres. */
24
32
  radiusKm: number;
25
33
  /** Distance from the Earth's centre now, kilometres (0 for the Earth). */
@@ -48,9 +56,9 @@ export type SpaceState = "loading" | "live" | "unavailable" | "lost";
48
56
  * console.log(typeof zoomTo);
49
57
  * ```
50
58
  */
51
- export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" | `${Exclude<SpacePlanet, "mercury" | "venus">}-moons`;
59
+ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" | `${Exclude<SpacePlanet, "mercury" | "venus">}-moons` | `${"orcus" | "haumea" | "eris"}-moons`;
52
60
  /**
53
- * How a ride along is done: `view` `from` (the default) puts the camera at the target looking at the body it goes round, `follow` keeps it a distance from the target looking at it (`distanceKm`,
61
+ * How a ride along is done: `view` `from` (the default) puts the camera at the target looking at the body it goes round, `beside` (for a moon) puts it beyond the moon and off the line to its planet, the moon large in the foreground and the planet in view behind it, `follow` keeps it a distance from the target looking at it (`distanceKm`,
54
62
  * 3000 by default, for a point of your own; a body or a moon is kept at the distance the zoom says); `look` `down` (the default) or `horizon` is where a camera at the target points; `around` is the
55
63
  * body a point of your own goes round (the Earth by default); `smooth` (the default) glides 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.
56
64
  *
@@ -63,7 +71,7 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
63
71
  * ```
64
72
  */
65
73
  export interface RideOptions {
66
- view?: "from" | "follow";
74
+ view?: "from" | "follow" | "beside";
67
75
  look?: RideLook;
68
76
  distanceKm?: number;
69
77
  around?: SpaceBody;
@@ -84,9 +92,11 @@ export type Riding = RideState;
84
92
  /**
85
93
  * 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`
86
94
  * (`"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`),
87
- * `light` (`sun` or `lit`), `lang` (`en` or `ja`: the names), `labels` and `orbits` (`off` hides them), and `texture-base`, `texture-far-base` and `max-texture`. Positions come from this package's own models. It draws
95
+ * `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
88
96
  * only when something changes, and nothing while it is out of sight.
89
97
  *
98
+ * `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.
99
+ *
90
100
  * 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
91
101
  * focused. `controls="none"` turns them off; `zoom-min` and `zoom-max` set the range (a millionth to 3 by default); a `<kazoku-view-controls for="...">` takes over and reads it.
92
102
  *
@@ -130,13 +140,22 @@ export declare class WakuseiSpace extends HTMLElement {
130
140
  /** Seconds of game time per second: 1 is real time, 0 holds still, negative runs backwards. */
131
141
  get speed(): number;
132
142
  set speed(value: number);
133
- /** `compressed` (the default: every direction real, the distances squeezed) or `true` (real distances and sizes). */
143
+ /** `true` (the default: real distances and sizes; a body too small to see is marked with a ring and its name) or `compressed` (every direction real, the distances squeezed). The scale in use is always named on the view. */
134
144
  get scale(): ScaleMode;
135
145
  set scale(value: ScaleMode);
146
+ /** The words naming the scale on the view, for a page in another language (`{ true: "距離はそのまま" }`). A scale left out keeps its words in the element's `lang`. */
147
+ get scaleNames(): Partial<Record<ScaleMode, string>>;
148
+ set scaleNames(value: Partial<Record<ScaleMode, string>>);
136
149
  get labels(): boolean;
137
150
  set labels(value: boolean);
138
151
  get orbits(): boolean;
139
152
  set orbits(value: boolean);
153
+ /**
154
+ * Help mode (the `help` attribute; off by default): on the body looked at, a line along its axis and a curved arrow round it showing which way it spins, by the right-hand rule about the axis it really turns about, so it is
155
+ * right for Venus and Uranus, which turn backwards, and for Uranus on its side. It is about learning, so the arrow is drawn over the body.
156
+ */
157
+ get help(): boolean;
158
+ set help(value: boolean);
140
159
  /** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
141
160
  get look(): "realistic" | "painted";
142
161
  set look(value: "realistic" | "painted");
@@ -158,17 +177,48 @@ export declare class WakuseiSpace extends HTMLElement {
158
177
  panX?: number;
159
178
  panY?: number;
160
179
  }, final?: boolean): void;
161
- /** The body the camera looks at (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`): at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
162
- get body(): SpaceBody;
163
- set body(name: SpaceBody);
180
+ /** The body the camera looks at: any body the view places, by name in any case (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`, and the moons of the planets such as `titan`). At zoom 1 it fills the view; the yaw and tilt turn the camera round it. Setting it moves the camera there at once and keeps the zoom; `goTo` glides and brings the body into view. */
181
+ get body(): BodyId;
182
+ set body(name: BodyId | string);
183
+ /** What the hopper can do from where it is: the body at the middle, and the bodies the previous and next hop lead to. */
184
+ get hopper(): {
185
+ current: BodyInfo;
186
+ previous: BodyInfo;
187
+ next: BodyInfo;
188
+ };
189
+ /**
190
+ * 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
191
+ * 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.
192
+ *
193
+ * @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`).
194
+ * @param options - `smooth` (true by default) and `zoom` (1 by default).
195
+ * @returns Whether the view can go there.
196
+ */
197
+ goTo(target: BodyId | string, options?: {
198
+ smooth?: boolean;
199
+ zoom?: number;
200
+ }): boolean;
201
+ /** 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. */
202
+ next(options?: {
203
+ smooth?: boolean;
204
+ }): BodyInfo;
205
+ /** Go to the previous body in the same order. */
206
+ previous(options?: {
207
+ smooth?: boolean;
208
+ }): BodyInfo;
209
+ /** Every body the view can go to, in the hopper's order, with its kind and, for a moon, its planet: a page's jump list. */
210
+ bodyList(): BodyInfo[];
211
+ /** The body a press has chosen and the page may be showing a card for, or null. A second press on it, or `goTo`, makes it the middle of the view. */
212
+ get selected(): BodyId | null;
213
+ set selected(id: BodyId | null);
164
214
  /** The words shown beside each body, for a page in another language (`{ mars: "火星" }`). A body left out keeps its name in the element's `lang`. */
165
- get bodyNames(): Partial<Record<SpaceBody, string>>;
166
- set bodyNames(value: Partial<Record<SpaceBody, string>>);
215
+ get bodyNames(): Partial<Record<string, string>>;
216
+ set bodyNames(value: Partial<Record<string, string>>);
167
217
  /** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
168
218
  get bodyHint(): string;
169
219
  set bodyHint(value: string);
170
220
  /** The name, radius and distance from the Earth of a body now, for a page's own caption. */
171
- bodyInfo(id: SpaceBody): BodyInfo;
221
+ bodyInfo(id: BodyId): BodyInfo;
172
222
  /**
173
223
  * Ride along with a body, a moon or a moving point of your own. By default the camera sits at it and looks at the body it goes round, with the way it is going at the top of the picture, at its real place for the moment shown,
174
224
  * so the ground slides beneath as it moves along its orbit. 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
@@ -182,7 +232,7 @@ export declare class WakuseiSpace extends HTMLElement {
182
232
  /** What the camera is riding along with now, or null. */
183
233
  get riding(): Riding | null;
184
234
  /** The zoom that shows a part of the sky: the Earth alone, the Moon's orbit, the Sun, the planets out to Mars, all of them, or a planet's nearer moons, at this scale and moment. */
185
- zoomFor(preset: SpacePreset): number;
235
+ zoomFor(named: SpacePreset | string): number;
186
236
  /** What the element is doing, for a page or a test. */
187
237
  get stats(): {
188
238
  state: SpaceState;
@@ -214,12 +264,45 @@ export declare class WakuseiSpace extends HTMLElement {
214
264
  moons: number;
215
265
  held: number;
216
266
  };
267
+ /** What the windows of finer map tiles on the bodies are doing at the last draw, summed: tile fetches made, tiles being fetched, tiles or windows that failed, and the finest level on a body now (`null` for none). */
268
+ tiles: {
269
+ requested: number;
270
+ loading: number;
271
+ failed: number;
272
+ shown: number | null;
273
+ };
217
274
  ride: {
218
275
  riding: boolean;
219
276
  lost: boolean;
220
277
  gliding: boolean;
221
278
  };
279
+ /** 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. */
280
+ orbits: {
281
+ drawn: string[];
282
+ miss: Record<string, number>;
283
+ hidden: string[];
284
+ };
285
+ /** The arrowheads on the orbit lines at the last draw, by line (`earth`, the planets, `moon`): where each is and the way it points, the way the body goes (not the way the clock runs). */
286
+ arrows: Record<string, {
287
+ position: [number, number, number];
288
+ direction: [number, number, number];
289
+ }[]>;
290
+ /** How long an arrowhead on an orbit line is on the screen at the last draw, in CSS pixels (0 when none is drawn): the same at every zoom. */
291
+ arrowPx: number;
292
+ /** What help mode drew at the last draw, or null: the body, the axis it spins about, its north pole, and the axis the drawn arrow itself turns about. */
293
+ help: {
294
+ body: string;
295
+ axis: [number, number, number];
296
+ pole: [number, number, number];
297
+ retrograde: boolean;
298
+ arcTurn: [number, number, number];
299
+ } | null;
222
300
  };
301
+ /** 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. */
302
+ placeOf(id: BodyId): BodyPlace | null;
303
+ /** True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape, a plain wheel zooms instead of scrolling the page, and a touch drag turns the view instead of scrolling it. */
304
+ get immersive(): boolean;
305
+ set immersive(value: boolean);
223
306
  }
224
307
  declare global {
225
308
  interface HTMLElementTagNameMap {