@johnmorrisdotca/wakusei-planets 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +3 -3
- package/dist/element.js +7 -6
- package/dist/place-marks.d.ts +93 -1
- package/dist/place-marks.js +120 -7
- package/dist/places.d.ts +1 -1
- package/dist/places.js +1 -1
- package/dist/scene/place-layer.js +68 -5
- package/dist/scene/textures.d.ts +2 -2
- package/dist/space/element.d.ts +11 -0
- package/dist/space/element.js +35 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.44.0] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **Names of the great features are written on a body** (MODULES-1231). When the body looked at is big enough, `surface-names` (on unless `off`) writes its most important named features on the surface: fame first, then size (`placeRank`). They face the camera, fade at the limb, and stay apart so they do not crowd: a name is not written over a dot of the places asked for, a craft or another body's dot, another body's name, or another feature name, and gives way when it would be. A number is how many. A press sends `wakusei-place`. Nothing is drawn for a name.
|
|
8
|
+
|
|
9
|
+
- **Written names keep out of the way** (MODULES-1231). A name is not written over a dot of the places asked for, a craft or another body's dot, another body's name, or another name, and gives way when it would be: one that only names may move up to 24 pixels first, so a famous crater such as Tycho still gets its name beside a larger one. A press that begins on a name goes on to the view's controls, so a drag that starts on one turns the body; a tap that did not move picks the place (`wakusei-place`), by mouse or touch. The place's tip on hover, which the first cut of the names had dropped, is back, and names are not listed in `placesShown`.
|
|
10
|
+
|
|
5
11
|
## [0.43.0] - 2026-11-13
|
|
6
12
|
|
|
7
13
|
- **The space view draws the deep-space craft** (MODULES-1207). `spacecraft` on `<wakusei-space>` (and `space.spacecraft`) is off by default. `"all"` or `true` draws every craft whose record covers the date, as one points object with a name each; a space-separated list draws those. A craft outside its record is not drawn and `stats.spacecraft.status[id]` is `"outside"`. Each table loads the first time that craft is shown. `sight()` and `wakusei-sight` give each drawn craft `{ id, kind: "spacecraft" }` using the craft's own id. A press sends `wakusei-body-click` with that kind and does not go to the craft. No path line.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Wakusei Planets runs in the browser of a phone, a tablet or a computer: nothing
|
|
|
19
19
|
|
|
20
20
|
<p align="center"><img alt="The demo on a desk: Saturn in the painted look, turning in the big view, with the page's links to the portrait builder, the colouring sheets, the space view, the star page and the size line-up above it, and the choice of body and its moons below" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-desk.webp" width="620"> <img alt="The same page on a phone: the same links in rows, and Saturn in the painted look below them" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/main/docs/images/home-phone.webp" width="200"></p>
|
|
21
21
|
|
|
22
|
-
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
22
|
+
<p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.44.0/docs/images/lineup-desk.png" width="640"></p>
|
|
23
23
|
|
|
24
24
|
## Who it is for
|
|
25
25
|
|
|
@@ -388,7 +388,7 @@ The tiles of every body share one 48 MB budget, six loads at a time for a source
|
|
|
388
388
|
|
|
389
389
|
## The portrait builder
|
|
390
390
|
|
|
391
|
-
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.
|
|
391
|
+
<p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.44.0/docs/images/portrait-family.png" width="640"></p>
|
|
392
392
|
|
|
393
393
|
[The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
|
|
394
394
|
|
|
@@ -534,7 +534,7 @@ BODIES.pluto.kind; // "dwarf-planet"
|
|
|
534
534
|
|
|
535
535
|
If this package helps a paper, a talk or a class, please cite it as software. GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA; in plain text:
|
|
536
536
|
|
|
537
|
-
> Morris, J. (2026). *Wakusei Planets* (version 0.
|
|
537
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.44.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
|
|
538
538
|
|
|
539
539
|
Cite the version you used (`npm ls @johnmorrisdotca/wakusei-planets`), and cite the sources of the numbers you use as well: [NOTICE.md](NOTICE.md) names each one, with the paper or the page it was read from (the IAU working group's report for sizes and poles, VSOP87B, ELP2000-82B, L1.2 and TASS1.7 for positions, and NASA's JPL Horizons for the fits and the spacecraft).
|
|
540
540
|
|
package/dist/element.js
CHANGED
|
@@ -22,7 +22,7 @@ import { delegates, onRegister } from "./scene/store.js";
|
|
|
22
22
|
import { setThreeLoader, takeRenderer } from "./scene/shared.js";
|
|
23
23
|
import { turn as turnVec } from "./vec.js";
|
|
24
24
|
import { findPlace, PLACE_BODIES } from "./places.js";
|
|
25
|
-
import {
|
|
25
|
+
import { marksToShow, readPlaceLayers, readSurfaceNames, turnToPlace } from "./place-marks.js";
|
|
26
26
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "./scene/place-layer.js";
|
|
27
27
|
export { setThreeLoader };
|
|
28
28
|
export { placeLine, setPlacesLoader } from "./scene/place-layer.js";
|
|
@@ -101,7 +101,7 @@ const TEMPLATE = `<style>
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
export class WakuseiBody extends HTMLElement {
|
|
104
|
-
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", ...NAME_LABEL_ATTRIBUTES];
|
|
104
|
+
static observedAttributes = ["body", "star", "quality", ...STAR_ATTRS, "look", "size", "time", "tilt", "pitch", "phase", "meridian", "turn", "rate", "moons", "range", "scale-to", "span-km", "fit", "live", "texture-base", "texture-far-base", "tiles", "data", "lang", "labels", "places", "surface-names", ...NAME_LABEL_ATTRIBUTES];
|
|
105
105
|
#stage;
|
|
106
106
|
#state = "line";
|
|
107
107
|
#renderer;
|
|
@@ -346,8 +346,9 @@ export class WakuseiBody extends HTMLElement {
|
|
|
346
346
|
/** Lay the marks of the places over the picture as the scene state has it, or take them away. Draws nothing. */
|
|
347
347
|
#markPlaces(state = this.#sceneState) {
|
|
348
348
|
const layers = this.places;
|
|
349
|
+
const names = readSurfaceNames(this.getAttribute("surface-names"));
|
|
349
350
|
const shaded = this.look !== "line" && this.#view !== undefined && !this.hasAttribute("star");
|
|
350
|
-
if (layers.length === 0 || !shaded || state === undefined) {
|
|
351
|
+
if ((!names.on && layers.length === 0) || !shaded || state === undefined) {
|
|
351
352
|
if (this.#placeLayer !== undefined) {
|
|
352
353
|
this.#placeLayer.dispose();
|
|
353
354
|
this.#placeLayer = undefined;
|
|
@@ -393,7 +394,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
393
394
|
const facts = this.#facts();
|
|
394
395
|
const ax = facts.axesKm;
|
|
395
396
|
const scale = ax ? [ax[1] / facts.radiusKm, ax[2] / facts.radiusKm, ax[0] / facts.radiusKm] : [1, 1 - facts.flattening, 1];
|
|
396
|
-
const marks =
|
|
397
|
+
const marks = marksToShow(this.#placeList.list, layers, {
|
|
397
398
|
centre: [0, 0, 0],
|
|
398
399
|
radius: 1,
|
|
399
400
|
pole: state.pose.pole,
|
|
@@ -404,7 +405,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
404
405
|
width: w,
|
|
405
406
|
height: h,
|
|
406
407
|
radiusPx: (Math.min(w, h) / 2) * (state.zoom / state.extent),
|
|
407
|
-
}, facts.radiusKm);
|
|
408
|
+
}, facts.radiusKm, names, [], this.getAttribute("lang") === "ja" ? "ja" : "en");
|
|
408
409
|
this.#placeLayer.set(marks);
|
|
409
410
|
}
|
|
410
411
|
/** What the element is doing now. */
|
|
@@ -510,7 +511,7 @@ export class WakuseiBody extends HTMLElement {
|
|
|
510
511
|
this.#refreshLimits();
|
|
511
512
|
}
|
|
512
513
|
this.#lastAnchors = -1;
|
|
513
|
-
if (name === "places" || name === "lang" || name === "body" || name === "look" || name === "star")
|
|
514
|
+
if (name === "places" || name === "lang" || name === "body" || name === "look" || name === "star" || name === "surface-names")
|
|
514
515
|
this.#markPlaces();
|
|
515
516
|
this.#queue();
|
|
516
517
|
}
|
package/dist/place-marks.d.ts
CHANGED
|
@@ -117,6 +117,12 @@ export interface PlaceMark {
|
|
|
117
117
|
layer: PlaceLayer;
|
|
118
118
|
x: number;
|
|
119
119
|
y: number;
|
|
120
|
+
/** 1 facing the camera, falling to 0 at the limb. Set on a name. */
|
|
121
|
+
fade?: number;
|
|
122
|
+
/** The name is written, not only a dot. */
|
|
123
|
+
label?: boolean;
|
|
124
|
+
/** A name only: no layer the page asked for calls for this place, so it is not one of the places shown (`placesShown`). */
|
|
125
|
+
nameOnly?: boolean;
|
|
120
126
|
}
|
|
121
127
|
/**
|
|
122
128
|
* The rules that keep the marks quiet, in CSS pixels: nothing is marked on a body under `fromPx` of radius on the screen; a named feature is marked once it is `featureFromPx` across (a famous one at any size);
|
|
@@ -145,6 +151,7 @@ export declare const MARK_RULES: {
|
|
|
145
151
|
* @param layers - The layers to show.
|
|
146
152
|
* @param view - The body as drawn.
|
|
147
153
|
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
154
|
+
* @param options - `limit` caps how many marks, `gapPx` is how far apart they stay, and `label` writes the name, `avoid` lists boxes a name keeps clear of (dots, other names) `lang` is the language the name is written in, and `nudge` lets a name move a little off its place (by up to 24 pixels) to find room. All may be left out.
|
|
148
155
|
* @returns The marks, in the order they were chosen.
|
|
149
156
|
*
|
|
150
157
|
* @example
|
|
@@ -157,7 +164,92 @@ export declare const MARK_RULES: {
|
|
|
157
164
|
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
158
165
|
* ```
|
|
159
166
|
*/
|
|
160
|
-
export declare function placeMarks(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number
|
|
167
|
+
export declare function placeMarks(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number, options?: {
|
|
168
|
+
limit?: number;
|
|
169
|
+
gapPx?: number;
|
|
170
|
+
label?: boolean;
|
|
171
|
+
avoid?: readonly Obstacle[];
|
|
172
|
+
lang?: "en" | "ja";
|
|
173
|
+
nudge?: boolean;
|
|
174
|
+
}): PlaceMark[];
|
|
175
|
+
/**
|
|
176
|
+
* A box on the screen, by its centre and half sizes in pixels, that a written name keeps clear of: another dot, a craft's dot, another name. `id` is the place it belongs to, which a name of that place may cover.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import type { Obstacle } from "@johnmorrisdotca/wakusei-planets/places";
|
|
181
|
+
*
|
|
182
|
+
* const craftDot: Obstacle = { x: 400, y: 300, halfWidth: 8, halfHeight: 8 };
|
|
183
|
+
* console.log(craftDot.halfWidth * 2);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export interface Obstacle {
|
|
187
|
+
x: number;
|
|
188
|
+
y: number;
|
|
189
|
+
halfWidth: number;
|
|
190
|
+
halfHeight: number;
|
|
191
|
+
id?: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* How important a place is for a name on the surface. Lower is more important. Fame comes first: a famous place ranks ahead of every place that is not. Within each group a larger feature ranks ahead of a smaller one (its diameter in kilometres is taken off the rank). A place with no size ranks last in its group.
|
|
195
|
+
*
|
|
196
|
+
* @param place - One place.
|
|
197
|
+
* @returns The rank.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
202
|
+
* import { placeRank } from "@johnmorrisdotca/wakusei-planets/places";
|
|
203
|
+
*
|
|
204
|
+
* const tycho = PLACES_MOON.find((place) => place.id === "moon/tycho")!;
|
|
205
|
+
* const small = PLACES_MOON.find((place) => place.kind === "feature" && place.famous !== true)!;
|
|
206
|
+
* console.log(placeRank(tycho) < placeRank(small));
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
export declare function placeRank(place: Place): number;
|
|
210
|
+
/**
|
|
211
|
+
* Read the `surface-names` attribute. Omitted, empty or `on` is on, with the view's own cap. `off` or `0` is off. A positive whole number is on and is the most names to show.
|
|
212
|
+
*
|
|
213
|
+
* @param value - The attribute's value, or null when it is omitted.
|
|
214
|
+
* @returns Whether names are on, and `limit`: the most names, or null when the attribute sets no number.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
219
|
+
*
|
|
220
|
+
* console.log(readSurfaceNames(null).on, readSurfaceNames("8").limit, readSurfaceNames("off").on);
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export declare function readSurfaceNames(value: string | null): {
|
|
224
|
+
on: boolean;
|
|
225
|
+
limit: number | null;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* The marks to lay for the places a page asked for and, when names are on, the most important features written as names. A name keeps its place ahead of a dot on the same feature. Names use a wider gap so the words do not crowd, and they fade toward the limb.
|
|
229
|
+
*
|
|
230
|
+
* @param places - The body's list.
|
|
231
|
+
* @param layers - The layers asked for, possibly none.
|
|
232
|
+
* @param view - The body as drawn.
|
|
233
|
+
* @param radiusKm - The body's radius in kilometres.
|
|
234
|
+
* @param names - From `readSurfaceNames`.
|
|
235
|
+
* @param keepClear - Boxes on the screen the names stay off: other bodies' dots, craft, other names. May be left out.
|
|
236
|
+
* @param lang - The language the names are written in, to tell how wide each is. English when left out.
|
|
237
|
+
* @returns The marks.
|
|
238
|
+
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* import { marksToShow, readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
242
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
243
|
+
*
|
|
244
|
+
* 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],
|
|
245
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
246
|
+
* console.log(marksToShow(PLACES_MOON, [], view, 1737.4, readSurfaceNames(null)).some((mark) => mark.place.id === "moon/tycho"));
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function marksToShow(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number, names: {
|
|
250
|
+
on: boolean;
|
|
251
|
+
limit: number | null;
|
|
252
|
+
}, keepClear?: readonly Obstacle[], lang?: "en" | "ja"): PlaceMark[];
|
|
161
253
|
/**
|
|
162
254
|
* The turn of a body that brings a place to the middle of the disc, for a view that is turned by a yaw about the body's pole and then a tilt about the screen's x axis, looking along -z (the `<wakusei-body>` view):
|
|
163
255
|
* the yaw and the tilt in degrees. Where the pole is tipped so far that no yaw puts the place in the plane the tilt turns, it comes as near as it can.
|
package/dist/place-marks.js
CHANGED
|
@@ -102,6 +102,7 @@ export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4
|
|
|
102
102
|
* @param layers - The layers to show.
|
|
103
103
|
* @param view - The body as drawn.
|
|
104
104
|
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
105
|
+
* @param options - `limit` caps how many marks, `gapPx` is how far apart they stay, and `label` writes the name, `avoid` lists boxes a name keeps clear of (dots, other names) `lang` is the language the name is written in, and `nudge` lets a name move a little off its place (by up to 24 pixels) to find room. All may be left out.
|
|
105
106
|
* @returns The marks, in the order they were chosen.
|
|
106
107
|
*
|
|
107
108
|
* @example
|
|
@@ -114,7 +115,7 @@ export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4
|
|
|
114
115
|
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
115
116
|
* ```
|
|
116
117
|
*/
|
|
117
|
-
export function placeMarks(places, layers, view, radiusKm) {
|
|
118
|
+
export function placeMarks(places, layers, view, radiusKm, options) {
|
|
118
119
|
if (layers.length === 0 || !(view.radiusPx >= MARK_RULES.fromPx))
|
|
119
120
|
return [];
|
|
120
121
|
const wanted = [];
|
|
@@ -126,28 +127,140 @@ export function placeMarks(places, layers, view, radiusKm) {
|
|
|
126
127
|
continue;
|
|
127
128
|
wanted.push(place);
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
if (options?.label === true)
|
|
131
|
+
wanted.sort((a, b) => placeRank(a) - placeRank(b));
|
|
132
|
+
else {
|
|
133
|
+
const rank = (place) => (place.kind === "feature" ? 2 : 0) + (place.famous === true ? 0 : 1);
|
|
134
|
+
wanted.sort((a, b) => rank(a) - rank(b) || (b.feature?.diameterKm ?? 0) - (a.feature?.diameterKm ?? 0));
|
|
135
|
+
}
|
|
131
136
|
const most = Math.max(8, Math.min(MARK_RULES.most, Math.round(view.radiusPx / MARK_RULES.sharePx)));
|
|
137
|
+
const cap = options?.limit === undefined ? most : Math.max(0, Math.min(MARK_RULES.most, options.limit));
|
|
138
|
+
const gap = options?.gapPx ?? MARK_RULES.gapPx;
|
|
132
139
|
const out = [];
|
|
133
140
|
for (const place of wanted) {
|
|
134
|
-
if (out.length >=
|
|
141
|
+
if (out.length >= cap)
|
|
135
142
|
break;
|
|
136
143
|
const { point, normal } = surfacePoint(view, place.lat, place.lon);
|
|
137
144
|
const sight = view.eye !== undefined ? [view.eye[0] - point[0], view.eye[1] - point[1], view.eye[2] - point[2]] : (view.toward ?? [0, 0, 1]);
|
|
138
145
|
const len = Math.hypot(sight[0], sight[1], sight[2]) || 1;
|
|
146
|
+
const face = dot(normal, sight) / len;
|
|
139
147
|
// a little short of the limb: a mark seen edge-on is a crowd of dots on the rim, and the surface there is a sliver
|
|
140
|
-
if (
|
|
148
|
+
if (face < 0.12)
|
|
141
149
|
continue;
|
|
142
150
|
const at = view.project(point);
|
|
143
151
|
if (at === null || at.x < 0 || at.y < 0 || at.x > view.width || at.y > view.height)
|
|
144
152
|
continue;
|
|
145
|
-
|
|
153
|
+
let x = at.x;
|
|
154
|
+
let y = at.y;
|
|
155
|
+
if (options?.label === true) {
|
|
156
|
+
const lang = options.lang ?? "en";
|
|
157
|
+
const mine = { ...nameBox(place.name[lang]), id: place.id };
|
|
158
|
+
const clash = (px, py) => {
|
|
159
|
+
const box = { x: px, y: py, ...mine };
|
|
160
|
+
if (px - mine.halfWidth < 0 || px + mine.halfWidth > view.width || py - mine.halfHeight < 0 || py + mine.halfHeight > view.height)
|
|
161
|
+
return true;
|
|
162
|
+
if ((options.avoid ?? []).some((one) => one.id !== place.id && touches(box, one)))
|
|
163
|
+
return true;
|
|
164
|
+
return out.some((mark) => mark.label === true && touches(box, { x: mark.x, y: mark.y, ...nameBox(mark.place.name[lang]) }));
|
|
165
|
+
};
|
|
166
|
+
// a name stays on its feature unless it may nudge: it moves a little up, down or aside to find room, and gives way if there is none. A name that stands in for a dot the page asked for does not nudge: its mark is where the place is.
|
|
167
|
+
let spot;
|
|
168
|
+
for (const [dx, dy] of options.nudge === true ? [[0, 0], [0, -10], [0, 10], [0, -18], [0, 18], [-24, 0], [24, 0]] : [[0, 0]]) {
|
|
169
|
+
if (!clash(x + dx, y + dy)) {
|
|
170
|
+
spot = { x: x + dx, y: y + dy };
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (spot === undefined)
|
|
175
|
+
continue;
|
|
176
|
+
x = spot.x;
|
|
177
|
+
y = spot.y;
|
|
178
|
+
}
|
|
179
|
+
if (x < 0 || y < 0 || x > view.width || y > view.height)
|
|
180
|
+
continue;
|
|
181
|
+
if (options?.label !== true && out.some((mark) => Math.hypot(mark.x - x, mark.y - y) < gap))
|
|
146
182
|
continue;
|
|
147
|
-
out.push({ place, layer: layerOf(place.kind), x:
|
|
183
|
+
out.push({ place, layer: layerOf(place.kind), x, y, ...(options?.label === true ? { label: true, fade: Math.min(1, (face - 0.12) / 0.4) } : {}) });
|
|
148
184
|
}
|
|
149
185
|
return out;
|
|
150
186
|
}
|
|
187
|
+
/** The half sizes of a written name's box, from its length (the names are 12 pixels, semibold). */
|
|
188
|
+
const nameBox = (text) => ({ halfWidth: Math.ceil(text.length * 3.7) + 5, halfHeight: 9 });
|
|
189
|
+
const touches = (a, b) => Math.abs(a.x - b.x) < a.halfWidth + b.halfWidth && Math.abs(a.y - b.y) < a.halfHeight + b.halfHeight;
|
|
190
|
+
/**
|
|
191
|
+
* How important a place is for a name on the surface. Lower is more important. Fame comes first: a famous place ranks ahead of every place that is not. Within each group a larger feature ranks ahead of a smaller one (its diameter in kilometres is taken off the rank). A place with no size ranks last in its group.
|
|
192
|
+
*
|
|
193
|
+
* @param place - One place.
|
|
194
|
+
* @returns The rank.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```ts
|
|
198
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
199
|
+
* import { placeRank } from "@johnmorrisdotca/wakusei-planets/places";
|
|
200
|
+
*
|
|
201
|
+
* const tycho = PLACES_MOON.find((place) => place.id === "moon/tycho")!;
|
|
202
|
+
* const small = PLACES_MOON.find((place) => place.kind === "feature" && place.famous !== true)!;
|
|
203
|
+
* console.log(placeRank(tycho) < placeRank(small));
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export function placeRank(place) {
|
|
207
|
+
const size = Math.min(1_000_000, place.feature?.diameterKm ?? 0);
|
|
208
|
+
return (place.famous === true ? 0 : 1_000_000) - size;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Read the `surface-names` attribute. Omitted, empty or `on` is on, with the view's own cap. `off` or `0` is off. A positive whole number is on and is the most names to show.
|
|
212
|
+
*
|
|
213
|
+
* @param value - The attribute's value, or null when it is omitted.
|
|
214
|
+
* @returns Whether names are on, and `limit`: the most names, or null when the attribute sets no number.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```ts
|
|
218
|
+
* import { readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
219
|
+
*
|
|
220
|
+
* console.log(readSurfaceNames(null).on, readSurfaceNames("8").limit, readSurfaceNames("off").on);
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
export function readSurfaceNames(value) {
|
|
224
|
+
if (value === null || value === "" || value === "on")
|
|
225
|
+
return { on: true, limit: null };
|
|
226
|
+
if (value === "off" || value === "0")
|
|
227
|
+
return { on: false, limit: null };
|
|
228
|
+
const n = Number(value);
|
|
229
|
+
if (Number.isInteger(n) && n > 0 && n <= 60)
|
|
230
|
+
return { on: true, limit: n };
|
|
231
|
+
return { on: true, limit: null };
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The marks to lay for the places a page asked for and, when names are on, the most important features written as names. A name keeps its place ahead of a dot on the same feature. Names use a wider gap so the words do not crowd, and they fade toward the limb.
|
|
235
|
+
*
|
|
236
|
+
* @param places - The body's list.
|
|
237
|
+
* @param layers - The layers asked for, possibly none.
|
|
238
|
+
* @param view - The body as drawn.
|
|
239
|
+
* @param radiusKm - The body's radius in kilometres.
|
|
240
|
+
* @param names - From `readSurfaceNames`.
|
|
241
|
+
* @param keepClear - Boxes on the screen the names stay off: other bodies' dots, craft, other names. May be left out.
|
|
242
|
+
* @param lang - The language the names are written in, to tell how wide each is. English when left out.
|
|
243
|
+
* @returns The marks.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* import { marksToShow, readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
248
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
249
|
+
*
|
|
250
|
+
* 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],
|
|
251
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
252
|
+
* console.log(marksToShow(PLACES_MOON, [], view, 1737.4, readSurfaceNames(null)).some((mark) => mark.place.id === "moon/tycho"));
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
export function marksToShow(places, layers, view, radiusKm, names, keepClear = [], lang = "en") {
|
|
256
|
+
const asked = layers.length === 0 ? [] : placeMarks(places, layers, view, radiusKm);
|
|
257
|
+
// a mark the page drew always wins over a name: a name keeps off every dot that stays, and off what the page itself draws over the body
|
|
258
|
+
const avoid = [...keepClear, ...asked.map((mark) => ({ x: mark.x, y: mark.y, halfWidth: 12, halfHeight: 12, id: mark.place.id }))];
|
|
259
|
+
const named = names.on ? placeMarks(places, ["feature"], view, radiusKm, { ...(names.limit === null ? {} : { limit: names.limit }), gapPx: 48, label: true, avoid, lang, nudge: !layers.includes("feature") }) : [];
|
|
260
|
+
const ids = new Set(named.map((mark) => mark.place.id));
|
|
261
|
+
const wanted = new Set(asked.map((mark) => mark.place.id));
|
|
262
|
+
return [...named.map((mark) => (wanted.has(mark.place.id) || layers.includes("feature") ? mark : { ...mark, nameOnly: true })), ...asked.filter((mark) => !ids.has(mark.place.id))];
|
|
263
|
+
}
|
|
151
264
|
/**
|
|
152
265
|
* The turn of a body that brings a place to the middle of the disc, for a view that is turned by a yaw about the body's pole and then a tilt about the screen's x axis, looking along -z (the `<wakusei-body>` view):
|
|
153
266
|
* the yaw and the tilt in degrees. Where the pole is tipped so far that no yaw puts the place in the plane the tilt turns, it comes as near as it can.
|
package/dist/places.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BodyId } from "./facts.ts";
|
|
2
2
|
import { type When } from "./when.ts";
|
|
3
3
|
export type { When } from "./when.ts";
|
|
4
|
-
export { layerOf, MARK_RULES, PLACE_LAYERS, placeMarks, pointUnder, readPlaceLayers, spotView, surfacePoint, turnToPlace, type PlaceLayer, type PlaceMark, type SpotView, type SurfaceSpot, type SurfaceView } from "./place-marks.ts";
|
|
4
|
+
export { layerOf, MARK_RULES, PLACE_LAYERS, marksToShow, placeMarks, placeRank, type Obstacle, pointUnder, readPlaceLayers, readSurfaceNames, spotView, surfacePoint, turnToPlace, type PlaceLayer, type PlaceMark, type SpotView, type SurfaceSpot, type SurfaceView } from "./place-marks.ts";
|
|
5
5
|
/**
|
|
6
6
|
* What a place is: a `crewed` landing (an Apollo lunar module), a `landing` (a lander that worked after touchdown), a `rover` that drove there, a `crash` (a craft that hit the surface and was lost, by accident or at the end of its mission), an
|
|
7
7
|
* `impact` (a craft sent to hit it on purpose), an `entry` (a probe or orbiter lost in the atmosphere of Venus, Jupiter or Saturn: no surface was reached or none is there), a `planned` landing (announced, not flown) or a named `feature` of the surface.
|
package/dist/places.js
CHANGED
|
@@ -5,7 +5,7 @@ import { apparent } from "./ephemeris.js";
|
|
|
5
5
|
import { BODIES } from "./facts.js";
|
|
6
6
|
import { cross, dot } from "./vec.js";
|
|
7
7
|
import { moment } from "./when.js";
|
|
8
|
-
export { layerOf, MARK_RULES, PLACE_LAYERS, placeMarks, pointUnder, readPlaceLayers, spotView, surfacePoint, turnToPlace } from "./place-marks.js";
|
|
8
|
+
export { layerOf, MARK_RULES, PLACE_LAYERS, marksToShow, placeMarks, placeRank, pointUnder, readPlaceLayers, readSurfaceNames, spotView, surfacePoint, turnToPlace } from "./place-marks.js";
|
|
9
9
|
/**
|
|
10
10
|
* The credit a page that shows places owes each source, one row for every `source.id` the tables use: the line to print, the licence or terms it rests on and the address. The lander catalogue's is a condition of its licence (CC BY 4.0: "data from GCAT (J. McDowell,
|
|
11
11
|
* planet4589.org/space/gcat)"); the others are US government works, credited as their owners ask, and the papers' coordinates are facts (each record's `source.url` names the paper).
|
|
@@ -8,6 +8,9 @@ const STYLE = `.wk-places{position:absolute;inset:0;pointer-events:none;overflow
|
|
|
8
8
|
.wk-place:focus-visible{outline:2px solid #6cd0ff;outline-offset:-3px;border-radius:50%}
|
|
9
9
|
.wk-place-tip{position:absolute;left:0;top:0;max-width:min(260px,80%);padding:3px 7px;border-radius:5px;background:rgba(10,14,22,.86);color:#fff;font:12px/1.35 var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;visibility:hidden}
|
|
10
10
|
.wk-place-tip small{display:block;font-size:11px;opacity:.8}
|
|
11
|
+
.wk-place[data-name]{width:auto;height:auto;margin:0;padding:0 3px;color:#fff;font:600 12px/1.2 var(--wakusei-place-font,system-ui,-apple-system,sans-serif);white-space:nowrap;text-shadow:0 1px 2px #000,0 0 3px #000;pointer-events:auto}
|
|
12
|
+
.wk-place[data-pure]{pointer-events:none}
|
|
13
|
+
.wk-place[data-name]::before{display:none}
|
|
11
14
|
.wk-place-tip[data-on]{visibility:visible}`;
|
|
12
15
|
const KIND_WORD = {
|
|
13
16
|
crewed: { en: "crewed landing", ja: "有人着陸" },
|
|
@@ -144,7 +147,7 @@ export function createPlaceLayer(root, options) {
|
|
|
144
147
|
button.addEventListener("pointerleave", () => hideTip(id));
|
|
145
148
|
button.addEventListener("focus", () => showTip(id));
|
|
146
149
|
button.addEventListener("blur", () => hideTip(id));
|
|
147
|
-
// a press on a
|
|
150
|
+
// a press on a dot is the dot's, not the start of a drag or a pick of the body under it; a touch shows the name as well. (A written name takes no press at all: see `name press` below.)
|
|
148
151
|
button.addEventListener("pointerdown", (event) => {
|
|
149
152
|
event.stopPropagation();
|
|
150
153
|
if (event.pointerType !== "mouse")
|
|
@@ -158,6 +161,42 @@ export function createPlaceLayer(root, options) {
|
|
|
158
161
|
});
|
|
159
162
|
return button;
|
|
160
163
|
};
|
|
164
|
+
// name press: a written name lies over the middle of the body, where a drag starts, and the view's controls leave a press that begins on a button to the button. So a name takes no pointer (CSS) and a press goes
|
|
165
|
+
// on to the controls, which turn the body; a tap that did not move, up over a name, picks its place.
|
|
166
|
+
const host = root.host;
|
|
167
|
+
let pressed = null;
|
|
168
|
+
const nameDown = (event) => {
|
|
169
|
+
pressed = event.button === 0 && event.composedPath().includes(host) ? { x: event.clientX, y: event.clientY, id: event.pointerId } : null;
|
|
170
|
+
};
|
|
171
|
+
const nameUp = (event) => {
|
|
172
|
+
const down = pressed;
|
|
173
|
+
pressed = null;
|
|
174
|
+
if (down === null || down.id !== event.pointerId || Math.hypot(event.clientX - down.x, event.clientY - down.y) > 6)
|
|
175
|
+
return;
|
|
176
|
+
const first = event.composedPath()[0];
|
|
177
|
+
// a press on a dot was the dot's
|
|
178
|
+
if (first instanceof Element && first.classList.contains("wk-place"))
|
|
179
|
+
return;
|
|
180
|
+
let best;
|
|
181
|
+
for (const entry of held.values()) {
|
|
182
|
+
if (entry.button.dataset.pure === undefined || Number(entry.button.style.opacity || "1") < 0.2)
|
|
183
|
+
continue;
|
|
184
|
+
const r = entry.button.getBoundingClientRect();
|
|
185
|
+
if (event.clientX < r.left || event.clientX > r.right || event.clientY < r.top || event.clientY > r.bottom)
|
|
186
|
+
continue;
|
|
187
|
+
const away = Math.hypot(event.clientX - (r.left + r.right) / 2, event.clientY - (r.top + r.bottom) / 2);
|
|
188
|
+
if (best === undefined || away < best.away)
|
|
189
|
+
best = { entry, away };
|
|
190
|
+
}
|
|
191
|
+
if (best !== undefined)
|
|
192
|
+
options.pick(best.entry.mark.place, { x: best.entry.x, y: best.entry.y });
|
|
193
|
+
};
|
|
194
|
+
const nameCancel = () => {
|
|
195
|
+
pressed = null;
|
|
196
|
+
};
|
|
197
|
+
window.addEventListener("pointerdown", nameDown, true);
|
|
198
|
+
window.addEventListener("pointerup", nameUp, true);
|
|
199
|
+
window.addEventListener("pointercancel", nameCancel, true);
|
|
161
200
|
return {
|
|
162
201
|
set(marks) {
|
|
163
202
|
const lang = options.lang();
|
|
@@ -173,15 +212,36 @@ export function createPlaceLayer(root, options) {
|
|
|
173
212
|
box.insertBefore(button, tip);
|
|
174
213
|
}
|
|
175
214
|
entry.mark = mark;
|
|
176
|
-
if (entry.lang !== lang) {
|
|
215
|
+
if (entry.lang !== lang || entry.button.dataset.name !== (mark.label === true ? "1" : undefined)) {
|
|
177
216
|
entry.lang = lang;
|
|
178
217
|
entry.button.dataset.layer = mark.layer;
|
|
218
|
+
if (mark.label === true) {
|
|
219
|
+
entry.button.dataset.name = "1";
|
|
220
|
+
entry.button.textContent = mark.place.name[lang];
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
delete entry.button.dataset.name;
|
|
224
|
+
entry.button.textContent = "";
|
|
225
|
+
}
|
|
179
226
|
entry.button.setAttribute("aria-label", `${mark.place.name[lang]}, ${placeLine(mark.place, lang)}`);
|
|
180
227
|
}
|
|
181
|
-
|
|
228
|
+
// a name for a place the page asked for stands in for its dot and takes the press as the dot does; a name only is the picture's, and takes no press
|
|
229
|
+
const pure = mark.label === true && mark.nameOnly === true ? "1" : undefined;
|
|
230
|
+
if (entry.button.dataset.pure !== pure) {
|
|
231
|
+
if (pure === undefined)
|
|
232
|
+
delete entry.button.dataset.pure;
|
|
233
|
+
else
|
|
234
|
+
entry.button.dataset.pure = pure;
|
|
235
|
+
}
|
|
236
|
+
const opacity = mark.label === true ? (mark.fade ?? 1).toFixed(2) : "";
|
|
237
|
+
if (entry.button.style.opacity !== opacity)
|
|
238
|
+
entry.button.style.opacity = opacity;
|
|
239
|
+
const shift = mark.label === true ? " translate(-50%, -50%)" : "";
|
|
240
|
+
if (!(Math.abs(entry.x - mark.x) < 0.25 && Math.abs(entry.y - mark.y) < 0.25) || entry.button.dataset.shift !== shift) {
|
|
182
241
|
entry.x = mark.x;
|
|
183
242
|
entry.y = mark.y;
|
|
184
|
-
entry.button.
|
|
243
|
+
entry.button.dataset.shift = shift;
|
|
244
|
+
entry.button.style.transform = `translate(${mark.x.toFixed(1)}px,${mark.y.toFixed(1)}px)${shift}`;
|
|
185
245
|
}
|
|
186
246
|
}
|
|
187
247
|
for (const [id, entry] of held) {
|
|
@@ -191,7 +251,7 @@ export function createPlaceLayer(root, options) {
|
|
|
191
251
|
held.delete(id);
|
|
192
252
|
hideTip(id);
|
|
193
253
|
}
|
|
194
|
-
shown = marks.map((mark) => ({ id: mark.place.id, layer: mark.layer, x: mark.x, y: mark.y }));
|
|
254
|
+
shown = marks.filter((mark) => mark.nameOnly !== true).map((mark) => ({ id: mark.place.id, layer: mark.layer, x: mark.x, y: mark.y }));
|
|
195
255
|
placeTip();
|
|
196
256
|
},
|
|
197
257
|
clear() {
|
|
@@ -205,6 +265,9 @@ export function createPlaceLayer(root, options) {
|
|
|
205
265
|
return shown;
|
|
206
266
|
},
|
|
207
267
|
dispose() {
|
|
268
|
+
window.removeEventListener("pointerdown", nameDown, true);
|
|
269
|
+
window.removeEventListener("pointerup", nameUp, true);
|
|
270
|
+
window.removeEventListener("pointercancel", nameCancel, true);
|
|
208
271
|
this.clear();
|
|
209
272
|
box.remove();
|
|
210
273
|
style.remove();
|
package/dist/scene/textures.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { type BodyMapSource } from "../door/map.ts";
|
|
|
11
11
|
* console.log(TEXTURE_BASE);
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.
|
|
14
|
+
export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdotca/wakusei-planets@0.44.0/dist/textures/";
|
|
15
15
|
/**
|
|
16
16
|
* Where the sharpest surface pictures are: the files of this exact version in the repository, on jsDelivr's GitHub address. The npm package holds only the two smaller widths, so a page that
|
|
17
17
|
* never zooms in never fetches them. Set `texture-far-base` on an element to serve them yourself.
|
|
@@ -23,7 +23,7 @@ export declare const TEXTURE_BASE = "https://cdn.jsdelivr.net/npm/@johnmorrisdot
|
|
|
23
23
|
* console.log(TEXTURE_FAR_BASE);
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.
|
|
26
|
+
export declare const TEXTURE_FAR_BASE = "https://cdn.jsdelivr.net/gh/johnmorrisdotca/wakusei-planets@v0.44.0/textures/";
|
|
27
27
|
/**
|
|
28
28
|
* Where the finer map tiles are by default: the demo site's `tiles/` folder (GitHub Pages sends `access-control-allow-origin: *`). The tiles are made by `scripts/make-body-tiles.py` and are in no package and no repository:
|
|
29
29
|
* a page that serves its own gives the folder in the `tiles` attribute, and `tiles="off"` turns them off. A page that sets `texture-base` (it serves its own pictures) has none unless it says where they are.
|
package/dist/space/element.d.ts
CHANGED
|
@@ -196,6 +196,17 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
196
196
|
x: number;
|
|
197
197
|
y: number;
|
|
198
198
|
}[];
|
|
199
|
+
/**
|
|
200
|
+
* Names of the most important features on the body looked at, on by default (`surface-names`). A bare attribute or `on` is the view's own cap. A positive number is how many, at most. `off` or `0` turns them off.
|
|
201
|
+
* Fame comes first, then size. They are written only on the side facing the camera, fade at the limb, and never overlap. Setting the property writes the attribute.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
* ```ts no-run
|
|
205
|
+
* document.querySelector("wakusei-space")!.setAttribute("surface-names", "8");
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
get surfaceNames(): number | boolean;
|
|
209
|
+
set surfaceNames(value: number | boolean);
|
|
199
210
|
/**
|
|
200
211
|
* The reader's own place and the places they keep, drawn on the Earth wherever the camera looks: a list of `{ id, lon, lat, label, kind, color }` (`kind` is `here` or `favourite`), as JSON in the attribute `earth-places`.
|
|
201
212
|
* Each is a marker standing out of the ground that turns with the Earth, is hidden on the far side, fades at the edge and keeps its size in pixels; a name shows beside it when there is room, never over another name. Setting the property
|
package/dist/space/element.js
CHANGED
|
@@ -23,7 +23,7 @@ import { besideMoon } from "./beside.js";
|
|
|
23
23
|
import { SUN_REGIONS } from "./regions.js";
|
|
24
24
|
import { travelArrival } from "./travel.js";
|
|
25
25
|
import { findPlace, PLACE_BODIES } from "../places.js";
|
|
26
|
-
import {
|
|
26
|
+
import { marksToShow, pointUnder, readPlaceLayers, readSurfaceNames, spotView } from "../place-marks.js";
|
|
27
27
|
import { createPlaceLayer, onPlacesLoader, placesLoader } from "../scene/place-layer.js";
|
|
28
28
|
import { createEarthPlaceLayer, EARTH_PLACE_MARKS, EARTH_PLACES_FROM_PX, earthPlacesLayout, onEarthPlacesLayout, readEarthPlaceLook } from "../scene/earth-places.js";
|
|
29
29
|
import { cross, dot, length, sub, unit } from "../vec.js";
|
|
@@ -140,7 +140,7 @@ const orbiterLines = (value) => (value === "chosen" || value === "none" ? value
|
|
|
140
140
|
* ```
|
|
141
141
|
*/
|
|
142
142
|
export class WakuseiSpace extends HTMLElement {
|
|
143
|
-
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
143
|
+
static observedAttributes = ["center", "time", "speed", "scale", "labels", "labels-always", "covered", "roadster", "spacecraft", "orbiters", "orbiter", "orbiter-lines", "orbiter-track", "orbits", "help", "look", "light", "lang", "data", "arrows", "help-through", "places", "surface-names", "earth-places", "earth-places-look", "all-moons", "far-opacity", "transition", "pace", "belts", "moon-size", ...NAME_LABEL_ATTRIBUTES];
|
|
144
144
|
#model = newSpaceModel();
|
|
145
145
|
#allMoons = false;
|
|
146
146
|
#catalogue;
|
|
@@ -409,7 +409,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
409
409
|
}
|
|
410
410
|
else if (NAME_LABEL_ATTRIBUTES.includes(name))
|
|
411
411
|
this.#relabel();
|
|
412
|
-
if (name === "places" || name === "lang")
|
|
412
|
+
if (name === "places" || name === "lang" || name === "surface-names")
|
|
413
413
|
this.#markSurface();
|
|
414
414
|
if (name === "earth-places" || name === "earth-places-look")
|
|
415
415
|
this.#askEarthPlaces();
|
|
@@ -431,6 +431,27 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
431
431
|
get placesShown() {
|
|
432
432
|
return this.#markLayer?.shown ?? [];
|
|
433
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* Names of the most important features on the body looked at, on by default (`surface-names`). A bare attribute or `on` is the view's own cap. A positive number is how many, at most. `off` or `0` turns them off.
|
|
436
|
+
* Fame comes first, then size. They are written only on the side facing the camera, fade at the limb, and never overlap. Setting the property writes the attribute.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* ```ts no-run
|
|
440
|
+
* document.querySelector("wakusei-space")!.setAttribute("surface-names", "8");
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
get surfaceNames() {
|
|
444
|
+
const read = readSurfaceNames(this.getAttribute("surface-names"));
|
|
445
|
+
return read.on ? (read.limit ?? true) : false;
|
|
446
|
+
}
|
|
447
|
+
set surfaceNames(value) {
|
|
448
|
+
if (value === false || value === 0)
|
|
449
|
+
this.setAttribute("surface-names", "off");
|
|
450
|
+
else if (value === true)
|
|
451
|
+
this.removeAttribute("surface-names");
|
|
452
|
+
else
|
|
453
|
+
this.setAttribute("surface-names", String(value));
|
|
454
|
+
}
|
|
434
455
|
/**
|
|
435
456
|
* The reader's own place and the places they keep, drawn on the Earth wherever the camera looks: a list of `{ id, lon, lat, label, kind, color }` (`kind` is `here` or `favourite`), as JSON in the attribute `earth-places`.
|
|
436
457
|
* Each is a marker standing out of the ground that turns with the Earth, is hidden on the far side, fades at the edge and keeps its size in pixels; a name shows beside it when there is room, never over another name. Setting the property
|
|
@@ -600,10 +621,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
600
621
|
/** Lay the marks of the places over the body looked at, as the last draw left it, or take them away. Draws nothing. */
|
|
601
622
|
#markSurface() {
|
|
602
623
|
const layers = this.places;
|
|
624
|
+
const names = readSurfaceNames(this.getAttribute("surface-names"));
|
|
603
625
|
const surface = this.#surface;
|
|
604
626
|
const root = this.shadowRoot;
|
|
605
|
-
if (layers.length === 0 || surface === null || root === null || !PLACE_BODIES.includes(surface.id)) {
|
|
606
|
-
if (layers.length === 0 && this.#markLayer !== undefined) {
|
|
627
|
+
if ((!names.on && layers.length === 0) || surface === null || root === null || !PLACE_BODIES.includes(surface.id)) {
|
|
628
|
+
if (!names.on && layers.length === 0 && this.#markLayer !== undefined) {
|
|
607
629
|
this.#markLayer.dispose();
|
|
608
630
|
this.#markLayer = undefined;
|
|
609
631
|
if (this.getAttribute("role") === "group")
|
|
@@ -639,7 +661,12 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
639
661
|
const facts = BODIES[id];
|
|
640
662
|
const ax = facts.axesKm;
|
|
641
663
|
const scale = ax ? [ax[1] / facts.radiusKm, ax[2] / facts.radiusKm, ax[0] / facts.radiusKm] : [1, 1 - facts.flattening, 1];
|
|
642
|
-
|
|
664
|
+
// what the page draws over the body that a name keeps off: the names of the other bodies and of the craft (not the body's own name, which is the body they are written on), and the dots of the craft and the other bodies
|
|
665
|
+
const keepClear = this.#nameBoxes.filter((one) => one.id !== id).map((one) => ({ x: one.x + one.width / 2, y: one.y + one.height / 2, halfWidth: one.width / 2, halfHeight: one.height / 2 }));
|
|
666
|
+
for (const [other, at] of Object.entries(this.#places ?? {}))
|
|
667
|
+
if (at !== null && other !== id)
|
|
668
|
+
keepClear.push({ x: at.x, y: at.y, halfWidth: 8, halfHeight: 8 });
|
|
669
|
+
this.#markLayer.set(marksToShow(this.#markList.list, layers, { ...surface, scale }, facts.radiusKm, names, keepClear, this.getAttribute("lang") === "ja" ? "ja" : "en"));
|
|
643
670
|
}
|
|
644
671
|
#bodyLabel;
|
|
645
672
|
/**
|
|
@@ -1898,6 +1925,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1898
1925
|
}
|
|
1899
1926
|
this.#placeArrows(places);
|
|
1900
1927
|
this.#markFar();
|
|
1928
|
+
// the names written on the body keep off the names and dots just placed
|
|
1929
|
+
this.#markSurface();
|
|
1901
1930
|
}
|
|
1902
1931
|
// --- far names, and the system under the pointer ---------------------------------------------------------------------------------------------------
|
|
1903
1932
|
#hovered = null;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.44.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.44.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|