@johnmorrisdotca/chikyu-earth 0.5.0 → 0.8.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 +70 -0
- package/NOTICE.md +22 -0
- package/README.md +186 -27
- package/dist/countries.d.ts +11 -0
- package/dist/countries.js +11 -0
- package/dist/element.d.ts +18 -0
- package/dist/element.js +15 -2
- package/dist/globe.d.ts +15 -1
- package/dist/globe.js +15 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +12 -1
- package/dist/markers/cluster.d.ts +27 -0
- package/dist/markers/cluster.js +16 -0
- package/dist/markers/labels.d.ts +40 -0
- package/dist/markers/labels.js +18 -0
- package/dist/markers/layer.d.ts +80 -0
- package/dist/markers/layer.js +21 -0
- package/dist/markers/project.d.ts +63 -2
- package/dist/markers/project.js +52 -2
- package/dist/markers/types.d.ts +48 -3
- package/dist/realistic/earth.d.ts +30 -5
- package/dist/realistic/earth.js +41 -134
- package/dist/realistic/element.d.ts +47 -7
- package/dist/realistic/element.js +48 -44
- package/dist/realistic/gate.d.ts +45 -1
- package/dist/realistic/gate.js +33 -1
- package/dist/realistic/shaders.d.ts +9 -4
- package/dist/realistic/shaders.js +54 -9
- package/dist/realistic/shared.d.ts +23 -0
- package/dist/realistic/shared.js +51 -0
- package/dist/realistic/sun.d.ts +40 -3
- package/dist/realistic/sun.js +40 -3
- package/dist/realistic/textures.d.ts +43 -0
- package/dist/realistic/textures.js +141 -0
- package/dist/realistic/tiers.d.ts +80 -6
- package/dist/realistic/tiers.js +69 -5
- package/dist/rotate.d.ts +59 -4
- package/dist/rotate.js +59 -4
- package/dist/satellites/index.d.ts +3 -0
- package/dist/satellites/index.js +3 -0
- package/dist/satellites/limits.d.ts +22 -0
- package/dist/satellites/limits.js +23 -0
- package/dist/satellites/track.d.ts +50 -0
- package/dist/satellites/track.js +227 -0
- package/dist/satellites/types.d.ts +161 -0
- package/dist/satellites/types.js +3 -0
- package/dist/space/element.d.ts +179 -0
- package/dist/space/element.js +541 -0
- package/dist/space/ephemeris.d.ts +151 -0
- package/dist/space/ephemeris.js +162 -0
- package/dist/space/index.d.ts +3 -0
- package/dist/space/index.js +5 -0
- package/dist/space/satellite-layer.d.ts +53 -0
- package/dist/space/satellite-layer.js +230 -0
- package/dist/space/scale.d.ts +124 -0
- package/dist/space/scale.js +141 -0
- package/dist/space/scene.d.ts +146 -0
- package/dist/space/scene.js +320 -0
- package/dist/styles.d.ts +65 -2
- package/dist/styles.js +43 -2
- package/dist/textures/moon-1024.webp +0 -0
- package/dist/textures/moon-2048.webp +0 -0
- package/dist/types.d.ts +55 -5
- package/dist/view.d.ts +63 -4
- package/dist/view.js +52 -4
- package/package.json +71 -8
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { GeoPoint } from "../types.ts";
|
|
2
|
+
import { setThreeLoader } from "../realistic/shared.ts";
|
|
3
|
+
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
4
|
+
import { type SatelliteStyle } from "./satellite-layer.ts";
|
|
5
|
+
import { type ScaleMode } from "./scale.ts";
|
|
6
|
+
import { BODY_NAMES, type BodyName, type BodyPainter } from "./scene.ts";
|
|
7
|
+
export { BODY_NAMES, type BodyName };
|
|
8
|
+
/**
|
|
9
|
+
* 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
|
|
10
|
+
* the painter only for what to draw at each place (see `BodyPainter`). Left alone, they are plain spheres in the right colours.
|
|
11
|
+
*
|
|
12
|
+
* @param next - The painter to use, or `undefined` for the plain one.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts no-run
|
|
16
|
+
* import { plainPainter } from "@johnmorrisdotca/chikyu-earth/space";
|
|
17
|
+
* import { setBodyPainter } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
18
|
+
*
|
|
19
|
+
* setBodyPainter({ make: (three, name) => plainPainter.make(three, name) });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function setBodyPainter(next: BodyPainter | undefined): void;
|
|
23
|
+
/**
|
|
24
|
+
* What a page can tell a reader about a body now.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts no-run
|
|
28
|
+
* import type { BodyInfo } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
29
|
+
*
|
|
30
|
+
* const info: BodyInfo = { name: "Mars", radiusKm: 3389.5, distanceKm: 225_000_000 };
|
|
31
|
+
* console.log(`${info.name}: ${info.radiusKm} km`);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export interface BodyInfo {
|
|
35
|
+
name: BodyName;
|
|
36
|
+
/** Mean radius, kilometres. */
|
|
37
|
+
radiusKm: number;
|
|
38
|
+
/** Distance from the Earth's centre now, kilometres (0 for the Earth). */
|
|
39
|
+
distanceKm: number;
|
|
40
|
+
}
|
|
41
|
+
export { setThreeLoader };
|
|
42
|
+
/**
|
|
43
|
+
* 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).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts no-run
|
|
47
|
+
* import type { ChikyuSpace, SpaceState } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
48
|
+
*
|
|
49
|
+
* const stateOf = (space: ChikyuSpace): SpaceState => space.stats.state;
|
|
50
|
+
* console.log(typeof stateOf);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export type SpaceState = "loading" | "live" | "unavailable" | "lost" | "idle";
|
|
54
|
+
/**
|
|
55
|
+
* A named distance for `zoomFor`: the Earth, the Moon, the Sun, the inner planets or the whole solar system.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts no-run
|
|
59
|
+
* import type { ChikyuSpace, SpacePreset } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
60
|
+
*
|
|
61
|
+
* const zoomTo = (space: ChikyuSpace, preset: SpacePreset): number => space.zoomFor(preset);
|
|
62
|
+
* console.log(typeof zoomTo);
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export type SpacePreset = "earth" | "moon" | "sun" | "inner" | "solar-system";
|
|
66
|
+
type SatelliteStats = {
|
|
67
|
+
groups: number;
|
|
68
|
+
placed: number;
|
|
69
|
+
tooFast: boolean;
|
|
70
|
+
propagations: number;
|
|
71
|
+
lastBatchMs: number;
|
|
72
|
+
maxBatchMs: number;
|
|
73
|
+
updateMs: number;
|
|
74
|
+
maxUpdateMs: number;
|
|
75
|
+
averageUpdateMs: number;
|
|
76
|
+
updates: number;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* 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.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts no-run
|
|
83
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
84
|
+
*
|
|
85
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
86
|
+
* space.setAttribute("time", "2026-11-02T12:00Z");
|
|
87
|
+
* space.setAttribute("speed", "0");
|
|
88
|
+
* document.body.append(space);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare class ChikyuSpace extends HTMLElement {
|
|
92
|
+
#private;
|
|
93
|
+
static observedAttributes: string[];
|
|
94
|
+
connectedCallback(): void;
|
|
95
|
+
disconnectedCallback(): void;
|
|
96
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
97
|
+
get centre(): GeoPoint;
|
|
98
|
+
set centre(value: GeoPoint);
|
|
99
|
+
/** 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. */
|
|
100
|
+
get time(): number;
|
|
101
|
+
set time(value: number | Date | "now");
|
|
102
|
+
/** Seconds of game time per second: 1 is real time, 0 holds still, negative runs backwards. */
|
|
103
|
+
get speed(): number;
|
|
104
|
+
set speed(value: number);
|
|
105
|
+
get scale(): ScaleMode;
|
|
106
|
+
set scale(value: ScaleMode);
|
|
107
|
+
get labels(): boolean;
|
|
108
|
+
set labels(value: boolean);
|
|
109
|
+
get orbits(): boolean;
|
|
110
|
+
set orbits(value: boolean);
|
|
111
|
+
/** The shared controls' camera: yaw and tilt turn the view, zoom brings the camera in (1 shows the Earth, less shows the sky round it). Pan is not used. */
|
|
112
|
+
setView(view: {
|
|
113
|
+
yaw: number;
|
|
114
|
+
tilt: number;
|
|
115
|
+
zoom: number;
|
|
116
|
+
}): void;
|
|
117
|
+
/** The body the camera looks at: at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
|
|
118
|
+
get body(): BodyName;
|
|
119
|
+
set body(name: BodyName);
|
|
120
|
+
/**
|
|
121
|
+
* 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
|
|
122
|
+
* 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).
|
|
123
|
+
* The groups are placed by SGP4 about once a second and interpolated between, and are hidden while the clock runs faster than `MAX_SATELLITE_SPEED`.
|
|
124
|
+
*
|
|
125
|
+
* @param group - The group's name, for `showSatellites`, `selectSatellite` and the events.
|
|
126
|
+
* @param satellites - The group, or `null` to remove it.
|
|
127
|
+
* @param style - How to draw it.
|
|
128
|
+
*/
|
|
129
|
+
setSatellites(group: string, satellites: Satellites | null, style?: Partial<SatelliteStyle>): void;
|
|
130
|
+
/** Show or hide a group without losing it. */
|
|
131
|
+
showSatellites(group: string, on: boolean): void;
|
|
132
|
+
/** The groups now set, with how many satellites each holds and whether it is shown. */
|
|
133
|
+
get satelliteGroups(): {
|
|
134
|
+
name: string;
|
|
135
|
+
count: number;
|
|
136
|
+
visible: boolean;
|
|
137
|
+
}[];
|
|
138
|
+
/** Mark one satellite: a larger ring round it, its orbit drawn, and its name beside it. `null` lets it go. */
|
|
139
|
+
selectSatellite(ref: SatelliteRef | null): void;
|
|
140
|
+
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
141
|
+
get selectedSatellite(): SatelliteRef | null;
|
|
142
|
+
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
|
|
143
|
+
satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
|
|
144
|
+
/** The words shown beside each body, for a page in another language (`{ Mars: "火星" }`). A body left out keeps its English name. */
|
|
145
|
+
get bodyNames(): Partial<Record<BodyName, string>>;
|
|
146
|
+
set bodyNames(value: Partial<Record<BodyName, string>>);
|
|
147
|
+
/** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
|
|
148
|
+
get bodyHint(): string;
|
|
149
|
+
set bodyHint(value: string);
|
|
150
|
+
/** The radius and the distance from the Earth of a body now, for a page's own caption. */
|
|
151
|
+
bodyInfo(name: BodyName): BodyInfo;
|
|
152
|
+
/** 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. */
|
|
153
|
+
zoomFor(preset: SpacePreset): number;
|
|
154
|
+
/** What the element is doing, for a page or a test. */
|
|
155
|
+
get stats(): {
|
|
156
|
+
state: SpaceState;
|
|
157
|
+
draws: number;
|
|
158
|
+
contexts: number;
|
|
159
|
+
canvas: {
|
|
160
|
+
width: number;
|
|
161
|
+
height: number;
|
|
162
|
+
pixels: number;
|
|
163
|
+
};
|
|
164
|
+
tiers: Record<string, number>;
|
|
165
|
+
distance: number;
|
|
166
|
+
assets: {
|
|
167
|
+
entries: number;
|
|
168
|
+
refs: number;
|
|
169
|
+
};
|
|
170
|
+
time: number;
|
|
171
|
+
lookups: number;
|
|
172
|
+
satellites: SatelliteStats;
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
declare global {
|
|
176
|
+
interface HTMLElementTagNameMap {
|
|
177
|
+
"chikyu-space": ChikyuSpace;
|
|
178
|
+
}
|
|
179
|
+
}
|