# three-vive-controller

> Use the vive controller in ThreeJS

Latest version **1.4.1** (published 2017-01-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install three-vive-controller
pnpm add three-vive-controller
yarn add three-vive-controller
bun add three-vive-controller
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.1 |
| Published | 2017-01-08 |
| First published | 2016-06-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Michael Feldstein |
| Maintainers | msfeldstein |

## Links

- npm: https://www.npmjs.com/package/three-vive-controller
- Repository: https://github.com/msfeldstein/three-vive-controller
- Homepage: https://github.com/msfeldstein/three-vive-controller#readme
- Issues: https://github.com/msfeldstein/three-vive-controller/issues
- npm.io page: https://npm.io/package/three-vive-controller

## Dependencies (5)

- [budo](https://npm.io/package/budo.md) ^9.3.0
- [three](https://npm.io/package/three.md) ^0.82.1
- [browserify](https://npm.io/package/browserify.md) ^13.1.1
- [eventemitter3](https://npm.io/package/eventemitter3.md) ^1.2.0
- [three-obj-loader](https://npm.io/package/three-obj-loader.md) ^1.0.2

## Recent versions

- 1.4.1 (latest) — 2017-01-08
- 1.4.0 — 2016-12-12
- 1.3.0 — 2016-12-01
- 1.2.0 — 2016-11-30
- 1.1.0 — 2016-11-18
- 1.0.2 — 2016-06-26
- 1.0.0 — 2016-06-25

## README

# three-vive-controller

Use the Vive's controller in ThreeJS webVR applications.  It will render a nice model for it, and give it an event based API.

Try the [demo](https://msfeldstein.github.io/three-vive-controller/demo/).  Since this is a module only for the controller, it doesn't use the HMD, it just shows the controller interacting in the browser window.

### Installation

`npm install --save three-vive-controller`

### Usage

Set up a ThreeJS scene using the THREE.VRControls addon, then create controllers using the ids 0 and 1.

```
var ViveController = require('three-vive-controller')(THREE)
var controls = new THREE.VRControls(camera)
var controller = new ViveController(0, controls)
scene.add(controller)

// Listen to events on the controller emitter
controller.on(controller.TriggerClicked, () => {
  console.log("Trigger Clicked")
})

controller.on(controller.TriggerUnclicked, () => {
  console.log("Trigger Unclicked")
})
```

### Available events
```
TriggerClicked -> ()
TriggerUnclicked -> ()
MenuPressed -> ()
MenuUnpressed -> ()
PadTouched -> ()
PadUntouched -> ()
PadPressed -> ()
PadUnpressed -> ()
PadDragged -> (dx, dy) // Normalized touch deltas
Connected -> () // Called when the controller first becomes available
```

### Available properties
```
// Current touch positions, normalized from -1 to 1.  Is null if the pad is not currently being touched.
controller.padX
controller.padY
// Boolean if the pad is currently being touched
controller.padTouched
// Boolean if the trigger is currently pressed
controller.triggerClicked
// Is there a vive controller available for this controller. Disconnection doesn't seem to work yet, so if it turns off, it still shows as connected.
controller.connected
// How far the trigger is pulled from 0-1
controller.triggerLevel
```

See demo for a full example, which can be run with `npm start`

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