mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Follow aircraft and satellites through the camera port
Flights and military follow their tracked aircraft with an entityFollowTarget: framed in ENU from viewFrom, never closer than 150 m, presentation read from the drawn entity's record. Satellites follow in Cesium's autodetect frame. The layers' own framing (applyTrackedCameraFrame) goes; the port's follow has the same close-range rules, and trackedCamera.js no longer imports Cesium. The port's helper entity draws nothing: its point's outline is transparent too, and click and voice picks of it count as picks of the target's drawn entity. The fake camera binder follows when the fake has Cesium's entity tracking.
This commit is contained in:
1 parent
99f9a701d9
commit
e3a850bc9c
22 files changed
+291
-332
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { readEntityRecord } from '../../data/entityRecords.js';
|
||||
import { onFollowChanged } from '../../data/followed.js';
|
||||
|
||||
export function createInteraction({
|
||||
state: layerState,
|
||||
@@ -25,22 +25,22 @@ export function createInteraction({
|
||||
// new owner controls it). Guarded so our OWN switch (viewer.trackedEntity
|
||||
// briefly undefined mid-_trackSatellite) doesn't self-clear.
|
||||
if (!layerState._trackedEntityChangedRemove) {
|
||||
layerState._trackedEntityChangedRemove =
|
||||
viewer.trackedEntityChanged.addEventListener(() => {
|
||||
layerState._trackedEntityChangedRemove = onFollowChanged(
|
||||
viewer,
|
||||
(followed) => {
|
||||
if (!layerState._enabled) return;
|
||||
if (
|
||||
layerState._trackedNorad &&
|
||||
layerState._viewer &&
|
||||
layerState._viewer.trackedEntity &&
|
||||
layerState._viewer.trackedEntity !== layerState._trackedEntity
|
||||
followed &&
|
||||
followed !== layerState._followTarget
|
||||
) {
|
||||
parts.tracking._clearTracking(true, {
|
||||
origin:
|
||||
readEntityRecord(layerState._viewer.trackedEntity)
|
||||
?.selectionOrigin || 'programmatic',
|
||||
origin: followed.selectionOrigin || 'programmatic',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
layerState._clickSubscription = inputFor(viewer).onClick((event) => {
|
||||
|
||||
@@ -83,6 +83,8 @@ export function createState({ services }) {
|
||||
};
|
||||
|
||||
state._trackedEntity = null;
|
||||
/** The FollowTarget the camera follows the tracked satellite with. */
|
||||
state._followTarget = null;
|
||||
|
||||
state._clickSubscription = null;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { cameraOf } from '../../render/cesium/camera.js';
|
||||
import { entityFollowTarget, stopFollowing } from '../../data/followed.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { satelliteClassLabel } from '../../data/satelliteClass.js';
|
||||
import { t } from '../../i18n/index.js';
|
||||
@@ -113,7 +115,8 @@ export function createTracking({ state: layerState, services, parts, source }) {
|
||||
parts.rendering._hideOrbitPath(layerState._trackedNorad);
|
||||
}
|
||||
if (layerState._viewer && !skipViewerUntrack)
|
||||
layerState._viewer.trackedEntity = undefined;
|
||||
stopFollowing(layerState._viewer);
|
||||
layerState._followTarget = null;
|
||||
if (layerState._trackedEntity) {
|
||||
layerState._viewer.entities.remove(layerState._trackedEntity);
|
||||
layerState._trackedEntity = null;
|
||||
@@ -425,10 +428,14 @@ export function createTracking({ state: layerState, services, parts, source }) {
|
||||
// Tracked entity position propagates per evaluation through the per-frame
|
||||
// cache (WS-D2) — dot, host readout, and camera share one SGP4 epoch per frame.
|
||||
// Falls back to the point primitive's 1s-throttled position if SGP4 fails.
|
||||
const positionProperty = new Cesium.CallbackProperty(() => {
|
||||
const trackedPosition = () => {
|
||||
const pos = _getTrackedFramePosition();
|
||||
return pos ? layerState._trackedFrameCartesian : point.position;
|
||||
}, false);
|
||||
};
|
||||
const positionProperty = new Cesium.CallbackProperty(
|
||||
trackedPosition,
|
||||
false,
|
||||
);
|
||||
|
||||
const name = sat.name.trim();
|
||||
|
||||
@@ -473,7 +480,14 @@ export function createTracking({ state: layerState, services, parts, source }) {
|
||||
selectTrackedSubjectContext(_contextSubjectMetadata(noradId, initialPos));
|
||||
layerState._contextRefreshedAtMs = Date.now();
|
||||
|
||||
layerState._viewer.trackedEntity = layerState._trackedEntity;
|
||||
// Cesium's own frame for a fast mover (AUTODETECT), as the tracked entity
|
||||
// had; no close-range rules at orbital distances.
|
||||
layerState._followTarget = entityFollowTarget(layerState._trackedEntity, {
|
||||
position: trackedPosition,
|
||||
frame: 'autodetect',
|
||||
viewFrom,
|
||||
});
|
||||
cameraOf(layerState._viewer).follow(layerState._followTarget);
|
||||
console.log(`[Data:Satellites] Tracking ${name} (NORAD ${noradId})`);
|
||||
}
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user