mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42: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
@@ -1,6 +1,5 @@
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { LAYER_ID } from './policy.js';
|
||||
import { installationMarkers } from './markerState.js';
|
||||
|
||||
export function createSelection({
|
||||
state: layerState,
|
||||
@@ -11,6 +10,7 @@ export function createSelection({
|
||||
const { clearSelectedEntityContextForLayer } = services.context;
|
||||
|
||||
let removeContextListeners = null;
|
||||
let removeDoubleClick = null;
|
||||
|
||||
function syncContextSelection(event) {
|
||||
if (!layerState.enabled) return;
|
||||
@@ -30,10 +30,10 @@ export function createSelection({
|
||||
|
||||
function selectRecord(id) {
|
||||
const record = layerState.recordById.get(id);
|
||||
if (!record || !layerState.dataSource) return false;
|
||||
if (!record || !layerState.sets) return false;
|
||||
layerState.selectedId = id;
|
||||
parts.rendering.renderRecords({ claimSelection: true });
|
||||
// renderRecords drops selectedId when the record produced no entity.
|
||||
// renderRecords drops selectedId when the record produced no marker.
|
||||
return layerState.selectedId === id;
|
||||
}
|
||||
|
||||
@@ -50,17 +50,17 @@ export function createSelection({
|
||||
for (const event of events)
|
||||
globalThis.window?.removeEventListener?.(event, syncContextSelection);
|
||||
};
|
||||
layerState.clickSubscription = inputFor(viewer).onClick((event) => {
|
||||
const input = inputFor(viewer);
|
||||
layerState.clickSubscription = input.onClick((event) => {
|
||||
if (!layerState.enabled) return;
|
||||
// A named marker is a draw item; site markers are still entities.
|
||||
// A site's dot, outline or fill, or a named marker: each draw item
|
||||
// names its installation in its `meta`.
|
||||
const hit = event.drawHit;
|
||||
const target = event.pick?.id;
|
||||
const id =
|
||||
(hit?.set === parts.namedMarkers?.setId
|
||||
hit?.set === parts.namedMarkers?.setId ||
|
||||
parts.rendering.ownsSet(hit?.set)
|
||||
? hit.meta?.installationId
|
||||
: null) ||
|
||||
installationMarkers.read(target)?.recordId ||
|
||||
(typeof target?.id === 'string' ? target.id : null);
|
||||
: null;
|
||||
if (id && layerState.recordById.has(id) && id !== layerState.selectedId) {
|
||||
selectRecord(id);
|
||||
} else if (layerState.selectedId) {
|
||||
@@ -72,6 +72,15 @@ export function createSelection({
|
||||
parts.rendering.renderRecords();
|
||||
}
|
||||
});
|
||||
// Follow a site on a double-click, as the renderer's own double-click
|
||||
// followed the site's entity.
|
||||
removeDoubleClick =
|
||||
input.onPointer?.('dblclick', (event) => {
|
||||
// The renderer's own double-click follow, off while a tool holds it
|
||||
// or on a renderer without one.
|
||||
if (input.stockEnabled?.('dblclickFollow') !== true) return;
|
||||
parts.rendering.followAt(event.position);
|
||||
}) ?? null;
|
||||
}
|
||||
return {
|
||||
selectRecord,
|
||||
@@ -79,6 +88,8 @@ export function createSelection({
|
||||
destroy() {
|
||||
removeContextListeners?.();
|
||||
removeContextListeners = null;
|
||||
removeDoubleClick?.();
|
||||
removeDoubleClick = null;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user