mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +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
+125
-21
No files matched your search
@@ -135,17 +135,32 @@ export function createContactTrailRenderer(viewer) {
|
|||||||
return lines;
|
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) {
|
function headItems(segment, fraction) {
|
||||||
return LANES.map((lane) => ({
|
const [backingLane, lineLane] = LANES;
|
||||||
id: lane.name,
|
return [
|
||||||
|
{
|
||||||
|
id: 'head',
|
||||||
positions: segment.positions,
|
positions: segment.positions,
|
||||||
widthPx: lane.widthPx,
|
widthPx: backingLane.widthPx,
|
||||||
mode: 'draped',
|
mode: 'draped',
|
||||||
clampTo: 'both',
|
clampTo: 'both',
|
||||||
style: { kind: 'solid', color: tint(HEAD_ALPHA, lane.dark) },
|
style: {
|
||||||
|
kind: 'solid',
|
||||||
|
color: tint(HEAD_ALPHA, false),
|
||||||
|
outline: {
|
||||||
|
color: tint(HEAD_ALPHA, true),
|
||||||
|
widthPx: backingLane.widthPx - lineLane.widthPx,
|
||||||
|
},
|
||||||
|
},
|
||||||
revealFraction: fraction,
|
revealFraction: fraction,
|
||||||
}));
|
},
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Written only when it changes: a renderer may redraw for each write.
|
// 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 };
|
const sample = { displayT: 15000, fromSeq: 0, toSeq: 1, fraction: 0.75 };
|
||||||
for (let i = 0; i < 120; i++) renderer.setDisplaySample(sample, marker);
|
for (let i = 0; i < 120; i++) renderer.setDisplaySample(sample, marker);
|
||||||
assert.equal(head.show, true);
|
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(
|
assert.deepEqual(
|
||||||
lanes.map((lane) => [lane.id, lane.widthPx, lane.revealFraction]),
|
lines.map((line) => [line.id, line.widthPx, line.revealFraction]),
|
||||||
[
|
[['head', 5, 0.5]],
|
||||||
['backing', 5, 0.5],
|
|
||||||
['line', 3, 0.5],
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
assert.deepEqual(lanes[1].positions, [point(1), point(2)]);
|
assert.deepEqual(lines[0].positions, [point(1), point(2)]);
|
||||||
assert.ok(close(lanes[1].style.color, [...GREEN, 0.8]));
|
assert.ok(close(lines[0].style.color, [...GREEN, 0.8]));
|
||||||
assert.ok(close(lanes[0].style.color, [...DARK, 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();
|
const result = renderer.diagnostics();
|
||||||
assert.equal(result.headRebuilds, 1, '120 frames retain head geometry');
|
assert.equal(result.headRebuilds, 1, '120 frames retain head geometry');
|
||||||
assert.equal(result.entitiesAdded, 0);
|
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.
|
// A frame further along writes only how far it is revealed.
|
||||||
renderer.setDisplaySample({ ...sample, displayT: 17500 }, marker);
|
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);
|
assert.equal(renderer.diagnostics().headRebuilds, 1);
|
||||||
// The next subdivision, or the end of the leg, hides it.
|
// The next subdivision, or the end of the leg, hides it.
|
||||||
renderer.setDisplaySample({ ...sample, fraction: 1 }, marker);
|
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.ok(close(line.segmentColors[0], [1, 1, 1, trailAlpha(5000)]));
|
||||||
assert.equal(renderer.diagnostics().rebuilds, 1);
|
assert.equal(renderer.diagnostics().rebuilds, 1);
|
||||||
assert.equal(renderer.diagnostics().headRebuilds, 1, 'no crossing');
|
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');
|
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.equal(renderer.diagnostics().headRebuilds, 2, 'one per subdivision');
|
||||||
assert.deepEqual(body.items.get('line:0').segmentShow, [true, false]);
|
assert.deepEqual(body.items.get('line:0').segmentShow, [true, false]);
|
||||||
assert.deepEqual(head.items.get('line').positions, [point(1), point(2)]);
|
assert.deepEqual(head.items.get('head').positions, [point(1), point(2)]);
|
||||||
assert.ok(head.items.get('line').revealFraction > 0.99);
|
assert.ok(head.items.get('head').revealFraction > 0.99);
|
||||||
// Body writes: one a second, and one at the crossing at most.
|
// Body writes: one a second, and one at the crossing at most.
|
||||||
assert.ok(body.writes <= 1 + 20 + 1, `${body.writes} body writes`);
|
assert.ok(body.writes <= 1 + 20 + 1, `${body.writes} body writes`);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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) =>
|
const lanes = Array.from({ length: head.length }, (_, i) =>
|
||||||
head.get(i),
|
head.get(i),
|
||||||
).filter((part) => part instanceof Cesium.GroundPolylinePrimitive);
|
).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;
|
const added = scene.added.length;
|
||||||
// A second and a half of frames within the subdivision.
|
// A second and a half of frames within the subdivision.
|
||||||
for (let t = 12016; t < 13500; t += 16)
|
for (let t = 12016; t < 13500; t += 16)
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export const CESIUM_CHECKS = new Set([
|
|||||||
'draw.lines.outline',
|
'draw.lines.outline',
|
||||||
'draw.lines.drape',
|
'draw.lines.drape',
|
||||||
'draw.lines.split',
|
'draw.lines.split',
|
||||||
|
'draw.lines.outlineDraped',
|
||||||
'draw.lines.segments',
|
'draw.lines.segments',
|
||||||
'draw.lines.segmentStyles',
|
'draw.lines.segmentStyles',
|
||||||
'draw.sets.blend',
|
'draw.sets.blend',
|
||||||
|
|||||||
@@ -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(
|
check(
|
||||||
'draw.lines.segments',
|
'draw.lines.segments',
|
||||||
'a draped line takes segment colours and shows, changed every frame in place, without stopping the frame or picks',
|
'a draped line takes segment colours and shows, changed every frame in place, without stopping the frame or picks',
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ test('the stub passes the conformance suite', async () => {
|
|||||||
.filter((r) => r.status === 'skip')
|
.filter((r) => r.status === 'skip')
|
||||||
.map((r) => r.id);
|
.map((r) => r.id);
|
||||||
// It draws only models into pixels, so the sweep's, a lit shape's, a line outline's, a
|
// 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).
|
// camera that does (a controller over it, say).
|
||||||
assert.deepEqual(skipped, [
|
assert.deepEqual(skipped, [
|
||||||
'effects.screenModulation.pixels',
|
'effects.screenModulation.pixels',
|
||||||
@@ -28,6 +28,7 @@ test('the stub passes the conformance suite', async () => {
|
|||||||
'draw.lines.outline',
|
'draw.lines.outline',
|
||||||
'draw.sets.blend',
|
'draw.sets.blend',
|
||||||
'draw.lines.split',
|
'draw.lines.split',
|
||||||
|
'draw.lines.outlineDraped',
|
||||||
'draw.models.blend',
|
'draw.models.blend',
|
||||||
'globe.imagery.video',
|
'globe.imagery.video',
|
||||||
'globe.weather.drawn',
|
'globe.weather.drawn',
|
||||||
|
|||||||
Reference in new issue
Block a user