Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the 'enabled' property #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
8 changes: 6 additions & 2 deletions SOrbitCameraController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -46,6 +48,8 @@ Entity{
lastPos = Qt.point(mouse.x, mouse.y)
}
onWheel: {
if(!root.enabled) return;

zoom(wheel.angleDelta.y * dt * linearSpeed)
}

Expand Down