spacemap 0.1.2 → 0.1.3

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/index.d.ts CHANGED
@@ -273,6 +273,7 @@ export declare type ControlPosition = 'top-left' | 'top-right' | 'bottom-left' |
273
273
  export declare interface CoreMessages {
274
274
  body_note_no_model: () => string;
275
275
  body_note_no_radius: () => string;
276
+ body_note_crash_site: () => string;
276
277
  carried_by_scene_label: (inputs: {
277
278
  carrier: string;
278
279
  }) => string;
package/index.js CHANGED
@@ -24,6 +24,7 @@ var DEFAULT_HOST = {
24
24
  messages: {
25
25
  body_note_no_model: () => "no model available",
26
26
  body_note_no_radius: () => "no size data available",
27
+ body_note_crash_site: () => "crash site, no wreckage model",
27
28
  carried_by_scene_label: ({ carrier }) => `Carried by ${carrier}`,
28
29
  scene_canvas_label: () => "Interactive 3D map of the Solar System",
29
30
  attribution_orbits: () => "Orbits",
@@ -6434,8 +6435,8 @@ var loadProgress = new LoadProgress();
6434
6435
  //#endregion
6435
6436
  //#region src/lib/fetch/fetch-timeout.ts
6436
6437
  var BOOT_FETCH_TIMEOUT_MS = 3e4;
6437
- function countBootBytes(res) {
6438
- if (!loadProgress.active || !res.body) return res;
6438
+ function countBootBytes(res, background) {
6439
+ if (background || !loadProgress.active || !res.body) return res;
6439
6440
  const total = Number(res.headers.get("content-length"));
6440
6441
  if (!Number.isFinite(total) || total <= 0) return res;
6441
6442
  loadProgress.announce(total);
@@ -6458,7 +6459,7 @@ async function fetchWithTimeout(input, init = {}, timeoutMs = BOOT_FETCH_TIMEOUT
6458
6459
  return countBootBytes(await fetch(input, {
6459
6460
  ...init,
6460
6461
  signal: controller.signal
6461
- }));
6462
+ }), init.priority === "low");
6462
6463
  } catch (e) {
6463
6464
  if (controller.signal.aborted && !init.signal?.aborted) throw new Error(`Request timed out after ${timeoutMs} ms: ${input}`, { cause: e });
6464
6465
  throw e;
@@ -7307,6 +7308,7 @@ function parseKeplerPayload(buffer, offset, method, float64) {
7307
7308
  var LANDED_LATLNG_SCALE = 1e-7;
7308
7309
  var LANDED_ALT_MM_SCALE = .001;
7309
7310
  var LANDED_FLAG_STATIC = 1;
7311
+ var LANDED_FLAG_DESTROYED = 2;
7310
7312
  var LANDED_SAMPLE_SIZE = 16;
7311
7313
  var LANDED_HEADER_SIZE = 32;
7312
7314
  function parseLandedPayload(buffer, offset, chunkStartEt) {
@@ -7336,6 +7338,7 @@ function parseLandedPayload(buffer, offset, chunkStartEt) {
7336
7338
  return {
7337
7339
  bodyNaifId,
7338
7340
  isStatic: (flagsByte & LANDED_FLAG_STATIC) !== 0,
7341
+ isDestroyed: (flagsByte & LANDED_FLAG_DESTROYED) !== 0,
7339
7342
  startEt: chunkStartEt + startOffsetS,
7340
7343
  endEt: chunkStartEt + endOffsetS,
7341
7344
  latRefDeg,
@@ -9549,7 +9552,7 @@ function memoizedGzJson(url, opts = {}) {
9549
9552
  //#region src/lib/fetch/bundle-cache.ts
9550
9553
  var MAX_BUNDLES = 24;
9551
9554
  var cache$2 = /* @__PURE__ */ new Map();
9552
- function fetchGzipBundle(url) {
9555
+ function fetchGzipBundle(url, init) {
9553
9556
  let p = cache$2.get(url);
9554
9557
  if (p) {
9555
9558
  cache$2.delete(url);
@@ -9557,7 +9560,7 @@ function fetchGzipBundle(url) {
9557
9560
  }
9558
9561
  if (!p) {
9559
9562
  p = (async () => {
9560
- const res = await fetchWithTimeout(url);
9563
+ const res = await fetchWithTimeout(url, init);
9561
9564
  if (!res.ok) {
9562
9565
  if (res.status === 404) return {};
9563
9566
  throw new Error(`fetchGzipBundle: ${url} returned ${res.status} ${res.statusText}`);
@@ -13101,6 +13104,7 @@ async function loadSpacecraftModel(bo, modelScene, ctx) {
13101
13104
  fitToUnitRadius(root, anchor && baseFrame ? anchor.applyQuaternion(baseFrame) : anchor);
13102
13105
  enableShadows(root);
13103
13106
  modelScene.add(root);
13107
+ root.visible = !bo.isCrashed;
13104
13108
  bo.model = root;
13105
13109
  bo.modelName = slug;
13106
13110
  setHaloLoading(bo, false);
@@ -14121,11 +14125,16 @@ function refreshVisibleBodyLabelRects(bodyObjects, screenWidth, screenHeight, ca
14121
14125
  //#region src/lib/scene/label/factory.ts
14122
14126
  var SPACECRAFT_ICON_D = "M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z";
14123
14127
  var LANDED_PROBE_ICON_D = "M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z";
14124
- function setSpacecraftLanded(halo, landed) {
14128
+ var SPACECRAFT_GLYPH_D = {
14129
+ flying: SPACECRAFT_ICON_D,
14130
+ landed: LANDED_PROBE_ICON_D,
14131
+ crashed: LANDED_PROBE_ICON_D + "M15 9l-6 6M9 9l6 6"
14132
+ };
14133
+ function setSpacecraftGlyph(halo, glyph) {
14125
14134
  if (!halo) return;
14126
14135
  const path = halo.querySelector("path");
14127
14136
  if (!path) return;
14128
- path.setAttribute("d", landed ? LANDED_PROBE_ICON_D : SPACECRAFT_ICON_D);
14137
+ path.setAttribute("d", SPACECRAFT_GLYPH_D[glyph]);
14129
14138
  }
14130
14139
  function addLabelNameSpan(el, name, variant, isLarge) {
14131
14140
  const span = document.createElement("span");
@@ -16334,6 +16343,8 @@ function attachRingBundles(bodyId, systemId, rings, radii, bo, scene, maxTexture
16334
16343
  return;
16335
16344
  }
16336
16345
  node.mesh.userData.ringBundle = ringMeta.bundle;
16346
+ const host = bo.mesh ?? bo.model;
16347
+ if (host) node.mesh.quaternion.copy(host.quaternion);
16337
16348
  bo.rings.push(node);
16338
16349
  scene.add(node.mesh);
16339
16350
  bo.extraObjects.push(node.mesh);
@@ -19910,9 +19921,15 @@ function updateBodyVisibility(bodyObjects, camera, ctx, focusTruePos, focusedBod
19910
19921
  const cameraInverse = camera.matrixWorldInverse;
19911
19922
  for (const bo of bodyObjects.values()) {
19912
19923
  bo.cachedDist = f64dist(camTrue, bo.body.position);
19913
- if (bo.noPhysical) {
19924
+ if (bo.isCrashed || bo.noPhysical) {
19914
19925
  const isModel = bo.noPhysical === "model";
19915
- setLabelAnnotation(bo, "missing", sceneToKm(bo.cachedDist) < (isModel ? .1 : 1) ? isModel ? host().messages.body_note_no_model() : host().messages.body_note_no_radius() : null);
19926
+ const near = sceneToKm(bo.cachedDist) < (bo.isCrashed || isModel ? .1 : 1);
19927
+ let text = null;
19928
+ if (near) {
19929
+ const m = host().messages;
19930
+ text = bo.isCrashed ? m.body_note_crash_site() : isModel ? m.body_note_no_model() : m.body_note_no_radius();
19931
+ }
19932
+ setLabelAnnotation(bo, "missing", text);
19916
19933
  }
19917
19934
  const label = bo.label;
19918
19935
  if (!label) continue;
@@ -21356,10 +21373,13 @@ function updatePositions(params) {
21356
21373
  if (flyingFrameId !== d.parentId) body.trailBuffer?.clear();
21357
21374
  if (bo) {
21358
21375
  bo.outOfRange = false;
21359
- if (!bo.isLanded) {
21360
- setSpacecraftLanded(bo.labelHalo, true);
21376
+ const crashed = probeLanded.isDestroyed;
21377
+ if (!bo.isLanded || bo.isCrashed !== crashed) {
21378
+ setSpacecraftGlyph(bo.labelHalo, crashed ? "crashed" : "landed");
21361
21379
  bo.isLanded = true;
21380
+ bo.isCrashed = crashed;
21362
21381
  }
21382
+ if (bo.model) bo.model.visible = !crashed;
21363
21383
  }
21364
21384
  body.position[0] = landedRender.x;
21365
21385
  body.position[1] = landedRender.y;
@@ -21398,8 +21418,13 @@ function updatePositions(params) {
21398
21418
  }
21399
21419
  diagnostics.clear("probe-unavailable", d.id);
21400
21420
  if (bo?.isLanded) {
21401
- setSpacecraftLanded(bo.labelHalo, false);
21421
+ setSpacecraftGlyph(bo.labelHalo, "flying");
21402
21422
  bo.isLanded = false;
21423
+ if (bo.isCrashed) {
21424
+ bo.isCrashed = false;
21425
+ if (bo.model) bo.model.visible = true;
21426
+ if (!bo.noPhysical) setLabelAnnotation(bo, "missing", null);
21427
+ }
21403
21428
  }
21404
21429
  const earthPos = positionMap.get(EARTH_ID);
21405
21430
  const sunPos = positionMap.get(SUN_ID);
@@ -23362,6 +23387,9 @@ function resolvePose(pose, ctx, jd) {
23362
23387
  //#region src/lib/scene/camera/motion-scale.ts
23363
23388
  var MIN_TRANSLATE_SCALE = .02;
23364
23389
  var MIN_ROTATE_SCALE = 1e-4;
23390
+ function orbitDamping(reducedMotion) {
23391
+ return reducedMotion ? .4 : .05;
23392
+ }
23365
23393
  function cameraMotionScale(camera, focusTruePos, focused, parent, seated) {
23366
23394
  const orbitRadius = camera.position.length();
23367
23395
  if (!(orbitRadius > 0)) return {
@@ -23437,8 +23465,6 @@ function updateUserLocationOcclusion(marker, bodyObjects, camera) {
23437
23465
  //#endregion
23438
23466
  //#region src/lib/scene/renderer.ts
23439
23467
  var NO_TOUCH_GESTURE = -1;
23440
- var DEFAULT_DAMPING = .05;
23441
- var REDUCED_MOTION_DAMPING = .4;
23442
23468
  var FAR_MARGIN = 1.2;
23443
23469
  var FAR_MIN = kmToScene(1e6);
23444
23470
  var FAR_UPDATE_EPS = .02;
@@ -23667,7 +23693,7 @@ var SceneRenderer = class SceneRenderer {
23667
23693
  this.pointClouds.setPointBudget(this.tier.pointBudget);
23668
23694
  this.controls = new OrbitControls(this.camera, canvas);
23669
23695
  this.controls.enableDamping = true;
23670
- this.controls.dampingFactor = sceneSettings().resolvedReducedMotion ? REDUCED_MOTION_DAMPING : DEFAULT_DAMPING;
23696
+ this.controls.dampingFactor = orbitDamping(sceneSettings().resolvedReducedMotion);
23671
23697
  this.controls.minDistance = focusBody ? minCameraDistance(focusBody) : kmToScene(.01);
23672
23698
  this.controls.maxDistance = 31620.5 * 10;
23673
23699
  this.controls.target.set(0, 0, 0);
@@ -24249,7 +24275,7 @@ var SceneRenderer = class SceneRenderer {
24249
24275
  if (this.modelShadowPlane) {
24250
24276
  this._tmpUp.set(0, 1, 0).applyQuaternion(bo.model.quaternion);
24251
24277
  const daytime = this._tmpSun.dot(this._tmpUp) > .03;
24252
- this.modelShadowPlane.visible = Boolean(bo.isLanded) && daytime;
24278
+ this.modelShadowPlane.visible = Boolean(bo.isLanded) && !bo.isCrashed && daytime;
24253
24279
  if (this.modelShadowPlane.visible) this.modelShadowPlane.quaternion.setFromUnitVectors(this._planeNormal, this._tmpUp);
24254
24280
  }
24255
24281
  this._tmpV3.set(0, 0, 0);
@@ -24555,7 +24581,7 @@ var SceneRenderer = class SceneRenderer {
24555
24581
  }
24556
24582
  }
24557
24583
  setReducedMotion(on) {
24558
- this.controls.dampingFactor = on ? REDUCED_MOTION_DAMPING : DEFAULT_DAMPING;
24584
+ this.controls.dampingFactor = orbitDamping(on);
24559
24585
  }
24560
24586
  focusOnBody(id, zoom, latitude, longitude) {
24561
24587
  this.disarmLimits();
@@ -30308,10 +30334,16 @@ function kmToAu(km) {
30308
30334
 
30309
30335
  //#endregion
30310
30336
  //#region src/lib/fetch/panoramas.ts
30311
- async function fetchPanoramaIndex(fetcher = fetchWithTimeout) {
30312
- const res = await fetcher(`${dataBase()}/v1/panoramas.json`);
30313
- if (!res.ok) throw new Error(`Failed to load panoramas.json: ${res.status}`);
30314
- return (await res.json()).bodies ?? [];
30337
+ var index = null;
30338
+ function fetchPanoramaIndex(fetcher = fetchWithTimeout) {
30339
+ if (index) return index;
30340
+ index = (async () => {
30341
+ const res = await fetcher(`${dataBase()}/v1/panoramas.json`);
30342
+ if (!res.ok) throw new Error(`Failed to load panoramas.json: ${res.status}`);
30343
+ return (await res.json()).bodies ?? [];
30344
+ })();
30345
+ index.catch(() => index = null);
30346
+ return index;
30315
30347
  }
30316
30348
  async function fetchPanoramas(bodyId) {
30317
30349
  return (await fetchObjectDetail(bodyId, false)).global?.panoramas ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spacemap",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "The map of the Solar System from spacemap.co, on your website!",
5
5
  "keywords": ["solar system", "spacecraft", "orbits", "map", "three.js"],
6
6
  "homepage": "https://spacemap.co",