diff --git a/leap-1.1.0.js b/leap-1.1.0.js index a5fe15a..6e9dfa8 100644 --- a/leap-1.1.0.js +++ b/leap-1.1.0.js @@ -11853,16 +11853,19 @@ module.exports = function () { }; },{}],34:[function(require,module,exports){ -if (typeof(window) !== 'undefined' && typeof(window.requestAnimationFrame) !== 'function') { - window.requestAnimationFrame = ( - window.webkitRequestAnimationFrame || - window.mozRequestAnimationFrame || - window.oRequestAnimationFrame || - window.msRequestAnimationFrame || - function(callback) { setTimeout(callback, 1000 / 60); } - ); +if (typeof (window) !== 'undefined'){ + if (typeof (window.requestAnimationFrame) !== 'function') { + window.requestAnimationFrame = ( + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function (callback) { setTimeout(callback, 1000 / 60); } + ); + } + window.Leap = require("../lib/index"); +} else { + Leap = require("../lib/index"); } -Leap = require("../lib/index"); - },{"../lib/index":11}]},{},[34]); diff --git a/leap-1.1.0.min.js b/leap-1.1.0.min.js index a90d2a0..7ee138e 100644 --- a/leap-1.1.0.min.js +++ b/leap-1.1.0.min.js @@ -6,4 +6,4 @@ * Released under the Apache-2.0 license * http://github.com/leapmotion/leapjs/blob/master/LICENSE */ -!function r(o,i,a){function s(n,t){if(!i[n]){if(!o[n]){var e="function"==typeof require&&require;if(!t&&e)return e(n,!0);if(u)return u(n,!0);throw(e=new Error("Cannot find module '"+n+"'")).code="MODULE_NOT_FOUND",e}e=i[n]={exports:{}},o[n][0].call(e.exports,function(t){return s(o[n][1][t]||t)},e,e.exports,r,o,i,a)}return i[n].exports}for(var u="function"==typeof require&&require,t=0;t=this.size||t>=this._buf.length))return this._buf[(this.pos-t-1)%this.size]},n.prototype.push=function(t){return this._buf[this.pos%this.size]=t,this.pos++}},{}],3:[function(t,n,e){var r=t("../protocol").chooseProtocol,t=t("events").EventEmitter,o=n.exports=function(t){this.opts=Object.assign({host:"127.0.0.1",scheme:this.getScheme(),port:this.getPort(),background:!1,optimizeHMD:!1,requestProtocolVersion:o.defaultProtocolVersion},t||{}),this.host=this.opts.host,this.port=this.opts.port,this.scheme=this.opts.scheme,this.protocolVersionVerified=!1,this.background=null,this.optimizeHMD=null,this.on("ready",function(){this.setBackground(this.opts.background),this.setOptimizeHMD(this.opts.optimizeHMD),this.opts.optimizeHMD?console.log("Optimized for head mounted display usage."):console.log("Optimized for desktop usage.")})};o.defaultProtocolVersion=6,o.prototype.getUrl=function(){return this.scheme+"//"+this.host+":"+this.port+"/v"+this.opts.requestProtocolVersion+".json"},o.prototype.getScheme=function(){return"ws:"},o.prototype.getPort=function(){return 6437},o.prototype.setBackground=function(t){this.opts.background=t,this.protocol&&this.protocol.sendBackground&&this.background!==this.opts.background&&(this.background=this.opts.background,this.protocol.sendBackground(this,this.opts.background))},o.prototype.setOptimizeHMD=function(t){this.opts.optimizeHMD=t,this.protocol&&this.protocol.sendOptimizeHMD&&this.optimizeHMD!==this.opts.optimizeHMD&&(this.optimizeHMD=this.opts.optimizeHMD,this.protocol.sendOptimizeHMD(this,this.opts.optimizeHMD))},o.prototype.handleOpen=function(){this.connected||(this.connected=!0,this.emit("connect"))},o.prototype.handleClose=function(t,n){this.connected&&(this.disconnect(),1001===t&&1Upgrade",{onclick:function(t){return"leapjs-decline-upgrade"!=t.target.id&&(t=window.open(e,"_blank","height=800,width=1000,location=1,menubar=1,resizable=1,status=1,toolbar=1,scrollbars=1"),window.focus&&t.focus()),r.hide(),!0},onmousemove:function(t){t.target==document.getElementById("leapjs-decline-upgrade")?(document.getElementById("leapjs-decline-upgrade").style.color="#000",document.getElementById("leapjs-decline-upgrade").style.boxShadow="0px 0px 2px #5daa00",document.getElementById("leapjs-accept-upgrade").style.color="#444",document.getElementById("leapjs-accept-upgrade").style.boxShadow="none"):(document.getElementById("leapjs-accept-upgrade").style.color="#000",document.getElementById("leapjs-accept-upgrade").style.boxShadow="0px 0px 2px #5daa00",document.getElementById("leapjs-decline-upgrade").style.color="#444",document.getElementById("leapjs-decline-upgrade").style.boxShadow="none")},onmouseout:function(){document.getElementById("leapjs-decline-upgrade").style.color="#444",document.getElementById("leapjs-decline-upgrade").style.boxShadow="none",document.getElementById("leapjs-accept-upgrade").style.color="#444",document.getElementById("leapjs-accept-upgrade").style.boxShadow="none"}});return r.show()},o.hasWarnedBones=!1,o.warnBones=function(){this.hasWarnedBones||(this.hasWarnedBones=!0,console.warn("Your Leap Service is out of date"),void 0!==t&&t.versions&&t.versions.node||this.warnOutOfDate({reason:"bones"}))}}).call(this)}).call(this,t("_process"))},{_process:32}],8:[function(t,n,e){var r=t("./pointable"),o=t("./bone"),i=t("./dialog"),n=n.exports=function(t){r.call(this,t),this.dipPosition=t.dipPosition,this.pipPosition=t.pipPosition,this.mcpPosition=t.mcpPosition,this.carpPosition=t.carpPosition,this.extended=t.extended,this.type=t.type,this.finger=!0,this.positions=[this.carpPosition,this.mcpPosition,this.pipPosition,this.dipPosition,this.tipPosition],t.bases?this.addBones(t):i.warnBones()};Object.assign(n.prototype,r.prototype),n.prototype.addBones=function(t){this.metacarpal=new o(this,{type:0,width:this.width,prevJoint:this.carpPosition,nextJoint:this.mcpPosition,basis:t.bases[0]}),this.proximal=new o(this,{type:1,width:this.width,prevJoint:this.mcpPosition,nextJoint:this.pipPosition,basis:t.bases[1]}),this.medial=new o(this,{type:2,width:this.width,prevJoint:this.pipPosition,nextJoint:this.dipPosition,basis:t.bases[2]}),this.distal=new o(this,{type:3,width:this.width,prevJoint:this.dipPosition,nextJoint:t.btipPosition,basis:t.bases[3]}),this.bones=[this.metacarpal,this.proximal,this.medial,this.distal]},n.prototype.toString=function(){return"Finger [ id:"+this.id+" "+this.length+"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"},n.Invalid={valid:!1}},{"./bone":1,"./dialog":7,"./pointable":14}],9:[function(t,n,e){var u=t("./hand"),c=t("./pointable"),r=t("gl-matrix"),o=r.mat3,i=r.vec3,a=t("./interaction_box"),h=t("./finger"),n=n.exports=function(t){this.valid=!0,this.id=t.id,this.timestamp=t.timestamp,this.hands=[],this.handsMap={},this.pointables=[],this.fingers=[],t.interactionBox&&(this.interactionBox=new a(t.interactionBox)),this.pointablesMap={},this._translation=t.t,this._rotation=function e(t){return Array.isArray(t)?t.reduce(function(t,n){return t.concat(e(n))},[]):[t]}(t.r),this._scaleFactor=t.s,this.data=t,this.type="frame",this.currentFrameRate=t.currentFrameRate,this.postprocessData(t)};n.prototype.postprocessData=function(t){for(var n=0,e=(t=t||this.data).hands.length;n!=e;n++){var r=new u(t.hands[n]);(r.frame=this).hands.push(r),this.handsMap[r.id]=r}var o;t.pointables.sort((o="id",function(t,n){return t[o]>n[o]?1:n[o]>t[o]?-1:0}));for(var i=0,a=t.pointables.length;i!=a;i++){var s=t.pointables[i],s=new(s.dipPosition?h:c)(s);(s.frame=this).addPointable(s)}},n.prototype.addPointable=function(t){if(this.pointables.push(t),this.pointablesMap[t.id]=t,this.fingers.push(t),void 0!==t.handId&&this.handsMap.hasOwnProperty(t.handId)){var n=this.handsMap[t.handId];switch(n.pointables.push(t),n.fingers.push(t),t.type){case 0:n.thumb=t;break;case 1:n.indexFinger=t;break;case 2:n.middleFinger=t;break;case 3:n.ringFinger=t;break;case 4:n.pinky=t}}},n.prototype.pointable=function(t){return this.pointablesMap[t]||c.Invalid},n.prototype.finger=function(t){return this.pointable(t)},n.prototype.hand=function(t){return this.handsMap[t]||u.Invalid},n.prototype.rotationAngle=function(t,n){if(!this.valid||!t.valid)return 0;var e=this.rotationMatrix(t),e=.5*(e[0]+e[4]+e[8]-1),e=Math.acos(e),e=isNaN(e)?0:e;return void 0!==n&&(t=this.rotationAxis(t),e*=i.dot(t,i.normalize(i.create(),n))),e},n.prototype.rotationAxis=function(t){return this.valid&&t.valid?i.normalize(i.create(),[this._rotation[7]-t._rotation[5],this._rotation[2]-t._rotation[6],this._rotation[3]-t._rotation[1]]):i.create()},n.prototype.rotationMatrix=function(t){if(!this.valid||!t.valid)return o.create();var n=o.transpose(o.create(),this._rotation);return o.multiply(o.create(),t._rotation,n)},n.prototype.scaleFactor=function(t){return this.valid&&t.valid?Math.exp(this._scaleFactor-t._scaleFactor):1},n.prototype.translation=function(t){return this.valid&&t.valid?i.subtract(i.create(),this._translation,t._translation):i.create()},n.prototype.toString=function(){var t="Frame [ id:"+this.id+" | timestamp:"+this.timestamp+" | Hand count:("+this.hands.length+") | Pointable count:("+this.pointables.length+")";return t+=" ]"},n.prototype.dump=function(){var t="";t+="Frame Info:
",t+=this.toString(),t+="

