mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Ask heights through the gateway at the flight sites, and load the camera factory from ground snapping
The camera ground guard, place and landmark flights and imported-file flights read terrain and surface heights through heightsOf, the one place the app's height queries go, rather than asking the query port themselves. With the annotation resolver off the allow-list, ground snapping, which the application operations entry also reaches and which stays listed, loads the Cesium camera factory for a viewer with no renderer bound. The height docs say what the Cesium renderer answers without depth textures: no surface or tiles height, and terrain from the loaded tiles.
This commit is contained in:
1 parent
f509c688e8
commit
8c024f5ea7
6 files changed
+34
-22
No files matched your search
@@ -17,7 +17,8 @@
|
||||
import { onFollowChanged } from './data/followed.js';
|
||||
import { ownCameraArrival } from './data/cameraArrival.js';
|
||||
import { distance, dot, fromDegrees, toLonLatH } from './geo/index.js';
|
||||
import { findCamera, findQuery } from './render/rendererOf.js';
|
||||
import { heightsOf } from './queries/heights.js';
|
||||
import { findCamera } from './render/rendererOf.js';
|
||||
|
||||
/** Minimum eye height above the rendered surface for a usable view. */
|
||||
export const MIN_EYE_CLEARANCE_M = 120;
|
||||
@@ -33,17 +34,18 @@ const TURNED_COS = 1 - 1e-9;
|
||||
/**
|
||||
* Highest rendered surface across a few cells, with how many cells answered.
|
||||
* A cell whose tiles are not streamed yet contributes nothing.
|
||||
* @param {object|null} query The scene's query port.
|
||||
* @param {import('./queries/heights.js').HeightService|null} heights The
|
||||
* scene's height service.
|
||||
* @param {Array<{lat: number, lon: number}>} cells Cells to probe.
|
||||
* @returns {{heightM: number, sampled: number}} Reading.
|
||||
*/
|
||||
function sampleSurfaceM(query, cells) {
|
||||
function sampleSurfaceM(heights, cells) {
|
||||
let heightM = Number.NaN;
|
||||
let sampled = 0;
|
||||
if (!query) return { heightM, sampled };
|
||||
if (!heights) return { heightM, sampled };
|
||||
for (const cell of cells) {
|
||||
// A miss is a cell whose tiles are not ready.
|
||||
const height = query.sampleHeightNow({ lon: cell.lon, lat: cell.lat });
|
||||
const height = heights.now(cell);
|
||||
if (!Number.isFinite(height)) continue;
|
||||
sampled += 1;
|
||||
heightM = Number.isFinite(heightM) ? Math.max(heightM, height) : height;
|
||||
@@ -180,10 +182,10 @@ export function guardCameraAboveGround(viewer, at, options = {}) {
|
||||
remaining -= 1;
|
||||
// The eye must clear both the framed target and the ground beneath it.
|
||||
const below = { lat: now.lat, lon: now.lon };
|
||||
const { heightM, sampled } = sampleSurfaceM(findQuery(viewer), [
|
||||
{ lat: at.lat, lon: at.lon },
|
||||
below,
|
||||
]);
|
||||
const { heightM, sampled } = sampleSurfaceM(
|
||||
viewer ? heightsOf(viewer) : null,
|
||||
[{ lat: at.lat, lon: at.lon }, below],
|
||||
);
|
||||
if (sampled > 0 && Number.isFinite(heightM)) {
|
||||
const deficit = groundClearanceDeficitM(now.height, heightM, clearanceM);
|
||||
if (deficit > 0) {
|
||||
|
||||
Reference in new issue
Block a user