@johnmorrisdotca/wakusei-planets 0.37.2 → 0.39.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 (46) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/NOTICE.md +14 -3
  3. package/README.md +6 -4
  4. package/dist/belts/data.d.ts +2 -0
  5. package/dist/belts/data.js +12 -0
  6. package/dist/belts/index.d.ts +270 -0
  7. package/dist/belts/index.js +308 -0
  8. package/dist/belts/totals.d.ts +43 -0
  9. package/dist/belts/totals.js +25 -0
  10. package/dist/data/orbiters.d.ts +221 -199
  11. package/dist/data/orbiters.js +288 -200
  12. package/dist/data-door.d.ts +2 -0
  13. package/dist/data-door.js +4 -2
  14. package/dist/door/own.js +4 -2
  15. package/dist/door/points.d.ts +14 -5
  16. package/dist/door/points.js +78 -27
  17. package/dist/earth-places.d.ts +40 -0
  18. package/dist/earth-places.js +47 -0
  19. package/dist/embed.d.ts +4 -1
  20. package/dist/embed.js +21 -10
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +1 -0
  23. package/dist/orbiter-facts.d.ts +61 -4
  24. package/dist/orbiter-facts.js +17 -3
  25. package/dist/orbiters.d.ts +122 -2
  26. package/dist/orbiters.js +205 -3
  27. package/dist/picture-credits.d.ts +78 -0
  28. package/dist/picture-credits.js +120 -0
  29. package/dist/place-marks.d.ts +76 -0
  30. package/dist/place-marks.js +66 -0
  31. package/dist/places.d.ts +1 -1
  32. package/dist/places.js +1 -1
  33. package/dist/scene/earth-places.d.ts +190 -0
  34. package/dist/scene/earth-places.js +190 -0
  35. package/dist/scene/painter.d.ts +11 -0
  36. package/dist/scene/painter.js +30 -2
  37. package/dist/scene/textures.d.ts +2 -2
  38. package/dist/space/element.d.ts +74 -3
  39. package/dist/space/element.js +293 -8
  40. package/dist/space/ride.d.ts +4 -4
  41. package/dist/space/ride.js +10 -3
  42. package/dist/space/scene.d.ts +44 -2
  43. package/dist/space/scene.js +139 -11
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +1 -1
  46. package/package.json +15 -2
