@johnmorrisdotca/wakusei-planets 0.49.0 → 0.50.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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.50.0] - 2026-11-13
6
+
7
+ - **Watch Apollo 17's powered descent** (MODULES-1333). `watch="landing"` on `<wakusei-surface>` (and `land(site, { watch: "landing" })` on `<wakusei-space>`) runs the descent at the real moment (the Sun, the Earth and the shadows of 19:42:52 to 19:54:57 UTC on 1972-12-11) from the commander's window or from the ground, with the clock, the report's moments shown as they pass, a scrubber (`landingTime`), `playLanding()`, `pauseLanding()`, `landingRate` and the `wakusei-landing-clock` event. **Real**: the times of the Apollo 17 Mission Report's table of events (ignition 110:09:53, radar lock T+3:35, throttle down T+7:26, high gate T+9:22, the first of eight redesignations, low gate T+10:58, touchdown T+12:05), the state at ignition (19.13 N, 48.75 E, 8.7 nautical miles, 5,550 ft/s, heading 276 degrees) and the altitudes it names (30,000 ft, 13,000 ft, pitchover at about 7,500 ft, manual takeover under 300 ft, dust at 60 to 70 ft, touchdown at about 3 ft/s). **Made, and said on the picture**: the altitude and speed between those moments (a smooth curve through them that covers the real distance), the ground path, the window's attitude, the plume, and the dust, thrown as a low sheet of many soft grains along the ground from the 60 to 70 ft call-out. The view starts at T+4:00 (the first minutes are beyond the ground the package has). The lunar module is drawn whole, with its plume and shadow; the ground camera stands 150 m north of the touchdown point (`watch-from`, `watch-camera`) and draws a ring with the height beside it until the stage is larger than about 6 pixels. Nothing is drawn once the descent is paused or finished.
8
+
5
9
  ## [0.49.0] - 2026-11-13
6
10
 
7
11
  - **Drive the Apollo 17 rover** (MODULES-1331). `drive="on"` on `<wakusei-surface>` puts the eyes behind the rover at its published place and lets you drive it: W and S (or the arrows, or the walking stick) for the throttle, A and D for the steering, C between the chase view and the commander's seat, a drag to turn the view round it. A pure drive step (`driveStep`) reads the four places the wheels touch on the same ground the eyes walk on, the measured heights and the made craters, so the rover tilts and settles on a spring and, where the ground falls away, is in free fall at the Moon's gravity; the speed follows the throttle to about 12 km/h, is slowed uphill, stops at 25 degrees and at big rocks and the things at the site, and a brake holds it still once it has nearly stopped. The wheels throw fine grey grains up and back in a fan, in parabolas at 1.62 m/s2 (made, not measured), and leave tracks like the published traverse. One draw per step while moving and nothing at rest; `driveFor(seconds, input)` drives by a set time, `vehicle` and `driveCamera` are its state and view. The rover's drawing is corrected to the published sizes (about 3.05 m by 2.13 m, wheels 0.81 m, wheelbase 2.29 m), the lunar module and the rover read as themselves (gold body, ladder and porch, fenders, seats, masts), and the dish stands on a taller mast so the seat view sees under it.
package/README.md CHANGED
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
19
19
 
20
20
  <p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
21
21
 
22
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.49.0/docs/images/lineup-desk.png" width="640"></p>
22
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.50.0/docs/images/lineup-desk.png" width="640"></p>
23
23
 
24
24
  ## Who it is for
25
25
 
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
388
388
 
389
389
  ## The portrait builder
390
390
 
391
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.49.0/docs/images/portrait-family.png" width="640"></p>
391
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.50.0/docs/images/portrait-family.png" width="640"></p>
392
392
 
393
393
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
394
394
 
@@ -536,7 +536,7 @@ BODIES.pluto.kind; // "dwarf-planet"
536
536
 
537
537
  If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
538
538
 
