mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +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
@@ -180,7 +180,6 @@ async function fixture(t) {
|
||||
addLaunchEntity: noop,
|
||||
flushLaunchEntities: noop,
|
||||
clearLaunchEntities: noop,
|
||||
followTargetFor: () => null,
|
||||
launchIdFromPicks: () => null,
|
||||
launchMarkerAt: () => null,
|
||||
missionHitsAt: () => [],
|
||||
|
||||
@@ -137,7 +137,6 @@ async function fixture({ legacySource = false } = {}) {
|
||||
},
|
||||
launchIdFromPicks: () => null,
|
||||
missionHitsAt: () => [],
|
||||
followTargetFor: () => null,
|
||||
launchMarkerAt: () => false,
|
||||
addLaunchEntity(record) {
|
||||
state._missionSets.items.push(record.id);
|
||||
@@ -327,11 +326,8 @@ test('destroy followed by actual init starts a clean instance with owned handler
|
||||
assert.equal(typeof f.state._inputSubscription, 'function');
|
||||
await f.destroy();
|
||||
assert.equal(f.state._inputSubscription, null);
|
||||
assert.equal(
|
||||
input.subscriberCount(),
|
||||
before - 3,
|
||||
'click, hover and double-click follow',
|
||||
);
|
||||
assert.equal(input.subscriberCount(), before - 2, 'click and hover');
|
||||
|
||||
assert.equal(f.attachedSets(), 0);
|
||||
assert.equal(f.viewer.scene.preRender.numberOfListeners, 0);
|
||||
} finally {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { canvasOf, findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
import { followOnDoubleClick } from '../../data/stockFollow.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
|
||||
const HOVER_PICK_INTERVAL_MS = 120;
|
||||
@@ -204,20 +203,9 @@ export function createLifecycle({
|
||||
launchAt: parts.rendering.launchMarkerAt,
|
||||
});
|
||||
const unsubscribeHover = input.onPointer('move', hover.move);
|
||||
// A double-click follows a mission point, as the default renderer
|
||||
// followed the missions' entities.
|
||||
layerState._stockFollow = followOnDoubleClick({
|
||||
viewer,
|
||||
inputFor: () => input,
|
||||
name: 'rocket-launches',
|
||||
enabled: () => layerState._enabled && parts.rendering.missionsShown(),
|
||||
targetFor: parts.rendering.followTargetFor,
|
||||
});
|
||||
layerState._inputSubscription = () => {
|
||||
unsubscribeClick();
|
||||
unsubscribeHover();
|
||||
layerState._stockFollow?.destroy();
|
||||
layerState._stockFollow = null;
|
||||
};
|
||||
// Apply horizon visibility before the renderer draws and picks.
|
||||
// A postRender write is one frame late and can remain visibly stale when
|
||||
@@ -307,7 +295,6 @@ export function createLifecycle({
|
||||
layerState._cameraReleased = true;
|
||||
parts.selection.stopMissionZoomAnchor();
|
||||
parts.rendering.showMissions(false);
|
||||
layerState._stockFollow?.stop();
|
||||
parts.orbitRendering.syncMissionOrbitPrimitiveVisibility();
|
||||
const canvas = canvasOf(layerState._viewer);
|
||||
if (canvas) canvas.style.cursor = '';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { fromDegrees, fromDegreesInto } from '../../geo/ellipsoid.js';
|
||||
import { horizonFrom } from '../../geo/horizon.js';
|
||||
import { sphereFromPoints } from '../../geo/sphere.js';
|
||||
import { clamp } from '../../geo/vector.js';
|
||||
import { hexColor } from '../../render/color.js';
|
||||
import { drawOf, findCamera, findQuery } from '../../render/rendererOf.js';
|
||||
@@ -42,18 +41,7 @@ export function createRendering({
|
||||
let setIds = null;
|
||||
/** Frames the mission sets have been walked in, the live cache's key. */
|
||||
let frameNumber = 0;
|
||||
// The follow reads its target before preRender (once a tick, and again
|
||||
// in preUpdate while it first frames), so a follow read opens the live
|
||||
// sample the next preRender keeps: the camera and the marker stand at
|
||||
// the same instant, and every read until then shares it.
|
||||
let followSampled = false;
|
||||
|
||||
/** Open the live sample a follow read and the next preRender share. */
|
||||
function openFollowSample() {
|
||||
if (followSampled) return;
|
||||
followSampled = true;
|
||||
frameNumber += 1;
|
||||
}
|
||||
/**
|
||||
* Every drawn mission item by set and id, with what decides whether it
|
||||
* shows: `isolated` (the mission's selection), and for points and icons
|
||||
@@ -173,9 +161,6 @@ export function createRendering({
|
||||
|
||||
/** Remove every mission item, ahead of a rebuild. */
|
||||
function clearLaunchEntities() {
|
||||
// A followed item goes with them, as a removed entity stopped being
|
||||
// followed.
|
||||
layerState._stockFollow?.stop();
|
||||
const sets = layerState._missionSets;
|
||||
records.clear();
|
||||
pending.clear();
|
||||
@@ -194,28 +179,6 @@ export function createRendering({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* What a double-click on a mission item follows: a point by where it is
|
||||
* drawn (the payload as it moves), a line zoomed to by its bounds.
|
||||
*/
|
||||
function followTargetFor(hit) {
|
||||
if (!missionHit(hit)) return null;
|
||||
const name = Object.keys(setIds).find((key) => setIds[key] === hit.set);
|
||||
const record = records.get(recordKey(name, hit.id));
|
||||
if (!record) return null;
|
||||
if (!record.position)
|
||||
return { zoomTo: sphereFromPoints(record.item.positions) };
|
||||
const at = record.position;
|
||||
return {
|
||||
key: `${setIds.sites}:${hit.id}`,
|
||||
position: () => {
|
||||
if (typeof at === 'function') openFollowSample();
|
||||
const p = typeof at === 'function' ? at() : at;
|
||||
return p ? copy(p) : null;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** The launch of the first mission item among a click's drilled hits. */
|
||||
function launchIdFromPicks(hits) {
|
||||
for (const hit of hits) {
|
||||
@@ -287,8 +250,7 @@ export function createRendering({
|
||||
}
|
||||
|
||||
function updateMissionFrame() {
|
||||
if (followSampled) followSampled = false;
|
||||
else frameNumber += 1;
|
||||
frameNumber += 1;
|
||||
if (!layerState._enabled || !layerState._viewer || !missionsShown()) {
|
||||
parts.overlays.hideReplayVehicleOverlay();
|
||||
return;
|
||||
@@ -841,7 +803,6 @@ export function createRendering({
|
||||
showMissions,
|
||||
clearLaunchEntities,
|
||||
launchIdFromPicks,
|
||||
followTargetFor,
|
||||
missionHitsAt,
|
||||
launchMarkerAt,
|
||||
selectLaunchEntity,
|
||||
|
||||
@@ -35,9 +35,6 @@ export function createState({ services }) {
|
||||
|
||||
state._inputSubscription = null;
|
||||
|
||||
// The double-click follow of mission points, while initialised.
|
||||
state._stockFollow = null;
|
||||
|
||||
state._viewer = null;
|
||||
|
||||
state._declutterHandler = null;
|
||||
|
||||
Reference in new issue
Block a user