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:
Sameh Khamis committed 2026-11-06 16:10:48 -08:00
1 parent 99f9a701d9
commit e3a850bc9c
22 files changed
+291 -332

No files matched your search

+25 -2
View File
@@ -23,6 +23,21 @@ import { trackedEntityViewEntity } from './internals.js';
const MAX_FRAME_ATTEMPTS = 120;
const TRANSPARENT = new Cesium.Color(0, 0, 0, 0);
const ZOOM_STATES = new WeakMap();
/** Each helper entity's FollowTarget. */
const HELPER_TARGETS = new WeakMap();
/**
* A pick as the follow's helper entity should not make it: a hit on a helper
* is a hit on its target's drawn `entity`, or no hit when it has none. Any
* other pick comes back as it was.
* @param {object|undefined} picked What `scene.pick` or `drillPick` gave.
* @returns {object|undefined}
*/
export function pickThroughFollowHelper(picked) {
const target = picked?.id && HELPER_TARGETS.get(picked.id);
if (!target) return picked;
return target.entity ? { ...picked, id: target.entity } : undefined;
}
/**
* Turn zoom coasting off and raise the zoom floor to `minRange` while any
@@ -186,14 +201,20 @@ export function createCesiumFollow({ widget, scene, camera, onChanged }) {
: target.viewFrom;
function helperFor(target) {
return widget.entities.add({
const helper = widget.entities.add({
position: new Cesium.CallbackProperty((time, result) => {
const p = target.position(msOf(time));
return p ? Cesium.Cartesian3.fromElements(p.x, p.y, p.z, result) : p;
}, false),
// EntityView tracks an entity only once its bounding sphere is
// ready, and an entity without graphics has none.
point: { pixelSize: 1, color: TRANSPARENT },
// Outline too: Cesium blends an opaque default outline into the edge.
point: {
pixelSize: 1,
color: TRANSPARENT,
outlineColor: TRANSPARENT,
outlineWidth: 0,
},
viewFrom: new Cesium.CallbackProperty((time, result) => {
const v = viewFromAt(target, time);
return v ? startOffset(target, v, result) : v;
@@ -203,6 +224,8 @@ export function createCesiumFollow({ widget, scene, camera, onChanged }) {
? Cesium.TrackingReferenceFrame.AUTODETECT
: Cesium.TrackingReferenceFrame.ENU,
});
HELPER_TARGETS.set(helper, target);
return helper;
}
// preUpdate on purpose: in preRender the target's drawing is already