Settle a line outline's width as the whole outline, half on each side

A solid line's outline.widthPx is the outline in all, half on each side and
inside the line's width, as Cesium draws it. The range ring's pulse fronts
pass their halo width whole again, so they keep main's look, and the
conformance check draw.lines.outline pins the width. The lines scene's
outlined line keeps its 2 px edge each side and its references are
re-recorded.
This commit is contained in:
Sameh Khamis committed 2026-11-10 08:59:36 -08:00
1 parent 94138d9698
commit 149f8aad4d
12 files changed
+94 -16

No files matched your search

+67
View File
@@ -2004,6 +2004,73 @@ export function portChecks() {
lines.dispose();
},
),
check(
'draw.lines.outline',
'a solid line’s outline is `widthPx` in all, half on each side, inside the line’s width',
async (h, r) => {
await overAustin(h, r);
const lines = r.draw.lines({ id: 'conf:line-outline' });
const at = (dLon) =>
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat, height: 200 });
// 20 px wide with an outline of 8: 4 px of red each side of 12 px
// of green. Read as 8 px each side, it would leave 4 px of green.
lines.set([
{
id: 'l',
positions: [at(-0.004), at(0.004)],
widthPx: 20,
mode: '3d',
style: {
kind: 'solid',
color: '#00ff00',
outline: { color: '#ff0000', widthPx: 8 },
},
},
]);
await drawn(h, r);
await settled(r);
r.frame.renderNow();
const s = r.query.project(at(0));
ok(s, 'the line projects');
const half = 30;
const image = r.readPixels({
crop: {
x: Math.round(s.x) - 2,
y: Math.round(s.y) - half,
width: 5,
height: 2 * half + 1,
},
});
// The middle column, top to bottom: r(ed), g(reen) or - (neither).
let column = '';
for (let row = 0; row < image.height; row++) {
const i = (row * image.width + 2) * 4;
const [red, green, blue] = image.data.slice(i, i + 3);
column +=
red > 160 && green < 100 && blue < 100
? 'r'
: green > 160 && red < 100 && blue < 100
? 'g'
: '-';
}
lines.dispose();
if (!column.includes('g') && !column.includes('r'))
return { skip: 'this renderer draws no line pixels' };
const runs = column.match(/r+|g+/g) ?? [];
const sides = runs.filter((run) => run[0] === 'r');
const core = runs.find((run) => run[0] === 'g') ?? '';
equal(sides.length, 2, `an outline each side (${column})`);
for (const side of sides)
ok(
side.length >= 3 && side.length <= 5,
`4 px of outline each side, not ${side.length} (${column})`,
);
ok(
core.length >= 10 && core.length <= 14,
`12 px of line between them, not ${core.length} (${column})`,
);
},
),
check(
'draw.lines.drape',
'draped glow, dash and arrow lines draw and pick; a revealed line draws only its first part; a draped line and a clamped point that move every frame are drawn where they now are in the next frame',
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

+3 -2
View File
@@ -192,7 +192,8 @@ export const REFERENCE_SCENES = Object.freeze([
style: { kind: 'solid', color: '#ff3b30' },
},
{
// A bright core inside a dark edge 2 px wide on each side.
// A bright core inside a dark edge 4 px wide in all, 2 px on
// each side.
id: 'outlined',
positions: row(800),
widthPx: 8,
@@ -200,7 +201,7 @@ export const REFERENCE_SCENES = Object.freeze([
style: {
kind: 'solid',
color: '#30d158',
outline: { color: '#000000', widthPx: 2 },
outline: { color: '#000000', widthPx: 4 },
},
},
{