mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Read the HUD and share-link camera through the renderer's camera port
The first camera-family slice. The camera port's events move into a shared module (render/camera/events.js) that the stub and the Cesium port both use: listener lists, delivery with errors reported, and the contract's per-listener `changed` measure. The Cesium port gains: - camera.on: `changed` measured per listener on every tick, where Cesium measures its single threshold (the counts match Cesium's own at each threshold); moveStart and moveEnd relayed from Cesium's camera; - camera.viewRectangle, in degrees (now in CESIUM_CHECKS); - lon and lat in pose, and NaN where Cesium has no cartographic position. Code that still holds the viewer reaches the renderer through rendererOf(viewer); the application renderer binds it on create and unbinds on destroy. The HUD reads its telemetry from the camera port and no longer imports Cesium (off the allow-list). The share link writes the hash from the pose. Its restore path stays on the viewer's camera for a later slice. Behaviour changes: - The share link listens to `changed` at its own 0.5 threshold, not at whatever global threshold layers had set, and also to moveEnd, so the hash always catches up with where the camera comes to rest. - The HUD's and share link's camera callbacks run from the port's single relay, ahead of other moveStart/moveEnd listeners, and a throw in one is reported to the renderer's error listeners instead of escaping from Cesium's render.
This commit is contained in:
1 parent
910185bfe0
commit
b5900b4178
28 files changed
+688
-243
No files matched your search
@@ -22,6 +22,7 @@ import {
|
||||
fromLegacyShareState,
|
||||
toLegacyShareState,
|
||||
} from './legacyShareState.js';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const DEG = Math.PI / 180;
|
||||
|
||||
@@ -47,7 +48,7 @@ function parseLegacy(hash) {
|
||||
globalThis.window = {
|
||||
location: { hash: body, href: `http://localhost/${body}` },
|
||||
};
|
||||
const manager = new ShareLinkManager(stubViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(stubViewer()));
|
||||
const parsed = manager.parseInitialHash();
|
||||
manager.destroy();
|
||||
return parsed;
|
||||
@@ -209,7 +210,7 @@ function generatedLegacyHash(random) {
|
||||
const int = (min, max) => min + Math.floor(random() * (max - min + 1));
|
||||
globalThis.window = { location: { hash: '', href: 'http://localhost/' } };
|
||||
const manager = new ShareLinkManager(
|
||||
stubViewer({
|
||||
bindFakeCesiumCamera(stubViewer({
|
||||
position: {
|
||||
latitude: (int(-899999, 899999) / 1e4) * DEG,
|
||||
longitude: (int(-1799999, 1799999) / 1e4) * DEG,
|
||||
@@ -218,7 +219,7 @@ function generatedLegacyHash(random) {
|
||||
heading: int(0, 359) * DEG + (random() < 0.1 ? 0.99 * DEG : 0),
|
||||
pitch: int(-90, 0) * DEG,
|
||||
roll: pick(random, [0, 359.7 * DEG, int(0, 359) * DEG]),
|
||||
}),
|
||||
})),
|
||||
);
|
||||
const style = pick(random, VIEW_STYLES);
|
||||
manager.onStyleChange(style);
|
||||
@@ -305,7 +306,7 @@ test('the converter ignores non-objects and restore bookkeeping', () => {
|
||||
test('the converter knows every key of the long form’s parsed state', () => {
|
||||
// A key the converter does not list would silently drop out of share codes.
|
||||
globalThis.window = { location: { hash: '', href: 'http://localhost/' } };
|
||||
const manager = new ShareLinkManager(stubViewer({}));
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(stubViewer({})));
|
||||
const parsed = manager._parseShareHash('v=2&lat=1&lon=2');
|
||||
assert.deepEqual(
|
||||
Object.keys(parsed).sort(),
|
||||
|
||||
Reference in new issue
Block a user