mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Draw the installations layer through the renderer ports
The site dots, outlines and selected footprint fill are now draw-port sets (points, draped lines, clamped shapes) instead of Cesium entities. The selected site's dot is drawn by a set of its own, so selecting a site redraws no other dot. Selection is registered through plain carrier objects in the context store, as the local GeoJSON layer does, and the tracked card reads the site's label and position from the carrier's entity record. A double-click on a site dot now follows it through camera.follow (gated on the stock double-click follow), centred on the surface under the dot when its height is loaded; one on an outline or fill zooms to it. Hiding the layer stops a follow it started. The layer no longer lowers the shared camera change sensitivity: its own camera-port listener carries its threshold. The follow offset fitting moves to src/geo/frames.js and is shared with the local GeoJSON layer. rendering.js leaves the Cesium allow-list (33 -> 32); the layer's entry joins DRAW_FROM_CALLER.
This commit is contained in:
1 parent
a59f9b10b2
commit
1bff078097
21 files changed
+864
-337
No files matched your search
+32
-1
@@ -4,7 +4,7 @@
|
||||
* east-north-up frame at a point, rotation about an axis, and the offset a
|
||||
* heading, pitch and range puts an eye at.
|
||||
*/
|
||||
import { geodeticSurfaceNormal } from './ellipsoid.js';
|
||||
import { WGS84, geodeticSurfaceNormal } from './ellipsoid.js';
|
||||
import {
|
||||
EPSILON14,
|
||||
PI_OVER_TWO,
|
||||
@@ -113,3 +113,34 @@ export function offsetFromHeadingPitchRange(heading, pitch, range) {
|
||||
);
|
||||
return scale(negate(offset), range);
|
||||
}
|
||||
|
||||
/** The range the default renderer frames a sphere of no size from. */
|
||||
const MINIMUM_FIT_RANGE_M = 100;
|
||||
|
||||
/**
|
||||
* Where the eye stands to follow a target, as the default renderer framed
|
||||
* an entity it started following with no view of its own: looking at the
|
||||
* centre of `sphere`, heading north, pitched down 45° (steeper far from the
|
||||
* ground), at the range that fits the sphere in view (100 m for one of no
|
||||
* size), within the camera's zoom limits. Returned as the eye's offset from
|
||||
* the centre, east-north-up there; `at` is where the target stands.
|
||||
* @param {{radius: number}} sphere
|
||||
* @param {{x: number, y: number, z: number}} at
|
||||
* @param {{fovy?: number, aspectRatio?: number, minDistance?: number,
|
||||
* maxDistance?: number}} view The camera's field of view and zoom limits.
|
||||
*/
|
||||
export function followOffsetFitting(sphere, at, view = {}) {
|
||||
const fovy = Number.isFinite(view.fovy) ? view.fovy : Math.PI / 3;
|
||||
const aspect = Number.isFinite(view.aspectRatio) ? view.aspectRatio : 1;
|
||||
const tanPhi = Math.tan(fovy / 2);
|
||||
const tanTheta = aspect * tanPhi;
|
||||
let range =
|
||||
sphere.radius === 0
|
||||
? MINIMUM_FIT_RANGE_M
|
||||
: Math.max(sphere.radius / tanTheta, sphere.radius / tanPhi);
|
||||
const { minDistance = 0, maxDistance = Infinity } = view;
|
||||
range = Math.min(Math.max(range, minDistance), maxDistance);
|
||||
const factor =
|
||||
2 - 1 / Math.max(1, Math.hypot(at.x, at.y, at.z) / WGS84.radii.x);
|
||||
return offsetFromHeadingPitchRange(0, (-Math.PI / 4) * factor, range);
|
||||
}
|
||||
Reference in new issue
Block a user