mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Draw civil flights from an icon set moved on the GPU
Every flight is now a row in the layer's icon set. Its motion segment follows the same regime `_deadReckon` picks (interpolate between fixes, warm up backward from the oldest, coast forward from the newest), and one shared `_motionRegime` makes that choice for both. The shader moves every untracked contact between polls, so the 12 Hz fleet tick no longer touches each billboard. It now only re-plans expired rows, floors grounded contacts, advances focus while needed, and runs the 3D model regime. Grounded contacts the floor lifts are pinned to a hold at the floored position. Their nose glides on the GPU. Contacts within 50 km re-floor every tick, and farther ones take turns about once a second. Low contacts are judged for the horizon at no lower than 12 m above the ellipsoid, as before. Below hover speed a contact's nose holds. A row whose fleet model is drawn keeps its focus updated, because the model reads it. Untracking re-plans and re-floors the icon from the tracked course. On the same views with about 6,700 OpenSky flights, frame gaps at p95 drop from 28-40 ms to 17 ms, and the fleet tick from 16-37 ms to about 2 ms at most.
This commit is contained in:
1 parent
37dd4058c1
commit
fa3a3a3bca
33 files changed
+1598
-986
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { aircraftIcon } from '../../data/aircraftIcons.js';
|
||||
import { FOCUS_EVIDENCE_DEV } from './policy.js';
|
||||
import { writeHoldSegment } from '../../data/iconSegment.js';
|
||||
import {
|
||||
addBillboard,
|
||||
billboardState,
|
||||
setBillboard,
|
||||
} from '../../data/billboardMirror.js';
|
||||
aircraftRecessionFactors,
|
||||
aircraftTreatmentAlpha,
|
||||
} from '../../data/aircraftRecession.js';
|
||||
import { horizonOccluder } from '../../data/iconOrientation.js';
|
||||
|
||||
export function createEvidence({
|
||||
flightState,
|
||||
@@ -44,17 +44,14 @@ export function createEvidence({
|
||||
/** Replace the real fleet with deterministic explicit-position contacts. */
|
||||
|
||||
function _setFocusEvidenceAircraft(records = []) {
|
||||
if (
|
||||
!FOCUS_EVIDENCE_DEV ||
|
||||
!flightState._billboardCollection ||
|
||||
!flightState._viewer
|
||||
)
|
||||
if (!FOCUS_EVIDENCE_DEV || !flightState._icons || !flightState._viewer)
|
||||
return { ok: false, count: 0 };
|
||||
if (flightState._trackedIcao) parts.tracking._clearTracking();
|
||||
parts.rendering._releaseModels();
|
||||
for (const bb of flightState._billboards.values())
|
||||
flightState._billboardCollection.remove(bb);
|
||||
flightState._billboards.clear();
|
||||
const icons = flightState._icons;
|
||||
icons.clear();
|
||||
flightState._grounded.clear();
|
||||
flightState._floorPinned.clear();
|
||||
flightState.records.data.clear();
|
||||
flightState._positionHistory.clear();
|
||||
flightState._displayCourse.clear();
|
||||
@@ -86,32 +83,19 @@ export function createEvidence({
|
||||
rawLon: record.longitude ?? null,
|
||||
};
|
||||
flightState.records.data.set(id, meta);
|
||||
flightState._cullPositions.delete(id);
|
||||
flightState._focusEvidenceIds.add(id);
|
||||
const bb = addBillboard(flightState._billboardCollection, {
|
||||
position,
|
||||
image: aircraftIcon(parts.rendering._iconKind(id, klass)),
|
||||
width: 20,
|
||||
height: 20,
|
||||
scale: parts.rendering._fleetBillboardScale(id, klass),
|
||||
rotation: 0,
|
||||
alignedAxis: Cesium.Cartesian3.ZERO,
|
||||
color: parts.rendering._fleetBillboardColor(id),
|
||||
sizeInMeters: false,
|
||||
scaleByDistance: parts.rendering._normalBillboardScaleByDistance(),
|
||||
disableDepthTestDistance: parts.rendering._groundDepthDistance(),
|
||||
id,
|
||||
show: true,
|
||||
});
|
||||
flightState._billboards.set(id, bb);
|
||||
parts.icons._addIcon(id);
|
||||
const row = icons.row(id);
|
||||
writeHoldSegment(icons.segments, row, position, meta.true_track);
|
||||
icons.segmentWritten(row);
|
||||
}
|
||||
flightState.feed._count = flightState._billboards.size;
|
||||
flightState.feed._count = icons.count;
|
||||
flightState._lastFleetTickMs = 0;
|
||||
flightState._viewer.scene.requestRender?.();
|
||||
return { ok: true, count: flightState.feed._count };
|
||||
}
|
||||
|
||||
/** Update explicit evidence positions without rebuilding billboards. */
|
||||
/** Update explicit evidence positions without rebuilding rows. */
|
||||
|
||||
function _moveFocusEvidenceAircraft(records = []) {
|
||||
if (!FOCUS_EVIDENCE_DEV) return { ok: false, moved: 0 };
|
||||
@@ -122,15 +106,21 @@ export function createEvidence({
|
||||
.toLowerCase();
|
||||
if (!flightState._focusEvidenceIds.has(id)) continue;
|
||||
const position = _focusEvidencePosition(record);
|
||||
const bb = flightState._billboards.get(id);
|
||||
if (!position || !bb) continue;
|
||||
setBillboard(bb, 'position', position);
|
||||
const row = flightState._icons?.row(id) ?? -1;
|
||||
if (!position || row < 0) continue;
|
||||
const meta = flightState.records.data.get(id);
|
||||
if (meta) {
|
||||
if (Number.isFinite(record.trackDeg)) meta.true_track = record.trackDeg;
|
||||
if (Number.isFinite(record.velocityMps))
|
||||
meta.velocity = record.velocityMps;
|
||||
}
|
||||
writeHoldSegment(
|
||||
flightState._icons.segments,
|
||||
row,
|
||||
position,
|
||||
meta?.true_track ?? 0,
|
||||
);
|
||||
flightState._icons.segmentWritten(row);
|
||||
moved += 1;
|
||||
}
|
||||
flightState._lastFleetTickMs = 0;
|
||||
@@ -142,27 +132,42 @@ export function createEvidence({
|
||||
|
||||
function _focusEvidenceSnapshot() {
|
||||
if (!FOCUS_EVIDENCE_DEV || !flightState._viewer) return [];
|
||||
const icons = flightState._icons;
|
||||
const { scene, camera } = flightState._viewer;
|
||||
const occluder = horizonOccluder(camera);
|
||||
const cameraHeightM = camera.positionCartographic?.height;
|
||||
return [...flightState._focusEvidenceIds].map((id) => {
|
||||
const bb = flightState._billboards.get(id);
|
||||
const screen = billboardState(bb)?.position
|
||||
? Cesium.SceneTransforms.worldToWindowCoordinates(
|
||||
flightState._viewer.scene,
|
||||
billboardState(bb).position,
|
||||
)
|
||||
const row = icons?.row(id) ?? -1;
|
||||
const position = row < 0 ? null : parts.icons._iconPosition(id);
|
||||
const cameraDistanceM = position
|
||||
? Cesium.Cartesian3.distance(camera.positionWC, position)
|
||||
: null;
|
||||
const screen = position
|
||||
? Cesium.SceneTransforms.worldToWindowCoordinates(scene, position)
|
||||
: null;
|
||||
// What the icon shader composes: base scale × limb taper, and base
|
||||
// alpha × max(floor, focus × limb haze).
|
||||
const factors = position
|
||||
? aircraftRecessionFactors({ cameraDistanceM, cameraHeightM })
|
||||
: null;
|
||||
return {
|
||||
id,
|
||||
show: billboardState(bb)?.show === true,
|
||||
scale: billboardState(bb)?.scale ?? null,
|
||||
alpha: bb?.color?.alpha ?? null,
|
||||
show:
|
||||
!!position &&
|
||||
icons.shown(row) &&
|
||||
parts.icons._aboveHorizon(row, position, occluder),
|
||||
scale: factors ? icons.scale(row) * factors.scale : null,
|
||||
alpha: position
|
||||
? aircraftTreatmentAlpha({
|
||||
baseAlpha: icons.alpha(row),
|
||||
focusFactor: icons.focus(row),
|
||||
cameraDistanceM,
|
||||
cameraHeightM,
|
||||
})
|
||||
: null,
|
||||
x: screen?.x ?? null,
|
||||
y: screen?.y ?? null,
|
||||
cameraDistanceM: billboardState(bb)?.position
|
||||
? Cesium.Cartesian3.distance(
|
||||
flightState._viewer.camera.positionWC,
|
||||
billboardState(bb).position,
|
||||
)
|
||||
: null,
|
||||
cameraDistanceM,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user