Sunday, May 26, 2013

Leap Motion / Getting Started with Raw Data


Here is my presentation from Stage3D online conference

Quick Note about my speech

It consists from 4 parts:
  • quick review of LeapMotion device - not technical
  • work with Raw data from WebSocket
  • work with LeapMotionAS3 API
  • Drag-n-Drop demos
In this post I'll talk about the 1st part for this presentation:


I started my speech with quick overview of LeapMotion capabilities. It's very similar to my post All About LeapMotion.

Raw data from Socket

It's never been so easy to track data from any device. Just plug to WebSocket and get raw data.



Because Adobe Flash doesn't have WebSockets we need to emulate it.
WebSocket fix recipe:
  1. Connect to Socket 'localhost:6437'
  2. Send WebSocket handshake
  3. Get WebSocket handshake
  4. Track data from socket

Here is example

Socket policy files / Cross domain

The big difference between Sockets in Flash and JS is that Flash Sockets require special CrossDomain.xml file on server side. Without it you will get an error:
onSecurityErrorHandler Error #2048: Security sandbox violation:
Victor Norgren informed LeapMotion team about this issue but still haven't received any response. Maybe them will fix it in upcoming driver versions. But we don't have any confidence.

Fix it

But we can fix it.
Cross domain fix recipe:
  1. Don't use Flash for Socket communication
  2. Connect to Socket in JS
  3. Handle onmesssage
  4. Use ExternalInterface.addCallback to pass data from js to flash
Here is working example - despite on ExternalInterface communication it doesn't become performance bottleneck.


In upcoming part I'll show you how to use LeapMotionAs3 library from Victor Norgren and Wouter Verweirder to create 3D Controller for drag'n'drop 3D object.


I plan to do more presentations on LeapMotion interaction so If you have any questions about it or you're interested in some topics - just write down here in the comments section and I'll try to address them in the upcoming speeches.
Thanks, See you guys!

survey service

No comments :

Post a Comment