# aframe-controller-cursor-component

> Cursor component for tracked controls in A-Frame.

Latest version **0.2.7** (published 2017-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install aframe-controller-cursor-component
pnpm add aframe-controller-cursor-component
yarn add aframe-controller-cursor-component
bun add aframe-controller-cursor-component
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.7 |
| Published | 2017-06-05 |
| First published | 2017-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bryik |
| Maintainers | bryik, ngokevin |
| Keywords | aframe, aframe-component, aframe-vr, vr, mozvr, webvr |

## Links

- npm: https://www.npmjs.com/package/aframe-controller-cursor-component
- Repository: https://github.com/bryik/aframe-controller-cursor-component
- Homepage: https://github.com/aframe-controller-cursor-component#readme
- Issues: https://github.com/aframe-controller-cursor-component/issues
- npm.io page: https://npm.io/package/aframe-controller-cursor-component

## Recent versions

- 0.2.7 (latest) — 2017-06-05
- 0.2.6 — 2017-04-03
- 0.2.5 — 2017-04-03
- 0.2.4 — 2017-04-03
- 0.2.3 — 2017-03-16
- 0.2.2 — 2017-03-08
- 0.2.1 — 2017-03-07
- 0.2.0 — 2017-03-03

## README

## aframe-controller-cursor-component

[A-Frame](https://aframe.io) component for adding a laser-style cursor to a
tracked controls (e.g., HTC Vive, Oculus Touch).

<p align="center">
  <img src="http://i.imgur.com/QCgZWd7.gif"/>
</p>

### API

| Property   | Description                                                                             | Default Value |
|------------|-----------------------------------------------------------------------------------------|---------------|
| color      | Laser color.                                                                            | #74BEC1       |
| downEvents | Event to detect button down, comma-separated. For example, use `trackpaddown` for 3DoF. | triggerdown   |
| upEvents   | Event to detect button up, comma-separated. For example, use `trackpadup` for 3DoF.     | triggerup     |
| radius     | Laser radius (top and bottom).                                                          | 0.001         |

### Usage

Attach the component to an entity alongside a tracked controls entity.

```html
<a-entity hand-controls="right" controller-cursor></a-entity>
```

The controller cursor component is based on A-Frame's [built-in
cursor](https://aframe.io/docs/master/components/cursor.html), many of the
events and states are shared.

`mouseup` and `mousedown` are mapped to the trigger. Pulling the trigger will
emit the same events as clicking.

### Notes

To avoid intersecting with the laser, the raycaster's `near` property is set to
0.03. Thus, you may see odd results when the top of the controller is held
extremely close to the entity you wish to intersect.

This component was built for the Vive controller model. If you are using a
different model, you may need to modify the raycaster and position of the
laser. In the future, this should be made more easily configurable.

#### Browser

Install and use by directly including the [browser files](dist):

```html
<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
  <script src="https://unpkg.com/aframe-controller-cursor-component@0.2.7/dist/aframe-controller-cursor-component.min.js"></script>
</head>

<body>
  <a-scene>
    <a-entity vive-controls="hand: left"></a-entity>
    <a-entity vive-controls="hand: right" controller-cursor></a-entity>
  </a-scene>
</body>
```

#### npm

Install via npm:

```bash
npm install aframe-controller-cursor-component
```

Then register and use.

```js
require('aframe');
require('aframe-controller-cursor-component');
```

---
_Source: https://npm.io/package/aframe-controller-cursor-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
