mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The three layers now add their billboards through addBillboard and write the mirrored fields through setBillboard, so selection, cards, queries, focus, view thinning and the FIRMS horizon cull read what was pushed from Core instead of from Cesium. Vessels and FIRMS state their sprites' own sizes (32 px ship artwork, the glow canvas at twice the core size), which the mirror needs. A vessel helper, iconPosition, replaces the repeated mirror-or-visual position lookups, and the vessel visibility pass writes show only when it changes, as CCTV and FIRMS already did. A billboard never given a position now has none in the mirror rather than the origin.
67 lines
2.1 KiB
JavaScript
67 lines
2.1 KiB
JavaScript
/** Connect portable vessel reconciliation to scene and selection operations. */
|
|
import { setBillboard } from '../../data/billboardMirror.js';
|
|
|
|
export function createVesselSnapshotRenderer({
|
|
state,
|
|
records,
|
|
rendering,
|
|
tracking,
|
|
selection,
|
|
cards,
|
|
}) {
|
|
function reconcileVessels(viewer, rows, { complete = true } = {}) {
|
|
rendering.ensureCollections(viewer);
|
|
const occluder = rendering.makeOccluder();
|
|
records.reconcile(
|
|
rows,
|
|
{
|
|
complete,
|
|
selectedRecord: state.selectedRecord,
|
|
cap: rendering.renderRowLimit(),
|
|
},
|
|
{
|
|
add(record) {
|
|
rendering.prepareRecordVisual(record);
|
|
rendering.addRecordPrimitives(record, occluder);
|
|
},
|
|
beforeUpdate(record) {
|
|
return rendering.shipIcon(record, record === state.selectedRecord);
|
|
},
|
|
updated(record, prevIcon) {
|
|
const selected = record === state.selectedRecord;
|
|
const visual = rendering.prepareRecordVisual(record);
|
|
if (visual.billboard) {
|
|
setBillboard(visual.billboard, 'position', visual.position);
|
|
setBillboard(
|
|
visual.billboard,
|
|
'scale',
|
|
rendering.shipScale(record) * (selected ? 1.2 : 1),
|
|
);
|
|
const nextIcon = rendering.shipIcon(record, selected);
|
|
if (nextIcon !== prevIcon) visual.billboard.image = nextIcon;
|
|
}
|
|
if (record.mmsi === state.trailMmsi)
|
|
tracking.appendSelectedVesselTrailFix(record);
|
|
if (selected) {
|
|
cards.updateSelectedVesselHud(record);
|
|
selection.registerSelectedContext(record);
|
|
}
|
|
},
|
|
remove(record, evicted) {
|
|
if (evicted) selection.clearVesselInspection({ evicted: true });
|
|
rendering.removeRecordPrimitives(record);
|
|
},
|
|
removed(mmsi) {
|
|
if (state.trailMmsi === mmsi) tracking.clearSelectedVesselTrail();
|
|
},
|
|
staleSelected(record) {
|
|
cards.updateSelectedVesselHud(record);
|
|
},
|
|
},
|
|
);
|
|
state.lastVisibilityUpdate = 0;
|
|
rendering.updateVisibility(true);
|
|
}
|
|
return { reconcileVessels };
|
|
}
|