package/dist/data-door.js CHANGED
@@ -94,6 +94,8 @@ export function validateSource(source, taken = []) {
94
94
  const terms = licence;
95
95
  if (!text(terms["name"]))
96
96
  refuse("the licence has no name");
97
+ if (terms["nameJa"] !== undefined && !text(terms["nameJa"]))
98
+ refuse("the licence's Japanese name is empty");
97
99
  if (!text(terms["url"]) || !WEB.test(terms["url"]))
98
100
  refuse("the licence has no link (an http or https address)");
99
101
  for (const flag of ["nonCommercial", "shareAlike"])
@@ -122,7 +124,7 @@ const TERMS = {
122
124
  ja: { nonCommercial: "非営利のみ", shareAlike: "同一条件で共有" },
123
125
  };
124
126
  /** Licence names that are plain phrases, not identifiers, and so are translated. An identifier such as "CC BY-NC 3.0 IGO" is a name and stays. */
125
- const JA_NAMES = { "public domain": "パブリックドメイン" };
127
+ const JA_NAMES = { "public domain": "パブリックドメイン", "published for use with credit": "出典を示せば利用可" };
126
128
  /**
127
129
  * The credit line for what a view drew: each source's credit with its licence name, and "non-commercial" or "share-alike" whenever the source says so, so a page cannot hide the terms of the data it
128
130
  * uses. The package's own sources come first, then the rest, each group in the order given; a source listed twice is written once. English: joined with semicolons, ending in a full stop. Japanese: the
@@ -146,7 +148,7 @@ export function creditLine(credits, language) {
146
148
  const parts = ordered.map((credit) => {
147
149
  const { source } = credit;
148
150
  const line = (source.credit[language] || source.credit.en).trim();
149
- const name = language === "ja" ? (JA_NAMES[source.licence.name.trim().toLowerCase()] ?? source.licence.name) : source.licence.name;
151
+ const name = language === "ja" ? (source.licence.nameJa?.trim() || JA_NAMES[source.licence.name.trim().toLowerCase()] || source.licence.name) : source.licence.name;
150
152
  const terms = [source.licence.nonCommercial === true ? words.nonCommercial : "", source.licence.shareAlike === true ? words.shareAlike : ""].filter((term) => term !== "");
151
153
  if (language === "ja")
152
154
  return `${line}(${[name, ...terms].join("、")})`;
package/dist/door/own.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { PICTURE_CREDITS, picturesCredit } from "../picture-credits.js";
2
+ const PICTURE_IDS = PICTURE_CREDITS.map((row) => row.id);
1
3
  const NOTICE = "https://github.com/johnmorrisdotca/wakusei-planets/blob/main/NOTICE.md";
2
4
  function freeze(value) {
3
5
  if (typeof value === "object" && value !== null)
@@ -21,8 +23,8 @@ export const OWN_SOURCES = freeze([
21
23
  id: "wakusei-pictures",
22
24
  name: { en: "Surface pictures", ja: "表面の地図" },
23
25
  credit: {
24
- en: "Surface pictures: maps by NASA, USGS and JPL (public domain), Solar System Scope and Nestaeric",
25
- ja: "表面の地図:NASA、USGS、JPLの地図(パブリックドメイン)、Solar System ScopeとNestaericの地図",
26
+ en: picturesCredit(PICTURE_IDS, "en"),
27
+ ja: picturesCredit(PICTURE_IDS, "ja"),
26
28
  },
27
29
  licence: { name: "CC BY 4.0", url: `${NOTICE}#surface-pictures`, spdx: "CC-BY-4.0" },
28
30
  url: "https://github.com/johnmorrisdotca/wakusei-planets/tree/main/textures",
@@ -3,7 +3,7 @@ import { type Vec3 } from "../vec.ts";
3
3
  import { type ScaleMode } from "../space/scale.ts";
4
4
  import { type SmallBody } from "./small-bodies.ts";
5
5
  /** The parts of three.js the points use, over and above the ones every body needs. A page's own subset of three that lacks the two instanced classes cannot draw them. */
6
- export type PointsThree = Pick<typeof THREE, "BufferAttribute" | "InstancedBufferAttribute" | "InstancedBufferGeometry" | "Mesh" | "ShaderMaterial" | "Vector2" | "Vector3">;
6
+ export type PointsThree = Pick<typeof THREE, "BufferAttribute" | "Group" | "InstancedBufferAttribute" | "InstancedBufferGeometry" | "Mesh" | "ShaderMaterial" | "Vector2" | "Vector3">;
7
7
  /** How the view places a body round the Sun in a compressed view: its distance in astronomical units to the power `SPREAD`, times `SUN_COMPRESSED` Earth radii (the same two numbers as `space/scale.ts`). */
8
8
  export declare const POINT_SCALE: {
9
9
  readonly sunCompressed: 70;
@@ -44,18 +44,27 @@ export interface PointsState {
44
44
  /** The points of a view's small bodies. */
45
45
  export interface SmallBodyPoints {
46
46
  readonly object: THREE.Object3D;
47
- /** The bodies drawn: the records of every record source in use, as many as `MAX_POINTS`. Packs them for the graphics card. */
47
+ /** The bodies drawn: the records of every record source in use, as many as `MAX_POINTS`. Packs them for the graphics card. A body with a `belt` is drawn with the others of its belt in one instanced draw of its colour; the rest are drawn together. */
48
48
  set(bodies: readonly SmallBody[]): void;
49
49
  /** Called at each draw. */
50
50
  update(state: PointsState): void;
51
- /** How many bodies are in the one draw. */
51
+ /** How many bodies are drawn in all. */
52
52
  readonly count: number;
53
+ /** How many instanced draws there are: one for each belt that has a body, and one for the bodies with no belt. */
54
+ readonly draws: number;
55
+ /** How many bodies each belt has (the bodies with no belt are under `""`). */
56
+ countOf(belt: string): number;
53
57
  dispose(): void;
54
58
  }
59
+ /** What `createSmallBodyPoints` is told: the colour of each belt's points (`#rrggbb`, by belt name), where a belt has none the points are the plain pale colour. */
60
+ export interface PointsOptions {
61
+ colours?: Readonly<Record<string, string>>;
62
+ }
55
63
  /**
56
- * Makes the points: one instanced draw of a quad for each small body.
64
+ * Makes the points: one instanced draw of a quad for each small body, one draw for each belt.
57
65
  *
58
66
  * @param T - The parts of three.js.
67
+ * @param options - The colour of each belt's points.
59
68
  * @returns The points, with no bodies yet.
60
69
  */
61
- export declare function createSmallBodyPoints(T: PointsThree): SmallBodyPoints;
70
+ export declare function createSmallBodyPoints(T: PointsThree, options?: PointsOptions): SmallBodyPoints;
@@ -80,21 +80,23 @@ void main() {
80
80
  }
81
81
  `;
82
82
  const FRAGMENT = /* glsl */ `
83
+ uniform vec3 uColour;
83
84
  varying vec2 vCorner;
84
85
  varying float vFade;
85
86
  void main() {
86
87
  float d = length(vCorner);
87
88
  if (d > 1.0 || vFade < 0.5) discard;
88
- gl_FragColor = vec4(0.86, 0.84, 0.78, 0.9 * smoothstep(1.0, 0.45, d));
89
+ gl_FragColor = vec4(uColour, 0.9 * smoothstep(1.0, 0.45, d));
89
90
  }
90
91
  `;
91
92
  /**
92
- * Makes the points: one instanced draw of a quad for each small body.
93
+ * Makes the points: one instanced draw of a quad for each small body, one draw for each belt.
93
94
  *
94
95
  * @param T - The parts of three.js.
96
+ * @param options - The colour of each belt's points.
95
97
  * @returns The points, with no bodies yet.
96
98
  */
97
- export function createSmallBodyPoints(T) {
99
+ export function createSmallBodyPoints(T, options = {}) {
98
100
  const fresh = (count, data) => {
99
101
  const made = new T.InstancedBufferGeometry();
100
102
  made.setAttribute("position", new T.BufferAttribute(new Float32Array(12), 3));
@@ -111,7 +113,13 @@ export function createSmallBodyPoints(T) {
111
113
  made.instanceCount = count;
112
114
  return made;
113
115
  };
114
- const material = new T.ShaderMaterial({
116
+ const colourOf = (belt) => {
117
+ const hex = options.colours?.[belt];
118
+ if (hex === undefined || !/^#[0-9a-f]{6}$/i.test(hex))
119
+ return [0.86, 0.84, 0.78];
120
+ return [parseInt(hex.slice(1, 3), 16) / 255, parseInt(hex.slice(3, 5), 16) / 255, parseInt(hex.slice(5, 7), 16) / 255];
121
+ };
122
+ const material = (belt) => new T.ShaderMaterial({
115
123
  vertexShader: VERTEX,
116
124
  fragmentShader: FRAGMENT,
117
125
  transparent: true,
@@ -126,50 +134,93 @@ export function createSmallBodyPoints(T) {
126
134
  uSunCompressed: { value: POINT_SCALE.sunCompressed },
127
135
  uSpread: { value: POINT_SCALE.spread },
128
136
  uObliquity: { value: new T.Vector2(Math.sin(OBLIQUITY * RAD), Math.cos(OBLIQUITY * RAD)) },
137
+ uColour: { value: new T.Vector3(...colourOf(belt)) },
129
138
  },
130
139
  });
131
- const mesh = new T.Mesh(fresh(0), material);
132
- mesh.frustumCulled = false;
133
- mesh.renderOrder = -1;
134
- mesh.visible = false;
140
+ const group = new T.Group();
141
+ group.visible = false;
142
+ // one instanced draw for each belt
143
+ const draws = new Map();
135
144
  let jd0 = 0;
136
145
  let count = 0;
137
146
  let bodies = [];
138
147
  let packed = false;
148
+ const beltOf = (body) => body.belt ?? "";
139
149
  const pack = (jd) => {
140
150
  // the shader counts days from the date the bodies were packed at: close to the one being drawn, so a float has the digits
141
151
  jd0 = jd;
142
- const data = packSmallBodies(bodies, jd0);
143
- count = data.length / 8;
144
- const old = mesh.geometry;
145
- mesh.geometry = fresh(count, data);
146
- old.dispose();
147
- mesh.visible = count > 0;
152
+ const by = new Map();
153
+ for (const body of bodies) {
154
+ const belt = beltOf(body);
155
+ const list = by.get(belt);
156
+ if (list === undefined)
157
+ by.set(belt, [body]);
158
+ else
159
+ list.push(body);
160
+ }
161
+ for (const [belt, held] of draws) {
162
+ if (by.has(belt))
163
+ continue;
164
+ group.remove(held.mesh);
165
+ held.mesh.geometry.dispose();
166
+ held.material.dispose();
167
+ draws.delete(belt);
168
+ }
169
+ count = 0;
170
+ for (const [belt, list] of by) {
171
+ const data = packSmallBodies(list, jd0);
172
+ let held = draws.get(belt);
173
+ if (held === undefined) {
174
+ const m = material(belt);
175
+ const mesh = new T.Mesh(fresh(0), m);
176
+ mesh.frustumCulled = false;
177
+ mesh.renderOrder = -1;
178
+ group.add(mesh);
179
+ draws.set(belt, (held = { mesh, material: m, count: 0 }));
180
+ }
181
+ const old = held.mesh.geometry;
182
+ held.count = data.length / 8;
183
+ held.mesh.geometry = fresh(held.count, data);
184
+ old.dispose();
185
+ held.mesh.visible = held.count > 0;
186
+ count += held.count;
187
+ }
188
+ group.visible = count > 0;
148
189
  packed = true;
149
190
  };
150
191
  return {
151
- object: mesh,
192
+ object: group,
152
193
  set(next) {
194
+ // the cap is of all the bodies together; the order is the sources' order, so the package's own come first
153
195
  bodies = next.length > MAX_POINTS ? next.slice(0, MAX_POINTS) : next;
154
196
  packed = false;
155
197
  },
156
- update(state) {
157
- if (!packed || Math.abs(state.jd - jd0) > REPACK_DAYS)
158
- pack(state.jd);
159
- const u = material.uniforms;
160
- u.uDays.value = state.jd - jd0;
161
- u.uTrue.value = state.mode === "true" ? 1 : 0;
162
- u.uSun.value.set(state.sun[0], state.sun[1], state.sun[2]);
163
- u.uViewport.value.set(Math.max(1, state.width), Math.max(1, state.height));
164
- u.uRatio.value = state.ratio;
198
+ update(now) {
199
+ if (!packed || Math.abs(now.jd - jd0) > REPACK_DAYS)
200
+ pack(now.jd);
201
+ for (const held of draws.values()) {
202
+ const u = held.material.uniforms;
203
+ u.uDays.value = now.jd - jd0;
204
+ u.uTrue.value = now.mode === "true" ? 1 : 0;
205
+ u.uSun.value.set(now.sun[0], now.sun[1], now.sun[2]);
206
+ u.uViewport.value.set(Math.max(1, now.width), Math.max(1, now.height));
207
+ u.uRatio.value = now.ratio;
208
+ }
165
209
  },
166
210
  get count() {
167
211
  return count;
168
212
  },
213
+ get draws() {
214
+ return [...draws.values()].filter((held) => held.count > 0).length;
215
+ },
216
+ countOf: (belt) => draws.get(belt)?.count ?? 0,
169
217
  dispose() {
170
- mesh.geometry.dispose();
171
- material.dispose();
172
- mesh.visible = false;
218
+ for (const held of draws.values()) {
219
+ held.mesh.geometry.dispose();
220
+ held.material.dispose();
221
+ }
222
+ draws.clear();
223
+ group.visible = false;
173
224
  },
174
225
  };
175
226
  }
@@ -0,0 +1,40 @@
1
+ import { type SurfaceView } from "./place-marks.ts";
2
+ import { type EarthPlace, type EarthPlaceLayout, type EarthPlaceLayoutOptions, type EarthPlaceLook } from "./scene/earth-places.ts";
3
+ export type { EarthPlace, EarthPlaceLayout, EarthPlaceLayoutOptions, EarthPlaceLook };
4
+ export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "./scene/earth-places.ts";
5
+ /**
6
+ * Read the text of the `earth-places` attribute (a JSON array) as the list the views draw: each place needs a longitude from -180 to 180 and a latitude from -90 to 90, one without an `id` is given its place in the list, a label is
7
+ * cut to 80 letters, a kind that is not `here` is `favourite`, and a colour is kept only when it is a hex colour, `rgb()` or `hsl()` with numbers, or a colour's name. At most 5,000 are kept. chikyu-earth's `readPlaces`.
8
+ *
9
+ * @param value - The attribute's text, or null.
10
+ * @returns The places to draw.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { readEarthPlaces } from "@johnmorrisdotca/wakusei-planets/earth-places";
15
+ *
16
+ * console.log(readEarthPlaces('[{"id":"me","lon":-79.4,"lat":43.7,"kind":"here"},{"lon":500,"lat":0}]'));
17
+ * ```
18
+ */
19
+ export declare function readEarthPlaces(value: string | null | undefined): EarthPlace[];
20
+ /**
21
+ * Where each place's marker and name go on a picture of a body, for a page or a server that draws places itself: chikyu-earth's `layoutPlaces` on the body as a view of it draws it (its axes, the camera and the projection to the screen).
22
+ * A place on the far side is left out and one near the edge fades; with `sun`, each marker says how far into the night it is.
23
+ *
24
+ * @param places - The places, as `readEarthPlaces` makes them.
25
+ * @param view - The body as drawn (`SurfaceView` from `/places`): the Earth's centre, radius, pole and prime meridian in the scene, the camera, and the projection to CSS pixels.
26
+ * @param look - `beam`, `pin` or `ring`.
27
+ * @param options - The size of each name, the boxes already used, the most names and where the Sun is overhead.
28
+ * @returns The markers and where the names go.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { layEarthPlaces } from "@johnmorrisdotca/wakusei-planets/earth-places";
33
+ *
34
+ * const view = { centre: [0, 0, 0] as [number, number, number], radius: 1, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], toward: [0, 0, 1] as [number, number, number],
35
+ * project: (p: [number, number, number]) => ({ x: 160 + p[0] * 100, y: 160 - p[1] * 100 }), width: 320, height: 320, radiusPx: 100 };
36
+ * const laid = layEarthPlaces([{ id: "gulf", lon: 0, lat: 0, label: "Null Island", kind: "here" }], view, "beam", { size: () => ({ width: 70, height: 18 }) });
37
+ * console.log(laid.shapes.length, laid.labels.length);
38
+ * ```
39
+ */
40
+ export declare function layEarthPlaces(places: readonly EarthPlace[], view: SurfaceView, look: EarthPlaceLook, options?: EarthPlaceLayoutOptions): EarthPlaceLayout;
@@ -0,0 +1,47 @@
1
+ // "You are here", and the places a reader keeps, on `<wakusei-space>`'s Earth. This entry point is what brings chikyu-earth's layout of places (its `/markers`, an optional peer) to the views: import it for its effect,
2
+ // `import "@johnmorrisdotca/wakusei-planets/earth-places"`, and `<wakusei-space earth-places='[...]'>` draws them. A page that never imports it carries none of chikyu-earth, and the attribute draws nothing.
3
+ import { layoutPlaces, readPlaces } from "@johnmorrisdotca/chikyu-earth/markers";
4
+ import { spotView } from "./place-marks.js";
5
+ import { setEarthPlacesLayout } from "./scene/earth-places.js";
6
+ setEarthPlacesLayout({ read: readPlaces, layout: layoutPlaces });
7
+ export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS } from "./scene/earth-places.js";
8
+ /**
9
+ * Read the text of the `earth-places` attribute (a JSON array) as the list the views draw: each place needs a longitude from -180 to 180 and a latitude from -90 to 90, one without an `id` is given its place in the list, a label is
10
+ * cut to 80 letters, a kind that is not `here` is `favourite`, and a colour is kept only when it is a hex colour, `rgb()` or `hsl()` with numbers, or a colour's name. At most 5,000 are kept. chikyu-earth's `readPlaces`.
11
+ *
12
+ * @param value - The attribute's text, or null.
13
+ * @returns The places to draw.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { readEarthPlaces } from "@johnmorrisdotca/wakusei-planets/earth-places";
18
+ *
19
+ * console.log(readEarthPlaces('[{"id":"me","lon":-79.4,"lat":43.7,"kind":"here"},{"lon":500,"lat":0}]'));
20
+ * ```
21
+ */
22
+ export function readEarthPlaces(value) {
23
+ return readPlaces(value);
24
+ }
25
+ /**
26
+ * Where each place's marker and name go on a picture of a body, for a page or a server that draws places itself: chikyu-earth's `layoutPlaces` on the body as a view of it draws it (its axes, the camera and the projection to the screen).
27
+ * A place on the far side is left out and one near the edge fades; with `sun`, each marker says how far into the night it is.
28
+ *
29
+ * @param places - The places, as `readEarthPlaces` makes them.
30
+ * @param view - The body as drawn (`SurfaceView` from `/places`): the Earth's centre, radius, pole and prime meridian in the scene, the camera, and the projection to CSS pixels.
31
+ * @param look - `beam`, `pin` or `ring`.
32
+ * @param options - The size of each name, the boxes already used, the most names and where the Sun is overhead.
33
+ * @returns The markers and where the names go.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { layEarthPlaces } from "@johnmorrisdotca/wakusei-planets/earth-places";
38
+ *
39
+ * const view = { centre: [0, 0, 0] as [number, number, number], radius: 1, pole: [0, 1, 0] as [number, number, number], meridian: [0, 0, 1] as [number, number, number], scale: [1, 1, 1] as [number, number, number], toward: [0, 0, 1] as [number, number, number],
40
+ * project: (p: [number, number, number]) => ({ x: 160 + p[0] * 100, y: 160 - p[1] * 100 }), width: 320, height: 320, radiusPx: 100 };
41
+ * const laid = layEarthPlaces([{ id: "gulf", lon: 0, lat: 0, label: "Null Island", kind: "here" }], view, "beam", { size: () => ({ width: 70, height: 18 }) });
42
+ * console.log(laid.shapes.length, laid.labels.length);
43
+ * ```
44
+ */
45
+ export function layEarthPlaces(places, view, look, options = {}) {
46
+ return layoutPlaces(places, spotView(view), look, options);
47
+ }
package/dist/embed.d.ts CHANGED
@@ -49,6 +49,8 @@ export interface EmbedOptions {
49
49
  turn?: number;
50
50
  /** Pixels across. */
51
51
  size?: number;
52
+ /** The credit's language: `en` (the default) or `ja`. */
53
+ lang?: "en" | "ja";
52
54
  /** How far in the embed page starts, as its `zoom` address key has it (1 is the whole body). Left out or 1, the page starts at Fit. Only the iframe way carries it: the element's own start is Fit. */
53
55
  zoom?: number;
54
56
  }
@@ -171,6 +173,7 @@ export interface LineupEmbed {
171
173
  export declare function lineupCode(options: LineupEmbed, kind?: EmbedKind, settings?: EmbedSettings): string;
172
174
  /**
173
175
  * The credits that travel with a picture of the size line-up: the radii are from refereed papers, the stars are drawn from numbers and not photographs, and the planets' sizes are the IAU's and NASA's.
176
+ * A painted Earth and Jupiter add `picturesCredit` for those two, in `options.lang` (`en` when left out).
174
177
  *
175
178
  * @param options - The choices, so the planets and their pictures are named only when they are used.
176
179
  * @returns A short line of credit to put near the picture.
@@ -184,7 +187,7 @@ export declare function lineupCode(options: LineupEmbed, kind?: EmbedKind, setti
184
187
  */
185
188
  export declare function lineupCredit(options: LineupEmbed): string;
186
189
  /**
187
- * The credits that travel with a picture of a body: the line and illustrated looks are drawn from numbers, and `realistic` and `painted` use the surface maps.
190
+ * The credits that travel with a picture of a body: the line and illustrated looks are drawn from numbers, and `realistic` and `painted` use the surface map of that body (`picturesCredit`). `lang` is `en` or `ja` (`en` when left out).
188
191
  *
189
192
  * @param options - The choices, so only what is used is named.
190
193
  * @returns A short line of credit to put near the picture.
package/dist/embed.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // section shows these as the reader changes a choice, and the tests build or parse every one. Pure: no DOM.
3
3
  import { embedSnippet } from "@johnmorrisdotca/kazoku-ui/embed-panel";
4
4
  import { BODIES, DWARF_IDS, MINOR_IDS } from "./facts.js";
5
+ import { picturesCredit } from "./picture-credits.js";
5
6
  import { decodeScene } from "./portrait/model.js";
6
7
  import { VERSION } from "./version.js";
7
8
  /**
@@ -177,6 +178,7 @@ export function lineupCode(options, kind = "html", settings = {}) {
177
178
  }
178
179
  /**
179
180
  * The credits that travel with a picture of the size line-up: the radii are from refereed papers, the stars are drawn from numbers and not photographs, and the planets' sizes are the IAU's and NASA's.
181
+ * A painted Earth and Jupiter add `picturesCredit` for those two, in `options.lang` (`en` when left out).
180
182
  *
181
183
  * @param options - The choices, so the planets and their pictures are named only when they are used.
182
184
  * @returns A short line of credit to put near the picture.
@@ -189,12 +191,18 @@ export function lineupCode(options, kind = "html", settings = {}) {
189
191
  * ```
190
192
  */
191
193
  export function lineupCredit(options) {
192
- const base = "Wakusei Planets by John Morris (MIT). Sizes at true relative scale; each star's radius is from a refereed paper that measured its angular diameter (sources and disagreements in the package's NOTICE.md). The stars are drawn from their numbers, not photographs: the cells, spots and glow are illustrative.";
193
- const planets = options.planets === true ? " Earth and Jupiter: IAU and NASA sizes." + (options.look === "painted" ? " Surface pictures: NASA and Nestaeric (CC BY 4.0), see NOTICE.md." : "") : "";
194
- return `${base}${planets}`;
194
+ const lang = options.lang ?? "en";
195
+ const base = lang === "ja"
196
+ ? "Wakusei Planets(John Morris、MIT)。大きさは実際の比です。星の半径は、角直径を測った査読論文によります(出典と食い違いはパッケージのNOTICE.md)。星は数字から描いたもので、写真ではありません。表面の模様、黒点、輝きは説明のためのものです。"
197
+ : "Wakusei Planets by John Morris (MIT). Sizes at true relative scale; each star's radius is from a refereed paper that measured its angular diameter (sources and disagreements in the package's NOTICE.md). The stars are drawn from their numbers, not photographs: the cells, spots and glow are illustrative.";
198
+ if (options.planets !== true)
199
+ return base;
200
+ const sizes = lang === "ja" ? " 地球と木星:IAUとNASAの大きさ。" : " Earth and Jupiter: IAU and NASA sizes.";
201
+ const pictures = options.look === "painted" ? ` ${picturesCredit(["earth", "jupiter"], lang)}` : "";
202
+ return `${base}${sizes}${pictures}`;
195
203
  }
196
204
  /**
197
- * The credits that travel with a picture of a body: the line and illustrated looks are drawn from numbers, and `realistic` and `painted` use the surface maps.
205
+ * The credits that travel with a picture of a body: the line and illustrated looks are drawn from numbers, and `realistic` and `painted` use the surface map of that body (`picturesCredit`). `lang` is `en` or `ja` (`en` when left out).
198
206
  *
199
207
  * @param options - The choices, so only what is used is named.
200
208
  * @returns A short line of credit to put near the picture.
@@ -207,11 +215,14 @@ export function lineupCredit(options) {
207
215
  * ```
208
216
  */
209
217
  export function embedCredit(options) {
210
- if (options.star !== undefined)
211
- return "Wakusei Planets by John Morris (MIT). A star drawn from its numbers, not a photo: the colour from its temperature, the size from its radius; the surface cells, spots and glow are illustrative.";
212
- const base = "Wakusei Planets by John Morris (MIT). Sizes, tilt and rotation: IAU and NASA fact sheets.";
218
+ const lang = options.lang ?? "en";
219
+ if (options.star !== undefined) {
220
+ return lang === "ja"
221
+ ? "Wakusei Planets(John Morris、MIT)。数字から描いた星で、写真ではありません。色は温度から、大きさは半径から。表面の模様、黒点、輝きは説明のためのものです。"
222
+ : "Wakusei Planets by John Morris (MIT). A star drawn from its numbers, not a photo: the colour from its temperature, the size from its radius; the surface cells, spots and glow are illustrative.";
223
+ }
224
+ const base = lang === "ja" ? "Wakusei Planets(John Morris、MIT)。大きさ、傾き、自転はIAUとNASAのファクトシートによります。" : "Wakusei Planets by John Morris (MIT). Sizes, tilt and rotation: IAU and NASA fact sheets.";
213
225
  const photos = options.look !== "line" && options.look !== "illustrated";
214
- const painted = photos ? " Surface pictures: NASA, USGS and JPL imagery in the public domain (details in the package's NOTICE.md)." : "";
215
- const earth = options.body === "earth" ? " Earth: NASA Earth Observatory, Blue Marble." : "";
216
- return `${base}${painted}${earth}`;
226
+ const pictures = photos ? picturesCredit([options.body], lang) : "";
227
+ return pictures === "" ? base : `${base} ${pictures}`;
217
228
  }
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { drawnTilt, portrait, type PortraitOptions } from "./pose.ts";
5
5
  export { lineSvg, mix, type LineOptions } from "./line.ts";
6
6
  export { ringStrip, type RingStrip } from "./scene/rings.ts";
7
7
  export { embedCode, embedCredit, EMBED_KINDS, lineupCode, lineupCredit, portraitCode, type EmbedKind, type EmbedOptions, type EmbedSettings, type LineupEmbed, type PortraitEmbed } from "./embed.ts";
8
+ export { mercuryTilesCredit, PICTURE_CREDITS, picturesCredit, type PictureCredit } from "./picture-credits.ts";
8
9
  export { addBody, decodeScene, defaultPortrait, encodeScene, PRESETS as PORTRAIT_PRESETS, resolve as layoutPortrait, type Item as PortraitItem, type Placed as PlacedItem, type Portrait, type Preset as PortraitPreset, type Resolved as PortraitLayout } from "./portrait/model.ts";
9
10
  export { LUMINOSITY_CLASSES, STAR_SUN, starLook, type LuminosityClass, type StarLook, type StarNumberName, type StarNumbers, type StarPart, type StarStatus } from "./star.ts";
10
11
  export { starLineSvg } from "./star-line.ts";
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export { drawnTilt, portrait } from "./pose.js";
5
5
  export { lineSvg, mix } from "./line.js";
6
6
  export { ringStrip } from "./scene/rings.js";
7
7
  export { embedCode, embedCredit, EMBED_KINDS, lineupCode, lineupCredit, portraitCode } from "./embed.js";
8
+ export { mercuryTilesCredit, PICTURE_CREDITS, picturesCredit } from "./picture-credits.js";
8
9
  export { addBody, decodeScene, defaultPortrait, encodeScene, PRESETS as PORTRAIT_PRESETS, resolve as layoutPortrait } from "./portrait/model.js";
9
10
  export { LUMINOSITY_CLASSES, STAR_SUN, starLook } from "./star.js";
10
11
  export { starLineSvg } from "./star-line.js";
@@ -30,6 +30,11 @@ export interface OrbiterFacts {
30
30
  en: string;
31
31
  ja: string;
32
32
  };
33
+ /** A short name for a button or a label: the initials the agency uses, or the first word. */
34
+ short: {
35
+ en: string;
36
+ ja: string;
37
+ };
33
38
  /** The body it goes round. */
34
39
  centre: "moon" | "mars";
35
40
  /** The agency or organisation that runs it. */
@@ -75,6 +80,10 @@ export declare const ORBITER_FACTS: {
75
80
  readonly en: "Lunar Reconnaissance Orbiter";
76
81
  readonly ja: "ルナー・リコネサンス・オービター";
77
82
  };
83
+ readonly short: {
84
+ readonly en: "LRO";
85
+ readonly ja: "LRO";
86
+ };
78
87
  readonly centre: "moon";
79
88
  readonly operator: "NASA (Goddard Space Flight Center)";
80
89
  readonly launch: {
@@ -118,6 +127,10 @@ export declare const ORBITER_FACTS: {
118
127
  readonly en: "Chandrayaan-2 orbiter";
119
128
  readonly ja: "チャンドラヤーン2号 オービター";
120
129
  };
130
+ readonly short: {
131
+ readonly en: "Chandrayaan-2";
132
+ readonly ja: "チャンドラヤーン2号";
133
+ };
121
134
  readonly centre: "moon";
122
135
  readonly operator: "ISRO";
123
136
  readonly launch: {
@@ -140,6 +153,10 @@ export declare const ORBITER_FACTS: {
140
153
  readonly en: "Danuri (KPLO)";
141
154
  readonly ja: "ダヌリ (KPLO)";
142
155
  };
156
+ readonly short: {
157
+ readonly en: "Danuri";
158
+ readonly ja: "ダヌリ";
159
+ };
143
160
  readonly centre: "moon";
144
161
  readonly operator: "KARI (Korea Aerospace Research Institute)";
145
162
  readonly launch: {
@@ -180,6 +197,10 @@ export declare const ORBITER_FACTS: {
180
197
  readonly en: "ARTEMIS P1";
181
198
  readonly ja: "ARTEMIS P1";
182
199
  };
200
+ readonly short: {
201
+ readonly en: "ARTEMIS P1";
202
+ readonly ja: "ARTEMIS P1";
203
+ };
183
204
  readonly centre: "moon";
184
205
  readonly operator: "NASA (University of California, Berkeley)";
185
206
  readonly launch: {
@@ -217,6 +238,10 @@ export declare const ORBITER_FACTS: {
217
238
  readonly en: "ARTEMIS P2";
218
239
  readonly ja: "ARTEMIS P2";
219
240
  };
241
+ readonly short: {
242
+ readonly en: "ARTEMIS P2";
243
+ readonly ja: "ARTEMIS P2";
244
+ };
220
245
  readonly centre: "moon";
221
246
  readonly operator: "NASA (University of California, Berkeley)";
222
247
  readonly launch: {
@@ -254,6 +279,10 @@ export declare const ORBITER_FACTS: {
254
279
  readonly en: "CAPSTONE";
255
280
  readonly ja: "キャップストーン";
256
281
  };
282
+ readonly short: {
283
+ readonly en: "CAPSTONE";
284
+ readonly ja: "CAPSTONE";
285
+ };
257
286
  readonly centre: "moon";
258
287
  readonly operator: "NASA (Advanced Space)";
259
288
  readonly launch: {
@@ -281,6 +310,10 @@ export declare const ORBITER_FACTS: {
281
310
  readonly en: "Mars Reconnaissance Orbiter";
282
311
  readonly ja: "マーズ・リコネサンス・オービター";
283
312
  };
313
+ readonly short: {
314
+ readonly en: "MRO";
315
+ readonly ja: "MRO";
316
+ };
284
317
  readonly centre: "mars";
285
318
  readonly operator: "NASA (JPL)";
286
319
  readonly launch: {
@@ -303,6 +336,10 @@ export declare const ORBITER_FACTS: {
303
336
  readonly en: "2001 Mars Odyssey";
304
337
  readonly ja: "2001マーズ・オデッセイ";
305
338
  };
339
+ readonly short: {
340
+ readonly en: "Odyssey";
341
+ readonly ja: "オデッセイ";
342
+ };
306
343
  readonly centre: "mars";
307
344
  readonly operator: "NASA (JPL)";
308
345
  readonly launch: {
@@ -333,6 +370,10 @@ export declare const ORBITER_FACTS: {
333
370
  readonly en: "MAVEN";
334
371
  readonly ja: "メイブン";
335
372
  };
373
+ readonly short: {
374
+ readonly en: "MAVEN";
375
+ readonly ja: "MAVEN";
376
+ };
336
377
  readonly centre: "mars";
337
378
  readonly operator: "NASA (Goddard Space Flight Center)";
338
379
  readonly launch: {
@@ -351,15 +392,15 @@ export declare const ORBITER_FACTS: {
351
392
  readonly short: "NGIMS";
352
393
  }];
353
394
  readonly about: {
354
- readonly en: "The Mars Atmosphere and Volatile Evolution orbiter studied how the upper atmosphere is lost to space from a 150 by 6,200 km orbit; contact was lost in December 2025 and NASA ended the mission in 2026, so its last known orbit is shown as modelled.";
355
- readonly ja: "火星の上層大気がどう宇宙へ失われるかを、150 × 6,200 kmの軌道から調べた探査機。2025年12月に交信が途絶え、2026年にNASAがミッションを終えたので、最後に分かっている軌道をモデルの軌道として示します。";
395
+ readonly en: "The Mars Atmosphere and Volatile Evolution orbiter studied how the upper atmosphere is lost to space from a 150 by 6,200 km orbit; contact was lost in December 2025 and NASA said on 2026-06-03 that the mission had ended, so its last known orbit is shown as modelled.";
396
+ readonly ja: "火星の上層大気がどう宇宙へ失われるかを、150 × 6,200 kmの軌道から調べた探査機。2025年12月に交信が途絶え、2026-06-03にNASAがミッションが終わったと発表したので、最後に分かっている軌道をモデルの軌道として示します。";
356
397
  };
357
398
  readonly status: {
358
399
  readonly state: "ended";
359
400
  readonly since: "2025-12-06";
360
401
  readonly note: {
361
- readonly en: "Horizons' page: no contact since 2025-12-06, with evidence of an unplanned change of velocity on 2025-12-04; its fit reaches 2025-12-04 and its track ends 2026-03-01.";
362
- readonly ja: "Horizonsのページ: 2025-12-06から交信がなく、2025-12-04に予定外の速度変化があった形跡があります。合わせた期間は2025-12-04まで、経路データは2026-03-01で終わります。";
402
+ readonly en: "Horizons' page: no contact since 2025-12-06, with evidence of an unplanned change of velocity on 2025-12-04; its fit reaches 2025-12-04 and its track ends 2026-03-01. NASA's news release of 2026-06-03, \"NASA Says Farewell to MAVEN Mars Mission\", says the mission has ended.";
403
+ readonly ja: "Horizonsのページ: 2025-12-06から交信がなく、2025-12-04に予定外の速度変化があった形跡があります。合わせた期間は2025-12-04まで、経路データは2026-03-01で終わります。NASAは2026-06-03の発表「NASA Says Farewell to MAVEN Mars Mission」で、ミッションが終わったと伝えました。";
363
404
  };
364
405
  };
365
406
  readonly horizonsId: -202;
@@ -369,6 +410,10 @@ export declare const ORBITER_FACTS: {
369
410
  readonly en: "Mars Express";
370
411
  readonly ja: "マーズ・エクスプレス";
371
412
  };
413
+ readonly short: {
414
+ readonly en: "Mars Express";
415
+ readonly ja: "マーズ・エクスプレス";
416
+ };
372
417
  readonly centre: "mars";
373
418
  readonly operator: "ESA";
374
419
  readonly launch: {
@@ -391,6 +436,10 @@ export declare const ORBITER_FACTS: {
391
436
  readonly en: "ExoMars Trace Gas Orbiter";
392
437
  readonly ja: "エクソマーズ・トレース・ガス・オービター";
393
438
  };
439
+ readonly short: {
440
+ readonly en: "TGO";
441
+ readonly ja: "TGO";
442
+ };
394
443
  readonly centre: "mars";
395
444
  readonly operator: "ESA (with Roscosmos)";
396
445
  readonly launch: {
@@ -425,6 +474,10 @@ export declare const ORBITER_FACTS: {
425
474
  readonly en: "Hope (Emirates Mars Mission)";
426
475
  readonly ja: "ホープ (エミレーツ・マーズ・ミッション)";
427
476
  };
477
+ readonly short: {
478
+ readonly en: "Hope";
479
+ readonly ja: "ホープ";
480
+ };
428
481
  readonly centre: "mars";
429
482
  readonly operator: "Mohammed Bin Rashid Space Centre (United Arab Emirates)";
430
483
  readonly launch: {
@@ -456,6 +509,10 @@ export declare const ORBITER_FACTS: {
456
509
  readonly en: "Tianwen-1 orbiter";
457
510
  readonly ja: "天問1号 オービター";
458
511
  };
512
+ readonly short: {
513
+ readonly en: "Tianwen-1";
514
+ readonly ja: "天問1号";
515
+ };
459
516
  readonly centre: "mars";
460
517
  readonly operator: "CNSA";
461
518
  readonly launch: {