@johnmorrisdotca/wakusei-planets 0.19.0 → 0.21.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 +23 -0
- package/NOTICE.md +14 -3
- package/README.md +39 -6
- package/dist/bodies/earth.js +13 -5
- package/dist/calendar.d.ts +119 -0
- package/dist/calendar.js +155 -0
- package/dist/clock.d.ts +244 -0
- package/dist/clock.js +325 -0
- package/dist/coordinates.d.ts +172 -0
- package/dist/coordinates.js +170 -0
- package/dist/craft/cassini.d.ts +1 -0
- package/dist/craft/cassini.js +1131 -0
- package/dist/craft/galileo.d.ts +1 -0
- package/dist/craft/galileo.js +224 -0
- package/dist/craft/juno.d.ts +1 -0
- package/dist/craft/juno.js +640 -0
- package/dist/craft/newhorizons.d.ts +1 -0
- package/dist/craft/newhorizons.js +18 -0
- package/dist/craft/parker.d.ts +1 -0
- package/dist/craft/parker.js +221 -0
- package/dist/craft/pioneer10.d.ts +1 -0
- package/dist/craft/pioneer10.js +24 -0
- package/dist/craft/pioneer11.d.ts +1 -0
- package/dist/craft/pioneer11.js +34 -0
- package/dist/craft/voyager1.d.ts +1 -0
- package/dist/craft/voyager1.js +28 -0
- package/dist/craft/voyager2.d.ts +1 -0
- package/dist/craft/voyager2.js +43 -0
- package/dist/craft/webb.d.ts +1 -0
- package/dist/craft/webb.js +28 -0
- package/dist/data/craft.d.ts +23 -0
- package/dist/data/craft.js +53 -0
- package/dist/data/lunar.d.ts +4 -0
- package/dist/data/lunar.js +548 -0
- package/dist/data/pluto.d.ts +6 -0
- package/dist/data/pluto.js +29 -0
- package/dist/data/stars.d.ts +4 -0
- package/dist/data/stars.js +5088 -0
- package/dist/data/tables.d.ts +41 -0
- package/dist/data/tables.js +37 -0
- package/dist/data/vsop.d.ts +19 -1
- package/dist/data/vsop.js +25 -8
- package/dist/element.d.ts +2 -23
- package/dist/element.js +75 -110
- package/dist/ephemeris.d.ts +22 -14
- package/dist/ephemeris.js +106 -58
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mars.d.ts +41 -0
- package/dist/mars.js +52 -0
- package/dist/portrait/element.d.ts +1 -0
- package/dist/portrait/element.js +27 -39
- package/dist/scales.d.ts +46 -0
- package/dist/scales.js +75 -0
- package/dist/scene/basis.d.ts +3 -0
- package/dist/scene/basis.js +4 -0
- package/dist/scene/body.d.ts +2 -4
- package/dist/scene/body.js +55 -67
- package/dist/scene/fallback.d.ts +4 -0
- package/dist/scene/fallback.js +5 -0
- package/dist/scene/painter.js +10 -23
- package/dist/scene/store.d.ts +2 -2
- package/dist/scene/textures.d.ts +30 -0
- package/dist/scene/textures.js +47 -0
- package/dist/sidereal.d.ts +70 -0
- package/dist/sidereal.js +94 -0
- package/dist/sky/engine.d.ts +37 -0
- package/dist/sky/engine.js +116 -0
- package/dist/sky/events.d.ts +37 -0
- package/dist/sky/events.js +133 -0
- package/dist/sky/frames.d.ts +3 -0
- package/dist/sky/frames.js +26 -0
- package/dist/sky/types.d.ts +20 -0
- package/dist/sky/types.js +1 -0
- package/dist/space/aim.d.ts +18 -0
- package/dist/space/aim.js +28 -0
- package/dist/space/element.d.ts +212 -0
- package/dist/space/element.js +524 -0
- package/dist/space/frame.d.ts +152 -0
- package/dist/space/frame.js +169 -0
- package/dist/space/index.d.ts +4 -0
- package/dist/space/index.js +5 -0
- package/dist/space/ride.d.ts +89 -0
- package/dist/space/ride.js +58 -0
- package/dist/space/scale.d.ts +126 -0
- package/dist/space/scale.js +139 -0
- package/dist/space/scene.d.ts +189 -0
- package/dist/space/scene.js +422 -0
- package/dist/spacecraft-facts.d.ts +114 -0
- package/dist/spacecraft-facts.js +215 -0
- package/dist/spacecraft.d.ts +134 -0
- package/dist/spacecraft.js +198 -0
- package/dist/stars.d.ts +160 -0
- package/dist/stars.js +193 -0
- package/dist/suncalc-legacy.d.ts +187 -0
- package/dist/suncalc-legacy.js +168 -0
- package/dist/suncalc.d.ts +209 -0
- package/dist/suncalc.js +167 -0
- package/dist/tables/all.d.ts +2 -0
- package/dist/tables/all.js +2 -0
- package/dist/tables/ceres.d.ts +1 -0
- package/dist/tables/ceres.js +57 -0
- package/dist/tables/dwarfs.d.ts +1 -0
- package/dist/tables/dwarfs.js +59 -0
- package/dist/theory.d.ts +20 -0
- package/dist/theory.js +98 -0
- package/dist/time.d.ts +6 -108
- package/dist/time.js +7 -180
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/when.d.ts +16 -0
- package/dist/when.js +13 -0
- package/package.json +95 -4
|
@@ -0,0 +1,524 @@
|
|
|
1
|
+
import { BODIES, MOONS_OF } from "../facts.js";
|
|
2
|
+
import { createGate, frameCap } from "../gate.js";
|
|
3
|
+
import { createPainter } from "../scene/painter.js";
|
|
4
|
+
import { setThreeLoader, takeRenderer } from "../scene/shared.js";
|
|
5
|
+
import { texturePaths } from "../scene/textures.js";
|
|
6
|
+
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt, SPACE_PLANETS } from "./frame.js";
|
|
7
|
+
import { placeAround, placeMoon, placeSun, radiusIn } from "./scale.js";
|
|
8
|
+
import { createSpaceItem, FIT_DISTANCE, newSpaceModel, SPACE_BODIES } from "./scene.js";
|
|
9
|
+
export { setThreeLoader, SPACE_BODIES };
|
|
10
|
+
const readLight = (value) => (value === "lit" ? "lit" : "sun");
|
|
11
|
+
const RAD = Math.PI / 180;
|
|
12
|
+
const REAL_TIME_TICK_MS = 60_000;
|
|
13
|
+
const readCentre = (value) => {
|
|
14
|
+
if (!value)
|
|
15
|
+
return null;
|
|
16
|
+
const [lon, lat] = value.split(",").map((part) => Number(part.trim()));
|
|
17
|
+
if (!Number.isFinite(lon) || !Number.isFinite(lat) || Math.abs(lon) > 180 || Math.abs(lat) > 90)
|
|
18
|
+
return null;
|
|
19
|
+
return { lon: lon, lat: lat };
|
|
20
|
+
};
|
|
21
|
+
const readTime = (value) => {
|
|
22
|
+
if (value === null || value === "" || value === "now")
|
|
23
|
+
return "now";
|
|
24
|
+
const ms = Date.parse(value);
|
|
25
|
+
return Number.isFinite(ms) ? ms : "now";
|
|
26
|
+
};
|
|
27
|
+
const readBody = (value) => {
|
|
28
|
+
const id = value.toLowerCase();
|
|
29
|
+
return SPACE_BODIES.includes(id) ? id : undefined;
|
|
30
|
+
};
|
|
31
|
+
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}</style><div id="stage"></div><div id="labels"></div>`;
|
|
32
|
+
/**
|
|
33
|
+
* 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`
|
|
34
|
+
* (`"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`),
|
|
35
|
+
* `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
|
|
36
|
+
* only when something changes, and nothing while it is out of sight.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts no-run
|
|
40
|
+
* import type { WakuseiSpace } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
41
|
+
*
|
|
42
|
+
* const space = document.createElement("wakusei-space") as WakuseiSpace;
|
|
43
|
+
* space.setAttribute("time", "2026-11-02T12:00Z");
|
|
44
|
+
* space.setAttribute("speed", "0");
|
|
45
|
+
* document.body.append(space);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export class WakuseiSpace extends HTMLElement {
|
|
49
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "orbits", "look", "light", "lang"];
|
|
50
|
+
#model = newSpaceModel();
|
|
51
|
+
#mode = "now";
|
|
52
|
+
#speed = 1;
|
|
53
|
+
#view;
|
|
54
|
+
#gate;
|
|
55
|
+
#taken;
|
|
56
|
+
#stage;
|
|
57
|
+
#labelBox;
|
|
58
|
+
#state = "loading";
|
|
59
|
+
#timer;
|
|
60
|
+
#last = 0;
|
|
61
|
+
#pool = new Map();
|
|
62
|
+
#places;
|
|
63
|
+
#names = {};
|
|
64
|
+
#hint = "choose to look at it";
|
|
65
|
+
#painter;
|
|
66
|
+
#focusBeforeRide = "earth";
|
|
67
|
+
#lostTold = false;
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
this.#model.centre = readCentre(this.getAttribute("center")) ?? this.#model.centre;
|
|
70
|
+
this.#mode = readTime(this.getAttribute("time"));
|
|
71
|
+
this.#model.time = this.#mode === "now" ? Date.now() : this.#mode;
|
|
72
|
+
this.#speed = this.#readSpeed();
|
|
73
|
+
this.#model.mode = this.getAttribute("scale") === "true" ? "true" : "compressed";
|
|
74
|
+
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
75
|
+
this.#model.orbits = this.getAttribute("orbits") !== "off";
|
|
76
|
+
this.#model.look = this.getAttribute("look") === "painted" ? "painted" : "realistic";
|
|
77
|
+
this.#model.light = readLight(this.getAttribute("light"));
|
|
78
|
+
this.#model.stepMs = Math.max(1000, Math.abs(this.#speed) * 1000);
|
|
79
|
+
if (!this.hasAttribute("role"))
|
|
80
|
+
this.setAttribute("role", "img");
|
|
81
|
+
if (!this.hasAttribute("aria-label"))
|
|
82
|
+
this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
|
|
83
|
+
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
84
|
+
root.innerHTML = STYLE;
|
|
85
|
+
this.#stage = root.getElementById("stage");
|
|
86
|
+
this.#labelBox = root.getElementById("labels");
|
|
87
|
+
this.#pool.clear();
|
|
88
|
+
const nav = navigator;
|
|
89
|
+
this.#gate = createGate(1000 / frameCap(30, { deviceMemory: nav.deviceMemory, hardwareConcurrency: nav.hardwareConcurrency }), () => this.#view?.invalidate());
|
|
90
|
+
this.#stage.addEventListener("webglcontextlost", this.#lost, true);
|
|
91
|
+
this.#stage.addEventListener("webglcontextrestored", this.#restored, true);
|
|
92
|
+
const taken = takeRenderer((state) => {
|
|
93
|
+
if (state === "unavailable")
|
|
94
|
+
this.#fail("WebGL is not available");
|
|
95
|
+
});
|
|
96
|
+
this.#taken = taken;
|
|
97
|
+
const item = createSpaceItem(this.#model, {
|
|
98
|
+
painter: () => this.#painterNow(),
|
|
99
|
+
cap: () => this.#textureCap(),
|
|
100
|
+
invalidate: () => this.#gate?.request(),
|
|
101
|
+
onLabels: (places) => this.#placeLabels(places),
|
|
102
|
+
onMoving: () => this.#gate?.request(),
|
|
103
|
+
onRideLost: () => this.#rideLost(),
|
|
104
|
+
onPainterError: (error) => this.dispatchEvent(new CustomEvent("wakusei-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
105
|
+
});
|
|
106
|
+
this.#view = taken.renderer.view(this.#stage, item, { still: null });
|
|
107
|
+
this.#set("loading");
|
|
108
|
+
void this.#view.focus().then((live) => {
|
|
109
|
+
if (live) {
|
|
110
|
+
this.#set("live");
|
|
111
|
+
this.dispatchEvent(new CustomEvent("wakusei-ready"));
|
|
112
|
+
}
|
|
113
|
+
else if (this.#state === "loading")
|
|
114
|
+
this.#set("unavailable");
|
|
115
|
+
});
|
|
116
|
+
this.#last = performance.now();
|
|
117
|
+
this.#schedule();
|
|
118
|
+
this.addEventListener("pointerdown", this.#down);
|
|
119
|
+
this.#labelBox.addEventListener("click", this.#labelClick);
|
|
120
|
+
this.#labelBox.addEventListener("focusin", this.#labelFocus);
|
|
121
|
+
}
|
|
122
|
+
disconnectedCallback() {
|
|
123
|
+
this.removeEventListener("pointerdown", this.#down);
|
|
124
|
+
window.removeEventListener("pointerup", this.#up, true);
|
|
125
|
+
clearTimeout(this.#timer);
|
|
126
|
+
this.#timer = undefined;
|
|
127
|
+
this.#gate?.cancel();
|
|
128
|
+
this.#view?.dispose();
|
|
129
|
+
this.#view = undefined;
|
|
130
|
+
this.#taken?.release();
|
|
131
|
+
this.#taken = undefined;
|
|
132
|
+
}
|
|
133
|
+
attributeChangedCallback(name, _old, value) {
|
|
134
|
+
if (name === "center")
|
|
135
|
+
this.centre = readCentre(value) ?? { lon: 0, lat: 0 };
|
|
136
|
+
else if (name === "time")
|
|
137
|
+
this.time = readTime(value);
|
|
138
|
+
else if (name === "speed")
|
|
139
|
+
this.speed = this.#readSpeed();
|
|
140
|
+
else if (name === "scale")
|
|
141
|
+
this.scale = value === "true" ? "true" : "compressed";
|
|
142
|
+
else if (name === "labels")
|
|
143
|
+
this.labels = value !== "off";
|
|
144
|
+
else if (name === "orbits")
|
|
145
|
+
this.orbits = value !== "off";
|
|
146
|
+
else if (name === "look")
|
|
147
|
+
this.look = value === "painted" ? "painted" : "realistic";
|
|
148
|
+
else if (name === "light")
|
|
149
|
+
this.light = readLight(value);
|
|
150
|
+
else if (name === "lang")
|
|
151
|
+
for (const [id, button] of this.#pool)
|
|
152
|
+
this.#nameLabel(button, id);
|
|
153
|
+
}
|
|
154
|
+
/** The home place the camera starts above, as longitude and latitude in degrees. */
|
|
155
|
+
get centre() {
|
|
156
|
+
return { ...this.#model.centre };
|
|
157
|
+
}
|
|
158
|
+
set centre(value) {
|
|
159
|
+
this.#model.centre = { ...value };
|
|
160
|
+
this.#gate?.request();
|
|
161
|
+
}
|
|
162
|
+
/** 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. */
|
|
163
|
+
get time() {
|
|
164
|
+
return this.#model.time;
|
|
165
|
+
}
|
|
166
|
+
set time(value) {
|
|
167
|
+
this.#mode = value instanceof Date ? value.getTime() : value;
|
|
168
|
+
this.#model.time = this.#mode === "now" ? Date.now() : this.#mode;
|
|
169
|
+
this.#model.anchor = null;
|
|
170
|
+
this.#last = performance.now();
|
|
171
|
+
this.#schedule();
|
|
172
|
+
this.#gate?.request();
|
|
173
|
+
}
|
|
174
|
+
/** Seconds of game time per second: 1 is real time, 0 holds still, negative runs backwards. */
|
|
175
|
+
get speed() {
|
|
176
|
+
return this.#speed;
|
|
177
|
+
}
|
|
178
|
+
set speed(value) {
|
|
179
|
+
this.#speed = Number.isFinite(value) ? value : 1;
|
|
180
|
+
this.#model.stepMs = Math.max(1000, Math.abs(this.#speed) * 1000);
|
|
181
|
+
this.#last = performance.now();
|
|
182
|
+
this.#schedule();
|
|
183
|
+
this.#gate?.request();
|
|
184
|
+
}
|
|
185
|
+
/** `compressed` (the default: every direction real, the distances squeezed) or `true` (real distances and sizes). */
|
|
186
|
+
get scale() {
|
|
187
|
+
return this.#model.mode;
|
|
188
|
+
}
|
|
189
|
+
set scale(value) {
|
|
190
|
+
this.#model.mode = value;
|
|
191
|
+
this.#gate?.request();
|
|
192
|
+
}
|
|
193
|
+
get labels() {
|
|
194
|
+
return this.#model.labels;
|
|
195
|
+
}
|
|
196
|
+
set labels(value) {
|
|
197
|
+
this.#model.labels = value;
|
|
198
|
+
if (!value)
|
|
199
|
+
for (const label of this.#pool.values())
|
|
200
|
+
label.hidden = true;
|
|
201
|
+
this.#gate?.request();
|
|
202
|
+
}
|
|
203
|
+
get orbits() {
|
|
204
|
+
return this.#model.orbits;
|
|
205
|
+
}
|
|
206
|
+
set orbits(value) {
|
|
207
|
+
this.#model.orbits = value;
|
|
208
|
+
this.#gate?.request();
|
|
209
|
+
}
|
|
210
|
+
/** How the bodies are drawn: `realistic` (shaded from the body's real colours and features) or `painted` (public-domain surface maps). */
|
|
211
|
+
get look() {
|
|
212
|
+
return this.#model.look === "painted" ? "painted" : "realistic";
|
|
213
|
+
}
|
|
214
|
+
set look(value) {
|
|
215
|
+
this.#model.look = value;
|
|
216
|
+
this.#gate?.request();
|
|
217
|
+
}
|
|
218
|
+
/** How the Earth is lit: `sun` (true, the default) or `lit` (as if by daylight from the camera's side, so the night side is never a black frame). The Sun, the Moon and the planets keep their true places. */
|
|
219
|
+
get light() {
|
|
220
|
+
return this.#model.light;
|
|
221
|
+
}
|
|
222
|
+
set light(value) {
|
|
223
|
+
this.#model.light = value;
|
|
224
|
+
this.#gate?.request();
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The shared controls' camera: yaw and tilt turn the view (the Earth's surface moves right for a drag right and up for a drag up), zoom brings the camera in (1 shows the body looked at, less shows the sky round it). Pan is not used. A turn that
|
|
228
|
+
* moves nothing on the screen by half a pixel is kept for the next draw but does not cause one unless `final` is true (the default).
|
|
229
|
+
*
|
|
230
|
+
* @param view - The controls' yaw and tilt in degrees and zoom.
|
|
231
|
+
* @param final - False for the frames of a turn that is still going on (Auto-turn, a drag); true when it has settled.
|
|
232
|
+
*/
|
|
233
|
+
setView(view, final = true) {
|
|
234
|
+
const now = this.#model.view;
|
|
235
|
+
if (view.yaw === now.yaw && view.tilt === now.tilt && view.zoom === now.zoom)
|
|
236
|
+
return;
|
|
237
|
+
this.#model.view = { yaw: view.yaw, tilt: view.tilt, zoom: view.zoom };
|
|
238
|
+
const drawn = this.#model.drawnView;
|
|
239
|
+
if (drawn && !final && view.zoom === drawn.zoom) {
|
|
240
|
+
const turned = Math.max(Math.abs(view.yaw - drawn.yaw), Math.abs(view.tilt - drawn.tilt)) * RAD;
|
|
241
|
+
if (turned * (this.#model.heightPx / 2) < 0.5)
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
this.#gate?.request();
|
|
245
|
+
}
|
|
246
|
+
/** 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. */
|
|
247
|
+
get body() {
|
|
248
|
+
return this.#model.focus;
|
|
249
|
+
}
|
|
250
|
+
set body(name) {
|
|
251
|
+
const id = readBody(name);
|
|
252
|
+
if (!id)
|
|
253
|
+
return;
|
|
254
|
+
this.#model.focus = id;
|
|
255
|
+
this.#gate?.request();
|
|
256
|
+
}
|
|
257
|
+
/** 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`. */
|
|
258
|
+
get bodyNames() {
|
|
259
|
+
return { ...this.#names };
|
|
260
|
+
}
|
|
261
|
+
set bodyNames(value) {
|
|
262
|
+
this.#names = { ...value };
|
|
263
|
+
for (const [id, button] of this.#pool)
|
|
264
|
+
this.#nameLabel(button, id);
|
|
265
|
+
}
|
|
266
|
+
/** What a screen reader hears after a body's name: "choose to look at it" by default, or the page's own words. */
|
|
267
|
+
get bodyHint() {
|
|
268
|
+
return this.#hint;
|
|
269
|
+
}
|
|
270
|
+
set bodyHint(value) {
|
|
271
|
+
this.#hint = value;
|
|
272
|
+
for (const [id, button] of this.#pool)
|
|
273
|
+
this.#nameLabel(button, id);
|
|
274
|
+
}
|
|
275
|
+
/** The name, radius and distance from the Earth of a body now, for a page's own caption. */
|
|
276
|
+
bodyInfo(id) {
|
|
277
|
+
const frame = this.#model.drawn?.frame ?? frameAt(this.#model.time);
|
|
278
|
+
const geo = id === "earth" ? [0, 0, 0] : id === "sun" ? frame.sun : id === "moon" ? frame.moon : frame.planets[id];
|
|
279
|
+
return { id, name: this.#nameOf(id), radiusKm: BODIES[id].radiusKm, distanceKm: Math.hypot(geo[0], geo[1], geo[2]) * AU_IN_EARTH_RADII * EARTH_RADIUS_KM };
|
|
280
|
+
}
|
|
281
|
+
// --- riding along -------------------------------------------------------------------------------------------------------------------------------
|
|
282
|
+
/**
|
|
283
|
+
* 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,
|
|
284
|
+
* 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
|
|
285
|
+
* controls' zoom narrows the view. A body of the view (`"moon"`, `"mars"`) goes round the Earth; a moon (`"io"`) goes round its planet; a point of your own (`{ at(ms) }`, a satellite, a probe) goes round `around` (the Earth by default) and the
|
|
286
|
+
* element knows nothing of what it is. Another call switches smoothly; `null` stops. The draw rate follows how fast the picture moves, never more than 30 a second (one a second for a reader who asked for reduced motion), and nothing is drawn out of sight.
|
|
287
|
+
*
|
|
288
|
+
* @param target - A body name, a moon name, a point, or `null` to stop.
|
|
289
|
+
* @param options - `view`, `look`, `distanceKm`, `around`, `smooth` (see `RideOptions`).
|
|
290
|
+
*/
|
|
291
|
+
ride(target, options = {}) {
|
|
292
|
+
const model = this.#model;
|
|
293
|
+
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
294
|
+
const wasRiding = model.ride !== null;
|
|
295
|
+
if (target === null) {
|
|
296
|
+
model.ride = null;
|
|
297
|
+
model.focus = this.#focusBeforeRide;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
const found = this.#resolveRide(target, options);
|
|
301
|
+
if (!found)
|
|
302
|
+
return;
|
|
303
|
+
if (!wasRiding)
|
|
304
|
+
this.#focusBeforeRide = model.focus;
|
|
305
|
+
model.ride = found;
|
|
306
|
+
if (found.view === "follow" && typeof target === "string" && SPACE_BODIES.includes(target))
|
|
307
|
+
model.focus = target;
|
|
308
|
+
else if (wasRiding)
|
|
309
|
+
model.focus = this.#focusBeforeRide;
|
|
310
|
+
}
|
|
311
|
+
this.#lostTold = false;
|
|
312
|
+
const pose = model.pose;
|
|
313
|
+
model.transition = (options.smooth ?? true) && !reduced && pose.valid ? { start: performance.now(), duration: 1200, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
314
|
+
this.#last = performance.now();
|
|
315
|
+
this.#schedule();
|
|
316
|
+
this.#gate?.request();
|
|
317
|
+
this.dispatchEvent(new CustomEvent("wakusei-ride", { detail: this.riding }));
|
|
318
|
+
}
|
|
319
|
+
#resolveRide(target, options) {
|
|
320
|
+
const look = options.look ?? "down";
|
|
321
|
+
const distanceKm = Math.max(100, options.distanceKm ?? 3000);
|
|
322
|
+
if (typeof target !== "string") {
|
|
323
|
+
const around = options.around && SPACE_BODIES.includes(options.around) ? options.around : "earth";
|
|
324
|
+
return { target, around, view: options.view ?? "from", look, distanceKm };
|
|
325
|
+
}
|
|
326
|
+
const id = target.toLowerCase();
|
|
327
|
+
if (SPACE_BODIES.includes(id))
|
|
328
|
+
return { target: id, around: "earth", view: id === "earth" ? "follow" : (options.view ?? "from"), look, distanceKm };
|
|
329
|
+
for (const [planet, moons] of Object.entries(MOONS_OF)) {
|
|
330
|
+
if (!moons.includes(id) || !SPACE_BODIES.includes(planet) || planet === "earth")
|
|
331
|
+
continue;
|
|
332
|
+
return { target: id, around: planet, view: options.view ?? "from", look, distanceKm };
|
|
333
|
+
}
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
/** What the camera is riding along with now, or null. */
|
|
337
|
+
get riding() {
|
|
338
|
+
return this.#model.ride ? { ...this.#model.ride } : null;
|
|
339
|
+
}
|
|
340
|
+
#rideLost() {
|
|
341
|
+
if (this.#lostTold)
|
|
342
|
+
return;
|
|
343
|
+
this.#lostTold = true;
|
|
344
|
+
this.dispatchEvent(new CustomEvent("wakusei-ride-lost", { detail: this.riding }));
|
|
345
|
+
}
|
|
346
|
+
/** 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. */
|
|
347
|
+
zoomFor(preset) {
|
|
348
|
+
const mode = this.#model.mode;
|
|
349
|
+
if (preset.endsWith("-moons")) {
|
|
350
|
+
const id = preset.slice(0, -6);
|
|
351
|
+
const sites = this.#painterNow().moons(id, this.#model.time);
|
|
352
|
+
const reach = Math.max(1, ...sites.map((site) => Math.hypot(...site.offset)).filter((r) => r <= 22));
|
|
353
|
+
const radius = radiusIn(id, mode);
|
|
354
|
+
return Math.min(1, (FIT_DISTANCE * radius) / ((reach * radius * 1.15) / Math.tan(17.5 * RAD)));
|
|
355
|
+
}
|
|
356
|
+
const frame = this.#model.drawn?.frame ?? frameAt(this.#model.time);
|
|
357
|
+
const sun = placeSun(mode, frame.sun);
|
|
358
|
+
const around = (id) => Math.hypot(...placeAround(mode, sun, [frame.planets[id][0] - frame.sun[0], frame.planets[id][1] - frame.sun[1], frame.planets[id][2] - frame.sun[2]]));
|
|
359
|
+
const reach = {
|
|
360
|
+
earth: 0,
|
|
361
|
+
moon: Math.hypot(...placeMoon(mode, frame.moon)),
|
|
362
|
+
sun: Math.hypot(...sun),
|
|
363
|
+
inner: Math.max(around("mercury"), around("venus"), around("mars"), Math.hypot(...sun)),
|
|
364
|
+
"solar-system": Math.max(...SPACE_PLANETS.map(around), Math.hypot(...sun)),
|
|
365
|
+
}[preset];
|
|
366
|
+
return preset === "earth" ? 1 : FIT_DISTANCE / Math.max(FIT_DISTANCE, reach * 3.4);
|
|
367
|
+
}
|
|
368
|
+
/** What the element is doing, for a page or a test. */
|
|
369
|
+
get stats() {
|
|
370
|
+
const stats = this.#taken?.renderer.stats;
|
|
371
|
+
return {
|
|
372
|
+
state: this.#state,
|
|
373
|
+
draws: stats?.draws ?? 0,
|
|
374
|
+
contexts: stats?.contexts ?? 0,
|
|
375
|
+
canvas: stats?.canvas ?? { width: 0, height: 0, pixels: 0 },
|
|
376
|
+
distance: this.#model.drawn?.distance ?? 0,
|
|
377
|
+
assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
|
|
378
|
+
time: this.#model.time,
|
|
379
|
+
lookups: this.#model.lookups,
|
|
380
|
+
camera: { position: [...this.#model.camera.position], fov: this.#model.camera.fov },
|
|
381
|
+
bodies: { look: this.#model.look, painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held },
|
|
382
|
+
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
386
|
+
#readSpeed() {
|
|
387
|
+
const raw = this.getAttribute("speed");
|
|
388
|
+
const value = raw === null || raw === "" ? 1 : Number(raw);
|
|
389
|
+
return Number.isFinite(value) ? value : 1;
|
|
390
|
+
}
|
|
391
|
+
/** While time runs, draw as often as it shows: real time once a minute; faster time as often as the fastest turning body in sight moves a pixel (1 to 30 times a second). A ride along moves the whole picture, so real time draws about as often as a pixel moves (once a second at least), and a reader who asked for reduced motion gets one step a second. */
|
|
392
|
+
#schedule() {
|
|
393
|
+
clearTimeout(this.#timer);
|
|
394
|
+
this.#timer = undefined;
|
|
395
|
+
if (!this.isConnected || this.#speed === 0)
|
|
396
|
+
return;
|
|
397
|
+
const riding = this.#model.ride !== null;
|
|
398
|
+
const pixels = Math.max(this.#model.motion || 0.015, this.#model.rideMotion) * Math.abs(this.#speed);
|
|
399
|
+
let perSecond = Math.min(30, Math.max(1, pixels));
|
|
400
|
+
if (riding && typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches)
|
|
401
|
+
perSecond = 1;
|
|
402
|
+
const wait = !riding && this.#speed === 1 ? REAL_TIME_TICK_MS : 1000 / perSecond;
|
|
403
|
+
this.#timer = setTimeout(this.#tick, wait);
|
|
404
|
+
}
|
|
405
|
+
#tick = () => {
|
|
406
|
+
const now = performance.now();
|
|
407
|
+
if (this.#speed === 1 && this.#mode === "now")
|
|
408
|
+
this.#model.time = Date.now();
|
|
409
|
+
else
|
|
410
|
+
this.#model.time += (now - this.#last) * this.#speed;
|
|
411
|
+
this.#last = now;
|
|
412
|
+
this.#gate?.request();
|
|
413
|
+
this.#schedule();
|
|
414
|
+
this.dispatchEvent(new CustomEvent("wakusei-time", { detail: { time: this.#model.time } }));
|
|
415
|
+
};
|
|
416
|
+
// --- labels --------------------------------------------------------------------------------------------------------------------------------------
|
|
417
|
+
#nameOf(id) {
|
|
418
|
+
return this.#names[id] ?? BODIES[id].name[this.getAttribute("lang") === "ja" ? "ja" : "en"];
|
|
419
|
+
}
|
|
420
|
+
#placeLabels(places) {
|
|
421
|
+
this.#places = places;
|
|
422
|
+
const box = this.#labelBox;
|
|
423
|
+
if (!box)
|
|
424
|
+
return;
|
|
425
|
+
for (const id of SPACE_BODIES) {
|
|
426
|
+
let label = this.#pool.get(id);
|
|
427
|
+
const at = places[id];
|
|
428
|
+
if (!label) {
|
|
429
|
+
if (!at)
|
|
430
|
+
continue;
|
|
431
|
+
const button = box.ownerDocument.createElement("button");
|
|
432
|
+
button.type = "button";
|
|
433
|
+
button.className = "sp-label";
|
|
434
|
+
button.dataset["body"] = id;
|
|
435
|
+
this.#nameLabel(button, id);
|
|
436
|
+
box.append(button);
|
|
437
|
+
this.#pool.set(id, button);
|
|
438
|
+
label = button;
|
|
439
|
+
}
|
|
440
|
+
if (!at) {
|
|
441
|
+
if (!label.hidden)
|
|
442
|
+
label.hidden = true;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
if (label.hidden)
|
|
446
|
+
label.hidden = false;
|
|
447
|
+
label.style.transform = `translate(${Math.round(at.x + Math.max(4, Math.min(at.r, 40)))}px,${Math.round(at.y - 8)}px)`;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
#nameLabel(button, id) {
|
|
451
|
+
const text = this.#nameOf(id);
|
|
452
|
+
button.textContent = text;
|
|
453
|
+
button.setAttribute("aria-label", `${text}: ${this.#hint}`);
|
|
454
|
+
}
|
|
455
|
+
// A body is chosen by pressing on it or on its name (and by Tab and Enter on the name); a drag that turns the view is not a choice.
|
|
456
|
+
#downX = 0;
|
|
457
|
+
#downY = 0;
|
|
458
|
+
#down = (event) => {
|
|
459
|
+
if (event.button !== 0)
|
|
460
|
+
return;
|
|
461
|
+
this.#downX = event.clientX;
|
|
462
|
+
this.#downY = event.clientY;
|
|
463
|
+
window.addEventListener("pointerup", this.#up, { capture: true, once: true });
|
|
464
|
+
};
|
|
465
|
+
#up = (event) => {
|
|
466
|
+
if (Math.hypot(event.clientX - this.#downX, event.clientY - this.#downY) > 6)
|
|
467
|
+
return;
|
|
468
|
+
if (!this.#places)
|
|
469
|
+
return;
|
|
470
|
+
const rect = this.getBoundingClientRect();
|
|
471
|
+
const x = event.clientX - rect.left;
|
|
472
|
+
const y = event.clientY - rect.top;
|
|
473
|
+
let best;
|
|
474
|
+
let bestD = Infinity;
|
|
475
|
+
for (const id of SPACE_BODIES) {
|
|
476
|
+
const at = this.#places[id];
|
|
477
|
+
if (!at)
|
|
478
|
+
continue;
|
|
479
|
+
const d = Math.hypot(x - at.x, y - at.y);
|
|
480
|
+
if (d <= Math.max(at.r, 14) && d < bestD) {
|
|
481
|
+
best = id;
|
|
482
|
+
bestD = d;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (best)
|
|
486
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: this.bodyInfo(best), bubbles: true, composed: true }));
|
|
487
|
+
};
|
|
488
|
+
#labelClick = (event) => {
|
|
489
|
+
const id = event.target?.dataset?.["body"];
|
|
490
|
+
if (id)
|
|
491
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-click", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
|
|
492
|
+
};
|
|
493
|
+
#labelFocus = (event) => {
|
|
494
|
+
const id = event.target?.dataset?.["body"];
|
|
495
|
+
if (id)
|
|
496
|
+
this.dispatchEvent(new CustomEvent("wakusei-body-focus", { detail: this.bodyInfo(id), bubbles: true, composed: true }));
|
|
497
|
+
};
|
|
498
|
+
// --- the rest --------------------------------------------------------------------------------------------------------------------------------------
|
|
499
|
+
#painterNow() {
|
|
500
|
+
return (this.#painter ??= createPainter({ textureBase: texturePaths(this).textureBase(), farBase: texturePaths(this).farBase() }));
|
|
501
|
+
}
|
|
502
|
+
#textureCap() {
|
|
503
|
+
const given = Number(this.getAttribute("max-texture"));
|
|
504
|
+
const memory = navigator.deviceMemory;
|
|
505
|
+
const cap = Number.isFinite(given) && given > 0 ? Math.min(given, 4096) : 2048;
|
|
506
|
+
return memory !== undefined && memory <= 2 ? Math.min(cap, 2048) : cap;
|
|
507
|
+
}
|
|
508
|
+
#lost = () => this.#set("lost");
|
|
509
|
+
#restored = () => this.#set("live");
|
|
510
|
+
#set(state) {
|
|
511
|
+
if (this.#state === state)
|
|
512
|
+
return;
|
|
513
|
+
this.#state = state;
|
|
514
|
+
this.dataset["state"] = state;
|
|
515
|
+
this.dispatchEvent(new CustomEvent("wakusei-state", { detail: { state } }));
|
|
516
|
+
}
|
|
517
|
+
#fail(reason) {
|
|
518
|
+
this.#set("unavailable");
|
|
519
|
+
this.dispatchEvent(new CustomEvent("wakusei-unavailable", { detail: { reason } }));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (typeof customElements !== "undefined" && !customElements.get("wakusei-space")) {
|
|
523
|
+
customElements.define("wakusei-space", WakuseiSpace);
|
|
524
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type Vec3 } from "../vec.ts";
|
|
2
|
+
/**
|
|
3
|
+
* A position or direction as `[x, y, z]` in the scene's axes: J2000 equatorial, x to the vernal equinox, y north.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { SpaceVec3 } from "@johnmorrisdotca/wakusei-planets/space";
|
|
8
|
+
*
|
|
9
|
+
* const origin: SpaceVec3 = [0, 0, 0];
|
|
10
|
+
* console.log(origin);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type SpaceVec3 = Vec3;
|
|
14
|
+
/**
|
|
15
|
+
* The Earth's equatorial radius in kilometres (IAU), the unit of the scene's distances.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { EARTH_RADIUS_KM } from "@johnmorrisdotca/wakusei-planets/space";
|
|
20
|
+
*
|
|
21
|
+
* console.log(EARTH_RADIUS_KM);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const EARTH_RADIUS_KM = 6378.137;
|
|
25
|
+
/**
|
|
26
|
+
* Earth radii in one astronomical unit.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { AU_IN_EARTH_RADII } from "@johnmorrisdotca/wakusei-planets/space";
|
|
31
|
+
*
|
|
32
|
+
* console.log(Math.round(AU_IN_EARTH_RADII));
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const AU_IN_EARTH_RADII: number;
|
|
36
|
+
/**
|
|
37
|
+
* The planets the space view places, nearest the Sun first (the Earth is the middle of the view).
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { SPACE_PLANETS } from "@johnmorrisdotca/wakusei-planets/space";
|
|
42
|
+
*
|
|
43
|
+
* console.log(SPACE_PLANETS.join(", "));
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare const SPACE_PLANETS: readonly ["mercury", "venus", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
|
47
|
+
/**
|
|
48
|
+
* One of the planets in `SPACE_PLANETS`.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { planetOrbit, type SpacePlanet } from "@johnmorrisdotca/wakusei-planets/space";
|
|
53
|
+
*
|
|
54
|
+
* const planet: SpacePlanet = "mars";
|
|
55
|
+
* console.log(planetOrbit(planet, Date.UTC(2026, 10, 2), 8).length);
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export type SpacePlanet = (typeof SPACE_PLANETS)[number];
|
|
59
|
+
/**
|
|
60
|
+
* Where everything is at one moment: positions in astronomical units from the Earth's centre, in J2000 equatorial axes with y north.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { frameAt, type SpaceFrame } from "@johnmorrisdotca/wakusei-planets/space";
|
|
65
|
+
*
|
|
66
|
+
* const frame: SpaceFrame = frameAt(Date.UTC(2026, 10, 2, 12));
|
|
67
|
+
* console.log(Object.keys(frame.planets).length);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface SpaceFrame {
|
|
71
|
+
ms: number;
|
|
72
|
+
sun: Vec3;
|
|
73
|
+
moon: Vec3;
|
|
74
|
+
planets: Record<SpacePlanet, Vec3>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The state of the sky at `ms`: the Sun, the Moon and eight planets as seen from the Earth's centre, worked out by this package's own models in a fraction of a millisecond.
|
|
78
|
+
*
|
|
79
|
+
* @param ms - A moment, in milliseconds since the Unix epoch.
|
|
80
|
+
* @returns The Sun, the Moon and the planets in astronomical units from the Earth's centre.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { frameAt } from "@johnmorrisdotca/wakusei-planets/space";
|
|
85
|
+
*
|
|
86
|
+
* const frame = frameAt(Date.UTC(2026, 10, 2, 12));
|
|
87
|
+
* console.log(frame.moon.map((n) => n.toFixed(4)));
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export declare function frameAt(ms: number): SpaceFrame;
|
|
91
|
+
/**
|
|
92
|
+
* A frame between two others, `t` from 0 to 1.
|
|
93
|
+
*
|
|
94
|
+
* @param a - The earlier frame.
|
|
95
|
+
* @param b - The later frame.
|
|
96
|
+
* @param t - How far from `a` to `b`, from 0 to 1.
|
|
97
|
+
* @returns The frame at that fraction.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { blend, frameAt } from "@johnmorrisdotca/wakusei-planets/space";
|
|
102
|
+
*
|
|
103
|
+
* const start = Date.UTC(2026, 10, 2);
|
|
104
|
+
* const middle = blend(frameAt(start), frameAt(start + 1000), 0.5);
|
|
105
|
+
* console.log(middle.ms - start);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function blend(a: SpaceFrame, b: SpaceFrame, t: number): SpaceFrame;
|
|
109
|
+
/**
|
|
110
|
+
* Answers for any moment from two real ones: `at(ms)` works out a frame only when `ms` leaves the span the last two answers cover, and then looks `stepMs` ahead, so playing
|
|
111
|
+
* time at a steady rate costs one pair of lookups every `stepMs` and every draw in between is arithmetic.
|
|
112
|
+
*
|
|
113
|
+
* @param initialStepMs - How far ahead the second answer looks, in milliseconds.
|
|
114
|
+
* @returns A track: `at(ms)` for a frame, `lookups` for how many frames were worked out, `ends()` for the two answers it is between (undefined before the first `at`), `reset()` and `setStep(ms)`.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* import { createTrack } from "@johnmorrisdotca/wakusei-planets/space";
|
|
119
|
+
*
|
|
120
|
+
* const track = createTrack(1000);
|
|
121
|
+
* const start = Date.UTC(2026, 10, 2);
|
|
122
|
+
* for (let step = 0; step < 10; step += 1) track.at(start + step * 50);
|
|
123
|
+
* console.log(track.lookups);
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function createTrack(initialStepMs?: number): {
|
|
127
|
+
at(ms: number): SpaceFrame;
|
|
128
|
+
/** The two answers the track is between now (undefined before the first). */
|
|
129
|
+
ends(): [SpaceFrame, SpaceFrame] | undefined;
|
|
130
|
+
/** How many frames have been worked out. */
|
|
131
|
+
readonly lookups: number;
|
|
132
|
+
reset(): void;
|
|
133
|
+
/** Look further ahead (a faster game clock): the next lookup uses it. */
|
|
134
|
+
setStep(ms: number): void;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* The path a planet takes round the Sun, as `count + 1` points round one trip from where the planet is at `ms`, from the Sun, in astronomical units and the scene's axes.
|
|
138
|
+
*
|
|
139
|
+
* @param id - The planet.
|
|
140
|
+
* @param ms - The moment the path starts at, in milliseconds since the Unix epoch.
|
|
141
|
+
* @param count - How many segments to cut the trip into.
|
|
142
|
+
* @returns `count + 1` points; the last is near the first.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts
|
|
146
|
+
* import { planetOrbit } from "@johnmorrisdotca/wakusei-planets/space";
|
|
147
|
+
*
|
|
148
|
+
* const points = planetOrbit("jupiter", Date.UTC(2026, 10, 2), 12);
|
|
149
|
+
* console.log(points.length);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
export declare function planetOrbit(id: SpacePlanet, ms: number, count?: number): Vec3[];
|