mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Read the agent world packet's camera through src/geo
The world packet converts the eye position with toLonLatH instead of Cesium's Cartographic, so the agent-world-packet group no longer needs cesium. Degree conversions use precomputed factors, as Cesium.Math does, so results stay bit for bit the same.
This commit is contained in:
1 parent
1d7d454dd6
commit
103ecae1f1
4 files changed
+29
-10
No files matched your search
@@ -7,7 +7,9 @@ import {
|
||||
geodeticSurfaceNormal,
|
||||
scaleToGeodeticSurface,
|
||||
toCartographicRadians,
|
||||
toDegrees,
|
||||
toLonLatH,
|
||||
toRadians,
|
||||
} from './index.js';
|
||||
|
||||
/** A seeded generator, so a failure names a reproducible point. */
|
||||
@@ -47,6 +49,13 @@ const closeVec = (a, b, tolerance, message) => {
|
||||
close(a.z, b.z, tolerance, `${message} z`);
|
||||
};
|
||||
|
||||
test("angle conversions are bit for bit the default renderer's", () => {
|
||||
for (const p of points()) {
|
||||
assert.equal(toRadians(p.lon), Cesium.Math.toRadians(p.lon));
|
||||
assert.equal(toDegrees(p.lat / 57), Cesium.Math.toDegrees(p.lat / 57));
|
||||
}
|
||||
});
|
||||
|
||||
test('geodetic to ECEF matches the default renderer', () => {
|
||||
for (const p of points()) {
|
||||
const ours = fromDegrees(p.lon, p.lat, p.height);
|
||||
|
||||
+6
-2
@@ -24,8 +24,12 @@ export function normalize(a) {
|
||||
return vec(a.x / m, a.y / m, a.z / m);
|
||||
}
|
||||
|
||||
export const toRadians = (degrees) => (degrees * Math.PI) / 180;
|
||||
export const toDegrees = (radians) => (radians * 180) / Math.PI;
|
||||
// As the default renderer converts: by a precomputed factor, so results are
|
||||
// bit for bit its own.
|
||||
export const RADIANS_PER_DEGREE = Math.PI / 180;
|
||||
export const DEGREES_PER_RADIAN = 180 / Math.PI;
|
||||
export const toRadians = (degrees) => degrees * RADIANS_PER_DEGREE;
|
||||
export const toDegrees = (radians) => radians * DEGREES_PER_RADIAN;
|
||||
export const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||
export const acosClamped = (v) => Math.acos(clamp(v, -1, 1));
|
||||
export const equalsEpsilon = (a, b, eps) => Math.abs(a - b) <= eps;
|
||||
|
||||
Reference in new issue
Block a user