mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix(director): turn heading and roll the short way for any authored angle
A single % made the seek delta negative when the target angle was more than 540° below the start, so 350° to -350° turned 340° through 180°. Uses the same double modulo as playback, and adds tests for exact ±180° endpoints and a near-antipodal seek.
This commit is contained in:
1 parent
b80ef27eb9
commit
cbefd529f9
3 files changed
+33
-2
No files matched your search
@@ -41,7 +41,9 @@ export function cameraAtProgress(fromCamera, toCamera, progress) {
|
||||
const lerp = (from, to) => Number(from) + (Number(to) - Number(from)) * eased;
|
||||
const lerpAngle = (from, to) => {
|
||||
const start = Number(from) || 0;
|
||||
const delta = ((Number(to) - start + 540) % 360) - 180;
|
||||
// Double modulo keeps the delta in [-180, 180) for any authored angles,
|
||||
// as sampleCameraMove does; a single % goes negative below -540.
|
||||
const delta = ((((Number(to) - start + 540) % 360) + 360) % 360) - 180;
|
||||
return start + delta * eased;
|
||||
};
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user