LeapJS API Reference
Class

Leap.Controller

Contents

class Leap.Controller

The Controller class is your main interface to the Leap Motion Controller.

Create an instance of this Controller class to access frames of tracking data and configuration information. Frame data can be polled at any time using the Controller.frame() function. Call frame() or frame(0) to get the most recent frame. Set the history parameter to a positive integer to access previous frames. A controller stores up to 60 frames in its frame history.

Polling is an appropriate strategy for applications which already have an intrinsic update loop, such as a game.

Constructor Top

  Controller ()

Methods Top

Leap.Frame frame (Number history)

Constructor details Top

controller.js at line 9
Controller ()

Constructs a Controller object.

When creating a Controller object, you may optionally pass in options to set the host , set the port, enable gestures, or select the frame event type.

var controller = new Leap.Controller({
  host: '127.0.0.1',
  port: 6437,
  enableGestures: true,
  frameEventName: 'animationFrame'
});

Methods Detail Top

controller.js at line 93
public Leap.Frame frame (Number history)

Returns a frame of tracking data from the Leap.

Use the optional history parameter to specify which frame to retrieve. Call frame() or frame(0) to access the most recent frame; call frame(1) to access the previous frame, and so on. If you use a history value greater than the number of stored frames, then the controller returns an invalid frame.

Parameters

Number history

The age of the frame to return, counting backwards from the most recent frame (0) into the past and up to the maximum age (59).

Return Value

Leap.Frame

The specified frame; or, if no history parameter is specified, the newest frame. If a frame is not available at the specified history position, an invalid Frame is returned.