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 不仅对希望提供标准场景导航方式的应用程序非常有用,也可作为开发和故障排除过程中的临时措施,因为它允许通过熟悉的键盘和鼠标导航在运行时检查场景。
键位绑定如下:
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 [default: Qt.LeftButton]
指定控制器支持的按钮。
另请参阅 DragHandler 和MultiPointHandler 。
backSpeed : real [default: 5]
指定按下“返回”键时的导航速度。
controlledObject : QtQuick3D::Node
指定要控制的节点。这通常是一个 Camera 对象。
downSpeed : real [default: 5]
指定按下向下键时的导航速度。
forwardSpeed : real [default: 5]
指定按下“前进”键时的导航速度。
inputsNeedProcessing : bool [read-only]
当有需要处理的输入时,该属性为真。
keysEnabled : bool [default: true]
启用关键控件。
leftSpeed : real [default: 5]
指定按下左键时的导航速度。
mouseEnabled : bool [default: true]
启用鼠标控制。
rightSpeed : real [default: 5]
指定按下右键时的导航速度。
shiftSpeed : real [default: 3]
指定按下 Shift 键时生效的速度倍数。
speed : real [default: 1]
指定导航速度。
upSpeed : real [default: 5]
指定按下向上键时的导航速度。
xInvert : bool [default: false]
反转x轴的控制方式。
xSpeed : real [default: 0.1]
指定沿 X 轴移动鼠标时的导航速度。
yInvert : bool [default: true]
反转 y 轴控制。
ySpeed : real [default: 0.1]
指定沿 Y 轴移动鼠标时的导航速度。
© 2026 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.