@johnmorrisdotca/wakusei-planets 0.30.0 → 0.32.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.
- package/CHANGELOG.md +16 -0
- package/NOTICE.md +5 -0
- package/README.md +98 -12
- package/dist/data-door.d.ts +357 -0
- package/dist/data-door.js +393 -0
- package/dist/door/book.d.ts +133 -0
- package/dist/door/book.js +256 -0
- package/dist/door/host.d.ts +30 -0
- package/dist/door/host.js +44 -0
- package/dist/door/index.d.ts +6 -0
- package/dist/door/index.js +10 -0
- package/dist/door/map.d.ts +152 -0
- package/dist/door/map.js +162 -0
- package/dist/door/own.d.ts +36 -0
- package/dist/door/own.js +86 -0
- package/dist/door/points.d.ts +61 -0
- package/dist/door/points.js +175 -0
- package/dist/door/small-bodies.d.ts +157 -0
- package/dist/door/small-bodies.js +148 -0
- package/dist/element.d.ts +21 -0
- package/dist/element.js +74 -4
- package/dist/scene/body.d.ts +5 -2
- package/dist/scene/body.js +2 -1
- package/dist/scene/detail.d.ts +29 -12
- package/dist/scene/detail.js +217 -135
- package/dist/scene/painter.d.ts +5 -0
- package/dist/scene/painter.js +8 -5
- package/dist/scene/textures.d.ts +9 -2
- package/dist/scene/textures.js +17 -0
- package/dist/space/arrows.d.ts +87 -0
- package/dist/space/arrows.js +117 -0
- package/dist/space/beside.d.ts +74 -0
- package/dist/space/beside.js +76 -0
- package/dist/space/bodies.d.ts +83 -0
- package/dist/space/bodies.js +93 -0
- package/dist/space/element.d.ts +114 -14
- package/dist/space/element.js +344 -28
- package/dist/space/frame.d.ts +45 -2
- package/dist/space/frame.js +56 -4
- package/dist/space/index.d.ts +6 -1
- package/dist/space/index.js +6 -1
- package/dist/space/labels.d.ts +52 -0
- package/dist/space/labels.js +40 -0
- package/dist/space/scale.d.ts +5 -5
- package/dist/space/scale.js +10 -4
- package/dist/space/scene.d.ts +49 -9
- package/dist/space/scene.js +325 -34
- package/dist/space/spin.d.ts +37 -0
- package/dist/space/spin.js +29 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -1
package/dist/space/element.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
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";
|
|
4
|
+
import type { Credit, DataSource } from "../data-door.ts";
|
|
5
|
+
import { type DoorHost } from "../door/host.ts";
|
|
2
6
|
import { setThreeLoader } from "../scene/shared.ts";
|
|
3
7
|
import { type SpacePlanet } from "./frame.ts";
|
|
4
8
|
import { type ScaleMode } from "./scale.ts";
|
|
5
9
|
import type { RideLook } from "./ride.ts";
|
|
6
|
-
import { SPACE_BODIES, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
10
|
+
import { SPACE_BODIES, type BodyPlace, type RidePoint, type RideState, type RideTarget, type SpaceBody, type SpaceLight } from "./scene.ts";
|
|
7
11
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type SpaceBody, type SpaceLight };
|
|
12
|
+
/** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
|
|
13
|
+
export type { BodyPlace };
|
|
8
14
|
/**
|
|
9
15
|
* What a page can tell a reader about a body now.
|
|
10
16
|
*
|
|
@@ -12,14 +18,18 @@ export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Spa
|
|
|
12
18
|
* ```ts no-run
|
|
13
19
|
* import type { BodyInfo } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
14
20
|
*
|
|
15
|
-
* const info: BodyInfo = { id: "mars", name: "Mars", radiusKm: 3389.5, distanceKm: 225_000_000 };
|
|
21
|
+
* const info: BodyInfo = { id: "mars", name: "Mars", kind: "planet", radiusKm: 3389.5, distanceKm: 225_000_000 };
|
|
16
22
|
* console.log(`${info.name}: ${info.radiusKm} km`);
|
|
17
23
|
* ```
|
|
18
24
|
*/
|
|
19
25
|
export interface BodyInfo {
|
|
20
|
-
id:
|
|
26
|
+
id: BodyId;
|
|
21
27
|
/** The name shown beside the body. */
|
|
22
28
|
name: string;
|
|
29
|
+
/** The Sun, a planet, a dwarf planet or a moon. */
|
|
30
|
+
kind: SpaceKind;
|
|
31
|
+
/** For a moon, the planet it goes round. */
|
|
32
|
+
host?: BodyId;
|
|
23
33
|
/** Mean radius, kilometres. */
|
|
24
34
|
radiusKm: number;
|
|
25
35
|
/** Distance from the Earth's centre now, kilometres (0 for the Earth). */
|
|
@@ -48,9 +58,9 @@ export type SpaceState = "loading" | "live" | "unavailable" | "lost";
|
|
|
48
58
|
* console.log(typeof zoomTo);
|
|
49
59
|
* ```
|
|
50
60
|
*/
|
|
51
|
-
export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" | `${Exclude<SpacePlanet, "mercury" | "venus">}-moons`;
|
|
61
|
+
export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" | `${Exclude<SpacePlanet, "mercury" | "venus">}-moons` | `${"orcus" | "haumea" | "eris"}-moons`;
|
|
52
62
|
/**
|
|
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`,
|
|
63
|
+
* 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
64
|
* 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
65
|
* 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
66
|
*
|
|
@@ -63,7 +73,7 @@ export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system" |
|
|
|
63
73
|
* ```
|
|
64
74
|
*/
|
|
65
75
|
export interface RideOptions {
|
|
66
|
-
view?: "from" | "follow";
|
|
76
|
+
view?: "from" | "follow" | "beside";
|
|
67
77
|
look?: RideLook;
|
|
68
78
|
distanceKm?: number;
|
|
69
79
|
around?: SpaceBody;
|
|
@@ -87,6 +97,8 @@ export type Riding = RideState;
|
|
|
87
97
|
* `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
98
|
* only when something changes, and nothing while it is out of sight.
|
|
89
99
|
*
|
|
100
|
+
* `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.
|
|
101
|
+
*
|
|
90
102
|
* 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
103
|
* 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
104
|
*
|
|
@@ -130,13 +142,22 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
130
142
|
/** Seconds of game time per second: 1 is real time, 0 holds still, negative runs backwards. */
|
|
131
143
|
get speed(): number;
|
|
132
144
|
set speed(value: number);
|
|
133
|
-
/** `
|
|
145
|
+
/** `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
146
|
get scale(): ScaleMode;
|
|
135
147
|
set scale(value: ScaleMode);
|
|
148
|
+
/** 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`. */
|
|
149
|
+
get scaleNames(): Partial<Record<ScaleMode, string>>;
|
|
150
|
+
set scaleNames(value: Partial<Record<ScaleMode, string>>);
|
|
136
151
|
get labels(): boolean;
|
|
137
152
|
set labels(value: boolean);
|
|
138
153
|
get orbits(): boolean;
|
|
139
154
|
set orbits(value: boolean);
|
|
155
|
+
/**
|
|
156
|
+
* 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
|
|
157
|
+
* 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.
|
|
158
|
+
*/
|
|
159
|
+
get help(): boolean;
|
|
160
|
+
set help(value: boolean);
|
|
140
161
|
/** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
|
|
141
162
|
get look(): "realistic" | "painted";
|
|
142
163
|
set look(value: "realistic" | "painted");
|
|
@@ -158,17 +179,48 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
158
179
|
panX?: number;
|
|
159
180
|
panY?: number;
|
|
160
181
|
}, final?: boolean): void;
|
|
161
|
-
/** The body the camera looks at (`earth`, `sun`, `moon`, `mercury` to `neptune`, `pluto`)
|
|
162
|
-
get body():
|
|
163
|
-
set body(name:
|
|
182
|
+
/** 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. */
|
|
183
|
+
get body(): BodyId;
|
|
184
|
+
set body(name: BodyId | string);
|
|
185
|
+
/** What the hopper can do from where it is: the body at the middle, and the bodies the previous and next hop lead to. */
|
|
186
|
+
get hopper(): {
|
|
187
|
+
current: BodyInfo;
|
|
188
|
+
previous: BodyInfo;
|
|
189
|
+
next: BodyInfo;
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* 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
|
|
193
|
+
* 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.
|
|
194
|
+
*
|
|
195
|
+
* @param target - A body's name (`"saturn"`, `"Saturn"`, `"土星"`).
|
|
196
|
+
* @param options - `smooth` (true by default) and `zoom` (1 by default).
|
|
197
|
+
* @returns Whether the view can go there.
|
|
198
|
+
*/
|
|
199
|
+
goTo(target: BodyId | string, options?: {
|
|
200
|
+
smooth?: boolean;
|
|
201
|
+
zoom?: number;
|
|
202
|
+
}): boolean;
|
|
203
|
+
/** 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. */
|
|
204
|
+
next(options?: {
|
|
205
|
+
smooth?: boolean;
|
|
206
|
+
}): BodyInfo;
|
|
207
|
+
/** Go to the previous body in the same order. */
|
|
208
|
+
previous(options?: {
|
|
209
|
+
smooth?: boolean;
|
|
210
|
+
}): BodyInfo;
|
|
211
|
+
/** 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. */
|
|
212
|
+
bodyList(): BodyInfo[];
|
|
213
|
+
/** 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. */
|
|
214
|
+
get selected(): BodyId | null;
|
|
215
|
+
set selected(id: BodyId | null);
|
|
164
216
|
/** 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<
|
|
166
|
-
set bodyNames(value: Partial<Record<
|
|
217
|
+
get bodyNames(): Partial<Record<string, string>>;
|
|
218
|
+
set bodyNames(value: Partial<Record<string, string>>);
|
|
167
219
|
/** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
|
|
168
220
|
get bodyHint(): string;
|
|
169
221
|
set bodyHint(value: string);
|
|
170
222
|
/** The name, radius and distance from the Earth of a body now, for a page's own caption. */
|
|
171
|
-
bodyInfo(id:
|
|
223
|
+
bodyInfo(id: BodyId): BodyInfo;
|
|
172
224
|
/**
|
|
173
225
|
* 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
226
|
* 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 +234,24 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
182
234
|
/** What the camera is riding along with now, or null. */
|
|
183
235
|
get riding(): Riding | null;
|
|
184
236
|
/** 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(
|
|
237
|
+
zoomFor(named: SpacePreset | string): number;
|
|
238
|
+
/**
|
|
239
|
+
* The outside sources of this view (the data door): maps of a body, which take the place of the folder of tiles for it, and records of small bodies, which are drawn as points in one instanced draw. Each carries its own
|
|
240
|
+
* licence and credit. Assign a list to replace them; a source `validateSource` refuses throws a `TypeError` and changes nothing. A property, not an attribute: data is not text.
|
|
241
|
+
*/
|
|
242
|
+
get sources(): readonly DataSource[];
|
|
243
|
+
set sources(list: readonly DataSource[]);
|
|
244
|
+
/** Adds one source (checked at once: a `TypeError` for an empty credit, no licence, a clashing id or a map source with no body). Returns the function that removes it. */
|
|
245
|
+
addSource(source: DataSource): () => void;
|
|
246
|
+
/** Removes a source by id: its loads are aborted, its tiles and records freed, its points and window taken off the picture, and its credit goes. Returns whether there was one. */
|
|
247
|
+
removeSource(id: string): boolean;
|
|
248
|
+
/** Switches a source off (`false`) or on, for a layers panel. */
|
|
249
|
+
enableSource(id: string, on: boolean): void;
|
|
250
|
+
/**
|
|
251
|
+
* The sources whose data was in the last drawn frame, the package's own first: the surface pictures and the positions of the bodies, the finer map tiles where a window of them is on a body, and each source of yours that
|
|
252
|
+
* gave points or tiles. `creditLine(credits, "en" | "ja")` from `@johnmorrisdotca/wakusei-planets/door` writes them with the licences. `wakusei-creditschange` fires when this set changes (not at each frame), with `detail: { credits }`.
|
|
253
|
+
*/
|
|
254
|
+
credits(): Credit[];
|
|
186
255
|
/** What the element is doing, for a page or a test. */
|
|
187
256
|
get stats(): {
|
|
188
257
|
state: SpaceState;
|
|
@@ -226,7 +295,38 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
226
295
|
lost: boolean;
|
|
227
296
|
gliding: boolean;
|
|
228
297
|
};
|
|
298
|
+
/** 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). */
|
|
299
|
+
door: {
|
|
300
|
+
points: number;
|
|
301
|
+
sources: ReturnType<DoorHost["book"]["stats"]>;
|
|
302
|
+
};
|
|
303
|
+
/** 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. */
|
|
304
|
+
orbits: {
|
|
305
|
+
drawn: string[];
|
|
306
|
+
miss: Record<string, number>;
|
|
307
|
+
hidden: string[];
|
|
308
|
+
};
|
|
309
|
+
/** 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). */
|
|
310
|
+
arrows: Record<string, {
|
|
311
|
+
position: [number, number, number];
|
|
312
|
+
direction: [number, number, number];
|
|
313
|
+
}[]>;
|
|
314
|
+
/** 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. */
|
|
315
|
+
arrowPx: number;
|
|
316
|
+
/** 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. */
|
|
317
|
+
help: {
|
|
318
|
+
body: string;
|
|
319
|
+
axis: [number, number, number];
|
|
320
|
+
pole: [number, number, number];
|
|
321
|
+
retrograde: boolean;
|
|
322
|
+
arcTurn: [number, number, number];
|
|
323
|
+
} | null;
|
|
229
324
|
};
|
|
325
|
+
/** 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. */
|
|
326
|
+
placeOf(id: BodyId): BodyPlace | null;
|
|
327
|
+
/** 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. */
|
|
328
|
+
get immersive(): boolean;
|
|
329
|
+
set immersive(value: boolean);
|
|
230
330
|
}
|
|
231
331
|
declare global {
|
|
232
332
|
interface HTMLElementTagNameMap {
|