539
- > Morris, J. (2026). *Wakusei Planets* (version 0.49.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
539
+ > Morris, J. (2026). *Wakusei Planets* (version 0.50.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
540
540
 
541
541
  Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
542
542
 
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
11
11
  * console.log(TEXTURE_BASE);
12
12
  * ```
13
13
  */
14
- export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.49.0/dist/textures/";
14
+ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.50.0/dist/textures/";
15
15
  /**
16
16
  * Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
17
17
  * never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
23
23
  * console.log(TEXTURE_FAR_BASE);
24
24
  * ```
25
25
  */
26
- export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.49.0/textures/";
26
+ export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.50.0/textures/";
27
27
  /**
28
28
  * Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
29
29
  * a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
@@ -78,6 +78,13 @@ export declare class WakuseiSurface extends HTMLElement {
78
78
  quality: string;
79
79
  scale: number;
80
80
  scaled: number;
81
+ landing: {
82
+ t: number;
83
+ playing: boolean;
84
+ camera: string;
85
+ altitude: number;
86
+ speed: number;
87
+ } | undefined;
81
88
  vehicle: DriveState | undefined;
82
89
  drawMs: number | undefined;
83
90
  rocks: number;
@@ -109,6 +116,26 @@ export declare class WakuseiSurface extends HTMLElement {
109
116
  throttle: number;
110
117
  steer: number;
111
118
  }): boolean;
119
+ /** The descent being watched: its clock in seconds from ignition, whether it runs, the camera and what the lunar module is doing at that moment; `undefined` when it is not watched. */
120
+ get landing(): {
121
+ t: number;
122
+ playing: boolean;
123
+ rate: number;
124
+ camera: "lander" | "ground";
125
+ altitude: number;
126
+ speed: number;
127
+ descent: number;
128
+ } | undefined;
129
+ /** The clock of the descent, in seconds from ignition (0 to 725). Setting it goes there at once, whether it runs or not. */
130
+ get landingTime(): number;
131
+ set landingTime(value: number);
132
+ /** How fast the descent runs: 1 is the real time of it (12 minutes 5 seconds); 2, 4 and 8 are quicker. */
133
+ get landingRate(): number;
134
+ set landingRate(value: number);
135
+ /** Run the descent from where the clock is (from the start again if it had ended). */
136
+ playLanding(): void;
137
+ /** Hold the descent where it is. */
138
+ pauseLanding(): void;
112
139
  /** The things at the site, at their published places (none where the site has none or `objects="off"`). */
113
140
  get objects(): readonly SiteObject[];
114
141
  /**
@@ -4,6 +4,7 @@ import { TILES_BASE } from "../scene/textures.js";
4
4
  import { madeGround, rocksAround, setKeepOut, standingPlace } from "./detail.js";
5
5
  import { driveStep, driveView, ROVER, startDrive, toWorld } from "./drive.js";
6
6
  import { DustField } from "./dust.js";
7
+ import { calloutsBy, clockText, LANDING, landingAt } from "./landing.js";
7
8
  import { drop, groundAt } from "./height.js";
8
9
  import { loadTerrain } from "./load.js";
9
10
  import { createSurfaceItem } from "./scene.js";
@@ -27,10 +28,20 @@ const TEMPLATE = `<style>
27
28
  .label[aria-pressed="true"] { background: rgba(255, 255, 255, 0.85); color: #10141c; }
28
29
  #about { position: absolute; left: 8px; right: 8px; top: 8px; margin: 0; padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, 0.62); color: #e8ecf2; font: 400 12px/1.4 system-ui, sans-serif; pointer-events: none; max-width: 32em; }
29
30
  #about[hidden] { display: none; }
31
+ #landing { position: absolute; inset: 8px; margin: 0; color: #e8ecf2; font: 400 12px/1.4 system-ui, sans-serif; text-shadow: 0 1px 2px #000; pointer-events: none; }
32
+ #landing[hidden] { display: none; }
33
+ #clock { margin: 0 0 4px; font-weight: 600; }
34
+ #callouts { margin: 0; padding: 0; list-style: none; }
35
+ #callouts li { opacity: 0.75; }
36
+ #callouts li:last-child { opacity: 1; font-weight: 600; }
37
+ #marker { position: absolute; left: 0; top: 0; width: 24px; height: 24px; margin: -12px 0 0 -12px; box-sizing: border-box; border: 1.5px solid rgba(255, 255, 255, 0.9); border-radius: 50%; box-shadow: 0 0 3px #000; pointer-events: none; will-change: transform; }
38
+ #markerText { position: absolute; left: 0; top: 0; margin: 0; font: 600 11px/1.2 system-ui, sans-serif; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; white-space: nowrap; pointer-events: none; will-change: transform; }
39
+ #marker[hidden], #markerText[hidden] { display: none; }
40
+ #curve { position: absolute; left: 0; right: 0; bottom: 50px; margin: 0; font-size: 11px; color: #c8ccd4; }
30
41
  #stick { position: absolute; left: 18px; bottom: 44px; width: 104px; height: 104px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.08); touch-action: none; }
31
42
  #stick[hidden] { display: none; }
32
43
  #knob { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); pointer-events: none; }
33
- </style><div id="stage"></div><p id="note"></p><p id="status" role="status"></p><div id="labels"></div><p id="about" role="status" hidden></p><div id="stick" part="stick" role="group" aria-label="Walk" hidden><div id="knob"></div></div>`;
44
+ </style><div id="stage"></div><p id="note"></p><p id="status" role="status"></p><div id="labels"></div><div id="landing" hidden><span id="marker" hidden></span><span id="markerText" hidden></span><p id="clock"></p><ul id="callouts"></ul><p id="curve"></p></div><p id="about" role="status" hidden></p><div id="stick" part="stick" role="group" aria-label="Walk" hidden><div id="knob"></div></div>`;
34
45
  const num = (value, fallback) => {
35
46
  const n = value === null || value.trim() === "" ? NaN : Number(value);
36
47
  return Number.isFinite(n) ? n : fallback;
@@ -55,7 +66,7 @@ const num = (value, fallback) => {
55
66
  * ```
56
67
  */
57
68
  export class WakuseiSurface extends HTMLElement {
58
- static observedAttributes = ["quality", "shadows", "detail", "exposure", "site", "time", "heading", "pitch", "fov", "tiles", "lang", "body", "standby", "scale", "stick", "objects", "drive", "drive-camera"];
69
+ static observedAttributes = ["quality", "shadows", "detail", "exposure", "site", "time", "heading", "pitch", "fov", "tiles", "lang", "body", "standby", "scale", "stick", "objects", "drive", "drive-camera", "watch", "watch-from", "watch-camera"];
59
70
  #root;
60
71
  #stage;
61
72
  #noteEl;
@@ -110,6 +121,11 @@ export class WakuseiSurface extends HTMLElement {
110
121
  #dust = new DustField(900, 17);
111
122
  #blockers = [];
112
123
  #blockersAt;
124
+ /** The descent being watched (`watch="landing"`): the clock in seconds from ignition, whether it runs, how fast, which camera, where the ground camera stands, and how far the callouts have got. */
125
+ #landing;
126
+ #landingTimer;
127
+ #landingAt = 0;
128
+ #landingEyeUp = 0;
113
129
  #stickPointer = -1;
114
130
  #pointers = new Map();
115
131
  #pinch = 0;
@@ -161,7 +177,7 @@ export class WakuseiSurface extends HTMLElement {
161
177
  /** Numbers for a test or a status line: the draws, the tiles, the renderer's own counts, the mesh, the quality of the last draw and the milliseconds of the last measured one. */
162
178
  get stats() {
163
179
  const scene = this.#view?.scene;
164
- return { state: this.#state, draws: this.#draws, tiles: this.#progress, renderer: this.#renderer?.stats, mesh: scene?.mesh, quality: this.#quality(), scale: this.#drawScale, scaled: this.#scaled, vehicle: this.#vehicle === undefined ? undefined : { ...this.#vehicle, spin: [...this.#vehicle.spin] }, drawMs: scene?.drawMs ?? this.#drawMs, rocks: scene?.rocks ?? 0 };
180
+ return { state: this.#state, draws: this.#draws, tiles: this.#progress, renderer: this.#renderer?.stats, mesh: scene?.mesh, quality: this.#quality(), scale: this.#drawScale, scaled: this.#scaled, landing: this.landing, vehicle: this.#vehicle === undefined ? undefined : { ...this.#vehicle, spin: [...this.#vehicle.spin] }, drawMs: scene?.drawMs ?? this.#drawMs, rocks: scene?.rocks ?? 0 };
165
181
  }
166
182
  /** The quality of the next draw: the `quality` attribute, or in `auto` the quality of motion while the view moves and the machine's own quality of rest otherwise. */
167
183
  #quality() {
@@ -217,6 +233,7 @@ export class WakuseiSurface extends HTMLElement {
217
233
  this.#abort?.abort();
218
234
  clearTimeout(this.#flush);
219
235
  this.#flush = undefined;
236
+ clearTimeout(this.#landingTimer);
220
237
  this.#gate?.cancel();
221
238
  clearTimeout(this.#walkTimer);
222
239
  for (const [type, fn] of [["pointerdown", this.#onPointerDown], ["pointermove", this.#onPointerMove], ["pointerup", this.#onPointerUp], ["pointercancel", this.#onPointerUp], ["wheel", this.#onWheel], ["keydown", this.#onKeyDown], ["keyup", this.#onKeyUp], ["blur", this.#onBlur]])
@@ -234,6 +251,10 @@ export class WakuseiSurface extends HTMLElement {
234
251
  this.#syncDrive();
235
252
  return;
236
253
  }
254
+ if (name === "watch" || name === "watch-from" || name === "watch-camera") {
255
+ this.#syncLanding(name !== "watch");
256
+ return;
257
+ }
237
258
  if (name === "drive-camera") {
238
259
  this.driveCamera = this.getAttribute("drive-camera") === "seat" ? "seat" : "chase";
239
260
  return;
@@ -325,6 +346,7 @@ export class WakuseiSurface extends HTMLElement {
325
346
  this.#at = { east: stand.x, north: stand.y };
326
347
  this.#placed = true;
327
348
  this.#syncDrive();
349
+ this.#syncLanding();
328
350
  }
329
351
  if (this.#view === undefined) {
330
352
  if (this.#renderer === undefined) {
@@ -414,6 +436,8 @@ export class WakuseiSurface extends HTMLElement {
414
436
  #eyeUp() {
415
437
  if (this.#vehicle !== undefined)
416
438
  return this.#driveEyeUp;
439
+ if (this.#landing !== undefined)
440
+ return this.#landingEyeUp;
417
441
  return this.#groundAt(this.#at.east, this.#at.north) + EYE_HEIGHT;
418
442
  }
419
443
  /** Ask for a draw. A change of the view (`moving`, the default) is drawn at the quality of motion and followed, a moment after the last, by one at the quality of rest. */
@@ -468,7 +492,7 @@ export class WakuseiSurface extends HTMLElement {
468
492
  this.#measured += 1;
469
493
  if (this.#drawScale < 1)
470
494
  this.#scaled += 1;
471
- scene.apply({ eye: { east: this.#at.east, north: this.#at.north, up: this.#eyeUp() }, look: this.#look, sky: this.#sky, shadows: this.getAttribute("shadows") !== "off", detail: this.getAttribute("detail") !== "off", exposure: num(this.getAttribute("exposure"), 1.6), quality: this.#quality(), scale: this.#drawScale, objects: this.#objects.length > 0, ...(this.#vehicle === undefined ? {} : { vehicle: this.#vehicle, trail: this.#trail, dust: this.#dust.position }), measure: measure || this.getAttribute("measure") !== null });
495
+ scene.apply({ eye: { east: this.#at.east, north: this.#at.north, up: this.#eyeUp() }, look: this.#look, sky: this.#sky, shadows: this.getAttribute("shadows") !== "off", detail: this.getAttribute("detail") !== "off", exposure: num(this.getAttribute("exposure"), 1.6), quality: this.#quality(), scale: this.#drawScale, objects: this.#objects.length > 0, ...(this.#vehicle === undefined ? {} : { vehicle: this.#vehicle, trail: this.#trail, dust: this.#dust.position }), ...(this.#landing === undefined ? {} : { lander: this.#landerState(), dust: this.#dust.position }), measure: measure || this.getAttribute("measure") !== null });
472
496
  this.#view.invalidate();
473
497
  this.#draws += 1;
474
498
  this.#placeLabels();
@@ -609,6 +633,230 @@ export class WakuseiSurface extends HTMLElement {
609
633
  this.#changed();
610
634
  return true;
611
635
  }
636
+ // --- watching the landing (`watch="landing"`): Apollo 17's powered descent from the lunar module's window or from the ground ---------------------------------------------------------------------
637
+ /** The descent being watched: its clock in seconds from ignition, whether it runs, the camera and what the lunar module is doing at that moment; `undefined` when it is not watched. */
638
+ get landing() {
639
+ const l = this.#landing;
640
+ if (l === undefined)
641
+ return undefined;
642
+ const pose = landingAt(l.t);
643
+ return { t: l.t, playing: l.playing, rate: l.rate, camera: l.camera, altitude: pose.altitude, speed: pose.speed, descent: pose.descent };
644
+ }
645
+ /** The clock of the descent, in seconds from ignition (0 to 725). Setting it goes there at once, whether it runs or not. */
646
+ get landingTime() {
647
+ return this.#landing?.t ?? 0;
648
+ }
649
+ set landingTime(value) {
650
+ const l = this.#landing;
651
+ if (l === undefined)
652
+ return;
653
+ const old = l.t;
654
+ l.t = Math.min(LANDING.duration, Math.max(0, value));
655
+ // a seek forward announces the latest moment it passes (the picture lists the last three); a step of a second or less carries the dust on, a jump or a step back starts it afresh
656
+ const delta = l.t - old;
657
+ if (delta < 0 || delta > 1)
658
+ this.#dust = new DustField(20000, 17);
659
+ this.#landingAt = performance.now();
660
+ this.#landingFrame(delta > 0 && delta <= 1 ? delta : 0, true);
661
+ }
662
+ /** How fast the descent runs: 1 is the real time of it (12 minutes 5 seconds); 2, 4 and 8 are quicker. */
663
+ get landingRate() {
664
+ return this.#landing?.rate ?? 1;
665
+ }
666
+ set landingRate(value) {
667
+ if (this.#landing !== undefined)
668
+ this.#landing.rate = Math.min(16, Math.max(0.25, value));
669
+ }
670
+ /** Run the descent from where the clock is (from the start again if it had ended). */
671
+ playLanding() {
672
+ const l = this.#landing;
673
+ if (l === undefined)
674
+ return;
675
+ if (l.t >= LANDING.duration)
676
+ this.landingTime = l.camera === "ground" ? 540 : LANDING.viewStart;
677
+ l.playing = true;
678
+ this.#landingAt = performance.now();
679
+ this.#landingTick();
680
+ }
681
+ /** Hold the descent where it is. */
682
+ pauseLanding() {
683
+ if (this.#landing === undefined)
684
+ return;
685
+ this.#landing.playing = false;
686
+ clearTimeout(this.#landingTimer);
687
+ this.#landingFrame(0, true);
688
+ }
689
+ /** The touchdown point: where the lunar module stands at Apollo 17 (the published place), or the site point where it has none. */
690
+ #touchdown() {
691
+ const lm = this.#objects.find((o) => o.kind === "lander");
692
+ return lm === undefined ? { east: 0, north: 0 } : { east: lm.east, north: lm.north };
693
+ }
694
+ /** The lunar module as the scene draws it now: its place, its height over the ground under it, its heading and its thrust. */
695
+ #landerState() {
696
+ const l = this.#landing;
697
+ const pose = landingAt(l.t);
698
+ const td = this.#touchdown();
699
+ return { east: td.east + pose.east, north: td.north + pose.north, altitude: pose.altitude, heading: pose.heading, throttle: l.t >= LANDING.duration ? 0 : pose.throttle, inside: l.camera === "lander" };
700
+ }
701
+ /** Start or stop watching as the `watch` attribute says; `again` re-reads the camera and the place the ground camera stands at. */
702
+ #syncLanding(again = false) {
703
+ const on = this.getAttribute("watch") === "landing" && this.#terrain !== undefined && this.#placed;
704
+ if (!on) {
705
+ if (this.#landing === undefined)
706
+ return;
707
+ this.#landing = undefined;
708
+ clearTimeout(this.#landingTimer);
709
+ this.#root.getElementById("landing").hidden = true;
710
+ this.#readAttributes();
711
+ const td = this.#touchdown();
712
+ this.#at = { east: td.east, north: td.north };
713
+ this.#changed();
714
+ return;
715
+ }
716
+ const camera = this.getAttribute("watch-camera") === "ground" ? "ground" : "lander";
717
+ const [distance, bearing] = (this.getAttribute("watch-from") ?? "150 0").split(/[\s,]+/).map(Number);
718
+ const from = { distance: Number.isFinite(distance) ? distance : 150, bearing: Number.isFinite(bearing) ? bearing : 0 };
719
+ if (this.#landing !== undefined) {
720
+ if (!again)
721
+ return;
722
+ if (this.#landing.camera !== camera)
723
+ this.#look = clampLook({ ...this.#look, fov: camera === "ground" ? 27 : 74 });
724
+ this.#landing.camera = camera;
725
+ this.#landing.from = from;
726
+ this.#camOffset = { azimuth: 0, pitch: 0 };
727
+ this.#landingFrame(0, true);
728
+ return;
729
+ }
730
+ this.#landing = { t: camera === "ground" ? 540 : LANDING.viewStart, playing: true, rate: 1, camera, from, passed: 0, second: -1 };
731
+ this.#landing.passed = calloutsBy(this.#landing.t).length;
732
+ this.#dust = new DustField(20000, 17);
733
+ this.#camOffset = { azimuth: 0, pitch: 0 };
734
+ for (const el of this.#labelEls.values())
735
+ el.hidden = true;
736
+ this.choose(undefined);
737
+ this.#root.getElementById("landing").hidden = false;
738
+ this.#root.getElementById("curve").textContent = this.#lang() === "ja" ? "報告された時刻のあいだの高度と速度は、こちらで作った滑らかな曲線です。" : "Altitude and speed between the reported moments are a smooth curve of ours.";
739
+ if (camera === "ground")
740
+ this.#look = clampLook({ ...this.#look, fov: 27 });
741
+ this.#landingAt = performance.now();
742
+ this.#landingFrame(0, true);
743
+ this.#landingTick();
744
+ }
745
+ /** The frame of the descent at the clock: the eyes of the chosen camera, the sky of that real moment, the dust of the blast, the words on the picture and the event for a page; `seconds` is how far the clock has just moved. */
746
+ #landingFrame(seconds, announce) {
747
+ const l = this.#landing;
748
+ if (l === undefined)
749
+ return;
750
+ const pose = landingAt(l.t);
751
+ const td = this.#touchdown();
752
+ const ground = (e, n) => this.#groundAt(e, n);
753
+ const [lx, ly] = [td.east + pose.east, td.north + pose.north];
754
+ const lz = ground(lx, ly);
755
+ this.#time = LANDING.ignition + l.t * 1000;
756
+ // the dust of the blast: from the altitude the Commander first saw it (60 to 70 ft), outward along the ground from under the engine, faster the nearer the ground
757
+ if (seconds > 0 && pose.altitude < 21.3 && l.t < LANDING.duration) {
758
+ // the report's dust is a low sheet driven outward along the ground, thickest in the last metres: most grains leave nearly flat and fast, a few higher
759
+ const strength = Math.pow(1 - pose.altitude / 21.3, 0.7) * pose.throttle;
760
+ const grains = strength * 12000 * seconds;
761
+ for (let k = 0; k < grains + Math.random() * 0.999; k += 1) {
762
+ const a = Math.random() * Math.PI * 2;
763
+ const r0 = 1.5 + Math.random() * 3;
764
+ const v = 6 + Math.random() * 26;
765
+ const lift = Math.random() < 0.85 ? 0.35 + Math.random() * 0.9 : 1.2 + Math.random() * 3;
766
+ const [e, n] = [lx + Math.sin(a) * r0, ly + Math.cos(a) * r0];
767
+ this.#dust.emit([e, ground(e, n) + 0.3, n], [Math.sin(a) * v, lift, Math.cos(a) * v], 4);
768
+ }
769
+ }
770
+ if (seconds > 0)
771
+ this.#dust.step(seconds, ground);
772
+ if (l.camera === "lander") {
773
+ this.#at = { east: lx, north: ly };
774
+ this.#landingEyeUp = lz + pose.altitude + 4;
775
+ this.#look = clampLook({ azimuth: (((pose.heading + this.#camOffset.azimuth) % 360) + 360) % 360, pitch: pose.pitch + this.#camOffset.pitch, fov: this.#look.fov });
776
+ }
777
+ else {
778
+ const b = (l.from.bearing * Math.PI) / 180;
779
+ const [ox, oy] = [td.east + Math.sin(b) * l.from.distance, td.north + Math.cos(b) * l.from.distance];
780
+ this.#at = { east: ox, north: oy };
781
+ this.#landingEyeUp = ground(ox, oy) + 1.7;
782
+ const horizontal = Math.hypot(lx - ox, ly - oy) || 1;
783
+ const azimuth = ((Math.atan2(lx - ox, ly - oy) * 180) / Math.PI + 360) % 360;
784
+ const pitch = (Math.atan2(lz + pose.altitude + 3.4 - this.#landingEyeUp, horizontal) * 180) / Math.PI;
785
+ this.#look = clampLook({ azimuth: azimuth + this.#camOffset.azimuth, pitch: pitch + this.#camOffset.pitch, fov: this.#look.fov });
786
+ }
787
+ // the marker: while the stage is smaller than about 6 pixels in the ground camera a ring and its height mark where it is, fading out as it grows
788
+ const ring = this.#root.getElementById("marker");
789
+ const ringText = this.#root.getElementById("markerText");
790
+ let showRing = false;
791
+ if (l.camera === "ground") {
792
+ const box = this.getBoundingClientRect();
793
+ const [w, h] = [box.width, box.height];
794
+ const vp = viewProjection([this.#at.east, this.#landingEyeUp, -this.#at.north], this.#look, w / Math.max(1, h));
795
+ const [x, y, z] = [lx, lz + pose.altitude + 3.4, -ly];
796
+ const cw = vp[3] * x + vp[7] * y + vp[11] * z + vp[15];
797
+ const px = cw > 0 ? (7 * h) / 2 / (cw * Math.tan((this.#look.fov * Math.PI) / 360)) : 0;
798
+ const fade = Math.min(1, Math.max(0, (9 - px) / 5));
799
+ if (cw > 0 && fade > 0) {
800
+ const nx = (vp[0] * x + vp[4] * y + vp[8] * z + vp[12]) / cw;
801
+ const ny = (vp[1] * x + vp[5] * y + vp[9] * z + vp[13]) / cw;
802
+ if (Math.abs(nx) < 1 && Math.abs(ny) < 1) {
803
+ showRing = true;
804
+ const [sx, sy] = [((nx + 1) / 2) * w, ((1 - ny) / 2) * h];
805
+ ring.style.transform = `translate(${sx}px, ${sy}px)`;
806
+ ring.style.opacity = String(fade);
807
+ ringText.textContent = `${Math.round(pose.altitude).toLocaleString(this.#lang() === "ja" ? "ja-JP" : "en-US")} m`;
808
+ ringText.style.transform = `translate(${sx + 16}px, ${sy - 7}px)`;
809
+ ringText.style.opacity = String(fade);
810
+ }
811
+ }
812
+ }
813
+ ring.hidden = !showRing;
814
+ ringText.hidden = !showRing;
815
+ // the words: the clock and what the lunar module is doing, and the reported moments as they pass
816
+ const clock = clockText(l.t);
817
+ const ja = this.#lang() === "ja";
818
+ const metres = (v) => Math.round(v).toLocaleString(ja ? "ja-JP" : "en-US");
819
+ this.#root.getElementById("clock").textContent = `${clock.t} · ${clock.get} ${ja ? "ミッション経過時間" : "ground elapsed"} · ${ja ? "高度" : "altitude"} ${metres(pose.altitude)} m · ${ja ? "対地速度" : "speed"} ${metres(pose.speed)} m/s`;
820
+ const passed = calloutsBy(l.t);
821
+ const list = this.#root.getElementById("callouts");
822
+ if (announce || passed.length !== l.passed) {
823
+ const show = passed.slice(-3);
824
+ list.replaceChildren(...show.map((c) => {
825
+ const li = document.createElement("li");
826
+ li.textContent = `${clockText(c.t).t} ${ja ? c.ja : c.en}${c.reported ? "" : ja ? "(時刻はこちらの曲線による)" : " (the time is from our curve)"}`;
827
+ return li;
828
+ }));
829
+ }
830
+ const newest = passed.length > l.passed ? passed[passed.length - 1] : undefined;
831
+ l.passed = passed.length;
832
+ const second = Math.floor(l.t);
833
+ if (announce || newest !== undefined || second !== l.second) {
834
+ l.second = second;
835
+ this.dispatchEvent(new CustomEvent("wakusei-landing-clock", { detail: { t: l.t, clock, altitude: pose.altitude, speed: pose.speed, descent: pose.descent, playing: l.playing, callout: newest === undefined ? undefined : { id: newest.id, t: newest.t, en: newest.en, ja: newest.ja, reported: newest.reported } }, bubbles: true, composed: true }));
836
+ }
837
+ this.#changed(l.playing);
838
+ }
839
+ /** While the descent runs: the clock moves by the real time between frames (times the rate), at most thirty times a second; at the touchdown, or paused, nothing is drawn. */
840
+ #landingTick = () => {
841
+ clearTimeout(this.#landingTimer);
842
+ const l = this.#landing;
843
+ if (l === undefined || !l.playing)
844
+ return;
845
+ const now = performance.now();
846
+ const dt = Math.min(0.25, (now - this.#landingAt) / 1000);
847
+ this.#landingAt = now;
848
+ const seconds = Math.min(dt * l.rate, LANDING.duration - l.t);
849
+ l.t += seconds;
850
+ if (l.t >= LANDING.duration - 1e-6) {
851
+ l.t = LANDING.duration;
852
+ l.playing = false;
853
+ }
854
+ this.#landingFrame(seconds, false);
855
+ if (l.playing)
856
+ this.#landingTimer = setTimeout(this.#landingTick, 33);
857
+ else
858
+ this.#changed(true);
859
+ };
612
860
  // --- the things at the site: a small button on each, which goes to it and says what it is ----------------------------------------------------------------------------------------------------
613
861
  /** The things at the site, at their published places (none where the site has none or `objects="off"`). */
614
862
  get objects() {
@@ -647,7 +895,7 @@ export class WakuseiSurface extends HTMLElement {
647
895
  }
648
896
  /** Put each button on its thing in the picture, or hide it behind the viewer, off the picture or too far to tell. Done at each draw: nothing moves by itself. */
649
897
  #placeLabels() {
650
- if (this.#labelEls.size === 0 || this.#vehicle !== undefined)
898
+ if (this.#labelEls.size === 0 || this.#vehicle !== undefined || this.#landing !== undefined)
651
899
  return;
652
900
  const box = this.getBoundingClientRect();
653
901
  const [w, h] = [box.width, box.height];
@@ -674,8 +922,8 @@ export class WakuseiSurface extends HTMLElement {
674
922
  * @returns Whether there is such a thing here.
675
923
  */
676
924
  choose(id) {
677
- if (this.#vehicle !== undefined)
678
- return false; // the rover is being driven: the eyes are its
925
+ if (this.#vehicle !== undefined || this.#landing !== undefined)
926
+ return false; // the rover is being driven or the landing watched: the eyes are not ours to move
679
927
  const about = this.#root.getElementById("about");
680
928
  const o = id === undefined ? undefined : this.#objects.find((x) => x.id === id);
681
929
  if (id !== undefined && o === undefined)
@@ -25,5 +25,8 @@ export declare const TRACK_FRAGMENT = "\nprecision highp float;\nvarying vec2 vU
25
25
  export declare const OBJECT_VERTEX: string;
26
26
  export declare const OBJECT_FRAGMENT: string;
27
27
  /** A grain of dust in flight: a small square that always faces the viewer, at a place in the site's plane, its size in metres. */
28
- export declare const DUST_VERTEX = "\nprecision highp float;\n// position (declared by three.js) is the grain's place; the corner of its square is in uv, -1 to 1\nuniform mat4 uVP;\nuniform vec3 uRight;\nuniform vec3 uUp;\nuniform float uSize;\nvarying vec2 vUv;\nvoid main() {\n vUv = uv * 2.0 - 1.0;\n vec3 w = vec3(position.x, position.y, -position.z) + (uRight * vUv.x + uUp * vUv.y) * uSize;\n gl_Position = uVP * vec4(w, 1.0);\n}\n";
29
- export declare const DUST_FRAGMENT = "\nprecision highp float;\nvarying vec2 vUv;\nvoid main() {\n float r = length(vUv);\n if (r > 1.0) discard;\n gl_FragColor = vec4(vec3(0.6), 0.55 * (1.0 - r * r));\n}\n";
28
+ export declare const DUST_VERTEX = "\nprecision highp float;\n// position (declared by three.js) is the grain's place; the corner of its square is in uv, -1 to 1\nuniform mat4 uVP;\nuniform vec3 uRight;\nuniform vec3 uUp;\nuniform float uSize;\nuniform vec3 uEyeWorld;\nuniform float uMinAngle; // the least a grain shows as, in radians (a blast seen from far off)\nvarying vec2 vUv;\nvoid main() {\n vUv = uv * 2.0 - 1.0;\n vec3 c = vec3(position.x, position.y, -position.z);\n float size = max(uSize, distance(c, uEyeWorld) * uMinAngle);\n vec3 w = c + (uRight * vUv.x + uUp * vUv.y) * size;\n gl_Position = uVP * vec4(w, 1.0);\n}\n";
29
+ export declare const DUST_FRAGMENT = "\nprecision highp float;\nvarying vec2 vUv;\nvoid main() {\n float r = length(vUv);\n if (r > 1.0) discard;\n gl_FragColor = vec4(vec3(0.62), 0.32 * (1.0 - r * r));\n}\n";
30
+ /** The engine's plume: a cone below the bell, its place and size in uniforms, faint and warm, widest at its end (a vacuum lets a plume spread). position.x is the angle round it (0 to 1), position.y the way along it (0 to 1). */
31
+ export declare const PLUME_VERTEX = "\nprecision highp float;\nuniform mat4 uVP;\nuniform vec3 uBell; // the bell's exit, in the site's plane (east, up, north)\nuniform float uLength;\nuniform float uRadius;\nvarying float vAlong;\nvoid main() {\n float a = position.x * 6.2831853;\n float u = position.y;\n float r = 0.7 + (uRadius - 0.7) * pow(u, 0.6);\n vec3 w = uBell + vec3(cos(a) * r, -u * uLength, sin(a) * r);\n vAlong = u;\n gl_Position = uVP * vec4(w.x, w.y, -w.z, 1.0);\n}\n";
32
+ export declare const PLUME_FRAGMENT = "\nprecision highp float;\nuniform float uPlume; // the share of full thrust\nvarying float vAlong;\nvoid main() {\n float a = uPlume * 0.38 * (1.0 - vAlong) * (1.0 - vAlong);\n if (a < 0.003) discard;\n gl_FragColor = vec4(1.0, 0.92, 0.78, a);\n}\n";
@@ -463,10 +463,14 @@ uniform mat4 uVP;
463
463
  uniform vec3 uRight;
464
464
  uniform vec3 uUp;
465
465
  uniform float uSize;
466
+ uniform vec3 uEyeWorld;
467
+ uniform float uMinAngle; // the least a grain shows as, in radians (a blast seen from far off)
466
468
  varying vec2 vUv;
467
469
  void main() {
468
470
  vUv = uv * 2.0 - 1.0;
469
- vec3 w = vec3(position.x, position.y, -position.z) + (uRight * vUv.x + uUp * vUv.y) * uSize;
471
+ vec3 c = vec3(position.x, position.y, -position.z);
472
+ float size = max(uSize, distance(c, uEyeWorld) * uMinAngle);
473
+ vec3 w = c + (uRight * vUv.x + uUp * vUv.y) * size;
470
474
  gl_Position = uVP * vec4(w, 1.0);
471
475
  }
472
476
  `;
@@ -476,6 +480,33 @@ varying vec2 vUv;
476
480
  void main() {
477
481
  float r = length(vUv);
478
482
  if (r > 1.0) discard;
479
- gl_FragColor = vec4(vec3(0.6), 0.55 * (1.0 - r * r));
483
+ gl_FragColor = vec4(vec3(0.62), 0.32 * (1.0 - r * r));
484
+ }
485
+ `;
486
+ /** The engine's plume: a cone below the bell, its place and size in uniforms, faint and warm, widest at its end (a vacuum lets a plume spread). position.x is the angle round it (0 to 1), position.y the way along it (0 to 1). */
487
+ export const PLUME_VERTEX = /* glsl */ `
488
+ precision highp float;
489
+ uniform mat4 uVP;
490
+ uniform vec3 uBell; // the bell's exit, in the site's plane (east, up, north)
491
+ uniform float uLength;
492
+ uniform float uRadius;
493
+ varying float vAlong;
494
+ void main() {
495
+ float a = position.x * 6.2831853;
496
+ float u = position.y;
497
+ float r = 0.7 + (uRadius - 0.7) * pow(u, 0.6);
498
+ vec3 w = uBell + vec3(cos(a) * r, -u * uLength, sin(a) * r);
499
+ vAlong = u;
500
+ gl_Position = uVP * vec4(w.x, w.y, -w.z, 1.0);
501
+ }
502
+ `;
503
+ export const PLUME_FRAGMENT = /* glsl */ `
504
+ precision highp float;
505
+ uniform float uPlume; // the share of full thrust
506
+ varying float vAlong;
507
+ void main() {
508
+ float a = uPlume * 0.38 * (1.0 - vAlong) * (1.0 - vAlong);
509
+ if (a < 0.003) discard;
510
+ gl_FragColor = vec4(1.0, 0.92, 0.78, a);
480
511
  }
481
512
  `;
@@ -4,7 +4,8 @@ export { EYE_HEIGHT, FOV_LIMITS, WALK_SPEED, clampLook, forward, stepOver, viewP
4
4
  export { decodeHeight, drop, emptyLevel, fillFromCoarser, groundAt, sampleLevel, tileAddress, type HeightLevel, type HeightLevelInfo, type TerrainManifest } from "./height.ts";
5
5
  export { loadPlan, loadTerrain, type LoadJob, type LoadOptions, type Terrain, type TerrainProgress } from "./load.ts";
6
6
  export type { SurfaceState } from "./element.ts";
7
- export { landerParts, roverParts } from "./shapes.ts";
7
+ export { ascentParts, landerParts, roverParts } from "./shapes.ts";
8
+ export { calloutsBy, CALLOUTS, clockText, LANDING, landingAt, type Callout, type LandingPose } from "./landing.ts";
8
9
  export { DustField } from "./dust.ts";
9
10
  export { driveParts, driveStep, driveView, startDrive, ROVER, type DriveInput, type DriveState, type DriveView } from "./drive.ts";
10
11
  export { keepAway, objectParts, objectsOf, partShadows, traverseOf, KEEP_OUT, type Part, type SiteObject } from "./objects.ts";
@@ -4,7 +4,8 @@ export { SURFACE_SITES, siteById } from "./site.js";
4
4
  export { EYE_HEIGHT, FOV_LIMITS, WALK_SPEED, clampLook, forward, stepOver, viewProjection } from "./view.js";
5
5
  export { decodeHeight, drop, emptyLevel, fillFromCoarser, groundAt, sampleLevel, tileAddress } from "./height.js";
6
6
  export { loadPlan, loadTerrain } from "./load.js";
7
- export { landerParts, roverParts } from "./shapes.js";
7
+ export { ascentParts, landerParts, roverParts } from "./shapes.js";
8
+ export { calloutsBy, CALLOUTS, clockText, LANDING, landingAt } from "./landing.js";
8
9
  export { DustField } from "./dust.js";
9
10
  export { driveParts, driveStep, driveView, startDrive, ROVER } from "./drive.js";
10
11
  export { keepAway, objectParts, objectsOf, partShadows, traverseOf, KEEP_OUT } from "./objects.js";
@@ -21,6 +21,12 @@ export interface LandOptions {
21
21
  pitch?: number;
22
22
  fov?: number;
23
23
  };
24
+ /** `"landing"` to watch Apollo 17's powered descent once down (the real moment: its Sun and Earth, the clock from T+4:00 or T+9:00): see `watch` of the standing view. */
25
+ watch?: "landing";
26
+ /** Which camera watches: `lander` (the commander's window, the default) or `ground` (an observer standing off the touchdown point). */
27
+ watchCamera?: "lander" | "ground";
28
+ /** Where the ground camera stands, as `"150 0"`: metres from the touchdown point and the bearing in degrees clockwise from north (150 m north by default). */
29
+ watchFrom?: string;
24
30
  /** False to cut straight to the ground with no turn, no zoom and no fade (reduced motion does the same). */
25
31
  smooth?: boolean;
26
32
  /** Milliseconds to wait for the standing view to be live before giving up (20,000 by default). */
@@ -176,6 +176,14 @@ export async function land(space, siteId, options = {}) {
176
176
  veil.style.opacity = "0";
177
177
  fail(live ? "this device cannot draw the ground" : "the ground did not come in time");
178
178
  }
179
+ // watching the descent: the standing view starts it as the veil goes up, so the first thing seen is its first frame
180
+ if (options.watch === "landing") {
181
+ if (options.watchCamera !== undefined)
182
+ surface.setAttribute("watch-camera", options.watchCamera);
183
+ if (options.watchFrom !== undefined)
184
+ surface.setAttribute("watch-from", options.watchFrom);
185
+ surface.setAttribute("watch", "landing");
186
+ }
179
187
  veil.style.opacity = "0";
180
188
  if (smooth)
181
189
  await sleep(FADE_MS, landing);
@@ -0,0 +1,134 @@
1
+ /**
2
+ * The descent's fixed facts: its length in seconds, when it began in real time, where the lunar module was at ignition, and the clock the view starts at (T+4:00, where the report has the radar locked: the first
3
+ * four minutes are 530 km up-range of the ground the package has, so they are a time lapse of the clock with no ground).
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { LANDING } from "@johnmorrisdotca/wakusei-planets/surface";
8
+ *
9
+ * console.log(`${LANDING.duration} s from ${new Date(LANDING.ignition).toISOString()}`);
10
+ * ```
11
+ */
12
+ export declare const LANDING: {
13
+ /** Seconds from ignition to touchdown (the report's 12:05). */
14
+ readonly duration: 725;
15
+ /** Ignition in real time: 110:09:53 ground elapsed time, 12:05 before the touchdown at 19:54:57 UTC on 1972-12-11. */
16
+ readonly ignition: number;
17
+ /** The clock the view starts at, in seconds from ignition. */
18
+ readonly viewStart: 240;
19
+ /** At ignition (table 3-III): latitude and east longitude in degrees, altitude in metres (8.7 nautical miles), speed in m/s (5,550.3 ft/s) and heading (276.07 degrees). */
20
+ readonly start: {
21
+ readonly lat: 19.13;
22
+ readonly lon: 48.75;
23
+ readonly altitude: number;
24
+ readonly speed: number;
25
+ readonly heading: 276.07;
26
+ };
27
+ /** The ground speed the made curve ends at, and the descent rate at touchdown the report gives ("approximately 3 ft/sec"), in m/s. */
28
+ readonly touchdownDescent: number;
29
+ };
30
+ /**
31
+ * Where the lunar module is and how it moves at one moment of the descent.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { landingAt, type LandingPose } from "@johnmorrisdotca/wakusei-planets/surface";
36
+ *
37
+ * const pose: LandingPose = landingAt(600);
38
+ * console.log(`${Math.round(pose.altitude)} m up, ${pose.descent.toFixed(1)} m/s down, throttle ${pose.throttle.toFixed(2)}`);
39
+ * ```
40
+ */
41
+ export interface LandingPose {
42
+ /** Seconds from ignition. */
43
+ t: number;
44
+ /** Metres over the ground under it, and metres a second down (positive down) and along the ground. */
45
+ altitude: number;
46
+ descent: number;
47
+ speed: number;
48
+ /** Metres still to go along the ground to the touchdown point. */
49
+ toGo: number;
50
+ /** Metres east and north of the touchdown point, on the site's plane, and the heading it flies, degrees clockwise from north. */
51
+ east: number;
52
+ north: number;
53
+ heading: number;
54
+ /** The way the crew's window looks, degrees above the horizon (negative looks down), and the share of full thrust. */
55
+ pitch: number;
56
+ throttle: number;
57
+ }
58
+ /**
59
+ * The lunar module at a moment of the descent. The altitude passes through the altitudes the report names, the speed starts at the report's and covers the real distance to the touchdown point, and the rest is a
60
+ * smooth curve of ours: `east` and `north` are on a straight line back from the touchdown point toward where the descent began, in metres on the site's plane (the curve of the Moon is the ground's to take off).
61
+ *
62
+ * @param t - Seconds from ignition (held between 0 and the length of the descent).
63
+ * @returns The pose.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * import { landingAt } from "@johnmorrisdotca/wakusei-planets/surface";
68
+ *
69
+ * const high = landingAt(562);
70
+ * console.log(`${Math.round(high.altitude)} m up at the high gate, ${high.speed.toFixed(0)} m/s along, ${Math.round(high.toGo)} m to go`);
71
+ * ```
72
+ */
73
+ export declare function landingAt(t: number): LandingPose;
74
+ /**
75
+ * One event the page shows as it passes: when (seconds from ignition), what it is in English and Japanese, and whether its TIME is the report's (the altitude events are placed by us on the curve).
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { CALLOUTS, type Callout } from "@johnmorrisdotca/wakusei-planets/surface";
80
+ *
81
+ * const touchdown: Callout = CALLOUTS.find((c) => c.id === "touchdown")!;
82
+ * console.log(touchdown.en, touchdown.reported);
83
+ * ```
84
+ */
85
+ export interface Callout {
86
+ id: string;
87
+ t: number;
88
+ en: string;
89
+ ja: string;
90
+ /** True where the time comes from the report's table of events; false where it is the moment the made curve reaches the altitude the report names. */
91
+ reported: boolean;
92
+ }
93
+ /**
94
+ * The events of the descent as the report gives them (the times in its table of events) and the altitudes it names (placed on the curve), in the order they pass.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { CALLOUTS } from "@johnmorrisdotca/wakusei-planets/surface";
99
+ *
100
+ * console.log(CALLOUTS.map((c) => `T+${c.t}s ${c.en}`).join("; "));
101
+ * ```
102
+ */
103
+ export declare const CALLOUTS: readonly Callout[];
104
+ /**
105
+ * The events that have passed by a moment, the latest last.
106
+ *
107
+ * @param t - Seconds from ignition.
108
+ * @returns The events with a time at or before `t`.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { calloutsBy } from "@johnmorrisdotca/wakusei-planets/surface";
113
+ *
114
+ * console.log(calloutsBy(600).map((c) => c.id).join(", "));
115
+ * ```
116
+ */
117
+ export declare function calloutsBy(t: number): Callout[];
118
+ /**
119
+ * The clock as the page shows it: `T+04:00` from ignition, and the ground elapsed time of the mission (ignition was 110:09:53).
120
+ *
121
+ * @param t - Seconds from ignition.
122
+ * @returns The two clocks as text.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * import { clockText } from "@johnmorrisdotca/wakusei-planets/surface";
127
+ *
128
+ * console.log(clockText(240));
129
+ * ```
130
+ */
131
+ export declare function clockText(t: number): {
132
+ t: string;
133
+ get: string;
134
+ };
@@ -0,0 +1,237 @@
1
+ // Apollo 17's powered descent as a function of time: where the lunar module is, how high, how fast and which way it points at each second from ignition to touchdown. What is REAL is what the Apollo 17 Mission
2
+ // Report (NASA, JSC-07904, NTRS 19730015117) prints: the times of the events (table 8-VI), the state at ignition (table 3-III: place, altitude, speed, heading), the altitudes it names in words (30,000 ft after the radar
3
+ // locked, 13,000 ft, pitchover at about 7,500 ft, manual takeover just under 300 ft, dust at 60 to 70 ft, touchdown at about 3 ft/s) and the place of touchdown. What is MADE is the smooth curve through those moments
4
+ // (the report prints no full table), the path on the ground between the start and the end, the attitude between events and the throttle. The page says so. Pure: no DOM.
5
+ const FT = 0.3048;
6
+ const NMI = 1852;
7
+ const R_MOON = 1_737_400;
8
+ /**
9
+ * The descent's fixed facts: its length in seconds, when it began in real time, where the lunar module was at ignition, and the clock the view starts at (T+4:00, where the report has the radar locked: the first
10
+ * four minutes are 530 km up-range of the ground the package has, so they are a time lapse of the clock with no ground).
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { LANDING } from "@johnmorrisdotca/wakusei-planets/surface";
15
+ *
16
+ * console.log(`${LANDING.duration} s from ${new Date(LANDING.ignition).toISOString()}`);
17
+ * ```
18
+ */
19
+ export const LANDING = {
20
+ /** Seconds from ignition to touchdown (the report's 12:05). */
21
+ duration: 725,
22
+ /** Ignition in real time: 110:09:53 ground elapsed time, 12:05 before the touchdown at 19:54:57 UTC on 1972-12-11. */
23
+ ignition: Date.UTC(1972, 11, 11, 19, 42, 52),
24
+ /** The clock the view starts at, in seconds from ignition. */
25
+ viewStart: 240,
26
+ /** At ignition (table 3-III): latitude and east longitude in degrees, altitude in metres (8.7 nautical miles), speed in m/s (5,550.3 ft/s) and heading (276.07 degrees). */
27
+ start: { lat: 19.13, lon: 48.75, altitude: 8.7 * NMI, speed: 5550.3 * FT, heading: 276.07 },
28
+ /** The ground speed the made curve ends at, and the descent rate at touchdown the report gives ("approximately 3 ft/sec"), in m/s. */
29
+ touchdownDescent: 3 * FT,
30
+ };
31
+ // The altitude through the moments the report names; the times of those it gives no clock for (30,000 ft, 13,000 ft, manual takeover, dust) are placed by us between the times it does give.
32
+ const ALTITUDE = [
33
+ [0, LANDING.start.altitude],
34
+ [255, 30_000 * FT],
35
+ [500, 13_000 * FT],
36
+ [562, 7_500 * FT],
37
+ [658, 152],
38
+ [678, 90],
39
+ [715, 20],
40
+ [722, 2.5],
41
+ [725, 0],
42
+ ];
43
+ // The speed along the ground: the start is the report's, the end is "near zero", the rest is made to fall smoothly and to cover the real distance from the start to the touchdown (the weights below are scaled to it).
44
+ const SPEED_SHAPE = [
45
+ [0, LANDING.start.speed],
46
+ [120, 1370],
47
+ [255, 1000],
48
+ [446, 430],
49
+ [562, 60],
50
+ [658, 8],
51
+ [700, 1.5],
52
+ [725, 0.5],
53
+ ];
54
+ /** A piecewise cubic through points that never overshoots (Fritsch-Carlson), as a function of t. */
55
+ function monotone(points) {
56
+ const n = points.length;
57
+ const h = [];
58
+ const d = [];
59
+ for (let i = 0; i < n - 1; i += 1) {
60
+ h.push(points[i + 1][0] - points[i][0]);
61
+ d.push((points[i + 1][1] - points[i][1]) / h[i]);
62
+ }
63
+ const m = new Array(n).fill(0);
64
+ m[0] = d[0];
65
+ m[n - 1] = d[n - 2];
66
+ for (let i = 1; i < n - 1; i += 1) {
67
+ if (d[i - 1] * d[i] <= 0)
68
+ m[i] = 0;
69
+ else {
70
+ const w1 = 2 * h[i] + h[i - 1];
71
+ const w2 = h[i] + 2 * h[i - 1];
72
+ m[i] = (w1 + w2) / (w1 / d[i - 1] + w2 / d[i]);
73
+ }
74
+ }
75
+ return (t) => {
76
+ if (t <= points[0][0])
77
+ return points[0][1];
78
+ if (t >= points[n - 1][0])
79
+ return points[n - 1][1];
80
+ let i = 0;
81
+ while (t > points[i + 1][0])
82
+ i += 1;
83
+ const s = (t - points[i][0]) / h[i];
84
+ const [s2, s3] = [s * s, s * s * s];
85
+ return (2 * s3 - 3 * s2 + 1) * points[i][1] + (s3 - 2 * s2 + s) * h[i] * m[i] + (-2 * s3 + 3 * s2) * points[i + 1][1] + (s3 - s2) * h[i] * m[i + 1];
86
+ };
87
+ }
88
+ /** The great-circle distance in metres between two places on the Moon given in degrees (a sphere of 1,737.4 km). */
89
+ function distance(lat1, lon1, lat2, lon2) {
90
+ const [p1, p2, dl] = [(lat1 * Math.PI) / 180, (lat2 * Math.PI) / 180, ((lon2 - lon1) * Math.PI) / 180];
91
+ const a = Math.sin(p1) * Math.sin(p2) + Math.cos(p1) * Math.cos(p2) * Math.cos(dl);
92
+ return R_MOON * Math.acos(Math.min(1, Math.max(-1, a)));
93
+ }
94
+ /** The place of touchdown the report gives is the lunar module's own place in the package (the orbiter's picture of it): the site point of Apollo 17 as the places list has it. */
95
+ const SITE = { lat: 20.1911, lon: 30.7723 };
96
+ const altitudeAt = monotone(ALTITUDE);
97
+ const DISTANCE = distance(LANDING.start.lat, LANDING.start.lon, SITE.lat, SITE.lon);
98
+ /** The speed curve scaled in its middle so that it covers the real distance from ignition to touchdown, and the distance still to go at each second. */
99
+ const { speedAt, toGoAt } = (() => {
100
+ const total = (k) => {
101
+ const shape = SPEED_SHAPE.map(([t, v], i) => (i === 0 || i === SPEED_SHAPE.length - 1 ? [t, v] : [t, v * k]));
102
+ const f = monotone(shape);
103
+ const to = new Array(LANDING.duration + 1).fill(0);
104
+ for (let t = LANDING.duration - 1; t >= 0; t -= 1)
105
+ to[t] = to[t + 1] + (f(t) + f(t + 1)) / 2;
106
+ return { f, to };
107
+ };
108
+ let [lo, hi] = [0.5, 1.5];
109
+ for (let i = 0; i < 50; i += 1) {
110
+ const mid = (lo + hi) / 2;
111
+ if (total(mid).to[0] < DISTANCE)
112
+ lo = mid;
113
+ else
114
+ hi = mid;
115
+ }
116
+ const fit = total((lo + hi) / 2);
117
+ return {
118
+ speedAt: fit.f,
119
+ toGoAt: (t) => {
120
+ const c = Math.min(Math.max(t, 0), LANDING.duration);
121
+ const i = Math.min(LANDING.duration - 1, Math.floor(c));
122
+ return fit.to[i] - (fit.to[i] - fit.to[i + 1]) * (c - i);
123
+ },
124
+ };
125
+ })();
126
+ /** The direction from the touchdown back to the start of the descent on the site's plane (east, north), and the heading flown, from the two places. */
127
+ const BACK = (() => {
128
+ const dLat = SITE.lat - LANDING.start.lat;
129
+ const north = -R_MOON * (dLat * Math.PI) / 180;
130
+ const east = R_MOON * Math.cos(((SITE.lat + LANDING.start.lat) / 2 * Math.PI) / 180) * (((LANDING.start.lon - SITE.lon) * Math.PI) / 180);
131
+ const length = Math.hypot(east, north);
132
+ return { east: east / length, north: north / length, heading: ((Math.atan2(-east, -north) * 180) / Math.PI + 360) % 360 };
133
+ })();
134
+ /**
135
+ * The lunar module at a moment of the descent. The altitude passes through the altitudes the report names, the speed starts at the report's and covers the real distance to the touchdown point, and the rest is a
136
+ * smooth curve of ours: `east` and `north` are on a straight line back from the touchdown point toward where the descent began, in metres on the site's plane (the curve of the Moon is the ground's to take off).
137
+ *
138
+ * @param t - Seconds from ignition (held between 0 and the length of the descent).
139
+ * @returns The pose.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { landingAt } from "@johnmorrisdotca/wakusei-planets/surface";
144
+ *
145
+ * const high = landingAt(562);
146
+ * console.log(`${Math.round(high.altitude)} m up at the high gate, ${high.speed.toFixed(0)} m/s along, ${Math.round(high.toGo)} m to go`);
147
+ * ```
148
+ */
149
+ export function landingAt(t) {
150
+ const c = Math.min(Math.max(t, 0), LANDING.duration);
151
+ const altitude = altitudeAt(c);
152
+ const ce = Math.min(Math.max(c, 0.25), LANDING.duration - 0.25);
153
+ const descent = -(altitudeAt(ce + 0.25) - altitudeAt(ce - 0.25)) / 0.5;
154
+ const toGo = toGoAt(c);
155
+ // the window: level in the braking, then the pitchover to look down at the site from the high gate, easing toward the horizon near the ground
156
+ const ease = (a, b, from, to) => {
157
+ const s = Math.min(1, Math.max(0, (c - from) / (to - from)));
158
+ return a + (b - a) * (s * s * (3 - 2 * s));
159
+ };
160
+ const pitch = c < 562 ? ease(10, 14, 0, 562) : c < 658 ? ease(14, -38, 562, 590) : ease(-38, -20, 658, 725);
161
+ const throttle = c < 28 ? 0.1 + 0.9 * (c / 28) : c < 446 ? 1 : c < 562 ? 0.57 : 0.34 + 0.12 * Math.sin(c / 7);
162
+ return {
163
+ t: c,
164
+ altitude,
165
+ descent,
166
+ speed: speedAt(c),
167
+ toGo,
168
+ east: BACK.east * toGo,
169
+ north: BACK.north * toGo,
170
+ heading: BACK.heading,
171
+ pitch,
172
+ throttle,
173
+ };
174
+ }
175
+ const when = (altitude) => {
176
+ let t = 0;
177
+ while (t < LANDING.duration && altitudeAt(t) > altitude)
178
+ t += 0.5;
179
+ return t;
180
+ };
181
+ /**
182
+ * The events of the descent as the report gives them (the times in its table of events) and the altitudes it names (placed on the curve), in the order they pass.
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * import { CALLOUTS } from "@johnmorrisdotca/wakusei-planets/surface";
187
+ *
188
+ * console.log(CALLOUTS.map((c) => `T+${c.t}s ${c.en}`).join("; "));
189
+ * ```
190
+ */
191
+ export const CALLOUTS = [
192
+ { id: "ignition", t: 0, en: "Descent engine ignition", ja: "降下エンジン点火", reported: true },
193
+ { id: "full", t: 28, en: "Full throttle", ja: "全開", reported: true },
194
+ { id: "radar", t: 215, en: "Landing radar locks on", ja: "着陸レーダーが捉える", reported: true },
195
+ { id: "throttle", t: 446, en: "Throttle down", ja: "スロットルを絞る", reported: true },
196
+ { id: "high-gate", t: 562, en: "High gate: the approach phase, pitchover at about 7,500 ft", ja: "ハイゲート:進入フェーズ、高度約7,500フィートでピッチオーバー", reported: true },
197
+ { id: "redesignation", t: 573, en: "First landing-point redesignation (eight in all)", ja: "最初の着陸点の変更(全部で8回)", reported: true },
198
+ { id: "low-gate", t: 658, en: "Low gate: the landing phase", ja: "ローゲート:着陸フェーズ", reported: true },
199
+ { id: "manual", t: when(300 * FT), en: "The Commander takes over by hand, just under 300 ft", ja: "司令官が手動操縦に切り替え(高度約300フィート未満)", reported: false },
200
+ { id: "dust", t: when(70 * FT), en: "Dust first seen, at 60 to 70 ft", ja: "砂ぼこりが見え始める(高度60〜70フィート)", reported: false },
201
+ { id: "touchdown", t: LANDING.duration, en: "Touchdown, 12:05 after ignition, at about 3 ft/s down", ja: "着陸(点火から12分5秒、降下速度は毎秒約3フィート)", reported: true },
202
+ ];
203
+ /**
204
+ * The events that have passed by a moment, the latest last.
205
+ *
206
+ * @param t - Seconds from ignition.
207
+ * @returns The events with a time at or before `t`.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * import { calloutsBy } from "@johnmorrisdotca/wakusei-planets/surface";
212
+ *
213
+ * console.log(calloutsBy(600).map((c) => c.id).join(", "));
214
+ * ```
215
+ */
216
+ export function calloutsBy(t) {
217
+ return CALLOUTS.filter((c) => c.t <= t + 1e-9);
218
+ }
219
+ /**
220
+ * The clock as the page shows it: `T+04:00` from ignition, and the ground elapsed time of the mission (ignition was 110:09:53).
221
+ *
222
+ * @param t - Seconds from ignition.
223
+ * @returns The two clocks as text.
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * import { clockText } from "@johnmorrisdotca/wakusei-planets/surface";
228
+ *
229
+ * console.log(clockText(240));
230
+ * ```
231
+ */
232
+ export function clockText(t) {
233
+ const two = (n) => String(Math.floor(n)).padStart(2, "0");
234
+ const s = Math.max(0, Math.floor(t));
235
+ const g = 110 * 3600 + 9 * 60 + 53 + s;
236
+ return { t: `T+${two(s / 60)}:${two(s % 60)}`, get: `${Math.floor(g / 3600)}:${two((g % 3600) / 60)}:${two(g % 60)}` };
237
+ }
@@ -31,6 +31,15 @@ export interface SurfaceState {
31
31
  vehicle?: DriveState;
32
32
  /** The path the driven rover has left, east, north, east, north, ... in metres: drawn as tracks. */
33
33
  trail?: readonly number[];
34
+ /** The lunar module coming down (Apollo 17's descent): where it is, how high over the ground under it, which way it flies and the share of full thrust; drawn whole, with its plume, in place of the one standing at its place. */
35
+ lander?: {
36
+ east: number;
37
+ north: number;
38
+ altitude: number;
39
+ heading: number;
40
+ throttle: number;
41
+ inside?: boolean;
42
+ };
34
43
  /** The grains of dust in flight, east, up, north for each (`DustField.position`), drawn as small squares. */
35
44
  dust?: Float32Array;
36
45
  /** Whether the things at the site (the lander, the rover, the flag, the station) and the rover's tracks are drawn (default true; the made ground keeps away from them while they are). */
@@ -1,6 +1,7 @@
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 } 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 } from "./glsl.js";
3
3
  import { driveParts } from "./drive.js";
4
+ import { placePart, ascentParts, landerParts } from "./shapes.js";
4
5
  import { KEEP_OUT, objectParts, partShadows } from "./objects.js";
5
6
  import { rockMesh } from "./rocks.js";
6
7
  import { cameraAxes, viewProjection } from "./view.js";
@@ -236,7 +237,7 @@ export function createSurfaceItem(options) {
236
237
  trackMesh.visible = on;
237
238
  if (!on || ground === undefined)
238
239
  return;
239
- const key = `${state.sky.sun.azimuth.toFixed(1)}|${state.sky.sun.altitude.toFixed(1)}|${objectVersion}|${driving}|${state.shadows !== false}`;
240
+ const key = `${state.sky.sun.azimuth.toFixed(1)}|${state.sky.sun.altitude.toFixed(1)}|${objectVersion}|${driving}|${state.shadows !== false}|${state.lander !== undefined}`;
240
241
  if (key === objectKey)
241
242
  return;
242
243
  objectKey = key;
@@ -248,6 +249,8 @@ export function createSurfaceItem(options) {
248
249
  for (const object of list) {
249
250
  if (driving && object.kind === "rover")
250
251
  continue;
252
+ if (state.lander !== undefined && object.kind === "lander")
253
+ continue;
251
254
  const base = ground(object.east, object.north);
252
255
  const parts = objectParts(object, base);
253
256
  for (const part of parts) {
@@ -470,7 +473,7 @@ export function createSurfaceItem(options) {
470
473
  // the dust: one small square for each grain in the pool, in the corners of a fixed set of triangles
471
474
  let dustMesh;
472
475
  let dustMaterial;
473
- const dustUniforms = { uVP: uniforms.uVP, uRight: { value: new T.Vector3(1, 0, 0) }, uUp: { value: new T.Vector3(0, 1, 0) }, uSize: { value: 0.022 } };
476
+ const dustUniforms = { uVP: uniforms.uVP, uRight: { value: new T.Vector3(1, 0, 0) }, uUp: { value: new T.Vector3(0, 1, 0) }, uSize: { value: 0.022 }, uEyeWorld: { value: new T.Vector3() }, uMinAngle: { value: 0 } };
474
477
  const makeDust = (state) => {
475
478
  const grains = state.dust;
476
479
  if (grains === undefined) {
@@ -506,8 +509,105 @@ export function createSurfaceItem(options) {
506
509
  const axes = cameraAxes(state.look);
507
510
  dustUniforms.uRight.value.set(axes.right[0], axes.right[1], axes.right[2]);
508
511
  dustUniforms.uUp.value.set(axes.up[0], axes.up[1], axes.up[2]);
512
+ dustUniforms.uSize.value = state.lander === undefined ? 0.022 : 0.09;
513
+ dustUniforms.uEyeWorld.value.set(state.eye.east, state.eye.up, -state.eye.north);
514
+ dustUniforms.uMinAngle.value = state.lander === undefined ? 0 : 2.6 * fullPixel; // seen from far off a grain still shows as about two pixels // a blast's grains are thrown wider and bigger than a wheel's
509
515
  dustMesh.visible = true;
510
516
  };
517
+ // the lunar module coming down: its parts placed at each draw (a few thousand corners), its shadow on the ground far below it, and its plume
518
+ let landerMesh;
519
+ let landerShadow;
520
+ let plumeMesh;
521
+ let plumeMaterial;
522
+ const plumeUniforms = { uVP: uniforms.uVP, uBell: { value: new T.Vector3() }, uLength: { value: 5 }, uRadius: { value: 2 }, uPlume: { value: 1 } };
523
+ const landerLocal = [...landerParts(), ...ascentParts()];
524
+ const landerVertices = landerLocal.reduce((n, part) => n + part.position.length / 3, 0);
525
+ const makeLander = (state) => {
526
+ const l = state.lander;
527
+ const groundOf = options.groundY;
528
+ if (l === undefined || groundOf === undefined) {
529
+ if (landerMesh !== undefined)
530
+ landerMesh.visible = false;
531
+ if (landerShadow !== undefined)
532
+ landerShadow.visible = false;
533
+ if (plumeMesh !== undefined)
534
+ plumeMesh.visible = false;
535
+ return;
536
+ }
537
+ const base = groundOf(l.east, l.north);
538
+ const turn = (l.heading * Math.PI) / 180;
539
+ const parts = landerLocal.map((part) => placePart(part, l.east, base + l.altitude, l.north, turn));
540
+ if (landerMesh === undefined) {
541
+ const geometry = new T.BufferGeometry();
542
+ geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(landerVertices * 3), 3));
543
+ geometry.setAttribute("normal", new T.BufferAttribute(new Float32Array(landerVertices * 3), 3));
544
+ const tone = new Float32Array(landerVertices);
545
+ const tint = new Float32Array(landerVertices * 3);
546
+ let at = 0;
547
+ for (const part of parts) {
548
+ for (let i = 0; i < part.position.length / 3; i += 1) {
549
+ tone[at] = part.tone;
550
+ tint.set(part.colour ?? [1, 1, 1], at * 3);
551
+ at += 1;
552
+ }
553
+ }
554
+ geometry.setAttribute("tone", new T.BufferAttribute(tone, 1));
555
+ geometry.setAttribute("tint", new T.BufferAttribute(tint, 3));
556
+ landerMesh = new T.Mesh(geometry, objectMaterial);
557
+ landerMesh.frustumCulled = false;
558
+ landerMesh.renderOrder = 1;
559
+ scene.add(landerMesh);
560
+ // the plume: a fixed cone of 24 by 12 corners, sized and placed by uniforms
561
+ const pos = [];
562
+ const index = [];
563
+ for (let j = 0; j <= 12; j += 1)
564
+ for (let i = 0; i <= 24; i += 1)
565
+ pos.push(i / 24, j / 12, 0);
566
+ for (let j = 0; j < 12; j += 1)
567
+ for (let i = 0; i < 24; i += 1)
568
+ index.push(j * 25 + i, j * 25 + i + 1, (j + 1) * 25 + i, j * 25 + i + 1, (j + 1) * 25 + i + 1, (j + 1) * 25 + i);
569
+ const cone = new T.BufferGeometry();
570
+ cone.setAttribute("position", new T.BufferAttribute(new Float32Array(pos), 3));
571
+ cone.setIndex(new T.BufferAttribute(new Uint16Array(index), 1));
572
+ plumeMaterial = new T.ShaderMaterial({ vertexShader: PLUME_VERTEX, fragmentShader: PLUME_FRAGMENT, uniforms: plumeUniforms, transparent: true, depthWrite: false, side: 2 });
573
+ plumeMesh = new T.Mesh(cone, plumeMaterial);
574
+ plumeMesh.frustumCulled = false;
575
+ plumeMesh.renderOrder = 4;
576
+ scene.add(plumeMesh);
577
+ }
578
+ const position = landerMesh.geometry.getAttribute("position");
579
+ const normal = landerMesh.geometry.getAttribute("normal");
580
+ let at = 0;
581
+ for (const part of parts) {
582
+ position.array.set(part.position, at * 3);
583
+ normal.array.set(part.normal, at * 3);
584
+ at += part.position.length / 3;
585
+ }
586
+ position.needsUpdate = true;
587
+ normal.needsUpdate = true;
588
+ landerMesh.visible = l.inside !== true;
589
+ const shadow = state.shadows === false ? [] : partShadows(parts, base, state.sky.sun.azimuth, state.sky.sun.altitude);
590
+ const shadowGeometry = new T.BufferGeometry();
591
+ shadowGeometry.setAttribute("position", new T.BufferAttribute(new Float32Array(shadow), 3));
592
+ shadowGeometry.setAttribute("uv", new T.BufferAttribute(new Float32Array((shadow.length / 3) * 2).map((_, i) => (i % 2 === 1 ? 0 : 0.5)), 2));
593
+ if (landerShadow === undefined) {
594
+ landerShadow = new T.Mesh(shadowGeometry, shadowMaterial);
595
+ landerShadow.frustumCulled = false;
596
+ landerShadow.renderOrder = 2;
597
+ scene.add(landerShadow);
598
+ }
599
+ else {
600
+ landerShadow.geometry.dispose();
601
+ landerShadow.geometry = shadowGeometry;
602
+ }
603
+ landerShadow.visible = true;
604
+ // the bell's exit is 0.3 m up; the plume reaches farther and wider the harder the engine works
605
+ plumeUniforms.uBell.value.set(l.east, base + l.altitude + 0.3, l.north);
606
+ plumeUniforms.uLength.value = 3 + 9 * l.throttle;
607
+ plumeUniforms.uRadius.value = 1.3 + 2.6 * l.throttle;
608
+ plumeUniforms.uPlume.value = l.throttle;
609
+ plumeMesh.visible = l.throttle > 0.02 && l.inside !== true;
610
+ };
511
611
  let measuring = false;
512
612
  let drawMs;
513
613
  let aspect = context.width / Math.max(1, context.height);
@@ -522,6 +622,7 @@ export function createSurfaceItem(options) {
522
622
  makeRocks(state);
523
623
  makeObjects(state);
524
624
  makeVehicle(state);
625
+ makeLander(state);
525
626
  makeTrail(state);
526
627
  makeDust(state);
527
628
  measuring = state.measure === true;
@@ -661,6 +762,10 @@ export function createSurfaceItem(options) {
661
762
  vehicleShadow?.geometry.dispose();
662
763
  trailMesh?.geometry.dispose();
663
764
  dustMesh?.geometry.dispose();
765
+ landerMesh?.geometry.dispose();
766
+ landerShadow?.geometry.dispose();
767
+ plumeMesh?.geometry.dispose();
768
+ plumeMaterial?.dispose();
664
769
  trailMaterialDriven?.dispose();
665
770
  dustMaterial?.dispose();
666
771
  objectMaterial.dispose();
@@ -60,3 +60,17 @@ export declare function landerParts(): Part[];
60
60
  * ```
61
61
  */
62
62
  export declare function roverParts(): Part[];
63
+ /**
64
+ * The lunar module's ascent stage in the same frame as `landerParts` (it sits on the descent stage's deck, 3.2 m up): the cabin, its two triangular windows, the hatch section on top with the docking tunnel, the four
65
+ * thruster quads at its corners, the rendezvous radar on its boom and the antenna. Plain shapes from the published sizes (the whole craft stands about 7 m on its legs); no mark or flag is drawn.
66
+ *
67
+ * @returns The parts.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { ascentParts } from "@johnmorrisdotca/wakusei-planets/surface";
72
+ *
73
+ * console.log(ascentParts().length, "parts");
74
+ * ```
75
+ */
76
+ export declare function ascentParts(): Part[];
@@ -245,3 +245,36 @@ export function roverParts() {
245
245
  parts.push(box([0, 0.78, -1.15], [0.9, 0.3, 0.5], 0, 1.05, 0, SILVER));
246
246
  return parts;
247
247
  }
248
+ /**
249
+ * The lunar module's ascent stage in the same frame as `landerParts` (it sits on the descent stage's deck, 3.2 m up): the cabin, its two triangular windows, the hatch section on top with the docking tunnel, the four
250
+ * thruster quads at its corners, the rendezvous radar on its boom and the antenna. Plain shapes from the published sizes (the whole craft stands about 7 m on its legs); no mark or flag is drawn.
251
+ *
252
+ * @returns The parts.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * import { ascentParts } from "@johnmorrisdotca/wakusei-planets/surface";
257
+ *
258
+ * console.log(ascentParts().length, "parts");
259
+ * ```
260
+ */
261
+ export function ascentParts() {
262
+ const parts = [];
263
+ const cabin = [0.86, 0.83, 0.76];
264
+ const dark = [0.2, 0.22, 0.26];
265
+ parts.push(box([0, 4.1, 0.1], [3.0, 1.8, 2.6], 0, 1.2, 0, cabin));
266
+ // the front face's two windows, and the hatch section with its tunnel on top
267
+ for (const x of [-0.8, 0.8])
268
+ parts.push(box([x, 4.3, 1.42], [0.5, 0.55, 0.05], 0, 0.6, 0, dark));
269
+ parts.push(box([0, 5.2, 0], [2.2, 0.7, 2.0], 0, 1.1, 0, cabin));
270
+ parts.push(cylinder([0, 5.55, 0], 0.5, 0.45, 12, 1.0, false, [0.7, 0.7, 0.72]));
271
+ // the four thruster quads at the corners of the cabin
272
+ for (const x of [-1, 1])
273
+ for (const z of [-1, 1])
274
+ parts.push(box([x * 1.65, 4.1, z * 1.2], [0.45, 0.45, 0.45], 0, 1.0, 0, [0.78, 0.78, 0.8]));
275
+ // the rendezvous radar on a boom and the antenna
276
+ parts.push(strut([0.6, 5.4, 0.2], [1.1, 6.1, 0.2], 0.06, 1.1, [0.8, 0.8, 0.82]));
277
+ parts.push(dish([1.1, 6.15, 0.2], [0.4, 0.8, 0.4], 0.35, 0.1, 10, 1.4, [0.95, 0.95, 0.97]));
278
+ parts.push(strut([-0.5, 5.4, -0.4], [-0.5, 6.4, -0.4], 0.02, 1.0, [0.5, 0.5, 0.52]));
279
+ return parts;
280
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.49.0";
1
+ export declare const VERSION = "0.50.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.49.0";
1
+ export const VERSION = "0.50.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/wakusei-planets",
3
- "version": "0.49.0",
3
+ "version": "0.50.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",