Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions meshroom/ui/qml/Viewer3D/DefaultCameraController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ Entity {
property real translateSpeed: 75.0
property real tiltSpeed: 500.0
property real panSpeed: 500.0
readonly property bool moving: actionLMB.active
readonly property bool panning: (keyboardHandler._pressed && actionLMB.active && actionShift.active) || actionMMB.active
readonly property bool zooming: keyboardHandler._pressed && actionRMB.active && actionAlt.active
property alias focus: keyboardHandler.focus
readonly property bool pickingActive: actionControl.active && keyboardHandler._pressed
property alias rotationSpeed: trackball.rotationSpeed
Expand All @@ -25,6 +22,10 @@ Entity {

property bool loseMouseFocus: false // Must be changed by other entities when they want to take mouse focus

property bool moving: false
property bool panning: false
property bool zooming: false

readonly property alias pressed: mouseHandler._pressed
signal mousePressed(var mouse)
signal mouseReleased(var mouse, var moved)
Expand Down Expand Up @@ -68,15 +69,20 @@ Entity {
const dt = 0.02
var d

if (panning) { // Translate
root.moving = mouse.buttons & Qt.LeftButton
root.panning = (mouse.buttons & Qt.MiddleButton)
var panningAlt = actionShift.active && (mouse.buttons & Qt.LeftButton)
root.zooming = actionAlt.active && (mouse.buttons & Qt.RightButton)

if (panning || panningAlt) { // Translate
d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03
var tx = axisMX.value * root.translateSpeed * d
var ty = axisMY.value * root.translateSpeed * d
mouseHandler.hasMoved = true
root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt))
return
}
if (moving){ // Trackball rotation
if (moving) { // Trackball rotation
trackball.rotate(mouseHandler.lastPosition, mouseHandler.currentPosition, dt)
mouseHandler.lastPosition = mouseHandler.currentPosition
mouseHandler.hasMoved = true
Expand Down
Loading