From 727a6a2f5eb7cf2f3157427c9623331fccf228d6 Mon Sep 17 00:00:00 2001 From: Sameh Khamis Date: Wed, 11 Nov 2026 20:13:19 -0800 Subject: [PATCH] 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. --- src/render/conformance/checks/ports.js | 70 ++++++++++++++++++++++++++ src/render/stub/stub.test.mjs | 3 +- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/src/render/conformance/checks/ports.js b/src/render/conformance/checks/ports.js index 6f0f879fc..2442e21a4 100644 --- a/src/render/conformance/checks/ports.js +++ b/src/render/conformance/checks/ports.js @@ -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', diff --git a/src/render/stub/stub.test.mjs b/src/render/stub/stub.test.mjs index 40cde5111..a9950e0a4 100644 --- a/src/render/stub/stub.test.mjs +++ b/src/render/stub/stub.test.mjs @@ -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, a line outline's and + // It draws only models into pixels, so the sweep's, a lit shape's, a line outline's and // the blends' (over a drawn shape) and video tiles' 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.shapes.lit', 'draw.lines.outline', 'draw.sets.blend', 'draw.models.blend',