@johnmorrisdotca/wakusei-planets 0.58.0 → 0.59.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 +5 -0
- package/README.md +3 -3
- package/dist/space/covered.d.ts +23 -0
- package/dist/space/covered.js +33 -11
- package/dist/space/element.d.ts +27 -4
- package/dist/space/element.js +39 -10
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/scene.d.ts +5 -0
- package/dist/space/scene.js +19 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.59.0] - 2026-11-17
|
|
6
|
+
|
|
7
|
+
- **A name, a ring or a note behind a nearer body is hidden, not drawn over its disc** (MODULES-1404; John Morris, 2026-11-17, from the view at Pholus on spaceprogramx.com: Jupiter, Mercury with its ring, Halley and the Hildas' name were drawn over the dark disc as if it were glass). In `<wakusei-space>` a body whose place is inside a nearer body's drawn disc now fades its floating name and ring out (the 0.35 s fade the far names already use, none under reduced motion) and back as it comes out; a body's own name stays. The disc is the one drawn, at the edge-round radius 0.57 gave it (`placeOf(id).r`), tested once per label per draw against the few discs of 6 pixels of radius or more, with nothing read back from the picture. This is the new default of the `covered` attribute and property: `hide`; `arrow` is as before and `name` is the old way, names over the disc. The Oort cloud's note and the marks of the places on a body (the body looked at, or the Earth's `earth-places`) that is itself behind another go the same way. New: `space.coveredAt(point)`, the id of the body whose disc hides a point of the scene (as `stats.camera` has it) or `null`, for a page's own labels over the view (spaceprogramx's belt names: the Hildas, the Centaurs, the Kuiper belt, the Jupiter Trojans); and `coverOf(point, discs, self?)` from `/space`, the maths, which `coveredBy` now uses. Unit tests of the maths; `e2e/space-occlude.demo.ts` goes to Pholus at 2026-11-30T06:01Z and checks that the names behind its disc are hidden and Pholus's own is not, and that `coveredAt` hides a point behind the disc and none beside or in front of it.
|
|
8
|
+
- **A move asked for before the first draw arrives on the lit side** (MODULES-1404, from the same view at Pholus: drawn almost all dark, with the Sun in the picture beside it). The lit-side rule (`arrivalSide`) is the same for every body, centaurs and small bodies included, but `goTo` chose no side at all when the camera had not drawn yet, which is how an address that opens at a body, or a page that moves the view as soon as the element is defined, goes: the body was then looked at from whichever side the default aim fell on, which for Pholus on 2026-11-30 runs from 76 per cent lit at 06:01 UTC to 2 per cent at 14:01 and back through the day. A move before the first draw now comes from where the view opens, the Earth, as every later one comes from where the camera is, so the body is at least half lit (the Earth itself keeps its first view). `e2e/space-occlude.demo.ts` asks for Pholus before the first draw at 14:01 UTC and checks the camera is on its lit side.
|
|
9
|
+
|
|
5
10
|
## [0.58.0] - 2026-11-17
|
|
6
11
|
|
|
7
12
|
- **Landing sites with their country's flag** (MODULES-1398; John Morris, 2026-11-16). New entry point `/landing-sites`: `LANDING_SITES`, 39 landings that touched down softly and were heard from (28 on the Moon: Apollo 11 to 17, Surveyor 1, 3, 5, 6 and 7, Luna 9, 13, 16, 17, 20, 21, 23 and 24, Chang'e 3 to 6, Chandrayaan-3, SLIM, IM-1, Blue Ghost 1, IM-2; 11 on Mars: Mars 3, Viking 1 and 2, Pathfinder, Spirit, Opportunity, Phoenix, Curiosity, InSight, Perseverance, Zhurong), each with its names in English and Japanese, its day, its point, its agency, its ISO country code and the page each coordinate is from, plus `landingSitesOf`, `findLandingSite` and `flagCodeOf`. The points are the place tables' own and a test pins them together; the Moon's were compared row by row with NASA NSSDCA's table. The attribute `site-flags` (property `siteFlags`) on `<wakusei-body>` and `<wakusei-space>` puts the country's flag in the tip of a place and, on a body at least 110 pixels of radius across on the screen, names each landing site beside its dot with its flag; the flag is `<hata-flag>`, drawn when the page has imported `@johnmorrisdotca/hata` (no new dependency: without it only the name shows). `wakusei-place`'s `detail` gains `site`. Nothing changes with the attribute off. The demo's Places row has a Flags button (`flags=1` in the address). `@johnmorrisdotca/hata` is a dev dependency, for the tests and the demo. Guide: Landing sites, with their flags.
|
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.59.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.59.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
|
|
|
@@ -539,7 +539,7 @@ BODIES.pluto.kind; // "dwarf-planet"
|
|
|
539
539
|
|
|
540
540
|
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:
|
|
541
541
|
|
|
542
|
-
> Morris, J. (2026). *Wakusei Planets* (version 0.
|
|
542
|
+
> Morris, J. (2026). *Wakusei Planets* (version 0.59.0) [Computer software]. https://github.com/johnmorrisdotca/wakusei-planets
|
|
543
543
|
|
|
544
544
|
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).
|
|
545
545
|
|
package/dist/space/covered.d.ts
CHANGED
|
@@ -48,6 +48,29 @@ export declare const COVER_MIN_PX = 6;
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
export declare function coveredBy(entries: readonly CoverEntry[]): Map<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Which body, if any, hides a point of a label: the nearest body whose drawn disc holds the point on the screen and which is nearer the camera than the point is. For a name, a ring or a pin whose place is a point
|
|
53
|
+
* (a belt's name at its anchor, the Oort cloud's note, a mark on a surface), not a body. A disc narrower than `COVER_MIN_PX` hides nothing, and `self` (the point's own body) never hides it. A disc test
|
|
54
|
+
* for each of the few discs big enough to matter; nothing is read back from the picture.
|
|
55
|
+
*
|
|
56
|
+
* @param point - The point's place on the screen in CSS pixels and its distance from the camera (any unit, the same as the discs').
|
|
57
|
+
* @param discs - The drawn discs: their places and radii on the screen (the radius `placeOf(id).r` gives, rounded at the edge of the picture) and their distances.
|
|
58
|
+
* @param self - The id of the body the point belongs to, if it belongs to one.
|
|
59
|
+
* @returns The id of the covering body, or `null` when the point is in the open.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { coverOf } from "@johnmorrisdotca/wakusei-planets/space";
|
|
64
|
+
*
|
|
65
|
+
* const discs = [{ id: "pholus", x: 300, y: 300, r: 200, distance: 4 }];
|
|
66
|
+
* console.log(coverOf({ x: 340, y: 280, distance: 5_000 }, discs), coverOf({ x: 640, y: 280, distance: 5_000 }, discs));
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function coverOf(point: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
distance: number;
|
|
73
|
+
}, discs: readonly CoverEntry[], self?: string): string | null;
|
|
51
74
|
/**
|
|
52
75
|
* One quiet arrow: outside the covering body's disc, on the side nearest the bodies behind it, pointing in behind it, with the surest of them named and the rest counted.
|
|
53
76
|
*
|
package/dist/space/covered.js
CHANGED
|
@@ -31,20 +31,42 @@ export const COVER_MIN_PX = 6;
|
|
|
31
31
|
export function coveredBy(entries) {
|
|
32
32
|
const behind = new Map();
|
|
33
33
|
for (const body of entries) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
continue;
|
|
38
|
-
if (Math.hypot(body.x - other.x, body.y - other.y) >= other.r)
|
|
39
|
-
continue;
|
|
40
|
-
if (cover === undefined || other.distance < cover.distance)
|
|
41
|
-
cover = other;
|
|
42
|
-
}
|
|
43
|
-
if (cover !== undefined)
|
|
44
|
-
behind.set(body.id, cover.id);
|
|
34
|
+
const cover = coverOf(body, entries, body.id);
|
|
35
|
+
if (cover !== null)
|
|
36
|
+
behind.set(body.id, cover);
|
|
45
37
|
}
|
|
46
38
|
return behind;
|
|
47
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Which body, if any, hides a point of a label: the nearest body whose drawn disc holds the point on the screen and which is nearer the camera than the point is. For a name, a ring or a pin whose place is a point
|
|
42
|
+
* (a belt's name at its anchor, the Oort cloud's note, a mark on a surface), not a body. A disc narrower than `COVER_MIN_PX` hides nothing, and `self` (the point's own body) never hides it. A disc test
|
|
43
|
+
* for each of the few discs big enough to matter; nothing is read back from the picture.
|
|
44
|
+
*
|
|
45
|
+
* @param point - The point's place on the screen in CSS pixels and its distance from the camera (any unit, the same as the discs').
|
|
46
|
+
* @param discs - The drawn discs: their places and radii on the screen (the radius `placeOf(id).r` gives, rounded at the edge of the picture) and their distances.
|
|
47
|
+
* @param self - The id of the body the point belongs to, if it belongs to one.
|
|
48
|
+
* @returns The id of the covering body, or `null` when the point is in the open.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { coverOf } from "@johnmorrisdotca/wakusei-planets/space";
|
|
53
|
+
*
|
|
54
|
+
* const discs = [{ id: "pholus", x: 300, y: 300, r: 200, distance: 4 }];
|
|
55
|
+
* console.log(coverOf({ x: 340, y: 280, distance: 5_000 }, discs), coverOf({ x: 640, y: 280, distance: 5_000 }, discs));
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export function coverOf(point, discs, self) {
|
|
59
|
+
let cover;
|
|
60
|
+
for (const other of discs) {
|
|
61
|
+
if (other.id === self || other.r < COVER_MIN_PX || other.distance >= point.distance)
|
|
62
|
+
continue;
|
|
63
|
+
if (Math.hypot(point.x - other.x, point.y - other.y) >= other.r)
|
|
64
|
+
continue;
|
|
65
|
+
if (cover === undefined || other.distance < cover.distance)
|
|
66
|
+
cover = other;
|
|
67
|
+
}
|
|
68
|
+
return cover === undefined ? null : cover.id;
|
|
69
|
+
}
|
|
48
70
|
/**
|
|
49
71
|
* How far outside the disc's edge the arrow's tip sits, in CSS pixels.
|
|
50
72
|
*
|
package/dist/space/element.d.ts
CHANGED
|
@@ -26,6 +26,18 @@ export { EARTH_PLACE_LOOKS, EARTH_PLACE_MARKS, type EarthPlace, type EarthPlaceK
|
|
|
26
26
|
export { setThreeLoader, SPACE_BODIES, type RidePoint, type RideTarget, type Sight, type SightEdge, type SpaceBody, type SpaceLight };
|
|
27
27
|
/** Where a body is on the screen, in CSS pixels in the element: its centre and its radius. */
|
|
28
28
|
export type { BodyPlace };
|
|
29
|
+
/**
|
|
30
|
+
* What a body behind another gets: `hide` (fade its name and ring out), `arrow` (a quiet arrow on the disc's edge) or `name` (draw it over the disc).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import type { Covered } from "@johnmorrisdotca/wakusei-planets/space/element";
|
|
35
|
+
*
|
|
36
|
+
* const how: Covered = "hide";
|
|
37
|
+
* console.log(how);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export type Covered = "hide" | "arrow" | "name";
|
|
29
41
|
/**
|
|
30
42
|
* What a page can tell a reader about a body now.
|
|
31
43
|
*
|
|
@@ -403,11 +415,13 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
403
415
|
get orbiterTrack(): boolean;
|
|
404
416
|
set orbiterTrack(value: boolean);
|
|
405
417
|
/**
|
|
406
|
-
* What a body behind another gets (the attribute `covered`): `
|
|
407
|
-
* disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted
|
|
418
|
+
* What a body behind another gets (the attribute `covered`): `hide` (the default) fades its floating name and ring out while its place is inside a nearer body's drawn disc, and back when it comes out, as if the disc hid
|
|
419
|
+
* them; `arrow` draws instead one small quiet arrow just outside the disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted
|
|
420
|
+
* (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out; `name` draws the name and ring over the nearer body's disc as 0.57 and earlier did. The same discs hide the Oort cloud's note, the
|
|
421
|
+
* marks of the places on a body that is behind another, and, through `coveredAt`, any label a page draws over the view.
|
|
408
422
|
*/
|
|
409
|
-
get covered():
|
|
410
|
-
set covered(value:
|
|
423
|
+
get covered(): Covered;
|
|
424
|
+
set covered(value: Covered);
|
|
411
425
|
/**
|
|
412
426
|
* Keep a body's floating name and dot while its name is drawn on its globe (the attribute `labels-always`; off by default). Off, a body that carries its drawn name (`body-label` on, and the body at least 24 CSS pixels in
|
|
413
427
|
* radius) fades its floating name and dot out, and they fade back when it shrinks below that; bodies with no drawn name keep their floating names.
|
|
@@ -790,6 +804,15 @@ export declare class WakuseiSpace extends HTMLElement {
|
|
|
790
804
|
};
|
|
791
805
|
/** Where a body is on the screen now: its centre and radius in CSS pixels in the element, or `null` when it is behind the camera or not drawn. */
|
|
792
806
|
placeOf(id: BodyId): BodyPlace | null;
|
|
807
|
+
/**
|
|
808
|
+
* Which body's drawn disc hides a point of the scene at the last draw, or `null`: for a page that draws its own label over the view (a belt's name at its anchor, a pin) and wants it to go where a nearer body is in
|
|
809
|
+
* front of it, the way the view's own names do. The point is in the scene's places (`stats.camera` is in the same ones); the discs are the bodies and moons placed on the screen, at the radius `placeOf(id).r`
|
|
810
|
+
* gives. Always `null` while `labels` is off, since the discs are worked out with the names.
|
|
811
|
+
*
|
|
812
|
+
* @param point - A place in the scene.
|
|
813
|
+
* @returns The id of the covering body, or `null` when the point is in the open or off the view.
|
|
814
|
+
*/
|
|
815
|
+
coveredAt(point: readonly [number, number, number]): string | null;
|
|
793
816
|
/** True for the full-screen mode (the `immersive` attribute): the element fills its box in any shape, a plain wheel zooms instead of scrolling the page, and a touch drag turns the view instead of scrolling it. */
|
|
794
817
|
get immersive(): boolean;
|
|
795
818
|
set immersive(value: boolean);
|
package/dist/space/element.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createGameClock } from "./clock.js";
|
|
|
7
7
|
import { bodyKindOf, findBody, hopFrom, hostOf, HOP_ORDER, systemOf } from "./bodies.js";
|
|
8
8
|
import { sightChanged, sightOf, withinMargin } from "./sight.js";
|
|
9
9
|
import { chooseLabels, nameSpot } from "./labels.js";
|
|
10
|
-
import { coverArrows } from "./covered.js";
|
|
10
|
+
import { coverArrows, coverOf } from "./covered.js";
|
|
11
11
|
import { createPainter, picturesPending } from "../scene/painter.js";
|
|
12
12
|
import { NAME_LABEL_ATTRIBUTES, readNameLabel } from "../scene/name-label.js";
|
|
13
13
|
import { createDoorHost } from "../door/host.js";
|
|
@@ -41,6 +41,7 @@ const SCALE_WORDS = {
|
|
|
41
41
|
};
|
|
42
42
|
/** A body whose disc is smaller than this many CSS pixels across its radius is marked with a ring as well as its name. */
|
|
43
43
|
const RING_BELOW_PX = 4;
|
|
44
|
+
const readCovered = (value) => (value === "arrow" ? "arrow" : value === "name" ? "name" : "hide");
|
|
44
45
|
/** The id of the package's own source of the belts: it is in every view, but is not one of `sources`. */
|
|
45
46
|
const BELTS_SOURCE_ID = "wakusei-belts";
|
|
46
47
|
/** The belts the attribute `belts` names: all of them where it is left out or says `all`, none for `off`, else a list of names separated by commas or spaces. */
|
|
@@ -107,7 +108,7 @@ const readBody = (value) => {
|
|
|
107
108
|
* 1.05 radii from the surface (`FIT_DISTANCE` over the zoom), so past a zoom of about 3.9 nothing moves; 3.6 is where the finest map tiles of the Earth, Mars and the Moon (16384 pixels round) run out of detail too, so it is the same ceiling for both.
|
|
108
109
|
*/
|
|
109
110
|
const CARRIED_LIMITS = { zoomMin: 1e-6, zoomMax: 3.6, tiltMax: 90 };
|
|
110
|
-
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[data-flip]{display:flex;flex-direction:row-reverse}.sp-label[data-flip]::before{margin:0 -2px 1px 5px}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label[data-far]:not([data-carried]),.sp-ring[data-far]:not([data-carried]){opacity:var(--wakusei-far-opacity,.5)}.sp-arrow[data-far]{opacity:calc(.8*var(--wakusei-far-opacity,.5))}.sp-label,.sp-ring,.sp-arrow{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring,.sp-arrow{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-region{position:absolute;left:10px;bottom:8px;margin:0;padding:0;font:600 15px/20px system-ui,-apple-system,sans-serif;color:#fff;opacity:.95;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:none;transition:opacity .35s}.sp-region[hidden]{display:block;opacity:0}@media (prefers-reduced-motion:reduce){.sp-region{transition:none}}.sp-note{position:absolute;left:10px;right:10px;top:28px;max-width:44em;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.92;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-note[hidden],.sp-oort[hidden]{display:none}.sp-oort{position:absolute;left:0;top:0;margin:0;padding:0;font:italic 12px/16px system-ui,-apple-system,sans-serif;color:#aeb8e6;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p><p class="sp-region" id="region" part="region" role="status" hidden></p><p class="sp-note" part="note" role="status" hidden></p><p class="sp-oort" part="oort" hidden></p>`;
|
|
111
|
+
const STYLE = `<style>:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}:host([immersive]){aspect-ratio:auto;width:100%;height:100%;touch-action:none!important;user-select:none;-webkit-user-select:none;-webkit-tap-highlight-color:transparent}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[data-flip]{display:flex;flex-direction:row-reverse}.sp-label[data-flip]::before{margin:0 -2px 1px 5px}.sp-label[hidden]{display:none}.sp-arrow{position:absolute;left:0;top:0;margin:0;padding:0 4px 0 0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.8;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:auto;cursor:pointer}.sp-arrow::before{content:"";display:inline-block;width:0;height:0;margin:0 5px 1px 0;border:5px solid transparent;border-left:7px solid #fff;transform:rotate(var(--turn,0deg));transform-origin:30% 50%}.sp-arrow[hidden]{display:none}.sp-arrow:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label[data-far]:not([data-carried]),.sp-ring[data-far]:not([data-carried]){opacity:var(--wakusei-far-opacity,.5)}.sp-arrow[data-far]{opacity:calc(.8*var(--wakusei-far-opacity,.5))}.sp-label,.sp-ring,.sp-arrow{transition:opacity .35s ease}.sp-label[data-carried],.sp-ring[data-carried]{opacity:0;pointer-events:none}@media (prefers-reduced-motion:reduce){.sp-label,.sp-ring,.sp-arrow{transition:none}}.sp-ring{position:absolute;left:0;top:0;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;border:1.5px solid rgba(255,255,255,.85);border-radius:50%;box-shadow:0 0 3px #000;pointer-events:none;will-change:transform}.sp-ring[hidden]{display:none}.sp-scale{position:absolute;left:10px;top:8px;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.9;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-region{position:absolute;left:10px;bottom:8px;margin:0;padding:0;font:600 15px/20px system-ui,-apple-system,sans-serif;color:#fff;opacity:.95;text-shadow:0 0 4px #000,0 0 4px #000;pointer-events:none;transition:opacity .35s}.sp-region[hidden]{display:block;opacity:0}@media (prefers-reduced-motion:reduce){.sp-region{transition:none}}.sp-note{position:absolute;left:10px;right:10px;top:28px;max-width:44em;margin:0;padding:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;opacity:.92;text-shadow:0 0 3px #000,0 0 3px #000;pointer-events:none}.sp-note[hidden],.sp-oort[hidden]{display:none}.sp-oort{position:absolute;left:0;top:0;margin:0;padding:0;font:italic 12px/16px system-ui,-apple-system,sans-serif;color:#aeb8e6;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none;transition:opacity .35s ease}.sp-oort[data-covered]{opacity:0}@media (prefers-reduced-motion:reduce){.sp-oort{transition:none}}</style><div id="stage"></div><div id="labels"></div><p class="sp-scale" part="scale" role="status"></p><p class="sp-region" id="region" part="region" role="status" hidden></p><p class="sp-note" part="note" role="status" hidden></p><p class="sp-oort" part="oort" hidden></p>`;
|
|
111
112
|
const orbiterLines = (value) => (value === "chosen" || value === "none" ? value : "all");
|
|
112
113
|
/**
|
|
113
114
|
* The `<wakusei-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`
|
|
@@ -209,7 +210,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
209
210
|
this.#model.moonSize = readMoonSize(this.getAttribute("moon-size") ?? 2);
|
|
210
211
|
this.#model.labels = this.getAttribute("labels") !== "off";
|
|
211
212
|
this.#labelsAlways = this.hasAttribute("labels-always") && this.getAttribute("labels-always") !== "off";
|
|
212
|
-
this.#covered = this.getAttribute("covered")
|
|
213
|
+
this.#covered = readCovered(this.getAttribute("covered"));
|
|
213
214
|
this.roadster = this.hasAttribute("roadster") && this.getAttribute("roadster") !== "off";
|
|
214
215
|
const craft = this.getAttribute("spacecraft");
|
|
215
216
|
if (craft !== null && craft !== "off")
|
|
@@ -368,7 +369,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
368
369
|
else if (name === "labels-always")
|
|
369
370
|
this.labelsAlways = value !== null && value !== "off";
|
|
370
371
|
else if (name === "covered")
|
|
371
|
-
this.covered = value
|
|
372
|
+
this.covered = readCovered(value);
|
|
372
373
|
else if (name === "roadster")
|
|
373
374
|
this.roadster = value !== null && value !== "off";
|
|
374
375
|
else if (name === "spacecraft")
|
|
@@ -712,6 +713,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
712
713
|
this.#earthLayer?.clear();
|
|
713
714
|
this.#earthOmitted = 0;
|
|
714
715
|
};
|
|
716
|
+
if (surface !== null && this.#covered !== "name" && this.#places?.["earth"]?.behind !== undefined)
|
|
717
|
+
return clear();
|
|
715
718
|
if (surface === null || root === null || using === undefined || !this.hasAttribute("earth-places") || !(surface.radiusPx >= EARTH_PLACES_FROM_PX))
|
|
716
719
|
return clear();
|
|
717
720
|
const places = this.#readEarthPlaces();
|
|
@@ -751,6 +754,11 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
751
754
|
const names = readSurfaceNames(this.getAttribute("surface-names"));
|
|
752
755
|
const surface = this.#surface;
|
|
753
756
|
const root = this.shadowRoot;
|
|
757
|
+
// the marks lie on the body looked at: not drawn while a nearer body's disc is over it
|
|
758
|
+
if (surface !== null && this.#covered !== "name" && this.#places?.[surface.id]?.behind !== undefined) {
|
|
759
|
+
this.#markLayer?.clear();
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
754
762
|
if ((!names.on && layers.length === 0) || surface === null || root === null || !PLACE_BODIES.includes(surface.id)) {
|
|
755
763
|
if (!names.on && layers.length === 0 && this.#markLayer !== undefined) {
|
|
756
764
|
this.#markLayer.dispose();
|
|
@@ -1085,11 +1093,13 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1085
1093
|
this.#model.orbiterTrack = value;
|
|
1086
1094
|
this.#gate?.request();
|
|
1087
1095
|
}
|
|
1088
|
-
#covered = "
|
|
1096
|
+
#covered = "hide";
|
|
1089
1097
|
#arrows = new Map();
|
|
1090
1098
|
/**
|
|
1091
|
-
* What a body behind another gets (the attribute `covered`): `
|
|
1092
|
-
* disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted
|
|
1099
|
+
* What a body behind another gets (the attribute `covered`): `hide` (the default) fades its floating name and ring out while its place is inside a nearer body's drawn disc, and back when it comes out, as if the disc hid
|
|
1100
|
+
* them; `arrow` draws instead one small quiet arrow just outside the disc's edge on the side nearest the hidden body, pointing in behind it, with the surest hidden body's name beside it and the others counted
|
|
1101
|
+
* (`Uranus +4`); a press on it goes to that body. The arrow goes as the body comes out; `name` draws the name and ring over the nearer body's disc as 0.57 and earlier did. The same discs hide the Oort cloud's note, the
|
|
1102
|
+
* marks of the places on a body that is behind another, and, through `coveredAt`, any label a page draws over the view.
|
|
1093
1103
|
*/
|
|
1094
1104
|
get covered() {
|
|
1095
1105
|
return this.#covered;
|
|
@@ -1098,6 +1108,7 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1098
1108
|
this.#covered = value;
|
|
1099
1109
|
if (this.#places)
|
|
1100
1110
|
this.#placeLabels(this.#places);
|
|
1111
|
+
this.#placeOort();
|
|
1101
1112
|
}
|
|
1102
1113
|
#labelsAlways = false;
|
|
1103
1114
|
/**
|
|
@@ -1641,12 +1652,14 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1641
1652
|
return out;
|
|
1642
1653
|
}
|
|
1643
1654
|
/**
|
|
1644
|
-
* The controls' yaw and tilt that look at a body from the side the camera comes from, swung so a companion is in the picture and the body stays at least half lit; null
|
|
1655
|
+
* The controls' yaw and tilt that look at a body from the side the camera comes from, swung so a companion is in the picture and the body stays at least half lit; null for the Earth before the camera has drawn.
|
|
1645
1656
|
* The reader's own later turn is not touched: this runs for an arrival and for a double click, not for a drag.
|
|
1646
1657
|
*/
|
|
1647
1658
|
#faceApproach(id, swing = true) {
|
|
1648
1659
|
const model = this.#model;
|
|
1649
|
-
|
|
1660
|
+
// a move asked for before the first draw (an address that opens at a body, `goTo` on a page that has just loaded) comes from where the view opens, the Earth: its camera is not drawn yet, and with no side
|
|
1661
|
+
// chosen the body is looked at from whichever side the default aim falls on, which for a body beyond the Earth is the night side half the day
|
|
1662
|
+
if (!model.pose.valid && id === "earth")
|
|
1650
1663
|
return null;
|
|
1651
1664
|
const body = this.#site(id);
|
|
1652
1665
|
const sun = id === "sun" ? undefined : this.#site("sun").at;
|
|
@@ -1991,6 +2004,10 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
1991
2004
|
this.#showNote();
|
|
1992
2005
|
if (this.#oortLabel.hidden)
|
|
1993
2006
|
this.#oortLabel.hidden = false;
|
|
2007
|
+
// the note fades out while a nearer body's disc is over its place
|
|
2008
|
+
const behind = this.#covered !== "name" && coverOf(at, this.#model.discs) !== null;
|
|
2009
|
+
if (this.#oortLabel.hasAttribute("data-covered") !== behind)
|
|
2010
|
+
this.#oortLabel.toggleAttribute("data-covered", behind);
|
|
1994
2011
|
this.#oortLabel.style.transform = `translate(${Math.round(at.x) + 6}px,${Math.round(at.y) - 8}px)`;
|
|
1995
2012
|
}
|
|
1996
2013
|
/** What the camera is riding along with now, or null. */
|
|
@@ -2190,7 +2207,8 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2190
2207
|
// beside the dot, on the side that stays inside the view
|
|
2191
2208
|
const { x, y, flipped } = nameSpot(at, { width, height: 16 }, frame);
|
|
2192
2209
|
// a body that carries its drawn name gives its floating name up (it fades, and leaves its place to the others) unless the page keeps both; a body behind another gives it up for the arrow
|
|
2193
|
-
const
|
|
2210
|
+
const hidden = at.behind !== undefined && this.#covered === "hide";
|
|
2211
|
+
const carried = hidden || (at.named === true && !this.#labelsAlways);
|
|
2194
2212
|
const covered = at.behind !== undefined && this.#covered === "arrow";
|
|
2195
2213
|
if (covered)
|
|
2196
2214
|
continue;
|
|
@@ -2451,6 +2469,17 @@ export class WakuseiSpace extends HTMLElement {
|
|
|
2451
2469
|
const at = this.#places?.[id];
|
|
2452
2470
|
return at ? { ...at } : null;
|
|
2453
2471
|
}
|
|
2472
|
+
/**
|
|
2473
|
+
* Which body's drawn disc hides a point of the scene at the last draw, or `null`: for a page that draws its own label over the view (a belt's name at its anchor, a pin) and wants it to go where a nearer body is in
|
|
2474
|
+
* front of it, the way the view's own names do. The point is in the scene's places (`stats.camera` is in the same ones); the discs are the bodies and moons placed on the screen, at the radius `placeOf(id).r`
|
|
2475
|
+
* gives. Always `null` while `labels` is off, since the discs are worked out with the names.
|
|
2476
|
+
*
|
|
2477
|
+
* @param point - A place in the scene.
|
|
2478
|
+
* @returns The id of the covering body, or `null` when the point is in the open or off the view.
|
|
2479
|
+
*/
|
|
2480
|
+
coveredAt(point) {
|
|
2481
|
+
return this.#model.coverAt([point[0], point[1], point[2]]);
|
|
2482
|
+
}
|
|
2454
2483
|
#nameLabel(button, id) {
|
|
2455
2484
|
const text = this.#nameOf(id);
|
|
2456
2485
|
button.textContent = text;
|
package/dist/space/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, systemOf, type SpaceK
|
|
|
7
7
|
export { besideMoon, BESIDE_RADII, type BesideCamera, type BesideInput } from "./beside.ts";
|
|
8
8
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, helpSpin, readHelpPlace, spinArrow, type HelpPlace, type OrbitArrow } from "./arrows.ts";
|
|
9
9
|
export { spinAxis, type SpinAxis } from "./spin.ts";
|
|
10
|
-
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, type CoverArrow, type CoverEntry } from "./covered.ts";
|
|
10
|
+
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, coverOf, type CoverArrow, type CoverEntry } from "./covered.ts";
|
|
11
11
|
export { TRAVEL_BUDGET_MS, TRAVEL_CLEARANCE, arrivalSide, travelArrival, travelPlan, travelPose, type ArrivalCompanion, type TravelBody, type TravelInput, type TravelKind, type TravelPlan, type TravelSample, type TravelSight, type TravelView } from "./travel.ts";
|
|
12
12
|
export { bodyBasis, carry, controlsFor, directionBetween, FRAMES, hasRotation, holdSite, keepClear, pairAxis, pairBasis, readFrame, type FrameKind, type HoldBasis } from "./hold.ts";
|
|
13
13
|
export { regionOrbits, regionView, SUN_REGIONS, type SunRegion } from "./regions.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { bodyKindOf, findBody, HOP_ORDER, hopFrom, hostOf, systemOf } from "./bo
|
|
|
8
8
|
export { besideMoon, BESIDE_RADII } from "./beside.js";
|
|
9
9
|
export { ARROWS_PER_ORBIT, arrowCount, arrowSites, MAX_ARROWS_PER_ORBIT, chevron, helpSpin, readHelpPlace, spinArrow } from "./arrows.js";
|
|
10
10
|
export { spinAxis } from "./spin.js";
|
|
11
|
-
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy } from "./covered.js";
|
|
11
|
+
export { COVER_ARROW_GAP, COVER_MIN_PX, coverArrows, coveredBy, coverOf } from "./covered.js";
|
|
12
12
|
export { TRAVEL_BUDGET_MS, TRAVEL_CLEARANCE, arrivalSide, travelArrival, travelPlan, travelPose } from "./travel.js";
|
|
13
13
|
export { bodyBasis, carry, controlsFor, directionBetween, FRAMES, hasRotation, holdSite, keepClear, pairAxis, pairBasis, readFrame } from "./hold.js";
|
|
14
14
|
export { regionOrbits, regionView, SUN_REGIONS } from "./regions.js";
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { type PaintLabel, type WakuseiPainter } from "../scene/painter.ts";
|
|
|
9
9
|
import "../bodies/all.ts";
|
|
10
10
|
import { type Vec3 } from "../vec.ts";
|
|
11
11
|
import { type HelpPlace, type OrbitArrow } from "./arrows.ts";
|
|
12
|
+
import { type CoverEntry } from "./covered.ts";
|
|
12
13
|
import type { SightInput } from "./sight.ts";
|
|
13
14
|
import { type SpaceDwarf, type SpaceFrame, type SpacePlanet, type SpaceVec3 } from "./frame.ts";
|
|
14
15
|
import { type PaintSpec, type PaintTrail } from "../paint/trail.ts";
|
|
@@ -319,7 +320,11 @@ export interface SpaceModel {
|
|
|
319
320
|
oort: {
|
|
320
321
|
x: number;
|
|
321
322
|
y: number;
|
|
323
|
+
distance: number;
|
|
322
324
|
} | null;
|
|
325
|
+
/** The drawn discs at the last draw (the bodies and moons placed on the screen, with their distances from the camera), and which of them hides a point of the scene (in the scene's absolute places), or null when none does. */
|
|
326
|
+
discs: readonly CoverEntry[];
|
|
327
|
+
coverAt: (point: Vec3) => string | null;
|
|
323
328
|
/** How many frames the ephemeris has worked out. */
|
|
324
329
|
lookups: number;
|
|
325
330
|
/** Pixels a game-second moves things on the screen (the fastest turning body in sight): the draw rate follows it. */
|
package/dist/space/scene.js
CHANGED
|
@@ -12,7 +12,7 @@ import { groundDirection } from "./aim.js";
|
|
|
12
12
|
import { hostOf } from "./bodies.js";
|
|
13
13
|
import { arrowSites, ARROWS_PER_ORBIT, chevron, helpSpin, MAX_ARROWS_PER_ORBIT } from "./arrows.js";
|
|
14
14
|
import { besideMoon } from "./beside.js";
|
|
15
|
-
import { coveredBy } from "./covered.js";
|
|
15
|
+
import { coveredBy, coverOf } from "./covered.js";
|
|
16
16
|
import { spinAxis } from "./spin.js";
|
|
17
17
|
import { createTrack, EARTH_RADIUS_KM, eclipticToScene, frameAt, moonOrbit, planetOrbit, SPACE_DWARFS, SPACE_MINORS, SPACE_PLANETS } from "./frame.js";
|
|
18
18
|
import { createPaintOverlay } from "./paint-overlay.js";
|
|
@@ -170,6 +170,8 @@ export const newSpaceModel = () => ({
|
|
|
170
170
|
door: { points: 0, belts: 0, draws: 0, used: {} },
|
|
171
171
|
belts: BELT_IDS,
|
|
172
172
|
oort: null,
|
|
173
|
+
discs: [],
|
|
174
|
+
coverAt: () => null,
|
|
173
175
|
lookups: 0,
|
|
174
176
|
motion: 0,
|
|
175
177
|
drawnView: null,
|
|
@@ -852,7 +854,7 @@ export function createSpaceItem(model, deps) {
|
|
|
852
854
|
const off = projected.x * projected.x + projected.y * projected.y;
|
|
853
855
|
if (off < best) {
|
|
854
856
|
best = off;
|
|
855
|
-
model.oort = { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height };
|
|
857
|
+
model.oort = { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height, distance: Math.hypot(oortPositions[i * 3] - camera.position.x, oortPositions[i * 3 + 1] - camera.position.y, oortPositions[i * 3 + 2] - camera.position.z) };
|
|
856
858
|
}
|
|
857
859
|
}
|
|
858
860
|
}
|
|
@@ -1314,8 +1316,23 @@ export function createSpaceItem(model, deps) {
|
|
|
1314
1316
|
}
|
|
1315
1317
|
for (const [id, cover] of coveredBy(entries))
|
|
1316
1318
|
places[id].behind = cover;
|
|
1319
|
+
// a point of the scene that a page labels (a belt's name at its anchor) is hidden by the same discs
|
|
1320
|
+
model.discs = entries;
|
|
1321
|
+
model.coverAt = (point) => {
|
|
1322
|
+
// in front of the camera, whatever the far plane cuts: a belt's name is labelled far beyond what is drawn
|
|
1323
|
+
projected.set(point[0] - origin[0], point[1] - origin[1], point[2] - origin[2]).applyMatrix4(camera.matrixWorldInverse);
|
|
1324
|
+
if (!(projected.z < 0))
|
|
1325
|
+
return null;
|
|
1326
|
+
const distance = Math.hypot(projected.x, projected.y, projected.z);
|
|
1327
|
+
projected.applyMatrix4(camera.projectionMatrix);
|
|
1328
|
+
return coverOf({ x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height, distance }, entries);
|
|
1329
|
+
};
|
|
1317
1330
|
deps.onLabels(places);
|
|
1318
1331
|
}
|
|
1332
|
+
else {
|
|
1333
|
+
model.discs = [];
|
|
1334
|
+
model.coverAt = () => null;
|
|
1335
|
+
}
|
|
1319
1336
|
// after the names: the places on the Earth keep clear of them
|
|
1320
1337
|
if (deps.onEarth && (deps.wantEarth?.() ?? false)) {
|
|
1321
1338
|
const earth = rideFrom ? undefined : slots.get("earth")?.drawing;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.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",
|