@johnmorrisdotca/chikyu-earth 0.46.6 → 0.48.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 +14 -0
- package/README.md +3 -3
- package/dist/beam/layer.d.ts +1 -1
- package/dist/markers/place-layer.d.ts +4 -0
- package/dist/markers/place-layer.js +20 -6
- package/dist/place/index.d.ts +230 -0
- package/dist/place/index.js +183 -0
- package/dist/place/land.d.ts +30 -0
- package/dist/place/land.js +177 -0
- package/dist/place/water.d.ts +15 -0
- package/dist/place/water.js +63 -0
- package/dist/realistic/earth.d.ts +12 -1
- package/dist/realistic/earth.js +17 -1
- package/dist/realistic/element-base.d.ts +92 -0
- package/dist/realistic/element-base.js +179 -4
- package/dist/sky/claim.d.ts +4 -0
- package/dist/sky/claim.js +8 -0
- package/dist/sky/host.js +5 -0
- package/dist/space/element-base.d.ts +168 -2
- package/dist/space/element-base.js +402 -8
- package/dist/space/ephemeris.d.ts +1 -1
- package/dist/space/ephemeris.js +4 -2
- package/dist/space/follow.d.ts +36 -0
- package/dist/space/follow.js +46 -0
- package/dist/space/index.d.ts +1 -1
- package/dist/space/index.js +1 -0
- package/dist/space/path-controls.d.ts +56 -0
- package/dist/space/path-controls.js +121 -0
- package/dist/space/path-ribbons.d.ts +25 -0
- package/dist/space/path-ribbons.js +165 -0
- package/dist/space/paths.d.ts +119 -0
- package/dist/space/paths.js +163 -0
- package/dist/space/ride.d.ts +3 -2
- package/dist/space/ride.js +6 -4
- package/dist/space/satellite-hover.d.ts +47 -0
- package/dist/space/satellite-hover.js +183 -0
- package/dist/space/satellite-layer.d.ts +83 -2
- package/dist/space/satellite-layer.js +231 -52
- package/dist/space/satellite-model.d.ts +2 -1
- package/dist/space/satellite-model.js +4 -3
- package/dist/space/scene.d.ts +41 -0
- package/dist/space/scene.js +82 -13
- package/package.json +6 -1
|
@@ -32,6 +32,11 @@ import { MAX_TEXTURE } from "../realistic/tiers.js";
|
|
|
32
32
|
import { AU_IN_EARTH_RADII, EARTH_RADIUS_KM, frameAt } from "./ephemeris.js";
|
|
33
33
|
import { MAX_ORBIT_GROUP, readStreakMax } from "./satellite-layer.js";
|
|
34
34
|
import { applySatelliteFocus, satelliteEmphasis, satelliteGroupRows, shellRadiusOf, zoomForPerspectiveShell } from "./satellite-focus.js";
|
|
35
|
+
import { claimPress } from "../sky/claim.js";
|
|
36
|
+
import { bindPaths, emptyPathStats, pointerOf } from "./path-controls.js";
|
|
37
|
+
import { styleTable } from "./paths.js";
|
|
38
|
+
import { bindSatelliteHover, hoverPathOn, hoverStyleOf, namesOnHover as namesHoverOn } from "./satellite-hover.js";
|
|
39
|
+
import { clampFollow, retargetFollow } from "./follow.js";
|
|
35
40
|
import { RIDE_FACES, rideTiltLimits, rideTurnDegrees } from "./ride.js";
|
|
36
41
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
37
42
|
import { BODY_NAMES, createSpaceItem, DEFAULT_EARTH_SIZE, newSpaceModel } from "./scene.js";
|
|
@@ -101,7 +106,18 @@ const TIME_EVENT_MS = 250;
|
|
|
101
106
|
* Riding at a body looking at the Earth, the zoom only narrows the camera's field a little either way: 0.5 to 6.
|
|
102
107
|
*/
|
|
103
108
|
const LIMITS = { tiltMax: 90, zoomMin: 0.000001, zoomMax: 2.5 };
|
|
104
|
-
|
|
109
|
+
/** A number from an attribute, held between `min` and `max`; `null` when it is absent or not a number. */
|
|
110
|
+
function readFrame(value, min, max) {
|
|
111
|
+
if (value === null || value.trim() === "")
|
|
112
|
+
return null;
|
|
113
|
+
const number = Number(value);
|
|
114
|
+
return Number.isFinite(number) ? Math.min(max, Math.max(min, number)) : null;
|
|
115
|
+
}
|
|
116
|
+
/** An option's number held between `min` and `max`, or `undefined` when it is not given. */
|
|
117
|
+
function clampFrame(value, min, max) {
|
|
118
|
+
return typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, value)) : undefined;
|
|
119
|
+
}
|
|
120
|
+
const RIDE_ZOOM = { "zoom-min": "0.5", "zoom-max": "40" };
|
|
105
121
|
const readCentre = (value) => {
|
|
106
122
|
if (!value)
|
|
107
123
|
return null;
|
|
@@ -116,7 +132,7 @@ const readTime = (value) => {
|
|
|
116
132
|
const ms = Date.parse(value);
|
|
117
133
|
return Number.isFinite(ms) ? ms : "now";
|
|
118
134
|
};
|
|
119
|
-
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}${IMMERSIVE_STYLE}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-sat[hidden]{display:none}${PLACE_STYLE}${SKY_STYLE}${COUNTRY_NAMES_STYLE}${SEA_NAMES_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
135
|
+
const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:hidden;isolation:isolate}${IMMERSIVE_STYLE}#stage,#labels{position:absolute;inset:0}#labels{pointer-events:none;overflow:hidden}.sp-label{position:absolute;left:0;top:0;margin:0;padding:0;border:0;background:none;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-label:focus-visible{outline:2px solid #6cd0ff;outline-offset:2px;border-radius:4px}.sp-label::before{content:"";display:inline-block;width:5px;height:5px;margin:0 5px 1px -2px;border-radius:50%;background:#fff}.sp-label[hidden]{display:none}.sp-sat{position:absolute;left:0;top:0;font:12px/16px system-ui,-apple-system,sans-serif;color:#fff;white-space:nowrap;text-shadow:0 0 3px #000,0 0 3px #000;will-change:transform;pointer-events:none}.sp-sat[hidden]{display:none}.sp-sat[data-hover]{transition:opacity 180ms linear}@media (prefers-reduced-motion: reduce){.sp-sat[data-hover]{transition:none}}${PLACE_STYLE}${SKY_STYLE}${COUNTRY_NAMES_STYLE}${SEA_NAMES_STYLE}${CITY_NAMES_STYLE}${METEOR_NOTE_STYLE}${NOTES_STYLE}`;
|
|
120
136
|
/**
|
|
121
137
|
* 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.
|
|
122
138
|
*
|
|
@@ -161,7 +177,7 @@ const STYLE = `:host{display:block;aspect-ratio:1/1;position:relative;overflow:h
|
|
|
161
177
|
* ```
|
|
162
178
|
*/
|
|
163
179
|
export class ChikyuSpace extends HTMLElement {
|
|
164
|
-
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size"];
|
|
180
|
+
static observedAttributes = ["cloud-drift", "camera", "earth-size", "earth-x", "earth-y", "center", "time", "speed", "scale", "labels", "orbits", "bodies", "light", "meteors", "meteors-label", "meteors-strength", ...BODY_LABEL_ATTRIBUTES, ...SKY_ATTRIBUTES, ...CITY_NAMES_ATTRIBUTES, ...BORDER_ATTRIBUTES, ...GRID_ATTRIBUTES, ...BEAM_ATTRIBUTES, ...COUNTRY_NAMES_ATTRIBUTES, ...SEA_NAMES_ATTRIBUTES, "air-thickness", "air-label", "lang", "places", "places-look", "place-groups", "here-city", "route", "bodies-credit", "satellite-tint", "satellite-streak-max", "tiles", "tiles-finer", "tiles-finer-layer", "tiles-finer-date", "tiles-finer-timeout", "ride-viewpoint", "ride-model-size", "hover-path", "names-on-hover", "selected-path", "path-hit", "follow", "follow-ease", "dim-occluded", "ride-model-share", "ride-model-seat", "ride-zoom"];
|
|
165
181
|
#model = newSpaceModel();
|
|
166
182
|
/** The finer imagery (NASA's tile service), one source while the attributes stay the same. Off unless `tiles-finer="gibs"`. */
|
|
167
183
|
#finerHold = createFinerHolder(() => new Date(this.#model.time), () => this.#gate?.request());
|
|
@@ -204,6 +220,11 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
204
220
|
#pool = new Map();
|
|
205
221
|
#places;
|
|
206
222
|
#chosenLabel;
|
|
223
|
+
/** The name and the faint orbit while the pointer rests on a satellite. */
|
|
224
|
+
#hover;
|
|
225
|
+
#pathControls;
|
|
226
|
+
/** The ease of `follow` from one share to the next, if one is running. */
|
|
227
|
+
#followTimer;
|
|
207
228
|
#focusBeforeRide = "Earth";
|
|
208
229
|
/** The yaw, tilt and zoom from before a satellite group was framed, put back when the focus is cleared. */
|
|
209
230
|
#focusView = null;
|
|
@@ -276,6 +297,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
276
297
|
this.#placeLayer.set(this.#here.named(this.#placeList));
|
|
277
298
|
this.#placeLayer.look = readPlaceLook(this.getAttribute("places-look"));
|
|
278
299
|
this.#placeLayer.grouping = readPlaceGroups(this.getAttribute("place-groups"));
|
|
300
|
+
this.#dimOccluded = this.getAttribute("dim-occluded") !== "off";
|
|
301
|
+
this.#placeLayer.dimOccluded = this.#dimOccluded;
|
|
279
302
|
this.#cities = createCityHost({
|
|
280
303
|
root,
|
|
281
304
|
attribute: (name) => this.getAttribute(name),
|
|
@@ -341,6 +364,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
341
364
|
onLabelError: (error) => this.dispatchEvent(new CustomEvent("chikyu-body-label-unavailable", { detail: { reason: error instanceof Error ? error.message : String(error) } })),
|
|
342
365
|
onSatelliteMarks: (marks) => this.#showMarks(marks),
|
|
343
366
|
onSelected: (place) => this.#placeChosen(place),
|
|
367
|
+
onHover: (place) => this.#hover?.follow(place),
|
|
344
368
|
onMoving: () => this.#gate?.request(),
|
|
345
369
|
onRideLost: () => this.#rideLost(),
|
|
346
370
|
onPlaceRings: (drawn) => this.#ringsDrawn(drawn),
|
|
@@ -373,6 +397,29 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
373
397
|
this.#last = performance.now();
|
|
374
398
|
this.#schedule();
|
|
375
399
|
this.addEventListener("pointerdown", this.#down);
|
|
400
|
+
this.#hover = bindSatelliteHover({
|
|
401
|
+
element: this,
|
|
402
|
+
state: this.#model.satellites,
|
|
403
|
+
pick: (x, y) => this.#model.pick?.(x, y, 12) ?? null,
|
|
404
|
+
place: (ref) => this.placeSatellite(ref),
|
|
405
|
+
name: (ref) => this.satelliteInfo(ref)?.name,
|
|
406
|
+
selected: () => this.selectedSatellite,
|
|
407
|
+
request: () => this.#gate?.request(),
|
|
408
|
+
labelParent: () => this.#labelBox ?? null,
|
|
409
|
+
pathOn: () => hoverPathOn(this.getAttribute("hover-path"), this.getAttribute("names-on-hover")),
|
|
410
|
+
namesOn: () => namesHoverOn(this.getAttribute("names-on-hover")),
|
|
411
|
+
style: () => hoverStyleOf(this),
|
|
412
|
+
});
|
|
413
|
+
this.#hover.sync();
|
|
414
|
+
this.#pathControls = bindPaths({
|
|
415
|
+
element: this,
|
|
416
|
+
state: this.#model.satellites,
|
|
417
|
+
request: () => this.#gate?.request(),
|
|
418
|
+
pathAt: (x, y, radius) => this.#model.pathAt?.(x, y, radius) ?? null,
|
|
419
|
+
pick: (x, y) => this.#model.pick?.(x, y, 12) ?? null,
|
|
420
|
+
riding: () => this.#model.ride !== null,
|
|
421
|
+
});
|
|
422
|
+
this.#pathControls.sync();
|
|
376
423
|
// before the shared hands (which hear it after this): a plain wheel in an immersive view zooms
|
|
377
424
|
this.addEventListener("wheel", this.#wheel, { capture: true, passive: false });
|
|
378
425
|
this.addEventListener("keydown", this.#faceKey);
|
|
@@ -390,12 +437,18 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
390
437
|
this.#hands?.unbind();
|
|
391
438
|
this.#hands = undefined;
|
|
392
439
|
this.#zoomRange(false);
|
|
440
|
+
this.#hover?.stop();
|
|
441
|
+
this.#hover = undefined;
|
|
442
|
+
this.#pathControls?.stop();
|
|
443
|
+
this.#pathControls = undefined;
|
|
393
444
|
this.removeEventListener("pointerdown", this.#down);
|
|
394
445
|
this.removeEventListener("wheel", this.#wheel, { capture: true });
|
|
395
446
|
this.removeEventListener("keydown", this.#faceKey);
|
|
396
447
|
window.removeEventListener("pointerup", this.#up, true);
|
|
397
448
|
clearTimeout(this.#timer);
|
|
398
449
|
this.#timer = undefined;
|
|
450
|
+
clearTimeout(this.#followTimer);
|
|
451
|
+
this.#followTimer = undefined;
|
|
399
452
|
this.#gate?.cancel();
|
|
400
453
|
this.#view?.dispose();
|
|
401
454
|
this.#view = undefined;
|
|
@@ -419,6 +472,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
419
472
|
this.#applyViewpoint();
|
|
420
473
|
else if (name === "ride-model-size")
|
|
421
474
|
this.#applyModelSize();
|
|
475
|
+
else if (name === "ride-model-share" || name === "ride-model-seat")
|
|
476
|
+
this.#applyFrame();
|
|
477
|
+
else if (name === "ride-zoom")
|
|
478
|
+
this.#applyRideZoom();
|
|
422
479
|
else if (name === "center")
|
|
423
480
|
this.centre = readCentre(value) ?? { lon: 0, lat: 0 };
|
|
424
481
|
else if (name === "time")
|
|
@@ -435,6 +492,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
435
492
|
this.bodies = value ?? "";
|
|
436
493
|
else if (name === "light")
|
|
437
494
|
this.light = readLight(value);
|
|
495
|
+
else if (name === "dim-occluded")
|
|
496
|
+
this.dimOccluded = value !== "off";
|
|
438
497
|
else if (name === "camera")
|
|
439
498
|
this.camera = readCamera(value);
|
|
440
499
|
else if (name === "cloud-drift") {
|
|
@@ -517,6 +576,15 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
517
576
|
this.#model.satellites.orbitTint = value === "orbit";
|
|
518
577
|
this.#gate?.request();
|
|
519
578
|
}
|
|
579
|
+
else if (name === "hover-path" || name === "names-on-hover")
|
|
580
|
+
this.#hover?.sync();
|
|
581
|
+
else if (name === "selected-path")
|
|
582
|
+
this.#pathControls?.sync();
|
|
583
|
+
else if (name === "path-hit") {
|
|
584
|
+
/* read at each press and move */
|
|
585
|
+
}
|
|
586
|
+
else if (name === "follow")
|
|
587
|
+
this.#easeFollow(clampFollow(Number(value)));
|
|
520
588
|
else if (name === "satellite-streak-max") {
|
|
521
589
|
this.#model.satellites.streakMax = readStreakMax(value);
|
|
522
590
|
this.#gate?.request();
|
|
@@ -876,7 +944,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
876
944
|
/** Lays the places on the picture just drawn, clear of the bodies' names shown beside it. */
|
|
877
945
|
#drawPlaces(view) {
|
|
878
946
|
const layer = this.#placeLayer;
|
|
879
|
-
if (!layer || (this.#placeList.length === 0 && this.#marks.length === 0 && layer.stats.shown === 0 && layer.stats.rings === 0))
|
|
947
|
+
if (!layer || (this.#placeList.length === 0 && this.#marks.length === 0 && layer.stats.shown === 0 && layer.stats.rings === 0 && layer.stats.satelliteNames === 0))
|
|
880
948
|
return;
|
|
881
949
|
layer.frame(view, this.#bodyNameBoxes(), this.#marks, this.#model.light === "lit" ? null : subsolarPoint(this.#model.time));
|
|
882
950
|
this.#notePlacesLost();
|
|
@@ -1156,6 +1224,81 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1156
1224
|
this.#model.cameraSpin = null;
|
|
1157
1225
|
this.#gate?.request();
|
|
1158
1226
|
}
|
|
1227
|
+
/**
|
|
1228
|
+
* How much of the Earth's turn the space camera takes, from 0 to 1. 0, the default, holds the stars: the Earth turns beneath the camera, which is what `camera="space"` already does, so a page that sets nothing keeps that.
|
|
1229
|
+
* 1 turns with the Earth, so the ground under the middle stays. A value between takes that share of the turn. Changing it does not move the longitude under the middle. `follow-ease` is how many seconds the change takes (0.4 when left out, 0 for none; at once when the reader asks for reduced motion). It asks for no frame of its own once the change has settled, and none while the clock is stopped.
|
|
1230
|
+
*/
|
|
1231
|
+
get follow() {
|
|
1232
|
+
return clampFollow(Number(this.getAttribute("follow")));
|
|
1233
|
+
}
|
|
1234
|
+
set follow(value) {
|
|
1235
|
+
const next = clampFollow(value);
|
|
1236
|
+
const text = String(next);
|
|
1237
|
+
if (this.getAttribute("follow") === text)
|
|
1238
|
+
this.#easeFollow(next);
|
|
1239
|
+
else
|
|
1240
|
+
this.setAttribute("follow", text);
|
|
1241
|
+
}
|
|
1242
|
+
/** Seconds `follow` takes to change. Left out, 0.4. `0` changes at once. */
|
|
1243
|
+
get followEase() {
|
|
1244
|
+
const raw = this.getAttribute("follow-ease");
|
|
1245
|
+
if (raw === null || raw === "")
|
|
1246
|
+
return 0.4;
|
|
1247
|
+
const value = Number(raw);
|
|
1248
|
+
return Number.isFinite(value) && value > 0 ? value : 0;
|
|
1249
|
+
}
|
|
1250
|
+
set followEase(value) {
|
|
1251
|
+
this.setAttribute("follow-ease", String(value));
|
|
1252
|
+
}
|
|
1253
|
+
/** The longitude, in degrees, under the middle of the view, or null before the first draw. */
|
|
1254
|
+
get centreLongitude() {
|
|
1255
|
+
const base = this.#model.lookBase;
|
|
1256
|
+
if (!base)
|
|
1257
|
+
return null;
|
|
1258
|
+
return ((((base.lon - this.#model.view.yaw) % 360) + 540) % 360) - 180;
|
|
1259
|
+
}
|
|
1260
|
+
/** The moment of the last draw, in milliseconds, or null before the first. The longitude under the middle belongs to this moment. */
|
|
1261
|
+
get shownTime() {
|
|
1262
|
+
return this.#model.drawn?.frame.ms ?? null;
|
|
1263
|
+
}
|
|
1264
|
+
/** Move `follow` to `next`, keeping the longitude under the middle, and ask for the frames of the ease. */
|
|
1265
|
+
#easeFollow(next) {
|
|
1266
|
+
if (this.#followTimer !== undefined) {
|
|
1267
|
+
clearTimeout(this.#followTimer);
|
|
1268
|
+
this.#followTimer = undefined;
|
|
1269
|
+
}
|
|
1270
|
+
const to = clampFollow(next);
|
|
1271
|
+
const from = this.#model.follow;
|
|
1272
|
+
const seconds = prefersLessMotion() ? 0 : this.followEase;
|
|
1273
|
+
if (!(seconds > 0) || to === from) {
|
|
1274
|
+
this.#applyFollow(to);
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
const started = performance.now();
|
|
1278
|
+
const step = () => {
|
|
1279
|
+
const t = Math.min(1, (performance.now() - started) / (seconds * 1000));
|
|
1280
|
+
const eased = t * t * (3 - 2 * t);
|
|
1281
|
+
this.#applyFollow(from + (to - from) * eased);
|
|
1282
|
+
if (t < 1 && this.isConnected)
|
|
1283
|
+
this.#followTimer = setTimeout(step, 32);
|
|
1284
|
+
else
|
|
1285
|
+
this.#followTimer = undefined;
|
|
1286
|
+
};
|
|
1287
|
+
step();
|
|
1288
|
+
}
|
|
1289
|
+
#applyFollow(value) {
|
|
1290
|
+
const spin = this.#model.drawn?.frame.spin;
|
|
1291
|
+
if (this.#model.camera === "space" && this.#model.cameraSpin !== null && spin !== undefined) {
|
|
1292
|
+
const turned = retargetFollow(this.#model.cameraSpin, spin, this.#model.follow, value, this.#model.view.yaw);
|
|
1293
|
+
this.#model.cameraSpin = turned.anchor;
|
|
1294
|
+
if (turned.yaw !== this.#model.view.yaw) {
|
|
1295
|
+
this.#model.view = { ...this.#model.view, yaw: turned.yaw };
|
|
1296
|
+
this.#controls()?.set({ yaw: turned.yaw, tilt: this.#model.view.tilt, zoom: this.#model.view.zoom }, value === this.follow, "follow");
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
this.#model.follow = clampFollow(value);
|
|
1300
|
+
this.#gate?.request();
|
|
1301
|
+
}
|
|
1159
1302
|
/** The share of the view's shorter side the Earth's disc fills at zoom 1 (the `earth-size` attribute): 0.9 by default, so the atmosphere's glow is never cut at any shape of box. Above 1 the Earth is larger than the view. */
|
|
1160
1303
|
get earthSize() {
|
|
1161
1304
|
return this.#model.earth.size;
|
|
@@ -1241,6 +1384,30 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1241
1384
|
this.#showBodiesCredit();
|
|
1242
1385
|
this.#gate?.request();
|
|
1243
1386
|
}
|
|
1387
|
+
#dimOccluded = true;
|
|
1388
|
+
/**
|
|
1389
|
+
* Dim the name of a satellite the Earth hides, and leave its ring off (the attribute `dim-occluded`). On by default. `off` leaves that name out.
|
|
1390
|
+
*
|
|
1391
|
+
* @example
|
|
1392
|
+
* ```ts
|
|
1393
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1394
|
+
*
|
|
1395
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1396
|
+
* space.dimOccluded = false;
|
|
1397
|
+
* console.log(space.dimOccluded);
|
|
1398
|
+
* ```
|
|
1399
|
+
*/
|
|
1400
|
+
get dimOccluded() {
|
|
1401
|
+
return this.#dimOccluded;
|
|
1402
|
+
}
|
|
1403
|
+
set dimOccluded(value) {
|
|
1404
|
+
if (value === this.#dimOccluded)
|
|
1405
|
+
return;
|
|
1406
|
+
this.#dimOccluded = value;
|
|
1407
|
+
if (this.#placeLayer)
|
|
1408
|
+
this.#placeLayer.dimOccluded = value;
|
|
1409
|
+
this.#gate?.request();
|
|
1410
|
+
}
|
|
1244
1411
|
/** How the Earth is lit: `sun` (true, the default), `lit` (always lit, as if by daylight from the camera's side, so a ride on the night side is never a black frame) or `boost` (the true terminator, with the night side raised). The Sun, the Moon and the planets keep their true places. */
|
|
1245
1412
|
get light() {
|
|
1246
1413
|
return this.#model.light;
|
|
@@ -1330,6 +1497,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1330
1497
|
const model = this.#model;
|
|
1331
1498
|
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1332
1499
|
const wasRiding = model.ride !== null;
|
|
1500
|
+
model.rideFrame.share = clampFrame(options.modelShare, 0.02, 1.2) ?? this.rideModelShare;
|
|
1501
|
+
model.rideFrame.seat = clampFrame(options.modelSeat, 0.5, 1.4) ?? this.rideModelSeat;
|
|
1502
|
+
model.rideFrame.ms = reduced ? 0 : 400;
|
|
1503
|
+
model.rideFrame.fresh = true;
|
|
1333
1504
|
if (target === null) {
|
|
1334
1505
|
model.ride = null;
|
|
1335
1506
|
model.rideTurn = 0;
|
|
@@ -1521,6 +1692,99 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1521
1692
|
this.#gate?.request();
|
|
1522
1693
|
this.dispatchEvent(new CustomEvent("chikyu-ride", { detail: this.riding }));
|
|
1523
1694
|
}
|
|
1695
|
+
/**
|
|
1696
|
+
* The radius of the ridden satellite's model as a share of the picture's height, 0.02 to 1.2 (the attribute `ride-model-share`), or `null` for the ride's own: 0.22 along the way it goes, 0.17 above the satellite (its size at the lowest height; `ride-model-size="distance"` still shrinks it as the ride rises).
|
|
1697
|
+
* Set while riding it glides in 0.4 s (at once for a reader who asked for less motion). `stats.followModel.share` is the share in use.
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* ```ts
|
|
1701
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1702
|
+
*
|
|
1703
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1704
|
+
* space.rideModelShare = 0.4;
|
|
1705
|
+
* console.log(space.rideModelShare);
|
|
1706
|
+
* ```
|
|
1707
|
+
*/
|
|
1708
|
+
get rideModelShare() {
|
|
1709
|
+
return readFrame(this.getAttribute("ride-model-share"), 0.02, 1.2);
|
|
1710
|
+
}
|
|
1711
|
+
set rideModelShare(value) {
|
|
1712
|
+
if (value === null || !Number.isFinite(value))
|
|
1713
|
+
this.removeAttribute("ride-model-share");
|
|
1714
|
+
else
|
|
1715
|
+
this.setAttribute("ride-model-share", String(value));
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Where the middle of the ridden model sits in a ride along the way it goes, as a share of the picture's height from the top, 0.5 to 1.4 (the attribute `ride-model-seat`; 0.5 the middle, 1 the bottom edge), or `null` for the ride's own (0.86). The camera moves to keep the satellite there.
|
|
1719
|
+
* Set while riding it glides in 0.4 s (at once for a reader who asked for less motion). `stats.followModel.seat` is the seat in use.
|
|
1720
|
+
*
|
|
1721
|
+
* @example
|
|
1722
|
+
* ```ts
|
|
1723
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1724
|
+
*
|
|
1725
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1726
|
+
* space.rideModelSeat = 1;
|
|
1727
|
+
* console.log(space.rideModelSeat);
|
|
1728
|
+
* ```
|
|
1729
|
+
*/
|
|
1730
|
+
get rideModelSeat() {
|
|
1731
|
+
return readFrame(this.getAttribute("ride-model-seat"), 0.5, 1.4);
|
|
1732
|
+
}
|
|
1733
|
+
set rideModelSeat(value) {
|
|
1734
|
+
if (value === null || !Number.isFinite(value))
|
|
1735
|
+
this.removeAttribute("ride-model-seat");
|
|
1736
|
+
else
|
|
1737
|
+
this.setAttribute("ride-model-seat", String(value));
|
|
1738
|
+
}
|
|
1739
|
+
#applyFrame() {
|
|
1740
|
+
const frame = this.#model.rideFrame;
|
|
1741
|
+
frame.share = this.rideModelShare;
|
|
1742
|
+
frame.seat = this.rideModelSeat;
|
|
1743
|
+
frame.ms = prefersLessMotion() ? 0 : 400;
|
|
1744
|
+
this.#schedule();
|
|
1745
|
+
this.#gate?.request();
|
|
1746
|
+
}
|
|
1747
|
+
/**
|
|
1748
|
+
* The zoom of a ride, 0.5 to 40 (the attribute `ride-zoom`): the field of view is 60 degrees over it from the satellite, so 40 looks at 1.5 degrees of the ground below. Set while riding the view glides in 0.4 s (at once for a reader who asked for less motion).
|
|
1749
|
+
* It is the shared controls' zoom, so their pinch, wheel and keys move it too. `stats.ride.groundKm` says how many kilometres of ground the picture spans, to stop where the tiles stop being sharp.
|
|
1750
|
+
*
|
|
1751
|
+
* @example
|
|
1752
|
+
* ```ts
|
|
1753
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
1754
|
+
*
|
|
1755
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
1756
|
+
* space.rideZoom = 8;
|
|
1757
|
+
* console.log(space.rideZoom);
|
|
1758
|
+
* ```
|
|
1759
|
+
*/
|
|
1760
|
+
get rideZoom() {
|
|
1761
|
+
return this.#model.view.zoom;
|
|
1762
|
+
}
|
|
1763
|
+
set rideZoom(value) {
|
|
1764
|
+
if (Number.isFinite(value))
|
|
1765
|
+
this.setAttribute("ride-zoom", String(value));
|
|
1766
|
+
}
|
|
1767
|
+
#applyRideZoom() {
|
|
1768
|
+
const wanted = readFrame(this.getAttribute("ride-zoom"), 0.5, 40);
|
|
1769
|
+
if (wanted === null)
|
|
1770
|
+
return;
|
|
1771
|
+
const model = this.#model;
|
|
1772
|
+
if (Math.abs(wanted - model.view.zoom) < 1e-9)
|
|
1773
|
+
return;
|
|
1774
|
+
const pose = model.pose;
|
|
1775
|
+
const glide = model.ride !== null && !prefersLessMotion() && pose.valid;
|
|
1776
|
+
if (glide)
|
|
1777
|
+
model.transition = { start: performance.now(), duration: 400, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } };
|
|
1778
|
+
const next = { yaw: model.view.yaw, tilt: model.view.tilt, zoom: wanted };
|
|
1779
|
+
const controls = this.#controls();
|
|
1780
|
+
if (controls)
|
|
1781
|
+
controls.set(next, true, "ride");
|
|
1782
|
+
else
|
|
1783
|
+
this.setView(next);
|
|
1784
|
+
this.#last = performance.now();
|
|
1785
|
+
this.#schedule();
|
|
1786
|
+
this.#gate?.request();
|
|
1787
|
+
}
|
|
1524
1788
|
#applyViewpoint() {
|
|
1525
1789
|
const model = this.#model;
|
|
1526
1790
|
const ride = model.ride;
|
|
@@ -1530,6 +1794,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1530
1794
|
const reduced = typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
1531
1795
|
const pose = model.pose;
|
|
1532
1796
|
model.ride = { ...ride, viewpoint: next };
|
|
1797
|
+
model.rideFrame.ms = reduced ? 0 : 400;
|
|
1533
1798
|
model.transition = !reduced && pose.valid ? { start: performance.now(), duration: 1200, from: { p: [pose.p[0], pose.p[1], pose.p[2]], q: [pose.q[0], pose.q[1], pose.q[2], pose.q[3]], fov: pose.fov } } : null;
|
|
1534
1799
|
this.#last = performance.now();
|
|
1535
1800
|
this.#schedule();
|
|
@@ -1620,6 +1885,10 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1620
1885
|
this.#restoreFocusView();
|
|
1621
1886
|
this.dispatchEvent(new CustomEvent("chikyu-satellite-focus", { detail: { group: null, count: 0 }, bubbles: true, composed: true }));
|
|
1622
1887
|
}
|
|
1888
|
+
if (this.#model.satellites.hover.ref?.group === group) {
|
|
1889
|
+
this.#model.satellites.hover.ref = null;
|
|
1890
|
+
this.#model.satellites.hover.fade = 0;
|
|
1891
|
+
}
|
|
1623
1892
|
}
|
|
1624
1893
|
else {
|
|
1625
1894
|
const was = groups.get(group);
|
|
@@ -1708,6 +1977,29 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1708
1977
|
else
|
|
1709
1978
|
this.setView(view, true);
|
|
1710
1979
|
}
|
|
1980
|
+
/**
|
|
1981
|
+
* Draw a faint orbit while the pointer rests on a satellite. On unless `hover-path="off"`. Left unset, it is on when `names-on-hover` is on.
|
|
1982
|
+
* The colour and the opacity are the custom properties `--chikyu-hover-path` and `--chikyu-hover-path-opacity`.
|
|
1983
|
+
*/
|
|
1984
|
+
get hoverPath() {
|
|
1985
|
+
return hoverPathOn(this.getAttribute("hover-path"), this.getAttribute("names-on-hover"));
|
|
1986
|
+
}
|
|
1987
|
+
set hoverPath(value) {
|
|
1988
|
+
if (value)
|
|
1989
|
+
this.setAttribute("hover-path", "");
|
|
1990
|
+
else
|
|
1991
|
+
this.setAttribute("hover-path", "off");
|
|
1992
|
+
}
|
|
1993
|
+
/** Show a satellite's name while the pointer rests on it. On unless `names-on-hover="off"`. A touch does not rest, so it shows nothing. */
|
|
1994
|
+
get namesOnHover() {
|
|
1995
|
+
return namesHoverOn(this.getAttribute("names-on-hover"));
|
|
1996
|
+
}
|
|
1997
|
+
set namesOnHover(value) {
|
|
1998
|
+
if (value)
|
|
1999
|
+
this.removeAttribute("names-on-hover");
|
|
2000
|
+
else
|
|
2001
|
+
this.setAttribute("names-on-hover", "off");
|
|
2002
|
+
}
|
|
1711
2003
|
/** Mark one satellite: a larger ring round it, its orbit drawn, and its name beside it. `null` lets it go. */
|
|
1712
2004
|
selectSatellite(ref) {
|
|
1713
2005
|
const found = ref ? this.#model.satellites.groups.get(ref.group) : undefined;
|
|
@@ -1721,6 +2013,102 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1721
2013
|
const chosen = this.#model.satellites.selected;
|
|
1722
2014
|
return chosen ? { ...chosen } : null;
|
|
1723
2015
|
}
|
|
2016
|
+
// --- paths -------------------------------------------------------------------------------------------------------------------------------------
|
|
2017
|
+
/**
|
|
2018
|
+
* Draw these satellites' orbits at once, each in a look from the table (`pathStyles`), without a satellite being chosen. One draw call for all of them and the chosen satellite's own orbit, and nothing is drawn at rest. At most 16 are kept, the last of the list.
|
|
2019
|
+
* `id` is a NORAD catalogue number or `group:index` (`stations:0`); an id that matches no satellite is skipped (`stats.paths.unresolved`). A satellite asked for twice is drawn once, in the later look. `style` is the name of a look (`selected`, `hovered`, `favourite`, `path`, or one of the page's own)
|
|
2020
|
+
* or a partial look over `path`. `[]` takes them all away. Where the pointer is on one, `chikyu-path-hover` and `chikyu-path-click` say which (`path-hit`).
|
|
2021
|
+
*
|
|
2022
|
+
* @param list - The paths, oldest first.
|
|
2023
|
+
*
|
|
2024
|
+
* @example
|
|
2025
|
+
* ```ts
|
|
2026
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
2027
|
+
*
|
|
2028
|
+
* const show = (space: ChikyuSpace): void => space.setPaths([{ id: 25544, style: "favourite" }, { id: "stations:1", style: { color: "#7fdbff", dash: [8, 4] } }]);
|
|
2029
|
+
* console.log(typeof show);
|
|
2030
|
+
* ```
|
|
2031
|
+
*/
|
|
2032
|
+
setPaths(list) {
|
|
2033
|
+
this.#pathControls?.setPaths(list);
|
|
2034
|
+
}
|
|
2035
|
+
/** The paths in use, as set (the last 16). Setting it is `setPaths`. */
|
|
2036
|
+
get paths() {
|
|
2037
|
+
return this.#pathControls?.paths ?? [];
|
|
2038
|
+
}
|
|
2039
|
+
set paths(list) {
|
|
2040
|
+
this.setPaths(list);
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Change the looks the paths are drawn in, by name. Each entry is a partial look over the built-in one of that name (or over `path`, for a name of the page's own); `null` takes the page's entry away. Without `replace` the entries are added to those already set.
|
|
2044
|
+
* The built-in looks differ by width and dash as well as colour: `selected` (white, 2 px, solid, also the look of the chosen satellite's own orbit), `hovered` (white, 1.5 px, dashed), `favourite` (amber, 1.75 px, dotted) and `path` (white, 1.5 px, solid).
|
|
2045
|
+
* A look is `{ color, width (0.5 to 8 CSS pixels), opacity (0 to 1), dash ([dash, gap] in CSS pixels, or null) }`.
|
|
2046
|
+
*
|
|
2047
|
+
* @param table - The entries by name.
|
|
2048
|
+
* @param replace - `true` to drop the entries set before.
|
|
2049
|
+
*
|
|
2050
|
+
* @example
|
|
2051
|
+
* ```ts
|
|
2052
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
2053
|
+
*
|
|
2054
|
+
* const quiet = (space: ChikyuSpace): void => space.setPathStyles({ selected: { color: "#ffd166", width: 3, dash: null } });
|
|
2055
|
+
* console.log(typeof quiet);
|
|
2056
|
+
* ```
|
|
2057
|
+
*/
|
|
2058
|
+
setPathStyles(table, replace = false) {
|
|
2059
|
+
this.#pathControls?.setStyles(table, replace);
|
|
2060
|
+
}
|
|
2061
|
+
/** The table of looks in use, whole: the built-in ones with the page's own over them. A copy. */
|
|
2062
|
+
get pathStyles() {
|
|
2063
|
+
return this.#pathControls?.styles ?? styleTable({});
|
|
2064
|
+
}
|
|
2065
|
+
set pathStyles(table) {
|
|
2066
|
+
this.setPathStyles(table, true);
|
|
2067
|
+
}
|
|
2068
|
+
/**
|
|
2069
|
+
* Draw the chosen satellite's own orbit (the attribute `selected-path`; on unless `off`). Off, `selectSatellite` still rings and names the satellite and a ride still follows it, but no line is drawn: the page draws it, with `setPaths` and the `selected` look, or its own. The look of the line when it is on is the `selected` entry of `pathStyles`.
|
|
2070
|
+
*/
|
|
2071
|
+
get selectedPath() {
|
|
2072
|
+
return this.getAttribute("selected-path") !== "off";
|
|
2073
|
+
}
|
|
2074
|
+
set selectedPath(value) {
|
|
2075
|
+
if (value)
|
|
2076
|
+
this.removeAttribute("selected-path");
|
|
2077
|
+
else
|
|
2078
|
+
this.setAttribute("selected-path", "off");
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* How near, in CSS pixels, the pointer has to be to a path for the pick and hover events to report it (the attribute `path-hit`; 8 when left out, 0 to 40; `0` or `off` turns the test off). A touch is given twice that, and at least 16.
|
|
2082
|
+
* The test covers the page's paths and the chosen satellite's own orbit, not the part of an orbit the Earth hides, and a satellite's dot under the pointer comes first. In a ride from a satellite the test is off unless the attribute is set.
|
|
2083
|
+
*/
|
|
2084
|
+
get pathHit() {
|
|
2085
|
+
return this.#pathControls?.hit ?? 8;
|
|
2086
|
+
}
|
|
2087
|
+
set pathHit(value) {
|
|
2088
|
+
if (Number.isFinite(value) && value >= 0)
|
|
2089
|
+
this.setAttribute("path-hit", String(value));
|
|
2090
|
+
else
|
|
2091
|
+
this.removeAttribute("path-hit");
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* The path under a point of the element, from the last draw: its id as given, the satellite (`ref`, the same shape as in `chikyu-satellite-click`), the name of its look, the nearest point on it and the distance to it, or `null`.
|
|
2095
|
+
*
|
|
2096
|
+
* @param x - CSS pixels from the element's left.
|
|
2097
|
+
* @param y - CSS pixels from its top.
|
|
2098
|
+
* @param radiusPx - How near the point must be, 0 to 200; `path-hit` when left out.
|
|
2099
|
+
* @returns The path, or `null` when none is within reach.
|
|
2100
|
+
*
|
|
2101
|
+
* @example
|
|
2102
|
+
* ```ts
|
|
2103
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space";
|
|
2104
|
+
*
|
|
2105
|
+
* const name = (space: ChikyuSpace, x: number, y: number): string => space.pathAt(x, y, 10)?.style ?? "none";
|
|
2106
|
+
* console.log(typeof name);
|
|
2107
|
+
* ```
|
|
2108
|
+
*/
|
|
2109
|
+
pathAt(x, y, radiusPx) {
|
|
2110
|
+
return this.#pathControls?.at(x, y, radiusPx) ?? null;
|
|
2111
|
+
}
|
|
1724
2112
|
/**
|
|
1725
2113
|
* 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.
|
|
1726
2114
|
* 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).
|
|
@@ -1762,7 +2150,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1762
2150
|
this.#gate?.request();
|
|
1763
2151
|
}
|
|
1764
2152
|
/**
|
|
1765
|
-
* Where a satellite is on the screen as of the last draw: `{ x, y, visible, heightKm, edge, behind }` in CSS pixels from the view's top left. `visible` means it is inside the box, in front of the camera and not behind the Earth. `edge` is `top`, `right`, `bottom` or `left` when the place lies beyond that edge, and `null` when it is inside the box. `behind` is true when it is behind the camera (the picture would mirror it, so `edge` is read from the camera's own axes). `x` and `y` may lie outside the box. `null` when its group is not set or not shown, or it cannot be placed (its elements are too old). 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, or a mark on the edge, need not repeat either.
|
|
2153
|
+
* Where a satellite is on the screen as of the last draw: `{ x, y, visible, heightKm, edge, behind, occluded }` in CSS pixels from the view's top left. `visible` means it is inside the box, in front of the camera and not behind the Earth. `edge` is `top`, `right`, `bottom` or `left` when the place lies beyond that edge, and `null` when it is inside the box. `behind` is true when it is behind the camera (the picture would mirror it, so `edge` is read from the camera's own axes). `occluded` is true when the Earth hides the satellite and false at the limb, in front, and when it is only behind the camera. `x` and `y` may lie outside the box. `null` when its group is not set or not shown, or it cannot be placed (its elements are too old). 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, or a mark on the edge, need not repeat either.
|
|
1766
2154
|
*/
|
|
1767
2155
|
placeSatellite(ref) {
|
|
1768
2156
|
return this.#model.placeSatellite?.(ref) ?? null;
|
|
@@ -1802,7 +2190,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1802
2190
|
const ridden = this.#model.satellites.modelOver;
|
|
1803
2191
|
if (ridden)
|
|
1804
2192
|
marks = marks.filter((m) => !(m.ref.group === ridden.group && m.ref.index === ridden.index));
|
|
1805
|
-
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 }));
|
|
2193
|
+
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, occluded: m.occluded === true }));
|
|
1806
2194
|
const now = new Map();
|
|
1807
2195
|
for (const m of marks) {
|
|
1808
2196
|
const key = `${m.ref.group}:${m.ref.index}`;
|
|
@@ -1882,7 +2270,8 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1882
2270
|
time: this.#model.time,
|
|
1883
2271
|
lookups: this.#model.lookups,
|
|
1884
2272
|
satellites: this.#satelliteStats(),
|
|
1885
|
-
|
|
2273
|
+
paths: this.#pathControls?.stats() ?? emptyPathStats(),
|
|
2274
|
+
ride: { riding: this.#model.ride !== null, lost: this.#model.rideLost, gliding: this.#model.transition !== null || this.#model.rideFrame.moving, facing: this.facing, groundKm: this.#model.rideFrame.groundKm },
|
|
1886
2275
|
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 },
|
|
1887
2276
|
bodies: { look: this.#model.bodies || painter?.looks?.[0] || "plain", painted: this.#model.painted.bodies, moons: this.#model.painted.moons, held: this.#model.painted.held, moon: this.#model.painted.moon, tiles: this.#model.painted.tiles, mapped: this.#model.painted.mapped, pending: this.#model.painted.pending },
|
|
1888
2277
|
meteors: { on: this.#model.meteors.on, strength: this.#model.meteors.strength, ...this.#model.meteors.drawn },
|
|
@@ -1914,7 +2303,7 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
1914
2303
|
let epochMs = 0;
|
|
1915
2304
|
for (const group of this.#model.satellites.groups.values())
|
|
1916
2305
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1917
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing };
|
|
2306
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing, hoverPath: drawn.hoverPath, hoverOpacity: drawn.hoverOpacity, selectedOpacity: drawn.selectedOpacity };
|
|
1918
2307
|
}
|
|
1919
2308
|
// --- the game clock ----------------------------------------------------------------------------------------------------------------------------
|
|
1920
2309
|
#readSpeed() {
|
|
@@ -2043,9 +2432,14 @@ export class ChikyuSpace extends HTMLElement {
|
|
|
2043
2432
|
const y = event.clientY - rect.top;
|
|
2044
2433
|
const satellite = this.#model.pick?.(x, y, 12);
|
|
2045
2434
|
if (satellite) {
|
|
2435
|
+
claimPress(event);
|
|
2046
2436
|
this.dispatchEvent(new CustomEvent("chikyu-satellite-click", { detail: { ...satellite, info: this.satelliteInfo(satellite) }, bubbles: true, composed: true }));
|
|
2047
2437
|
return;
|
|
2048
2438
|
}
|
|
2439
|
+
if (this.#pathControls?.press(x, y, pointerOf(event))) {
|
|
2440
|
+
claimPress(event);
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2049
2443
|
if (!this.#places)
|
|
2050
2444
|
return;
|
|
2051
2445
|
let best;
|
|
@@ -90,7 +90,7 @@ export declare const AU_IN_EARTH_RADII: number;
|
|
|
90
90
|
*/
|
|
91
91
|
export declare function frameAt(ms: number): Frame;
|
|
92
92
|
/**
|
|
93
|
-
* A frame between two others, `t` from 0 to 1. The spin
|
|
93
|
+
* A frame between two others, `t` from 0 to 1. The spin advances by how far the Earth turns in that time, so a step of a second takes the short way and a step of a day is a full turn.
|
|
94
94
|
*
|
|
95
95
|
* @param a - The earlier frame.
|
|
96
96
|
* @param b - The later frame.
|
package/dist/space/ephemeris.js
CHANGED
|
@@ -66,7 +66,7 @@ export function frameAt(ms) {
|
|
|
66
66
|
}
|
|
67
67
|
const lerp3 = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t, a[2] + (b[2] - a[2]) * t];
|
|
68
68
|
/**
|
|
69
|
-
* A frame between two others, `t` from 0 to 1. The spin
|
|
69
|
+
* A frame between two others, `t` from 0 to 1. The spin advances by how far the Earth turns in that time, so a step of a second takes the short way and a step of a day is a full turn.
|
|
70
70
|
*
|
|
71
71
|
* @param a - The earlier frame.
|
|
72
72
|
* @param b - The later frame.
|
|
@@ -87,7 +87,9 @@ export function blend(a, b, t) {
|
|
|
87
87
|
for (const name of PLANETS)
|
|
88
88
|
planets[name] = lerp3(a.planets[name], b.planets[name], t);
|
|
89
89
|
let turn = b.spin - a.spin;
|
|
90
|
-
|
|
90
|
+
// The samples are wrapped to a circle. Pick the turn that matches how far the Earth really turns in the time between them, so a step of a day is a full turn and a step of a second is the short way.
|
|
91
|
+
const expected = ((b.ms - a.ms) / 86_164_090.5) * 360;
|
|
92
|
+
turn += 360 * Math.round((expected - turn) / 360);
|
|
91
93
|
return { ms: a.ms + (b.ms - a.ms) * t, sun: lerp3(a.sun, b.sun, t), moon: lerp3(a.moon, b.moon, t), planets, spin: a.spin + turn * t };
|
|
92
94
|
}
|
|
93
95
|
/**
|