mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
feat(cctv): show how many cameras a thinned marker stands for
Zoomed out, the layer keeps one camera per ground cell and drew it as an ordinary icon, so nothing showed that dozens or hundreds of other cameras sat behind it. A cell with two or more cameras is now one round marker with the count inside, at the centre of its cameras. Single cameras and the active camera keep their icons. The count covers the whole cell, so it does not change while the cell crosses the screen edge. Markers that would overlap on screen merge into one carrying their sum. Counts above 999 use the compact form of the UI language and widen the marker into a pill. Clicking a marker zooms to its group and does not choose a camera. Ambient cards and coverage attach only to cameras drawn as icons; the camera picker keeps one representative per visible cell as before.
This commit is contained in:
1 parent
c08bd1103d
commit
607796737c
20 files changed
+965
-77
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { isFollowing } from '../../data/followed.js';
|
||||
import { CCTV_FOCUS_RESULT } from './policy.js';
|
||||
import { cameraOf } from '../../render/rendererOf.js';
|
||||
import { cellBounds } from '../../data/cctvCellCounts.js';
|
||||
import { CCTV_FOCUS_RESULT, VIEW_CELL_PX, VIEW_MIN_CELL_M } from './policy.js';
|
||||
import { cameraOf, canvasOf } from '../../render/rendererOf.js';
|
||||
|
||||
export function createNavigation({
|
||||
state: layerState,
|
||||
@@ -104,6 +105,27 @@ export function createNavigation({
|
||||
return CCTV_FOCUS_RESULT.FOCUSED;
|
||||
}
|
||||
|
||||
/** Frame a group's padded bounds from above, including coincident mounts. */
|
||||
function zoomToCell(cell) {
|
||||
const viewer = layerState._viewer;
|
||||
const camera = cameraOf(viewer);
|
||||
const pose = camera.pose();
|
||||
const tanHalfY = Math.tan((pose.fovy || Math.PI / 3) / 2);
|
||||
const canvas = canvasOf(viewer);
|
||||
const height = canvas?.clientHeight || canvas?.height || 1;
|
||||
const halfFov = Math.atan(tanHalfY * Math.min(1, pose.aspectRatio || 1));
|
||||
const bounds = cellBounds(cell);
|
||||
// A tight group lands comfortably inside the individual-icon level.
|
||||
const closeRange =
|
||||
(VIEW_MIN_CELL_M * height) / (4 * VIEW_CELL_PX * tanHalfY);
|
||||
const range = Math.max(closeRange, bounds.radius / Math.sin(halfFov));
|
||||
camera.flyToBounds(bounds, {
|
||||
offset: { heading: 0, pitch: -Math.PI / 2, range },
|
||||
durationS: 1.2,
|
||||
easing: 'cubicInOut',
|
||||
});
|
||||
}
|
||||
|
||||
function focusCamera(cameraId, duration = 2.2) {
|
||||
return focusCctvRecord(
|
||||
layerState._viewer,
|
||||
@@ -179,6 +201,7 @@ export function createNavigation({
|
||||
openingCameraId,
|
||||
reopenNearestCamera,
|
||||
focusCctvRecord,
|
||||
zoomToCell,
|
||||
focusCamera,
|
||||
maybeAutoHop,
|
||||
cctvCycleIndex,
|
||||
|
||||
Reference in new issue
Block a user