mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Let a host application place live contacts
createApplicationCatalog takes an optional placement provider. Its layer(kind) hands Flights, Military Flights, AIS Vessels, Transit and Rail a place(id, wallMs), and optionally observe(id, fix) and forget(id). While live, each layer tells it every fix it accepts and draws a contact where it places it: position, height (the layer's own when none is given), course and speed. A null answer, a provider that throws, a kind it leaves out, or no provider at all keeps the layer's own motion unchanged, and following the world clock the layers never ask it. A transit vehicle or train it holds still lets the render loop idle and is asked again each second; vessels ask for frames only while it places one, and stop when the layer turns off. Tests show the layers draw and reconcile exactly as before without a provider and with one that places nothing, draw where a provider places them, and idle while it holds them still.
This commit is contained in:
1 parent
e53cfef1d1
commit
6f830a2e70
46 files changed
+1417
-34
No files matched your search
@@ -1,14 +1,20 @@
|
||||
import { forgetPlacedAircraft } from '../flights/placed.js';
|
||||
|
||||
/**
|
||||
* What the layer drops when the world clock moves it to another time (its
|
||||
* source declares a timeline; see src/time/snapshotTimeline.js).
|
||||
*/
|
||||
export function createClockFollow({ flightState, parts }) {
|
||||
export function createClockFollow({ flightState, services, parts }) {
|
||||
/**
|
||||
* Forget how every contact moved, before the snapshot at another time takes
|
||||
* the place of every contact: their fixes, courses and the tracked trail
|
||||
* belong to the time the clock left.
|
||||
*/
|
||||
function resetMotion() {
|
||||
forgetPlacedAircraft(
|
||||
services?.placement,
|
||||
flightState._positionHistory.keys(),
|
||||
);
|
||||
flightState.records.reset();
|
||||
flightState._positionHistory.clear();
|
||||
flightState._displayCourse.clear();
|
||||
|
||||
@@ -31,6 +31,7 @@ export function createMilitaryFlightLayer({
|
||||
parts.clockFollow = createClockFollow(context);
|
||||
const applySnapshot = createMilitarySnapshotRenderer({
|
||||
flightState,
|
||||
placement: services.placement ?? null,
|
||||
records: flightState.records,
|
||||
groundFloor: services.groundFloor,
|
||||
meshFloor: services.meshFloor,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { loadFleetModelSet } from '../../data/fleetModels.js';
|
||||
import { forgetPlacedAircraft } from '../flights/placed.js';
|
||||
|
||||
export function createLifecycle({
|
||||
flightState,
|
||||
@@ -66,6 +67,10 @@ export function createLifecycle({
|
||||
flightState._cullPositions.clear();
|
||||
flightState._detectionObjects = new Map();
|
||||
flightState.records.data = new Map();
|
||||
forgetPlacedAircraft(
|
||||
services.placement,
|
||||
flightState._positionHistory.keys(),
|
||||
);
|
||||
flightState._positionHistory = new Map();
|
||||
flightState._displayCourse.clear();
|
||||
flightState._groundSnap.clear();
|
||||
@@ -264,6 +269,10 @@ export function createLifecycle({
|
||||
flightState._cullPositions.clear();
|
||||
flightState._detectionObjects.clear();
|
||||
flightState.records.data.clear();
|
||||
forgetPlacedAircraft(
|
||||
services.placement,
|
||||
flightState._positionHistory.keys(),
|
||||
);
|
||||
flightState._positionHistory.clear();
|
||||
flightState._displayCourse.clear();
|
||||
flightState._groundSnap.clear();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
COAST_MAX_SPEED_MPS,
|
||||
} from '../../data/motionModel.js';
|
||||
import { CLASS_SCALE_2D } from '../../data/aircraftClass.js';
|
||||
import { placeLiveAircraft } from '../flights/placed.js';
|
||||
import {
|
||||
modelVisualAnchor,
|
||||
modelAnchorWorld,
|
||||
@@ -70,6 +71,19 @@ export function createMotion({
|
||||
}
|
||||
|
||||
const out = result || new Cesium.Cartesian3();
|
||||
// A host-supplied placement decides where a live contact is drawn; with
|
||||
// none, or no answer for this contact, the layer's own motion below does.
|
||||
if (
|
||||
placeLiveAircraft(
|
||||
flightState,
|
||||
services.placement,
|
||||
icao24,
|
||||
info,
|
||||
history,
|
||||
out,
|
||||
)
|
||||
)
|
||||
return out;
|
||||
// Render one poll interval behind real time so we interpolate between
|
||||
// two KNOWN fixes whenever possible (see RENDER_DELAY_SEC rationale).
|
||||
const renderTime = Cesium.JulianDate.addSeconds(
|
||||
|
||||
@@ -15,10 +15,12 @@ import {
|
||||
TRACKED_ICON_COLOR,
|
||||
followsClock,
|
||||
} from './policy.js';
|
||||
import { observeLiveAircraft } from '../flights/placed.js';
|
||||
|
||||
/** Apply military record changes to Cesium resources and existing follow operations. */
|
||||
export function createMilitarySnapshotRenderer({
|
||||
flightState,
|
||||
placement = null,
|
||||
records,
|
||||
groundFloor,
|
||||
meshFloor,
|
||||
@@ -73,6 +75,17 @@ export function createMilitarySnapshotRenderer({
|
||||
);
|
||||
const isTracked = icao24 === flightState._trackedIcao;
|
||||
|
||||
// A host-supplied placement, if any, is told every fix as taken.
|
||||
observeLiveAircraft(
|
||||
flightState,
|
||||
placement,
|
||||
icao24,
|
||||
fixEpochMs,
|
||||
meta,
|
||||
meta.speedMps,
|
||||
meta.track,
|
||||
);
|
||||
|
||||
// Append to position history stamped with the FEED's fix epoch.
|
||||
// adsb.lol's seen_pos is the AGE in seconds of the last position
|
||||
// report, so the fix epoch is receipt time minus that age. Only
|
||||
@@ -324,6 +337,7 @@ export function createMilitarySnapshotRenderer({
|
||||
flightState._billboards.delete(icao24);
|
||||
rendering._releaseModel(icao24); // aged-out aircraft: drop its 3D model (no orphan / cap leak)
|
||||
records.forget(icao24);
|
||||
placement?.forget(icao24);
|
||||
flightState._cullPositions.delete(icao24);
|
||||
flightState._positionHistory.delete(icao24);
|
||||
flightState._displayCourse.delete(icao24);
|
||||
|
||||
Reference in new issue
Block a user