mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(input): no double-click follow or zoom on the map
The globe viewer's own double-click tracked a picked entity with a position or zoomed to one without. Layers moving onto the draw port had it re-created one by one (data/stockFollow.js); following is a click in GEV, so the viewer's handler is removed where the viewer is made and every re-creation goes: earthquakes, cyclones, air quality, news, perimeters, drone airspace, ghost maps, places, radio, cables, CCTV, ALPR, launches, bikeshare, Local ADS-B, installations, directions, trails, data packs, annotations, the library's view and local GeoJSON. The Cockpit's own double-click and the draw tool's finishing double-click stay.
This commit is contained in:
1 parent
bb2d22dbce
commit
b86014244d
69 files changed
+94
-2797
No files matched your search
@@ -3,8 +3,6 @@ import assert from 'node:assert/strict';
|
||||
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
|
||||
import { CHUNK_POINTS, createTrail } from './trailRenderer.js';
|
||||
import { findPickOwner } from './pickRegistry.js';
|
||||
import { bindFakeGroundRenderer } from '../testSupport/fakeGroundRenderer.mjs';
|
||||
import { fromDegrees } from '../geo/ellipsoid.js';
|
||||
|
||||
function viewerWithDraw(t) {
|
||||
const viewer = { isDestroyed: () => false };
|
||||
@@ -231,56 +229,3 @@ test('clearing a segmented trail lets every line go', (t) => {
|
||||
trail.setSegments([points(4)]);
|
||||
assert.equal(historyLines(set).length, 1, 'drawn again after a clear');
|
||||
});
|
||||
|
||||
test('a double-click on a trail line zooms to that line, as to the polyline entity it was', (t) => {
|
||||
const viewer = { isDestroyed: () => false };
|
||||
const fake = bindFakeGroundRenderer(viewer);
|
||||
t.after(fake.unbind);
|
||||
let dblclick = null;
|
||||
const stock = { dblclickFollow: true };
|
||||
fake.renderer.input = {
|
||||
onPointer(type, handler) {
|
||||
assert.equal(type, 'dblclick');
|
||||
dblclick = handler;
|
||||
return () => {
|
||||
dblclick = null;
|
||||
};
|
||||
},
|
||||
stockEnabled: (name) => stock[name] === true,
|
||||
};
|
||||
const trail = createTrail(viewer, { color: '#00d4ff' });
|
||||
const a = fromDegrees(0, 0, 1000);
|
||||
const b = fromDegrees(0.1, 0, 1000);
|
||||
trail.setPositions([a, b]);
|
||||
const set = fake.liveSets().find((s) => s.spec.id.startsWith('trail:'));
|
||||
const [line] = set.items.values();
|
||||
fake.setPick(() => ({ set: set.spec.id, id: line.id }));
|
||||
const at = { position: { x: 1, y: 2 } };
|
||||
|
||||
dblclick(at);
|
||||
assert.equal(fake.flights.length, 1, 'zoomed at once');
|
||||
const { sphere, options } = fake.flights[0];
|
||||
assert.equal(options.durationS, 0);
|
||||
const mid = { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2, z: (a.z + b.z) / 2 };
|
||||
assert.ok(
|
||||
Math.hypot(
|
||||
sphere.center.x - mid.x,
|
||||
sphere.center.y - mid.y,
|
||||
sphere.center.z - mid.z,
|
||||
) < 1,
|
||||
);
|
||||
assert.equal(fake.follows.length, 0, 'nothing followed');
|
||||
|
||||
// Held off (a tool holds the stock follow), a hidden trail line, or
|
||||
// another layer's hit: nothing.
|
||||
stock.dblclickFollow = false;
|
||||
dblclick(at);
|
||||
stock.dblclickFollow = true;
|
||||
fake.setPick(() => ({ set: 'other', id: line.id }));
|
||||
dblclick(at);
|
||||
assert.equal(fake.flights.length, 1);
|
||||
|
||||
// The last trail gone, the viewer's double-click is let go.
|
||||
trail.destroy();
|
||||
assert.equal(dblclick, null);
|
||||
});
|
||||
Reference in new issue
Block a user