@johnmorrisdotca/chikyu-earth 0.42.0 → 0.45.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 +17 -0
- package/NOTICE.md +15 -5
- package/README.md +4 -4
- package/dist/door/map.js +5 -1
- package/dist/element.d.ts +30 -0
- package/dist/element.js +82 -2
- package/dist/markers/here-city-host.d.ts +3 -1
- package/dist/markers/here-city-host.js +67 -5
- package/dist/markers/here-city.d.ts +94 -1
- package/dist/markers/here-city.js +69 -1
- package/dist/markers/index.d.ts +1 -1
- package/dist/markers/index.js +1 -1
- package/dist/realistic/element-base.d.ts +44 -1
- package/dist/realistic/element-base.js +128 -16
- package/dist/realistic/index.d.ts +1 -0
- package/dist/realistic/index.js +1 -0
- package/dist/realistic/zoom-reach.d.ts +29 -0
- package/dist/realistic/zoom-reach.js +30 -0
- package/dist/satellites/catalogue.d.ts +52 -1
- package/dist/satellites/catalogue.js +96 -5
- package/dist/satellites/index.d.ts +1 -1
- package/dist/satellites/index.js +1 -1
- package/dist/sea-names/features.d.ts +12 -0
- package/dist/sea-names/features.js +46 -0
- package/dist/sea-names/geometry.d.ts +121 -0
- package/dist/sea-names/geometry.js +135 -0
- package/dist/sea-names/host.d.ts +46 -0
- package/dist/sea-names/host.js +111 -0
- package/dist/space/element-base.d.ts +58 -11
- package/dist/space/element-base.js +153 -13
- package/dist/space/generic-satellite.d.ts +46 -0
- package/dist/space/generic-satellite.js +96 -0
- package/dist/space/index.d.ts +2 -1
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +45 -0
- package/dist/space/ride.js +38 -0
- package/dist/space/satellite-focus.d.ts +90 -0
- package/dist/space/satellite-focus.js +109 -0
- package/dist/space/satellite-layer.d.ts +32 -3
- package/dist/space/satellite-layer.js +95 -29
- package/dist/space/scene.d.ts +3 -1
- package/dist/space/scene.js +54 -25
- package/package.json +3 -3
package/dist/space/scene.js
CHANGED
|
@@ -5,7 +5,8 @@ import { createTextureSet } from "../realistic/textures.js";
|
|
|
5
5
|
import { createTileSet } from "../realistic/tile-set.js";
|
|
6
6
|
import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
|
|
7
7
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
8
|
-
import { faceOffset, ridePose } from "./ride.js";
|
|
8
|
+
import { faceOffset, outsidePose, ridePose } from "./ride.js";
|
|
9
|
+
import { genericSatellite, satelliteKind } from "./generic-satellite.js";
|
|
9
10
|
import { coverBody, covers } from "../sky/cover.js";
|
|
10
11
|
import { beginPlaceSprites, createPlaceSprites } from "../markers/place-sprites.js";
|
|
11
12
|
import { aboveAxes, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
|
|
@@ -22,6 +23,8 @@ import { subsolarPoint, unitVector } from "../realistic/sun.js";
|
|
|
22
23
|
const MAX_MARKED = 80;
|
|
23
24
|
const RAD = Math.PI / 180;
|
|
24
25
|
const FOV = 35;
|
|
26
|
+
/** 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). */
|
|
27
|
+
const OUTSIDE_RADIUS_SHARE = 0.09;
|
|
25
28
|
/** 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. */
|
|
26
29
|
export const DEFAULT_EARTH_SIZE = 0.9;
|
|
27
30
|
/**
|
|
@@ -516,6 +519,8 @@ export function createSpaceItem(model, deps) {
|
|
|
516
519
|
let focusRadius = radiusOf(focus);
|
|
517
520
|
let rideFrom = null;
|
|
518
521
|
let followed = null;
|
|
522
|
+
// a satellite ridden from itself: where it is, so that an outside ride can show it
|
|
523
|
+
let ridden = null;
|
|
519
524
|
model.rideLost = false;
|
|
520
525
|
model.lookBase = null;
|
|
521
526
|
model.rideMotion = 0;
|
|
@@ -543,8 +548,10 @@ export function createSpaceItem(model, deps) {
|
|
|
543
548
|
focusRadius = Math.max(1e-4, ride.distanceKm / 6371 / fit);
|
|
544
549
|
followed = { place, velocity: [rideState[3], rideState[4], rideState[5]], ref: ride.target };
|
|
545
550
|
}
|
|
546
|
-
else
|
|
551
|
+
else {
|
|
547
552
|
rideFrom = { position: place, velocity: [rideState[3], rideState[4], rideState[5]], hidden: null, gameSeconds: 0 };
|
|
553
|
+
ridden = { place, velocity: rideFrom.velocity, ref: ride.target };
|
|
554
|
+
}
|
|
548
555
|
}
|
|
549
556
|
else
|
|
550
557
|
model.rideLost = true;
|
|
@@ -561,14 +568,21 @@ export function createSpaceItem(model, deps) {
|
|
|
561
568
|
let fovNow = FOV;
|
|
562
569
|
let distance = 0;
|
|
563
570
|
if (rideFrom) {
|
|
564
|
-
|
|
571
|
+
let pose = ridePose({ position: rideFrom.position, velocity: rideFrom.velocity, look: ride.look, yaw: model.view.yaw, tilt: model.view.tilt, zoom: model.view.zoom, turn: model.rideTurn, ...(ride.face ? { face: ride.face } : {}) });
|
|
565
572
|
model.rideDistance = Math.hypot(...rideFrom.position);
|
|
573
|
+
// an outside ride: the same look, from a little way back along it, so the satellite is in the picture
|
|
574
|
+
let outsideAway = Infinity;
|
|
575
|
+
if (ridden && ride.viewpoint === "outside") {
|
|
576
|
+
const out = outsidePose(pose, ride.look);
|
|
577
|
+
pose = out.pose;
|
|
578
|
+
outsideAway = out.distance;
|
|
579
|
+
}
|
|
566
580
|
camera.position.set(pose.position[0], pose.position[1], pose.position[2]);
|
|
567
581
|
camera.up.set(pose.up[0], pose.up[1], pose.up[2]);
|
|
568
582
|
camera.lookAt(pose.position[0] + pose.forward[0], pose.position[1] + pose.forward[1], pose.position[2] + pose.forward[2]);
|
|
569
583
|
fovNow = pose.fov;
|
|
570
584
|
const away = Math.hypot(...rideFrom.position);
|
|
571
|
-
camera.near = Math.max(0.0008, Math.min(0.05, (away - 1) * 0.1));
|
|
585
|
+
camera.near = outsideAway < Infinity ? Math.max(1e-5, outsideAway * 0.1) : Math.max(0.0008, Math.min(0.05, (away - 1) * 0.1));
|
|
572
586
|
camera.far = Math.max(2000, 400 + (mode === "true" ? 40 * 23_481 : 0));
|
|
573
587
|
// how fast the ground goes by under the camera, in pixels a second at 1x: the speed over the height for a satellite, the turn of the direction to the Earth for a body
|
|
574
588
|
const focal = (size.height / 2) / Math.tan((fovNow / 2) * RAD);
|
|
@@ -755,14 +769,36 @@ export function createSpaceItem(model, deps) {
|
|
|
755
769
|
model.painted = { bodies: paintedBodies, moons: paintedMoons, held: 0, moon: paintedMoon !== undefined, tiles: tiled, mapped: model.painted.mapped, pending: model.painted.pending };
|
|
756
770
|
// the followed satellite as a model, when the page has one for it: made once, placed where the satellite is, pointed the way it flies, sized to read and lit by the Sun
|
|
757
771
|
const satellitePainter = deps.satellitePainter?.();
|
|
758
|
-
|
|
759
|
-
const
|
|
760
|
-
const
|
|
772
|
+
// the satellite to draw: the one followed or seen from above, or (an outside ride from the satellite itself) the one ridden
|
|
773
|
+
const candidate = followed ?? ridden;
|
|
774
|
+
const shownSat = followed ?? (ride?.viewpoint === "outside" ? ridden : null);
|
|
775
|
+
const group = candidate ? model.satellites.groups.get(candidate.ref.group) : undefined;
|
|
776
|
+
const set = candidate && group ? group.satellites.sets[candidate.ref.index] : undefined;
|
|
777
|
+
const norad = set?.NORAD_CAT_ID;
|
|
778
|
+
// a model the page made for it, drawn only while the camera is outside it (followed or above it, or an outside ride); else the package's own small drawing by kind, kept (hidden) while the ride stays on the satellite, and let go when it ends
|
|
779
|
+
const painted = norad !== undefined && satellitePainter?.has(norad) === true;
|
|
780
|
+
const genericKey = set ? `generic:${satelliteKind(set.OBJECT_NAME ?? "")}` : "";
|
|
781
|
+
const modelKey = set === undefined || norad === undefined ? "" : painted ? (shownSat ? String(norad) : "") : ride?.viewpoint === "outside" || modelSlot.key === genericKey ? genericKey : "";
|
|
761
782
|
if (modelKey !== modelSlot.key) {
|
|
762
783
|
dropModel();
|
|
763
784
|
modelSlot.key = modelKey;
|
|
764
785
|
const turn = (modelSlot.turn += 1);
|
|
765
|
-
|
|
786
|
+
const adopt = (made) => {
|
|
787
|
+
made.object.matrixAutoUpdate = false;
|
|
788
|
+
made.object.visible = false;
|
|
789
|
+
scene.add(made.object);
|
|
790
|
+
modelSlot.drawing = made;
|
|
791
|
+
// how many meshes the model is made of: a draw call each, which a test of the draw budget adds to the scene's own
|
|
792
|
+
modelSlot.parts = 0;
|
|
793
|
+
made.object.traverse((part) => {
|
|
794
|
+
if (part.isMesh)
|
|
795
|
+
modelSlot.parts += 1;
|
|
796
|
+
});
|
|
797
|
+
deps.invalidate();
|
|
798
|
+
};
|
|
799
|
+
if (modelKey.startsWith("generic:"))
|
|
800
|
+
adopt(genericSatellite(three, modelKey.slice(8)));
|
|
801
|
+
else if (modelKey && satellitePainter && norad !== undefined) {
|
|
766
802
|
void Promise.resolve(satellitePainter.make(three, norad, { look: "", invalidate: () => deps.invalidate(), ratio: model.ratio(), maxTexture: deps.cap() }))
|
|
767
803
|
.then((made) => {
|
|
768
804
|
if (!made)
|
|
@@ -771,32 +807,25 @@ export function createSpaceItem(model, deps) {
|
|
|
771
807
|
made.dispose();
|
|
772
808
|
return;
|
|
773
809
|
}
|
|
774
|
-
made
|
|
775
|
-
made.object.visible = false;
|
|
776
|
-
scene.add(made.object);
|
|
777
|
-
modelSlot.drawing = made;
|
|
778
|
-
// how many meshes the model is made of: a draw call each, which a test of the draw budget adds to the scene's own
|
|
779
|
-
modelSlot.parts = 0;
|
|
780
|
-
made.object.traverse((part) => {
|
|
781
|
-
if (part.isMesh)
|
|
782
|
-
modelSlot.parts += 1;
|
|
783
|
-
});
|
|
784
|
-
deps.invalidate();
|
|
810
|
+
adopt(made);
|
|
785
811
|
})
|
|
786
812
|
.catch((error) => deps.onPainterError?.(error));
|
|
787
813
|
}
|
|
788
814
|
}
|
|
789
|
-
const axes =
|
|
790
|
-
|
|
815
|
+
const axes = shownSat ? satelliteAxes(shownSat.place, shownSat.velocity) : null;
|
|
816
|
+
// a generic drawing is for an outside ride only; a page's model is drawn wherever the camera is not at the satellite
|
|
817
|
+
const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (followed !== null && painted));
|
|
818
|
+
if (modelSlot.drawing && shownSat && axes && drawn) {
|
|
791
819
|
const object = modelSlot.drawing.object;
|
|
792
|
-
const away = Math.hypot(
|
|
793
|
-
|
|
820
|
+
const away = Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z);
|
|
821
|
+
const share = followed ? MODEL_RADIUS_SHARE : OUTSIDE_RADIUS_SHARE;
|
|
822
|
+
object.matrix.set(...modelMatrix(shownSat.place, axes, modelRadius(away, half, share, 1e-9)));
|
|
794
823
|
object.matrixWorldNeedsUpdate = true;
|
|
795
824
|
object.visible = true;
|
|
796
825
|
const toSunNow = unit(frame.sun);
|
|
797
826
|
modelSlot.drawing.light?.(toSunNow);
|
|
798
|
-
modelSlot.drawing.update?.({ toSun: toSunNow, ms: model.time, radiusPx: size.height *
|
|
799
|
-
projected.set(
|
|
827
|
+
modelSlot.drawing.update?.({ toSun: toSunNow, ms: model.time, radiusPx: size.height * share });
|
|
828
|
+
projected.set(shownSat.place[0], shownSat.place[1], shownSat.place[2]).project(camera);
|
|
800
829
|
model.followModel = { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height, shown: true, parts: modelSlot.parts };
|
|
801
830
|
}
|
|
802
831
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.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",
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
},
|
|
221
221
|
"peerDependencies": {
|
|
222
222
|
"@johnmorrisdotca/hoshi-stars": ">=0.30.0",
|
|
223
|
-
"@johnmorrisdotca/kuni": ">=1.
|
|
223
|
+
"@johnmorrisdotca/kuni": ">=1.8.0",
|
|
224
224
|
"@johnmorrisdotca/wakusei-planets": ">=0.5.0",
|
|
225
225
|
"astronomy-engine": ">=2.1.0",
|
|
226
226
|
"satellite.js": ">=6.0.0",
|
|
@@ -254,7 +254,7 @@
|
|
|
254
254
|
"@eslint/js": "^9.0.0",
|
|
255
255
|
"@johnmorrisdotca/hata": "^1.8.0",
|
|
256
256
|
"@johnmorrisdotca/hoshi-stars": "^0.30.0",
|
|
257
|
-
"@johnmorrisdotca/kuni": "^1.
|
|
257
|
+
"@johnmorrisdotca/kuni": "^1.8.0",
|
|
258
258
|
"@johnmorrisdotca/wakusei-planets": "^0.39.0",
|
|
259
259
|
"@playwright/test": "1.64.0",
|
|
260
260
|
"@sveltejs/vite-plugin-svelte": "^7.3.1",
|