Skip to content

Commit b49f32c

Browse files
authored
Bugfix: upside down detection with custom axis (#118)
1 parent 25afca1 commit b49f32c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/lib.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,13 @@ fn pan_orbit_camera(
623623

624624
// 2 - Process input into target yaw/pitch, or focus, radius
625625

626+
// Only check for upside down when orbiting started or ended this frame,
627+
// so we don't reverse the yaw direction while the user is still dragging
626628
if orbit_button_changed {
627-
// Only check for upside down when orbiting started or ended this frame,
628-
// so we don't reverse the yaw direction while the user is still dragging
629-
let wrapped_pitch = (pan_orbit.target_pitch % TAU).abs();
629+
// To account for swapped or different axis to identify whether the world is upside down.
630+
let pitch_axis_rotation = Vec3::X.dot(pan_orbit.axis[0]);
631+
let target_pitch = pan_orbit.target_pitch + pitch_axis_rotation;
632+
let wrapped_pitch = (target_pitch % TAU).abs();
630633
pan_orbit.is_upside_down = wrapped_pitch > TAU / 4.0 && wrapped_pitch < 3.0 * TAU / 4.0;
631634
}
632635

0 commit comments

Comments
 (0)