@johnmorrisdotca/wakusei-planets 0.71.0 → 0.73.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/dist/element.js CHANGED
@@ -19,6 +19,7 @@ export { TEXTURE_BASE, TEXTURE_FAR_BASE, TILES_BASE } from "./scene/textures.js"
19
19
  import { mapWidthOf, ringWidthOf, zoomLimit } from "./scene/reach.js";
20
20
  import { viewPose } from "./scene/tumble.js";
21
21
  import { createBodyItem } from "./scene/body.js";
22
+ import { estimatedRock, estimatedRockLine } from "./scene/estimated-rock.js";
22
23
  import { NAME_LABEL_ATTRIBUTES, nameLabelKey, nameLabelText, readNameLabel } from "./scene/name-label.js";
23
24
  import { delegates, onRegister } from "./scene/store.js";
24
25
  import { setThreeLoader, takeRenderer } from "./scene/shared.js";
@@ -72,13 +73,17 @@ const TEMPLATE = `<style>
72
73
  #cutaway li { display: grid; grid-template-columns: 12px 1fr; gap: 2px 8px; align-items: baseline; }
73
74
  #cutaway [data-swatch] { width: 12px; height: 12px; }
74
75
  #stage svg { display: block; width: 100%; height: 100%; }
75
- </style><div id="stage"></div><ol id="cutaway" hidden></ol>`;
76
+ #estimate { position: absolute; z-index: 2; left: 2px; right: 2px; bottom: 1px; margin: 0; max-height: 2.4em; overflow: hidden; text-align: center; font: 10px/1.2 system-ui, sans-serif; color: inherit; pointer-events: none; }
77
+ #estimate[hidden] { display: none; }
78
+ :host([data-shape="estimated"]) #stage { bottom: 22px; }
79
+ </style><div id="stage"></div><p id="estimate" hidden></p><ol id="cutaway" hidden></ol>`;
76
80
  /**
77
81
  * The `<wakusei-body>` custom element: a body of the solar system, drawn in a look.
78
82
  *
79
83
  * Attributes: `body` (a name, such as `jupiter`), `look` (`line`, `realistic` or `painted`), `size` (pixels across), `time` (`now` or an ISO date: the body as the Earth sees it then; leave it out for a portrait),
80
84
  * `tilt`, `pitch`, `phase` and `meridian` (a portrait's pose, degrees), `turn` (a portrait turns this many degrees a second; left out, 12 a second, backwards when the body is, and a date keeps its orientation and adds this turn; `live="off"` stays still unless this is set; `0` stays still; reduced motion keeps a quarter of it), `rate` (simulated seconds for each real second), `moons` (draw the planet's moons on their orbits),
81
85
  * `range` (planet radii the moons picture reaches), `scale-to` (draw to scale with another body), `span-km` (draw to scale: the half-width of the picture in kilometres, the same in every picture of a lineup), `live` (`always`, `hover` or `off`: when it takes the page's one WebGL context), `texture-base` (where the surface pictures are) and `lang` (`en` or `ja`).
86
+ * A `body` that names a catalogue moon the package does not draw in full (such as `himalia`, or `S/2003 J 18`) is an estimated rock: the size is the catalogue radius, the shape is a guess from that id, and the picture says the shape is estimated. A size worked out from the brightness says so. Any other unknown name stays the Earth.
82
87
  *
83
88
  * It carries the shared view controls itself: a drag turns the body, two fingers pinch, Ctrl, Command or Alt with the wheel zooms (the plain wheel scrolls the page at Fit), the arrow keys, + and - and 0 work once it is focused.
84
89
  * `controls="none"` turns them off, and `live="off"` (a still, a thumbnail) starts without them (`controls` with no value brings them back). `zoom-min` and `zoom-max` set the range (0.1 to 50 for the line drawing; for the shaded looks 0.1 up to where the body's detail runs out, 8 at least and 1000 at most: see the close zoom guide); a `<kazoku-view-controls for="...">` takes over and reads it.
@@ -686,9 +691,18 @@ export class WakuseiBody extends HTMLElement {
686
691
  }
687
692
  return this.#starMade;
688
693
  }
689
- /** The facts of what is drawn: the body's, or the star's (the Sun's with its own size, shape and outlines). */
694
+ /** A catalogue moon this element draws as an estimated rock, or `null` when `body` is a body the package draws in full (or not a moon). */
695
+ #estimate() {
696
+ if (this.hasAttribute("star"))
697
+ return null;
698
+ const id = this.getAttribute("body");
699
+ if (id === null || id in BODIES)
700
+ return null;
701
+ return estimatedRock(id);
702
+ }
703
+ /** The facts of what is drawn: the body's, the star's (the Sun's with its own size, shape and outlines), or an estimated rock's. */
690
704
  #facts() {
691
- return this.#star()?.facts ?? BODIES[this.body];
705
+ return this.#star()?.facts ?? this.#estimate()?.facts ?? BODIES[this.body];
692
706
  }
693
707
  // --- the clock ------------------------------------------------------------------------------------------------------------------------------------
694
708
  #clockFromAttributes() {
@@ -793,7 +807,7 @@ export class WakuseiBody extends HTMLElement {
793
807
  #limits() {
794
808
  if (this.look === "line")
795
809
  return LINE_LIMITS;
796
- if (this.hasAttribute("star"))
810
+ if (this.hasAttribute("star") || this.#estimate() !== null)
797
811
  return { zoomMin: 0.1, zoomMax: zoomLimit(1, 0, false), tiltMax: 90 };
798
812
  const moons = this.hasAttribute("moons");
799
813
  const look = lookOf(this.body);
@@ -901,7 +915,7 @@ export class WakuseiBody extends HTMLElement {
901
915
  }
902
916
  /** The picture's identity: a new one disposes the view and builds it again, so a cutaway gives its shells back when it is turned off. */
903
917
  #signature() {
904
- return `${this.#star()?.key ?? this.body}|${this.look}|${this.#cutawayOn() ? "cut" : "whole"}`;
918
+ return `${this.#star()?.key ?? this.#estimate()?.id ?? this.body}|${this.look}|${this.#cutawayOn() ? "cut" : "whole"}`;
905
919
  }
