@johnmorrisdotca/wakusei-planets 0.0.0-stage → 0.3.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 +31 -0
- package/LICENSE +21 -0
- package/NOTICE.md +48 -0
- package/README.md +214 -2
- package/dist/bodies/all.d.ts +16 -0
- package/dist/bodies/all.js +16 -0
- package/dist/bodies/earth.d.ts +1 -0
- package/dist/bodies/earth.js +23 -0
- package/dist/bodies/jupiter.d.ts +1 -0
- package/dist/bodies/jupiter.js +22 -0
- package/dist/bodies/mars.d.ts +1 -0
- package/dist/bodies/mars.js +25 -0
- package/dist/bodies/mercury.d.ts +1 -0
- package/dist/bodies/mercury.js +9 -0
- package/dist/bodies/moons-earth.d.ts +1 -0
- package/dist/bodies/moons-earth.js +37 -0
- package/dist/bodies/moons-jupiter.d.ts +1 -0
- package/dist/bodies/moons-jupiter.js +29 -0
- package/dist/bodies/moons-mars.d.ts +1 -0
- package/dist/bodies/moons-mars.js +4 -0
- package/dist/bodies/moons-neptune.d.ts +1 -0
- package/dist/bodies/moons-neptune.js +11 -0
- package/dist/bodies/moons-pluto.d.ts +1 -0
- package/dist/bodies/moons-pluto.js +5 -0
- package/dist/bodies/moons-saturn.d.ts +1 -0
- package/dist/bodies/moons-saturn.js +34 -0
- package/dist/bodies/moons-uranus.d.ts +1 -0
- package/dist/bodies/moons-uranus.js +7 -0
- package/dist/bodies/neptune.d.ts +1 -0
- package/dist/bodies/neptune.js +19 -0
- package/dist/bodies/pluto.d.ts +1 -0
- package/dist/bodies/pluto.js +22 -0
- package/dist/bodies/saturn.d.ts +1 -0
- package/dist/bodies/saturn.js +14 -0
- package/dist/bodies/sun.d.ts +1 -0
- package/dist/bodies/sun.js +20 -0
- package/dist/bodies/uranus.d.ts +1 -0
- package/dist/bodies/uranus.js +15 -0
- package/dist/bodies/venus.d.ts +1 -0
- package/dist/bodies/venus.js +10 -0
- package/dist/data/orbits.d.ts +20 -0
- package/dist/data/orbits.js +27 -0
- package/dist/element.d.ts +88 -0
- package/dist/element.js +603 -0
- package/dist/ephemeris.d.ts +189 -0
- package/dist/ephemeris.js +340 -0
- package/dist/facts.d.ts +213 -0
- package/dist/facts.js +198 -0
- package/dist/gate.d.ts +37 -0
- package/dist/gate.js +54 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/line.d.ts +82 -0
- package/dist/line.js +280 -0
- package/dist/live.d.ts +42 -0
- package/dist/live.js +62 -0
- package/dist/pose.d.ts +62 -0
- package/dist/pose.js +69 -0
- package/dist/scene/body.d.ts +68 -0
- package/dist/scene/body.js +337 -0
- package/dist/scene/glsl.d.ts +13 -0
- package/dist/scene/glsl.js +186 -0
- package/dist/scene/look.d.ts +106 -0
- package/dist/scene/look.js +35 -0
- package/dist/scene/recipes.d.ts +49 -0
- package/dist/scene/recipes.js +76 -0
- package/dist/scene/rings.d.ts +34 -0
- package/dist/scene/rings.js +64 -0
- package/dist/scene/shared.d.ts +24 -0
- package/dist/scene/shared.js +55 -0
- package/dist/scene/store.d.ts +19 -0
- package/dist/scene/store.js +8 -0
- package/dist/textures/callisto-1024.webp +0 -0
- package/dist/textures/callisto-512.webp +0 -0
- package/dist/textures/enceladus-1024.webp +0 -0
- package/dist/textures/enceladus-512.webp +0 -0
- package/dist/textures/europa-1024.webp +0 -0
- package/dist/textures/europa-512.webp +0 -0
- package/dist/textures/ganymede-1024.webp +0 -0
- package/dist/textures/ganymede-512.webp +0 -0
- package/dist/textures/io-1024.webp +0 -0
- package/dist/textures/io-512.webp +0 -0
- package/dist/textures/jupiter-1024.webp +0 -0
- package/dist/textures/jupiter-512.webp +0 -0
- package/dist/textures/mars-1024.webp +0 -0
- package/dist/textures/mars-512.webp +0 -0
- package/dist/textures/mercury-1024.webp +0 -0
- package/dist/textures/mercury-512.webp +0 -0
- package/dist/textures/mimas-1024.webp +0 -0
- package/dist/textures/mimas-512.webp +0 -0
- package/dist/textures/moon-1024.webp +0 -0
- package/dist/textures/moon-512.webp +0 -0
- package/dist/textures/neptune-1024.webp +0 -0
- package/dist/textures/neptune-512.webp +0 -0
- package/dist/textures/pluto-1024.webp +0 -0
- package/dist/textures/pluto-512.webp +0 -0
- package/dist/textures/rhea-1024.webp +0 -0
- package/dist/textures/rhea-512.webp +0 -0
- package/dist/textures/saturn-1024.webp +0 -0
- package/dist/textures/saturn-512.webp +0 -0
- package/dist/textures/saturn-ring-2048.webp +0 -0
- package/dist/textures/sun-1024.webp +0 -0
- package/dist/textures/sun-512.webp +0 -0
- package/dist/textures/titan-1024.webp +0 -0
- package/dist/textures/titan-512.webp +0 -0
- package/dist/textures/uranus-1024.webp +0 -0
- package/dist/textures/uranus-512.webp +0 -0
- package/dist/textures/venus-1024.webp +0 -0
- package/dist/textures/venus-512.webp +0 -0
- package/dist/vec.d.ts +19 -0
- package/dist/vec.js +32 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/package.json +236 -4
package/dist/facts.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The planets and the dwarf planet Pluto, nearest the Sun first.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { PLANET_IDS } from "@johnmorrisdotca/wakusei-planets";
|
|
7
|
+
*
|
|
8
|
+
* console.log(PLANET_IDS.join(", "));
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export declare const PLANET_IDS: readonly ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
|
12
|
+
/**
|
|
13
|
+
* The moons the package draws, by planet.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { MOONS_OF } from "@johnmorrisdotca/wakusei-planets";
|
|
18
|
+
*
|
|
19
|
+
* console.log(MOONS_OF.jupiter.join(", "));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const MOONS_OF: {
|
|
23
|
+
readonly earth: readonly ["moon"];
|
|
24
|
+
readonly mars: readonly ["phobos", "deimos"];
|
|
25
|
+
readonly jupiter: readonly ["io", "europa", "ganymede", "callisto"];
|
|
26
|
+
readonly saturn: readonly ["mimas", "enceladus", "tethys", "dione", "rhea", "titan", "iapetus"];
|
|
27
|
+
readonly uranus: readonly ["miranda", "ariel", "umbriel", "titania", "oberon"];
|
|
28
|
+
readonly neptune: readonly ["proteus", "triton", "nereid"];
|
|
29
|
+
readonly pluto: readonly ["charon", "nix", "hydra"];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The name of a planet or of Pluto: `mercury` to `pluto`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { PLANET_IDS, type PlanetId } from "@johnmorrisdotca/wakusei-planets";
|
|
37
|
+
*
|
|
38
|
+
* const id: PlanetId = PLANET_IDS[4];
|
|
39
|
+
* console.log(id);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export type PlanetId = (typeof PLANET_IDS)[number];
|
|
43
|
+
/**
|
|
44
|
+
* The name of a moon the package draws, such as `moon`, `io` or `titan`.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* import { MOONS_OF, type MoonId } from "@johnmorrisdotca/wakusei-planets";
|
|
49
|
+
*
|
|
50
|
+
* const id: MoonId = MOONS_OF.saturn[5];
|
|
51
|
+
* console.log(id);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type MoonId = (typeof MOONS_OF)[keyof typeof MOONS_OF][number];
|
|
55
|
+
/**
|
|
56
|
+
* The name of a body: `sun`, a planet or a moon.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { lineSvg, type BodyId } from "@johnmorrisdotca/wakusei-planets";
|
|
61
|
+
*
|
|
62
|
+
* const id: BodyId = "mars";
|
|
63
|
+
* console.log(lineSvg(id, { size: 64 }).length > 100);
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export type BodyId = "sun" | PlanetId | MoonId;
|
|
67
|
+
/**
|
|
68
|
+
* How a body is drawn: `line` (an outline drawing), `realistic` (shaded, from the numbers) or `painted` (a real surface map).
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { type Look } from "@johnmorrisdotca/wakusei-planets";
|
|
73
|
+
*
|
|
74
|
+
* const looks: Look[] = ["line", "realistic", "painted"];
|
|
75
|
+
* console.log(looks.length);
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export type Look = "line" | "realistic" | "painted";
|
|
79
|
+
/**
|
|
80
|
+
* One band of a ring system, in kilometres from the planet's centre: how much light it stops (`alpha`, 0 to 1) and how bright it is (`tone`, 0 dark, 1 bright).
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { BODIES, type RingBand } from "@johnmorrisdotca/wakusei-planets";
|
|
85
|
+
*
|
|
86
|
+
* const bands: readonly RingBand[] = BODIES.saturn.rings ?? [];
|
|
87
|
+
* console.log(bands.length, bands[2]?.from);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export interface RingBand {
|
|
91
|
+
from: number;
|
|
92
|
+
to: number;
|
|
93
|
+
alpha: number;
|
|
94
|
+
tone: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A thing a line drawing shows on a body's surface, placed by longitude and latitude in degrees (angular sizes in degrees): a circle, an oval, a band of latitude or a line.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { BODIES, type Feature } from "@johnmorrisdotca/wakusei-planets";
|
|
102
|
+
*
|
|
103
|
+
* const features: readonly Feature[] = BODIES.jupiter.features ?? [];
|
|
104
|
+
* console.log(features.length);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export type Feature = {
|
|
108
|
+
kind: "circle";
|
|
109
|
+
lon: number;
|
|
110
|
+
lat: number;
|
|
111
|
+
radius: number;
|
|
112
|
+
fill?: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
kind: "oval";
|
|
115
|
+
lon: number;
|
|
116
|
+
lat: number;
|
|
117
|
+
rx: number;
|
|
118
|
+
ry: number;
|
|
119
|
+
fill?: boolean;
|
|
120
|
+
} | {
|
|
121
|
+
kind: "band";
|
|
122
|
+
lat: number;
|
|
123
|
+
} | {
|
|
124
|
+
kind: "line";
|
|
125
|
+
points: readonly (readonly [number, number])[];
|
|
126
|
+
close?: boolean;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* The facts of one body: its radius, flattening, axial tilt, pole, prime meridian, rotation, colour, rings and the features a line drawing shows.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* import { BODIES, type BodyFacts } from "@johnmorrisdotca/wakusei-planets";
|
|
134
|
+
*
|
|
135
|
+
* const uranus: BodyFacts = BODIES.uranus;
|
|
136
|
+
* console.log(uranus.tiltDeg, uranus.rotationHours);
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export interface BodyFacts {
|
|
140
|
+
id: BodyId;
|
|
141
|
+
kind: "star" | "planet" | "dwarf-planet" | "moon";
|
|
142
|
+
/** The planet a moon goes round. */
|
|
143
|
+
parent?: PlanetId;
|
|
144
|
+
name: {
|
|
145
|
+
en: string;
|
|
146
|
+
ja: string;
|
|
147
|
+
};
|
|
148
|
+
/** The equatorial radius in kilometres (a moon's mean radius). */
|
|
149
|
+
radiusKm: number;
|
|
150
|
+
/** (equatorial − polar) / equatorial. */
|
|
151
|
+
flattening: number;
|
|
152
|
+
/** The angle between the spin axis and the orbit's normal, in degrees. Above 90 the spin is backwards. */
|
|
153
|
+
tiltDeg: number;
|
|
154
|
+
/** The north pole's right ascension and declination, J2000, in degrees (IAU). */
|
|
155
|
+
pole: {
|
|
156
|
+
ra: number;
|
|
157
|
+
dec: number;
|
|
158
|
+
};
|
|
159
|
+
/** The prime meridian at J2000, in degrees, and how fast it turns, in degrees a day (negative: backwards). */
|
|
160
|
+
prime: {
|
|
161
|
+
w0: number;
|
|
162
|
+
rate: number;
|
|
163
|
+
};
|
|
164
|
+
/** The sidereal rotation period in hours; negative when it turns backwards. */
|
|
165
|
+
rotationHours: number;
|
|
166
|
+
/** A moon that always shows the same face to its planet. */
|
|
167
|
+
synchronous?: boolean;
|
|
168
|
+
/** The semi-axes in kilometres along the line to the planet, along the orbit and along the pole, for a moon that is far from round. */
|
|
169
|
+
axesKm?: readonly [number, number, number];
|
|
170
|
+
/** The body's mean colour, `#rrggbb`. */
|
|
171
|
+
colour: string;
|
|
172
|
+
/** The longitude a portrait faces, degrees east: the side with the body's best-known features. */
|
|
173
|
+
showLon?: number;
|
|
174
|
+
rings?: readonly RingBand[];
|
|
175
|
+
features?: readonly Feature[];
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Every body's facts, by name: sizes, flattening, axial tilt, poles and rotation from the IAU and NASA.
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```ts
|
|
182
|
+
* import { BODIES } from "@johnmorrisdotca/wakusei-planets";
|
|
183
|
+
*
|
|
184
|
+
* console.log(BODIES.jupiter.radiusKm, BODIES.venus.rotationHours < 0);
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare const BODIES: Readonly<Record<BodyId, BodyFacts>>;
|
|
188
|
+
/**
|
|
189
|
+
* Every body's name: the Sun, the planets outward, then the moons of each planet.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { BODY_IDS } from "@johnmorrisdotca/wakusei-planets";
|
|
194
|
+
*
|
|
195
|
+
* console.log(BODY_IDS.length, BODY_IDS[0]);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export declare const BODY_IDS: readonly BodyId[];
|
|
199
|
+
/** A body's polar radius as a fraction of its equatorial radius. */
|
|
200
|
+
export declare const polarRatio: (facts: BodyFacts) => number;
|
|
201
|
+
/**
|
|
202
|
+
* The ring system's outer edge in body radii, or 1 for a body with no rings.
|
|
203
|
+
* @param facts - A body's facts.
|
|
204
|
+
* @returns The outer edge of its rings in body radii; `1` when it has no rings.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* import { BODIES, ringReach } from "@johnmorrisdotca/wakusei-planets";
|
|
209
|
+
*
|
|
210
|
+
* console.log(ringReach(BODIES.saturn).toFixed(2), ringReach(BODIES.mars));
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export declare const ringReach: (facts: BodyFacts) => number;
|
package/dist/facts.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
// What is known about each body: sizes, tilt, poles and rotation from the IAU Working Group on Cartographic Coordinates and Rotational Elements (Archinal et al., 2018) and NASA's
|
|
2
|
+
// planetary fact sheets, plus the few features a line drawing shows. Facts, not artwork: every picture is drawn from these numbers.
|
|
3
|
+
/**
|
|
4
|
+
* The planets and the dwarf planet Pluto, nearest the Sun first.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { PLANET_IDS } from "@johnmorrisdotca/wakusei-planets";
|
|
9
|
+
*
|
|
10
|
+
* console.log(PLANET_IDS.join(", "));
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const PLANET_IDS = ["mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto"];
|
|
14
|
+
/**
|
|
15
|
+
* The moons the package draws, by planet.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { MOONS_OF } from "@johnmorrisdotca/wakusei-planets";
|
|
20
|
+
*
|
|
21
|
+
* console.log(MOONS_OF.jupiter.join(", "));
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const MOONS_OF = {
|
|
25
|
+
earth: ["moon"],
|
|
26
|
+
mars: ["phobos", "deimos"],
|
|
27
|
+
jupiter: ["io", "europa", "ganymede", "callisto"],
|
|
28
|
+
saturn: ["mimas", "enceladus", "tethys", "dione", "rhea", "titan", "iapetus"],
|
|
29
|
+
uranus: ["miranda", "ariel", "umbriel", "titania", "oberon"],
|
|
30
|
+
neptune: ["proteus", "triton", "nereid"],
|
|
31
|
+
pluto: ["charon", "nix", "hydra"],
|
|
32
|
+
};
|
|
33
|
+
const f = (id, kind, en, ja, radiusKm, flattening, tiltDeg, ra, dec, w0, rate, rotationHours, colour, more = {}) => ({
|
|
34
|
+
id,
|
|
35
|
+
kind,
|
|
36
|
+
name: { en, ja },
|
|
37
|
+
radiusKm,
|
|
38
|
+
flattening,
|
|
39
|
+
tiltDeg,
|
|
40
|
+
pole: { ra, dec },
|
|
41
|
+
prime: { w0, rate },
|
|
42
|
+
rotationHours,
|
|
43
|
+
colour,
|
|
44
|
+
...more,
|
|
45
|
+
});
|
|
46
|
+
const bandsAt = (lats) => lats.map((lat) => ({ kind: "band", lat }));
|
|
47
|
+
const dots = (list) => list.map(([lon, lat, radius]) => ({ kind: "circle", lon, lat, radius }));
|
|
48
|
+
// The IAU north poles and prime meridians (J2000) are Archinal et al. 2018 (Celestial Mechanics and Dynamical Astronomy 130:22). A moon that keeps one face to its planet is oriented from the geometry, so its own pole is its planet's.
|
|
49
|
+
const SATURN_RINGS = [
|
|
50
|
+
{ from: 66900, to: 74510, alpha: 0.05, tone: 0.3 },
|
|
51
|
+
{ from: 74658, to: 91975, alpha: 0.25, tone: 0.45 },
|
|
52
|
+
{ from: 91975, to: 117507, alpha: 0.85, tone: 0.8 },
|
|
53
|
+
{ from: 117507, to: 122340, alpha: 0.06, tone: 0.4 },
|
|
54
|
+
{ from: 122340, to: 133570, alpha: 0.55, tone: 0.7 },
|
|
55
|
+
{ from: 133610, to: 136775, alpha: 0.5, tone: 0.65 },
|
|
56
|
+
{ from: 140100, to: 140260, alpha: 0.35, tone: 0.8 },
|
|
57
|
+
];
|
|
58
|
+
const URANUS_RINGS = [
|
|
59
|
+
{ from: 41800, to: 41880, alpha: 0.3, tone: 0.2 },
|
|
60
|
+
{ from: 42200, to: 42270, alpha: 0.3, tone: 0.2 },
|
|
61
|
+
{ from: 42540, to: 42610, alpha: 0.3, tone: 0.2 },
|
|
62
|
+
{ from: 44680, to: 44760, alpha: 0.3, tone: 0.2 },
|
|
63
|
+
{ from: 45620, to: 45700, alpha: 0.3, tone: 0.2 },
|
|
64
|
+
{ from: 47140, to: 47210, alpha: 0.3, tone: 0.2 },
|
|
65
|
+
{ from: 47590, to: 47660, alpha: 0.3, tone: 0.2 },
|
|
66
|
+
{ from: 48260, to: 48340, alpha: 0.3, tone: 0.2 },
|
|
67
|
+
{ from: 51100, to: 51200, alpha: 0.55, tone: 0.3 },
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Every body's facts, by name: sizes, flattening, axial tilt, poles and rotation from the IAU and NASA.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { BODIES } from "@johnmorrisdotca/wakusei-planets";
|
|
75
|
+
*
|
|
76
|
+
* console.log(BODIES.jupiter.radiusKm, BODIES.venus.rotationHours < 0);
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export const BODIES = {
|
|
80
|
+
sun: f("sun", "star", "Sun", "太陽", 695700, 0, 7.25, 286.13, 63.87, 84.176, 14.1844, 609.12, "#ffcf4d", {
|
|
81
|
+
features: [
|
|
82
|
+
{ kind: "oval", lon: 20, lat: 14, rx: 7, ry: 4 },
|
|
83
|
+
{ kind: "oval", lon: -30, lat: -12, rx: 5, ry: 3 },
|
|
84
|
+
{ kind: "circle", lon: 40, lat: -20, radius: 2.5, fill: true },
|
|
85
|
+
{ kind: "circle", lon: -5, lat: 18, radius: 3, fill: true },
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
mercury: f("mercury", "planet", "Mercury", "水星", 2439.7, 0, 0.034, 281.0103, 61.4155, 329.5988, 6.1385108, 1407.6, "#a39b92", {
|
|
89
|
+
features: [...dots([[-30, 20, 9], [35, 35, 6], [60, -25, 7], [-60, -30, 5], [5, -10, 4], [-10, 50, 6], [20, 10, 3], [75, 15, 4], [-80, 10, 4]]), { kind: "circle", lon: 90, lat: 30, radius: 14 }],
|
|
90
|
+
}),
|
|
91
|
+
venus: f("venus", "planet", "Venus", "金星", 6051.8, 0, 177.36, 272.76, 67.16, 160.2, -1.4813688, -5832.5, "#e8cf94", {
|
|
92
|
+
features: [
|
|
93
|
+
{ kind: "line", points: [[-90, 40], [-45, 48], [0, 38], [45, 44], [90, 36]] },
|
|
94
|
+
{ kind: "line", points: [[-90, 8], [-45, 14], [0, 4], [45, 12], [90, 6]] },
|
|
95
|
+
{ kind: "line", points: [[-90, -26], [-45, -20], [0, -30], [45, -22], [90, -28]] },
|
|
96
|
+
{ kind: "line", points: [[-90, -58], [-40, -52], [10, -60], [60, -54], [90, -58]] },
|
|
97
|
+
],
|
|
98
|
+
}),
|
|
99
|
+
earth: f("earth", "planet", "Earth", "地球", 6378.137, 0.00335281, 23.4393, 0, 90, 190.147, 360.9856235, 23.9345, "#3b78c4"),
|
|
100
|
+
mars: f("mars", "planet", "Mars", "火星", 3396.19, 0.00589, 25.19, 317.68143, 52.8865, 176.63, 350.89198226, 24.6229, "#c76a3f", {
|
|
101
|
+
showLon: 75,
|
|
102
|
+
features: [
|
|
103
|
+
{ kind: "band", lat: 78 },
|
|
104
|
+
{ kind: "band", lat: -82 },
|
|
105
|
+
{ kind: "oval", lon: 70, lat: 8, rx: 14, ry: 10, fill: true },
|
|
106
|
+
{ kind: "oval", lon: 25, lat: -30, rx: 22, ry: 6, fill: true },
|
|
107
|
+
{ kind: "circle", lon: 70, lat: -42, radius: 8 },
|
|
108
|
+
{ kind: "circle", lon: -135, lat: 18, radius: 6 },
|
|
109
|
+
{ kind: "line", points: [[-90, -8], [-70, -6], [-50, -10], [-30, -5]] },
|
|
110
|
+
],
|
|
111
|
+
}),
|
|
112
|
+
jupiter: f("jupiter", "planet", "Jupiter", "木星", 71492, 0.06487, 3.13, 268.056595, 64.495303, 284.95, 870.536, 9.925, "#d9b48a", {
|
|
113
|
+
showLon: -48,
|
|
114
|
+
features: [...bandsAt([62, 48, 35, 22, 8, -8, -22, -34, -48, -62]), { kind: "oval", lon: 20, lat: -22, rx: 12, ry: 6 }, { kind: "oval", lon: -70, lat: -33, rx: 3, ry: 2 }],
|
|
115
|
+
}),
|
|
116
|
+
saturn: f("saturn", "planet", "Saturn", "土星", 60268, 0.09796, 26.73, 40.589, 83.537, 38.9, 810.7939024, 10.656, "#e4d09c", {
|
|
117
|
+
rings: SATURN_RINGS,
|
|
118
|
+
features: [...bandsAt([72, 58, 44, 28, 12, -6, -22, -40, -56]), { kind: "line", points: [[0, 78], [60, 78], [120, 78], [180, 78], [240, 78], [300, 78]], close: true }],
|
|
119
|
+
}),
|
|
120
|
+
uranus: f("uranus", "planet", "Uranus", "天王星", 25559, 0.02293, 97.77, 257.311, -15.175, 203.81, -501.1600928, -17.24, "#a9e0e5", { rings: URANUS_RINGS, features: bandsAt([62, 38, 14, -14, -38]) }),
|
|
121
|
+
neptune: f("neptune", "planet", "Neptune", "海王星", 24764, 0.01708, 28.32, 299.36, 43.46, 249.978, 541.1397757, 16.11, "#4a6ee0", {
|
|
122
|
+
showLon: -30,
|
|
123
|
+
features: [...bandsAt([58, 34, 10, -14, -38, -60]), { kind: "oval", lon: -20, lat: -22, rx: 12, ry: 6 }, { kind: "oval", lon: 45, lat: -42, rx: 5, ry: 2.5 }],
|
|
124
|
+
}),
|
|
125
|
+
pluto: f("pluto", "dwarf-planet", "Pluto", "冥王星", 1188.3, 0, 122.53, 132.993, -6.163, 302.695, 56.3625225, -153.2935, "#c9a98a", {
|
|
126
|
+
showLon: 190,
|
|
127
|
+
features: [
|
|
128
|
+
{ kind: "line", points: [[165, 5], [175, 22], [188, 30], [200, 24], [208, 12], [196, 4], [190, -10], [176, -18], [166, -8]], close: true },
|
|
129
|
+
{ kind: "line", points: [[208, 12], [222, 26], [236, 22], [240, 8], [226, 0], [212, 2]], close: true },
|
|
130
|
+
{ kind: "oval", lon: 20, lat: -8, rx: 40, ry: 10, fill: true },
|
|
131
|
+
...dots([[-60, 20, 6], [-100, -20, 7], [60, 40, 5]]),
|
|
132
|
+
],
|
|
133
|
+
}),
|
|
134
|
+
moon: f("moon", "moon", "Moon", "月", 1737.4, 0.0012, 6.68, 269.9949, 66.5392, 38.3213, 13.17635815, 655.728, "#b8b5ae", {
|
|
135
|
+
parent: "earth",
|
|
136
|
+
synchronous: true,
|
|
137
|
+
features: [
|
|
138
|
+
{ kind: "oval", lon: -20, lat: 32, rx: 14, ry: 10, fill: true },
|
|
139
|
+
{ kind: "oval", lon: 18, lat: 28, rx: 8, ry: 7, fill: true },
|
|
140
|
+
{ kind: "oval", lon: 30, lat: 8, rx: 10, ry: 8, fill: true },
|
|
141
|
+
{ kind: "oval", lon: 58, lat: 17, rx: 6, ry: 5, fill: true },
|
|
142
|
+
{ kind: "oval", lon: -58, lat: 8, rx: 18, ry: 22, fill: true },
|
|
143
|
+
{ kind: "oval", lon: -14, lat: -22, rx: 8, ry: 7, fill: true },
|
|
144
|
+
{ kind: "circle", lon: -11, lat: -43, radius: 3 },
|
|
145
|
+
{ kind: "circle", lon: -20, lat: 10, radius: 1.5 },
|
|
146
|
+
],
|
|
147
|
+
}),
|
|
148
|
+
phobos: f("phobos", "moon", "Phobos", "フォボス", 11.08, 0.1, 0, 317.68143, 52.8865, 35.06, 1128.8445850, 7.65, "#8c8782", { parent: "mars", synchronous: true, axesKm: [13, 11.4, 9.1], features: [{ kind: "circle", lon: 55, lat: 5, radius: 24 }, ...dots([[-30, 20, 9], [10, -35, 7], [120, 15, 8]])] }),
|
|
149
|
+
deimos: f("deimos", "moon", "Deimos", "ダイモス", 6.2, 0.1, 0, 316.65, 53.52, 79.41, 285.161897, 30.3, "#9a948b", { parent: "mars", synchronous: true, axesKm: [7.8, 6, 5.1], features: dots([[-30, 10, 14], [60, -25, 10], [140, 30, 9]]) }),
|
|
150
|
+
io: f("io", "moon", "Io", "イオ", 1821.6, 0, 0, 268.05, 64.5, 200, 203.4889538, 42.46, "#e5d26a", { parent: "jupiter", synchronous: true, features: [...dots([[-30, 20, 5], [40, -10, 4], [120, 30, 4], [-80, -40, 4], [160, -20, 3], [-120, 10, 3]]), { kind: "circle", lon: -10, lat: 10, radius: 11 }] }),
|
|
151
|
+
europa: f("europa", "moon", "Europa", "エウロパ", 1560.8, 0, 0, 268.08, 64.51, 36.022, 101.3747235, 85.23, "#dcd2c0", { parent: "jupiter", synchronous: true, features: [{ kind: "line", points: [[-120, -10], [-60, 8], [0, -4], [50, 16], [110, 4]] }, { kind: "line", points: [[-90, 40], [-30, 24], [40, 36], [100, 20]] }, { kind: "line", points: [[-100, -40], [-40, -26], [30, -42], [90, -30]] }, { kind: "line", points: [[20, 60], [30, 20], [10, -20], [30, -60]] }, { kind: "circle", lon: -70, lat: -10, radius: 7 }] }),
|
|
152
|
+
ganymede: f("ganymede", "moon", "Ganymede", "ガニメデ", 2634.1, 0, 0, 268.2, 64.57, 44.064, 50.3176081, 171.7, "#a09484", { parent: "jupiter", synchronous: true, features: [{ kind: "oval", lon: -140, lat: 20, rx: 40, ry: 55, fill: true }, { kind: "oval", lon: 20, lat: 25, rx: 25, ry: 30, fill: true }, { kind: "oval", lon: 60, lat: -35, rx: 20, ry: 16, fill: true }, { kind: "circle", lon: 128, lat: -22, radius: 6 }, ...bandsAt([62, -62])] }),
|
|
153
|
+
callisto: f("callisto", "moon", "Callisto", "カリスト", 2410.3, 0, 0, 268.72, 64.83, 259.51, 21.5710715, 400.5, "#70675d", { parent: "jupiter", synchronous: true, features: [{ kind: "circle", lon: 55, lat: 15, radius: 8 }, { kind: "circle", lon: 55, lat: 15, radius: 16 }, { kind: "circle", lon: 55, lat: 15, radius: 26 }, ...dots([[-40, 30, 4], [-70, -20, 5], [0, -40, 4], [-20, 5, 3], [100, -30, 4], [-100, 40, 3]])] }),
|
|
154
|
+
mimas: f("mimas", "moon", "Mimas", "ミマス", 198.2, 0.02, 0, 40.66, 83.52, 333.46, 381.994555, 22.6, "#bdbab4", { parent: "saturn", synchronous: true, features: [{ kind: "circle", lon: -60, lat: 0, radius: 33 }, ...dots([[30, 30, 12], [60, -25, 10], [-130, 40, 9], [120, 5, 10], [10, -50, 9]])] }),
|
|
155
|
+
enceladus: f("enceladus", "moon", "Enceladus", "エンケラドス", 252.1, 0.003, 0, 40.66, 83.52, 6.32, 262.7318996, 32.9, "#f1f4f6", { parent: "saturn", synchronous: true, features: [{ kind: "line", points: [[-40, -72], [-20, -76], [0, -78], [20, -76], [40, -72]] }, { kind: "line", points: [[-30, -66], [-10, -70], [10, -70], [30, -66]] }, ...dots([[-60, 20, 8], [60, 30, 7], [110, -10, 6]])] }),
|
|
156
|
+
tethys: f("tethys", "moon", "Tethys", "テティス", 531.1, 0.001, 0, 40.66, 83.52, 8.95, 190.6979085, 45.3, "#d6d3ce", { parent: "saturn", synchronous: true, features: [{ kind: "circle", lon: 140, lat: 10, radius: 22 }, { kind: "line", points: [[-180, 0], [-120, 4], [-60, -2], [0, 3], [60, -3]] }, ...dots([[-40, 30, 7], [30, -30, 6], [70, 40, 5]])] }),
|
|
157
|
+
dione: f("dione", "moon", "Dione", "ディオネ", 561.4, 0.002, 0, 40.66, 83.52, 357.0, 131.5349316, 65.7, "#cfcdc7", { parent: "saturn", synchronous: true, features: [{ kind: "line", points: [[-150, 20], [-120, 12], [-100, 30], [-60, 18]] }, { kind: "line", points: [[-170, -20], [-130, -28], [-90, -18]] }, ...dots([[10, 10, 9], [50, -30, 7], [90, 30, 6], [-20, -45, 6]])] }),
|
|
158
|
+
rhea: f("rhea", "moon", "Rhea", "レア", 763.8, 0.001, 0, 40.38, 83.55, 235.16, 79.6900478, 108.4, "#c7c4be", { parent: "saturn", synchronous: true, features: [...dots([[-60, 15, 10], [20, -30, 9], [60, 40, 8], [110, -10, 9], [-20, 50, 7], [-100, -25, 8], [160, 20, 7]])] }),
|
|
159
|
+
titan: f("titan", "moon", "Titan", "タイタン", 2574.7, 0, 0, 36.41, 83.94, 189.64, 22.5769768, 382.69, "#dba84a", { parent: "saturn", synchronous: true, features: [...bandsAt([60, 30, 0, -30, -60]), { kind: "oval", lon: 0, lat: 85, rx: 60, ry: 6 }] }),
|
|
160
|
+
iapetus: f("iapetus", "moon", "Iapetus", "イアペトゥス", 734.3, 0.02, 0, 318.16, 75.03, 355.2, 4.5379572, 1903.7, "#a89f93", { parent: "saturn", synchronous: true, features: [{ kind: "line", points: [[-90, -85], [-90, -40], [-90, 0], [-90, 40], [-90, 85]] }, { kind: "line", points: [[90, -85], [90, -40], [90, 0], [90, 40], [90, 85]] }, { kind: "oval", lon: 0, lat: 0, rx: 100, ry: 25, fill: true }, { kind: "line", points: [[-180, 0], [-120, 0], [-60, 0], [0, 0], [60, 0], [120, 0]], close: true }] }),
|
|
161
|
+
miranda: f("miranda", "moon", "Miranda", "ミランダ", 235.8, 0, 0, 257.43, -15.08, 30.7, 254.6906924, 33.9, "#b8b5b0", { parent: "uranus", synchronous: true, features: [{ kind: "oval", lon: 30, lat: -60, rx: 40, ry: 20, fill: true }, { kind: "circle", lon: -30, lat: 10, radius: 20 }, { kind: "line", points: [[60, 30], [75, 5], [80, -20]] }, ...dots([[-80, -30, 8], [100, 40, 7]])] }),
|
|
162
|
+
ariel: f("ariel", "moon", "Ariel", "アリエル", 578.9, 0, 0, 257.43, -15.1, 156.22, 142.8356681, 60.5, "#bcb9b3", { parent: "uranus", synchronous: true, features: [{ kind: "line", points: [[-80, 20], [-50, 8], [-20, 26], [10, 10]] }, { kind: "line", points: [[40, -20], [70, -34], [100, -20]] }, { kind: "oval", lon: -10, lat: -30, rx: 30, ry: 12, fill: true }, ...dots([[60, 30, 7], [-100, 0, 6]])] }),
|
|
163
|
+
umbriel: f("umbriel", "moon", "Umbriel", "ウンブリエル", 584.7, 0, 0, 257.43, -15.1, 108.05, 86.8688923, 99.5, "#807d79", { parent: "uranus", synchronous: true, features: [{ kind: "circle", lon: 50, lat: 85, radius: 8 }, { kind: "circle", lon: 80, lat: 80, radius: 14, fill: false }, ...dots([[-70, 20, 8], [20, -30, 9], [-20, 40, 7], [110, -10, 7]])] }),
|
|
164
|
+
titania: f("titania", "moon", "Titania", "ティタニア", 788.9, 0, 0, 257.43, -15.1, 77.74, 41.3514246, 208.9, "#aaa59d", { parent: "uranus", synchronous: true, features: [{ kind: "line", points: [[-120, -10], [-80, -30], [-40, -10], [0, -34]] }, { kind: "line", points: [[-60, 36], [-20, 20], [20, 40]] }, ...dots([[40, 20, 9], [80, -25, 8], [-100, 30, 7]])] }),
|
|
165
|
+
oberon: f("oberon", "moon", "Oberon", "オベロン", 761.4, 0, 0, 257.43, -15.1, 6.77, 26.7394932, 323.1, "#918981", { parent: "uranus", synchronous: true, features: [{ kind: "circle", lon: 40, lat: -15, radius: 12 }, ...dots([[-60, 20, 9], [90, 30, 8], [-110, -25, 8], [10, 45, 7]])] }),
|
|
166
|
+
proteus: f("proteus", "moon", "Proteus", "プロテウス", 210, 0.1, 0, 299.36, 43.36, 93.38, 320.7654228, 26.9, "#6e6c6a", { parent: "neptune", synchronous: true, axesKm: [218, 208, 201], features: [{ kind: "circle", lon: 0, lat: -5, radius: 28 }, ...dots([[60, 30, 10], [-70, 20, 9], [110, -20, 8]])] }),
|
|
167
|
+
triton: f("triton", "moon", "Triton", "トリトン", 1353.4, 0, 0, 299.36, 41.17, 296.53, -61.2572638, -141.04, "#cdbbac", { parent: "neptune", synchronous: true, features: [{ kind: "band", lat: -30 }, { kind: "oval", lon: 20, lat: -70, rx: 80, ry: 25, fill: true }, ...dots([[-40, -40, 3], [10, -45, 3], [50, -35, 3], [100, -42, 3]])] }),
|
|
168
|
+
nereid: f("nereid", "moon", "Nereid", "ネレイド", 178.5, 0, 0, 299.36, 43.46, 0, 0, 0, "#9b9b9b", { parent: "neptune", features: dots([[-40, 20, 12], [50, -20, 10]]) }),
|
|
169
|
+
charon: f("charon", "moon", "Charon", "カロン", 606, 0, 0, 132.993, -6.163, 122.695, 56.3625225, 153.2935, "#9c9189", { parent: "pluto", synchronous: true, features: [{ kind: "oval", lon: 0, lat: 76, rx: 90, ry: 14, fill: true }, { kind: "circle", lon: 40, lat: -15, radius: 12 }, ...dots([[-60, 10, 8], [120, 30, 7]])] }),
|
|
170
|
+
nix: f("nix", "moon", "Nix", "ニクス", 19.3, 0.3, 0, 132.993, -6.163, 0, 14.48, 0, "#b3ada7", { parent: "pluto", axesKm: [24.9, 16.6, 15.6], features: [{ kind: "circle", lon: 0, lat: 0, radius: 18 }] }),
|
|
171
|
+
hydra: f("hydra", "moon", "Hydra", "ヒドラ", 19.5, 0.4, 0, 132.993, -6.163, 0, 9.42, 0, "#c4beb6", { parent: "pluto", axesKm: [32.5, 22.5, 12.5], features: [{ kind: "circle", lon: 30, lat: 10, radius: 20 }] }),
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Every body's name: the Sun, the planets outward, then the moons of each planet.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { BODY_IDS } from "@johnmorrisdotca/wakusei-planets";
|
|
179
|
+
*
|
|
180
|
+
* console.log(BODY_IDS.length, BODY_IDS[0]);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export const BODY_IDS = ["sun", ...PLANET_IDS, ...Object.values(MOONS_OF).flat()];
|
|
184
|
+
/** A body's polar radius as a fraction of its equatorial radius. */
|
|
185
|
+
export const polarRatio = (facts) => 1 - facts.flattening;
|
|
186
|
+
/**
|
|
187
|
+
* The ring system's outer edge in body radii, or 1 for a body with no rings.
|
|
188
|
+
* @param facts - A body's facts.
|
|
189
|
+
* @returns The outer edge of its rings in body radii; `1` when it has no rings.
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* import { BODIES, ringReach } from "@johnmorrisdotca/wakusei-planets";
|
|
194
|
+
*
|
|
195
|
+
* console.log(ringReach(BODIES.saturn).toFixed(2), ringReach(BODIES.mars));
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
export const ringReach = (facts) => (facts.rings === undefined ? 1 : Math.max(...facts.rings.map((band) => band.to)) / facts.radiusKm);
|
package/dist/gate.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface Timers {
|
|
2
|
+
set(callback: () => void, ms: number): unknown;
|
|
3
|
+
clear(handle: unknown): void;
|
|
4
|
+
now(): number;
|
|
5
|
+
}
|
|
6
|
+
export declare const browserTimers: Timers;
|
|
7
|
+
/**
|
|
8
|
+
* A rate gate for the draw: what `createGate` returns.
|
|
9
|
+
*/
|
|
10
|
+
export interface Gate {
|
|
11
|
+
/** Ask for `fire` to run: now if the last run was `minMs` ago or more, else once, when that time has passed. */
|
|
12
|
+
request(): void;
|
|
13
|
+
/** Forget a run that is waiting. */
|
|
14
|
+
cancel(): void;
|
|
15
|
+
/** Change the least time between runs (a lower frame rate on a battery). */
|
|
16
|
+
setMinMs(minMs: number): void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A rate gate for the draw: asks that come faster than `minMs` apart become one, and the last ask is never lost, so a burst of changes costs one draw.
|
|
20
|
+
*
|
|
21
|
+
* @param minMs - The least time between two runs, in milliseconds.
|
|
22
|
+
* @param fire - What to run.
|
|
23
|
+
* @param timers - A clock and timers; the browser's by default (a test passes its own).
|
|
24
|
+
* @returns The gate: `request()` to ask, `cancel()` to forget a waiting run, `setMinMs()` to change the pace.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createGate(minMs: number, fire: () => void, timers?: Timers): Gate;
|
|
27
|
+
/**
|
|
28
|
+
* The frame rate cap for this device: `maxFps` (30 by default), lower on a small device.
|
|
29
|
+
*
|
|
30
|
+
* @param maxFps - The most frames a second to allow.
|
|
31
|
+
* @param device - `deviceMemory` in gigabytes and `hardwareConcurrency` in cores, from `navigator`; either may be left out.
|
|
32
|
+
* @returns The frames a second to allow, at least 1; 20 at most on a small device.
|
|
33
|
+
*/
|
|
34
|
+
export declare function frameCap(maxFps?: number, device?: {
|
|
35
|
+
deviceMemory?: number;
|
|
36
|
+
hardwareConcurrency?: number;
|
|
37
|
+
}): number;
|
package/dist/gate.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// A rate gate for the draw: asks that come faster than `minMs` apart become one, and the last ask is never lost. Pure, with its own clock.
|
|
2
|
+
export const browserTimers = {
|
|
3
|
+
set: (callback, ms) => setTimeout(callback, ms),
|
|
4
|
+
clear: (handle) => clearTimeout(handle),
|
|
5
|
+
now: () => performance.now(),
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A rate gate for the draw: asks that come faster than `minMs` apart become one, and the last ask is never lost, so a burst of changes costs one draw.
|
|
9
|
+
*
|
|
10
|
+
* @param minMs - The least time between two runs, in milliseconds.
|
|
11
|
+
* @param fire - What to run.
|
|
12
|
+
* @param timers - A clock and timers; the browser's by default (a test passes its own).
|
|
13
|
+
* @returns The gate: `request()` to ask, `cancel()` to forget a waiting run, `setMinMs()` to change the pace.
|
|
14
|
+
*/
|
|
15
|
+
export function createGate(minMs, fire, timers = browserTimers) {
|
|
16
|
+
let least = minMs;
|
|
17
|
+
let last = -Infinity;
|
|
18
|
+
let waiting;
|
|
19
|
+
const run = () => {
|
|
20
|
+
waiting = undefined;
|
|
21
|
+
last = timers.now();
|
|
22
|
+
fire();
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
request() {
|
|
26
|
+
if (waiting !== undefined)
|
|
27
|
+
return;
|
|
28
|
+
const wait = last + least - timers.now();
|
|
29
|
+
if (wait <= 0)
|
|
30
|
+
run();
|
|
31
|
+
else
|
|
32
|
+
waiting = timers.set(run, wait);
|
|
33
|
+
},
|
|
34
|
+
cancel() {
|
|
35
|
+
if (waiting !== undefined)
|
|
36
|
+
timers.clear(waiting);
|
|
37
|
+
waiting = undefined;
|
|
38
|
+
},
|
|
39
|
+
setMinMs(value) {
|
|
40
|
+
least = value;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The frame rate cap for this device: `maxFps` (30 by default), lower on a small device.
|
|
46
|
+
*
|
|
47
|
+
* @param maxFps - The most frames a second to allow.
|
|
48
|
+
* @param device - `deviceMemory` in gigabytes and `hardwareConcurrency` in cores, from `navigator`; either may be left out.
|
|
49
|
+
* @returns The frames a second to allow, at least 1; 20 at most on a small device.
|
|
50
|
+
*/
|
|
51
|
+
export function frameCap(maxFps = 30, device = {}) {
|
|
52
|
+
const small = (device.deviceMemory !== undefined && device.deviceMemory <= 2) || (device.hardwareConcurrency !== undefined && device.hardwareConcurrency <= 2);
|
|
53
|
+
return Math.max(1, small ? Math.min(maxFps, 20) : maxFps);
|
|
54
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BODIES, BODY_IDS, MOONS_OF, PLANET_IDS, ringReach, type BodyFacts, type BodyId, type Feature, type Look, type MoonId, type PlanetId, type RingBand } from "./facts.ts";
|
|
2
|
+
export { apparent, moonGeocentric, heliocentric, orbitPath, system, type Apparent, type MoonPlace, type Pose, type System } from "./ephemeris.ts";
|
|
3
|
+
export { drawnTilt, portrait, type PortraitOptions } from "./pose.ts";
|
|
4
|
+
export { lineSvg, mix, type LineOptions } from "./line.ts";
|
|
5
|
+
export { ringStrip, type RingStrip } from "./scene/rings.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BODIES, BODY_IDS, MOONS_OF, PLANET_IDS, ringReach } from "./facts.js";
|
|
2
|
+
export { apparent, moonGeocentric, heliocentric, orbitPath, system } from "./ephemeris.js";
|
|
3
|
+
export { drawnTilt, portrait } from "./pose.js";
|
|
4
|
+
export { lineSvg, mix } from "./line.js";
|
|
5
|
+
export { ringStrip } from "./scene/rings.js";
|
package/dist/line.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type Pose } from "./ephemeris.ts";
|
|
2
|
+
import { type BodyId, type MoonId } from "./facts.ts";
|
|
3
|
+
import { type PortraitOptions } from "./pose.ts";
|
|
4
|
+
/**
|
|
5
|
+
* Options for `lineSvg`: the size, a pose (`tilt`, `pitch`, `phase`, `spin`, a `time` or a `pose`), `moons`, `range`, `fill`, the language and the colours.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { lineSvg, type LineOptions } from "@johnmorrisdotca/wakusei-planets";
|
|
10
|
+
*
|
|
11
|
+
* const options: LineOptions = { size: 200, tilt: 15, lang: "ja" };
|
|
12
|
+
* console.log(lineSvg("mars", options).includes("火星"));
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export interface LineOptions extends PortraitOptions {
|
|
16
|
+
/** The width and height of the square drawing, in pixels. Default 320. */
|
|
17
|
+
size?: number;
|
|
18
|
+
/** A moment in milliseconds since 1970: the body is drawn as the Earth sees it then (its real pose, phase and rings). Without it the body is a portrait. */
|
|
19
|
+
time?: number;
|
|
20
|
+
/** The radius of the body as a fraction of half the drawing's width, to draw bodies to scale side by side. Default: as large as fits, with its rings. */
|
|
21
|
+
fill?: number;
|
|
22
|
+
/** A pose to draw instead of the portrait or the date's (the viewer's frame; see {@link Pose}). */
|
|
23
|
+
pose?: Pose;
|
|
24
|
+
/** Zoom, and the pan as a fraction of half the picture, for a view a shared control moves. */
|
|
25
|
+
zoom?: number;
|
|
26
|
+
panX?: number;
|
|
27
|
+
panY?: number;
|
|
28
|
+
/** Draw the planet's moons on their orbits as the Earth sees them at `time` (now when `time` is left out). */
|
|
29
|
+
moons?: boolean;
|
|
30
|
+
/** Moons already placed (planet radii, the viewer's frame), for a picture that moves them itself; used with `pose`. */
|
|
31
|
+
moonsAt?: readonly {
|
|
32
|
+
id: MoonId;
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
z: number;
|
|
36
|
+
distance: number;
|
|
37
|
+
}[];
|
|
38
|
+
/** Orbit paths already worked out (x, y, z in planet radii, by moon), to draw instead of working them out. */
|
|
39
|
+
orbits?: ReadonlyMap<string, Float32Array>;
|
|
40
|
+
/** How far the picture reaches from the planet's centre, in planet radii, when `moons` is on. Default: past the farthest moon. */
|
|
41
|
+
range?: number;
|
|
42
|
+
/** Write the names of the moons. Default true. */
|
|
43
|
+
labels?: boolean;
|
|
44
|
+
/** The language of the names and the description. Default `en`. */
|
|
45
|
+
lang?: "en" | "ja";
|
|
46
|
+
/** The colour of the lines. Default: a pale tint of the body's colour. */
|
|
47
|
+
stroke?: string;
|
|
48
|
+
/** The colour of the disc. Default: a dark tint of the body's colour. */
|
|
49
|
+
paper?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Mix two `#rrggbb` colours: `t` is how much of `b` (0 to 1).
|
|
53
|
+
* @param a - The first colour.
|
|
54
|
+
* @param b - The second colour.
|
|
55
|
+
* @param t - How much of `b`, 0 to 1.
|
|
56
|
+
* @returns The mixed colour as `#rrggbb`.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { mix } from "@johnmorrisdotca/wakusei-planets";
|
|
61
|
+
*
|
|
62
|
+
* console.log(mix("#000000", "#ffffff", 0.5));
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function mix(a: string, b: string, t: number): string;
|
|
66
|
+
/**
|
|
67
|
+
* A body as a line drawing, as an SVG string: the outline (squeezed by its flattening and leaning at its axial tilt), bands and features, rings with their gaps, and the dark side
|
|
68
|
+
* dashed off. Give it a `time` to draw the body as the Earth sees it then; leave it out for a portrait. `moons: true` draws a planet with its moons on their orbits.
|
|
69
|
+
*
|
|
70
|
+
* @param id - The body's name: `sun`, a planet or a moon.
|
|
71
|
+
* @param options - The size, the pose (`tilt`, `pitch`, `phase`, `spin` or a `time`), `moons`, `fill`, the language and the colours.
|
|
72
|
+
* @returns The SVG markup, `<svg ...>` to `</svg>`.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* import { lineSvg } from "@johnmorrisdotca/wakusei-planets";
|
|
77
|
+
*
|
|
78
|
+
* const svg = lineSvg("saturn", { size: 320 });
|
|
79
|
+
* console.log(svg.startsWith("<svg"), svg.includes("Saturn"));
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function lineSvg(id: BodyId, options?: LineOptions): string;
|