mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 03:32:19 +00:00
A line can be drawn as several runs (breaks) (#1895)
* A line can be drawn as several runs (`breaks`) LineItem.breaks (capability lineBreaks) lists the positions that start a new run of a line: the segment into each is not drawn nor picked, and the line does not join across it, each run having ends of its own. Many lines in one style, such as many moving objects' trails, can then be sent as one item. Segment colours and shows stay one a pair of positions, age times one a position, and the reveal runs along the runs in order. The Cesium port draws a line in runs a piece a run, draped or not, and lists the capability; the stub picks the runs only; the conformance check draw.lines.breaks pins it. * A line in runs is cut by time run by run, whatever their order The conformance check draw.lines.breaks.timeWindow draws a line in runs, draped and not, whose first run is later than its second, and reads each run drawn and cut by its own times as the scene clock moves. It found that a plain line drawn in a polyline collection after an aged one was the page's first of its style's type stopped the frame: Cesium keeps a material type's uniform names from the first material of it, and a part of a composite material has them renumbered. A part's type is now made on its own first. * Changelog for line breaks (#1895)
This commit is contained in:
1 parent
e4caf5d3af
commit
d9d79ebc4d
15 files changed
+868
-29
No files matched your search
@@ -3627,6 +3627,205 @@ export function portChecks() {
|
||||
},
|
||||
{ capability: 'lineTimeWindow' },
|
||||
),
|
||||
check(
|
||||
'draw.lines.breaks',
|
||||
'a line in runs, draped or not, draws and picks each run, in its segment colours, and nothing between them',
|
||||
async (h, r) => {
|
||||
await overAustin(h, r);
|
||||
// Off the row under the camera, where a ground line can leave a gap.
|
||||
const at = (dLon, dLat, height) =>
|
||||
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat + dLat, height });
|
||||
const lines = r.draw.lines({ id: 'conf:line-breaks' });
|
||||
// Two runs, west and east, the second starting at position 2: the
|
||||
// pair from position 1 to 2, across the break, is not drawn.
|
||||
const lons = [-0.004, -0.002, 0.001, 0.004];
|
||||
const line = (id, dLat, mode, segmentColors) => ({
|
||||
id,
|
||||
positions: lons.map((dLon) =>
|
||||
at(dLon, dLat, mode === 'draped' ? 0 : 20),
|
||||
),
|
||||
breaks: [2],
|
||||
widthPx: 16,
|
||||
mode,
|
||||
style: { kind: 'solid', color: [0, 1, 0, 1] },
|
||||
...(segmentColors
|
||||
? {
|
||||
// The pair across the break has a colour, ignored.
|
||||
segmentColors: [
|
||||
[1, 0, 0, 1],
|
||||
[0, 1, 0, 1],
|
||||
[0, 0, 1, 1],
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
const kinds = [
|
||||
['3d', 0.003, false],
|
||||
['draped', 0.001, false],
|
||||
['3d coloured', -0.001, true],
|
||||
['draped coloured', -0.003, true],
|
||||
];
|
||||
const lat = new Map(kinds.map(([what, dLat]) => [what, dLat]));
|
||||
lines.set(
|
||||
kinds.map(([what, dLat, coloured]) =>
|
||||
line(
|
||||
what,
|
||||
dLat,
|
||||
what.startsWith('draped') ? 'draped' : '3d',
|
||||
coloured,
|
||||
),
|
||||
),
|
||||
);
|
||||
const where = (what, dLon) =>
|
||||
at(dLon, lat.get(what), what.startsWith('draped') ? 0 : 20);
|
||||
// The colour drawn there, strongly: 'r', 'g', 'b', or null.
|
||||
const colour = (what, dLon) => {
|
||||
r.frame.renderNow();
|
||||
const s = r.query.project(where(what, dLon));
|
||||
const image = r.readPixels({
|
||||
crop: {
|
||||
x: Math.round(s.x),
|
||||
y: Math.round(s.y),
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
});
|
||||
const [red, green, blue] = image.data;
|
||||
if (red > green + 80 && red > blue + 80) return 'r';
|
||||
if (green > red + 80 && green > blue + 80) return 'g';
|
||||
if (blue > red + 80 && blue > green + 80) return 'b';
|
||||
return null;
|
||||
};
|
||||
const picked = (what, dLon) => {
|
||||
const s = r.query.project(where(what, dLon));
|
||||
ok(s, `${what} projects`);
|
||||
return r.query
|
||||
.drillPick(s.x, s.y)
|
||||
.filter((hit) => hit.set === 'conf:line-breaks')
|
||||
.map((hit) => hit.id);
|
||||
};
|
||||
try {
|
||||
await drawn(h, r);
|
||||
await settled(r);
|
||||
await drawn(h, r);
|
||||
for (const [what, , coloured] of kinds) {
|
||||
deepEqual(
|
||||
picked(what, -0.003),
|
||||
[what],
|
||||
`${what}: its first run picks`,
|
||||
);
|
||||
deepEqual(
|
||||
picked(what, -0.0005),
|
||||
[],
|
||||
`${what}: nothing between its runs`,
|
||||
);
|
||||
deepEqual(
|
||||
picked(what, 0.0025),
|
||||
[what],
|
||||
`${what}: its second run picks`,
|
||||
);
|
||||
if (h.pixels === false) continue;
|
||||
equal(
|
||||
colour(what, -0.003),
|
||||
coloured ? 'r' : 'g',
|
||||
`${what}: its first run drawn`,
|
||||
);
|
||||
equal(
|
||||
colour(what, -0.0005),
|
||||
null,
|
||||
`${what}: nothing drawn between its runs`,
|
||||
);
|
||||
equal(
|
||||
colour(what, 0.0025),
|
||||
coloured ? 'b' : 'g',
|
||||
`${what}: its second run drawn`,
|
||||
);
|
||||
}
|
||||
equal(lines.size(), kinds.length, 'one item a line');
|
||||
} finally {
|
||||
lines.dispose();
|
||||
}
|
||||
},
|
||||
{ capability: 'lineBreaks' },
|
||||
),
|
||||
check(
|
||||
'draw.lines.breaks.timeWindow',
|
||||
'a line in runs, draped or not, whose first run is later than its second, cuts each run by its own times',
|
||||
async (h, r) => {
|
||||
if (!r.capabilities.has('lineBreaks'))
|
||||
return { skip: 'the renderer draws no lines in runs' };
|
||||
if (h.pixels === false)
|
||||
return { skip: 'this harness reads no drawn pixels' };
|
||||
await overAustin(h, r);
|
||||
const t0 = Date.UTC(2026, 0, 1, 18);
|
||||
r.frame.setTime(t0);
|
||||
const at = (dLon, dLat, height) =>
|
||||
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat + dLat, height });
|
||||
const lines = r.draw.lines({ id: 'conf:line-breaks-window' });
|
||||
// Its first run, west, the last ten seconds to t0; its second, east,
|
||||
// two minutes before.
|
||||
const line = (id, dLat, mode) => ({
|
||||
id,
|
||||
positions: [-0.004, -0.001, 0.001, 0.004].map((dLon) =>
|
||||
at(dLon, dLat, mode === 'draped' ? 0 : 20),
|
||||
),
|
||||
breaks: [2],
|
||||
widthPx: 16,
|
||||
mode,
|
||||
style: { kind: 'solid', color: [0, 1, 0, 1] },
|
||||
ageFade: {
|
||||
times: [t0 - 10_000, t0, t0 - 120_000, t0 - 110_000],
|
||||
windowMs: 60_000,
|
||||
alphaFloor: 1,
|
||||
showMs: 30_000,
|
||||
},
|
||||
});
|
||||
lines.set([line('air', 0.002, '3d'), line('ground', -0.002, 'draped')]);
|
||||
const green = (dLon, dLat) => {
|
||||
r.frame.renderNow();
|
||||
const s = r.query.project(at(dLon, dLat, dLat > 0 ? 20 : 0));
|
||||
const image = r.readPixels({
|
||||
crop: {
|
||||
x: Math.round(s.x),
|
||||
y: Math.round(s.y),
|
||||
width: 1,
|
||||
height: 1,
|
||||
},
|
||||
});
|
||||
const [red, g, blue] = image.data;
|
||||
return g > red + 80 && g > blue + 80;
|
||||
};
|
||||
try {
|
||||
await drawn(h, r);
|
||||
await settled(r);
|
||||
await drawn(h, r);
|
||||
for (const [what, dLat] of [
|
||||
['3d', 0.002],
|
||||
['draped', -0.002],
|
||||
]) {
|
||||
ok(green(-0.0025, dLat), `${what}: its later run drawn at t0`);
|
||||
ok(!green(0.0025, dLat), `${what}: its earlier run too old at t0`);
|
||||
ok(!green(0, dLat), `${what}: nothing between its runs`);
|
||||
}
|
||||
// 105 s before t0 the second run is within the span, the first
|
||||
// not yet begun.
|
||||
r.frame.setTime(t0 - 105_000);
|
||||
await drawn(h, r);
|
||||
for (const [what, dLat] of [
|
||||
['3d', 0.002],
|
||||
['draped', -0.002],
|
||||
]) {
|
||||
ok(green(0.0025, dLat), `${what}: its earlier run drawn then`);
|
||||
ok(!green(-0.0025, dLat), `${what}: its later run not yet drawn`);
|
||||
ok(!green(0, dLat), `${what}: still nothing between its runs`);
|
||||
}
|
||||
equal(lines.size(), 2, 'never sent again');
|
||||
} finally {
|
||||
lines.dispose();
|
||||
}
|
||||
},
|
||||
{ capability: 'lineTimeWindow' },
|
||||
),
|
||||
check(
|
||||
'draw.lines.segments',
|
||||
'a draped line takes segment colours and shows, changed every frame in place, without stopping the frame or picks',
|
||||
|
||||
Reference in new issue
Block a user