Keep the camera layer's Cesium picks, entities and projection in its rendering part

The camera layer's lifecycle, cards, geometry, hover and selection parts
had left the Cesium allow-list but still drove the scene: Cesium camera
move events, scene picks and pick objects, entity removal, the
activation ray probe and the cards' canvas projection. The move events
now come from the camera port and card render requests go through the
frame port; the rest moves into the rendering part, which stays listed.
The move listeners are attached and released in one place, with a test.
This commit is contained in:
Sameh Khamis committed 2026-11-07 01:04:46 -08:00
1 parent f6c5e6ba10
commit a8f41d30fc
9 files changed
+348 -161

No files matched your search

+19 -23
View File
@@ -1,3 +1,4 @@
import { findFrame } from '../../render/rendererOf.js';
import {
createFrameSlot,
CCTV_OVERLAY_SOURCE_ID,
@@ -8,7 +9,6 @@ import {
CCTV_FRAME_CANVAS_H,
applyFrameResult,
} from '../../data/cctvCards.js';
import { horizonOccluder } from '../../data/iconOrientation.js';
import { selectCctvLod, applyEvictionGrace } from '../../data/cctvLod.js';
import {
CCTV_OVERLAY_SOURCE_OPTIONS,
@@ -34,7 +34,7 @@ export function createCards({ state: layerState, services, parts, source }) {
} = {}) {
layerState._activeCameraCardEnabled = activeCameraCardEnabled === true;
if (layerState._enabled) pushAmbientCardEntries();
layerState._viewer?.scene?.requestRender?.();
findFrame(layerState._viewer)?.requestRender('cctv-cards');
return { activeCameraCardEnabled: layerState._activeCameraCardEnabled };
}
@@ -82,7 +82,6 @@ export function createCards({ state: layerState, services, parts, source }) {
);
return;
}
const scene = layerState._viewer.scene;
// An eye with no geographic position (the earth's centre) measures from 0, 0.
const pose = parts.model.eyePose();
const viewerLat = pose ? pose.lat : 0;
@@ -91,9 +90,8 @@ export function createCards({ state: layerState, services, parts, source }) {
// after its async activation settles). It is published separately in the
// protected lane below, and grace never applies to it.
const activeId = layerState._activeCameraId;
const occluder = horizonOccluder(layerState._viewer.camera);
const width = scene.canvas.clientWidth || scene.canvas.width || 0;
const height = scene.canvas.clientHeight || scene.canvas.height || 0;
const view = parts.rendering.cardView();
const { width, height } = view;
const marginX = width * CARD_VIEW_MARGIN;
const marginY = height * CARD_VIEW_MARGIN;
@@ -106,22 +104,20 @@ export function createCards({ state: layerState, services, parts, source }) {
let inView = false;
let sx = NaN;
let sy = NaN;
if (occluder.isPointVisible(record.position)) {
const screen = scene.cartesianToCanvasCoordinates(record.position);
if (
screen &&
Number.isFinite(screen.x) &&
Number.isFinite(screen.y) &&
screen.x >= -marginX &&
screen.x <= width + marginX &&
screen.y >= -marginY &&
screen.y <= height + marginY
) {
inView = true;
sx = screen.x;
sy = screen.y;
screenById.set(id, { sx, sy });
}
const screen = view.screenOf(record.position);
if (
screen &&
Number.isFinite(screen.x) &&
Number.isFinite(screen.y) &&
screen.x >= -marginX &&
screen.x <= width + marginX &&
screen.y >= -marginY &&
screen.y <= height + marginY
) {
inView = true;
sx = screen.x;
sy = screen.y;
screenById.set(id, { sx, sy });
}
candidates.push({
id,
@@ -333,7 +329,7 @@ export function createCards({ state: layerState, services, parts, source }) {
slot,
applyFrameResult(slot, { ok: !!frame, frame }, Date.now()),
);
layerState._viewer?.scene?.requestRender?.();
findFrame(layerState._viewer)?.requestRender('cctv-card-frame');
};
image.onload = () => settle(true);
image.onerror = () => settle(false);