fix(transit): a selected vehicle's trail head is one outlined line again, its centre no darker than before

The seam drew the head as two stacked translucent lanes (a 5 px dark
backing under a 3 px colour line), which darkened its centre by up to 40
of 255 over light ground. It is now one 5 px line with a 2 px dark
outline in the same pass, as the head's own material drew it before.

Conformance gains draw.lines.outlineDraped: a draped, translucent,
revealed outlined line, its centre as bright as a plain line of the
colour, its edges dark, nothing past the reveal.
This commit is contained in:
Sameh Khamis committed 2026-11-14 12:35:24 -08:00
1 parent cdd855b7ec
commit d3cc95e9a6
6 files changed
+129 -25

No files matched your search

+25 -10
View File
@@ -135,17 +135,32 @@ export function createContactTrailRenderer(viewer) {
return lines;
}
/** The head's lines over `segment`, revealed to `fraction`. */
/**
* The head over `segment`, revealed to `fraction`: one line the backing's
* width, its edge the backing's colour and its centre the line's width,
* in one pass. Two lanes stacked would darken the centre where their
* translucent passes overlap.
*/
function headItems(segment, fraction) {
return LANES.map((lane) => ({
id: lane.name,
positions: segment.positions,
widthPx: lane.widthPx,
mode: 'draped',
clampTo: 'both',
style: { kind: 'solid', color: tint(HEAD_ALPHA, lane.dark) },
revealFraction: fraction,
}));
const [backingLane, lineLane] = LANES;
return [
{
id: 'head',
positions: segment.positions,
widthPx: backingLane.widthPx,
mode: 'draped',
clampTo: 'both',
style: {
kind: 'solid',
color: tint(HEAD_ALPHA, false),
outline: {
color: tint(HEAD_ALPHA, true),
widthPx: backingLane.widthPx - lineLane.widthPx,
},
},
revealFraction: fraction,
},
];
}
// Written only when it changes: a renderer may redraw for each write.
+13 -13
View File
@@ -104,17 +104,17 @@ test('the head is revealed to the vehicle and drawn anew only at a crossing', (t
const sample = { displayT: 15000, fromSeq: 0, toSeq: 1, fraction: 0.75 };
for (let i = 0; i < 120; i++) renderer.setDisplaySample(sample, marker);
assert.equal(head.show, true);
const lanes = [...record.items.values()];
// One line, its dark edge in the same pass: lanes stacked would darken
// its centre where their translucent passes overlap.
const lines = [...record.items.values()];
assert.deepEqual(
lanes.map((lane) => [lane.id, lane.widthPx, lane.revealFraction]),
[
['backing', 5, 0.5],
['line', 3, 0.5],
],
lines.map((line) => [line.id, line.widthPx, line.revealFraction]),
[['head', 5, 0.5]],
);
assert.deepEqual(lanes[1].positions, [point(1), point(2)]);
assert.ok(close(lanes[1].style.color, [...GREEN, 0.8]));
assert.ok(close(lanes[0].style.color, [...DARK, 0.8]));
assert.deepEqual(lines[0].positions, [point(1), point(2)]);
assert.ok(close(lines[0].style.color, [...GREEN, 0.8]));
assert.ok(close(lines[0].style.outline.color, [...DARK, 0.8]));
assert.equal(lines[0].style.outline.widthPx, 2);
const result = renderer.diagnostics();
assert.equal(result.headRebuilds, 1, '120 frames retain head geometry');
assert.equal(result.entitiesAdded, 0);
@@ -125,7 +125,7 @@ test('the head is revealed to the vehicle and drawn anew only at a crossing', (t
// A frame further along writes only how far it is revealed.
renderer.setDisplaySample({ ...sample, displayT: 17500 }, marker);
assert.equal(record.items.get('line').revealFraction, 0.75);
assert.equal(record.items.get('head').revealFraction, 0.75);
assert.equal(renderer.diagnostics().headRebuilds, 1);
// The next subdivision, or the end of the leg, hides it.
renderer.setDisplaySample({ ...sample, fraction: 1 }, marker);
@@ -151,7 +151,7 @@ test('a new mode colour is written into the segments, never rebuilding the body'
assert.ok(close(line.segmentColors[0], [1, 1, 1, trailAlpha(5000)]));
assert.equal(renderer.diagnostics().rebuilds, 1);
assert.equal(renderer.diagnostics().headRebuilds, 1, 'no crossing');
const headLine = setOf(draw, ':head').items.get('line');
const headLine = setOf(draw, ':head').items.get('head');
assert.ok(close(headLine.style.color, [1, 1, 1, 0.8]), 'and the head');
});
@@ -199,8 +199,8 @@ test('playback across a crossing redraws the head once and shows the passed segm
);
assert.equal(renderer.diagnostics().headRebuilds, 2, 'one per subdivision');
assert.deepEqual(body.items.get('line:0').segmentShow, [true, false]);
assert.deepEqual(head.items.get('line').positions, [point(1), point(2)]);
assert.ok(head.items.get('line').revealFraction > 0.99);
assert.deepEqual(head.items.get('head').positions, [point(1), point(2)]);
assert.ok(head.items.get('head').revealFraction > 0.99);
// Body writes: one a second, and one at the crossing at most.
assert.ok(body.writes <= 1 + 20 + 1, `${body.writes} body writes`);
});
+1 -1
View File
@@ -6484,7 +6484,7 @@ test('a transit trail moves its head, across subdivisions too, and fades its bod
const lanes = Array.from({ length: head.length }, (_, i) =>
head.get(i),
).filter((part) => part instanceof Cesium.GroundPolylinePrimitive);
assert.equal(lanes.length, 2, 'a backing lane and a line lane');
assert.equal(lanes.length, 1, 'one line, its dark edge in the same pass');
const added = scene.added.length;
// A second and a half of frames within the subdivision.
for (let t = 12016; t < 13500; t += 16)
+1
View File
@@ -70,6 +70,7 @@ export const CESIUM_CHECKS = new Set([
'draw.lines.outline',
'draw.lines.drape',
'draw.lines.split',
'draw.lines.outlineDraped',
'draw.lines.segments',
'draw.lines.segmentStyles',
'draw.sets.blend',
+87
View File
@@ -3122,6 +3122,93 @@ export function portChecks() {
}
},
),
check(
'draw.lines.outlineDraped',
'a draped, translucent, revealed solid line draws its outline in the same pass: its centre as bright as a plain line of the colour, its edges dark, nothing past the reveal',
async (h, r) => {
if (h.pixels === false)
return { skip: 'this harness reads no drawn pixels' };
await overAustin(h, r);
// Off the row under the camera, where a ground line can leave a gap.
const at = (dLon, dLat) =>
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat + dLat });
const lines = r.draw.lines({ id: 'conf:line-outline-draped' });
const green = [0, 1, 0, 0.8];
lines.set([
{
// 24 px with an outline of 8: 4 px of dark each side of 16 px
// of green, revealed to its middle.
id: 'outlined',
positions: [at(-0.004, 0.002), at(0.004, 0.002)],
widthPx: 24,
mode: 'draped',
style: {
kind: 'solid',
color: green,
outline: { color: [0, 0, 0, 0.8], widthPx: 8 },
},
revealFraction: 0.5,
},
{
id: 'plain',
positions: [at(-0.004, -0.002), at(0.004, -0.002)],
widthPx: 24,
mode: 'draped',
style: { kind: 'solid', color: green },
},
]);
// The middle column across the line at `dLon`, as green values.
const column = (dLon, dLat) => {
r.frame.renderNow();
const s = r.query.project(at(dLon, dLat));
const half = 20;
const image = r.readPixels({
crop: {
x: Math.round(s.x) - 2,
y: Math.round(s.y) - half,
width: 5,
height: 2 * half + 1,
},
});
const read = [];
for (let row = 0; row < image.height; row++) {
const i = (row * image.width + 2) * 4;
const [red, g, blue] = image.data.slice(i, i + 3);
read.push({ g, greenish: g > red + 30 && g > blue + 30 });
}
return read;
};
try {
await drawn(h, r);
await settled(r);
await drawn(h, r);
const outlined = column(-0.002, 0.002);
const plain = column(-0.002, -0.002);
const centre = (col) => col[(col.length - 1) >> 1];
const coreG = centre(outlined).g;
const plainG = centre(plain).g;
ok(
centre(outlined).greenish && centre(plain).greenish,
`both centres green (${coreG}, ${plainG})`,
);
ok(
Math.abs(coreG - plainG) <= 0.08 * plainG + 4,
`the outlined centre as bright as the plain line (${coreG} vs ${plainG})`,
);
// The rows just inside each edge: dark, 4 px of outline a side.
const mid = (outlined.length - 1) >> 1;
for (const row of [mid - 10, mid + 10])
ok(
outlined[row].g < 0.6 * coreG,
`dark at its edge, row ${row - mid} (${outlined[row].g} vs ${coreG})`,
);
const past = column(0.002, 0.002);
ok(!past.some((p) => p.greenish), 'nothing drawn past the reveal');
} finally {
lines.dispose();
}
},
),
check(
'draw.lines.segments',
'a draped line takes segment colours and shows, changed every frame in place, without stopping the frame or picks',
+2 -1
View File
@@ -20,7 +20,7 @@ test('the stub passes the conformance suite', async () => {
.filter((r) => r.status === 'skip')
.map((r) => r.id);
// It draws only models into pixels, so the sweep's, a lit shape's, a line outline's, a
// split line's and the blends' (over a drawn shape), video tiles' and the weather's pixels (drawn, and by scene time) go unread; its camera takes no user gestures: the drag and wheel scripts are for a
// split line's, a draped outlined line's and the blends' (over a drawn shape), video tiles' and the weather's pixels (drawn, and by scene time) go unread; its camera takes no user gestures: the drag and wheel scripts are for a
// camera that does (a controller over it, say).
assert.deepEqual(skipped, [
'effects.screenModulation.pixels',
@@ -28,6 +28,7 @@ test('the stub passes the conformance suite', async () => {
'draw.lines.outline',
'draw.sets.blend',
'draw.lines.split',
'draw.lines.outlineDraped',
'draw.models.blend',
'globe.imagery.video',
'globe.weather.drawn',