This repository has been archived by the owner on May 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathLeap.min.js
1 lines (1 loc) · 25 KB
/
Leap.min.js
1
var Leap={APIVersion:"0.7.7"};Leap.List=function(){},Leap.List.prototype=new Array,Leap.List.prototype.count=function(){return this.length},Leap.List.prototype.isEmpty=function(){return 0===this.length},Leap.List.prototype.empty=function(){return 0===this.length},Leap.List.prototype.append=function(t){for(i=0;i<t.length;i++)this.push(t[i])},Leap.List.prototype.U=function(){for(var t=0;t<this.length;t++)this[t].U()},Leap.Pointable=function(t,i,e){null==e&&(e=this),null==t?(e.Q=Leap.Frame.invalid(),e.Ai=Leap.Hand.invalid(),e.H=null,e.C=!1,e.M=new Leap.Vector,e.l=new Leap.Vector,e.o=new Leap.Vector,e.AJ=null,e.AT=null):(e.Q=i?i.Q:Leap.Frame.invalid(),e.Ai=i,e.H=t.id,e.C=!0,e.M=new Leap.Vector(t.direction),e.l=new Leap.Vector(t.tipPosition),e.o=new Leap.Vector(t.tipVelocity),e.AJ=t.length,e.AT=t.width)},Leap.Pointable.prototype={frame:function(){return this.Q},hand:function(){return this.Ai},id:function(){return this.H},direction:function(){return this.M},tipPosition:function(){return this.l},tipVelocity:function(){return this.o},isFinger:function(){return this.AN},isTool:function(){return this.AZ},length:function(){return this.AJ},width:function(){return this.AT},toString:function(){var t="{id:"+this.H+",direction:"+this.M.toString()+",";return t+="tipPosition:"+this.l.toString()+",",t+="tipVelocity:"+this.o.toString()+",",t+="length:"+this.AJ+",",t+="width:"+this.AT+"}"},isValid:function(){return this.C},U:function(){this.Q=null}},Leap.Pointable.invalid=function(){return new Leap.Pointable},Leap.PointableList=function(){},Leap.PointableList.prototype=new Leap.List,Leap.PointableList.prototype.leftmost=function(){var t=Leap.Pointable.invalid();for(i=0;i<this.length;i++)(0==t.C||this[i].tipPosition().x<t.tipPosition().x)&&this[i].C&&(t=this[i]);return t},Leap.PointableList.prototype.rightmost=function(){var t=Leap.Pointable.invalid();for(i=0;i<this.length;i++)(0==t.C||this[i].tipPosition().x>t.tipPosition().x)&&this[i].C&&(t=this[i]);return t},Leap.PointableList.prototype.frontmost=function(){var t=Leap.Pointable.invalid();for(i=0;i<this.length;i++)(0==t.C||this[i].tipPosition().z<t.tipPosition().z)&&this[i].C&&(t=this[i]);return t},window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}(),Leap.AnimLoop=function(t,i){this.B=t,this.Ah=i;var e=this;this.Ae=function(t){window.requestAnimFrame(function(){e.Ae(e.B)}),e.Ah(t)},t.isConnected()?window.requestAnimFrame(function(){e.Ae(e.B)}):(this.S=new Leap.Listener,this.S.onConnect=function(){e.B.removeListener(e.S),window.requestAnimFrame(function(){e.Ae(e.B)})},t.addListener(this.S))},Leap.Calibrate=function(t){this.B=t,this.AE=[];var i=this;this.a=document.createElement("div"),this.a.style.cssText=this.w+this.u,this.a.innerHTML="1",this.AD=this.AW,this.a.onclick=function(){i.AD()},window.onkeyup=function(t){32===t.keyCode&&i.AD()},this.AI=document.createElement("div"),this.AI.style.cssText=this.AK+this.u,this.AI.innerHTML="Position one finger on the square until<br>it turns green then click it or press space.",this.AA=document.createElement("div"),this.AA.style.cssText=this.AC+this.u,document.body.appendChild(this.a),document.body.appendChild(this.AI),document.body.appendChild(this.AA);var i=this;this.S=new Leap.Listener,this.S.onFrame=function(t){i.AR(t)},this.B.addListener(this.S),this.G=null,this.AP=new Leap.Vector([0,0,-1])},Leap.Calibrate.prototype={w:"width: 20px; height: 20px; padding: 10px; margin: -20px; position: fixed; text-align: center; background-color: #c3cccc; color: #ffffff; cursor: pointer; ",u:"left: 25%; top: 50%;",s:"left: 25%; top: 25%;",v:"left: 75%; top: 50%;",AK:"height: 32px; padding-top: 4px; padding-bottom: 4px; padding-left: 8px; padding-right: 8px; margin-top: -20px; margin-left: 26px; border-radius: 5px; position: fixed; background-color: rgba(0,0,0,0.7); color: #FFFFFF; font: 14px Helvetica, Sans-Serif;",AC:"height: 0; width: 0; border: 6px solid; border-color: transparent rgba(0,0,0,0.7) transparent transparent; margin-top: -6px; margin-left: 14px; position: fixed;",AW:function(){this.B.frame().pointables();this.G&&(this.AE[0]=this.G.tipPosition(),this.a.style.cssText=this.w+this.s,this.AI.style.cssText=this.AK+this.s,this.AA.style.cssText=this.AC+this.s,this.a.innerHTML="2",this.AD=this.AX)},AX:function(){this.B.frame().pointables();this.G&&(this.AE[1]=this.G.tipPosition(),this.a.style.cssText=this.w+this.v,this.AI.style.cssText=this.AK+this.v,this.AA.style.cssText=this.AC+this.v,this.a.innerHTML="3",this.AD=this.AY)},AY:function(){this.B.frame().pointables();if(this.G){this.AE[2]=this.G.tipPosition(),document.body.removeChild(this.a),document.body.removeChild(this.AI),document.body.removeChild(this.AA),delete this.a;var t=new Leap.Screen(this.AE);this.B.t.push(t),this.B.t.save(),this.B.removeListener(this.S),this.onComplete(t)}},AR:function(t){var i=t.frame().pointables(),e=i.count();this.G=null;for(var n=0;e>n;n++){var s=i[n];s.direction().angleTo(this.AP)<Math.PI/8&&(null==this.G||this.G.tipPosition().z>s.tipPosition().z)&&(this.G=s)}this.a.style.backgroundColor=null==this.G?"#c3cccc":"#BCD63C"},onComplete:function(){}},"undefined"==typeof WebSocket&&"undefined"!=typeof MozWebSocket&&(WebSocket=MozWebSocket),Leap.Controller=function(t){this.k=[],this.r={},this.J={},this.AV=0,this.e=64,this.I=0,this.t=new Leap.ScreenList,this.O=!1,this.K={};for(var i=0;i<this.e;i++)this.k[i]=Leap.Frame.invalid();this.AU(t)},Leap.Controller.prototype={isConnected:function(){return this.L.connected},frame:function(t){return null==t||0==t?this.k[this.I]:t>this.e-1?Leap.Frame.invalid():(t=this.I-t,0>t&&(t+=this.e),this.k[t])},addListener:function(t){t.H=this.AV++,this.J[t.H]=t,t.onInit(this)},removeListener:function(t){t.onExit(this),this.J[t.H].onExit(this),delete this.J[t.H]},config:function(){},locatedScreens:function(){return this.t},calibratedScreens:function(){return this.t},enableGesture:function(t,i){i?(this.K[t]=Leap.Gesture.Type[t],this.O||(this.O=!0,this.isConnected()&&this.L.send('{"enableGestures": true}'))):(delete this.K[t],this.O&&0==Object.keys(this.K).length&&(this.O=!1,this.isConnected()&&this.L.send('{"enableGestures": false}')))},isGestureEnabled:function(t){return this.K[t]?!0:!1},Ac:function(t){var i=JSON.parse(t.data),e=new Leap.Frame(i,this);this.I++,this.I==this.e&&(this.I=0);var n=this.k[this.I];n.U(),delete this.r[n.H],delete this.k[this.I],this.r[e.H]=e,this.k[this.I]=e;for(index in this.J)this.J[index].onFrame(this)},AQ:function(t){Leap.serverVersion=JSON.parse(t.data).version,this.L.onmessage=function(t){this.B.Ac(t)}},AU:function(t){"undefined"!=typeof WebSocket&&(this.L&&delete this.L,this.L=new WebSocket(t),this.L.B=this,this.L.connected=!1,this.L.onmessage=function(t){this.B.AQ(t)},this.L.onopen=function(){this.connected=!0,this.B.O&&this.send('{"enableGestures": true}');for(index in this.B.J)this.B.J[index].onConnect(this.B)},this.L.onclose=function(){this.connected=!1;for(index in this.B.J)this.B.J[index].onDisconnect(this.B);var t=this;setTimeout(function(){t.B.AU(t.url)},1e3)},this.L.onerror=function(t){this.onclose(t)})}},Leap.Finger=function(t,i){Leap.Pointable(t,i,this),this.AN=!0,this.AZ=!1},Leap.Finger.prototype=Leap.Pointable.prototype,Leap.Finger.invalid=function(){return new Leap.Finger},Leap.FingerList=function(){},Leap.FingerList.prototype=new Leap.PointableList,Leap.Frame=function(t,i){if(this.B=i,this.T=new Leap.FingerList,this.m=new Leap.ToolList,this.E=new Leap.PointableList,this.p=new Leap.HandList,this.q=new Leap.GestureList,this.P={},this.R={},this.F={},this.j={},this.h={},null==t)this.H=null,this.i=null,this.C=!1,this.A=new Leap.Matrix,this.n=null,this.D=new Leap.Vector;else{this.H=t.id,this.i=t.timestamp,this.C=!0,this.A=new Leap.Matrix(t.r),this.n=t.s,this.D=new Leap.Vector(t.t);for(index in t.hands){var e=new Leap.Hand(t.hands[index],this);this.j[e.H]=e,this.p.push(e)}for(index in t.pointables){var n=this.j[t.pointables[index].handId];if(t.pointables[index].tool){var s=new Leap.Tool(t.pointables[index],n);this.F[s.H]=this.R[s.H]=s,this.E.push(s),this.m.push(s),n&&(n.F[s.H]=n.R[s.H]=s,n.E.push(s),n.m.push(s))}else{var s=new Leap.Finger(t.pointables[index],n);this.F[s.H]=this.P[s.H]=s,this.E.push(s),this.T.push(s),n&&(n.F[s.H]=n.P[s.H]=s,n.E.push(s),n.T.push(s))}}for(index in t.gestures){var o=this.B.K[t.gestures[index].type];if(o){var r=new o(t.gestures[index],this);this.h[r.H]=r,this.q.push(r)}}}},Leap.Frame.prototype={id:function(){return this.H},timestamp:function(){return this.i},rotationAngle:function(t,i){if(!this.C||!t.C)return 0;var e=.5*(this.A.xBasis.x+this.A.yBasis.y+this.A.zBasis.z-1),n=Math.acos(e);if(n=isNaN(n)?0:n,i){var s=this.rotationAxis(t);n*=s.dot(i.normalized())}return n},rotationAxis:function(t){if(!this.C||!t.C)return Leap.Vector.zero();var i=this.A.zBasis.y-t.A.yBasis.z,e=this.A.xBasis.z-t.A.zBasis.x,n=this.A.yBasis.x-t.A.xBasis.y,s=new Leap.Vector([i,e,n]);return s.normalized()},rotationMatrix:function(t){if(!this.C||!t.C)return Leap.Matrix.identity();var i=new Leap.Vector([this.A.xBasis.x,this.A.yBasis.x,this.A.zBasis.x]),e=new Leap.Vector([this.A.xBasis.y,this.A.yBasis.y,this.A.zBasis.y]),n=new Leap.Vector([this.A.xBasis.z,this.A.yBasis.z,this.A.zBasis.z]),s=new Leap.Matrix([i,e,n]);return t.A.times(s)},scaleFactor:function(t){return this.C&&t.C?Math.exp(this.n-t.n):1},translation:function(t){if(!this.C||!t.C)return Leap.Vector.zero();var i=this.D.x-t.D.x,e=this.D.y-t.D.y,n=this.D.z-t.D.z;return new Leap.Vector([i,e,n])},finger:function(t){return null==this.P[t]?Leap.Finger.invalid():this.T[t]},fingers:function(){return this.T},gesture:function(t){return null==this.h[t]?Leap.Gesture.invalid():this.h[t]},gestures:function(t){if(null==t)return this.q;for(var i=new Leap.GestureList,e=t.id();e<=this.H;e++){var n=this.B.r[e];null!=n&&i.push(n.q)}return i},hand:function(t){return null==this.j[t]?Leap.Hand.invalid():this.j[t]},hands:function(){return this.p},pointable:function(t){return null==this.F[t]?Leap.Pointable.invalid():this.F[t]},pointables:function(){return this.E},tool:function(t){return null==this.R[t]?Leap.Tool.invalid():this.R[t]},tools:function(){return this.m},pointables:function(){return this.E},compare:function(t){return this.H==t.id},toString:function(){for(var t="{timestamp:"+this.i+",id:"+this.H+",hands:[",i=0;i<this.p.length;i++)t+=this.p[i].toString();return t+="]}"},isValid:function(){return this.C},U:function(){this.q.U(),this.p.U(),this.E.U()}},Leap.Frame.invalid=function(){return new Leap.Frame},Leap.Gesture=function(t,i,e){if(null==e&&(e=this),e.E=new Leap.PointableList,e.p=new Leap.HandList,null==t)e.H=null,e.Q=Leap.Frame.invalid(),e.AS=Leap.Gesture.State.invalid,e.Ad=Leap.Gesture.Type.invalid,e.C=!1;else{e.H=t.id,e.Q=i,e.AS=t.state,e.Ad=t.type,e.C=!0;for(index in t.handIds){var n=i.hand(t.handIds[index]);e.p.push(n)}for(index in t.pointableIds){var s=i.pointable(t.pointableIds[index]);e.E.push(s)}}},Leap.Gesture.prototype={id:function(){return this.H},frame:function(){return this.Q},state:function(){return this.AS},type:function(){return this.Ad},toString:function(){return"{timestamp:"+this.Q.i+",id:"+this.H+",type:"+this.Ad+",state:"+this.AS+"}"},isValid:function(){return this.C},U:function(){this.Q=null}},Leap.Gesture.invalid=function(){return new Leap.Gesture},Leap.CircleGesture=function(t,i){Leap.Gesture(t,i,this),this.b=new Leap.Vector(t.normal),this.N=this.E[0],this.f=t.progress,this.Aj=t.radius,this.AF=new Leap.Vector(t.center),this.Ab=this.N.direction().angleTo(this.b)<=Math.PI/4},Leap.CircleGesture.prototype=Leap.Gesture.prototype,Leap.CircleGesture.prototype.normal=function(){return this.b},Leap.CircleGesture.prototype.pointable=function(){return this.N},Leap.CircleGesture.prototype.progress=function(){return this.f},Leap.CircleGesture.prototype.radius=function(){return this.Aj},Leap.CircleGesture.prototype.center=function(){return this.AF},Leap.CircleGesture.prototype.isClockwise=function(){return this.Ab},Leap.KeyTapGesture=function(t,i){Leap.Gesture(t,i,this),this.N=this.E[0],this.g=new Leap.Vector(t.position),this.f=t.progress},Leap.KeyTapGesture.prototype=Leap.Gesture.prototype,Leap.KeyTapGesture.prototype.pointable=function(){return this.N},Leap.KeyTapGesture.prototype.position=function(){return this.g},Leap.KeyTapGesture.prototype.progress=function(){return this.f},Leap.ScreenTapGesture=function(t,i){Leap.Gesture(t,i,this),this.N=this.E[0],this.g=new Leap.Vector(t.position),this.f=t.progress},Leap.ScreenTapGesture.prototype=Leap.Gesture.prototype,Leap.ScreenTapGesture.prototype.pointable=function(){return this.N},Leap.ScreenTapGesture.prototype.position=function(){return this.g},Leap.ScreenTapGesture.prototype.progress=function(){return this.f},Leap.SwipeGesture=function(t,i){Leap.Gesture(t,i,this),this.M=new Leap.Vector(t.direction),this.N=this.E[0],this.g=new Leap.Vector(t.position),this.Ak=t.speed,this.AH=new Leap.Vector(t.startPosition)},Leap.SwipeGesture.prototype=Leap.Gesture.prototype,Leap.SwipeGesture.prototype.direction=function(){return this.M},Leap.SwipeGesture.prototype.pointable=function(){return this.N},Leap.SwipeGesture.prototype.position=function(){return this.g},Leap.SwipeGesture.prototype.speed=function(){return this.Ak},Leap.SwipeGesture.prototype.startPosition=function(){return this.AH},Leap.Gesture.State={invalid:"invalid",start:"start",stop:"stop",update:"update"},Leap.Gesture.Type={invalid:Leap.Gesture.invalid,circle:Leap.CircleGesture,keyTap:Leap.KeyTapGesture,screenTap:Leap.ScreenTapGesture,swipe:Leap.SwipeGesture},Leap.GestureList=function(){},Leap.GestureList.prototype=new Leap.List,Leap.Hand=function(t,i){this.T=new Leap.FingerList,this.m=new Leap.ToolList,this.E=new Leap.PointableList,this.P={},this.R={},this.F={},null==t?(this.Q=Leap.Frame.invalid(),this.H=null,this.C=!1,this.A=new Leap.Matrix,this.n=null,this.D=new Leap.Vector,this.M=new Leap.Vector,this.c=new Leap.Vector,this.W=new Leap.Vector,this.V=new Leap.Vector,this.X=new Leap.Vector,this.Y=null):(this.Q=i,this.H=t.id,this.C=!0,this.A=new Leap.Matrix(t.r),this.n=t.s,this.D=new Leap.Vector(t.t),this.M=new Leap.Vector(t.direction),this.c=new Leap.Vector(t.palmNormal),this.W=new Leap.Vector(t.palmPosition),this.V=new Leap.Vector(t.palmVelocity),this.X=new Leap.Vector(t.sphereCenter),this.Y=t.sphereRadius)},Leap.Hand.prototype={frame:function(){return this.Q},id:function(){return this.H},direction:function(){return this.M},palmNormal:function(){return this.c},palmPosition:function(){return this.W},palmVelocity:function(){return this.V},sphereCenter:function(){return this.X},sphereRadius:function(){return this.Y},rotationAngle:function(t,i){if(!this.C||!t.C)return 0;var e=t.hand(this.H);if(!e.C)return 0;var n=this.rotationMatrix(t),s=.5*(n.xBasis.x+n.yBasis.y+n.zBasis.z-1),o=Math.acos(s);if(o=isNaN(o)?0:o,i){var r=this.rotationAxis(t);o*=r.dot(i.normalized())}return o},rotationAxis:function(t){if(!this.C||!t.C)return Leap.Vector.zero();var i=t.hand(this.H);if(!i.C)return Leap.Vector.zero();var e=this.A.zBasis.y-i.A.yBasis.z,n=this.A.xBasis.z-i.A.zBasis.x,s=this.A.yBasis.x-i.A.xBasis.y,o=new Leap.Vector([e,n,s]);return o.normalized()},rotationMatrix:function(t){if(!this.C||!t.C)return Leap.Matrix.identity();var i=t.hand(this.H);if(!i.C)return Leap.Matrix.identity();var e=new Leap.Vector([this.A.xBasis.x,this.A.yBasis.x,this.A.zBasis.x]),n=new Leap.Vector([this.A.xBasis.y,this.A.yBasis.y,this.A.zBasis.y]),s=new Leap.Vector([this.A.xBasis.z,this.A.yBasis.z,this.A.zBasis.z]),o=new Leap.Matrix([e,n,s]);return i.A.times(o)},scaleFactor:function(t){if(!this.C||!t.C)return 1;var i=t.hand(this.H);return i.C?Math.exp(this.n-i.n):1},translation:function(t){if(!this.valid||!t.valid)return Leap.Vector.zero();var i=t.hand(this.H);if(!i.C)return Leap.Vector.zero();var e=this.D.x-i.D.x,n=this.D.y-i.D.y,s=this.D.z-i.D.z;return new Leap.Vector([e,n,s])},finger:function(t){return null==this.P[t]?Leap.Finger.invalid():this.P[t]},fingers:function(){return this.T},pointable:function(t){return null==this.F[t]?Leap.Pointable.invalid():this.F[t]},pointables:function(){return this.E},tool:function(t){return null==this.R[t]?{isValid:!1}:this.R[t]},tools:function(){return this.m},toString:function(){var t="{id:"+obj.H+",sphereCenter:"+(null==obj.X?"null":obj.X)+",";t+="sphereRadius:"+(null==obj.Y?"null":obj.Y)+",",t+="normal:"+(void 0==obj.b?"null":obj.b.toString())+",fingers:[";for(var i=0;i<this.T.length;i++)t+=this.T[i].toString();t+="],tools:[";for(var i=0;i<this.m.length;i++)t+=this.m[i].toString();return t+="],palmNormal:"+(void 0==obj.c?"null":obj.c.toString())+",",t+="palmPosition:"+(void 0==obj.W?"null":obj.W.toString())+",",t+="palmVelocity:"+(void 0==obj.V?"null":obj.V.toString())+"}"},isValid:function(){return this.C},U:function(){this.Q=null}},Leap.Hand.invalid=function(){return new Leap.Hand},Leap.HandList=function(){},Leap.HandList.prototype=new Leap.List,Leap.Listener=function(){this.onConnect=function(){},this.onDisconnect=function(){},this.onExit=function(){},this.onFrame=function(){},this.onInit=function(){}},Leap.Matrix=function(t){t instanceof Leap.Matrix?(this.xBasis=new Leap.Vector(t.xBasis),this.yBasis=new Leap.Vector(t.yBasis),this.zBasis=new Leap.Vector(t.zBasis),this.origin=new Leap.Vector(t.origin)):t instanceof Array?t[0]instanceof Leap.Vector&&"number"==typeof t[1]?(this.setRotation(t[0],t[1]),this.origin=new Leap.Vector(t[2])):(this.xBasis=new Leap.Vector(t[0]),this.yBasis=new Leap.Vector(t[1]),this.zBasis=new Leap.Vector(t[2]),this.origin=new Leap.Vector(t[3])):(this.xBasis=new Leap.Vector([1,0,0]),this.yBasis=new Leap.Vector([0,1,0]),this.zBasis=new Leap.Vector([0,0,1]),this.origin=new Leap.Vector([0,0,0]))},Leap.Matrix.prototype={setRotation:function(t,i){var e=t.normalized(),n=Math.sin(i),s=Math.cos(i),o=1-s;this.xBasis=new Leap.Vector([e.x*e.x*o+s,e.x*e.y*o-e.z*n,e.x*e.z*o+e.y*n]),this.yBasis=new Leap.Vector([e.y*e.x*o+e.z*n,e.y*e.y*o+s,e.y*e.z*o-e.x*n]),this.zBasis=new Leap.Vector([e.z*e.x*o-e.y*n,e.z*e.y*o+e.x*n,e.z*e.z*o+s])},transformPoint:function(t){return this.origin.plus(this.transformDirection(t))},transformDirection:function(t){var i=this.xBasis.multiply(t.x),e=this.yBasis.multiply(t.y),n=this.zBasis.multiply(t.z);return i.plus(e).plus(n)},times:function(t){var i=this.transformDirection(t.xBasis),e=this.transformDirection(t.yBasis),n=this.transformDirection(t.zBasis),s=this.transformPoint(t.origin);return new Leap.Matrix([i,e,n,s])},rigidInverse:function(){var t=new Leap.Vector([this.xBasis.x,this.yBasis.x,this.zBasis.x]),i=new Leap.Vector([this.xBasis.y,this.yBasis.y,this.zBasis.y]),e=new Leap.Vector([this.xBasis.z,this.yBasis.z,this.zBasis.z]),n=new Leap.Matrix([t,i,e]);return n.origin=n.transformDirection(Leap.Vector.zero().minus(this.origin)),n},toArray3x3:function(t){return null==t?t=[]:t.length=0,t[0]=this.xBasis.x,t[1]=this.xBasis.y,t[2]=this.xBasis.z,t[3]=this.yBasis.x,t[4]=this.yBasis.y,t[5]=this.yBasis.z,t[6]=this.zBasis.x,t[7]=this.zBasis.y,t[8]=this.zBasis.z,t},toArray4x4:function(t){return null==t?t=[]:t.length=0,t[0]=this.xBasis.x,t[1]=this.xBasis.y,t[2]=this.xBasis.z,t[3]=0,t[4]=this.yBasis.x,t[5]=this.yBasis.y,t[6]=this.yBasis.z,t[7]=0,t[8]=this.zBasis.x,t[9]=this.zBasis.y,t[10]=this.zBasis.z,t[11]=0,t[12]=this.origin.x,t[13]=this.origin.y,t[14]=this.origin.z,t[15]=1,t},toString:function(){return"{xBasis:"+this.xBasis+",yBasis:"+this.yBasis+",zBasis:"+this.zBasis+",origin:"+this.origin+"}"},compare:function(t){return this.xBasis.compare(t.xBasis)&&this.yBasis.compare(t.yBasis)&&this.zBasis.compare(t.zBasis)&&this.origin.compare(t.origin)}},Leap.Matrix.identity=function(){return new Leap.Matrix},Leap.Plane=function(t,i,e){this.Z=new Leap.Vector(t),this.AL=new Leap.Vector(i),this.AM=new Leap.Vector(e)},Leap.Plane.prototype={normal:function(){var t=this.Z.x-this.AL.x,i=this.AL.y-this.Z.y,e=this.Z.z-this.AL.z,n=this.Z.x-this.AM.x,s=this.AM.y-this.Z.y,o=this.Z.z-this.AM.z,r=i*o-s*e,a=t*o-n*e,h=t*s-n*i;return this.b=0==r&&0==a&&0==h?null:new Leap.Vector([r,a,h]),this.normal=function(){return this.b},this.b},unitnormal:function(){var t=this.normal();return this.AG=null==t?null:t.normalized(),this.unitnormal=function(){return this.AG},this.AG},pointIntersect:function(t){var i=this.unitnormal(),e=this.pointDistance(t),n=i.multiply(e).plus(t);return{position:n,distance:e}},pointDistance:function(t){var i=this.unitnormal(),e=-i.dot(this.Z.minus(t));return e},rayIntersect:function(t,i){var e=i.dot(this.normal());if(0==e)return null;var n=this.Z.minus(t).dot(this.normal()),s=n/e;if(0>s&&this.normal().angleTo(i)<Math.PI/2)return null;var o=t.plus(i.multiply(s)),r=s*i.magnitude();return{position:o,distance:r}}},Leap.Screen=function(t){if(this.d=t,t){"3"in t||(this.d[3]=window.innerWidth),"4"in t||(this.d[4]=window.innerHeight),"5"in t||(this.d[5]=window.screenX),"6"in t||(this.d[6]=window.screenY),this.offset(),this.AB=new Leap.Plane(t[0],t[1],t[2]),this.AF=t[0].plus(t[2]).dividedBy(2),this.Aa=t[1].plus(t[1].minus(this.AF));var i=t[2].minus(t[0]),e=t[0].minus(t[1]),n=2*i.magnitude()/this.d[3],s=4*e.magnitude()/this.d[4];this.Af=i.normalized().dividedBy(n),this.Ag=e.normalized().dividedBy(s),this.C=!0}else this.AB=new Leap.Plane,this.AF=new Leap.Vector,this.Aa=new Leap.Vector,this.Af=new Leap.Vector,this.Ag=new Leap.Vector,this.d=[new Leap.Vector,new Leap.Vector,new Leap.Vector,0,0,0,0],this.C=!1},Leap.Screen.prototype={distanceToPoint:function(t){return this.AB.pointDistance(t)},intersect:function(){var t,i,e,n;arguments[0]instanceof Leap.Vector?(t=arguments[0],i=arguments[1],e=arguments[2],n=arguments[3]):(t=arguments[0].tipPosition(),i=arguments[0].direction(),e=arguments[1],n=arguments[2]);var s=this.AB.rayIntersect(t,i);if(null!=s)return e&&(s=this.AO(s)),s},normal:function(){return this.AB.normal()},project:function(t,i){arguments[0]instanceof Leap.Vector||(t=t.tipPosition());var e=this.AB.pointIntersect(t);if(null!=e)return i&&(e=this.AO(e)),e},AO:function(t){var i=t.position.minus(this.Aa),e=this.Af.dot(i)+this.x,n=this.Ag.dot(i)+this.y;return t.position=new Leap.Vector([e,n,0]),t},offset:function(){this.x=this.d[5]-window.screenX,this.y=this.d[6]-window.screenY},isValid:function(){return this.C}},Leap.Screen.invalid=function(){return new Leap.Screen},Leap.ScreenList=function(){if(localStorage.screens){var t=JSON.parse(localStorage.screens);for(var i in t){var e=t[i];if(7==e.length){var n=[new Leap.Vector(e[0]),new Leap.Vector(e[1]),new Leap.Vector(e[2]),e[3],e[4],e[5],e[6]];this.push(new Leap.Screen(n))}}this.save()}},Leap.ScreenList.prototype=new Leap.List,Leap.ScreenList.prototype.closestScreenHit=function(t){if(this.empty())return Leap.Screen.invalid();for(var i,e=Leap.Screen.invalid(),n=0;n<this.length;n++){var s=this[n].intersect(t);s&&(0==e.C||s.distance<i)&&(e=this[n],i=s.distance)}return e},Leap.ScreenList.prototype.save=function(){for(var t=[],i=0;i<this.length;i++)t.push(this[i].d);localStorage.screens=JSON.stringify(t)},Leap.ScreenList.prototype.clear=function(){this.length=0,this.save()},Leap.Tool=function(t,i){Leap.Pointable(t,i,this),this.AZ=!0,this.AN=!1},Leap.Tool.prototype=Leap.Pointable.prototype,Leap.Tool.invalid=function(){return new Leap.Tool},Leap.ToolList=function(){},Leap.ToolList.prototype=new Leap.PointableList,Leap.Vector=function(t){null==t?(this.x=0,this.y=0,this.z=0):"x"in t?(this.x=t.x,this.y=t.y,this.z=t.z):"0"in t&&(this.x="number"==typeof t[0]?t[0]:0,this.y="number"==typeof t[1]?t[1]:0,this.z="number"==typeof t[2]?t[2]:0)},Leap.Vector.prototype={angleTo:function(t){var i=this.magnitude()*t.magnitude();return i>0?Math.acos(this.dot(t)/i):0},cross:function(t){var i=this.y*t.z-t.y*this.z,e=this.x*t.z-t.x*this.z,n=this.x*t.y-t.x*this.y;return new Leap.Vector([i,e,n])},distanceTo:function(t){return this.minus(t).magnitude()},dot:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},plus:function(t){return new Leap.Vector([this.x+t.x,this.y+t.y,this.z+t.z])},minus:function(t){return new Leap.Vector([this.x-t.x,this.y-t.y,this.z-t.z])},multiply:function(t){return new Leap.Vector([this.x*t,this.y*t,this.z*t])},dividedBy:function(t){return new Leap.Vector([this.x/t,this.y/t,this.z/t])},magnitude:function(){return Math.sqrt(this.magnitudeSquared())},magnitudeSquared:function(){return Math.pow(this.x,2)+Math.pow(this.y,2)+Math.pow(this.z,2)},normalized:function(){var t=this.magnitude();return t>0?this.dividedBy(t):new Leap.Vector},pitch:function(){return Math.atan2(this.y,-this.z)},roll:function(){return Math.atan2(this.x,-this.y)},yaw:function(){return Math.atan2(this.x,-this.z)},toArray:function(){return[this.x,this.y,this.z]},toString:function(){return"{x:"+this.x+",y:"+this.y+",z:"+this.z+"}"},compare:function(t){return this.x==t.x&&this.y==t.y&&this.z==t.z},isValid:function(){return 0/0!=this.x&&this.x>-1/0&&this.x<1/0&&0/0!=this.y&&this.y>-1/0&&this.y<1/0&&0/0!=this.z&&this.z>-1/0&&this.z<1/0}},Leap.Vector.backward=function(){return new Leap.Vector([0,0,1])},Leap.Vector.down=function(){return new Leap.Vector([0,-1,0])},Leap.Vector.forward=function(){return new Leap.Vector([0,0,-1])},Leap.Vector.left=function(){return new Leap.Vector([-1,0,0])},Leap.Vector.right=function(){return new Leap.Vector([1,0,0])},Leap.Vector.up=function(){return new Leap.Vector([0,1,0])},Leap.Vector.xAxis=function(){return new Leap.Vector([1,0,0])},Leap.Vector.yAxis=function(){return new Leap.Vector([0,1,0])},Leap.Vector.zAxis=function(){return new Leap.Vector([0,0,1])},Leap.Vector.zero=function(){return new Leap.Vector([0,0,0])};