@johnmorrisdotca/chikyu-earth 0.52.0 → 0.54.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 +19 -0
- package/README.md +4 -2
- package/dist/flat/colours.d.ts +55 -0
- package/dist/flat/colours.js +71 -0
- package/dist/flat/define.d.ts +3 -0
- package/dist/flat/define.js +6 -0
- package/dist/flat/element.d.ts +188 -0
- package/dist/flat/element.js +1541 -0
- package/dist/flat/facts.d.ts +172 -0
- package/dist/flat/facts.js +168 -0
- package/dist/flat/geometry.d.ts +160 -0
- package/dist/flat/geometry.js +156 -0
- package/dist/flat/index.d.ts +6 -0
- package/dist/flat/index.js +7 -0
- package/dist/flat/track-state.d.ts +174 -0
- package/dist/flat/track-state.js +223 -0
- package/dist/flat/words.d.ts +25 -0
- package/dist/flat/words.js +78 -0
- package/dist/passes/index.d.ts +2 -1
- package/dist/passes/index.js +1 -1
- package/dist/passes/passes.d.ts +34 -0
- package/dist/passes/passes.js +43 -2
- package/dist/realistic/element-base.d.ts +6 -0
- package/dist/realistic/element-base.js +15 -2
- package/dist/space/compass.d.ts +36 -0
- package/dist/space/compass.js +72 -0
- package/dist/space/element-base.d.ts +48 -1
- package/dist/space/element-base.js +95 -6
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +1 -0
- package/dist/space/north-up.d.ts +86 -0
- package/dist/space/north-up.js +104 -0
- package/dist/space/path-controls.d.ts +1 -1
- package/dist/space/path-controls.js +13 -2
- package/dist/space/path-ribbons.d.ts +4 -0
- package/dist/space/path-ribbons.js +8 -4
- package/dist/space/satellite-layer.d.ts +5 -0
- package/dist/space/satellite-layer.js +16 -4
- package/dist/space/scene.d.ts +23 -0
- package/dist/space/scene.js +18 -1
- package/package.json +13 -1
|
@@ -165,7 +165,7 @@ export const readTime = (value) => {
|
|
|
165
165
|
* ```
|
|
166
166
|
*/
|
|
167
167
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
168
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far"];
|
|
168
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "satellite-tint", "satellite-streak-max", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far"];
|
|
169
169
|
#model = newModel();
|
|
170
170
|
#paint = createPaintState();
|
|
171
171
|
#mode = "now";
|
|
@@ -556,7 +556,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
556
556
|
}
|
|
557
557
|
else if (name === "hover-path" || name === "names-on-hover")
|
|
558
558
|
this.#hover?.sync();
|
|
559
|
-
else if (name === "selected-path")
|
|
559
|
+
else if (name === "selected-path" || name === "path-light")
|
|
560
560
|
this.#pathControls?.sync();
|
|
561
561
|
else if (name === "estimate-far")
|
|
562
562
|
this.#applyEstimate();
|
|
@@ -1562,6 +1562,19 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1562
1562
|
else
|
|
1563
1563
|
this.setAttribute("selected-path", "off");
|
|
1564
1564
|
}
|
|
1565
|
+
/**
|
|
1566
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
1567
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
1568
|
+
*/
|
|
1569
|
+
get pathLight() {
|
|
1570
|
+
return !/^(off|false|no|0)$/i.test((this.getAttribute("path-light") ?? "").trim());
|
|
1571
|
+
}
|
|
1572
|
+
set pathLight(value) {
|
|
1573
|
+
if (value)
|
|
1574
|
+
this.removeAttribute("path-light");
|
|
1575
|
+
else
|
|
1576
|
+
this.setAttribute("path-light", "off");
|
|
1577
|
+
}
|
|
1565
1578
|
/**
|
|
1566
1579
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
1567
1580
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CompassPoint } from "../flat/track-state.ts";
|
|
2
|
+
import type { RideTrack } from "./scene.ts";
|
|
3
|
+
/** The two languages' words of the compass. `{point}` is the point of the compass and `{deg}` the bearing in whole degrees. */
|
|
4
|
+
export declare const COMPASS_WORDS: {
|
|
5
|
+
readonly en: {
|
|
6
|
+
readonly north: "N";
|
|
7
|
+
readonly heading: "Heading {point} {deg}°";
|
|
8
|
+
readonly label: "Compass: north is shown by the arrow. Heading {point}, {deg} degrees.";
|
|
9
|
+
readonly points: Record<CompassPoint, string>;
|
|
10
|
+
};
|
|
11
|
+
readonly ja: {
|
|
12
|
+
readonly north: "北";
|
|
13
|
+
readonly heading: "進行方向 {point} {deg}°";
|
|
14
|
+
readonly label: "方位磁針:矢印が北を指します。進行方向は{point}、{deg}度。";
|
|
15
|
+
readonly points: Record<CompassPoint, string>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
/** The styles of the compass (`#compass`) in an element's shadow root. The dial is white lines on a dark disc, the way-it-goes dot yellow, so it reads on the sea, the land, the night and the day alike; `--chikyu-compass-colour` and `--chikyu-compass-travel` change them. */
|
|
19
|
+
export declare const COMPASS_STYLE = "#compass{position:absolute;left:8px;top:8px;display:flex;flex-direction:column;align-items:center;gap:2px;pointer-events:none;color:var(--chikyu-compass-colour,#fff);font:11px/1.2 system-ui,-apple-system,sans-serif}#compass[hidden]{display:none}#compass svg{width:64px;height:64px;display:block;overflow:visible}#compass .disc{fill:#0b0e14b3;stroke:currentColor;stroke-opacity:.55;stroke-width:1}#compass .north{fill:currentColor}#compass .south{fill:currentColor;fill-opacity:.35}#compass .travel{fill:var(--chikyu-compass-travel,#ffd166);stroke:#0b0e14;stroke-width:1}#compass text{fill:currentColor;font:600 11px system-ui,-apple-system,sans-serif;text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#0b0e14;stroke-width:2.5px}#compass .words{background:#0b0e14b3;padding:1px 6px;border-radius:4px;white-space:nowrap}#compass .words[hidden]{display:none}";
|
|
20
|
+
/** The compass's markup: put it in the shadow root and hand it to `createCompass`. */
|
|
21
|
+
export declare const COMPASS_HTML = "<div id=\"compass\" role=\"img\" hidden><svg viewBox=\"-36 -36 72 72\" aria-hidden=\"true\"><circle class=\"disc\" r=\"25\"></circle><g class=\"arrow\"><path class=\"north\" d=\"M0 -21 L5 -3 L0 -7 L-5 -3 Z\"></path><path class=\"south\" d=\"M0 21 L4 4 L0 7 L-4 4 Z\"></path></g><text class=\"n\" x=\"0\" y=\"-31\">N</text><circle class=\"travel\" r=\"3.4\" cx=\"0\" cy=\"-25\"></circle></svg><span class=\"words\"></span></div>";
|
|
22
|
+
export type CompassMode = "full" | "north" | "off";
|
|
23
|
+
/** Read the attribute `compass`: `off` takes the compass away, `north` shows the arrow without the words, anything else (or nothing) shows both. */
|
|
24
|
+
export declare function readCompass(value: string | null): CompassMode;
|
|
25
|
+
export interface Compass {
|
|
26
|
+
/** Show what the last draw found (or hide the compass for `null`). Changes the page only when something it shows moved by half a degree (the words: a whole degree), the language or the mode changed, so a view at rest does nothing. */
|
|
27
|
+
update(track: RideTrack | null, lang: "en" | "ja", mode: CompassMode): void;
|
|
28
|
+
/** What the compass shows now, for a test: the angle of the arrow, the angle of the dot and the words; `null` when it is hidden. */
|
|
29
|
+
readonly shown: {
|
|
30
|
+
northDeg: number;
|
|
31
|
+
travelDeg: number | null;
|
|
32
|
+
text: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}
|
|
35
|
+
/** Take the markup the element put in its shadow root and make the compass of it. */
|
|
36
|
+
export declare function createCompass(root: ShadowRoot): Compass;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// The compass mark on a ride's picture: a small dial in the element's shadow root with an arrow that points to north, a dot on its rim for the way the satellite is going, and the heading in words ("Heading SE 128°"). It is a few DOM nodes, not the graphics card's,
|
|
2
|
+
// and it is changed only by the draw that moves it, and only when what it shows has changed by half a degree: a picture at rest touches nothing.
|
|
3
|
+
import { compassPoint } from "../flat/track-state.js";
|
|
4
|
+
/** The two languages' words of the compass. `{point}` is the point of the compass and `{deg}` the bearing in whole degrees. */
|
|
5
|
+
export const COMPASS_WORDS = {
|
|
6
|
+
en: { north: "N", heading: "Heading {point} {deg}°", label: "Compass: north is shown by the arrow. Heading {point}, {deg} degrees.", points: { N: "N", NE: "NE", E: "E", SE: "SE", S: "S", SW: "SW", W: "W", NW: "NW" } },
|
|
7
|
+
ja: { north: "北", heading: "進行方向 {point} {deg}°", label: "方位磁針:矢印が北を指します。進行方向は{point}、{deg}度。", points: { N: "北", NE: "北東", E: "東", SE: "南東", S: "南", SW: "南西", W: "西", NW: "北西" } },
|
|
8
|
+
};
|
|
9
|
+
/** The styles of the compass (`#compass`) in an element's shadow root. The dial is white lines on a dark disc, the way-it-goes dot yellow, so it reads on the sea, the land, the night and the day alike; `--chikyu-compass-colour` and `--chikyu-compass-travel` change them. */
|
|
10
|
+
export const COMPASS_STYLE = "#compass{position:absolute;left:8px;top:8px;display:flex;flex-direction:column;align-items:center;gap:2px;pointer-events:none;color:var(--chikyu-compass-colour,#fff);font:11px/1.2 system-ui,-apple-system,sans-serif}#compass[hidden]{display:none}#compass svg{width:64px;height:64px;display:block;overflow:visible}#compass .disc{fill:#0b0e14b3;stroke:currentColor;stroke-opacity:.55;stroke-width:1}#compass .north{fill:currentColor}#compass .south{fill:currentColor;fill-opacity:.35}#compass .travel{fill:var(--chikyu-compass-travel,#ffd166);stroke:#0b0e14;stroke-width:1}#compass text{fill:currentColor;font:600 11px system-ui,-apple-system,sans-serif;text-anchor:middle;dominant-baseline:central;paint-order:stroke;stroke:#0b0e14;stroke-width:2.5px}#compass .words{background:#0b0e14b3;padding:1px 6px;border-radius:4px;white-space:nowrap}#compass .words[hidden]{display:none}";
|
|
11
|
+
/** The compass's markup: put it in the shadow root and hand it to `createCompass`. */
|
|
12
|
+
export const COMPASS_HTML = '<div id="compass" role="img" hidden><svg viewBox="-36 -36 72 72" aria-hidden="true"><circle class="disc" r="25"></circle><g class="arrow"><path class="north" d="M0 -21 L5 -3 L0 -7 L-5 -3 Z"></path><path class="south" d="M0 21 L4 4 L0 7 L-4 4 Z"></path></g><text class="n" x="0" y="-31">N</text><circle class="travel" r="3.4" cx="0" cy="-25"></circle></svg><span class="words"></span></div>';
|
|
13
|
+
/** Read the attribute `compass`: `off` takes the compass away, `north` shows the arrow without the words, anything else (or nothing) shows both. */
|
|
14
|
+
export function readCompass(value) {
|
|
15
|
+
const text = (value ?? "").trim().toLowerCase();
|
|
16
|
+
return text === "off" || text === "false" || text === "no" || text === "none" ? "off" : text === "north" ? "north" : "full";
|
|
17
|
+
}
|
|
18
|
+
/** Take the markup the element put in its shadow root and make the compass of it. */
|
|
19
|
+
export function createCompass(root) {
|
|
20
|
+
const box = root.getElementById("compass");
|
|
21
|
+
const arrow = box.querySelector(".arrow");
|
|
22
|
+
const letter = box.querySelector("text.n");
|
|
23
|
+
const dot = box.querySelector(".travel");
|
|
24
|
+
const words = box.querySelector(".words");
|
|
25
|
+
let key = "";
|
|
26
|
+
let shown = null;
|
|
27
|
+
return {
|
|
28
|
+
update(track, lang, mode) {
|
|
29
|
+
if (!track || mode === "off" || track.northDeg === null) {
|
|
30
|
+
if (!box.hidden)
|
|
31
|
+
box.hidden = true;
|
|
32
|
+
key = "";
|
|
33
|
+
shown = null;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const north = Math.round(track.northDeg * 2) / 2;
|
|
37
|
+
const travel = track.travelDeg === null ? null : Math.round(track.travelDeg * 2) / 2;
|
|
38
|
+
const bearing = Math.round(track.bearingDeg) % 360;
|
|
39
|
+
const next = `${north}|${travel}|${bearing}|${lang}|${mode}`;
|
|
40
|
+
if (next === key && !box.hidden)
|
|
41
|
+
return;
|
|
42
|
+
key = next;
|
|
43
|
+
const set = COMPASS_WORDS[lang];
|
|
44
|
+
const text = set.heading.replace("{point}", set.points[compassPoint(bearing)]).replace("{deg}", String(bearing));
|
|
45
|
+
arrow.setAttribute("transform", `rotate(${north})`);
|
|
46
|
+
// the letter stays upright, at the arrow's tip
|
|
47
|
+
const a = north * (Math.PI / 180);
|
|
48
|
+
letter.setAttribute("x", (31 * Math.sin(a)).toFixed(2));
|
|
49
|
+
letter.setAttribute("y", (-31 * Math.cos(a)).toFixed(2));
|
|
50
|
+
if (letter.textContent !== set.north)
|
|
51
|
+
letter.textContent = set.north;
|
|
52
|
+
if (travel === null)
|
|
53
|
+
dot.setAttribute("visibility", "hidden");
|
|
54
|
+
else {
|
|
55
|
+
dot.removeAttribute("visibility");
|
|
56
|
+
const t = travel * (Math.PI / 180);
|
|
57
|
+
dot.setAttribute("cx", (25 * Math.sin(t)).toFixed(2));
|
|
58
|
+
dot.setAttribute("cy", (-25 * Math.cos(t)).toFixed(2));
|
|
59
|
+
}
|
|
60
|
+
words.textContent = text;
|
|
61
|
+
words.hidden = mode === "north";
|
|
62
|
+
box.setAttribute("aria-label", set.label.replace("{point}", set.points[compassPoint(bearing)]).replace("{deg}", String(bearing)));
|
|
63
|
+
box.lang = lang;
|
|
64
|
+
if (box.hidden)
|
|
65
|
+
box.hidden = false;
|
|
66
|
+
shown = { northDeg: north, travelDeg: travel, text };
|
|
67
|
+
},
|
|
68
|
+
get shown() {
|
|
69
|
+
return shown;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -21,9 +21,10 @@ import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts"
|
|
|
21
21
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
22
22
|
import { type PathStats } from "./path-controls.ts";
|
|
23
23
|
import { type PathHit, type PathRequest, type PathStyle } from "./paths.ts";
|
|
24
|
+
import type { RideUp } from "./north-up.ts";
|
|
24
25
|
import { type RideDrag, type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
25
26
|
import { type ScaleMode } from "./scale.ts";
|
|
26
|
-
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
27
|
+
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type RideTrack, type SatellitePainter } from "./scene.ts";
|
|
27
28
|
import { type PaintSpec } from "../paint/buffer.ts";
|
|
28
29
|
export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
29
30
|
/**
|
|
@@ -127,6 +128,8 @@ export interface RideOptions {
|
|
|
127
128
|
modelSize?: RideModelSize;
|
|
128
129
|
/** What a drag does in an outside ride from the satellite (`view: "from"`): `head` (the default, or the element's `ride-drag`) turns the view where the camera is, like turning your head, so the camera keeps its place behind and above the satellite and the scene turns round it; `orbit` takes the camera round the satellite as it looks about, so the satellite stays in the same place in the picture and is seen from every side, as a ride did up to 0.51. */
|
|
129
130
|
drag?: RideDrag;
|
|
131
|
+
/** Which way is up in the view above a satellite (`view: "above"`): `travel` (the default, or the element's `ride-up`) puts the way the satellite is going at the top of the picture, `north` puts north there, so the satellite is seen to go the way it really goes over the ground. Within 3 degrees of a pole it is `travel` (mixed in smoothly out to 6). A drag turns the picture from there. */
|
|
132
|
+
up?: RideUp;
|
|
130
133
|
distanceKm?: number;
|
|
131
134
|
smooth?: boolean;
|
|
132
135
|
}
|
|
@@ -153,6 +156,8 @@ export interface Riding {
|
|
|
153
156
|
modelSize: RideModelSize;
|
|
154
157
|
/** `head` or `orbit` (see `RideOptions`). */
|
|
155
158
|
drag: RideDrag;
|
|
159
|
+
/** `travel` or `north` (see `RideOptions`). */
|
|
160
|
+
up: RideUp;
|
|
156
161
|
}
|
|
157
162
|
type SatelliteStats = {
|
|
158
163
|
groups: number;
|
|
@@ -606,6 +611,36 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
606
611
|
*/
|
|
607
612
|
get rideDrag(): RideDrag;
|
|
608
613
|
set rideDrag(value: RideDrag);
|
|
614
|
+
/**
|
|
615
|
+
* Which way is up in the picture of a ride above a satellite (the attribute `ride-up`): `travel` (the default) keeps the way the satellite is going at the top, so the picture turns as the heading does; `north` keeps north at the top, so the satellite is seen to go south-east, or whichever way
|
|
616
|
+
* it really goes over the ground. Within 3 degrees of a pole north-up gives way to travel-up (mixed in smoothly out to 6 degrees), because there north's direction swings round faster than a picture can follow. A drag turns the picture from the up it has, so with `north` a drag turns it away from north, and the compass shows where north has gone.
|
|
617
|
+
* It is the default for the next `ride` and, set while riding, turns the picture to the new up in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock. The other views (`from`, `follow`) keep the way it is going at the top. See `RideOptions.up`.
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```ts
|
|
621
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
622
|
+
*
|
|
623
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
624
|
+
* space.rideUp = "north";
|
|
625
|
+
* console.log(space.rideUp);
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
get rideUp(): RideUp;
|
|
629
|
+
set rideUp(value: RideUp);
|
|
630
|
+
/**
|
|
631
|
+
* Where the ridden satellite is over the ground and how it is going, as of the last draw: `lat`, `lon`, `heightKm`, `bearingDeg` (the way its ground track runs, degrees clockwise from north, with the Earth's turn taken out), `ascending` (going north), `sunlit` (the Sun lights it; the Earth's shadow is a cylinder),
|
|
632
|
+
* and where north is in the picture: `northDeg` (degrees clockwise from the top; 0 means north is at the top) and `travelDeg` (the way it goes, in the picture). `null` when no satellite is ridden or followed. A page that prints "heading SE 128°" reads `bearingDeg` and needs no maths of its own;
|
|
633
|
+
* `chikyu-ride-track` is sent with the same object when the whole degree of the heading, `ascending` or `sunlit` changes, never on a timer. It is worked out by the draws the picture makes, so it is as new as the last draw.
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```ts
|
|
637
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
638
|
+
*
|
|
639
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
640
|
+
* console.log(space.rideTrack);
|
|
641
|
+
* ```
|
|
642
|
+
*/
|
|
643
|
+
get rideTrack(): RideTrack | null;
|
|
609
644
|
/**
|
|
610
645
|
* The radius of the ridden satellite's model as a share of the picture's height, 0.02 to 1.2 (the attribute `ride-model-share`), or `null` for the ride's own: 0.22 along the way it goes, 0.17 above the satellite (its size at the lowest height; `ride-model-size="distance"` still shrinks it as the ride rises).
|
|
611
646
|
* Set while riding it glides in 0.4 s (at once for a reader who asked for less motion). `stats.followModel.share` is the share in use.
|
|
@@ -799,6 +834,12 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
799
834
|
*/
|
|
800
835
|
get selectedPath(): boolean;
|
|
801
836
|
set selectedPath(value: boolean);
|
|
837
|
+
/**
|
|
838
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
839
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
840
|
+
*/
|
|
841
|
+
get pathLight(): boolean;
|
|
842
|
+
set pathLight(value: boolean);
|
|
802
843
|
/**
|
|
803
844
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
804
845
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -894,6 +935,12 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
894
935
|
/** The page's paths: asked for, drawn (with the chosen satellite's own), left out over the cap of 16, unmatched, whether the chosen satellite's own orbit is drawn, draw calls they took at the last draw (0 or 1), the path under the mouse and the `chikyu-path-click` events sent. */
|
|
895
936
|
paths: PathStats;
|
|
896
937
|
ride: {
|
|
938
|
+
track: RideTrack | null;
|
|
939
|
+
compass: {
|
|
940
|
+
northDeg: number;
|
|
941
|
+
travelDeg: number | null;
|
|
942
|
+
text: string;
|
|
943
|
+
} | null;
|
|
897
944
|
riding: boolean;
|
|
898
945
|
lost: boolean;
|
|
899
946
|
gliding: boolean;
|
|
@@ -37,6 +37,7 @@ import { bindPaths, emptyPathStats, pointerOf, readPathPriority } from "./path-c
|
|
|
37
37
|
import { styleTable } from "./paths.js";
|
|
38
38
|
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
|
|
39
39
|
import { clampFollow, retargetFollow } from "./follow.js";
|
|
40
|
+
import { COMPASS_HTML, COMPASS_STYLE, createCompass, readCompass } from "./compass.js";
|
|
40
41
|
import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
41
42
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
42
43
|
import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
|
|
@@ -132,7 +133,7 @@ const readTime = (value) => {
|
|
|
132
133
|
const ms = Date.parse(value);
|
|
133
134
|
return Number.isFinite(ms) ? ms : "now";
|
|
134
135
|
};
|
|
135
|
-
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}${IMMERSIVE_STYLE}#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[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;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-sat[hidden]{display:none}.sp-sat[data-hover]{transition:opacity 180ms linear}@media (prefers-reduced-motion: reduce){.sp-sat[data-hover]{transition:none}}${PLACE_STYLE}${SKY_STYLE}${COUNTRY_NAMES_STYLE}${SEA_NAMES_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
136
|
+
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}${IMMERSIVE_STYLE}#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[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;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-sat[hidden]{display:none}.sp-sat[data-hover]{transition:opacity 180ms linear}@media (prefers-reduced-motion: reduce){.sp-sat[data-hover]{transition:none}}${PLACE_STYLE}${SKY_STYLE}${COUNTRY_NAMES_STYLE}${SEA_NAMES_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}${COMPASS_STYLE}`;
|
|
136
137
|
/**
|
|
137
138
|
* The `<chikyu-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`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
138
139
|
*
|
|
@@ -177,7 +178,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
177
178
|
* ```
|
|
178
179
|
*/
|
|
179
180
|
export class ChikyuSpace extends HTMLElement {
|
|
180
|
-
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "ride-drag", "hover-path", "names-on-hover", "selected-path", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
181
|
+
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "ride-drag", "hover-path", "names-on-hover", "selected-path", "path-light", "path-hit", "path-priority", "estimate-far", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom", "ride-up", "compass"];
|
|
181
182
|
#model = newSpaceModel();
|
|
182
183
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
183
184
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -208,6 +209,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
208
209
|
/** The ringed satellites of the last draw (`labelSatellites`), laid out with the places. */
|
|
209
210
|
#marks = [];
|
|
210
211
|
#airNote;
|
|
212
|
+
/** The compass on a ride's picture. */
|
|
213
|
+
#compass;
|
|
214
|
+
/** The heading last told to the page (`chikyu-ride-track`): whole degrees, ascending and sunlit, so a heading that has not changed is not told again. */
|
|
215
|
+
#toldTrack = "";
|
|
211
216
|
#bodiesNote;
|
|
212
217
|
#gate;
|
|
213
218
|
#taken;
|
|
@@ -273,8 +278,9 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
273
278
|
if (!this.hasAttribute("aria-label"))
|
|
274
279
|
this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
|
|
275
280
|
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
276
|
-
root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div
|
|
281
|
+
root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div>${COMPASS_HTML}<div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p><p id="bodies-note" hidden></p><p id="finer-credit" hidden></p></div>`;
|
|
277
282
|
adoptStyles(root, STYLE, this.nonce);
|
|
283
|
+
this.#compass = createCompass(root);
|
|
278
284
|
this.#stage = root.getElementById("stage");
|
|
279
285
|
this.#labelBox = root.getElementById("labels");
|
|
280
286
|
this.#note = root.getElementById("meteor-note");
|
|
@@ -474,6 +480,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
474
480
|
this.#applyModelSize();
|
|
475
481
|
else if (name === "ride-drag")
|
|
476
482
|
this.#applyDrag();
|
|
483
|
+
else if (name === "ride-up")
|
|
484
|
+
this.#applyUp();
|
|
485
|
+
else if (name === "compass")
|
|
486
|
+
this.#showCompass();
|
|
477
487
|
else if (name === "ride-model-share" || name === "ride-model-seat")
|
|
478
488
|
this.#applyFrame();
|
|
479
489
|
else if (name === "ride-zoom")
|
|
@@ -580,7 +590,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
580
590
|
}
|
|
581
591
|
else if (name === "hover-path" || name === "names-on-hover")
|
|
582
592
|
this.#hover?.sync();
|
|
583
|
-
else if (name === "selected-path")
|
|
593
|
+
else if (name === "selected-path" || name === "path-light")
|
|
584
594
|
this.#pathControls?.sync();
|
|
585
595
|
else if (name === "estimate-far")
|
|
586
596
|
this.#applyEstimate();
|
|
@@ -957,6 +967,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
957
967
|
#nameFrame(frame) {
|
|
958
968
|
this.#lastNameFrame = frame;
|
|
959
969
|
this.#tellModel();
|
|
970
|
+
this.#showCompass();
|
|
960
971
|
this.#relayNames(true, false);
|
|
961
972
|
}
|
|
962
973
|
/**
|
|
@@ -1525,7 +1536,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1525
1536
|
// a body followed (a planet, the Moon, the Earth) is looked at from round it as the view turns: it has no ways to face
|
|
1526
1537
|
const faceable = !(view === "follow" && typeof target === "string");
|
|
1527
1538
|
const face = faceable && options.face && RIDE_FACES.includes(options.face) ? options.face : null;
|
|
1528
|
-
model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: face && view === "from" ? "horizon" : (options.look ?? "down"), face, distanceKm: Math.max(100, options.distanceKm ?? 3000), viewpoint: options.viewpoint === "inside" || options.viewpoint === "outside" ? options.viewpoint : this.rideViewpoint, modelSize: options.modelSize === "fixed" || options.modelSize === "distance" ? options.modelSize : this.rideModelSize, drag: options.drag === "head" || options.drag === "orbit" ? options.drag : this.rideDrag };
|
|
1539
|
+
model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: face && view === "from" ? "horizon" : (options.look ?? "down"), face, distanceKm: Math.max(100, options.distanceKm ?? 3000), viewpoint: options.viewpoint === "inside" || options.viewpoint === "outside" ? options.viewpoint : this.rideViewpoint, modelSize: options.modelSize === "fixed" || options.modelSize === "distance" ? options.modelSize : this.rideModelSize, drag: options.drag === "head" || options.drag === "orbit" ? options.drag : this.rideDrag, up: options.up === "north" || options.up === "travel" ? options.up : this.rideUp };
|
|
1529
1540
|
if (face) {
|
|
1530
1541
|
model.view = { yaw: 0, tilt: 0, zoom: model.view.zoom };
|
|
1531
1542
|
model.rideTurn = 0;
|
|
@@ -1724,6 +1735,71 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1724
1735
|
this.#gate?.request();
|
|
1725
1736
|
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1726
1737
|
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Which way is up in the picture of a ride above a satellite (the attribute `ride-up`): `travel` (the default) keeps the way the satellite is going at the top, so the picture turns as the heading does; `north` keeps north at the top, so the satellite is seen to go south-east, or whichever way
|
|
1740
|
+
* it really goes over the ground. Within 3 degrees of a pole north-up gives way to travel-up (mixed in smoothly out to 6 degrees), because there north's direction swings round faster than a picture can follow. A drag turns the picture from the up it has, so with `north` a drag turns it away from north, and the compass shows where north has gone.
|
|
1741
|
+
* It is the default for the next `ride` and, set while riding, turns the picture to the new up in one eased glide (a jump for a reader who asked for reduced motion), keeping the ride and the clock. The other views (`from`, `follow`) keep the way it is going at the top. See `RideOptions.up`.
|
|
1742
|
+
*
|
|
1743
|
+
* @example
|
|
1744
|
+
* ```ts
|
|
1745
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1746
|
+
*
|
|
1747
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1748
|
+
* space.rideUp = "north";
|
|
1749
|
+
* console.log(space.rideUp);
|
|
1750
|
+
* ```
|
|
1751
|
+
*/
|
|
1752
|
+
get rideUp() {
|
|
1753
|
+
return this.getAttribute("ride-up") === "north" ? "north" : "travel";
|
|
1754
|
+
}
|
|
1755
|
+
set rideUp(value) {
|
|
1756
|
+
this.setAttribute("ride-up", value === "north" ? "north" : "travel");
|
|
1757
|
+
}
|
|
1758
|
+
#applyUp() {
|
|
1759
|
+
const model = this.#model;
|
|
1760
|
+
const ride = model.ride;
|
|
1761
|
+
const next = this.rideUp;
|
|
1762
|
+
if (!ride || ride.up === next)
|
|
1763
|
+
return;
|
|
1764
|
+
const reduced = prefersLessMotion();
|
|
1765
|
+
const pose = model.pose;
|
|
1766
|
+
model.ride = { ...ride, up: next };
|
|
1767
|
+
// only the view above a satellite looks different
|
|
1768
|
+
const moves = ride.view === "above" && typeof ride.target !== "string";
|
|
1769
|
+
model.transition = moves && !reduced && pose.valid ? { start: performance.now(), duration: 800, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
1770
|
+
this.#last = performance.now();
|
|
1771
|
+
this.#schedule();
|
|
1772
|
+
this.#gate?.request();
|
|
1773
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1774
|
+
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Where the ridden satellite is over the ground and how it is going, as of the last draw: `lat`, `lon`, `heightKm`, `bearingDeg` (the way its ground track runs, degrees clockwise from north, with the Earth's turn taken out), `ascending` (going north), `sunlit` (the Sun lights it; the Earth's shadow is a cylinder),
|
|
1777
|
+
* and where north is in the picture: `northDeg` (degrees clockwise from the top; 0 means north is at the top) and `travelDeg` (the way it goes, in the picture). `null` when no satellite is ridden or followed. A page that prints "heading SE 128°" reads `bearingDeg` and needs no maths of its own;
|
|
1778
|
+
* `chikyu-ride-track` is sent with the same object when the whole degree of the heading, `ascending` or `sunlit` changes, never on a timer. It is worked out by the draws the picture makes, so it is as new as the last draw.
|
|
1779
|
+
*
|
|
1780
|
+
* @example
|
|
1781
|
+
* ```ts
|
|
1782
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1783
|
+
*
|
|
1784
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1785
|
+
* console.log(space.rideTrack);
|
|
1786
|
+
* ```
|
|
1787
|
+
*/
|
|
1788
|
+
get rideTrack() {
|
|
1789
|
+
return this.#model.rideTrack ? { ...this.#model.rideTrack } : null;
|
|
1790
|
+
}
|
|
1791
|
+
/** Shows the compass for the last draw (the language, the mode of the attribute `compass`), and tells the page when the heading changed by a whole degree, or the satellite went into or out of the Earth's shadow. Called with the draw. */
|
|
1792
|
+
#showCompass() {
|
|
1793
|
+
const track = this.#model.rideTrack;
|
|
1794
|
+
const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
1795
|
+
this.#compass?.update(track, lang, readCompass(this.getAttribute("compass")));
|
|
1796
|
+
const key = track ? `${Math.round(track.bearingDeg) % 360}|${track.ascending}|${track.sunlit}` : "";
|
|
1797
|
+
if (key === this.#toldTrack)
|
|
1798
|
+
return;
|
|
1799
|
+
this.#toldTrack = key;
|
|
1800
|
+
if (track)
|
|
1801
|
+
this.dispatchEvent(new CustomEvent("chikyu-ride-track", { detail: { ...track } }));
|
|
1802
|
+
}
|
|
1727
1803
|
#applyModelSize() {
|
|
1728
1804
|
const ride = this.#model.ride;
|
|
1729
1805
|
const next = this.rideModelSize;
|
|
@@ -2157,6 +2233,19 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2157
2233
|
else
|
|
2158
2234
|
this.setAttribute("selected-path", "off");
|
|
2159
2235
|
}
|
|
2236
|
+
/**
|
|
2237
|
+
* Colour the chosen satellite's own orbit by the light on it (the attribute `path-light`; on unless `off`): amber where the satellite is in sunlight and blue where it is in the Earth's shadow (a cylinder of the Earth's radius along the line from the Sun; `--chikyu-path-sun` and `--chikyu-path-shadow` change the two colours, read when the attribute, `selected-path` or the element changes). The width, opacity and dash are still those of the `selected` look.
|
|
2238
|
+
* Off, the whole orbit is the `selected` look's one colour, as the orbit always was. The page's other paths (`setPaths`) are not coloured by light. The light is worked out for the moment the orbit was last laid out (it is again every half hour of the clock), and the Sun is taken as fixed over the one revolution the path is.
|
|
2239
|
+
*/
|
|
2240
|
+
get pathLight() {
|
|
2241
|
+
return !/^(off|false|no|0)$/i.test((this.getAttribute("path-light") ?? "").trim());
|
|
2242
|
+
}
|
|
2243
|
+
set pathLight(value) {
|
|
2244
|
+
if (value)
|
|
2245
|
+
this.removeAttribute("path-light");
|
|
2246
|
+
else
|
|
2247
|
+
this.setAttribute("path-light", "off");
|
|
2248
|
+
}
|
|
2160
2249
|
/**
|
|
2161
2250
|
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
2162
2251
|
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
@@ -2366,7 +2455,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2366
2455
|
satellites: this.#satelliteStats(),
|
|
2367
2456
|
lightFade: { mix: this.#model.lightFade.mix, fading: this.#model.lightFade.fading },
|
|
2368
2457
|
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
2369
|
-
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
|
|
2458
|
+
ride: { track: this.#model.rideTrack ? { ...this.#model.rideTrack } : null, compass: this.#compass?.shown ? { ...this.#compass.shown } : null, riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
|
|
2370
2459
|
camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], quaternion: [this.#model.pose.q[0], this.#model.pose.q[1], this.#model.pose.q[2], this.#model.pose.q[3]], fov: this.#model.pose.fov },
|
|
2371
2460
|
bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held, moon: this.#model.painted.moon, tiles: this.#model.painted.tiles, mapped: this.#model.painted.mapped, pending: this.#model.painted.pending },
|
|
2372
2461
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, orbitPath, PLANETS, type Frame, type PlanetName, type Vec3 } from "./ephemeris.ts";
|
|
2
2
|
export { compress, MOON_COMPRESSED, placeAround, placeMoon, placeSun, RADIUS, SUN_COMPRESSED, truePosition, type ScaleMode } from "./scale.ts";
|
|
3
|
-
export { fitDistance, plainPainter, type BodyDrawing, type BodyMoon, type BodyPainter, type BodyView, type PaintContext, type SatellitePainter } from "./scene.ts";
|
|
3
|
+
export { fitDistance, plainPainter, type BodyDrawing, type RideTrack, type BodyMoon, type BodyPainter, type BodyView, type PaintContext, type SatellitePainter } from "./scene.ts";
|
|
4
4
|
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees, type RideDrag, type RideFace, type RideInput, type RideLook, type RidePose, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
5
5
|
export { earthHides, type SatelliteScreen } from "./satellite-layer.ts";
|
|
6
6
|
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.ts";
|
|
7
|
+
export { localNorth, NORTH_UP_BLEND_DEG, NORTH_UP_POLE_DEG, northUpYaw, screenAngle, type RideUp } from "./north-up.ts";
|
|
7
8
|
export { genericSatellite, satelliteKind, type SatelliteKind } from "./generic-satellite.ts";
|
|
8
9
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam, type BeamCells, type BeamOptions } from "../beam/geometry.ts";
|
|
9
10
|
export type { BeamStats } from "../beam/layer.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export { fitDistance, plainPainter } from "./scene.js";
|
|
|
6
6
|
export { faceOffset, OUTSIDE_KM, outsidePose, RIDE_FACES, RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
7
7
|
export { earthHides } from "./satellite-layer.js";
|
|
8
8
|
export { ABOVE_MODEL_KM, ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_FADE_FROM_KM, MODEL_FADE_TO_KM, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
9
|
+
export { localNorth, NORTH_UP_BLEND_DEG, NORTH_UP_POLE_DEG, northUpYaw, screenAngle } from "./north-up.js";
|
|
9
10
|
export { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
10
11
|
export { BEAM_ATTRIBUTES, BEAM_COLOUR, BEAM_ELEVATION, beamCells, footprintAngle, footprintKm, readBeam } from "../beam/geometry.js";
|
|
11
12
|
export { RIDE_PATH_FADE_KM } from "./path-ribbons.js";
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Vec3 } from "./ephemeris.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Which way is up in the picture of a ride above a satellite: `travel` (the default) puts the way the satellite is going at the top, so the picture turns with its heading; `north` puts north at the top, so the satellite is seen to move in its real direction over the ground (south-east, say).
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { RideUp } from "@johnmorrisdotca/chikyu-earth/space";
|
|
8
|
+
*
|
|
9
|
+
* const ups: RideUp[] = ["travel", "north"];
|
|
10
|
+
* console.log(ups.join(" or "));
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export type RideUp = "travel" | "north";
|
|
14
|
+
/**
|
|
15
|
+
* How close to a pole, in degrees of arc, a satellite must be for north-up to give way to travel-up: inside this, north's direction on the ground swings round faster than a picture can follow (and at the pole itself it has none), so the way it is going is at the top.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { NORTH_UP_POLE_DEG } from "@johnmorrisdotca/chikyu-earth/space";
|
|
20
|
+
*
|
|
21
|
+
* console.log(NORTH_UP_POLE_DEG);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const NORTH_UP_POLE_DEG = 3;
|
|
25
|
+
/**
|
|
26
|
+
* How many more degrees from a pole north-up takes to come back in: travel-up holds inside {@link NORTH_UP_POLE_DEG}, north-up holds beyond that many degrees more, and between them the two are mixed by a smooth step so the picture turns, never jumps.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { NORTH_UP_BLEND_DEG } from "@johnmorrisdotca/chikyu-earth/space";
|
|
31
|
+
*
|
|
32
|
+
* console.log(NORTH_UP_BLEND_DEG);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare const NORTH_UP_BLEND_DEG = 3;
|
|
36
|
+
/**
|
|
37
|
+
* Which way north is at a place, as a unit vector in the scene's axes (y is north): the way along the ground that goes towards the pole. `null` at the poles themselves and at the centre, where it is not defined.
|
|
38
|
+
*
|
|
39
|
+
* @param position - Where the place is, from the Earth's centre, in any unit.
|
|
40
|
+
* @returns A unit vector level with the ground there, or `null`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { localNorth } from "@johnmorrisdotca/chikyu-earth/space";
|
|
45
|
+
*
|
|
46
|
+
* console.log(localNorth([1.066, 0, 0]));
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function localNorth(position: Vec3): Vec3 | null;
|
|
50
|
+
/**
|
|
51
|
+
* The turn that puts north at the top of the picture of the view above a satellite (`aboveAxes` turns the picture by its `yaw`, from the way the satellite is going at the top), and how much of it holds. Add `yaw * weight` to the picture's own turn. The weight is 1 away from the poles,
|
|
52
|
+
* 0 within {@link NORTH_UP_POLE_DEG} degrees of one (the way it is going stays at the top), and a smooth step between, over {@link NORTH_UP_BLEND_DEG} degrees. A satellite that is not moving has no way to turn from, and gives a weight of 0.
|
|
53
|
+
*
|
|
54
|
+
* @param position - Where the satellite is, from the Earth's centre.
|
|
55
|
+
* @param velocity - The way it is going.
|
|
56
|
+
* @returns The yaw in radians (positive turns the top towards the left of the way it goes) and its weight, 0 to 1.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { northUpYaw } from "@johnmorrisdotca/chikyu-earth/space";
|
|
61
|
+
*
|
|
62
|
+
* // over the equator going east: north is on the left, a quarter turn
|
|
63
|
+
* const turn = northUpYaw([1.066, 0, 0], [0, 0, -7.66]);
|
|
64
|
+
* console.log((turn.yaw / (Math.PI / 180)).toFixed(0), turn.weight);
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function northUpYaw(position: Vec3, velocity: Vec3): {
|
|
68
|
+
yaw: number;
|
|
69
|
+
weight: number;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Where north points in a picture: the angle, clockwise from the top of the picture, of a direction as the camera sees it (the part of it in the picture's plane). 0 means north is at the top, 90 to the right. `null` when the direction points along the camera's line of sight (or away), where it has no direction in the picture.
|
|
73
|
+
*
|
|
74
|
+
* @param quaternion - The camera's turn, `[x, y, z, w]` as three.js has it (the camera looks along its own -z, with +y up and +x to the right).
|
|
75
|
+
* @param direction - The direction in the scene's axes, such as `localNorth`.
|
|
76
|
+
* @returns Degrees clockwise from the top of the picture, 0 up to 360, or `null`.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { screenAngle } from "@johnmorrisdotca/chikyu-earth/space";
|
|
81
|
+
*
|
|
82
|
+
* // a camera that is not turned: +y is at the top, +x to the right
|
|
83
|
+
* console.log(screenAngle([0, 0, 0, 1], [0, 1, 0]), screenAngle([0, 0, 0, 1], [1, 0, 0]));
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function screenAngle(quaternion: readonly [number, number, number, number], direction: Vec3): number | null;
|