Getting Started
You can run leapjs-gesture in Browser or Node.js. How to use it?
Browser
- Install leapjs-gesture.
Add two
scripts to reference leap.js and leapjs-gesture.js. The leap.js file must place before leapjs-gesture.js.Example:
<script src="../node_modules/leapjs/leap-0.6.4.min.js"></script> <script src="../node_modules/leapjs-gesture/src/leapjs-gesture.js"></script>- Begin to use.
Leap .loop() .use('handEntry') .use('handDrag', { distance: 120 }) .on('handFound', function () { // do something })
Node.js
- Install leapjs-gesture.
Import leapjs and leapjs.gesture. Then use
Leap.Controller.pluginto register plugins you need.let Leap = require('leapjs') import {handEntry,handSwipe,handFlip,handFist} from 'leapjs-gesture' Leap.Controller.plugin('handEntry', handEntry.handEntry) Leap.Controller.plugin('handSwipe', handSwipe.handSwipe) Leap.Controller.plugin('handFlip', handFlip.handFlip) Leap.Controller.plugin('handFist', handFist.handFist)Let your controller use plugin, and then begin use them.
let controller = new Leap.Controller({ enableGestures: true, background: true, loopWhileDisconnected: 'true' }) controller.use('handEntry') controller.use('handSwipe', { verticle: 100, horizontal: 120 }) controller.on('handFound', (hand) => { // do something })