WasdController QML Type
用按键和鼠标控制节点的位置和方向。更多
Import Statement: | import QtQuick3D.Helpers |
Inherits: |
属性
- acceptedButtons : enumeration
- backSpeed : real
- controlledObject : QtQuick3D::Node
- downSpeed : real
- forwardSpeed : real
- inputsNeedProcessing : bool
- keysEnabled : bool
- leftSpeed : real
- mouseEnabled : bool
- rightSpeed : real
- shiftSpeed : real
- speed : real
- upSpeed : real
- xInvert : bool
- xSpeed : real
- yInvert : bool
- ySpeed : real
详细说明
该辅助程序允许用户使用 W、A、S、D、方向键和鼠标控制一个节点。通常,受控节点是在controlledObject 属性中指定的相机。
在希望提供标准场景导航方式的应用程序中,添加 WasdController 非常有用;在开发和故障排除过程中,添加 WasdController 也是一项临时措施,因为它允许在运行时通过熟悉的键盘和鼠标导航来检查场景。
按键绑定如下
W
或 - 向前up
S
或 - 向后退down
A
或 - 向左飞left
D
或 - 向右移动right
R
或 - 向上移动page up
F
或 - 向下移动page down
shift
与其他按键一起使用 - 移动速度更快,取决于shiftSpeed
下面的代码段展示了如何添加 WasdController 对象。默认情况下,按键和鼠标导航都处于激活状态,因此大多数情况下无需进一步配置:
View3D { anchors.fill: parent camera: camera PerspectiveCamera { id: camera position: Qt.vector3d(0, 0, 600) } ... } WasdController { controlledObject: camera }
属性文档
acceptedButtons : enumeration |
指定控制器接受的按钮。
另请参阅 DragHandler 和MultiPointHandler 。
backSpeed : real |
指定按下后退键时的导航速度。
controlledObject : QtQuick3D::Node |
指定要控制的节点。这通常是一个摄像机对象。
downSpeed : real |
指定按向下键时的导航速度。
forwardSpeed : real |
指定按下前进键时的导航速度。
inputsNeedProcessing : bool |
当有输入需要处理时,该属性为 true。
keysEnabled : bool |
启用按键控制。
leftSpeed : real |
指定按下左键时的导航速度。
mouseEnabled : bool |
启用鼠标控制。
rightSpeed : real |
指定按下右键时的导航速度。
shiftSpeed : real |
指定按下 shift 键时的速度倍增器。
speed : real |
指定导航速度。
upSpeed : real |
指定按向上键时的导航速度。
xInvert : bool |
反转 X 轴控制。
xSpeed : real |
指定鼠标沿 X 轴移动时的导航速度。
yInvert : bool |
反转 Y 轴控制。
ySpeed : real |
指定鼠标沿 Y 轴移动时的导航速度。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.