mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Draw the ALPR layer's markers through the renderer's ports
The ALPR badges were Cesium entities whose billboards the layer changed in place: the canvas overlay swapped a badge to a faint pick target at its anchor, selection swapped the image, and unresolved floors clamped to the ground. They are now one icon set from the draw port, updated in place through upsert, so selection and the overlay swap change the same billboard without a rebuild or a blink. Badges keep their scale by distance, ground clamping and depth-test settings. Marker state lives in the app (markerState.js): a plain carrier per camera, registered as the camera's context entity, and a marker set that batches changes and sends only the icons that draw differently. Clicks on native badges come from the dispatcher's draw hit. Projection, the on-screen count, height samples (excluding the layer's own set), the screen-centre ellipsoid pick and the camera reach the renderer through the query, camera and frame ports. A resync of the overlay now hands back only the cameras that leave it, so kept ones are not written twice. index.js, overlay.js and presentation.js leave the Cesium allow-list; the layer's entry is Cesium-free, and a caller's own viewer loads the unbound factories. Differences the contract does not let us avoid: - Double-clicking a badge no longer starts the viewer's entity follow, since draw items are not entities. - The terrain fallback for anchors is no longer skipped while the globe is hidden: the globe port has no visibility getter. - Without depth support the query port answers no heights, terrain included, so anchors wait for a cached floor there. - On a viewer with no renderer bound, the surface counts as settled when anchors are refined.
This commit is contained in:
1 parent
faded8a418
commit
2592289612
11 files changed
+722
-537
No files matched your search
@@ -9,7 +9,9 @@
|
||||
* `positionCartographic`; `viewRectangle()` from its
|
||||
* `computeViewRectangle()`, in degrees; events from its own `moveEnd`,
|
||||
* `moveStart` and `changed`.
|
||||
* - query: `project` (and `projectMany`) through `Cesium.SceneTransforms.worldToWindowCoordinates`
|
||||
* - query: `sampleHeightNow` through the scene's height service;
|
||||
* `pickEllipsoid` through the double camera's, when it has one; `project`
|
||||
* (and `projectMany`) through `Cesium.SceneTransforms.worldToWindowCoordinates`
|
||||
* (which a test may stub), `isOccluded` against the ellipsoid's horizon
|
||||
* from the camera's `positionWC` (never occluded without one).
|
||||
* - frame: phases from the scene's own `preUpdate`, `preRender` and
|
||||
@@ -18,6 +20,7 @@
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import { bindRenderer } from '../render/rendererOf.js';
|
||||
import { heightsFor } from '../queries/heights.js';
|
||||
import { fakeDrawPort } from './fakeDrawPort.mjs';
|
||||
|
||||
const toCartesian = (p) => new Cesium.Cartesian3(p.x, p.y, p.z);
|
||||
@@ -51,6 +54,15 @@ export function fakeSceneQuery(viewer) {
|
||||
);
|
||||
return s ? { x: s.x, y: s.y } : null;
|
||||
},
|
||||
/** The double camera's own, when it has one. */
|
||||
get pickEllipsoid() {
|
||||
const camera = cameraOfDouble(viewer);
|
||||
if (typeof camera?.pickEllipsoid !== 'function') return undefined;
|
||||
return (x, y) => {
|
||||
const hit = camera.pickEllipsoid(new Cesium.Cartesian2(x, y));
|
||||
return hit ? plain(hit) : null;
|
||||
};
|
||||
},
|
||||
projectMany(source, out) {
|
||||
for (let i = 0, j = 0; i + 2 < source.length; i += 3, j += 2) {
|
||||
const s = this.project({
|
||||
@@ -62,6 +74,16 @@ export function fakeSceneQuery(viewer) {
|
||||
out[j + 1] = s ? s.y : Number.NaN;
|
||||
}
|
||||
},
|
||||
// The scene's own height service, the surface only where the scene has
|
||||
// depth support. Unlike the Cesium port it samples terrain without depth
|
||||
// support too, and sees through nothing (`exclude` is ignored).
|
||||
sampleHeightNow(point, { against = 'surface' } = {}) {
|
||||
if (against === 'terrain')
|
||||
return heightsFor(viewer.scene).now(point, { against: 'terrain' });
|
||||
return viewer.scene?.sampleHeightSupported
|
||||
? heightsFor(viewer.scene).now(point)
|
||||
: null;
|
||||
},
|
||||
isOccluded(position) {
|
||||
const eye = cameraOfDouble(viewer)?.positionWC;
|
||||
if (!eye) return false;
|
||||
|
||||
Reference in new issue
Block a user