mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 18:52:18 +00:00
Fix the review findings across the engines, layers, data and QA
Navara now matches Cesium where the review found it diverging: a flight holds the camera inputs, camera.changed counts turns as Cesium does, render requests made during a frame survive it, follow pinches zoom, ground widths follow the pixel ratio and Cyber sonar reaches glyph caches and models. On Cesium, a staged imagery swap keeps loading tiles, setView replaces a running flight, and a cleared weather detail goes away. The contract gains MoverSet.failed, maps.terrainRevision, render.maxTextureSize and surface.sampleTerrainMostDetailed on every engine, so layers retry failed models, key road heights by terrain, size weather textures to the GPU and place Bhote Koshi cards on detailed terrain. Engine switches keep the live view, follows, focus, layer options and cards: a pick hands over the exact pose, applies no address options and pans no carried-over card; a history visit still applies its entry. Layers put GhostMaps pins, cable landings, OSM Places and directions on the measured surface without per-frame sampling, draw the Cockpit contact dot, hide disabled CCTV on attach, and keep ALPR running outside secure contexts. KML imports draw raised polygon fills, rotated and coloured ground overlays and north-referenced icon headings, and report files with nothing to draw. QA scripts read the contract instead of Cesium internals (test:track is 109/109 again), wait for the camera to rest before clicking, and give cold switches and parked engines realistic time. Docs follow the code.
This commit is contained in:
1 parent
69fbf5b38d
commit
0ef29781e5
276 files changed
+7217
-1517
No files matched your search
+26
-23
@@ -6,15 +6,19 @@ import { createExclusivePointer } from '../exclusivePointer.js';
|
||||
// that key is held (shift over ctrl over alt), one without only while none is.
|
||||
//
|
||||
// Camera inputs map to Navara's controller flags (view.camera.options).
|
||||
// Navara 0.2.1 lets a flyTo run on under user input, where Cesium cancels it;
|
||||
// `onCameraInput` reports user camera input so the engine can do the same.
|
||||
// Flights suspend camera inputs, matching Cesium's flight controller.
|
||||
|
||||
import { INPUT_TYPES, normalizeInputOptions } from '../contract.js';
|
||||
import { createPickDelivery } from '../pickDelivery.js';
|
||||
|
||||
const CLICK_PIXEL_TOLERANCE = 5; // Cesium's _clickPixelTolerance
|
||||
const SCREEN_EVENTS = ['pointerdown', 'pointerup', 'pointermove', 'dblclick'];
|
||||
const CAMERA_EVENTS = ['pointerdown', 'wheel', 'touchstart'];
|
||||
const SCREEN_EVENTS = [
|
||||
'pointerdown',
|
||||
'pointerup',
|
||||
'pointermove',
|
||||
'pointercancel',
|
||||
'dblclick',
|
||||
];
|
||||
|
||||
function modifierOf(event) {
|
||||
if (event.shiftKey) return 'shift';
|
||||
@@ -25,8 +29,7 @@ function modifierOf(event) {
|
||||
|
||||
/**
|
||||
* @param {{ canvas: HTMLCanvasElement, camera: { options: object } }} view
|
||||
* @param {{ onCameraInput?: (type: string) => void,
|
||||
* picker?: { clickPick: Function, pick: Function, drillPick: Function },
|
||||
* @param {{ picker?: { clickPick: Function, pick: Function, drillPick: Function },
|
||||
* scheduleFrame?: (run: () => void) => void }} [options] `picker`
|
||||
* answers listeners with { pick, drill } (picking.js): clicks from the
|
||||
* GPU pick of the gesture, moves from the CPU pick once a frame.
|
||||
@@ -34,11 +37,7 @@ function modifierOf(event) {
|
||||
*/
|
||||
export function createNavaraInput(
|
||||
view,
|
||||
{
|
||||
onCameraInput = () => {},
|
||||
picker = null,
|
||||
scheduleFrame = (run) => requestAnimationFrame(run),
|
||||
} = {},
|
||||
{ picker = null, scheduleFrame = (run) => requestAnimationFrame(run) } = {},
|
||||
) {
|
||||
const { canvas } = view;
|
||||
const listeners = new Map(INPUT_TYPES.map((type) => [type, new Set()]));
|
||||
@@ -46,6 +45,7 @@ export function createNavaraInput(
|
||||
let destroyed = false;
|
||||
let cameraOptions = {};
|
||||
let downAt = null;
|
||||
const activePointers = new Set();
|
||||
let last = null;
|
||||
|
||||
const pointer = createExclusivePointer();
|
||||
@@ -92,23 +92,37 @@ export function createNavaraInput(
|
||||
const position = positionOf(event);
|
||||
switch (event.type) {
|
||||
case 'pointerdown':
|
||||
// A primary pointer starts a new gesture: pointers released off the
|
||||
// canvas cannot hold its click back.
|
||||
if (event.isPrimary === true) activePointers.clear();
|
||||
activePointers.add(event.pointerId);
|
||||
if (activePointers.size > 1 || event.isPrimary === false) {
|
||||
downAt = null;
|
||||
break;
|
||||
}
|
||||
if (event.button !== 0) break;
|
||||
downAt = position;
|
||||
downAt = { ...position, pointerId: event.pointerId };
|
||||
emit('down', event, { position });
|
||||
break;
|
||||
case 'pointerup': {
|
||||
activePointers.delete(event.pointerId);
|
||||
if (event.button !== 0) break;
|
||||
emit('up', event, { position });
|
||||
const start = downAt;
|
||||
downAt = null;
|
||||
if (
|
||||
start &&
|
||||
start.pointerId === event.pointerId &&
|
||||
Math.hypot(position.x - start.x, position.y - start.y) <
|
||||
CLICK_PIXEL_TOLERANCE
|
||||
)
|
||||
emit('click', event, { position });
|
||||
break;
|
||||
}
|
||||
case 'pointercancel':
|
||||
activePointers.delete(event.pointerId);
|
||||
downAt = null;
|
||||
break;
|
||||
case 'pointermove':
|
||||
emit('move', event, {
|
||||
startPosition: last ?? position,
|
||||
@@ -121,15 +135,6 @@ export function createNavaraInput(
|
||||
}
|
||||
last = position;
|
||||
};
|
||||
const onCameraEvent = (event) => {
|
||||
onCameraInput(event.type);
|
||||
};
|
||||
for (const type of CAMERA_EVENTS)
|
||||
canvas.addEventListener(type, onCameraEvent, {
|
||||
capture: true,
|
||||
passive: true,
|
||||
});
|
||||
|
||||
let suspended = 0;
|
||||
const sendCameraInputs = () => {
|
||||
const enabled = suspended === 0;
|
||||
@@ -199,8 +204,6 @@ export function createNavaraInput(
|
||||
if (destroyed) return;
|
||||
pointer.destroy();
|
||||
destroyed = true;
|
||||
for (const type of CAMERA_EVENTS)
|
||||
canvas.removeEventListener(type, onCameraEvent, { capture: true });
|
||||
if (attached)
|
||||
for (const name of SCREEN_EVENTS)
|
||||
canvas.removeEventListener(name, onScreenEvent);
|
||||
|
||||
Reference in new issue
Block a user