From 9038417164dbfb1809f2359a74d849caac21e50c Mon Sep 17 00:00:00 2001 From: Federico Ferri Date: Thu, 20 Feb 2020 14:27:54 +0100 Subject: [PATCH 1/2] fix a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f0f5fe..7c48ba0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # SOrbitCameraController -A orbir camera controller for Qt3D(QML) +A orbit camera controller for Qt3D(QML) The Qt3D.Extras model provide a camera controller name with OrbitCameraController. But you can not specity which button of mouse for rotation or translation. So I make one. The default action is: From 13963105258f2e9a226655ee4cb99cea86a7fb7b Mon Sep 17 00:00:00 2001 From: Federico Ferri Date: Thu, 20 Feb 2020 14:29:53 +0100 Subject: [PATCH 2/2] use 'enabled' prop to enable/disable contrtoller --- SOrbitCameraController.qml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SOrbitCameraController.qml b/SOrbitCameraController.qml index 62fa45c..fb35156 100644 --- a/SOrbitCameraController.qml +++ b/SOrbitCameraController.qml @@ -2,7 +2,7 @@ import Qt3D.Core 2.0 import Qt3D.Render 2.0 import Qt3D.Input 2.0 -Entity{ +Entity { id: root property Camera camera; property real dt: 0.001 @@ -30,8 +30,10 @@ Entity{ lastPos = Qt.point(mouse.x, mouse.y); } onPositionChanged: { + if(!root.enabled) return; + // You can change the button as you like for rotation or translation - if (mouse.buttons === 1){ // Left button for rotation + if (mouse.buttons === 1) { // Left button for rotation pan = -(mouse.x - lastPos.x) * dt * lookSpeed; tilt = (mouse.y - lastPos.y) * dt * lookSpeed; } else if (mouse.buttons === 2) { // Right button for translate @@ -46,6 +48,8 @@ Entity{ lastPos = Qt.point(mouse.x, mouse.y) } onWheel: { + if(!root.enabled) return; + zoom(wheel.angleDelta.y * dt * linearSpeed) }