Files
gods-eye-view/src/layers/submarineCables/interaction.js
T
Sameh Khamis b86014244d 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.
2026-11-14 09:10:14 -08:00

47 lines
1.3 KiB
JavaScript

import { toRadians } from '../../geo/vector.js';
import { cameraOf } from '../../render/rendererOf.js';
export function createInteraction({ state, parts, inputFor }) {
function beginInteraction(viewer) {
if (state._clickSubscription) return;
state._clickSubscription = inputFor(viewer).onClick((event) => {
if (!state._enabled) return;
const record = resolvePickRecord(event.drawHit);
if (!record?.reference) return;
flyToReference(viewer, record.reference);
});
}
/**
* What a click's draw hit names: a cable, landing point or reference of
* this layer's current items, as `{ label, kind, featureId, reference }`,
* or null.
*/
function resolvePickRecord(hit) {
return parts.rendering.pickInfo(hit);
}
function flyToReference(viewer, reference) {
if (!viewer || !reference) return;
const camera = cameraOf(viewer);
camera.cancelFlight();
camera.flyTo(
{ lon: reference.lon, lat: reference.lat, height: 6500 },
{
orientation: {
heading: camera.pose().heading || 0,
pitch: toRadians(-52),
roll: 0,
},
durationS: 1.35,
easing: 'cubicInOut',
},
);
}
return {
beginInteraction,
resolvePickRecord,
flyToReference,
};
}