@johnmorrisdotca/chikyu-earth 0.24.0 → 0.25.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 +6 -0
- package/NOTICE.md +7 -1
- package/README.md +49 -9
- package/dist/data/meteor-showers.d.ts +53 -0
- package/dist/data/meteor-showers.js +57 -0
- package/dist/meteors/index.d.ts +3 -0
- package/dist/meteors/index.js +6 -0
- package/dist/meteors/layer.d.ts +108 -0
- package/dist/meteors/layer.js +337 -0
- package/dist/meteors/note.d.ts +11 -0
- package/dist/meteors/note.js +19 -0
- package/dist/meteors/rate.d.ts +206 -0
- package/dist/meteors/rate.js +252 -0
- package/dist/realistic/earth.d.ts +3 -0
- package/dist/realistic/earth.js +14 -0
- package/dist/realistic/element.d.ts +21 -0
- package/dist/realistic/element.js +52 -3
- package/dist/space/element.d.ts +17 -0
- package/dist/space/element.js +44 -3
- package/dist/space/scene.d.ts +3 -0
- package/dist/space/scene.js +22 -0
- package/package.json +6 -1
package/dist/space/scene.js
CHANGED
|
@@ -5,6 +5,8 @@ import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
|
|
|
5
5
|
import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
|
|
6
6
|
import { ridePose } from "./ride.js";
|
|
7
7
|
import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
|
|
8
|
+
import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
|
|
9
|
+
import { subsolarPoint, unitVector } from "../realistic/sun.js";
|
|
8
10
|
const RAD = Math.PI / 180;
|
|
9
11
|
/** The camera's distance, in Earth radii, at which the Earth fills the view at zoom 1. */
|
|
10
12
|
export const FIT_DISTANCE = 3.4;
|
|
@@ -53,6 +55,7 @@ export const newSpaceModel = () => ({
|
|
|
53
55
|
pose: { p: [0, 0, 0], q: [0, 0, 0, 1], fov: FOV, valid: false },
|
|
54
56
|
rideMotion: 0,
|
|
55
57
|
satellites: newSatelliteState(),
|
|
58
|
+
meteors: newMeteorState(),
|
|
56
59
|
pick: null,
|
|
57
60
|
ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
|
|
58
61
|
});
|
|
@@ -231,6 +234,8 @@ export function createSpaceItem(model, deps) {
|
|
|
231
234
|
}
|
|
232
235
|
const moonSlots = new Map();
|
|
233
236
|
let releaseTimer;
|
|
237
|
+
let meteors = null;
|
|
238
|
+
let meteorTimer;
|
|
234
239
|
let layer;
|
|
235
240
|
const rideState = new Float64Array(6);
|
|
236
241
|
let selectedShown = false;
|
|
@@ -535,6 +540,20 @@ export function createSpaceItem(model, deps) {
|
|
|
535
540
|
deps.onSelected(at);
|
|
536
541
|
selectedShown = at !== null;
|
|
537
542
|
}
|
|
543
|
+
// 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
|
|
544
|
+
if (model.meteors.on && !meteors)
|
|
545
|
+
meteors = createMeteorLayer(three, earth, model.meteors);
|
|
546
|
+
if (meteors) {
|
|
547
|
+
// the camera's place, turned into the Earth's own axes (the Earth is at the middle of the scene and turns about its pole)
|
|
548
|
+
const turn = earth.rotation.y;
|
|
549
|
+
const fx = camera.position.x * Math.cos(turn) - camera.position.z * Math.sin(turn);
|
|
550
|
+
const fz = camera.position.x * Math.sin(turn) + camera.position.z * Math.cos(turn);
|
|
551
|
+
const far = Math.hypot(fx, camera.position.y, fz) || 1;
|
|
552
|
+
const wait = meteors.step({ now: performance.now(), time: model.time, facing: [fx / far, camera.position.y / far, fz / far], sun: unitVector(subsolarPoint(model.time)), radius: Math.min(px.Earth, 1e5), width: size.width, height: size.height });
|
|
553
|
+
if (meteorTimer !== undefined)
|
|
554
|
+
clearTimeout(meteorTimer);
|
|
555
|
+
meteorTimer = Number.isFinite(wait) ? setTimeout(() => deps.invalidate(), wait) : undefined;
|
|
556
|
+
}
|
|
538
557
|
if (model.rideLost)
|
|
539
558
|
deps.onRideLost?.();
|
|
540
559
|
if (model.transition)
|
|
@@ -547,6 +566,9 @@ export function createSpaceItem(model, deps) {
|
|
|
547
566
|
dispose() {
|
|
548
567
|
if (releaseTimer !== undefined)
|
|
549
568
|
clearTimeout(releaseTimer);
|
|
569
|
+
if (meteorTimer !== undefined)
|
|
570
|
+
clearTimeout(meteorTimer);
|
|
571
|
+
meteors?.dispose();
|
|
550
572
|
layer?.dispose();
|
|
551
573
|
model.pick = null;
|
|
552
574
|
textures.dispose();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/chikyu-earth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.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 where you are, 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",
|
|
@@ -119,6 +119,11 @@
|
|
|
119
119
|
"import": "./dist/space/element.js",
|
|
120
120
|
"default": "./dist/space/element.js"
|
|
121
121
|
},
|
|
122
|
+
"./meteors": {
|
|
123
|
+
"types": "./dist/meteors/index.d.ts",
|
|
124
|
+
"import": "./dist/meteors/index.js",
|
|
125
|
+
"default": "./dist/meteors/index.js"
|
|
126
|
+
},
|
|
122
127
|
"./satellites": {
|
|
123
128
|
"types": "./dist/satellites/index.d.ts",
|
|
124
129
|
"import": "./dist/satellites/index.js",
|