906
920
  #cutawayOn() {
907
921
  const value = this.getAttribute("cutaway");
@@ -953,6 +967,7 @@ export class WakuseiBody extends HTMLElement {
953
967
  if (!this.isConnected)
954
968
  return;
955
969
  this.#syncLegend();
970
+ this.#syncEstimate();
956
971
  this.setAttribute("aria-label", this.#label());
957
972
  if (this.hasAttribute("size"))
958
973
  this.style.setProperty("--wakusei-size", `${num(this.getAttribute("size"), 320)}px`);
@@ -962,7 +977,7 @@ export class WakuseiBody extends HTMLElement {
962
977
  this.#set("line");
963
978
  return;
964
979
  }
965
- const delegate = this.look === "line" ? delegates.get(this.body) : undefined;
980
+ const delegate = this.#estimate() === null && this.look === "line" ? delegates.get(this.body) : undefined;
966
981
  if (delegate !== undefined && (await this.#delegated(delegate)))
967
982
  return;
968
983
  const undelegated = this.#delegateEl !== undefined;
@@ -1018,9 +1033,36 @@ export class WakuseiBody extends HTMLElement {
1018
1033
  this.addEventListener(name, this.#hover);
1019
1034
  }
1020
1035
  }
1036
+ #syncEstimate() {
1037
+ const rock = this.#estimate();
1038
+ const note = this.shadowRoot?.querySelector("#estimate");
1039
+ if (rock === null) {
1040
+ this.removeAttribute("data-shape");
1041
+ this.removeAttribute("data-size");
1042
+ this.removeAttribute("data-estimated");
1043
+ if (note instanceof HTMLElement) {
1044
+ note.hidden = true;
1045
+ note.textContent = "";
1046
+ }
1047
+ return;
1048
+ }
1049
+ this.dataset.shape = "estimated";
1050
+ this.dataset.size = rock.sizeFrom;
1051
+ this.dataset.estimated = rock.id;
1052
+ if (note instanceof HTMLElement) {
1053
+ note.hidden = false;
1054
+ note.textContent = this.getAttribute("lang") === "ja" ? rock.line.ja : rock.line.en;
1055
+ note.title = this.getAttribute("lang") === "ja" ? rock.legend.ja : rock.legend.en;
1056
+ }
1057
+ }
1021
1058
  #label() {
1022
1059
  const star = this.#star();
1023
1060
  const ja = this.getAttribute("lang") === "ja";
1061
+ const rock = this.#estimate();
1062
+ if (rock !== null) {
1063
+ const note = ja ? rock.note.ja : rock.note.en;
1064
+ return ja ? `${rock.label}。${note}` : `${rock.label}. ${note}`;
1065
+ }
1024
1066
  if (star !== undefined)
1025
1067
  return this.look === "line" ? (ja ? `${star.facts.name.ja}の線画。${star.disclaimer.ja}` : `${star.facts.name.en}, line drawing. ${star.disclaimer.en}`) : ja ? `${star.facts.name.ja}の陰影つきの絵。${star.disclaimer.ja}` : `${star.facts.name.en}, shaded star. ${star.disclaimer.en}`;
1026
1068
  const f = BODIES[this.body];
@@ -1028,6 +1070,11 @@ export class WakuseiBody extends HTMLElement {
1028
1070
  return ja ? `${f.name.ja}の${looks[this.look]}` : `${f.name.en}, ${looks[this.look]}`;
1029
1071
  }
1030
1072
  #drawLine() {
1073
+ const rock = this.#estimate();
1074
+ if (rock !== null) {
1075
+ this.#stage.innerHTML = estimatedRockLine(rock, 480);
1076
+ return;
1077
+ }
1031
1078
  const r = this.#request();
1032
1079
  const frame = this.#frameNow();
1033
1080
  const scaleTo = this.getAttribute("scale-to");
@@ -1052,7 +1099,7 @@ export class WakuseiBody extends HTMLElement {
1052
1099
  }
1053
1100
  #key(state) {
1054
1101
  const moons = (state.moons ?? []).map((m) => `${m.id}:${m.x.toFixed(1)},${m.y.toFixed(1)}`).join(";");
1055
- return `${this.#star()?.key ?? this.body}|${this.look}|${vectorKey(state.pose.pole)}|${vectorKey(state.pose.meridian)}|${vectorKey(state.pose.light)}|${state.extent.toFixed(2)}|${state.zoom.toFixed(2)}|${state.panX.toFixed(2)},${state.panY.toFixed(2)}|${moons}|${this.#labelKey()}`;
1102
+ return `${this.#star()?.key ?? this.#estimate()?.id ?? this.body}|${this.look}|${vectorKey(state.pose.pole)}|${vectorKey(state.pose.meridian)}|${vectorKey(state.pose.light)}|${state.extent.toFixed(2)}|${state.zoom.toFixed(2)}|${state.panX.toFixed(2)},${state.panY.toFixed(2)}|${moons}|${this.#labelKey()}`;
1056
1103
  }
1057
1104
  // Replacing a view keeps the renderer lease; leaving 3D gives it back.
1058
1105
  #disposeView(releaseRenderer = false) {
@@ -1084,11 +1131,12 @@ export class WakuseiBody extends HTMLElement {
1084
1131
  this.#stilled = false;
1085
1132
  this.#stage.innerHTML = "";
1086
1133
  const star = this.#star();
1134
+ const rock = this.#estimate();
1087
1135
  const item = createBodyItem({
1088
1136
  id: this.body,
1089
- ...(star === undefined ? {} : { shaded: star.look, facts: star.facts, assetKey: `star:${star.key}` }),
1137
+ ...(star !== undefined ? { shaded: star.look, facts: star.facts, assetKey: `star:${star.key}` } : rock === null ? {} : { shaded: rock.look, facts: rock.facts, assetKey: `rock:${rock.id}`, coarse: true }),
1090
1138
  look: this.look === "illustrated" ? "realistic" : "painted",
1091
- cutaway: this.#cutawayOn(),
1139
+ cutaway: rock === null && this.#cutawayOn(),
1092
1140
  onShells: (count) => {
1093
1141
  this.dataset.shells = String(count);
1094
1142
  },
@@ -0,0 +1,57 @@
1
+ /** One irregular body a distance can be measured on: a volume-equivalent mean radius, and the published full extents when the source gives them. */
2
+ export interface PlaceMeanRadius {
3
+ /** The radius of the sphere with the body's measured volume, in kilometres. */
4
+ radiusKm: number;
5
+ /** The published full extents in kilometres, longest first. Absent when the source gives none. */
6
+ axesKm?: readonly [number, number] | readonly [number, number, number];
7
+ /** Where the radius and the extents were read. */
8
+ source: string;
9
+ /** A fact that is not a shape bound. */
10
+ note?: string;
11
+ }
12
+ /**
13
+ * The six place bodies `BODIES` has no radius for. Read 2026-11-19, one request a second, from JPL's Small-Body Database except Dimorphos, which is not in it.
14
+ *
15
+ * Eros: diameter 16.84 ± 0.06 km (Yeomans et al. 2000), extents 34.4 × 11.2 × 11.2 km (Veverka et al. 2000).
16
+ * Ryugu: diameter 0.896 ± 0.004 km, extents 1.004 × 0.876 km, two axes (Watanabe et al. 2019).
17
+ * Bennu: diameter 0.48444 ± 0.00030 km, extents 0.5047 × 0.4918 × 0.4567 km (Daly et al. 2020).
18
+ * Dimorphos: volume-equivalent diameter 151 ± 5 m, extents 177 ± 2 × 174 ± 4 × 116 ± 2 m (Daly et al., Nature 2023). The volume is the shape model's, not an ellipsoid of those extents.
19
+ * Tempel 1: diameter 6.0 ± 0.2 km, extents 7.6 × 4.9 km, two axes, preliminary (A'Hearn et al. 2005).
20
+ * 67P: diameter 3.4 ± 0.1 km (Sierks et al. 2015). No extents.
21
+ */
22
+ export declare const PLACE_MEAN_RADII: {
23
+ readonly eros: {
24
+ readonly radiusKm: 8.42;
25
+ readonly axesKm: readonly [34.4, 11.2, 11.2];
26
+ readonly source: "JPL SBDB: Yeomans et al. 2000; Veverka et al. 2000";
27
+ };
28
+ readonly ryugu: {
29
+ readonly radiusKm: 0.448;
30
+ readonly axesKm: readonly [1.004, 0.876];
31
+ readonly source: "JPL SBDB, Watanabe et al. 2019";
32
+ readonly note: "Two extents only.";
33
+ };
34
+ readonly bennu: {
35
+ readonly radiusKm: 0.24222;
36
+ readonly axesKm: readonly [0.5047, 0.4918, 0.4567];
37
+ readonly source: "JPL SBDB, Daly et al. 2020";
38
+ };
39
+ readonly dimorphos: {
40
+ readonly radiusKm: 0.0755;
41
+ readonly axesKm: readonly [0.177, 0.174, 0.116];
42
+ readonly source: "Daly et al., Nature 2023";
43
+ };
44
+ readonly "tempel-1": {
45
+ readonly radiusKm: 3;
46
+ readonly axesKm: readonly [7.6, 4.9];
47
+ readonly source: "JPL SBDB, A'Hearn et al. 2005";
48
+ readonly note: "The extents are preliminary, and only two.";
49
+ };
50
+ readonly "67p": {
51
+ readonly radiusKm: 1.7;
52
+ readonly source: "JPL SBDB, Sierks et al. 2015";
53
+ readonly note: "The diameter is 3.4 ± 0.1 km, so the mean radius is uncertain by 0.05 km. The nucleus is two lobes, and the source gives no extents.";
54
+ };
55
+ };
56
+ /** Half the spread of the semi-axes, in kilometres. The extents are full lengths. */
57
+ export declare const shapeHalfRangeKm: (axesKm: readonly number[]) => number;
@@ -0,0 +1,24 @@
1
+ // Volume-equivalent mean radii for the place bodies that are not in BODIES. The extents are the published full lengths, two when the source gives two. accuracyKm uses only those extents.
2
+ /**
3
+ * The six place bodies `BODIES` has no radius for. Read 2026-11-19, one request a second, from JPL's Small-Body Database except Dimorphos, which is not in it.
4
+ *
5
+ * Eros: diameter 16.84 ± 0.06 km (Yeomans et al. 2000), extents 34.4 × 11.2 × 11.2 km (Veverka et al. 2000).
6
+ * Ryugu: diameter 0.896 ± 0.004 km, extents 1.004 × 0.876 km, two axes (Watanabe et al. 2019).
7
+ * Bennu: diameter 0.48444 ± 0.00030 km, extents 0.5047 × 0.4918 × 0.4567 km (Daly et al. 2020).
8
+ * Dimorphos: volume-equivalent diameter 151 ± 5 m, extents 177 ± 2 × 174 ± 4 × 116 ± 2 m (Daly et al., Nature 2023). The volume is the shape model's, not an ellipsoid of those extents.
9
+ * Tempel 1: diameter 6.0 ± 0.2 km, extents 7.6 × 4.9 km, two axes, preliminary (A'Hearn et al. 2005).
10
+ * 67P: diameter 3.4 ± 0.1 km (Sierks et al. 2015). No extents.
11
+ */
12
+ export const PLACE_MEAN_RADII = {
13
+ eros: { radiusKm: 8.42, axesKm: [34.4, 11.2, 11.2], source: "JPL SBDB: Yeomans et al. 2000; Veverka et al. 2000" },
14
+ ryugu: { radiusKm: 0.448, axesKm: [1.004, 0.876], source: "JPL SBDB, Watanabe et al. 2019", note: "Two extents only." },
15
+ bennu: { radiusKm: 0.24222, axesKm: [0.5047, 0.4918, 0.4567], source: "JPL SBDB, Daly et al. 2020" },
16
+ dimorphos: { radiusKm: 0.0755, axesKm: [0.177, 0.174, 0.116], source: "Daly et al., Nature 2023" },
17
+ "tempel-1": { radiusKm: 3, axesKm: [7.6, 4.9], source: "JPL SBDB, A'Hearn et al. 2005", note: "The extents are preliminary, and only two." },
18
+ "67p": { radiusKm: 1.7, source: "JPL SBDB, Sierks et al. 2015", note: "The diameter is 3.4 ± 0.1 km, so the mean radius is uncertain by 0.05 km. The nucleus is two lobes, and the source gives no extents." },
19
+ };
20
+ /** Half the spread of the semi-axes, in kilometres. The extents are full lengths. */
21
+ export const shapeHalfRangeKm = (axesKm) => {
22
+ const semis = axesKm.map((km) => km / 2);
23
+ return (Math.max(...semis) - Math.min(...semis)) / 2;
24
+ };
package/dist/places.d.ts CHANGED
@@ -240,9 +240,39 @@ export declare function nearestPlace(places: readonly Place[], lat: number, lon:
240
240
  degrees: number;
241
241
  } | undefined;
242
242
  /**
243
- * The distance over the surface between two places on a body, in kilometres: the great circle on a sphere of the body's equatorial radius from `BODIES` (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). A body the package has no radius for (Eros, Ryugu, Bennu, Dimorphos and the two comets: their shapes are not spheres) is a `RangeError`.
243
+ * The distance over the surface between two points, and the shape bound on it.
244
244
  *
245
- * @param body - A body of `PLACE_BODIES` that has a radius in `BODIES`.
245
+ * `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On Eros, Ryugu, Bennu, Dimorphos, Tempel 1 and 67P the sphere is the volume-equivalent mean radius.
246
+ *
247
+ * `accuracyKm` is the shape bound: the same angle times half the spread of the published semi-axes. It is `null` when no shape bound is stated, which is a sphere in `BODIES`, and 67P (the source gives no extents; the 0.05 km uncertainty of its mean radius is a note, not this bound).
248
+ *
249
+ * @param body - A body of `PLACE_BODIES`.
250
+ * @param a - A place, or a latitude and east longitude.
251
+ * @param b - The other.
252
+ * @returns The kilometres, and the shape bound in kilometres, or `null` when none is stated.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * import { placeDistance } from "@johnmorrisdotca/wakusei-planets/places";
257
+ *
258
+ * const d = placeDistance("bennu", { lat: 0, lon: 0 }, { lat: 0, lon: 90 });
259
+ * console.log(d.km.toFixed(3), d.accuracyKm?.toFixed(3) ?? "not stated");
260
+ * ```
261
+ */
262
+ export declare function placeDistance(body: PlaceBody, a: Place | {
263
+ lat: number;
264
+ lon: number;
265
+ }, b: Place | {
266
+ lat: number;
267
+ lon: number;
268
+ }): {
269
+ km: number;
270
+ accuracyKm: number | null;
271
+ };
272
+ /**
273
+ * The distance over the surface between two places on a body, in kilometres: `placeDistance(body, a, b).km`.
274
+ *
275
+ * @param body - A body of `PLACE_BODIES`.
246
276
  * @param a - A place, or a latitude and east longitude.
247
277
  * @param b - The other.
248
278
  * @returns Kilometres.
package/dist/places.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // themselves are the entry points `/places/<body>`, so a page pays only for the body it shows.
4
4
  import { apparent } from "./ephemeris.js";
5
5
  import { BODIES } from "./facts.js";
6
+ import { PLACE_MEAN_RADII, shapeHalfRangeKm } from "./place-radii.js";
6
7
  import { cross, dot } from "./vec.js";
7
8
  import { moment } from "./when.js";
8
9
  export { layerOf, MARK_RULES, PLACE_LAYERS, marksToShow, placeMarks, placeRank, pointUnder, readPlaceLayers, readSurfaceNames, spotView, surfacePoint, turnToPlace } from "./place-marks.js";
@@ -211,9 +212,42 @@ export function nearestPlace(places, lat, lon, ...kinds) {
211
212
  return best;
212
213
  }
213
214
  /**
214
- * The distance over the surface between two places on a body, in kilometres: the great circle on a sphere of the body's equatorial radius from `BODIES` (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). A body the package has no radius for (Eros, Ryugu, Bennu, Dimorphos and the two comets: their shapes are not spheres) is a `RangeError`.
215
+ * The distance over the surface between two points, and the shape bound on it.
215
216
  *
216
- * @param body - A body of `PLACE_BODIES` that has a radius in `BODIES`.
217
+ * `km` is the great circle. On a body in `BODIES` the sphere is the equatorial radius (1737.4 km for the Moon, 3396.19 km for Mars; flattening is not allowed for, which is 0.6 per cent on Mars and nothing on the Moon). On Eros, Ryugu, Bennu, Dimorphos, Tempel 1 and 67P the sphere is the volume-equivalent mean radius.
218
+ *
219
+ * `accuracyKm` is the shape bound: the same angle times half the spread of the published semi-axes. It is `null` when no shape bound is stated, which is a sphere in `BODIES`, and 67P (the source gives no extents; the 0.05 km uncertainty of its mean radius is a note, not this bound).
220
+ *
221
+ * @param body - A body of `PLACE_BODIES`.
222
+ * @param a - A place, or a latitude and east longitude.
223
+ * @param b - The other.
224
+ * @returns The kilometres, and the shape bound in kilometres, or `null` when none is stated.
225
+ *
226
+ * @example
227
+ * ```ts
228
+ * import { placeDistance } from "@johnmorrisdotca/wakusei-planets/places";
229
+ *
230
+ * const d = placeDistance("bennu", { lat: 0, lon: 0 }, { lat: 0, lon: 90 });
231
+ * console.log(d.km.toFixed(3), d.accuracyKm?.toFixed(3) ?? "not stated");
232
+ * ```
233
+ */
234
+ export function placeDistance(body, a, b) {
235
+ if (!PLACE_BODIES.includes(body))
236
+ throw new RangeError(`places are held for ${PLACE_BODIES.join(", ")}, not "${String(body)}"`);
237
+ const radians = angleBetween(a.lat, a.lon, b.lat, b.lon) * RAD;
238
+ const facts = BODIES[body];
239
+ if (facts !== undefined)
240
+ return { km: radians * facts.radiusKm, accuracyKm: null };
241
+ const mean = PLACE_MEAN_RADII[body];
242
+ if (mean === undefined)
243
+ throw new RangeError(`the package has no radius for ${body}`);
244
+ const accuracyKm = "axesKm" in mean ? radians * shapeHalfRangeKm(mean.axesKm) : null;
245
+ return { km: radians * mean.radiusKm, accuracyKm };
246
+ }
247
+ /**
248
+ * The distance over the surface between two places on a body, in kilometres: `placeDistance(body, a, b).km`.
249
+ *
250
+ * @param body - A body of `PLACE_BODIES`.
217
251
  * @param a - A place, or a latitude and east longitude.
218
252
  * @param b - The other.
219
253
  * @returns Kilometres.
@@ -229,12 +263,7 @@ export function nearestPlace(places, lat, lon, ...kinds) {
229
263
  * ```
230
264
  */
231
265
  export function placeDistanceKm(body, a, b) {
232
- if (!PLACE_BODIES.includes(body))
233
- throw new RangeError(`places are held for ${PLACE_BODIES.join(", ")}, not "${String(body)}"`);
234
- const facts = BODIES[body];
235
- if (facts === undefined)
236
- throw new RangeError(`the package has no radius for ${body}, an irregular body: no distance over a sphere is given`);
237
- return (angleBetween(a.lat, a.lon, b.lat, b.lon) * RAD * facts.radiusKm);
266
+ return placeDistance(body, a, b).km;
238
267
  }
239
268
  /**
240
269
  * The great-circle angle between two points on a sphere, in degrees.
@@ -64,6 +64,8 @@ export interface BodyItemOptions {
64
64
  facts?: BodyFacts;
65
65
  /** What the renderer keeps this body's materials under, instead of `id`: a star's key, so two stars do not share a program. */
66
66
  assetKey?: string;
67
+ /** A coarse globe for an estimated rock: 48 by 24 on a large picture, 24 by 12 on a card, 12 by 6 when it is small. A page may hold every moon of a planet. */
68
+ coarse?: boolean;
67
69
  look: "realistic" | "painted";
68
70
  /** A key that changes whenever the picture would: the renderer keeps one still for each key. */
69
71
  key: string;
@@ -46,6 +46,13 @@ export function makeBodyMaterial(T, look, painted) {
46
46
  uRingOn: { value: 0 },
47
47
  uRingTex: { value: null },
48
48
  uMap: { value: null },
49
+ ...(look.rock === undefined
50
+ ? {}
51
+ : {
52
+ uRockSeed: { value: look.rock.seed },
53
+ uRockDark: { value: new T.Vector3(...look.rock.dark) },
54
+ uRockLight: { value: new T.Vector3(...look.rock.light) },
55
+ }),
49
56
  },
50
57
  });
51
58
  }
@@ -72,8 +79,11 @@ export function createBodyItem(options) {
72
79
  const wantPainted = (options.look === "painted" || look.mapped === true) && look.painted !== undefined;
73
80
  // a moon with a published shape model is the globe moved to its radii (its table is a chunk of its own, waited for here), and then needs no stretching to an ellipsoid
74
81
  const shapeTable = look.shape === undefined ? undefined : await look.shape().catch(() => undefined);
75
- // a big picture gets a globe of 192 by 96 steps (as the unshaped sphere has), a tile or a card one of 96 by 48: a page can hold a dozen moons, and the arrays of a globe stay in the page
76
- const grid = Math.min(width, height) >= 300 ? { lon: 192, lat: 96 } : { lon: 96, lat: 48 };
82
+ // a big picture gets a globe of 192 by 96 steps (as the unshaped sphere has), a tile or a card one of 96 by 48: a page can hold a dozen moons, and the arrays of a globe stay in the page.
83
+ // an estimated rock is coarser: 48 by 24 on a large picture, 24 by 12 on a card, 12 by 6 when it is small, so a page can hold every moon of Jupiter
84
+ const grid = options.coarse === true
85
+ ? (Math.min(width, height) >= 280 ? { lon: 48, lat: 24 } : Math.min(width, height) >= 140 ? { lon: 24, lat: 12 } : { lon: 12, lat: 6 })
86
+ : (Math.min(width, height) >= 300 ? { lon: 192, lat: 96 } : { lon: 96, lat: 48 });
77
87
  const geometry = shapeTable === undefined ? assets.acquire("wk:sphere", () => new T.SphereGeometry(1, 192, 96), (g) => g.dispose()) : assets.acquire(`wk:shape:${held}:${grid.lon}`, () => shapeGeometry(T, shapeTable, facts.radiusKm, grid), (g) => g.dispose());
78
88
  const shader = assets.acquire(`wk:body:${held}:r`, () => makeBodyMaterial(T, look, false), (m) => m.dispose());
79
89
  const paintedMaterial = wantPainted ? assets.acquire(`wk:body:${held}:p`, () => makeBodyMaterial(T, look, true), (m) => m.dispose()) : undefined;
@@ -0,0 +1,57 @@
1
+ import { type BodyFacts, type HostId } from "../facts.ts";
2
+ import type { BodyLook } from "./look.ts";
3
+ import { type ShapeTable } from "./shape.ts";
4
+ /** Where a catalogue radius comes from. `derived` was worked out from the brightness. `unknown` means the catalogue gives no size, and the rock is drawn at 1 km so the poster still has a picture. */
5
+ export type EstimatedSize = "measured" | "sheet" | "derived" | "unknown";
6
+ /** The colour class of an albedo. Unknown is neutral grey. */
7
+ export type AlbedoTone = "dark" | "mid" | "bright" | "grey";
8
+ /** One estimated rock, ready for `<wakusei-body>`. */
9
+ export interface EstimatedRock {
10
+ id: string;
11
+ host: HostId;
12
+ label: string;
13
+ /** The mean radius in kilometres. 1 when the catalogue gives no size. */
14
+ radiusKm: number;
15
+ sizeFrom: EstimatedSize;
16
+ albedo: number | null;
17
+ tone: AlbedoTone;
18
+ /** The flat colour of the line drawing, `#rrggbb`. */
19
+ colour: string;
20
+ /** The seed of the shape and of the craters. The same id has the same seed. */
21
+ seed: number;
22
+ facts: BodyFacts;
23
+ look: BodyLook;
24
+ /** The words under the picture: the shape is always a guess, and a derived or unknown size says so. */
25
+ note: {
26
+ en: string;
27
+ ja: string;
28
+ };
29
+ /** The short line drawn on the picture: the catalogue name and a star. The longer `note` is the accessible name. */
30
+ line: {
31
+ en: string;
32
+ ja: string;
33
+ };
34
+ /** One line for a picture that shows estimated moons: what the star means. */
35
+ legend: {
36
+ en: string;
37
+ ja: string;
38
+ };
39
+ /** The guessed shape. The same object every time for this rock. */
40
+ table: ShapeTable;
41
+ }
42
+ /**
43
+ * One surface shader for every estimated rock. `uRockSeed`, `uRockDark` and `uRockLight` are that moon's own, set on its material, so the page compiles this once.
44
+ */
45
+ export declare const ESTIMATED_SURFACE = "\nuniform float uRockSeed;\nuniform vec3 uRockDark;\nuniform vec3 uRockLight;\nvec4 surface(vec3 p) {\n float h1 = craters(p, 3.0, 0.85, uRockSeed);\n float h2 = craters(p, 8.0, 0.55, uRockSeed + 7.0) * 0.6;\n float h3 = craters(p, 18.0, 0.40, uRockSeed + 3.0) * 0.3;\n float h = h1 + h2 + h3;\n float hr = h1 * reliefShare(p, 3.0) + h2 * reliefShare(p, 8.0) + h3 * reliefShare(p, 18.0);\n float tone = fbm(p * 2.4 + uRockSeed);\n vec3 col = mix(uRockDark, uRockLight, smoothstep(0.25, 0.75, tone));\n col *= 1.0 + 0.9 * h;\n return vec4(col, hr);\n}";
46
+ /** The albedo class: dark under 0.08, mid under 0.25, bright from there, and grey when the albedo is unknown. */
47
+ export declare function albedoTone(albedo: number | null): AlbedoTone;
48
+ /** How far the longest radius is past the shortest. A potato is well above 1; a globe is near 1. */
49
+ export declare function rockSpread(seed: number, radiusKm: number): number;
50
+ /**
51
+ * The estimated rock for a catalogue id, a name or a designation (`himalia`, `Himalia`, `S/2003 J 18`). `null` for a body the package draws in full, and for a name that is not a moon.
52
+ *
53
+ * @param query - The catalogue id, name or designation.
54
+ * @returns The rock, or `null`.
55
+ */
56
+ export declare function estimatedRock(query: string): EstimatedRock | null;
57
+ export declare function estimatedRockLine(rock: EstimatedRock, size: number): string;