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
@@ -0,0 +1,120 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import * as Cesium from 'cesium';
|
||||
import { createFlightState } from './state.js';
|
||||
import { createIcons } from './icons.js';
|
||||
import { createIconSet } from '../../data/iconSet.js';
|
||||
import { writeHoldSegment } from '../../data/iconSegment.js';
|
||||
|
||||
function services(focus = {}) {
|
||||
return {
|
||||
focus: { focusPassIsNeeded: () => true, ...focus },
|
||||
groundSnap: { createGroundSnap: () => ({ clear() {}, forget() {} }) },
|
||||
};
|
||||
}
|
||||
|
||||
function setup({ focus, motion = {}, rendering = {} } = {}) {
|
||||
const svc = services(focus);
|
||||
const flightState = createFlightState({ services: svc });
|
||||
flightState._icons = createIconSet();
|
||||
const parts = {
|
||||
motion,
|
||||
rendering: { _modelOwnsVisual: () => false, ...rendering },
|
||||
};
|
||||
const icons = createIcons({ flightState, services: svc, parts });
|
||||
return { flightState, icons, set: flightState._icons };
|
||||
}
|
||||
|
||||
function hold(set, id, position, course = 0) {
|
||||
const row = set.add(id, { layer: 'flights', id });
|
||||
writeHoldSegment(set.segments, row, position, course);
|
||||
set.segmentWritten(row);
|
||||
return row;
|
||||
}
|
||||
|
||||
const at = (lon, h = 1000) => Cesium.Cartesian3.fromDegrees(lon, 30, h);
|
||||
|
||||
test('focus advances for drawn rows and for rows a fleet model draws for', () => {
|
||||
const advanced = [];
|
||||
const { flightState, icons, set } = setup({
|
||||
focus: {
|
||||
nearFarScalarValueAtDistance: () => 1,
|
||||
advanceProjectedSpriteFocus(meta) {
|
||||
advanced.push(meta.id);
|
||||
return { factor: 0.4, active: true };
|
||||
},
|
||||
},
|
||||
});
|
||||
set.setShown(hold(set, 'drawn', at(0)), true);
|
||||
const modeled = hold(set, 'modeled', at(0.1));
|
||||
hold(set, 'hidden', at(0.2));
|
||||
flightState._models.set('modeled', {});
|
||||
|
||||
icons._focusIcons(0, {}, { positionWC: at(0, 50_000) }, 0, {});
|
||||
assert.deepEqual(advanced, ['drawn', 'modeled']);
|
||||
assert.ok(
|
||||
Math.abs(set.focus(modeled) - 0.4) < 1e-6,
|
||||
"the model's alpha reads it",
|
||||
);
|
||||
assert.equal(flightState._iconFocusActive, 2);
|
||||
});
|
||||
|
||||
test('settling a pinned grounded contact re-floors it where it is now, nose kept', () => {
|
||||
const taxied = at(0.01, 100);
|
||||
const floored = at(0.01, 131.5);
|
||||
const { flightState, icons, set } = setup({
|
||||
motion: {
|
||||
_motionRegime: () => ({
|
||||
kind: 'fix',
|
||||
fix: { position: taxied, time: Cesium.JulianDate.now() },
|
||||
speed: 0,
|
||||
heading: 200,
|
||||
turnRateDps: 0,
|
||||
minDt: -60,
|
||||
maxDt: 60,
|
||||
}),
|
||||
_deadReckon(icao24, result) {
|
||||
flightState._drCourseDeg = 200;
|
||||
flightState._drSpeedMps = 0;
|
||||
flightState._drCourseHold = true;
|
||||
return Cesium.Cartesian3.clone(taxied, result);
|
||||
},
|
||||
_floorGroundedDisplayPosition: () => floored,
|
||||
},
|
||||
});
|
||||
// Pinned before it was tracked, 1 km back, facing 10°.
|
||||
const row = hold(set, 'g', at(0, 131.5), 10);
|
||||
flightState._floorPinned.add('g');
|
||||
flightState._grounded.add('g');
|
||||
flightState.records.data.set('g', { onGround: true });
|
||||
flightState._positionHistory.set('g', [{}]);
|
||||
|
||||
icons._settleIcon('g', { fromCourseDeg: 123 });
|
||||
const tau = icons._displayTau();
|
||||
assert.ok(Cesium.Cartesian3.distance(set.position(row, tau), floored) < 0.01);
|
||||
assert.ok(Math.abs(set.course(row, tau) - 123) < 1e-3, 'tracked nose kept');
|
||||
assert.ok(flightState._floorPinned.has('g'), 'pinned on the new floor');
|
||||
});
|
||||
|
||||
test('a contact that comes back dimmed re-arms the idle focus pass', () => {
|
||||
const advanced = [];
|
||||
const { flightState, icons, set } = setup({
|
||||
focus: {
|
||||
focusPassIsNeeded: (target, active) => target != null || active > 0,
|
||||
nearFarScalarValueAtDistance: () => 1,
|
||||
advanceProjectedSpriteFocus(meta) {
|
||||
advanced.push(meta.id);
|
||||
return { factor: 1, active: false, transitioning: false };
|
||||
},
|
||||
},
|
||||
motion: { _motionRegime: () => null },
|
||||
});
|
||||
const row = hold(set, 'was-tracked', at(0));
|
||||
set.setFocus(row, 0.2);
|
||||
flightState._iconFocusActive = 0;
|
||||
icons._settleIcon('was-tracked');
|
||||
set.setShown(row, true);
|
||||
icons._focusIcons(0, {}, { positionWC: at(0, 50_000) }, 0, null);
|
||||
assert.deepEqual(advanced, ['was-tracked']);
|
||||
assert.equal(set.focus(row), 1);
|
||||
});
|
||||
Reference in new issue
Block a user