-
Notifications
You must be signed in to change notification settings - Fork 0
/
CindyLeap.js
376 lines (374 loc) · 181 KB
/
CindyLeap.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
(function(){
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(f){var m=0;return function(){return m<f.length?{done:!1,value:f[m++]}:{done:!0}}};$jscomp.arrayIterator=function(f){return{next:$jscomp.arrayIteratorImpl(f)}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(f,m,J){if(f==Array.prototype||f==Object.prototype)return f;f[m]=J.value;return f};$jscomp.getGlobal=function(f){f=["object"==typeof globalThis&&globalThis,f,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var m=0;m<f.length;++m){var J=f[m];if(J&&J.Math==Math)return J}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(f,m){var J=$jscomp.propertyToPolyfillSymbol[m];if(null==J)return f[m];J=f[J];return void 0!==J?J:f[m]};
$jscomp.polyfill=function(f,m,J,v){m&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(f,m,J,v):$jscomp.polyfillUnisolated(f,m,J,v))};$jscomp.polyfillUnisolated=function(f,m,J,v){J=$jscomp.global;f=f.split(".");for(v=0;v<f.length-1;v++){var n=f[v];if(!(n in J))return;J=J[n]}f=f[f.length-1];v=J[f];m=m(v);m!=v&&null!=m&&$jscomp.defineProperty(J,f,{configurable:!0,writable:!0,value:m})};
$jscomp.polyfillIsolated=function(f,m,J,v){var n=f.split(".");f=1===n.length;v=n[0];v=!f&&v in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var r=0;r<n.length-1;r++){var t=n[r];if(!(t in v))return;v=v[t]}n=n[n.length-1];J=$jscomp.IS_SYMBOL_NATIVE&&"es6"===J?v[n]:null;m=m(J);null!=m&&(f?$jscomp.defineProperty($jscomp.polyfills,n,{configurable:!0,writable:!0,value:m}):m!==J&&(void 0===$jscomp.propertyToPolyfillSymbol[n]&&(J=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[n]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(n):$jscomp.POLYFILL_PREFIX+J+"$"+n),$jscomp.defineProperty(v,$jscomp.propertyToPolyfillSymbol[n],{configurable:!0,writable:!0,value:m})))};$jscomp.initSymbol=function(){};$jscomp.iteratorPrototype=function(f){f={next:f};f[Symbol.iterator]=function(){return this};return f};
$jscomp.iteratorFromArray=function(f,m){f instanceof String&&(f+="");var J=0,v=!1,n={next:function(){if(!v&&J<f.length){var r=J++;return{value:m(r,f[r]),done:!1}}v=!0;return{done:!0,value:void 0}}};n[Symbol.iterator]=function(){return n};return n};$jscomp.polyfill("Array.prototype.values",function(f){return f?f:function(){return $jscomp.iteratorFromArray(this,function(m,J){return J})}},"es8","es3");
let coerce={toList:function(f,m=null){return"list"!==f.ctype?(console.log("argument is not a list"),m):f.value},toHomog:function(f,m=[0,0,0,0],J=3){f=coerce.toList(f);if(null===f)return m;m=f.map(coerce.toReal);m.length>J+1&&(console.log("Coordinate vector too long."),m=m.slice(0,J+1));for(;m.length<J;)m.push(0);m.length===J&&m.push(1);return m},toDirection:function(f,m=[0,0,0]){f=coerce.toList(f);if(null===f)return m;m=f.map(coerce.toReal);3<m.length&&(console.log("Coordinate vector too long."),
m=m.slice(0,3));for(;3>m.length;)m.push(0);return m},toDirectionPoint:function(f,m=[0,0,0,0]){f=coerce.toDirection(f,m);f!==m&&(f[3]=0);return f},toColor:function(f,m=[.5,.5,.5]){if("number"===f.ctype){let J=coerce.toInterval(0,1,f);if(!isNaN(J))return[J,J,J]}f=coerce.toList(f);return null===f?m:3!=f.length?(console.log("Not an RGB color vector"),m):f.map(J=>coerce.toInterval(0,1,J))},toReal:function(f,m=Number.NaN){if("number"!==f.ctype)return console.log("argument is not a number"),m;f=f.value;
m=f.real;0!==f.imag&&console.log("complex number is not real");return m},toInt:function(f,m=Number.NaN){if("number"!==f.ctype)return console.log("argument is not a number"),m;m=f.value;f=m.real;m=m.imag;0!==m&&console.log("complex number is not real");m=Math.round(f);m!==f&&console.log("number is not an integer");return m},clamp:function(f,m,J){return J<f?f:J>m?m:J},toInterval:function(f,m,J,v=Number.NaN){return coerce.clamp(f,m,coerce.toReal(J,v))},toString:function(f,m=null){if("string"===f.ctype)return f.value;
console.log("argument is not a string");return m},toEnum:function(f,m,J=null){m=coerce.toString(m,J);if(m!==J&&-1!==f.indexOf(m))return m;console.log("argument is not one of "+f.join(", "));return J},toBool:function(f,m){if("boolean"===f.ctype)return f.value;console.log("argument is not boolean");return m}};function norm3(f){let m=f[0],J=f[1];f=f[2];return Math.sqrt(m*m+J*J+f*f)}function normalized3(f){let m=f[0],J=f[1];f=f[2];let v=1/Math.sqrt(m*m+J*J+f*f);return[v*m,v*J,v*f]}function dehom3(f){let m=1/f[3];return[m*f[0],m*f[1],m*f[2]]}function scale3(f,m){return[f*m[0],f*m[1],f*m[2]]}function transpose3(f){return[f[0],f[3],f[6],f[1],f[4],f[7],f[2],f[5],f[8]]}function transpose4(f){return[f[0],f[4],f[8],f[12],f[1],f[5],f[9],f[13],f[2],f[6],f[10],f[14],f[3],f[7],f[11],f[15]]}
function adj3(f){return[f[4]*f[8]-f[5]*f[7],f[2]*f[7]-f[1]*f[8],f[1]*f[5]-f[2]*f[4],f[5]*f[6]-f[3]*f[8],f[0]*f[8]-f[2]*f[6],f[2]*f[3]-f[0]*f[5],f[3]*f[7]-f[4]*f[6],f[1]*f[6]-f[0]*f[7],f[0]*f[4]-f[1]*f[3]]}function sub3(f,m){return[f[0]-m[0],f[1]-m[1],f[2]-m[2]]}function add3(f,m){return[f[0]+m[0],f[1]+m[1],f[2]+m[2]]}function add4(f,m){return[f[0]+m[0],f[1]+m[1],f[2]+m[2],f[3]+m[3]]}function cross3(f,m){return[f[1]*m[2]-f[2]*m[1],f[2]*m[0]-f[0]*m[2],f[0]*m[1]-f[1]*m[0]]}
function mul4mm(f,m){return[f[0]*m[0]+f[1]*m[4]+f[2]*m[8]+f[3]*m[12],f[0]*m[1]+f[1]*m[5]+f[2]*m[9]+f[3]*m[13],f[0]*m[2]+f[1]*m[6]+f[2]*m[10]+f[3]*m[14],f[0]*m[3]+f[1]*m[7]+f[2]*m[11]+f[3]*m[15],f[4]*m[0]+f[5]*m[4]+f[6]*m[8]+f[7]*m[12],f[4]*m[1]+f[5]*m[5]+f[6]*m[9]+f[7]*m[13],f[4]*m[2]+f[5]*m[6]+f[6]*m[10]+f[7]*m[14],f[4]*m[3]+f[5]*m[7]+f[6]*m[11]+f[7]*m[15],f[8]*m[0]+f[9]*m[4]+f[10]*m[8]+f[11]*m[12],f[8]*m[1]+f[9]*m[5]+f[10]*m[9]+f[11]*m[13],f[8]*m[2]+f[9]*m[6]+f[10]*m[10]+f[11]*m[14],f[8]*m[3]+f[9]*
m[7]+f[10]*m[11]+f[11]*m[15],f[12]*m[0]+f[13]*m[4]+f[14]*m[8]+f[15]*m[12],f[12]*m[1]+f[13]*m[5]+f[14]*m[9]+f[15]*m[13],f[12]*m[2]+f[13]*m[6]+f[14]*m[10]+f[15]*m[14],f[12]*m[3]+f[13]*m[7]+f[14]*m[11]+f[15]*m[15]]}function mul3mv(f,m){return[f[0]*m[0]+f[1]*m[1]+f[2]*m[2],f[3]*m[0]+f[4]*m[1]+f[5]*m[2],f[6]*m[0]+f[7]*m[1]+f[8]*m[2]]}
function mul4mv(f,m){return[f[0]*m[0]+f[1]*m[1]+f[2]*m[2]+f[3]*m[3],f[4]*m[0]+f[5]*m[1]+f[6]*m[2]+f[7]*m[3],f[8]*m[0]+f[9]*m[1]+f[10]*m[2]+f[11]*m[3],f[12]*m[0]+f[13]*m[1]+f[14]*m[2]+f[15]*m[3]]}function transform4to3(f,m){let J=1/(f[12]*m[0]+f[13]*m[1]+f[14]*m[2]+f[15]*m[3]);return[(f[0]*m[0]+f[1]*m[1]+f[2]*m[2]+f[3]*m[3])*J,(f[4]*m[0]+f[5]*m[1]+f[6]*m[2]+f[7]*m[3])*J,(f[8]*m[0]+f[9]*m[1]+f[10]*m[2]+f[11]*m[3])*J]}
function triangleNormal(f,m,J){f=dehom3(f);m=sub3(dehom3(m),f);J=sub3(dehom3(J),f);return normalized3(cross3(m,J))};function nestedArrayToCSList(f){return Array.isArray(f)?{ctype:"list",value:f.map(m=>nestedArrayToCSList(m))}:{ctype:"number",value:{real:f,imag:0}}}
function convertObjectToCindyDict(f,m,J){if(f instanceof Object&&J.has(f))return J.get(f);if(Array.isArray(f)){let r=[];f.forEach(function(t){t=convertObjectToCindyDict(t,m,J);null!=t&&r.push(t)});return{ctype:"list",value:r}}if("string"===typeof f||f instanceof String)return{ctype:"string",value:f};if("number"===typeof f&&isFinite(f))return{ctype:"number",value:{real:f,imag:0}};if("boolean"===typeof f)return{ctype:"boolean",value:f};if(null===f||"undefined"===typeof f||"function"===typeof f)return null;
let v={},n=new Map(J);n.set(f,v);for(let r in f)if(!m.has(r)&&f.hasOwnProperty(r)){let t=convertObjectToCindyDict(f[r],m,n);v[r]=t}return{ctype:"JSON",value:v}};(function(f){"object"===typeof exports&&"undefined"!==typeof module?module.exports=f():"function"===typeof define&&define.amd?define([],f):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Leap=f()})(function(){return function(){function f(m,J,v){function n(K,E){if(!J[K]){if(!m[K]){var U="function"==typeof require&&require;if(!E&&U)return U(K,!0);if(r)return r(K,!0);E=Error("Cannot find module '"+K+"'");throw E.code="MODULE_NOT_FOUND",E;}E=
J[K]={exports:{}};m[K][0].call(E.exports,function(M){return n(m[K][1][M]||M)},E,E.exports,f,m,J,v)}return J[K].exports}for(var r="function"==typeof require&&require,t=0;t<v.length;t++)n(v[t]);return n}return f}()({1:[function(f,m,J){function v(){v.init.call(this)}function n(a){if("function"!==typeof a)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof a);}function r(a,b,d,e){n(d);var g=a._events;if(void 0===g)g=a._events=Object.create(null),a._eventsCount=
0;else{void 0!==g.newListener&&(a.emit("newListener",b,d.listener?d.listener:d),g=a._events);var l=g[b]}void 0===l?(g[b]=d,++a._eventsCount):("function"===typeof l?l=g[b]=e?[d,l]:[l,d]:e?l.unshift(d):l.push(d),d=void 0===a._maxListeners?v.defaultMaxListeners:a._maxListeners,0<d&&l.length>d&&!l.warned&&(l.warned=!0,d=Error("Possible EventEmitter memory leak detected. "+l.length+" "+String(b)+" listeners added. Use emitter.setMaxListeners() to increase limit"),d.name="MaxListenersExceededWarning",d.emitter=
a,d.type=b,d.count=l.length,console&&console.warn&&console.warn(d)));return a}function t(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function K(a,b,d){a={fired:!1,wrapFn:void 0,target:a,type:b,listener:d};b=t.bind(a);b.listener=d;return a.wrapFn=b}function E(a,b,d){a=a._events;if(void 0===a)return[];b=a[b];if(void 0===b)return[];if("function"===typeof b)return d?
[b.listener||b]:[b];if(d)for(d=Array(b.length),a=0;a<d.length;++a)d[a]=b[a].listener||b[a];else d=M(b,b.length);return d}function U(a){var b=this._events;if(void 0!==b){a=b[a];if("function"===typeof a)return 1;if(void 0!==a)return a.length}return 0}function M(a,b){for(var d=Array(b),e=0;e<b;++e)d[e]=a[e];return d}function w(a,b,d){"function"===typeof a.on&&N(a,"error",b,d)}function N(a,b,d,e){if("function"===typeof a.on)if(e.once)a.once(b,d);else a.on(b,d);else if("function"===typeof a.addEventListener)a.addEventListener(b,
function u(l){e.once&&a.removeEventListener(b,u);d(l)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof a);}var R=(f="object"===typeof Reflect?Reflect:null)&&"function"===typeof f.apply?f.apply:function(a,b,d){return Function.prototype.apply.call(a,b,d)};var F=f&&"function"===typeof f.ownKeys?f.ownKeys:Object.getOwnPropertySymbols?function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:function(a){return Object.getOwnPropertyNames(a)};
var A=Number.isNaN||function(a){return a!==a};m.exports=v;m.exports.once=function(a,b){return new Promise(function(d,e){function g(u){a.removeListener(b,l);e(u)}function l(){"function"===typeof a.removeListener&&a.removeListener("error",g);d([].slice.call(arguments))}N(a,b,l,{once:!0});"error"!==b&&w(a,g,{once:!0})})};v.EventEmitter=v;v.prototype._events=void 0;v.prototype._eventsCount=0;v.prototype._maxListeners=void 0;var c=10;Object.defineProperty(v,"defaultMaxListeners",{enumerable:!0,get:function(){return c},
set:function(a){if("number"!==typeof a||0>a||A(a))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+a+".");c=a}});v.init=function(){if(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)this._events=Object.create(null),this._eventsCount=0;this._maxListeners=this._maxListeners||void 0};v.prototype.setMaxListeners=function(a){if("number"!==typeof a||0>a||A(a))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+
a+".");this._maxListeners=a;return this};v.prototype.getMaxListeners=function(){return void 0===this._maxListeners?v.defaultMaxListeners:this._maxListeners};v.prototype.emit=function(a){for(var b=[],d=1;d<arguments.length;d++)b.push(arguments[d]);d="error"===a;var e=this._events;if(void 0!==e)d=d&&void 0===e.error;else if(!d)return!1;if(d){var g;0<b.length&&(g=b[0]);if(g instanceof Error)throw g;b=Error("Unhandled error."+(g?" ("+g.message+")":""));b.context=g;throw b;}d=e[a];if(void 0===d)return!1;
if("function"===typeof d)R(d,this,b);else for(g=d.length,e=M(d,g),d=0;d<g;++d)R(e[d],this,b);return!0};v.prototype.addListener=function(a,b){return r(this,a,b,!1)};v.prototype.on=v.prototype.addListener;v.prototype.prependListener=function(a,b){return r(this,a,b,!0)};v.prototype.once=function(a,b){n(b);this.on(a,K(this,a,b));return this};v.prototype.prependOnceListener=function(a,b){n(b);this.prependListener(a,K(this,a,b));return this};v.prototype.removeListener=function(a,b){var d;n(b);var e=this._events;
if(void 0===e)return this;var g=e[a];if(void 0===g)return this;if(g===b||g.listener===b)0===--this._eventsCount?this._events=Object.create(null):(delete e[a],e.removeListener&&this.emit("removeListener",a,g.listener||b));else if("function"!==typeof g){var l=-1;for(d=g.length-1;0<=d;d--)if(g[d]===b||g[d].listener===b){var u=g[d].listener;l=d;break}if(0>l)return this;if(0===l)g.shift();else{for(;l+1<g.length;l++)g[l]=g[l+1];g.pop()}1===g.length&&(e[a]=g[0]);void 0!==e.removeListener&&this.emit("removeListener",
a,u||b)}return this};v.prototype.off=v.prototype.removeListener;v.prototype.removeAllListeners=function(a){var b=this._events;if(void 0===b)return this;if(void 0===b.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==b[a]&&(0===--this._eventsCount?this._events=Object.create(null):delete b[a]),this;if(0===arguments.length){var d=Object.keys(b);for(b=0;b<d.length;++b){var e=d[b];"removeListener"!==e&&this.removeAllListeners(e)}this.removeAllListeners("removeListener");
this._events=Object.create(null);this._eventsCount=0;return this}d=b[a];if("function"===typeof d)this.removeListener(a,d);else if(void 0!==d)for(b=d.length-1;0<=b;b--)this.removeListener(a,d[b]);return this};v.prototype.listeners=function(a){return E(this,a,!0)};v.prototype.rawListeners=function(a){return E(this,a,!1)};v.listenerCount=function(a,b){return"function"===typeof a.listenerCount?a.listenerCount(b):U.call(a,b)};v.prototype.listenerCount=U;v.prototype.eventNames=function(){return 0<this._eventsCount?
F(this._events):[]}},{}],2:[function(f,m,J){f("./pointable");J=f("gl-matrix");var v=J.vec3,n=J.mat3,r=J.mat4;f("underscore");f=m.exports=function(t,K){this.finger=t;this._matrix=this._center=null;this.type=K.type;this.prevJoint=K.prevJoint;this.nextJoint=K.nextJoint;this.width=K.width;t=Array(3);v.sub(t,K.nextJoint,K.prevJoint);this.length=v.length(t);this.basis=K.basis};f.prototype.left=function(){return this._left?this._left:this._left=0>n.determinant(this.basis[0].concat(this.basis[1]).concat(this.basis[2]))};
f.prototype.matrix=function(){if(this._matrix)return this._matrix;var t=this.basis,K=this._matrix=r.create();K[0]=t[0][0];K[1]=t[0][1];K[2]=t[0][2];K[4]=t[1][0];K[5]=t[1][1];K[6]=t[1][2];K[8]=t[2][0];K[9]=t[2][1];K[10]=t[2][2];K[3]=this.center()[0];K[7]=this.center()[1];K[11]=this.center()[2];this.left()&&(K[0]*=-1,K[1]*=-1,K[2]*=-1);return this._matrix};f.prototype.lerp=function(t,K){v.lerp(t,this.prevJoint,this.nextJoint,K)};f.prototype.center=function(){if(this._center)return this._center;var t=
v.create();this.lerp(t,.5);return this._center=t};f.prototype.direction=function(){return[-1*this.basis[2][0],-1*this.basis[2][1],-1*this.basis[2][2]]}},{"./pointable":16,"gl-matrix":22,underscore:25}],3:[function(f,m,J){f=m.exports=function(v){this.pos=0;this._buf=[];this.size=v};f.prototype.get=function(v){void 0==v&&(v=0);if(!(v>=this.size||v>=this._buf.length))return this._buf[(this.pos-v-1)%this.size]};f.prototype.push=function(v){this._buf[this.pos%this.size]=v;return this.pos++}},{}],4:[function(f,
m,J){var v=f("../protocol").chooseProtocol;J=f("events").EventEmitter;var n=f("underscore"),r=m.exports=function(t){this.opts=n.defaults(t||{},{host:"127.0.0.1",enableGestures:!1,scheme:this.getScheme(),port:this.getPort(),background:!1,optimizeHMD:!1,requestProtocolVersion:r.defaultProtocolVersion});this.host=this.opts.host;this.port=this.opts.port;this.scheme=this.opts.scheme;this.protocolVersionVerified=!1;this.optimizeHMD=this.background=null;this.on("ready",function(){this.enableGestures(this.opts.enableGestures);
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.")})};r.defaultProtocolVersion=6;r.prototype.getUrl=function(){return this.scheme+"//"+this.host+":"+this.port+"/v"+this.opts.requestProtocolVersion+".json"};r.prototype.getScheme=function(){return"ws:"};r.prototype.getPort=function(){return 6437};r.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))};r.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))};r.prototype.handleOpen=function(){this.connected||(this.connected=!0,
this.emit("connect"))};r.prototype.enableGestures=function(t){this.gesturesEnabled=t?!0:!1;this.send(this.protocol.encode({enableGestures:this.gesturesEnabled}))};r.prototype.handleClose=function(t,K){this.connected&&(this.disconnect(),1001===t&&1<this.opts.requestProtocolVersion&&(this.protocolVersionVerified?this.protocolVersionVerified=!1:this.opts.requestProtocolVersion--),this.startReconnection())};r.prototype.startReconnection=function(){var t=this;this.reconnectionTimer||(this.reconnectionTimer=
setInterval(function(){t.reconnect()},500))};r.prototype.stopReconnection=function(){this.reconnectionTimer=clearInterval(this.reconnectionTimer)};r.prototype.disconnect=function(t){t||this.stopReconnection();if(this.socket)return this.socket.close(),delete this.socket,delete this.protocol,delete this.background,delete this.optimizeHMD,delete this.focusedState,this.connected&&(this.connected=!1,this.emit("disconnect")),!0};r.prototype.reconnect=function(){this.connected?this.stopReconnection():(this.disconnect(!0),
this.connect())};r.prototype.handleData=function(t){t=JSON.parse(t);void 0===this.protocol?(t=this.protocol=v(t),this.protocolVersionVerified=!0,this.emit("ready")):t=this.protocol(t);this.emit(t.type,t)};r.prototype.connect=function(){if(!this.socket)return this.socket=this.setupSocket(),!0};r.prototype.send=function(t){this.socket.send(t)};r.prototype.reportFocus=function(t){this.connected&&this.focusedState!==t&&(this.focusedState=t,this.emit(this.focusedState?"focus":"blur"),this.protocol&&this.protocol.sendFocused&&
this.protocol.sendFocused(this,this.focusedState))};n.extend(r.prototype,J.prototype)},{"../protocol":17,events:1,underscore:25}],5:[function(f,m,J){var v=m.exports=f("./base");f=f("underscore");m=m.exports=function(n){v.call(this,n);var r=this;this.on("ready",function(){r.startFocusLoop()});this.on("disconnect",function(){r.stopFocusLoop()})};f.extend(m.prototype,v.prototype);m.__proto__=v;m.prototype.useSecure=function(){return"https:"===location.protocol};m.prototype.getScheme=function(){return this.useSecure()?
"wss:":"ws:"};m.prototype.getPort=function(){return this.useSecure()?6436:6437};m.prototype.setupSocket=function(){var n=this,r=new WebSocket(this.getUrl());r.onopen=function(){n.handleOpen()};r.onclose=function(t){n.handleClose(t.code,t.reason)};r.onmessage=function(t){n.handleData(t.data)};r.onerror=function(t){n.useSecure()&&"wss:"===n.scheme&&(n.scheme="ws:",n.port=6437,n.disconnect(),n.connect())};return r};m.prototype.startFocusLoop=function(){if(!this.focusDetectorTimer){var n=this,r=null;
r="undefined"!==typeof document.hidden?"hidden":"undefined"!==typeof document.mozHidden?"mozHidden":"undefined"!==typeof document.msHidden?"msHidden":"undefined"!==typeof document.webkitHidden?"webkitHidden":void 0;void 0===n.windowVisible&&(n.windowVisible=void 0===r?!0:!1===document[r]);var t=window.addEventListener("focus",function(U){n.windowVisible=!0;E()}),K=window.addEventListener("blur",function(U){n.windowVisible=!1;E()});this.on("disconnect",function(){window.removeEventListener("focus",
t);window.removeEventListener("blur",K)});var E=function(){n.reportFocus((void 0===r?!0:!1===document[r])&&n.windowVisible)};E();this.focusDetectorTimer=setInterval(E,100)}};m.prototype.stopFocusLoop=function(){this.focusDetectorTimer&&(clearTimeout(this.focusDetectorTimer),delete this.focusDetectorTimer)}},{"./base":4,underscore:25}],6:[function(f,m,J){var v=f("ws"),n=f("./base");f=f("underscore");m=m.exports=function(r){n.call(this,r);var t=this;this.on("ready",function(){t.reportFocus(!0)})};f.extend(m.prototype,
n.prototype);m.__proto__=n;m.prototype.setupSocket=function(){var r=this,t=new v(this.getUrl());t.on("open",function(){r.handleOpen()});t.on("message",function(K){r.handleData(K)});t.on("close",function(K,E){r.handleClose(K,E)});t.on("error",function(){r.startReconnection()});return t}},{"./base":4,underscore:25,ws:23}],7:[function(f,m,J){(function(v){(function(){var n=f("./frame"),r=f("./hand"),t=f("./pointable"),K=f("./finger"),E=f("./circular_buffer"),U=f("./pipeline"),M=f("events").EventEmitter,
w=f("./gesture").gestureListener,N=f("./dialog"),R=f("underscore"),F=m.exports=function(A){var c=this;A=R.defaults(A||{},{inNode:"undefined"!==typeof v&&v.versions&&v.versions.node});this.inNode=A.inNode;A=R.defaults(A||{},{frameEventName:this.useAnimationLoop()?"animationFrame":"deviceFrame",suppressAnimationLoop:!this.useAnimationLoop(),loopWhileDisconnected:!0,useAllPlugins:!1,checkVersion:!0});this.animationFrameRequested=!1;this.onAnimationFrame=function(a){c.lastConnectionFrame.valid&&c.emit("animationFrame",
c.lastConnectionFrame);c.emit("frameEnd",a);c.loopWhileDisconnected&&(!1!==c.connection.focusedState||c.connection.opts.background)?window.requestAnimationFrame(c.onAnimationFrame):c.animationFrameRequested=!1};this.suppressAnimationLoop=A.suppressAnimationLoop;this.loopWhileDisconnected=A.loopWhileDisconnected;this.frameEventName=A.frameEventName;this.useAllPlugins=A.useAllPlugins;this.history=new E(200);this.lastConnectionFrame=this.lastValidFrame=this.lastFrame=n.Invalid;this.accumulatedGestures=
[];this.checkVersion=A.checkVersion;this.connectionType=void 0===A.connectionType?this.inBrowser()?f("./connection/browser"):f("./connection/node"):A.connectionType;this.connection=new this.connectionType(A);this.streamingCount=0;this.devices={};this.plugins={};this._pluginPipelineSteps={};this._pluginExtendedMethods={};A.useAllPlugins&&this.useRegisteredPlugins();this.setupFrameEvents(A);this.setupConnectionEvents();this.startAnimationLoop()};F.prototype.gesture=function(A,c){A=w(this,A);void 0!==
c&&A.stop(c);return A};F.prototype.setBackground=function(A){this.connection.setBackground(A);return this};F.prototype.setOptimizeHMD=function(A){this.connection.setOptimizeHMD(A);return this};F.prototype.inBrowser=function(){return!this.inNode};F.prototype.useAnimationLoop=function(){return this.inBrowser()&&!this.inBackgroundPage()};F.prototype.inBackgroundPage=function(){return"undefined"!==typeof chrome&&chrome.extension&&chrome.extension.getBackgroundPage&&chrome.extension.getBackgroundPage()===
window};F.prototype.connect=function(){this.connection.connect();return this};F.prototype.streaming=function(){return 0<this.streamingCount};F.prototype.connected=function(){return!!this.connection.connected};F.prototype.startAnimationLoop=function(){this.suppressAnimationLoop||this.animationFrameRequested||(this.animationFrameRequested=!0,window.requestAnimationFrame(this.onAnimationFrame))};F.prototype.disconnect=function(){this.connection.disconnect();return this};F.prototype.frame=function(A){return this.history.get(A)||
n.Invalid};F.prototype.loop=function(A){if(A)if("function"===typeof A)this.on(this.frameEventName,A);else this.setupFrameEvents(A);return this.connect()};F.prototype.addStep=function(A){this.pipeline||(this.pipeline=new U(this));this.pipeline.addStep(A)};F.prototype.processFrame=function(A){A.gestures&&(this.accumulatedGestures=this.accumulatedGestures.concat(A.gestures));this.lastConnectionFrame=A;this.startAnimationLoop();this.emit("deviceFrame",A)};F.prototype.processFinishedFrame=function(A){this.lastFrame=
A;A.valid&&(this.lastValidFrame=A);A.controller=this;A.historyIdx=this.history.push(A);if(A.gestures){A.gestures=this.accumulatedGestures;this.accumulatedGestures=[];for(var c=0;c!=A.gestures.length;c++)this.emit("gesture",A.gestures[c],A)}this.pipeline&&(A=this.pipeline.run(A),A||(A=n.Invalid));this.emit("frame",A);this.emitHandEvents(A)};F.prototype.emitHandEvents=function(A){for(var c=0;c<A.hands.length;c++)this.emit("hand",A.hands[c])};F.prototype.setupFrameEvents=function(A){if(A.frame)this.on("frame",
A.frame);if(A.hand)this.on("hand",A.hand)};F.prototype.setupConnectionEvents=function(){var A=this;this.connection.on("frame",function(b){A.processFrame(b)});this.on(this.frameEventName,function(b){A.processFinishedFrame(b)});var c=function(){if(5>A.connection.opts.requestProtocolVersion&&0==A.streamingCount){A.streamingCount=1;var b={attached:!0,streaming:!0,type:"unknown",id:"Lx00000000000"};A.devices[b.id]=b;A.emit("deviceAttached",b);A.emit("deviceStreaming",b);A.emit("streamingStarted",b);A.connection.removeListener("frame",
c)}},a=function(){if(0<A.streamingCount){for(var b in A.devices)A.emit("deviceStopped",A.devices[b]),A.emit("deviceRemoved",A.devices[b]);A.emit("streamingStopped",A.devices[b]);A.streamingCount=0;for(b in A.devices)delete A.devices[b]}};this.connection.on("focus",function(){A.loopWhileDisconnected&&A.startAnimationLoop();A.emit("focus")});this.connection.on("blur",function(){A.emit("blur")});this.connection.on("protocol",function(b){b.on("beforeFrameCreated",function(d){A.emit("beforeFrameCreated",
d)});b.on("afterFrameCreated",function(d,e){A.emit("afterFrameCreated",d,e)});A.emit("protocol",b)});this.connection.on("ready",function(){A.checkVersion&&!A.inNode&&A.checkOutOfDate();A.emit("ready")});this.connection.on("connect",function(){A.emit("connect");A.connection.removeListener("frame",c);A.connection.on("frame",c)});this.connection.on("disconnect",function(){A.emit("disconnect");a()});this.connection.on("deviceConnect",function(b){b.state?(A.emit("deviceConnected"),A.connection.removeListener("frame",
c),A.connection.on("frame",c)):(A.emit("deviceDisconnected"),a())});this.connection.on("deviceEvent",function(b){b=b.state;var d=A.devices[b.id],e={},g;for(g in b)d&&d.hasOwnProperty(g)&&d[g]==b[g]||(e[g]=!0);A.devices[b.id]=b;e.attached&&A.emit(b.attached?"deviceAttached":"deviceRemoved",b);e.streaming&&(b.streaming?(A.streamingCount++,A.emit("deviceStreaming",b),1==A.streamingCount&&A.emit("streamingStarted",b),e.attached||A.emit("deviceConnected")):e.attached&&b.attached||(A.streamingCount--,A.emit("deviceStopped",
b),0==A.streamingCount&&A.emit("streamingStopped",b),A.emit("deviceDisconnected")))});this.on("newListener",function(b,d){"deviceConnected"!=b&&"deviceDisconnected"!=b||console.warn(b+" events are depricated. Consider using 'streamingStarted/streamingStopped' or 'deviceStreaming/deviceStopped' instead")})};F.prototype.checkOutOfDate=function(){console.assert(this.connection&&this.connection.protocol);var A=this.connection.protocol.serviceVersion,c=this.connection.protocol.version,a=this.connectionType.defaultProtocolVersion;
return a>c?(console.warn("Your Protocol Version is v"+c+", this app was designed for v"+a),N.warnOutOfDate({sV:A,pV:c}),!0):!1};F._pluginFactories={};F.plugin=function(A,c){this._pluginFactories[A]&&console.warn('Plugin "'+A+'" already registered');return this._pluginFactories[A]=c};F.plugins=function(){return R.keys(this._pluginFactories)};F.prototype.use=function(A,c){var a;var b="function"==typeof A?A:F._pluginFactories[A];if(!b)throw"Leap Plugin "+A+" not found.";c||(c={});if(this.plugins[A])return R.extend(this.plugins[A],
c),this;this.plugins[A]=c;c=b.call(this,c);for(a in c)if(b=c[a],"function"===typeof b){var d=A,e=a;if(-1!=["beforeFrameCreated","afterFrameCreated"].indexOf(e))this.on(e,b);else this.pipeline||(this.pipeline=new U(this)),this._pluginPipelineSteps[d]||(this._pluginPipelineSteps[d]=[]),this._pluginPipelineSteps[d].push(this.pipeline.addWrappedStep(e,b))}else{d=A;e=a;this._pluginExtendedMethods[d]||(this._pluginExtendedMethods[d]=[]);switch(e){case "frame":e=n;break;case "hand":e=r;break;case "pointable":e=
t;R.extend(K.prototype,b);R.extend(K.Invalid,b);break;case "finger":e=K;break;default:throw d+' specifies invalid object type "'+e+'" for prototypical extension';}R.extend(e.prototype,b);R.extend(e.Invalid,b);this._pluginExtendedMethods[d].push([e,b])}return this};F.prototype.stopUsing=function(A){var c=this._pluginPipelineSteps[A],a=this._pluginExtendedMethods[A],b;if(this.plugins[A]){if(c)for(b=0;b<c.length;b++)this.pipeline.removeStep(c[b]);if(a)for(b=0;b<a.length;b++){c=a[b][0];var d=a[b][1];
for(var e in d)delete c.prototype[e],delete c.Invalid[e]}delete this.plugins[A];return this}};F.prototype.useRegisteredPlugins=function(){for(var A in F._pluginFactories)this.use(A)};R.extend(F.prototype,M.prototype)}).call(this)}).call(this,f("_process"))},{"./circular_buffer":3,"./connection/browser":5,"./connection/node":6,"./dialog":8,"./finger":9,"./frame":10,"./gesture":11,"./hand":12,"./pipeline":15,"./pointable":16,_process:24,events:1,underscore:25}],8:[function(f,m,J){(function(v){(function(){var n=
m.exports=function(r,t){this.options=t||{};this.message=r;this.createElement()};n.prototype.createElement=function(){this.element=document.createElement("div");this.element.className="leapjs-dialog";this.element.style.position="fixed";this.element.style.top="8px";this.element.style.left=0;this.element.style.right=0;this.element.style.textAlign="center";this.element.style.zIndex=1E3;var r=document.createElement("div");this.element.appendChild(r);r.style.className="leapjs-dialog";r.style.display="inline-block";
r.style.margin="auto";r.style.padding="8px";r.style.color="#222";r.style.background="#eee";r.style.borderRadius="4px";r.style.border="1px solid #999";r.style.textAlign="left";r.style.cursor="pointer";r.style.whiteSpace="nowrap";r.style.transition="box-shadow 1s linear";r.innerHTML=this.message;this.options.onclick&&r.addEventListener("click",this.options.onclick);this.options.onmouseover&&r.addEventListener("mouseover",this.options.onmouseover);this.options.onmouseout&&r.addEventListener("mouseout",
this.options.onmouseout);this.options.onmousemove&&r.addEventListener("mousemove",this.options.onmousemove)};n.prototype.show=function(){document.body.appendChild(this.element);return this};n.prototype.hide=function(){document.body.removeChild(this.element);return this};n.warnOutOfDate=function(r){r||(r={});var t="http://developer.leapmotion.com?";r.returnTo=window.location.href;for(var K in r)t+=K+"="+encodeURIComponent(r[K])+"&";var E=new n("This site requires Leap Motion Tracking V2.<button id='leapjs-accept-upgrade' style='color: #444; transition: box-shadow 100ms linear; cursor: pointer; vertical-align: baseline; margin-left: 16px;'>Upgrade</button><button id='leapjs-decline-upgrade' style='color: #444; transition: box-shadow 100ms linear; cursor: pointer; vertical-align: baseline; margin-left: 8px; '>Not Now</button>",
{onclick:function(U){"leapjs-decline-upgrade"!=U.target.id&&(U=window.open(t,"_blank","height=800,width=1000,location=1,menubar=1,resizable=1,status=1,toolbar=1,scrollbars=1"),window.focus&&U.focus());E.hide();return!0},onmousemove:function(U){U.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 E.show()};n.hasWarnedBones=!1;n.warnBones=function(){this.hasWarnedBones||(this.hasWarnedBones=!0,console.warn("Your Leap Service is out of date"),"undefined"!==typeof v&&v.versions&&v.versions.node||this.warnOutOfDate({reason:"bones"}))}}).call(this)}).call(this,f("_process"))},{_process:24}],9:[function(f,m,J){var v=f("./pointable"),n=f("./bone"),
r=f("./dialog");f=f("underscore");m=m.exports=function(t){v.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):r.warnBones()};f.extend(m.prototype,v.prototype);m.prototype.addBones=function(t){this.metacarpal=new n(this,{type:0,
width:this.width,prevJoint:this.carpPosition,nextJoint:this.mcpPosition,basis:t.bases[0]});this.proximal=new n(this,{type:1,width:this.width,prevJoint:this.mcpPosition,nextJoint:this.pipPosition,basis:t.bases[1]});this.medial=new n(this,{type:2,width:this.width,prevJoint:this.pipPosition,nextJoint:this.dipPosition,basis:t.bases[2]});this.distal=new n(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]};m.prototype.toString=function(){return"Finger [ id:"+this.id+" "+this.length+"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"};m.Invalid={valid:!1}},{"./bone":2,"./dialog":8,"./pointable":16,underscore:25}],10:[function(f,m,J){var v=f("./hand"),n=f("./pointable"),r=f("./gesture").createGesture;J=f("gl-matrix");var t=J.mat3,K=J.vec3,E=f("./interaction_box"),U=f("./finger"),M=f("underscore");f=m.exports=function(w){this.valid=!0;this.id=w.id;this.timestamp=w.timestamp;this.hands=
[];this.handsMap={};this.pointables=[];this.tools=[];this.fingers=[];w.interactionBox&&(this.interactionBox=new E(w.interactionBox));this.gestures=[];this.pointablesMap={};this._translation=w.t;this._rotation=M.flatten(w.r);this._scaleFactor=w.s;this.data=w;this.type="frame";this.currentFrameRate=w.currentFrameRate;if(w.gestures)for(var N=0,R=w.gestures.length;N!=R;N++)this.gestures.push(r(w.gestures[N]));this.postprocessData(w)};f.prototype.postprocessData=function(w){w||(w=this.data);for(var N=
0,R=w.hands.length;N!=R;N++){var F=new v(w.hands[N]);F.frame=this;this.hands.push(F);this.handsMap[F.id]=F}w.pointables=M.sortBy(w.pointables,function(A){return A.id});N=0;for(R=w.pointables.length;N!=R;N++)F=w.pointables[N],F=F.dipPosition?new U(F):new n(F),F.frame=this,this.addPointable(F)};f.prototype.addPointable=function(w){this.pointables.push(w);this.pointablesMap[w.id]=w;(w.tool?this.tools:this.fingers).push(w);if(void 0!==w.handId&&this.handsMap.hasOwnProperty(w.handId)){var N=this.handsMap[w.handId];
N.pointables.push(w);(w.tool?N.tools:N.fingers).push(w);switch(w.type){case 0:N.thumb=w;break;case 1:N.indexFinger=w;break;case 2:N.middleFinger=w;break;case 3:N.ringFinger=w;break;case 4:N.pinky=w}}};f.prototype.tool=function(w){w=this.pointable(w);return w.tool?w:n.Invalid};f.prototype.pointable=function(w){return this.pointablesMap[w]||n.Invalid};f.prototype.finger=function(w){w=this.pointable(w);return w.tool?n.Invalid:w};f.prototype.hand=function(w){return this.handsMap[w]||v.Invalid};f.prototype.rotationAngle=
function(w,N){if(!this.valid||!w.valid)return 0;var R=this.rotationMatrix(w);R=Math.acos(.5*(R[0]+R[4]+R[8]-1));R=isNaN(R)?0:R;void 0!==N&&(w=this.rotationAxis(w),R*=K.dot(w,K.normalize(K.create(),N)));return R};f.prototype.rotationAxis=function(w){return this.valid&&w.valid?K.normalize(K.create(),[this._rotation[7]-w._rotation[5],this._rotation[2]-w._rotation[6],this._rotation[3]-w._rotation[1]]):K.create()};f.prototype.rotationMatrix=function(w){if(!this.valid||!w.valid)return t.create();var N=
t.transpose(t.create(),this._rotation);return t.multiply(t.create(),w._rotation,N)};f.prototype.scaleFactor=function(w){return this.valid&&w.valid?Math.exp(this._scaleFactor-w._scaleFactor):1};f.prototype.translation=function(w){return this.valid&&w.valid?K.subtract(K.create(),this._translation,w._translation):K.create()};f.prototype.toString=function(){var w="Frame [ id:"+this.id+" | timestamp:"+this.timestamp+" | Hand count:("+this.hands.length+") | Pointable count:("+this.pointables.length+")";
this.gestures&&(w+=" | Gesture count:("+this.gestures.length+")");return w+" ]"};f.prototype.dump=function(){var w="Frame Info:<br/>"+this.toString();w+="<br/><br/>Hands:<br/>";for(var N=0,R=this.hands.length;N!=R;N++)w+=" "+this.hands[N].toString()+"<br/>";w+="<br/><br/>Pointables:<br/>";N=0;for(R=this.pointables.length;N!=R;N++)w+=" "+this.pointables[N].toString()+"<br/>";if(this.gestures)for(w+="<br/><br/>Gestures:<br/>",N=0,R=this.gestures.length;N!=R;N++)w+=" "+this.gestures[N].toString()+
"<br/>";return w=w+"<br/><br/>Raw JSON:<br/>"+JSON.stringify(this.data)};f.Invalid={valid:!1,hands:[],fingers:[],tools:[],gestures:[],pointables:[],pointable:function(){return n.Invalid},finger:function(){return n.Invalid},hand:function(){return v.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return t.create()},rotationAxis:function(){return K.create()},scaleFactor:function(){return 1},translation:function(){return K.create()}}},
{"./finger":9,"./gesture":11,"./hand":12,"./interaction_box":14,"./pointable":16,"gl-matrix":22,underscore:25}],11:[function(f,m,J){var v=f("gl-matrix").vec3;m=f("events").EventEmitter;var n=f("underscore");J.createGesture=function(M){switch(M.type){case "circle":var w=new t(M);break;case "swipe":w=new K(M);break;case "screenTap":w=new E(M);break;case "keyTap":w=new U(M);break;default:throw"unknown gesture type";}w.id=M.id;w.handIds=M.handIds.slice();w.pointableIds=M.pointableIds.slice();w.duration=
M.duration;w.state=M.state;w.type=M.type;return w};J.gestureListener=function(M,w){var N={},R={};M.on("gesture",function(A,c){if(A.type==w){if(("start"==A.state||"stop"==A.state)&&void 0===R[A.id]){var a=new r(A,c);R[A.id]=a;n.each(N,function(b,d){a.on(d,b)})}R[A.id].update(A,c);"stop"==A.state&&delete R[A.id]}});var F={start:function(A){N.start=A;return F},stop:function(A){N.stop=A;return F},complete:function(A){N.stop=A;return F},update:function(A){N.update=A;return F}};return F};var r=J.Gesture=
function(M,w){this.gestures=[M];this.frames=[w]};r.prototype.update=function(M,w){this.lastGesture=M;this.lastFrame=w;this.gestures.push(M);this.frames.push(w);this.emit(M.state,this)};r.prototype.translation=function(){return v.subtract(v.create(),this.lastGesture.startPosition,this.lastGesture.position)};n.extend(r.prototype,m.prototype);var t=function(M){this.center=M.center;this.normal=M.normal;this.progress=M.progress;this.radius=M.radius};t.prototype.toString=function(){return"CircleGesture ["+
JSON.stringify(this)+"]"};var K=function(M){this.startPosition=M.startPosition;this.position=M.position;this.direction=M.direction;this.speed=M.speed};K.prototype.toString=function(){return"SwipeGesture ["+JSON.stringify(this)+"]"};var E=function(M){this.position=M.position;this.direction=M.direction;this.progress=M.progress};E.prototype.toString=function(){return"ScreenTapGesture ["+JSON.stringify(this)+"]"};var U=function(M){this.position=M.position;this.direction=M.direction;this.progress=M.progress};
U.prototype.toString=function(){return"KeyTapGesture ["+JSON.stringify(this)+"]"}},{events:1,"gl-matrix":22,underscore:25}],12:[function(f,m,J){var v=f("./pointable"),n=f("./bone");J=f("gl-matrix");var r=J.mat3,t=J.vec3,K=f("underscore");f=m.exports=function(E){this.id=E.id;this.palmPosition=E.palmPosition;this.direction=E.direction;this.palmVelocity=E.palmVelocity;this.palmNormal=E.palmNormal;this.sphereCenter=E.sphereCenter;this.sphereRadius=E.sphereRadius;this.valid=!0;this.pointables=[];this.fingers=
[];this.arm=E.armBasis?new n(this,{type:4,width:E.armWidth,prevJoint:E.elbow,nextJoint:E.wrist,basis:E.armBasis}):null;this.tools=[];this._translation=E.t;this._rotation=K.flatten(E.r);this._scaleFactor=E.s;this.timeVisible=E.timeVisible;this.stabilizedPalmPosition=E.stabilizedPalmPosition;this.type=E.type;this.grabStrength=E.grabStrength;this.pinchStrength=E.pinchStrength;this.confidence=E.confidence};f.prototype.finger=function(E){return(E=this.frame.finger(E))&&E.handId==this.id?E:v.Invalid};f.prototype.rotationAngle=
function(E,U){if(!this.valid||!E.valid||!E.hand(this.id).valid)return 0;var M=this.rotationMatrix(E);M=Math.acos(.5*(M[0]+M[4]+M[8]-1));M=isNaN(M)?0:M;void 0!==U&&(E=this.rotationAxis(E),M*=t.dot(E,t.normalize(t.create(),U)));return M};f.prototype.rotationAxis=function(E){if(!this.valid||!E.valid)return t.create();E=E.hand(this.id);return E.valid?t.normalize(t.create(),[this._rotation[7]-E._rotation[5],this._rotation[2]-E._rotation[6],this._rotation[3]-E._rotation[1]]):t.create()};f.prototype.rotationMatrix=
function(E){if(!this.valid||!E.valid)return r.create();E=E.hand(this.id);if(!E.valid)return r.create();var U=r.transpose(r.create(),this._rotation);return r.multiply(r.create(),E._rotation,U)};f.prototype.scaleFactor=function(E){if(!this.valid||!E.valid)return 1;E=E.hand(this.id);return E.valid?Math.exp(this._scaleFactor-E._scaleFactor):1};f.prototype.translation=function(E){if(!this.valid||!E.valid)return t.create();E=E.hand(this.id);return E.valid?[this._translation[0]-E._translation[0],this._translation[1]-
E._translation[1],this._translation[2]-E._translation[2]]:t.create()};f.prototype.toString=function(){return"Hand ("+this.type+") [ id: "+this.id+" | palm velocity:"+this.palmVelocity+" | sphere center:"+this.sphereCenter+" ] "};f.prototype.pitch=function(){return Math.atan2(this.direction[1],-this.direction[2])};f.prototype.yaw=function(){return Math.atan2(this.direction[0],-this.direction[2])};f.prototype.roll=function(){return Math.atan2(this.palmNormal[0],-this.palmNormal[1])};f.Invalid={valid:!1,
fingers:[],tools:[],pointables:[],left:!1,pointable:function(){return v.Invalid},finger:function(){return v.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return r.create()},rotationAxis:function(){return t.create()},scaleFactor:function(){return 1},translation:function(){return t.create()}}},{"./bone":2,"./pointable":16,"gl-matrix":22,underscore:25}],13:[function(f,m,J){m.exports={Controller:f("./controller"),
Frame:f("./frame"),Gesture:f("./gesture"),Hand:f("./hand"),Pointable:f("./pointable"),Finger:f("./finger"),InteractionBox:f("./interaction_box"),CircularBuffer:f("./circular_buffer"),UI:f("./ui"),JSONProtocol:f("./protocol").JSONProtocol,glMatrix:f("gl-matrix"),mat3:f("gl-matrix").mat3,vec3:f("gl-matrix").vec3,loopController:void 0,version:f("./version.js"),_:f("underscore"),EventEmitter:f("events").EventEmitter,loop:function(v,n){v&&void 0===n&&"[object Function]"==={}.toString.call(v)&&(n=v,v={});
this.loopController?v&&this.loopController.setupFrameEvents(v):this.loopController=new this.Controller(v);this.loopController.loop(n);return this.loopController},plugin:function(v,n){this.Controller.plugin(v,n)}}},{"./circular_buffer":3,"./controller":7,"./finger":9,"./frame":10,"./gesture":11,"./hand":12,"./interaction_box":14,"./pointable":16,"./protocol":17,"./ui":18,"./version.js":21,events:1,"gl-matrix":22,underscore:25}],14:[function(f,m,J){var v=f("gl-matrix").vec3;f=m.exports=function(n){this.valid=
!0;this.center=n.center;this.size=n.size;this.width=n.size[0];this.height=n.size[1];this.depth=n.size[2]};f.prototype.denormalizePoint=function(n){return v.fromValues((n[0]-.5)*this.size[0]+this.center[0],(n[1]-.5)*this.size[1]+this.center[1],(n[2]-.5)*this.size[2]+this.center[2])};f.prototype.normalizePoint=function(n,r){n=v.fromValues((n[0]-this.center[0])/this.size[0]+.5,(n[1]-this.center[1])/this.size[1]+.5,(n[2]-this.center[2])/this.size[2]+.5);r&&(n[0]=Math.min(Math.max(n[0],0),1),n[1]=Math.min(Math.max(n[1],
0),1),n[2]=Math.min(Math.max(n[2],0),1));return n};f.prototype.toString=function(){return"InteractionBox [ width:"+this.width+" | height:"+this.height+" | depth:"+this.depth+" ]"};f.Invalid={valid:!1}},{"gl-matrix":22}],15:[function(f,m,J){f=m.exports=function(v){this.steps=[];this.controller=v};f.prototype.addStep=function(v){this.steps.push(v)};f.prototype.run=function(v){for(var n=this.steps.length,r=0;r!=n&&v;r++)v=this.steps[r](v);return v};f.prototype.removeStep=function(v){v=this.steps.indexOf(v);
if(-1===v)throw"Step not found in pipeline";this.steps.splice(v,1)};f.prototype.addWrappedStep=function(v,n){var r=this.controller,t=function(K){var E;var U="frame"==v?[K]:K[v+"s"]||[];var M=0;for(E=U.length;M<E;M++)n.call(r,U[M]);return K};this.addStep(t);return t}},{}],16:[function(f,m,J){f("gl-matrix");f=m.exports=function(v){this.valid=!0;this.id=v.id;this.handId=v.handId;this.length=v.length;this.tool=v.tool;this.width=v.width;this.direction=v.direction;this.stabilizedTipPosition=v.stabilizedTipPosition;
this.tipPosition=v.tipPosition;this.tipVelocity=v.tipVelocity;this.touchZone=v.touchZone;this.touchDistance=v.touchDistance;this.timeVisible=v.timeVisible};f.prototype.toString=function(){return"Pointable [ id:"+this.id+" "+this.length+"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"};f.prototype.hand=function(){return this.frame.hand(this.handId)};f.Invalid={valid:!1}},{"gl-matrix":22}],17:[function(f,m,J){var v=f("./frame");f("./hand");f("./pointable");f("./finger");var n=f("underscore"),
r=f("events").EventEmitter,t=function(E){this.type=E.type;this.state=E.state};J.chooseProtocol=function(E){switch(E.version){case 1:case 2:case 3:case 4:case 5:case 6:var U=K(E);U.sendBackground=function(M,w){M.send(U.encode({background:w}))};U.sendFocused=function(M,w){M.send(U.encode({focused:w}))};U.sendOptimizeHMD=function(M,w){M.send(U.encode({optimizeHMD:w}))};break;default:throw"unrecognized version";}return U};var K=J.JSONProtocol=function(E){var U=function(M){if(M.event)return new t(M.event);
U.emit("beforeFrameCreated",M);var w=new v(M);U.emit("afterFrameCreated",w,M);return w};U.encode=function(M){return JSON.stringify(M)};U.version=E.version;U.serviceVersion=E.serviceVersion;U.versionLong="Version "+E.version;U.type="protocol";n.extend(U,r.prototype);return U}},{"./finger":9,"./frame":10,"./hand":12,"./pointable":16,events:1,underscore:25}],18:[function(f,m,J){J.UI={Region:f("./ui/region"),Cursor:f("./ui/cursor")}},{"./ui/cursor":19,"./ui/region":20}],19:[function(f,m,J){m.exports=
function(){return function(v){var n=v.pointables.sort(function(r,t){return r.z-t.z})[0];n&&n.valid&&(v.cursorPosition=n.tipPosition);return v}}},{}],20:[function(f,m,J){J=f("events").EventEmitter;f=f("underscore");var v=m.exports=function(n,r){this.start=new Vector(n);this.end=new Vector(r);this.enteredFrame=null};v.prototype.hasPointables=function(n){for(var r=0;r!=n.pointables.length;r++){var t=n.pointables[r].tipPosition;if(t.x>=this.start.x&&t.x<=this.end.x&&t.y>=this.start.y&&t.y<=this.end.y&&
t.z>=this.start.z&&t.z<=this.end.z)return!0}return!1};v.prototype.listener=function(n){var r=this;n&&n.nearThreshold&&this.setupNearRegion(n.nearThreshold);return function(t){return r.updatePosition(t)}};v.prototype.clipper=function(){var n=this;return function(r){n.updatePosition(r);return n.enteredFrame?r:null}};v.prototype.setupNearRegion=function(n){n=this.nearRegion=new v([this.start.x-n,this.start.y-n,this.start.z-n],[this.end.x+n,this.end.y+n,this.end.z+n]);var r=this;n.on("enter",function(t){r.emit("near",
t)});n.on("exit",function(t){r.emit("far",t)});r.on("exit",function(t){r.emit("near",t)})};v.prototype.updatePosition=function(n){this.nearRegion&&this.nearRegion.updatePosition(n);this.hasPointables(n)&&null==this.enteredFrame?(this.enteredFrame=n,this.emit("enter",this.enteredFrame)):this.hasPointables(n)||null==this.enteredFrame||(this.enteredFrame=null,this.emit("exit",this.enteredFrame));return n};v.prototype.normalize=function(n){return new Vector([(n.x-this.start.x)/(this.end.x-this.start.x),
(n.y-this.start.y)/(this.end.y-this.start.y),(n.z-this.start.z)/(this.end.z-this.start.z)])};v.prototype.mapToXY=function(n,r,t){n=this.normalize(n);var K=n.x,E=n.y;1<K?K=1:-1>K&&(K=-1);1<E?E=1:-1>E&&(E=-1);return[(K+1)/2*r,(1-E)/2*t,n.z]};f.extend(v.prototype,J.prototype)},{events:1,underscore:25}],21:[function(f,m,J){m.exports={full:"0.6.4",major:0,minor:6,dot:4}},{}],22:[function(f,m,J){(function(v){(function(n){if(!r)var r=1E-6;if(!t)var t="undefined"!==typeof Float32Array?Float32Array:Array;
if(!K)var K=Math.random;var E={setMatrixArrayType:function(c){t=c}};"undefined"!==typeof n&&(n.glMatrix=E);var U=Math.PI/180;E.toRadian=function(c){return c*U};var M={create:function(){var c=new t(2);c[0]=0;c[1]=0;return c},clone:function(c){var a=new t(2);a[0]=c[0];a[1]=c[1];return a},fromValues:function(c,a){var b=new t(2);b[0]=c;b[1]=a;return b},copy:function(c,a){c[0]=a[0];c[1]=a[1];return c},set:function(c,a,b){c[0]=a;c[1]=b;return c},add:function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];return c},
subtract:function(c,a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];return c}};M.sub=M.subtract;M.multiply=function(c,a,b){c[0]=a[0]*b[0];c[1]=a[1]*b[1];return c};M.mul=M.multiply;M.divide=function(c,a,b){c[0]=a[0]/b[0];c[1]=a[1]/b[1];return c};M.div=M.divide;M.min=function(c,a,b){c[0]=Math.min(a[0],b[0]);c[1]=Math.min(a[1],b[1]);return c};M.max=function(c,a,b){c[0]=Math.max(a[0],b[0]);c[1]=Math.max(a[1],b[1]);return c};M.scale=function(c,a,b){c[0]=a[0]*b;c[1]=a[1]*b;return c};M.scaleAndAdd=function(c,a,b,d){c[0]=
a[0]+b[0]*d;c[1]=a[1]+b[1]*d;return c};M.distance=function(c,a){var b=a[0]-c[0];c=a[1]-c[1];return Math.sqrt(b*b+c*c)};M.dist=M.distance;M.squaredDistance=function(c,a){var b=a[0]-c[0];c=a[1]-c[1];return b*b+c*c};M.sqrDist=M.squaredDistance;M.length=function(c){var a=c[0];c=c[1];return Math.sqrt(a*a+c*c)};M.len=M.length;M.squaredLength=function(c){var a=c[0];c=c[1];return a*a+c*c};M.sqrLen=M.squaredLength;M.negate=function(c,a){c[0]=-a[0];c[1]=-a[1];return c};M.normalize=function(c,a){var b=a[0],
d=a[1];b=b*b+d*d;0<b&&(b=1/Math.sqrt(b),c[0]=a[0]*b,c[1]=a[1]*b);return c};M.dot=function(c,a){return c[0]*a[0]+c[1]*a[1]};M.cross=function(c,a,b){a=a[0]*b[1]-a[1]*b[0];c[0]=c[1]=0;c[2]=a;return c};M.lerp=function(c,a,b,d){var e=a[0];a=a[1];c[0]=e+d*(b[0]-e);c[1]=a+d*(b[1]-a);return c};M.random=function(c,a){a=a||1;var b=2*K()*Math.PI;c[0]=Math.cos(b)*a;c[1]=Math.sin(b)*a;return c};M.transformMat2=function(c,a,b){var d=a[0];a=a[1];c[0]=b[0]*d+b[2]*a;c[1]=b[1]*d+b[3]*a;return c};M.transformMat2d=function(c,
a,b){var d=a[0];a=a[1];c[0]=b[0]*d+b[2]*a+b[4];c[1]=b[1]*d+b[3]*a+b[5];return c};M.transformMat3=function(c,a,b){var d=a[0];a=a[1];c[0]=b[0]*d+b[3]*a+b[6];c[1]=b[1]*d+b[4]*a+b[7];return c};M.transformMat4=function(c,a,b){var d=a[0];a=a[1];c[0]=b[0]*d+b[4]*a+b[12];c[1]=b[1]*d+b[5]*a+b[13];return c};M.forEach=function(){var c=M.create();return function(a,b,d,e,g,l){b||(b=2);d||(d=0);for(e=e?Math.min(e*b+d,a.length):a.length;d<e;d+=b)c[0]=a[d],c[1]=a[d+1],g(c,c,l),a[d]=c[0],a[d+1]=c[1];return a}}();
M.str=function(c){return"vec2("+c[0]+", "+c[1]+")"};"undefined"!==typeof n&&(n.vec2=M);var w={create:function(){var c=new t(3);c[0]=0;c[1]=0;c[2]=0;return c},clone:function(c){var a=new t(3);a[0]=c[0];a[1]=c[1];a[2]=c[2];return a},fromValues:function(c,a,b){var d=new t(3);d[0]=c;d[1]=a;d[2]=b;return d},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];return c},set:function(c,a,b,d){c[0]=a;c[1]=b;c[2]=d;return c},add:function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];return c},subtract:function(c,
a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];return c}};w.sub=w.subtract;w.multiply=function(c,a,b){c[0]=a[0]*b[0];c[1]=a[1]*b[1];c[2]=a[2]*b[2];return c};w.mul=w.multiply;w.divide=function(c,a,b){c[0]=a[0]/b[0];c[1]=a[1]/b[1];c[2]=a[2]/b[2];return c};w.div=w.divide;w.min=function(c,a,b){c[0]=Math.min(a[0],b[0]);c[1]=Math.min(a[1],b[1]);c[2]=Math.min(a[2],b[2]);return c};w.max=function(c,a,b){c[0]=Math.max(a[0],b[0]);c[1]=Math.max(a[1],b[1]);c[2]=Math.max(a[2],b[2]);return c};w.scale=function(c,
a,b){c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;return c};w.scaleAndAdd=function(c,a,b,d){c[0]=a[0]+b[0]*d;c[1]=a[1]+b[1]*d;c[2]=a[2]+b[2]*d;return c};w.distance=function(c,a){var b=a[0]-c[0],d=a[1]-c[1];c=a[2]-c[2];return Math.sqrt(b*b+d*d+c*c)};w.dist=w.distance;w.squaredDistance=function(c,a){var b=a[0]-c[0],d=a[1]-c[1];c=a[2]-c[2];return b*b+d*d+c*c};w.sqrDist=w.squaredDistance;w.length=function(c){var a=c[0],b=c[1];c=c[2];return Math.sqrt(a*a+b*b+c*c)};w.len=w.length;w.squaredLength=function(c){var a=
c[0],b=c[1];c=c[2];return a*a+b*b+c*c};w.sqrLen=w.squaredLength;w.negate=function(c,a){c[0]=-a[0];c[1]=-a[1];c[2]=-a[2];return c};w.normalize=function(c,a){var b=a[0],d=a[1],e=a[2];b=b*b+d*d+e*e;0<b&&(b=1/Math.sqrt(b),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b);return c};w.dot=function(c,a){return c[0]*a[0]+c[1]*a[1]+c[2]*a[2]};w.cross=function(c,a,b){var d=a[0],e=a[1];a=a[2];var g=b[0],l=b[1];b=b[2];c[0]=e*b-a*l;c[1]=a*g-d*b;c[2]=d*l-e*g;return c};w.lerp=function(c,a,b,d){var e=a[0],g=a[1];a=a[2];c[0]=
e+d*(b[0]-e);c[1]=g+d*(b[1]-g);c[2]=a+d*(b[2]-a);return c};w.random=function(c,a){a=a||1;var b=2*K()*Math.PI,d=2*K()-1,e=Math.sqrt(1-d*d)*a;c[0]=Math.cos(b)*e;c[1]=Math.sin(b)*e;c[2]=d*a;return c};w.transformMat4=function(c,a,b){var d=a[0],e=a[1];a=a[2];c[0]=b[0]*d+b[4]*e+b[8]*a+b[12];c[1]=b[1]*d+b[5]*e+b[9]*a+b[13];c[2]=b[2]*d+b[6]*e+b[10]*a+b[14];return c};w.transformMat3=function(c,a,b){var d=a[0],e=a[1];a=a[2];c[0]=d*b[0]+e*b[3]+a*b[6];c[1]=d*b[1]+e*b[4]+a*b[7];c[2]=d*b[2]+e*b[5]+a*b[8];return c};
w.transformQuat=function(c,a,b){var d=a[0],e=a[1],g=a[2];a=b[0];var l=b[1],u=b[2];b=b[3];var h=b*d+l*g-u*e,C=b*e+u*d-a*g,H=b*g+a*e-l*d;d=-a*d-l*e-u*g;c[0]=h*b+d*-a+C*-u-H*-l;c[1]=C*b+d*-l+H*-a-h*-u;c[2]=H*b+d*-u+h*-l-C*-a;return c};w.rotateX=function(c,a,b,d){var e=[],g=[];e[0]=a[0]-b[0];e[1]=a[1]-b[1];e[2]=a[2]-b[2];g[0]=e[0];g[1]=e[1]*Math.cos(d)-e[2]*Math.sin(d);g[2]=e[1]*Math.sin(d)+e[2]*Math.cos(d);c[0]=g[0]+b[0];c[1]=g[1]+b[1];c[2]=g[2]+b[2];return c};w.rotateY=function(c,a,b,d){var e=[],g=
[];e[0]=a[0]-b[0];e[1]=a[1]-b[1];e[2]=a[2]-b[2];g[0]=e[2]*Math.sin(d)+e[0]*Math.cos(d);g[1]=e[1];g[2]=e[2]*Math.cos(d)-e[0]*Math.sin(d);c[0]=g[0]+b[0];c[1]=g[1]+b[1];c[2]=g[2]+b[2];return c};w.rotateZ=function(c,a,b,d){var e=[],g=[];e[0]=a[0]-b[0];e[1]=a[1]-b[1];e[2]=a[2]-b[2];g[0]=e[0]*Math.cos(d)-e[1]*Math.sin(d);g[1]=e[0]*Math.sin(d)+e[1]*Math.cos(d);g[2]=e[2];c[0]=g[0]+b[0];c[1]=g[1]+b[1];c[2]=g[2]+b[2];return c};w.forEach=function(){var c=w.create();return function(a,b,d,e,g,l){b||(b=3);d||(d=
0);for(e=e?Math.min(e*b+d,a.length):a.length;d<e;d+=b)c[0]=a[d],c[1]=a[d+1],c[2]=a[d+2],g(c,c,l),a[d]=c[0],a[d+1]=c[1],a[d+2]=c[2];return a}}();w.str=function(c){return"vec3("+c[0]+", "+c[1]+", "+c[2]+")"};"undefined"!==typeof n&&(n.vec3=w);var N={create:function(){var c=new t(4);c[0]=0;c[1]=0;c[2]=0;c[3]=0;return c},clone:function(c){var a=new t(4);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];return a},fromValues:function(c,a,b,d){var e=new t(4);e[0]=c;e[1]=a;e[2]=b;e[3]=d;return e},copy:function(c,a){c[0]=
a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];return c},set:function(c,a,b,d,e){c[0]=a;c[1]=b;c[2]=d;c[3]=e;return c},add:function(c,a,b){c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];c[3]=a[3]+b[3];return c},subtract:function(c,a,b){c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];c[3]=a[3]-b[3];return c}};N.sub=N.subtract;N.multiply=function(c,a,b){c[0]=a[0]*b[0];c[1]=a[1]*b[1];c[2]=a[2]*b[2];c[3]=a[3]*b[3];return c};N.mul=N.multiply;N.divide=function(c,a,b){c[0]=a[0]/b[0];c[1]=a[1]/b[1];c[2]=a[2]/b[2];c[3]=a[3]/
b[3];return c};N.div=N.divide;N.min=function(c,a,b){c[0]=Math.min(a[0],b[0]);c[1]=Math.min(a[1],b[1]);c[2]=Math.min(a[2],b[2]);c[3]=Math.min(a[3],b[3]);return c};N.max=function(c,a,b){c[0]=Math.max(a[0],b[0]);c[1]=Math.max(a[1],b[1]);c[2]=Math.max(a[2],b[2]);c[3]=Math.max(a[3],b[3]);return c};N.scale=function(c,a,b){c[0]=a[0]*b;c[1]=a[1]*b;c[2]=a[2]*b;c[3]=a[3]*b;return c};N.scaleAndAdd=function(c,a,b,d){c[0]=a[0]+b[0]*d;c[1]=a[1]+b[1]*d;c[2]=a[2]+b[2]*d;c[3]=a[3]+b[3]*d;return c};N.distance=function(c,
a){var b=a[0]-c[0],d=a[1]-c[1],e=a[2]-c[2];c=a[3]-c[3];return Math.sqrt(b*b+d*d+e*e+c*c)};N.dist=N.distance;N.squaredDistance=function(c,a){var b=a[0]-c[0],d=a[1]-c[1],e=a[2]-c[2];c=a[3]-c[3];return b*b+d*d+e*e+c*c};N.sqrDist=N.squaredDistance;N.length=function(c){var a=c[0],b=c[1],d=c[2];c=c[3];return Math.sqrt(a*a+b*b+d*d+c*c)};N.len=N.length;N.squaredLength=function(c){var a=c[0],b=c[1],d=c[2];c=c[3];return a*a+b*b+d*d+c*c};N.sqrLen=N.squaredLength;N.negate=function(c,a){c[0]=-a[0];c[1]=-a[1];
c[2]=-a[2];c[3]=-a[3];return c};N.normalize=function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3];b=b*b+d*d+e*e+g*g;0<b&&(b=1/Math.sqrt(b),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c[3]=a[3]*b);return c};N.dot=function(c,a){return c[0]*a[0]+c[1]*a[1]+c[2]*a[2]+c[3]*a[3]};N.lerp=function(c,a,b,d){var e=a[0],g=a[1],l=a[2];a=a[3];c[0]=e+d*(b[0]-e);c[1]=g+d*(b[1]-g);c[2]=l+d*(b[2]-l);c[3]=a+d*(b[3]-a);return c};N.random=function(c,a){a=a||1;c[0]=K();c[1]=K();c[2]=K();c[3]=K();N.normalize(c,c);N.scale(c,c,a);return c};
N.transformMat4=function(c,a,b){var d=a[0],e=a[1],g=a[2];a=a[3];c[0]=b[0]*d+b[4]*e+b[8]*g+b[12]*a;c[1]=b[1]*d+b[5]*e+b[9]*g+b[13]*a;c[2]=b[2]*d+b[6]*e+b[10]*g+b[14]*a;c[3]=b[3]*d+b[7]*e+b[11]*g+b[15]*a;return c};N.transformQuat=function(c,a,b){var d=a[0],e=a[1],g=a[2];a=b[0];var l=b[1],u=b[2];b=b[3];var h=b*d+l*g-u*e,C=b*e+u*d-a*g,H=b*g+a*e-l*d;d=-a*d-l*e-u*g;c[0]=h*b+d*-a+C*-u-H*-l;c[1]=C*b+d*-l+H*-a-h*-u;c[2]=H*b+d*-u+h*-l-C*-a;return c};N.forEach=function(){var c=N.create();return function(a,b,
d,e,g,l){b||(b=4);d||(d=0);for(e=e?Math.min(e*b+d,a.length):a.length;d<e;d+=b)c[0]=a[d],c[1]=a[d+1],c[2]=a[d+2],c[3]=a[d+3],g(c,c,l),a[d]=c[0],a[d+1]=c[1],a[d+2]=c[2],a[d+3]=c[3];return a}}();N.str=function(c){return"vec4("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+")"};"undefined"!==typeof n&&(n.vec4=N);E={create:function(){var c=new t(4);c[0]=1;c[1]=0;c[2]=0;c[3]=1;return c},clone:function(c){var a=new t(4);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];
c[3]=a[3];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=1;return c},transpose:function(c,a){if(c===a){var b=a[1];c[1]=a[2];c[2]=b}else c[0]=a[0],c[1]=a[2],c[2]=a[1],c[3]=a[3];return c},invert:function(c,a){var b=a[0],d=a[1],e=a[2];a=a[3];var g=b*a-e*d;if(!g)return null;g=1/g;c[0]=a*g;c[1]=-d*g;c[2]=-e*g;c[3]=b*g;return c},adjoint:function(c,a){var b=a[0];c[0]=a[3];c[1]=-a[1];c[2]=-a[2];c[3]=b;return c},determinant:function(c){return c[0]*c[3]-c[2]*c[1]},multiply:function(c,a,b){var d=a[0],
e=a[1],g=a[2];a=a[3];var l=b[0],u=b[1],h=b[2];b=b[3];c[0]=d*l+g*u;c[1]=e*l+a*u;c[2]=d*h+g*b;c[3]=e*h+a*b;return c}};E.mul=E.multiply;E.rotate=function(c,a,b){var d=a[0],e=a[1],g=a[2];a=a[3];var l=Math.sin(b);b=Math.cos(b);c[0]=d*b+g*l;c[1]=e*b+a*l;c[2]=d*-l+g*b;c[3]=e*-l+a*b;return c};E.scale=function(c,a,b){var d=a[1],e=a[2],g=a[3],l=b[0];b=b[1];c[0]=a[0]*l;c[1]=d*l;c[2]=e*b;c[3]=g*b;return c};E.str=function(c){return"mat2("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+")"};E.frob=function(c){return Math.sqrt(Math.pow(c[0],
2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2))};E.LDU=function(c,a,b,d){c[2]=d[2]/d[0];b[0]=d[0];b[1]=d[1];b[3]=d[3]-c[2]*b[1];return[c,a,b]};"undefined"!==typeof n&&(n.mat2=E);E={create:function(){var c=new t(6);c[0]=1;c[1]=0;c[2]=0;c[3]=1;c[4]=0;c[5]=0;return c},clone:function(c){var a=new t(6);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];a[4]=c[4];a[5]=c[5];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=a[5];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=
0;c[3]=1;c[4]=0;c[5]=0;return c},invert:function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3],l=a[4];a=a[5];var u=b*g-d*e;if(!u)return null;u=1/u;c[0]=g*u;c[1]=-d*u;c[2]=-e*u;c[3]=b*u;c[4]=(e*a-g*l)*u;c[5]=(d*l-b*a)*u;return c},determinant:function(c){return c[0]*c[3]-c[1]*c[2]},multiply:function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4];a=a[5];var h=b[0],C=b[1],H=b[2],L=b[3],P=b[4];b=b[5];c[0]=d*h+g*C;c[1]=e*h+l*C;c[2]=d*H+g*L;c[3]=e*H+l*L;c[4]=d*P+g*b+u;c[5]=e*P+l*b+a;return c}};E.mul=E.multiply;E.rotate=
function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4];a=a[5];var h=Math.sin(b);b=Math.cos(b);c[0]=d*b+g*h;c[1]=e*b+l*h;c[2]=d*-h+g*b;c[3]=e*-h+l*b;c[4]=u;c[5]=a;return c};E.scale=function(c,a,b){var d=a[1],e=a[2],g=a[3],l=a[4],u=a[5],h=b[0];b=b[1];c[0]=a[0]*h;c[1]=d*h;c[2]=e*b;c[3]=g*b;c[4]=l;c[5]=u;return c};E.translate=function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4];a=a[5];var h=b[0];b=b[1];c[0]=d;c[1]=e;c[2]=g;c[3]=l;c[4]=d*h+g*b+u;c[5]=e*h+l*b+a;return c};E.str=function(c){return"mat2d("+
c[0]+", "+c[1]+", "+c[2]+", "+c[3]+", "+c[4]+", "+c[5]+")"};E.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2)+Math.pow(c[4],2)+Math.pow(c[5],2)+1)};"undefined"!==typeof n&&(n.mat2d=E);var R={create:function(){var c=new t(9);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c},fromMat4:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[4];c[4]=a[5];c[5]=a[6];c[6]=a[8];c[7]=a[9];c[8]=a[10];return c},clone:function(c){var a=new t(9);
a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];a[4]=c[4];a[5]=c[5];a[6]=c[6];a[7]=c[7];a[8]=c[8];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=a[5];c[6]=a[6];c[7]=a[7];c[8]=a[8];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=1;c[5]=0;c[6]=0;c[7]=0;c[8]=1;return c},transpose:function(c,a){if(c===a){var b=a[1],d=a[2],e=a[5];c[1]=a[3];c[2]=a[6];c[3]=b;c[5]=a[7];c[6]=d;c[7]=e}else c[0]=a[0],c[1]=a[3],c[2]=a[6],c[3]=a[1],c[4]=a[4],c[5]=a[7],c[6]=a[2],c[7]=
a[5],c[8]=a[8];return c},invert:function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3],l=a[4],u=a[5],h=a[6],C=a[7];a=a[8];var H=a*l-u*C,L=-a*g+u*h,P=C*g-l*h,S=b*H+d*L+e*P;if(!S)return null;S=1/S;c[0]=H*S;c[1]=(-a*d+e*C)*S;c[2]=(u*d-e*l)*S;c[3]=L*S;c[4]=(a*b-e*h)*S;c[5]=(-u*b+e*g)*S;c[6]=P*S;c[7]=(-C*b+d*h)*S;c[8]=(l*b-d*g)*S;return c},adjoint:function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3],l=a[4],u=a[5],h=a[6],C=a[7];a=a[8];c[0]=l*a-u*C;c[1]=e*C-d*a;c[2]=d*u-e*l;c[3]=u*h-g*a;c[4]=b*a-e*h;c[5]=e*g-b*u;c[6]=g*
C-l*h;c[7]=d*h-b*C;c[8]=b*l-d*g;return c},determinant:function(c){var a=c[3],b=c[4],d=c[5],e=c[6],g=c[7],l=c[8];return c[0]*(l*b-d*g)+c[1]*(-l*a+d*e)+c[2]*(g*a-b*e)},multiply:function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4],h=a[5],C=a[6],H=a[7];a=a[8];var L=b[0],P=b[1],S=b[2],V=b[3],Z=b[4],Y=b[5],da=b[6],ia=b[7];b=b[8];c[0]=L*d+P*l+S*C;c[1]=L*e+P*u+S*H;c[2]=L*g+P*h+S*a;c[3]=V*d+Z*l+Y*C;c[4]=V*e+Z*u+Y*H;c[5]=V*g+Z*h+Y*a;c[6]=da*d+ia*l+b*C;c[7]=da*e+ia*u+b*H;c[8]=da*g+ia*h+b*a;return c}};R.mul=
R.multiply;R.translate=function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4],h=a[5],C=a[6],H=a[7];a=a[8];var L=b[0];b=b[1];c[0]=d;c[1]=e;c[2]=g;c[3]=l;c[4]=u;c[5]=h;c[6]=L*d+b*l+C;c[7]=L*e+b*u+H;c[8]=L*g+b*h+a;return c};R.rotate=function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4],h=a[5],C=a[6],H=a[7];a=a[8];var L=Math.sin(b);b=Math.cos(b);c[0]=b*d+L*l;c[1]=b*e+L*u;c[2]=b*g+L*h;c[3]=b*l-L*d;c[4]=b*u-L*e;c[5]=b*h-L*g;c[6]=C;c[7]=H;c[8]=a;return c};R.scale=function(c,a,b){var d=b[0];b=b[1];c[0]=
d*a[0];c[1]=d*a[1];c[2]=d*a[2];c[3]=b*a[3];c[4]=b*a[4];c[5]=b*a[5];c[6]=a[6];c[7]=a[7];c[8]=a[8];return c};R.fromMat2d=function(c,a){c[0]=a[0];c[1]=a[1];c[2]=0;c[3]=a[2];c[4]=a[3];c[5]=0;c[6]=a[4];c[7]=a[5];c[8]=1;return c};R.fromQuat=function(c,a){var b=a[0],d=a[1],e=a[2];a=a[3];var g=b+b,l=d+d,u=e+e;b*=g;var h=d*g;d*=l;var C=e*g,H=e*l;e*=u;g*=a;l*=a;a*=u;c[0]=1-d-e;c[3]=h-a;c[6]=C+l;c[1]=h+a;c[4]=1-b-e;c[7]=H-g;c[2]=C-l;c[5]=H+g;c[8]=1-b-d;return c};R.normalFromMat4=function(c,a){var b=a[0],d=a[1],
e=a[2],g=a[3],l=a[4],u=a[5],h=a[6],C=a[7],H=a[8],L=a[9],P=a[10],S=a[11],V=a[12],Z=a[13],Y=a[14];a=a[15];var da=b*u-d*l,ia=b*h-e*l,ba=b*C-g*l,ea=d*h-e*u,ca=d*C-g*u,p=e*C-g*h,D=H*Z-L*V,G=H*Y-P*V;H=H*a-S*V;var Q=L*Y-P*Z;L=L*a-S*Z;P=P*a-S*Y;S=da*P-ia*L+ba*Q+ea*H-ca*G+p*D;if(!S)return null;S=1/S;c[0]=(u*P-h*L+C*Q)*S;c[1]=(h*H-l*P-C*G)*S;c[2]=(l*L-u*H+C*D)*S;c[3]=(e*L-d*P-g*Q)*S;c[4]=(b*P-e*H+g*G)*S;c[5]=(d*H-b*L-g*D)*S;c[6]=(Z*p-Y*ca+a*ea)*S;c[7]=(Y*ba-V*p-a*ia)*S;c[8]=(V*ca-Z*ba+a*da)*S;return c};R.str=
function(c){return"mat3("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+", "+c[4]+", "+c[5]+", "+c[6]+", "+c[7]+", "+c[8]+")"};R.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2)+Math.pow(c[4],2)+Math.pow(c[5],2)+Math.pow(c[6],2)+Math.pow(c[7],2)+Math.pow(c[8],2))};"undefined"!==typeof n&&(n.mat3=R);var F={create:function(){var c=new t(16);c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;
return c},clone:function(c){var a=new t(16);a[0]=c[0];a[1]=c[1];a[2]=c[2];a[3]=c[3];a[4]=c[4];a[5]=c[5];a[6]=c[6];a[7]=c[7];a[8]=c[8];a[9]=c[9];a[10]=c[10];a[11]=c[11];a[12]=c[12];a[13]=c[13];a[14]=c[14];a[15]=c[15];return a},copy:function(c,a){c[0]=a[0];c[1]=a[1];c[2]=a[2];c[3]=a[3];c[4]=a[4];c[5]=a[5];c[6]=a[6];c[7]=a[7];c[8]=a[8];c[9]=a[9];c[10]=a[10];c[11]=a[11];c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c},identity:function(c){c[0]=1;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=1;c[6]=0;c[7]=
0;c[8]=0;c[9]=0;c[10]=1;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c},transpose:function(c,a){if(c===a){var b=a[1],d=a[2],e=a[3],g=a[6],l=a[7],u=a[11];c[1]=a[4];c[2]=a[8];c[3]=a[12];c[4]=b;c[6]=a[9];c[7]=a[13];c[8]=d;c[9]=g;c[11]=a[14];c[12]=e;c[13]=l;c[14]=u}else c[0]=a[0],c[1]=a[4],c[2]=a[8],c[3]=a[12],c[4]=a[1],c[5]=a[5],c[6]=a[9],c[7]=a[13],c[8]=a[2],c[9]=a[6],c[10]=a[10],c[11]=a[14],c[12]=a[3],c[13]=a[7],c[14]=a[11],c[15]=a[15];return c},invert:function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3],
l=a[4],u=a[5],h=a[6],C=a[7],H=a[8],L=a[9],P=a[10],S=a[11],V=a[12],Z=a[13],Y=a[14];a=a[15];var da=b*u-d*l,ia=b*h-e*l,ba=b*C-g*l,ea=d*h-e*u,ca=d*C-g*u,p=e*C-g*h,D=H*Z-L*V,G=H*Y-P*V,Q=H*a-S*V,W=L*Y-P*Z,X=L*a-S*Z,fa=P*a-S*Y,ja=da*fa-ia*X+ba*W+ea*Q-ca*G+p*D;if(!ja)return null;ja=1/ja;c[0]=(u*fa-h*X+C*W)*ja;c[1]=(e*X-d*fa-g*W)*ja;c[2]=(Z*p-Y*ca+a*ea)*ja;c[3]=(P*ca-L*p-S*ea)*ja;c[4]=(h*Q-l*fa-C*G)*ja;c[5]=(b*fa-e*Q+g*G)*ja;c[6]=(Y*ba-V*p-a*ia)*ja;c[7]=(H*p-P*ba+S*ia)*ja;c[8]=(l*X-u*Q+C*D)*ja;c[9]=(d*Q-b*
X-g*D)*ja;c[10]=(V*ca-Z*ba+a*da)*ja;c[11]=(L*ba-H*ca-S*da)*ja;c[12]=(u*G-l*W-h*D)*ja;c[13]=(b*W-d*G+e*D)*ja;c[14]=(Z*ia-V*ea-Y*da)*ja;c[15]=(H*ea-L*ia+P*da)*ja;return c},adjoint:function(c,a){var b=a[0],d=a[1],e=a[2],g=a[3],l=a[4],u=a[5],h=a[6],C=a[7],H=a[8],L=a[9],P=a[10],S=a[11],V=a[12],Z=a[13],Y=a[14];a=a[15];c[0]=u*(P*a-S*Y)-L*(h*a-C*Y)+Z*(h*S-C*P);c[1]=-(d*(P*a-S*Y)-L*(e*a-g*Y)+Z*(e*S-g*P));c[2]=d*(h*a-C*Y)-u*(e*a-g*Y)+Z*(e*C-g*h);c[3]=-(d*(h*S-C*P)-u*(e*S-g*P)+L*(e*C-g*h));c[4]=-(l*(P*a-S*Y)-
H*(h*a-C*Y)+V*(h*S-C*P));c[5]=b*(P*a-S*Y)-H*(e*a-g*Y)+V*(e*S-g*P);c[6]=-(b*(h*a-C*Y)-l*(e*a-g*Y)+V*(e*C-g*h));c[7]=b*(h*S-C*P)-l*(e*S-g*P)+H*(e*C-g*h);c[8]=l*(L*a-S*Z)-H*(u*a-C*Z)+V*(u*S-C*L);c[9]=-(b*(L*a-S*Z)-H*(d*a-g*Z)+V*(d*S-g*L));c[10]=b*(u*a-C*Z)-l*(d*a-g*Z)+V*(d*C-g*u);c[11]=-(b*(u*S-C*L)-l*(d*S-g*L)+H*(d*C-g*u));c[12]=-(l*(L*Y-P*Z)-H*(u*Y-h*Z)+V*(u*P-h*L));c[13]=b*(L*Y-P*Z)-H*(d*Y-e*Z)+V*(d*P-e*L);c[14]=-(b*(u*Y-h*Z)-l*(d*Y-e*Z)+V*(d*h-e*u));c[15]=b*(u*P-h*L)-l*(d*P-e*L)+H*(d*h-e*u);return c},
determinant:function(c){var a=c[0],b=c[1],d=c[2],e=c[3],g=c[4],l=c[5],u=c[6],h=c[7],C=c[8],H=c[9],L=c[10],P=c[11],S=c[12],V=c[13],Z=c[14];c=c[15];return(a*l-b*g)*(L*c-P*Z)-(a*u-d*g)*(H*c-P*V)+(a*h-e*g)*(H*Z-L*V)+(b*u-d*l)*(C*c-P*S)-(b*h-e*l)*(C*Z-L*S)+(d*h-e*u)*(C*V-H*S)},multiply:function(c,a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=a[4],h=a[5],C=a[6],H=a[7],L=a[8],P=a[9],S=a[10],V=a[11],Z=a[12],Y=a[13],da=a[14];a=a[15];var ia=b[0],ba=b[1],ea=b[2],ca=b[3];c[0]=ia*d+ba*u+ea*L+ca*Z;c[1]=ia*e+ba*h+ea*P+
ca*Y;c[2]=ia*g+ba*C+ea*S+ca*da;c[3]=ia*l+ba*H+ea*V+ca*a;ia=b[4];ba=b[5];ea=b[6];ca=b[7];c[4]=ia*d+ba*u+ea*L+ca*Z;c[5]=ia*e+ba*h+ea*P+ca*Y;c[6]=ia*g+ba*C+ea*S+ca*da;c[7]=ia*l+ba*H+ea*V+ca*a;ia=b[8];ba=b[9];ea=b[10];ca=b[11];c[8]=ia*d+ba*u+ea*L+ca*Z;c[9]=ia*e+ba*h+ea*P+ca*Y;c[10]=ia*g+ba*C+ea*S+ca*da;c[11]=ia*l+ba*H+ea*V+ca*a;ia=b[12];ba=b[13];ea=b[14];ca=b[15];c[12]=ia*d+ba*u+ea*L+ca*Z;c[13]=ia*e+ba*h+ea*P+ca*Y;c[14]=ia*g+ba*C+ea*S+ca*da;c[15]=ia*l+ba*H+ea*V+ca*a;return c}};F.mul=F.multiply;F.translate=
function(c,a,b){var d=b[0],e=b[1];b=b[2];if(a===c)c[12]=a[0]*d+a[4]*e+a[8]*b+a[12],c[13]=a[1]*d+a[5]*e+a[9]*b+a[13],c[14]=a[2]*d+a[6]*e+a[10]*b+a[14],c[15]=a[3]*d+a[7]*e+a[11]*b+a[15];else{var g=a[0];var l=a[1];var u=a[2];var h=a[3];var C=a[4];var H=a[5];var L=a[6];var P=a[7];var S=a[8];var V=a[9];var Z=a[10];var Y=a[11];c[0]=g;c[1]=l;c[2]=u;c[3]=h;c[4]=C;c[5]=H;c[6]=L;c[7]=P;c[8]=S;c[9]=V;c[10]=Z;c[11]=Y;c[12]=g*d+C*e+S*b+a[12];c[13]=l*d+H*e+V*b+a[13];c[14]=u*d+L*e+Z*b+a[14];c[15]=h*d+P*e+Y*b+a[15]}return c};
F.scale=function(c,a,b){var d=b[0],e=b[1];b=b[2];c[0]=a[0]*d;c[1]=a[1]*d;c[2]=a[2]*d;c[3]=a[3]*d;c[4]=a[4]*e;c[5]=a[5]*e;c[6]=a[6]*e;c[7]=a[7]*e;c[8]=a[8]*b;c[9]=a[9]*b;c[10]=a[10]*b;c[11]=a[11]*b;c[12]=a[12];c[13]=a[13];c[14]=a[14];c[15]=a[15];return c};F.rotate=function(c,a,b,d){var e=d[0],g=d[1];d=d[2];var l=Math.sqrt(e*e+g*g+d*d);if(Math.abs(l)<r)return null;l=1/l;e*=l;g*=l;d*=l;var u=Math.sin(b);var h=Math.cos(b);var C=1-h;b=a[0];l=a[1];var H=a[2];var L=a[3];var P=a[4];var S=a[5];var V=a[6];
var Z=a[7];var Y=a[8];var da=a[9];var ia=a[10];var ba=a[11];var ea=e*e*C+h;var ca=g*e*C+d*u;var p=d*e*C-g*u;var D=e*g*C-d*u;var G=g*g*C+h;var Q=d*g*C+e*u;var W=e*d*C+g*u;e=g*d*C-e*u;g=d*d*C+h;c[0]=b*ea+P*ca+Y*p;c[1]=l*ea+S*ca+da*p;c[2]=H*ea+V*ca+ia*p;c[3]=L*ea+Z*ca+ba*p;c[4]=b*D+P*G+Y*Q;c[5]=l*D+S*G+da*Q;c[6]=H*D+V*G+ia*Q;c[7]=L*D+Z*G+ba*Q;c[8]=b*W+P*e+Y*g;c[9]=l*W+S*e+da*g;c[10]=H*W+V*e+ia*g;c[11]=L*W+Z*e+ba*g;a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);return c};F.rotateX=function(c,
a,b){var d=Math.sin(b);b=Math.cos(b);var e=a[4],g=a[5],l=a[6],u=a[7],h=a[8],C=a[9],H=a[10],L=a[11];a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);c[4]=e*b+h*d;c[5]=g*b+C*d;c[6]=l*b+H*d;c[7]=u*b+L*d;c[8]=h*b-e*d;c[9]=C*b-g*d;c[10]=H*b-l*d;c[11]=L*b-u*d;return c};F.rotateY=function(c,a,b){var d=Math.sin(b);b=Math.cos(b);var e=a[0],g=a[1],l=a[2],u=a[3],h=a[8],C=a[9],H=a[10],L=a[11];a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],
c[14]=a[14],c[15]=a[15]);c[0]=e*b-h*d;c[1]=g*b-C*d;c[2]=l*b-H*d;c[3]=u*b-L*d;c[8]=e*d+h*b;c[9]=g*d+C*b;c[10]=l*d+H*b;c[11]=u*d+L*b;return c};F.rotateZ=function(c,a,b){var d=Math.sin(b);b=Math.cos(b);var e=a[0],g=a[1],l=a[2],u=a[3],h=a[4],C=a[5],H=a[6],L=a[7];a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]);c[0]=e*b+h*d;c[1]=g*b+C*d;c[2]=l*b+H*d;c[3]=u*b+L*d;c[4]=h*b-e*d;c[5]=C*b-g*d;c[6]=H*b-l*d;c[7]=L*b-u*d;return c};F.fromRotationTranslation=function(c,
a,b){var d=a[0],e=a[1],g=a[2],l=a[3],u=d+d,h=e+e,C=g+g;a=d*u;var H=d*h;d*=C;var L=e*h;e*=C;g*=C;u*=l;h*=l;l*=C;c[0]=1-(L+g);c[1]=H+l;c[2]=d-h;c[3]=0;c[4]=H-l;c[5]=1-(a+g);c[6]=e+u;c[7]=0;c[8]=d+h;c[9]=e-u;c[10]=1-(a+L);c[11]=0;c[12]=b[0];c[13]=b[1];c[14]=b[2];c[15]=1;return c};F.fromQuat=function(c,a){var b=a[0],d=a[1],e=a[2];a=a[3];var g=b+b,l=d+d,u=e+e;b*=g;var h=d*g;d*=l;var C=e*g,H=e*l;e*=u;g*=a;l*=a;a*=u;c[0]=1-d-e;c[1]=h+a;c[2]=C-l;c[3]=0;c[4]=h-a;c[5]=1-b-e;c[6]=H+g;c[7]=0;c[8]=C+l;c[9]=H-
g;c[10]=1-b-d;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return c};F.frustum=function(c,a,b,d,e,g,l){var u=1/(b-a),h=1/(e-d),C=1/(g-l);c[0]=2*g*u;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=2*g*h;c[6]=0;c[7]=0;c[8]=(b+a)*u;c[9]=(e+d)*h;c[10]=(l+g)*C;c[11]=-1;c[12]=0;c[13]=0;c[14]=l*g*2*C;c[15]=0;return c};F.perspective=function(c,a,b,d,e){a=1/Math.tan(a/2);var g=1/(d-e);c[0]=a/b;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=a;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=(e+d)*g;c[11]=-1;c[12]=0;c[13]=0;c[14]=2*e*d*g;c[15]=0;return c};
F.ortho=function(c,a,b,d,e,g,l){var u=1/(a-b),h=1/(d-e),C=1/(g-l);c[0]=-2*u;c[1]=0;c[2]=0;c[3]=0;c[4]=0;c[5]=-2*h;c[6]=0;c[7]=0;c[8]=0;c[9]=0;c[10]=2*C;c[11]=0;c[12]=(a+b)*u;c[13]=(e+d)*h;c[14]=(l+g)*C;c[15]=1;return c};F.lookAt=function(c,a,b,d){var e=a[0],g=a[1];a=a[2];var l=d[0];var u=d[1];var h=d[2];var C=b[0];d=b[1];var H=b[2];if(Math.abs(e-C)<r&&Math.abs(g-d)<r&&Math.abs(a-H)<r)return F.identity(c);b=e-C;d=g-d;C=a-H;var L=1/Math.sqrt(b*b+d*d+C*C);b*=L;d*=L;C*=L;H=u*C-h*d;h=h*b-l*C;l=l*d-u*b;
(L=Math.sqrt(H*H+h*h+l*l))?(L=1/L,H*=L,h*=L,l*=L):l=h=H=0;u=d*l-C*h;var P=C*H-b*l;var S=b*h-d*H;(L=Math.sqrt(u*u+P*P+S*S))?(L=1/L,u*=L,P*=L,S*=L):S=P=u=0;c[0]=H;c[1]=u;c[2]=b;c[3]=0;c[4]=h;c[5]=P;c[6]=d;c[7]=0;c[8]=l;c[9]=S;c[10]=C;c[11]=0;c[12]=-(H*e+h*g+l*a);c[13]=-(u*e+P*g+S*a);c[14]=-(b*e+d*g+C*a);c[15]=1;return c};F.str=function(c){return"mat4("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+", "+c[4]+", "+c[5]+", "+c[6]+", "+c[7]+", "+c[8]+", "+c[9]+", "+c[10]+", "+c[11]+", "+c[12]+", "+c[13]+", "+c[14]+
", "+c[15]+")"};F.frob=function(c){return Math.sqrt(Math.pow(c[0],2)+Math.pow(c[1],2)+Math.pow(c[2],2)+Math.pow(c[3],2)+Math.pow(c[4],2)+Math.pow(c[5],2)+Math.pow(c[6],2)+Math.pow(c[6],2)+Math.pow(c[7],2)+Math.pow(c[8],2)+Math.pow(c[9],2)+Math.pow(c[10],2)+Math.pow(c[11],2)+Math.pow(c[12],2)+Math.pow(c[13],2)+Math.pow(c[14],2)+Math.pow(c[15],2))};"undefined"!==typeof n&&(n.mat4=F);var A={create:function(){var c=new t(4);c[0]=0;c[1]=0;c[2]=0;c[3]=1;return c}};A.rotationTo=function(){var c=w.create(),
a=w.fromValues(1,0,0),b=w.fromValues(0,1,0);return function(d,e,g){var l=w.dot(e,g);if(-.999999>l)return w.cross(c,a,e),1E-6>w.length(c)&&w.cross(c,b,e),w.normalize(c,c),A.setAxisAngle(d,c,Math.PI),d;if(.999999<l)return d[0]=0,d[1]=0,d[2]=0,d[3]=1,d;w.cross(c,e,g);d[0]=c[0];d[1]=c[1];d[2]=c[2];d[3]=1+l;return A.normalize(d,d)}}();A.setAxes=function(){var c=R.create();return function(a,b,d,e){c[0]=d[0];c[3]=d[1];c[6]=d[2];c[1]=e[0];c[4]=e[1];c[7]=e[2];c[2]=-b[0];c[5]=-b[1];c[8]=-b[2];return A.normalize(a,
A.fromMat3(a,c))}}();A.clone=N.clone;A.fromValues=N.fromValues;A.copy=N.copy;A.set=N.set;A.identity=function(c){c[0]=0;c[1]=0;c[2]=0;c[3]=1;return c};A.setAxisAngle=function(c,a,b){b*=.5;var d=Math.sin(b);c[0]=d*a[0];c[1]=d*a[1];c[2]=d*a[2];c[3]=Math.cos(b);return c};A.add=N.add;A.multiply=function(c,a,b){var d=a[0],e=a[1],g=a[2];a=a[3];var l=b[0],u=b[1],h=b[2];b=b[3];c[0]=d*b+a*l+e*h-g*u;c[1]=e*b+a*u+g*l-d*h;c[2]=g*b+a*h+d*u-e*l;c[3]=a*b-d*l-e*u-g*h;return c};A.mul=A.multiply;A.scale=N.scale;A.rotateX=
function(c,a,b){b*=.5;var d=a[0],e=a[1],g=a[2];a=a[3];var l=Math.sin(b);b=Math.cos(b);c[0]=d*b+a*l;c[1]=e*b+g*l;c[2]=g*b-e*l;c[3]=a*b-d*l;return c};A.rotateY=function(c,a,b){b*=.5;var d=a[0],e=a[1],g=a[2];a=a[3];var l=Math.sin(b);b=Math.cos(b);c[0]=d*b-g*l;c[1]=e*b+a*l;c[2]=g*b+d*l;c[3]=a*b-e*l;return c};A.rotateZ=function(c,a,b){b*=.5;var d=a[0],e=a[1],g=a[2];a=a[3];var l=Math.sin(b);b=Math.cos(b);c[0]=d*b+e*l;c[1]=e*b-d*l;c[2]=g*b+a*l;c[3]=a*b-g*l;return c};A.calculateW=function(c,a){var b=a[0],
d=a[1];a=a[2];c[0]=b;c[1]=d;c[2]=a;c[3]=-Math.sqrt(Math.abs(1-b*b-d*d-a*a));return c};A.dot=N.dot;A.lerp=N.lerp;A.slerp=function(c,a,b,d){var e=a[0],g=a[1],l=a[2];a=a[3];var u=b[0],h=b[1],C=b[2];b=b[3];var H=e*u+g*h+l*C+a*b;0>H&&(H=-H,u=-u,h=-h,C=-C,b=-b);if(1E-6<1-H){var L=Math.acos(H);var P=Math.sin(L);H=Math.sin((1-d)*L)/P;d=Math.sin(d*L)/P}else H=1-d;c[0]=H*e+d*u;c[1]=H*g+d*h;c[2]=H*l+d*C;c[3]=H*a+d*b;return c};A.invert=function(c,a){var b=a[0],d=a[1],e=a[2];a=a[3];var g=b*b+d*d+e*e+a*a;g=g?1/
g:0;c[0]=-b*g;c[1]=-d*g;c[2]=-e*g;c[3]=a*g;return c};A.conjugate=function(c,a){c[0]=-a[0];c[1]=-a[1];c[2]=-a[2];c[3]=a[3];return c};A.length=N.length;A.len=A.length;A.squaredLength=N.squaredLength;A.sqrLen=A.squaredLength;A.normalize=N.normalize;A.fromMat3=function(c,a){var b=a[0]+a[4]+a[8];if(0<b)b=Math.sqrt(b+1),c[3]=.5*b,b=.5/b,c[0]=(a[7]-a[5])*b,c[1]=(a[2]-a[6])*b,c[2]=(a[3]-a[1])*b;else{var d=0;a[4]>a[0]&&(d=1);a[8]>a[3*d+d]&&(d=2);var e=(d+1)%3,g=(d+2)%3;b=Math.sqrt(a[3*d+d]-a[3*e+e]-a[3*g+
g]+1);c[d]=.5*b;b=.5/b;c[3]=(a[3*g+e]-a[3*e+g])*b;c[e]=(a[3*e+d]+a[3*d+e])*b;c[g]=(a[3*g+d]+a[3*d+g])*b}return c};A.str=function(c){return"quat("+c[0]+", "+c[1]+", "+c[2]+", "+c[3]+")"};"undefined"!==typeof n&&(n.quat=A)})("undefined"===typeof J?"undefined"!==typeof window?window:v:J)})(this)},{}],23:[function(f,m,J){m.exports=function(){throw Error("ws does not work in the browser. Browser clients must use the native WebSocket object");}},{}],24:[function(f,m,J){function v(){throw Error("setTimeout has not been defined");
}function n(){throw Error("clearTimeout has not been defined");}function r(a){if(w===setTimeout)return setTimeout(a,0);if((w===v||!w)&&setTimeout)return w=setTimeout,setTimeout(a,0);try{return w(a,0)}catch(b){try{return w.call(null,a,0)}catch(d){return w.call(this,a,0)}}}function t(a){if(N===clearTimeout)return clearTimeout(a);if((N===n||!N)&&clearTimeout)return N=clearTimeout,clearTimeout(a);try{return N(a)}catch(b){try{return N.call(null,a)}catch(d){return N.call(this,a)}}}function K(){F&&A&&(F=
!1,A.length?R=A.concat(R):c=-1,R.length&&E())}function E(){if(!F){var a=r(K);F=!0;for(var b=R.length;b;){A=R;for(R=[];++c<b;)A&&A[c].run();c=-1;b=R.length}A=null;F=!1;t(a)}}function U(a,b){this.fun=a;this.array=b}function M(){}f=m.exports={};try{var w="function"===typeof setTimeout?setTimeout:v}catch(a){w=v}try{var N="function"===typeof clearTimeout?clearTimeout:n}catch(a){N=n}var R=[],F=!1,A,c=-1;f.nextTick=function(a){var b=Array(arguments.length-1);if(1<arguments.length)for(var d=1;d<arguments.length;d++)b[d-
1]=arguments[d];R.push(new U(a,b));1!==R.length||F||r(E)};U.prototype.run=function(){this.fun.apply(null,this.array)};f.title="browser";f.browser=!0;f.env={};f.argv=[];f.version="";f.versions={};f.on=M;f.addListener=M;f.once=M;f.off=M;f.removeListener=M;f.removeAllListeners=M;f.emit=M;f.prependListener=M;f.prependOnceListener=M;f.listeners=function(a){return[]};f.binding=function(a){throw Error("process.binding is not supported");};f.cwd=function(){return"/"};f.chdir=function(a){throw Error("process.chdir is not supported");
};f.umask=function(){return 0}},{}],25:[function(f,m,J){(function(v){(function(){(function(n,r){"object"===typeof J&&"undefined"!==typeof m?m.exports=r():(n="undefined"!==typeof globalThis?globalThis:n||self,function(){var t=n._,K=n._=r();K.noConflict=function(){n._=t;return K}}())})(this,function(){function n(k,q){q=null==q?k.length-1:+q;return function(){for(var B=Math.max(arguments.length-q,0),I=Array(B),O=0;O<B;O++)I[O]=arguments[O+q];switch(q){case 0:return k.call(this,I);case 1:return k.call(this,
arguments[0],I);case 2:return k.call(this,arguments[0],arguments[1],I)}B=Array(q+1);for(O=0;O<q;O++)B[O]=arguments[O];B[q]=I;return k.apply(this,B)}}function r(k){var q=typeof k;return"function"===q||"object"===q&&!!k}function t(k){return void 0===k}function K(k){return!0===k||!1===k||"[object Boolean]"===ya.call(k)}function E(k){var q="[object "+k+"]";return function(B){return ya.call(B)===q}}function U(k){return null!=k&&oa(k.getInt8)&&ab(k.buffer)}function M(k,q){return null!=k&&Mb.call(k,q)}function w(k){return bb(k)&&
Nb(k)}function N(k){return function(){return k}}function R(k){return function(q){q=k(q);return"number"==typeof q&&0<=q&&q<=Ob}}function F(k){return function(q){return null==q?void 0:q[k]}}function A(k){return cb?cb(k)&&!Ea(k):Pb(k)&&Qb.test(ya.call(k))}function c(k){for(var q={},B=k.length,I=0;I<B;++I)q[k[I]]=!0;return{contains:function(O){return!0===q[O]},push:function(O){q[O]=!0;return k.push(O)}}}function a(k,q){q=c(q);var B=db.length,I=k.constructor;I=oa(I)&&I.prototype||Ka;var O="constructor";
for(M(k,O)&&!q.contains(O)&&q.push(O);B--;)O=db[B],O in k&&k[O]!==I[O]&&!q.contains(O)&&q.push(O)}function b(k){if(!r(k))return[];if(eb)return eb(k);var q=[],B;for(B in k)M(k,B)&&q.push(B);fb&&a(k,q);return q}function d(k,q){var B=b(q),I=B.length;if(null==k)return!I;k=Object(k);for(var O=0;O<I;O++){var T=B[O];if(q[T]!==k[T]||!(T in k))return!1}return!0}function e(k){if(k instanceof e)return k;if(!(this instanceof e))return new e(k);this._wrapped=k}function g(k,q,B,I){if(k===q)return 0!==k||1/k===
1/q;if(null==k||null==q)return!1;if(k!==k)return q!==q;var O=typeof k;return"function"!==O&&"object"!==O&&"object"!=typeof q?!1:l(k,q,B,I)}function l(k,q,B,I){k instanceof e&&(k=k._wrapped);q instanceof e&&(q=q._wrapped);var O=ya.call(k);if(O!==ya.call(q))return!1;if(gb&&"[object Object]"==O&&Ea(k)){if(!Ea(q))return!1;O="[object DataView]"}switch(O){case "[object RegExp]":case "[object String]":return""+k===""+q;case "[object Number]":return+k!==+k?+q!==+q:0===+k?1/+k===1/q:+k===+q;case "[object Date]":case "[object Boolean]":return+k===
+q;case "[object Symbol]":return hb.valueOf.call(k)===hb.valueOf.call(q);case "[object ArrayBuffer]":case "[object DataView]":return l(new Uint8Array(k.buffer||k,k.byteOffset||0,za(k)),new Uint8Array(q.buffer||q,q.byteOffset||0,za(q)),B,I)}O="[object Array]"===O;if(!O&&ib(k)){if(za(k)!==za(q))return!1;if(k.buffer===q.buffer&&k.byteOffset===q.byteOffset)return!0;O=!0}if(!O){if("object"!=typeof k||"object"!=typeof q)return!1;var T=k.constructor,aa=q.constructor;if(T!==aa&&!(oa(T)&&T instanceof T&&oa(aa)&&
aa instanceof aa)&&"constructor"in k&&"constructor"in q)return!1}B=B||[];I=I||[];for(T=B.length;T--;)if(B[T]===k)return I[T]===q;B.push(k);I.push(q);if(O){T=k.length;if(T!==q.length)return!1;for(;T--;)if(!g(k[T],q[T],B,I))return!1}else{O=b(k);T=O.length;if(b(q).length!==T)return!1;for(;T--;)if(aa=O[T],!M(q,aa)||!g(k[aa],q[aa],B,I))return!1}B.pop();I.pop();return!0}function u(k){if(!r(k))return[];var q=[],B;for(B in k)q.push(B);fb&&a(k,q);return q}function h(k){var q=pa(k);return function(B){if(null==
B)return!1;var I=u(B);if(pa(I))return!1;for(I=0;I<q;I++)if(!oa(B[k[I]]))return!1;return k!==jb||!oa(B[La])}}function C(k){for(var q=b(k),B=q.length,I=Array(B),O=0;O<B;O++)I[O]=k[q[O]];return I}function H(k){for(var q={},B=b(k),I=0,O=B.length;I<O;I++)q[k[B[I]]]=B[I];return q}function L(k){var q=[],B;for(B in k)oa(k[B])&&q.push(B);return q.sort()}function P(k,q){return function(B){var I=arguments.length;q&&(B=Object(B));if(2>I||null==B)return B;for(var O=1;O<I;O++)for(var T=arguments[O],aa=k(T),ha=
aa.length,la=0;la<ha;la++){var na=aa[la];q&&void 0!==B[na]||(B[na]=T[na])}return B}}function S(){return function(){}}function V(k){if(!r(k))return{};if(kb)return kb(k);var q=S();q.prototype=k;k=new q;q.prototype=null;return k}function Z(k){return ua(k)?k:[k]}function Y(k,q){for(var B=q.length,I=0;I<B;I++){if(null==k)return;k=k[q[I]]}return B?k:void 0}function da(k,q,B){k=Y(k,e.toPath(q));return t(k)?B:k}function ia(k){return k}function ba(k){k=Fa({},k);return function(q){return d(q,k)}}function ea(k){k=
e.toPath(k);return function(q){return Y(q,k)}}function ca(k,q,B){if(void 0===q)return k;switch(null==B?3:B){case 1:return function(I){return k.call(q,I)};case 3:return function(I,O,T){return k.call(q,I,O,T)};case 4:return function(I,O,T,aa){return k.call(q,I,O,T,aa)}}return function(){return k.apply(q,arguments)}}function p(k,q,B){return null==k?ia:oa(k)?ca(k,q,B):r(k)&&!ua(k)?ba(k):ea(k)}function D(k,q){return p(k,q,Infinity)}function G(k,q,B){return e.iteratee!==D?e.iteratee(k,q):p(k,q,B)}function Q(){}
function W(k,q){null==q&&(q=k,k=0);return k+Math.floor(Math.random()*(q-k+1))}function X(k){var q=function(T){return k[T]},B="(?:"+b(k).join("|")+")",I=RegExp(B),O=RegExp(B,"g");return function(T){T=null==T?"":""+T;return I.test(T)?T.replace(O,q):T}}function fa(k){return"\\"+Rb[k]}function ja(k,q,B,I,O){if(!(I instanceof q))return k.apply(B,O);q=V(k.prototype);k=k.apply(q,O);return r(k)?k:q}function ka(k,q,B,I){I=I||[];if(!q&&0!==q)q=Infinity;else if(0>=q)return I.concat(k);for(var O=I.length,T=0,
aa=pa(k);T<aa;T++){var ha=k[T];if(qa(ha)&&(ua(ha)||Ma(ha)))if(1<q)ka(ha,q-1,B,I),O=I.length;else for(var la=0,na=ha.length;la<na;)I[O++]=ha[la++];else B||(I[O++]=ha)}return I}function ra(k){return function(){return!k.apply(this,arguments)}}function Aa(k,q){var B;return function(){0<--k&&(B=q.apply(this,arguments));1>=k&&(q=null);return B}}function Ba(k,q,B){q=G(q,B);B=b(k);for(var I,O=0,T=B.length;O<T;O++)if(I=B[O],q(k[I],I,k))return I}function Ga(k){return function(q,B,I){B=G(B,I);I=pa(q);for(var O=
0<k?0:I-1;0<=O&&O<I;O+=k)if(B(q[O],O,q))return O;return-1}}function lb(k,q,B,I){B=G(B,I,1);q=B(q);I=0;for(var O=pa(k);I<O;){var T=Math.floor((I+O)/2);B(k[T])<q?I=T+1:O=T}return I}function mb(k,q,B){return function(I,O,T){var aa=0,ha=pa(I);if("number"==typeof T)0<k?aa=0<=T?T:Math.max(T+ha,aa):ha=0<=T?Math.min(T+1,ha):T+ha+1;else if(B&&T&&ha)return T=B(I,O),I[T]===O?T:-1;if(O!==O)return T=q(Ca.call(I,aa,ha),w),0<=T?T+aa:-1;for(T=0<k?aa:ha-1;0<=T&&T<ha;T+=k)if(I[T]===O)return T;return-1}}function Na(k,
q,B){q=(qa(k)?Oa:Ba)(k,q,B);if(void 0!==q&&-1!==q)return k[q]}function sa(k,q,B){q=ca(q,B);var I;if(qa(k))for(B=0,I=k.length;B<I;B++)q(k[B],B,k);else{var O=b(k);B=0;for(I=O.length;B<I;B++)q(k[O[B]],O[B],k)}return k}function va(k,q,B){q=G(q,B);B=!qa(k)&&b(k);for(var I=(B||k).length,O=Array(I),T=0;T<I;T++){var aa=B?B[T]:T;O[T]=q(k[aa],aa,k)}return O}function nb(k){return function(q,B,I,O){var T=3<=arguments.length,aa=ca(B,O,4),ha=I,la=!qa(q)&&b(q),na=(la||q).length,ma=0<k?0:na-1;T||(ha=q[la?la[ma]:
ma],ma+=k);for(;0<=ma&&ma<na;ma+=k)T=la?la[ma]:ma,ha=aa(ha,q[T],T,q);return ha}}function wa(k,q,B){var I=[];q=G(q,B);sa(k,function(O,T,aa){q(O,T,aa)&&I.push(O)});return I}function ob(k,q,B){q=G(q,B);B=!qa(k)&&b(k);for(var I=(B||k).length,O=0;O<I;O++){var T=B?B[O]:O;if(!q(k[T],T,k))return!1}return!0}function pb(k,q,B){q=G(q,B);B=!qa(k)&&b(k);for(var I=(B||k).length,O=0;O<I;O++){var T=B?B[O]:O;if(q(k[T],T,k))return!0}return!1}function ta(k,q,B,I){qa(k)||(k=C(k));if("number"!=typeof B||I)B=0;return 0<=
qb(k,q,B)}function Pa(k,q){return va(k,ea(q))}function rb(k,q,B){var I=-Infinity,O=-Infinity,T;if(null==q||"number"==typeof q&&"object"!=typeof k[0]&&null!=k){k=qa(k)?k:C(k);for(var aa=0,ha=k.length;aa<ha;aa++)B=k[aa],null!=B&&B>I&&(I=B)}else q=G(q,B),sa(k,function(la,na,ma){T=q(la,na,ma);if(T>O||-Infinity===T&&-Infinity===I)I=la,O=T});return I}function sb(k){return k?ua(k)?Ca.call(k):Qa(k)?k.match(Sb):qa(k)?va(k,ia):C(k):[]}function tb(k,q,B){if(null==q||B)return qa(k)||(k=C(k)),k[W(k.length-1)];
k=sb(k);B=pa(k);q=Math.max(Math.min(q,B),0);--B;for(var I=0;I<q;I++){var O=W(I,B),T=k[I];k[I]=k[O];k[O]=T}return k.slice(0,q)}function Ha(k,q){return function(B,I,O){var T=q?[[],[]]:{};I=G(I,O);sa(B,function(aa,ha){ha=I(aa,ha,B);k(T,aa,ha)});return T}}function Tb(k,q,B){return q in B}function ub(k,q,B){return Ca.call(k,0,Math.max(0,k.length-(null==q||B?1:q)))}function Ra(k,q,B){return null==k||1>k.length?null==q||B?void 0:[]:null==q||B?k[0]:ub(k,k.length-q)}function Ia(k,q,B){return Ca.call(k,null==
q||B?1:q)}function Sa(k,q,B,I){K(q)||(I=B,B=q,q=!1);null!=B&&(B=G(B,I));I=[];for(var O=[],T=0,aa=pa(k);T<aa;T++){var ha=k[T],la=B?B(ha,T,k):ha;q&&!B?(T&&O===la||I.push(ha),O=la):B?ta(O,la)||(O.push(la),I.push(ha)):ta(I,ha)||I.push(ha)}return I}function Ta(k){for(var q=k&&rb(k,pa).length||0,B=Array(q),I=0;I<q;I++)B[I]=Pa(k,I);return B}function Ua(k,q){return k._chain?e(q).chain():q}function vb(k){sa(L(k),function(q){var B=e[q]=k[q];e.prototype[q]=function(){var I=[this._wrapped];Ub.apply(I,arguments);
return Ua(this,B.apply(e,I))}});return e}var wb="object"==typeof self&&self.self===self&&self||"object"==typeof v&&v.global===v&&v||Function("return this")()||{},Ja=Array.prototype,Ka=Object.prototype,hb="undefined"!==typeof Symbol?Symbol.prototype:null,Ub=Ja.push,Ca=Ja.slice,ya=Ka.toString,Mb=Ka.hasOwnProperty,xb="undefined"!==typeof ArrayBuffer,Vb="undefined"!==typeof DataView,Wb=Array.isArray,eb=Object.keys,kb=Object.create,cb=xb&&ArrayBuffer.isView,Nb=isNaN,Xb=isFinite,fb=!{toString:null}.propertyIsEnumerable("toString"),
db="valueOf isPrototypeOf toString propertyIsEnumerable hasOwnProperty toLocaleString".split(" "),Ob=Math.pow(2,53)-1,Qa=E("String"),bb=E("Number"),Yb=E("Date"),Zb=E("RegExp"),$b=E("Error"),yb=E("Symbol"),ab=E("ArrayBuffer"),zb=E("Function"),ac=wb.document&&wb.document.childNodes;"function"!=typeof/./&&"object"!=typeof Int8Array&&"function"!=typeof ac&&(zb=function(k){return"function"==typeof k||!1});var oa=zb,Ab=E("Object"),gb=Vb&&Ab(new DataView(new ArrayBuffer(8))),Va="undefined"!==typeof Map&&
Ab(new Map),bc=E("DataView"),Ea=gb?U:bc,ua=Wb||E("Array"),Wa=E("Arguments");(function(){Wa(arguments)||(Wa=function(k){return M(k,"callee")})})();var Ma=Wa,za=F("byteLength"),Pb=R(za),Qb=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,ib=xb?A:N(!1),pa=F("length");e.VERSION="1.13.2";e.prototype.value=function(){return this._wrapped};e.prototype.valueOf=e.prototype.toJSON=e.prototype.value;e.prototype.toString=function(){return String(this._wrapped)};var La="forEach",Xa=
["clear","delete"],Bb=["get","has","set"],cc=Xa.concat(La,Bb),jb=Xa.concat(Bb),dc=["add"].concat(Xa,La,"has"),ec=Va?h(cc):E("Map"),fc=Va?h(jb):E("WeakMap"),gc=Va?h(dc):E("Set"),hc=E("WeakSet"),Cb=P(u),Fa=P(b),Db=P(u,!0);e.toPath=Z;e.iteratee=D;var Da=Date.now||function(){return(new Date).getTime()},Eb={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},ic=X(Eb),jc=H(Eb),kc=X(jc),lc=e.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},
Ya=/(.)^/,Rb={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},mc=/\\|'|\r|\n|\u2028|\u2029/g,nc=/^\s*(\w|\$)+\s*$/,oc=0,xa=n(function(k,q){var B=xa.placeholder,I=function(){for(var O=0,T=q.length,aa=Array(T),ha=0;ha<T;ha++)aa[ha]=q[ha]===B?arguments[O++]:q[ha];for(;O<arguments.length;)aa.push(arguments[O++]);return ja(k,I,this,this,aa)};return I});xa.placeholder=e;var Fb=n(function(k,q,B){if(!oa(k))throw new TypeError("Bind must be called on a function");var I=n(function(O){return ja(k,
I,q,this,B.concat(O))});return I}),qa=R(pa),pc=n(function(k,q){q=ka(q,!1,!1);var B=q.length;if(1>B)throw Error("bindAll must be passed function names");for(;B--;){var I=q[B];k[I]=Fb(k[I],k)}return k}),Gb=n(function(k,q,B){return setTimeout(function(){return k.apply(null,B)},q)}),qc=xa(Gb,e,1),rc=xa(Aa,2),Oa=Ga(1),Hb=Ga(-1),qb=mb(1,Oa,lb),sc=mb(-1,Hb),Za=nb(1),Ib=nb(-1),tc=n(function(k,q,B){if(oa(q))var I=q;else{q=e.toPath(q);var O=q.slice(0,-1);q=q[q.length-1]}return va(k,function(T){var aa=I;if(!aa){O&&
O.length&&(T=Y(T,O));if(null==T)return;aa=T[q]}return null==aa?aa:aa.apply(T,B)})}),Sb=/[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g,uc=Ha(function(k,q,B){M(k,B)?k[B].push(q):k[B]=[q]}),vc=Ha(function(k,q,B){k[B]=q}),wc=Ha(function(k,q,B){M(k,B)?k[B]++:k[B]=1}),xc=Ha(function(k,q,B){k[B?0:1].push(q)},!0),Jb=n(function(k,q){var B={},I=q[0];if(null==k)return B;oa(I)?(1<q.length&&(I=ca(I,q[1])),q=u(k)):(I=Tb,q=ka(q,!1,!1),k=Object(k));for(var O=0,T=q.length;O<T;O++){var aa=q[O],
ha=k[aa];I(ha,aa,k)&&(B[aa]=ha)}return B}),yc=n(function(k,q){var B=q[0],I;oa(B)?(B=ra(B),1<q.length&&(I=q[1])):(q=va(ka(q,!1,!1),String),B=function(O,T){return!ta(q,T)});return Jb(k,B,I)}),Kb=n(function(k,q){q=ka(q,!0,!0);return wa(k,function(B){return!ta(q,B)})}),zc=n(function(k,q){return Kb(k,q)}),Ac=n(function(k){return Sa(ka(k,!0,!0))}),Bc=n(Ta);sa("pop push reverse shift sort splice unshift".split(" "),function(k){var q=Ja[k];e.prototype[k]=function(){var B=this._wrapped;null!=B&&(q.apply(B,
arguments),"shift"!==k&&"splice"!==k||0!==B.length||delete B[0]);return Ua(this,B)}});sa(["concat","join","slice"],function(k){var q=Ja[k];e.prototype[k]=function(){var B=this._wrapped;null!=B&&(B=q.apply(B,arguments));return Ua(this,B)}});var Lb=vb({__proto__:null,VERSION:"1.13.2",restArguments:n,isObject:r,isNull:function(k){return null===k},isUndefined:t,isBoolean:K,isElement:function(k){return!(!k||1!==k.nodeType)},isString:Qa,isNumber:bb,isDate:Yb,isRegExp:Zb,isError:$b,isSymbol:yb,isArrayBuffer:ab,
isDataView:Ea,isArray:ua,isFunction:oa,isArguments:Ma,isFinite:function(k){return!yb(k)&&Xb(k)&&!isNaN(parseFloat(k))},isNaN:w,isTypedArray:ib,isEmpty:function(k){if(null==k)return!0;var q=pa(k);return"number"==typeof q&&(ua(k)||Qa(k)||Ma(k))?0===q:0===pa(b(k))},isMatch:d,isEqual:function(k,q){return g(k,q)},isMap:ec,isWeakMap:fc,isSet:gc,isWeakSet:hc,keys:b,allKeys:u,values:C,pairs:function(k){for(var q=b(k),B=q.length,I=Array(B),O=0;O<B;O++)I[O]=[q[O],k[q[O]]];return I},invert:H,functions:L,methods:L,
extend:Cb,extendOwn:Fa,assign:Fa,defaults:Db,create:function(k,q){k=V(k);q&&Fa(k,q);return k},clone:function(k){return r(k)?ua(k)?k.slice():Cb({},k):k},tap:function(k,q){q(k);return k},get:da,has:function(k,q){q=e.toPath(q);for(var B=q.length,I=0;I<B;I++){var O=q[I];if(!M(k,O))return!1;k=k[O]}return!!B},mapObject:function(k,q,B){q=G(q,B);B=b(k);for(var I=B.length,O={},T=0;T<I;T++){var aa=B[T];O[aa]=q(k[aa],aa,k)}return O},identity:ia,constant:N,noop:Q,toPath:Z,property:ea,propertyOf:function(k){return null==
k?Q:function(q){return da(k,q)}},matcher:ba,matches:ba,times:function(k,q,B){var I=Array(Math.max(0,k));q=ca(q,B,1);for(B=0;B<k;B++)I[B]=q(B);return I},random:W,now:Da,escape:ic,unescape:kc,templateSettings:lc,template:function(k,q,B){!q&&B&&(q=B);q=Db({},q,e.templateSettings);B=RegExp([(q.escape||Ya).source,(q.interpolate||Ya).source,(q.evaluate||Ya).source].join("|")+"|$","g");var I=0,O="__p+='";k.replace(B,function(aa,ha,la,na,ma){O+=k.slice(I,ma).replace(mc,fa);I=ma+aa.length;ha?O+="'+\n((__t=("+
ha+"))==null?'':_.escape(__t))+\n'":la?O+="'+\n((__t=("+la+"))==null?'':__t)+\n'":na&&(O+="';\n"+na+"\n__p+='");return aa});O+="';\n";if(q=q.variable){if(!nc.test(q))throw Error("variable is not a bare identifier: "+q);}else O="with(obj||{}){\n"+O+"}\n",q="obj";O="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+O+"return __p;\n";try{var T=new Function(q,"_",O)}catch(aa){throw aa.source=O,aa;}B=function(aa){return T.call(this,aa,e)};B.source="function("+q+
"){\n"+O+"}";return B},result:function(k,q,B){q=e.toPath(q);var I=q.length;if(!I)return oa(B)?B.call(k):B;for(var O=0;O<I;O++){var T=null==k?void 0:k[q[O]];void 0===T&&(T=B,O=I);k=oa(T)?T.call(k):T}return k},uniqueId:function(k){var q=++oc+"";return k?k+q:q},chain:function(k){k=e(k);k._chain=!0;return k},iteratee:D,partial:xa,bind:Fb,bindAll:pc,memoize:function(k,q){var B=function(I){var O=B.cache,T=""+(q?q.apply(this,arguments):I);M(O,T)||(O[T]=k.apply(this,arguments));return O[T]};B.cache={};return B},
delay:Gb,defer:qc,throttle:function(k,q,B){var I,O,T,aa,ha=0;B||(B={});var la=function(){ha=!1===B.leading?0:Da();I=null;aa=k.apply(O,T);I||(O=T=null)},na=function(){var ma=Da();ha||!1!==B.leading||(ha=ma);var $a=q-(ma-ha);O=this;T=arguments;0>=$a||$a>q?(I&&(clearTimeout(I),I=null),ha=ma,aa=k.apply(O,T),I||(O=T=null)):I||!1===B.trailing||(I=setTimeout(la,$a));return aa};na.cancel=function(){clearTimeout(I);ha=0;I=O=T=null};return na},debounce:function(k,q,B){var I,O,T,aa,ha,la=function(){var ma=Da()-
O;q>ma?I=setTimeout(la,q-ma):(I=null,B||(aa=k.apply(ha,T)),I||(T=ha=null))},na=n(function(ma){ha=this;T=ma;O=Da();I||(I=setTimeout(la,q),B&&(aa=k.apply(ha,T)));return aa});na.cancel=function(){clearTimeout(I);I=T=ha=null};return na},wrap:function(k,q){return xa(q,k)},negate:ra,compose:function(){var k=arguments,q=k.length-1;return function(){for(var B=q,I=k[q].apply(this,arguments);B--;)I=k[B].call(this,I);return I}},after:function(k,q){return function(){if(1>--k)return q.apply(this,arguments)}},
before:Aa,once:rc,findKey:Ba,findIndex:Oa,findLastIndex:Hb,sortedIndex:lb,indexOf:qb,lastIndexOf:sc,find:Na,detect:Na,findWhere:function(k,q){return Na(k,ba(q))},each:sa,forEach:sa,map:va,collect:va,reduce:Za,foldl:Za,inject:Za,reduceRight:Ib,foldr:Ib,filter:wa,select:wa,reject:function(k,q,B){return wa(k,ra(G(q)),B)},every:ob,all:ob,some:pb,any:pb,contains:ta,includes:ta,include:ta,invoke:tc,pluck:Pa,where:function(k,q){return wa(k,ba(q))},max:rb,min:function(k,q,B){var I=Infinity,O=Infinity,T;if(null==
q||"number"==typeof q&&"object"!=typeof k[0]&&null!=k){k=qa(k)?k:C(k);for(var aa=0,ha=k.length;aa<ha;aa++)B=k[aa],null!=B&&B<I&&(I=B)}else q=G(q,B),sa(k,function(la,na,ma){T=q(la,na,ma);if(T<O||Infinity===T&&Infinity===I)I=la,O=T});return I},shuffle:function(k){return tb(k,Infinity)},sample:tb,sortBy:function(k,q,B){var I=0;q=G(q,B);return Pa(va(k,function(O,T,aa){return{value:O,index:I++,criteria:q(O,T,aa)}}).sort(function(O,T){var aa=O.criteria,ha=T.criteria;if(aa!==ha){if(aa>ha||void 0===aa)return 1;
if(aa<ha||void 0===ha)return-1}return O.index-T.index}),"value")},groupBy:uc,indexBy:vc,countBy:wc,partition:xc,toArray:sb,size:function(k){return null==k?0:qa(k)?k.length:b(k).length},pick:Jb,omit:yc,first:Ra,head:Ra,take:Ra,initial:ub,last:function(k,q,B){return null==k||1>k.length?null==q||B?void 0:[]:null==q||B?k[k.length-1]:Ia(k,Math.max(0,k.length-q))},rest:Ia,tail:Ia,drop:Ia,compact:function(k){return wa(k,Boolean)},flatten:function(k,q){return ka(k,q,!1)},without:zc,uniq:Sa,unique:Sa,union:Ac,
intersection:function(k){for(var q=[],B=arguments.length,I=0,O=pa(k);I<O;I++){var T=k[I];if(!ta(q,T)){var aa;for(aa=1;aa<B&&ta(arguments[aa],T);aa++);aa===B&&q.push(T)}}return q},difference:Kb,unzip:Ta,transpose:Ta,zip:Bc,object:function(k,q){for(var B={},I=0,O=pa(k);I<O;I++)q?B[k[I]]=q[I]:B[k[I][0]]=k[I][1];return B},range:function(k,q,B){null==q&&(q=k||0,k=0);B||(B=q<k?-1:1);q=Math.max(Math.ceil((q-k)/B),0);for(var I=Array(q),O=0;O<q;O++,k+=B)I[O]=k;return I},chunk:function(k,q){if(null==q||1>q)return[];
for(var B=[],I=0,O=k.length;I<O;)B.push(Ca.call(k,I,I+=q));return B},mixin:vb,"default":e});return Lb._=Lb})}).call(this)}).call(this,"undefined"!==typeof global?global:"undefined"!==typeof self?self:"undefined"!==typeof window?window:{})},{}]},{},[13])(13)});let CindyLeap=function(f){function m(r,t){let K,E;for(K in r)(E=t[K])?E(v(r[K])):console.log("Modifier "+K+" not supported")}let J=f.nada,v=f.evaluate,n=f.defineFunction;n("initleapmotion",0,function(r,t){let K=!1;m(t,{enablegestures:E=>K=coerce.toBool(E,!1),usehandtransformcdy3d:E=>setManipulateSceneTransformActive(coerce.toBool(E,!1)),rotationfactor:E=>setLeapMotionRotationFactor(coerce.toReal(E,2)),translationfactor:E=>setLeapMotionTranslationFactor(coerce.toReal(E,1))});initLeapMotion(f,K);return J});
n("leapdebugprinthands",0,function(r,t){r=getLeapHandsData();0<r.length&&console.log(r);return J});n("leapdebugprintgestures",0,function(r,t){r=getLeapGestureData();0<r.length&&console.log(r);return J});n("leapnormalizeposition",1,function(r,t){r=f.evaluate(r[0]).value;r=leapNormalizePosition([r[0].value.real,r[1].value.real,r[2].value.real]);return nestedArrayToCSList(r)});n("getleaphandsdata",0,function(r,t){r=new Set(["frame"]);t=getLeapHandsData();return convertObjectToCindyDict(t,r,new Map)});
n("getleapgesturedata",0,function(r,t){r=new Set(["frame"]);t=getLeapGestureData();return convertObjectToCindyDict(t,r,new Map)});n("getleapmotionmodelmatrix",0,function(r,t){r=getLeapMotionModelMatrix();return nestedArrayToCSList([[r[0],r[1],r[2],r[3]],[r[4],r[5],r[6],r[7]],[r[8],r[9],r[10],r[11]],[r[12],r[13],r[14],r[15]]])});n("getleapmotionrotationmatrix",0,function(r,t){r=getLeapMotionModelMatrix();return nestedArrayToCSList([[r[0],r[1],r[2]],[r[4],r[5],r[6]],[r[8],r[9],r[10]]])});n("getleapmotiontranslationvector",
0,function(r,t){r=getLeapMotionModelMatrix();return nestedArrayToCSList([r[3]+1E-6,r[7],r[11]])});n("getleapmotiontransformhaschanged",0,function(r,t){return{ctype:"boolean",value:getLeapMotionTransformHasChanged()}})};CindyLeap.leapPreRender=leapPreRender;CindyLeap.leapPostRender=leapPostRender;CindyJS.registerPlugin(1,"CindyLeap",CindyLeap);var modelMatrixTmp,mvMatrixTmp,leapMotionModelMatrixInternal=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],leapMotionRotationMatrixInternal=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],leapMotionTransformHasChanged=!1,leapMotionRotationFactor=2,leapMotionTranslationFactor=1,lastLeapFrame=null,manipulateSceneTransformActive=!1,gesturesEnabled=!1;
function leapPreRender(f){if(manipulateSceneTransformActive){modelMatrixTmp=f.modelMatrix.slice();mvMatrixTmp=f.mvMatrix.slice();let m=getLeapMotionModelMatrix();f.modelMatrix=mul4mm(m,f.modelMatrix);f.mvMatrix=mul4mm(f.viewMatrix,f.modelMatrix)}}function leapPostRender(f){manipulateSceneTransformActive&&(f.modelMatrix=modelMatrixTmp.slice(),f.mvMatrix=mvMatrixTmp.slice())}
function initLeapMotion(f,m){gesturesEnabled=m;var J=new Leap.Controller({enableGestures:m});J.on("frame",function(v){onLeapMotionControllerFrame(f,J,v)});J.connect()}
function onLeapMotionControllerFrame(f,m,J){if(0<J.hands.length){lastLeapFrame=J;var v=J.hands[0];m=m.frame(1);v.rotationMatrix(m);J=J.interactionBox.normalizePoint(v.palmPosition,!0);m=v.palmNormal;var n=v.direction;m=[m[1]*n[2]-m[2]*n[1],m[2]*n[0]-m[0]*n[2],m[0]*n[1]-m[1]*n[0]];leapMotionRotationMatrixInternal=[m[0],m[1],m[2],0,v.palmNormal[0],v.palmNormal[1],v.palmNormal[2],0,v.direction[0],v.direction[1],v.direction[2],0,0,0,0,1];leapMotionRotationMatrixInternal=transpose4(mul4mm([1,0,0,0,0,-1,
0,0,0,0,-1,0,0,0,0,1],leapMotionRotationMatrixInternal));2==leapMotionRotationFactor?leapMotionRotationMatrixInternal=mul4mm(leapMotionRotationMatrixInternal,leapMotionRotationMatrixInternal):1!=leapMotionRotationFactor&&(v=axisAngleFromRotationMatrix(leapMotionRotationMatrixInternal),leapMotionRotationMatrixInternal=rotationMatrixFromAxisAngle(v[0],leapMotionRotationFactor*v[1]));leapMotionModelMatrixInternal=leapMotionRotationMatrixInternal.slice();leapMotionModelMatrixInternal[3]=leapMotionTranslationFactor*
(2*J[0]-1);leapMotionModelMatrixInternal[7]=leapMotionTranslationFactor*(2*J[1]-1);leapMotionModelMatrixInternal[11]=leapMotionTranslationFactor*(2*J[2]-1);leapMotionTransformHasChanged=!0;f.scheduleUpdate()}}function setManipulateSceneTransformActive(f){manipulateSceneTransformActive=f}function getLeapHandsData(){return null!=lastLeapFrame?lastLeapFrame.hands:[]}function getLeapGestureData(){return null!=lastLeapFrame&&gesturesEnabled?lastLeapFrame.gestures:[]}
function leapNormalizePosition(f){return null!=lastLeapFrame?(f=lastLeapFrame.interactionBox.normalizePoint(f,!0),[leapMotionTranslationFactor*(2*f[0]-1),leapMotionTranslationFactor*(2*f[1]-1),leapMotionTranslationFactor*(2*f[2]-1)]):f}function rotationMatrixFromAxisAngle(f,m){let J=Math.sin(m);m=Math.cos(m);let v=1-m;return[m+f[0]*f[0]*v,f[0]*f[1]*v-f[2]*J,f[0]*f[2]*v+f[1]*J,0,f[1]*f[0]*v+f[2]*J,m+f[1]*f[1]*v,f[1]*f[2]*v-f[0]*J,0,f[2]*f[0]*v-f[1]*J,f[2]*f[1]*v+f[0]*J,m+f[2]*f[2]*v,0,0,0,0,1]}
function axisAngleFromRotationMatrix(f){var m=function(J){return J*J};if(.001>Math.abs(f[1]-f[4])&&.001>Math.abs(f[2]-f[8])&&.001>Math.abs(f[6]-f[9])){if(.001>Math.abs(f[1]+f[4])&&.01>Math.abs(f[2]+f[8])&&.01>Math.abs(f[6]+f[9])&&.01>Math.abs(f[0]+f[5]+f[10]-3))return[[1,0,0],0];m=(f[0]+1)/2;let J=(f[5]+1)/2,v=(f[10]+1)/2,n=(f[1]+f[4])/4,r=(f[2]+f[8])/4;f=(f[6]+f[9])/4;let t=1/Math.sqrt(2);m>J&&m>v?.001>m?(x=0,z=y=t):(x=Math.sqrt(m),y=n/x,z=r/x):J>v?.001>J?(x=t,y=0,z=t):(y=Math.sqrt(J),x=n/y,z=f/
y):.001>v?(y=x=t,z=0):(z=Math.sqrt(v),x=r/z,y=f/z);return[[0,0,0],Math.PI]}m=Math.sqrt(m(f[9]-f[6])+m(f[2]-f[8])+m(f[4]-f[1]));return[[(f[9]-f[6])/m,(f[2]-f[8])/m,(f[4]-f[1])/m],Math.acos((f[0]+f[5]+f[10]-1)/2)]}function getLeapMotionModelMatrix(){return leapMotionModelMatrixInternal}function getLeapMotionTransformHasChanged(){return leapMotionTransformHasChanged?(leapMotionTransformHasChanged=!1,!0):!1}function setLeapMotionRotationFactor(f){leapMotionRotationFactor=f}
function setLeapMotionTranslationFactor(f){leapMotionTranslationFactor=f};/*
LeapJS v0.6.4
http://github.com/leapmotion/leapjs/
Copyright 2013 LeapMotion, Inc. and other contributors
Released under the Apache-2.0 license
http://github.com/leapmotion/leapjs/blob/master/LICENSE.txt
*/
(function(f,m,J){function v(t,K){if(!m[t]){if(!f[t]){var E="function"==typeof require&&require;if(!K&&E)return E(t,!0);if(n)return n(t,!0);throw Error("Cannot find module '"+t+"'");}K=m[t]={exports:{}};f[t][0].call(K.exports,function(U){var M=f[t][1][U];return v(M?M:U)},K,K.exports)}return m[t].exports}for(var n="function"==typeof require&&require,r=0;r<J.length;r++)v(J[r]);return v})({1:[function(f,m,J){f("./pointable");J=f("gl-matrix");var v=J.vec3,n=J.mat3,r=J.mat4;f("underscore");f=m.exports=
function(t,K){this.finger=t;this._matrix=this._center=null;this.type=K.type;this.prevJoint=K.prevJoint;this.nextJoint=K.nextJoint;this.width=K.width;t=Array(3);v.sub(t,K.nextJoint,K.prevJoint);this.length=v.length(t);this.basis=K.basis};f.prototype.left=function(){return this._left?this._left:this._left=0>n.determinant(this.basis[0].concat(this.basis[1]).concat(this.basis[2]))};f.prototype.matrix=function(){if(this._matrix)return this._matrix;var t=this.basis,K=this._matrix=r.create();K[0]=t[0][0];
K[1]=t[0][1];K[2]=t[0][2];K[4]=t[1][0];K[5]=t[1][1];K[6]=t[1][2];K[8]=t[2][0];K[9]=t[2][1];K[10]=t[2][2];K[3]=this.center()[0];K[7]=this.center()[1];K[11]=this.center()[2];this.left()&&(K[0]*=-1,K[1]*=-1,K[2]*=-1);return this._matrix};f.prototype.lerp=function(t,K){v.lerp(t,this.prevJoint,this.nextJoint,K)};f.prototype.center=function(){if(this._center)return this._center;var t=v.create();this.lerp(t,.5);return this._center=t};f.prototype.direction=function(){return[-1*this.basis[2][0],-1*this.basis[2][1],
-1*this.basis[2][2]]}},{"./pointable":14,"gl-matrix":23,underscore:24}],2:[function(f,m,J){f=m.exports=function(v){this.pos=0;this._buf=[];this.size=v};f.prototype.get=function(v){void 0==v&&(v=0);if(!(v>=this.size||v>=this._buf.length))return this._buf[(this.pos-v-1)%this.size]};f.prototype.push=function(v){this._buf[this.pos%this.size]=v;return this.pos++}},{}],3:[function(f,m,J){var v=f("../protocol").chooseProtocol;J=f("events").EventEmitter;var n=f("underscore"),r=m.exports=function(t){this.opts=
n.defaults(t||{},{host:"127.0.0.1",enableGestures:!1,scheme:this.getScheme(),port:this.getPort(),background:!1,optimizeHMD:!1,requestProtocolVersion:r.defaultProtocolVersion});this.host=this.opts.host;this.port=this.opts.port;this.scheme=this.opts.scheme;this.protocolVersionVerified=!1;this.optimizeHMD=this.background=null;this.on("ready",function(){this.enableGestures(this.opts.enableGestures);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.")})};r.defaultProtocolVersion=6;r.prototype.getUrl=function(){return this.scheme+"//"+this.host+":"+this.port+"/v"+this.opts.requestProtocolVersion+".json"};r.prototype.getScheme=function(){return"ws:"};r.prototype.getPort=function(){return 6437};r.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))};r.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))};r.prototype.handleOpen=function(){this.connected||(this.connected=!0,this.emit("connect"))};r.prototype.enableGestures=function(t){this.gesturesEnabled=t?!0:!1;this.send(this.protocol.encode({enableGestures:this.gesturesEnabled}))};
r.prototype.handleClose=function(t,K){this.connected&&(this.disconnect(),1001===t&&1<this.opts.requestProtocolVersion&&(this.protocolVersionVerified?this.protocolVersionVerified=!1:this.opts.requestProtocolVersion--),this.startReconnection())};r.prototype.startReconnection=function(){var t=this;this.reconnectionTimer||(this.reconnectionTimer=setInterval(function(){t.reconnect()},500))};r.prototype.stopReconnection=function(){this.reconnectionTimer=clearInterval(this.reconnectionTimer)};r.prototype.disconnect=
function(t){t||this.stopReconnection();if(this.socket)return this.socket.close(),delete this.socket,delete this.protocol,delete this.background,delete this.optimizeHMD,delete this.focusedState,this.connected&&(this.connected=!1,this.emit("disconnect")),!0};r.prototype.reconnect=function(){this.connected?this.stopReconnection():(this.disconnect(!0),this.connect())};r.prototype.handleData=function(t){t=JSON.parse(t);void 0===this.protocol?(t=this.protocol=v(t),this.protocolVersionVerified=!0,this.emit("ready")):
t=this.protocol(t);this.emit(t.type,t)};r.prototype.connect=function(){if(!this.socket)return this.socket=this.setupSocket(),!0};r.prototype.send=function(t){this.socket.send(t)};r.prototype.reportFocus=function(t){this.connected&&this.focusedState!==t&&(this.focusedState=t,this.emit(this.focusedState?"focus":"blur"),this.protocol&&this.protocol.sendFocused&&this.protocol.sendFocused(this,this.focusedState))};n.extend(r.prototype,J.prototype)},{"../protocol":15,events:21,underscore:24}],4:[function(f,
m,J){var v=m.exports=f("./base");f=f("underscore");m=m.exports=function(n){v.call(this,n);var r=this;this.on("ready",function(){r.startFocusLoop()});this.on("disconnect",function(){r.stopFocusLoop()})};f.extend(m.prototype,v.prototype);m.__proto__=v;m.prototype.useSecure=function(){return"https:"===location.protocol};m.prototype.getScheme=function(){return this.useSecure()?"wss:":"ws:"};m.prototype.getPort=function(){return this.useSecure()?6436:6437};m.prototype.setupSocket=function(){var n=this,
r=new WebSocket(this.getUrl());r.onopen=function(){n.handleOpen()};r.onclose=function(t){n.handleClose(t.code,t.reason)};r.onmessage=function(t){n.handleData(t.data)};r.onerror=function(t){n.useSecure()&&"wss:"===n.scheme?(n.scheme="ws:",n.port=6437,n.disconnect(),n.connect()):confirm("Leap Motion controller driver (V2) not found. Please download the driver from the following website and check that the port 6437 is open.")&&(window.location.href="https://developer.leapmotion.com/sdk/v2")};return r};
m.prototype.startFocusLoop=function(){if(!this.focusDetectorTimer){var n=this,r=null;r="undefined"!==typeof document.hidden?"hidden":"undefined"!==typeof document.mozHidden?"mozHidden":"undefined"!==typeof document.msHidden?"msHidden":"undefined"!==typeof document.webkitHidden?"webkitHidden":void 0;void 0===n.windowVisible&&(n.windowVisible=void 0===r?!0:!1===document[r]);var t=window.addEventListener("focus",function(U){n.windowVisible=!0;E()}),K=window.addEventListener("blur",function(U){n.windowVisible=
!1;E()});this.on("disconnect",function(){window.removeEventListener("focus",t);window.removeEventListener("blur",K)});var E=function(){n.reportFocus((void 0===r?!0:!1===document[r])&&n.windowVisible)};E();this.focusDetectorTimer=setInterval(E,100)}};m.prototype.stopFocusLoop=function(){this.focusDetectorTimer&&(clearTimeout(this.focusDetectorTimer),delete this.focusDetectorTimer)}},{"./base":3,underscore:24}],5:[function(f,m,J){var v=f("__browserify_process"),n=f("./frame"),r=f("./hand"),t=f("./pointable"),
K=f("./finger"),E=f("./circular_buffer"),U=f("./pipeline");J=f("events").EventEmitter;var M=f("./gesture").gestureListener,w=f("./dialog"),N=f("underscore"),R=m.exports=function(F){var A=this;F=N.defaults(F||{},{inNode:"undefined"!==typeof v&&v.versions&&v.versions.node});this.inNode=F.inNode;F=N.defaults(F||{},{frameEventName:this.useAnimationLoop()?"animationFrame":"deviceFrame",suppressAnimationLoop:!this.useAnimationLoop(),loopWhileDisconnected:!0,useAllPlugins:!1,checkVersion:!0});this.animationFrameRequested=
!1;this.onAnimationFrame=function(c){A.lastConnectionFrame.valid&&A.emit("animationFrame",A.lastConnectionFrame);A.emit("frameEnd",c);A.loopWhileDisconnected&&(!1!==A.connection.focusedState||A.connection.opts.background)?window.requestAnimationFrame(A.onAnimationFrame):A.animationFrameRequested=!1};this.suppressAnimationLoop=F.suppressAnimationLoop;this.loopWhileDisconnected=F.loopWhileDisconnected;this.frameEventName=F.frameEventName;this.useAllPlugins=F.useAllPlugins;this.history=new E(200);this.lastConnectionFrame=
this.lastValidFrame=this.lastFrame=n.Invalid;this.accumulatedGestures=[];this.checkVersion=F.checkVersion;this.connectionType=void 0===F.connectionType?this.inBrowser()?f("./connection/browser"):f("./connection/node"):F.connectionType;this.connection=new this.connectionType(F);this.streamingCount=0;this.devices={};this.plugins={};this._pluginPipelineSteps={};this._pluginExtendedMethods={};F.useAllPlugins&&this.useRegisteredPlugins();this.setupFrameEvents(F);this.setupConnectionEvents();this.startAnimationLoop()};
R.prototype.gesture=function(F,A){F=M(this,F);void 0!==A&&F.stop(A);return F};R.prototype.setBackground=function(F){this.connection.setBackground(F);return this};R.prototype.setOptimizeHMD=function(F){this.connection.setOptimizeHMD(F);return this};R.prototype.inBrowser=function(){return!this.inNode};R.prototype.useAnimationLoop=function(){return this.inBrowser()&&!this.inBackgroundPage()};R.prototype.inBackgroundPage=function(){return"undefined"!==typeof chrome&&chrome.extension&&chrome.extension.getBackgroundPage&&
chrome.extension.getBackgroundPage()===window};R.prototype.connect=function(){this.connection.connect();return this};R.prototype.streaming=function(){return 0<this.streamingCount};R.prototype.connected=function(){return!!this.connection.connected};R.prototype.startAnimationLoop=function(){this.suppressAnimationLoop||this.animationFrameRequested||(this.animationFrameRequested=!0,window.requestAnimationFrame(this.onAnimationFrame))};R.prototype.disconnect=function(){this.connection.disconnect();return this};
R.prototype.frame=function(F){return this.history.get(F)||n.Invalid};R.prototype.loop=function(F){if(F)if("function"===typeof F)this.on(this.frameEventName,F);else this.setupFrameEvents(F);return this.connect()};R.prototype.addStep=function(F){this.pipeline||(this.pipeline=new U(this));this.pipeline.addStep(F)};R.prototype.processFrame=function(F){F.gestures&&(this.accumulatedGestures=this.accumulatedGestures.concat(F.gestures));this.lastConnectionFrame=F;this.startAnimationLoop();this.emit("deviceFrame",
F)};R.prototype.processFinishedFrame=function(F){this.lastFrame=F;F.valid&&(this.lastValidFrame=F);F.controller=this;F.historyIdx=this.history.push(F);if(F.gestures){F.gestures=this.accumulatedGestures;this.accumulatedGestures=[];for(var A=0;A!=F.gestures.length;A++)this.emit("gesture",F.gestures[A],F)}this.pipeline&&(F=this.pipeline.run(F),F||(F=n.Invalid));this.emit("frame",F);this.emitHandEvents(F)};R.prototype.emitHandEvents=function(F){for(var A=0;A<F.hands.length;A++)this.emit("hand",F.hands[A])};
R.prototype.setupFrameEvents=function(F){if(F.frame)this.on("frame",F.frame);if(F.hand)this.on("hand",F.hand)};R.prototype.setupConnectionEvents=function(){var F=this;this.connection.on("frame",function(a){F.processFrame(a)});this.on(this.frameEventName,function(a){F.processFinishedFrame(a)});var A=function(){if(5>F.connection.opts.requestProtocolVersion&&0==F.streamingCount){F.streamingCount=1;var a={attached:!0,streaming:!0,type:"unknown",id:"Lx00000000000"};F.devices[a.id]=a;F.emit("deviceAttached",
a);F.emit("deviceStreaming",a);F.emit("streamingStarted",a);F.connection.removeListener("frame",A)}},c=function(){if(0<F.streamingCount){for(var a in F.devices)F.emit("deviceStopped",F.devices[a]),F.emit("deviceRemoved",F.devices[a]);F.emit("streamingStopped",F.devices[a]);F.streamingCount=0;for(a in F.devices)delete F.devices[a]}};this.connection.on("focus",function(){F.loopWhileDisconnected&&F.startAnimationLoop();F.emit("focus")});this.connection.on("blur",function(){F.emit("blur")});this.connection.on("protocol",
function(a){a.on("beforeFrameCreated",function(b){F.emit("beforeFrameCreated",b)});a.on("afterFrameCreated",function(b,d){F.emit("afterFrameCreated",b,d)});F.emit("protocol",a)});this.connection.on("ready",function(){F.checkVersion&&!F.inNode&&F.checkOutOfDate();F.emit("ready")});this.connection.on("connect",function(){F.emit("connect");F.connection.removeListener("frame",A);F.connection.on("frame",A)});this.connection.on("disconnect",function(){F.emit("disconnect");c()});this.connection.on("deviceConnect",
function(a){a.state?(F.emit("deviceConnected"),F.connection.removeListener("frame",A),F.connection.on("frame",A)):(F.emit("deviceDisconnected"),c())});this.connection.on("deviceEvent",function(a){a=a.state;var b=F.devices[a.id],d={},e;for(e in a)b&&b.hasOwnProperty(e)&&b[e]==a[e]||(d[e]=!0);F.devices[a.id]=a;d.attached&&F.emit(a.attached?"deviceAttached":"deviceRemoved",a);d.streaming&&(a.streaming?(F.streamingCount++,F.emit("deviceStreaming",a),1==F.streamingCount&&F.emit("streamingStarted",a),d.attached||
F.emit("deviceConnected")):d.attached&&a.attached||(F.streamingCount--,F.emit("deviceStopped",a),0==F.streamingCount&&F.emit("streamingStopped",a),F.emit("deviceDisconnected")))});this.on("newListener",function(a,b){"deviceConnected"!=a&&"deviceDisconnected"!=a||console.warn(a+" events are depricated. Consider using 'streamingStarted/streamingStopped' or 'deviceStreaming/deviceStopped' instead")})};R.prototype.checkOutOfDate=function(){console.assert(this.connection&&this.connection.protocol);var F=
this.connection.protocol.serviceVersion,A=this.connection.protocol.version,c=this.connectionType.defaultProtocolVersion;return c>A?(console.warn("Your Protocol Version is v"+A+", this app was designed for v"+c),w.warnOutOfDate({sV:F,pV:A}),!0):!1};R._pluginFactories={};R.plugin=function(F,A){this._pluginFactories[F]&&console.warn('Plugin "'+F+'" already registered');return this._pluginFactories[F]=A};R.plugins=function(){return N.keys(this._pluginFactories)};R.prototype.use=function(F,A){var c;var a=
"function"==typeof F?F:R._pluginFactories[F];if(!a)throw"Leap Plugin "+F+" not found.";A||(A={});if(this.plugins[F])return N.extend(this.plugins[F],A),this;this.plugins[F]=A;A=a.call(this,A);for(c in A)if(a=A[c],"function"===typeof a){var b=F,d=c;if(-1!==["beforeFrameCreated","afterFrameCreated"].indexOf(d))this.on(d,a);else this.pipeline||(this.pipeline=new U(this)),this._pluginPipelineSteps[b]||(this._pluginPipelineSteps[b]=[]),this._pluginPipelineSteps[b].push(this.pipeline.addWrappedStep(d,a))}else{b=
F;d=c;this._pluginExtendedMethods[b]||(this._pluginExtendedMethods[b]=[]);switch(d){case "frame":d=n;break;case "hand":d=r;break;case "pointable":d=t;N.extend(K.prototype,a);N.extend(K.Invalid,a);break;case "finger":d=K;break;default:throw b+' specifies invalid object type "'+d+'" for prototypical extension';}N.extend(d.prototype,a);N.extend(d.Invalid,a);this._pluginExtendedMethods[b].push([d,a])}return this};R.prototype.stopUsing=function(F){var A=this._pluginPipelineSteps[F],c=this._pluginExtendedMethods[F],
a;if(this.plugins[F]){if(A)for(a=0;a<A.length;a++)this.pipeline.removeStep(A[a]);if(c)for(a=0;a<c.length;a++){A=c[a][0];var b=c[a][1];for(var d in b)delete A.prototype[d],delete A.Invalid[d]}delete this.plugins[F];return this}};R.prototype.useRegisteredPlugins=function(){for(var F in R._pluginFactories)this.use(F)};N.extend(R.prototype,J.prototype)},{"./circular_buffer":2,"./connection/browser":4,"./connection/node":20,"./dialog":6,"./finger":7,"./frame":8,"./gesture":9,"./hand":10,"./pipeline":13,
"./pointable":14,__browserify_process:22,events:21,underscore:24}],6:[function(f,m,J){var v=f("__browserify_process"),n=m.exports=function(r,t){this.options=t||{};this.message=r;this.createElement()};n.prototype.createElement=function(){this.element=document.createElement("div");this.element.className="leapjs-dialog";this.element.style.position="fixed";this.element.style.top="8px";this.element.style.left=0;this.element.style.right=0;this.element.style.textAlign="center";this.element.style.zIndex=
1E3;var r=document.createElement("div");this.element.appendChild(r);r.style.className="leapjs-dialog";r.style.display="inline-block";r.style.margin="auto";r.style.padding="8px";r.style.color="#222";r.style.background="#eee";r.style.borderRadius="4px";r.style.border="1px solid #999";r.style.textAlign="left";r.style.cursor="pointer";r.style.whiteSpace="nowrap";r.style.transition="box-shadow 1s linear";r.innerHTML=this.message;this.options.onclick&&r.addEventListener("click",this.options.onclick);this.options.onmouseover&&
r.addEventListener("mouseover",this.options.onmouseover);this.options.onmouseout&&r.addEventListener("mouseout",this.options.onmouseout);this.options.onmousemove&&r.addEventListener("mousemove",this.options.onmousemove)};n.prototype.show=function(){document.body.appendChild(this.element);return this};n.prototype.hide=function(){document.body.removeChild(this.element);return this};n.warnOutOfDate=function(r){r||(r={});var t="http://developer.leapmotion.com?";r.returnTo=window.location.href;for(var K in r)t+=
K+"="+encodeURIComponent(r[K])+"&";var E=new n("This site requires Leap Motion Tracking V2.<button id='leapjs-accept-upgrade' style='color: #444; transition: box-shadow 100ms linear; cursor: pointer; vertical-align: baseline; margin-left: 16px;'>Upgrade</button><button id='leapjs-decline-upgrade' style='color: #444; transition: box-shadow 100ms linear; cursor: pointer; vertical-align: baseline; margin-left: 8px; '>Not Now</button>",{onclick:function(U){"leapjs-decline-upgrade"!=U.target.id&&(U=window.open(t,
"_blank","height=800,width=1000,location=1,menubar=1,resizable=1,status=1,toolbar=1,scrollbars=1"),window.focus&&U.focus());E.hide();return!0},onmousemove:function(U){U.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 E.show()};n.hasWarnedBones=!1;n.warnBones=function(){this.hasWarnedBones||(this.hasWarnedBones=!0,console.warn("Your Leap Service is out of date"),"undefined"!==typeof v&&v.versions&&v.versions.node||this.warnOutOfDate({reason:"bones"}))}},{__browserify_process:22}],7:[function(f,m,J){var v=f("./pointable"),n=f("./bone"),r=f("./dialog");f=f("underscore");m=m.exports=function(t){v.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):r.warnBones()};f.extend(m.prototype,v.prototype);m.prototype.addBones=function(t){this.metacarpal=new n(this,{type:0,width:this.width,prevJoint:this.carpPosition,nextJoint:this.mcpPosition,basis:t.bases[0]});
this.proximal=new n(this,{type:1,width:this.width,prevJoint:this.mcpPosition,nextJoint:this.pipPosition,basis:t.bases[1]});this.medial=new n(this,{type:2,width:this.width,prevJoint:this.pipPosition,nextJoint:this.dipPosition,basis:t.bases[2]});this.distal=new n(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]};m.prototype.toString=function(){return"Finger [ id:"+this.id+" "+this.length+
"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"};m.Invalid={valid:!1}},{"./bone":1,"./dialog":6,"./pointable":14,underscore:24}],8:[function(f,m,J){var v=f("./hand"),n=f("./pointable"),r=f("./gesture").createGesture;J=f("gl-matrix");var t=J.mat3,K=J.vec3,E=f("./interaction_box"),U=f("./finger"),M=f("underscore");f=m.exports=function(w){this.valid=!0;this.id=w.id;this.timestamp=w.timestamp;this.hands=[];this.handsMap={};this.pointables=[];this.tools=[];this.fingers=[];w.interactionBox&&
(this.interactionBox=new E(w.interactionBox));this.gestures=[];this.pointablesMap={};this._translation=w.t;this._rotation=M.flatten(w.r);this._scaleFactor=w.s;this.data=w;this.type="frame";this.currentFrameRate=w.currentFrameRate;if(w.gestures)for(var N=0,R=w.gestures.length;N!=R;N++)this.gestures.push(r(w.gestures[N]));this.postprocessData(w)};f.prototype.postprocessData=function(w){w||(w=this.data);for(var N=0,R=w.hands.length;N!=R;N++){var F=new v(w.hands[N]);F.frame=this;this.hands.push(F);this.handsMap[F.id]=
F}w.pointables=M.sortBy(w.pointables,function(A){return A.id});N=0;for(R=w.pointables.length;N!=R;N++)F=w.pointables[N],F=F.dipPosition?new U(F):new n(F),F.frame=this,this.addPointable(F)};f.prototype.addPointable=function(w){this.pointables.push(w);this.pointablesMap[w.id]=w;(w.tool?this.tools:this.fingers).push(w);if(void 0!==w.handId&&this.handsMap.hasOwnProperty(w.handId)){var N=this.handsMap[w.handId];N.pointables.push(w);(w.tool?N.tools:N.fingers).push(w);switch(w.type){case 0:N.thumb=w;break;
case 1:N.indexFinger=w;break;case 2:N.middleFinger=w;break;case 3:N.ringFinger=w;break;case 4:N.pinky=w}}};f.prototype.tool=function(w){w=this.pointable(w);return w.tool?w:n.Invalid};f.prototype.pointable=function(w){return this.pointablesMap[w]||n.Invalid};f.prototype.finger=function(w){w=this.pointable(w);return w.tool?n.Invalid:w};f.prototype.hand=function(w){return this.handsMap[w]||v.Invalid};f.prototype.rotationAngle=function(w,N){if(!this.valid||!w.valid)return 0;var R=this.rotationMatrix(w);
R=Math.acos(.5*(R[0]+R[4]+R[8]-1));R=isNaN(R)?0:R;void 0!==N&&(w=this.rotationAxis(w),R*=K.dot(w,K.normalize(K.create(),N)));return R};f.prototype.rotationAxis=function(w){return this.valid&&w.valid?K.normalize(K.create(),[this._rotation[7]-w._rotation[5],this._rotation[2]-w._rotation[6],this._rotation[3]-w._rotation[1]]):K.create()};f.prototype.rotationMatrix=function(w){if(!this.valid||!w.valid)return t.create();var N=t.transpose(t.create(),this._rotation);return t.multiply(t.create(),w._rotation,
N)};f.prototype.scaleFactor=function(w){return this.valid&&w.valid?Math.exp(this._scaleFactor-w._scaleFactor):1};f.prototype.translation=function(w){return this.valid&&w.valid?K.subtract(K.create(),this._translation,w._translation):K.create()};f.prototype.toString=function(){var w="Frame [ id:"+this.id+" | timestamp:"+this.timestamp+" | Hand count:("+this.hands.length+") | Pointable count:("+this.pointables.length+")";this.gestures&&(w+=" | Gesture count:("+this.gestures.length+")");return w+" ]"};
f.prototype.dump=function(){var w="Frame Info:<br/>"+this.toString();w+="<br/><br/>Hands:<br/>";for(var N=0,R=this.hands.length;N!=R;N++)w+=" "+this.hands[N].toString()+"<br/>";w+="<br/><br/>Pointables:<br/>";N=0;for(R=this.pointables.length;N!=R;N++)w+=" "+this.pointables[N].toString()+"<br/>";if(this.gestures)for(w+="<br/><br/>Gestures:<br/>",N=0,R=this.gestures.length;N!=R;N++)w+=" "+this.gestures[N].toString()+"<br/>";return w=w+"<br/><br/>Raw JSON:<br/>"+JSON.stringify(this.data)};f.Invalid=
{valid:!1,hands:[],fingers:[],tools:[],gestures:[],pointables:[],pointable:function(){return n.Invalid},finger:function(){return n.Invalid},hand:function(){return v.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return t.create()},rotationAxis:function(){return K.create()},scaleFactor:function(){return 1},translation:function(){return K.create()}}},{"./finger":7,"./gesture":9,"./hand":10,"./interaction_box":12,
"./pointable":14,"gl-matrix":23,underscore:24}],9:[function(f,m,J){var v=f("gl-matrix").vec3;m=f("events").EventEmitter;var n=f("underscore");J.createGesture=function(M){switch(M.type){case "circle":var w=new t(M);break;case "swipe":w=new K(M);break;case "screenTap":w=new E(M);break;case "keyTap":w=new U(M);break;default:throw"unknown gesture type";}w.id=M.id;w.handIds=M.handIds.slice();w.pointableIds=M.pointableIds.slice();w.duration=M.duration;w.state=M.state;w.type=M.type;return w};J.gestureListener=
function(M,w){var N={},R={};M.on("gesture",function(A,c){if(A.type==w){if(("start"==A.state||"stop"==A.state)&&void 0===R[A.id]){var a=new r(A,c);R[A.id]=a;n.each(N,function(b,d){a.on(d,b)})}R[A.id].update(A,c);"stop"==A.state&&delete R[A.id]}});var F={start:function(A){N.start=A;return F},stop:function(A){N.stop=A;return F},complete:function(A){N.stop=A;return F},update:function(A){N.update=A;return F}};return F};var r=J.Gesture=function(M,w){this.gestures=[M];this.frames=[w]};r.prototype.update=
function(M,w){this.lastGesture=M;this.lastFrame=w;this.gestures.push(M);this.frames.push(w);this.emit(M.state,this)};r.prototype.translation=function(){return v.subtract(v.create(),this.lastGesture.startPosition,this.lastGesture.position)};n.extend(r.prototype,m.prototype);var t=function(M){this.center=M.center;this.normal=M.normal;this.progress=M.progress;this.radius=M.radius};t.prototype.toString=function(){return"CircleGesture ["+JSON.stringify(this)+"]"};var K=function(M){this.startPosition=M.startPosition;
this.position=M.position;this.direction=M.direction;this.speed=M.speed};K.prototype.toString=function(){return"SwipeGesture ["+JSON.stringify(this)+"]"};var E=function(M){this.position=M.position;this.direction=M.direction;this.progress=M.progress};E.prototype.toString=function(){return"ScreenTapGesture ["+JSON.stringify(this)+"]"};var U=function(M){this.position=M.position;this.direction=M.direction;this.progress=M.progress};U.prototype.toString=function(){return"KeyTapGesture ["+JSON.stringify(this)+
"]"}},{events:21,"gl-matrix":23,underscore:24}],10:[function(f,m,J){var v=f("./pointable"),n=f("./bone");J=f("gl-matrix");var r=J.mat3,t=J.vec3,K=f("underscore");f=m.exports=function(E){this.id=E.id;this.palmPosition=E.palmPosition;this.direction=E.direction;this.palmVelocity=E.palmVelocity;this.palmNormal=E.palmNormal;this.sphereCenter=E.sphereCenter;this.sphereRadius=E.sphereRadius;this.valid=!0;this.pointables=[];this.fingers=[];this.arm=E.armBasis?new n(this,{type:4,width:E.armWidth,prevJoint:E.elbow,
nextJoint:E.wrist,basis:E.armBasis}):null;this.tools=[];this._translation=E.t;this._rotation=K.flatten(E.r);this._scaleFactor=E.s;this.timeVisible=E.timeVisible;this.stabilizedPalmPosition=E.stabilizedPalmPosition;this.type=E.type;this.grabStrength=E.grabStrength;this.pinchStrength=E.pinchStrength;this.confidence=E.confidence};f.prototype.finger=function(E){return(E=this.frame.finger(E))&&E.handId==this.id?E:v.Invalid};f.prototype.rotationAngle=function(E,U){if(!this.valid||!E.valid||!E.hand(this.id).valid)return 0;
var M=this.rotationMatrix(E);M=Math.acos(.5*(M[0]+M[4]+M[8]-1));M=isNaN(M)?0:M;void 0!==U&&(E=this.rotationAxis(E),M*=t.dot(E,t.normalize(t.create(),U)));return M};f.prototype.rotationAxis=function(E){if(!this.valid||!E.valid)return t.create();E=E.hand(this.id);return E.valid?t.normalize(t.create(),[this._rotation[7]-E._rotation[5],this._rotation[2]-E._rotation[6],this._rotation[3]-E._rotation[1]]):t.create()};f.prototype.rotationMatrix=function(E){if(!this.valid||!E.valid)return r.create();E=E.hand(this.id);
if(!E.valid)return r.create();var U=r.transpose(r.create(),this._rotation);return r.multiply(r.create(),E._rotation,U)};f.prototype.scaleFactor=function(E){if(!this.valid||!E.valid)return 1;E=E.hand(this.id);return E.valid?Math.exp(this._scaleFactor-E._scaleFactor):1};f.prototype.translation=function(E){if(!this.valid||!E.valid)return t.create();E=E.hand(this.id);return E.valid?[this._translation[0]-E._translation[0],this._translation[1]-E._translation[1],this._translation[2]-E._translation[2]]:t.create()};
f.prototype.toString=function(){return"Hand ("+this.type+") [ id: "+this.id+" | palm velocity:"+this.palmVelocity+" | sphere center:"+this.sphereCenter+" ] "};f.prototype.pitch=function(){return Math.atan2(this.direction[1],-this.direction[2])};f.prototype.yaw=function(){return Math.atan2(this.direction[0],-this.direction[2])};f.prototype.roll=function(){return Math.atan2(this.palmNormal[0],-this.palmNormal[1])};f.Invalid={valid:!1,fingers:[],tools:[],pointables:[],left:!1,pointable:function(){return v.Invalid},
finger:function(){return v.Invalid},toString:function(){return"invalid frame"},dump:function(){return this.toString()},rotationAngle:function(){return 0},rotationMatrix:function(){return r.create()},rotationAxis:function(){return t.create()},scaleFactor:function(){return 1},translation:function(){return t.create()}}},{"./bone":1,"./pointable":14,"gl-matrix":23,underscore:24}],11:[function(f,m,J){m.exports={Controller:f("./controller"),Frame:f("./frame"),Gesture:f("./gesture"),Hand:f("./hand"),Pointable:f("./pointable"),
Finger:f("./finger"),InteractionBox:f("./interaction_box"),CircularBuffer:f("./circular_buffer"),UI:f("./ui"),JSONProtocol:f("./protocol").JSONProtocol,glMatrix:f("gl-matrix"),mat3:f("gl-matrix").mat3,vec3:f("gl-matrix").vec3,loopController:void 0,version:f("./version.js"),_:f("underscore"),EventEmitter:f("events").EventEmitter,loop:function(v,n){v&&void 0===n&&"[object Function]"==={}.toString.call(v)&&(n=v,v={});this.loopController?v&&this.loopController.setupFrameEvents(v):this.loopController=
new this.Controller(v);this.loopController.loop(n);return this.loopController},plugin:function(v,n){this.Controller.plugin(v,n)}}},{"./circular_buffer":2,"./controller":5,"./finger":7,"./frame":8,"./gesture":9,"./hand":10,"./interaction_box":12,"./pointable":14,"./protocol":15,"./ui":16,"./version.js":19,events:21,"gl-matrix":23,underscore:24}],12:[function(f,m,J){var v=f("gl-matrix").vec3;f=m.exports=function(n){this.valid=!0;this.center=n.center;this.size=n.size;this.width=n.size[0];this.height=
n.size[1];this.depth=n.size[2]};f.prototype.denormalizePoint=function(n){return v.fromValues((n[0]-.5)*this.size[0]+this.center[0],(n[1]-.5)*this.size[1]+this.center[1],(n[2]-.5)*this.size[2]+this.center[2])};f.prototype.normalizePoint=function(n,r){n=v.fromValues((n[0]-this.center[0])/this.size[0]+.5,(n[1]-this.center[1])/this.size[1]+.5,(n[2]-this.center[2])/this.size[2]+.5);r&&(n[0]=Math.min(Math.max(n[0],0),1),n[1]=Math.min(Math.max(n[1],0),1),n[2]=Math.min(Math.max(n[2],0),1));return n};f.prototype.toString=
function(){return"InteractionBox [ width:"+this.width+" | height:"+this.height+" | depth:"+this.depth+" ]"};f.Invalid={valid:!1}},{"gl-matrix":23}],13:[function(f,m,J){f=m.exports=function(v){this.steps=[];this.controller=v};f.prototype.addStep=function(v){this.steps.push(v)};f.prototype.run=function(v){for(var n=this.steps.length,r=0;r!=n&&v;r++)v=this.steps[r](v);return v};f.prototype.removeStep=function(v){v=this.steps.indexOf(v);if(-1===v)throw"Step not found in pipeline";this.steps.splice(v,
1)};f.prototype.addWrappedStep=function(v,n){var r=this.controller,t=function(K){var E;var U="frame"==v?[K]:K[v+"s"]||[];var M=0;for(E=U.length;M<E;M++)n.call(r,U[M]);return K};this.addStep(t);return t}},{}],14:[function(f,m,J){f("gl-matrix");f=m.exports=function(v){this.valid=!0;this.id=v.id;this.handId=v.handId;this.length=v.length;this.tool=v.tool;this.width=v.width;this.direction=v.direction;this.stabilizedTipPosition=v.stabilizedTipPosition;this.tipPosition=v.tipPosition;this.tipVelocity=v.tipVelocity;
this.touchZone=v.touchZone;this.touchDistance=v.touchDistance;this.timeVisible=v.timeVisible};f.prototype.toString=function(){return"Pointable [ id:"+this.id+" "+this.length+"mmx | width:"+this.width+"mm | direction:"+this.direction+" ]"};f.prototype.hand=function(){return this.frame.hand(this.handId)};f.Invalid={valid:!1}},{"gl-matrix":23}],15:[function(f,m,J){var v=f("./frame");f("./hand");f("./pointable");f("./finger");var n=f("underscore"),r=f("events").EventEmitter,t=function(E){this.type=E.type;
this.state=E.state};J.chooseProtocol=function(E){switch(E.version){case 1:case 2:case 3:case 4:case 5:case 6:var U=K(E);U.sendBackground=function(M,w){M.send(U.encode({background:w}))};U.sendFocused=function(M,w){M.send(U.encode({focused:w}))};U.sendOptimizeHMD=function(M,w){M.send(U.encode({optimizeHMD:w}))};break;default:throw"unrecognized version";}return U};var K=J.JSONProtocol=function(E){var U=function(M){if(M.event)return new t(M.event);U.emit("beforeFrameCreated",M);var w=new v(M);U.emit("afterFrameCreated",
w,M);return w};U.encode=function(M){return JSON.stringify(M)};U.version=E.version;U.serviceVersion=E.serviceVersion;U.versionLong="Version "+E.version;U.type="protocol";n.extend(U,r.prototype);return U}},{"./finger":7,"./frame":8,"./hand":10,"./pointable":14,events:21,underscore:24}],16:[function(f,m,J){J.UI={Region:f("./ui/region"),Cursor:f("./ui/cursor")}},{"./ui/cursor":17,"./ui/region":18}],17:[function(f,m,J){m.exports=function(){return function(v){var n=v.pointables.sort(function(r,t){return r.z-
t.z})[0];n&&n.valid&&(v.cursorPosition=n.tipPosition);return v}}},{}],18:[function(f,m,J){J=f("events").EventEmitter;f=f("underscore");var v=m.exports=function(n,r){this.start=new Vector(n);this.end=new Vector(r);this.enteredFrame=null};v.prototype.hasPointables=function(n){for(var r=0;r!=n.pointables.length;r++){var t=n.pointables[r].tipPosition;if(t.x>=this.start.x&&t.x<=this.end.x&&t.y>=this.start.y&&t.y<=this.end.y&&t.z>=this.start.z&&t.z<=this.end.z)return!0}return!1};v.prototype.listener=function(n){var r=
this;n&&n.nearThreshold&&this.setupNearRegion(n.nearThreshold);return function(t){return r.updatePosition(t)}};v.prototype.clipper=function(){var n=this;return function(r){n.updatePosition(r);return n.enteredFrame?r:null}};v.prototype.setupNearRegion=function(n){n=this.nearRegion=new v([this.start.x-n,this.start.y-n,this.start.z-n],[this.end.x+n,this.end.y+n,this.end.z+n]);var r=this;n.on("enter",function(t){r.emit("near",t)});n.on("exit",function(t){r.emit("far",t)});r.on("exit",function(t){r.emit("near",
t)})};v.prototype.updatePosition=function(n){this.nearRegion&&this.nearRegion.updatePosition(n);this.hasPointables(n)&&null==this.enteredFrame?(this.enteredFrame=n,this.emit("enter",this.enteredFrame)):this.hasPointables(n)||null==this.enteredFrame||(this.enteredFrame=null,this.emit("exit",this.enteredFrame));return n};v.prototype.normalize=function(n){return new Vector([(n.x-this.start.x)/(this.end.x-this.start.x),(n.y-this.start.y)/(this.end.y-this.start.y),(n.z-this.start.z)/(this.end.z-this.start.z)])};
v.prototype.mapToXY=function(n,r,t){n=this.normalize(n);var K=n.x,E=n.y;1<K?K=1:-1>K&&(K=-1);1<E?E=1:-1>E&&(E=-1);return[(K+1)/2*r,(1-E)/2*t,n.z]};f.extend(v.prototype,J.prototype)},{events:21,underscore:24}],19:[function(f,m,J){m.exports={full:"0.6.4",major:0,minor:6,dot:4}},{}],20:[function(f,m,J){},{}],21:[function(f,m,J){f=f("__browserify_process");f.EventEmitter||(f.EventEmitter=function(){});J=J.EventEmitter=f.EventEmitter;var v="function"===typeof Array.isArray?Array.isArray:function(n){return"[object Array]"===
Object.prototype.toString.call(n)};J.prototype.setMaxListeners=function(n){this._events||(this._events={});this._events.maxListeners=n};J.prototype.emit=function(n){if("error"===n&&(!this._events||!this._events.error||v(this._events.error)&&!this._events.error.length)){if(arguments[1]instanceof Error)throw arguments[1];throw Error("Uncaught, unspecified 'error' event.");}if(!this._events)return!1;var r=this._events[n];if(!r)return!1;if("function"==typeof r){switch(arguments.length){case 1:r.call(this);
break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:var t=Array.prototype.slice.call(arguments,1);r.apply(this,t)}return!0}if(v(r)){t=Array.prototype.slice.call(arguments,1);r=r.slice();for(var K=0,E=r.length;K<E;K++)r[K].apply(this,t);return!0}return!1};J.prototype.addListener=function(n,r){if("function"!==typeof r)throw Error("addListener only takes instances of Function");this._events||(this._events={});this.emit("newListener",n,r);if(this._events[n])if(v(this._events[n])){if(!this._events[n].warned){var t;
(t=void 0!==this._events.maxListeners?this._events.maxListeners:10)&&0<t&&this._events[n].length>t&&(this._events[n].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[n].length),console.trace())}this._events[n].push(r)}else this._events[n]=[this._events[n],r];else this._events[n]=r;return this};J.prototype.on=J.prototype.addListener;J.prototype.once=function(n,r){var t=this;t.on(n,
function E(){t.removeListener(n,E);r.apply(this,arguments)});return this};J.prototype.removeListener=function(n,r){if("function"!==typeof r)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[n])return this;var t=this._events[n];if(v(t)){a:if(t.indexOf)r=t.indexOf(r);else{for(var K=0;K<t.length;K++)if(r===t[K]){r=K;break a}r=-1}if(0>r)return this;t.splice(r,1);0==t.length&&delete this._events[n]}else this._events[n]===r&&delete this._events[n];return this};
J.prototype.removeAllListeners=function(n){if(0===arguments.length)return this._events={},this;n&&this._events&&this._events[n]&&(this._events[n]=null);return this};J.prototype.listeners=function(n){this._events||(this._events={});this._events[n]||(this._events[n]=[]);v(this._events[n])||(this._events[n]=[this._events[n]]);return this._events[n]};J.listenerCount=function(n,r){return n._events&&n._events[r]?"function"===typeof n._events[r]?1:n._events[r].length:0}},{__browserify_process:22}],22:[function(f,
m,J){f=m.exports={};f.nextTick=function(){if("undefined"!==typeof window&&window.setImmediate)return function(n){return window.setImmediate(n)};if("undefined"!==typeof window&&window.postMessage&&window.addEventListener){var v=[];window.addEventListener("message",function(n){var r=n.source;r!==window&&null!==r||"process-tick"!==n.data||(n.stopPropagation(),0<v.length&&v.shift()())},!0);return function(n){v.push(n);window.postMessage("process-tick","*")}}return function(n){setTimeout(n,0)}}();f.title=
"browser";f.browser=!0;f.env={};f.argv=[];f.binding=function(v){throw Error("process.binding is not supported");};f.cwd=function(){return"/"};f.chdir=function(v){throw Error("process.chdir is not supported");}},{}],23:[function(f,m,J){(function(v){if("undefined"===typeof J)if("function"==typeof define&&"object"==typeof define.amd&&define.amd){var n={};define(function(){return n})}else n="undefined"!==typeof window?window:v;else n=J;(function(r){if(!t)var t=1E-6;if(!K)var K="undefined"!==typeof Float32Array?
Float32Array:Array;if(!E)var E=Math.random;var U={setMatrixArrayType:function(a){K=a}};"undefined"!==typeof r&&(r.glMatrix=U);var M=Math.PI/180;U.toRadian=function(a){return a*M};var w={create:function(){var a=new K(2);a[0]=0;a[1]=0;return a},clone:function(a){var b=new K(2);b[0]=a[0];b[1]=a[1];return b},fromValues:function(a,b){var d=new K(2);d[0]=a;d[1]=b;return d},copy:function(a,b){a[0]=b[0];a[1]=b[1];return a},set:function(a,b,d){a[0]=b;a[1]=d;return a},add:function(a,b,d){a[0]=b[0]+d[0];a[1]=
b[1]+d[1];return a},subtract:function(a,b,d){a[0]=b[0]-d[0];a[1]=b[1]-d[1];return a}};w.sub=w.subtract;w.multiply=function(a,b,d){a[0]=b[0]*d[0];a[1]=b[1]*d[1];return a};w.mul=w.multiply;w.divide=function(a,b,d){a[0]=b[0]/d[0];a[1]=b[1]/d[1];return a};w.div=w.divide;w.min=function(a,b,d){a[0]=Math.min(b[0],d[0]);a[1]=Math.min(b[1],d[1]);return a};w.max=function(a,b,d){a[0]=Math.max(b[0],d[0]);a[1]=Math.max(b[1],d[1]);return a};w.scale=function(a,b,d){a[0]=b[0]*d;a[1]=b[1]*d;return a};w.scaleAndAdd=
function(a,b,d,e){a[0]=b[0]+d[0]*e;a[1]=b[1]+d[1]*e;return a};w.distance=function(a,b){var d=b[0]-a[0];a=b[1]-a[1];return Math.sqrt(d*d+a*a)};w.dist=w.distance;w.squaredDistance=function(a,b){var d=b[0]-a[0];a=b[1]-a[1];return d*d+a*a};w.sqrDist=w.squaredDistance;w.length=function(a){var b=a[0];a=a[1];return Math.sqrt(b*b+a*a)};w.len=w.length;w.squaredLength=function(a){var b=a[0];a=a[1];return b*b+a*a};w.sqrLen=w.squaredLength;w.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];return a};w.normalize=function(a,
b){var d=b[0],e=b[1];d=d*d+e*e;0<d&&(d=1/Math.sqrt(d),a[0]=b[0]*d,a[1]=b[1]*d);return a};w.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]};w.cross=function(a,b,d){b=b[0]*d[1]-b[1]*d[0];a[0]=a[1]=0;a[2]=b;return a};w.lerp=function(a,b,d,e){var g=b[0];b=b[1];a[0]=g+e*(d[0]-g);a[1]=b+e*(d[1]-b);return a};w.random=function(a,b){b=b||1;var d=2*E()*Math.PI;a[0]=Math.cos(d)*b;a[1]=Math.sin(d)*b;return a};w.transformMat2=function(a,b,d){var e=b[0];b=b[1];a[0]=d[0]*e+d[2]*b;a[1]=d[1]*e+d[3]*b;return a};w.transformMat2d=
function(a,b,d){var e=b[0];b=b[1];a[0]=d[0]*e+d[2]*b+d[4];a[1]=d[1]*e+d[3]*b+d[5];return a};w.transformMat3=function(a,b,d){var e=b[0];b=b[1];a[0]=d[0]*e+d[3]*b+d[6];a[1]=d[1]*e+d[4]*b+d[7];return a};w.transformMat4=function(a,b,d){var e=b[0];b=b[1];a[0]=d[0]*e+d[4]*b+d[12];a[1]=d[1]*e+d[5]*b+d[13];return a};w.forEach=function(){var a=w.create();return function(b,d,e,g,l,u){d||(d=2);e||(e=0);for(g=g?Math.min(g*d+e,b.length):b.length;e<g;e+=d)a[0]=b[e],a[1]=b[e+1],l(a,a,u),b[e]=a[0],b[e+1]=a[1];return b}}();
w.str=function(a){return"vec2("+a[0]+", "+a[1]+")"};"undefined"!==typeof r&&(r.vec2=w);var N={create:function(){var a=new K(3);a[0]=0;a[1]=0;a[2]=0;return a},clone:function(a){var b=new K(3);b[0]=a[0];b[1]=a[1];b[2]=a[2];return b},fromValues:function(a,b,d){var e=new K(3);e[0]=a;e[1]=b;e[2]=d;return e},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a},set:function(a,b,d,e){a[0]=b;a[1]=d;a[2]=e;return a},add:function(a,b,d){a[0]=b[0]+d[0];a[1]=b[1]+d[1];a[2]=b[2]+d[2];return a},subtract:function(a,
b,d){a[0]=b[0]-d[0];a[1]=b[1]-d[1];a[2]=b[2]-d[2];return a}};N.sub=N.subtract;N.multiply=function(a,b,d){a[0]=b[0]*d[0];a[1]=b[1]*d[1];a[2]=b[2]*d[2];return a};N.mul=N.multiply;N.divide=function(a,b,d){a[0]=b[0]/d[0];a[1]=b[1]/d[1];a[2]=b[2]/d[2];return a};N.div=N.divide;N.min=function(a,b,d){a[0]=Math.min(b[0],d[0]);a[1]=Math.min(b[1],d[1]);a[2]=Math.min(b[2],d[2]);return a};N.max=function(a,b,d){a[0]=Math.max(b[0],d[0]);a[1]=Math.max(b[1],d[1]);a[2]=Math.max(b[2],d[2]);return a};N.scale=function(a,
b,d){a[0]=b[0]*d;a[1]=b[1]*d;a[2]=b[2]*d;return a};N.scaleAndAdd=function(a,b,d,e){a[0]=b[0]+d[0]*e;a[1]=b[1]+d[1]*e;a[2]=b[2]+d[2]*e;return a};N.distance=function(a,b){var d=b[0]-a[0],e=b[1]-a[1];a=b[2]-a[2];return Math.sqrt(d*d+e*e+a*a)};N.dist=N.distance;N.squaredDistance=function(a,b){var d=b[0]-a[0],e=b[1]-a[1];a=b[2]-a[2];return d*d+e*e+a*a};N.sqrDist=N.squaredDistance;N.length=function(a){var b=a[0],d=a[1];a=a[2];return Math.sqrt(b*b+d*d+a*a)};N.len=N.length;N.squaredLength=function(a){var b=
a[0],d=a[1];a=a[2];return b*b+d*d+a*a};N.sqrLen=N.squaredLength;N.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];return a};N.normalize=function(a,b){var d=b[0],e=b[1],g=b[2];d=d*d+e*e+g*g;0<d&&(d=1/Math.sqrt(d),a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d);return a};N.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]};N.cross=function(a,b,d){var e=b[0],g=b[1];b=b[2];var l=d[0],u=d[1];d=d[2];a[0]=g*d-b*u;a[1]=b*l-e*d;a[2]=e*u-g*l;return a};N.lerp=function(a,b,d,e){var g=b[0],l=b[1];b=b[2];a[0]=
g+e*(d[0]-g);a[1]=l+e*(d[1]-l);a[2]=b+e*(d[2]-b);return a};N.random=function(a,b){b=b||1;var d=2*E()*Math.PI,e=2*E()-1,g=Math.sqrt(1-e*e)*b;a[0]=Math.cos(d)*g;a[1]=Math.sin(d)*g;a[2]=e*b;return a};N.transformMat4=function(a,b,d){var e=b[0],g=b[1];b=b[2];a[0]=d[0]*e+d[4]*g+d[8]*b+d[12];a[1]=d[1]*e+d[5]*g+d[9]*b+d[13];a[2]=d[2]*e+d[6]*g+d[10]*b+d[14];return a};N.transformMat3=function(a,b,d){var e=b[0],g=b[1];b=b[2];a[0]=e*d[0]+g*d[3]+b*d[6];a[1]=e*d[1]+g*d[4]+b*d[7];a[2]=e*d[2]+g*d[5]+b*d[8];return a};
N.transformQuat=function(a,b,d){var e=b[0],g=b[1],l=b[2];b=d[0];var u=d[1],h=d[2];d=d[3];var C=d*e+u*l-h*g,H=d*g+h*e-b*l,L=d*l+b*g-u*e;e=-b*e-u*g-h*l;a[0]=C*d+e*-b+H*-h-L*-u;a[1]=H*d+e*-u+L*-b-C*-h;a[2]=L*d+e*-h+C*-u-H*-b;return a};N.rotateX=function(a,b,d,e){var g=[],l=[];g[0]=b[0]-d[0];g[1]=b[1]-d[1];g[2]=b[2]-d[2];l[0]=g[0];l[1]=g[1]*Math.cos(e)-g[2]*Math.sin(e);l[2]=g[1]*Math.sin(e)+g[2]*Math.cos(e);a[0]=l[0]+d[0];a[1]=l[1]+d[1];a[2]=l[2]+d[2];return a};N.rotateY=function(a,b,d,e){var g=[],l=
[];g[0]=b[0]-d[0];g[1]=b[1]-d[1];g[2]=b[2]-d[2];l[0]=g[2]*Math.sin(e)+g[0]*Math.cos(e);l[1]=g[1];l[2]=g[2]*Math.cos(e)-g[0]*Math.sin(e);a[0]=l[0]+d[0];a[1]=l[1]+d[1];a[2]=l[2]+d[2];return a};N.rotateZ=function(a,b,d,e){var g=[],l=[];g[0]=b[0]-d[0];g[1]=b[1]-d[1];g[2]=b[2]-d[2];l[0]=g[0]*Math.cos(e)-g[1]*Math.sin(e);l[1]=g[0]*Math.sin(e)+g[1]*Math.cos(e);l[2]=g[2];a[0]=l[0]+d[0];a[1]=l[1]+d[1];a[2]=l[2]+d[2];return a};N.forEach=function(){var a=N.create();return function(b,d,e,g,l,u){d||(d=3);e||(e=
0);for(g=g?Math.min(g*d+e,b.length):b.length;e<g;e+=d)a[0]=b[e],a[1]=b[e+1],a[2]=b[e+2],l(a,a,u),b[e]=a[0],b[e+1]=a[1],b[e+2]=a[2];return b}}();N.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"};"undefined"!==typeof r&&(r.vec3=N);var R={create:function(){var a=new K(4);a[0]=0;a[1]=0;a[2]=0;a[3]=0;return a},clone:function(a){var b=new K(4);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},fromValues:function(a,b,d,e){var g=new K(4);g[0]=a;g[1]=b;g[2]=d;g[3]=e;return g},copy:function(a,b){a[0]=
b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];return a},set:function(a,b,d,e,g){a[0]=b;a[1]=d;a[2]=e;a[3]=g;return a},add:function(a,b,d){a[0]=b[0]+d[0];a[1]=b[1]+d[1];a[2]=b[2]+d[2];a[3]=b[3]+d[3];return a},subtract:function(a,b,d){a[0]=b[0]-d[0];a[1]=b[1]-d[1];a[2]=b[2]-d[2];a[3]=b[3]-d[3];return a}};R.sub=R.subtract;R.multiply=function(a,b,d){a[0]=b[0]*d[0];a[1]=b[1]*d[1];a[2]=b[2]*d[2];a[3]=b[3]*d[3];return a};R.mul=R.multiply;R.divide=function(a,b,d){a[0]=b[0]/d[0];a[1]=b[1]/d[1];a[2]=b[2]/d[2];a[3]=b[3]/
d[3];return a};R.div=R.divide;R.min=function(a,b,d){a[0]=Math.min(b[0],d[0]);a[1]=Math.min(b[1],d[1]);a[2]=Math.min(b[2],d[2]);a[3]=Math.min(b[3],d[3]);return a};R.max=function(a,b,d){a[0]=Math.max(b[0],d[0]);a[1]=Math.max(b[1],d[1]);a[2]=Math.max(b[2],d[2]);a[3]=Math.max(b[3],d[3]);return a};R.scale=function(a,b,d){a[0]=b[0]*d;a[1]=b[1]*d;a[2]=b[2]*d;a[3]=b[3]*d;return a};R.scaleAndAdd=function(a,b,d,e){a[0]=b[0]+d[0]*e;a[1]=b[1]+d[1]*e;a[2]=b[2]+d[2]*e;a[3]=b[3]+d[3]*e;return a};R.distance=function(a,
b){var d=b[0]-a[0],e=b[1]-a[1],g=b[2]-a[2];a=b[3]-a[3];return Math.sqrt(d*d+e*e+g*g+a*a)};R.dist=R.distance;R.squaredDistance=function(a,b){var d=b[0]-a[0],e=b[1]-a[1],g=b[2]-a[2];a=b[3]-a[3];return d*d+e*e+g*g+a*a};R.sqrDist=R.squaredDistance;R.length=function(a){var b=a[0],d=a[1],e=a[2];a=a[3];return Math.sqrt(b*b+d*d+e*e+a*a)};R.len=R.length;R.squaredLength=function(a){var b=a[0],d=a[1],e=a[2];a=a[3];return b*b+d*d+e*e+a*a};R.sqrLen=R.squaredLength;R.negate=function(a,b){a[0]=-b[0];a[1]=-b[1];
a[2]=-b[2];a[3]=-b[3];return a};R.normalize=function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3];d=d*d+e*e+g*g+l*l;0<d&&(d=1/Math.sqrt(d),a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d);return a};R.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};R.lerp=function(a,b,d,e){var g=b[0],l=b[1],u=b[2];b=b[3];a[0]=g+e*(d[0]-g);a[1]=l+e*(d[1]-l);a[2]=u+e*(d[2]-u);a[3]=b+e*(d[3]-b);return a};R.random=function(a,b){b=b||1;a[0]=E();a[1]=E();a[2]=E();a[3]=E();R.normalize(a,a);R.scale(a,a,b);return a};
R.transformMat4=function(a,b,d){var e=b[0],g=b[1],l=b[2];b=b[3];a[0]=d[0]*e+d[4]*g+d[8]*l+d[12]*b;a[1]=d[1]*e+d[5]*g+d[9]*l+d[13]*b;a[2]=d[2]*e+d[6]*g+d[10]*l+d[14]*b;a[3]=d[3]*e+d[7]*g+d[11]*l+d[15]*b;return a};R.transformQuat=function(a,b,d){var e=b[0],g=b[1],l=b[2];b=d[0];var u=d[1],h=d[2];d=d[3];var C=d*e+u*l-h*g,H=d*g+h*e-b*l,L=d*l+b*g-u*e;e=-b*e-u*g-h*l;a[0]=C*d+e*-b+H*-h-L*-u;a[1]=H*d+e*-u+L*-b-C*-h;a[2]=L*d+e*-h+C*-u-H*-b;return a};R.forEach=function(){var a=R.create();return function(b,d,
e,g,l,u){d||(d=4);e||(e=0);for(g=g?Math.min(g*d+e,b.length):b.length;e<g;e+=d)a[0]=b[e],a[1]=b[e+1],a[2]=b[e+2],a[3]=b[e+3],l(a,a,u),b[e]=a[0],b[e+1]=a[1],b[e+2]=a[2],b[e+3]=a[3];return b}}();R.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};"undefined"!==typeof r&&(r.vec4=R);U={create:function(){var a=new K(4);a[0]=1;a[1]=0;a[2]=0;a[3]=1;return a},clone:function(a){var b=new K(4);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];return b},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];
a[3]=b[3];return a},identity:function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=1;return a},transpose:function(a,b){if(a===b){var d=b[1];a[1]=b[2];a[2]=d}else a[0]=b[0],a[1]=b[2],a[2]=b[1],a[3]=b[3];return a},invert:function(a,b){var d=b[0],e=b[1],g=b[2];b=b[3];var l=d*b-g*e;if(!l)return null;l=1/l;a[0]=b*l;a[1]=-e*l;a[2]=-g*l;a[3]=d*l;return a},adjoint:function(a,b){var d=b[0];a[0]=b[3];a[1]=-b[1];a[2]=-b[2];a[3]=d;return a},determinant:function(a){return a[0]*a[3]-a[2]*a[1]},multiply:function(a,b,d){var e=b[0],
g=b[1],l=b[2];b=b[3];var u=d[0],h=d[1],C=d[2];d=d[3];a[0]=e*u+l*h;a[1]=g*u+b*h;a[2]=e*C+l*d;a[3]=g*C+b*d;return a}};U.mul=U.multiply;U.rotate=function(a,b,d){var e=b[0],g=b[1],l=b[2];b=b[3];var u=Math.sin(d);d=Math.cos(d);a[0]=e*d+l*u;a[1]=g*d+b*u;a[2]=e*-u+l*d;a[3]=g*-u+b*d;return a};U.scale=function(a,b,d){var e=b[1],g=b[2],l=b[3],u=d[0];d=d[1];a[0]=b[0]*u;a[1]=e*u;a[2]=g*d;a[3]=l*d;return a};U.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};U.frob=function(a){return Math.sqrt(Math.pow(a[0],
2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2))};U.LDU=function(a,b,d,e){a[2]=e[2]/e[0];d[0]=e[0];d[1]=e[1];d[3]=e[3]-a[2]*d[1];return[a,b,d]};"undefined"!==typeof r&&(r.mat2=U);U={create:function(){var a=new K(6);a[0]=1;a[1]=0;a[2]=0;a[3]=1;a[4]=0;a[5]=0;return a},clone:function(a){var b=new K(6);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];return b},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];return a},identity:function(a){a[0]=1;a[1]=0;a[2]=
0;a[3]=1;a[4]=0;a[5]=0;return a},invert:function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3],u=b[4];b=b[5];var h=d*l-e*g;if(!h)return null;h=1/h;a[0]=l*h;a[1]=-e*h;a[2]=-g*h;a[3]=d*h;a[4]=(g*b-l*u)*h;a[5]=(e*u-d*b)*h;return a},determinant:function(a){return a[0]*a[3]-a[1]*a[2]},multiply:function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4];b=b[5];var C=d[0],H=d[1],L=d[2],P=d[3],S=d[4];d=d[5];a[0]=e*C+l*H;a[1]=g*C+u*H;a[2]=e*L+l*P;a[3]=g*L+u*P;a[4]=e*S+l*d+h;a[5]=g*S+u*d+b;return a}};U.mul=U.multiply;U.rotate=
function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4];b=b[5];var C=Math.sin(d);d=Math.cos(d);a[0]=e*d+l*C;a[1]=g*d+u*C;a[2]=e*-C+l*d;a[3]=g*-C+u*d;a[4]=h;a[5]=b;return a};U.scale=function(a,b,d){var e=b[1],g=b[2],l=b[3],u=b[4],h=b[5],C=d[0];d=d[1];a[0]=b[0]*C;a[1]=e*C;a[2]=g*d;a[3]=l*d;a[4]=u;a[5]=h;return a};U.translate=function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4];b=b[5];var C=d[0];d=d[1];a[0]=e;a[1]=g;a[2]=l;a[3]=u;a[4]=e*C+l*d+h;a[5]=g*C+u*d+b;return a};U.str=function(a){return"mat2d("+
a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"};U.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+1)};"undefined"!==typeof r&&(r.mat2d=U);var F={create:function(){var a=new K(9);a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a},fromMat4:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[4];a[4]=b[5];a[5]=b[6];a[6]=b[8];a[7]=b[9];a[8]=b[10];return a},clone:function(a){var b=new K(9);
b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return b},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];return a},identity:function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return a},transpose:function(a,b){if(a===b){var d=b[1],e=b[2],g=b[5];a[1]=b[3];a[2]=b[6];a[3]=d;a[5]=b[7];a[6]=e;a[7]=g}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=
b[5],a[8]=b[8];return a},invert:function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3],u=b[4],h=b[5],C=b[6],H=b[7];b=b[8];var L=b*u-h*H,P=-b*l+h*C,S=H*l-u*C,V=d*L+e*P+g*S;if(!V)return null;V=1/V;a[0]=L*V;a[1]=(-b*e+g*H)*V;a[2]=(h*e-g*u)*V;a[3]=P*V;a[4]=(b*d-g*C)*V;a[5]=(-h*d+g*l)*V;a[6]=S*V;a[7]=(-H*d+e*C)*V;a[8]=(u*d-e*l)*V;return a},adjoint:function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3],u=b[4],h=b[5],C=b[6],H=b[7];b=b[8];a[0]=u*b-h*H;a[1]=g*H-e*b;a[2]=e*h-g*u;a[3]=h*C-l*b;a[4]=d*b-g*C;a[5]=g*l-d*h;a[6]=l*
H-u*C;a[7]=e*C-d*H;a[8]=d*u-e*l;return a},determinant:function(a){var b=a[3],d=a[4],e=a[5],g=a[6],l=a[7],u=a[8];return a[0]*(u*d-e*l)+a[1]*(-u*b+e*g)+a[2]*(l*b-d*g)},multiply:function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4],C=b[5],H=b[6],L=b[7];b=b[8];var P=d[0],S=d[1],V=d[2],Z=d[3],Y=d[4],da=d[5],ia=d[6],ba=d[7];d=d[8];a[0]=P*e+S*u+V*H;a[1]=P*g+S*h+V*L;a[2]=P*l+S*C+V*b;a[3]=Z*e+Y*u+da*H;a[4]=Z*g+Y*h+da*L;a[5]=Z*l+Y*C+da*b;a[6]=ia*e+ba*u+d*H;a[7]=ia*g+ba*h+d*L;a[8]=ia*l+ba*C+d*b;return a}};
F.mul=F.multiply;F.translate=function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4],C=b[5],H=b[6],L=b[7];b=b[8];var P=d[0];d=d[1];a[0]=e;a[1]=g;a[2]=l;a[3]=u;a[4]=h;a[5]=C;a[6]=P*e+d*u+H;a[7]=P*g+d*h+L;a[8]=P*l+d*C+b;return a};F.rotate=function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4],C=b[5],H=b[6],L=b[7];b=b[8];var P=Math.sin(d);d=Math.cos(d);a[0]=d*e+P*u;a[1]=d*g+P*h;a[2]=d*l+P*C;a[3]=d*u-P*e;a[4]=d*h-P*g;a[5]=d*C-P*l;a[6]=H;a[7]=L;a[8]=b;return a};F.scale=function(a,b,d){var e=d[0];d=d[1];
a[0]=e*b[0];a[1]=e*b[1];a[2]=e*b[2];a[3]=d*b[3];a[4]=d*b[4];a[5]=d*b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];return a};F.fromMat2d=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=0;a[3]=b[2];a[4]=b[3];a[5]=0;a[6]=b[4];a[7]=b[5];a[8]=1;return a};F.fromQuat=function(a,b){var d=b[0],e=b[1],g=b[2];b=b[3];var l=d+d,u=e+e,h=g+g;d*=l;var C=e*l;e*=u;var H=g*l,L=g*u;g*=h;l*=b;u*=b;b*=h;a[0]=1-e-g;a[3]=C-b;a[6]=H+u;a[1]=C+b;a[4]=1-d-g;a[7]=L-l;a[2]=H-u;a[5]=L+l;a[8]=1-d-e;return a};F.normalFromMat4=function(a,b){var d=b[0],
e=b[1],g=b[2],l=b[3],u=b[4],h=b[5],C=b[6],H=b[7],L=b[8],P=b[9],S=b[10],V=b[11],Z=b[12],Y=b[13],da=b[14];b=b[15];var ia=d*h-e*u,ba=d*C-g*u,ea=d*H-l*u,ca=e*C-g*h,p=e*H-l*h,D=g*H-l*C,G=L*Y-P*Z,Q=L*da-S*Z;L=L*b-V*Z;var W=P*da-S*Y;P=P*b-V*Y;S=S*b-V*da;V=ia*S-ba*P+ea*W+ca*L-p*Q+D*G;if(!V)return null;V=1/V;a[0]=(h*S-C*P+H*W)*V;a[1]=(C*L-u*S-H*Q)*V;a[2]=(u*P-h*L+H*G)*V;a[3]=(g*P-e*S-l*W)*V;a[4]=(d*S-g*L+l*Q)*V;a[5]=(e*L-d*P-l*G)*V;a[6]=(Y*D-da*p+b*ca)*V;a[7]=(da*ea-Z*D-b*ba)*V;a[8]=(Z*p-Y*ea+b*ia)*V;return a};
F.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"};F.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2))};"undefined"!==typeof r&&(r.mat3=F);var A={create:function(){var a=new K(16);a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=
1;return a},clone:function(a){var b=new K(16);b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return b},copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a},identity:function(a){a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=1;a[6]=0;a[7]=
0;a[8]=0;a[9]=0;a[10]=1;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a},transpose:function(a,b){if(a===b){var d=b[1],e=b[2],g=b[3],l=b[6],u=b[7],h=b[11];a[1]=b[4];a[2]=b[8];a[3]=b[12];a[4]=d;a[6]=b[9];a[7]=b[13];a[8]=e;a[9]=l;a[11]=b[14];a[12]=g;a[13]=u;a[14]=h}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a},invert:function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3],
u=b[4],h=b[5],C=b[6],H=b[7],L=b[8],P=b[9],S=b[10],V=b[11],Z=b[12],Y=b[13],da=b[14];b=b[15];var ia=d*h-e*u,ba=d*C-g*u,ea=d*H-l*u,ca=e*C-g*h,p=e*H-l*h,D=g*H-l*C,G=L*Y-P*Z,Q=L*da-S*Z,W=L*b-V*Z,X=P*da-S*Y,fa=P*b-V*Y,ja=S*b-V*da,ka=ia*ja-ba*fa+ea*X+ca*W-p*Q+D*G;if(!ka)return null;ka=1/ka;a[0]=(h*ja-C*fa+H*X)*ka;a[1]=(g*fa-e*ja-l*X)*ka;a[2]=(Y*D-da*p+b*ca)*ka;a[3]=(S*p-P*D-V*ca)*ka;a[4]=(C*W-u*ja-H*Q)*ka;a[5]=(d*ja-g*W+l*Q)*ka;a[6]=(da*ea-Z*D-b*ba)*ka;a[7]=(L*D-S*ea+V*ba)*ka;a[8]=(u*fa-h*W+H*G)*ka;a[9]=
(e*W-d*fa-l*G)*ka;a[10]=(Z*p-Y*ea+b*ia)*ka;a[11]=(P*ea-L*p-V*ia)*ka;a[12]=(h*Q-u*X-C*G)*ka;a[13]=(d*X-e*Q+g*G)*ka;a[14]=(Y*ba-Z*ca-da*ia)*ka;a[15]=(L*ca-P*ba+S*ia)*ka;return a},adjoint:function(a,b){var d=b[0],e=b[1],g=b[2],l=b[3],u=b[4],h=b[5],C=b[6],H=b[7],L=b[8],P=b[9],S=b[10],V=b[11],Z=b[12],Y=b[13],da=b[14];b=b[15];a[0]=h*(S*b-V*da)-P*(C*b-H*da)+Y*(C*V-H*S);a[1]=-(e*(S*b-V*da)-P*(g*b-l*da)+Y*(g*V-l*S));a[2]=e*(C*b-H*da)-h*(g*b-l*da)+Y*(g*H-l*C);a[3]=-(e*(C*V-H*S)-h*(g*V-l*S)+P*(g*H-l*C));a[4]=
-(u*(S*b-V*da)-L*(C*b-H*da)+Z*(C*V-H*S));a[5]=d*(S*b-V*da)-L*(g*b-l*da)+Z*(g*V-l*S);a[6]=-(d*(C*b-H*da)-u*(g*b-l*da)+Z*(g*H-l*C));a[7]=d*(C*V-H*S)-u*(g*V-l*S)+L*(g*H-l*C);a[8]=u*(P*b-V*Y)-L*(h*b-H*Y)+Z*(h*V-H*P);a[9]=-(d*(P*b-V*Y)-L*(e*b-l*Y)+Z*(e*V-l*P));a[10]=d*(h*b-H*Y)-u*(e*b-l*Y)+Z*(e*H-l*h);a[11]=-(d*(h*V-H*P)-u*(e*V-l*P)+L*(e*H-l*h));a[12]=-(u*(P*da-S*Y)-L*(h*da-C*Y)+Z*(h*S-C*P));a[13]=d*(P*da-S*Y)-L*(e*da-g*Y)+Z*(e*S-g*P);a[14]=-(d*(h*da-C*Y)-u*(e*da-g*Y)+Z*(e*C-g*h));a[15]=d*(h*S-C*P)-u*
(e*S-g*P)+L*(e*C-g*h);return a},determinant:function(a){var b=a[0],d=a[1],e=a[2],g=a[3],l=a[4],u=a[5],h=a[6],C=a[7],H=a[8],L=a[9],P=a[10],S=a[11],V=a[12],Z=a[13],Y=a[14];a=a[15];return(b*u-d*l)*(P*a-S*Y)-(b*h-e*l)*(L*a-S*Z)+(b*C-g*l)*(L*Y-P*Z)+(d*h-e*u)*(H*a-S*V)-(d*C-g*u)*(H*Y-P*V)+(e*C-g*h)*(H*Z-L*V)},multiply:function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=b[4],C=b[5],H=b[6],L=b[7],P=b[8],S=b[9],V=b[10],Z=b[11],Y=b[12],da=b[13],ia=b[14];b=b[15];var ba=d[0],ea=d[1],ca=d[2],p=d[3];a[0]=ba*e+ea*
h+ca*P+p*Y;a[1]=ba*g+ea*C+ca*S+p*da;a[2]=ba*l+ea*H+ca*V+p*ia;a[3]=ba*u+ea*L+ca*Z+p*b;ba=d[4];ea=d[5];ca=d[6];p=d[7];a[4]=ba*e+ea*h+ca*P+p*Y;a[5]=ba*g+ea*C+ca*S+p*da;a[6]=ba*l+ea*H+ca*V+p*ia;a[7]=ba*u+ea*L+ca*Z+p*b;ba=d[8];ea=d[9];ca=d[10];p=d[11];a[8]=ba*e+ea*h+ca*P+p*Y;a[9]=ba*g+ea*C+ca*S+p*da;a[10]=ba*l+ea*H+ca*V+p*ia;a[11]=ba*u+ea*L+ca*Z+p*b;ba=d[12];ea=d[13];ca=d[14];p=d[15];a[12]=ba*e+ea*h+ca*P+p*Y;a[13]=ba*g+ea*C+ca*S+p*da;a[14]=ba*l+ea*H+ca*V+p*ia;a[15]=ba*u+ea*L+ca*Z+p*b;return a}};A.mul=
A.multiply;A.translate=function(a,b,d){var e=d[0],g=d[1];d=d[2];if(b===a)a[12]=b[0]*e+b[4]*g+b[8]*d+b[12],a[13]=b[1]*e+b[5]*g+b[9]*d+b[13],a[14]=b[2]*e+b[6]*g+b[10]*d+b[14],a[15]=b[3]*e+b[7]*g+b[11]*d+b[15];else{var l=b[0];var u=b[1];var h=b[2];var C=b[3];var H=b[4];var L=b[5];var P=b[6];var S=b[7];var V=b[8];var Z=b[9];var Y=b[10];var da=b[11];a[0]=l;a[1]=u;a[2]=h;a[3]=C;a[4]=H;a[5]=L;a[6]=P;a[7]=S;a[8]=V;a[9]=Z;a[10]=Y;a[11]=da;a[12]=l*e+H*g+V*d+b[12];a[13]=u*e+L*g+Z*d+b[13];a[14]=h*e+P*g+Y*d+b[14];
a[15]=C*e+S*g+da*d+b[15]}return a};A.scale=function(a,b,d){var e=d[0],g=d[1];d=d[2];a[0]=b[0]*e;a[1]=b[1]*e;a[2]=b[2]*e;a[3]=b[3]*e;a[4]=b[4]*g;a[5]=b[5]*g;a[6]=b[6]*g;a[7]=b[7]*g;a[8]=b[8]*d;a[9]=b[9]*d;a[10]=b[10]*d;a[11]=b[11]*d;a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15];return a};A.rotate=function(a,b,d,e){var g=e[0],l=e[1];e=e[2];var u=Math.sqrt(g*g+l*l+e*e);if(Math.abs(u)<t)return null;u=1/u;g*=u;l*=u;e*=u;var h=Math.sin(d);var C=Math.cos(d);var H=1-C;d=b[0];u=b[1];var L=b[2];var P=b[3];
var S=b[4];var V=b[5];var Z=b[6];var Y=b[7];var da=b[8];var ia=b[9];var ba=b[10];var ea=b[11];var ca=g*g*H+C;var p=l*g*H+e*h;var D=e*g*H-l*h;var G=g*l*H-e*h;var Q=l*l*H+C;var W=e*l*H+g*h;var X=g*e*H+l*h;g=l*e*H-g*h;l=e*e*H+C;a[0]=d*ca+S*p+da*D;a[1]=u*ca+V*p+ia*D;a[2]=L*ca+Z*p+ba*D;a[3]=P*ca+Y*p+ea*D;a[4]=d*G+S*Q+da*W;a[5]=u*G+V*Q+ia*W;a[6]=L*G+Z*Q+ba*W;a[7]=P*G+Y*Q+ea*W;a[8]=d*X+S*g+da*l;a[9]=u*X+V*g+ia*l;a[10]=L*X+Z*g+ba*l;a[11]=P*X+Y*g+ea*l;b!==a&&(a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);
return a};A.rotateX=function(a,b,d){var e=Math.sin(d);d=Math.cos(d);var g=b[4],l=b[5],u=b[6],h=b[7],C=b[8],H=b[9],L=b[10],P=b[11];b!==a&&(a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[4]=g*d+C*e;a[5]=l*d+H*e;a[6]=u*d+L*e;a[7]=h*d+P*e;a[8]=C*d-g*e;a[9]=H*d-l*e;a[10]=L*d-u*e;a[11]=P*d-h*e;return a};A.rotateY=function(a,b,d){var e=Math.sin(d);d=Math.cos(d);var g=b[0],l=b[1],u=b[2],h=b[3],C=b[8],H=b[9],L=b[10],P=b[11];b!==a&&(a[4]=b[4],a[5]=b[5],a[6]=b[6],
a[7]=b[7],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=g*d-C*e;a[1]=l*d-H*e;a[2]=u*d-L*e;a[3]=h*d-P*e;a[8]=g*e+C*d;a[9]=l*e+H*d;a[10]=u*e+L*d;a[11]=h*e+P*d;return a};A.rotateZ=function(a,b,d){var e=Math.sin(d);d=Math.cos(d);var g=b[0],l=b[1],u=b[2],h=b[3],C=b[4],H=b[5],L=b[6],P=b[7];b!==a&&(a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15]);a[0]=g*d+C*e;a[1]=l*d+H*e;a[2]=u*d+L*e;a[3]=h*d+P*e;a[4]=C*d-g*e;a[5]=H*d-l*e;a[6]=L*d-u*e;a[7]=P*d-h*e;return a};
A.fromRotationTranslation=function(a,b,d){var e=b[0],g=b[1],l=b[2],u=b[3],h=e+e,C=g+g,H=l+l;b=e*h;var L=e*C;e*=H;var P=g*C;g*=H;l*=H;h*=u;C*=u;u*=H;a[0]=1-(P+l);a[1]=L+u;a[2]=e-C;a[3]=0;a[4]=L-u;a[5]=1-(b+l);a[6]=g+h;a[7]=0;a[8]=e+C;a[9]=g-h;a[10]=1-(b+P);a[11]=0;a[12]=d[0];a[13]=d[1];a[14]=d[2];a[15]=1;return a};A.fromQuat=function(a,b){var d=b[0],e=b[1],g=b[2];b=b[3];var l=d+d,u=e+e,h=g+g;d*=l;var C=e*l;e*=u;var H=g*l,L=g*u;g*=h;l*=b;u*=b;b*=h;a[0]=1-e-g;a[1]=C+b;a[2]=H-u;a[3]=0;a[4]=C-b;a[5]=1-
d-g;a[6]=L+l;a[7]=0;a[8]=H+u;a[9]=L-l;a[10]=1-d-e;a[11]=0;a[12]=0;a[13]=0;a[14]=0;a[15]=1;return a};A.frustum=function(a,b,d,e,g,l,u){var h=1/(d-b),C=1/(g-e),H=1/(l-u);a[0]=2*l*h;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=2*l*C;a[6]=0;a[7]=0;a[8]=(d+b)*h;a[9]=(g+e)*C;a[10]=(u+l)*H;a[11]=-1;a[12]=0;a[13]=0;a[14]=u*l*2*H;a[15]=0;return a};A.perspective=function(a,b,d,e,g){b=1/Math.tan(b/2);var l=1/(e-g);a[0]=b/d;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=b;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=(g+e)*l;a[11]=-1;a[12]=0;a[13]=
0;a[14]=2*g*e*l;a[15]=0;return a};A.ortho=function(a,b,d,e,g,l,u){var h=1/(b-d),C=1/(e-g),H=1/(l-u);a[0]=-2*h;a[1]=0;a[2]=0;a[3]=0;a[4]=0;a[5]=-2*C;a[6]=0;a[7]=0;a[8]=0;a[9]=0;a[10]=2*H;a[11]=0;a[12]=(b+d)*h;a[13]=(g+e)*C;a[14]=(u+l)*H;a[15]=1;return a};A.lookAt=function(a,b,d,e){var g=b[0],l=b[1];b=b[2];var u=e[0];var h=e[1];var C=e[2];var H=d[0];e=d[1];var L=d[2];if(Math.abs(g-H)<t&&Math.abs(l-e)<t&&Math.abs(b-L)<t)return A.identity(a);d=g-H;e=l-e;H=b-L;var P=1/Math.sqrt(d*d+e*e+H*H);d*=P;e*=P;
H*=P;L=h*H-C*e;C=C*d-u*H;u=u*e-h*d;(P=Math.sqrt(L*L+C*C+u*u))?(P=1/P,L*=P,C*=P,u*=P):u=C=L=0;h=e*u-H*C;var S=H*L-d*u;var V=d*C-e*L;(P=Math.sqrt(h*h+S*S+V*V))?(P=1/P,h*=P,S*=P,V*=P):V=S=h=0;a[0]=L;a[1]=h;a[2]=d;a[3]=0;a[4]=C;a[5]=S;a[6]=e;a[7]=0;a[8]=u;a[9]=V;a[10]=H;a[11]=0;a[12]=-(L*g+C*l+u*b);a[13]=-(h*g+S*l+V*b);a[14]=-(d*g+e*l+H*b);a[15]=1;return a};A.str=function(a){return"mat4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+
", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+")"};A.frob=function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2)+Math.pow(a[9],2)+Math.pow(a[10],2)+Math.pow(a[11],2)+Math.pow(a[12],2)+Math.pow(a[13],2)+Math.pow(a[14],2)+Math.pow(a[15],2))};"undefined"!==typeof r&&(r.mat4=A);var c={create:function(){var a=new K(4);a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a}};c.rotationTo=
function(){var a=N.create(),b=N.fromValues(1,0,0),d=N.fromValues(0,1,0);return function(e,g,l){var u=N.dot(g,l);if(-.999999>u)return N.cross(a,b,g),1E-6>N.length(a)&&N.cross(a,d,g),N.normalize(a,a),c.setAxisAngle(e,a,Math.PI),e;if(.999999<u)return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e;N.cross(a,g,l);e[0]=a[0];e[1]=a[1];e[2]=a[2];e[3]=1+u;return c.normalize(e,e)}}();c.setAxes=function(){var a=F.create();return function(b,d,e,g){a[0]=e[0];a[3]=e[1];a[6]=e[2];a[1]=g[0];a[4]=g[1];a[7]=g[2];a[2]=-d[0];a[5]=-d[1];
a[8]=-d[2];return c.normalize(b,c.fromMat3(b,a))}}();c.clone=R.clone;c.fromValues=R.fromValues;c.copy=R.copy;c.set=R.set;c.identity=function(a){a[0]=0;a[1]=0;a[2]=0;a[3]=1;return a};c.setAxisAngle=function(a,b,d){d*=.5;var e=Math.sin(d);a[0]=e*b[0];a[1]=e*b[1];a[2]=e*b[2];a[3]=Math.cos(d);return a};c.add=R.add;c.multiply=function(a,b,d){var e=b[0],g=b[1],l=b[2];b=b[3];var u=d[0],h=d[1],C=d[2];d=d[3];a[0]=e*d+b*u+g*C-l*h;a[1]=g*d+b*h+l*u-e*C;a[2]=l*d+b*C+e*h-g*u;a[3]=b*d-e*u-g*h-l*C;return a};c.mul=
c.multiply;c.scale=R.scale;c.rotateX=function(a,b,d){d*=.5;var e=b[0],g=b[1],l=b[2];b=b[3];var u=Math.sin(d);d=Math.cos(d);a[0]=e*d+b*u;a[1]=g*d+l*u;a[2]=l*d-g*u;a[3]=b*d-e*u;return a};c.rotateY=function(a,b,d){d*=.5;var e=b[0],g=b[1],l=b[2];b=b[3];var u=Math.sin(d);d=Math.cos(d);a[0]=e*d-l*u;a[1]=g*d+b*u;a[2]=l*d+e*u;a[3]=b*d-g*u;return a};c.rotateZ=function(a,b,d){d*=.5;var e=b[0],g=b[1],l=b[2];b=b[3];var u=Math.sin(d);d=Math.cos(d);a[0]=e*d+g*u;a[1]=g*d-e*u;a[2]=l*d+b*u;a[3]=b*d-l*u;return a};
c.calculateW=function(a,b){var d=b[0],e=b[1];b=b[2];a[0]=d;a[1]=e;a[2]=b;a[3]=-Math.sqrt(Math.abs(1-d*d-e*e-b*b));return a};c.dot=R.dot;c.lerp=R.lerp;c.slerp=function(a,b,d,e){var g=b[0],l=b[1],u=b[2];b=b[3];var h=d[0],C=d[1],H=d[2];d=d[3];var L=g*h+l*C+u*H+b*d;0>L&&(L=-L,h=-h,C=-C,H=-H,d=-d);if(1E-6<1-L){var P=Math.acos(L);var S=Math.sin(P);L=Math.sin((1-e)*P)/S;e=Math.sin(e*P)/S}else L=1-e;a[0]=L*g+e*h;a[1]=L*l+e*C;a[2]=L*u+e*H;a[3]=L*b+e*d;return a};c.invert=function(a,b){var d=b[0],e=b[1],g=b[2];
b=b[3];var l=d*d+e*e+g*g+b*b;l=l?1/l:0;a[0]=-d*l;a[1]=-e*l;a[2]=-g*l;a[3]=b*l;return a};c.conjugate=function(a,b){a[0]=-b[0];a[1]=-b[1];a[2]=-b[2];a[3]=b[3];return a};c.length=R.length;c.len=c.length;c.squaredLength=R.squaredLength;c.sqrLen=c.squaredLength;c.normalize=R.normalize;c.fromMat3=function(a,b){var d=b[0]+b[4]+b[8];if(0<d)d=Math.sqrt(d+1),a[3]=.5*d,d=.5/d,a[0]=(b[7]-b[5])*d,a[1]=(b[2]-b[6])*d,a[2]=(b[3]-b[1])*d;else{var e=0;b[4]>b[0]&&(e=1);b[8]>b[3*e+e]&&(e=2);var g=(e+1)%3,l=(e+2)%3;d=
Math.sqrt(b[3*e+e]-b[3*g+g]-b[3*l+l]+1);a[e]=.5*d;d=.5/d;a[3]=(b[3*l+g]-b[3*g+l])*d;a[g]=(b[3*g+e]+b[3*e+g])*d;a[l]=(b[3*l+e]+b[3*e+l])*d}return a};c.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};"undefined"!==typeof r&&(r.quat=c)})(n)})(this)},{}],24:[function(f,m,J){(function(){var v=this,n=v._,r={},t=Array.prototype,K=Object.prototype,E=t.push,U=t.slice,M=t.concat,w=K.toString,N=K.hasOwnProperty,R=t.forEach,F=t.map,A=t.reduce,c=t.reduceRight,a=t.filter,b=t.every,d=t.some,
e=t.indexOf,g=t.lastIndexOf;K=Array.isArray;var l=Object.keys,u=Function.prototype.bind,h=function(p){if(p instanceof h)return p;if(!(this instanceof h))return new h(p);this._wrapped=p};"undefined"!==typeof J?("undefined"!==typeof m&&m.exports&&(J=m.exports=h),J._=h):v._=h;h.VERSION="1.4.4";var C=h.each=h.forEach=function(p,D,G){if(null!=p)if(R&&p.forEach===R)p.forEach(D,G);else if(p.length===+p.length)for(var Q=0,W=p.length;Q<W&&D.call(G,p[Q],Q,p)!==r;Q++);else for(Q in p)if(h.has(p,Q)&&D.call(G,
p[Q],Q,p)===r)break};h.map=h.collect=function(p,D,G){var Q=[];if(null==p)return Q;if(F&&p.map===F)return p.map(D,G);C(p,function(W,X,fa){Q[Q.length]=D.call(G,W,X,fa)});return Q};h.reduce=h.foldl=h.inject=function(p,D,G,Q){var W=2<arguments.length;null==p&&(p=[]);if(A&&p.reduce===A)return Q&&(D=h.bind(D,Q)),W?p.reduce(D,G):p.reduce(D);C(p,function(X,fa,ja){W?G=D.call(Q,G,X,fa,ja):(G=X,W=!0)});if(!W)throw new TypeError("Reduce of empty array with no initial value");return G};h.reduceRight=h.foldr=function(p,
D,G,Q){var W=2<arguments.length;null==p&&(p=[]);if(c&&p.reduceRight===c)return Q&&(D=h.bind(D,Q)),W?p.reduceRight(D,G):p.reduceRight(D);var X=p.length;if(X!==+X){var fa=h.keys(p);X=fa.length}C(p,function(ja,ka,ra){ka=fa?fa[--X]:--X;W?G=D.call(Q,G,p[ka],ka,ra):(G=p[ka],W=!0)});if(!W)throw new TypeError("Reduce of empty array with no initial value");return G};h.find=h.detect=function(p,D,G){var Q;H(p,function(W,X,fa){if(D.call(G,W,X,fa))return Q=W,!0});return Q};h.filter=h.select=function(p,D,G){var Q=
[];if(null==p)return Q;if(a&&p.filter===a)return p.filter(D,G);C(p,function(W,X,fa){D.call(G,W,X,fa)&&(Q[Q.length]=W)});return Q};h.reject=function(p,D,G){return h.filter(p,function(Q,W,X){return!D.call(G,Q,W,X)},G)};h.every=h.all=function(p,D,G){D||(D=h.identity);var Q=!0;if(null==p)return Q;if(b&&p.every===b)return p.every(D,G);C(p,function(W,X,fa){if(!(Q=Q&&D.call(G,W,X,fa)))return r});return!!Q};var H=h.some=h.any=function(p,D,G){D||(D=h.identity);var Q=!1;if(null==p)return Q;if(d&&p.some===d)return p.some(D,
G);C(p,function(W,X,fa){if(Q||(Q=D.call(G,W,X,fa)))return r});return!!Q};h.contains=h.include=function(p,D){return null==p?!1:e&&p.indexOf===e?-1!==p.indexOf(D):H(p,function(G){return G===D})};h.invoke=function(p,D){var G=U.call(arguments,2),Q=h.isFunction(D);return h.map(p,function(W){return(Q?D:W[D]).apply(W,G)})};h.pluck=function(p,D){return h.map(p,function(G){return G[D]})};h.where=function(p,D,G){return h.isEmpty(D)?G?null:[]:h[G?"find":"filter"](p,function(Q){for(var W in D)if(D[W]!==Q[W])return!1;
return!0})};h.findWhere=function(p,D){return h.where(p,D,!0)};h.max=function(p,D,G){if(!D&&h.isArray(p)&&p[0]===+p[0]&&65535>p.length)return Math.max.apply(Math,p);if(!D&&h.isEmpty(p))return-Infinity;var Q={computed:-Infinity,value:-Infinity};C(p,function(W,X,fa){X=D?D.call(G,W,X,fa):W;X>=Q.computed&&(Q={value:W,computed:X})});return Q.value};h.min=function(p,D,G){if(!D&&h.isArray(p)&&p[0]===+p[0]&&65535>p.length)return Math.min.apply(Math,p);if(!D&&h.isEmpty(p))return Infinity;var Q={computed:Infinity,
value:Infinity};C(p,function(W,X,fa){X=D?D.call(G,W,X,fa):W;X<Q.computed&&(Q={value:W,computed:X})});return Q.value};h.shuffle=function(p){var D,G=0,Q=[];C(p,function(W){D=h.random(G++);Q[G-1]=Q[D];Q[D]=W});return Q};var L=function(p){return h.isFunction(p)?p:function(D){return D[p]}};h.sortBy=function(p,D,G){var Q=L(D);return h.pluck(h.map(p,function(W,X,fa){return{value:W,index:X,criteria:Q.call(G,W,X,fa)}}).sort(function(W,X){var fa=W.criteria,ja=X.criteria;if(fa!==ja){if(fa>ja||void 0===fa)return 1;
if(fa<ja||void 0===ja)return-1}return W.index<X.index?-1:1}),"value")};var P=function(p,D,G,Q){var W={},X=L(D||h.identity);C(p,function(fa,ja){ja=X.call(G,fa,ja,p);Q(W,ja,fa)});return W};h.groupBy=function(p,D,G){return P(p,D,G,function(Q,W,X){(h.has(Q,W)?Q[W]:Q[W]=[]).push(X)})};h.countBy=function(p,D,G){return P(p,D,G,function(Q,W){h.has(Q,W)||(Q[W]=0);Q[W]++})};h.sortedIndex=function(p,D,G,Q){G=null==G?h.identity:L(G);D=G.call(Q,D);for(var W=0,X=p.length;W<X;){var fa=W+X>>>1;G.call(Q,p[fa])<D?
W=fa+1:X=fa}return W};h.toArray=function(p){return p?h.isArray(p)?U.call(p):p.length===+p.length?h.map(p,h.identity):h.values(p):[]};h.size=function(p){return null==p?0:p.length===+p.length?p.length:h.keys(p).length};h.first=h.head=h.take=function(p,D,G){if(null!=p)return null==D||G?p[0]:U.call(p,0,D)};h.initial=function(p,D,G){return U.call(p,0,p.length-(null==D||G?1:D))};h.last=function(p,D,G){if(null!=p)return null==D||G?p[p.length-1]:U.call(p,Math.max(p.length-D,0))};h.rest=h.tail=h.drop=function(p,
D,G){return U.call(p,null==D||G?1:D)};h.compact=function(p){return h.filter(p,h.identity)};var S=function(p,D,G){C(p,function(Q){h.isArray(Q)?D?E.apply(G,Q):S(Q,D,G):G.push(Q)});return G};h.flatten=function(p,D){return S(p,D,[])};h.without=function(p){return h.difference(p,U.call(arguments,1))};h.uniq=h.unique=function(p,D,G,Q){h.isFunction(D)&&(Q=G,G=D,D=!1);G=G?h.map(p,G,Q):p;var W=[],X=[];C(G,function(fa,ja){(D?ja&&X[X.length-1]===fa:h.contains(X,fa))||(X.push(fa),W.push(p[ja]))});return W};h.union=
function(){return h.uniq(M.apply(t,arguments))};h.intersection=function(p){var D=U.call(arguments,1);return h.filter(h.uniq(p),function(G){return h.every(D,function(Q){return 0<=h.indexOf(Q,G)})})};h.difference=function(p){var D=M.apply(t,U.call(arguments,1));return h.filter(p,function(G){return!h.contains(D,G)})};h.zip=function(){for(var p=U.call(arguments),D=h.max(h.pluck(p,"length")),G=Array(D),Q=0;Q<D;Q++)G[Q]=h.pluck(p,""+Q);return G};h.object=function(p,D){if(null==p)return{};for(var G={},Q=
0,W=p.length;Q<W;Q++)D?G[p[Q]]=D[Q]:G[p[Q][0]]=p[Q][1];return G};h.indexOf=function(p,D,G){if(null==p)return-1;var Q=0,W=p.length;if(G)if("number"==typeof G)Q=0>G?Math.max(0,W+G):G;else return Q=h.sortedIndex(p,D),p[Q]===D?Q:-1;if(e&&p.indexOf===e)return p.indexOf(D,G);for(;Q<W;Q++)if(p[Q]===D)return Q;return-1};h.lastIndexOf=function(p,D,G){if(null==p)return-1;var Q=null!=G;if(g&&p.lastIndexOf===g)return Q?p.lastIndexOf(D,G):p.lastIndexOf(D);for(G=Q?G:p.length;G--;)if(p[G]===D)return G;return-1};
h.range=function(p,D,G){1>=arguments.length&&(D=p||0,p=0);G=arguments[2]||1;for(var Q=Math.max(Math.ceil((D-p)/G),0),W=0,X=Array(Q);W<Q;)X[W++]=p,p+=G;return X};h.bind=function(p,D){if(p.bind===u&&u)return u.apply(p,U.call(arguments,1));var G=U.call(arguments,2);return function(){return p.apply(D,G.concat(U.call(arguments)))}};h.partial=function(p){var D=U.call(arguments,1);return function(){return p.apply(this,D.concat(U.call(arguments)))}};h.bindAll=function(p){var D=U.call(arguments,1);0===D.length&&
(D=h.functions(p));C(D,function(G){p[G]=h.bind(p[G],p)});return p};h.memoize=function(p,D){var G={};D||(D=h.identity);return function(){var Q=D.apply(this,arguments);return h.has(G,Q)?G[Q]:G[Q]=p.apply(this,arguments)}};h.delay=function(p,D){var G=U.call(arguments,2);return setTimeout(function(){return p.apply(null,G)},D)};h.defer=function(p){return h.delay.apply(h,[p,1].concat(U.call(arguments,1)))};h.throttle=function(p,D){var G,Q,W,X,fa=0,ja=function(){fa=new Date;W=null;X=p.apply(G,Q)};return function(){var ka=
new Date,ra=D-(ka-fa);G=this;Q=arguments;0>=ra?(clearTimeout(W),W=null,fa=ka,X=p.apply(G,Q)):W||(W=setTimeout(ja,ra));return X}};h.debounce=function(p,D,G){var Q,W;return function(){var X=this,fa=arguments,ja=G&&!Q;clearTimeout(Q);Q=setTimeout(function(){Q=null;G||(W=p.apply(X,fa))},D);ja&&(W=p.apply(X,fa));return W}};h.once=function(p){var D=!1,G;return function(){if(D)return G;D=!0;G=p.apply(this,arguments);p=null;return G}};h.wrap=function(p,D){return function(){var G=[p];E.apply(G,arguments);
return D.apply(this,G)}};h.compose=function(){var p=arguments;return function(){for(var D=arguments,G=p.length-1;0<=G;G--)D=[p[G].apply(this,D)];return D[0]}};h.after=function(p,D){return 0>=p?D():function(){if(1>--p)return D.apply(this,arguments)}};h.keys=l||function(p){if(p!==Object(p))throw new TypeError("Invalid object");var D=[],G;for(G in p)h.has(p,G)&&(D[D.length]=G);return D};h.values=function(p){var D=[],G;for(G in p)h.has(p,G)&&D.push(p[G]);return D};h.pairs=function(p){var D=[],G;for(G in p)h.has(p,
G)&&D.push([G,p[G]]);return D};h.invert=function(p){var D={},G;for(G in p)h.has(p,G)&&(D[p[G]]=G);return D};h.functions=h.methods=function(p){var D=[],G;for(G in p)h.isFunction(p[G])&&D.push(G);return D.sort()};h.extend=function(p){C(U.call(arguments,1),function(D){if(D)for(var G in D)p[G]=D[G]});return p};h.pick=function(p){var D={},G=M.apply(t,U.call(arguments,1));C(G,function(Q){Q in p&&(D[Q]=p[Q])});return D};h.omit=function(p){var D={},G=M.apply(t,U.call(arguments,1)),Q;for(Q in p)h.contains(G,
Q)||(D[Q]=p[Q]);return D};h.defaults=function(p){C(U.call(arguments,1),function(D){if(D)for(var G in D)null==p[G]&&(p[G]=D[G])});return p};h.clone=function(p){return h.isObject(p)?h.isArray(p)?p.slice():h.extend({},p):p};h.tap=function(p,D){D(p);return p};var V=function(p,D,G,Q){if(p===D)return 0!==p||1/p==1/D;if(null==p||null==D)return p===D;p instanceof h&&(p=p._wrapped);D instanceof h&&(D=D._wrapped);var W=w.call(p);if(W!=w.call(D))return!1;switch(W){case "[object String]":return p==String(D);
case "[object Number]":return p!=+p?D!=+D:0==p?1/p==1/D:p==+D;case "[object Date]":case "[object Boolean]":return+p==+D;case "[object RegExp]":return p.source==D.source&&p.global==D.global&&p.multiline==D.multiline&&p.ignoreCase==D.ignoreCase}if("object"!=typeof p||"object"!=typeof D)return!1;for(var X=G.length;X--;)if(G[X]==p)return Q[X]==D;G.push(p);Q.push(D);X=0;var fa=!0;if("[object Array]"==W){if(X=p.length,fa=X==D.length)for(;X--&&(fa=V(p[X],D[X],G,Q)););}else{W=p.constructor;var ja=D.constructor;
if(W!==ja&&!(h.isFunction(W)&&W instanceof W&&h.isFunction(ja)&&ja instanceof ja))return!1;for(var ka in p)if(h.has(p,ka)&&(X++,!(fa=h.has(D,ka)&&V(p[ka],D[ka],G,Q))))break;if(fa){for(ka in D)if(h.has(D,ka)&&!X--)break;fa=!X}}G.pop();Q.pop();return fa};h.isEqual=function(p,D){return V(p,D,[],[])};h.isEmpty=function(p){if(null==p)return!0;if(h.isArray(p)||h.isString(p))return 0===p.length;for(var D in p)if(h.has(p,D))return!1;return!0};h.isElement=function(p){return!(!p||1!==p.nodeType)};h.isArray=
K||function(p){return"[object Array]"==w.call(p)};h.isObject=function(p){return p===Object(p)};C("Arguments Function String Number Date RegExp".split(" "),function(p){h["is"+p]=function(D){return w.call(D)=="[object "+p+"]"}});h.isArguments(arguments)||(h.isArguments=function(p){return!(!p||!h.has(p,"callee"))});"function"!==typeof/./&&(h.isFunction=function(p){return"function"===typeof p});h.isFinite=function(p){return isFinite(p)&&!isNaN(parseFloat(p))};h.isNaN=function(p){return h.isNumber(p)&&
p!=+p};h.isBoolean=function(p){return!0===p||!1===p||"[object Boolean]"==w.call(p)};h.isNull=function(p){return null===p};h.isUndefined=function(p){return void 0===p};h.has=function(p,D){return N.call(p,D)};h.noConflict=function(){v._=n;return this};h.identity=function(p){return p};h.times=function(p,D,G){for(var Q=Array(p),W=0;W<p;W++)Q[W]=D.call(G,W);return Q};h.random=function(p,D){null==D&&(D=p,p=0);return p+Math.floor(Math.random()*(D-p+1))};var Z={escape:{"&":"&","<":"<",">":">",'"':""",
"'":"'","/":"/"}};Z.unescape=h.invert(Z.escape);var Y={escape:new RegExp("["+h.keys(Z.escape).join("")+"]","g"),unescape:new RegExp("("+h.keys(Z.unescape).join("|")+")","g")};h.each(["escape","unescape"],function(p){h[p]=function(D){return null==D?"":(""+D).replace(Y[p],function(G){return Z[p][G]})}});h.result=function(p,D){if(null==p)return null;D=p[D];return h.isFunction(D)?D.call(p):D};h.mixin=function(p){C(h.functions(p),function(D){var G=h[D]=p[D];h.prototype[D]=function(){var Q=[this._wrapped];
E.apply(Q,arguments);return ca.call(this,G.apply(h,Q))}})};var da=0;h.uniqueId=function(p){var D=++da+"";return p?p+D:D};h.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var ia=/(.)^/,ba={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},ea=/\\|'|\r|\n|\t|\u2028|\u2029/g;h.template=function(p,D,G){G=h.defaults({},G,h.templateSettings);var Q=new RegExp([(G.escape||ia).source,(G.interpolate||ia).source,(G.evaluate||
ia).source].join("|")+"|$","g"),W=0,X="__p+='";p.replace(Q,function(ja,ka,ra,Aa,Ba){X+=p.slice(W,Ba).replace(ea,function(Ga){return"\\"+ba[Ga]});ka&&(X+="'+\n((__t=("+ka+"))==null?'':_.escape(__t))+\n'");ra&&(X+="'+\n((__t=("+ra+"))==null?'':__t)+\n'");Aa&&(X+="';\n"+Aa+"\n__p+='");W=Ba+ja.length;return ja});X+="';\n";G.variable||(X="with(obj||{}){\n"+X+"}\n");X="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+X+"return __p;\n";try{var fa=new Function(G.variable||
"obj","_",X)}catch(ja){throw ja.source=X,ja;}if(D)return fa(D,h);D=function(ja){return fa.call(this,ja,h)};D.source="function("+(G.variable||"obj")+"){\n"+X+"}";return D};h.chain=function(p){return h(p).chain()};var ca=function(p){return this._chain?h(p).chain():p};h.mixin(h);C("pop push reverse shift sort splice unshift".split(" "),function(p){var D=t[p];h.prototype[p]=function(){var G=this._wrapped;D.apply(G,arguments);"shift"!=p&&"splice"!=p||0!==G.length||delete G[0];return ca.call(this,G)}});
C(["concat","join","slice"],function(p){var D=t[p];h.prototype[p]=function(){return ca.call(this,D.apply(this._wrapped,arguments))}});h.extend(h.prototype,{chain:function(){this._chain=!0;return this},value:function(){return this._wrapped}})}).call(this)},{}],25:[function(f,m,J){"undefined"!==typeof window&&"function"!==typeof window.requestAnimationFrame&&(window.requestAnimationFrame=window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||
function(v){setTimeout(v,1E3/60)});Leap=f("../lib/index")},{"../lib/index":11}]},{},[25]);
}).call(this);//# sourceMappingURL=CindyLeap.js.map