@johnmorrisdotca/wakusei-planets 0.43.0 → 0.44.1
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 +14 -0
- package/README.md +3 -3
- package/dist/element.js +7 -6
- package/dist/place-marks.d.ts +98 -1
- package/dist/place-marks.js +130 -8
- package/dist/places.d.ts +1 -1
- package/dist/places.js +1 -1
- package/dist/scene/place-layer.js +73 -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,20 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.44.1] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
- **Few names on a small body** (MODULES-1231). On a phone the Moon at 49 px of radius had five names laid across it, wider than the disc. A name is now written only from 70 px of radius (`MARK_RULES.nameFromPx`), comes in over the next 20 px, at most one to every 20 px of radius, and never wider than the disc.
|
|
8
|
+
|
|
9
|
+
- **Written names are not Tab stops** (MODULES-1275). With names on by default every name was a stop between the view and its controls. A name that only names is out of the Tab order; Tab reaches the view and the arrow keys turn it, with no click, on the body page, the space view and the embed page (tested), and an element added with no `tabindex` is a stop all the same.
|
|
10
|
+
|
|
11
|
+
- **The 1980 craft step waits for a draw after the date change** (MODULES-1274, test only): it read the drawn list from the draw before the change.
|
|
12
|
+
|
|
13
|
+
## [0.44.0] - 2026-11-13
|
|
14
|
+
|
|
15
|
+
- **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.
|
|
16
|
+
|
|
17
|
+
- **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`.
|
|
18
|
+
|
|
5
19
|
## [0.43.0] - 2026-11-13
|
|
6
20
|
|
|
7
21
|
- **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.1/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.1/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.1) [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,11 +117,19 @@ 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);
|
|
123
129
|
* no two marks are closer than `gapPx` (the one chosen first keeps its place); and a body gets one mark for every `sharePx` of its radius, 8 at least and `most` at most.
|
|
124
130
|
*
|
|
131
|
+
* Written names (not dots) keep to a smaller rule: none below `nameFromPx` of radius, fading in over the next `nameFadePx`, at most one for every `namePerPx` of radius, and never one wider than the disc.
|
|
132
|
+
*
|
|
125
133
|
* @example
|
|
126
134
|
* ```ts
|
|
127
135
|
* import { MARK_RULES } from "@johnmorrisdotca/wakusei-planets/places";
|
|
@@ -135,6 +143,9 @@ export declare const MARK_RULES: {
|
|
|
135
143
|
readonly gapPx: 12;
|
|
136
144
|
readonly sharePx: 4;
|
|
137
145
|
readonly most: 60;
|
|
146
|
+
readonly nameFromPx: 70;
|
|
147
|
+
readonly nameFadePx: 20;
|
|
148
|
+
readonly namePerPx: 20;
|
|
138
149
|
};
|
|
139
150
|
/**
|
|
140
151
|
* The marks to lay over a body: the places of the layers asked for that face the viewer (not too near the edge of the disc, where they would crowd), are inside the view, and are not crowded out by a mark
|
|
@@ -145,6 +156,7 @@ export declare const MARK_RULES: {
|
|
|
145
156
|
* @param layers - The layers to show.
|
|
146
157
|
* @param view - The body as drawn.
|
|
147
158
|
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
159
|
+
* @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
160
|
* @returns The marks, in the order they were chosen.
|
|
149
161
|
*
|
|
150
162
|
* @example
|
|
@@ -157,7 +169,92 @@ export declare const MARK_RULES: {
|
|
|
157
169
|
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
158
170
|
* ```
|
|
159
171
|
*/
|
|
160
|
-
export declare function placeMarks(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number
|
|
172
|
+
export declare function placeMarks(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number, options?: {
|
|
173
|
+
limit?: number;
|
|
174
|
+
gapPx?: number;
|
|
175
|
+
label?: boolean;
|
|
176
|
+
avoid?: readonly Obstacle[];
|
|
177
|
+
lang?: "en" | "ja";
|
|
178
|
+
nudge?: boolean;
|
|
179
|
+
}): PlaceMark[];
|
|
180
|
+
/**
|
|
181
|
+
* 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.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* import type { Obstacle } from "@johnmorrisdotca/wakusei-planets/places";
|
|
186
|
+
*
|
|
187
|
+
* const craftDot: Obstacle = { x: 400, y: 300, halfWidth: 8, halfHeight: 8 };
|
|
188
|
+
* console.log(craftDot.halfWidth * 2);
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export interface Obstacle {
|
|
192
|
+
x: number;
|
|
193
|
+
y: number;
|
|
194
|
+
halfWidth: number;
|
|
195
|
+
halfHeight: number;
|
|
196
|
+
id?: string;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* 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.
|
|
200
|
+
*
|
|
201
|
+
* @param place - One place.
|
|
202
|
+
* @returns The rank.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
207
|
+
* import { placeRank } from "@johnmorrisdotca/wakusei-planets/places";
|
|
208
|
+
*
|
|
209
|
+
* const tycho = PLACES_MOON.find((place) => place.id === "moon/tycho")!;
|
|
210
|
+
* const small = PLACES_MOON.find((place) => place.kind === "feature" && place.famous !== true)!;
|
|
211
|
+
* console.log(placeRank(tycho) < placeRank(small));
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
export declare function placeRank(place: Place): number;
|
|
215
|
+
/**
|
|
216
|
+
* 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.
|
|
217
|
+
*
|
|
218
|
+
* @param value - The attribute's value, or null when it is omitted.
|
|
219
|
+
* @returns Whether names are on, and `limit`: the most names, or null when the attribute sets no number.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* import { readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
224
|
+
*
|
|
225
|
+
* console.log(readSurfaceNames(null).on, readSurfaceNames("8").limit, readSurfaceNames("off").on);
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
export declare function readSurfaceNames(value: string | null): {
|
|
229
|
+
on: boolean;
|
|
230
|
+
limit: number | null;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* 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.
|
|
234
|
+
*
|
|
235
|
+
* @param places - The body's list.
|
|
236
|
+
* @param layers - The layers asked for, possibly none.
|
|
237
|
+
* @param view - The body as drawn.
|
|
238
|
+
* @param radiusKm - The body's radius in kilometres.
|
|
239
|
+
* @param names - From `readSurfaceNames`.
|
|
240
|
+
* @param keepClear - Boxes on the screen the names stay off: other bodies' dots, craft, other names. May be left out.
|
|
241
|
+
* @param lang - The language the names are written in, to tell how wide each is. English when left out.
|
|
242
|
+
* @returns The marks.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```ts
|
|
246
|
+
* import { marksToShow, readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
247
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
248
|
+
*
|
|
249
|
+
* 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],
|
|
250
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
251
|
+
* console.log(marksToShow(PLACES_MOON, [], view, 1737.4, readSurfaceNames(null)).some((mark) => mark.place.id === "moon/tycho"));
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
254
|
+
export declare function marksToShow(places: readonly Place[], layers: readonly PlaceLayer[], view: SurfaceView, radiusKm: number, names: {
|
|
255
|
+
on: boolean;
|
|
256
|
+
limit: number | null;
|
|
257
|
+
}, keepClear?: readonly Obstacle[], lang?: "en" | "ja"): PlaceMark[];
|
|
161
258
|
/**
|
|
162
259
|
* 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
260
|
* 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
|
@@ -85,6 +85,8 @@ export function surfacePoint(view, lat, lon) {
|
|
|
85
85
|
* 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);
|
|
86
86
|
* no two marks are closer than `gapPx` (the one chosen first keeps its place); and a body gets one mark for every `sharePx` of its radius, 8 at least and `most` at most.
|
|
87
87
|
*
|
|
88
|
+
* Written names (not dots) keep to a smaller rule: none below `nameFromPx` of radius, fading in over the next `nameFadePx`, at most one for every `namePerPx` of radius, and never one wider than the disc.
|
|
89
|
+
*
|
|
88
90
|
* @example
|
|
89
91
|
* ```ts
|
|
90
92
|
* import { MARK_RULES } from "@johnmorrisdotca/wakusei-planets/places";
|
|
@@ -92,7 +94,7 @@ export function surfacePoint(view, lat, lon) {
|
|
|
92
94
|
* console.log(MARK_RULES.gapPx, MARK_RULES.most);
|
|
93
95
|
* ```
|
|
94
96
|
*/
|
|
95
|
-
export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4, most: 60 };
|
|
97
|
+
export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4, most: 60, nameFromPx: 70, nameFadePx: 20, namePerPx: 20 };
|
|
96
98
|
/**
|
|
97
99
|
* The marks to lay over a body: the places of the layers asked for that face the viewer (not too near the edge of the disc, where they would crowd), are inside the view, and are not crowded out by a mark
|
|
98
100
|
* that comes first. The visited sites come first, the famous before the rest, then the named features by size, and a feature is marked only once it is big enough on the screen to show (`MARK_RULES`;
|
|
@@ -102,6 +104,7 @@ export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4
|
|
|
102
104
|
* @param layers - The layers to show.
|
|
103
105
|
* @param view - The body as drawn.
|
|
104
106
|
* @param radiusKm - The body's radius in kilometres, to tell a feature's size on the screen.
|
|
107
|
+
* @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
108
|
* @returns The marks, in the order they were chosen.
|
|
106
109
|
*
|
|
107
110
|
* @example
|
|
@@ -114,9 +117,13 @@ export const MARK_RULES = { fromPx: 40, featureFromPx: 14, gapPx: 12, sharePx: 4
|
|
|
114
117
|
* console.log(placeMarks(PLACES_MOON, ["landing"], view, 1737.4).slice(0, 3).map((mark) => mark.place.name.en));
|
|
115
118
|
* ```
|
|
116
119
|
*/
|
|
117
|
-
export function placeMarks(places, layers, view, radiusKm) {
|
|
120
|
+
export function placeMarks(places, layers, view, radiusKm, options) {
|
|
118
121
|
if (layers.length === 0 || !(view.radiusPx >= MARK_RULES.fromPx))
|
|
119
122
|
return [];
|
|
123
|
+
// a written name takes room: none on a small disc, a few on a middling one, and they come in gently
|
|
124
|
+
if (options?.label === true && !(view.radiusPx >= MARK_RULES.nameFromPx))
|
|
125
|
+
return [];
|
|
126
|
+
const come = options?.label === true ? Math.min(1, (view.radiusPx - MARK_RULES.nameFromPx) / MARK_RULES.nameFadePx) : 1;
|
|
120
127
|
const wanted = [];
|
|
121
128
|
for (const place of places) {
|
|
122
129
|
const layer = layerOf(place.kind);
|
|
@@ -126,28 +133,143 @@ export function placeMarks(places, layers, view, radiusKm) {
|
|
|
126
133
|
continue;
|
|
127
134
|
wanted.push(place);
|
|
128
135
|
}
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
if (options?.label === true)
|
|
137
|
+
wanted.sort((a, b) => placeRank(a) - placeRank(b));
|
|
138
|
+
else {
|
|
139
|
+
const rank = (place) => (place.kind === "feature" ? 2 : 0) + (place.famous === true ? 0 : 1);
|
|
140
|
+
wanted.sort((a, b) => rank(a) - rank(b) || (b.feature?.diameterKm ?? 0) - (a.feature?.diameterKm ?? 0));
|
|
141
|
+
}
|
|
131
142
|
const most = Math.max(8, Math.min(MARK_RULES.most, Math.round(view.radiusPx / MARK_RULES.sharePx)));
|
|
143
|
+
const cap = Math.min(options?.limit === undefined ? most : Math.max(0, Math.min(MARK_RULES.most, options.limit)), options?.label === true ? Math.floor(view.radiusPx / MARK_RULES.namePerPx) : Infinity);
|
|
144
|
+
const gap = options?.gapPx ?? MARK_RULES.gapPx;
|
|
132
145
|
const out = [];
|
|
133
146
|
for (const place of wanted) {
|
|
134
|
-
if (out.length >=
|
|
147
|
+
if (out.length >= cap)
|
|
135
148
|
break;
|
|
136
149
|
const { point, normal } = surfacePoint(view, place.lat, place.lon);
|
|
137
150
|
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
151
|
const len = Math.hypot(sight[0], sight[1], sight[2]) || 1;
|
|
152
|
+
const face = dot(normal, sight) / len;
|
|
139
153
|
// 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 (
|
|
154
|
+
if (face < 0.12)
|
|
141
155
|
continue;
|
|
142
156
|
const at = view.project(point);
|
|
143
157
|
if (at === null || at.x < 0 || at.y < 0 || at.x > view.width || at.y > view.height)
|
|
144
158
|
continue;
|
|
145
|
-
|
|
159
|
+
let x = at.x;
|
|
160
|
+
let y = at.y;
|
|
161
|
+
if (options?.label === true) {
|
|
162
|
+
const lang = options.lang ?? "en";
|
|
163
|
+
const mine = { ...nameBox(place.name[lang]), id: place.id };
|
|
164
|
+
// never wider than the disc it is written on
|
|
165
|
+
if (mine.halfWidth > view.radiusPx)
|
|
166
|
+
continue;
|
|
167
|
+
const clash = (px, py) => {
|
|
168
|
+
const box = { x: px, y: py, ...mine };
|
|
169
|
+
if (px - mine.halfWidth < 0 || px + mine.halfWidth > view.width || py - mine.halfHeight < 0 || py + mine.halfHeight > view.height)
|
|
170
|
+
return true;
|
|
171
|
+
if ((options.avoid ?? []).some((one) => one.id !== place.id && touches(box, one)))
|
|
172
|
+
return true;
|
|
173
|
+
return out.some((mark) => mark.label === true && touches(box, { x: mark.x, y: mark.y, ...nameBox(mark.place.name[lang]) }));
|
|
174
|
+
};
|
|
175
|
+
// 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.
|
|
176
|
+
let spot;
|
|
177
|
+
for (const [dx, dy] of options.nudge === true ? [[0, 0], [0, -10], [0, 10], [0, -18], [0, 18], [-24, 0], [24, 0]] : [[0, 0]]) {
|
|
178
|
+
if (!clash(x + dx, y + dy)) {
|
|
179
|
+
spot = { x: x + dx, y: y + dy };
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (spot === undefined)
|
|
184
|
+
continue;
|
|
185
|
+
x = spot.x;
|
|
186
|
+
y = spot.y;
|
|
187
|
+
}
|
|
188
|
+
if (x < 0 || y < 0 || x > view.width || y > view.height)
|
|
146
189
|
continue;
|
|
147
|
-
|
|
190
|
+
if (options?.label !== true && out.some((mark) => Math.hypot(mark.x - x, mark.y - y) < gap))
|
|
191
|
+
continue;
|
|
192
|
+
out.push({ place, layer: layerOf(place.kind), x, y, ...(options?.label === true ? { label: true, fade: Math.min(1, (face - 0.12) / 0.4) * come } : {}) });
|
|
148
193
|
}
|
|
149
194
|
return out;
|
|
150
195
|
}
|
|
196
|
+
/** The half sizes of a written name's box, from its length (the names are 12 pixels, semibold). */
|
|
197
|
+
const nameBox = (text) => ({ halfWidth: Math.ceil(text.length * 3.7) + 5, halfHeight: 9 });
|
|
198
|
+
const touches = (a, b) => Math.abs(a.x - b.x) < a.halfWidth + b.halfWidth && Math.abs(a.y - b.y) < a.halfHeight + b.halfHeight;
|
|
199
|
+
/**
|
|
200
|
+
* 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.
|
|
201
|
+
*
|
|
202
|
+
* @param place - One place.
|
|
203
|
+
* @returns The rank.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
208
|
+
* import { placeRank } from "@johnmorrisdotca/wakusei-planets/places";
|
|
209
|
+
*
|
|
210
|
+
* const tycho = PLACES_MOON.find((place) => place.id === "moon/tycho")!;
|
|
211
|
+
* const small = PLACES_MOON.find((place) => place.kind === "feature" && place.famous !== true)!;
|
|
212
|
+
* console.log(placeRank(tycho) < placeRank(small));
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
export function placeRank(place) {
|
|
216
|
+
const size = Math.min(1_000_000, place.feature?.diameterKm ?? 0);
|
|
217
|
+
return (place.famous === true ? 0 : 1_000_000) - size;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* 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.
|
|
221
|
+
*
|
|
222
|
+
* @param value - The attribute's value, or null when it is omitted.
|
|
223
|
+
* @returns Whether names are on, and `limit`: the most names, or null when the attribute sets no number.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* import { readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
228
|
+
*
|
|
229
|
+
* console.log(readSurfaceNames(null).on, readSurfaceNames("8").limit, readSurfaceNames("off").on);
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
export function readSurfaceNames(value) {
|
|
233
|
+
if (value === null || value === "" || value === "on")
|
|
234
|
+
return { on: true, limit: null };
|
|
235
|
+
if (value === "off" || value === "0")
|
|
236
|
+
return { on: false, limit: null };
|
|
237
|
+
const n = Number(value);
|
|
238
|
+
if (Number.isInteger(n) && n > 0 && n <= 60)
|
|
239
|
+
return { on: true, limit: n };
|
|
240
|
+
return { on: true, limit: null };
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* 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.
|
|
244
|
+
*
|
|
245
|
+
* @param places - The body's list.
|
|
246
|
+
* @param layers - The layers asked for, possibly none.
|
|
247
|
+
* @param view - The body as drawn.
|
|
248
|
+
* @param radiusKm - The body's radius in kilometres.
|
|
249
|
+
* @param names - From `readSurfaceNames`.
|
|
250
|
+
* @param keepClear - Boxes on the screen the names stay off: other bodies' dots, craft, other names. May be left out.
|
|
251
|
+
* @param lang - The language the names are written in, to tell how wide each is. English when left out.
|
|
252
|
+
* @returns The marks.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { marksToShow, readSurfaceNames } from "@johnmorrisdotca/wakusei-planets/places";
|
|
257
|
+
* import { PLACES_MOON } from "@johnmorrisdotca/wakusei-planets/places/moon";
|
|
258
|
+
*
|
|
259
|
+
* 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],
|
|
260
|
+
* project: (p: [number, number, number]) => ({ x: 200 + p[0] * 180, y: 200 - p[1] * 180 }), width: 400, height: 400, radiusPx: 180 };
|
|
261
|
+
* console.log(marksToShow(PLACES_MOON, [], view, 1737.4, readSurfaceNames(null)).some((mark) => mark.place.id === "moon/tycho"));
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
export function marksToShow(places, layers, view, radiusKm, names, keepClear = [], lang = "en") {
|
|
265
|
+
const asked = layers.length === 0 ? [] : placeMarks(places, layers, view, radiusKm);
|
|
266
|
+
// 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
|
|
267
|
+
const avoid = [...keepClear, ...asked.map((mark) => ({ x: mark.x, y: mark.y, halfWidth: 12, halfHeight: 12, id: mark.place.id }))];
|
|
268
|
+
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") }) : [];
|
|
269
|
+
const ids = new Set(named.map((mark) => mark.place.id));
|
|
270
|
+
const wanted = new Set(asked.map((mark) => mark.place.id));
|
|
271
|
+
return [...named.map((mark) => (wanted.has(mark.place.id) || layers.includes("feature") ? mark : { ...mark, nameOnly: true })), ...asked.filter((mark) => !ids.has(mark.place.id))];
|
|
272
|
+
}
|
|
151
273
|
/**
|
|
152
274
|
* 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
275
|
* 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,41 @@ 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
|
+
entry.button.removeAttribute("tabindex");
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
entry.button.dataset.pure = pure;
|
|
237
|
+
// a written name is part of the picture, and a dozen of them would be a dozen stops between the view and its controls
|
|
238
|
+
entry.button.tabIndex = -1;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const opacity = mark.label === true ? (mark.fade ?? 1).toFixed(2) : "";
|
|
242
|
+
if (entry.button.style.opacity !== opacity)
|
|
243
|
+
entry.button.style.opacity = opacity;
|
|
244
|
+
const shift = mark.label === true ? " translate(-50%, -50%)" : "";
|
|
245
|
+
if (!(Math.abs(entry.x - mark.x) < 0.25 && Math.abs(entry.y - mark.y) < 0.25) || entry.button.dataset.shift !== shift) {
|
|
182
246
|
entry.x = mark.x;
|
|
183
247
|
entry.y = mark.y;
|
|
184
|
-
entry.button.
|
|
248
|
+
entry.button.dataset.shift = shift;
|
|
249
|
+
entry.button.style.transform = `translate(${mark.x.toFixed(1)}px,${mark.y.toFixed(1)}px)${shift}`;
|
|
185
250
|
}
|
|
186
251
|
}
|
|
187
252
|
for (const [id, entry] of held) {
|
|
@@ -191,7 +256,7 @@ export function createPlaceLayer(root, options) {
|
|
|
191
256
|
held.delete(id);
|
|
192
257
|
hideTip(id);
|
|
193
258
|
}
|
|
194
|
-
shown = marks.map((mark) => ({ id: mark.place.id, layer: mark.layer, x: mark.x, y: mark.y }));
|
|
259
|
+
shown = marks.filter((mark) => mark.nameOnly !== true).map((mark) => ({ id: mark.place.id, layer: mark.layer, x: mark.x, y: mark.y }));
|
|
195
260
|
placeTip();
|
|
196
261
|
},
|
|
197
262
|
clear() {
|
|
@@ -205,6 +270,9 @@ export function createPlaceLayer(root, options) {
|
|
|
205
270
|
return shown;
|
|
206
271
|
},
|
|
207
272
|
dispose() {
|
|
273
|
+
window.removeEventListener("pointerdown", nameDown, true);
|
|
274
|
+
window.removeEventListener("pointerup", nameUp, true);
|
|
275
|
+
window.removeEventListener("pointercancel", nameCancel, true);
|
|
208
276
|
this.clear();
|
|
209
277
|
box.remove();
|
|
210
278
|
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.1/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.1/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.1";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.44.1";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.1",
|
|
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",
|