mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
refactor(military): Cesium rendering behind a renderer interface
Task 11a. The military flights logic no longer imports Cesium: it draws
through the shared aircraft renderer (src/layers/aircraft/render/cesium.js)
with the military's parameters in src/layers/military/render/cesium.js
(sprite-order slot 'military', jet.glb's 180° nose offset), registered for
'cesium' in the renderer registry and created at init(viewer, {engine}).
The same pure move as flights in 10a:
- Fleet: the BillboardCollection and its sprite-order slot (enable keeps
restoreSpriteOrder, as before); sprites stay Billboard handles.
- Models: fleet/tracked/preload glTF loads (asynchronous:false, MIX tint at
MODEL_COLOR_BLEND_AMOUNT, IR boost as `unlit` → the UNLIT CustomShader),
the model collection, setPose. The per-class specs keep their own nose
offset: setPose takes an optional offsetDeg (default the layer's), on
both aircraft renderers (same arithmetic, test added).
- Tracked: the ENU billboard Entity with its position/colour/rotation
callbacks (#FFD166, transparent amber once the model owns the visual),
viewFrom, followed through viewer.trackedEntity + the one exact tracked
frame; refocusTrackedById through follow.refocus.
- Trail: the entity trail and the floored live head segment.
- View: camera/scene reads, frame number, frustum and horizon tests,
render requests, frame events.
- Clicks and Escape go through the engine's selection dispatcher (the
ScreenSpaceEventHandler and keydown listener are gone); the cross-layer
untrack watches the renderer's follow. Same rules: cockpit clicks are
inert, the tracked visual/model is a no-op, another layer's pick is not
empty space, an unowned pick is.
- Colours are engine-neutral Rgba (MIL_ICON_COLOR #FFB800,
TRACKED_ICON_COLOR #FFD166, AMBER_TRANSPARENT), NearFarScalar →
nearFarScale; Cesium math → src/geo.
- check-import-directions: src/layers/military/ joins the rendered layers
(cesium only in render/cesium*.js).
- The military registry and the flights' duplicate suppression are
untouched.
Source-text tests updated with the moved code, same meaning:
- militaryAwareness.test: military's hasContact guard reads fleet.visible().
- trackingClickGesture.test: the military gesture rules are the
dispatcher's (selection gesture before select, click classifier before
the empty-space clear), military answers the empty click with a
user-origin clear — the same assertion flights already had.
- ownership.test: the services fixture names selection and renderer; the
app-composed services build the layer's Cesium renderer.
- renderers.test: flights and military have extracted Cesium renderers.
New tests: the military logic over a plain-data renderer and a fake engine
(amber fleet, click-select, #FFD166 tracked glyph, no-op on the tracked
visual, empty-click and Escape release, the keyboard left on destroy); the
plain-data renderer moved to src/testSupport for both aircraft layers;
setPose with a per-model offset.
W1 replay vs 7c7422e2 (the 10a reference run): every layer's counts, known
objects, screen points, tracking pose after 2 s, requests and the
city/global/orbit shots (sha256) identical. qa-military-names (it checks
the installations layer): the same verdict as 7c7422e2 (the zoom-markers
assertion fails on both). Main chunk 2,890,763 B (−2.9 KB).
This commit is contained in:
1 parent
e007350645
commit
7c0891deda
26 files changed
+829
-803
No files matched your search
@@ -263,12 +263,11 @@ export function createAircraftCesiumRenderer({
|
||||
* written into the model's OWN modelMatrix: Model.modelMatrix is a plain
|
||||
* field Cesium clones per frame, so models never share one mutable
|
||||
* matrix (a shared scratch stacked every model on the last-written
|
||||
* plane: the "flickering like mad" bug).
|
||||
* plane: the "flickering like mad" bug). `offsetDeg`: this model's nose
|
||||
* offset when the layer's models differ (default: the layer's).
|
||||
*/
|
||||
setPose(model, position, headingDeg) {
|
||||
scratchHpr.heading = Cesium.Math.toRadians(
|
||||
(headingDeg || 0) + headingOffsetDeg,
|
||||
);
|
||||
setPose(model, position, headingDeg, offsetDeg = headingOffsetDeg) {
|
||||
scratchHpr.heading = Cesium.Math.toRadians((headingDeg || 0) + offsetDeg);
|
||||
scratchHpr.pitch = 0;
|
||||
scratchHpr.roll = 0;
|
||||
return Cesium.Transforms.headingPitchRollToFixedFrame(
|
||||
|
||||
@@ -110,6 +110,23 @@ test('a model pose is the old heading-pitch-roll frame with the nose offset', ()
|
||||
);
|
||||
});
|
||||
|
||||
test('a model pose takes a per-model nose offset (military per-class specs)', () => {
|
||||
const { viewer } = stubViewer();
|
||||
const r = renderer(viewer);
|
||||
const model = { modelMatrix: new Cesium.Matrix4() };
|
||||
const position = geo.cartesian3.fromDegrees(-97.7, 30.2, 3000);
|
||||
r.models.setPose(model, position, 75, 90);
|
||||
const expected = Cesium.Transforms.headingPitchRollToFixedFrame(
|
||||
position,
|
||||
new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(75 + 90), 0, 0),
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
);
|
||||
assert.deepEqual(
|
||||
[...Cesium.Matrix4.toArray(model.modelMatrix)],
|
||||
[...Cesium.Matrix4.toArray(expected)],
|
||||
);
|
||||
});
|
||||
|
||||
test('model loads carry the layer spec; the IR boost loads an UNLIT model', async () => {
|
||||
const { viewer } = stubViewer();
|
||||
const r = renderer(viewer);
|
||||
|
||||
@@ -71,7 +71,8 @@
|
||||
* restoreOrder(), restoreOrderOnEnable().
|
||||
* @property {object} models live(), setVisible(bool), loadFleet(spec),
|
||||
* loadTracked(spec), preload(url) → Promise<ModelHandle>, add(model),
|
||||
* remove(model), destroy(model), setPose(model, position, headingDeg).
|
||||
* remove(model), destroy(model), setPose(model, position, headingDeg,
|
||||
* offsetDeg?) (offsetDeg: the model's nose offset, default the layer's).
|
||||
* spec: { url, minimumPixelSize, scale, color, blendAmount, unlit, id }.
|
||||
* @property {object} tracked create(spec) → TrackedHandle, remove(handle),
|
||||
* isLive(handle), setImage(handle, image), setViewFrom(handle, enu),
|
||||
|
||||
@@ -719,11 +719,10 @@ export function createAircraftNavaraRenderer({
|
||||
model?.gevBank?.remove(model);
|
||||
},
|
||||
/** The same HPR frame as Cesium (modelMatrix); the instance turned by
|
||||
* Navara's glTF axes (NAVARA_GLTF_AXIS). */
|
||||
setPose(model, position, headingDeg) {
|
||||
scratchHpr.heading = geo.math.toRadians(
|
||||
(headingDeg || 0) + headingOffsetDeg,
|
||||
);
|
||||
* Navara's glTF axes (NAVARA_GLTF_AXIS). `offsetDeg`: this model's
|
||||
* nose offset when the layer's models differ (default: the layer's). */
|
||||
setPose(model, position, headingDeg, offsetDeg = headingOffsetDeg) {
|
||||
scratchHpr.heading = geo.math.toRadians((headingDeg || 0) + offsetDeg);
|
||||
geo.transforms.headingPitchRollToFixedFrame(
|
||||
position,
|
||||
scratchHpr,
|
||||
|
||||
Reference in new issue
Block a user