From 944a44c8dae9af0602594d18baf2552dcac4a4ac Mon Sep 17 00:00:00 2001 From: Rohit Paul <113459757+RohitPaul12345@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:33:00 +0530 Subject: [PATCH] Update hand.js --- lib/hand.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/hand.js b/lib/hand.js index f77a1ba..57fd678 100644 --- a/lib/hand.js +++ b/lib/hand.js @@ -1,4 +1,4 @@ -var Pointable = require("./pointable") +let Pointable = require("./pointable") , Bone = require('./bone') , glMatrix = require("gl-matrix") , mat3 = glMatrix.mat3 @@ -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 @@ -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; } @@ -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; @@ -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], @@ -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; } @@ -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],