mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Read the eye's follow frame through the camera port and take share-follow off the Cesium list
The camera port gains an optional followFrame() (capability followFrame): the frame the eye is placed in now, as a column-major 4x4 matrix to ECEF. Once a follow has framed the camera it is the follow's own frame (east-north-up, or the orbit frame an autodetect follow chose), under lookAt the target's east-north-up frame, otherwise the identity. setView places a world pose and keeps that frame. The Cesium port reads it from camera.transform, only when the capability is on; the stub from its own eye frame. A conformance check covers the world, lookAt and enu-follow frames, the offset in it, and setView keeping it. src/ui/shareFollow.js now reads the pose, the frame and the follow offset through the camera and frame ports: a shared offset is re-expressed in the follow's own frame as before, satellites included, and the eye is placed with setView at exact heading, pitch and roll, so a near-vertical view keeps its roll. placeFollowEye returns false on a camera that cannot say its frame. offsetFromHeadingPitchRange moves to src/geo/frames.js, shared with the stub.
This commit is contained in:
1 parent
b0ed9d7e90
commit
90e73f2ef2
19 files changed
+596
-143
No files matched your search
@@ -83,13 +83,21 @@ const NO_FOLLOW_OFFSET = Object.freeze({ get: () => null, set() {} });
|
||||
|
||||
/**
|
||||
* @param {{scene: object, camera: object, report: (error: unknown) => void,
|
||||
* widget?: object}} options `scene` gives `requestRender` and the
|
||||
* `postUpdate` tick `changed` is measured on; `widget`, the Viewer or
|
||||
* CesiumWidget, gives the entity tracking `follow` runs on (without it the
|
||||
* camera cannot follow).
|
||||
* widget?: object, capabilities?: ReadonlySet<string>}} options `scene`
|
||||
* gives `requestRender` and the `postUpdate` tick `changed` is measured
|
||||
* on; `widget`, the Viewer or CesiumWidget, gives the entity tracking
|
||||
* `follow` runs on (without it the camera cannot follow);
|
||||
* `capabilities`, the renderer's, gates the optional members (a camera
|
||||
* with none given has them all).
|
||||
* @returns {{port: import('../contract/camera').CameraPort, dispose: () => void}}
|
||||
*/
|
||||
export function createCesiumCamera({ scene, camera, report, widget }) {
|
||||
export function createCesiumCamera({
|
||||
scene,
|
||||
camera,
|
||||
report,
|
||||
widget,
|
||||
capabilities,
|
||||
}) {
|
||||
const removers = [];
|
||||
// Camera events: Cesium's own moveStart and moveEnd (500 ms after the
|
||||
// last change, never while following), and `changed` measured per
|
||||
@@ -379,6 +387,11 @@ export function createCesiumCamera({ scene, camera, report, widget }) {
|
||||
};
|
||||
},
|
||||
};
|
||||
// Cesium keeps the eye in `camera.transform`: a tracked entity's frame, a
|
||||
// `lookAt` target's, or the identity.
|
||||
if (!capabilities || capabilities.has('followFrame'))
|
||||
cameraPort.followFrame = () =>
|
||||
Float64Array.from(Cesium.Matrix4.toArray(camera.transform));
|
||||
|
||||
return {
|
||||
port: cameraPort,
|
||||
|
||||
@@ -254,3 +254,13 @@ test('setFov holds the vertical angle across resizes, and waits for a first one'
|
||||
assert.throws(() => port.setFov({ vertical: Math.PI }), RangeError);
|
||||
assert.throws(() => port.setFov({ vertical: NaN }), RangeError);
|
||||
});
|
||||
|
||||
test('followFrame is there only with its capability', () => {
|
||||
const { scene, camera } = headlessCamera();
|
||||
scene.postUpdate = new Cesium.Event();
|
||||
const make = (capabilities) =>
|
||||
createCesiumCamera({ scene, camera, report: () => {}, capabilities }).port;
|
||||
assert.equal(make(new Set()).followFrame, undefined);
|
||||
assert.equal(typeof make(new Set(['followFrame'])).followFrame, 'function');
|
||||
assert.equal(typeof make(undefined).followFrame, 'function');
|
||||
});
|
||||
@@ -26,6 +26,7 @@ export const CESIUM_CHECKS = new Set([
|
||||
'camera.controls.holds',
|
||||
'camera.controls.settings',
|
||||
'camera.follow',
|
||||
'camera.followFrame',
|
||||
'camera.trace.flyTo with a duration of 0 completes inside the call',
|
||||
'camera.trace.flyTo where the camera already is completes inside the call',
|
||||
'camera.viewRectangle',
|
||||
|
||||
@@ -60,6 +60,7 @@ const GLOBE_CAPABILITIES = [
|
||||
export function cesiumCapabilities(scene, only) {
|
||||
const all = [
|
||||
'models',
|
||||
'followFrame',
|
||||
...GPU_ICON_CAPABILITIES,
|
||||
'styles',
|
||||
'bloom',
|
||||
@@ -305,7 +306,13 @@ export function createCesiumPorts(widget, { capabilities, credentials = {} }) {
|
||||
});
|
||||
const { port: draw, sets, tilesets } = drawPart;
|
||||
|
||||
const cameraPart = createCesiumCamera({ scene, camera, report, widget });
|
||||
const cameraPart = createCesiumCamera({
|
||||
scene,
|
||||
camera,
|
||||
report,
|
||||
widget,
|
||||
capabilities,
|
||||
});
|
||||
const cameraPort = cameraPart.port;
|
||||
const effectsPart = createCesiumEffects(scene, {
|
||||
capabilities,
|
||||
|
||||
@@ -10,6 +10,7 @@ import { updateCameraChanged } from './internals.js';
|
||||
|
||||
test('capabilities follow what the scene supports', () => {
|
||||
const effects = [
|
||||
'followFrame',
|
||||
'columns',
|
||||
'motionSegments',
|
||||
'courseGlide',
|
||||
|
||||
Reference in new issue
Block a user