@johnmorrisdotca/wakusei-planets 0.69.0 → 0.71.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/NOTICE.md +29 -1
  3. package/README.md +20 -8
  4. package/dist/bodies/moons-jupiter.js +2 -0
  5. package/dist/bodies/moons-mars.js +2 -2
  6. package/dist/bodies/moons-neptune.js +2 -1
  7. package/dist/bodies/moons-pluto.js +2 -2
  8. package/dist/bodies/moons-saturn.js +14 -2
  9. package/dist/data/discovery.js +225 -0
  10. package/dist/data/moon-catalogue.js +15 -15
  11. package/dist/data/orbits.js +15 -0
  12. package/dist/data/shapes/amalthea.d.ts +2 -0
  13. package/dist/data/shapes/amalthea.js +1 -0
  14. package/dist/data/shapes/atlas.d.ts +2 -0
  15. package/dist/data/shapes/atlas.js +1 -0
  16. package/dist/data/shapes/calypso.d.ts +2 -0
  17. package/dist/data/shapes/calypso.js +1 -0
  18. package/dist/data/shapes/daphnis.d.ts +2 -0
  19. package/dist/data/shapes/daphnis.js +1 -0
  20. package/dist/data/shapes/deimos.d.ts +2 -0
  21. package/dist/data/shapes/deimos.js +1 -0
  22. package/dist/data/shapes/epimetheus.d.ts +2 -0
  23. package/dist/data/shapes/epimetheus.js +1 -0
  24. package/dist/data/shapes/helene.d.ts +2 -0
  25. package/dist/data/shapes/helene.js +1 -0
  26. package/dist/data/shapes/hydra.d.ts +2 -0
  27. package/dist/data/shapes/hydra.js +1 -0
  28. package/dist/data/shapes/hyperion.d.ts +2 -0
  29. package/dist/data/shapes/hyperion.js +1 -0
  30. package/dist/data/shapes/janus.d.ts +2 -0
  31. package/dist/data/shapes/janus.js +1 -0
  32. package/dist/data/shapes/larissa.d.ts +2 -0
  33. package/dist/data/shapes/larissa.js +1 -0
  34. package/dist/data/shapes/nix.d.ts +2 -0
  35. package/dist/data/shapes/nix.js +1 -0
  36. package/dist/data/shapes/pan.d.ts +2 -0
  37. package/dist/data/shapes/pan.js +1 -0
  38. package/dist/data/shapes/pandora.d.ts +2 -0
  39. package/dist/data/shapes/pandora.js +1 -0
  40. package/dist/data/shapes/phobos.d.ts +2 -0
  41. package/dist/data/shapes/phobos.js +1 -0
  42. package/dist/data/shapes/phoebe.d.ts +2 -0
  43. package/dist/data/shapes/phoebe.js +1 -0
  44. package/dist/data/shapes/prometheus.d.ts +2 -0
  45. package/dist/data/shapes/prometheus.js +1 -0
  46. package/dist/data/shapes/proteus.d.ts +2 -0
  47. package/dist/data/shapes/proteus.js +1 -0
  48. package/dist/data/shapes/telesto.d.ts +2 -0
  49. package/dist/data/shapes/telesto.js +1 -0
  50. package/dist/data/shapes/thebe.d.ts +2 -0
  51. package/dist/data/shapes/thebe.js +1 -0
  52. package/dist/discovery.d.ts +1 -1
  53. package/dist/earth-places.d.ts +7 -6
  54. package/dist/earth-places.js +11 -8
  55. package/dist/facts.d.ts +21 -4
  56. package/dist/facts.js +71 -38
  57. package/dist/index.d.ts +2 -1
  58. package/dist/index.js +2 -1
  59. package/dist/moon-catalogue.d.ts +1 -1
  60. package/dist/moon-pages/data.d.ts +157 -0
  61. package/dist/moon-pages/data.js +138 -0
  62. package/dist/moon-pages/element.d.ts +82 -0
  63. package/dist/moon-pages/element.js +670 -0
  64. package/dist/moon-pages/index.d.ts +1 -0
  65. package/dist/moon-pages/index.js +2 -0
  66. package/dist/moon-pages/words.d.ts +115 -0
  67. package/dist/moon-pages/words.js +116 -0
  68. package/dist/nearest.js +2 -0
  69. package/dist/picture-credits.js +3 -0
  70. package/dist/scene/body-places.js +4 -5
  71. package/dist/scene/body.js +10 -5
  72. package/dist/scene/earth-places.d.ts +110 -2
  73. package/dist/scene/earth-places.js +149 -9
  74. package/dist/scene/glsl.d.ts +2 -2
  75. package/dist/scene/glsl.js +11 -0
  76. package/dist/scene/look.d.ts +7 -0
  77. package/dist/scene/look.js +1 -0
  78. package/dist/scene/painter.js +18 -3
  79. package/dist/scene/recipes.js +6 -2
  80. package/dist/scene/rings.js +11 -2
  81. package/dist/scene/shape.d.ts +50 -0
  82. package/dist/scene/shape.js +110 -0
  83. package/dist/shape-basis.d.ts +43 -0
  84. package/dist/shape-basis.js +45 -0
  85. package/dist/space/all-moons.d.ts +6 -1
  86. package/dist/space/all-moons.js +5 -1
  87. package/dist/space/element.d.ts +28 -3
  88. package/dist/space/element.js +169 -40
  89. package/dist/space/orbit-lines.d.ts +66 -0
  90. package/dist/space/orbit-lines.js +118 -0
  91. package/dist/space/scale.d.ts +1 -1
  92. package/dist/space/scale.js +20 -5
  93. package/dist/space/scene.d.ts +8 -0
  94. package/dist/space/scene.js +116 -9
  95. package/dist/stops.js +12 -0
  96. package/dist/surface/element.js +3 -3
  97. package/dist/surface/glsl.d.ts +2 -2
  98. package/dist/surface/glsl.js +15 -3
  99. package/dist/surface/height.d.ts +7 -0
  100. package/dist/surface/height.js +10 -0
  101. package/dist/textures/deimos-1024.webp +0 -0
  102. package/dist/textures/deimos-512.webp +0 -0
  103. package/dist/textures/phobos-1024.webp +0 -0
  104. package/dist/textures/phobos-512.webp +0 -0
  105. package/dist/textures/phoebe-1024.webp +0 -0
  106. package/dist/textures/phoebe-512.webp +0 -0
  107. package/package.json +13 -1
