mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(cockpit): the orbital view gives the field of view back on exit
Cesium's fov was saved and put back when the orbital view closed, so a later resize or rotation kept Cesium's own behaviour. The exit held the saved vertical angle through setFov instead, which the camera port kept for the rest of the session: rotated to portrait, the view stayed zoomed in. setFov(null) gives the field of view back: Cesium's fov as it was before the first hold, the stub's own angle.
This commit is contained in:
1 parent
03a7d8827a
commit
4a781f0480
6 files changed
+52
-12
No files matched your search
@@ -305,6 +305,26 @@ test('setFov holds the vertical angle across resizes, and waits for a first one'
|
||||
assert.throws(() => port.setFov({ vertical: NaN }), RangeError);
|
||||
});
|
||||
|
||||
test('setFov(null) gives the angle back: Cesium’s own fov again, kept as Cesium keeps it', () => {
|
||||
const { scene, camera } = headlessCamera();
|
||||
scene.postUpdate = new Cesium.Event();
|
||||
scene.requestRender = () => {};
|
||||
camera.frustum.aspectRatio = 16 / 9;
|
||||
const own = camera.frustum.fov;
|
||||
const { port } = createCesiumCamera({ scene, camera, report: () => {} });
|
||||
port.setFov({ vertical: 0.5 });
|
||||
port.setFov({ vertical: 0.3 });
|
||||
scene.postUpdate.raiseEvent(scene);
|
||||
port.setFov(null);
|
||||
assert.equal(camera.frustum.fov, own, 'the fov it had before the first hold');
|
||||
// Rotated to portrait: Cesium keeps its fov, which is now the vertical
|
||||
// angle, rather than the held one.
|
||||
camera.frustum.aspectRatio = 9 / 16;
|
||||
scene.postUpdate.raiseEvent(scene);
|
||||
assert.equal(camera.frustum.fov, own);
|
||||
assert.ok(Math.abs(camera.frustum.fovy - own) < 1e-12);
|
||||
});
|
||||
|
||||
test('a pose measures heading, pitch and roll as Cesium does, and leaves the camera as it was', () => {
|
||||
const { camera, port } = headlessPort();
|
||||
const bits = () =>
|
||||
|
||||
Reference in new issue
Block a user