答案 0 :(得分:1)
当指针对象(手指或工具)消失时没有事件,但要处理此事件,您可以保留前一帧或有关前一帧的信息,并检查手指是否在设备区域中。
var lastNbFingers = 0;
// Setup Leap loop with frame callback function
var controllerOptions = {enableGestures: true};
Leap.loop(controllerOptions, function(frame)
{
var nbFingers = 0; // Cpt for all fingers from all hands in the current frame
var fingerRemoved = false; // are all the fingers just removed from device area ?
// how many fingers in our scene
for (var h = 0; h < frame.hands.length; ++h)
{
var hand = frame.hands[h];
nbFingers += hand.fingers.length;
}
if (nbFingers > 0) // there are fingers
lastNbFingers = nbFingers;
else if (lastNbFingers > 0) // there is no finger on current frame, but some on previous frame
{
lastNbFingers = 0;
fingerRemoved = true;
}
if (fingerRemoved)
// do some stuff
});