mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52: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
9f165e68f3
commit
5652236a27
4 files changed
+29
-10
No files matched your search
@@ -2355,6 +2355,10 @@
|
|||||||
"./standalone/catalog"
|
"./standalone/catalog"
|
||||||
],
|
],
|
||||||
"modules": [
|
"modules": [
|
||||||
|
"src/geo/index.js",
|
||||||
|
"src/geo/vector.js",
|
||||||
|
"src/geo/ellipsoid.js",
|
||||||
|
"src/geo/frames.js",
|
||||||
"src/layers/flights/icons.js",
|
"src/layers/flights/icons.js",
|
||||||
"src/data/aircraftIconLayer.js",
|
"src/data/aircraftIconLayer.js",
|
||||||
"src/data/aircraftModelLayer.js",
|
"src/data/aircraftModelLayer.js",
|
||||||
@@ -5112,6 +5116,10 @@
|
|||||||
"agent-world-packet": {
|
"agent-world-packet": {
|
||||||
"exports": ["./agent/world-packet"],
|
"exports": ["./agent/world-packet"],
|
||||||
"modules": [
|
"modules": [
|
||||||
|
"src/geo/index.js",
|
||||||
|
"src/geo/vector.js",
|
||||||
|
"src/geo/ellipsoid.js",
|
||||||
|
"src/geo/frames.js",
|
||||||
"src/agent/worldPacket.js",
|
"src/agent/worldPacket.js",
|
||||||
"src/data/layerSnapshot.js",
|
"src/data/layerSnapshot.js",
|
||||||
"src/data/feedState.js",
|
"src/data/feedState.js",
|
||||||
@@ -5120,7 +5128,7 @@
|
|||||||
"src/data/installationFeedback.js",
|
"src/data/installationFeedback.js",
|
||||||
"src/i18n/marker.js"
|
"src/i18n/marker.js"
|
||||||
],
|
],
|
||||||
"external": ["cesium"]
|
"external": []
|
||||||
},
|
},
|
||||||
"heights": {
|
"heights": {
|
||||||
"exports": ["./queries/heights"],
|
"exports": ["./queries/heights"],
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as Cesium from 'cesium';
|
import { toLonLatH } from '../geo/index.js';
|
||||||
import {
|
import {
|
||||||
feedProvenanceEnvelope,
|
feedProvenanceEnvelope,
|
||||||
layerSnapshot,
|
layerSnapshot,
|
||||||
@@ -109,9 +109,7 @@ export function getWorldPacket(options = {}) {
|
|||||||
if (!dataManager || typeof dataManager.getAll !== 'function')
|
if (!dataManager || typeof dataManager.getAll !== 'function')
|
||||||
throw new TypeError('World Packet requires a data manager');
|
throw new TypeError('World Packet requires a data manager');
|
||||||
|
|
||||||
const cartographic = Cesium.Cartographic.fromCartesian(
|
const eye = toLonLatH(viewer.camera.positionWC);
|
||||||
viewer.camera.positionWC,
|
|
||||||
);
|
|
||||||
// Read the roster once. Voice must not rewalk disabled layers: preserving the
|
// Read the roster once. Voice must not rewalk disabled layers: preserving the
|
||||||
// current enabled-only view keeps the model's context budget bounded.
|
// current enabled-only view keeps the model's context budget bounded.
|
||||||
const rows = dataManager.getAll();
|
const rows = dataManager.getAll();
|
||||||
@@ -126,9 +124,9 @@ export function getWorldPacket(options = {}) {
|
|||||||
ok: true,
|
ok: true,
|
||||||
action: 'get_current_view_state',
|
action: 'get_current_view_state',
|
||||||
camera: {
|
camera: {
|
||||||
latitude: Cesium.Math.toDegrees(cartographic.latitude),
|
latitude: eye.lat,
|
||||||
longitude: Cesium.Math.toDegrees(cartographic.longitude),
|
longitude: eye.lon,
|
||||||
heightM: cartographic.height,
|
heightM: eye.height,
|
||||||
},
|
},
|
||||||
style: styleManager?.activeStyle || 'normal',
|
style: styleManager?.activeStyle || 'normal',
|
||||||
context: contextState
|
context: contextState
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import {
|
|||||||
geodeticSurfaceNormal,
|
geodeticSurfaceNormal,
|
||||||
scaleToGeodeticSurface,
|
scaleToGeodeticSurface,
|
||||||
toCartographicRadians,
|
toCartographicRadians,
|
||||||
|
toDegrees,
|
||||||
toLonLatH,
|
toLonLatH,
|
||||||
|
toRadians,
|
||||||
} from './index.js';
|
} from './index.js';
|
||||||
|
|
||||||
/** A seeded generator, so a failure names a reproducible point. */
|
/** 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`);
|
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', () => {
|
test('geodetic to ECEF matches the default renderer', () => {
|
||||||
for (const p of points()) {
|
for (const p of points()) {
|
||||||
const ours = fromDegrees(p.lon, p.lat, p.height);
|
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);
|
return vec(a.x / m, a.y / m, a.z / m);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const toRadians = (degrees) => (degrees * Math.PI) / 180;
|
// As the default renderer converts: by a precomputed factor, so results are
|
||||||
export const toDegrees = (radians) => (radians * 180) / Math.PI;
|
// 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 clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
||||||
export const acosClamped = (v) => Math.acos(clamp(v, -1, 1));
|
export const acosClamped = (v) => Math.acos(clamp(v, -1, 1));
|
||||||
export const equalsEpsilon = (a, b, eps) => Math.abs(a - b) <= eps;
|
export const equalsEpsilon = (a, b, eps) => Math.abs(a - b) <= eps;
|
||||||
|
|||||||
Reference in new issue
Block a user