# 3drudder-js

> Javascript API for the 3dRudder controller

Latest version **2.0.7** (published 2019-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install 3drudder-js
pnpm add 3drudder-js
yarn add 3drudder-js
bun add 3drudder-js
```

## 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 | 2.0.7 |
| Published | 2019-12-16 |
| First published | 2018-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 2.5 MB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | mvivant |
| Maintainers | mvivant |
| Keywords | 3drudder, virtual, reality, foot-controller, vr |

## Links

- npm: https://www.npmjs.com/package/3drudder-js
- Repository: https://github.com/3DRudder/3dRudder-js
- Homepage: https://github.com/3DRudder/3dRudder-js#readme
- Issues: https://github.com/3DRudder/3dRudder-js/issues
- npm.io page: https://npm.io/package/3drudder-js

## Dependencies (5)

- [ws](https://npm.io/package/ws.md) ^3.3.1
- [bufferutil](https://npm.io/package/bufferutil.md) ^3.0.3
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [underscore](https://npm.io/package/underscore.md) ^1.8.3
- [utf-8-validate](https://npm.io/package/utf-8-validate.md) ^3.0.4

## Recent versions

- 2.0.7 (latest) — 2019-12-16
- 2.0.6 — 2019-12-16
- 2.0.5 — 2019-12-16
- 2.0.4 — 2019-11-28
- 2.0.3 — 2019-11-20
- 2.0.2 — 2019-01-09
- 2.0.1 — 2018-12-20
- 2.0.0 — 2018-11-15
- 1.0.4 — 2018-02-28
- 1.0.3 — 2018-02-16
- 1.0.2 — 2018-01-10
- 1.0.1 — 2018-01-09
- 1.0.0 — 2018-01-09

## README

![license](https://img.shields.io/github/license/mashape/apistatus.svg)
![language](https://img.shields.io/badge/Language-javascript-green.svg) 
![Node.js](https://img.shields.io/badge/Node.js-v12.13.1-green.svg)

|      Browsers     | HTTP/WS  | HTTPS/WSS  | File://  |
|:--------------:|:--------:|:--------:|:--------:|
|   Chrome   |    ✔     |    ✔     |    ✔     |
|   FireFox  |    ✔     |    ✔    |    ✔     |
|   Edge   |    ✔     |    ✔    |    :x:     |
|   Safari   |    ✔     |    ✔     |    :warning:     |

# 3dRudderjs v2.0.7

## Installation

* **Node** ```npm install 3drudder-js```

## API Documentation on [Wiki](https://github.com/3DRudder/3dRudder-js/wiki/API-doc)

# Usage

## Node.js

```javascript
var Sdk3dRudder = require('3drudder-js');
// default options {host: "127.51.100.82", port: 15698, schemeWs: "wss", autoReconnect: true, autoReconnectInterval: 500 /*ms*/};
var SDK = new Sdk3dRudder(); 
or
// with options
var opts = {host: "127.0.0.0", port: 1234, schemeWs: "ws", autoReconnect: false, autoReconnectInterval: 1000 /*1 sec*/};
var SDK = new Sdk3dRudder(opts);

SDK.init();
var rudder = SDK.controllers[0];
// if you want to custom the behaviour of 3dRudder
/* by default {roll2YawCompensation: 0.0, nonSymmetricalPitch: true,
    curves: {
        leftright: {deadzone: 0.15, xSat: 1.0, exp: 1.0},
        forwardbackward: {deadzone: 0.15, xSat: 1.0, exp: 1.0},					
        updown: {deadzone: 0.15, xSat: 1.0, exp: 1.0},
        rotation: {deadzone: 0.15, xSat: 1.0, exp: 1.0}
    }
}*/

controller.setAxesParam({
    roll2YawCompensation: 0.15,
    nonSymmetricalPitch: false,
    curves: {
        leftright: {deadzone: 0.15, xSat: 1.0, exp: 2.0},
        forwardbackward: {deadzone: 0.15, xSat: 1.0, exp: 2.0},					
        updown: {deadzone: 0.15, xSat: 1.0, exp: 2.0},
        rotation: {deadzone: 0.15, xSat: 1.0, exp: 1.0}
    }
});
var x = rudder.axis.leftright;
...
```

## Browser

Include in html page ```<script src="../dist/3dRudder-x.x.x.js"></script>```

```javascript
var SDK = new Sdk3dRudder();
SDK.init();
var rudder = SDK.controllers[0];
var x = rudder.axis.leftright;
...
```

## Use the discovery

```javascript
var SDK = new Sdk3dRudder({"schemeWs": "ws", "discovery": true});
SDK.startDiscovery();
SDK.on('discovery', function(urls) {    
    if (urls.length > 0) {
        for(i in urls) {
            console.log(`${decodeURIComponent(escape(urls[i].name))} [${urls[i].ip }]`);
        }
        // select your url
        SDK.init(urls[selected ID].ip);
    } else {
        console.log("servers not found");
    }    
});
```


## See examples

* [Axis](/examples/axis.html)  
* [WebGL (three.js)](/examples/webgl.html)
* [WebVR (A-Frame)](https://3drudder.github.io/aframe-3dRudder/)
* [WebGL/WebVR (BabylonJS)](https://3drudder.github.io/babylonjs-3dRudder/)
* [Youtube](/examples/video.html)
* [Poly](/examples/poly.html)
* [Google Maps](/examples/maps.html) rotation experimental
* [Sketchfab Viewer](/examples/sketchfab.html) orbit mode
* ```npm run-script sample``` to see in local:
  * Axis: http://localhost:3000/
  * WebGL: http://localhost:3000/webgl/
  * Youtube: http://localhost:3000/video/
  * Maps: http://localhost:3000/maps/ 
  * Google Poly: http://localhost:3000/poly or http://localhost:3000/poly?t=ID (ID of poly model)
  * Sketchfab: http://localhost:3000/sketchfab or http://localhost:3000/sketchfab?t=ID (ID of sketchfab model)

## Build for browser

* ```npm install --save-optional bufferutil``` (optionnal)
* ```npm install browserify -g``` -g is for global install
* ```npm install grunt-cli -g```
* ```npm run build```
* Result in ```dist/3dRudder-x.x.x.js```

## Unit Test

* Command ```npm test```

## TODO features

* add http request for the function

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