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

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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

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
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

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)');