I am working on making an interface for a Leap motion controlled robot. From the server side node.js, I am emitting an event 'action' which contains the data to be displayed on a HTML page. I am using leapjs-rigged-hand for visualization (https://github.com/leapmotion/leapjs-rigged-hand)
<body>
<div id="display"><span id="direction">undefined</span></div>
</body>
<script type="text/javascript">
var socket = io();
socket.on('action', function(data) {
$('$display').html(data);
});
var controller = new Leap.Controller;
(controller).use('riggedHand', {
scale: 1.5
})
.connect();
controller.on('riggedHand.meshAdded', function(handMesh, leapHand){
handMesh.material.opacity = 1;
handMesh.material.color.set('#7b4b2a');
handMesh.material.ambient = handMesh.material.color;
});
</script>
Shown above is the relevant part of the code. The problem is that socket callback works only before the first "riggedHand.meshAdded" event is fired.
How do I make them work simultaneously?
Issue solved. Initialized controller with {background: true} on both the client and the server side