mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Read the navigation and point-and-ask camera through the renderer's ports
The navigation controller and the location navigation cancel flights and read the camera's place through the camera port. Point-and-ask's camera pose key and its "around here" radius read the camera port's pose; its entity pick moves into the input dispatcher (pickAt), which picks as a click does, so the follow's helper still reads as its target. navigationController, locationNavigation and pointerPick leave the Cesium allow-list. Their package entries (./ui/navigation and three voice entries) no longer load the Cesium adapter: given a viewer of a caller's own, they find its camera once the caller loads ./render/cesium/unbound. They are listed as such in the unbound camera test, which fails if one starts loading the factory again.
This commit is contained in:
1 parent
3484bfa56d
commit
a2c4d27b5a
9 files changed
+92
-35
No files matched your search
@@ -18,6 +18,7 @@
|
||||
*
|
||||
* Provider-neutral and Cesium-free: the pick is injected.
|
||||
*/
|
||||
import { findCamera } from '../render/rendererOf.js';
|
||||
|
||||
/** Movement below this many CSS pixels is still the same dwell. */
|
||||
const POINTER_DWELL_PX = 12;
|
||||
@@ -55,23 +56,28 @@ const finite = finiteOrNull;
|
||||
|
||||
/**
|
||||
* Camera pose identity: position to 1 m, orientation to about 0.06 degrees.
|
||||
* A pixel read under one key names nothing under another. Reads plain
|
||||
* numbers only, so it needs no Cesium import.
|
||||
* @param {object} viewer Cesium viewer.
|
||||
* A pixel read under one key names nothing under another. Reads the
|
||||
* camera port's pose.
|
||||
* @param {object} viewer The scene object.
|
||||
* @returns {string|null}
|
||||
*/
|
||||
export function cameraPoseKey(viewer) {
|
||||
const camera = viewer?.camera;
|
||||
const p = camera?.positionWC;
|
||||
let pose = null;
|
||||
try {
|
||||
pose = findCamera(viewer)?.pose() ?? null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
const p = pose?.position;
|
||||
if (!p || !Number.isFinite(p.x)) return null;
|
||||
const angle = (value) => Math.round((Number(value) || 0) * 1000);
|
||||
return [
|
||||
Math.round(p.x),
|
||||
Math.round(p.y),
|
||||
Math.round(p.z),
|
||||
angle(camera.heading),
|
||||
angle(camera.pitch),
|
||||
angle(camera.roll),
|
||||
angle(pose.heading),
|
||||
angle(pose.pitch),
|
||||
angle(pose.roll),
|
||||
].join(',');
|
||||
}
|
||||
|
||||
|
||||
+16
-11
@@ -1,5 +1,5 @@
|
||||
import { pickThroughFollowHelper } from '../render/cesium/follow.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { pickAt as defaultPickAt } from '../input/dispatcher.js';
|
||||
import { findCamera } from '../render/rendererOf.js';
|
||||
import { resolvePickedContext } from '../data/pickedContext.js';
|
||||
import { cameraPoseKey } from './pointerContext.js';
|
||||
import * as defaultAnnotationResolver from '../annotations/annotationResolver.js';
|
||||
@@ -11,20 +11,30 @@ function pointerRadiusKm(cameraHeightM) {
|
||||
return Math.round(Math.min(400, Math.max(5, heightKm * 0.75)));
|
||||
}
|
||||
|
||||
function cameraHeightM(viewer) {
|
||||
try {
|
||||
return findCamera(viewer)?.pose().height;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Cesium side of point-and-ask: one entity pick and one depth-aware world
|
||||
* The scene side of point-and-ask: one entity pick and one depth-aware world
|
||||
* pick at canvas CSS pixels. Called lazily by the pointer tracker (dwell and
|
||||
* snapshot only), never per mouse move.
|
||||
* @param {object} options
|
||||
* @param {object} options.viewer Cesium viewer.
|
||||
* @param {object} options.viewer The scene object.
|
||||
* @param {object} [options.dataManager] Layer lifecycle.
|
||||
* @param {Function} [options.pickWorldFromScreen] Normalized-pixel world pick.
|
||||
* @param {Function} [options.pickAt] Entity pick at canvas CSS pixels.
|
||||
* @returns {(x: number, y: number) => {entity: object|null, ground: object|null, radiusKm: number}|null}
|
||||
*/
|
||||
export function createPointerPicker({
|
||||
viewer,
|
||||
dataManager = null,
|
||||
pickWorldFromScreen = defaultAnnotationResolver.pickWorldFromScreen,
|
||||
pickAt = defaultPickAt,
|
||||
}) {
|
||||
return function pickPointer(x, y) {
|
||||
const scene = viewer?.scene;
|
||||
@@ -33,12 +43,7 @@ export function createPointerPicker({
|
||||
const width = canvas.clientWidth || canvas.width || 0;
|
||||
const height = canvas.clientHeight || canvas.height || 0;
|
||||
if (!width || !height) return null;
|
||||
let picked = null;
|
||||
try {
|
||||
picked = pickThroughFollowHelper(scene.pick(new Cesium.Cartesian2(x, y)));
|
||||
} catch {
|
||||
picked = null;
|
||||
}
|
||||
const picked = pickAt(viewer, x, y);
|
||||
const entity = resolvePickedContext(picked, { dataManager });
|
||||
let ground = null;
|
||||
try {
|
||||
@@ -55,7 +60,7 @@ export function createPointerPicker({
|
||||
return {
|
||||
entity,
|
||||
ground,
|
||||
radiusKm: pointerRadiusKm(viewer.camera?.positionCartographic?.height),
|
||||
radiusKm: pointerRadiusKm(cameraHeightM(viewer)),
|
||||
cameraKey: cameraPoseKey(viewer),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user