@johnmorrisdotca/chikyu-earth 0.31.0 → 0.33.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 +18 -0
- package/NOTICE.md +10 -1
- package/README.md +32 -2
- package/dist/catalogue/fleets.d.ts +70 -0
- package/dist/catalogue/fleets.js +66 -0
- package/dist/catalogue/index.d.ts +5 -0
- package/dist/catalogue/index.js +7 -0
- package/dist/catalogue/kinds.d.ts +143 -0
- package/dist/catalogue/kinds.js +121 -0
- package/dist/catalogue/omm.d.ts +44 -0
- package/dist/catalogue/omm.js +92 -0
- package/dist/catalogue/orbit.d.ts +95 -0
- package/dist/catalogue/orbit.js +91 -0
- package/dist/catalogue/pack.d.ts +193 -0
- package/dist/catalogue/pack.js +327 -0
- package/dist/data/meteor-iau.d.ts +79 -0
- package/dist/data/meteor-iau.js +77 -0
- package/dist/data/meteor-showers.js +24 -20
- package/dist/data-door.d.ts +2 -0
- package/dist/data-door.js +4 -2
- package/dist/door/index.d.ts +1 -0
- package/dist/door/index.js +1 -0
- package/dist/door/packed.d.ts +64 -0
- package/dist/door/packed.js +91 -0
- package/dist/meteors/index.d.ts +2 -0
- package/dist/meteors/index.js +2 -0
- package/dist/meteors/parents.d.ts +45 -0
- package/dist/meteors/parents.js +67 -0
- package/dist/realistic/body-label.d.ts +126 -0
- package/dist/realistic/body-label.js +187 -0
- package/dist/realistic/earth.d.ts +8 -0
- package/dist/realistic/earth.js +29 -0
- package/dist/realistic/element.d.ts +35 -0
- package/dist/realistic/element.js +78 -2
- package/dist/realistic/index.d.ts +1 -0
- package/dist/realistic/index.js +1 -0
- package/dist/realistic/textures.d.ts +8 -0
- package/dist/satellites/source.d.ts +4 -0
- package/dist/satellites/source.js +2 -2
- package/dist/sky/host.d.ts +55 -0
- package/dist/sky/host.js +382 -0
- package/dist/space/element.d.ts +35 -0
- package/dist/space/element.js +78 -2
- package/dist/space/scene.d.ts +8 -0
- package/dist/space/scene.js +34 -0
- package/package.json +12 -2
package/dist/realistic/earth.js
CHANGED
|
@@ -5,6 +5,7 @@ import { greenwichSidereal, subsolarPoint, unitVector } from "./sun.js";
|
|
|
5
5
|
import { createSatelliteLayer, newSatelliteState } from "../space/satellite-layer.js";
|
|
6
6
|
import { createTextureSet } from "./textures.js";
|
|
7
7
|
import { createTileSet } from "./tile-set.js";
|
|
8
|
+
import { createBodyLabelLayer, newBodyLabelState } from "./body-label.js";
|
|
8
9
|
import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
|
|
9
10
|
const RAD = Math.PI / 180;
|
|
10
11
|
/**
|
|
@@ -38,6 +39,7 @@ export const newModel = () => ({
|
|
|
38
39
|
pick: null,
|
|
39
40
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
40
41
|
meteors: newMeteorState(),
|
|
42
|
+
bodyLabel: newBodyLabelState(),
|
|
41
43
|
});
|
|
42
44
|
/**
|
|
43
45
|
* The disc's radius in CSS pixels in a box of `width` x `height` at `zoom`: it fits the glow in the box at 1x.
|
|
@@ -183,6 +185,7 @@ export function createEarthItem(model, deps) {
|
|
|
183
185
|
// the meteors: made the first time they are switched on, and asking for their own next draw while a streak is alive or one is due
|
|
184
186
|
let meteors = null;
|
|
185
187
|
let meteorTimer;
|
|
188
|
+
let nameOn = null;
|
|
186
189
|
return {
|
|
187
190
|
scene,
|
|
188
191
|
camera,
|
|
@@ -227,6 +230,31 @@ export function createEarthItem(model, deps) {
|
|
|
227
230
|
textures.sync(radius * model.ratio());
|
|
228
231
|
tiles.sync({ lon: look.lon, lat: look.lat, width: size.width, height: size.height, panX: view.panX, panY: view.panY, radius }, [sunDir.value.x, sunDir.value.y, sunDir.value.z], true, model.ratio());
|
|
229
232
|
deps.onTiled?.();
|
|
233
|
+
// the name written on the Earth: the layer is made the first time the settings ask for it, and keeps itself right
|
|
234
|
+
if (model.bodyLabel.settings && !nameOn)
|
|
235
|
+
nameOn = createBodyLabelLayer(three, turned, model.bodyLabel, { invalidate: deps.invalidate, ...(deps.onLabelError ? { onError: deps.onLabelError } : {}) });
|
|
236
|
+
nameOn?.sync(camera, radius);
|
|
237
|
+
if (deps.onSky) {
|
|
238
|
+
// the sky as the picture's own axes see it: a direction in space, turned as the satellites are into the picture's axes, falls where its sideways and upward parts say, in front when it points towards the viewer
|
|
239
|
+
spun.updateWorldMatrix(true, false);
|
|
240
|
+
const sky = new three.Vector3();
|
|
241
|
+
const scale = Math.min(size.width, size.height) / 2;
|
|
242
|
+
const cx = size.width / 2 + view.panX;
|
|
243
|
+
const cy = size.height / 2 + view.panY;
|
|
244
|
+
deps.onSky({
|
|
245
|
+
width: size.width,
|
|
246
|
+
height: size.height,
|
|
247
|
+
discs: [{ x: cx, y: cy, radius }],
|
|
248
|
+
project(rightAscension, declination, out) {
|
|
249
|
+
const r = rightAscension * RAD;
|
|
250
|
+
const d = declination * RAD;
|
|
251
|
+
sky.set(Math.cos(d) * Math.cos(r), Math.sin(d), -Math.cos(d) * Math.sin(r)).transformDirection(spun.matrixWorld);
|
|
252
|
+
out.x = cx + scale * sky.x;
|
|
253
|
+
out.y = cy - scale * sky.y;
|
|
254
|
+
return sky.z > 0;
|
|
255
|
+
},
|
|
256
|
+
});
|
|
257
|
+
}
|
|
230
258
|
deps.onPose?.({ lon: look.lon, lat: look.lat, radius, cx: size.width / 2 + view.panX, cy: size.height / 2 + view.panY, width: size.width, height: size.height });
|
|
231
259
|
if (model.meteors.on && !meteors)
|
|
232
260
|
meteors = createMeteorLayer(three, turned, model.meteors);
|
|
@@ -245,6 +273,7 @@ export function createEarthItem(model, deps) {
|
|
|
245
273
|
model.pick = null;
|
|
246
274
|
clearTimeout(meteorTimer);
|
|
247
275
|
meteors?.dispose();
|
|
276
|
+
nameOn?.dispose();
|
|
248
277
|
model.tiles = null;
|
|
249
278
|
tiles.dispose();
|
|
250
279
|
textures.dispose();
|
|
@@ -4,6 +4,8 @@ import { type CameraMode, type LightMode } from "./earth.ts";
|
|
|
4
4
|
import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/types.ts";
|
|
5
5
|
import { type SatelliteStyle } from "../space/satellite-layer.ts";
|
|
6
6
|
import type { Credit, DataSource } from "../data-door.ts";
|
|
7
|
+
import { type BodyLabelSettings } from "./body-label.ts";
|
|
8
|
+
import type { LabelStyle } from "@johnmorrisdotca/hoshi-stars/sky-labels";
|
|
7
9
|
import { setSharedRenderer, setThreeLoader } from "./shared.ts";
|
|
8
10
|
export { setSharedRenderer, setThreeLoader };
|
|
9
11
|
export type { CameraMode };
|
|
@@ -123,6 +125,22 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
123
125
|
*/
|
|
124
126
|
get meteorsStrength(): number;
|
|
125
127
|
set meteorsStrength(value: number);
|
|
128
|
+
/**
|
|
129
|
+
* The name written on the Earth, as the family's body label: `EARTH` (`地球` on a Japanese page) laid on the globe so it turns with it, the surface showing through the letters. Off (`null`) unless the page sets it. The plain attributes are the family's:
|
|
130
|
+
* `body-label` (`painted`, `etched`, `outline` or `burned`; absent, no label), `body-label-strength` (0 to 1, 0.5), `body-label-repeat` (`once`, `both` or `around`), `body-label-latitude` (degrees), `body-label-facing` (present: always facing the reader),
|
|
131
|
+
* `body-label-font` (a CSS font family the page has loaded; Michroma, fetched once, when left out) and `body-label-fallback-font` (for letters the font has none of, such as Japanese). The property is the same options as an object, or `null`; setting it writes the attributes.
|
|
132
|
+
* Nothing of it is fetched or made until it is first set, it is not drawn while the Earth is under 24 pixels in radius, and nothing is drawn at rest. A three.js handed over with `setThreeLoader` must include `CanvasTexture`, `SphereGeometry`, `MeshLambertMaterial`, `SRGBColorSpace`, `NormalBlending`
|
|
133
|
+
* and `AdditiveBlending`; without them `chikyu-body-label-unavailable` is sent and the name is not drawn.
|
|
134
|
+
*/
|
|
135
|
+
get bodyLabel(): BodyLabelSettings | null;
|
|
136
|
+
set bodyLabel(value: Partial<BodyLabelSettings> | null);
|
|
137
|
+
/**
|
|
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
|
+
* 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 hoshi-stars `LabelStyle` (font, size, case, ring, leader and the rest).
|
|
141
|
+
*/
|
|
142
|
+
get skyStyle(): Partial<LabelStyle>;
|
|
143
|
+
set skyStyle(value: Partial<LabelStyle>);
|
|
126
144
|
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
127
145
|
get controller(): ViewController | undefined;
|
|
128
146
|
/**
|
|
@@ -203,6 +221,23 @@ export declare class ChikyuEarthRealistic extends HTMLElement {
|
|
|
203
221
|
shower: string | null;
|
|
204
222
|
zhr: number;
|
|
205
223
|
};
|
|
224
|
+
/** The name written on the Earth: whether `body-label` is set, its text, the label is made, and it is showing (it is hidden while the Earth is small). */
|
|
225
|
+
bodyLabel: {
|
|
226
|
+
on: boolean;
|
|
227
|
+
text: string;
|
|
228
|
+
made: boolean;
|
|
229
|
+
showing: boolean;
|
|
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 and the language its names were last laid out in. */
|
|
232
|
+
sky: {
|
|
233
|
+
on: boolean;
|
|
234
|
+
loaded: boolean;
|
|
235
|
+
names: number;
|
|
236
|
+
figures: number;
|
|
237
|
+
picked: string | null;
|
|
238
|
+
renders: number;
|
|
239
|
+
lang: string;
|
|
240
|
+
};
|
|
206
241
|
};
|
|
207
242
|
/**
|
|
208
243
|
* Apply a shared view controller's camera (yaw, tilt, zoom, pan). A change under half a pixel is not drawn, a settled change always is,
|
|
@@ -13,6 +13,8 @@ import { METEOR_NOTE_STYLE, prefersLessMotion, setMeteorNote } from "../meteors/
|
|
|
13
13
|
import { createDoorHost } from "../door/host.js";
|
|
14
14
|
import { folderSource } from "../door/map.js";
|
|
15
15
|
import { ownCredit } from "../door/own.js";
|
|
16
|
+
import { BODY_LABEL_ATTRIBUTES, bodyLabelText, loadMichroma, readBodyLabel } from "./body-label.js";
|
|
17
|
+
import { createSkyHost, SKY_ATTRIBUTES } from "../sky/host.js";
|
|
16
18
|
import { createGate, frameCap } from "./gate.js";
|
|
17
19
|
import { setSharedRenderer, setThreeLoader, takeRenderer } from "./shared.js";
|
|
18
20
|
export { setSharedRenderer, setThreeLoader };
|
|
@@ -128,7 +130,7 @@ export const readTime = (value) => {
|
|
|
128
130
|
* ```
|
|
129
131
|
*/
|
|
130
132
|
export class ChikyuEarthRealistic extends HTMLElement {
|
|
131
|
-
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", "air-thickness", "air-label", "lang"];
|
|
133
|
+
static observedAttributes = ["cloud-drift", "center", "time", "speed", "clouds", "lights", "light", "live-seconds", "tiles", "data", "camera", "immersive", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, "air-thickness", "air-label", "lang"];
|
|
132
134
|
#model = newModel();
|
|
133
135
|
#mode = "now";
|
|
134
136
|
#view;
|
|
@@ -158,6 +160,9 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
158
160
|
/** The page has set a `speed` since the element came into the page: for a reader who prefers reduced motion, that is the Play that lets meteors start. */
|
|
159
161
|
#played = false;
|
|
160
162
|
#note;
|
|
163
|
+
/** The names of the stars and the constellation lines (`star-names`, `constellation-lines`), and the look of the names. */
|
|
164
|
+
#sky;
|
|
165
|
+
#skyStyle = {};
|
|
161
166
|
#airNote;
|
|
162
167
|
#onContext = (state) => {
|
|
163
168
|
if (state === "unavailable")
|
|
@@ -178,6 +183,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
178
183
|
this.#model.camera = readCamera(this.getAttribute("camera"));
|
|
179
184
|
this.#model.cloudDrift = readDrift(this.getAttribute("cloud-drift"));
|
|
180
185
|
this.#model.airThickness = readAirThickness(this.getAttribute("air-thickness"));
|
|
186
|
+
this.#applyBodyLabel();
|
|
181
187
|
this.#door.book.ownOnly(this.getAttribute("data") === "own");
|
|
182
188
|
this.#model.speed = this.speed;
|
|
183
189
|
if (!this.hasAttribute("role"))
|
|
@@ -191,6 +197,14 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
191
197
|
this.#overlay = root.getElementById("overlay");
|
|
192
198
|
this.#note = root.getElementById("meteor-note");
|
|
193
199
|
this.#airNote = root.getElementById("air-note");
|
|
200
|
+
this.#sky = createSkyHost({
|
|
201
|
+
root,
|
|
202
|
+
attribute: (name) => this.getAttribute(name),
|
|
203
|
+
language: () => ((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en"),
|
|
204
|
+
onError: (error) => this.dispatchEvent(new CustomEvent("chikyu-sky-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
205
|
+
loadFont: loadMichroma,
|
|
206
|
+
});
|
|
207
|
+
this.#sky.setStyle(this.#skyStyle);
|
|
194
208
|
this.#played = false;
|
|
195
209
|
this.#model.meteors.on = this.#meteorsAsked();
|
|
196
210
|
this.#model.meteors.strength = readMeteorStrength(this.getAttribute("meteors-strength"));
|
|
@@ -230,6 +244,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
230
244
|
invalidate: () => this.#gate?.soon(),
|
|
231
245
|
onDraw: () => this.#gate?.drawn(),
|
|
232
246
|
onTiled: () => this.#door.announce(),
|
|
247
|
+
onSky: (sky) => this.#sky?.frame(sky),
|
|
248
|
+
onLabelError: (error) => this.dispatchEvent(new CustomEvent("chikyu-body-label-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
233
249
|
onPose: (pose) => {
|
|
234
250
|
if (this.#hands)
|
|
235
251
|
this.#hands.controller.grabRadius = discRadius(pose.width, pose.height, 1);
|
|
@@ -285,6 +301,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
285
301
|
this.#view = undefined;
|
|
286
302
|
this.#taken?.release();
|
|
287
303
|
this.#taken = undefined;
|
|
304
|
+
this.#sky?.dispose();
|
|
305
|
+
this.#sky = undefined;
|
|
288
306
|
}
|
|
289
307
|
attributeChangedCallback(name, _old, value) {
|
|
290
308
|
if (name === "center")
|
|
@@ -321,8 +339,17 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
321
339
|
this.#model.airThickness = readAirThickness(value);
|
|
322
340
|
this.#gate?.soon();
|
|
323
341
|
}
|
|
324
|
-
else if (name === "meteors-label" || name === "lang")
|
|
342
|
+
else if (name === "meteors-label" || name === "lang") {
|
|
325
343
|
this.#meteorNote();
|
|
344
|
+
if (name === "lang") {
|
|
345
|
+
this.#applyBodyLabel();
|
|
346
|
+
this.#sky?.refresh();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
else if (BODY_LABEL_ATTRIBUTES.includes(name))
|
|
350
|
+
this.#applyBodyLabel();
|
|
351
|
+
else if (SKY_ATTRIBUTES.includes(name))
|
|
352
|
+
this.#sky?.refresh();
|
|
326
353
|
if (name === "air-thickness" || name === "air-label" || name === "lang")
|
|
327
354
|
setAirNote(this.#airNote, this, this.#model.airThickness);
|
|
328
355
|
}
|
|
@@ -372,6 +399,53 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
372
399
|
set meteorsStrength(value) {
|
|
373
400
|
this.setAttribute("meteors-strength", String(value));
|
|
374
401
|
}
|
|
402
|
+
/**
|
|
403
|
+
* The name written on the Earth, as the family's body label: `EARTH` (`地球` on a Japanese page) laid on the globe so it turns with it, the surface showing through the letters. Off (`null`) unless the page sets it. The plain attributes are the family's:
|
|
404
|
+
* `body-label` (`painted`, `etched`, `outline` or `burned`; absent, no label), `body-label-strength` (0 to 1, 0.5), `body-label-repeat` (`once`, `both` or `around`), `body-label-latitude` (degrees), `body-label-facing` (present: always facing the reader),
|
|
405
|
+
* `body-label-font` (a CSS font family the page has loaded; Michroma, fetched once, when left out) and `body-label-fallback-font` (for letters the font has none of, such as Japanese). The property is the same options as an object, or `null`; setting it writes the attributes.
|
|
406
|
+
* Nothing of it is fetched or made until it is first set, it is not drawn while the Earth is under 24 pixels in radius, and nothing is drawn at rest. A three.js handed over with `setThreeLoader` must include `CanvasTexture`, `SphereGeometry`, `MeshLambertMaterial`, `SRGBColorSpace`, `NormalBlending`
|
|
407
|
+
* and `AdditiveBlending`; without them `chikyu-body-label-unavailable` is sent and the name is not drawn.
|
|
408
|
+
*/
|
|
409
|
+
get bodyLabel() {
|
|
410
|
+
return readBodyLabel((name) => this.getAttribute(name));
|
|
411
|
+
}
|
|
412
|
+
set bodyLabel(value) {
|
|
413
|
+
for (const name of BODY_LABEL_ATTRIBUTES)
|
|
414
|
+
this.removeAttribute(name);
|
|
415
|
+
if (value === null)
|
|
416
|
+
return;
|
|
417
|
+
this.setAttribute("body-label", value.look ?? "painted");
|
|
418
|
+
if (value.strength !== undefined)
|
|
419
|
+
this.setAttribute("body-label-strength", String(value.strength));
|
|
420
|
+
if (value.repeat !== undefined)
|
|
421
|
+
this.setAttribute("body-label-repeat", value.repeat);
|
|
422
|
+
if (value.latitude !== undefined)
|
|
423
|
+
this.setAttribute("body-label-latitude", String(value.latitude));
|
|
424
|
+
if (value.facing)
|
|
425
|
+
this.setAttribute("body-label-facing", "");
|
|
426
|
+
if (value.font)
|
|
427
|
+
this.setAttribute("body-label-font", value.font);
|
|
428
|
+
if (value.fallbackFont)
|
|
429
|
+
this.setAttribute("body-label-fallback-font", value.fallbackFont);
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
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
|
+
* 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 hoshi-stars `LabelStyle` (font, size, case, ring, leader and the rest).
|
|
435
|
+
*/
|
|
436
|
+
get skyStyle() {
|
|
437
|
+
return { ...this.#skyStyle };
|
|
438
|
+
}
|
|
439
|
+
set skyStyle(value) {
|
|
440
|
+
this.#skyStyle = { ...value };
|
|
441
|
+
this.#sky?.setStyle(this.#skyStyle);
|
|
442
|
+
}
|
|
443
|
+
/** Puts the name's settings and text right from the attributes (`body-label` and its family, `lang`). */
|
|
444
|
+
#applyBodyLabel() {
|
|
445
|
+
this.#model.bodyLabel.settings = readBodyLabel((name) => this.getAttribute(name));
|
|
446
|
+
this.#model.bodyLabel.text = bodyLabelText((this.closest("[lang]")?.getAttribute("lang") ?? "").toLowerCase().startsWith("ja") ? "ja" : "en");
|
|
447
|
+
this.#gate?.soon();
|
|
448
|
+
}
|
|
375
449
|
/** The controller behind the element's own hands (`set`, `fit`, `state`), while it is in a page. */
|
|
376
450
|
get controller() {
|
|
377
451
|
return this.#hands?.controller;
|
|
@@ -550,6 +624,8 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
550
624
|
canvas: stats?.canvas ?? { width: 0, height: 0, pixels: 0 },
|
|
551
625
|
assets: { entries: stats?.assets.entries ?? 0, refs: stats?.assets.refs ?? 0 },
|
|
552
626
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
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: "" },
|
|
553
629
|
};
|
|
554
630
|
}
|
|
555
631
|
/**
|
|
@@ -5,5 +5,6 @@ export { lookAt, discRadius, ATMOSPHERE_OUTER, cameraCentre, type CameraMode, ty
|
|
|
5
5
|
export type { ThreeParts } from "./earth.ts";
|
|
6
6
|
export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView, type TileCamera, type TileId, type TileLayer, type VisibleTile } from "./tiles.ts";
|
|
7
7
|
export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.ts";
|
|
8
|
+
export { BODY_LABEL_ATTRIBUTES, bodyLabelText, readBodyLabel, loadMichroma, setBodyLabelFontUrl, type BodyLabelSettings } from "./body-label.ts";
|
|
8
9
|
export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness, type AirSamples } from "./air.ts";
|
|
9
10
|
export { AIR_NOTE } from "./air-note.ts";
|
package/dist/realistic/index.js
CHANGED
|
@@ -6,5 +6,6 @@ export { createGate, frameCap } from "./gate.js";
|
|
|
6
6
|
export { lookAt, discRadius, ATMOSPHERE_OUTER, cameraCentre } from "./earth.js";
|
|
7
7
|
export { TEXEL_SLACK, coveringTile, parseManifest, pointOnEarth, tileColumns, tileLevel, tileRect, tileRows, tilesInView } from "./tiles.js";
|
|
8
8
|
export { TILE_KEEP_MS, TILE_LIMIT } from "./tile-set.js";
|
|
9
|
+
export { BODY_LABEL_ATTRIBUTES, bodyLabelText, readBodyLabel, loadMichroma, setBodyLabelFontUrl } from "./body-label.js";
|
|
9
10
|
export { AIR_QUALITY, AIR_THICKNESS_DEFAULT, AIR_THICKNESS_MAX, AIR_TOP, AIR_VERT, airFor, airFrag, airTop, readAirThickness } from "./air.js";
|
|
10
11
|
export { AIR_NOTE } from "./air-note.js";
|
|
@@ -17,6 +17,14 @@ export type ThreeParts = {
|
|
|
17
17
|
} & {
|
|
18
18
|
/** Only the satellites use it, so a loader that hands over a subset of three.js without it still draws everything else. */
|
|
19
19
|
Points?: typeof THREE.Points;
|
|
20
|
+
} & {
|
|
21
|
+
/** Only the name written on the Earth (`body-label`) uses these, so a subset of three.js without them still draws everything else. */
|
|
22
|
+
CanvasTexture?: typeof THREE.CanvasTexture;
|
|
23
|
+
SphereGeometry?: typeof THREE.SphereGeometry;
|
|
24
|
+
MeshLambertMaterial?: typeof THREE.MeshLambertMaterial;
|
|
25
|
+
SRGBColorSpace?: typeof THREE.SRGBColorSpace;
|
|
26
|
+
NormalBlending?: typeof THREE.NormalBlending;
|
|
27
|
+
AdditiveBlending?: typeof THREE.AdditiveBlending;
|
|
20
28
|
};
|
|
21
29
|
/** Milliseconds a lower texture size must be enough before the larger one is let go. */
|
|
22
30
|
export declare const DOWNGRADE_AFTER_MS = 4000;
|
|
@@ -30,6 +30,10 @@ export interface ParsedElements {
|
|
|
30
30
|
reason: string;
|
|
31
31
|
}[];
|
|
32
32
|
}
|
|
33
|
+
/** A record with the fields of an OMM, from text or numbers, or the reason it is not one. */
|
|
34
|
+
export declare function toElementSet(record: Record<string, unknown>): ElementSet | string;
|
|
35
|
+
/** The cells of one CSV line (a cell may be in double quotes, with `""` for a quote). */
|
|
36
|
+
export declare function cellsOf(line: string): string[];
|
|
33
37
|
/**
|
|
34
38
|
* Read element sets from text: OMM as JSON (an array or a single object), OMM as CSV (a header row, then one satellite a row) or TLE (two lines, or three with the name first). The format is found from the text.
|
|
35
39
|
* An element set that is missing a number, has a wrong TLE checksum or is not a possible orbit is left out, with the reason, in `skipped`. It throws if the text is none of the three.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const NUMBERS = ["MEAN_MOTION", "ECCENTRICITY", "INCLINATION", "RA_OF_ASC_NODE", "ARG_OF_PERICENTER", "MEAN_ANOMALY", "NORAD_CAT_ID", "BSTAR", "MEAN_MOTION_DOT", "MEAN_MOTION_DDOT"];
|
|
2
2
|
const OPTIONAL_NUMBERS = ["EPHEMERIS_TYPE", "ELEMENT_SET_NO", "REV_AT_EPOCH"];
|
|
3
3
|
/** A record with the fields of an OMM, from text or numbers, or the reason it is not one. */
|
|
4
|
-
function toElementSet(record) {
|
|
4
|
+
export function toElementSet(record) {
|
|
5
5
|
const out = {};
|
|
6
6
|
const name = typeof record["OBJECT_NAME"] === "string" ? record["OBJECT_NAME"].trim() : "";
|
|
7
7
|
out["OBJECT_NAME"] = name || `NORAD ${String(record["NORAD_CAT_ID"] ?? "?")}`;
|
|
@@ -47,7 +47,7 @@ function fromRecords(records, format) {
|
|
|
47
47
|
return { format, sets, skipped };
|
|
48
48
|
}
|
|
49
49
|
/** The cells of one CSV line (a cell may be in double quotes, with `""` for a quote). */
|
|
50
|
-
function cellsOf(line) {
|
|
50
|
+
export function cellsOf(line) {
|
|
51
51
|
const cells = [];
|
|
52
52
|
let at = 0;
|
|
53
53
|
while (at <= line.length) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { LabelStyle, ScreenPoint } from "@johnmorrisdotca/hoshi-stars/sky-labels";
|
|
2
|
+
/** 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
|
+
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
|
+
export interface SkyHost {
|
|
18
|
+
/** Tells where the sky falls in the picture just drawn, or `null` when there is no picture. */
|
|
19
|
+
frame(frame: SkyFrame | null): void;
|
|
20
|
+
/** What the settings are now (`star-names`, `star-names-magnitude`, `constellation-lines`, the language): read again after any of them changed. */
|
|
21
|
+
refresh(): void;
|
|
22
|
+
/** The look of the names, as a partial hoshi-stars `LabelStyle` (the property `skyStyle`). */
|
|
23
|
+
setStyle(style: Partial<LabelStyle>): void;
|
|
24
|
+
readonly stats: {
|
|
25
|
+
on: boolean;
|
|
26
|
+
loaded: boolean;
|
|
27
|
+
names: number;
|
|
28
|
+
figures: number;
|
|
29
|
+
picked: string | null;
|
|
30
|
+
renders: number;
|
|
31
|
+
lang: string;
|
|
32
|
+
};
|
|
33
|
+
dispose(): void;
|
|
34
|
+
}
|
|
35
|
+
export interface SkyHostOptions {
|
|
36
|
+
/** Reads one of the element's attributes. */
|
|
37
|
+
attribute(name: string): string | null;
|
|
38
|
+
/** The page's language, `en` or `ja`. */
|
|
39
|
+
language(): "en" | "ja";
|
|
40
|
+
/** The shadow root and its host. */
|
|
41
|
+
root: ShadowRoot;
|
|
42
|
+
/** Told when the layer could not be made (hoshi-stars is not installed, or its font did not load). */
|
|
43
|
+
onError(error: unknown): void;
|
|
44
|
+
/** Loads Michroma for the names, when the page has named no font of its own: kazoku-ui's `loadBodyLabelFont`. */
|
|
45
|
+
loadFont(): Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
/** The attributes this layer reads. */
|
|
48
|
+
export declare const SKY_ATTRIBUTES: readonly ["star-names", "star-names-magnitude", "constellation-lines"];
|
|
49
|
+
/**
|
|
50
|
+
* Makes the layer of one element, inside its shadow root. Nothing of hoshi-stars is loaded, and nothing is added to the root, until one of the three attributes is there.
|
|
51
|
+
*
|
|
52
|
+
* @param options - The attribute reader, the language and the shadow root.
|
|
53
|
+
* @returns The host.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSkyHost(options: SkyHostOptions): SkyHost;
|