fix(globe): the Navara follow turns and dollies as Cesium's tracked camera

Review of Tasks 6-7: a 240 px drag right turned Navara's follow by -67.5°
where Cesium turns +119.5°, and a right drag did nothing (Cesium dollies,
1.95 Mm → 0.91 Mm). followGestures.js now follows Cesium's
ScreenSpaceCameraController for a tracked camera:
- left drag (rotate3D): heading += 1.77 × dx / width × 2π (clockwise for a
  drag right; 1.77 is Cesium's maximum rotate rate, which a tracked camera
  beyond a few metres always reaches) and the camera rises by
  1.77 × -dy / height × π; each move counts at most a tenth of the canvas
  (maximumMovementRatio);
- right drag (zoom3D): follow.js dollyOffset moves 5 × dy / height of the
  distance above the floor (closing) or of the range (opening), never
  inside it; no context menu while following.

The contract follow check turns the camera with a 240 px drag right and
asserts the heading turn against Cesium's rate (±15 %; the harness holds the
pointer before releasing it so Cesium adds no inertia), and dollies with a
right drag down (range below 80 %, never under 149 m). Cesium 73/73, Navara
79/79.
This commit is contained in:
German Khokhlov committed 2026-10-16 22:14:02 +04:00
1 parent b0cbed081b
commit f0ce1b04c7
5 files changed
+188 -19

No files matched your search

+22
View File
@@ -199,3 +199,25 @@ test('a still target and offset request no renders', () => {
for (let i = 0; i < 5; i++) h.frame();
assert.equal(h.renders(), settled, 'idle while nothing moves');
});
test('a dolly moves along the offset as Cesium zoom3D, never inside the floor', async () => {
const { dollyOffset } = await import('./follow.js');
const offset = cartesian3.create(0, -1000, 0);
// Five times the window ratio of the distance above the floor (closing).
const closer = dollyOffset(offset, 0.05, 150);
assert.ok(
Math.abs(cartesian3.magnitude(closer) - (1000 - 5 * 850 * 0.05)) < 1e-9,
);
const away = dollyOffset(offset, -0.05, 150);
assert.ok(
Math.abs(cartesian3.magnitude(away) - (1000 + 5 * 1000 * 0.05)) < 1e-9,
);
// At most a tenth per move, and never through the floor.
const capped = dollyOffset(offset, 0.5, 150);
assert.ok(
Math.abs(cartesian3.magnitude(capped) - (1000 - 5 * 850 * 0.1)) < 1e-9,
);
let near = cartesian3.create(0, -160, 0);
for (let i = 0; i < 20; i++) near = dollyOffset(near, 0.1, 150);
assert.ok(cartesian3.magnitude(near) >= 150);
});