mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
cdd855b7ec
commit
d3cc95e9a6
6 files changed
+129
-25
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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`);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user