mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
feat(cockpit): keep the orbital camera on a ground target
In the satellite orbital view a single click on a mapped ground point (a ground point of a layer that is on, such as a Mapped Installations site, a fire or a local data pack feature) keeps the camera on it. Each frame the look is aimed from the satellite's position to the point's Earth-fixed position in the track-up nadir frame the arrows tilt, so the point stays at the centre as the satellite moves. The swing onto the point, or between points, uses the arrows' easing on a slower clock and then holds the point exactly; reduced motion cuts. A click elsewhere, FOCUS on the focused point, NADIR, Home or 0 ends the focus and the view eases back to nadir; an arrow ends it and tilts on from where the view is. The focus also ends, easing back, when the point leaves the ±45° reach or the satellite's horizon, when its layer is turned off or its record is dropped, and with the view. While focused the readout gives the single off-nadir angle to the point (OFF-NADIR 23.4°), names it in a polite live region, and the swath reads approximate as for a tilt. Clicks still reach Cesium's own handler and never untrack the satellite; a click a tool owns is ignored. Under the readout, IN REACH lists the mapped points facing the satellite that are within the reach or in the frame, nearest to nadir first and at most 12, rebuilt once a second. A row opens the point's position, source and OpenStreetMap tags (or its layer's properties); FOCUS focuses it, switches to it, or ends the focus held on it, and is unavailable for a point in frame but beyond the reach.
This commit is contained in:
1 parent
745c11969b
commit
567c833582
24 files changed
+2132
-19
No files matched your search
@@ -34,7 +34,6 @@ import {
|
||||
} from '../cockpitOrbital.js';
|
||||
import {
|
||||
clampOrbitalLook,
|
||||
easeLook,
|
||||
lookIsOffset,
|
||||
orbitalLookReadoutParts,
|
||||
stepOrbitalLook,
|
||||
@@ -43,6 +42,13 @@ import { cockpitUiUpdateDue } from '../cockpitMath.js';
|
||||
import { createPlaceTracker, nearPlaceRadiusKm } from '../data/placeBelow.js';
|
||||
import { isPointerFree } from '../data/inputOwnership.js';
|
||||
import { zoomableSwathKm } from '../layers/satellites/sensors.js';
|
||||
import {
|
||||
easeOrbitalLook,
|
||||
endOrbitalFocus,
|
||||
orbitalFocusReadout,
|
||||
releaseOrbitalFocus,
|
||||
updateOrbitalFocus,
|
||||
} from './cockpitOrbitalFocus.js';
|
||||
import {
|
||||
COCKPIT_CONTEXT_UPDATE_MS,
|
||||
COCKPIT_HUD_UPDATE_MS,
|
||||
@@ -131,6 +137,7 @@ export function endOrbital() {
|
||||
// Back to the map the operator had, unless they picked another meanwhile.
|
||||
state.imagery?.release?.()?.catch?.(() => {});
|
||||
this.publishOrbital(null);
|
||||
endOrbitalFocus.call(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,12 +325,13 @@ export function updateOrbital(nowMs) {
|
||||
this.lastSubjectInfo = info;
|
||||
goToZoom.call(this, maxZoom);
|
||||
}
|
||||
state.lookView = easeLook(
|
||||
state.lookView,
|
||||
state.lookTarget,
|
||||
nowMs - (state.lookLastMs || nowMs),
|
||||
{ immediate: prefersReducedMotion() },
|
||||
);
|
||||
// A ground focus aims the look itself (src/ui/cockpitOrbitalFocus.js).
|
||||
if (!updateOrbitalFocus.call(this, state, nadir, position, nowMs))
|
||||
state.lookView = easeOrbitalLook(
|
||||
state,
|
||||
nowMs - (state.lookLastMs || nowMs),
|
||||
{ immediate: prefersReducedMotion() },
|
||||
);
|
||||
state.lookLastMs = nowMs;
|
||||
const view = offNadirOrientation(nadir, {
|
||||
northDeg: state.lookView.pitchDeg,
|
||||
@@ -592,16 +600,31 @@ function lookTilt(parts) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Word a ground focus's off-nadir angle, as image metadata gives it:
|
||||
* `OFF-NADIR 23.4°`.
|
||||
*/
|
||||
function wordFocusOffNadir(focus) {
|
||||
return t('OFF-NADIR {angle}°', {
|
||||
angle: formatNumber(focus.offNadirDeg, {
|
||||
minimumFractionDigits: 1,
|
||||
maximumFractionDigits: 1,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the orbital HUD. The swath is the nadir footprint, so it is left
|
||||
* out while the view is tilted off nadir.
|
||||
* out while the view is tilted off nadir. A ground focus reads the single
|
||||
* off-nadir angle to its target and scales the swath by the tilt onto it.
|
||||
* @param {object} info Satellite subject (`readSatelliteInfo`).
|
||||
* @param {{active: boolean, blurPx: number, lockTick: boolean}} transition
|
||||
*/
|
||||
export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
const state = this.orbital;
|
||||
if (!state || !info) return;
|
||||
const offset = lookIsOffset(state.lookTarget, 0);
|
||||
const focus = orbitalFocusReadout.call(this);
|
||||
const offset = Boolean(focus) || lookIsOffset(state.lookTarget, 0);
|
||||
const aspect = Number.isFinite(this.viewer.camera?.frustum?.aspectRatio)
|
||||
? this.viewer.camera.frustum.aspectRatio
|
||||
: canvasAspect(this.viewer);
|
||||
@@ -610,15 +633,21 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
const maxZoom = orbitalMaxZoomFor.call(this, info);
|
||||
const swathKm = sensorSwathKm(info);
|
||||
const trackUp = Number.isFinite(info.groundTrackDeg);
|
||||
const tilt = offset
|
||||
? lookTilt(orbitalLookReadoutParts(state.lookTarget))
|
||||
: null;
|
||||
const swathScale = offset ? offNadirSwathScale(tilt) : 1;
|
||||
// A ground focus sets the tilt; otherwise the look target does.
|
||||
const tilt = focus
|
||||
? { northDeg: focus.pitchDeg, eastDeg: focus.yawDeg }
|
||||
: offset
|
||||
? lookTilt(orbitalLookReadoutParts(state.lookTarget))
|
||||
: null;
|
||||
const swathScale = tilt ? offNadirSwathScale(tilt) : 1;
|
||||
// Tilted past the limb, the view's centre looks into space: no swath. The
|
||||
// camera eases toward the target, so both must meet the Earth; the HUD
|
||||
// republishes on its cadence, so the swath appears once the view arrives.
|
||||
// Exact angles here, not the whole degrees the readout rounds to.
|
||||
const target = clampOrbitalLook(state.lookTarget);
|
||||
// Exact angles here, not the whole degrees the readout rounds to; a ground
|
||||
// focus aims the look itself, so its angles are the target.
|
||||
const target = focus
|
||||
? { pitchDeg: focus.pitchDeg, yawDeg: focus.yawDeg }
|
||||
: clampOrbitalLook(state.lookTarget);
|
||||
// The eased view is tested even with the target at nadir: on the way back
|
||||
// from past the limb it still looks into space.
|
||||
const seesEarth =
|
||||
@@ -664,7 +693,13 @@ export function publishOrbitalView(info, transition = IDLE_TRANSITION) {
|
||||
transition: { ...transition },
|
||||
look: {
|
||||
offset,
|
||||
readout: offset ? wordOffNadir(state.lookTarget, { trackUp }) : '',
|
||||
readout: focus
|
||||
? wordFocusOffNadir(focus)
|
||||
: offset
|
||||
? wordOffNadir(state.lookTarget, { trackUp })
|
||||
: '',
|
||||
// The mapped point the view is held on, or null.
|
||||
focus: focus ? { key: focus.key, label: focus.label } : null,
|
||||
// Off nadir, the ground width at the view's centre, approximated from
|
||||
// the nadir footprint (`offNadirSwathScale`); 1 and null at nadir.
|
||||
swathScale,
|
||||
@@ -844,6 +879,8 @@ export function turnOrbitalLook(step) {
|
||||
return false;
|
||||
if (!step) return false;
|
||||
const state = this.orbital;
|
||||
// An arrow takes the view over from a ground focus where it is.
|
||||
releaseOrbitalFocus.call(this, { handOver: true });
|
||||
state.lookTarget = stepOrbitalLook(state.lookTarget, step);
|
||||
if (prefersReducedMotion()) state.lookView = { ...state.lookTarget };
|
||||
presentNow.call(this);
|
||||
@@ -859,6 +896,8 @@ export function resetOrbitalLook({ immediate = false } = {}) {
|
||||
if (!this.active || this.subjectKind !== 'satellite' || !this.orbital)
|
||||
return false;
|
||||
const state = this.orbital;
|
||||
// Ends a ground focus too, easing back on its clock.
|
||||
releaseOrbitalFocus.call(this);
|
||||
state.lookTarget = { ...NADIR_LOOK };
|
||||
if (immediate || prefersReducedMotion()) state.lookView = { ...NADIR_LOOK };
|
||||
presentNow.call(this);
|
||||
|
||||
Reference in new issue
Block a user