# Controls
Extensible movement/rotation/hotkey controls, with support for a variety of input devices.
- **movement-controls**: Collection of locomotion controls, which can switch between input devices as they become active. Automatically includes the following components:
+ **keyboard-controls**: WASD + arrow controls for movement, and more.
+ **touch-controls**: Touch screen (or Cardboard button) to move forward.
+ **gamepad-controls**: Gamepad-based rotation and movement.
+ **trackpad-controls**: Trackpad-based movement.
- **checkpoint-controls**: Move to checkpoints created with the `checkpoint` component. *Not included by default with `movement-controls`, but may be added as shown in examples.*
## Usage
The `movement-controls` component requires the use of a camera "rig" wrapping the camera element. The rig may be assigned any position within your scene, and should be placed at ground level. The camera should only have height offset (used for devices without positional tracking) such as `0 1.6 0`.
Basic movement:
```html
<a-entity id="rig"
movement-controls
position="25 0 25">
<a-entity camera
position="0 1.6 0"
look-controls="pointerLockEnabled: true"></a-entity>
</a-entity>
```
With checkpoints, and other input methods disabled:
```html
<a-entity id="rig"
movement-controls="controls: checkpoint"
checkpoint-controls="mode: animate">
<a-entity camera
position="0 1.6 0"
look-controls="pointerLockEnabled: true">
</a-entity>
</a-entity>
```
With navigation mesh:
```html
<a-entity id="rig" movement-controls="constrainToNavMesh: true">
<a-entity camera
position="0 1.6 0"
look-controls="pointerLockEnabled: true">
</a-entity>
</a-entity>
```
With physics-based movement.
> **WARNING** *Using physics for movement is unstable and performs poorly. When preventing players from passing through obstacles, use a navigation mesh instead whenever possible.*
```html
<a-entity id="rig" movement-controls kinematic-body>
<a-entity camera
position="0 1.6 0"
look-controls="pointerLockEnabled: true"></a-entity>
</a-entity>
```
## Options
| Property | Default | Description |
|--------------------|---------|-------------|
| enabled | true | Enables/disables movement controls. |
| controls | gamepad, keyboard, touch | Ordered list of controls to be injected. |
| speed | 0.3 | Movement speed. |
| fly | false | Whether vertical movement is enabled. |
| constrainToNavMesh | false | Whether to use navigation system to clamp movement. |
| camera | [camera] | Camera element used for heading of the camera rig. |
## Customizing movement-controls
To implement your custom controls, define a component and override one or more methods:
| Method | Type | Required |
|----------------------------------------------------|----------|----------|
| isVelocityActive() : boolean | Movement | Yes |
| getVelocityDelta(deltaMS : number) : THREE.Vector3 | Movement | No |
| getPositionDelta(deltaMS : number) : THREE.Vector3 | Movement | No |
Example:
```js
AFRAME.registerComponent('custom-controls', {
isVelocityActive: function () {
return Math.random() < 0.25;
},
getPositionDelta: function () {
return new THREE.Vector3(1, 0, 0);
}
});
```
## Other Controls
I've written standalone components for several other control components. These do not work with `movement-controls`, and are older and less well maintained.
- [gamepad-controls](https://github.com/donmccurdy/aframe-gamepad-controls): A more advanced standalone gamepad controller than the version in this package.
- [keyboard-controls](https://github.com/donmccurdy/aframe-keyboard-controls): A more advanced standalone keyboard controller than the version in this package.
## Mobile + Desktop Input Devices
Connect input devices from your desktop to your mobile phone with WebRTC, using [ProxyControls.js](https://proxy-controls.donmccurdy.com).
## Mobile Gamepad Support
See my [separate overview of gamepad support](https://gist.github.com/donmccurdy/cf336a8b88ba0f10991d4aab936cc28b).
没有合适的资源?快使用搜索试试~ 我知道了~
aframe-extras:A-Frame VR的附加组件和帮助器
共125个文件
js:64个
md:12个
html:10个
需积分: 24 2 下载量 136 浏览量
2021-04-29
11:28:41
上传
评论
收藏 3.3MB ZIP 举报
温馨提示
A-Frame Extras A-Frame VR的附加组件和帮助器。 包括控件,模型加载器,寻路等组件: src ├── controls/ ( ) │ ├── movement-controls.js │ ├── checkpoint-controls.js │ ├── gamepad-controls.js │ ├── keyboard-controls.js │ ├── mouse-controls.js │ ├── touch-controls.js │ └── trackpad-controls.js ├── loaders/ ( ) │ ├── animation-mixer.js │ ├── collada-model-legacy.js │ ├── fbx-model.js │ ├── gltf-model-legac
资源详情
资源评论
资源推荐
收起资源包目录
aframe-extras:A-Frame VR的附加组件和帮助器 (125个子文件)
skeleton.css 11KB
normalize.css 8KB
scythian.fbx 81KB
.gitignore 106B
Castle.glb 609KB
Castle-navmesh.glb 19KB
rupee.glb 8KB
index.html 4KB
index.html 4KB
index.html 3KB
index.html 3KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 2KB
index.html 1KB
index.html 1KB
negx.jpg 527KB
posx.jpg 435KB
negz.jpg 428KB
posy.jpg 427KB
posz.jpg 379KB
negy.jpg 98KB
aframe-extras.js 339KB
aframe-extras.loaders.js 190KB
aframe-extras.min.js 167KB
FBXLoader.js 95KB
ColladaLoader.js 87KB
aframe-extras.loaders.min.js 79KB
flamingo.js 78KB
aframe-extras.controls.js 59KB
aframe-extras.primitives.js 51KB
aframe-extras.primitives.min.js 38KB
hex-grid.min.js 33KB
keyboard.polyfill.js 28KB
aframe-extras.controls.min.js 27KB
aframe-extras.misc.js 23KB
aframe-extras.pathfinding.js 17KB
aframe-extras.pathfinding.min.js 13KB
aframe-extras.misc.min.js 11KB
gamepad-controls.js 10KB
kinematic-body.js 7KB
movement-controls.js 6KB
sphere-collider.js 5KB
keyboard-controls.js 5KB
trackpad-controls.js 5KB
animation-mixer.js 4KB
sphere-collider.js 4KB
cube-env-map.js 4KB
sphere-collider.test.js 3KB
nav-agent.js 3KB
grab.js 3KB
publish.js 3KB
a-ocean.js 3KB
grab.js 3KB
keyboard-controls.test.js 2KB
sphere-collider.min.js 2KB
checkpoint-controls.js 2KB
system.js 2KB
dist.js 2KB
grab.min.js 2KB
fetch-script.js 2KB
jump-ability.js 2KB
touch-controls.js 2KB
a-tube.js 2KB
helpers.js 2KB
object-model.js 1KB
collada-model-legacy.js 1KB
gltf-model-legacy.js 1KB
a-hexgrid.js 1KB
default-hex-grid.js 1KB
nav-mesh.js 1KB
checkpoint.js 899B
fbx-model.js 847B
__init.test.js 718B
normal-material.js 687B
karma.conf.js 521B
a-grid.js 494B
mesh-smooth.js 406B
GamepadButton.js 290B
index.js 213B
GamepadButtonEvent.js 199B
index.js 190B
index.js 148B
index.js 135B
index.js 88B
index.js 68B
.jshintrc 549B
.jshintrc 388B
wolf.json 276KB
package-lock.json 270KB
scene-animation.json 115KB
scythian.json 21KB
hexmap.json 7KB
package.json 2KB
registry.json 840B
LICENSE 1KB
hex-grid.min.js.map 127KB
README.md 4KB
README.md 4KB
共 125 条
- 1
- 2
火锅与理想
- 粉丝: 31
- 资源: 4569
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0