mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
refactor(localAdsb): Cesium rendering behind a renderer interface
Task 12a. The Local ADS-B logic (index.js, models.js) no longer imports
Cesium. src/layers/localAdsb/render/cesium.js holds what it built, one
for one: the CustomDataSource of marker entities (billboard with
per-frame position/rotation/visibility CallbackProperties, the 2,000 km
DistanceDisplayCondition, the 978 MHz UAT ring as a PointGraphics), the
model PrimitiveCollection (models load, pose and leave through the shared
aircraft renderer's model part, adopting that collection), the selected
aircraft's trail (data/trailRenderer, as before) and live head segment,
and the camera reads. Registered for 'local-adsb' in the renderer
registry, created at init(viewer, {engine}).
- Clicks go through the engine's selection dispatcher (drill 8) instead of
the layer's ScreenSpaceEventHandler, with the layer's own rule kept as is
— a new `lookUnder` owner kind: its marker on top, or under picks no
layer owns and under trail lines, is selected (and re-selected);
another layer's contact on top, or empty map, releases only its own
selection; a trail line alone does nothing; no gesture rule. To the
other owners it is another layer, as its pick-owner registration made
it before. (The dispatcher's `drillThrough` would have taken the marker
from under another layer's contact, which the old handler never did.)
- models.js reads the camera through the renderer's view (frustum and
horizon tests, ground snap owner) and draws through renderer.models
(loadFleet/add/remove/destroy/setPose: the same MIX-tinted glTF options,
the same HPR frame with the Flights nose offset). The shared aircraft
renderer gains a loadModel seam (default Cesium.Model.fromGltfAsync).
- Cesium math → src/geo; the model tint is an Rgba equal to the old
Cesium.Color; check-import-directions: src/layers/localAdsb/ joins the
rendered layers.
Tests moved with the code, same meaning:
- index.test: the services fixture creates the layer's Cesium renderer and
the selection dispatcher; the click harness scripts the picks on a fake
engine registered for the fake viewer (was a fake ScreenSpaceEventHandler)
and the app's pick owners (trails, a Flights contact) are registered in
the pick registry (was an injected picking service).
- cockpitModels.test: the GLB loads are the aircraft renderer's loadModel
calls (Cesium.Model.fromGltfAsync by default), each asynchronous:false.
- trackingClickGesture.test: the dispatcher's empty click goes to the
plain owners (filter(plain)).
- renderers.test: local-adsb has an extracted Cesium renderer.
New: the dispatcher's look-under rule beside a plain owner (7 click cases).
W1 replay (flights, military, localAdsb) vs a fresh 7c7422e2 run: counts,
known objects, screen points, tracking poses, requests and every shot's
sha256 identical.
This commit is contained in:
1 parent
941b308c29
commit
0b8cb855fa
15 files changed
+549
-306
No files matched your search
@@ -65,7 +65,10 @@ const cesiumNearFar = (scalar) =>
|
||||
* @param {string} options.spriteLayer The fleet's slot in data/spriteOrder.
|
||||
* @param {number} [options.headingOffsetDeg=0] Model nose vs Cesium heading 0.
|
||||
* @param {{ billboardCollection?: object, modelCollection?: object }} [options.adopt]
|
||||
* Test seam: drive existing (fake) collections instead of creating them.
|
||||
* Drive existing collections instead of creating them (test fakes; a
|
||||
* layer that keeps its own model collection, local ADS-B).
|
||||
* @param {(options: object) => Promise<object>} [options.loadModel] The glTF
|
||||
* loader (test seam; Cesium.Model.fromGltfAsync).
|
||||
* @returns {import('./contract.js').AircraftRenderer}
|
||||
*/
|
||||
export function createAircraftCesiumRenderer({
|
||||
@@ -74,6 +77,7 @@ export function createAircraftCesiumRenderer({
|
||||
spriteLayer,
|
||||
headingOffsetDeg = 0,
|
||||
adopt = null,
|
||||
loadModel = (options) => Cesium.Model.fromGltfAsync(options),
|
||||
}) {
|
||||
let billboards = adopt?.billboardCollection ?? null;
|
||||
let models = adopt?.modelCollection ?? null;
|
||||
@@ -202,7 +206,7 @@ export function createAircraftCesiumRenderer({
|
||||
unlit,
|
||||
id,
|
||||
}) =>
|
||||
Cesium.Model.fromGltfAsync({
|
||||
loadModel({
|
||||
url,
|
||||
asynchronous: false,
|
||||
minimumPixelSize,
|
||||
@@ -222,7 +226,7 @@ export function createAircraftCesiumRenderer({
|
||||
unlit,
|
||||
id,
|
||||
}) =>
|
||||
Cesium.Model.fromGltfAsync({
|
||||
loadModel({
|
||||
url,
|
||||
asynchronous: false,
|
||||
minimumPixelSize,
|
||||
@@ -237,7 +241,7 @@ export function createAircraftCesiumRenderer({
|
||||
}),
|
||||
// Warms Cesium's glTF cache (the retained instance is never drawn).
|
||||
preload: (url) =>
|
||||
Cesium.Model.fromGltfAsync({
|
||||
loadModel({
|
||||
url,
|
||||
asynchronous: false,
|
||||
}),
|
||||
|
||||
Reference in new issue
Block a user