How to use the leapjs.vec3 function in leapjs

To help you get started, we’ve selected a few leapjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rhansby / leap-gamepad / main.js View on Github external
function isCurled(hand, finger) {
    var finger_dir = finger.direction;
    var palm_dir = hand.direction;
    var palm_normal = hand.palmNormal;
    var threshhold = 7*Math.PI/36;  //35 degrees
    var right_angle = Math.PI/2; //90 degrees
    //Angle between the finger and the palm normal
    var fn_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_normal));
    //Angle between the finger and the palm direction
    var fd_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_dir));
    //We check fd_angle > 90 to detect the condition where the user has curled their finger past the palm normal
    return fn_angle < threshhold || fd_angle > right_angle;
}
github rhansby / leap-gamepad / main.js View on Github external
function isCurled(hand, finger) {
    var finger_dir = finger.direction;
    var palm_dir = hand.direction;
    var palm_normal = hand.palmNormal;
    var threshhold = 7*Math.PI/36;  //35 degrees
    var right_angle = Math.PI/2; //90 degrees
    //Angle between the finger and the palm normal
    var fn_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_normal));
    //Angle between the finger and the palm direction
    var fd_angle = Math.acos(Leap.vec3.dot(finger_dir, palm_dir));
    //We check fd_angle > 90 to detect the condition where the user has curled their finger past the palm normal
    return fn_angle < threshhold || fd_angle > right_angle;
}
github Zeukkari / leapgim / index.js View on Github external
Gesture.prototype.detect = function() {
      var direction, dotProduct, gesture, j, len, pointableID, ref;
      if (this.frame.gestures.length > 0) {
        ref = this.frame.gestures;
        for (j = 0, len = ref.length; j < len; j++) {
          gesture = ref[j];
          switch (gesture.type) {
            case "circle":
              if (this.extendedFingers.is(["thumb", "index"])) {
                pointableID = gesture.pointableIds[0];
                direction = this.frame.pointable(pointableID).direction;
                dotProduct = Leap.vec3.dot(direction, gesture.normal);
                if (dotProduct > 0) {
                  return 'oneFingerRotateClockwise';
                } else {
                  return 'oneFingerRotateContraClockwise';
                }
              }
          }
        }
      }
      return false;
    };

leapjs

JavaScript client for the Leap Motion Controller

Apache-2.0
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis