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
@@ -656,6 +656,25 @@ export function createStubRenderer(options = {}) {
|
||||
return set && item ? itemPosition(set, item, aheadMs) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether `lon`, `lat` (degrees) is in a rectangle geometry, turned by its
|
||||
* `rotation` about its centre in longitude and latitude.
|
||||
*/
|
||||
function inRectangle({ rect, rotation = 0 }, lon, lat) {
|
||||
// A rectangle across the antimeridian runs east past 180°.
|
||||
const span = rect.east - rect.west;
|
||||
const width = span >= 360 ? 360 : ((span % 360) + 360) % 360;
|
||||
const wrap = (d) => ((((d + 180) % 360) + 360) % 360) - 180;
|
||||
const dLon = wrap(lon - (rect.west + width / 2));
|
||||
const dLat = lat - (rect.south + rect.north) / 2;
|
||||
const cos = Math.cos(rotation);
|
||||
const sin = Math.sin(rotation);
|
||||
return (
|
||||
Math.abs(cos * dLon + sin * dLat) <= width / 2 &&
|
||||
Math.abs(-sin * dLon + cos * dLat) <= (rect.north - rect.south) / 2
|
||||
);
|
||||
}
|
||||
|
||||
function hitsAt(x, y, win = {}) {
|
||||
if (scriptedPicks) return scriptedPicks(x, y, win) ?? [];
|
||||
const halfW = (win.width ?? 3) / 2;
|
||||
@@ -681,6 +700,30 @@ export function createStubRenderer(options = {}) {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (set.kind === 'shapes') {
|
||||
// Draped rectangles are picked where they cover the ellipsoid, turned
|
||||
// as the default renderer turns them; other shapes are not picked.
|
||||
const ground = rayEllipsoid(pickRay(x, y));
|
||||
const at = ground && toCartographicRadians(ground);
|
||||
if (!at) continue;
|
||||
for (const item of set.items.values()) {
|
||||
if (item.show === false || item.pickable === false) continue;
|
||||
if (!item.fill || item.outlineOnly) continue;
|
||||
if (item.height !== 'clampGround') continue;
|
||||
if (item.geometry?.kind !== 'rectangle') continue;
|
||||
if (!inRectangle(item.geometry, toDegrees(at.lon), toDegrees(at.lat)))
|
||||
continue;
|
||||
hits.push({
|
||||
set: setId,
|
||||
id: item.id,
|
||||
meta: item.meta,
|
||||
surface: false,
|
||||
position: ground,
|
||||
depth: magnitude(sub(ground, eye().position)),
|
||||
});
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (
|
||||
set.kind !== 'icons' &&
|
||||
set.kind !== 'points' &&
|
||||
|
||||
Reference in new issue
Block a user