WasdController QML Type

Control node position and orientation with keys and mouse. More...

Import Statement: import QtQuick3D.Helpers 1.0
Inherits:

Item

Properties

Detailed Description

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 forward
  • S or down - go backward
  • A or left - strafe left
  • D or right - strafe right
  • R or page up - move up
  • F or page down - move down
  • shift 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
}

Property Documentation

acceptedButtons : enumeration

Specifies the buttons accepted by the controller.

See also DragHandler and MultiPointHandler.

backSpeed : real

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

Specifies the speed of navigation when the down key is pressed.

forwardSpeed : real

Specifies the speed of navigation when the forward key is pressed.

[read-only] inputsNeedProcessing : bool

This property is true when there are inputs needing processing.

keysEnabled : bool

Enables key controls. The default value is true.

leftSpeed : real

Specifies the speed of navigation when the left key is pressed.

mouseEnabled : bool

Enables mouse controls. The default value is true.

rightSpeed : real

Specifies the speed of navigation when the right key is pressed.

shiftSpeed : real

Specifies the speed multiplier that is active when the shift key is pressed.

speed : real

Specifies the speed of navigation.

upSpeed : real

Specifies the speed of navigation when the up key is pressed.

xInvert : bool

Inverts the x-axis controls. The default value is false.

xSpeed : real

Specifies the speed of navigation when the mouse is moved along the X axis.

yInvert : bool

Inverts the y-axis controls. The default value is true.

ySpeed : real

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.0/qml-qtquick3d-helpers-wasdcontroller.html