mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Turn draped rectangles by an optional rotation, and drape image fills in the Cesium port
A rectangle shape gains an optional rotation: radians counter-clockwise, turning it about its centre in longitude and latitude, as a KML ground overlay turns; an image fill turns with it. A renderer that predates it draws the rectangle unturned. The Cesium draw port passes it as the rectangle's rotation and texture rotation, and now drapes image fills on clamped shapes, each on a ground primitive of its own that owns its material, where it refused them before. Hidden image fills are not built until they show. The stub picks draped rectangles, turned and across the antimeridian, and a conformance check picks a quarter-turned overlay on both renderers. The KML importer still draws its overlays itself.
This commit is contained in:
1 parent
7ad65b2e87
commit
6286bcfb07
9 files changed
+331
-14
No files matched your search
@@ -1378,6 +1378,70 @@ export function portChecks() {
|
||||
lines.dispose();
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.shapes.drapedRotation',
|
||||
'a draped rectangle with an image fill draws turned by its rotation, picks there, and hides in place',
|
||||
async (h, r) => {
|
||||
await overAustin(h, r);
|
||||
const at = (dLon, dLat = 0) =>
|
||||
h.toEcef({ lon: AUSTIN.lon + dLon, lat: AUSTIN.lat + dLat });
|
||||
const shapes = r.draw.shapes({ id: 'conf:overlay' });
|
||||
const mine = (pos) => {
|
||||
const s = r.query.project(pos);
|
||||
return Boolean(
|
||||
s &&
|
||||
r.query
|
||||
.drillPick(s.x, s.y)
|
||||
.some(
|
||||
(hit) => hit.set === 'conf:overlay' && hit.id === 'overlay',
|
||||
),
|
||||
);
|
||||
};
|
||||
// Wide east to west; a quarter turn stands it north to south.
|
||||
const overlay = (rotation, extra = {}) => ({
|
||||
id: 'overlay',
|
||||
geometry: {
|
||||
kind: 'rectangle',
|
||||
rect: {
|
||||
west: AUSTIN.lon - 0.004,
|
||||
south: AUSTIN.lat - 0.001,
|
||||
east: AUSTIN.lon + 0.004,
|
||||
north: AUSTIN.lat + 0.001,
|
||||
},
|
||||
...(rotation === undefined ? {} : { rotation }),
|
||||
},
|
||||
fill: { image: PIXEL_PNG },
|
||||
height: 'clampGround',
|
||||
...extra,
|
||||
});
|
||||
const until = async (test) => {
|
||||
for (let i = 0; i < 300; i++) {
|
||||
await drawn(h, r, 1);
|
||||
if (test()) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
shapes.set([overlay(undefined)]);
|
||||
ok(await until(() => mine(at(0))), 'unturned, it draws');
|
||||
ok(mine(at(0.003)), 'unturned, it is wide');
|
||||
ok(!mine(at(0, 0.003)), 'unturned, it is not tall');
|
||||
shapes.set([overlay(Math.PI / 2)]);
|
||||
ok(
|
||||
await until(() => mine(at(0, 0.003)) && !mine(at(0.003))),
|
||||
'a quarter turn stands it north to south',
|
||||
);
|
||||
ok(mine(at(0)), 'turned about its centre');
|
||||
shapes.upsert([overlay(Math.PI / 2, { show: false })]);
|
||||
await drawn(h, r);
|
||||
ok(!mine(at(0)), 'hidden');
|
||||
shapes.upsert([overlay(Math.PI / 2)]);
|
||||
ok(await until(() => mine(at(0, 0.003))), 'shown again');
|
||||
equal(shapes.size(), 1, 'held');
|
||||
shapes.dispose();
|
||||
await drawn(h, r);
|
||||
ok(!mine(at(0)), 'gone with its set');
|
||||
},
|
||||
),
|
||||
check(
|
||||
'draw.lines.styles',
|
||||
'flow lines draw draped and in space, and a line with a depth-fail colour moves every frame, without stopping the frame or picks',
|
||||
|
||||
Reference in new issue
Block a user