Hands:
";for(var n=0,e=this.hands.length;n!=e;n++)t+=" "+this.hands[n].toString()+"
";t+="

Pointables:
";for(var r=0,o=this.pointables.length;r!=o;r++)t+=" "+this.pointables[r].toString()+"
";return t+="

Raw JSON:
",t+=JSON.stringify(this.data)},n.Invalid={valid:!1,hands:[],fingers:[],pointables:[],pointable:function(){return c.Invalid},finger:function(){return c.Invalid},hand:function(){return u.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return o.create()},rotationAxis:function(){return i.create()},scaleFactor:function(){return 1},translation:function(){return i.create()}}},{"./finger":8,"./hand":10,"./interaction_box":12,"./pointable":14,"gl-matrix":22}],10:[function(t,n,e){var r=t("./pointable"),o=t("./bone"),t=t("gl-matrix"),i=t.mat3,a=t.vec3,n=n.exports=function(t){this.id=t.id,this.palmPosition=t.palmPosition,this.direction=t.direction,this.palmVelocity=t.palmVelocity,this.palmNormal=t.palmNormal,this.sphereCenter=t.sphereCenter,this.sphereRadius=t.sphereRadius,this.valid=!0,this.pointables=[],this.fingers=[],t.armBasis?this.arm=new o(this,{type:4,width:t.armWidth,prevJoint:t.elbow,nextJoint:t.wrist,basis:t.armBasis}):this.arm=null,this._translation=t.t,this._rotation=function e(t){return Array.isArray(t)?t.reduce(function(t,n){return t.concat(e(n))},[]):[t]}(t.r),this._scaleFactor=t.s,this.timeVisible=t.timeVisible,this.stabilizedPalmPosition=t.stabilizedPalmPosition,this.type=t.type,this.grabStrength=t.grabStrength,this.pinchStrength=t.pinchStrength,this.confidence=t.confidence};n.prototype.finger=function(t){t=this.frame.finger(t);return t&&t.handId==this.id?t:r.Invalid},n.prototype.rotationAngle=function(t,n){if(!this.valid||!t.valid)return 0;if(!t.hand(this.id).valid)return 0;var e=this.rotationMatrix(t),e=.5*(e[0]+e[4]+e[8]-1),e=Math.acos(e),e=isNaN(e)?0:e;return void 0!==n&&(t=this.rotationAxis(t),e*=a.dot(t,a.normalize(a.create(),n))),e},n.prototype.rotationAxis=function(t){if(!this.valid||!t.valid)return a.create();t=t.hand(this.id);return t.valid?a.normalize(a.create(),[this._rotation[7]-t._rotation[5],this._rotation[2]-t._rotation[6],this._rotation[3]-t._rotation[1]]):a.create()},n.prototype.rotationMatrix=function(t){if(!this.valid||!t.valid)return i.create();var n=t.hand(this.id);if(!n.valid)return i.create();t=i.transpose(i.create(),this._rotation);return i.multiply(i.create(),n._rotation,t)},n.prototype.scaleFactor=function(t){if(!this.valid||!t.valid)return 1;t=t.hand(this.id);return t.valid?Math.exp(this._scaleFactor-t._scaleFactor):1},n.prototype.translation=function(t){if(!this.valid||!t.valid)return a.create();t=t.hand(this.id);return t.valid?[this._translation[0]-t._translation[0],this._translation[1]-t._translation[1],this._translation[2]-t._translation[2]]:a.create()},n.prototype.toString=function(){return"Hand ("+this.type+") [ id: "+this.id+" | palm velocity:"+this.palmVelocity+" | sphere center:"+this.sphereCenter+" ] "},n.prototype.pitch=function(){return Math.atan2(this.direction[1],-this.direction[2])},n.prototype.yaw=function(){return Math.atan2(this.direction[0],-this.direction[2])},n.prototype.roll=function(){return Math.atan2(this.palmNormal[0],-this.palmNormal[1])},n.Invalid={valid:!1,fingers:[],pointables:[],left:!1,pointable:function(){return r.Invalid},finger:function(){return r.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return i.create()},rotationAxis:function(){return a.create()},scaleFactor:function(){return 1},translation:function(){return a.create()}}},{"./bone":1,"./pointable":14,"gl-matrix":22}],11:[function(t,n,e){n.exports={Controller:t("./controller"),Frame:t("./frame"),Hand:t("./hand"),Pointable:t("./pointable"),Finger:t("./finger"),InteractionBox:t("./interaction_box"),CircularBuffer:t("./circular_buffer"),UI:t("./ui"),JSONProtocol:t("./protocol").JSONProtocol,glMatrix:t("gl-matrix"),mat3:t("gl-matrix").mat3,vec3:t("gl-matrix").vec3,loopController:void 0,version:t("./version.js"),EventEmitter:t("events").EventEmitter,loop:function(t,n){return t&&void 0===n&&"[object Function]"==={}.toString.call(t)&&(n=t,t={}),this.loopController?t&&this.loopController.setupFrameEvents(t):this.loopController=new this.Controller(t),this.loopController.loop(n),this.loopController},plugin:function(t,n){this.Controller.plugin(t,n)}}},{"./circular_buffer":2,"./controller":6,"./finger":8,"./frame":9,"./hand":10,"./interaction_box":12,"./pointable":14,"./protocol":15,"./ui":16,"./version.js":19,events:20,"gl-matrix":22}],12:[function(t,n,e){var r=t("gl-matrix").vec3,n=n.exports=function(t){this.valid=!0,this.center=t.center,this.size=t.size,this.width=t.size[0],this.height=t.size[1],this.depth=t.size[2]};n.prototype.denormalizePoint=function(t){return r.fromValues((t[0]-.5)*this.size[0]+this.center[0],(t[1]-.5)*this.size[1]+this.center[1],(t[2]-.5)*this.size[2]+this.center[2])},n.prototype.normalizePoint=function(t,n){t=r.fromValues((t[0]-this.center[0])/this.size[0]+.5,(t[1]-this.center[1])/this.size[1]+.5,(t[2]-this.center[2])/this.size[2]+.5);return n&&(t[0]=Math.min(Math.max(t[0],0),1),t[1]=Math.min(Math.max(t[1],0),1),t[2]=Math.min(Math.max(t[2],0),1)),t},n.prototype.toString=function(){return"InteractionBox [ width:"+this.width+" | height:"+this.height+" | depth:"+this.depth+" ]"},n.Invalid={valid:!1}},{"gl-matrix":22}],13:[function(t,n,e){n=n.exports=function(t){this.steps=[],this.controller=t};n.prototype.addStep=function(t){this.steps.push(t)},n.prototype.run=function(t){for(var n=this.steps.length,e=0;e!=n&&t;e++)t=this.steps[e](t);return t},n.prototype.removeStep=function(t){t=this.steps.indexOf(t);if(-1===t)throw"Step not found in pipeline";this.steps.splice(t,1)},n.prototype.addWrappedStep=function(o,i){function t(t){for(var n="frame"==o?[t]:t[o+"s"]||[],e=0,r=n.length;e=this.start.x&&e.x<=this.end.x&&e.y>=this.start.y&&e.y<=this.end.y&&e.z>=this.start.z&&e.z<=this.end.z)return!0}return!1},r.prototype.listener=function(t){var n=this;return t&&t.nearThreshold&&this.setupNearRegion(t.nearThreshold),function(t){return n.updatePosition(t)}},r.prototype.clipper=function(){var n=this;return function(t){return n.updatePosition(t),n.enteredFrame?t:null}},r.prototype.setupNearRegion=function(t){var t=this.nearRegion=new r([this.start.x-t,this.start.y-t,this.start.z-t],[this.end.x+t,this.end.y+t,this.end.z+t]),n=this;t.on("enter",function(t){n.emit("near",t)}),t.on("exit",function(t){n.emit("far",t)}),n.on("exit",function(t){n.emit("near",t)})},r.prototype.updatePosition=function(t){return this.nearRegion&&this.nearRegion.updatePosition(t),this.hasPointables(t)&&null==this.enteredFrame?(this.enteredFrame=t,this.emit("enter",this.enteredFrame)):this.hasPointables(t)||null==this.enteredFrame||(this.enteredFrame=null,this.emit("exit",this.enteredFrame)),t},r.prototype.normalize=function(t){return new Vector([(t.x-this.start.x)/(this.end.x-this.start.x),(t.y-this.start.y)/(this.end.y-this.start.y),(t.z-this.start.z)/(this.end.z-this.start.z)])},r.prototype.mapToXY=function(t,n,e){var r=this.normalize(t),o=r.x,t=r.y;return 1r&&(i.warned=!0,(r=new Error("Possible EventEmitter memory leak detected. "+i.length+' "'+String(n)+'" listeners added. Use emitter.setMaxListeners() to increase limit.')).name="MaxListenersExceededWarning",r.emitter=t,r.type=n,r.count=i.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",r.name,r.message))):(i=o[n]=e,++t._eventsCount),t}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),n=0;np.EPSILON?(t[0]=n[0]/r,t[1]=n[1]/r,t[2]=n[2]/r):(t[0]=1,t[1]=0,t[2]=0);return e},e.getAngle=function(t,n){n=b(t,n);return Math.acos(2*n*n-1)},e.multiply=l,e.rotateX=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e+a*n,t[1]=o*e+i*n,t[2]=i*e-o*n,t[3]=a*e-r*n,t},e.rotateY=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e-i*n,t[1]=o*e+a*n,t[2]=i*e+r*n,t[3]=a*e-o*n,t},e.rotateZ=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e+o*n,t[1]=o*e-r*n,t[2]=i*e+a*n,t[3]=a*e-i*n,t},e.calculateW=function(t,n){var e=n[0],r=n[1],n=n[2];return t[0]=e,t[1]=r,t[2]=n,t[3]=Math.sqrt(Math.abs(1-e*e-r*r-n*n)),t},e.exp=f,e.ln=d,e.pow=function(t,n,e){return d(t,n),y(t,t,e),f(t,t),t},e.slerp=m,e.random=function(t){var n=p.RANDOM(),e=p.RANDOM(),r=p.RANDOM(),o=Math.sqrt(1-n),n=Math.sqrt(n);return t[0]=o*Math.sin(2*Math.PI*e),t[1]=o*Math.cos(2*Math.PI*e),t[2]=n*Math.sin(2*Math.PI*r),t[3]=n*Math.cos(2*Math.PI*r),t},e.invert=function(t,n){var e=n[0],r=n[1],o=n[2],i=n[3],n=e*e+r*r+o*o+i*i,n=n?1/n:0;return t[0]=-e*n,t[1]=-r*n,t[2]=-o*n,t[3]=i*n,t},e.conjugate=function(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t},e.fromMat3=v,e.fromEuler=function(t,n,e,r){var o=.5*Math.PI/180;n*=o,e*=o,r*=o;var i=Math.sin(n),a=Math.cos(n),o=Math.sin(e),n=Math.cos(e),e=Math.sin(r),r=Math.cos(r);return t[0]=i*n*r-a*o*e,t[1]=a*o*r+i*n*e,t[2]=a*n*e-i*o*r,t[3]=a*n*r+i*o*e,t},e.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},e.setAxes=e.sqlerp=e.rotationTo=e.equals=e.exactEquals=e.normalize=e.sqrLen=e.squaredLength=e.len=e.length=e.lerp=e.dot=e.scale=e.mul=e.add=e.set=e.copy=e.fromValues=e.clone=void 0;var p=u(t("./common.js")),r=u(t("./mat3.js")),o=u(t("./vec3.js")),i=u(t("./vec4.js"));function s(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return s=function(){return t},t}function u(t){if(t&&t.__esModule)return t;if(null===t||"object"!==a(t)&&"function"!=typeof t)return{default:t};var n=s();if(n&&n.has(t))return n.get(t);var e,r,o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&((r=i?Object.getOwnPropertyDescriptor(t,e):null)&&(r.get||r.set)?Object.defineProperty(o,e,r):o[e]=t[e]);return o.default=t,n&&n.set(t,o),o}function c(){var t=new p.ARRAY_TYPE(4);return p.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function h(t,n,e){e*=.5;var r=Math.sin(e);return t[0]=r*n[0],t[1]=r*n[1],t[2]=r*n[2],t[3]=Math.cos(e),t}function l(t,n,e){var r=n[0],o=n[1],i=n[2],a=n[3],s=e[0],u=e[1],n=e[2],e=e[3];return t[0]=r*e+a*s+o*n-i*u,t[1]=o*e+a*u+i*s-r*n,t[2]=i*e+a*n+r*u-o*s,t[3]=a*e-r*s-o*u-i*n,t}function f(t,n){var e=n[0],r=n[1],o=n[2],i=n[3],a=Math.sqrt(e*e+r*r+o*o),n=Math.exp(i),i=0p.EPSILON?(e=Math.acos(n),n=Math.sin(e),o=Math.sin((1-r)*e)/n,Math.sin(r*e)/n):(o=1-r,r),t[0]=o*i+r*c,t[1]=o*a+r*h,t[2]=o*s+r*l,t[3]=o*u+r*f,t}function v(t,n){var e,r,o,i=n[0]+n[4]+n[8];return 0n[0]&&(e=1),n[8]>n[3*e+e]&&(e=2),r=(e+1)%3,i=(e+2)%3,o=Math.sqrt(n[3*e+e]-n[3*r+r]-n[3*i+i]+1),t[e]=.5*o,o=.5/o,t[3]=(n[3*r+i]-n[3*i+r])*o,t[r]=(n[3*r+e]+n[3*e+r])*o,t[i]=(n[3*i+e]+n[3*e+i])*o),t}t=i.clone;e.clone=t;t=i.fromValues;e.fromValues=t;t=i.copy;e.copy=t;t=i.set;e.set=t;t=i.add;e.add=t,e.mul=l;var y=i.scale;e.scale=y;var b=i.dot;e.dot=b;t=i.lerp;e.lerp=t;t=i.length;e.length=t,e.len=t;t=i.squaredLength;e.squaredLength=t,e.sqrLen=t;var M=i.normalize;e.normalize=M;t=i.exactEquals;e.exactEquals=t;i=i.equals;e.equals=i;var g,w,P,i=(g=o.create(),w=o.fromValues(1,0,0),P=o.fromValues(0,1,0),function(t,n,e){var r=o.dot(n,e);return r<-.999999?(o.cross(g,w,n),o.len(g)<1e-6&&o.cross(g,P,n),o.normalize(g,g),h(t,g,Math.PI),t):.999999=this.size||t>=this._buf.length))return this._buf[(this.pos-t-1)%this.size]},n.prototype.push=function(t){return this._buf[this.pos%this.size]=t,this.pos++}},{}],3:[function(t,n,e){var r=t("../protocol").chooseProtocol,t=t("events").EventEmitter,o=n.exports=function(t){this.opts=Object.assign({host:"127.0.0.1",scheme:this.getScheme(),port:this.getPort(),background:!1,optimizeHMD:!1,requestProtocolVersion:o.defaultProtocolVersion},t||{}),this.host=this.opts.host,this.port=this.opts.port,this.scheme=this.opts.scheme,this.protocolVersionVerified=!1,this.background=null,this.optimizeHMD=null,this.on("ready",function(){this.setBackground(this.opts.background),this.setOptimizeHMD(this.opts.optimizeHMD),this.opts.optimizeHMD?console.log("Optimized for head mounted display usage."):console.log("Optimized for desktop usage.")})};o.defaultProtocolVersion=6,o.prototype.getUrl=function(){return this.scheme+"//"+this.host+":"+this.port+"/v"+this.opts.requestProtocolVersion+".json"},o.prototype.getScheme=function(){return"ws:"},o.prototype.getPort=function(){return 6437},o.prototype.setBackground=function(t){this.opts.background=t,this.protocol&&this.protocol.sendBackground&&this.background!==this.opts.background&&(this.background=this.opts.background,this.protocol.sendBackground(this,this.opts.background))},o.prototype.setOptimizeHMD=function(t){this.opts.optimizeHMD=t,this.protocol&&this.protocol.sendOptimizeHMD&&this.optimizeHMD!==this.opts.optimizeHMD&&(this.optimizeHMD=this.opts.optimizeHMD,this.protocol.sendOptimizeHMD(this,this.opts.optimizeHMD))},o.prototype.handleOpen=function(){this.connected||(this.connected=!0,this.emit("connect"))},o.prototype.handleClose=function(t,n){this.connected&&(this.disconnect(),1001===t&&1Upgrade",{onclick:function(t){return"leapjs-decline-upgrade"!=t.target.id&&(t=window.open(e,"_blank","height=800,width=1000,location=1,menubar=1,resizable=1,status=1,toolbar=1,scrollbars=1"),window.focus&&t.focus()),r.hide(),!0},onmousemove:function(t){t.target==document.getElementById("leapjs-decline-upgrade")?(document.getElementById("leapjs-decline-upgrade").style.color="#000",document.getElementById("leapjs-decline-upgrade").style.boxShadow="0px 0px 2px #5daa00",document.getElementById("leapjs-accept-upgrade").style.color="#444",document.getElementById("leapjs-accept-upgrade").style.boxShadow="none"):(document.getElementById("leapjs-accept-upgrade").style.color="#000",document.getElementById("leapjs-accept-upgrade").style.boxShadow="0px 0px 2px #5daa00",document.getElementById("leapjs-decline-upgrade").style.color="#444",document.getElementById("leapjs-decline-upgrade").style.boxShadow="none")},onmouseout:function(){document.getElementById("leapjs-decline-upgrade").style.color="#444",document.getElementById("leapjs-decline-upgrade").style.boxShadow="none",document.getElementById("leapjs-accept-upgrade").style.color="#444",document.getElementById("leapjs-accept-upgrade").style.boxShadow="none"}});return r.show()},o.hasWarnedBones=!1,o.warnBones=function(){this.hasWarnedBones||(this.hasWarnedBones=!0,console.warn("Your Leap Service is out of date"),void 0!==t&&t.versions&&t.versions.node||this.warnOutOfDate({reason:"bones"}))}}).call(this)}).call(this,t("_process"))},{_process:32}],8:[function(t,n,e){var r=t("./pointable"),o=t("./bone"),i=t("./dialog"),n=n.exports=function(t){r.call(this,t),this.dipPosition=t.dipPosition,this.pipPosition=t.pipPosition,this.mcpPosition=t.mcpPosition,this.carpPosition=t.carpPosition,this.extended=t.extended,this.type=t.type,this.finger=!0,this.positions=[this.carpPosition,this.mcpPosition,this.pipPosition,this.dipPosition,this.tipPosition],t.bases?this.addBones(t):i.warnBones()};Object.assign(n.prototype,r.prototype),n.prototype.addBones=function(t){this.metacarpal=new o(this,{type:0,width:this.width,prevJoint:this.carpPosition,nextJoint:this.mcpPosition,basis:t.bases[0]}),this.proximal=new o(this,{type:1,width:this.width,prevJoint:this.mcpPosition,nextJoint:this.pipPosition,basis:t.bases[1]}),this.medial=new o(this,{type:2,width:this.width,prevJoint:this.pipPosition,nextJoint:this.dipPosition,basis:t.bases[2]}),this.distal=new o(this,{type:3,width:this.width,prevJoint:this.dipPosition,nextJoint:t.btipPosition,basis:t.bases[3]}),this.bones=[this.metacarpal,this.proximal,this.medial,this.distal]},n.prototype.toString=function(){return"Finger [ id:"+this.id+" "+this.length+"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"},n.Invalid={valid:!1}},{"./bone":1,"./dialog":7,"./pointable":14}],9:[function(t,n,e){var u=t("./hand"),c=t("./pointable"),r=t("gl-matrix"),o=r.mat3,i=r.vec3,a=t("./interaction_box"),h=t("./finger"),n=n.exports=function(t){this.valid=!0,this.id=t.id,this.timestamp=t.timestamp,this.hands=[],this.handsMap={},this.pointables=[],this.fingers=[],t.interactionBox&&(this.interactionBox=new a(t.interactionBox)),this.pointablesMap={},this._translation=t.t,this._rotation=function e(t){return Array.isArray(t)?t.reduce(function(t,n){return t.concat(e(n))},[]):[t]}(t.r),this._scaleFactor=t.s,this.data=t,this.type="frame",this.currentFrameRate=t.currentFrameRate,this.postprocessData(t)};n.prototype.postprocessData=function(t){for(var n=0,e=(t=t||this.data).hands.length;n!=e;n++){var r=new u(t.hands[n]);(r.frame=this).hands.push(r),this.handsMap[r.id]=r}var o;t.pointables.sort((o="id",function(t,n){return t[o]>n[o]?1:n[o]>t[o]?-1:0}));for(var i=0,a=t.pointables.length;i!=a;i++){var s=t.pointables[i],s=new(s.dipPosition?h:c)(s);(s.frame=this).addPointable(s)}},n.prototype.addPointable=function(t){if(this.pointables.push(t),this.pointablesMap[t.id]=t,this.fingers.push(t),void 0!==t.handId&&this.handsMap.hasOwnProperty(t.handId)){var n=this.handsMap[t.handId];switch(n.pointables.push(t),n.fingers.push(t),t.type){case 0:n.thumb=t;break;case 1:n.indexFinger=t;break;case 2:n.middleFinger=t;break;case 3:n.ringFinger=t;break;case 4:n.pinky=t}}},n.prototype.pointable=function(t){return this.pointablesMap[t]||c.Invalid},n.prototype.finger=function(t){return this.pointable(t)},n.prototype.hand=function(t){return this.handsMap[t]||u.Invalid},n.prototype.rotationAngle=function(t,n){if(!this.valid||!t.valid)return 0;var e=this.rotationMatrix(t),e=.5*(e[0]+e[4]+e[8]-1),e=Math.acos(e),e=isNaN(e)?0:e;return void 0!==n&&(t=this.rotationAxis(t),e*=i.dot(t,i.normalize(i.create(),n))),e},n.prototype.rotationAxis=function(t){return this.valid&&t.valid?i.normalize(i.create(),[this._rotation[7]-t._rotation[5],this._rotation[2]-t._rotation[6],this._rotation[3]-t._rotation[1]]):i.create()},n.prototype.rotationMatrix=function(t){if(!this.valid||!t.valid)return o.create();var n=o.transpose(o.create(),this._rotation);return o.multiply(o.create(),t._rotation,n)},n.prototype.scaleFactor=function(t){return this.valid&&t.valid?Math.exp(this._scaleFactor-t._scaleFactor):1},n.prototype.translation=function(t){return this.valid&&t.valid?i.subtract(i.create(),this._translation,t._translation):i.create()},n.prototype.toString=function(){var t="Frame [ id:"+this.id+" | timestamp:"+this.timestamp+" | Hand count:("+this.hands.length+") | Pointable count:("+this.pointables.length+")";return t+=" ]"},n.prototype.dump=function(){var t="";t+="Frame Info:
",t+=this.toString(),t+="

Hands:
";for(var n=0,e=this.hands.length;n!=e;n++)t+=" "+this.hands[n].toString()+"
";t+="

Pointables:
";for(var r=0,o=this.pointables.length;r!=o;r++)t+=" "+this.pointables[r].toString()+"
";return t+="

Raw JSON:
",t+=JSON.stringify(this.data)},n.Invalid={valid:!1,hands:[],fingers:[],pointables:[],pointable:function(){return c.Invalid},finger:function(){return c.Invalid},hand:function(){return u.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return o.create()},rotationAxis:function(){return i.create()},scaleFactor:function(){return 1},translation:function(){return i.create()}}},{"./finger":8,"./hand":10,"./interaction_box":12,"./pointable":14,"gl-matrix":22}],10:[function(t,n,e){var r=t("./pointable"),o=t("./bone"),t=t("gl-matrix"),i=t.mat3,a=t.vec3,n=n.exports=function(t){this.id=t.id,this.palmPosition=t.palmPosition,this.direction=t.direction,this.palmVelocity=t.palmVelocity,this.palmNormal=t.palmNormal,this.sphereCenter=t.sphereCenter,this.sphereRadius=t.sphereRadius,this.valid=!0,this.pointables=[],this.fingers=[],t.armBasis?this.arm=new o(this,{type:4,width:t.armWidth,prevJoint:t.elbow,nextJoint:t.wrist,basis:t.armBasis}):this.arm=null,this._translation=t.t,this._rotation=function e(t){return Array.isArray(t)?t.reduce(function(t,n){return t.concat(e(n))},[]):[t]}(t.r),this._scaleFactor=t.s,this.timeVisible=t.timeVisible,this.stabilizedPalmPosition=t.stabilizedPalmPosition,this.type=t.type,this.grabStrength=t.grabStrength,this.pinchStrength=t.pinchStrength,this.confidence=t.confidence};n.prototype.finger=function(t){t=this.frame.finger(t);return t&&t.handId==this.id?t:r.Invalid},n.prototype.rotationAngle=function(t,n){if(!this.valid||!t.valid)return 0;if(!t.hand(this.id).valid)return 0;var e=this.rotationMatrix(t),e=.5*(e[0]+e[4]+e[8]-1),e=Math.acos(e),e=isNaN(e)?0:e;return void 0!==n&&(t=this.rotationAxis(t),e*=a.dot(t,a.normalize(a.create(),n))),e},n.prototype.rotationAxis=function(t){if(!this.valid||!t.valid)return a.create();t=t.hand(this.id);return t.valid?a.normalize(a.create(),[this._rotation[7]-t._rotation[5],this._rotation[2]-t._rotation[6],this._rotation[3]-t._rotation[1]]):a.create()},n.prototype.rotationMatrix=function(t){if(!this.valid||!t.valid)return i.create();var n=t.hand(this.id);if(!n.valid)return i.create();t=i.transpose(i.create(),this._rotation);return i.multiply(i.create(),n._rotation,t)},n.prototype.scaleFactor=function(t){if(!this.valid||!t.valid)return 1;t=t.hand(this.id);return t.valid?Math.exp(this._scaleFactor-t._scaleFactor):1},n.prototype.translation=function(t){if(!this.valid||!t.valid)return a.create();t=t.hand(this.id);return t.valid?[this._translation[0]-t._translation[0],this._translation[1]-t._translation[1],this._translation[2]-t._translation[2]]:a.create()},n.prototype.toString=function(){return"Hand ("+this.type+") [ id: "+this.id+" | palm velocity:"+this.palmVelocity+" | sphere center:"+this.sphereCenter+" ] "},n.prototype.pitch=function(){return Math.atan2(this.direction[1],-this.direction[2])},n.prototype.yaw=function(){return Math.atan2(this.direction[0],-this.direction[2])},n.prototype.roll=function(){return Math.atan2(this.palmNormal[0],-this.palmNormal[1])},n.Invalid={valid:!1,fingers:[],pointables:[],left:!1,pointable:function(){return r.Invalid},finger:function(){return r.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return i.create()},rotationAxis:function(){return a.create()},scaleFactor:function(){return 1},translation:function(){return a.create()}}},{"./bone":1,"./pointable":14,"gl-matrix":22}],11:[function(t,n,e){n.exports={Controller:t("./controller"),Frame:t("./frame"),Hand:t("./hand"),Pointable:t("./pointable"),Finger:t("./finger"),InteractionBox:t("./interaction_box"),CircularBuffer:t("./circular_buffer"),UI:t("./ui"),JSONProtocol:t("./protocol").JSONProtocol,glMatrix:t("gl-matrix"),mat3:t("gl-matrix").mat3,vec3:t("gl-matrix").vec3,loopController:void 0,version:t("./version.js"),EventEmitter:t("events").EventEmitter,loop:function(t,n){return t&&void 0===n&&"[object Function]"==={}.toString.call(t)&&(n=t,t={}),this.loopController?t&&this.loopController.setupFrameEvents(t):this.loopController=new this.Controller(t),this.loopController.loop(n),this.loopController},plugin:function(t,n){this.Controller.plugin(t,n)}}},{"./circular_buffer":2,"./controller":6,"./finger":8,"./frame":9,"./hand":10,"./interaction_box":12,"./pointable":14,"./protocol":15,"./ui":16,"./version.js":19,events:20,"gl-matrix":22}],12:[function(t,n,e){var r=t("gl-matrix").vec3,n=n.exports=function(t){this.valid=!0,this.center=t.center,this.size=t.size,this.width=t.size[0],this.height=t.size[1],this.depth=t.size[2]};n.prototype.denormalizePoint=function(t){return r.fromValues((t[0]-.5)*this.size[0]+this.center[0],(t[1]-.5)*this.size[1]+this.center[1],(t[2]-.5)*this.size[2]+this.center[2])},n.prototype.normalizePoint=function(t,n){t=r.fromValues((t[0]-this.center[0])/this.size[0]+.5,(t[1]-this.center[1])/this.size[1]+.5,(t[2]-this.center[2])/this.size[2]+.5);return n&&(t[0]=Math.min(Math.max(t[0],0),1),t[1]=Math.min(Math.max(t[1],0),1),t[2]=Math.min(Math.max(t[2],0),1)),t},n.prototype.toString=function(){return"InteractionBox [ width:"+this.width+" | height:"+this.height+" | depth:"+this.depth+" ]"},n.Invalid={valid:!1}},{"gl-matrix":22}],13:[function(t,n,e){n=n.exports=function(t){this.steps=[],this.controller=t};n.prototype.addStep=function(t){this.steps.push(t)},n.prototype.run=function(t){for(var n=this.steps.length,e=0;e!=n&&t;e++)t=this.steps[e](t);return t},n.prototype.removeStep=function(t){t=this.steps.indexOf(t);if(-1===t)throw"Step not found in pipeline";this.steps.splice(t,1)},n.prototype.addWrappedStep=function(o,i){function t(t){for(var n="frame"==o?[t]:t[o+"s"]||[],e=0,r=n.length;e=this.start.x&&e.x<=this.end.x&&e.y>=this.start.y&&e.y<=this.end.y&&e.z>=this.start.z&&e.z<=this.end.z)return!0}return!1},r.prototype.listener=function(t){var n=this;return t&&t.nearThreshold&&this.setupNearRegion(t.nearThreshold),function(t){return n.updatePosition(t)}},r.prototype.clipper=function(){var n=this;return function(t){return n.updatePosition(t),n.enteredFrame?t:null}},r.prototype.setupNearRegion=function(t){var t=this.nearRegion=new r([this.start.x-t,this.start.y-t,this.start.z-t],[this.end.x+t,this.end.y+t,this.end.z+t]),n=this;t.on("enter",function(t){n.emit("near",t)}),t.on("exit",function(t){n.emit("far",t)}),n.on("exit",function(t){n.emit("near",t)})},r.prototype.updatePosition=function(t){return this.nearRegion&&this.nearRegion.updatePosition(t),this.hasPointables(t)&&null==this.enteredFrame?(this.enteredFrame=t,this.emit("enter",this.enteredFrame)):this.hasPointables(t)||null==this.enteredFrame||(this.enteredFrame=null,this.emit("exit",this.enteredFrame)),t},r.prototype.normalize=function(t){return new Vector([(t.x-this.start.x)/(this.end.x-this.start.x),(t.y-this.start.y)/(this.end.y-this.start.y),(t.z-this.start.z)/(this.end.z-this.start.z)])},r.prototype.mapToXY=function(t,n,e){var r=this.normalize(t),o=r.x,t=r.y;return 1r&&(i.warned=!0,(r=new Error("Possible EventEmitter memory leak detected. "+i.length+' "'+String(n)+'" listeners added. Use emitter.setMaxListeners() to increase limit.')).name="MaxListenersExceededWarning",r.emitter=t,r.type=n,r.count=i.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",r.name,r.message))):(i=o[n]=e,++t._eventsCount),t}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),n=0;np.EPSILON?(t[0]=n[0]/r,t[1]=n[1]/r,t[2]=n[2]/r):(t[0]=1,t[1]=0,t[2]=0);return e},e.getAngle=function(t,n){n=b(t,n);return Math.acos(2*n*n-1)},e.multiply=l,e.rotateX=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e+a*n,t[1]=o*e+i*n,t[2]=i*e-o*n,t[3]=a*e-r*n,t},e.rotateY=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e-i*n,t[1]=o*e+a*n,t[2]=i*e+r*n,t[3]=a*e-o*n,t},e.rotateZ=function(t,n,e){e*=.5;var r=n[0],o=n[1],i=n[2],a=n[3],n=Math.sin(e),e=Math.cos(e);return t[0]=r*e+o*n,t[1]=o*e-r*n,t[2]=i*e+a*n,t[3]=a*e-i*n,t},e.calculateW=function(t,n){var e=n[0],r=n[1],n=n[2];return t[0]=e,t[1]=r,t[2]=n,t[3]=Math.sqrt(Math.abs(1-e*e-r*r-n*n)),t},e.exp=f,e.ln=d,e.pow=function(t,n,e){return d(t,n),y(t,t,e),f(t,t),t},e.slerp=m,e.random=function(t){var n=p.RANDOM(),e=p.RANDOM(),r=p.RANDOM(),o=Math.sqrt(1-n),n=Math.sqrt(n);return t[0]=o*Math.sin(2*Math.PI*e),t[1]=o*Math.cos(2*Math.PI*e),t[2]=n*Math.sin(2*Math.PI*r),t[3]=n*Math.cos(2*Math.PI*r),t},e.invert=function(t,n){var e=n[0],r=n[1],o=n[2],i=n[3],n=e*e+r*r+o*o+i*i,n=n?1/n:0;return t[0]=-e*n,t[1]=-r*n,t[2]=-o*n,t[3]=i*n,t},e.conjugate=function(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t},e.fromMat3=v,e.fromEuler=function(t,n,e,r){var o=.5*Math.PI/180;n*=o,e*=o,r*=o;var i=Math.sin(n),a=Math.cos(n),o=Math.sin(e),n=Math.cos(e),e=Math.sin(r),r=Math.cos(r);return t[0]=i*n*r-a*o*e,t[1]=a*o*r+i*n*e,t[2]=a*n*e-i*o*r,t[3]=a*n*r+i*o*e,t},e.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},e.setAxes=e.sqlerp=e.rotationTo=e.equals=e.exactEquals=e.normalize=e.sqrLen=e.squaredLength=e.len=e.length=e.lerp=e.dot=e.scale=e.mul=e.add=e.set=e.copy=e.fromValues=e.clone=void 0;var p=u(t("./common.js")),r=u(t("./mat3.js")),o=u(t("./vec3.js")),i=u(t("./vec4.js"));function s(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return s=function(){return t},t}function u(t){if(t&&t.__esModule)return t;if(null===t||"object"!==a(t)&&"function"!=typeof t)return{default:t};var n=s();if(n&&n.has(t))return n.get(t);var e,r,o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&((r=i?Object.getOwnPropertyDescriptor(t,e):null)&&(r.get||r.set)?Object.defineProperty(o,e,r):o[e]=t[e]);return o.default=t,n&&n.set(t,o),o}function c(){var t=new p.ARRAY_TYPE(4);return p.ARRAY_TYPE!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function h(t,n,e){e*=.5;var r=Math.sin(e);return t[0]=r*n[0],t[1]=r*n[1],t[2]=r*n[2],t[3]=Math.cos(e),t}function l(t,n,e){var r=n[0],o=n[1],i=n[2],a=n[3],s=e[0],u=e[1],n=e[2],e=e[3];return t[0]=r*e+a*s+o*n-i*u,t[1]=o*e+a*u+i*s-r*n,t[2]=i*e+a*n+r*u-o*s,t[3]=a*e-r*s-o*u-i*n,t}function f(t,n){var e=n[0],r=n[1],o=n[2],i=n[3],a=Math.sqrt(e*e+r*r+o*o),n=Math.exp(i),i=0p.EPSILON?(e=Math.acos(n),n=Math.sin(e),o=Math.sin((1-r)*e)/n,Math.sin(r*e)/n):(o=1-r,r),t[0]=o*i+r*c,t[1]=o*a+r*h,t[2]=o*s+r*l,t[3]=o*u+r*f,t}function v(t,n){var e,r,o,i=n[0]+n[4]+n[8];return 0n[0]&&(e=1),n[8]>n[3*e+e]&&(e=2),r=(e+1)%3,i=(e+2)%3,o=Math.sqrt(n[3*e+e]-n[3*r+r]-n[3*i+i]+1),t[e]=.5*o,o=.5/o,t[3]=(n[3*r+i]-n[3*i+r])*o,t[r]=(n[3*r+e]+n[3*e+r])*o,t[i]=(n[3*i+e]+n[3*e+i])*o),t}t=i.clone;e.clone=t;t=i.fromValues;e.fromValues=t;t=i.copy;e.copy=t;t=i.set;e.set=t;t=i.add;e.add=t,e.mul=l;var y=i.scale;e.scale=y;var b=i.dot;e.dot=b;t=i.lerp;e.lerp=t;t=i.length;e.length=t,e.len=t;t=i.squaredLength;e.squaredLength=t,e.sqrLen=t;var M=i.normalize;e.normalize=M;t=i.exactEquals;e.exactEquals=t;i=i.equals;e.equals=i;var g,w,P,i=(g=o.create(),w=o.fromValues(1,0,0),P=o.fromValues(0,1,0),function(t,n,e){var r=o.dot(n,e);return r<-.999999?(o.cross(g,w,n),o.len(g)<1e-6&&o.cross(g,P,n),o.normalize(g,g),h(t,g,Math.PI),t):.999999