@johnmorrisdotca/wakusei-planets 0.61.0 → 0.63.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 +17 -0
- package/README.md +3 -3
- package/dist/belts/filter.d.ts +128 -0
- package/dist/belts/filter.js +117 -0
- package/dist/belts/index.d.ts +2 -0
- package/dist/belts/index.js +1 -0
- package/dist/fact-sheets.d.ts +103 -0
- package/dist/fact-sheets.js +135 -0
- package/dist/flat/index.d.ts +1 -0
- package/dist/flat/index.js +1 -0
- package/dist/flat/projections.d.ts +300 -0
- package/dist/flat/projections.js +414 -0
- package/dist/landing-sites.js +6 -6
- package/dist/sky/events.d.ts +2 -0
- package/dist/sky/events.js +3 -2
- package/dist/suncalc-legacy.d.ts +21 -0
- package/dist/suncalc-legacy.js +13 -0
- package/dist/suncalc.d.ts +21 -0
- package/dist/suncalc.js +23 -8
- package/dist/surface/drive.d.ts +4 -3
- package/dist/surface/drive.js +6 -5
- package/dist/surface/dust.d.ts +2 -1
- package/dist/surface/dust.js +3 -2
- package/dist/surface/element.d.ts +3 -3
- package/dist/surface/element.js +31 -13
- package/dist/surface/flat.d.ts +34 -0
- package/dist/surface/flat.js +63 -0
- package/dist/surface/glsl.d.ts +6 -3
- package/dist/surface/glsl.js +35 -2
- package/dist/surface/height.d.ts +1 -1
- package/dist/surface/index.d.ts +3 -2
- package/dist/surface/index.js +3 -2
- package/dist/surface/land.d.ts +7 -5
- package/dist/surface/land.js +10 -8
- package/dist/surface/scene.d.ts +6 -2
- package/dist/surface/scene.js +41 -4
- package/dist/surface/site.d.ts +32 -3
- package/dist/surface/site.js +99 -2
- package/dist/surface/sky.d.ts +92 -1
- package/dist/surface/sky.js +78 -4
- package/package.json +6 -1
package/dist/surface/sky.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// The sky as a person standing on the Moon sees it: where the Sun and the Earth are, and how much of the Earth is lit. Pure: no DOM, no clock; the date is an argument.
|
|
2
|
-
import { apparent } from "../ephemeris.js";
|
|
2
|
+
import { apparent, heliocentric } from "../ephemeris.js";
|
|
3
3
|
import { surfacePoint } from "../pose.js";
|
|
4
|
-
import { cross, dot, unit, DEG } from "../vec.js";
|
|
4
|
+
import { cross, dot, length, unit, DEG } from "../vec.js";
|
|
5
5
|
const direction = (enu) => ({
|
|
6
6
|
enu,
|
|
7
7
|
azimuth: (Math.atan2(enu[0], enu[1]) * DEG + 360) % 360,
|
|
@@ -13,6 +13,7 @@ const direction = (enu) => ({
|
|
|
13
13
|
* @param lat - Latitude in degrees, positive north.
|
|
14
14
|
* @param lon - Longitude in degrees, positive east.
|
|
15
15
|
* @param time - Milliseconds since 1970.
|
|
16
|
+
* @param body - `moon` (the default) or `mars`; on Mars `[0, 0, 1]` is toward the Earth too, the frame being the viewer's.
|
|
16
17
|
* @returns The axes, and `toLocal`, which turns a vector of that frame into east, north and up.
|
|
17
18
|
*
|
|
18
19
|
* @example
|
|
@@ -23,8 +24,8 @@ const direction = (enu) => ({
|
|
|
23
24
|
* console.log(frame.toLocal([0, 0, 1]).map((n) => n.toFixed(2)).join(", "));
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
export function localFrame(lat, lon, time) {
|
|
27
|
-
const moon = apparent(
|
|
27
|
+
export function localFrame(lat, lon, time, body = "moon") {
|
|
28
|
+
const moon = apparent(body, time);
|
|
28
29
|
const up = surfacePoint(moon, lon, lat);
|
|
29
30
|
const east = unit(cross(moon.pole, up));
|
|
30
31
|
const north = cross(up, east);
|
|
@@ -58,3 +59,76 @@ export function moonSky(lat, lon, time) {
|
|
|
58
59
|
earthIllumination: (1 - dot(sun, earth)) / 2,
|
|
59
60
|
};
|
|
60
61
|
}
|
|
62
|
+
const smooth = (a, b, x) => {
|
|
63
|
+
const t = Math.min(1, Math.max(0, (x - a) / (b - a)));
|
|
64
|
+
return t * t * (3 - 2 * t);
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* The sky colours of Mars for a height of the Sun: butterscotch by day, a blue glow round a low Sun, black at night, with a twilight that lasts until the Sun is about 12 degrees down (dust holds the light).
|
|
68
|
+
*
|
|
69
|
+
* @param sunAltitude - The Sun's height over the horizon in degrees.
|
|
70
|
+
* @returns The colours and the light the sky gives the ground.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { marsAir } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
75
|
+
*
|
|
76
|
+
* const air = marsAir(25);
|
|
77
|
+
* console.log(air.daylight.toFixed(2), air.zenith.map((c) => c.toFixed(2)).join(" "));
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export function marsAir(sunAltitude) {
|
|
81
|
+
const day = smooth(-12, 8, sunAltitude);
|
|
82
|
+
const low = 1 - smooth(2, 28, sunAltitude); // 1 with the Sun at the horizon: the blue glow
|
|
83
|
+
const horizon = [0.62, 0.40, 0.26];
|
|
84
|
+
const zenith = [0.30, 0.17, 0.10];
|
|
85
|
+
const tan = [0.75, 0.50, 0.34];
|
|
86
|
+
const blue = [0.16, 0.32, 0.62];
|
|
87
|
+
const mix = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
88
|
+
const k = (c) => [c[0] * day, c[1] * day, c[2] * day];
|
|
89
|
+
return {
|
|
90
|
+
daylight: day,
|
|
91
|
+
horizon: k(horizon),
|
|
92
|
+
zenith: k(zenith),
|
|
93
|
+
glow: k(mix(tan, blue, low)),
|
|
94
|
+
glowSize: 0.12 + 0.2 * (1 - low),
|
|
95
|
+
ambient: 0.05 + 0.22 * day,
|
|
96
|
+
tint: [1.0, 0.72, 0.5],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The sky at a point on the Moon or Mars at a moment, from the package's own ephemeris. On Mars the Sun's disc is its size from Mars's own distance (about 0.35 degrees, 0.533 over its distance in astronomical units).
|
|
101
|
+
*
|
|
102
|
+
* @param body - `moon` or `mars`.
|
|
103
|
+
* @param lat - Latitude in degrees, positive north.
|
|
104
|
+
* @param lon - Longitude in degrees, positive east.
|
|
105
|
+
* @param time - Milliseconds since 1970.
|
|
106
|
+
* @returns The Sun, the Earth, and the air.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { standSky } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
111
|
+
*
|
|
112
|
+
* const sky = standSky("mars", -4.5895, 137.4417, Date.UTC(2012, 7, 6, 5, 17));
|
|
113
|
+
* console.log(`the Sun is ${sky.sun.altitude.toFixed(0)} degrees up and ${sky.sunDiameter.toFixed(2)} degrees across`);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export function standSky(body, lat, lon, time) {
|
|
117
|
+
if (body === "moon")
|
|
118
|
+
return { ...moonSky(lat, lon, time), body, air: null, earthDisc: true };
|
|
119
|
+
const frame = localFrame(lat, lon, time, "mars");
|
|
120
|
+
const sun = frame.toLocal(unit(frame.light));
|
|
121
|
+
const earth = frame.toLocal([0, 0, 1]);
|
|
122
|
+
const sunAu = length(heliocentric("mars", time));
|
|
123
|
+
const sunDirection = direction(sun);
|
|
124
|
+
return {
|
|
125
|
+
body,
|
|
126
|
+
sun: sunDirection,
|
|
127
|
+
sunDiameter: 0.533 / sunAu,
|
|
128
|
+
earth: direction(earth),
|
|
129
|
+
earthDiameter: 0.003,
|
|
130
|
+
earthIllumination: (1 - dot(sun, earth)) / 2,
|
|
131
|
+
air: marsAir(sunDirection.altitude),
|
|
132
|
+
earthDisc: false,
|
|
133
|
+
};
|
|
134
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|
|
@@ -236,6 +236,11 @@
|
|
|
236
236
|
"import": "./dist/spacecraft.js",
|
|
237
237
|
"default": "./dist/spacecraft.js"
|
|
238
238
|
},
|
|
239
|
+
"./fact-sheets": {
|
|
240
|
+
"types": "./dist/fact-sheets.d.ts",
|
|
241
|
+
"import": "./dist/fact-sheets.js",
|
|
242
|
+
"default": "./dist/fact-sheets.js"
|
|
243
|
+
},
|
|
239
244
|
"./roadster": {
|
|
240
245
|
"types": "./dist/roadster.d.ts",
|
|
241
246
|
"import": "./dist/roadster.js",
|