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
@@ -867,6 +867,15 @@ export function createStubCamera({
|
||||
near,
|
||||
}),
|
||||
holds: () => [...holds.values()],
|
||||
/** The frame the eye is in, column-major from it to the world. */
|
||||
eyeFrame: () =>
|
||||
Float64Array.of(
|
||||
...[frame.x, frame.y, frame.z].flatMap((a) => [a.x, a.y, a.z, 0]),
|
||||
frame.origin.x,
|
||||
frame.origin.y,
|
||||
frame.origin.z,
|
||||
1,
|
||||
),
|
||||
setViewRectangle(fn) {
|
||||
port.viewRectangle = fn;
|
||||
},
|
||||
|
||||
@@ -174,6 +174,8 @@ export function createStubRenderer(options = {}) {
|
||||
drawnPosition: (ref, aheadMs) => drawnPosition(ref, aheadMs),
|
||||
});
|
||||
camera.setViewRectangle(viewRectangle);
|
||||
if (capabilities.has('followFrame'))
|
||||
camera.port.followFrame = camera.eyeFrame;
|
||||
camera.port.setView({
|
||||
destination: { lon: -97.7431, lat: 30.2672, height: 15000000 },
|
||||
});
|
||||
|
||||
@@ -11,11 +11,8 @@ import {
|
||||
PI_OVER_TWO,
|
||||
TWO_PI,
|
||||
acosClamped,
|
||||
clamp,
|
||||
equalsEpsilon,
|
||||
negate,
|
||||
rotate,
|
||||
scale,
|
||||
vec,
|
||||
zeroToTwoPi,
|
||||
} from '../../geo/index.js';
|
||||
@@ -63,16 +60,4 @@ export function rollOf(direction, up, right) {
|
||||
return zeroToTwoPi(Math.atan2(-right.z, up.z) + TWO_PI);
|
||||
}
|
||||
|
||||
/** The local offset a heading, pitch and range puts the eye at. */
|
||||
export function offsetFromHeadingPitchRange(heading, pitch, range) {
|
||||
const p = clamp(pitch, -PI_OVER_TWO, PI_OVER_TWO);
|
||||
const h = zeroToTwoPi(heading) - PI_OVER_TWO;
|
||||
const offset = rotate(
|
||||
rotate(vec(1, 0, 0), vec(0, 1, 0), -p),
|
||||
vec(0, 0, 1),
|
||||
-h,
|
||||
);
|
||||
return scale(negate(offset), range);
|
||||
}
|
||||
|
||||
export { EPSILON10 };
|
||||
Reference in new issue
Block a user