Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update hand.js #308

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/hand.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Pointable = require("./pointable")
let Pointable = require("./pointable")
, Bone = require('./bone')
, glMatrix = require("gl-matrix")
, mat3 = glMatrix.mat3
Expand All @@ -25,7 +25,7 @@ var Pointable = require("./pointable")
* A Hand object created from the Hand constructor is also invalid.
* Test for validity with the [Hand.valid]{@link Leap.Hand#valid} property.
*/
var Hand = module.exports = function(data) {
let Hand = module.exports = function(data) {
/**
* A unique ID assigned to this Hand object, whose value remains the same
* across consecutive frames while the tracked hand remains visible. If
Expand Down Expand Up @@ -209,7 +209,7 @@ var Hand = module.exports = function(data) {
* invalid Finger object is returned.
*/
Hand.prototype.finger = function(id) {
var finger = this.frame.finger(id);
let finger = this.frame.finger(id);
return (finger && (finger.handId == this.id)) ? finger : Pointable.Invalid;
}

Expand All @@ -235,14 +235,14 @@ Hand.prototype.finger = function(id) {
*/
Hand.prototype.rotationAngle = function(sinceFrame, axis) {
if (!this.valid || !sinceFrame.valid) return 0.0;
var sinceHand = sinceFrame.hand(this.id);
let sinceHand = sinceFrame.hand(this.id);
if(!sinceHand.valid) return 0.0;
var rot = this.rotationMatrix(sinceFrame);
var cs = (rot[0] + rot[4] + rot[8] - 1.0)*0.5
var angle = Math.acos(cs);
let rot = this.rotationMatrix(sinceFrame);
let cs = (rot[0] + rot[4] + rot[8] - 1.0)*0.5
let angle = Math.acos(cs);
angle = isNaN(angle) ? 0.0 : angle;
if (axis !== undefined) {
var rotAxis = this.rotationAxis(sinceFrame);
let rotAxis = this.rotationAxis(sinceFrame);
angle *= vec3.dot(rotAxis, vec3.normalize(vec3.create(), axis));
}
return angle;
Expand All @@ -265,7 +265,7 @@ Hand.prototype.rotationAngle = function(sinceFrame, axis) {
*/
Hand.prototype.rotationAxis = function(sinceFrame) {
if (!this.valid || !sinceFrame.valid) return vec3.create();
var sinceHand = sinceFrame.hand(this.id);
let sinceHand = sinceFrame.hand(this.id);
if (!sinceHand.valid) return vec3.create();
return vec3.normalize(vec3.create(), [
this._rotation[7] - sinceHand._rotation[5],
Expand All @@ -291,10 +291,10 @@ Hand.prototype.rotationAxis = function(sinceFrame) {
*/
Hand.prototype.rotationMatrix = function(sinceFrame) {
if (!this.valid || !sinceFrame.valid) return mat3.create();
var sinceHand = sinceFrame.hand(this.id);
let sinceHand = sinceFrame.hand(this.id);
if(!sinceHand.valid) return mat3.create();
var transpose = mat3.transpose(mat3.create(), this._rotation);
var m = mat3.multiply(mat3.create(), sinceHand._rotation, transpose);
let transpose = mat3.transpose(mat3.create(), this._rotation);
let m = mat3.multiply(mat3.create(), sinceHand._rotation, transpose);
return m;
}

Expand Down Expand Up @@ -341,7 +341,7 @@ Hand.prototype.scaleFactor = function(sinceFrame) {
*/
Hand.prototype.translation = function(sinceFrame) {
if (!this.valid || !sinceFrame.valid) return vec3.create();
var sinceHand = sinceFrame.hand(this.id);
let sinceHand = sinceFrame.hand(this.id);
if(!sinceHand.valid) return vec3.create();
return [
this._translation[0] - sinceHand._translation[0],
Expand Down