SlideShare a Scribd company logo
1 of 11
Download to read offline
by John Tubert

LeapMotion
Communicating with other browsers
and adding graphics (and maybe
moving some 3d shape)
Communicating with other browsers
Technologies used:
● Node.js (with socket.io and express)
● Hosted on Heroku
Server code
var express = require('express');

io.sockets.on('connection', function (socket) {

var app = express.createServer();

socket.on('frame',function(data){
socket.broadcast.emit('frame', data);

var io = require('socket.io').listen(app), fs = require('fs');

});
});

io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});

app.use(express.static(__dirname + '/static'));

var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});
Front end code
var socket = io.connect(window.location.host.toString());

if(socket){

...

socket.on('frame', function (data) {

Leap.loop(function(frame) {

console.log("data: ",data);

Controller.getFrame(frame);

Controller.getFrame(data);

if(socket){
var obj = {};
obj.pointables = {};
obj.pointables.length = frame.pointables.length;
obj.hands = [];
obj.hands[0] = {};
obj.hands[0].palmPosition = [];
obj.hands[0].palmPosition[0] = {};
obj.hands[0].palmPosition[1] = {};
obj.hands[0].palmPosition[1] = frame.hands[0].palmPosition[1];
socket.emit("frame",obj);
}
});
...

});
}
Graphics
Using http://paperjs.org/, a canvas
framework.
Graphics - create/update
//CREATE -------

//UPDATE ON FRAME --------

var a = x*Math.floor(360/6);

paper.view.onFrame = function(event) {

var angle = (a*dtr);

graphicsArr[id]["angle"]+=1;

var x = (gRadius*Math.cos(angle));

var angle = (graphicsArr[id]["angle"]*dtr);

var y = (gRadius*Math.sin(angle));

var x = (gRadius*Math.cos(angle));

graphicsArr[id] = new paper.Path.Rectangle([x+xOffset, y+yOffset], [40, 40]);

var y = (gRadius*Math.sin(angle));

graphicsArr[id]["angle"] = a;

graphicsArr[id].position = [x+xOffset,y+yOffset];

graphicsArr[id]["text"] = new paper.PointText({

graphicsArr[id]["text"].position = [x+xOffset,y+yOffset+40];

point: [x+xOffset,y+yOffset],
justification: 'left',
fontSize: 13,
fillColor: 'white'
});

graphicsArr[id]["text"].content = id;
graphicsArr[id].strokeColor = '#ffffff';
graphicsArr[id].fillColor = 'black';
paper.view.draw();

}
Graphics - in main.js
Loop.prototype = {
…
Graphics.createShape(audio.id,counter);
}
play : function(id) {
if (id !== this.id) { this.audio.play(); } else { this.changeState(false); }
Graphics.updateColor(id,"red");
},
pause : function(id) {
Graphics.updateColor(id,"black");
this.changeState(true);
},
...
setGlobalVolume : function(frame, pointables){
...
Graphics.updateVolume(Math.round(volOutput*100));
}
Demo
http://jtubert-leap.herokuapp.com/
Controlling a 3d shape
● 3d cube using CSS3
● Controlling it using Leap’s palm position
var hand = frame.hands[0];
yVal = hand.palmPosition;
var volChangeY = parseFloat(yVal[0].toFixed(1));
volOutputY = volChangeY/yThreshold;
...
var x = volOutputX*360;
var y = volOutputY*360;
var z = volOutputZ*360;
$('#cube').css('-webkit-transform', 'rotate3d('+x+', '+y+', '+z+', '+z+'deg)');
Demo - cube
http://jtubert-leap.herokuapp.com/cube.html
Thanks
https://github.com/jtubert/leap

More Related Content

Similar to LeapMotion

soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascriptEldar Djafarov
 
Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication developmentGanesh Gembali
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSocketsGonzalo Ayuso
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioCaesar Chi
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with ExpressAaron Stannard
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Visual Engineering
 
