mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
conformance: draw.shapes.lit shows the globe again however it ends
This commit is contained in:
1 parent
d440f5bfaf
commit
90695db611
2 files changed
+87
-59
No files matched your search
@@ -2360,69 +2360,73 @@ export function portChecks() {
|
|||||||
async (h, r) => {
|
async (h, r) => {
|
||||||
if (h.pixels === false) return { skip: 'reads pixels' };
|
if (h.pixels === false) return { skip: 'reads pixels' };
|
||||||
r.globe.setGlobeVisible(false);
|
r.globe.setGlobeVisible(false);
|
||||||
const dLat = 150 / 111320;
|
// Shown again however the check ends.
|
||||||
const dLon = dLat / Math.cos((AUSTIN.lat * Math.PI) / 180);
|
try {
|
||||||
const shapes = r.draw.shapes({ id: 'conf:lit' });
|
const dLat = 150 / 111320;
|
||||||
shapes.set([
|
const dLon = dLat / Math.cos((AUSTIN.lat * Math.PI) / 180);
|
||||||
{
|
const shapes = r.draw.shapes({ id: 'conf:lit' });
|
||||||
id: 'block',
|
shapes.set([
|
||||||
geometry: {
|
{
|
||||||
kind: 'polygon',
|
id: 'block',
|
||||||
rings: [
|
geometry: {
|
||||||
[
|
kind: 'polygon',
|
||||||
{ lon: AUSTIN.lon - dLon, lat: AUSTIN.lat - dLat },
|
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 },
|
{ 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',
|
||||||
},
|
},
|
||||||
fill: '#808080',
|
]);
|
||||||
extrudeHeight: 300,
|
// 3.3 km south, 1.5 km up, looking north and down.
|
||||||
height: 'absolute',
|
r.camera.setView({
|
||||||
},
|
destination: {
|
||||||
]);
|
lon: AUSTIN.lon,
|
||||||
// 3.3 km south, 1.5 km up, looking north and down.
|
lat: AUSTIN.lat - 3300 / 111320,
|
||||||
r.camera.setView({
|
height: 1500,
|
||||||
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,
|
|
||||||
},
|
},
|
||||||
|
orientation: { heading: 0, pitch: (-35 * Math.PI) / 180, roll: 0 },
|
||||||
});
|
});
|
||||||
let sum = 0;
|
await h.frame(r);
|
||||||
for (let i = 0; i < data.length; i += 4)
|
await settled(r);
|
||||||
sum += (data[i] + data[i + 1] + data[i + 2]) / 3;
|
await drawn(h, r);
|
||||||
return sum / (data.length / 4);
|
const grey = (lon, lat, height) => {
|
||||||
};
|
const s = r.query.project(h.toEcef({ lon, lat, height }));
|
||||||
// A little in from the south face's middle, and the top's middle.
|
ok(s, 'projects');
|
||||||
const wall = grey(AUSTIN.lon, AUSTIN.lat - dLat * 0.98, 150);
|
const { data } = r.readPixels({
|
||||||
const top = grey(AUSTIN.lon, AUSTIN.lat, 300);
|
crop: {
|
||||||
ok(
|
x: Math.round(s.x) - 2,
|
||||||
wall > 85,
|
y: Math.round(s.y) - 2,
|
||||||
`the wall facing the eye is lit, brighter than half its colour (${Math.round(wall)})`,
|
width: 5,
|
||||||
);
|
height: 5,
|
||||||
ok(
|
},
|
||||||
Math.abs(top - wall) > 10,
|
});
|
||||||
`its top and its wall shade differently (${Math.round(top)}, ${Math.round(wall)})`,
|
let sum = 0;
|
||||||
);
|
for (let i = 0; i < data.length; i += 4)
|
||||||
shapes.dispose();
|
sum += (data[i] + data[i + 1] + data[i + 2]) / 3;
|
||||||
r.globe.setGlobeVisible(true);
|
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();
|
||||||
|
} finally {
|
||||||
|
r.globe.setGlobeVisible(true);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ capability: 'globeVisibility' },
|
{ capability: 'globeVisibility' },
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -310,3 +310,27 @@ test('a setBase that ends while a later one’s style still loads is settled; th
|
|||||||
globalThis.fetch = original;
|
globalThis.fetch = original;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a lit-shape check that fails still shows the globe again', async () => {
|
||||||
|
const shown = [];
|
||||||
|
const harness = {
|
||||||
|
...createStubHarness(),
|
||||||
|
// As a renderer reading pixels would; the stub draws no shapes, so the
|
||||||
|
// check fails its reads.
|
||||||
|
pixels: true,
|
||||||
|
create: async (options) => {
|
||||||
|
const r = await createStubHarness().create(options);
|
||||||
|
const destroy = r.destroy.bind(r);
|
||||||
|
r.destroy = () => {
|
||||||
|
shown.push(r.globe.isGlobeVisible());
|
||||||
|
destroy();
|
||||||
|
};
|
||||||
|
return r;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const report = await runConformance(harness, {
|
||||||
|
only: (id) => id === 'draw.shapes.lit',
|
||||||
|
});
|
||||||
|
assert.equal(report.results[0].status, 'fail');
|
||||||
|
assert.deepEqual(shown, [true]);
|
||||||
|
});
|
||||||
Reference in new issue
Block a user