mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Let the camera picker pick the opening CCTV camera
The picker preselected the active camera, and a native select fires no
change for the option it already shows. So while CCTV was still following
the view, choosing the camera the picker showed did nothing, and the next
pan switched to another camera.
The layer now reports whether the active camera is the opening one
(activeCameraProvisional). While it is, the picker shows that camera from
a hidden, disabled first option, so choosing it from the list is a change
and ends automatic selection; closing the list keeps it. A same-camera
pick that ends the opening pick notifies listeners so the picker drops the
hidden option, and reopenNearestCamera passes { opening: true } so its own
notification already carries the opening state.
docs/CURRENT-STATE.md now says when automatic selection ends. Tests cover
the hidden option, confirming and dismissing the picker before a pan, the
notification, and focusNearestToPoint, which is now on main.
This commit is contained in:
1 parent
fe37cacba0
commit
a6eecee157
12 files changed
+315
-30
No files matched your search
@@ -11,6 +11,7 @@ import cctvLayer, {
|
||||
_setCctvOverlayHostForTest,
|
||||
reopenNearestCamera,
|
||||
} from './cctv.js';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
|
||||
const BASE = {
|
||||
headingDeg: 41,
|
||||
@@ -39,19 +40,9 @@ function record(id, lat, lon) {
|
||||
}
|
||||
|
||||
function viewerAt(lat, lon) {
|
||||
return {
|
||||
entities: new Cesium.EntityCollection(),
|
||||
const viewer = {
|
||||
isDestroyed: () => false,
|
||||
trackedEntity: null,
|
||||
camera: {
|
||||
positionWC: Cesium.Cartesian3.fromDegrees(lon, lat, 300),
|
||||
positionCartographic: Cesium.Cartographic.fromDegrees(lon, lat, 300),
|
||||
heading: 0.4,
|
||||
pitch: -0.7,
|
||||
roll: 0,
|
||||
transform: Cesium.Matrix4.clone(Cesium.Matrix4.IDENTITY),
|
||||
flyToBoundingSphere() {},
|
||||
},
|
||||
eye: { lat, lon, height: 300 },
|
||||
scene: {
|
||||
canvas: { clientWidth: 1200, clientHeight: 800 },
|
||||
cartesianToCanvasCoordinates: () => undefined,
|
||||
@@ -59,14 +50,20 @@ function viewerAt(lat, lon) {
|
||||
requestRender() {},
|
||||
},
|
||||
};
|
||||
// The layer reads the eye and flies through the renderer's camera port.
|
||||
viewer.draw = bindFakeDraw(viewer, {
|
||||
camera: {
|
||||
pose: () => ({ ...viewer.eye }),
|
||||
on: () => () => {},
|
||||
followed: null,
|
||||
flyToBounds() {},
|
||||
},
|
||||
}).draw;
|
||||
return viewer;
|
||||
}
|
||||
|
||||
function moveViewer(viewer, lat, lon) {
|
||||
viewer.camera.positionCartographic = Cesium.Cartographic.fromDegrees(
|
||||
lon,
|
||||
lat,
|
||||
300,
|
||||
);
|
||||
viewer.eye = { lat, lon, height: 300 };
|
||||
}
|
||||
|
||||
function withReopenedLayer(fn) {
|
||||
@@ -98,6 +95,7 @@ function withReopenedLayer(fn) {
|
||||
moveViewer(viewer, 51.5131, -0.1291);
|
||||
assert.equal(reopenNearestCamera(), true);
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, true);
|
||||
fn(viewer);
|
||||
} finally {
|
||||
globalThis.document = originalDocument;
|
||||
@@ -114,11 +112,16 @@ for (const [name, pick] of [
|
||||
'setParams({ selectedCameraId })',
|
||||
() => cctvLayer.setParams({ selectedCameraId: 'b-cambridge' }),
|
||||
],
|
||||
[
|
||||
'focusNearestToPoint',
|
||||
() => cctvLayer.focusNearestToPoint(51.513, -0.129, { focus: false }),
|
||||
],
|
||||
]) {
|
||||
test(`an explicit ${name} pick of the re-opened camera ends the opening pick`, () => {
|
||||
withReopenedLayer((viewer) => {
|
||||
pick();
|
||||
assert.equal(cctvLayer.getUIState().activeCameraId, 'b-cambridge');
|
||||
assert.equal(cctvLayer.getUIState().activeCameraProvisional, false);
|
||||
// A later settled move (a pan, or the landing of the pick's own flight)
|
||||
// leaves the explicit choice alone.
|
||||
moveViewer(viewer, 51.5081, -0.1281);
|
||||
|
||||
Reference in new issue
Block a user