Kraken Front-Trends
Kraken Front-TrendsKraken Front-Trends
Kraken Front-TrendsPayPal
 
NodeJs
NodeJsNodeJs
NodeJsdizabl
 
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGapFAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGapLoiane Groner
 
The Death of a Mouse
The Death of a MouseThe Death of a Mouse
The Death of a MouseGeert Bevin
 
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''OdessaJS Conf
 

Similar to LeapMotion (20)

Socket.io
Socket.ioSocket.io
Socket.io
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
 
Mobile webapplication development
Mobile webapplication developmentMobile webapplication development
Mobile webapplication development
 
NodeJS
NodeJSNodeJS
NodeJS
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
mobl
moblmobl
mobl
 
Building Web Apps with Express
Building Web Apps with ExpressBuilding Web Apps with Express
Building Web Apps with Express
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Nest in Peace
Nest in PeaceNest in Peace
Nest in Peace
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2Switch to Backend 2023 | Day 1 Part 2
Switch to Backend 2023 | Day 1 Part 2
 
Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.Workshop 4: NodeJS. Express Framework & MongoDB.
Workshop 4: NodeJS. Express Framework & MongoDB.
 
Kraken Front-Trends
Kraken Front-TrendsKraken Front-Trends
Kraken Front-Trends
 
NodeJs
NodeJsNodeJs
NodeJs
 
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGapFAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
FAESA CONENCO 2013: Sencha Touch 2 + PhoneGap
 
The Death of a Mouse
The Death of a MouseThe Death of a Mouse
The Death of a Mouse
 
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''
Alexey Orlenko ''High-performance IPC and RPC for microservices and apps''
 

More from John Tubert

Sibling rivalry tech vs. philosophy on bias in ai
Sibling rivalry  tech vs. philosophy on bias in aiSibling rivalry  tech vs. philosophy on bias in ai
Sibling rivalry tech vs. philosophy on bias in aiJohn Tubert
 
Sibling rivalry tech vs. philosophy on bias & AI
Sibling rivalry  tech vs. philosophy on bias & AISibling rivalry  tech vs. philosophy on bias & AI
Sibling rivalry tech vs. philosophy on bias & AIJohn Tubert
 
Extreme Danger of bias in Artificial Inteligence
Extreme Danger of bias in Artificial InteligenceExtreme Danger of bias in Artificial Inteligence
Extreme Danger of bias in Artificial InteligenceJohn Tubert
 
Sketchio presentation at Parse Developer meetup
Sketchio presentation at Parse Developer meetupSketchio presentation at Parse Developer meetup
Sketchio presentation at Parse Developer meetupJohn Tubert
 
Browserless javascript testing
Browserless javascript testingBrowserless javascript testing
Browserless javascript testingJohn Tubert
 
Drawing room experiment
Drawing room experimentDrawing room experiment
Drawing room experimentJohn Tubert
 
Bunch of random tech things
Bunch of random tech thingsBunch of random tech things
Bunch of random tech thingsJohn Tubert
 

More from John Tubert (8)

Sibling rivalry tech vs. philosophy on bias in ai
Sibling rivalry  tech vs. philosophy on bias in aiSibling rivalry  tech vs. philosophy on bias in ai
Sibling rivalry tech vs. philosophy on bias in ai
 
Sibling rivalry tech vs. philosophy on bias & AI
Sibling rivalry  tech vs. philosophy on bias & AISibling rivalry  tech vs. philosophy on bias & AI
Sibling rivalry tech vs. philosophy on bias & AI
 
Extreme Danger of bias in Artificial Inteligence
Extreme Danger of bias in Artificial InteligenceExtreme Danger of bias in Artificial Inteligence
Extreme Danger of bias in Artificial Inteligence
 
Sketchio presentation at Parse Developer meetup
Sketchio presentation at Parse Developer meetupSketchio presentation at Parse Developer meetup
Sketchio presentation at Parse Developer meetup
 
