@johnmorrisdotca/chikyu-earth 0.7.0 → 0.8.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.
@@ -3,6 +3,7 @@ import { ATMOSPHERE_FRAG, ATMOSPHERE_VERT, BODY_FRAG, CLOUD_FRAG, GLOW_FRAG, GLO
3
3
  import { createTextureSet } from "../realistic/textures.js";
4
4
  import { createTrack, orbitPath, PLANETS } from "./ephemeris.js";
5
5
  import { placeAround, placeMoon, placeSun, RADIUS } from "./scale.js";
6
+ import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
6
7
  const RAD = Math.PI / 180;
7
8
  /** The camera's distance, in Earth radii, at which the Earth fills the view at zoom 1. */
8
9
  export const FIT_DISTANCE = 3.4;
@@ -34,6 +35,9 @@ export const newSpaceModel = () => ({
34
35
  focus: "Earth",
35
36
  drawn: null,
36
37
  lookups: 0,
38
+ speed: 1,
39
+ satellites: newSatelliteState(),
40
+ pick: null,
37
41
  ratio: () => Math.min(globalThis.devicePixelRatio || 1, 2),
38
42
  });
39
43
  /** An inertial direction from the Earth's centre, in scene axes, for right ascension and declination in degrees. */
@@ -162,6 +166,8 @@ export function createSpaceItem(model, deps) {
162
166
  scene.add(drawing.object, orbit);
163
167
  planets.set(name, { drawing, orbit, positions, samples: [], epoch: Number.NaN });
164
168
  }
169
+ let layer;
170
+ let selectedShown = false;
165
171
  const camera = new three.PerspectiveCamera(FOV, width / Math.max(1, height), 0.05, 1000);
166
172
  const target = new three.Vector3();
167
173
  const projected = new three.Vector3();
@@ -229,6 +235,17 @@ export function createSpaceItem(model, deps) {
229
235
  p.orbit.geometry.getAttribute("position").needsUpdate = true;
230
236
  }
231
237
  }
238
+ if (!layer && model.satellites.groups.size > 0) {
239
+ try {
240
+ layer = createSatelliteLayer(three, scene, model.satellites, model.ratio);
241
+ }
242
+ catch (error) {
243
+ model.satellites.groups.clear();
244
+ deps.onSatellitesError?.(error);
245
+ }
246
+ }
247
+ layer?.update(model.time, model.speed);
248
+ model.pick = layer ? (x, y, radius) => layer.pick(x, y, camera, size, radius) : null;
232
249
  // the camera: looks at the focus body from the direction the sky was in when it was last moved, turned by yaw and tilt, as far as the zoom says
233
250
  const focus = model.focus;
234
251
  const focusRadius = radiusOf(focus);
@@ -269,12 +286,20 @@ export function createSpaceItem(model, deps) {
269
286
  }
270
287
  deps.onLabels(places);
271
288
  }
289
+ if (layer && deps.onSelected) {
290
+ const at = model.satellites.selected ? layer.place(camera, size) : null;
291
+ if (at || selectedShown)
292
+ deps.onSelected(at);
293
+ selectedShown = at !== null;
294
+ }
272
295
  return false;
273
296
  },
274
297
  resize(w, h) {
275
298
  size = { width: w, height: h };
276
299
  },
277
300
  dispose() {
301
+ layer?.dispose();
302
+ model.pick = null;
278
303
  textures.dispose();
279
304
  sunDrawing.dispose();
280
305
  for (const p of planets.values()) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.7.0",
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, and markers for any place. A web component and an SVG string.",
3
+ "version": "0.8.0",
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",
7
7
  "globe",
@@ -31,7 +31,13 @@
31
31
  "solar-system",
32
32
  "moon",
33
33
  "planets",
34
- "ephemeris"
34
+ "ephemeris",
35
+ "satellites",
36
+ "sgp4",
37
+ "orbits",
38
+ "iss",
39
+ "starlink",
40
+ "celestrak"
35
41
  ],
36
42
  "homepage": "https://johnmorrisdotca.github.io/chikyu-earth/",
37
43
  "repository": {
@@ -91,6 +97,11 @@
91
97
  "import": "./dist/space/element.js",
92
98
  "default": "./dist/space/element.js"
93
99
  },
100
+ "./satellites": {
101
+ "types": "./dist/satellites/index.d.ts",
102
+ "import": "./dist/satellites/index.js",
103
+ "default": "./dist/satellites/index.js"
104
+ },
94
105
  "./package.json": "./package.json"
95
106
  },
96
107
  "files": [
@@ -134,7 +145,8 @@
134
145
  "peerDependencies": {
135
146
  "@johnmorrisdotca/kazoku-ui": ">=0.9.0",
136
147
  "three": ">=0.160.0",
137
- "astronomy-engine": ">=2.1.0"
148
+ "astronomy-engine": ">=2.1.0",
149
+ "satellite.js": ">=6.0.0"
138
150
  },
139
151
  "peerDependenciesMeta": {
140
152
  "@johnmorrisdotca/kazoku-ui": {
@@ -145,6 +157,9 @@
145
157
  },
146
158
  "astronomy-engine": {
147
159
  "optional": true
160
+ },
161
+ "satellite.js": {
162
+ "optional": true
148
163
  }
149
164
  },
150
165
  "devDependencies": {
@@ -171,6 +186,7 @@
171
186
  "react": "^19.3.1",
172
187
  "react-dom": "^19.3.1",
173
188
  "rxjs": "^7.8.2",
189
+ "satellite.js": "6.0.2",
174
190
  "svelte": "^5.57.3",
175
191
  "three": "0.186.1",
176
192
  "typescript": "^5.9.0",