@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/glsl.js
CHANGED
|
@@ -240,7 +240,8 @@ uniform vec2 uEyeEN;
|
|
|
240
240
|
uniform float uExposure;
|
|
241
241
|
uniform float uAlbedo;
|
|
242
242
|
uniform float uMaxY; // the highest ground over the site's, for the end of a shadow's march
|
|
243
|
-
uniform float uEarthshine; // the light of the sunlit ground round the shade, a small share of a lit slope's
|
|
243
|
+
uniform float uEarthshine; // the light of the sunlit ground round the shade, a small share of a lit slope's (on Mars the sky's light, a good deal more)
|
|
244
|
+
uniform vec3 uTint; // the ground's colour over its grey: white on the Moon
|
|
244
245
|
uniform float uShadows; // 1 for the ground to shadow itself (the default), 0 for none (a try-out)
|
|
245
246
|
uniform float uSunDegrees; // the Sun's elevation in degrees
|
|
246
247
|
uniform vec3 uNear; // the near march: steps, the distance it reaches in metres, the distance out to which the made craters are in it (the quality of the draw)
|
|
@@ -309,7 +310,7 @@ void main() {
|
|
|
309
310
|
float shine = 0.0;
|
|
310
311
|
if (mu0 > 0.0 && uSun.y > -0.01) shine = (uShadows > 0.5 ? lit(vP, dist) : 1.0) * 2.0 * mu0 / (mu0 + mu);
|
|
311
312
|
float light = uAlbedo * albedoAt(vP.xz, dist) * (shine + uEarthshine * max(n.y, 0.0)) * uExposure;
|
|
312
|
-
gl_FragColor = vec4(
|
|
313
|
+
gl_FragColor = vec4(pow(clamp(vec3(light) * uTint, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
|
|
313
314
|
}
|
|
314
315
|
`;
|
|
315
316
|
/** The rocks: pieces of ground standing on it. Their corners come from the page already in the site's plane (east, up, north). */
|
|
@@ -510,3 +511,35 @@ void main() {
|
|
|
510
511
|
gl_FragColor = vec4(1.0, 0.92, 0.78, a);
|
|
511
512
|
}
|
|
512
513
|
`;
|
|
514
|
+
/** The sky of a body with air (Mars): one square over the whole picture, behind everything. Each pixel's direction is found from the camera's axes, so the colour follows how high it looks and how near the Sun it is. */
|
|
515
|
+
export const SKY_VERTEX = /* glsl */ `
|
|
516
|
+
precision highp float;
|
|
517
|
+
varying vec2 vNdc;
|
|
518
|
+
void main() {
|
|
519
|
+
vNdc = position.xy;
|
|
520
|
+
gl_Position = vec4(position.xy, 0.999, 1.0);
|
|
521
|
+
}
|
|
522
|
+
`;
|
|
523
|
+
export const SKY_FRAGMENT = /* glsl */ `
|
|
524
|
+
precision highp float;
|
|
525
|
+
uniform vec3 uForwardEnu; // the camera's axes in the sky's frame (east, north, up)
|
|
526
|
+
uniform vec3 uRightEnu;
|
|
527
|
+
uniform vec3 uUpEnu;
|
|
528
|
+
uniform vec2 uTan; // half the picture's width and height as tangents
|
|
529
|
+
uniform vec3 uSunEnu;
|
|
530
|
+
uniform vec3 uHorizon; // the colour at the horizon, at the zenith and round the Sun, already scaled by the daylight
|
|
531
|
+
uniform vec3 uZenith;
|
|
532
|
+
uniform vec3 uGlow;
|
|
533
|
+
uniform float uGlowSize; // the glow's width as the sine of its half angle
|
|
534
|
+
varying vec2 vNdc;
|
|
535
|
+
void main() {
|
|
536
|
+
vec3 ray = normalize(uForwardEnu + uRightEnu * vNdc.x * uTan.x + uUpEnu * vNdc.y * uTan.y);
|
|
537
|
+
float up = clamp(ray.z, 0.0, 1.0);
|
|
538
|
+
vec3 colour = mix(uHorizon, uZenith, pow(up, 0.55));
|
|
539
|
+
float s = length(cross(ray, uSunEnu));
|
|
540
|
+
float near = dot(ray, uSunEnu) > 0.0 ? exp(-(s * s) / (uGlowSize * uGlowSize)) : 0.0;
|
|
541
|
+
colour = mix(colour, uGlow, clamp(near, 0.0, 1.0));
|
|
542
|
+
// under the horizon the ground hides it; keep the horizon colour so a gap shows no seam
|
|
543
|
+
gl_FragColor = vec4(pow(clamp(colour, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
|
|
544
|
+
}
|
|
545
|
+
`;
|
package/dist/surface/height.d.ts
CHANGED
package/dist/surface/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { moonSky, localFrame, type MoonSky, type SkyDirection } from "./sky.ts";
|
|
2
|
-
export { SURFACE_SITES, siteById, type SurfaceSite } from "./site.ts";
|
|
1
|
+
export { moonSky, standSky, marsAir, localFrame, type MoonSky, type StandSky, type SkyAir, type Rgb, type SkyDirection } from "./sky.ts";
|
|
2
|
+
export { SURFACE_SITES, MOON_GRAVITY, MARS_GRAVITY, siteById, type SurfaceSite } from "./site.ts";
|
|
3
|
+
export { flatManifest, flatTerrain } from "./flat.ts";
|
|
3
4
|
export { EYE_HEIGHT, FOV_LIMITS, WALK_SPEED, clampLook, forward, stepOver, viewProjection, type Look } from "./view.ts";
|
|
4
5
|
export { decodeHeight, drop, emptyLevel, fillFromCoarser, groundAt, sampleLevel, tileAddress, type HeightLevel, type HeightLevelInfo, type TerrainManifest } from "./height.ts";
|
|
5
6
|
export { loadPlan, loadTerrain, type LoadJob, type LoadOptions, type Terrain, type TerrainProgress } from "./load.ts";
|
package/dist/surface/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// The standing view: the Moon's measured ground, the Sun and the Earth as a person standing there sees them. `import "@johnmorrisdotca/wakusei-planets/surface/element"` registers `<wakusei-surface>`.
|
|
2
|
-
export { moonSky, localFrame } from "./sky.js";
|
|
3
|
-
export { SURFACE_SITES, siteById } from "./site.js";
|
|
2
|
+
export { moonSky, standSky, marsAir, localFrame } from "./sky.js";
|
|
3
|
+
export { SURFACE_SITES, MOON_GRAVITY, MARS_GRAVITY, siteById } from "./site.js";
|
|
4
|
+
export { flatManifest, flatTerrain } from "./flat.js";
|
|
4
5
|
export { EYE_HEIGHT, FOV_LIMITS, WALK_SPEED, clampLook, forward, stepOver, viewProjection } from "./view.js";
|
|
5
6
|
export { decodeHeight, drop, emptyLevel, fillFromCoarser, groundAt, sampleLevel, tileAddress } from "./height.js";
|
|
6
7
|
export { loadPlan, loadTerrain } from "./load.js";
|
package/dist/surface/land.d.ts
CHANGED
|
@@ -61,12 +61,12 @@ export declare function landedAt(space: WakuseiSpace): string | null;
|
|
|
61
61
|
*/
|
|
62
62
|
export declare function surfaceOf(space: WakuseiSpace): HTMLElement | null;
|
|
63
63
|
/**
|
|
64
|
-
* Come down to a site from the orbit view in one move: the camera goes to the Moon if it is not there, turns over the site and comes in to the
|
|
64
|
+
* Come down to a site from the orbit view in one move: the camera goes to the site's body (the Moon or Mars) if it is not there, turns over the site and comes in to the closest zoom, the standing view is made and its ground
|
|
65
65
|
* loaded meanwhile, and it fades in over the picture. `wakusei-landing` is sent when it starts and `wakusei-landed` (with the site) when the person is standing. Resolves the standing view; rejects when there is
|
|
66
66
|
* no such site, the view cannot be drawn, the ground does not come in time, or `leave` is called first.
|
|
67
67
|
*
|
|
68
|
-
* @param space - The orbit view, with the Moon in it.
|
|
69
|
-
* @param siteId - A site's name from `SURFACE_SITES`.
|
|
68
|
+
* @param space - The orbit view, with the site's body (the Moon or Mars) in it.
|
|
69
|
+
* @param siteId - A site's name from `SURFACE_SITES`: `apollo-17`, `apollo-15`, `apollo-16`, `chang-e-3`, `chang-e-4`, `perseverance` or `curiosity`.
|
|
70
70
|
* @param options - Where the tiles are, the moment, where to look first, and whether to move smoothly.
|
|
71
71
|
* @returns The `<wakusei-surface>` element, standing.
|
|
72
72
|
*
|
|
@@ -79,11 +79,13 @@ export declare function surfaceOf(space: WakuseiSpace): HTMLElement | null;
|
|
|
79
79
|
* space.addEventListener("wakusei-landed", (event) => console.log("down at", (event as CustomEvent).detail.site));
|
|
80
80
|
* await land(space, "apollo-17");
|
|
81
81
|
* await leave(space);
|
|
82
|
+
* await land(space, "perseverance"); // Jezero, on Mars: flat ground until a height model is added
|
|
83
|
+
* await leave(space);
|
|
82
84
|
* ```
|
|
83
85
|
*/
|
|
84
86
|
export declare function land(space: WakuseiSpace, siteId: string, options?: LandOptions): Promise<HTMLElement>;
|
|
85
87
|
/**
|
|
86
|
-
* Go back up: the standing view fades out and the orbit view's camera rises to the whole
|
|
88
|
+
* Go back up: the standing view fades out and the orbit view's camera rises to the whole body. Sends `wakusei-left`. Does nothing when nobody has landed; a landing that is still coming down is called off (its
|
|
87
89
|
* `land` rejects).
|
|
88
90
|
*
|
|
89
91
|
* @param space - The orbit view.
|
|
@@ -103,7 +105,7 @@ export declare function leave(space: WakuseiSpace, options?: {
|
|
|
103
105
|
}): Promise<void>;
|
|
104
106
|
declare module "../space/element.ts" {
|
|
105
107
|
interface WakuseiSpace {
|
|
106
|
-
/** Come down to a site on the Moon from this view in one move; see `land` in `/surface/land`. */
|
|
108
|
+
/** Come down to a site on the Moon or Mars from this view in one move; see `land` in `/surface/land`. */
|
|
107
109
|
land(siteId: string, options?: LandOptions): Promise<HTMLElement>;
|
|
108
110
|
/** Go back up from a site; see `leave` in `/surface/land`. */
|
|
109
111
|
leave(options?: {
|
package/dist/surface/land.js
CHANGED
|
@@ -58,12 +58,12 @@ export function surfaceOf(space) {
|
|
|
58
58
|
return landings.get(space)?.surface ?? null;
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
|
-
* Come down to a site from the orbit view in one move: the camera goes to the Moon if it is not there, turns over the site and comes in to the
|
|
61
|
+
* Come down to a site from the orbit view in one move: the camera goes to the site's body (the Moon or Mars) if it is not there, turns over the site and comes in to the closest zoom, the standing view is made and its ground
|
|
62
62
|
* loaded meanwhile, and it fades in over the picture. `wakusei-landing` is sent when it starts and `wakusei-landed` (with the site) when the person is standing. Resolves the standing view; rejects when there is
|
|
63
63
|
* no such site, the view cannot be drawn, the ground does not come in time, or `leave` is called first.
|
|
64
64
|
*
|
|
65
|
-
* @param space - The orbit view, with the Moon in it.
|
|
66
|
-
* @param siteId - A site's name from `SURFACE_SITES`.
|
|
65
|
+
* @param space - The orbit view, with the site's body (the Moon or Mars) in it.
|
|
66
|
+
* @param siteId - A site's name from `SURFACE_SITES`: `apollo-17`, `apollo-15`, `apollo-16`, `chang-e-3`, `chang-e-4`, `perseverance` or `curiosity`.
|
|
67
67
|
* @param options - Where the tiles are, the moment, where to look first, and whether to move smoothly.
|
|
68
68
|
* @returns The `<wakusei-surface>` element, standing.
|
|
69
69
|
*
|
|
@@ -76,6 +76,8 @@ export function surfaceOf(space) {
|
|
|
76
76
|
* space.addEventListener("wakusei-landed", (event) => console.log("down at", (event as CustomEvent).detail.site));
|
|
77
77
|
* await land(space, "apollo-17");
|
|
78
78
|
* await leave(space);
|
|
79
|
+
* await land(space, "perseverance"); // Jezero, on Mars: flat ground until a height model is added
|
|
80
|
+
* await leave(space);
|
|
79
81
|
* ```
|
|
80
82
|
*/
|
|
81
83
|
export async function land(space, siteId, options = {}) {
|
|
@@ -134,8 +136,8 @@ export async function land(space, siteId, options = {}) {
|
|
|
134
136
|
if (landing.cancelled)
|
|
135
137
|
throw new Error("the landing was called off");
|
|
136
138
|
// the camera: to the Moon, then over the site and in to the closest zoom, while the standing view loads behind
|
|
137
|
-
if (space.body !==
|
|
138
|
-
space.goTo(
|
|
139
|
+
if (space.body !== site.body) {
|
|
140
|
+
space.goTo(site.body, { smooth });
|
|
139
141
|
if (smooth) {
|
|
140
142
|
await frame();
|
|
141
143
|
await waitWhile(landing, () => space.stats.ride.gliding || space.stats.travelling !== null, 60_000);
|
|
@@ -143,7 +145,7 @@ export async function land(space, siteId, options = {}) {
|
|
|
143
145
|
}
|
|
144
146
|
if (landing.cancelled)
|
|
145
147
|
throw new Error("the landing was called off");
|
|
146
|
-
const place = await space.goToPlace(site.place, { body:
|
|
148
|
+
const place = await space.goToPlace(site.place, { body: site.body, smooth, zoom: 3.6 });
|
|
147
149
|
if (place === undefined)
|
|
148
150
|
fail(`the orbit view has no place ${site.place}`);
|
|
149
151
|
if (smooth)
|
|
@@ -209,7 +211,7 @@ export async function land(space, siteId, options = {}) {
|
|
|
209
211
|
return surface;
|
|
210
212
|
}
|
|
211
213
|
/**
|
|
212
|
-
* Go back up: the standing view fades out and the orbit view's camera rises to the whole
|
|
214
|
+
* Go back up: the standing view fades out and the orbit view's camera rises to the whole body. Sends `wakusei-left`. Does nothing when nobody has landed; a landing that is still coming down is called off (its
|
|
213
215
|
* `land` rejects).
|
|
214
216
|
*
|
|
215
217
|
* @param space - The orbit view.
|
|
@@ -242,7 +244,7 @@ export async function leave(space, options = {}) {
|
|
|
242
244
|
surface.remove();
|
|
243
245
|
if (wasDown) {
|
|
244
246
|
await space.resume();
|
|
245
|
-
await space.goToPlace(site.place, { body:
|
|
247
|
+
await space.goToPlace(site.place, { body: site.body, smooth: false, zoom: 1 });
|
|
246
248
|
}
|
|
247
249
|
else {
|
|
248
250
|
await space.resume();
|
package/dist/surface/scene.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type DriveState } from "./drive.ts";
|
|
|
4
4
|
import type { VehicleModel } from "./model.ts";
|
|
5
5
|
import { type SiteObject } from "./objects.ts";
|
|
6
6
|
import type { HeightLevel, TerrainManifest } from "./height.ts";
|
|
7
|
-
import type { MoonSky } from "./sky.ts";
|
|
7
|
+
import type { MoonSky, SkyAir } from "./sky.ts";
|
|
8
8
|
import { type Look } from "./view.ts";
|
|
9
9
|
/** Everything that changes how the view looks. The element fills one in and hands it over; the scene holds no clock of its own. */
|
|
10
10
|
export interface SurfaceState {
|
|
@@ -15,7 +15,11 @@ export interface SurfaceState {
|
|
|
15
15
|
up: number;
|
|
16
16
|
};
|
|
17
17
|
look: Look;
|
|
18
|
-
sky:
|
|
18
|
+
/** The sky: the Moon's (`moonSky`) or a body's with air (`standSky`: `air` is its colours, and `earthDisc` false hides the Earth's disc). */
|
|
19
|
+
sky: MoonSky & {
|
|
20
|
+
air?: SkyAir | null;
|
|
21
|
+
earthDisc?: boolean;
|
|
22
|
+
};
|
|
19
23
|
/** Brightness: the sunlit ground of an albedo of 0.14 comes out as this share of white times the Sun's height factor (default 4.5). */
|
|
20
24
|
exposure?: number;
|
|
21
25
|
/** The ground's own brightness, 0 to 1 (default 0.14, a grey a little lighter than the Moon's mean). */
|
package/dist/surface/scene.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { rocksAround } from "./detail.js";
|
|
2
|
-
import { DISC_FRAGMENT, DISC_VERTEX, GROUND_FRAGMENT, GROUND_VERTEX, OBJECT_FRAGMENT, OBJECT_VERTEX, ROCK_FRAGMENT, ROCK_VERTEX, SHADOW_FRAGMENT, SHADOW_VERTEX, TRACK_FRAGMENT, TRACK_VERTEX, DUST_FRAGMENT, DUST_VERTEX, PLUME_FRAGMENT, PLUME_VERTEX } from "./glsl.js";
|
|
2
|
+
import { DISC_FRAGMENT, DISC_VERTEX, GROUND_FRAGMENT, GROUND_VERTEX, OBJECT_FRAGMENT, OBJECT_VERTEX, ROCK_FRAGMENT, ROCK_VERTEX, SHADOW_FRAGMENT, SHADOW_VERTEX, TRACK_FRAGMENT, TRACK_VERTEX, DUST_FRAGMENT, DUST_VERTEX, PLUME_FRAGMENT, PLUME_VERTEX, SKY_FRAGMENT, SKY_VERTEX } from "./glsl.js";
|
|
3
3
|
import { driveParts } from "./drive.js";
|
|
4
4
|
import { modelShadowParts } from "./rig.js";
|
|
5
5
|
import { placePart, ascentParts, landerParts } from "./shapes.js";
|
|
@@ -109,6 +109,7 @@ export function createSurfaceItem(options) {
|
|
|
109
109
|
uAlbedo: { value: 0.14 },
|
|
110
110
|
uMaxY: { value: maxY },
|
|
111
111
|
uEarthshine: { value: 0.05 },
|
|
112
|
+
uTint: { value: new T.Vector3(1, 1, 1) },
|
|
112
113
|
uShadows: { value: 1 },
|
|
113
114
|
uHmin: { value: manifest.height.min },
|
|
114
115
|
uHrange: { value: manifest.height.range },
|
|
@@ -169,8 +170,25 @@ export function createSurfaceItem(options) {
|
|
|
169
170
|
};
|
|
170
171
|
const sun = disc(0, Math.tan((0.533 * Math.PI) / 360));
|
|
171
172
|
const earth = disc(1, Math.tan((1.9 * Math.PI) / 360));
|
|
173
|
+
// the sky of a body with air: one square behind the discs, hidden where there is none
|
|
174
|
+
const skyUniforms = {
|
|
175
|
+
uForwardEnu: { value: new T.Vector3(0, 1, 0) },
|
|
176
|
+
uRightEnu: { value: new T.Vector3(1, 0, 0) },
|
|
177
|
+
uUpEnu: { value: new T.Vector3(0, 0, 1) },
|
|
178
|
+
uTan: { value: new T.Vector2(1, 1) },
|
|
179
|
+
uSunEnu: { value: new T.Vector3(0, 0, 1) },
|
|
180
|
+
uHorizon: { value: new T.Vector3() },
|
|
181
|
+
uZenith: { value: new T.Vector3() },
|
|
182
|
+
uGlow: { value: new T.Vector3() },
|
|
183
|
+
uGlowSize: { value: 0.2 },
|
|
184
|
+
};
|
|
185
|
+
const skyMaterial = new T.ShaderMaterial({ vertexShader: SKY_VERTEX, fragmentShader: SKY_FRAGMENT, uniforms: skyUniforms, depthTest: false, depthWrite: false });
|
|
186
|
+
const skyMesh = new T.Mesh(square, skyMaterial);
|
|
187
|
+
skyMesh.frustumCulled = false;
|
|
188
|
+
skyMesh.renderOrder = -20;
|
|
189
|
+
skyMesh.visible = false;
|
|
172
190
|
const scene = new T.Scene();
|
|
173
|
-
scene.add(sun.mesh, earth.mesh, ground);
|
|
191
|
+
scene.add(skyMesh, sun.mesh, earth.mesh, ground);
|
|
174
192
|
// the rocks and their shadows, made again when the eyes have walked a while or the Sun has moved
|
|
175
193
|
const rockMaterial = new T.ShaderMaterial({ vertexShader: ROCK_VERTEX, fragmentShader: ROCK_FRAGMENT, uniforms });
|
|
176
194
|
const shadowMaterial = new T.ShaderMaterial({ vertexShader: SHADOW_VERTEX, fragmentShader: SHADOW_FRAGMENT, uniforms: { uVP: uniforms.uVP }, transparent: true, depthWrite: false });
|
|
@@ -655,7 +673,10 @@ export function createSurfaceItem(options) {
|
|
|
655
673
|
const tilt = Math.abs(look.pitch) + look.fov / 2;
|
|
656
674
|
uniforms.uSpan.value = tilt > 78 ? Math.PI : Math.min(Math.PI, halfH / Math.cos((tilt * Math.PI) / 180) + 0.06);
|
|
657
675
|
uniforms.uSun.value.set(sky.sun.enu[0], sky.sun.enu[2], sky.sun.enu[1]);
|
|
658
|
-
|
|
676
|
+
const air = sky.air ?? null;
|
|
677
|
+
uniforms.uExposure.value = state.exposure ?? (air === null ? 4.5 : 3.2);
|
|
678
|
+
uniforms.uEarthshine.value = air === null ? 0.05 : air.ambient;
|
|
679
|
+
uniforms.uTint.value.set(air?.tint[0] ?? 1, air?.tint[1] ?? 1, air?.tint[2] ?? 1);
|
|
659
680
|
uniforms.uAlbedo.value = state.albedo ?? 0.14;
|
|
660
681
|
uniforms.uShadows.value = state.shadows === false ? 0 : 1;
|
|
661
682
|
uniforms.uDetail.value = state.detail === false ? 0 : 1;
|
|
@@ -691,7 +712,22 @@ export function createSurfaceItem(options) {
|
|
|
691
712
|
earth.uniforms.uHalf.value = Math.tan((sky.earthDiameter * Math.PI) / 360);
|
|
692
713
|
sun.uniforms.uHalf.value = Math.tan((sky.sunDiameter * Math.PI) / 360);
|
|
693
714
|
sun.mesh.visible = sky.sun.altitude > -1;
|
|
694
|
-
earth.mesh.visible = sky.earth.altitude > -1;
|
|
715
|
+
earth.mesh.visible = sky.earthDisc !== false && sky.earth.altitude > -1;
|
|
716
|
+
skyMesh.visible = air !== null;
|
|
717
|
+
if (air !== null) {
|
|
718
|
+
const e = toEnu(axes.forward);
|
|
719
|
+
skyUniforms.uForwardEnu.value.set(e[0], e[1], e[2]);
|
|
720
|
+
const r2 = toEnu(axes.right);
|
|
721
|
+
skyUniforms.uRightEnu.value.set(r2[0], r2[1], r2[2]);
|
|
722
|
+
const u2 = toEnu(axes.up);
|
|
723
|
+
skyUniforms.uUpEnu.value.set(u2[0], u2[1], u2[2]);
|
|
724
|
+
skyUniforms.uTan.value.set(halfV * aspect, halfV);
|
|
725
|
+
skyUniforms.uSunEnu.value.set(sky.sun.enu[0], sky.sun.enu[1], sky.sun.enu[2]);
|
|
726
|
+
skyUniforms.uHorizon.value.set(...air.horizon);
|
|
727
|
+
skyUniforms.uZenith.value.set(...air.zenith);
|
|
728
|
+
skyUniforms.uGlow.value.set(...air.glow);
|
|
729
|
+
skyUniforms.uGlowSize.value = air.glowSize;
|
|
730
|
+
}
|
|
695
731
|
};
|
|
696
732
|
const camera = new T.OrthographicCamera(-1, 1, 1, -1, 0, 1);
|
|
697
733
|
// the stretch of a smaller draw to the canvas: one square with the target as its texture (made when first needed)
|
|
@@ -773,6 +809,7 @@ export function createSurfaceItem(options) {
|
|
|
773
809
|
rockMaterial.dispose();
|
|
774
810
|
shadowMaterial.dispose();
|
|
775
811
|
sun.material.dispose();
|
|
812
|
+
skyMaterial.dispose();
|
|
776
813
|
earth.material.dispose();
|
|
777
814
|
target?.dispose();
|
|
778
815
|
objectMesh?.geometry.dispose();
|
package/dist/surface/site.d.ts
CHANGED
|
@@ -14,7 +14,13 @@ export interface SurfaceSite {
|
|
|
14
14
|
/** The name in the `site` attribute. */
|
|
15
15
|
id: string;
|
|
16
16
|
/** The body it is on. */
|
|
17
|
-
body: "moon";
|
|
17
|
+
body: "moon" | "mars";
|
|
18
|
+
/**
|
|
19
|
+
* What the ground is: `measured` (height tiles made from a published height model) or `flat`, a flat stand-in at the site's datum until a model is added. A flat site has no relief, no made craters and no made rocks, and says so in the line the page shows.
|
|
20
|
+
*/
|
|
21
|
+
ground: "measured" | "flat";
|
|
22
|
+
/** The body's surface gravity at the site, m/s2: what the driven rover and the thrown dust fall at. */
|
|
23
|
+
gravity: number;
|
|
18
24
|
name: {
|
|
19
25
|
en: string;
|
|
20
26
|
ja: string;
|
|
@@ -30,8 +36,31 @@ export interface SurfaceSite {
|
|
|
30
36
|
look: Look;
|
|
31
37
|
}
|
|
32
38
|
/**
|
|
33
|
-
* The
|
|
34
|
-
*
|
|
39
|
+
* The Moon's surface gravity, m/s2.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { MOON_GRAVITY } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
44
|
+
*
|
|
45
|
+
* console.log(`${MOON_GRAVITY} m/s2, a sixth of the Earth's`);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare const MOON_GRAVITY = 1.62;
|
|
49
|
+
/**
|
|
50
|
+
* Mars's surface gravity, m/s2 (NASA's fact sheet gives 3.73 as the mean and 3.69 at the equator; 3.71 is the figure the standing view uses).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { MARS_GRAVITY, MOON_GRAVITY } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
55
|
+
*
|
|
56
|
+
* console.log(`Mars pulls ${(MARS_GRAVITY / MOON_GRAVITY).toFixed(1)} times as hard as the Moon`);
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const MARS_GRAVITY = 3.71;
|
|
60
|
+
/**
|
|
61
|
+
* The sites a person can stand at. Apollo 17 is the one with measured heights: it stands in Taurus-Littrow, a valley a few kilometres wide between mountains 2 kilometres high; it is first looked at toward the South Massif,
|
|
62
|
+
* at the moment of the landing, with the Sun 13 degrees up and the Earth above the mountain. Perseverance (Jezero), Curiosity (Gale), Apollo 15, Apollo 16, Chang'e 3 and Chang'e 4 have the real Sun, sky and gravity of
|
|
63
|
+
* their place and time and a flat stand-in for the ground (`ground: "flat"`) until a height model is added.
|
|
35
64
|
*
|
|
36
65
|
* @example
|
|
37
66
|
* ```ts
|
package/dist/surface/site.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
2
|
+
* The Moon's surface gravity, m/s2.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { MOON_GRAVITY } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
7
|
+
*
|
|
8
|
+
* console.log(`${MOON_GRAVITY} m/s2, a sixth of the Earth's`);
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export const MOON_GRAVITY = 1.62;
|
|
12
|
+
/**
|
|
13
|
+
* Mars's surface gravity, m/s2 (NASA's fact sheet gives 3.73 as the mean and 3.69 at the equator; 3.71 is the figure the standing view uses).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { MARS_GRAVITY, MOON_GRAVITY } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
18
|
+
*
|
|
19
|
+
* console.log(`Mars pulls ${(MARS_GRAVITY / MOON_GRAVITY).toFixed(1)} times as hard as the Moon`);
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export const MARS_GRAVITY = 3.71;
|
|
23
|
+
/**
|
|
24
|
+
* The sites a person can stand at. Apollo 17 is the one with measured heights: it stands in Taurus-Littrow, a valley a few kilometres wide between mountains 2 kilometres high; it is first looked at toward the South Massif,
|
|
25
|
+
* at the moment of the landing, with the Sun 13 degrees up and the Earth above the mountain. Perseverance (Jezero), Curiosity (Gale), Apollo 15, Apollo 16, Chang'e 3 and Chang'e 4 have the real Sun, sky and gravity of
|
|
26
|
+
* their place and time and a flat stand-in for the ground (`ground: "flat"`) until a height model is added.
|
|
4
27
|
*
|
|
5
28
|
* @example
|
|
6
29
|
* ```ts
|
|
@@ -13,6 +36,8 @@ export const SURFACE_SITES = [
|
|
|
13
36
|
{
|
|
14
37
|
id: "apollo-17",
|
|
15
38
|
body: "moon",
|
|
39
|
+
ground: "measured",
|
|
40
|
+
gravity: MOON_GRAVITY,
|
|
16
41
|
name: { en: "Apollo 17, Taurus-Littrow", ja: "アポロ17号、タウルス・リットロー" },
|
|
17
42
|
lat: 20.1911,
|
|
18
43
|
lon: 30.7723,
|
|
@@ -20,6 +45,78 @@ export const SURFACE_SITES = [
|
|
|
20
45
|
time: Date.UTC(1972, 11, 11, 19, 54),
|
|
21
46
|
look: { azimuth: 232, pitch: 13, fov: 74 },
|
|
22
47
|
},
|
|
48
|
+
{
|
|
49
|
+
id: "perseverance",
|
|
50
|
+
body: "mars",
|
|
51
|
+
ground: "flat",
|
|
52
|
+
gravity: MARS_GRAVITY,
|
|
53
|
+
name: { en: "Perseverance, Jezero", ja: "パーシビアランス、ジェゼロ・クレーター" },
|
|
54
|
+
lat: 18.4446,
|
|
55
|
+
lon: 77.4508,
|
|
56
|
+
place: "mars/perseverance",
|
|
57
|
+
time: Date.UTC(2021, 1, 18, 20, 43),
|
|
58
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "curiosity",
|
|
62
|
+
body: "mars",
|
|
63
|
+
ground: "flat",
|
|
64
|
+
gravity: MARS_GRAVITY,
|
|
65
|
+
name: { en: "Curiosity, Gale", ja: "キュリオシティ、ゲール・クレーター" },
|
|
66
|
+
lat: -4.5895,
|
|
67
|
+
lon: 137.4417,
|
|
68
|
+
place: "mars/curiosity",
|
|
69
|
+
time: Date.UTC(2012, 7, 6, 5, 17),
|
|
70
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: "apollo-15",
|
|
74
|
+
body: "moon",
|
|
75
|
+
ground: "flat",
|
|
76
|
+
gravity: MOON_GRAVITY,
|
|
77
|
+
name: { en: "Apollo 15, Hadley-Apennine", ja: "アポロ15号、ハドレー谷とアペニン山脈" },
|
|
78
|
+
lat: 26.1324,
|
|
79
|
+
lon: 3.6333,
|
|
80
|
+
place: "moon/apollo-15-lunar-module",
|
|
81
|
+
time: Date.UTC(1971, 6, 30, 22, 16),
|
|
82
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: "apollo-16",
|
|
86
|
+
body: "moon",
|
|
87
|
+
ground: "flat",
|
|
88
|
+
gravity: MOON_GRAVITY,
|
|
89
|
+
name: { en: "Apollo 16, Descartes", ja: "アポロ16号、デカルト高地" },
|
|
90
|
+
lat: -8.9734,
|
|
91
|
+
lon: 15.5011,
|
|
92
|
+
place: "moon/apollo-16-lunar-module",
|
|
93
|
+
time: Date.UTC(1972, 3, 21, 2, 23),
|
|
94
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: "chang-e-3",
|
|
98
|
+
body: "moon",
|
|
99
|
+
ground: "flat",
|
|
100
|
+
gravity: MOON_GRAVITY,
|
|
101
|
+
name: { en: "Chang'e 3 and Yutu, Mare Imbrium", ja: "嫦娥3号と玉兎号、雨の海" },
|
|
102
|
+
lat: 44.1214,
|
|
103
|
+
lon: -19.5117,
|
|
104
|
+
place: "moon/chang-e-3",
|
|
105
|
+
time: Date.UTC(2013, 11, 14, 13, 11),
|
|
106
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "chang-e-4",
|
|
110
|
+
body: "moon",
|
|
111
|
+
ground: "flat",
|
|
112
|
+
gravity: MOON_GRAVITY,
|
|
113
|
+
name: { en: "Chang'e 4 and Yutu-2, Von Kármán", ja: "嫦娥4号と玉兎2号、フォン・カルマン・クレーター" },
|
|
114
|
+
lat: -45.4561,
|
|
115
|
+
lon: 177.5885,
|
|
116
|
+
place: "moon/chang-e-4",
|
|
117
|
+
time: Date.UTC(2019, 0, 3, 2, 26),
|
|
118
|
+
look: { azimuth: 90, pitch: 4, fov: 74 },
|
|
119
|
+
},
|
|
23
120
|
];
|
|
24
121
|
/**
|
|
25
122
|
* A site by name, or `undefined`.
|
package/dist/surface/sky.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface MoonSky {
|
|
|
44
44
|
* @param lat - Latitude in degrees, positive north.
|
|
45
45
|
* @param lon - Longitude in degrees, positive east.
|
|
46
46
|
* @param time - Milliseconds since 1970.
|
|
47
|
+
* @param body - `moon` (the default) or `mars`; on Mars `[0, 0, 1]` is toward the Earth too, the frame being the viewer's.
|
|
47
48
|
* @returns The axes, and `toLocal`, which turns a vector of that frame into east, north and up.
|
|
48
49
|
*
|
|
49
50
|
* @example
|
|
@@ -54,7 +55,7 @@ export interface MoonSky {
|
|
|
54
55
|
* console.log(frame.toLocal([0, 0, 1]).map((n) => n.toFixed(2)).join(", "));
|
|
55
56
|
* ```
|
|
56
57
|
*/
|
|
57
|
-
export declare function localFrame(lat: number, lon: number, time: number): {
|
|
58
|
+
export declare function localFrame(lat: number, lon: number, time: number, body?: "moon" | "mars"): {
|
|
58
59
|
east: Vec3;
|
|
59
60
|
north: Vec3;
|
|
60
61
|
up: Vec3;
|
|
@@ -79,3 +80,93 @@ export declare function localFrame(lat: number, lon: number, time: number): {
|
|
|
79
80
|
* ```
|
|
80
81
|
*/
|
|
81
82
|
export declare function moonSky(lat: number, lon: number, time: number): MoonSky;
|
|
83
|
+
/**
|
|
84
|
+
* A colour as red, green and blue, 0 to 1, in linear light.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* import { marsAir, type Rgb } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
89
|
+
*
|
|
90
|
+
* const zenith: Rgb = marsAir(40).zenith;
|
|
91
|
+
* console.log(zenith.map((c) => c.toFixed(2)).join(", "));
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export type Rgb = readonly [number, number, number];
|
|
95
|
+
/**
|
|
96
|
+
* The air over a site, for a body that has some (Mars): the colours of the sky and the light the ground gets from it. All are stylised from a few facts, not measured: NASA says the Martian sky is hazy and
|
|
97
|
+
* reddish-tan by day from suspended dust; the pale blue round the Sun when it is low, and the long twilight, are chosen here, not taken from a measurement.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { marsAir } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
102
|
+
*
|
|
103
|
+
* const noon = marsAir(60);
|
|
104
|
+
* const dusk = marsAir(2);
|
|
105
|
+
* console.log(noon.glowSize > dusk.glowSize, marsAir(-30).daylight);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export interface SkyAir {
|
|
109
|
+
/** 0 (night) to 1 (full day): the share of day the sky shows. */
|
|
110
|
+
daylight: number;
|
|
111
|
+
/** The sky at the horizon, at the zenith and round the Sun, already scaled by the daylight. */
|
|
112
|
+
horizon: Rgb;
|
|
113
|
+
zenith: Rgb;
|
|
114
|
+
glow: Rgb;
|
|
115
|
+
/** The glow's width as the sine of its half angle. */
|
|
116
|
+
glowSize: number;
|
|
117
|
+
/** The share of a lit slope's light the shade gets from the sky (the ground's `uEarthshine`); 0.05 on the Moon. */
|
|
118
|
+
ambient: number;
|
|
119
|
+
/** The ground's colour over its grey. */
|
|
120
|
+
tint: Rgb;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* 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).
|
|
124
|
+
*
|
|
125
|
+
* @param sunAltitude - The Sun's height over the horizon in degrees.
|
|
126
|
+
* @returns The colours and the light the sky gives the ground.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```ts
|
|
130
|
+
* import { marsAir } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
131
|
+
*
|
|
132
|
+
* const air = marsAir(25);
|
|
133
|
+
* console.log(air.daylight.toFixed(2), air.zenith.map((c) => c.toFixed(2)).join(" "));
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
export declare function marsAir(sunAltitude: number): SkyAir;
|
|
137
|
+
/**
|
|
138
|
+
* What a standing view's sky holds: the Moon's (the Sun and the Earth, no air) or Mars's (the Sun, the Earth as a point, and the air).
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```ts
|
|
142
|
+
* import { standSky, type StandSky } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
143
|
+
*
|
|
144
|
+
* const sky: StandSky = standSky("mars", 18.4446, 77.4508, Date.UTC(2021, 1, 18, 20, 43));
|
|
145
|
+
* console.log(sky.body, sky.air !== null, `${sky.sunDiameter.toFixed(2)} degrees`);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export interface StandSky extends MoonSky {
|
|
149
|
+
body: "moon" | "mars";
|
|
150
|
+
/** The air, or `null` where there is none (the Moon: a black sky). */
|
|
151
|
+
air: SkyAir | null;
|
|
152
|
+
/** Whether the Earth is drawn as a disc (the Moon's sky has it 1.9 degrees across; from Mars it is a point). */
|
|
153
|
+
earthDisc: boolean;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* 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).
|
|
157
|
+
*
|
|
158
|
+
* @param body - `moon` or `mars`.
|
|
159
|
+
* @param lat - Latitude in degrees, positive north.
|
|
160
|
+
* @param lon - Longitude in degrees, positive east.
|
|
161
|
+
* @param time - Milliseconds since 1970.
|
|
162
|
+
* @returns The Sun, the Earth, and the air.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* import { standSky } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
167
|
+
*
|
|
168
|
+
* const sky = standSky("mars", -4.5895, 137.4417, Date.UTC(2012, 7, 6, 5, 17));
|
|
169
|
+
* console.log(`the Sun is ${sky.sun.altitude.toFixed(0)} degrees up and ${sky.sunDiameter.toFixed(2)} degrees across`);
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function standSky(body: "moon" | "mars", lat: number, lon: number, time: number): StandSky;
|