mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
fix(cockpit): keep the orbital view on a double-click at a ground point
In the orbital view a double-click on a mapped ground point went on to Cesium's own double-click, which tracks the picked entity and so ended the view. The Cockpit's double-click routing now takes it in orbit: it keeps or starts the focus on that point (a point beyond the reach is left unfocused but still not tracked). A double-click anywhere else, one a tool owns, and every one outside orbit go on to Cesium's as before, and stopping the Cockpit still hands Cesium's handler back.
This commit is contained in:
1 parent
dd063b0e83
commit
b18336d3d4
5 files changed
+116
-9
No files matched your search
@@ -168,6 +168,37 @@ export function toggleOrbitalFocus(key) {
|
||||
return record ? startFocus.call(this, record) : false;
|
||||
}
|
||||
|
||||
/** The mapped ground point drawn at a canvas position, or null. */
|
||||
function groundRecordAt(controller, position) {
|
||||
let picked = null;
|
||||
try {
|
||||
picked = controller.viewer.scene?.pick?.(position) ?? null;
|
||||
} catch {
|
||||
picked = null;
|
||||
}
|
||||
return pickedGroundRecord(controller, picked);
|
||||
}
|
||||
|
||||
/**
|
||||
* A double-click on the orbital picture. On a mapped ground point it keeps
|
||||
* or starts the focus on it (as a single click does) and is taken: Cesium's
|
||||
* own double-click would track that point, which ends the view. Any other
|
||||
* double-click, one a tool owns, and every one outside orbit go on.
|
||||
* @param {{x: number, y: number}|null|undefined} position Canvas position.
|
||||
* @returns {boolean} True when it landed on a ground point and was taken.
|
||||
*/
|
||||
export function onOrbitalDoubleClick(position) {
|
||||
if (!inOrbit(this) || !isPointerFree()) return false;
|
||||
if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y))
|
||||
return false;
|
||||
const record = groundRecordAt(this, position);
|
||||
if (!record) return false;
|
||||
// A point beyond the reach is not focused, but still never tracked.
|
||||
if (this.orbital.focus?.key !== String(record.id))
|
||||
startFocus.call(this, record);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A click on the orbital picture. One on a mapped ground point in reach
|
||||
* focuses it; any other click ends a focus. A click a tool owns (drawing)
|
||||
@@ -179,13 +210,7 @@ export function onOrbitalClick(position) {
|
||||
if (!inOrbit(this) || !isPointerFree()) return false;
|
||||
if (!Number.isFinite(position?.x) || !Number.isFinite(position?.y))
|
||||
return false;
|
||||
let picked = null;
|
||||
try {
|
||||
picked = this.viewer.scene?.pick?.(position) ?? null;
|
||||
} catch {
|
||||
picked = null;
|
||||
}
|
||||
const record = pickedGroundRecord(this, picked);
|
||||
const record = groundRecordAt(this, position);
|
||||
const state = this.orbital;
|
||||
if (record) {
|
||||
if (state.focus?.key === String(record.id)) return true;
|
||||
|
||||
Reference in new issue
Block a user