首页 文章

跳跃动作JS,音高未定义

提问于
浏览
0

我使用nodeJS进行了跳跃动作,发生了一些问候世界

我想知道手的音高值,但是返回“未定义”

var Leap = require('leapjs');

var webSocket = require('ws'),
    ws = new webSocket('ws://127.0.0.1:6437');

ws.on('message', function(data, flags) {
    frame = JSON.parse(data); 

var controller = Leap.loop(function(frame){

    if(frame.hands.length == 1)
    {
        var hand = frame.hands[0];
        var position = hand.palmPosition;
        var velocity = hand.palmVelocity;
        var direction = hand.direction;
        var finger = hand.fingers[0];
        var pitch = direction.pitch;

        var type = hand.type;
        if(type == "left"){
            console.log("Left hand.");
            console.log("pitch ::"+pitch);
        } 

        if(type == "right") {
            console.log("Right hand.")
        }
    }
    });


    if (frame.hands && frame.hands.length > 1) {
        console.log("two");
    }    
    if (frame.hands && frame.hands.length == 0) {  
            console.log("apaga too");
    }
});

所以,当我记录我的左手时,我得到了

左手 . pitch :: undefined

1 回答

  • 1

    我相信音高是属于手而非方向的方法,而不是属于方向docs的属性 . 你试过 hand.pitch() 吗?

相关问题