mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Every layer and tool bound its own ScreenSpaceEventHandler and picked the same click again: with the usual layers on, one click ran about 26 scene.pick and 2 drillPick passes (120-215 ms in NYC with 18 layers). Pointer input now comes in through src/input/dispatcher.js, one handler per scene. A click is picked lazily and at most once per kind of query, and every subscriber reads the same ClickEvent (pick, hit, id, ownerId, gesture, drill, ground). The same click now costs 3 picks and 2 drills, 17-70 ms. - Ambient onClick subscribers run only while no tool holds the pointer, checked once per event; tools subscribe with their lease. Moves and releases always reach ambient subscribers, so hover and drags end cleanly. - Camera input and the viewer's stock select/track clicks are ref-counted holds (suspendCamera, suppressStockClicks). The dispatcher owns the controller's enableInputs, so a Cesium flight that ends no longer turns input back on under a drag or the cockpit. - The draw tool, imagery box, CCTV gizmo, cockpit, directions and every selecting layer use it; bindTrackingClickGesture is gone (the gesture is on the event). A source scan forbids new handlers, enableInputs writes and stock-click removal outside the dispatcher. - The sensor-style pick correction transit had now applies to every layer. - Radio's 8-pick near-miss ring is one 17x17 windowed drill. - A missed pick passed to pickContact is no longer picked again, and a touch tap's contact search shares the click's drill. - A gizmo drag whose release Cesium never reported ends on the next press instead of leaving the camera held. The dispatcher is exported as ./input with the pointer-lease functions, and documented in docs/APPLICATION.md.
110 lines
2.6 KiB
JavaScript
110 lines
2.6 KiB
JavaScript
import * as Cesium from 'cesium';
|
|
|
|
export function createFirmsState({ services, config }) {
|
|
const layerState = {};
|
|
|
|
/** Pre-baked radial-glow sprites keyed by color stop name. */
|
|
|
|
layerState.glowSpriteCache = new Map();
|
|
|
|
layerState.scratchViewRect = new Cesium.Rectangle();
|
|
|
|
layerState.scratchCenterA = new Cesium.Cartographic();
|
|
|
|
layerState.scratchCenterB = new Cesium.Cartographic();
|
|
|
|
layerState.scratchWindowCoord = new Cesium.Cartesian2();
|
|
|
|
layerState._viewer = null;
|
|
|
|
layerState._dataSource = null;
|
|
|
|
/** Detection glow rows and the primitive that draws them. */
|
|
|
|
layerState._icons = null;
|
|
|
|
layerState._iconPrimitive = null;
|
|
|
|
layerState._enabled = false;
|
|
|
|
layerState._destroyed = false;
|
|
|
|
layerState._loading = false;
|
|
|
|
/** True when the proxy answered 503 {error:'no_key'} — FIRMS_MAP_KEY unset. */
|
|
|
|
layerState._keyRequired = false;
|
|
|
|
/** True when the proxy served a cached payload past TTL (upstream failing). */
|
|
|
|
layerState._stale = false;
|
|
|
|
/** Surfaced error string when the live fetch failed outright. */
|
|
|
|
layerState._error = null;
|
|
|
|
layerState._fires = [];
|
|
|
|
layerState._firesByFrp = [];
|
|
|
|
layerState._count = 0;
|
|
|
|
layerState._cellCount = 0;
|
|
|
|
layerState._lastUpdate = null;
|
|
|
|
layerState._currentLodId = null;
|
|
|
|
layerState._currentLodIndex = -1;
|
|
|
|
layerState._lastViewRect = null;
|
|
|
|
layerState._preRenderRemover = null;
|
|
|
|
layerState._moveEndSettleRemover = null;
|
|
|
|
layerState._lastLodCheck = 0;
|
|
|
|
layerState._contextIds = new Set();
|
|
|
|
layerState._clickSubscription = null;
|
|
|
|
layerState._moveEndRemover = null;
|
|
|
|
layerState._selectedFire = null;
|
|
|
|
/** Priority-ordered label candidates from the last rebuild (detections or cells). */
|
|
|
|
layerState._labelCandidates = [];
|
|
|
|
layerState._labelLodDistance = 0;
|
|
|
|
/** pick id string -> fire record, for the currently rendered sprites. */
|
|
|
|
layerState._pickIndexById = new Map();
|
|
|
|
/** Actionable card id -> current detection record painted for that id. */
|
|
|
|
layerState._fireByCardId = new Map();
|
|
|
|
/**
|
|
* gridDegrees -> heat-sorted full cell list. The full-grid aggregation is
|
|
* viewport-independent but walks every detection (~200k live), so it is
|
|
* computed once per grid size per data refresh; renders only clip + cap
|
|
* (field-test round 1: intermediate-zoom chug during LOD rebuilds).
|
|
* @type {Map<number, Array<Object>>}
|
|
*/
|
|
|
|
layerState._cellCacheByGrid = new Map();
|
|
|
|
/** Camera idle snapshot so the throttled LOD check is ~free when parked. */
|
|
|
|
layerState._camSnapValid = false;
|
|
|
|
layerState._camPos = new Cesium.Cartesian3();
|
|
|
|
layerState._camDir = new Cesium.Cartesian3();
|
|
layerState.request = null;
|
|
return layerState;
|
|
}
|