@@ -0,0 +1,118 @@
1
+ // How faint the space view draws its orbit lines, and which line is under the pointer. Pure: no DOM, no clock, no three.js.
2
+ /** Up to this many lines drawn, none is made fainter for the crowd. */
3
+ export const FEW_LINES = 12;
4
+ /** The least share of its opacity a line keeps, however many are drawn and however far out the view is. */
5
+ export const LEAST_KEEP = 0.15;
6
+ /** The view is "near" at this many radii of the body it looks at, and "far out" at the second: the share of opacity falls between them on a log scale (the Earth and the Moon from a few hundred radii, the inner planets from the Sun a thousand, the whole system from the Earth a million). */
7
+ export const NEAR_RADII = 30;
8
+ export const FAR_RADII = 30_000;
9
+ /** How much of a line's opacity the farthest view takes away. */
10
+ export const FAR_LOSS = 0.5;
11
+ /**
12
+ * How far out the view is: 0 within `NEAR_RADII` of the body it looks at, 1 from `FAR_RADII`, and the log of the distance between.
13
+ *
14
+ * @param radii - The camera's distance from the body looked at, in that body's radii.
15
+ * @returns A number from 0 to 1.
16
+ */
17
+ export function outnessOf(radii) {
18
+ if (!(radii > NEAR_RADII))
19
+ return 0;
20
+ return Math.min(1, Math.log(radii / NEAR_RADII) / Math.log(FAR_RADII / NEAR_RADII));
21
+ }
22
+ /**
23
+ * The share of its opacity an orbit line keeps: all of it while few lines are drawn and the view is near, less as more are drawn (by the square root of how many times over `FEW_LINES` they are) and as the view goes out, never under `LEAST_KEEP`.
24
+ *
25
+ * @param input - `crowd`, how many lines are drawn, and `outness`, from `outnessOf`.
26
+ * @returns The share, from `LEAST_KEEP` to 1.
27
+ */
28
+ export function lineKeep(input) {
29
+ const crowded = input.crowd > FEW_LINES ? Math.sqrt(FEW_LINES / input.crowd) : 1;
30
+ const far = 1 - FAR_LOSS * Math.max(0, Math.min(1, input.outness));
31
+ return Math.max(LEAST_KEEP, crowded * far);
32
+ }
33
+ /**
34
+ * The opacity to draw an orbit line at.
35
+ *
36
+ * @param input - `base`, the opacity the kind of line has when it is alone, and what `lineKeep` takes.
37
+ * @returns The opacity, from `base * LEAST_KEEP` to `base`.
38
+ */
39
+ export const lineAlpha = (input) => input.base * lineKeep(input);
40
+ /**
41
+ * How many lines have some of their length in the picture: a line counts when one of its segments has the box it lies in over the picture (a long segment that only crosses a corner counts too).
42
+ *
43
+ * @param lines - The lines, in CSS pixels.
44
+ * @param width - The picture's width, in CSS pixels.
45
+ * @param height - The picture's height.
46
+ * @returns The number of lines in the picture.
47
+ */
48
+ export function linesInView(lines, width, height) {
49
+ let count = 0;
50
+ for (const line of lines) {
51
+ const p = line.xy;
52
+ for (let i = 0; i + 3 < p.length; i += 2) {
53
+ const ax = p[i];
54
+ const bx = p[i + 2];
55
+ if (ax !== ax || bx !== bx)
56
+ continue;
57
+ const ay = p[i + 1];
58
+ const by = p[i + 3];
59
+ if (Math.max(ax, bx) >= 0 && Math.min(ax, bx) <= width && Math.max(ay, by) >= 0 && Math.min(ay, by) <= height) {
60
+ count += 1;
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ return count;
66
+ }
67
+ /**
68
+ * The line nearest a point of the screen, within a distance. Each line is first measured by the box its points lie in (the box grown by the distance), and only a line the point is in the box of has its segments measured.
69
+ *
70
+ * @param lines - The lines on the screen.
71
+ * @param pointer - The point, in CSS pixels.
72
+ * @param tolerance - The farthest a line may be from the point, in CSS pixels.
73
+ * @returns The nearest line, or `null` when none is within the distance.
74
+ */
75
+ export function nearestLine(lines, pointer, tolerance) {
76
+ const { x, y } = pointer;
77
+ let best = null;
78
+ let bestD = tolerance;
79
+ for (const line of lines) {
80
+ const p = line.xy;
81
+ let minX = Infinity;
82
+ let minY = Infinity;
83
+ let maxX = -Infinity;
84
+ let maxY = -Infinity;
85
+ for (let i = 0; i + 1 < p.length; i += 2) {
86
+ const px = p[i];
87
+ const py = p[i + 1];
88
+ if (px < minX)
89
+ minX = px;
90
+ if (px > maxX)
91
+ maxX = px;
92
+ if (py < minY)
93
+ minY = py;
94
+ if (py > maxY)
95
+ maxY = py;
96
+ }
97
+ if (x < minX - bestD || x > maxX + bestD || y < minY - bestD || y > maxY + bestD)
98
+ continue;
99
+ for (let i = 0; i + 3 < p.length; i += 2) {
100
+ const ax = p[i];
101
+ const ay = p[i + 1];
102
+ const bx = p[i + 2];
103
+ const by = p[i + 3];
104
+ if (ax !== ax || bx !== bx)
105
+ continue;
106
+ const dx = bx - ax;
107
+ const dy = by - ay;
108
+ const length = dx * dx + dy * dy;
109
+ const t = length === 0 ? 0 : Math.max(0, Math.min(1, ((x - ax) * dx + (y - ay) * dy) / length));
110
+ const d = Math.hypot(x - (ax + t * dx), y - (ay + t * dy));
111
+ if (d <= bestD) {
112
+ best = line;
113
+ bestD = d;
114
+ }
115
+ }
116
+ }
117
+ return best;
118
+ }
@@ -126,7 +126,7 @@ type BaseBody = "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor
126
126
  */
127
127
  export declare function radiusIn(id: "sun" | "earth" | "moon" | SpacePlanet | SpaceDwarf | SpaceMinor, mode: ScaleMode): number;
128
128
  /**
129
- * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
129
+ * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same (but never inside the planet's rings: a moon that really goes through them is drawn just outside), until the farthest of the planet's moons would
130
130
  * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's,
131
131
  * and none is drawn nearer than 1.5 radii or inside the planet's rings (Mimas stays outside Saturn's, Proteus outside Neptune's), so a camera at a moon is never in the ring plane.
132
132
  *
@@ -161,21 +161,24 @@ function room(host) {
161
161
  return 0.35 * Math.min(...gaps);
162
162
  }
163
163
  const reaches = new Map();
164
- /** How far out a body's moons go, in its radii: the farthest any of them is found in a year of looks. */
164
+ /** A moon so far out beyond the others that, if it set the scale, every other moon of its planet would be crowded into a few radii: Phoebe is 183 Saturn radii away and Iapetus, the next, 58. It is drawn just past the farthest of the others. */
165
+ const OUTLIERS = new Set(["phoebe"]);
166
+ /** How far out a body's moons go, in its radii: the farthest any of them is found in a year of looks (an outlier does not count). */
165
167
  function reachOf(host) {
166
168
  let reach = reaches.get(host);
167
169
  if (reach === undefined) {
168
170
  reach = 0;
169
171
  const start = Date.UTC(2026, 0, 1);
170
172
  for (const moon of MOONS_OF[host] ?? [])
171
- for (let i = 0; i < 24; i += 1)
172
- reach = Math.max(reach, length(moonOffset(moon, start + i * 15 * 86_400_000)));
173
+ if (!OUTLIERS.has(moon))
174
+ for (let i = 0; i < 24; i += 1)
175
+ reach = Math.max(reach, length(moonOffset(moon, start + i * 15 * 86_400_000)));
173
176
  reaches.set(host, reach);
174
177
  }
175
178
  return reach;
176
179
  }
177
180
  /**
178
- * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same, until the farthest of the planet's moons would
181
+ * How far from its planet a moon is drawn, in the planet's radii, when it is really `distance` radii away. True: as it is. Compressed: the same (but never inside the planet's rings: a moon that really goes through them is drawn just outside), until the farthest of the planet's moons would
179
182
  * reach across the gap to the next planet's orbit; then every moon is drawn nearer, the farthest at about a third of the gap and the nearer ones in the order they are, so no moon's orbit crosses another planet's,
180
183
  * and none is drawn nearer than 1.5 radii or inside the planet's rings (Mimas stays outside Saturn's, Proteus outside Neptune's), so a camera at a moon is never in the ring plane.
181
184
  *
@@ -197,12 +200,18 @@ export function moonDistance(mode, host, distance) {
197
200
  const reach = reachOf(host);
198
201
  const radius = radiusIn(host, "compressed");
199
202
  const space = room(host);
203
+ // a moon that really goes inside the planet's rings (Amalthea in Jupiter's gossamer ring, Saturn's small moons round the A ring and the F ring) is drawn just outside them, in the order the moons are, in the little room between the ring and the next moon
204
+ const inner = nearestOf(host);
205
+ if (distance < inner)
206
+ return inner + 0.25 * (distance / inner) ** 8;
200
207
  if (reach === 0 || reach * radius <= space)
201
208
  return distance;
202
209
  // from the nearest a moon may be drawn (clear of the globe and its rings) out to the room's edge, in the order the moons are: a moon drawn in the ring plane, or inside the globe, put the camera riding beside it in the rings
203
210
  const near = nearestOf(host);
204
211
  const far = Math.max(space / radius, near * 1.6);
205
- return Math.min(distance, near + (far - near) * Math.sqrt(distance / reach));
212
+ // beyond the reach (an outlier) the curve flattens: a little past the farthest of the others, in the order the moons are
213
+ const t = Math.sqrt(distance / reach);
214
+ return Math.min(distance, near + (far - near) * (t <= 1 ? t : 1 + 0.15 * (1 - 1 / t)));
206
215
  }
207
216
  /** The squeezed view draws moons this many times their real size, unless a moon would pass a limit. 1 is today's size. True distances ignore it. */
208
217
  export const MOON_SIZE_DEFAULT = 2;
@@ -239,6 +248,12 @@ export function moonSizeFactor(mode, host, size, moons) {
239
248
  for (const other of moons) {
240
249
  if (other === moon)
241
250
  continue;
251
+ // a moon more than ten times the size of the other, or less than a tenth of it, is not held by it: at the same distance from the planet they may be on opposite sides (Telesto and Calypso, a sixtieth of a turn ahead of and behind Tethys, Helene beside Dione) and a speck hidden by a big moon is no loss
252
+ if (other.radius > 0 && (other.radius > moon.radius * 10 || moon.radius > other.radius * 10))
253
+ continue;
254
+ // two at the same distance (within a fiftieth of a radius: Telesto and Calypso) are side by side on the circle, not one behind the other
255
+ if (Math.abs(moon.orbit - other.orbit) < 0.02)
256
+ continue;
242
257
  cap = Math.min(cap, Math.max(moon.radius, Math.abs(moon.orbit - other.orbit) * 0.9));
243
258
  }
244
259
  factor = Math.min(factor, cap / moon.radius);
@@ -16,6 +16,7 @@ import type { SightInput } from "./sight.ts";
16
16
  import { type SpaceDwarf, type SpaceFrame, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
17
17
  import { type PaintSpec, type PaintTrail } from "../paint/trail.ts";
18
18
  import { type RideLook } from "./ride.ts";
19
+ import { type ScreenLine } from "./orbit-lines.ts";
19
20
  import { type ScaleMode } from "./scale.ts";
20
21
  import { type SunRegion } from "./regions.ts";
21
22
  import { type TravelInput, type TravelKind, type TravelPlan } from "./travel.ts";
@@ -258,7 +259,14 @@ export interface SpaceModel {
258
259
  miss: Record<string, number>;
259
260
  hidden: string[];
260
261
  faded: string[];
262
+ fade: {
263
+ crowd: number;
264
+ outness: number;
265
+ opacity: number;
266
+ };
261
267
  };
268
+ /** The orbit lines on the screen as the last draw left them (every kind, the catalogue moons' too), for a hover and a press; with `only`, the one line of that key. */
269
+ orbitPaths: (only?: string) => ScreenLine[];
262
270
  /** The arrowheads on the orbit lines at the last draw, by line: where each is and the way it points. */
263
271
  arrows: Record<string, OrbitArrow[]>;
264
272
  /** Help mode: draw, on the body looked at, the axis it turns about and a curved arrow showing which way it turns. */
@@ -1,7 +1,7 @@
1
1
  import { BODIES, MOONS_OF } from "../facts.js";
2
2
  import { createSmallBodyPoints, smallBodyPlace } from "../door/points.js";
3
3
  import { asteroidKey } from "./asteroid-ids.js";
4
- import { createMoonLayer } from "./all-moons.js";
4
+ import { createMoonLayer, MOON_ORBIT_OPACITY } from "./all-moons.js";
5
5
  import { BELT_IDS, BELTS, OORT } from "../belts/index.js";
6
6
  import { toTerrestrialTime } from "../clock.js";
7
7
  import { moonOffset, orientation } from "../scene/orient.js";
@@ -20,7 +20,9 @@ import { createPaintOverlay } from "./paint-overlay.js";
20
20
  import { createPaintTrail, groundUnder, paintMinute } from "../paint/trail.js";
21
21
  import { BALL_FRAGMENT, VERTEX } from "../scene/glsl.js";
22
22
  import { ridePose } from "./ride.js";
23
+ import { lineAlpha, linesInView, outnessOf } from "./orbit-lines.js";
23
24
  import { fadesNearBody, isOwnLine, nearBodyKeep } from "./orbit-rules.js";
25
+ import { catalogueMoonKey } from "./moon-settings.js";
24
26
  import { moonDistance, moonSizeFactor, orbitLine, placeAround, placeBodies, placeMoon, radiusIn } from "./scale.js";
25
27
  import { regionOrbits, regionView } from "./regions.js";
26
28
  import { TRAVEL_BUDGET_MS, travelPlan, travelPose } from "./travel.js";
@@ -30,9 +32,15 @@ const RAD = Math.PI / 180;
30
32
  export const FIT_DISTANCE = 4.1;
31
33
  const FOV = 35;
32
34
  const ORBIT_POINTS = 96;
35
+ /** The opacity of a planet's, a dwarf planet's, a minor body's or the Moon's orbit line, and of the Roadster's, when few lines are drawn and the view is near. */
36
+ const LINE_OPACITY = 0.55;
33
37
  const ORBIT_BODIES = ["earth", ...SPACE_PLANETS, ...SPACE_DWARFS, ...SPACE_MINORS, "moon"];
34
38
  /** A dwarf planet or a minor body is drawn once it is this many CSS pixels across its radius, or when it is the body looked at: Sedna at true scale is never anything but a speck, and its picture is not made for it. */
35
39
  const DWARF_MIN_PX = 0.4;
40
+ /** The most moons made for the first time (or made again after a change of look) in one draw. A moon's shader is compiled at the first draw it is in, and a rock moon's takes a good part of a second on a software renderer: Saturn's nineteen moons in one draw were a pause of five seconds on the Linux software renderers the tests run on (the page answered nothing meanwhile), so the moons come a few at a time, the moons the package drew first (the bigger ones) first, and the view asks for one more draw until they are all there. */
41
+ const MOON_MAKES_PER_DRAW = 3;
42
+ /** The colour of a body's orbit line, `#rrggbb`. */
43
+ const orbitColour = (id) => (id === "earth" ? "#6aa8ff" : id === "moon" ? "#c5cdd9" : BODIES[id].colour);
36
44
  /** A colour as three numbers from 0 to 1, from `#rrggbb`. */
37
45
  const rgb = (hex) => [parseInt(hex.slice(1, 3), 16) / 255, parseInt(hex.slice(3, 5), 16) / 255, parseInt(hex.slice(5, 7), 16) / 255];
38
46
  /** How long each arrowhead on an orbit line is, in CSS pixels: small, so it reads at every zoom and never hides a body. */
@@ -153,7 +161,8 @@ export const newSpaceModel = () => ({
153
161
  drawn: null,
154
162
  painted: { bodies: 0, moons: 0, held: 0 },
155
163
  tiles: { requested: 0, loading: 0, failed: 0, shown: null },
156
- rings: { drawn: [], miss: {}, hidden: [], faded: [] },
164
+ rings: { drawn: [], miss: {}, hidden: [], faded: [], fade: { crowd: 0, outness: 0, opacity: LINE_OPACITY } },
165
+ orbitPaths: () => [],
157
166
  arrows: {},
158
167
  help: false,
159
168
  helpThrough: false,
@@ -329,13 +338,13 @@ export function createSpaceItem(model, deps) {
329
338
  for (const id of ORBIT_BODIES) {
330
339
  const positions = new Float32Array((ORBIT_POINTS + 1) * 3);
331
340
  const colours = new Float32Array((ORBIT_POINTS + 1) * 4);
332
- const base = rgb(id === "earth" ? "#6aa8ff" : id === "moon" ? "#c5cdd9" : BODIES[id].colour);
341
+ const base = rgb(orbitColour(id));
333
342
  for (let i = 0; i <= ORBIT_POINTS; i += 1)
334
343
  colours.set([base[0], base[1], base[2], 1], i * 4);
335
344
  const geometry = new three.BufferGeometry();
336
345
  geometry.setAttribute("position", new three.BufferAttribute(positions, 3));
337
346
  geometry.setAttribute("color", new three.BufferAttribute(colours, 4));
338
- const line = new three.Line(geometry, new three.LineBasicMaterial({ vertexColors: true, transparent: true, opacity: 0.55 }));
347
+ const line = new three.Line(geometry, new three.LineBasicMaterial({ vertexColors: true, transparent: true, opacity: LINE_OPACITY }));
339
348
  line.frustumCulled = false;
340
349
  scene.add(line);
341
350
  orbits.set(id, { line, positions, colours, faded: false, samples: [], epoch: Number.NaN });
@@ -351,7 +360,7 @@ export function createSpaceItem(model, deps) {
351
360
  arrowLines.frustumCulled = false;
352
361
  scene.add(arrowLines);
353
362
  ORBIT_BODIES.forEach((id, k) => {
354
- const c = rgb(id === "earth" ? "#6aa8ff" : id === "moon" ? "#c5cdd9" : BODIES[id].colour);
363
+ const c = rgb(orbitColour(id));
355
364
  for (let v = 0; v < MAX_ARROWS_PER_ORBIT * 4; v += 1)
356
365
  arrowColours.set(c, (k * MAX_ARROWS_PER_ORBIT * 4 + v) * 3);
357
366
  });
@@ -385,7 +394,7 @@ export function createSpaceItem(model, deps) {
385
394
  const roadsterPositions = new Float32Array((ORBIT_POINTS + 1) * 3);
386
395
  const roadsterLineGeometry = new three.BufferGeometry();
387
396
  roadsterLineGeometry.setAttribute("position", new three.BufferAttribute(roadsterPositions, 3));
388
- const roadsterLine = new three.Line(roadsterLineGeometry, new three.LineBasicMaterial({ color: 0xe8705a, transparent: true, opacity: 0.55 }));
397
+ const roadsterLine = new three.Line(roadsterLineGeometry, new three.LineBasicMaterial({ color: 0xe8705a, transparent: true, opacity: LINE_OPACITY }));
389
398
  roadsterLine.visible = false;
390
399
  roadsterLine.frustumCulled = false;
391
400
  scene.add(roadsterLine);
@@ -421,7 +430,7 @@ export function createSpaceItem(model, deps) {
421
430
  const line = new three.Line(geometry, lineMaterial);
422
431
  line.frustumCulled = false;
423
432
  scene.add(line);
424
- drawing = { mesh, material, line, lineMaterial, positions, epoch: Number.NaN };
433
+ drawing = { mesh, material, line, lineMaterial, positions, epoch: Number.NaN, base: 0.4, chosen: false };
425
434
  orbiterDrawings.set(id, drawing);
426
435
  return drawing;
427
436
  };
@@ -441,6 +450,69 @@ export function createSpaceItem(model, deps) {
441
450
  return null;
442
451
  return { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height };
443
452
  };
453
+ // The orbit lines of every kind as the screen shows them, for a hover and a press: worked out when asked (a pointer move, a press), from the places the last draw left. A draw works out the planets' and craft's own (a
454
+ // few thousand points) to count the lines in the picture, never the catalogue moons'. A line is broken
455
+ // where it is behind the camera or outside its depth range; the catalogue moons' lines are cut from their planet's one object, a moon a line.
456
+ const pathsOf = (which, only) => {
457
+ const a = camera.projectionMatrix.elements;
458
+ const b = camera.matrixWorldInverse.elements;
459
+ const m = new Float64Array(16);
460
+ for (let c = 0; c < 4; c += 1)
461
+ for (let r = 0; r < 4; r += 1)
462
+ m[c * 4 + r] = a[r] * b[c * 4] + a[4 + r] * b[c * 4 + 1] + a[8 + r] * b[c * 4 + 2] + a[12 + r] * b[c * 4 + 3];
463
+ const out = [];
464
+ const trace = (id, colour, positions, count, vertexAt, at, scale, fades) => {
465
+ if (only !== undefined && only !== id)
466
+ return;
467
+ const xy = new Float32Array(count * 2);
468
+ for (let k = 0; k < count; k += 1) {
469
+ const v = vertexAt(k) * 3;
470
+ const x = at[0] + positions[v] * scale;
471
+ const y = at[1] + positions[v + 1] * scale;
472
+ const z = at[2] + positions[v + 2] * scale;
473
+ const w = m[3] * x + m[7] * y + m[11] * z + m[15];
474
+ const depth = m[2] * x + m[6] * y + m[10] * z + m[14];
475
+ // a point of a line that has been let go near the close body is not there to be pointed at
476
+ if (!(w > 1e-12) || depth > w || depth < -w || (fades !== undefined && fades[k * 4 + 3] < 0.1)) {
477
+ xy[k * 2] = Number.NaN;
478
+ xy[k * 2 + 1] = Number.NaN;
479
+ continue;
480
+ }
481
+ xy[k * 2] = (((m[0] * x + m[4] * y + m[8] * z + m[12]) / w + 1) / 2) * size.width;
482
+ xy[k * 2 + 1] = ((1 - (m[1] * x + m[5] * y + m[9] * z + m[13]) / w) / 2) * size.height;
483
+ }
484
+ out.push({ id, colour, xy });
485
+ };
486
+ const origin0 = [0, 0, 0];
487
+ for (const id of ORBIT_BODIES) {
488
+ const o = orbits.get(id);
489
+ if (o.line.visible)
490
+ trace(id, orbitColour(id), o.positions, ORBIT_POINTS + 1, (k) => k, origin0, 1, o.colours);
491
+ }
492
+ if (roadsterLine.visible)
493
+ trace("roadster", "#e8705a", roadsterPositions, ORBIT_POINTS + 1, (k) => k, origin0, 1);
494
+ for (const [id, drawing] of orbiterDrawings)
495
+ if (drawing.line.visible)
496
+ trace(id, "#9fd0ff", drawing.positions, ORBIT_POINTS + 1, (k) => k, [drawing.line.position.x, drawing.line.position.y, drawing.line.position.z], drawing.line.scale.x);
497
+ if (which === "all" && moonLayer !== undefined) {
498
+ for (const host of model.moonHosts) {
499
+ const object = moonLayer.orbitObject(host);
500
+ if (object === undefined || !object.visible)
501
+ continue;
502
+ const positions = object.geometry.getAttribute("position").array;
503
+ const at = [object.position.x, object.position.y, object.position.z];
504
+ let first = 0;
505
+ for (const moon of moonLayer.orbitMoons(host)) {
506
+ const start = first;
507
+ first += moon.segments;
508
+ // a segment is two vertices: the first of each, then the last of the last
509
+ trace(catalogueMoonKey(moon.id), moon.colour, positions, moon.segments + 1, (k) => (k < moon.segments ? 2 * (start + k) : 2 * (start + moon.segments - 1) + 1), at, object.scale.x);
510
+ }
511
+ }
512
+ }
513
+ return out;
514
+ };
515
+ model.orbitPaths = (only) => pathsOf("all", only);
444
516
  return {
445
517
  scene,
446
518
  camera,
@@ -930,7 +1002,7 @@ export function createSpaceItem(model, deps) {
930
1002
  drawnRings.push(id);
931
1003
  miss[id] = distanceToLine(pos[id], line) / radius;
932
1004
  }
933
- model.rings = { drawn: drawnRings, miss, hidden: hiddenRings, faded: fadedRings };
1005
+ model.rings = { drawn: drawnRings, miss, hidden: hiddenRings, faded: fadedRings, fade: model.rings.fade };
934
1006
  // Starman and the Roadster: where the table puts the car, in the same mapping as the planets, as a dot a few pixels across, on its orbit line (about one trip round the Sun, from the table, worked out again every month)
935
1007
  const path = model.roadster ? model.roadsterPath : null;
936
1008
  let roadsterAt = null;
@@ -1050,7 +1122,8 @@ export function createSpaceItem(model, deps) {
1050
1122
  // the line is in the body's radii round the origin: placed and scaled with the body
1051
1123
  drawing.line.position.set(pos[centre][0], pos[centre][1], pos[centre][2]);
1052
1124
  drawing.line.scale.setScalar(hostRadius);
1053
- drawing.lineMaterial.opacity = chosen ? (dim ? 0.5 : 0.85) : dim ? 0.2 : 0.4;
1125
+ drawing.base = chosen ? (dim ? 0.5 : 0.85) : dim ? 0.2 : 0.4;
1126
+ drawing.chosen = chosen;
1054
1127
  drawing.line.visible = model.orbiterLines === "all" || (model.orbiterLines === "chosen" && chosen);
1055
1128
  if (drawing.line.visible)
1056
1129
  linesDrawn += 1;
@@ -1093,6 +1166,24 @@ export function createSpaceItem(model, deps) {
1093
1166
  }
1094
1167
  if (trackDrawn === 0)
1095
1168
  trackLine.visible = false;
1169
+ // every orbit line is fainter the more are drawn and the farther out the view is (the orbiter chosen keeps its own)
1170
+ // (the lines with some of their length in the picture, and a planet's moon lines once the planet is big enough for its moons to be told from it)
1171
+ let crowd = linesInView(pathsOf("base"), size.width, size.height);
1172
+ if (moonLayer !== undefined && model.orbits) {
1173
+ for (const host of model.moonHosts)
1174
+ if (moonLayer.orbitObject(host)?.visible && px[host] >= MOON_MIN_PLANET_PX)
1175
+ crowd += moonLayer.orbitMoons(host).length;
1176
+ }
1177
+ const crowding = { crowd, outness: outnessOf(distance / Math.max(1e-9, focusRadius)) };
1178
+ const faint = (base) => lineAlpha({ base, ...crowding });
1179
+ for (const o of orbits.values())
1180
+ o.line.material.opacity = faint(LINE_OPACITY);
1181
+ roadsterLine.material.opacity = faint(LINE_OPACITY);
1182
+ for (const drawing of orbiterDrawings.values())
1183
+ drawing.lineMaterial.opacity = drawing.chosen ? drawing.base : faint(drawing.base);
1184
+ moonLayer?.setOrbitOpacity(faint(MOON_ORBIT_OPACITY));
1185
+ arrowLines.material.opacity = faint(0.95);
1186
+ model.rings.fade = { crowd, outness: crowding.outness, opacity: faint(LINE_OPACITY) };
1096
1187
  model.orbitersDrawn = { count: Object.keys(orbiterPlaces).length, status: orbiterStatus, dim: orbitersDim, lines: linesDrawn, track: trackDrawn };
1097
1188
  // the painted trail: stepped and uploaded only while the painted craft's body is drawn, and only when the shown moment moved
1098
1189
  const paintedCraft = model.paint;
@@ -1189,6 +1280,8 @@ export function createSpaceItem(model, deps) {
1189
1280
  const now = performance.now();
1190
1281
  const seen = new Set();
1191
1282
  const moonPlaces = {};
1283
+ let moonsMade = 0;
1284
+ let moonsLeft = false;
1192
1285
  const moonDistances = {};
1193
1286
  for (const id of [...SPACE_PLANETS, ...SPACE_DWARFS]) {
1194
1287
  const planet = slotOf(id).drawing;
@@ -1216,6 +1309,17 @@ export function createSpaceItem(model, deps) {
1216
1309
  if (key === hiddenMoon)
1217
1310
  continue;
1218
1311
  let held = moonSlots.get(key);
1312
+ // a moon not yet made, or made with another look, is made in this draw only if there is room for it in the draw (the moon looked at always is)
1313
+ if ((held === undefined || (held.slot.look !== model.look && !held.slot.failed)) && moonsMade >= MOON_MAKES_PER_DRAW && key !== model.focus) {
1314
+ moonsLeft = true;
1315
+ if (held !== undefined) {
1316
+ held.seen = now;
1317
+ seen.add(key);
1318
+ }
1319
+ continue;
1320
+ }
1321
+ if (held === undefined || (held.slot.look !== model.look && !held.slot.failed))
1322
+ moonsMade += 1;
1219
1323
  if (!held)
1220
1324
  moonSlots.set(key, (held = { slot: { drawing: undefined, look: null, failed: false, labelled: -1 }, seen: now }));
1221
1325
  held.seen = now;
@@ -1244,6 +1348,9 @@ export function createSpaceItem(model, deps) {
1244
1348
  }
1245
1349
  }
1246
1350
  }
1351
+ // moons left for the next draw: ask for it (the view at rest draws nothing)
1352
+ if (moonsLeft)
1353
+ deps.invalidate();
1247
1354
  let soonest = Number.POSITIVE_INFINITY;
1248
1355
  for (const [key, held] of moonSlots) {
1249
1356
  if (seen.has(key))
package/dist/stops.js CHANGED
@@ -57,6 +57,18 @@ const GM = {
57
57
  charon: 106.1,
58
58
  nix: 0.0015,
59
59
  hydra: 0.002,
60
+ // JPL "Planetary Satellite Physical Parameters", read 2026-11-18, for the moons added with their shape models. Telesto, Calypso and Daphnis print no GM, and Larissa's (0.25484) has an uncertainty of 3.1, larger than itself, so it is left empty.
61
+ amalthea: 0.16456,
62
+ thebe: 0.03015,
63
+ hyperion: 0.37049,
64
+ phoebe: 0.55479,
65
+ janus: 0.12662,
66
+ epimetheus: 0.03514,
67
+ helene: 0.00048,
68
+ atlas: 0.00037,
69
+ prometheus: 0.01071,
70
+ pandora: 0.00926,
71
+ pan: 0.00028,
60
72
  };
61
73
  /** Escape speed in km/s, where a page prints one. Anything else is worked out from GM and the radius. */
62
74
  const ESCAPE = {
@@ -5,7 +5,7 @@ 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
7
  import { calloutsBy, clockText, LANDING, landingAt, turnedBy, watchedLook } from "./landing.js";
8
- import { drop, groundAt } from "./height.js";
8
+ import { drop, groundAt, joinCredits } from "./height.js";
9
9
  import { loadTerrain } from "./load.js";
10
10
  import { createSurfaceItem } from "./scene.js";
11
11
  import { objectsOf, traverseOf } from "./objects.js";
@@ -472,8 +472,8 @@ export class WakuseiSurface extends HTMLElement {
472
472
  return this.#lang() === "ja" ? "地面: 高さのデータが追加されるまでの平らな代用です。ここには、実測した起伏も作った起伏もありません。太陽、空、重力は、この場所と時刻の実際のとおりです。" : "Ground: flat stand-in until a DTM is added. There is no relief here, measured or made. The Sun, sky and gravity are the real ones for this place and time.";
473
473
  const made = this.#noDetail() ? "" : this.#lang() === "ja" ? "5 m より細かい地形(小さなクレーター、砂塵、岩)は計算で作ったもので、実測ではありません。" : "Detail finer than the 5 m grid (small craters, dust, rocks) is made, not measured.";
474
474
  const things = this.#objects.length === 0 ? "" : this.#lang() === "ja" ? " 地面の物は、公表された座標の位置にこのパッケージが置いたもので、形は簡単な絵です。" : " The things on the ground are placed by this package at published positions, as plain drawings.";
475
- const picture = m.picture === null || m.picture === undefined ? "" : ` ${m.picture.credit}.`;
476
- return this.#lang() === "ja" ? `高さの実測: ${m.accuracy}。${m.credit}。${made}${things}` : `Heights measured: ${m.accuracy}. ${m.credit}.${picture} ${made}${things}`;
475
+ const credit = joinCredits(m.credit, m.picture?.credit);
476
+ return this.#lang() === "ja" ? `高さの実測: ${m.accuracy}。${credit}。${made}${things}` : `Heights measured: ${m.accuracy}. ${credit}. ${made}${things}`;
477
477
  }
478
478
  /** The ground's height at a point over the site's: the measured heights, the made craters on them (if the page has them on) and the Moon's curve taken off. */
479
479
  #groundAt(east, north) {