mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Merge remote-tracking branch 'origin/main' into models/three-km-true-size
# Conflicts: # docs/CURRENT-STATE.md
This commit is contained in:
commit
b9cbc42f20
137 files changed
+8267
-688
No files matched your search
@@ -24,7 +24,8 @@ export function localAdsbClass(record, meta = null) {
|
||||
const category = record?.category || null;
|
||||
return {
|
||||
klass: classifyAircraft({ typeCode, category }),
|
||||
evidence: Boolean(typeCode) || /^(?:A[1-7]|B1)$/.test(category || ''),
|
||||
evidence:
|
||||
Boolean(typeCode) || /^(?:A[1-7]|B1|C[1-5])$/.test(category || ''),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { CLASS_SCALE_2D } from '../../data/aircraftClass.js';
|
||||
import { VEHICLE_TINT_CSS } from '../../data/aircraftClass.js';
|
||||
import { aircraftIcon } from '../../data/aircraftIcons.js';
|
||||
import { rotorFrame } from '../../data/rotorFrames.js';
|
||||
import { KNOT_MPS } from '../../data/units.js';
|
||||
import {
|
||||
courseScreenRotation,
|
||||
stabilizeScreenRotation,
|
||||
@@ -133,6 +135,8 @@ export function createLocalAdsbLayer({
|
||||
} = services.context;
|
||||
const { registerPickOwner, unregisterPickOwner } = services.picking;
|
||||
const color = hexColor(LOCAL_ADSB_COLOR);
|
||||
// An airport vehicle's tint, as in the Flights layer.
|
||||
const vehicleColor = hexColor(VEHICLE_TINT_CSS);
|
||||
const uatRingColor = hexColor(LOCAL_ADSB_UAT_RING_COLOR);
|
||||
|
||||
let viewer = null;
|
||||
@@ -265,9 +269,7 @@ export function createLocalAdsbLayer({
|
||||
}
|
||||
|
||||
function billboardScale(marker) {
|
||||
return (
|
||||
(CLASS_SCALE_2D[marker.klass] || 1) * (marker.onGround ? GROUND_SCALE : 1)
|
||||
);
|
||||
return marker.onGround ? GROUND_SCALE : 1;
|
||||
}
|
||||
|
||||
/** Class silhouette and per-class scale (×0.8 on the ground), magenta. */
|
||||
@@ -350,18 +352,34 @@ export function createLocalAdsbLayer({
|
||||
};
|
||||
}
|
||||
|
||||
/** A marker's icon, where and how it now draws. */
|
||||
function markerItem(marker, basis) {
|
||||
/**
|
||||
* A marker's icon, where and how it now draws: a helicopter's rotor frame
|
||||
* at `at` (still on the ground), an airport vehicle in its own tint, a
|
||||
* ground station's mast upright.
|
||||
*/
|
||||
function markerItem(marker, basis, at) {
|
||||
const kind = marker.iconKind ?? 'airliner';
|
||||
return {
|
||||
id: marker.id,
|
||||
pos: marker.position,
|
||||
image: aircraftIcon(marker.iconKind ?? 'airliner'),
|
||||
image: aircraftIcon(
|
||||
kind,
|
||||
undefined,
|
||||
kind === 'helicopter'
|
||||
? rotorFrame(marker.id, at, {
|
||||
onGround: marker.onGround,
|
||||
speedMps: Number.isFinite(marker.record?.groundSpeedKt)
|
||||
? marker.record.groundSpeedKt * KNOT_MPS
|
||||
: null,
|
||||
})
|
||||
: undefined,
|
||||
),
|
||||
size: [MARKER_SPRITE.width, MARKER_SPRITE.height],
|
||||
scale: marker.iconScale ?? 1,
|
||||
color,
|
||||
color: kind === 'vehicle' ? vehicleColor : color,
|
||||
scaleByDistance: MARKER_SPRITE.scaleByDistance,
|
||||
rotationMode: 'screen',
|
||||
rotation: markerRotation(marker, basis),
|
||||
rotation: kind === 'station' ? 0 : markerRotation(marker, basis),
|
||||
// The 3D model, once loaded and placed, is the visual instead.
|
||||
show: !marker.modelOwnsVisual,
|
||||
disableDepthTest: Number.POSITIVE_INFINITY,
|
||||
@@ -390,11 +408,12 @@ export function createLocalAdsbLayer({
|
||||
function drawMarkers() {
|
||||
if (!sets) return;
|
||||
const basis = cameraBasis();
|
||||
const at = now();
|
||||
const icons = [];
|
||||
const rings = [];
|
||||
for (const marker of markers.values()) {
|
||||
if (!marker.position) continue;
|
||||
icons.push(markerItem(marker, basis));
|
||||
icons.push(markerItem(marker, basis, at));
|
||||
if (marker.uat) rings.push(ringItem(marker));
|
||||
}
|
||||
if (icons.length) sets.markers.upsert(icons);
|
||||
|
||||
@@ -2,9 +2,10 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
import { CLASS_SCALE_2D } from '../../data/aircraftClass.js';
|
||||
import { VEHICLE_TINT_CSS } from '../../data/aircraftClass.js';
|
||||
import { layerFeedState } from '../../data/feedState.js';
|
||||
import { aircraftIcon } from '../../data/aircraftIcons.js';
|
||||
import { ROTOR_STILL_FRAME, rotorFrame } from '../../data/rotorFrames.js';
|
||||
import {
|
||||
createLocalAdsbLayer,
|
||||
HEARD_BY_RECEIVER,
|
||||
@@ -239,7 +240,7 @@ test('enabling Local ADS-B asks the shared tuner for 1090 MHz; disabling leaves
|
||||
);
|
||||
});
|
||||
|
||||
test('local aircraft use their class silhouette and scale in magenta', async (t) => {
|
||||
test('local aircraft use their class silhouette at one size in magenta', async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
const { layer, draw, calls } = await enabledLayer(receiver, clock);
|
||||
@@ -266,8 +267,17 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
|
||||
assert.equal(typeof readEntityRecord(carrier)?.displayPosition, 'function');
|
||||
|
||||
const heli = () => iconOf(draw, 'local-adsb:a0b702');
|
||||
assert.equal(heli().image, aircraftIcon('helicopter'));
|
||||
assert.equal(heli().scale, CLASS_SCALE_2D.helicopter);
|
||||
// Airborne, its rotor turns: the frame of its own phase at the layer's time.
|
||||
assert.equal(
|
||||
heli().image,
|
||||
aircraftIcon(
|
||||
'helicopter',
|
||||
undefined,
|
||||
rotorFrame('local-adsb:a0b702', clock.now),
|
||||
),
|
||||
);
|
||||
assert.equal(heli().scale, 1, 'every class draws at one size');
|
||||
assert.equal(icon.scale, heli().scale);
|
||||
assert.deepEqual(
|
||||
heli().color,
|
||||
MAGENTA,
|
||||
@@ -286,18 +296,48 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
|
||||
icao: 'a0b702',
|
||||
category: 'A7',
|
||||
onGround: true,
|
||||
groundSpeedKt: 0,
|
||||
lastPositionAt: 100_500,
|
||||
}),
|
||||
],
|
||||
});
|
||||
await layer.update();
|
||||
assert.equal(heli().scale, CLASS_SCALE_2D.helicopter * 0.8);
|
||||
assert.equal(heli().scale, 0.8);
|
||||
// Parked on the ground its rotor holds still.
|
||||
assert.equal(
|
||||
heli().image,
|
||||
aircraftIcon('helicopter', undefined, ROTOR_STILL_FRAME),
|
||||
);
|
||||
|
||||
const [detectable] = layer.getDetectableObjects();
|
||||
assert.equal(detectable.sourceId, 'a0b702');
|
||||
assert.equal(detectable.type, 'AIR');
|
||||
});
|
||||
|
||||
test('local airport vehicles draw the amber vehicle sprite, ground stations the upright mast', async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
const { layer, draw } = await enabledLayer(receiver, clock);
|
||||
t.after(() => layer.destroy());
|
||||
receiver.set({
|
||||
aircraft: [
|
||||
record({ icao: 'a0c001', category: 'C1', trackDeg: 90 }),
|
||||
record({ icao: 'a0c002', category: 'C2', trackDeg: 90 }),
|
||||
record({ icao: 'a0c003', category: 'C3', trackDeg: 90 }),
|
||||
],
|
||||
});
|
||||
await layer.update();
|
||||
for (const id of ['a0c001', 'a0c002']) {
|
||||
const icon = iconOf(draw, `local-adsb:${id}`);
|
||||
assert.equal(icon.image, aircraftIcon('vehicle'), id);
|
||||
assert.deepEqual(icon.color, hexColor(VEHICLE_TINT_CSS), id);
|
||||
}
|
||||
const mast = iconOf(draw, 'local-adsb:a0c003');
|
||||
assert.equal(mast.image, aircraftIcon('station'));
|
||||
assert.deepEqual(mast.color, MAGENTA);
|
||||
assert.equal(mast.rotation, 0, 'upright whatever its track');
|
||||
});
|
||||
|
||||
test('the heading slews toward a new track instead of snapping', async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
|
||||
@@ -8,7 +8,13 @@ import {
|
||||
sub,
|
||||
} from '../../geo/vector.js';
|
||||
import { aircraftLayerModelSpec } from '../flights/modelSpec.js';
|
||||
import { fleetModelSet, loadFleetModelSet } from '../../data/fleetModels.js';
|
||||
import {
|
||||
fleetModelSet,
|
||||
fleetPartTable,
|
||||
loadFleetModelSet,
|
||||
} from '../../data/fleetModels.js';
|
||||
import { aircraftLayerPartState } from '../../data/modelPartDrivers.js';
|
||||
import { KNOT_MPS } from '../../data/units.js';
|
||||
import {
|
||||
FLEET_DR_INTERVAL_MS,
|
||||
MODEL_ADD_M,
|
||||
@@ -162,6 +168,36 @@ export function createLocalAdsbModels({
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The moving parts an aircraft's model is posed with, from its record
|
||||
* (`aircraftLayerPartState`). The receiver knows no ground height, so its gear
|
||||
* follows the approach rule by its reported altitude, climb and speed. An
|
||||
* airport vehicle is a road vehicle (`groundVehiclePartState`): its wheels
|
||||
* roll with its speed.
|
||||
*/
|
||||
function partsOf(marker, spec) {
|
||||
const table = fleetPartTable(fleetModelSet(), spec.model);
|
||||
if (!table) return undefined;
|
||||
const record = marker.record ?? {};
|
||||
const finite = (v) => (Number.isFinite(v) ? v : null);
|
||||
const speedMps =
|
||||
finite(record.groundSpeedKt) === null
|
||||
? null
|
||||
: record.groundSpeedKt * KNOT_MPS;
|
||||
return aircraftLayerPartState(table, {
|
||||
klass: marker.klass,
|
||||
onGround: marker.onGround === true,
|
||||
heightAboveGroundM: null,
|
||||
altitudeM:
|
||||
finite(record.altitudeFt) === null ? null : record.altitudeFt * 0.3048,
|
||||
verticalRateMps:
|
||||
finite(record.verticalRateFpm) === null
|
||||
? null
|
||||
: (record.verticalRateFpm * 0.3048) / 60,
|
||||
speedMps,
|
||||
});
|
||||
}
|
||||
|
||||
function regime(preferences, pose) {
|
||||
if (!preferences?.models3d) return false;
|
||||
return pose.height < MODEL_ALT_CEIL_M;
|
||||
@@ -241,6 +277,7 @@ export function createLocalAdsbModels({
|
||||
const gltf = fleetModelSet()?.bytes?.get(spec.model);
|
||||
noteAsset(record, url, spec.bellyM);
|
||||
const position = placement(id, marker);
|
||||
const parts = partsOf(marker, spec);
|
||||
const shown =
|
||||
Boolean(position) && horizon.isPointVisible(marker.position);
|
||||
items.push({
|
||||
@@ -262,6 +299,7 @@ export function createLocalAdsbModels({
|
||||
tint: WHITE,
|
||||
colorBlend: aircraftModelBlend(false),
|
||||
environmentMap: AIRCRAFT_ENVIRONMENT_MAP_OPTIONS.enabled,
|
||||
...(parts ? { parts } : {}),
|
||||
show: shown,
|
||||
});
|
||||
if (shown && record.ready) marker.modelOwnsVisual = true;
|
||||
|
||||
Reference in new issue
Block a user