Skip to content
Permalink
Browse files

[3d] Allow Shift+up/down/left/right keys to rotate/tilt camera

Just like user can drag map with mouse or move it with up/down/left/right keys,
for consistency with Shift+drag we have now also support for arrow keys.
  • Loading branch information
wonder-sk committed Dec 30, 2017
1 parent 63c1925 commit 9f3b3e50d587720f1625a30fbe78b7369a4c560e
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/3d/qgscameracontroller.cpp
@@ -240,7 +240,7 @@ void QgsCameraController::frameTriggered( float dt )
float tx = mTxAxis->value() * dt * mCameraData.dist * 1.5;
float ty = -mTyAxis->value() * dt * mCameraData.dist * 1.5;

if ( tx || ty )
if ( !mShiftAction->isActive() && ( tx || ty ) )
{
// moving with keyboard - take into account yaw of camera
float t = sqrt( tx * tx + ty * ty );
@@ -253,9 +253,16 @@ void QgsCameraController::frameTriggered( float dt )

if ( ( mLeftMouseButtonAction->isActive() && mShiftAction->isActive() ) || mMiddleMouseButtonAction->isActive() )
{
// rotate/tilt using mouse
mCameraData.pitch += dy;
mCameraData.yaw -= dx / 2;
}
else if ( mShiftAction->isActive() && ( mTxAxis->value() || mTyAxis->value() ) )
{
// rotate/tilt using keyboard
mCameraData.pitch -= mTyAxis->value(); // down key = moving camera toward terrain
mCameraData.yaw -= mTxAxis->value(); // right key = moving camera clockwise
}
else if ( mLeftMouseButtonAction->isActive() && !mShiftAction->isActive() )
{
// translation works as if one grabbed a point on the plane and dragged it

0 comments on commit 9f3b3e5

Please sign in to comment.
You can’t perform that action at this time.