@johnmorrisdotca/chikyu-earth 0.33.1 → 0.34.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 +23 -5
- package/dist/cities/geometry.d.ts +233 -0
- package/dist/cities/geometry.js +174 -0
- package/dist/cities/host.d.ts +73 -0
- package/dist/cities/host.js +240 -0
- package/dist/element.d.ts +1 -1
- package/dist/element.js +2 -13
- package/dist/markers/index.d.ts +1 -0
- package/dist/markers/index.js +1 -0
- package/dist/markers/labels.d.ts +7 -1
- package/dist/markers/labels.js +12 -1
- package/dist/markers/place-layer.d.ts +43 -0
- package/dist/markers/place-layer.js +238 -0
- package/dist/markers/places.d.ts +279 -0
- package/dist/markers/places.js +213 -0
- package/dist/passes/element.js +2 -5
- package/dist/realistic/body-label.js +19 -11
- package/dist/realistic/earth.d.ts +1 -1
- package/dist/realistic/element.d.ts +45 -5
- package/dist/realistic/element.js +96 -13
- package/dist/realistic/index.d.ts +3 -0
- package/dist/realistic/index.js +2 -0
- package/dist/satellites/index.d.ts +1 -0
- package/dist/satellites/index.js +1 -0
- package/dist/satellites/names.d.ts +14 -0
- package/dist/satellites/names.js +16 -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 +116 -8
- package/dist/space/element.js +253 -8
- package/dist/space/index.d.ts +4 -2
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +60 -4
- package/dist/space/ride.js +78 -6
- package/dist/space/satellite-layer.d.ts +26 -0
- package/dist/space/satellite-layer.js +37 -1
- package/dist/space/satellite-model.d.ts +72 -0
- package/dist/space/satellite-model.js +82 -0
- package/dist/space/scene.d.ts +47 -2
- package/dist/space/scene.js +169 -1
- package/package.json +8 -4
package/dist/space/element.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
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
|
+
import { type Place, type PlaceLook } from "../markers/places.ts";
|
|
6
|
+
import { type CityNamesStyle } from "../cities/host.ts";
|
|
5
7
|
import { setThreeLoader } from "../realistic/shared.ts";
|
|
6
8
|
import type { LightMode } from "../realistic/earth.ts";
|
|
7
9
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
8
10
|
import { type PlanetName } from "./ephemeris.ts";
|
|
9
11
|
import { type SatelliteStyle } from "./satellite-layer.ts";
|
|
10
|
-
import type
|
|
12
|
+
import { type RideLook } from "./ride.ts";
|
|
11
13
|
import { type ScaleMode } from "./scale.ts";
|
|
12
|
-
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget } from "./scene.ts";
|
|
14
|
+
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
13
15
|
export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
14
16
|
/**
|
|
15
17
|
* Change how the Sun and the planets are drawn (before the first element connects): the space view keeps their places, sizes, light, names and orbits and asks
|
|
@@ -26,6 +28,20 @@ export { BODY_NAMES, type BodyName, type CameraMode, type RideTarget };
|
|
|
26
28
|
* ```
|
|
27
29
|
*/
|
|
28
30
|
export declare function setBodyPainter(next: BodyPainter | undefined): void;
|
|
31
|
+
/**
|
|
32
|
+
* Where the 3D models of large satellites come from if the page has any: the package ships none. With a painter set, a satellite followed (`ride(ref, { view: "follow" })`) that the painter has a model for is drawn as that model, in the middle
|
|
33
|
+
* of the picture at a size that reads, pointed the way it flies, lit by the Sun; a satellite it has none for stays a dot. See `SatellitePainter`.
|
|
34
|
+
*
|
|
35
|
+
* @param next - The painter, or `undefined` for none.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts no-run
|
|
39
|
+
* import { setSatellitePainter } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
40
|
+
*
|
|
41
|
+
* setSatellitePainter({ has: (norad) => norad === 25544, make: async () => null });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare function setSatellitePainter(next: SatellitePainter | undefined): void;
|
|
29
45
|
/**
|
|
30
46
|
* What a page can tell a reader about a body now.
|
|
31
47
|
*
|
|
@@ -176,10 +192,26 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
176
192
|
/**
|
|
177
193
|
* 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
194
|
* 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
|
|
195
|
+
* 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
196
|
*/
|
|
181
|
-
get skyStyle(): Partial<
|
|
182
|
-
set skyStyle(value: Partial<
|
|
197
|
+
get skyStyle(): Partial<SkyLabelStyle>;
|
|
198
|
+
set skyStyle(value: Partial<SkyLabelStyle>);
|
|
199
|
+
/**
|
|
200
|
+
* Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
|
|
201
|
+
* (the default: quieter). Each stands up out of the ground, turns with the Earth, is hidden on its far side and keeps its size in pixels at any zoom. Names go at the top, `here` first, and never overlap
|
|
202
|
+
* one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where it likes. Setting the property writes
|
|
203
|
+
* the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked for less motion.
|
|
204
|
+
*/
|
|
205
|
+
get places(): Place[];
|
|
206
|
+
set places(value: readonly Place[]);
|
|
207
|
+
/** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
|
|
208
|
+
get placesLook(): PlaceLook;
|
|
209
|
+
set placesLook(value: PlaceLook);
|
|
210
|
+
/**
|
|
211
|
+
* The look of the names of cities (`city-names`): font, size, weight, colour, the outline round the text, and the dot's colour and size. Any of them may be left out; the Earth's size, the language and the data are not set here.
|
|
212
|
+
*/
|
|
213
|
+
get cityNamesStyle(): CityNamesStyle;
|
|
214
|
+
set cityNamesStyle(value: CityNamesStyle);
|
|
183
215
|
/**
|
|
184
216
|
* 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
217
|
* under the picture (`air-label="off"` takes the line away, for a page that says it itself).
|
|
@@ -252,6 +284,25 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
252
284
|
* @param options - `view`, `look`, `distanceKm`, `smooth` (see `RideOptions`).
|
|
253
285
|
*/
|
|
254
286
|
ride(target: RideTarget | null, options?: RideOptions): void;
|
|
287
|
+
/**
|
|
288
|
+
* The satellites the page has a model for (`setSatellitePainter`) in the groups now set, each with its name in the page's language: the large satellites that can be followed as a model. Empty with no painter.
|
|
289
|
+
*/
|
|
290
|
+
largeSatellites(): {
|
|
291
|
+
ref: SatelliteRef;
|
|
292
|
+
noradId: number;
|
|
293
|
+
name: string;
|
|
294
|
+
}[];
|
|
295
|
+
/**
|
|
296
|
+
* Follow the next (or, with a negative `step`, the previous) of the large satellites in `largeSatellites()`, going round: the first when none is followed yet. The followed satellite stays in the middle of the picture, as a model where the page has one,
|
|
297
|
+
* with the Earth turning and sliding beneath. Returns the satellite now followed, or `null` when there is none to follow.
|
|
298
|
+
*
|
|
299
|
+
* @param step - How many places to hop: 1 (the default) is the next.
|
|
300
|
+
*/
|
|
301
|
+
followNext(step?: number): {
|
|
302
|
+
ref: SatelliteRef;
|
|
303
|
+
noradId: number;
|
|
304
|
+
name: string;
|
|
305
|
+
} | null;
|
|
255
306
|
/** What the camera is riding along with now, or null. */
|
|
256
307
|
get riding(): Riding | null;
|
|
257
308
|
/**
|
|
@@ -276,6 +327,32 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
276
327
|
selectSatellite(ref: SatelliteRef | null): void;
|
|
277
328
|
/** The satellite marked by `selectSatellite` or by a press on it, if any. */
|
|
278
329
|
get selectedSatellite(): SatelliteRef | null;
|
|
330
|
+
/**
|
|
331
|
+
* Ring and name every satellite of a group (or stop): a ring round each and its name beside it, in the page's language (the ISS, Tiangong and Hubble by their short names, the rest as their elements name them, or as `satelliteNames` says), never over another name, a place's or a ring's.
|
|
332
|
+
* Names and rings are drawn with the places, only for satellites that are in the picture and not behind the Earth, and nothing is drawn at rest. `chikyu-satellite-visibility` is sent with `detail: { ref, visible }` when a labelled satellite comes into view or goes out of it (not at every frame).
|
|
333
|
+
* At most 80 satellites are ringed, over all the groups. A group that is not set, or is not shown, has none.
|
|
334
|
+
*
|
|
335
|
+
* @param group - The group's name, as given to `setSatellites`.
|
|
336
|
+
* @param on - `true` to ring and name its members (the default), `false` to stop.
|
|
337
|
+
*/
|
|
338
|
+
labelSatellites(group: string, on?: boolean): void;
|
|
339
|
+
/** The groups whose satellites are ringed and named now (`labelSatellites`). */
|
|
340
|
+
get labelledSatellites(): string[];
|
|
341
|
+
/**
|
|
342
|
+
* The names written beside the ringed satellites, by NORAD number, for a page in another language or with names of its own (`{ 25544: "Space Station" }`). One left out keeps its short name (the ISS, Tiangong and Hubble) or the name in its elements.
|
|
343
|
+
*/
|
|
344
|
+
get satelliteNames(): Record<number, string>;
|
|
345
|
+
set satelliteNames(value: Record<number, string>);
|
|
346
|
+
/**
|
|
347
|
+
* Where a satellite is on the screen as of the last draw: `{ x, y, visible, heightKm }` in CSS pixels from the view's top left, `visible` meaning it is inside the box and not behind the Earth. `null` when its group is not set or not shown, it cannot be
|
|
348
|
+
* placed (its elements are too old), or it is behind the camera. It is the picture's own camera maths and its own test for the Earth in the way, so a page that draws its own rings need not repeat either.
|
|
349
|
+
*/
|
|
350
|
+
placeSatellite(ref: SatelliteRef): {
|
|
351
|
+
x: number;
|
|
352
|
+
y: number;
|
|
353
|
+
visible: boolean;
|
|
354
|
+
heightKm: number;
|
|
355
|
+
} | null;
|
|
279
356
|
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
|
|
280
357
|
satelliteInfo(ref: SatelliteRef): SatelliteInfo | undefined;
|
|
281
358
|
/** The words shown beside each body, for a page in another language (`{ Mars: "火星" }`). A body left out keeps its English name. */
|
|
@@ -312,9 +389,10 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
312
389
|
lost: boolean;
|
|
313
390
|
gliding: boolean;
|
|
314
391
|
};
|
|
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. */
|
|
392
|
+
/** 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
393
|
camera: {
|
|
317
394
|
position: [number, number, number];
|
|
395
|
+
quaternion: [number, number, number, number];
|
|
318
396
|
fov: number;
|
|
319
397
|
};
|
|
320
398
|
/** 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 +418,7 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
340
418
|
made: boolean;
|
|
341
419
|
showing: boolean;
|
|
342
420
|
};
|
|
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
|
|
421
|
+
/** 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
422
|
sky: {
|
|
345
423
|
on: boolean;
|
|
346
424
|
loaded: boolean;
|
|
@@ -349,6 +427,36 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
349
427
|
picked: string | null;
|
|
350
428
|
renders: number;
|
|
351
429
|
lang: string;
|
|
430
|
+
stars: {
|
|
431
|
+
text: string;
|
|
432
|
+
x: number;
|
|
433
|
+
y: number;
|
|
434
|
+
}[];
|
|
435
|
+
};
|
|
436
|
+
/** The followed satellite's model (`setSatellitePainter`), when one is drawn: where its middle is on the screen, in CSS pixels, as of the last draw; `null` otherwise. */
|
|
437
|
+
followModel: {
|
|
438
|
+
x: number;
|
|
439
|
+
y: number;
|
|
440
|
+
shown: boolean;
|
|
441
|
+
} | null;
|
|
442
|
+
/** The places: how many were handed over, how many are drawn and named at the last draw, and how many times they were laid out. */
|
|
443
|
+
places: {
|
|
444
|
+
places: number;
|
|
445
|
+
shown: number;
|
|
446
|
+
labels: number;
|
|
447
|
+
renders: number;
|
|
448
|
+
rings: number;
|
|
449
|
+
satelliteNames: number;
|
|
450
|
+
};
|
|
451
|
+
/** The names of cities: whether `city-names` is set and the most it asks for, the Earth's radius on the screen, the tiers of kuni's cities that have arrived and how many cities, the names shown at the last draw and how many times the layer was drawn. */
|
|
452
|
+
cityNames: {
|
|
453
|
+
on: boolean;
|
|
454
|
+
max: number;
|
|
455
|
+
radius: number;
|
|
456
|
+
tiers: string[];
|
|
457
|
+
cities: number;
|
|
458
|
+
names: number;
|
|
459
|
+
renders: number;
|
|
352
460
|
};
|
|
353
461
|
};
|
|
354
462
|
}
|
package/dist/space/element.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
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
5
|
import { createSkyHost, SKY_ATTRIBUTES, SKY_STYLE } from "../sky/host.js";
|
|
6
|
+
import { cleanPlaces, readPlaces } from "../markers/places.js";
|
|
7
|
+
import { createPlaceLayer, PLACE_STYLE, readPlaceLook } from "../markers/place-layer.js";
|
|
8
|
+
import { SHORT_NAMES } from "../satellites/names.js";
|
|
9
|
+
import { CITY_NAMES_ATTRIBUTES, CITY_NAMES_STYLE, createCityHost } from "../cities/host.js";
|
|
6
10
|
import { createGate, frameCap } from "../realistic/gate.js";
|
|
7
11
|
import { setThreeLoader, takeRenderer } from "../realistic/shared.js";
|
|
8
12
|
import { NOTES_STYLE, setAirNote } from "../realistic/air-note.js";
|
|
@@ -12,10 +16,12 @@ import { MAX_TEXTURE } from "../realistic/tiers.js";
|
|
|
12
16
|
import { MAX_SATELLITE_SPEED } from "../satellites/limits.js";
|
|
13
17
|
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
14
18
|
import { MAX_ORBIT_GROUP } from "./satellite-layer.js";
|
|
19
|
+
import { rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
15
20
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
16
21
|
import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
|
|
17
22
|
export { BODY_NAMES };
|
|
18
23
|
let painter;
|
|
24
|
+
let satellitePainter;
|
|
19
25
|
/**
|
|
20
26
|
* Change how the Sun and the planets are drawn (before the first element connects): the space view keeps their places, sizes, light, names and orbits and asks
|
|
21
27
|
* the painter only for what to draw at each place (see `BodyPainter`). Left alone, they are plain spheres in the right colours.
|
|
@@ -33,6 +39,22 @@ let painter;
|
|
|
33
39
|
export function setBodyPainter(next) {
|
|
34
40
|
painter = next;
|
|
35
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Where the 3D models of large satellites come from if the page has any: the package ships none. With a painter set, a satellite followed (`ride(ref, { view: "follow" })`) that the painter has a model for is drawn as that model, in the middle
|
|
44
|
+
* of the picture at a size that reads, pointed the way it flies, lit by the Sun; a satellite it has none for stays a dot. See `SatellitePainter`.
|
|
45
|
+
*
|
|
46
|
+
* @param next - The painter, or `undefined` for none.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts no-run
|
|
50
|
+
* import { setSatellitePainter } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
51
|
+
*
|
|
52
|
+
* setSatellitePainter({ has: (norad) => norad === 25544, make: async () => null });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export function setSatellitePainter(next) {
|
|
56
|
+
satellitePainter = next;
|
|
57
|
+
}
|
|
36
58
|
/** Mean radii in kilometres (IAU), for what a click tells. */
|
|
37
59
|
const RADIUS_KM = { Sun: 695_700, Mercury: 2439.7, Venus: 6051.8, Earth: 6371, Moon: 1737.4, Mars: 3389.5, Jupiter: 69_911, Saturn: 58_232, Uranus: 25_362, Neptune: 24_622, Pluto: 1188.3 };
|
|
38
60
|
export { setThreeLoader };
|
|
@@ -76,7 +98,7 @@ const readTime = (value) => {
|
|
|
76
98
|
const ms = Date.parse(value);
|
|
77
99
|
return Number.isFinite(ms) ? ms : "now";
|
|
78
100
|
};
|
|
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}${SKY_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
101
|
+
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}${PLACE_STYLE}${SKY_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
80
102
|
/**
|
|
81
103
|
* 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
104
|
*
|
|
@@ -102,7 +124,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
102
124
|
* ```
|
|
103
125
|
*/
|
|
104
126
|
export class ChikyuSpace extends HTMLElement {
|
|
105
|
-
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, "air-thickness", "air-label", "lang"];
|
|
127
|
+
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, "air-thickness", "air-label", "lang", "places", "places-look"];
|
|
106
128
|
#model = newSpaceModel();
|
|
107
129
|
#mode = "now";
|
|
108
130
|
#speed = 1;
|
|
@@ -113,6 +135,12 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
113
135
|
/** The names of the stars and the constellation lines (`star-names`, `constellation-lines`), and the look of the names. */
|
|
114
136
|
#sky;
|
|
115
137
|
#skyStyle = {};
|
|
138
|
+
/** The names of cities on the Earth (`city-names`), and the look of the names. */
|
|
139
|
+
#cities;
|
|
140
|
+
#citiesStyle = {};
|
|
141
|
+
#satNames = {};
|
|
142
|
+
/** The ringed satellites of the last draw (`labelSatellites`), laid out with the places. */
|
|
143
|
+
#marks = [];
|
|
116
144
|
#airNote;
|
|
117
145
|
#gate;
|
|
118
146
|
#taken;
|
|
@@ -132,6 +160,9 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
132
160
|
#tiers = {};
|
|
133
161
|
#hands;
|
|
134
162
|
#ridden = {};
|
|
163
|
+
#placeLayer;
|
|
164
|
+
#placeList = [];
|
|
165
|
+
#nameBoxes = new Map();
|
|
135
166
|
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
136
167
|
get controller() {
|
|
137
168
|
return this.#hands?.controller;
|
|
@@ -156,7 +187,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
156
187
|
if (!this.hasAttribute("aria-label"))
|
|
157
188
|
this.setAttribute("aria-label", "The Earth, the Moon, the Sun and the planets in their places for the date shown");
|
|
158
189
|
const root = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
159
|
-
root.innerHTML = `<div id="stage"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p></div>`;
|
|
190
|
+
root.innerHTML = `<div id="stage"></div><div id="places"></div><div id="labels" aria-hidden="true"></div><div id="notes"><p id="air-note" hidden></p><p id="meteor-note" hidden></p></div>`;
|
|
160
191
|
adoptStyles(root, STYLE, this.nonce);
|
|
161
192
|
this.#stage = root.getElementById("stage");
|
|
162
193
|
this.#labelBox = root.getElementById("labels");
|
|
@@ -170,6 +201,17 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
170
201
|
loadFont: loadMichroma,
|
|
171
202
|
});
|
|
172
203
|
this.#sky.setStyle(this.#skyStyle);
|
|
204
|
+
this.#placeLayer = createPlaceLayer(root.getElementById("places"));
|
|
205
|
+
this.#placeList = readPlaces(this.getAttribute("places"));
|
|
206
|
+
this.#placeLayer.set(this.#placeList);
|
|
207
|
+
this.#placeLayer.look = readPlaceLook(this.getAttribute("places-look"));
|
|
208
|
+
this.#cities = createCityHost({
|
|
209
|
+
root,
|
|
210
|
+
attribute: (name) => this.getAttribute(name),
|
|
211
|
+
language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
|
|
212
|
+
onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-city-names-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
213
|
+
});
|
|
214
|
+
this.#cities.setStyle(this.#citiesStyle);
|
|
173
215
|
this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
|
|
174
216
|
this.#applyBodyLabel();
|
|
175
217
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
@@ -201,12 +243,16 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
201
243
|
},
|
|
202
244
|
onLabels: (places) => this.#placeLabels(places),
|
|
203
245
|
onSky: (sky) => this.#sky?.frame(sky),
|
|
246
|
+
onPlaces: (view) => this.#drawPlaces(view),
|
|
247
|
+
onCities: (frame) => this.#cities?.frame(frame),
|
|
204
248
|
onLabelError: (error) => this.dispatchEvent(new CustomEvent("chikyu-body-label-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
249
|
+
onSatelliteMarks: (marks) => this.#showMarks(marks),
|
|
205
250
|
onSelected: (place) => this.#placeChosen(place),
|
|
206
251
|
onMoving: () => this.#gate?.request(),
|
|
207
252
|
onRideLost: () => this.#rideLost(),
|
|
208
253
|
onSatellitesError: (error) => this.dispatchEvent(new CustomEvent("chikyu-satellites-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
209
254
|
...(painter ? { painter } : {}),
|
|
255
|
+
satellitePainter: () => satellitePainter,
|
|
210
256
|
onPainterError: (error) => this.dispatchEvent(new CustomEvent("chikyu-bodies-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
211
257
|
});
|
|
212
258
|
this.#view = taken.renderer.view(this.#stage, item, { still: null });
|
|
@@ -241,6 +287,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
241
287
|
this.#taken = undefined;
|
|
242
288
|
this.#sky?.dispose();
|
|
243
289
|
this.#sky = undefined;
|
|
290
|
+
this.#placeLayer?.dispose();
|
|
291
|
+
this.#placeLayer = undefined;
|
|
292
|
+
this.#cities?.dispose();
|
|
293
|
+
this.#cities = undefined;
|
|
244
294
|
}
|
|
245
295
|
attributeChangedCallback(name, _old, value) {
|
|
246
296
|
if (name === "center")
|
|
@@ -286,12 +336,24 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
286
336
|
if (name === "lang") {
|
|
287
337
|
this.#applyBodyLabel();
|
|
288
338
|
this.#sky?.refresh();
|
|
339
|
+
this.#cities?.refresh();
|
|
289
340
|
}
|
|
290
341
|
}
|
|
291
342
|
else if (BODY_LABEL_ATTRIBUTES.includes(name))
|
|
292
343
|
this.#applyBodyLabel();
|
|
293
344
|
else if (SKY_ATTRIBUTES.includes(name))
|
|
294
345
|
this.#sky?.refresh();
|
|
346
|
+
else if (name === "places") {
|
|
347
|
+
this.#placeList = readPlaces(value);
|
|
348
|
+
this.#placeLayer?.set(this.#placeList);
|
|
349
|
+
this.#gate?.request();
|
|
350
|
+
}
|
|
351
|
+
else if (name === "places-look" && this.#placeLayer) {
|
|
352
|
+
this.#placeLayer.look = readPlaceLook(value);
|
|
353
|
+
this.#gate?.request();
|
|
354
|
+
}
|
|
355
|
+
else if (CITY_NAMES_ATTRIBUTES.includes(name))
|
|
356
|
+
this.#cities?.refresh();
|
|
295
357
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
296
358
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
297
359
|
}
|
|
@@ -362,7 +424,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
362
424
|
/**
|
|
363
425
|
* 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
426
|
* 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
|
|
427
|
+
* 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
428
|
*/
|
|
367
429
|
get skyStyle() {
|
|
368
430
|
return { ...this.#skyStyle };
|
|
@@ -371,6 +433,64 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
371
433
|
this.#skyStyle = { ...value };
|
|
372
434
|
this.#sky?.setStyle(this.#skyStyle);
|
|
373
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Places marked on the Earth (the attribute `places`, a JSON array): each `{ id, lon, lat, label, kind }`, `kind` being `here` (where the reader is: drawn bright and taller, with a quiet pulse) or `favourite`
|
|
438
|
+
* (the default: quieter). Each stands up out of the ground, turns with the Earth, is hidden on its far side and keeps its size in pixels at any zoom. Names go at the top, `here` first, and never overlap
|
|
439
|
+
* one another or the bodies' names; one with no room is left out. The element stores nothing and sends nothing: the page hands the places over and keeps them where it likes. Setting the property writes
|
|
440
|
+
* the attribute; at most `MAX_PLACES` are drawn. Nothing is drawn again at rest: the pulse is the page's own animation, stopped out of sight and for a reader who asked for less motion.
|
|
441
|
+
*/
|
|
442
|
+
get places() {
|
|
443
|
+
return this.#placeList.map((place) => ({ ...place }));
|
|
444
|
+
}
|
|
445
|
+
set places(value) {
|
|
446
|
+
const clean = cleanPlaces(value);
|
|
447
|
+
if (clean.length === 0)
|
|
448
|
+
this.removeAttribute("places");
|
|
449
|
+
else
|
|
450
|
+
this.setAttribute("places", JSON.stringify(clean));
|
|
451
|
+
}
|
|
452
|
+
/** How the places are drawn (the attribute `places-look`): `beam` (a light rising out of the ground with a ring at its foot, the default), `pin` (a thin stick with a round head) or `ring` (only the ring on the ground). */
|
|
453
|
+
get placesLook() {
|
|
454
|
+
return this.#placeLayer?.look ?? readPlaceLook(this.getAttribute("places-look"));
|
|
455
|
+
}
|
|
456
|
+
set placesLook(value) {
|
|
457
|
+
this.setAttribute("places-look", value);
|
|
458
|
+
}
|
|
459
|
+
/** Lays the places on the picture just drawn, clear of the bodies' names shown beside it. */
|
|
460
|
+
#drawPlaces(view) {
|
|
461
|
+
const layer = this.#placeLayer;
|
|
462
|
+
if (!layer || (this.#placeList.length === 0 && this.#marks.length === 0 && layer.stats.shown === 0 && layer.stats.rings === 0))
|
|
463
|
+
return;
|
|
464
|
+
const taken = [];
|
|
465
|
+
if (this.#model.labels && this.#places) {
|
|
466
|
+
for (const name of BODY_NAMES) {
|
|
467
|
+
const at = this.#places[name];
|
|
468
|
+
const label = this.#pool.get(name);
|
|
469
|
+
if (!at || !label || label.hidden)
|
|
470
|
+
continue;
|
|
471
|
+
const text = label.textContent ?? "";
|
|
472
|
+
let box = this.#nameBoxes.get(text);
|
|
473
|
+
if (!box) {
|
|
474
|
+
const rect = label.getBoundingClientRect();
|
|
475
|
+
box = { width: Math.ceil(rect.width), height: Math.ceil(rect.height) };
|
|
476
|
+
if (box.width > 0)
|
|
477
|
+
this.#nameBoxes.set(text, box);
|
|
478
|
+
}
|
|
479
|
+
taken.push({ left: at.x + Math.max(4, Math.min(at.r, 40)), top: at.y - 8, ...box });
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
layer.frame(view, taken, this.#marks);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* The look of the names of cities (`city-names`): font, size, weight, colour, the outline round the text, and the dot's colour and size. Any of them may be left out; the Earth's size, the language and the data are not set here.
|
|
486
|
+
*/
|
|
487
|
+
get cityNamesStyle() {
|
|
488
|
+
return { ...this.#citiesStyle };
|
|
489
|
+
}
|
|
490
|
+
set cityNamesStyle(value) {
|
|
491
|
+
this.#citiesStyle = { ...value };
|
|
492
|
+
this.#cities?.setStyle(this.#citiesStyle);
|
|
493
|
+
}
|
|
374
494
|
/** Puts the name's settings and text right from the attributes (`body-label` and its family, `lang`). */
|
|
375
495
|
#applyBodyLabel() {
|
|
376
496
|
this.#model.bodyLabel.settings = readBodyLabel((name) => this.getAttribute(name));
|
|
@@ -522,7 +642,19 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
522
642
|
const now = this.#model.view;
|
|
523
643
|
if (view.yaw === now.yaw && view.tilt === now.tilt && view.zoom === now.zoom)
|
|
524
644
|
return;
|
|
525
|
-
|
|
645
|
+
const model = this.#model;
|
|
646
|
+
// 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
|
|
647
|
+
if (view.yaw !== now.yaw)
|
|
648
|
+
model.rideTurn += rideTurnDegrees(wrapYaw(view.yaw - now.yaw), view.zoom);
|
|
649
|
+
// 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)
|
|
650
|
+
let tilt = view.tilt;
|
|
651
|
+
const limits = model.ride && model.ride.view === "from" && model.rideDistance !== null ? rideTiltLimits(model.rideDistance, model.ride.look, view.zoom) : null;
|
|
652
|
+
if (limits)
|
|
653
|
+
tilt = Math.max(limits.min, Math.min(limits.max, tilt));
|
|
654
|
+
this.#model.view = { yaw: view.yaw, tilt, zoom: view.zoom };
|
|
655
|
+
// 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
|
|
656
|
+
if (tilt !== view.tilt)
|
|
657
|
+
this.#controls()?.set({ yaw: view.yaw, tilt, zoom: view.zoom }, final, "ride");
|
|
526
658
|
const drawn = this.#model.drawnView;
|
|
527
659
|
if (drawn && !final && view.zoom === drawn.zoom) {
|
|
528
660
|
const turned = Math.max(Math.abs(view.yaw - drawn.yaw), Math.abs(view.tilt - drawn.tilt)) * RAD;
|
|
@@ -531,6 +663,19 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
531
663
|
}
|
|
532
664
|
this.#gate?.request();
|
|
533
665
|
}
|
|
666
|
+
/**
|
|
667
|
+
* 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.
|
|
668
|
+
*/
|
|
669
|
+
#controls() {
|
|
670
|
+
if (this.hasAttribute("data-kazoku-bar") && this.id) {
|
|
671
|
+
const root = this.getRootNode();
|
|
672
|
+
const bar = root.querySelector?.(`kazoku-view-controls[for="${CSS.escape(this.id)}"]`);
|
|
673
|
+
const held = bar ? Reflect.get(bar, "controller") : undefined;
|
|
674
|
+
if (held)
|
|
675
|
+
return held;
|
|
676
|
+
}
|
|
677
|
+
return this.#hands?.controller;
|
|
678
|
+
}
|
|
534
679
|
/** The body the camera looks at: at zoom 1 it fills the view; the yaw and tilt turn the camera round it. */
|
|
535
680
|
get body() {
|
|
536
681
|
return this.#model.focus;
|
|
@@ -557,6 +702,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
557
702
|
const wasRiding = model.ride !== null;
|
|
558
703
|
if (target === null) {
|
|
559
704
|
model.ride = null;
|
|
705
|
+
model.rideTurn = 0;
|
|
560
706
|
model.focus = this.#focusBeforeRide;
|
|
561
707
|
}
|
|
562
708
|
else {
|
|
@@ -566,6 +712,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
566
712
|
return;
|
|
567
713
|
if (!wasRiding)
|
|
568
714
|
this.#focusBeforeRide = model.focus;
|
|
715
|
+
// 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
|
|
716
|
+
model.rideTurn = rideTurnDegrees(model.view.yaw, model.view.zoom);
|
|
569
717
|
const view = typeof target === "string" && target === "Earth" ? "follow" : (options.view ?? "from");
|
|
570
718
|
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
719
|
if (typeof target === "string" && view === "follow")
|
|
@@ -599,6 +747,37 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
599
747
|
}
|
|
600
748
|
}
|
|
601
749
|
}
|
|
750
|
+
/**
|
|
751
|
+
* The satellites the page has a model for (`setSatellitePainter`) in the groups now set, each with its name in the page's language: the large satellites that can be followed as a model. Empty with no painter.
|
|
752
|
+
*/
|
|
753
|
+
largeSatellites() {
|
|
754
|
+
const out = [];
|
|
755
|
+
if (!satellitePainter)
|
|
756
|
+
return out;
|
|
757
|
+
for (const [group, state] of this.#model.satellites.groups) {
|
|
758
|
+
state.satellites.sets.forEach((set, index) => {
|
|
759
|
+
if (satellitePainter.has(set.NORAD_CAT_ID))
|
|
760
|
+
out.push({ ref: { group, index }, noradId: set.NORAD_CAT_ID, name: this.#satelliteName({ group, index }) });
|
|
761
|
+
});
|
|
762
|
+
}
|
|
763
|
+
return out;
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Follow the next (or, with a negative `step`, the previous) of the large satellites in `largeSatellites()`, going round: the first when none is followed yet. The followed satellite stays in the middle of the picture, as a model where the page has one,
|
|
767
|
+
* with the Earth turning and sliding beneath. Returns the satellite now followed, or `null` when there is none to follow.
|
|
768
|
+
*
|
|
769
|
+
* @param step - How many places to hop: 1 (the default) is the next.
|
|
770
|
+
*/
|
|
771
|
+
followNext(step = 1) {
|
|
772
|
+
const list = this.largeSatellites();
|
|
773
|
+
if (list.length === 0)
|
|
774
|
+
return null;
|
|
775
|
+
const ride = this.#model.ride;
|
|
776
|
+
const current = ride && typeof ride.target !== "string" ? list.findIndex((one) => one.ref.group === ride.target.group && one.ref.index === ride.target.index) : -1;
|
|
777
|
+
const next = list[(((current < 0 ? (step > 0 ? -1 : 0) : current) + step) % list.length + list.length) % list.length];
|
|
778
|
+
this.ride(next.ref, { view: "follow" });
|
|
779
|
+
return next;
|
|
780
|
+
}
|
|
602
781
|
/** What the camera is riding along with now, or null. */
|
|
603
782
|
get riding() {
|
|
604
783
|
const ride = this.#model.ride;
|
|
@@ -667,6 +846,69 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
667
846
|
const chosen = this.#model.satellites.selected;
|
|
668
847
|
return chosen ? { ...chosen } : null;
|
|
669
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* Ring and name every satellite of a group (or stop): a ring round each and its name beside it, in the page's language (the ISS, Tiangong and Hubble by their short names, the rest as their elements name them, or as `satelliteNames` says), never over another name, a place's or a ring's.
|
|
851
|
+
* Names and rings are drawn with the places, only for satellites that are in the picture and not behind the Earth, and nothing is drawn at rest. `chikyu-satellite-visibility` is sent with `detail: { ref, visible }` when a labelled satellite comes into view or goes out of it (not at every frame).
|
|
852
|
+
* At most 80 satellites are ringed, over all the groups. A group that is not set, or is not shown, has none.
|
|
853
|
+
*
|
|
854
|
+
* @param group - The group's name, as given to `setSatellites`.
|
|
855
|
+
* @param on - `true` to ring and name its members (the default), `false` to stop.
|
|
856
|
+
*/
|
|
857
|
+
labelSatellites(group, on = true) {
|
|
858
|
+
if (on)
|
|
859
|
+
this.#model.satellites.marked.add(group);
|
|
860
|
+
else
|
|
861
|
+
this.#model.satellites.marked.delete(group);
|
|
862
|
+
this.#gate?.request();
|
|
863
|
+
}
|
|
864
|
+
/** The groups whose satellites are ringed and named now (`labelSatellites`). */
|
|
865
|
+
get labelledSatellites() {
|
|
866
|
+
return [...this.#model.satellites.marked];
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* The names written beside the ringed satellites, by NORAD number, for a page in another language or with names of its own (`{ 25544: "Space Station" }`). One left out keeps its short name (the ISS, Tiangong and Hubble) or the name in its elements.
|
|
870
|
+
*/
|
|
871
|
+
get satelliteNames() {
|
|
872
|
+
return { ...this.#satNames };
|
|
873
|
+
}
|
|
874
|
+
set satelliteNames(value) {
|
|
875
|
+
this.#satNames = { ...value };
|
|
876
|
+
this.#gate?.request();
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* Where a satellite is on the screen as of the last draw: `{ x, y, visible, heightKm }` in CSS pixels from the view's top left, `visible` meaning it is inside the box and not behind the Earth. `null` when its group is not set or not shown, it cannot be
|
|
880
|
+
* placed (its elements are too old), or it is behind the camera. It is the picture's own camera maths and its own test for the Earth in the way, so a page that draws its own rings need not repeat either.
|
|
881
|
+
*/
|
|
882
|
+
placeSatellite(ref) {
|
|
883
|
+
return this.#model.placeSatellite?.(ref) ?? null;
|
|
884
|
+
}
|
|
885
|
+
/** The name beside a ringed satellite: the page's own (`satelliteNames`), else the short one in the page's language, else the name in its elements. */
|
|
886
|
+
#satelliteName(ref) {
|
|
887
|
+
const info = this.satelliteInfo(ref);
|
|
888
|
+
if (!info)
|
|
889
|
+
return "";
|
|
890
|
+
const lang = (this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en";
|
|
891
|
+
return this.#satNames[info.noradId] ?? SHORT_NAMES[info.noradId]?.[lang] ?? info.name;
|
|
892
|
+
}
|
|
893
|
+
#markSeen = new Map();
|
|
894
|
+
/** Hands the places layer the ringed satellites of this draw, and tells the page when one comes into view or goes out of it. */
|
|
895
|
+
#showMarks(marks) {
|
|
896
|
+
this.#marks = marks.map((m) => ({ id: `${m.ref.group}:${m.ref.index}`, label: this.#satelliteName(m.ref), x: m.x, y: m.y, visible: m.visible }));
|
|
897
|
+
const now = new Map();
|
|
898
|
+
for (const m of marks) {
|
|
899
|
+
const key = `${m.ref.group}:${m.ref.index}`;
|
|
900
|
+
now.set(key, m.visible);
|
|
901
|
+
if (this.#markSeen.get(key) !== m.visible && (this.#markSeen.has(key) || m.visible))
|
|
902
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: m.ref, visible: m.visible }, bubbles: true, composed: true }));
|
|
903
|
+
}
|
|
904
|
+
for (const [key, was] of this.#markSeen) {
|
|
905
|
+
if (!now.has(key) && was) {
|
|
906
|
+
const [group, index] = key.split(":");
|
|
907
|
+
this.dispatchEvent(new CustomEvent("chikyu-satellite-visibility", { detail: { ref: { group: group, index: Number(index) }, visible: false }, bubbles: true, composed: true }));
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
this.#markSeen = now;
|
|
911
|
+
}
|
|
670
912
|
/** Facts about one satellite at the moment shown (name, number, element age, height, speed, period); undefined if it cannot be placed then. */
|
|
671
913
|
satelliteInfo(ref) {
|
|
672
914
|
return this.#model.satellites.groups.get(ref.group)?.satellites.info(ref.index, this.#model.time);
|
|
@@ -732,11 +974,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
732
974
|
lookups: this.#model.lookups,
|
|
733
975
|
satellites: this.#satelliteStats(),
|
|
734
976
|
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 },
|
|
977
|
+
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
978
|
bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons },
|
|
737
979
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
738
980
|
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: "" },
|
|
981
|
+
sky: this.#sky?.stats ?? { on: false, loaded: false, names: 0, figures: 0, picked: null, renders: 0, lang: "", stars: [] },
|
|
982
|
+
followModel: this.#model.followModel,
|
|
983
|
+
places: { ...(this.#placeLayer?.stats ?? { places: 0, shown: 0, labels: 0, renders: 0, rings: 0, satelliteNames: 0 }) },
|
|
984
|
+
cityNames: this.#cities?.stats ?? { on: false, max: 0, radius: 0, tiers: [], cities: 0, names: 0, renders: 0 },
|
|
740
985
|
};
|
|
741
986
|
}
|
|
742
987
|
#satelliteStats() {
|
package/dist/space/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
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 PaintContext } from "./scene.ts";
|
|
4
|
-
export { RIDE_FOV, ridePose, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
3
|
+
export { fitDistance, plainPainter, type BodyDrawing, type BodyMoon, type BodyPainter, type PaintContext, type SatellitePainter } from "./scene.ts";
|
|
4
|
+
export { RIDE_FOV, rideFov, ridePose, rideTiltLimits, rideTurnDegrees, type RideInput, type RideLook, type RidePose } from "./ride.ts";
|
|
5
|
+
export type { SatelliteScreen } from "./satellite-layer.ts";
|
|
6
|
+
export { MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.ts";
|
package/dist/space/index.js
CHANGED
|
@@ -3,4 +3,5 @@
|
|
|
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";
|
|
7
|
+
export { MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|