fix(webclient): fix XR panel snapping to face away from user when dragged to the side#629
fix(webclient): fix XR panel snapping to face away from user when dragged to the side#629yanziz-nvidia wants to merge 1 commit into
Conversation
…gged to the side Two bugs in the face-camera rotation logic in CloudXRUI: 1. Missing angle wrapping before damp(): eulerHelper.y lives in [-π, +π]. When the panel is near the side of the scene the target angle can flip from +π-ε to -π+ε — geometrically ~0° but numerically ~2π. damp() is a plain lerp so it interpolated the full ~2π the wrong way, spinning the panel to face backward. Fix wraps the diff to [-π, π] before calling damp() so it always takes the shortest rotation path. 2. 3D quaternion for a yaw-only problem: setFromUnitVectors(zAxis, dir3D) computed the shortest-path 3D rotation including height offset, so the extracted Euler Y was not the correct horizontal yaw when camera and panel heights differed. Replaced with Math.atan2(dx, dz) on the XZ plane which gives correct horizontal yaw directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthrough
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
gareth-morgan-nv
left a comment
There was a problem hiding this comment.
LGTM. Maybe add a test?
Closes #546
Summary
damp()call had no angle wrapping. The target yaw fromsetFromQuaternionlives in[-π, +π], so when the camera crosses near the side/behind the panel the target jumps from+π-εto-π+ε— geometrically ~0° but numerically ~2π.damp()is a plainlerpso it took the ~2π wrong-way path, spinning the panel to face backward. Fix normalizes thediffto[-π, π]before callingdamp().setFromUnitVectors(zAxis, dir3D)+setFromQuaternion('YXZ')to get the horizontal yaw. Becausedir3Dincluded the camera's height offset, the 3D shortest-path quaternion's Euler Y was not the true horizontal yaw. Replaced withMath.atan2(dx, dz)on the XZ plane — simpler and correct.Test plan
🤖 Generated with Claude Code