Read transit's viewport from the camera port

Feed activation and the view bounds read the camera port's pose and view
rectangle instead of the Cesium camera; the look-at centre comes from
geo/rectangle, which crosses the antimeridian as Cesium's does. The layer's
lifecycle loads the Cesium camera factory, so a viewer of a caller's own
still has a camera to read. viewport leaves the Cesium allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 21:23:57 -08:00
1 parent 56d56a4d6d
commit af449184ca
5 files changed
+64 -31

No files matched your search

+29
View File
@@ -306,6 +306,34 @@ function harness(
},
});
// The layer reads the camera through its port; this one reads the fake
// camera above as the Cesium port reads a real one, so a test can still
// move it by changing the fake.
const unbindCamera = bindRenderer(viewer, {
camera: {
pose() {
const carto = viewer.camera.positionCartographic;
return {
lon: carto ? Cesium.Math.toDegrees(carto.longitude) : NaN,
lat: carto ? Cesium.Math.toDegrees(carto.latitude) : NaN,
height: carto ? carto.height : NaN,
};
},
viewRectangle() {
const rect = viewer.camera.computeViewRectangle?.(
Cesium.Ellipsoid.WGS84,
);
if (!rect) return null;
const deg = Cesium.Math.toDegrees;
return {
west: deg(rect.west),
south: deg(rect.south),
east: deg(rect.east),
north: deg(rect.north),
};
},
},
});
installRenderGovernor(framePortFor(viewer.scene));
layer.init(viewer);
@@ -316,6 +344,7 @@ function harness(
/* a test may already have destroyed it */
}
uninstallRenderGovernor(framePortFor(viewer.scene));
unbindCamera();
_resetRenderGovernorForTest();
globalThis.fetch = originalFetch;
if (originalDocument === undefined) delete globalThis.document;