@johnmorrisdotca/chikyu-earth 0.53.0 → 0.54.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.
@@ -13,6 +13,8 @@ import { genericSatellite, satelliteKind } from "./generic-satellite.js";
13
13
  import { followSpin } from "./follow.js";
14
14
  import { coverBody, covers } from "../sky/cover.js";
15
15
  import { beginPlaceSprites, createPlaceSprites } from "../markers/place-sprites.js";
16
+ import { localNorth, northUpYaw, screenAngle } from "./north-up.js";
17
+ import { trackStateOfScene } from "../flat/track-state.js";
16
18
  import { ABOVE_MODEL_SHARE, aboveAxes, aboveModelShare, MODEL_HANDOVER_PX, MODEL_RADIUS_SHARE, modelMatrix, modelRadius, satelliteAxes } from "./satellite-model.js";
17
19
  import { createSatelliteLayer, newSatelliteState } from "./satellite-layer.js";
18
20
  import { paintMinute } from "../paint/buffer.js";
@@ -133,6 +135,7 @@ export const newSpaceModel = () => ({
133
135
  pose: { p: [0, 0, 0], q: [0, 0, 0, 1], fov: FOV, valid: false },
134
136
  rideMotion: 0,
135
137
  rideTurn: 0,
138
+ rideTrack: null,
136
139
  rideDistance: null,
137
140
  satellites: newSatelliteState(),
138
141
  meteors: newMeteorState(),
@@ -698,7 +701,9 @@ export function createSpaceItem(model, deps) {
698
701
  // A facing puts the camera ahead, behind, left, right, down or up; a drag turns and tips from there.
699
702
  distance = Math.max(1e-4, ride.distanceKm / 6371 / Math.max(1e-9, model.view.zoom));
700
703
  const base = ride.face ? faceOffset(ride.face) : { yaw: 0, tilt: 0 };
701
- const up = aboveAxes(followed.place, followed.velocity, base.yaw + model.view.yaw * RAD, base.tilt + Math.max(-80, Math.min(80, model.view.tilt)) * RAD);
704
+ // north up (the view above a satellite only): the picture is turned so north is at the top, less near a pole; a drag turns it from there
705
+ const north = ride.view === "above" && ride.up === "north" ? northUpYaw(followed.place, followed.velocity) : null;
706
+ const up = aboveAxes(followed.place, followed.velocity, base.yaw + (north ? north.yaw * north.weight : 0) + model.view.yaw * RAD, base.tilt + Math.max(-80, Math.min(80, model.view.tilt)) * RAD);
702
707
  target.set(focusPos[0], focusPos[1], focusPos[2]);
703
708
  camera.position.set(target.x + up.offset[0] * distance, target.y + up.offset[1] * distance, target.z + up.offset[2] * distance);
704
709
  camera.up.set(up.up[0], up.up[1], up.up[2]);
@@ -755,6 +760,18 @@ export function createSpaceItem(model, deps) {
755
760
  camera.clearViewOffset();
756
761
  camera.updateProjectionMatrix();
757
762
  camera.updateMatrixWorld();
763
+ // the ridden satellite's heading and where north is in the picture, worked out with the draw that is being made, never on a timer
764
+ {
765
+ const sat = followed ?? ridden;
766
+ if (sat && ride) {
767
+ const state = trackStateOfScene(sat.place, sat.velocity, model.time);
768
+ const north = localNorth(sat.place);
769
+ const northDeg = north ? screenAngle([camera.quaternion.x, camera.quaternion.y, camera.quaternion.z, camera.quaternion.w], north) : null;
770
+ model.rideTrack = { ...state, northDeg, travelDeg: northDeg === null ? null : (northDeg + state.bearingDeg) % 360 };
771
+ }
772
+ else
773
+ model.rideTrack = null;
774
+ }
758
775
  // always lit: the light comes from the camera's side of the Earth (the Sun, Moon and planets stay where they are)
759
776
  if (model.light === "lit")
760
777
  sunEarth.value.set(camera.position.x, camera.position.y, camera.position.z).normalize();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnmorrisdotca/chikyu-earth",
3
- "version": "0.53.0",
3
+ "version": "0.54.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 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",