mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the aircraft fleet icons through the draw port
The civil flights and military layers now draw their contacts as one GPU icon set each from the renderer's draw port instead of a custom primitive. Each contact is an icon item whose motion is the dead reckoning the layer plans (interpolation between fixes, warm-up and coast arcs, or a hold), with its nose gliding onto a new course at the fleet's slew cap. A contact's item is replanned when its motion runs out, grounded contacts are pinned with held motion, and focus de-emphasis is written per item. The near/far image switch follows the renderer's pixel ratio, and writes made during a fleet tick reach the set before that frame draws. The aircraft icon layer and the flights icon part no longer touch Cesium and leave the allow-list. Clicks resolve the draw port's pick ids as well as the ones the tracked model and entities still carry, so selection, follow and share-follow work as before.
This commit is contained in:
1 parent
e94b7ffb01
commit
dbd6363e43
30 files changed
+977
-551
No files matched your search
+47
-50
@@ -1,11 +1,7 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { courseSlewCapDps, norm180 } from '../../data/motionModel.js';
|
||||
import {
|
||||
segmentTargetCourse,
|
||||
writeCourseGlide,
|
||||
writeHoldSegment,
|
||||
} from '../../data/iconSegment.js';
|
||||
import { courseSlewCapDps } from '../../data/motionModel.js';
|
||||
import { createAircraftIcons } from '../../data/aircraftIconLayer.js';
|
||||
import { motionCourse } from '../../render/motion/iconMotion.js';
|
||||
import { distanceSquared, norm180 } from '../../geo/vector.js';
|
||||
import {
|
||||
COCKPIT_CONTACT_SIZE_PX,
|
||||
COURSE_MAX_DPS,
|
||||
@@ -24,7 +20,6 @@ const PIN_TURN_DEG = 0.1;
|
||||
* planned, and settling a grounded contact puts it straight onto the floor.
|
||||
*/
|
||||
export function createIcons({ flightState, services, parts }) {
|
||||
const scratchPosition = new Cesium.Cartesian3();
|
||||
const icons = createAircraftIcons({
|
||||
state: flightState,
|
||||
services,
|
||||
@@ -42,13 +37,8 @@ export function createIcons({ flightState, services, parts }) {
|
||||
// until the next fleet tick raises it.
|
||||
afterSettle(icao24) {
|
||||
if (!flightState._grounded.has(icao24)) return;
|
||||
const renderTime = icons._displayTime();
|
||||
_floorIcon(
|
||||
icao24,
|
||||
renderTime,
|
||||
flightState._icons.seconds(renderTime),
|
||||
Date.now(),
|
||||
);
|
||||
const t = icons._displayMs();
|
||||
_floorIcon(icao24, parts.motion._displayTimeAt(t), t, Date.now());
|
||||
},
|
||||
onForget(icao24) {
|
||||
flightState._displayFloorState.delete(icao24);
|
||||
@@ -59,11 +49,16 @@ export function createIcons({ flightState, services, parts }) {
|
||||
|
||||
/**
|
||||
* Grounded contacts stand on the floor under where they are DRAWN, which the
|
||||
* GPU cannot sample. While the floor lifts one, the CPU pins its row to a
|
||||
* hold at the floored dead-reckoned position each tick (rewritten only when
|
||||
* it moved); once nothing lifts it the row goes back to its planned segment.
|
||||
* renderer cannot sample. While the floor lifts one, the CPU pins its item
|
||||
* to a hold at the floored dead-reckoned position each tick (rewritten only
|
||||
* when it moved); once nothing lifts it the item goes back to its planned
|
||||
* motion.
|
||||
* @param {object} renderTime The display instant (the motion part's `_displayTimeAt`).
|
||||
* @param {number} t The same instant, epoch ms.
|
||||
* @param {number} nowMs
|
||||
* @param {{x: number, y: number, z: number}|null} cameraPosition The eye.
|
||||
*/
|
||||
function _floorGroundedIcons(renderTime, tau, nowMs, cameraPosition) {
|
||||
function _floorGroundedIcons(renderTime, t, nowMs, cameraPosition) {
|
||||
const set = flightState._icons;
|
||||
// Past FLOOR_NEAR_M a taxiing contact moves well under a pixel per tick,
|
||||
// so far rows take turns: each refreshes every FLOOR_FAR_EVERY_TICKS. Their
|
||||
@@ -71,28 +66,25 @@ export function createIcons({ flightState, services, parts }) {
|
||||
// out there too — sub-pixel at that range, and full rate once near.
|
||||
const turn = flightState._floorTick++ % FLOOR_FAR_EVERY_TICKS;
|
||||
const nearSq = FLOOR_NEAR_M * FLOOR_NEAR_M;
|
||||
let index = -1;
|
||||
for (const icao24 of flightState._grounded) {
|
||||
if (icao24 === flightState._trackedIcao) continue;
|
||||
const row = set.row(icao24);
|
||||
if (row < 0) continue;
|
||||
if (!set.has(icao24)) continue;
|
||||
index += 1;
|
||||
if (
|
||||
row % FLOOR_FAR_EVERY_TICKS !== turn &&
|
||||
index % FLOOR_FAR_EVERY_TICKS !== turn &&
|
||||
cameraPosition &&
|
||||
Cesium.Cartesian3.distanceSquared(
|
||||
cameraPosition,
|
||||
set.position(row, tau, scratchPosition),
|
||||
) > nearSq
|
||||
distanceSquared(cameraPosition, set.position(icao24, t)) > nearSq
|
||||
)
|
||||
continue;
|
||||
_floorIcon(icao24, renderTime, tau, nowMs);
|
||||
_floorIcon(icao24, renderTime, t, nowMs);
|
||||
}
|
||||
}
|
||||
|
||||
/** One grounded contact's floor pass (see `_floorGroundedIcons`). */
|
||||
function _floorIcon(icao24, renderTime, tau, nowMs) {
|
||||
function _floorIcon(icao24, renderTime, t, nowMs) {
|
||||
const set = flightState._icons;
|
||||
const row = set.row(icao24);
|
||||
if (row < 0) return;
|
||||
if (!set?.has(icao24)) return;
|
||||
const info = flightState.records.data.get(icao24);
|
||||
const raw = parts.motion._deadReckon(
|
||||
icao24,
|
||||
@@ -112,35 +104,40 @@ export function createIcons({ flightState, services, parts }) {
|
||||
);
|
||||
if (!display || display === raw) {
|
||||
if (flightState._floorPinned.delete(icao24))
|
||||
icons._planIcon(icao24, { fromCourseDeg: set.course(row, tau) });
|
||||
icons._planIcon(icao24, { fromCourseDeg: set.course(icao24, t) });
|
||||
return;
|
||||
}
|
||||
const planned = set.expires(row) !== -Infinity;
|
||||
const prev = planned ? set.course(row, tau) : null;
|
||||
// The pin holds the position; the GPU glides the course onto the target,
|
||||
// so the rate stays exact however seldom the pin is rewritten.
|
||||
const planned = set.expires(icao24) !== -Infinity;
|
||||
const prev = planned ? set.course(icao24, t) : null;
|
||||
// The pin holds the position; the renderer glides the course onto the
|
||||
// target, so the rate stays exact however seldom the pin is rewritten.
|
||||
const target = hold && prev != null ? prev : rawCourse;
|
||||
const item = set.item(icao24);
|
||||
if (
|
||||
flightState._floorPinned.has(icao24) &&
|
||||
Cesium.Cartesian3.distanceSquared(
|
||||
display,
|
||||
set.position(row, tau, scratchPosition),
|
||||
) <= PIN_MOVE_SQ_M &&
|
||||
Math.abs(norm180(target - segmentTargetCourse(set.segments, row, tau))) <=
|
||||
distanceSquared(display, set.position(icao24, t)) <= PIN_MOVE_SQ_M &&
|
||||
Math.abs(norm180(target - motionCourse(item.motion, item.course, t))) <=
|
||||
PIN_TURN_DEG
|
||||
)
|
||||
return;
|
||||
flightState._floorPinned.add(icao24);
|
||||
writeHoldSegment(set.segments, row, display, target);
|
||||
if (prev != null)
|
||||
writeCourseGlide(
|
||||
set.segments,
|
||||
row,
|
||||
prev,
|
||||
tau,
|
||||
courseSlewCapDps(speed, COURSE_MAX_DPS),
|
||||
);
|
||||
set.segmentWritten(row);
|
||||
set.update(
|
||||
icao24,
|
||||
{
|
||||
pos: { x: display.x, y: display.y, z: display.z },
|
||||
course: target,
|
||||
motion: { kind: 'hold', courseDeg: target },
|
||||
courseGlide:
|
||||
prev == null
|
||||
? undefined
|
||||
: {
|
||||
fromCourseDeg: prev,
|
||||
t0: t,
|
||||
rateDps: courseSlewCapDps(speed, COURSE_MAX_DPS),
|
||||
},
|
||||
},
|
||||
{ expiresAt: Infinity },
|
||||
);
|
||||
}
|
||||
|
||||
return { ...icons, _floorGroundedIcons };
|
||||
|
||||
Reference in new issue
Block a user