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:
German Khokhlov committed 2026-10-16 20:57:10 +04:00
1 parent 68ff4e1c25
commit 4e195dac6b
9 files changed
+362 -15

No files matched your search

+72
View File
@@ -127,3 +127,75 @@ test('stop ends the follow; a new follow replaces the old one', () => {
TypeError,
);
});
test('with engine gestures, drag orbits at the same range and wheel stops at the floor', () => {
let pose = {
position: cartesian3.fromDegrees(0, 0, 1e7),
direction: cartesian3.create(-1, 0, 0),
up: cartesian3.create(0, 0, 1),
};
const commanded = createEngineEvent();
const frame = createEngineEvent();
let handlers = null;
let suspended = 0;
const controller = createFollowController({
camera: { pose: () => pose, commanded },
aim: (next) => {
pose = next;
},
frame,
requestRender: () => {},
gestures: (next) => {
handlers = next;
suspended++;
return () => {
handlers = null;
suspended--;
};
},
});
const handle = controller.follow({
position: () => target0,
viewFrom: cartesian3.create(0, -1000, 500),
});
assert.equal(suspended, 1, 'the engine gestures are taken');
frame.raiseEvent();
const range = () => cartesian3.distance(pose.position, target0);
const start = range();
handlers.orbit(0.8, 0.3);
frame.raiseEvent();
assert.ok(Math.abs(range() - start) < 1e-6 * start, 'orbit keeps the range');
const offset = enuOffset(target0, pose.position);
assert.ok(Math.abs(offset.x) > 100, 'the heading turned');
// A camera move nobody commanded (the engine's own controller) is not
// read back while the gestures are the follow's.
pose = { ...pose, position: cartesian3.fromDegrees(10, 10, 1e6) };
frame.raiseEvent();
assert.ok(Math.abs(range() - start) < 1e-6 * start);
for (let i = 0; i < 40; i++) {
handlers.zoom(0.5);
frame.raiseEvent();
assert.ok(range() >= MIN_FOLLOW_RANGE_M - 1e-6, `range ${range()}`);
}
assert.ok(Math.abs(range() - MIN_FOLLOW_RANGE_M) < 1e-6, 'at the floor');
// Pitch stays above the target's horizon and short of straight down.
handlers.orbit(0, 10);
frame.raiseEvent();
const up = enuOffset(target0, pose.position);
assert.ok(up.z > 0 && up.z < MIN_FOLLOW_RANGE_M, 'pitch clamped');
handle.stop();
assert.equal(suspended, 0, 'the gestures are given back');
});
test('a still target and offset request no renders', () => {
const h = harness();
h.controller.follow({
position: () => target0,
viewFrom: cartesian3.create(0, -1000, 500),
});
h.frame();
h.frame();
const settled = h.renders();
for (let i = 0; i < 5; i++) h.frame();
assert.equal(h.renders(), settled, 'idle while nothing moves');
});