forked from leapmotion/chrome-draw
/
relativeMotion.html
54 lines (40 loc) · 1.16 KB
/
relativeMotion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/three.js/r67/three.min.js"></script>
<script src="//js.leapmotion.com/leap-0.6.0.min.js"></script>
<script src="javascripts/lib/leap-plugins-0.1.4-data-defaults.js"></script>
<script src="javascripts/lib/leap.rigged-hand-0.1.4-readyEvent.js"></script>
<script src="javascripts/leap.relative-motion.js"></script>
</head>
<script>
window.hand = null;
window.recalibrate = function(){
console.log('recalibrate');
hand.recalibrate();
};
Leap.loop({
hand: function(hand){
window.hand = hand;
var position = hand.relativePosition();
// position is a Float32Array, not a regular Javascript Array
// cannot use map or join :-(
document.getElementById('out').innerHTML = '';
for (var i = 0; i < 3; i++){
document.getElementById('out').innerHTML += "<br/>" + Math.round(position[i]);
}
}
})
.use('relativeMotion');
setTimeout(recalibrate, 1500);
</script>
<style>
body{
font-family: "Helvetica";
font-size: 2em;
}
</style>
<body>
<button onclick="recalibrate();">Recalibrate</button>
<div id="out"></div>
</body>
</html>