Browserless javascript testing
Browserless javascript testingBrowserless javascript testing
Browserless javascript testing
 
Drawing room experiment
Drawing room experimentDrawing room experiment
Drawing room experiment
 
Parse.com
Parse.comParse.com
Parse.com
 
Bunch of random tech things
Bunch of random tech thingsBunch of random tech things
Bunch of random tech things
 

Recently uploaded

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

LeapMotion

  • 1. by John Tubert LeapMotion Communicating with other browsers and adding graphics (and maybe moving some 3d shape)
  • 2. Communicating with other browsers Technologies used: ● Node.js (with socket.io and express) ● Hosted on Heroku
  • 3. Server code var express = require('express'); io.sockets.on('connection', function (socket) { var app = express.createServer(); socket.on('frame',function(data){ socket.broadcast.emit('frame', data); var io = require('socket.io').listen(app), fs = require('fs'); }); }); io.configure(function () { io.set("transports", ["xhr-polling"]); io.set("polling duration", 10); }); app.use(express.static(__dirname + '/static')); var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); });
  • 4. Front end code var socket = io.connect(window.location.host.toString()); if(socket){ ... socket.on('frame', function (data) { Leap.loop(function(frame) { console.log("data: ",data); Controller.getFrame(frame); Controller.getFrame(data); if(socket){ var obj = {}; obj.pointables = {}; obj.pointables.length = frame.pointables.length; obj.hands = []; obj.hands[0] = {}; obj.hands[0].palmPosition = []; obj.hands[0].palmPosition[0] = {}; obj.hands[0].palmPosition[1] = {}; obj.hands[0].palmPosition[1] = frame.hands[0].palmPosition[1]; socket.emit("frame",obj); } }); ... }); }
  • 6. Graphics - create/update //CREATE ------- //UPDATE ON FRAME -------- var a = x*Math.floor(360/6); paper.view.onFrame = function(event) { var angle = (a*dtr); graphicsArr[id]["angle"]+=1; var x = (gRadius*Math.cos(angle)); var angle = (graphicsArr[id]["angle"]*dtr); var y = (gRadius*Math.sin(angle)); var x = (gRadius*Math.cos(angle)); graphicsArr[id] = new paper.Path.Rectangle([x+xOffset, y+yOffset], [40, 40]); var y = (gRadius*Math.sin(angle)); graphicsArr[id]["angle"] = a; graphicsArr[id].position = [x+xOffset,y+yOffset]; graphicsArr[id]["text"] = new paper.PointText({ graphicsArr[id]["text"].position = [x+xOffset,y+yOffset+40]; point: [x+xOffset,y+yOffset], justification: 'left', fontSize: 13, fillColor: 'white' }); graphicsArr[id]["text"].content = id; graphicsArr[id].strokeColor = '#ffffff'; graphicsArr[id].fillColor = 'black'; paper.view.draw(); }
  • 7. Graphics - in main.js Loop.prototype = { … Graphics.createShape(audio.id,counter); } play : function(id) { if (id !== this.id) { this.audio.play(); } else { this.changeState(false); } Graphics.updateColor(id,"red"); }, pause : function(id) { Graphics.updateColor(id,"black"); this.changeState(true); }, ... setGlobalVolume : function(frame, pointables){ ... Graphics.updateVolume(Math.round(volOutput*100)); }
  • 9. Controlling a 3d shape ● 3d cube using CSS3 ● Controlling it using Leap’s palm position var hand = frame.hands[0]; yVal = hand.palmPosition; var volChangeY = parseFloat(yVal[0].toFixed(1)); volOutputY = volChangeY/yThreshold; ... var x = volOutputX*360; var y = volOutputY*360; var z = volOutputZ*360; $('#cube').css('-webkit-transform', 'rotate3d('+x+', '+y+', '+z+', '+z+'deg)');