Take the camera layer's policy, state, model and ground off Cesium

The layer's colours are renderer colours; the parts that still draw with
Cesium (icons, coverage lines, the monitor plane) turn them into Cesium
colours with the adapter's own conversion. The screen and matrix scratches
are plain objects, which is all the projections that fill them write.

The model part converts angles with geo/vector, reads where the eye is
from the camera port's pose, and builds the monitor plane's orientation
with geo/quaternion from the same axes; the projection part hands the
entity a Cesium quaternion of it. The photoreal tileset readiness check,
which looks through the scene's primitives, moves to the geometry part.
The ground pass moves a camera icon by writing geo/ellipsoid's position
into the record's own position object. The test plane's plain material
comes from the projection part, and the selection part only lost an
unused import.

All give the same numbers as the Cesium calls they replace. Policy,
state, selection, testing, model and ground leave the allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 23:47:08 -08:00
1 parent 2592289612
commit 7d760d32fc
13 files changed
+147 -127

No files matched your search

+18 -6
View File
@@ -3,11 +3,14 @@ import * as Cesium from 'cesium';
import {
CCTV_PROJECTION_OVERLAY_SOURCE_ID,
CCTV_PROJECTION_OVERLAY_SOURCE_OPTIONS,
PLANE_OUTLINE_COLOR,
PLANE_OUTLINE_COLOR as PLANE_OUTLINE_RGBA,
PROJECTION_CANVAS_WIDTH,
PROJECTION_CANVAS_HEIGHT,
} from './policy.js';
import { cctvPicks } from './pickState.js';
import { toColor } from '../../render/cesium/draw.js';
const PLANE_OUTLINE_COLOR = toColor(PLANE_OUTLINE_RGBA);
export function createProjection({
state: layerState,
@@ -17,6 +20,12 @@ export function createProjection({
}) {
const { holdContinuousRender, releaseContinuousRender } = services.render;
/** The monitor plane's orientation, as the Cesium quaternion its entity takes. */
function planeOrientation(camera, capCenter) {
const q = parts.model.planeOrientationFor(camera, capCenter);
return new Cesium.Quaternion(q.x, q.y, q.z, q.w);
}
/**
* Build the protected label associated with one active monitor plane.
* @param {{cameraId: string, name: string, position: Cesium.Cartesian3|Function}} input
@@ -67,7 +76,7 @@ export function createProjection({
const positions =
record.frustumPositions || parts.geometry.frustumCartesians(geometry);
runtime.planeEntity.position = positions.capCenter;
runtime.planeEntity.orientation = parts.model.planeOrientationFor(
runtime.planeEntity.orientation = planeOrientation(
record.camera,
positions.capCenter,
);
@@ -122,6 +131,11 @@ export function createProjection({
}
}
/** A plain white plane material, for a plane with no media (tests). */
function plainPlaneMaterial() {
return new Cesium.ColorMaterialProperty(Cesium.Color.WHITE);
}
/** Create the native monitor plane plus its cached host-label presentation. */
function createProjectionPlane(record, runtime, geometry, positions) {
@@ -137,10 +151,7 @@ export function createProjection({
id: `cctv-${record.camera.id}-plane`,
show: false,
position: positions.capCenter,
orientation: parts.model.planeOrientationFor(
record.camera,
positions.capCenter,
),
orientation: planeOrientation(record.camera, positions.capCenter),
plane: {
plane: new Cesium.Plane(Cesium.Cartesian3.UNIT_Z, 0.0),
dimensions: new Cesium.Cartesian2(
@@ -428,6 +439,7 @@ export function createProjection({
updatePlanePlacement,
clearProjectionOverlay,
setPlaneVisible,
plainPlaneMaterial,
createProjectionPlane,
createProjectionRuntime,
ensureProjectionRuntime,