@johnmorrisdotca/chikyu-earth 0.33.0 → 0.33.2
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 +12 -0
- package/README.md +1 -1
- package/dist/realistic/earth.d.ts +1 -1
- package/dist/realistic/element.d.ts +10 -5
- package/dist/realistic/element.js +4 -4
- package/dist/realistic/index.d.ts +1 -0
- package/dist/sky/cover.d.ts +27 -0
- package/dist/sky/cover.js +32 -0
- package/dist/sky/frame.d.ts +21 -0
- package/dist/sky/frame.js +2 -0
- package/dist/sky/host.d.ts +10 -15
- package/dist/sky/host.js +37 -3
- package/dist/sky/style.d.ts +50 -0
- package/dist/sky/style.js +2 -0
- package/dist/space/element.d.ts +13 -7
- package/dist/space/element.js +36 -7
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -1
- package/dist/space/ride.d.ts +60 -4
- package/dist/space/ride.js +78 -6
- package/dist/space/scene.d.ts +5 -1
- package/dist/space/scene.js +17 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.33.2 - 2026-11-11
|
|
6
|
+
|
|
7
|
+
- **kazoku-ui 0.38.1** (KAZOKU-UI-133). The view controls keep a pace of 1 in the address when the page starts at another, so the line globe's 1× (the Earth's real rate) survives a reload; the test of it is switched on (it was `fixme`).
|
|
8
|
+
- **Riding with the horizon look: a drag looks round on the spot, the horizon level** (MODULES-1030). A sideways drag is now a turn about the local vertical (the line from the Earth's centre through the satellite) all the way round, and an up or down drag only tips the camera, from straight down to 20 degrees above the horizon: no roll. Before, the drag turned the camera about its own tipped axis, so the Earth's edge ran diagonally across the picture and a long drag swung it into a corner. The `down` look is as it was. The turn is added up change by change from the controls' wrapped yaw (`rideTurnDegrees`, passed to `ridePose` as `turn`), so a drag really goes the whole way round at any zoom and a change of zoom does not swing the heading, and the controls' tilt is held to the range that does something (`rideTiltLimits`), so a drag back moves the view at once. New in `@johnmorrisdotca/chikyu-earth/space`: `rideFov`, `rideTurnDegrees`, `rideTiltLimits`. `stats.camera` has the camera's turn (`quaternion`). Tests: the camera maths (`ridePose`) over a whole turn, and a browser test that the camera's turn and the Earth's edge in the picture are level at 90, 180 and 270 degrees.
|
|
9
|
+
- **A ride opened from an address keeps the turn the address carries** (MODULES-1030). The riding camera's heading is added up from the controls' changes, and starting a ride set it to nothing, so a link with `ride=iss&yaw=-21` opened looking another way than the view that was dragged to that yaw; the ride now starts from the yaw the controls already hold.
|
|
10
|
+
- **A link to the demo's realistic Earth or space view keeps its Auto-turn pace** (MODULES-900). Opening a 3D look reset the pace to 1×, so `?look=realistic&pace=2` (or a reload after choosing 0.5× or 2×) opened at 1×; the look a link opens on now keeps the pace it names, and a look chosen later starts at its own. The line globe's 1× was left out of the address by kazoku-ui's view controls (KAZOKU-UI-133); kazoku-ui 0.38.1, which this release takes, keeps it, and the test of it is on.
|
|
11
|
+
- **A test that runs the page's own clock pays for the frames it asked for** (MODULES-897). `page.clock.runFor` fires a span's animation frames all at once, and the software GPU then needed 20 to 40 s to draw them, which the next page to open waited for: the satellites and embed tests timed out that way in CI. `timed()` now waits for the GPU before the clock runs on.
|
|
12
|
+
- **The demo's gesture check has room to finish** (MODULES-933). Thirteen gestures with screenshots in software GL take up to 39 s of a 60 s limit in CI, and a run cut off there reads as failed gestures; it now has 120 s, three times the most seen, so a real slowdown still fails.
|
|
13
|
+
- **The map-tiles freeze test waits for the tile sweep's frame before it counts rest.** The tile set lets the coarser tiles go 4 s after a zoom and draws the sphere once more when one of them was on it; when the finer tiles took about 2 to 3.5 s to come, that frame fell inside the count and the test failed (2 runs in 3 on a busy Mac, whatever the kazoku-ui version). It now waits for the page to let them go and for that frame, and has 150 s for its six rounds.
|
|
14
|
+
|
|
15
|
+
## 0.33.1 - 2026-11-11
|
|
16
|
+
|
|
5
17
|
## 0.33.0 - 2026-11-11
|
|
6
18
|
|
|
7
19
|
- **The data door names licences in Japanese** (KAZOKU-UI-105): `src/data-door.ts` copied again, unchanged, from kazoku-ui's template: a licence may carry `nameJa` for a Japanese credit line.
|
package/README.md
CHANGED
|
@@ -572,7 +572,7 @@ console.log(countryList().filter((country) => country.alpha2 === null).map((coun
|
|
|
572
572
|
|
|
573
573
|
## How to cite
|
|
574
574
|
|
|
575
|
-
> Morris, J. (2026). *Chikyu Earth* (version 0.33.
|
|
575
|
+
> Morris, J. (2026). *Chikyu Earth* (version 0.33.2) [Computer software]. https://github.com/johnmorrisdotca/chikyu-earth
|
|
576
576
|
|
|
577
577
|
GitHub's "Cite this repository" button reads [CITATION.cff](CITATION.cff) and gives BibTeX and APA. Cite the version you used (`npm ls @johnmorrisdotca/chikyu-earth`), and credit the sources behind the numbers and pictures: [NOTICE.md](NOTICE.md) says who made each one and under what terms.
|
|
578
578
|
|
|
@@ -7,7 +7,7 @@ import { type SatelliteState } from "../space/satellite-layer.ts";
|
|
|
7
7
|
import type { Layer } from "./tiers.ts";
|
|
8
8
|
import { type ThreeParts } from "./textures.ts";
|
|
9
9
|
import { type TileSet, type TileSources } from "./tile-set.ts";
|
|
10
|
-
import type { SkyFrame } from "../sky/
|
|
10
|
+
import type { SkyFrame } from "../sky/frame.ts";
|
|
11
11
|
import { type BodyLabelState } from "./body-label.ts";
|
|
12
12
|
import { type MeteorState } from "../meteors/layer.ts";
|
|
13
13
|
export type { ThreeParts };
|
|
@@ -5,7 +5,7 @@ import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/type
|
|
|
5
5
|
import { type SatelliteStyle } from "../space/satellite-layer.ts";
|
|
6
6
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
7
7
|
import { type BodyLabelSettings } from "./body-label.ts";
|
|
8
|
-
import type {
|
|
8
|
+
import type { SkyLabelStyle } from "../sky/style.ts";
|
|
9
9
|
import { setSharedRenderer, setThreeLoader } from "./shared.ts";
|
|
10
10
|
export { setSharedRenderer, setThreeLoader };
|
|
11
11
|
export type { CameraMode };
|
|
@@ -137,10 +137,10 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
137
137
|
/**
|
|
138
138
|
* The names of the brightest stars and the constellations as faint lines, laid over the sky the page draws (hoshi-stars' `sky-labels`, an optional peer loaded only when one of these is set). The plain attributes are hoshi's: `star-names` (a count of the brightest stars in view and not covered by the
|
|
139
139
|
* Earth, the Moon or the Sun; bare is 10), `star-names-magnitude` (only stars at least that bright) and `constellation-lines` (the 88 figures as lines at this strength, 0 to 1; bare is 0.16): none of them, and nothing is loaded. The figure under the pointer or touched is at full strength and shows its name. Names are in the
|
|
140
|
-
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial
|
|
140
|
+
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial `SkyLabelStyle` (font, size, case, ring, leader and the rest).
|
|
141
141
|
*/
|
|
142
|
-
get skyStyle(): Partial<
|
|
143
|
-
set skyStyle(value: Partial<
|
|
142
|
+
get skyStyle(): Partial<SkyLabelStyle>;
|
|
143
|
+
set skyStyle(value: Partial<SkyLabelStyle>);
|
|
144
144
|
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
145
145
|
get controller(): ViewController | undefined;
|
|
146
146
|
/**
|
|
@@ -228,7 +228,7 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
228
228
|
made: boolean;
|
|
229
229
|
showing: boolean;
|
|
230
230
|
};
|
|
231
|
-
/** The names of the stars and the constellation lines: whether one is asked for, whether hoshi-stars is loaded, the names and figures laid out at the last draw, the figure picked, how many times the layer was drawn
|
|
231
|
+
/** The names of the stars and the constellation lines: whether one is asked for, whether hoshi-stars is loaded, the names and figures laid out at the last draw, the figure picked, how many times the layer was drawn, the language its names were last laid out in, and the named stars' own points on the screen (`stars`). */
|
|
232
232
|
sky: {
|
|
233
233
|
on: boolean;
|
|
234
234
|
loaded: boolean;
|
|
@@ -237,6 +237,11 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
237
237
|
picked: string | null;
|
|
238
238
|
renders: number;
|
|
239
239
|
lang: string;
|
|
240
|
+
stars: {
|
|
241
|
+
text: string;
|
|
242
|
+
x: number;
|
|
243
|
+
y: number;
|
|
244
|
+
}[];
|
|
240
245
|
};
|
|
241
246
|
};
|
|
242
247
|
/**
|
|
@@ -14,12 +14,12 @@ import { createDoorHost } from "../door/host.js";
|
|
|
14
14
|
import { folderSource } from "../door/map.js";
|
|
15
15
|
import { ownCredit } from "../door/own.js";
|
|
16
16
|
import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "./body-label.js";
|
|
17
|
-
import { createSkyHost, SKY_ATTRIBUTES } from "../sky/host.js";
|
|
17
|
+
import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
|
|
18
18
|
import { createGate, frameCap } from "./gate.js";
|
|
19
19
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
20
20
|
export { setSharedRenderer, setThreeLoader };
|
|
21
21
|
import { MAX_TEXTURE, TIERS } from "./tiers.js";
|
|
22
|
-
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative}: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,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + METEOR_NOTE_STYLE + NOTES_STYLE;
|
|
22
|
+
const STYLE = ":host{display:block;aspect-ratio:1/1;position:relative}: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,#overlay{position:absolute;inset:0}#overlay{pointer-events:none}" + SKY_STYLE + METEOR_NOTE_STYLE + NOTES_STYLE;
|
|
23
23
|
const RAD = Math.PI / 180;
|
|
24
24
|
/** The Sun and the clouds are re-placed this often at real time: 15 degrees an hour is 0.25 degree a minute. */
|
|
25
25
|
const LIVE_TICK_MS = 60_000;
|
|
@@ -431,7 +431,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
431
431
|
/**
|
|
432
432
|
* The names of the brightest stars and the constellations as faint lines, laid over the sky the page draws (hoshi-stars' `sky-labels`, an optional peer loaded only when one of these is set). The plain attributes are hoshi's: `star-names` (a count of the brightest stars in view and not covered by the
|
|
433
433
|
* Earth, the Moon or the Sun; bare is 10), `star-names-magnitude` (only stars at least that bright) and `constellation-lines` (the 88 figures as lines at this strength, 0 to 1; bare is 0.16): none of them, and nothing is loaded. The figure under the pointer or touched is at full strength and shows its name. Names are in the
|
|
434
|
-
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial
|
|
434
|
+
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial `SkyLabelStyle` (font, size, case, ring, leader and the rest).
|
|
435
435
|
*/
|
|
436
436
|
get skyStyle() {
|
|
437
437
|
return { ...this.#skyStyle };
|
|
@@ -625,7 +625,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
625
625
|
assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
|
|
626
626
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
627
627
|
bodyLabel: { on: this.#model.bodyLabel.settings !== null, text: this.#model.bodyLabel.text, ...this.#model.bodyLabel.drawn },
|
|
628
|
-
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "" },
|
|
628
|
+
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "", stars: [] },
|
|
629
629
|
};
|
|
630
630
|
}
|
|
631
631
|
/**
|
|
@@ -8,3 +8,4 @@ export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.ts";
|
|
|
8
8
|
export { BODY_LABEL_ATTRIBUTES, bodyLabelText, readBodyLabel, loadMichroma, setBodyLabelFontUrl, type BodyLabelSettings } from "./body-label.ts";
|
|
9
9
|
export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness, type AirSamples } from "./air.ts";
|
|
10
10
|
export { AIR_NOTE } from "./air-note.ts";
|
|
11
|
+
export type { SkyLabelStyle } from "../sky/style.ts";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** A body as the camera sees it: the unit direction to its centre, whether the camera is inside it, and the cosine of its angular radius. */
|
|
2
|
+
export interface CoverBody {
|
|
3
|
+
dx: number;
|
|
4
|
+
dy: number;
|
|
5
|
+
dz: number;
|
|
6
|
+
inside: boolean;
|
|
7
|
+
cos: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The cover of a body for a camera.
|
|
11
|
+
*
|
|
12
|
+
* @param position - The body's centre, x y z.
|
|
13
|
+
* @param camera - The camera's place, x y z, in the same units.
|
|
14
|
+
* @param radius - The body's radius, in the same units.
|
|
15
|
+
* @returns The body as the camera sees it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function coverBody(position: readonly number[], camera: readonly number[], radius: number): CoverBody;
|
|
18
|
+
/**
|
|
19
|
+
* Whether any of the bodies covers a ray from the camera.
|
|
20
|
+
*
|
|
21
|
+
* @param bodies - The bodies, from `coverBody`.
|
|
22
|
+
* @param x - The ray's direction, x (a unit vector's).
|
|
23
|
+
* @param y - The ray's direction, y.
|
|
24
|
+
* @param z - The ray's direction, z.
|
|
25
|
+
* @returns True where the ray meets a body.
|
|
26
|
+
*/
|
|
27
|
+
export declare function covers(bodies: readonly CoverBody[], x: number, y: number, z: number): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Which bodies cover the sky at a ray from the camera: the Earth, the Moon and the Sun. Pure: a body covers a ray when the angle between the ray and the line to the body's centre is less than the body's angular radius, which is exact for any camera,
|
|
2
|
+
// where a circle on the screen is right only for a body on the camera's axis (a wide view draws the Earth as an ellipse towards its edges).
|
|
3
|
+
/**
|
|
4
|
+
* The cover of a body for a camera.
|
|
5
|
+
*
|
|
6
|
+
* @param position - The body's centre, x y z.
|
|
7
|
+
* @param camera - The camera's place, x y z, in the same units.
|
|
8
|
+
* @param radius - The body's radius, in the same units.
|
|
9
|
+
* @returns The body as the camera sees it.
|
|
10
|
+
*/
|
|
11
|
+
export function coverBody(position, camera, radius) {
|
|
12
|
+
const dx = position[0] - camera[0];
|
|
13
|
+
const dy = position[1] - camera[1];
|
|
14
|
+
const dz = position[2] - camera[2];
|
|
15
|
+
const away = Math.hypot(dx, dy, dz) || 1;
|
|
16
|
+
return { dx: dx / away, dy: dy / away, dz: dz / away, inside: away <= radius, cos: away > radius ? Math.sqrt(1 - (radius / away) ** 2) : -1 };
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether any of the bodies covers a ray from the camera.
|
|
20
|
+
*
|
|
21
|
+
* @param bodies - The bodies, from `coverBody`.
|
|
22
|
+
* @param x - The ray's direction, x (a unit vector's).
|
|
23
|
+
* @param y - The ray's direction, y.
|
|
24
|
+
* @param z - The ray's direction, z.
|
|
25
|
+
* @returns True where the ray meets a body.
|
|
26
|
+
*/
|
|
27
|
+
export function covers(bodies, x, y, z) {
|
|
28
|
+
for (const body of bodies)
|
|
29
|
+
if (body.inside || x * body.dx + y * body.dy + z * body.dz > body.cos)
|
|
30
|
+
return true;
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** What an element tells the layer at each draw: where a direction in the sky falls on the screen, the size of the box, and the bodies that cover the sky (round, in pixels). */
|
|
2
|
+
export interface SkyFrame {
|
|
3
|
+
/** Writes where the direction (right ascension and declination, degrees) falls on the screen in CSS pixels and answers whether it is in front of the camera. */
|
|
4
|
+
project(rightAscension: number, declination: number, out: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}): boolean;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
/** Bodies in front of the sky, each a disc on the screen: the Earth, the Moon, the Sun. Used where `covered` is not given (a view that looks straight at the Earth, where a body is a circle). */
|
|
11
|
+
discs: readonly {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
radius: number;
|
|
15
|
+
}[];
|
|
16
|
+
/**
|
|
17
|
+
* Whether a body covers the sky at a point of the screen, worked out from the ray through the point: a body covers it when the ray's angle to the body's centre is less than the body's angular radius. A camera with a wide field of view (a ride along a satellite sees the
|
|
18
|
+
* Earth 70 degrees across) draws a body as an ellipse towards the edges, which a circle on the screen cannot say.
|
|
19
|
+
*/
|
|
20
|
+
covered?: (x: number, y: number) => boolean;
|
|
21
|
+
}
|
package/dist/sky/host.d.ts
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SkyFrame } from "./frame.ts";
|
|
2
|
+
import type { SkyLabelStyle } from "./style.ts";
|
|
2
3
|
/** The styles of the layer, for an element to add to its own (`#sk-canvas`, `#sk-names` and the labels in its shadow root). */
|
|
3
4
|
export declare const SKY_STYLE: string;
|
|
4
|
-
/** What an element tells the layer at each draw: where a direction in the sky falls on the screen, the size of the box, and the bodies that cover the sky (round, in pixels). */
|
|
5
|
-
export interface SkyFrame {
|
|
6
|
-
/** Writes where the direction (right ascension and declination, degrees) falls on the screen in CSS pixels and answers whether it is in front of the camera. */
|
|
7
|
-
project(rightAscension: number, declination: number, out: ScreenPoint): boolean;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
/** Bodies in front of the sky, each a disc on the screen: the Earth, the Moon, the Sun. */
|
|
11
|
-
discs: readonly {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
radius: number;
|
|
15
|
-
}[];
|
|
16
|
-
}
|
|
17
5
|
export interface SkyHost {
|
|
18
6
|
/** Tells where the sky falls in the picture just drawn, or `null` when there is no picture. */
|
|
19
7
|
frame(frame: SkyFrame | null): void;
|
|
20
8
|
/** What the settings are now (`star-names`, `star-names-magnitude`, `constellation-lines`, the language): read again after any of them changed. */
|
|
21
9
|
refresh(): void;
|
|
22
10
|
/** The look of the names, as a partial hoshi-stars `LabelStyle` (the property `skyStyle`). */
|
|
23
|
-
setStyle(style: Partial<
|
|
11
|
+
setStyle(style: Partial<SkyLabelStyle>): void;
|
|
24
12
|
readonly stats: {
|
|
25
13
|
on: boolean;
|
|
26
14
|
loaded: boolean;
|
|
@@ -29,6 +17,11 @@ export interface SkyHost {
|
|
|
29
17
|
picked: string | null;
|
|
30
18
|
renders: number;
|
|
31
19
|
lang: string;
|
|
20
|
+
stars: {
|
|
21
|
+
text: string;
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
}[];
|
|
32
25
|
};
|
|
33
26
|
dispose(): void;
|
|
34
27
|
}
|
|
@@ -43,6 +36,8 @@ export interface SkyHostOptions {
|
|
|
43
36
|
onError(error: unknown): void;
|
|
44
37
|
/** Loads Michroma for the names, when the page has named no font of its own: kazoku-ui's `loadBodyLabelFont`. */
|
|
45
38
|
loadFont(): Promise<unknown>;
|
|
39
|
+
/** Brings hoshi-stars' `sky-labels` in: a dynamic import of the package by default, a page's own (or a test's) where it has one. */
|
|
40
|
+
importer?: () => Promise<typeof import("@johnmorrisdotca/hoshi-stars/sky-labels")>;
|
|
46
41
|
}
|
|
47
42
|
/** The attributes this layer reads. */
|
|
48
43
|
export declare const SKY_ATTRIBUTES: readonly ["star-names", "star-names-magnitude", "constellation-lines"];
|
package/dist/sky/host.js
CHANGED
|
@@ -217,6 +217,19 @@ export function createSkyHost(options) {
|
|
|
217
217
|
continue;
|
|
218
218
|
}
|
|
219
219
|
const rect = name.getBoundingClientRect();
|
|
220
|
+
// a name whose whole top edge is over a body (the Earth, the Moon, the Sun) lies on it: hoshi-stars tests the star's point only, so a name set below a star at the Earth's edge can be left entirely on the Earth, and is left out
|
|
221
|
+
const own = covered ? root.host.getBoundingClientRect() : undefined;
|
|
222
|
+
if (covered && own) {
|
|
223
|
+
const top = rect.top - own.top;
|
|
224
|
+
const left = rect.left - own.left;
|
|
225
|
+
const right = rect.right - own.left;
|
|
226
|
+
if (covered(left, top) && covered((left + right) / 2, top) && covered(right, top)) {
|
|
227
|
+
name.hidden = true;
|
|
228
|
+
designations[i].hidden = true;
|
|
229
|
+
culled.push(true);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
220
233
|
const over = kept.some((one) => rect.left < one.r && rect.right > one.l && rect.top < one.b && rect.bottom > one.t);
|
|
221
234
|
if (over) {
|
|
222
235
|
name.hidden = true;
|
|
@@ -271,7 +284,7 @@ export function createSkyHost(options) {
|
|
|
271
284
|
return;
|
|
272
285
|
loading = true;
|
|
273
286
|
attach();
|
|
274
|
-
void import("@johnmorrisdotca/hoshi-stars/sky-labels")
|
|
287
|
+
void (options.importer ?? (() => import("@johnmorrisdotca/hoshi-stars/sky-labels")))()
|
|
275
288
|
.then(async (loaded) => {
|
|
276
289
|
module = loaded;
|
|
277
290
|
if (!style.font)
|
|
@@ -283,6 +296,14 @@ export function createSkyHost(options) {
|
|
|
283
296
|
.catch((error) => {
|
|
284
297
|
loading = false;
|
|
285
298
|
failed = true;
|
|
299
|
+
// nothing of the layer stays in the page when hoshi-stars is not there
|
|
300
|
+
canvas?.remove();
|
|
301
|
+
box?.remove();
|
|
302
|
+
canvas = undefined;
|
|
303
|
+
box = undefined;
|
|
304
|
+
attached = false;
|
|
305
|
+
pool.length = 0;
|
|
306
|
+
designations.length = 0;
|
|
286
307
|
options.onError(error);
|
|
287
308
|
});
|
|
288
309
|
};
|
|
@@ -294,7 +315,7 @@ export function createSkyHost(options) {
|
|
|
294
315
|
if (usedLang !== undefined && options.language() !== usedLang)
|
|
295
316
|
configure();
|
|
296
317
|
const discs = frame.discs;
|
|
297
|
-
covered = discs.length === 0 ? undefined : (x, y) => discs.some((d) => (x - d.x) * (x - d.x) + (y - d.y) * (y - d.y) <= d.radius * d.radius);
|
|
318
|
+
covered = frame.covered ?? (discs.length === 0 ? undefined : (x, y) => discs.some((d) => (x - d.x) * (x - d.x) + (y - d.y) * (y - d.y) <= d.radius * d.radius));
|
|
298
319
|
const view = { width: frame.width, height: frame.height };
|
|
299
320
|
if (names)
|
|
300
321
|
names.update(frame.project, view, covered);
|
|
@@ -303,6 +324,16 @@ export function createSkyHost(options) {
|
|
|
303
324
|
placeNames();
|
|
304
325
|
drawLines();
|
|
305
326
|
}
|
|
327
|
+
/** The stars that are named at the last frame: each one's own point on the screen (the label's anchor) and its name, from the picture's top left, without the names the browser's measure left out. */
|
|
328
|
+
const starPoints = () => {
|
|
329
|
+
const out = [];
|
|
330
|
+
if (!names)
|
|
331
|
+
return out;
|
|
332
|
+
for (const [index, label] of names.labels.entries())
|
|
333
|
+
if (!culled[index])
|
|
334
|
+
out.push({ text: label.text, x: label.x, y: label.y });
|
|
335
|
+
return out;
|
|
336
|
+
};
|
|
306
337
|
// the family's chooser tells the document when the page's language changes: the names are written again, though nothing else is drawn
|
|
307
338
|
const onLanguage = () => queueMicrotask(() => {
|
|
308
339
|
if (module && wanted() && usedLang !== options.language()) {
|
|
@@ -368,7 +399,7 @@ export function createSkyHost(options) {
|
|
|
368
399
|
}
|
|
369
400
|
},
|
|
370
401
|
get stats() {
|
|
371
|
-
return { on: wanted(), loaded: module !== undefined, names: names ? drawnNames : 0, figures: lines?.count ?? 0, picked: lines?.picked?.abbreviation ?? null, renders, lang: usedLang ?? "" };
|
|
402
|
+
return { on: wanted(), loaded: module !== undefined, names: names ? drawnNames : 0, figures: lines?.count ?? 0, picked: lines?.picked?.abbreviation ?? null, renders, lang: usedLang ?? "", stars: starPoints() };
|
|
372
403
|
},
|
|
373
404
|
dispose() {
|
|
374
405
|
doc.removeEventListener("kazoku-languagechange", onLanguage);
|
|
@@ -380,3 +411,6 @@ export function createSkyHost(options) {
|
|
|
380
411
|
},
|
|
381
412
|
};
|
|
382
413
|
}
|
|
414
|
+
// The look chikyu-earth names (`SkyLabelStyle`) and hoshi-stars' `LabelStyle` are the same type: either one given where the other is asked for must compile, or this file does not.
|
|
415
|
+
const sameStyle = [{}, {}];
|
|
416
|
+
void sameStyle;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The look of a name drawn on the sky (the property `skyStyle` of `<chikyu-space>` and `<chikyu-earth-realistic>` takes any part of it): font, size, weight, colour, outline, case, letter spacing, the leader line, the ring round a star and the catalogue letter under the name. These are
|
|
3
|
+
* hoshi-stars' `LabelStyle`, with the same defaults and ranges, written out so a page without hoshi-stars installed still type-checks.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* import type { SkyLabelStyle } from "@johnmorrisdotca/chikyu-earth/realistic";
|
|
8
|
+
*
|
|
9
|
+
* const look: Partial<SkyLabelStyle> = { size: 12, colour: "#ffe9b0", case: "as-written", ring: 0 };
|
|
10
|
+
* console.log(Object.keys(look).join(" "));
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export interface SkyLabelStyle {
|
|
14
|
+
/** The font family, as CSS writes it. `Michroma, system-ui, sans-serif` by default: Michroma is the family's font for a name on a body, and the page loads it (kazoku-ui's `loadBodyLabelFont`); until it is in, the next family is used. */
|
|
15
|
+
font: string;
|
|
16
|
+
/** The text size in pixels, 6 to 48. 11 by default. */
|
|
17
|
+
size: number;
|
|
18
|
+
/** The font weight, 100 to 900. 400 by default. */
|
|
19
|
+
weight: number;
|
|
20
|
+
/** The text colour, any CSS colour. A quiet white by default. */
|
|
21
|
+
colour: string;
|
|
22
|
+
/** The colour of the outline round the letters that keeps them readable over stars, any CSS colour, or `none` for no outline. A dark blue by default. */
|
|
23
|
+
halo: string;
|
|
24
|
+
/** The width of that outline in pixels, 0 to 12. 3 by default. */
|
|
25
|
+
haloWidth: number;
|
|
26
|
+
/** `small-caps` writes the name in small capitals (the page draws it with CSS `font-variant: small-caps`), `as-written` keeps it as it is, `upper` and `lower` change the case (Japanese is not changed by any). `small-caps` by default. */
|
|
27
|
+
case: "small-caps" | "as-written" | "upper" | "lower";
|
|
28
|
+
/** The space added between letters, in em, -0.1 to 1. 0.14 by default. */
|
|
29
|
+
letterSpacing: number;
|
|
30
|
+
/** The length in pixels of a short line from the star to its name, 0 to 80, or 0 for no line and the name set beside the star. 0 by default. */
|
|
31
|
+
leader: number;
|
|
32
|
+
/** The colour of that line, any CSS colour. A quiet blue-white by default. */
|
|
33
|
+
leaderColour: string;
|
|
34
|
+
/** The gap in pixels between the ring round a star (or the star) and its name (or its line), 0 to 40. 4 by default. */
|
|
35
|
+
offset: number;
|
|
36
|
+
/** The radius in pixels of a thin ring drawn round each named star, 0 to 30, or 0 for no ring. 6 by default. */
|
|
37
|
+
ring: number;
|
|
38
|
+
/** The colour of the ring, any CSS colour. A quiet blue-white by default. */
|
|
39
|
+
ringColour: string;
|
|
40
|
+
/** The line width of the ring in pixels, 0.25 to 4. 0.75 by default. */
|
|
41
|
+
ringWidth: number;
|
|
42
|
+
/** `below` writes the star's catalogue letter (`α Ori`) in small type under its name; `none` leaves it out. A star with no Bayer letter or Flamsteed number has none to write. `below` by default. */
|
|
43
|
+
designation: "below" | "none";
|
|
44
|
+
/** The font family of that line. A small monospace by default. */
|
|
45
|
+
designationFont: string;
|
|
46
|
+
/** Its size in pixels, 6 to 24. 9 by default. */
|
|
47
|
+
designationSize: number;
|
|
48
|
+
/** Its colour, any CSS colour. A quieter white by default. */
|
|
49
|
+
designationColour: string;
|
|
50
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// The look of the names on the sky, as chikyu-earth's own type: the same fields as hoshi-stars' `LabelStyle` (an optional peer), written out here so the package's types never import a package a page may not have installed. A drift check in `host.ts` keeps the two the same.
|
|
2
|
+
export {};
|
package/dist/space/element.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { type ViewController } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
2
|
import type { GeoPoint } from "../types.ts";
|
|
3
3
|
import { type BodyLabelSettings } from "../realistic/body-label.ts";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SkyLabelStyle } from "../sky/style.ts";
|
|
5
5
|
import { setThreeLoader } from "../realistic/shared.ts";
|
|
6
6
|
import type { LightMode } from "../realistic/earth.ts";
|
|
7
7
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
8
8
|
import { type PlanetName } from "./ephemeris.ts";
|
|
9
9
|
import { type SatelliteStyle } from "./satellite-layer.ts";
|
|
10
|
-
import type
|
|
10
|
+
import { type RideLook } from "./ride.ts";
|
|
11
11
|
import { type ScaleMode } from "./scale.ts";
|
|
12
12
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget } from "./scene.ts";
|
|
13
13
|
export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
@@ -176,10 +176,10 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
176
176
|
/**
|
|
177
177
|
* The names of the brightest stars and the constellations as faint lines, laid over the sky the page draws (hoshi-stars' `sky-labels`, an optional peer loaded only when one of these is set). The plain attributes are hoshi's: `star-names` (a count of the brightest stars in view and not covered by the
|
|
178
178
|
* Earth, the Moon or the Sun; bare is 10), `star-names-magnitude` (only stars at least that bright) and `constellation-lines` (the 88 figures as lines at this strength, 0 to 1; bare is 0.16): none of them, and nothing is loaded. The figure under the pointer or touched is at full strength and shows its name. Names are in the
|
|
179
|
-
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial
|
|
179
|
+
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial `SkyLabelStyle` (font, size, case, ring, leader and the rest).
|
|
180
180
|
*/
|
|
181
|
-
get skyStyle(): Partial<
|
|
182
|
-
set skyStyle(value: Partial<
|
|
181
|
+
get skyStyle(): Partial<SkyLabelStyle>;
|
|
182
|
+
set skyStyle(value: Partial<SkyLabelStyle>);
|
|
183
183
|
/**
|
|
184
184
|
* How many times its real thickness the air is drawn, from 1 (the true thickness) to 5 (the attribute `air-thickness`; 3 when the page says nothing): see `<chikyu-earth-realistic>`. While it is above 1 the element says so in a line
|
|
185
185
|
* under the picture (`air-label="off"` takes the line away, for a page that says it itself).
|
|
@@ -312,9 +312,10 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
312
312
|
lost: boolean;
|
|
313
313
|
gliding: boolean;
|
|
314
314
|
};
|
|
315
|
-
/** The camera as the last draw left it: its place in Earth radii from the Earth's centre, and its field of view in degrees. */
|
|
315
|
+
/** The camera as the last draw left it: its place in Earth radii from the Earth's centre, the way it is turned (a unit quaternion, x y z w) and its field of view in degrees. */
|
|
316
316
|
camera: {
|
|
317
317
|
position: [number, number, number];
|
|
318
|
+
quaternion: [number, number, number, number];
|
|
318
319
|
fov: number;
|
|
319
320
|
};
|
|
320
321
|
/** What the body painter has made at the last draw: the Sun and planets with a drawing, and the moons shown round a planet that is near. */
|
|
@@ -340,7 +341,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
340
341
|
made: boolean;
|
|
341
342
|
showing: boolean;
|
|
342
343
|
};
|
|
343
|
-
/** The names of the stars and the constellation lines: whether one is asked for, whether hoshi-stars is loaded, the names and figures laid out at the last draw, the figure picked, how many times the layer was drawn
|
|
344
|
+
/** The names of the stars and the constellation lines: whether one is asked for, whether hoshi-stars is loaded, the names and figures laid out at the last draw, the figure picked, how many times the layer was drawn, the language its names were last laid out in, and the named stars' own points on the screen (`stars`). */
|
|
344
345
|
sky: {
|
|
345
346
|
on: boolean;
|
|
346
347
|
loaded: boolean;
|
|
@@ -349,6 +350,11 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
349
350
|
picked: string | null;
|
|
350
351
|
renders: number;
|
|
351
352
|
lang: string;
|
|
353
|
+
stars: {
|
|
354
|
+
text: string;
|
|
355
|
+
x: number;
|
|
356
|
+
y: number;
|
|
357
|
+
}[];
|
|
352
358
|
};
|
|
353
359
|
};
|
|
354
360
|
}
|
package/dist/space/element.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { carryControls } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
1
|
+
import { carryControls, wrapYaw } from "@johnmorrisdotca/kazoku-ui/view-controls";
|
|
2
2
|
import { adoptStyles } from "../adopt.js";
|
|
3
3
|
import { airFor, readAirThickness } from "../realistic/air.js";
|
|
4
4
|
import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "../realistic/body-label.js";
|
|
5
|
-
import { createSkyHost, SKY_ATTRIBUTES } from "../sky/host.js";
|
|
5
|
+
import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
|
|
6
6
|
import { createGate, frameCap } from "../realistic/gate.js";
|
|
7
7
|
import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
|
|
8
8
|
import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
|
|
@@ -12,6 +12,7 @@ import { MAX_TEXTURE } from "../realistic/tiers.js";
|
|
|
12
12
|
import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
|
|
13
13
|
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
14
14
|
import { MAX_ORBIT_GROUP } from "./satellite-layer.js";
|
|
15
|
+
import { rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
15
16
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
16
17
|
import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
|
|
17
18
|
export { BODY_NAMES };
|
|
@@ -76,7 +77,7 @@ const readTime = (value) => {
|
|
|
76
77
|
const ms = Date.parse(value);
|
|
77
78
|
return Number.isFinite(ms) ? ms : "now";
|
|
78
79
|
};
|
|
79
|
-
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}#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}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
80
|
+
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden}#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}${SKY_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
80
81
|
/**
|
|
81
82
|
* 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.
|
|
82
83
|
*
|
|
@@ -362,7 +363,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
362
363
|
/**
|
|
363
364
|
* The names of the brightest stars and the constellations as faint lines, laid over the sky the page draws (hoshi-stars' `sky-labels`, an optional peer loaded only when one of these is set). The plain attributes are hoshi's: `star-names` (a count of the brightest stars in view and not covered by the
|
|
364
365
|
* Earth, the Moon or the Sun; bare is 10), `star-names-magnitude` (only stars at least that bright) and `constellation-lines` (the 88 figures as lines at this strength, 0 to 1; bare is 0.16): none of them, and nothing is loaded. The figure under the pointer or touched is at full strength and shows its name. Names are in the
|
|
365
|
-
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial
|
|
366
|
+
* page's language and never overlap. Nothing is redrawn at rest. `chikyu-sky-unavailable` is sent when hoshi-stars is not there. The property is the look of the names, a partial `SkyLabelStyle` (font, size, case, ring, leader and the rest).
|
|
366
367
|
*/
|
|
367
368
|
get skyStyle() {
|
|
368
369
|
return { ...this.#skyStyle };
|
|
@@ -522,7 +523,19 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
522
523
|
const now = this.#model.view;
|
|
523
524
|
if (view.yaw === now.yaw && view.tilt === now.tilt && view.zoom === now.zoom)
|
|
524
525
|
return;
|
|
525
|
-
|
|
526
|
+
const model = this.#model;
|
|
527
|
+
// a riding camera that looks round adds up its turn change by change: the controls wrap their yaw into -180..180, so the yaw alone cannot say how far round the camera has gone, and a change of zoom must not swing it
|
|
528
|
+
if (view.yaw !== now.yaw)
|
|
529
|
+
model.rideTurn += rideTurnDegrees(wrapYaw(view.yaw - now.yaw), view.zoom);
|
|
530
|
+
// and the tilt is held to what does something in the look: past it a drag would have to come back before anything moved (the controls driving the view are handed the held tilt, the bar's own when one is bound)
|
|
531
|
+
let tilt = view.tilt;
|
|
532
|
+
const limits = model.ride && model.ride.view === "from" && model.rideDistance !== null ? rideTiltLimits(model.rideDistance, model.ride.look, view.zoom) : null;
|
|
533
|
+
if (limits)
|
|
534
|
+
tilt = Math.max(limits.min, Math.min(limits.max, tilt));
|
|
535
|
+
this.#model.view = { yaw: view.yaw, tilt, zoom: view.zoom };
|
|
536
|
+
// the whole view is handed back, the yaw as it is, so the controls keep what they held and the element hears nothing it did not already have
|
|
537
|
+
if (tilt !== view.tilt)
|
|
538
|
+
this.#controls()?.set({ yaw: view.yaw, tilt, zoom: view.zoom }, final, "ride");
|
|
526
539
|
const drawn = this.#model.drawnView;
|
|
527
540
|
if (drawn && !final && view.zoom === drawn.zoom) {
|
|
528
541
|
const turned = Math.max(Math.abs(view.yaw - drawn.yaw), Math.abs(view.tilt - drawn.tilt)) * RAD;
|
|
@@ -531,6 +544,19 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
531
544
|
}
|
|
532
545
|
this.#gate?.request();
|
|
533
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* The controls that are driving this view: a `<kazoku-view-controls for="...">` bound to it (its hands are then the only ones and its controller holds the yaw and tilt), else the element's own hands.
|
|
549
|
+
*/
|
|
550
|
+
#controls() {
|
|
551
|
+
if (this.hasAttribute("data-kazoku-bar") && this.id) {
|
|
552
|
+
const root = this.getRootNode();
|
|
553
|
+
const bar = root.querySelector?.(`kazoku-view-controls[for="${CSS.escape(this.id)}"]`);
|
|
554
|
+
const held = bar ? Reflect.get(bar, "controller") : undefined;
|
|
555
|
+
if (held)
|
|
556
|
+
return held;
|
|
557
|
+
}
|
|
558
|
+
return this.#hands?.controller;
|
|
559
|
+
}
|
|
534
560
|
/** The body the camera looks at: at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
|
|
535
561
|
get body() {
|
|
536
562
|
return this.#model.focus;
|
|
@@ -557,6 +583,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
557
583
|
const wasRiding = model.ride !== null;
|
|
558
584
|
if (target === null) {
|
|
559
585
|
model.ride = null;
|
|
586
|
+
model.rideTurn = 0;
|
|
560
587
|
model.focus = this.#focusBeforeRide;
|
|
561
588
|
}
|
|
562
589
|
else {
|
|
@@ -566,6 +593,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
566
593
|
return;
|
|
567
594
|
if (!wasRiding)
|
|
568
595
|
this.#focusBeforeRide = model.focus;
|
|
596
|
+
// the heading starts from the yaw the controls already hold (an address that carries `yaw` is read before the ride begins), so a ride opened from the address looks where the one that was dragged there looked
|
|
597
|
+
model.rideTurn = rideTurnDegrees(model.view.yaw, model.view.zoom);
|
|
569
598
|
const view = typeof target === "string" && target === "Earth" ? "follow" : (options.view ?? "from");
|
|
570
599
|
model.ride = { target: typeof target === "string" ? target : { group: target.group, index: target.index }, view, look: options.look ?? "down", distanceKm: Math.max(100, options.distanceKm ?? 3000) };
|
|
571
600
|
if (typeof target === "string" && view === "follow")
|
|
@@ -732,11 +761,11 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
732
761
|
lookups: this.#model.lookups,
|
|
733
762
|
satellites: this.#satelliteStats(),
|
|
734
763
|
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null },
|
|
735
|
-
camera: { position: [this.#model.pose.p[0], this.#model.pose.p[1], this.#model.pose.p[2]], fov: this.#model.pose.fov },
|
|
764
|
+
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 },
|
|
736
765
|
bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons },
|
|
737
766
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
738
767
|
bodyLabel: { on: this.#model.bodyLabel.settings !== null, text: this.#model.bodyLabel.text, ...this.#model.bodyLabel.drawn },
|
|
739
|
-
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "" },
|
|
768
|
+
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "", stars: [] },
|
|
740
769
|
};
|
|
741
770
|
}
|
|
742
771
|
#satelliteStats() {
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
3
|
export { fitDistance, plainPainter, type BodyDrawing, type BodyMoon, type BodyPainter, type PaintContext } from "./scene.ts";
|
|
4
|
-
export { RIDE_FOV, ridePose, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
4
|
+
export { RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
export { AU_IN_EARTH_RADII, blend, createTrack, EARTH_RADIUS_KM, frameAt, orbitPath, PLANETS } from "./ephemeris.js";
|
|
4
4
|
export { compress, MOON_COMPRESSED, placeAround, placeMoon, placeSun, RADIUS, SUN_COMPRESSED, truePosition } from "./scale.js";
|
|
5
5
|
export { fitDistance, plainPainter } from "./scene.js";
|
|
6
|
-
export { RIDE_FOV, ridePose } from "./ride.js";
|
|
6
|
+
export { RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
package/dist/space/ride.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { Vec3 } from "./ephemeris.ts";
|
|
|
12
12
|
export declare const RIDE_FOV = 60;
|
|
13
13
|
/**
|
|
14
14
|
* Where a riding camera looks: `down` straight at the Earth's centre (the ground goes by under the camera), or `horizon` tipped forward along the way it is going until the horizon
|
|
15
|
-
* is a little above the middle of the view.
|
|
15
|
+
* is a little above the middle of the view. A drag looks round from there on the spot with the horizon kept level: sideways turns about the local vertical, all the way round, and up and down only tips the view, from straight down to 20 degrees above the horizon.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
@@ -23,6 +23,57 @@ export declare const RIDE_FOV = 60;
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export type RideLook = "down" | "horizon";
|
|
26
|
+
/**
|
|
27
|
+
* The field of view, in degrees, of a riding camera at a zoom: the natural 60 divided by the zoom, held between 5 and 100.
|
|
28
|
+
*
|
|
29
|
+
* @param zoom - The shared controls' zoom.
|
|
30
|
+
* @returns The field of view in degrees.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { rideFov } from "@johnmorrisdotca/chikyu-earth/space";
|
|
35
|
+
*
|
|
36
|
+
* console.log(rideFov(1), rideFov(6), rideFov(100));
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function rideFov(zoom: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* How many degrees the camera turns for a change of the controls' yaw at a zoom. The controls wrap their yaw into -180 to 180, so a page adds up the turns itself, change by change (`wrapYaw` of the change, scaled by this at the zoom of the moment), and hands
|
|
42
|
+
* the total to `ridePose` as `turn`: a drag the whole way round is then a turn the whole way round, and the pace follows the field of view at any zoom.
|
|
43
|
+
*
|
|
44
|
+
* @param change - The change of yaw, in degrees, between two views of the controls (already brought into -180 to 180).
|
|
45
|
+
* @param zoom - The shared controls' zoom at the moment.
|
|
46
|
+
* @returns The turn, in degrees.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { rideTurnDegrees } from "@johnmorrisdotca/chikyu-earth/space";
|
|
51
|
+
*
|
|
52
|
+
* console.log(rideTurnDegrees(180, 1), rideTurnDegrees(180, 6));
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function rideTurnDegrees(change: number, zoom: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* The range of the controls' tilt that does something in the `horizon` look: from straight down to a little above the horizon. A tilt beyond it moves nothing, so a page holds the tilt to it, and a drag back starts moving at once instead of after the
|
|
58
|
+
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is) and the zoom. The `down` look has no such range.
|
|
59
|
+
*
|
|
60
|
+
* @param distance - The camera's distance from the Earth's centre, in Earth radii.
|
|
61
|
+
* @param look - The look.
|
|
62
|
+
* @param zoom - The shared controls' zoom.
|
|
63
|
+
* @returns The lowest and highest tilt, or `null` for the `down` look.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* import { rideTiltLimits } from "@johnmorrisdotca/chikyu-earth/space";
|
|
68
|
+
*
|
|
69
|
+
* const range = rideTiltLimits(1.066, "horizon", 1);
|
|
70
|
+
* console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function rideTiltLimits(distance: number, look: RideLook, zoom: number): {
|
|
74
|
+
min: number;
|
|
75
|
+
max: number;
|
|
76
|
+
} | null;
|
|
26
77
|
/**
|
|
27
78
|
* What `ridePose` is asked: the camera's place and its way of travel (any length), where it looks, and the shared controls' yaw, tilt and zoom.
|
|
28
79
|
*
|
|
@@ -46,6 +97,10 @@ export interface RideInput {
|
|
|
46
97
|
tilt: number;
|
|
47
98
|
/** 1 is the natural view; more narrows the field of view. */
|
|
48
99
|
zoom: number;
|
|
100
|
+
/**
|
|
101
|
+
* The heading in degrees, accumulated by the caller (see `rideTurnDegrees`): used in place of `yaw` when given, so a turn of more than half a way round is not undone by the controls wrapping their yaw, and a change of zoom does not swing it.
|
|
102
|
+
*/
|
|
103
|
+
turn?: number;
|
|
49
104
|
}
|
|
50
105
|
/**
|
|
51
106
|
* The camera `ridePose` works out: where it is, which way it looks, which way is up in the picture, its field of view in degrees, and how big the Earth looks from there (its angular radius in degrees).
|
|
@@ -66,9 +121,10 @@ export interface RidePose {
|
|
|
66
121
|
earthRadiusDegrees: number;
|
|
67
122
|
}
|
|
68
123
|
/**
|
|
69
|
-
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the
|
|
70
|
-
*
|
|
71
|
-
*
|
|
124
|
+
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the horizon is a little above the middle. A drag looks about from there on the spot:
|
|
125
|
+
* `yaw` turns the camera to its left and `tilt` tips it towards the bottom of its picture, so the ground follows the pointer (right for a drag right, up for a drag up); the angle for each pixel of the drag is the field of view's, so the pace is the same at any zoom.
|
|
126
|
+
* In the `horizon` look a sideways drag turns about the local vertical (the line from the Earth's centre through the camera), all the way round, and up and down only tips the view, from straight down to 20 degrees above the horizon, so the horizon stays level and
|
|
127
|
+
* nothing rolls; in the `down` look the camera turns about its own up. `zoom` narrows the field of view.
|
|
72
128
|
*
|
|
73
129
|
* @param input - The camera's place, its way of travel, the look, and the shared controls' yaw, tilt and zoom.
|
|
74
130
|
* @returns The camera's place, forward and up directions (unit vectors), its field of view, and the Earth's angular radius from there.
|
package/dist/space/ride.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const RAD = Math.PI / 180;
|
|
2
2
|
/** How far the ground moves in the picture for each pixel of a drag at the middle of it: the same pace as the line globe and the Earth from space (about one and a half). */
|
|
3
3
|
const GRAB = 1.5;
|
|
4
|
+
/** How far above the horizon a drag may tip the horizon look, in degrees. */
|
|
5
|
+
const MAX_ABOVE_HORIZON = 20;
|
|
4
6
|
/**
|
|
5
7
|
* The field of view, in degrees, of a camera riding along at zoom 1 (the Earth's view from outside is 35).
|
|
6
8
|
*
|
|
@@ -12,6 +14,65 @@ const GRAB = 1.5;
|
|
|
12
14
|
* ```
|
|
13
15
|
*/
|
|
14
16
|
export const RIDE_FOV = 60;
|
|
17
|
+
/**
|
|
18
|
+
* The field of view, in degrees, of a riding camera at a zoom: the natural 60 divided by the zoom, held between 5 and 100.
|
|
19
|
+
*
|
|
20
|
+
* @param zoom - The shared controls' zoom.
|
|
21
|
+
* @returns The field of view in degrees.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* import { rideFov } from "@johnmorrisdotca/chikyu-earth/space";
|
|
26
|
+
*
|
|
27
|
+
* console.log(rideFov(1), rideFov(6), rideFov(100));
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function rideFov(zoom) {
|
|
31
|
+
return Math.min(100, Math.max(5, RIDE_FOV / Math.max(0.05, zoom)));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* How many degrees the camera turns for a change of the controls' yaw at a zoom. The controls wrap their yaw into -180 to 180, so a page adds up the turns itself, change by change (`wrapYaw` of the change, scaled by this at the zoom of the moment), and hands
|
|
35
|
+
* the total to `ridePose` as `turn`: a drag the whole way round is then a turn the whole way round, and the pace follows the field of view at any zoom.
|
|
36
|
+
*
|
|
37
|
+
* @param change - The change of yaw, in degrees, between two views of the controls (already brought into -180 to 180).
|
|
38
|
+
* @param zoom - The shared controls' zoom at the moment.
|
|
39
|
+
* @returns The turn, in degrees.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { rideTurnDegrees } from "@johnmorrisdotca/chikyu-earth/space";
|
|
44
|
+
*
|
|
45
|
+
* console.log(rideTurnDegrees(180, 1), rideTurnDegrees(180, 6));
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export function rideTurnDegrees(change, zoom) {
|
|
49
|
+
return change * (GRAB * rideFov(zoom)) / 180;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The range of the controls' tilt that does something in the `horizon` look: from straight down to a little above the horizon. A tilt beyond it moves nothing, so a page holds the tilt to it, and a drag back starts moving at once instead of after the
|
|
53
|
+
* excess is dragged back. It depends on the height (the horizon is further from straight down the higher the camera is) and the zoom. The `down` look has no such range.
|
|
54
|
+
*
|
|
55
|
+
* @param distance - The camera's distance from the Earth's centre, in Earth radii.
|
|
56
|
+
* @param look - The look.
|
|
57
|
+
* @param zoom - The shared controls' zoom.
|
|
58
|
+
* @returns The lowest and highest tilt, or `null` for the `down` look.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { rideTiltLimits } from "@johnmorrisdotca/chikyu-earth/space";
|
|
63
|
+
*
|
|
64
|
+
* const range = rideTiltLimits(1.066, "horizon", 1);
|
|
65
|
+
* console.log(range && `${range.min.toFixed(0)} to ${range.max.toFixed(0)}`, rideTiltLimits(1.066, "down", 1));
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export function rideTiltLimits(distance, look, zoom) {
|
|
69
|
+
if (look !== "horizon")
|
|
70
|
+
return null;
|
|
71
|
+
const radius = distance <= 1 ? 90 : Math.asin(1 / distance) / RAD;
|
|
72
|
+
const start = Math.max(0, radius - 12) * RAD - Math.PI / 2;
|
|
73
|
+
const perDegree = (GRAB * rideFov(zoom)) / 60;
|
|
74
|
+
return { min: (start - (MAX_ABOVE_HORIZON * RAD)) / RAD / perDegree, max: (start + Math.PI / 2) / RAD / perDegree };
|
|
75
|
+
}
|
|
15
76
|
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
16
77
|
const cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
|
|
17
78
|
const scale = (a, k) => [a[0] * k, a[1] * k, a[2] * k];
|
|
@@ -22,9 +83,10 @@ const unit = (a) => {
|
|
|
22
83
|
return n === 0 ? [0, 0, 0] : [a[0] / n, a[1] / n, a[2] / n];
|
|
23
84
|
};
|
|
24
85
|
/**
|
|
25
|
-
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the
|
|
26
|
-
*
|
|
27
|
-
*
|
|
86
|
+
* The camera of a body-borne view: at `position`, looking at the Earth, with the way the body is going at the top of the picture. `look: "horizon"` tips it forward until the horizon is a little above the middle. A drag looks about from there on the spot:
|
|
87
|
+
* `yaw` turns the camera to its left and `tilt` tips it towards the bottom of its picture, so the ground follows the pointer (right for a drag right, up for a drag up); the angle for each pixel of the drag is the field of view's, so the pace is the same at any zoom.
|
|
88
|
+
* In the `horizon` look a sideways drag turns about the local vertical (the line from the Earth's centre through the camera), all the way round, and up and down only tips the view, from straight down to 20 degrees above the horizon, so the horizon stays level and
|
|
89
|
+
* nothing rolls; in the `down` look the camera turns about its own up. `zoom` narrows the field of view.
|
|
28
90
|
*
|
|
29
91
|
* @param input - The camera's place, its way of travel, the look, and the shared controls' yaw, tilt and zoom.
|
|
30
92
|
* @returns The camera's place, forward and up directions (unit vectors), its field of view, and the Earth's angular radius from there.
|
|
@@ -51,11 +113,21 @@ export function ridePose(input) {
|
|
|
51
113
|
ahead = unit(ahead);
|
|
52
114
|
const earthRadiusDegrees = distance <= 1 ? 90 : Math.asin(1 / distance) / RAD;
|
|
53
115
|
const base = input.look === "horizon" ? Math.max(0, earthRadiusDegrees - 12) * RAD : 0;
|
|
116
|
+
const fov = rideFov(input.zoom);
|
|
117
|
+
const turn = (input.turn ?? input.yaw * (GRAB * fov / 180)) * RAD;
|
|
118
|
+
const lift = input.tilt * (GRAB * fov / 60) * RAD;
|
|
119
|
+
if (input.look === "horizon") {
|
|
120
|
+
// looking round on the spot: a drag sideways turns the camera about the local vertical, all the way round, and a drag up or down tips it up or down in the vertical plane it faces, from straight down to a little above the horizon,
|
|
121
|
+
// so the horizon stays level and nothing rolls
|
|
122
|
+
const zenith = scale(nadir, -1);
|
|
123
|
+
const heading = add(scale(ahead, Math.cos(turn)), scale(cross(zenith, ahead), Math.sin(turn)));
|
|
124
|
+
const elevation = Math.max(-Math.PI / 2, Math.min(MAX_ABOVE_HORIZON * RAD, base - Math.PI / 2 - lift));
|
|
125
|
+
const forward = add(scale(heading, Math.cos(elevation)), scale(zenith, Math.sin(elevation)));
|
|
126
|
+
const up = add(scale(heading, -Math.sin(elevation)), scale(zenith, Math.cos(elevation)));
|
|
127
|
+
return { position: [input.position[0], input.position[1], input.position[2]], forward, up, fov, earthRadiusDegrees };
|
|
128
|
+
}
|
|
54
129
|
const forward0 = add(scale(nadir, Math.cos(base)), scale(ahead, Math.sin(base)));
|
|
55
130
|
const up0 = add(scale(ahead, Math.cos(base)), scale(nadir, -Math.sin(base)));
|
|
56
|
-
const fov = Math.min(100, Math.max(5, RIDE_FOV / Math.max(0.05, input.zoom)));
|
|
57
|
-
const turn = input.yaw * (GRAB * fov / 180) * RAD;
|
|
58
|
-
const lift = input.tilt * (GRAB * fov / 60) * RAD;
|
|
59
131
|
const turned = add(scale(forward0, Math.cos(turn)), scale(cross(up0, forward0), Math.sin(turn)));
|
|
60
132
|
const forward = add(scale(turned, Math.cos(lift)), scale(up0, -Math.sin(lift)));
|
|
61
133
|
const up = add(scale(up0, Math.cos(lift)), scale(turned, Math.sin(lift)));
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { type Frame, type PlanetName, type Vec3 } from "./ephemeris.ts";
|
|
|
7
7
|
import { type ScaleMode } from "./scale.ts";
|
|
8
8
|
import type { SatelliteRef } from "../satellites/types.ts";
|
|
9
9
|
import { type RideLook } from "./ride.ts";
|
|
10
|
-
import type { SkyFrame } from "../sky/
|
|
10
|
+
import type { SkyFrame } from "../sky/frame.ts";
|
|
11
11
|
import { type SatelliteState } from "./satellite-layer.ts";
|
|
12
12
|
import { type BodyLabelState } from "../realistic/body-label.ts";
|
|
13
13
|
import { type MeteorState } from "../meteors/layer.ts";
|
|
@@ -180,6 +180,10 @@ export interface SpaceModel {
|
|
|
180
180
|
pose: Pose;
|
|
181
181
|
/** Pixels a second that riding makes things move on the screen at 1x clock speed (0 when not riding): the draw rate follows it. */
|
|
182
182
|
rideMotion: number;
|
|
183
|
+
/** The heading of a riding camera in degrees, added up change by change from the controls' wrapped yaw (`rideTurnDegrees`): a drag the whole way round is a turn the whole way round, and a change of zoom swings nothing. */
|
|
184
|
+
rideTurn: number;
|
|
185
|
+
/** How far the riding camera is from the Earth's centre in Earth radii as of the last draw, or null when none rides: the range of tilt that does something follows it. */
|
|
186
|
+
rideDistance: number | null;
|
|
183
187
|
/** The satellite at a point of the view (CSS pixels), within a radius, if a draw has been made and one is there. */
|
|
184
188
|
pick: ((x: number, y: number, radius: number) => SatelliteRef | null) | null;
|
|
185
189
|
ratio(): number;
|
package/dist/space/scene.js
CHANGED
|
@@ -5,6 +5,7 @@ import { createTextureSet } from "../realistic/textures.js";
|
|
|
5
5
|
import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
|
|
6
6
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
7
7
|
import { ridePose } from "./ride.js";
|
|
8
|
+
import { coverBody, covers } from "../sky/cover.js";
|
|
8
9
|
import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
|
|
9
10
|
import { createBodyLabelLayer, newBodyLabelState } from "../realistic/body-label.js";
|
|
10
11
|
import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
|
|
@@ -80,6 +81,8 @@ export const newSpaceModel = () => ({
|
|
|
80
81
|
heightPx: 420,
|
|
81
82
|
pose: { p: [0, 0, 0], q: [0, 0, 0, 1], fov: FOV, valid: false },
|
|
82
83
|
rideMotion: 0,
|
|
84
|
+
rideTurn: 0,
|
|
85
|
+
rideDistance: null,
|
|
83
86
|
satellites: newSatelliteState(),
|
|
84
87
|
meteors: newMeteorState(),
|
|
85
88
|
bodyLabel: newBodyLabelState(),
|
|
@@ -382,6 +385,7 @@ export function createSpaceItem(model, deps) {
|
|
|
382
385
|
let rideFrom = null;
|
|
383
386
|
model.rideLost = false;
|
|
384
387
|
model.rideMotion = 0;
|
|
388
|
+
model.rideDistance = null;
|
|
385
389
|
const ride = model.ride;
|
|
386
390
|
if (ride) {
|
|
387
391
|
if (typeof ride.target === "string") {
|
|
@@ -420,7 +424,8 @@ export function createSpaceItem(model, deps) {
|
|
|
420
424
|
let fovNow = FOV;
|
|
421
425
|
let distance = 0;
|
|
422
426
|
if (rideFrom) {
|
|
423
|
-
const pose = ridePose({ position: rideFrom.position, velocity: rideFrom.velocity, look: ride.look, yaw: model.view.yaw, tilt: model.view.tilt, zoom: model.view.zoom });
|
|
427
|
+
const pose = ridePose({ position: rideFrom.position, velocity: rideFrom.velocity, look: ride.look, yaw: model.view.yaw, tilt: model.view.tilt, zoom: model.view.zoom, turn: model.rideTurn });
|
|
428
|
+
model.rideDistance = Math.hypot(...rideFrom.position);
|
|
424
429
|
camera.position.set(pose.position[0], pose.position[1], pose.position[2]);
|
|
425
430
|
camera.up.set(pose.up[0], pose.up[1], pose.up[2]);
|
|
426
431
|
camera.lookAt(pose.position[0] + pose.forward[0], pose.position[1] + pose.forward[1], pose.position[2] + pose.forward[2]);
|
|
@@ -606,10 +611,21 @@ export function createSpaceItem(model, deps) {
|
|
|
606
611
|
continue;
|
|
607
612
|
discs.push({ x: ((sky.x + 1) / 2) * size.width, y: ((1 - sky.y) / 2) * size.height, radius: Math.min(px[name], 1e5) });
|
|
608
613
|
}
|
|
614
|
+
// a body covers the sky where the ray through a pixel passes within the body's angular radius of its centre: exact for any field of view, where a circle on the screen is right only on the axis
|
|
615
|
+
const ray = new three.Vector3();
|
|
616
|
+
const bodies = ["Earth", "Moon", "Sun"].map((name) => coverBody(pos[name], [camera.position.x, camera.position.y, camera.position.z], radiusOf(name)));
|
|
609
617
|
deps.onSky({
|
|
610
618
|
width: size.width,
|
|
611
619
|
height: size.height,
|
|
612
620
|
discs,
|
|
621
|
+
covered(x, y) {
|
|
622
|
+
ray.set((x / size.width) * 2 - 1, 1 - (y / size.height) * 2, 0.5).unproject(camera).sub(camera.position);
|
|
623
|
+
const length = ray.length() || 1;
|
|
624
|
+
const rx = ray.x / length;
|
|
625
|
+
const ry = ray.y / length;
|
|
626
|
+
const rz = ray.z / length;
|
|
627
|
+
return covers(bodies, rx, ry, rz);
|
|
628
|
+
},
|
|
613
629
|
project(rightAscension, declination, out) {
|
|
614
630
|
const r = rightAscension * RAD;
|
|
615
631
|
const d = declination * RAD;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.2",
|
|
4
4
|
"description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on where you are, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"earth",
|
|
@@ -195,7 +195,7 @@
|
|
|
195
195
|
},
|
|
196
196
|
"dependencies": {
|
|
197
197
|
"@johnmorrisdotca/chizu": "^1.6.0",
|
|
198
|
-
"@johnmorrisdotca/kazoku-ui": "^0.
|
|
198
|
+
"@johnmorrisdotca/kazoku-ui": "^0.38.1",
|
|
199
199
|
"d3-geo": "^3.1.1"
|
|
200
200
|
},
|
|
201
201
|
"peerDependencies": {
|