mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
refactor(data): focus projects through the engine; readout follows a tracked visual's follow
Task 10b foundation. - focusDeemphasis projects through the engine registered for the scene it is given (engineFromViewer(scene).projector), as iconOrientation already does, else Cesium's SceneTransforms. On Cesium the engine projector is SceneTransforms, so nothing changes there; on Navara the aircraft renderer's scene adapter is registered with the engine. Test with a fake engine. - refreshTrackedReadout accepts a layer's tracked visual that names its follow handle (gevFollowHandle): engines without tracked entities republish the card through it. Test.
This commit is contained in:
1 parent
4dfcba8989
commit
443c581280
4 files changed
+71
-14
No files matched your search
@@ -162,3 +162,46 @@ test('NearFarScalar rendered-size interpolation matches Cesium clamp endpoints',
|
||||
const middle = nearFarScalarValueAtDistance(scalar, 1_000_000);
|
||||
assert.ok(middle > 0.5 && middle < 3);
|
||||
});
|
||||
|
||||
test('a focus target projects through the engine registered for its scene', async () => {
|
||||
const { publishFocusTargetFromCachedPosition, clearFocusTarget } =
|
||||
await import('./focusDeemphasis.js');
|
||||
const { registerViewerEngine } = await import(
|
||||
'../globe/cesium/engineFromViewer.js'
|
||||
);
|
||||
const { createFakeEngine } = await import('../globe/testing/fakeEngine.js');
|
||||
const engine = createFakeEngine();
|
||||
const projected = [];
|
||||
engine.projector.worldToWindow = (position, result = {}) => {
|
||||
projected.push(position);
|
||||
return Object.assign(result, { x: 300, y: 200 });
|
||||
};
|
||||
// A scene with no Cesium behind it (the Navara renderer's adapter).
|
||||
const scene = { frameState: { frameNumber: 7 } };
|
||||
const unregister = registerViewerEngine(scene, engine);
|
||||
try {
|
||||
const target = publishFocusTargetFromCachedPosition({
|
||||
ownerLayer: 'flights',
|
||||
id: 'abc123',
|
||||
scene,
|
||||
camera: { positionWC: { x: 0, y: 0, z: 1000 } },
|
||||
displayPosition: { x: 0, y: 0, z: 0 },
|
||||
widthPx: 20,
|
||||
heightPx: 20,
|
||||
params: { paddingPx: 0 },
|
||||
});
|
||||
assert.equal(projected.length, 1);
|
||||
assert.deepEqual(target.screenRect, {
|
||||
left: 290,
|
||||
top: 190,
|
||||
right: 310,
|
||||
bottom: 210,
|
||||
});
|
||||
assert.equal(target.cameraDistance, 1000);
|
||||
assert.equal(target.frameNumber, 7);
|
||||
} finally {
|
||||
clearFocusTarget('flights');
|
||||
unregister();
|
||||
engine.destroy();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user