@johnmorrisdotca/chikyu-earth 0.46.4 → 0.46.6

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.
@@ -9,7 +9,7 @@ import { faceOffset, outsidePose, ridePose } from "./ride.js";
9
9
  import { genericSatellite, satelliteKind } from "./generic-satellite.js";
10
10
  import { coverBody, covers } from "../sky/cover.js";
11
11
  import { beginPlaceSprites, createPlaceSprites } from "../markers/place-sprites.js";
12
- import { aboveAxes, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
12
+ import { ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
13
13
  import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
14
14
  import { paintMinute } from "../paint/buffer.js";
15
15
  import { createPaintTexture } from "../paint/texture.js";
@@ -17,6 +17,7 @@ import { createBodyLabelLayer, newBodyLabelState } from "../realistic/body-label
17
17
  import { createMeteorLayer, newMeteorState } from "../meteors/layer.js";
18
18
  import { createBorderLayer, newBorderState } from "../borders/layer.js";
19
19
  import { createGridLayer, newGridState } from "../grid/layer.js";
20
+ import { createBeamLayer, newBeamState } from "../beam/layer.js";
20
21
  import { createRouteLayer, newRouteState } from "../route/layer.js";
21
22
  import { subsolarPoint, unitVector } from "../realistic/sun.js";
22
23
  /** The most satellites ringed and named at once, over all the labelled groups. */
@@ -113,6 +114,7 @@ export const newSpaceModel = () => ({
113
114
  bodyLabel: newBodyLabelState(),
114
115
  borders: newBorderState(),
115
116
  grid: newGridState(),
117
+ beam: newBeamState(),
116
118
  route: newRouteState(),
117
119
  pick: null,
118
120
  placeSatellite: null,
@@ -371,6 +373,8 @@ export function createSpaceItem(model, deps) {
371
373
  let borders = null;
372
374
  const placeRings = { sprites: null, tried: false };
373
375
  let gridLayer = null;
376
+ let beamLayer = null;
377
+ const beamAt = new Float64Array(6);
374
378
  let routeLayer = null;
375
379
  let marksTold = false;
376
380
  // 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
@@ -512,6 +516,18 @@ export function createSpaceItem(model, deps) {
512
516
  deps.onSatellitesError?.(error);
513
517
  }
514
518
  }
519
+ // the ridden satellite is drawn as its model while the model is big enough to read; its ring and name (the page's choice of it, or the marks) are left off exactly then, and come back when the model has shrunk to the size of a ring (MODULES-1303, 1306)
520
+ {
521
+ const riding = model.ride;
522
+ let over = null;
523
+ if (riding && riding.viewpoint === "outside" && typeof riding.target !== "string") {
524
+ const kmAbove = riding.distanceKm / Math.max(1e-9, model.view.zoom);
525
+ const would = riding.view === "above" ? (riding.modelSize === "fixed" ? ABOVE_MODEL_SHARE : aboveModelShare(kmAbove)) : riding.view === "from" ? (riding.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE) : MODEL_RADIUS_SHARE;
526
+ if (would * size.height >= MODEL_HANDOVER_PX)
527
+ over = riding.target;
528
+ }
529
+ model.satellites.modelOver = over;
530
+ }
515
531
  layer?.update(model.time, model.speed, model.drawn?.radiusPx ?? 0);
516
532
  model.pick = layer ? (x, y, radius) => layer.pick(x, y, camera, size, radius) : null;
517
533
  // 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; or, riding along, sits at the
@@ -824,10 +840,12 @@ export function createSpaceItem(model, deps) {
824
840
  const axes = freshAxes ?? (shownSat ? modelSlot.axes : null);
825
841
  // a generic drawing is for an outside ride only; a page's model is drawn wherever the camera is not at the satellite
826
842
  const drawn = shownSat !== null && (ride?.viewpoint === "outside" || (followed !== null && painted));
827
- if (modelSlot.drawing && shownSat && axes && drawn) {
843
+ const aboveShare = followed && ride?.view === "above" && ride.modelSize !== "fixed" ? aboveModelShare(Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z) * 6371) : 1;
844
+ // from far above the satellite is a point: the model has shrunk to nothing and the ordinary mark is all there is
845
+ if (modelSlot.drawing && shownSat && axes && drawn && aboveShare * size.height >= 0.5) {
828
846
  const object = modelSlot.drawing.object;
829
847
  const away = Math.hypot(shownSat.place[0] - camera.position.x, shownSat.place[1] - camera.position.y, shownSat.place[2] - camera.position.z);
830
- const share = followed ? MODEL_RADIUS_SHARE : ride?.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE;
848
+ const share = followed ? (ride?.view === "above" ? (ride.modelSize === "fixed" ? ABOVE_MODEL_SHARE : aboveModelShare(away * 6371)) : MODEL_RADIUS_SHARE) : ride?.look === "horizon" ? OUTSIDE_ALONG_SHARE : OUTSIDE_RADIUS_SHARE;
831
849
  object.matrix.set(...modelMatrix(shownSat.place, axes, modelRadius(away, half, share, 1e-9)));
832
850
  object.matrixWorldNeedsUpdate = true;
833
851
  object.visible = true;
@@ -1112,6 +1130,20 @@ export function createSpaceItem(model, deps) {
1112
1130
  }
1113
1131
  }
1114
1132
  gridLayer?.sync(Math.min(px.Earth, 1e5));
1133
+ // the beam, from the chosen satellite (the one ridden, else the one marked) to the ground below it: made the first time it is switched on
1134
+ if (model.beam.on && !beamLayer && !model.beam.stats.failed) {
1135
+ try {
1136
+ beamLayer = createBeamLayer(three, scene, model.beam, 7);
1137
+ }
1138
+ catch (error) {
1139
+ model.beam.stats.failed = true;
1140
+ model.beam.onError?.(error);
1141
+ }
1142
+ }
1143
+ if (beamLayer) {
1144
+ const chosen = model.ride && typeof model.ride.target === "object" ? model.ride.target : model.satellites.selected;
1145
+ beamLayer.sync(model.beam.on && chosen && layer?.exact(chosen, model.time, beamAt) ? [beamAt[0], beamAt[1], beamAt[2]] : null);
1146
+ }
1115
1147
  if ((model.route.ends || routeLayer) && !routeLayer && !model.route.failed) {
1116
1148
  try {
1117
1149
  routeLayer = createRouteLayer(three, earth, model.route);
@@ -1145,6 +1177,7 @@ export function createSpaceItem(model, deps) {
1145
1177
  borders?.dispose();
1146
1178
  placeRings.sprites?.dispose();
1147
1179
  gridLayer?.dispose();
1180
+ beamLayer?.dispose();
1148
1181
  routeLayer?.dispose();
1149
1182
  modelSlot.turn += 1;
1150
1183
  dropModel();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.46.4",
3
+ "version": "0.46.6",
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",