Skip to content

Instantly share code, notes, and snippets.

@trtg
Created January 21, 2013 20:39
Show Gist options
  • Save trtg/4589121 to your computer and use it in GitHub Desktop.
Save trtg/4589121 to your computer and use it in GitHub Desktop.
leap_motion_test
{"description":"leap_motion_test","endpoint":"","display":"svg","public":true,"require":[{"name":"leap","url":"https://raw.github.com/trtg/LeapJS-1/master/Leap.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"tab":"edit","display_percent":0.5130733944954128,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"hidepanel":false}
var svg = d3.select("svg").attr("width",500).attr("height",500);
myListener = new Leap.Listener();
myListener.onFrame = function(controller){
var numfings =controller.frame().fingers().count();
if(numfings>0){
//console.log(controller.frame());
}
var myfingers = svg.selectAll("circle").data(controller.frame().fingers());
myfingers
.enter()
.append("circle")
.attr("cx",function(d,i){return d._tipPosition.x+200})
.attr("cy",function(d,i){return d._tipPosition.y+200})
.attr("opacity",0.3)
.attr("r",function(d,i){
console.log(d);
return d._length
});
myfingers.exit().remove();
}
myListener.onConnect = function(controller){
console.log('leap device connected');
}
myListener.onDisconnect = function(controller){
console.log('leap device disconnected');
}
myController = new Leap.Controller("ws://localhost:6437/");
myController.addListener(myListener);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment