Conversation
mvaligursky
approved these changes
Feb 27, 2026
There was a problem hiding this comment.
Pull request overview
This PR addresses camera jitter/artifacts near vertical orientations by stabilizing angle extraction at the poles and by generating a non-degenerate orbit path when the camera offset is (nearly) Y-aligned.
Changes:
- Update
vecToAnglesto clampasininput and avoid unstable yaw near the poles by falling back to0when horizontal magnitude is tiny. - Rework
createRotateTrackto build an orbit from horizontal/vertical decomposition (instead of rotating the full offset vector), with a minimum orbit radius for near-vertical setups.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/core/math.ts |
Adds clamping and a pole-case fallback in vecToAngles to prevent yaw instability. |
src/animation/create-rotate-track.ts |
Replaces matrix-rotation orbit generation with an angle/radius approach and introduces a minimum orbit radius for near-vertical offsets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
createRotateTrackwhen the camera-to-target offset is aligned with the Y axis (rotating a Y-aligned vector around Y is a no-op, producing identical keyframes that cause spline ringing)vecToAnglesnear the poles where near-zero horizontal components causeatan2to produce wildly oscillating yaw valuesDetails
createRotateTrack: Decompose the camera offset into vertical and horizontal components instead of rotating the full 3D vector with a matrix. When the horizontal radius is near zero (looking straight up/down), a minimum orbit radius of 30% of the total distance is used so the camera actually traces a visible circle. For non-degenerate cases the result is mathematically identical.vecToAngles: When the squared horizontal length is below1e-8, yaw defaults to 0 instead of relying onatan2with near-zero arguments. Also clamps theasininput to[-1, 1]to guard against floating-point edge cases.Test plan