mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Read Street Level's camera and ground through the renderer's ports
The Street Level view maths no longer reads Cesium. The camera's place comes from the camera port's pose; the visible box and the view focus cast the query port's screen rays and meet them with the ground, the WGS84 ellipsoid raised to the ground height, in geo; heights come from the query port; the horizon cull for the marker and the cones tests against an ellipsoid 1,000 m below WGS84 in geo and re-culls on the frame port's pre-render. Ground clicks, the screen-centre aim, the nearest-image point, photo framing, the coverage refresh and the ground re-measure read the same ports and convert positions with geo. geo's ellipsoid functions (toLonLatH, rayEllipsoid and those under them) and horizonFrom take an optional ellipsoid, made with ellipsoidOf or offsetEllipsoid; anything else, a map index included, means WGS84. Tests check them against Cesium on raised and lowered ellipsoids. view, index, cameraFraming, groundClick and selection leave the Cesium allow-list. The Street Level entries are Cesium-free callers of the unbound factories: given a viewer of a caller's own, with no renderer bound, the caller loads ./render/cesium/unbound first. GhostMaps, which uses the horizon cull and is still on the list, loads the camera factory itself. Differences the contract does not let us avoid: - The ground under the camera no longer reads whether the globe is shown (the globe port has no visibility getter). Where 3D tiles answer under the camera they decide, as they did under Google 3D; elsewhere the terrain answers, then the drawn surface below the camera. Over 3D tiles shown on a map with the globe (and under other primitives at the nadir) those now count as ground. - Without depth-texture support the query port answers no heights, the terrain included, so the ground then reads as the ellipsoid. - selection and groundClick still read the click dispatcher's own pick for now; they move to draw-set hits with the coverage lines.
This commit is contained in:
1 parent
30b6be1da0
commit
a10f3a16e1
22 files changed
+567
-260
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import * as Cesium from 'cesium';
|
||||
import { createState } from './state.js';
|
||||
import { createMarker } from './marker.js';
|
||||
import { createCameraFraming } from './cameraFraming.js';
|
||||
@@ -14,7 +13,9 @@ import {
|
||||
keyAlternatives,
|
||||
summarizeCoverage,
|
||||
} from './uiState.js';
|
||||
import { groundUnderCamera, viewCentre } from './view.js';
|
||||
import { canvasSize, groundUnderCamera, viewCentre } from './view.js';
|
||||
import { toLonLatH } from '../../geo/index.js';
|
||||
import { findCamera } from '../../render/rendererOf.js';
|
||||
import { createGroundClick, groundClickHeightOk } from './groundClick.js';
|
||||
import { msg, t, translateKnown } from '../../i18n/index.js';
|
||||
import {
|
||||
@@ -38,7 +39,9 @@ const GROUND_RETRY_MS = 1000;
|
||||
* The core owns what they share: the filter and switches, the photo viewer
|
||||
* host, the position marker, the click handler and nearest-image lookups.
|
||||
* Providers own coverage, sequences and their viewer. One source is lit at
|
||||
* a time.
|
||||
* a time. It reaches the camera, queries and frames through the renderer's
|
||||
* ports; given a Cesium viewer with no renderer bound,
|
||||
* the caller loads the package's `./render/cesium/unbound` export first.
|
||||
* @param {{providers: Array<import('./registry.js').StreetLevelProvider>, services?: object}} options
|
||||
*/
|
||||
export function createStreetLevelLayer({
|
||||
@@ -209,7 +212,7 @@ export function createStreetLevelLayer({
|
||||
function watchCamera(viewer) {
|
||||
removeCameraListener?.();
|
||||
removeCameraListener =
|
||||
viewer?.camera?.moveEnd?.addEventListener(remeasureGround) || null;
|
||||
(viewer && findCamera(viewer)?.on('moveEnd', remeasureGround)) || null;
|
||||
}
|
||||
|
||||
const activeEntries = () =>
|
||||
@@ -257,21 +260,12 @@ export function createStreetLevelLayer({
|
||||
|
||||
/** Ground under the screen centre; null for sky, undefined when it cannot aim. */
|
||||
function screenCentreGround() {
|
||||
const canvas = state.viewer?.scene?.canvas;
|
||||
const { width, height } = canvasSize(state.viewer);
|
||||
const pick = state.services.scenePick?.pickGroundPosition;
|
||||
if (!pick || !canvas?.clientWidth || !canvas?.clientHeight)
|
||||
return undefined;
|
||||
const position = pick(state.viewer, {
|
||||
x: canvas.clientWidth / 2,
|
||||
y: canvas.clientHeight / 2,
|
||||
});
|
||||
const carto = position && Cesium.Cartographic.fromCartesian(position);
|
||||
return carto
|
||||
? {
|
||||
lon: Cesium.Math.toDegrees(carto.longitude),
|
||||
lat: Cesium.Math.toDegrees(carto.latitude),
|
||||
}
|
||||
: null;
|
||||
if (!pick || !width || !height) return undefined;
|
||||
const position = pick(state.viewer, { x: width / 2, y: height / 2 });
|
||||
const ground = position && toLonLatH(position);
|
||||
return ground ? { lon: ground.lon, lat: ground.lat } : null;
|
||||
}
|
||||
|
||||
/** `frame: false` keeps the camera where it is (the user picked the spot). */
|
||||
|
||||
Reference in new issue
Block a user