Merge branch 'sameh/renderer-transit' into sameh/renderer-seam

# Conflicts:
#	src/render/cesium/draw.test.mjs
This commit is contained in:
Sameh Khamis committed 2026-11-09 01:00:43 -08:00
commit 9d4e438e63
27 files changed
+2016 -465

No files matched your search

+2
View File
@@ -65,6 +65,8 @@
"src/render/motion/iconBook.test.mjs",
"src/render/camera/poseSignature.test.mjs",
"src/render/cesium/internals.test.mjs",
"src/render/cesium/uploadProbe.js",
"src/render/cesium/uploadProbe.test.mjs",
"src/render/cesium/tileRequests.js",
"src/render/cesium/tileRequests.test.mjs",
"src/queries/heights.test.mjs",
+2
View File
@@ -5748,6 +5748,7 @@
"src/layers/transit/qaMetrics.js",
"src/layers/transit/queries.js",
"src/layers/transit/rendering.js",
"src/geo/frustum.js",
"src/render/cesium/iconOrientation.js",
"src/layers/transit/selection.js",
"src/layers/transit/state.js",
@@ -5821,6 +5822,7 @@
"src/layers/transit/policy.js",
"src/layers/transit/queries.js",
"src/layers/transit/rendering.js",
"src/geo/frustum.js",
"src/render/cesium/iconOrientation.js",
"src/layers/transit/selection.js",
"src/geo/index.js",
+45 -18
View File
@@ -177,6 +177,19 @@ export async function sampleTransitPixels(page, palette) {
];
const width = canvas.clientWidth;
const height = canvas.clientHeight;
// The billboards the draw port drew for the layer's two sets, by
// vehicle key, with the collection drawing each.
const drawn = new Map();
const setIds = layer._transitSetIdsForTest();
for (let i = 0; i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++) {
const billboard = host.get(j);
if (typeof billboard?.id?.id === 'string')
drawn.set(billboard.id.id, { billboard, host });
}
}
const sprites = [];
const footprints = [];
const intersects = (a, b) =>
@@ -256,20 +269,26 @@ export async function sampleTransitPixels(page, palette) {
};
for (const entry of state._vehicles.values()) {
if (!entry.marker || entry.marker.show === false) continue;
const p = entry.marker.position;
const row = drawn.get(entry.key);
if (!row || row.billboard.show === false) {
skipped.push({ key: entry.key, reason: 'billboard not drawn' });
continue;
}
const billboard = row.billboard;
const p = billboard.position;
const clip = mul(proj, mul(view, [p.x, p.y, p.z, 1]));
if (!(clip[3] > 0)) continue;
const screen = entry.marker.computeScreenSpacePosition?.(scene) || {
const screen = billboard.computeScreenSpacePosition?.(scene) || {
x: ((clip[0] / clip[3]) * 0.5 + 0.5) * width,
y: (1 - ((clip[1] / clip[3]) * 0.5 + 0.5)) * height,
};
const rect = entry.marker.constructor.getScreenSpaceBoundingBox?.(
entry.marker,
const rect = billboard.constructor.getScreenSpaceBoundingBox?.(
billboard,
screen,
) || { x: screen.x - 16, y: screen.y - 16, width: 32, height: 32 };
const { x, y } = screenPoint(screen.x, screen.y);
const c = Math.abs(Math.cos(entry.marker.rotation || 0)),
sn = Math.abs(Math.sin(entry.marker.rotation || 0));
const c = Math.abs(Math.cos(billboard.rotation || 0)),
sn = Math.abs(Math.sin(billboard.rotation || 0));
const w = rect.width * c + rect.height * sn,
h = rect.height * c + rect.width * sn;
const footprint = { x: x - w / 2, y: y - h / 2, w, h };
@@ -282,10 +301,7 @@ export async function sampleTransitPixels(page, palette) {
rect.y + rect.height > height
)
reason = 'billboard rectangle outside frame';
if (
entry.marker.color?.alpha < 0.95 ||
entry.markerCollection?.show === false
)
if (billboard.color?.alpha < 0.95 || row.host.show === false)
reason = 'billboard not opaque/collection hidden';
const raster = rasters.get(entry.marker.image);
if (!raster) reason = 'billboard alpha unavailable';
@@ -351,12 +367,12 @@ export async function sampleTransitPixels(page, palette) {
bracketX: entry.detectContact?._candidateScreenX ?? screen.x,
bracketY: entry.detectContact?._candidateScreenY ?? screen.y,
raster,
rotation: entry.marker.rotation || 0,
halfW: Number.isFinite(entry.marker.width)
? Math.ceil(entry.marker.width / 2) + 2
rotation: billboard.rotation || 0,
halfW: Number.isFinite(billboard.width)
? Math.ceil(billboard.width / 2) + 2
: 11,
halfH: Number.isFinite(entry.marker.height)
? Math.ceil(entry.marker.height / 2) + 2
halfH: Number.isFinite(billboard.height)
? Math.ceil(billboard.height / 2) + 2
: 7,
});
}
@@ -658,12 +674,23 @@ export function readTransitFleetStyle({ key, resetSelection = false } = {}) {
const entry = key
? state._vehicles.get(key)
: [...state._vehicles.values()].find((e) => e.marker?.show);
return entry
// The billboard the draw port drew for it, in either of the layer's sets.
const scene = window.__godsEyeView.viewer.scene;
const setIds = layer._transitSetIdsForTest();
let billboard = null;
for (let i = 0; entry && !billboard && i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++)
if (host.get(j)?.id?.id === entry.key) billboard = host.get(j);
}
// An undrawn marker has no style to compare: no answer.
return entry && billboard
? {
key: entry.key,
selected: state._selectedKey === entry.key,
color: entry.marker.color.toCssColorString(),
width: entry.marker.width,
color: billboard.color.toCssColorString(),
width: billboard.width,
image: entry.marker.image,
}
: null;
+2 -1
View File
@@ -182,7 +182,8 @@ try {
});
parts.rendering.sampleIdle(entry);
parts.rendering.schedulePlayback(entry);
const V = entry.marker.position.constructor;
// Marker positions are plain records; the camera's eye is a Cartesian3.
const V = scene.camera.positionWC.constructor;
const points = entry.trailSegments
.filter((s) => s.toT <= entry.sample.displayT)
.flatMap((s) => s.positions);
+63 -17
View File
@@ -146,11 +146,7 @@ export async function runFleetBudgets({
// The retained delta is conservative: it includes concurrent page growth.
const retained = await cdp.send('Runtime.getHeapUsage');
// Timing/upload acceptance runs without the allocation profiler attached.
const trace = await page.evaluate(() =>
window.__godsEyeView.dataManager.layers
.get('transit')
.module._measureTransitFramesForTest(8000),
);
const trace = await page.evaluate(measureTransitFrames, 8000);
await page.evaluate(() =>
window.__godsEyeView.dataManager.layers
.get('transit')
@@ -166,11 +162,7 @@ export async function runFleetBudgets({
page,
`${count} budget visibility before allocation trace`,
);
const allocationTrace = await page.evaluate(() =>
window.__godsEyeView.dataManager.layers
.get('transit')
.module._measureTransitFramesForTest(6000),
);
const allocationTrace = await page.evaluate(measureTransitFrames, 6000);
const { profile } = await cdp.send('HeapProfiler.stopSampling');
const allocations = allocationTotals(profile);
const retainedBytes = retained.usedSize - before.usedSize;
@@ -361,13 +353,23 @@ export async function runBostonMatrix({
const modes = await page.evaluate(() => {
const layer =
window.__godsEyeView.dataManager.layers.get('transit').module;
// The billboards the draw port drew for the markers, by key.
const scene = window.__godsEyeView.viewer.scene;
const setIds = layer._transitSetIdsForTest();
const drawn = new Map();
for (let i = 0; i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++)
drawn.set(host.get(j)?.id?.id, host.get(j));
}
return [...layer._transitStateForTest()._vehicles.values()].map(
(e) => ({
key: e.key,
route: e.record.routeId,
image: e.marker.image,
width: e.marker.width,
color: e.marker.color.toCssHexString(),
width: drawn.get(e.key)?.width ?? null,
color: drawn.get(e.key)?.color.toCssHexString() ?? null,
}),
);
});
@@ -418,15 +420,27 @@ export async function runBostonMatrix({
window.__godsEyeView.dataManager.layers.get('transit').module;
layer._transitPartsForTest().selection.clearSelection();
const e = layer._transitStateForTest()._vehicles.get(key);
// The billboard the draw port drew for it.
const scene = window.__godsEyeView.viewer.scene;
const setIds = layer._transitSetIdsForTest();
let drawn = null;
for (let i = 0; !drawn && i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++)
if (host.get(j)?.id?.id === key) drawn = host.get(j);
}
return {
drawn: Boolean(drawn),
image: e.marker.image,
width: e.marker.width,
color: e.marker.color.toCssHexString(),
width: drawn?.width ?? null,
color: drawn?.color.toCssHexString() ?? null,
};
}, target.key);
check(
`Boston ${background.name}/${look.name}/${target.route}: deselect restores fleet styling`,
restored.image === target.image &&
restored.drawn &&
restored.image === target.image &&
restored.width === target.width &&
restored.color === target.color,
);
@@ -884,7 +898,18 @@ export async function runTrailVisibility({
if (points.length < 2)
return { ...setup, present: 0, reason: 'no completed path' };
const C = scene.camera.positionCartographic.constructor;
const V = entry.marker.position.constructor;
// Marker positions are plain records; the camera's eye is a Cartesian3.
const V = scene.camera.positionWC.constructor;
// The billboard the draw port drew for the marker, seen through.
const setIds = layer._transitSetIdsForTest();
const markerBillboards = [];
for (let i = 0; i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++)
if (host.get(j)?.id?.id === entry.key)
markerBillboards.push(host.get(j));
}
const lengths = [0];
for (let i = 1; i < points.length; i++)
lengths.push(lengths.at(-1) + V.distance(points[i - 1], points[i]));
@@ -905,7 +930,7 @@ export async function runTrailVisibility({
);
const cart = C.fromCartesian(p);
const height = scene.sampleHeight(cart, [
entry.marker,
...markerBillboards,
...partsOf(trail.body),
...partsOf(trail.headLines),
]);
@@ -1077,3 +1102,24 @@ export async function runTrailVisibility({
.selection.clearSelection(),
);
}
/**
* The transit frame probe over the bytes the renderer uploads for the
* layer's marker sets (the Cesium renderer's upload probe), in the page.
* @param {number} durationMs
*/
async function measureTransitFrames(durationMs) {
const { countDrawSetUploads } =
await import('/src/render/cesium/uploadProbe.js');
const app = window.__godsEyeView;
const layer = app.dataManager.layers.get('transit').module;
const uploads = countDrawSetUploads(
app.viewer,
layer._transitSetIdsForTest(),
);
try {
return await layer._measureTransitFramesForTest(durationMs, uploads);
} finally {
uploads.stop();
}
}
+48 -20
View File
@@ -98,7 +98,7 @@ const renderingSource = await readFile(
);
const frameSource = renderingSource
.split('function onPreRender()')[1]
.split('const occluder')[0];
.split('const candidatePosition')[0];
check(
'frame pass does not scan the fleet or copy the moving set',
!/_vehicles\.values|\[\.\.\.state\._moving\]/.test(frameSource),
@@ -815,25 +815,38 @@ try {
const layer =
window.__godsEyeView.dataManager.layers.get('transit').module;
const state = layer._transitStateForTest();
const entry = state._vehicles.get(key);
const scene = window.__godsEyeView.viewer.scene;
// The billboard the draw port drew for it, and the set drawing it.
const setIds = layer._transitSetIdsForTest();
let billboard = null,
setId = null;
for (let i = 0; !billboard && i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (!setIds.includes(host?.drawSetId)) continue;
for (let j = 0; j < host.length; j++)
if (host.get(j)?.id?.id === key) {
billboard = host.get(j);
setId = host.drawSetId;
}
}
const set = layer._transitPartsForTest().rendering.setNameOf(setId);
return {
selected: state._selectedKey === key,
color: entry?.marker.color.toCssColorString(),
width: entry?.marker.width,
color: billboard?.color.toCssColorString(),
width: billboard?.width,
pickOwner: (() => {
const p = window.__godsEyeView.viewer.scene.pick(
entry.marker.computeScreenSpacePosition(
window.__godsEyeView.viewer.scene,
),
);
const p = billboard
? scene.pick(billboard.computeScreenSpacePosition(scene))
: null;
return {
id: typeof p?.id === 'string' ? p.id : null,
primitiveId:
typeof p?.primitive?.id === 'string' ? p.primitive.id : null,
id: typeof p?.id?.id === 'string' ? p.id.id : null,
set: typeof p?.id?.set === 'string' ? p.id.set : null,
collection:
entry.markerCollection === state._animatedMarkers
set === 'moving'
? 'animated'
: 'stationary',
: set === 'still'
? 'stationary'
: null,
};
})(),
};
@@ -1596,7 +1609,8 @@ try {
key: entry.key,
x,
y,
pickKey: picked?.id ?? picked?.primitive?.id ?? null,
// A draw-port pick carries {set, id, meta}; the vehicle is its id.
pickKey: picked?.id?.id ?? picked?.id ?? picked?.primitive?.id ?? null,
};
});
let anchor = null;
@@ -1849,19 +1863,33 @@ try {
await page.$eval(row, (element) =>
element.scrollIntoView({ block: 'center' }),
);
// The marker sets drawn while on, to look for after disable.
const markerSets = await page.evaluate(() =>
window.__godsEyeView.dataManager.layers
.get('transit')
.module._transitSetIdsForTest(),
);
await page.click(`${row} .data-toggle-btn`);
await page.waitForFunction(
() => !window.__godsEyeView.dataManager.isEnabled('transit'),
{ timeout: 20_000 },
);
const afterDisable = transitRequests.length;
const teardown = await page.evaluate(() => {
const teardown = await page.evaluate((setIds) => {
const layer = window.__godsEyeView.dataManager.layers.get('transit').module;
const state = layer._transitStateForTest();
return {
vehicles: state._vehicles.size,
primitives:
(state._markers?.length || 0) + (state._animatedMarkers?.length || 0),
// Billboards still drawn in the sets drawn while on.
primitives: (() => {
const scene = window.__godsEyeView.viewer.scene;
let count = 0;
for (let i = 0; i < scene.primitives.length; i++) {
const host = scene.primitives.get(i);
if (setIds.includes(host?.drawSetId)) count += host.length || 0;
}
return count;
})(),
visible: state._visible.size,
moving: state._moving.size,
detect: state._detectCache,
@@ -1873,12 +1901,12 @@ try {
],
trailPending: layer._transitPartsForTest().trails.requestDiagnostics()
.pending,
shown: state._markers ? state._markers.show : null,
shown: state._markersShown ?? null,
inFlight: state._inFlight.size,
activeFeeds: state._activeFeeds.size,
holds: window.__godsEyeView.getRenderGovernorDiagnostics().holds,
};
});
}, markerSets);
check(
'disable leaves no vehicles and no point primitives',
teardown.vehicles === 0 &&