fix(cctv): address review of #1543 (horizon test, resume guard, no per-frame allocation, mobile sheet)

- frames.test: viewerAt uses Cesium's default far (5e8) so the below-horizon
  test fails without occluder.isPointVisible
- cctvControls: install the resume observer for a still-only panel too
- cctvPresentation: panelShown also requires the Cameras sheet on phones;
  the observer watches body class/data-mobile-sheet
- frames.projectionInView: shared horizonOccluder + scratch sphere/array
This commit is contained in:
Byrd-IT authored and brandonabyrd committed 2026-11-18 17:13:06 -06:00
1 parent 0151c178a4
commit 9a3fc84935
6 files changed
+110 -25

No files matched your search

+15 -8
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import { horizonOccluder } from '../../data/iconOrientation.js';
import {
FRAME_SIGNATURE_W,
FRAME_SIGNATURE_H,
@@ -42,6 +43,9 @@ export function fitToProjection(sourceW, sourceH) {
};
}
const _scratchPoints = [];
const _scratchSphere = new Cesium.BoundingSphere();
export function createFrames({ state: layerState, services, parts, source }) {
/**
* FNV-1a over the RGB channels of a downsampled frame. Pure (takes the raw
@@ -254,7 +258,10 @@ export function createFrames({ state: layerState, services, parts, source }) {
if (!camera || !scene || scene.mode !== Cesium.SceneMode.SCENE3D)
return true;
const placed = record?.frustumPositions;
const points = [
// Reused buffers: this runs on every projection tick while out of view.
const points = _scratchPoints;
points.length = 0;
for (const point of [
record?.billboard?.position,
placed?.mount,
placed?.capCenter,
@@ -262,16 +269,15 @@ export function createFrames({ state: layerState, services, parts, source }) {
placed?.tr,
placed?.br,
placed?.bl,
].filter(Boolean);
]) {
if (point) points.push(point);
}
if (
!points.length ||
typeof camera.frustum?.computeCullingVolume !== 'function'
)
return true;
const occluder = new Cesium.EllipsoidalOccluder(
Cesium.Ellipsoid.WGS84,
camera.positionWC,
);
const occluder = horizonOccluder(camera);
if (!points.some((point) => occluder.isPointVisible(point))) return false;
const culling = camera.frustum.computeCullingVolume(
camera.positionWC,
@@ -279,8 +285,9 @@ export function createFrames({ state: layerState, services, parts, source }) {
camera.upWC,
);
return (
culling.computeVisibility(Cesium.BoundingSphere.fromPoints(points)) !==
Cesium.Intersect.OUTSIDE
culling.computeVisibility(
Cesium.BoundingSphere.fromPoints(points, _scratchSphere),
) !== Cesium.Intersect.OUTSIDE
);
}
+3 -1
View File
@@ -185,7 +185,9 @@ function viewerAt(position, direction, up) {
fov: Cesium.Math.toRadians(60),
aspectRatio: 16 / 9,
near: 1,
far: 5e6,
// Cesium's default far plane, as the app uses: a smaller one rejects
// the far-side mount before the horizon check is ever reached.
far: 5e8,
}),
},
};