Run the submarine cables layer's sweep and render requests through the frame port

The cables lifecycle and ingestion parts had left the Cesium allow-list
but still hooked the scene's preRender event and asked the scene for
renders directly. They now use the frame port.
This commit is contained in:
Sameh Khamis committed 2026-11-07 01:04:46 -08:00
1 parent 6fc3c78e70
commit 6386034add
3 files changed
+23 -20

No files matched your search

@@ -6,6 +6,7 @@ import { MAP_STACKS } from '../mapStackController.js';
import { fromDegrees, toLonLatH } from '../geo/ellipsoid.js';
import { bindFakeDraw } from '../testSupport/fakeDrawPort.mjs';
import { fakeCameraPort } from '../testSupport/fakeCameraPort.mjs';
import { fakeSceneFrame } from '../testSupport/fakeCesiumScene.mjs';
import {
CABLE_LABEL_DEPTH_DECISION,
CABLE_OVERLAY_COLLISION_CAPACITY,
@@ -586,7 +587,10 @@ function createCableHarness({
camera.port.cancelFlight = () => flights.push('cancel');
camera.port.flyTo = (destination, options) =>
flights.push({ destination, options });
const { draw } = bindFakeDraw(viewer, { camera: camera.port });
const { draw } = bindFakeDraw(viewer, {
camera: camera.port,
frame: fakeSceneFrame(viewer),
});
layer.init(viewer);
/** The layer's live set named `name` (`lines`, `pins`, …). */
const set = (name) =>
+2 -1
View File
@@ -1,4 +1,5 @@
import { msg, t } from '../../i18n/index.js';
import { findFrame } from '../../render/rendererOf.js';
import { normalizeFeatures } from './geometry.js';
export function createIngestion({ state, parts, source }) {
@@ -54,7 +55,7 @@ export function createIngestion({ state, parts, source }) {
state._loadingLabel = '';
parts.rendering.updateVisibility();
state._referenceSweepGate.markDirty();
viewer?.scene?.requestRender?.();
findFrame(viewer)?.requestRender('submarine-cables');
} catch (error) {
// A stale or aborted load reports nothing: its failure belongs to a
// lifecycle the user already left.
+16 -18
View File
@@ -1,4 +1,4 @@
import { cameraOf } from '../../render/rendererOf.js';
import { cameraOf, findFrame, frameOf } from '../../render/rendererOf.js';
import {
cableClassificationTypeForScene,
cableClassificationTypeForStack,
@@ -38,27 +38,25 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
},
};
if (!state._preRenderRemover) {
state._preRenderRemover = viewer.scene.preRender.addEventListener(
() => {
// The camera is handed to the gate so tracked/orbit cameras — which
// never emit moveEnd — reach the motion fallback. No render is
// requested for a fallback sweep: it only fires while the camera is
// already moving, so frames are flowing by construction.
if (
!state._enabled ||
!state._loaded ||
!state._referenceSweepGate.shouldRun(eye)
)
return;
parts.rendering.updateReferenceVisibility();
},
);
state._preRenderRemover = frameOf(viewer).on('preRender', () => {
// The camera is handed to the gate so tracked/orbit cameras — which
// never emit moveEnd — reach the motion fallback. No render is
// requested for a fallback sweep: it only fires while the camera is
// already moving, so frames are flowing by construction.
if (
!state._enabled ||
!state._loaded ||
!state._referenceSweepGate.shouldRun(eye)
)
return;
parts.rendering.updateReferenceVisibility();
});
}
if (!state._moveEndRemover) {
state._moveEndRemover = cameraOf(viewer).on('moveEnd', () => {
if (!state._enabled) return;
state._referenceSweepGate.markDirty();
viewer.scene.requestRender?.();
findFrame(viewer)?.requestRender('submarine-cables');
});
}
},
@@ -73,7 +71,7 @@ export function createLifecycle({ state, parts, source, mapStackEventTarget }) {
state._referenceSweepGate.markDirty();
// The gate is dirty-only; ask for the frame its sweep needs in case the
// camera is parked and nothing else is rendering.
(viewer || state._viewer)?.scene?.requestRender?.();
findFrame(viewer || state._viewer)?.requestRender('submarine-cables');
void parts.ingestion.load(viewer || state._viewer);
},