mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 18:22:25 +00:00
- A count click stands aside when an overlay label or another layer's card already took the click, and CCTV now claims a count click in the shared pick registry, so the flights layer no longer reads it as an empty-map click and keeps tracking its aircraft. - The flight to a group halves the distance only while the group stays in frame; otherwise it flies to the nearest ground cell of the group, so a tilted click no longer ends with no camera on screen. - Counts hidden under the HUD no longer push the active icon aside, and a lone camera that would move a merged count under the HUD leaves the original count and its icon as they were. - Cameras on one mount are spread before counts merge, so a spread icon no longer slides under a neighbouring count. - The ground module comment says how a camera without a batch height takes the drawn terrain.
68 lines
2.3 KiB
JavaScript
68 lines
2.3 KiB
JavaScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { bindRenderer } from '../../render/rendererOf.js';
|
|
import { fromDegrees } from '../../geo/ellipsoid.js';
|
|
import { distance } from '../../geo/vector.js';
|
|
import {
|
|
addCellCamera,
|
|
createCameraCell,
|
|
mergeCountCells,
|
|
} from '../../data/cctvCellCounts.js';
|
|
import { createNavigation } from './navigation.js';
|
|
|
|
// A count of four merged in a tilted view: two pairs 10 km and 40 km north of
|
|
// an eye 800 m up. After the click, at least one member must be in frame.
|
|
test('a count click from a tilted view keeps the group members in the frame', () => {
|
|
const viewer = {};
|
|
const flights = [];
|
|
const fovy = Math.PI / 3;
|
|
const aspectRatio = 800 / 600;
|
|
const unbind = bindRenderer(viewer, {
|
|
camera: {
|
|
pose: () => ({ fovy, aspectRatio, position: fromDegrees(0, 0, 800) }),
|
|
flyToBounds: (bounds, options) => flights.push({ bounds, options }),
|
|
},
|
|
canvas: { clientHeight: 600, clientWidth: 800 },
|
|
});
|
|
try {
|
|
const metresPerDegree = 111_320;
|
|
const members = [];
|
|
const cells = [10_000, 40_000].map((start) => {
|
|
const cell = createCameraCell(String(start));
|
|
for (const northM of [start, start + 10]) {
|
|
const lat = northM / metresPerDegree;
|
|
addCellCamera(cell, { lat, lon: 0, absoluteHeightM: 8 });
|
|
members.push(fromDegrees(0, lat, 8));
|
|
}
|
|
return cell;
|
|
});
|
|
const screens = [
|
|
{ x: 400, y: 300 },
|
|
{ x: 433, y: 300 },
|
|
];
|
|
const groups = mergeCountCells(
|
|
cells,
|
|
() => screens.shift(),
|
|
() => ({ width: 40, height: 40 }),
|
|
2,
|
|
);
|
|
assert.equal(groups.length, 1);
|
|
assert.equal(groups[0].count, 4);
|
|
const state = { _viewer: viewer };
|
|
const navigation = createNavigation({ state, parts: {} });
|
|
navigation.zoomToCell(groups[0]);
|
|
assert.equal(flights.length, 1);
|
|
const { range, pitch } = flights[0].options.offset;
|
|
assert.equal(pitch, -Math.PI / 2);
|
|
const { center } = flights[0].bounds;
|
|
const halfSpanM = range * Math.tan(fovy / 2);
|
|
assert.ok(
|
|
members.some((point) => distance(point, center) <= halfSpanM),
|
|
'no member of the group is in the final frame',
|
|
);
|
|
assert.ok(range < distance(fromDegrees(0, 0, 800), center));
|
|
} finally {
|
|
unbind();
|
|
}
|
|
});
|