The leap-stream.js
script provides a leap
method which takes a single
callback for rendering data frames coming from the Leap’s websocket stream:
<script src="leap-stream.js"></script>
<script>
render = function(frame) { ... };
leap(render);
</script>
See index.html
and its rendering script (render.coffee
, render.js
) for
sample usage: in this case, a simple viewer for observing hand movement.
Note: index.coffee.html
is identical to index.html
albeit for the fact that we’ve embedded the rendering method as a coffeescript script.
Here’s the supplied method:
leap = (render) ->
stream = new WebSocket 'ws://localhost:6437'
stream.onmessage = (event) ->
render(JSON.parse(event.data)) if event.data
''
This is intended as a ultra-minimalist alternative to the leap.js framework, and a simple starting point for personal leap hacking.