mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
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:
1 parent
94138d9698
commit
149f8aad4d
12 files changed
+94
-16
No files matched your search
@@ -49,7 +49,8 @@ export const CONTEXT_RIM_HEIGHT_M = 2500;
|
||||
* the FLIR, NVG and CRT styles. A bright core inside a dark halo keeps
|
||||
* luminance contrast on light and dark ground alike, and luminance is what
|
||||
* the monochrome styles keep. The core is the Context panel's blue; the halo
|
||||
* is the map-card ink. Widths are screen pixels; `outlineWidth` is per side.
|
||||
* is the map-card ink. Widths are screen pixels; `outlineWidth` is the
|
||||
* halo's width in all, half on each side.
|
||||
* It is drawn as an unpickable primitive, so clicks on its edge reach the
|
||||
* contacts underneath.
|
||||
* While the sonar pulses run, the ring dims to `restOpacity` and flashes
|
||||
|
||||
@@ -189,8 +189,9 @@ function rgba(css) {
|
||||
const faded = ([r, g, b, a], alpha) => [r, g, b, a * alpha];
|
||||
|
||||
/**
|
||||
* A haloed line as the draw port draws it: `widthPx` wide, its outer
|
||||
* `haloPx` on each side in the halo's colour, the rest in the core's.
|
||||
* A haloed line as the draw port draws it: `widthPx` wide, an outer
|
||||
* `haloPx` in all (half on each side) in the halo's colour, the rest in the
|
||||
* core's.
|
||||
* @returns {object} The line item.
|
||||
*/
|
||||
const haloedLine = (id, positions, { core, halo, widthPx, haloPx, show }) => ({
|
||||
@@ -561,8 +562,7 @@ export function createRangeRing({
|
||||
core: faded(core, state.alpha * level),
|
||||
halo: faded(halo, state.alpha * level),
|
||||
widthPx: pulse.width,
|
||||
// The fronts' `outlineWidth` is both sides together.
|
||||
haloPx: pulse.outlineWidth / 2,
|
||||
haloPx: pulse.outlineWidth,
|
||||
show: level > 0,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -363,10 +363,10 @@ test('the ring core and halo contrast on light and dark ground', () => {
|
||||
const ratio = (luminance(core) + 0.05) / (luminance(halo) + 0.05);
|
||||
assert.ok(ratio >= 4.5, `core:halo contrast ${ratio.toFixed(2)}`);
|
||||
assert.ok(core.alpha >= 0.9 && halo.alpha >= 0.7);
|
||||
// A visible halo on each side of a core at least 2 px wide.
|
||||
// A visible halo, half on each side, around a core at least 2 px wide.
|
||||
const { width, outlineWidth } = AWARENESS_RANGE_RING_STYLE;
|
||||
assert.ok(outlineWidth >= 1);
|
||||
assert.ok(width - 2 * outlineWidth >= 2);
|
||||
assert.ok(width - outlineWidth >= 2);
|
||||
});
|
||||
|
||||
test('renderVisual draws the ring as a haloed line in an unpickable set, never an entity', (t) => {
|
||||
@@ -1126,9 +1126,10 @@ test('the band is one flat unpickable ellipse at the rim, drawn anew each step a
|
||||
assert.equal(core.show, true);
|
||||
assert.equal(core.widthPx, AWARENESS_RANGE_PULSE.width);
|
||||
assert.equal(halo.style.color.length, 4);
|
||||
// The outline is the halo's width in all, half on each side.
|
||||
assert.equal(
|
||||
core.style.outline.widthPx,
|
||||
AWARENESS_RANGE_PULSE.outlineWidth / 2,
|
||||
AWARENESS_RANGE_PULSE.outlineWidth,
|
||||
);
|
||||
const pulse = awarenessPulseState(at, index);
|
||||
const ground = Cesium.Cartesian3.fromDegrees(3, 27, 0);
|
||||
|
||||
@@ -47,6 +47,7 @@ export const CESIUM_CHECKS = new Set([
|
||||
'draw.lines.depthFail',
|
||||
'draw.lines.settled',
|
||||
'draw.lines.styles',
|
||||
'draw.lines.outline',
|
||||
'draw.lines.drape',
|
||||
'draw.lines.segments',
|
||||
'draw.ids',
|
||||
|
||||
@@ -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 |
@@ -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 },
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Vendored
+5
-3
@@ -196,9 +196,11 @@ export type LineStyle =
|
||||
kind: 'solid';
|
||||
color: Color;
|
||||
/**
|
||||
* A band `widthPx` wide each side, inside the line's width, drawn in
|
||||
* the same pass as the line: a translucent halo that does not darken
|
||||
* where it meets the line. Its colour changes in place.
|
||||
* An edge `widthPx` wide in all, half of it on each side, inside the
|
||||
* line's width (a line 8 px wide with an outline of 4 has 2 px of
|
||||
* outline each side and 4 px of `color` between), drawn in the same
|
||||
* pass as the line: a translucent edge does not darken where it meets
|
||||
* the line. Its colour changes in place.
|
||||
*/
|
||||
outline?: { color: Color; widthPx: number };
|
||||
}
|
||||
|
||||
@@ -19,11 +19,12 @@ test('the stub passes the conformance suite', async () => {
|
||||
const skipped = report.results
|
||||
.filter((r) => r.status === 'skip')
|
||||
.map((r) => r.id);
|
||||
// It draws only models into pixels, so the sweep's pixels go unread; its
|
||||
// camera takes no user gestures: the drag and wheel scripts are for a
|
||||
// It draws only models into pixels, so the sweep's and a line outline's
|
||||
// pixels 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',
|
||||
'draw.lines.outline',
|
||||
...CAMERA_SCRIPTS.filter(usesInput).map((s) => `camera.trace.${s.name}`),
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user