问题描述
我在我的节点应用程序中使用跳跃运动传感器来检测手势。使用我当前的设置,手势检测可以正常工作,但没有我需要的那么准确。当我执行滑动手势时,跳跃运动并不总是发送滑动手势对象,当它检测到滑动时,它通常会发送多个手势。例如,当向左滑动时,它将返回向左滑动和向上滑动。我想知道这是否是我的代码或我的跳跃运动传感器的问题。
这是我的跳跃控制代码:
var controller = Leap.loop({ inNode: true,enableGestures: true },function(frame) {
// finger location tracking
if(frame.hands.length > 0) {
var iBox = frame.interactionBox;
var pointable = frame.pointables[0];
if (pointable) {
var leapPoint = pointable.stabilizedTipPosition;
var normalizedPoint = iBox.normalizePoint(leapPoint,true);
let mouseControlY = (1 - normalizedPoint[1]) * appHeight; // with leap facing up
// invert directions for mirror
let invertMouseControlX = (1 - normalizedPoint[0]) * appWidth;
updateMouseCords(invertMouseControlX,mouseControlY)
}
}
// finger gesture tracking
if(frame.valid && frame.gestures.length > 0){
frame.gestures.forEach(function(gesture){
switch (gesture.type){
case "screenTap":
console.log("Click");
break;
case "swipe":
handleSwipe(gesture);
break;
}
});
}
});
function handleSwipe (swipe) {
let io = getIO();
if(swipe.state === 'stop'){
if (swipe.direction[0] > 0){
// user swiped right
swipeDirection = 'right'
} else {
// user swiped left
swipeDirection = 'left'
}
if(swipe.direction[1] > 0) {
// user swiped up
swipeDirection = 'up'
}
// send swipe direction to frontend
io.emit('swipeData',swipeDirection);
}
}
我只需要检测向左、向右或向上滑动以及可能的屏幕点击手势。我可以做些什么来优化我的代码,或者问题可能是我的传感器?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)