UNPKG

2.37 kBJavaScriptView Raw
1require("./_header")
2/**
3 * Leap is the global namespace of the Leap API.
4 * @namespace Leap
5 */
6module.exports = {
7 Controller: require("./controller"),
8 Frame: require("./frame"),
9 Gesture: require("./gesture"),
10 Hand: require("./hand"),
11 Pointable: require("./pointable"),
12 InteractionBox: require("./interaction_box"),
13 CircularBuffer: require("./circular_buffer"),
14 UI: require("./ui"),
15 glMatrix: require("gl-matrix"),
16 mat3: require("gl-matrix").mat3,
17 vec3: require("gl-matrix").vec3,
18 loopController: undefined,
19 version: require('./version.js'),
20 /**
21 * The Leap.loop() function passes a frame of Leap data to your
22 * callback function and then calls window.requestAnimationFrame() after
23 * executing your callback function.
24 *
25 * Leap.loop() sets up the Leap controller and WebSocket connection for you.
26 * You do not need to create your own controller when using this method.
27 *
28 * Your callback function is called on an interval determined by the client
29 * browser. Typically, this is on an interval of 60 frames/second. The most
30 * recent frame of Leap data is passed to your callback function. If the Leap
31 * is producing frames at a slower rate than the browser frame rate, the same
32 * frame of Leap data can be passed to your function in successive animation
33 * updates.
34 *
35 * As an alternative, you can create your own Controller object and use a
36 * {@link Controller#onFrame onFrame} callback to process the data at
37 * the frame rate of the Leap device. See {@link Controller} for an
38 * example.
39 *
40 * @method Leap.loop
41 * @param {function} callback A function called when the browser is ready to
42 * draw to the screen. The most recent {@link Frame} object is passed to
43 * your callback function.
44 *
45 * ```javascript
46 * Leap.loop( function( frame ) {
47 * // ... your code here
48 * })
49 * ```
50 */
51 loop: function(opts, callback) {
52 if (callback === undefined) {
53 callback = opts;
54 opts = {};
55 }
56 opts.useAllPlugins || (opts.useAllPlugins = true)
57 if (!this.loopController) this.loopController = new this.Controller(opts);
58 this.loopController.loop(callback);
59 return this.loopController;
60 },
61
62 /*
63 * Convenience method for Leap.Controller.plugin
64 */
65 plugin: function(name, options){
66 this.Controller.plugin(name, options)
67 }
68}