mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +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
+3
-2
@@ -166,8 +166,9 @@ with `includeInHeightQueries`; `clampNow` and `clampBatch` always clamp to
|
||||
the surface. `exclude` lists draw set ids to see through, of those drawn with
|
||||
`includeInHeightQueries`; every other draw set is seen through already. Every
|
||||
miss is `null`, and every caller treats it as one; `batch` and `clampBatch`
|
||||
reject when the query itself fails. The Cesium renderer answers no height,
|
||||
terrain included, without depth-texture support.
|
||||
reject when the query itself fails. Without depth-texture support the Cesium
|
||||
renderer answers no `surface` or `tiles` height; `now` still answers
|
||||
`terrain` from the loaded tiles.
|
||||
|
||||
## Cesium internals
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+5
-4
@@ -12,7 +12,8 @@ import { cancelCameraArrival } from './data/cameraArrival.js';
|
||||
import { guardCameraAboveGround } from './cameraGroundGuard.js';
|
||||
import { CITY_POIS } from './cityPois.js';
|
||||
import { fromDegrees, toRadians } from './geo/index.js';
|
||||
import { cameraOf, findQuery } from './render/rendererOf.js';
|
||||
import { heightsOf } from './queries/heights.js';
|
||||
import { cameraOf } from './render/rendererOf.js';
|
||||
|
||||
/** Newest landmark arrival; an older post-arrival ground guard yields to it. */
|
||||
let arrivalGeneration = 0;
|
||||
@@ -102,9 +103,9 @@ export function flyToLandmark(viewer, lat, lon, options = {}) {
|
||||
} = options;
|
||||
|
||||
// Sample terrain height (sync — uses loaded tiles; 0 if globe/terrain not ready)
|
||||
const sampledHeight =
|
||||
findQuery(viewer)?.sampleHeightNow({ lon, lat }, { against: 'terrain' }) ??
|
||||
null;
|
||||
const sampledHeight = viewer
|
||||
? heightsOf(viewer).now({ lon, lat }, { against: 'terrain' })
|
||||
: null;
|
||||
|
||||
// Use sampled height if available, otherwise the cached ground-floor
|
||||
// elevation (same ellipsoidal datum), then the pre-baked city elevation.
|
||||
|
||||
@@ -12,9 +12,10 @@
|
||||
* request error, a destroyed scene), so a caller can tell a failure from
|
||||
* points that are merely uncovered.
|
||||
*
|
||||
* What the renderer cannot answer is a miss: the Cesium renderer answers no
|
||||
* height, terrain included, without depth textures (its `sampleHeight`
|
||||
* capability).
|
||||
* What the renderer cannot answer is a miss: without depth textures (its
|
||||
* `sampleHeight` capability) the Cesium renderer answers no `'surface'` or
|
||||
* `'tiles'` height; `now()` still answers `'terrain'` from the globe's
|
||||
* loaded tiles.
|
||||
*
|
||||
* `against` picks the surface: `'surface'` is what is drawn (tiles, the
|
||||
* globe, and draw sets drawn as ground), `'terrain'` the terrain alone,
|
||||
|
||||
@@ -48,6 +48,12 @@
|
||||
|
||||
import * as Cesium from 'cesium';
|
||||
import { heightsFor } from '../render/cesium/heights.js';
|
||||
// The application operations entry reaches the annotation resolver and
|
||||
// locations.js, whose flights and heights go through the camera and query
|
||||
// ports and which cannot load the Cesium adapter themselves; this listed
|
||||
// module, on the same entry, loads the factories a viewer with no renderer
|
||||
// bound gets them from.
|
||||
import '../render/cesium/camera.js';
|
||||
|
||||
/** Taxi threshold: a cached snap answers directly for moves up to this far from
|
||||
* the sampled spot (m). Past it the value is demoted to a held last-known and a
|
||||
|
||||
@@ -4,7 +4,8 @@ import { rangeForBoundingSphere } from '../data/cameraFraming.js';
|
||||
import { cancelCameraArrival } from '../data/cameraArrival.js';
|
||||
import { distance, fromDegrees, toLonLatH } from '../geo/index.js';
|
||||
import { sphereFromPoints } from '../geo/sphere.js';
|
||||
import { findCamera, findQuery } from '../render/rendererOf.js';
|
||||
import { heightsOf } from '../queries/heights.js';
|
||||
import { findCamera } from '../render/rendererOf.js';
|
||||
|
||||
/**
|
||||
* Fly synchronously to a footprint, `[lon, lat, height]` points (degrees,
|
||||
@@ -30,9 +31,9 @@ export function flyToFootprint(
|
||||
height: 0,
|
||||
};
|
||||
const { lat, lon } = center;
|
||||
const terrain =
|
||||
findQuery(viewer)?.sampleHeightNow({ lon, lat }, { against: 'terrain' }) ??
|
||||
null;
|
||||
const terrain = viewer
|
||||
? heightsOf(viewer).now({ lon, lat }, { against: 'terrain' })
|
||||
: null;
|
||||
const cached = ground?.cachedGroundFloor?.(lat, lon);
|
||||
const height =
|
||||
Number.isFinite(terrain) && terrain > 0
|
||||
|
||||
Reference in new issue
Block a user