mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Set the field of view and read the matrices through the camera port
setFov holds the vertical angle it is given across resizes (Cesium keeps the wider one), waits for a frustum with a field of view, and rejects angles outside (0, pi). matrices returns Cesium's view and projection matrices, ECEF to eye in 3D, the only mode the app runs. The conformance run checks both on Cesium.
This commit is contained in:
1 parent
e3a850bc9c
commit
28b5de7196
4 files changed
+60
-4
No files matched your search
@@ -25,7 +25,7 @@ const QUERY_RECORDS = new Set([
|
||||
'occluded',
|
||||
]);
|
||||
/** Commands and records the port does not have yet. */
|
||||
const MISSING = new Set(['matrices']);
|
||||
const MISSING = new Set([]);
|
||||
|
||||
const runnable = CAMERA_SCRIPTS.filter((script) =>
|
||||
script.steps.every(
|
||||
@@ -232,3 +232,21 @@ test('a Cesium viewer with no renderer bound gets a camera port over its own cam
|
||||
assert.throws(() => cameraOf({ scene, camera: {} }), /no renderer camera/);
|
||||
});
|
||||
});
|
||||
|
||||
test('setFov holds the vertical angle across resizes, and waits for a first one', () => {
|
||||
const { scene, camera } = headlessCamera();
|
||||
scene.postUpdate = new Cesium.Event();
|
||||
scene.requestRender = () => {};
|
||||
camera.frustum.aspectRatio = NaN;
|
||||
const { port } = createCesiumCamera({ scene, camera, report: () => {} });
|
||||
port.setFov({ vertical: 0.5 });
|
||||
for (const aspect of [16 / 9, 0.6, 4 / 3]) {
|
||||
camera.frustum.aspectRatio = aspect;
|
||||
scene.postUpdate.raiseEvent(scene);
|
||||
assert.ok(Math.abs(camera.frustum.fovy - 0.5) < 1e-12, `aspect ${aspect}`);
|
||||
}
|
||||
camera.switchToOrthographicFrustum();
|
||||
assert.doesNotThrow(() => port.setFov({ vertical: 0.4 }));
|
||||
assert.throws(() => port.setFov({ vertical: Math.PI }), RangeError);
|
||||
assert.throws(() => port.setFov({ vertical: NaN }), RangeError);
|
||||
});
|
||||
Reference in new issue
Block a user