@johnmorrisdotca/chikyu-earth 0.46.5 → 0.47.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 +13 -0
- package/README.md +4 -3
- package/dist/beam/geometry.d.ts +131 -0
- package/dist/beam/geometry.js +141 -0
- package/dist/beam/layer.d.ts +47 -0
- package/dist/beam/layer.js +308 -0
- 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 +9 -1
- package/dist/realistic/earth.js +13 -0
- package/dist/realistic/element-base.d.ts +21 -0
- package/dist/realistic/element-base.js +58 -3
- package/dist/space/element-base.d.ts +136 -2
- package/dist/space/element-base.js +356 -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 +3 -1
- package/dist/space/index.js +2 -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 +56 -1
- package/dist/space/satellite-layer.js +93 -31
- 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 +96 -12
- package/package.json +6 -1
|
@@ -180,6 +180,7 @@ export const MODEL_HANDOVER_PX = 10;
|
|
|
180
180
|
* Pure, so a test can ask it at any height.
|
|
181
181
|
*
|
|
182
182
|
* @param distanceKm - The camera's distance from the satellite, in kilometres.
|
|
183
|
+
* @param lowest - The share at the lowest height, `ABOVE_MODEL_SHARE` by default (a page sets it with `ride-model-share`).
|
|
183
184
|
* @returns The share, from 0 to 0.17.
|
|
184
185
|
*
|
|
185
186
|
* @example
|
|
@@ -189,10 +190,10 @@ export const MODEL_HANDOVER_PX = 10;
|
|
|
189
190
|
* console.log(aboveModelShare(150), aboveModelShare(1000) < aboveModelShare(150), aboveModelShare(6000));
|
|
190
191
|
* ```
|
|
191
192
|
*/
|
|
192
|
-
export function aboveModelShare(distanceKm) {
|
|
193
|
+
export function aboveModelShare(distanceKm, lowest = ABOVE_MODEL_SHARE) {
|
|
193
194
|
if (!(distanceKm > 0))
|
|
194
|
-
return
|
|
195
|
-
const base =
|
|
195
|
+
return lowest;
|
|
196
|
+
const base = lowest * Math.min(1, ABOVE_MODEL_KM / distanceKm);
|
|
196
197
|
const t = Math.min(1, Math.max(0, (distanceKm - MODEL_FADE_FROM_KM) / (MODEL_FADE_TO_KM - MODEL_FADE_FROM_KM)));
|
|
197
198
|
return base * (1 - t * t * (3 - 2 * t));
|
|
198
199
|
}
|
package/dist/space/scene.d.ts
CHANGED
|
@@ -18,8 +18,17 @@ import { type BodyLabelState } from "../realistic/body-label.ts";
|
|
|
18
18
|
import { type MeteorState } from "../meteors/layer.ts";
|
|
19
19
|
import { type BorderState } from "../borders/layer.ts";
|
|
20
20
|
import { type GridState } from "../grid/layer.ts";
|
|
21
|
+
import { type BeamState } from "../beam/layer.ts";
|
|
21
22
|
import { type RouteState } from "../route/layer.ts";
|
|
22
23
|
type Three = ThreeParts;
|
|
24
|
+
/** How big a satellite seen from outside by a ride from itself is drawn: its radius is this share of the height of the view (a model about a fifth of the height across; the satellite is a few metres, so this is not to scale). */
|
|
25
|
+
/** A number easing from one value to another (the model's share, its seat, how much of it is there): `cur` is where it is. */
|
|
26
|
+
export interface FrameEase {
|
|
27
|
+
cur: number;
|
|
28
|
+
from: number;
|
|
29
|
+
to: number;
|
|
30
|
+
start: number;
|
|
31
|
+
}
|
|
23
32
|
/** How much of the view's shorter side the Earth's disc fills at zoom 1 when the page does not say: 0.9, so the atmosphere's glow (8% beyond the disc) is inside the view and never cut. */
|
|
24
33
|
export declare const DEFAULT_EARTH_SIZE = 0.9;
|
|
25
34
|
/**
|
|
@@ -142,6 +151,8 @@ export interface SpaceModel {
|
|
|
142
151
|
cloudDrift: number;
|
|
143
152
|
/** For the `space` camera: the Earth's turn against the stars (degrees) at the moment the camera was set, so it stays in the stars while the Earth turns beneath; null until the next draw sets it. */
|
|
144
153
|
cameraSpin: number | null;
|
|
154
|
+
/** How much of the Earth's turn the space camera takes: 0 holds the stars, 1 turns with the Earth. */
|
|
155
|
+
follow: number;
|
|
145
156
|
/** The share of the view's shorter side the Earth's disc fills at zoom 1, and where its centre is in the view (0 to 1 across and down; 0.5, 0.5 is the middle). */
|
|
146
157
|
earth: {
|
|
147
158
|
size: number;
|
|
@@ -190,6 +201,8 @@ export interface SpaceModel {
|
|
|
190
201
|
borders: BorderState;
|
|
191
202
|
/** The meridians and parallels on the Earth (src/grid/layer.ts): off unless the element switches them on. */
|
|
192
203
|
grid: GridState;
|
|
204
|
+
/** The beam of light from the chosen satellite to the ground below it (src/beam/layer.ts): off unless the element switches it on. */
|
|
205
|
+
beam: BeamState;
|
|
193
206
|
/** A route between two places, on the Earth (src/route/layer.ts): off unless the element sets it. */
|
|
194
207
|
route: RouteState;
|
|
195
208
|
/** The body or satellite the camera rides along with, or null. */
|
|
@@ -222,6 +235,24 @@ export interface SpaceModel {
|
|
|
222
235
|
rideTurn: number;
|
|
223
236
|
/** How far the riding camera is from the Earth's centre in Earth radii as of the last draw, or null when none rides: the range of tilt that does something follows it. */
|
|
224
237
|
rideDistance: number | null;
|
|
238
|
+
/**
|
|
239
|
+
* The framing of the ridden satellite's model (MODULES-1316): the radius as a share of the picture's height and where its middle sits (a share of the height from the top) as the page set them (`null`: the ride's own), the eased values the last
|
|
240
|
+
* draw used, how long a change takes (0 for reduced motion), and the ground the picture spans below the satellite as of the last draw.
|
|
241
|
+
*/
|
|
242
|
+
rideFrame: {
|
|
243
|
+
share: number | null;
|
|
244
|
+
seat: number | null;
|
|
245
|
+
fresh: boolean;
|
|
246
|
+
ms: number;
|
|
247
|
+
moving: boolean;
|
|
248
|
+
share_: FrameEase;
|
|
249
|
+
seat_: FrameEase;
|
|
250
|
+
weight_: FrameEase;
|
|
251
|
+
groundKm: {
|
|
252
|
+
across: number;
|
|
253
|
+
tall: number;
|
|
254
|
+
} | null;
|
|
255
|
+
};
|
|
225
256
|
/** The satellite at a point of the view (CSS pixels), within a radius, if a draw has been made and one is there. */
|
|
226
257
|
pick: ((x: number, y: number, radius: number) => SatelliteRef | null) | null;
|
|
227
258
|
/** The followed satellite's model, when there is one drawn: where its middle is on the screen (CSS pixels), as of the last draw. */
|
|
@@ -230,6 +261,9 @@ export interface SpaceModel {
|
|
|
230
261
|
y: number;
|
|
231
262
|
shown: boolean;
|
|
232
263
|
parts: number;
|
|
264
|
+
share: number;
|
|
265
|
+
seat: number;
|
|
266
|
+
weight: number;
|
|
233
267
|
radiusPx: number;
|
|
234
268
|
box: {
|
|
235
269
|
left: number;
|
|
@@ -414,6 +448,12 @@ export interface SpaceDeps {
|
|
|
414
448
|
x: number;
|
|
415
449
|
y: number;
|
|
416
450
|
} | null) => void;
|
|
451
|
+
/** Where the satellite under the pointer is, or null. Called at each draw while one is under the pointer (and once when it is let go). */
|
|
452
|
+
onHover?: (place: {
|
|
453
|
+
x: number;
|
|
454
|
+
y: number;
|
|
455
|
+
visible: boolean;
|
|
456
|
+
} | null) => void;
|
|
417
457
|
/** Where each member of a labelled group is on the screen at this draw (the groups of `model.satellites.marked`); an empty list once when the last group is let go. */
|
|
418
458
|
onSatelliteMarks?: (marks: {
|
|
419
459
|
ref: SatelliteRef;
|
|
@@ -421,6 +461,7 @@ export interface SpaceDeps {
|
|
|
421
461
|
y: number;
|
|
422
462
|
visible: boolean;
|
|
423
463
|
heightKm: number;
|
|
464
|
+
occluded: boolean;
|
|
424
465
|
}[]) => void;
|
|
425
466
|
/** Called at the end of a draw while the camera is moving from one ride to another, so the next frame is asked for (at the page's frame cap). */
|
|
426
467
|
onMoving?: () => void;
|
package/dist/space/scene.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
|
|
|
7
7
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
8
8
|
import { faceOffset, outsidePose, ridePose } from "./ride.js";
|
|
9
9
|
import { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
10
|
+
import { followSpin } from "./follow.js";
|
|
10
11
|
import { coverBody, covers } from "../sky/cover.js";
|
|
11
12
|
import { beginPlaceSprites, createPlaceSprites } from "../markers/place-sprites.js";
|
|
12
13
|
import { ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
@@ -17,16 +18,36 @@ import { createBodyLabelLayer, newBodyLabelState } from "../realistic/body-label
|
|
|
17
18
|
import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
|
|
18
19
|
import { createBorderLayer, newBorderState } from "../borders/layer.js";
|
|
19
20
|
import { createGridLayer, newGridState } from "../grid/layer.js";
|
|
21
|
+
import { createBeamLayer, newBeamState } from "../beam/layer.js";
|
|
20
22
|
import { createRouteLayer, newRouteState } from "../route/layer.js";
|
|
21
23
|
import { subsolarPoint, unitVector } from "../realistic/sun.js";
|
|
22
24
|
/** The most satellites ringed and named at once, over all the labelled groups. */
|
|
23
25
|
const MAX_MARKED = 80;
|
|
24
26
|
const RAD = Math.PI / 180;
|
|
25
27
|
const FOV = 35;
|
|
26
|
-
|
|
28
|
+
const newEase = () => ({ cur: Number.NaN, from: Number.NaN, to: Number.NaN, start: 0 });
|
|
29
|
+
/** Moves an ease towards `to`: at once when it is new or `ms` is 0 (reduced motion), else over `ms` milliseconds with a smooth step. True while it is still on its way. */
|
|
30
|
+
function stepEase(e, to, now, ms, fresh) {
|
|
31
|
+
if (fresh || !Number.isFinite(e.cur)) {
|
|
32
|
+
e.cur = e.from = e.to = to;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
if (to !== e.to) {
|
|
36
|
+
e.from = e.cur;
|
|
37
|
+
e.to = to;
|
|
38
|
+
e.start = now;
|
|
39
|
+
}
|
|
40
|
+
const k = ms > 0 ? Math.min(1, Math.max(0, (now - e.start) / ms)) : 1;
|
|
41
|
+
e.cur = e.from + (e.to - e.from) * k * k * (3 - 2 * k);
|
|
42
|
+
if (k >= 1)
|
|
43
|
+
e.cur = to;
|
|
44
|
+
return k < 1;
|
|
45
|
+
}
|
|
46
|
+
/** The radius share and the seat the rides have when the page sets none: along the way it goes the model is large and low (0.22, 0.86), looking down it is small and in the middle. */
|
|
47
|
+
const ALONG_SEAT = 0.86;
|
|
27
48
|
const OUTSIDE_RADIUS_SHARE = 0.1;
|
|
28
49
|
/** The share of the view's height an outside ride along (looking along the way it goes) draws the satellite's radius at: it sits at the bottom middle with part of it below the bottom edge, large enough to read and to be drawn sharp (MODULES-1303). */
|
|
29
|
-
const OUTSIDE_ALONG_SHARE = 0.
|
|
50
|
+
const OUTSIDE_ALONG_SHARE = 0.22;
|
|
30
51
|
/** How much of the view's shorter side the Earth's disc fills at zoom 1 when the page does not say: 0.9, so the atmosphere's glow (8% beyond the disc) is inside the view and never cut. */
|
|
31
52
|
export const DEFAULT_EARTH_SIZE = 0.9;
|
|
32
53
|
/**
|
|
@@ -86,6 +107,7 @@ export const newSpaceModel = () => ({
|
|
|
86
107
|
airThickness: AIR_THICKNESS_DEFAULT,
|
|
87
108
|
cloudDrift: 0,
|
|
88
109
|
cameraSpin: null,
|
|
110
|
+
follow: 0,
|
|
89
111
|
earth: { size: DEFAULT_EARTH_SIZE, x: 0.5, y: 0.5 },
|
|
90
112
|
fit: fitDistance(DEFAULT_EARTH_SIZE, 1),
|
|
91
113
|
orbits: true,
|
|
@@ -113,10 +135,12 @@ export const newSpaceModel = () => ({
|
|
|
113
135
|
bodyLabel: newBodyLabelState(),
|
|
114
136
|
borders: newBorderState(),
|
|
115
137
|
grid: newGridState(),
|
|
138
|
+
beam: newBeamState(),
|
|
116
139
|
route: newRouteState(),
|
|
117
140
|
pick: null,
|
|
118
141
|
placeSatellite: null,
|
|
119
142
|
followModel: null,
|
|
143
|
+
rideFrame: { share: null, seat: null, fresh: true, ms: 400, moving: false, share_: newEase(), seat_: newEase(), weight_: newEase(), groundKm: null },
|
|
120
144
|
tiles: null,
|
|
121
145
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
122
146
|
});
|
|
@@ -371,6 +395,8 @@ export function createSpaceItem(model, deps) {
|
|
|
371
395
|
let borders = null;
|
|
372
396
|
const placeRings = { sprites: null, tried: false };
|
|
373
397
|
let gridLayer = null;
|
|
398
|
+
let beamLayer = null;
|
|
399
|
+
const beamAt = new Float64Array(6);
|
|
374
400
|
let routeLayer = null;
|
|
375
401
|
let marksTold = false;
|
|
376
402
|
// the followed satellite's model: which satellite it is for, the drawing once it is made, and a count so that a model made for a satellite no longer followed is let go
|
|
@@ -383,6 +409,7 @@ export function createSpaceItem(model, deps) {
|
|
|
383
409
|
modelSlot.drawing = null;
|
|
384
410
|
};
|
|
385
411
|
let layer;
|
|
412
|
+
let hoverShown = false;
|
|
386
413
|
const rideState = new Float64Array(6);
|
|
387
414
|
let selectedShown = false;
|
|
388
415
|
const camera = new three.PerspectiveCamera(FOV, width / Math.max(1, height), 0.05, 1000);
|
|
@@ -512,13 +539,35 @@ export function createSpaceItem(model, deps) {
|
|
|
512
539
|
deps.onSatellitesError?.(error);
|
|
513
540
|
}
|
|
514
541
|
}
|
|
542
|
+
// the framing of the ridden satellite's model: its share of the picture, where its middle sits and how much of it there is (a switch to the view from inside fades it out over 0.4 s), each eased towards what the page set or the ride's own
|
|
543
|
+
let frameMoving = false;
|
|
544
|
+
const framing = (() => {
|
|
545
|
+
const riding = model.ride;
|
|
546
|
+
const f = model.rideFrame;
|
|
547
|
+
if (!riding || typeof riding.target === "string") {
|
|
548
|
+
f.fresh = true;
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
const along = riding.view === "from" && riding.look === "horizon";
|
|
552
|
+
const base = riding.view === "above" ? ABOVE_MODEL_SHARE : riding.view === "from" ? (along ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE) : MODEL_RADIUS_SHARE;
|
|
553
|
+
const now = performance.now();
|
|
554
|
+
if (stepEase(f.share_, f.share ?? base, now, f.ms, f.fresh))
|
|
555
|
+
frameMoving = true;
|
|
556
|
+
if (stepEase(f.seat_, f.seat ?? (along ? ALONG_SEAT : 0.5), now, f.ms, f.fresh))
|
|
557
|
+
frameMoving = true;
|
|
558
|
+
if (stepEase(f.weight_, riding.viewpoint === "outside" ? 1 : 0, now, f.ms, f.fresh))
|
|
559
|
+
frameMoving = true;
|
|
560
|
+
f.fresh = false;
|
|
561
|
+
return { share: f.share_.cur, seat: f.seat_.cur, weight: f.weight_.cur };
|
|
562
|
+
})();
|
|
563
|
+
model.rideFrame.moving = frameMoving;
|
|
515
564
|
// the ridden satellite is drawn as its model while the model is big enough to read; its ring and name (the page's choice of it, or the marks) are left off exactly then, and come back when the model has shrunk to the size of a ring (MODULES-1303, 1306)
|
|
516
565
|
{
|
|
517
566
|
const riding = model.ride;
|
|
518
567
|
let over = null;
|
|
519
|
-
if (riding && riding.viewpoint === "outside" && typeof riding.target !== "string") {
|
|
568
|
+
if (framing && riding && riding.viewpoint === "outside" && typeof riding.target !== "string") {
|
|
520
569
|
const kmAbove = riding.distanceKm / Math.max(1e-9, model.view.zoom);
|
|
521
|
-
const would = riding.view === "above" ? (riding.modelSize === "fixed" ?
|
|
570
|
+
const would = (riding.view === "above" ? (riding.modelSize === "fixed" ? framing.share : aboveModelShare(kmAbove, framing.share)) : framing.share) * framing.weight;
|
|
522
571
|
if (would * size.height >= MODEL_HANDOVER_PX)
|
|
523
572
|
over = riding.target;
|
|
524
573
|
}
|
|
@@ -587,7 +636,7 @@ export function createSpaceItem(model, deps) {
|
|
|
587
636
|
// an outside ride: the same look, from a little way back along it, so the satellite is in the picture
|
|
588
637
|
let outsideAway = Infinity;
|
|
589
638
|
if (ridden && ride.viewpoint === "outside") {
|
|
590
|
-
const out = outsidePose(pose, ride.look);
|
|
639
|
+
const out = outsidePose(pose, ride.look, framing ? (framing.seat - 0.5) / 0.5 : undefined);
|
|
591
640
|
pose = out.pose;
|
|
592
641
|
outsideAway = out.distance;
|
|
593
642
|
}
|
|
@@ -610,7 +659,8 @@ export function createSpaceItem(model, deps) {
|
|
|
610
659
|
if (model.camera === "space") {
|
|
611
660
|
if (model.cameraSpin === null)
|
|
612
661
|
model.cameraSpin = frame.spin;
|
|
613
|
-
|
|
662
|
+
// 0 holds the stars (the anchor alone, as before). 1 uses the Earth's turn now. In between, that share of the turn since the anchor.
|
|
663
|
+
spin = followSpin(model.cameraSpin, frame.spin, model.follow);
|
|
614
664
|
}
|
|
615
665
|
else if (model.camera === "sun") {
|
|
616
666
|
spin = Math.atan2(-frame.sun[2], frame.sun[0]) / RAD;
|
|
@@ -665,6 +715,14 @@ export function createSpaceItem(model, deps) {
|
|
|
665
715
|
}
|
|
666
716
|
camera.fov = fovNow;
|
|
667
717
|
camera.aspect = size.width / Math.max(1, size.height);
|
|
718
|
+
// the ground the picture spans straight below a ridden satellite, in kilometres: the height above the ground over the vertical field of view (flat-ground, to compare with a tile level's size)
|
|
719
|
+
if (framing) {
|
|
720
|
+
const heightKm = Math.max(0, (Math.hypot(camera.position.x, camera.position.y, camera.position.z) - 1) * 6371);
|
|
721
|
+
const tall = 2 * heightKm * Math.tan((fovNow / 2) * RAD);
|
|
722
|
+
model.rideFrame.groundKm = { across: tall * camera.aspect, tall };
|
|
723
|
+
}
|
|
724
|
+
else
|
|
725
|
+
model.rideFrame.groundKm = null;
|
|
668
726
|
// the Earth's place in the view: the picture is moved, not the camera (a camera riding from a body, or above a satellite, keeps the middle)
|
|
669
727
|
const centred = rideFrom !== null || (ride?.view === "above" && followed !== null);
|
|
670
728
|
const shiftX = centred ? 0 : (model.earth.x - 0.5) * size.width;
|
|
@@ -786,7 +844,7 @@ export function createSpaceItem(model, deps) {
|
|
|
786
844
|
const satellitePainter = deps.satellitePainter?.();
|
|
787
845
|
// the satellite to draw: the one followed or seen from above, or (an outside ride from the satellite itself) the one ridden
|
|
788
846
|
const candidate = followed ?? ridden;
|
|
789
|
-
const shownSat = followed ?? (ride?.viewpoint === "outside" ? ridden : null);
|
|
847
|
+
const shownSat = followed ?? (ride?.viewpoint === "outside" || (framing !== null && framing.weight > 0.001) ? ridden : null);
|
|
790
848
|
const group = candidate ? model.satellites.groups.get(candidate.ref.group) : undefined;
|
|
791
849
|
const set = candidate && group ? group.satellites.sets[candidate.ref.index] : undefined;
|
|
792
850
|
const norad = set?.NORAD_CAT_ID;
|
|
@@ -835,13 +893,15 @@ export function createSpaceItem(model, deps) {
|
|
|
835
893
|
modelSlot.axes = null;
|
|
836
894
|
const axes = freshAxes ?? (shownSat ? modelSlot.axes : null);
|
|
837
895
|
// a generic drawing is for an outside ride only; a page's model is drawn wherever the camera is not at the satellite
|
|
838
|
-
const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (followed !== null && painted));
|
|
839
|
-
const aboveShare = followed && ride?.view === "above" && ride.modelSize !== "fixed" ? aboveModelShare(Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z) * 6371) : 1;
|
|
896
|
+
const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (framing !== null && framing.weight > 0.001) || (followed !== null && painted));
|
|
897
|
+
const aboveShare = followed && ride?.view === "above" && ride.modelSize !== "fixed" ? aboveModelShare(Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z) * 6371, framing?.share) : 1;
|
|
840
898
|
// from far above the satellite is a point: the model has shrunk to nothing and the ordinary mark is all there is
|
|
841
899
|
if (modelSlot.drawing && shownSat && axes && drawn && aboveShare * size.height >= 0.5) {
|
|
842
900
|
const object = modelSlot.drawing.object;
|
|
843
901
|
const away = Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z);
|
|
844
|
-
const
|
|
902
|
+
const shape = framing?.share ?? MODEL_RADIUS_SHARE;
|
|
903
|
+
const weight = framing ? (followed !== null && ride?.viewpoint !== "outside" && framing.weight <= 0.001 ? 1 : framing.weight) : 1;
|
|
904
|
+
const share = (followed !== null && ride?.view === "above" && ride.modelSize !== "fixed" ? aboveModelShare(away * 6371, shape) : shape) * weight;
|
|
845
905
|
object.matrix.set(...modelMatrix(shownSat.place, axes, modelRadius(away, half, share, 1e-9)));
|
|
846
906
|
object.matrixWorldNeedsUpdate = true;
|
|
847
907
|
object.visible = true;
|
|
@@ -852,7 +912,7 @@ export function createSpaceItem(model, deps) {
|
|
|
852
912
|
const sx = ((projected.x + 1) / 2) * size.width;
|
|
853
913
|
const sy = ((1 - projected.y) / 2) * size.height;
|
|
854
914
|
const radiusPx = size.height * share;
|
|
855
|
-
model.followModel = { x: sx, y: sy, shown: true, parts: modelSlot.parts, radiusPx, box: { left: sx - radiusPx, top: sy - radiusPx, right: sx + radiusPx, bottom: sy + radiusPx }, axes };
|
|
915
|
+
model.followModel = { x: sx, y: sy, shown: true, parts: modelSlot.parts, share, seat: sy / size.height, weight, radiusPx, box: { left: sx - radiusPx, top: sy - radiusPx, right: sx + radiusPx, bottom: sy + radiusPx }, axes };
|
|
856
916
|
}
|
|
857
917
|
else {
|
|
858
918
|
if (modelSlot.drawing)
|
|
@@ -1084,6 +1144,15 @@ export function createSpaceItem(model, deps) {
|
|
|
1084
1144
|
deps.onSelected(at);
|
|
1085
1145
|
selectedShown = at !== null;
|
|
1086
1146
|
}
|
|
1147
|
+
if (layer && deps.onHover) {
|
|
1148
|
+
const hover = model.satellites.hover;
|
|
1149
|
+
const ref = hover.enabled && hover.ref && hover.fade > 0 ? hover.ref : null;
|
|
1150
|
+
const at = ref ? layer.placeOf(ref, camera, size) : null;
|
|
1151
|
+
const place = at ? { x: at.x, y: at.y, visible: at.visible } : null;
|
|
1152
|
+
if (place || hoverShown)
|
|
1153
|
+
deps.onHover(place);
|
|
1154
|
+
hoverShown = place !== null;
|
|
1155
|
+
}
|
|
1087
1156
|
// the meteors, on the Earth: made the first time they are switched on, and asking for their own next draw while a streak is alive or one is due
|
|
1088
1157
|
if (model.meteors.on && !meteors)
|
|
1089
1158
|
meteors = createMeteorLayer(three, earth, model.meteors);
|
|
@@ -1126,6 +1195,20 @@ export function createSpaceItem(model, deps) {
|
|
|
1126
1195
|
}
|
|
1127
1196
|
}
|
|
1128
1197
|
gridLayer?.sync(Math.min(px.Earth, 1e5));
|
|
1198
|
+
// the beam, from the chosen satellite (the one ridden, else the one marked) to the ground below it: made the first time it is switched on
|
|
1199
|
+
if (model.beam.on && !beamLayer && !model.beam.stats.failed) {
|
|
1200
|
+
try {
|
|
1201
|
+
beamLayer = createBeamLayer(three, scene, model.beam, 7);
|
|
1202
|
+
}
|
|
1203
|
+
catch (error) {
|
|
1204
|
+
model.beam.stats.failed = true;
|
|
1205
|
+
model.beam.onError?.(error);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
if (beamLayer) {
|
|
1209
|
+
const chosen = model.ride && typeof model.ride.target === "object" ? model.ride.target : model.satellites.selected;
|
|
1210
|
+
beamLayer.sync(model.beam.on && chosen && layer?.exact(chosen, model.time, beamAt) ? [beamAt[0], beamAt[1], beamAt[2]] : null);
|
|
1211
|
+
}
|
|
1129
1212
|
if ((model.route.ends || routeLayer) && !routeLayer && !model.route.failed) {
|
|
1130
1213
|
try {
|
|
1131
1214
|
routeLayer = createRouteLayer(three, earth, model.route);
|
|
@@ -1138,7 +1221,7 @@ export function createSpaceItem(model, deps) {
|
|
|
1138
1221
|
routeLayer?.sync();
|
|
1139
1222
|
if (model.rideLost)
|
|
1140
1223
|
deps.onRideLost?.();
|
|
1141
|
-
if (model.transition)
|
|
1224
|
+
if (model.transition || frameMoving)
|
|
1142
1225
|
deps.onMoving?.();
|
|
1143
1226
|
return false;
|
|
1144
1227
|
},
|
|
@@ -1159,6 +1242,7 @@ export function createSpaceItem(model, deps) {
|
|
|
1159
1242
|
borders?.dispose();
|
|
1160
1243
|
placeRings.sprites?.dispose();
|
|
1161
1244
|
gridLayer?.dispose();
|
|
1245
|
+
beamLayer?.dispose();
|
|
1162
1246
|
routeLayer?.dispose();
|
|
1163
1247
|
modelSlot.turn += 1;
|
|
1164
1248
|
dropModel();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.0",
|
|
4
4
|
"description": "Chikyu Earth 地球 — A line-drawn globe for the web: country outlines that turn at the Earth's own rate, centred on the place you give it, with an optional realistic Earth from space (three.js), the Sun, Moon and planets, satellites on their orbits, and markers for any place. A web component and an SVG string.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"earth",
|
|
@@ -174,6 +174,11 @@
|
|
|
174
174
|
"import": "./dist/catalogue/index.js",
|
|
175
175
|
"default": "./dist/catalogue/index.js"
|
|
176
176
|
},
|
|
177
|
+
"./place": {
|
|
178
|
+
"types": "./dist/place/index.d.ts",
|
|
179
|
+
"import": "./dist/place/index.js",
|
|
180
|
+
"default": "./dist/place/index.js"
|
|
181
|
+
},
|
|
177
182
|
"./package.json": "./package.json"
|
|
178
183
|
},
|
|
179
184
|
"files": [
|