mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(globe): the Navara follow orbits on drag and zooms to the floor
Review of Task 5: while following on Navara a left drag panned the globe about the ground point under the cursor (range 2,154 m → 54,136 m) and the wheel zoomed toward that point (462 m after 40 notches, Cesium stops at the 150 m floor). While a follow runs, Navara's spin, zoom and tilt are now suspended (input.suspendCameraInputs, which gives the app's own setCameraInputs choice back after the release) and followGestures.js turns a drag into heading and pitch of the ENU offset (a canvas width is one turn, its height half a turn; elevation kept within 2°-89°) and a wheel notch into 20 % of its range, never inside the minimum range, as Cesium's EntityView orbits the target. The offset is no longer read back from a camera the follow alone moves. Also (review item 7): a follow requests a render only when the target, the offset or a gesture changed, so a still target lets Navara idle. The contract follow check drags (range within ±5 %, target within 3 px) and turns the wheel 40 notches (never below 149 m, ends within 5 % of 150 m) on both engines with real input (qa-globe-contract's pointer gains drag and wheel); after stop it waits for Cesium's gesture inertia to end before checking that the camera is free. Contract: Cesium 73/73, Navara 79/79.
This commit is contained in:
1 parent
68ff4e1c25
commit
4e195dac6b
9 files changed
+362
-15
No files matched your search
@@ -2588,6 +2588,43 @@ export function createContractSuite(
|
||||
`the target drifted ${worst.toFixed(2)} px off centre`,
|
||||
);
|
||||
ensure(step - firstStep >= 120, 'the target did not move');
|
||||
if (pointer?.drag && pointer?.wheel) {
|
||||
// A left drag orbits the target: same range (±5 %), centred.
|
||||
const { width, height } = engine.host.size();
|
||||
const before = range();
|
||||
await pointer.drag(
|
||||
width / 2,
|
||||
height / 2,
|
||||
width / 2 + 200,
|
||||
height / 2 + 60,
|
||||
);
|
||||
await settle(4);
|
||||
ensure(camera.following() === handle, 'a drag ended the follow');
|
||||
ensure(
|
||||
Math.abs(range() - before) <= 0.05 * before,
|
||||
`a drag changed the range ${before.toFixed(0)} → ${range().toFixed(0)} m`,
|
||||
);
|
||||
ensure(offCentre() <= 3, 'the target left the centre after a drag');
|
||||
// The wheel zooms toward the target down to the floor, never below.
|
||||
let lowest = Infinity;
|
||||
for (let notch = 0; notch < 40; notch++) {
|
||||
await pointer.wheel(width / 2, height / 2, -100);
|
||||
await settle(2);
|
||||
lowest = Math.min(lowest, range());
|
||||
}
|
||||
await settle(4);
|
||||
lowest = Math.min(lowest, range());
|
||||
ensure(lowest >= 149, `the wheel reached ${lowest.toFixed(1)} m`);
|
||||
ensure(
|
||||
range() <= 150 * 1.05,
|
||||
`40 wheel notches stopped at ${range().toFixed(1)} m, not the 150 m floor`,
|
||||
);
|
||||
ensure(
|
||||
offCentre() <= 3,
|
||||
'the target left the centre after the wheel',
|
||||
);
|
||||
ensure(camera.following() === handle, 'the wheel ended the follow');
|
||||
}
|
||||
// A zoom through the target stops at the minimum range.
|
||||
camera.zoomIn(5000);
|
||||
await settle(4);
|
||||
@@ -2599,12 +2636,26 @@ export function createContractSuite(
|
||||
ensure(camera.following() === null, 'following() after stop');
|
||||
ensure(changes.at(-1) === null, 'followChanged did not report null');
|
||||
camera.release();
|
||||
await settle();
|
||||
// Gesture inertia (Cesium) may carry the camera a few frames:
|
||||
// wait for it to rest, then the target moves on without it.
|
||||
let last = camera.pose().position;
|
||||
let stillFrames = 0;
|
||||
await until(() => {
|
||||
const now = camera.pose().position;
|
||||
stillFrames =
|
||||
cartesian3.distance(now, last) < 1e-3 ? stillFrames + 1 : 0;
|
||||
last = now;
|
||||
return stillFrames >= 5;
|
||||
}, 'the camera at rest after stop');
|
||||
const free = camera.pose().position;
|
||||
await settle(10);
|
||||
ensure(
|
||||
cartesian3.distance(camera.pose().position, free) < 1e-3,
|
||||
'the camera still follows after stop',
|
||||
`the camera still moves after stop (${cartesian3
|
||||
.distance(camera.pose().position, free)
|
||||
.toFixed(2)} m in 10 frames; following ${Boolean(
|
||||
camera.following(),
|
||||
)})`,
|
||||
);
|
||||
// A command that takes the camera ends the follow.
|
||||
camera.follow({
|
||||
|
||||
Reference in new issue
Block a user