Conformance: draw.shapes.lit, a lit extruded shape's walls shade by the light

A grey block 300 m tall, seen from 3.3 km south and 1.5 km up looking
north: the wall facing the eye must be brighter than half its colour, as
the renderer's own lit solids draw it, and its top must shade unlike its
wall. It reads pixels, so the stub skips it.
This commit is contained in:
Sameh Khamis committed 2026-11-11 20:13:19 -08:00
1 parent 143f4df049
commit 727a6a2f5e
2 files changed
+72 -1

No files matched your search

+70
View File
@@ -2354,6 +2354,76 @@ export function portChecks() {
shapes.dispose();
},
),
check(
'draw.shapes.lit',
'a lit extruded shape shades its walls by the light, as the renderer shades its own solids: the wall facing the eye brighter than half its colour, its top unlike its wall',
async (h, r) => {
if (h.pixels === false) return { skip: 'reads pixels' };
r.globe.setGlobeVisible(false);
const dLat = 150 / 111320;
const dLon = dLat / Math.cos((AUSTIN.lat * Math.PI) / 180);
const shapes = r.draw.shapes({ id: 'conf:lit' });
shapes.set([
{
id: 'block',
geometry: {
kind: 'polygon',
rings: [
[
{ lon: AUSTIN.lon - dLon, lat: AUSTIN.lat - dLat },
{ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat - dLat },
{ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat + dLat },
{ lon: AUSTIN.lon - dLon, lat: AUSTIN.lat + dLat },
],
],
},
fill: '#808080',
extrudeHeight: 300,
height: 'absolute',
},
]);
// 3.3 km south, 1.5 km up, looking north and down.
r.camera.setView({
destination: {
lon: AUSTIN.lon,
lat: AUSTIN.lat - 3300 / 111320,
height: 1500,
},
orientation: { heading: 0, pitch: (-35 * Math.PI) / 180, roll: 0 },
});
await h.frame(r);
await settled(r);
await drawn(h, r);
const grey = (lon, lat, height) => {
const s = r.query.project(h.toEcef({ lon, lat, height }));
ok(s, 'projects');
const { data } = r.readPixels({
crop: {
x: Math.round(s.x) - 2,
y: Math.round(s.y) - 2,
width: 5,
height: 5,
},
});
let sum = 0;
for (let i = 0; i < data.length; i += 4)
sum += (data[i] + data[i + 1] + data[i + 2]) / 3;
return sum / (data.length / 4);
};
// A little in from the south face's middle, and the top's middle.
const wall = grey(AUSTIN.lon, AUSTIN.lat - dLat * 0.98, 150);
const top = grey(AUSTIN.lon, AUSTIN.lat, 300);
ok(
wall > 85,
`the wall facing the eye is lit, brighter than half its colour (${Math.round(wall)})`,
);
ok(
Math.abs(top - wall) > 10,
`its top and its wall shade differently (${Math.round(top)}, ${Math.round(wall)})`,
);
shapes.dispose();
},
),
check(
'draw.shapes.resize',
'a clamped ellipse whose radius alone is upserted draws at the new radius, growing and shrinking',