@johnmorrisdotca/chikyu-earth 0.46.0 → 0.46.2

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.
@@ -228,6 +228,18 @@ export interface SpaceModel {
228
228
  y: number;
229
229
  shown: boolean;
230
230
  parts: number;
231
+ radiusPx: number;
232
+ box: {
233
+ left: number;
234
+ top: number;
235
+ right: number;
236
+ bottom: number;
237
+ };
238
+ axes: {
239
+ x: Vec3;
240
+ y: Vec3;
241
+ z: Vec3;
242
+ };
231
243
  } | null;
232
244
  /** The map tiles laid over the Earth while the scene is built: what they are doing, for a page or a test. */
233
245
  tiles: TileSet | null;
@@ -435,6 +447,8 @@ export interface SpaceDeps {
435
447
  sources?: () => TileSources;
436
448
  /** Told once when the tile set has been read: the width in pixels of the finest level of each of its layers. */
437
449
  onTiles?: (layers: Record<string, number>) => void;
450
+ /** Told at the end of a draw, after the map tiles are placed, so a credit line can follow which tiles are on screen. */
451
+ onTilesDrawn?: () => void;
438
452
  }
439
453
  /**
440
454
  * The default look: a sphere in the planet's colour, lit by the Sun, and for the Sun a glowing disc.
@@ -24,7 +24,9 @@ const MAX_MARKED = 80;
24
24
  const RAD = Math.PI / 180;
25
25
  const FOV = 35;
26
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;
27
+ const OUTSIDE_RADIUS_SHARE = 0.1;
28
+ /** 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.17;
28
30
  /** 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. */
29
31
  export const DEFAULT_EARTH_SIZE = 0.9;
30
32
  /**
@@ -372,7 +374,7 @@ export function createSpaceItem(model, deps) {
372
374
  let routeLayer = null;
373
375
  let marksTold = false;
374
376
  // 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
375
- const modelSlot = { key: "", drawing: null, turn: 0, parts: 0 };
377
+ const modelSlot = { key: "", drawing: null, turn: 0, parts: 0, axes: null };
376
378
  const dropModel = () => {
377
379
  if (!modelSlot.drawing)
378
380
  return;
@@ -753,6 +755,7 @@ export function createSpaceItem(model, deps) {
753
755
  },
754
756
  };
755
757
  tiles.sync({ lon: 0, lat: 0, width: size.width, height: size.height, panX: 0, panY: 0, radius: focal / away, perspective: look }, [sunLocal.value.x, sunLocal.value.y, sunLocal.value.z], true, model.ratio());
758
+ deps.onTilesDrawn?.();
756
759
  }
757
760
  let paintedBodies = sunSlot.drawing ? 1 : 0;
758
761
  for (const p of planets.values())
@@ -812,13 +815,19 @@ export function createSpaceItem(model, deps) {
812
815
  .catch((error) => deps.onPainterError?.(error));
813
816
  }
814
817
  }
815
- const axes = shownSat ? satelliteAxes(shownSat.place, shownSat.velocity) : null;
818
+ // the model's attitude is the track frame (x along the way it goes, level; z straight up). A moment with no level speed keeps the last good frame, so the model neither drops nor turns (MODULES-1303)
819
+ const freshAxes = shownSat ? satelliteAxes(shownSat.place, shownSat.velocity) : null;
820
+ if (freshAxes)
821
+ modelSlot.axes = freshAxes;
822
+ else if (!shownSat)
823
+ modelSlot.axes = null;
824
+ const axes = freshAxes ?? (shownSat ? modelSlot.axes : null);
816
825
  // a generic drawing is for an outside ride only; a page's model is drawn wherever the camera is not at the satellite
817
826
  const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (followed !== null && painted));
818
827
  if (modelSlot.drawing && shownSat && axes && drawn) {
819
828
  const object = modelSlot.drawing.object;
820
829
  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;
830
+ const share = followed ? MODEL_RADIUS_SHARE : ride?.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE;
822
831
  object.matrix.set(...modelMatrix(shownSat.place, axes, modelRadius(away, half, share, 1e-9)));
823
832
  object.matrixWorldNeedsUpdate = true;
824
833
  object.visible = true;
@@ -826,7 +835,10 @@ export function createSpaceItem(model, deps) {
826
835
  modelSlot.drawing.light?.(toSunNow);
827
836
  modelSlot.drawing.update?.({ toSun: toSunNow, ms: model.time, radiusPx: size.height * share });
828
837
  projected.set(shownSat.place[0], shownSat.place[1], shownSat.place[2]).project(camera);
829
- model.followModel = { x: ((projected.x + 1) / 2) * size.width, y: ((1 - projected.y) / 2) * size.height, shown: true, parts: modelSlot.parts };
838
+ const sx = ((projected.x + 1) / 2) * size.width;
839
+ const sy = ((1 - projected.y) / 2) * size.height;
840
+ const radiusPx = size.height * share;
841
+ 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 };
830
842
  }
831
843
  else {
832
844
  if (modelSlot.drawing)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.46.0",
3
+ "version": "0.46.2",
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",