我正尝试使用JavaScript API简单地获取使用Leap Motion轻扫手势的方向。我的代码是:使用Leap Motion检测轻扫手势方向
$(document).ready(function() {
controller = new Leap.Controller("ws://localhost:6437/");
listener = new Leap.Listener();
listener.onFrame = function(controller) {
var frame = controller.frame();
var hands = frame.hands();
var pointables = frame.pointables();
var gestures = frame.gestures();
$("#rotationAxis").text(pointables.length);
$("#gestureDetected").text(gestures[0]);
}
controller.addListener(listener);
controller.enableGesture("swipe", true);
listener.onConnect = function(controller) {
// calibrate = new Leap.Calibrate(controller);
// calibrate.onComplete = function(screen){
// }
}
});
我可以从数组中获取当前手势,但无法获取类型或方向。有任何想法吗?
谢谢。
我得到“Uncaught TypeError:无法读取未定义的属性'type'on var gestureType = frame.gestures [0] .type;对不起,应该在我的问题中注意到。 – mrEmpty