Code Monkey home page Code Monkey logo

leapjs's Introduction

LeapJS

LeapJS

LeapJS is a Javascript library that provides the functionality and object structure of the Leap API to assist developers who are working with the Leap Motion in a browser environment.

Including

Include Leap.js for debugging and access to "private" variables:

<script src="Leap.js"></script>

Include Leap.min.js for deployed applications to reduce load times:

<script src="Leap.min.js"></script>

Tutorial

// Create a controller to connect to the Leap Motion
myController = new Leap.Controller("ws://localhost:6437/");

// Create a listener
myListener = new Leap.Listener();

// Listener.onFrame is called each time a frame is received
myListener.onFrame = function(controller){

    var frame = controller.frame();
    var hands = frame.hands();
    var pointables = frame.pointables();
    
    var gestures = frame.gestures();
    
    // Awesome code goes here
}

// Add the listener to the controller
myController.addListener(myListener);

// Enable the screenTap gesture
myController.enableGesture("screenTap", true);

// Listener.onConnect is called when the connection is open
myListener.onConnect = function(controller){
 
    // Calibrate the screen
    calibrate = new Leap.Calibrate(controller);
    calibrate.onComplete = function(screen){
        // Save the screen
        // Or access it later with myController.calibratedScreens()[0]
    }
}

Whats new? Gestures!

  • Gesture.Type
    • "circle"
    • "keyTap"
    • "screenTap"
    • "swipe"
  • CircleGesture : Gesture
  • KeyTapGesture : Gesture
  • ScreenTapGesture : Gesture
  • SwipeGesture : Gesture
  • Controller
    • void enableGesture( string type, Bool enable )
    • Bool isGestureEnabled( string type )
  • Frame
    • GestureList gestures()
    • GestureList gestures( Frame sinceFrame )

Whats new? Calibration!

  • Calibrate
    • Calibrate( Controller controller )
    • virtual void onComplete( Screen screen )
  • Screen
    • Screen()
    • float distanceToPoint( Vector point )
    • { position : Vector, distance : float } intersect( Pointable pointable, Bool normalize )
    • { position : Vector, distance : float } intersect( Vector position, Vector direction, Bool normalize )
    • { position : Vector, distance : float } project( Pointable pointable, Bool normalize )
    • { position : Vector, distance : float } project( Vector position, Bool normalize )
    • Vector normal()
    • void offset()
    • Bool isValid()
    • static Screen invalid()

Where is the API?

The API has been moved to the wiki page

leapjs's People

Contributors

brianantonelli avatar logotype avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.