Control node position and orientation with keys and mouse. More...
| Import Statement: | import QtQuick3D.Helpers
|
| Inherits: |
This helper allows the user to control a node using W, A, S, D, the arrow keys, and the mouse. Usually the controlled node is a Camera, specified in the controlledObject property.
Adding a WasdController can be highly useful both in applications that wish to provide a standard way of navigating the scene, and also as a temporary measure during development and troubleshooting, as it allows inspecting the scene at run time via familiar keyboard and mouse navigation.
The key bindings are as follows:
W or up - go forwardS or down - go backwardA or left - strafe leftD or right - strafe rightR or page up - move upF or page down - move downshift together with other keys - move faster, depending on shiftSpeed
The following snippet shows how a WasdController object can be added. By default both key and mouse based navigation is active, so in most cases there is no further configuration needed:
View3D {
anchors.fill: parent
camera: camera
PerspectiveCamera {
id: camera
position: Qt.vector3d(0, 0, 600)
}
...
}
WasdController {
controlledObject: camera
} acceptedButtons : enumeration [default: Qt.LeftButton]
Specifies the buttons accepted by the controller.
See also DragHandler and MultiPointHandler.
backSpeed : real [default: 5]
Specifies the speed of navigation when the back key is pressed.
controlledObject : QtQuick3D::Node
Specifies the node to control. This is typically a Camera object.
downSpeed : real [default: 5]
Specifies the speed of navigation when the down key is pressed.
forwardSpeed : real [default: 5]
Specifies the speed of navigation when the forward key is pressed.
inputsNeedProcessing : bool [read-only]
This property is true when there are inputs needing processing.
keysEnabled : bool [default: true]
Enables key controls.
leftSpeed : real [default: 5]
Specifies the speed of navigation when the left key is pressed.
mouseEnabled : bool [default: true]
Enables mouse controls.
rightSpeed : real [default: 5]
Specifies the speed of navigation when the right key is pressed.
shiftSpeed : real [default: 3]
Specifies the speed multiplier that is active when the shift key is pressed.
speed : real [default: 1]
Specifies the speed of navigation.
upSpeed : real [default: 5]
Specifies the speed of navigation when the up key is pressed.
xInvert : bool [default: false]
Inverts the x-axis controls.
xSpeed : real [default: 0.1]
Specifies the speed of navigation when the mouse is moved along the X axis.
yInvert : bool [default: true]
Inverts the y-axis controls.
ySpeed : real [default: 0.1]
Specifies the speed of navigation when the mouse is moved along the Y axis.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.9/qml-qtquick3d-helpers-wasdcontroller.html