fix(street-level): ground under the camera on Google 3D; tilted views load what they look at

Two regressions from the slimming, found in review:

- Google 3D hides the globe, so groundUnderCamera returned null once the
  ground caster was gone: in high cities (Denver ~1,600 m) the camera read
  kilometres too high, the coverage zoom came out coarse and the visible box
  slid kilometres ahead. With the globe hidden (or not yet loaded) the
  ground now comes from the rendered surface (scene.sampleHeight), checked
  for plausibility and ignored when above the camera. The plausibility check
  is shared with photo framing (plausibleSurfaceHeight, sampledSurfaceHeight).
- Tiles were ranked from the camera's ground point alone, so a tilted view
  from a few kilometres up (z13) could miss the tile at the centre of the
  screen. They are ranked from viewFocus: halfway between that point and the
  ground at the screen centre (or the nadir when the centre ray misses).
  A test pins the 3 km / 70° case: the nadir ranking leaves the centre tile
  out, the focus ranking loads it.

Also ignore .playwright-mcp/: its browser console logs can carry tokens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
German KhokhlovandClaude Opus 5.5 committed 2026-10-07 23:50:44 +04:00
1 parent 346245e8e7
commit 8706cafdd1
5 files changed
+148 -29

No files matched your search

+5 -17
View File
@@ -1,8 +1,5 @@
import * as Cesium from 'cesium';
/** Plausible ellipsoidal land heights: Dead Sea to Everest, with geoid slack. */
const SURFACE_MIN_M = -500;
const SURFACE_MAX_M = 9000;
import { plausibleSurfaceHeight, sampledSurfaceHeight } from './view.js';
/** Fly the globe camera once to frame a photo after it opens. */
export function createCameraFraming({ state }) {
@@ -34,19 +31,10 @@ export function createCameraFraming({ state }) {
function groundHeightAt(lon, lat, fallback) {
const scene = state.viewer?.scene;
const carto = Cesium.Cartographic.fromDegrees(lon, lat);
const plausible = (height) =>
Number.isFinite(height) &&
height >= SURFACE_MIN_M &&
height <= SURFACE_MAX_M;
let height = null;
try {
if (scene?.sampleHeightSupported) height = scene.sampleHeight(carto);
} catch {
/* not sampleable yet */
}
if (!plausible(height)) height = scene?.globe?.getHeight?.(carto);
if (!plausible(height)) height = fallback;
return plausible(height) ? height : 0;
let height = sampledSurfaceHeight(scene, carto);
if (height === null) height = scene?.globe?.getHeight?.(carto);
if (!plausibleSurfaceHeight(height)) height = fallback;
return plausibleSurfaceHeight(height) ? height : 0;
}
/**