mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Move radio navigation and viewport queries onto the camera port
Radio's camera state, globe recenter plan and viewport anchor now read the camera pose instead of the Cesium camera. The anchor intersects the view ray with the ellipsoid through a shared rayEllipsoid helper, moved into geo/ellipsoid from the stub renderer and checked against Cesium. Scratch vectors are plain objects. navigation, queries and state leave the Cesium allow-list; rendering and lifecycle stay, since they rely on entity clustering, which the draw port does not offer yet.
This commit is contained in:
1 parent
8c6fa6258b
commit
96d860854f
9 files changed
+127
-80
No files matched your search
@@ -2,9 +2,11 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import * as Cesium from 'cesium';
|
||||
import {
|
||||
distance,
|
||||
eastNorthUp,
|
||||
fromDegrees,
|
||||
geodeticSurfaceNormal,
|
||||
rayEllipsoid,
|
||||
scaleToGeodeticSurface,
|
||||
toCartographicRadians,
|
||||
toDegrees,
|
||||
@@ -167,3 +169,43 @@ test('east-north-up frames match the default renderer', () => {
|
||||
closeVec(ours.origin, column(m, 3), 0, `${where} origin`);
|
||||
}
|
||||
});
|
||||
|
||||
test('a ray meets the ellipsoid where Cesium picks it', () => {
|
||||
const rand = random(7);
|
||||
let misses = 0;
|
||||
for (let i = 0; i < 200; i++) {
|
||||
const origin = new Cesium.Cartesian3(
|
||||
(rand() - 0.5) * 4e7,
|
||||
(rand() - 0.5) * 4e7,
|
||||
(rand() - 0.5) * 4e7,
|
||||
);
|
||||
const toward = new Cesium.Cartesian3(
|
||||
(rand() - 0.5) * 2.4e7,
|
||||
(rand() - 0.5) * 2.4e7,
|
||||
(rand() - 0.5) * 2.4e7,
|
||||
);
|
||||
const direction = Cesium.Cartesian3.normalize(
|
||||
Cesium.Cartesian3.subtract(toward, origin, new Cesium.Cartesian3()),
|
||||
new Cesium.Cartesian3(),
|
||||
);
|
||||
const ray = new Cesium.Ray(origin, direction);
|
||||
// As `camera.pickEllipsoid` takes the hit.
|
||||
const span = Cesium.IntersectionTests.rayEllipsoid(
|
||||
ray,
|
||||
Cesium.Ellipsoid.WGS84,
|
||||
);
|
||||
const ours = rayEllipsoid({ origin, direction });
|
||||
if (!span) {
|
||||
misses += 1;
|
||||
assert.equal(ours, null);
|
||||
continue;
|
||||
}
|
||||
const expected = Cesium.Ray.getPoint(
|
||||
ray,
|
||||
span.start > 0 ? span.start : span.stop,
|
||||
);
|
||||
assert.ok(ours, 'a hit');
|
||||
assert.ok(distance(ours, expected) < 1e-3, `ray ${i}`);
|
||||
}
|
||||
assert.ok(misses > 0 && misses < 200, 'hits and misses both tried');
|
||||
});
|
||||
Reference in new issue
Block a user