1/**
2 * @fileoverview gl-matrix - High performance matrix and vector operations
3 * @author Brandon Jones
4 * @author Colin MacKenzie IV
5 * @version 2.3.1
6 */
7
8/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in
18all copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26THE SOFTWARE. */
27
28(function webpackUniversalModuleDefinition(root, factory) {
29	if(typeof exports === 'object' && typeof module === 'object')
30		module.exports = factory();
31	else if(typeof define === 'function' && define.amd)
32		define(factory);
33	else {
34		var a = factory();
35		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
36	}
37})(this, function() {
38return /******/ (function(modules) { // webpackBootstrap
39/******/ 	// The module cache
40/******/ 	var installedModules = {};
41
42/******/ 	// The require function
43/******/ 	function __webpack_require__(moduleId) {
44
45/******/ 		// Check if module is in cache
46/******/ 		if(installedModules[moduleId])
47/******/ 			return installedModules[moduleId].exports;
48
49/******/ 		// Create a new module (and put it into the cache)
50/******/ 		var module = installedModules[moduleId] = {
51/******/ 			exports: {},
52/******/ 			id: moduleId,
53/******/ 			loaded: false
54/******/ 		};
55
56/******/ 		// Execute the module function
57/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
58
59/******/ 		// Flag the module as loaded
60/******/ 		module.loaded = true;
61
62/******/ 		// Return the exports of the module
63/******/ 		return module.exports;
64/******/ 	}
65
66
67/******/ 	// expose the modules object (__webpack_modules__)
68/******/ 	__webpack_require__.m = modules;
69
70/******/ 	// expose the module cache
71/******/ 	__webpack_require__.c = installedModules;
72
73/******/ 	// __webpack_public_path__
74/******/ 	__webpack_require__.p = "";
75
76/******/ 	// Load entry module and return exports
77/******/ 	return __webpack_require__(0);
78/******/ })
79/************************************************************************/
80/******/ ([
81/* 0 */
82/***/ function(module, exports, __webpack_require__) {
83
84	/**
85	 * @fileoverview gl-matrix - High performance matrix and vector operations
86	 * @author Brandon Jones
87	 * @author Colin MacKenzie IV
88	 * @version 2.3.1
89	 */
90
91	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
92
93	Permission is hereby granted, free of charge, to any person obtaining a copy
94	of this software and associated documentation files (the "Software"), to deal
95	in the Software without restriction, including without limitation the rights
96	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
97	copies of the Software, and to permit persons to whom the Software is
98	furnished to do so, subject to the following conditions:
99
100	The above copyright notice and this permission notice shall be included in
101	all copies or substantial portions of the Software.
102
103	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
104	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
105	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
106	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
107	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
108	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
109	THE SOFTWARE. */
110	// END HEADER
111
112	exports.glMatrix = __webpack_require__(1);
113	exports.mat2 = __webpack_require__(2);
114	exports.mat2d = __webpack_require__(3);
115	exports.mat3 = __webpack_require__(4);
116	exports.mat4 = __webpack_require__(5);
117	exports.quat = __webpack_require__(6);
118	exports.vec2 = __webpack_require__(9);
119	exports.vec3 = __webpack_require__(7);
120	exports.vec4 = __webpack_require__(8);
121
122/***/ },
123/* 1 */
124/***/ function(module, exports, __webpack_require__) {
125
126	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
127
128	Permission is hereby granted, free of charge, to any person obtaining a copy
129	of this software and associated documentation files (the "Software"), to deal
130	in the Software without restriction, including without limitation the rights
131	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
132	copies of the Software, and to permit persons to whom the Software is
133	furnished to do so, subject to the following conditions:
134
135	The above copyright notice and this permission notice shall be included in
136	all copies or substantial portions of the Software.
137
138	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
140	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
141	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
142	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
143	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
144	THE SOFTWARE. */
145
146	/**
147	 * @class Common utilities
148	 * @name glMatrix
149	 */
150	var glMatrix = {};
151
152	// Constants
153	glMatrix.EPSILON = 0.000001;
154	glMatrix.ARRAY_TYPE = (typeof Float32Array !== 'undefined') ? Float32Array : Array;
155	glMatrix.RANDOM = Math.random;
156
157	/**
158	 * Sets the type of array used when creating new vectors and matrices
159	 *
160	 * @param {Type} type Array type, such as Float32Array or Array
161	 */
162	glMatrix.setMatrixArrayType = function(type) {
163	    GLMAT_ARRAY_TYPE = type;
164	}
165
166	var degree = Math.PI / 180;
167
168	/**
169	* Convert Degree To Radian
170	*
171	* @param {Number} Angle in Degrees
172	*/
173	glMatrix.toRadian = function(a){
174	     return a * degree;
175	}
176
177	module.exports = glMatrix;
178
179
180/***/ },
181/* 2 */
182/***/ function(module, exports, __webpack_require__) {
183
184	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
185
186	Permission is hereby granted, free of charge, to any person obtaining a copy
187	of this software and associated documentation files (the "Software"), to deal
188	in the Software without restriction, including without limitation the rights
189	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
190	copies of the Software, and to permit persons to whom the Software is
191	furnished to do so, subject to the following conditions:
192
193	The above copyright notice and this permission notice shall be included in
194	all copies or substantial portions of the Software.
195
196	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
198	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
199	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
200	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
201	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
202	THE SOFTWARE. */
203
204	var glMatrix = __webpack_require__(1);
205
206	/**
207	 * @class 2x2 Matrix
208	 * @name mat2
209	 */
210	var mat2 = {};
211
212	/**
213	 * Creates a new identity mat2
214	 *
215	 * @returns {mat2} a new 2x2 matrix
216	 */
217	mat2.create = function() {
218	    var out = new glMatrix.ARRAY_TYPE(4);
219	    out[0] = 1;
220	    out[1] = 0;
221	    out[2] = 0;
222	    out[3] = 1;
223	    return out;
224	};
225
226	/**
227	 * Creates a new mat2 initialized with values from an existing matrix
228	 *
229	 * @param {mat2} a matrix to clone
230	 * @returns {mat2} a new 2x2 matrix
231	 */
232	mat2.clone = function(a) {
233	    var out = new glMatrix.ARRAY_TYPE(4);
234	    out[0] = a[0];
235	    out[1] = a[1];
236	    out[2] = a[2];
237	    out[3] = a[3];
238	    return out;
239	};
240
241	/**
242	 * Copy the values from one mat2 to another
243	 *
244	 * @param {mat2} out the receiving matrix
245	 * @param {mat2} a the source matrix
246	 * @returns {mat2} out
247	 */
248	mat2.copy = function(out, a) {
249	    out[0] = a[0];
250	    out[1] = a[1];
251	    out[2] = a[2];
252	    out[3] = a[3];
253	    return out;
254	};
255
256	/**
257	 * Set a mat2 to the identity matrix
258	 *
259	 * @param {mat2} out the receiving matrix
260	 * @returns {mat2} out
261	 */
262	mat2.identity = function(out) {
263	    out[0] = 1;
264	    out[1] = 0;
265	    out[2] = 0;
266	    out[3] = 1;
267	    return out;
268	};
269
270	/**
271	 * Transpose the values of a mat2
272	 *
273	 * @param {mat2} out the receiving matrix
274	 * @param {mat2} a the source matrix
275	 * @returns {mat2} out
276	 */
277	mat2.transpose = function(out, a) {
278	    // If we are transposing ourselves we can skip a few steps but have to cache some values
279	    if (out === a) {
280	        var a1 = a[1];
281	        out[1] = a[2];
282	        out[2] = a1;
283	    } else {
284	        out[0] = a[0];
285	        out[1] = a[2];
286	        out[2] = a[1];
287	        out[3] = a[3];
288	    }
289
290	    return out;
291	};
292
293	/**
294	 * Inverts a mat2
295	 *
296	 * @param {mat2} out the receiving matrix
297	 * @param {mat2} a the source matrix
298	 * @returns {mat2} out
299	 */
300	mat2.invert = function(out, a) {
301	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
302
303	        // Calculate the determinant
304	        det = a0 * a3 - a2 * a1;
305
306	    if (!det) {
307	        return null;
308	    }
309	    det = 1.0 / det;
310
311	    out[0] =  a3 * det;
312	    out[1] = -a1 * det;
313	    out[2] = -a2 * det;
314	    out[3] =  a0 * det;
315
316	    return out;
317	};
318
319	/**
320	 * Calculates the adjugate of a mat2
321	 *
322	 * @param {mat2} out the receiving matrix
323	 * @param {mat2} a the source matrix
324	 * @returns {mat2} out
325	 */
326	mat2.adjoint = function(out, a) {
327	    // Caching this value is nessecary if out == a
328	    var a0 = a[0];
329	    out[0] =  a[3];
330	    out[1] = -a[1];
331	    out[2] = -a[2];
332	    out[3] =  a0;
333
334	    return out;
335	};
336
337	/**
338	 * Calculates the determinant of a mat2
339	 *
340	 * @param {mat2} a the source matrix
341	 * @returns {Number} determinant of a
342	 */
343	mat2.determinant = function (a) {
344	    return a[0] * a[3] - a[2] * a[1];
345	};
346
347	/**
348	 * Multiplies two mat2's
349	 *
350	 * @param {mat2} out the receiving matrix
351	 * @param {mat2} a the first operand
352	 * @param {mat2} b the second operand
353	 * @returns {mat2} out
354	 */
355	mat2.multiply = function (out, a, b) {
356	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3];
357	    var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
358	    out[0] = a0 * b0 + a2 * b1;
359	    out[1] = a1 * b0 + a3 * b1;
360	    out[2] = a0 * b2 + a2 * b3;
361	    out[3] = a1 * b2 + a3 * b3;
362	    return out;
363	};
364
365	/**
366	 * Alias for {@link mat2.multiply}
367	 * @function
368	 */
369	mat2.mul = mat2.multiply;
370
371	/**
372	 * Rotates a mat2 by the given angle
373	 *
374	 * @param {mat2} out the receiving matrix
375	 * @param {mat2} a the matrix to rotate
376	 * @param {Number} rad the angle to rotate the matrix by
377	 * @returns {mat2} out
378	 */
379	mat2.rotate = function (out, a, rad) {
380	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
381	        s = Math.sin(rad),
382	        c = Math.cos(rad);
383	    out[0] = a0 *  c + a2 * s;
384	    out[1] = a1 *  c + a3 * s;
385	    out[2] = a0 * -s + a2 * c;
386	    out[3] = a1 * -s + a3 * c;
387	    return out;
388	};
389
390	/**
391	 * Scales the mat2 by the dimensions in the given vec2
392	 *
393	 * @param {mat2} out the receiving matrix
394	 * @param {mat2} a the matrix to rotate
395	 * @param {vec2} v the vec2 to scale the matrix by
396	 * @returns {mat2} out
397	 **/
398	mat2.scale = function(out, a, v) {
399	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
400	        v0 = v[0], v1 = v[1];
401	    out[0] = a0 * v0;
402	    out[1] = a1 * v0;
403	    out[2] = a2 * v1;
404	    out[3] = a3 * v1;
405	    return out;
406	};
407
408	/**
409	 * Creates a matrix from a given angle
410	 * This is equivalent to (but much faster than):
411	 *
412	 *     mat2.identity(dest);
413	 *     mat2.rotate(dest, dest, rad);
414	 *
415	 * @param {mat2} out mat2 receiving operation result
416	 * @param {Number} rad the angle to rotate the matrix by
417	 * @returns {mat2} out
418	 */
419	mat2.fromRotation = function(out, rad) {
420	    var s = Math.sin(rad),
421	        c = Math.cos(rad);
422	    out[0] = c;
423	    out[1] = s;
424	    out[2] = -s;
425	    out[3] = c;
426	    return out;
427	}
428
429	/**
430	 * Creates a matrix from a vector scaling
431	 * This is equivalent to (but much faster than):
432	 *
433	 *     mat2.identity(dest);
434	 *     mat2.scale(dest, dest, vec);
435	 *
436	 * @param {mat2} out mat2 receiving operation result
437	 * @param {vec2} v Scaling vector
438	 * @returns {mat2} out
439	 */
440	mat2.fromScaling = function(out, v) {
441	    out[0] = v[0];
442	    out[1] = 0;
443	    out[2] = 0;
444	    out[3] = v[1];
445	    return out;
446	}
447
448	/**
449	 * Returns a string representation of a mat2
450	 *
451	 * @param {mat2} mat matrix to represent as a string
452	 * @returns {String} string representation of the matrix
453	 */
454	mat2.str = function (a) {
455	    return 'mat2(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
456	};
457
458	/**
459	 * Returns Frobenius norm of a mat2
460	 *
461	 * @param {mat2} a the matrix to calculate Frobenius norm of
462	 * @returns {Number} Frobenius norm
463	 */
464	mat2.frob = function (a) {
465	    return(Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2)))
466	};
467
468	/**
469	 * Returns L, D and U matrices (Lower triangular, Diagonal and Upper triangular) by factorizing the input matrix
470	 * @param {mat2} L the lower triangular matrix
471	 * @param {mat2} D the diagonal matrix
472	 * @param {mat2} U the upper triangular matrix
473	 * @param {mat2} a the input matrix to factorize
474	 */
475
476	mat2.LDU = function (L, D, U, a) {
477	    L[2] = a[2]/a[0];
478	    U[0] = a[0];
479	    U[1] = a[1];
480	    U[3] = a[3] - L[2] * U[1];
481	    return [L, D, U];
482	};
483
484
485	module.exports = mat2;
486
487
488/***/ },
489/* 3 */
490/***/ function(module, exports, __webpack_require__) {
491
492	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
493
494	Permission is hereby granted, free of charge, to any person obtaining a copy
495	of this software and associated documentation files (the "Software"), to deal
496	in the Software without restriction, including without limitation the rights
497	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
498	copies of the Software, and to permit persons to whom the Software is
499	furnished to do so, subject to the following conditions:
500
501	The above copyright notice and this permission notice shall be included in
502	all copies or substantial portions of the Software.
503
504	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
505	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
506	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
507	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
508	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
509	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
510	THE SOFTWARE. */
511
512	var glMatrix = __webpack_require__(1);
513
514	/**
515	 * @class 2x3 Matrix
516	 * @name mat2d
517	 *
518	 * @description
519	 * A mat2d contains six elements defined as:
520	 * <pre>
521	 * [a, c, tx,
522	 *  b, d, ty]
523	 * </pre>
524	 * This is a short form for the 3x3 matrix:
525	 * <pre>
526	 * [a, c, tx,
527	 *  b, d, ty,
528	 *  0, 0, 1]
529	 * </pre>
530	 * The last row is ignored so the array is shorter and operations are faster.
531	 */
532	var mat2d = {};
533
534	/**
535	 * Creates a new identity mat2d
536	 *
537	 * @returns {mat2d} a new 2x3 matrix
538	 */
539	mat2d.create = function() {
540	    var out = new glMatrix.ARRAY_TYPE(6);
541	    out[0] = 1;
542	    out[1] = 0;
543	    out[2] = 0;
544	    out[3] = 1;
545	    out[4] = 0;
546	    out[5] = 0;
547	    return out;
548	};
549
550	/**
551	 * Creates a new mat2d initialized with values from an existing matrix
552	 *
553	 * @param {mat2d} a matrix to clone
554	 * @returns {mat2d} a new 2x3 matrix
555	 */
556	mat2d.clone = function(a) {
557	    var out = new glMatrix.ARRAY_TYPE(6);
558	    out[0] = a[0];
559	    out[1] = a[1];
560	    out[2] = a[2];
561	    out[3] = a[3];
562	    out[4] = a[4];
563	    out[5] = a[5];
564	    return out;
565	};
566
567	/**
568	 * Copy the values from one mat2d to another
569	 *
570	 * @param {mat2d} out the receiving matrix
571	 * @param {mat2d} a the source matrix
572	 * @returns {mat2d} out
573	 */
574	mat2d.copy = function(out, a) {
575	    out[0] = a[0];
576	    out[1] = a[1];
577	    out[2] = a[2];
578	    out[3] = a[3];
579	    out[4] = a[4];
580	    out[5] = a[5];
581	    return out;
582	};
583
584	/**
585	 * Set a mat2d to the identity matrix
586	 *
587	 * @param {mat2d} out the receiving matrix
588	 * @returns {mat2d} out
589	 */
590	mat2d.identity = function(out) {
591	    out[0] = 1;
592	    out[1] = 0;
593	    out[2] = 0;
594	    out[3] = 1;
595	    out[4] = 0;
596	    out[5] = 0;
597	    return out;
598	};
599
600	/**
601	 * Inverts a mat2d
602	 *
603	 * @param {mat2d} out the receiving matrix
604	 * @param {mat2d} a the source matrix
605	 * @returns {mat2d} out
606	 */
607	mat2d.invert = function(out, a) {
608	    var aa = a[0], ab = a[1], ac = a[2], ad = a[3],
609	        atx = a[4], aty = a[5];
610
611	    var det = aa * ad - ab * ac;
612	    if(!det){
613	        return null;
614	    }
615	    det = 1.0 / det;
616
617	    out[0] = ad * det;
618	    out[1] = -ab * det;
619	    out[2] = -ac * det;
620	    out[3] = aa * det;
621	    out[4] = (ac * aty - ad * atx) * det;
622	    out[5] = (ab * atx - aa * aty) * det;
623	    return out;
624	};
625
626	/**
627	 * Calculates the determinant of a mat2d
628	 *
629	 * @param {mat2d} a the source matrix
630	 * @returns {Number} determinant of a
631	 */
632	mat2d.determinant = function (a) {
633	    return a[0] * a[3] - a[1] * a[2];
634	};
635
636	/**
637	 * Multiplies two mat2d's
638	 *
639	 * @param {mat2d} out the receiving matrix
640	 * @param {mat2d} a the first operand
641	 * @param {mat2d} b the second operand
642	 * @returns {mat2d} out
643	 */
644	mat2d.multiply = function (out, a, b) {
645	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
646	        b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3], b4 = b[4], b5 = b[5];
647	    out[0] = a0 * b0 + a2 * b1;
648	    out[1] = a1 * b0 + a3 * b1;
649	    out[2] = a0 * b2 + a2 * b3;
650	    out[3] = a1 * b2 + a3 * b3;
651	    out[4] = a0 * b4 + a2 * b5 + a4;
652	    out[5] = a1 * b4 + a3 * b5 + a5;
653	    return out;
654	};
655
656	/**
657	 * Alias for {@link mat2d.multiply}
658	 * @function
659	 */
660	mat2d.mul = mat2d.multiply;
661
662	/**
663	 * Rotates a mat2d by the given angle
664	 *
665	 * @param {mat2d} out the receiving matrix
666	 * @param {mat2d} a the matrix to rotate
667	 * @param {Number} rad the angle to rotate the matrix by
668	 * @returns {mat2d} out
669	 */
670	mat2d.rotate = function (out, a, rad) {
671	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
672	        s = Math.sin(rad),
673	        c = Math.cos(rad);
674	    out[0] = a0 *  c + a2 * s;
675	    out[1] = a1 *  c + a3 * s;
676	    out[2] = a0 * -s + a2 * c;
677	    out[3] = a1 * -s + a3 * c;
678	    out[4] = a4;
679	    out[5] = a5;
680	    return out;
681	};
682
683	/**
684	 * Scales the mat2d by the dimensions in the given vec2
685	 *
686	 * @param {mat2d} out the receiving matrix
687	 * @param {mat2d} a the matrix to translate
688	 * @param {vec2} v the vec2 to scale the matrix by
689	 * @returns {mat2d} out
690	 **/
691	mat2d.scale = function(out, a, v) {
692	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
693	        v0 = v[0], v1 = v[1];
694	    out[0] = a0 * v0;
695	    out[1] = a1 * v0;
696	    out[2] = a2 * v1;
697	    out[3] = a3 * v1;
698	    out[4] = a4;
699	    out[5] = a5;
700	    return out;
701	};
702
703	/**
704	 * Translates the mat2d by the dimensions in the given vec2
705	 *
706	 * @param {mat2d} out the receiving matrix
707	 * @param {mat2d} a the matrix to translate
708	 * @param {vec2} v the vec2 to translate the matrix by
709	 * @returns {mat2d} out
710	 **/
711	mat2d.translate = function(out, a, v) {
712	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3], a4 = a[4], a5 = a[5],
713	        v0 = v[0], v1 = v[1];
714	    out[0] = a0;
715	    out[1] = a1;
716	    out[2] = a2;
717	    out[3] = a3;
718	    out[4] = a0 * v0 + a2 * v1 + a4;
719	    out[5] = a1 * v0 + a3 * v1 + a5;
720	    return out;
721	};
722
723	/**
724	 * Creates a matrix from a given angle
725	 * This is equivalent to (but much faster than):
726	 *
727	 *     mat2d.identity(dest);
728	 *     mat2d.rotate(dest, dest, rad);
729	 *
730	 * @param {mat2d} out mat2d receiving operation result
731	 * @param {Number} rad the angle to rotate the matrix by
732	 * @returns {mat2d} out
733	 */
734	mat2d.fromRotation = function(out, rad) {
735	    var s = Math.sin(rad), c = Math.cos(rad);
736	    out[0] = c;
737	    out[1] = s;
738	    out[2] = -s;
739	    out[3] = c;
740	    out[4] = 0;
741	    out[5] = 0;
742	    return out;
743	}
744
745	/**
746	 * Creates a matrix from a vector scaling
747	 * This is equivalent to (but much faster than):
748	 *
749	 *     mat2d.identity(dest);
750	 *     mat2d.scale(dest, dest, vec);
751	 *
752	 * @param {mat2d} out mat2d receiving operation result
753	 * @param {vec2} v Scaling vector
754	 * @returns {mat2d} out
755	 */
756	mat2d.fromScaling = function(out, v) {
757	    out[0] = v[0];
758	    out[1] = 0;
759	    out[2] = 0;
760	    out[3] = v[1];
761	    out[4] = 0;
762	    out[5] = 0;
763	    return out;
764	}
765
766	/**
767	 * Creates a matrix from a vector translation
768	 * This is equivalent to (but much faster than):
769	 *
770	 *     mat2d.identity(dest);
771	 *     mat2d.translate(dest, dest, vec);
772	 *
773	 * @param {mat2d} out mat2d receiving operation result
774	 * @param {vec2} v Translation vector
775	 * @returns {mat2d} out
776	 */
777	mat2d.fromTranslation = function(out, v) {
778	    out[0] = 1;
779	    out[1] = 0;
780	    out[2] = 0;
781	    out[3] = 1;
782	    out[4] = v[0];
783	    out[5] = v[1];
784	    return out;
785	}
786
787	/**
788	 * Returns a string representation of a mat2d
789	 *
790	 * @param {mat2d} a matrix to represent as a string
791	 * @returns {String} string representation of the matrix
792	 */
793	mat2d.str = function (a) {
794	    return 'mat2d(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +
795	                    a[3] + ', ' + a[4] + ', ' + a[5] + ')';
796	};
797
798	/**
799	 * Returns Frobenius norm of a mat2d
800	 *
801	 * @param {mat2d} a the matrix to calculate Frobenius norm of
802	 * @returns {Number} Frobenius norm
803	 */
804	mat2d.frob = function (a) {
805	    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))
806	};
807
808	module.exports = mat2d;
809
810
811/***/ },
812/* 4 */
813/***/ function(module, exports, __webpack_require__) {
814
815	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
816
817	Permission is hereby granted, free of charge, to any person obtaining a copy
818	of this software and associated documentation files (the "Software"), to deal
819	in the Software without restriction, including without limitation the rights
820	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
821	copies of the Software, and to permit persons to whom the Software is
822	furnished to do so, subject to the following conditions:
823
824	The above copyright notice and this permission notice shall be included in
825	all copies or substantial portions of the Software.
826
827	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
828	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
829	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
830	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
831	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
832	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
833	THE SOFTWARE. */
834
835	var glMatrix = __webpack_require__(1);
836
837	/**
838	 * @class 3x3 Matrix
839	 * @name mat3
840	 */
841	var mat3 = {};
842
843	/**
844	 * Creates a new identity mat3
845	 *
846	 * @returns {mat3} a new 3x3 matrix
847	 */
848	mat3.create = function() {
849	    var out = new glMatrix.ARRAY_TYPE(9);
850	    out[0] = 1;
851	    out[1] = 0;
852	    out[2] = 0;
853	    out[3] = 0;
854	    out[4] = 1;
855	    out[5] = 0;
856	    out[6] = 0;
857	    out[7] = 0;
858	    out[8] = 1;
859	    return out;
860	};
861
862	/**
863	 * Copies the upper-left 3x3 values into the given mat3.
864	 *
865	 * @param {mat3} out the receiving 3x3 matrix
866	 * @param {mat4} a   the source 4x4 matrix
867	 * @returns {mat3} out
868	 */
869	mat3.fromMat4 = function(out, a) {
870	    out[0] = a[0];
871	    out[1] = a[1];
872	    out[2] = a[2];
873	    out[3] = a[4];
874	    out[4] = a[5];
875	    out[5] = a[6];
876	    out[6] = a[8];
877	    out[7] = a[9];
878	    out[8] = a[10];
879	    return out;
880	};
881
882	/**
883	 * Creates a new mat3 initialized with values from an existing matrix
884	 *
885	 * @param {mat3} a matrix to clone
886	 * @returns {mat3} a new 3x3 matrix
887	 */
888	mat3.clone = function(a) {
889	    var out = new glMatrix.ARRAY_TYPE(9);
890	    out[0] = a[0];
891	    out[1] = a[1];
892	    out[2] = a[2];
893	    out[3] = a[3];
894	    out[4] = a[4];
895	    out[5] = a[5];
896	    out[6] = a[6];
897	    out[7] = a[7];
898	    out[8] = a[8];
899	    return out;
900	};
901
902	/**
903	 * Copy the values from one mat3 to another
904	 *
905	 * @param {mat3} out the receiving matrix
906	 * @param {mat3} a the source matrix
907	 * @returns {mat3} out
908	 */
909	mat3.copy = function(out, a) {
910	    out[0] = a[0];
911	    out[1] = a[1];
912	    out[2] = a[2];
913	    out[3] = a[3];
914	    out[4] = a[4];
915	    out[5] = a[5];
916	    out[6] = a[6];
917	    out[7] = a[7];
918	    out[8] = a[8];
919	    return out;
920	};
921
922	/**
923	 * Set a mat3 to the identity matrix
924	 *
925	 * @param {mat3} out the receiving matrix
926	 * @returns {mat3} out
927	 */
928	mat3.identity = function(out) {
929	    out[0] = 1;
930	    out[1] = 0;
931	    out[2] = 0;
932	    out[3] = 0;
933	    out[4] = 1;
934	    out[5] = 0;
935	    out[6] = 0;
936	    out[7] = 0;
937	    out[8] = 1;
938	    return out;
939	};
940
941	/**
942	 * Transpose the values of a mat3
943	 *
944	 * @param {mat3} out the receiving matrix
945	 * @param {mat3} a the source matrix
946	 * @returns {mat3} out
947	 */
948	mat3.transpose = function(out, a) {
949	    // If we are transposing ourselves we can skip a few steps but have to cache some values
950	    if (out === a) {
951	        var a01 = a[1], a02 = a[2], a12 = a[5];
952	        out[1] = a[3];
953	        out[2] = a[6];
954	        out[3] = a01;
955	        out[5] = a[7];
956	        out[6] = a02;
957	        out[7] = a12;
958	    } else {
959	        out[0] = a[0];
960	        out[1] = a[3];
961	        out[2] = a[6];
962	        out[3] = a[1];
963	        out[4] = a[4];
964	        out[5] = a[7];
965	        out[6] = a[2];
966	        out[7] = a[5];
967	        out[8] = a[8];
968	    }
969
970	    return out;
971	};
972
973	/**
974	 * Inverts a mat3
975	 *
976	 * @param {mat3} out the receiving matrix
977	 * @param {mat3} a the source matrix
978	 * @returns {mat3} out
979	 */
980	mat3.invert = function(out, a) {
981	    var a00 = a[0], a01 = a[1], a02 = a[2],
982	        a10 = a[3], a11 = a[4], a12 = a[5],
983	        a20 = a[6], a21 = a[7], a22 = a[8],
984
985	        b01 = a22 * a11 - a12 * a21,
986	        b11 = -a22 * a10 + a12 * a20,
987	        b21 = a21 * a10 - a11 * a20,
988
989	        // Calculate the determinant
990	        det = a00 * b01 + a01 * b11 + a02 * b21;
991
992	    if (!det) {
993	        return null;
994	    }
995	    det = 1.0 / det;
996
997	    out[0] = b01 * det;
998	    out[1] = (-a22 * a01 + a02 * a21) * det;
999	    out[2] = (a12 * a01 - a02 * a11) * det;
1000	    out[3] = b11 * det;
1001	    out[4] = (a22 * a00 - a02 * a20) * det;
1002	    out[5] = (-a12 * a00 + a02 * a10) * det;
1003	    out[6] = b21 * det;
1004	    out[7] = (-a21 * a00 + a01 * a20) * det;
1005	    out[8] = (a11 * a00 - a01 * a10) * det;
1006	    return out;
1007	};
1008
1009	/**
1010	 * Calculates the adjugate of a mat3
1011	 *
1012	 * @param {mat3} out the receiving matrix
1013	 * @param {mat3} a the source matrix
1014	 * @returns {mat3} out
1015	 */
1016	mat3.adjoint = function(out, a) {
1017	    var a00 = a[0], a01 = a[1], a02 = a[2],
1018	        a10 = a[3], a11 = a[4], a12 = a[5],
1019	        a20 = a[6], a21 = a[7], a22 = a[8];
1020
1021	    out[0] = (a11 * a22 - a12 * a21);
1022	    out[1] = (a02 * a21 - a01 * a22);
1023	    out[2] = (a01 * a12 - a02 * a11);
1024	    out[3] = (a12 * a20 - a10 * a22);
1025	    out[4] = (a00 * a22 - a02 * a20);
1026	    out[5] = (a02 * a10 - a00 * a12);
1027	    out[6] = (a10 * a21 - a11 * a20);
1028	    out[7] = (a01 * a20 - a00 * a21);
1029	    out[8] = (a00 * a11 - a01 * a10);
1030	    return out;
1031	};
1032
1033	/**
1034	 * Calculates the determinant of a mat3
1035	 *
1036	 * @param {mat3} a the source matrix
1037	 * @returns {Number} determinant of a
1038	 */
1039	mat3.determinant = function (a) {
1040	    var a00 = a[0], a01 = a[1], a02 = a[2],
1041	        a10 = a[3], a11 = a[4], a12 = a[5],
1042	        a20 = a[6], a21 = a[7], a22 = a[8];
1043
1044	    return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
1045	};
1046
1047	/**
1048	 * Multiplies two mat3's
1049	 *
1050	 * @param {mat3} out the receiving matrix
1051	 * @param {mat3} a the first operand
1052	 * @param {mat3} b the second operand
1053	 * @returns {mat3} out
1054	 */
1055	mat3.multiply = function (out, a, b) {
1056	    var a00 = a[0], a01 = a[1], a02 = a[2],
1057	        a10 = a[3], a11 = a[4], a12 = a[5],
1058	        a20 = a[6], a21 = a[7], a22 = a[8],
1059
1060	        b00 = b[0], b01 = b[1], b02 = b[2],
1061	        b10 = b[3], b11 = b[4], b12 = b[5],
1062	        b20 = b[6], b21 = b[7], b22 = b[8];
1063
1064	    out[0] = b00 * a00 + b01 * a10 + b02 * a20;
1065	    out[1] = b00 * a01 + b01 * a11 + b02 * a21;
1066	    out[2] = b00 * a02 + b01 * a12 + b02 * a22;
1067
1068	    out[3] = b10 * a00 + b11 * a10 + b12 * a20;
1069	    out[4] = b10 * a01 + b11 * a11 + b12 * a21;
1070	    out[5] = b10 * a02 + b11 * a12 + b12 * a22;
1071
1072	    out[6] = b20 * a00 + b21 * a10 + b22 * a20;
1073	    out[7] = b20 * a01 + b21 * a11 + b22 * a21;
1074	    out[8] = b20 * a02 + b21 * a12 + b22 * a22;
1075	    return out;
1076	};
1077
1078	/**
1079	 * Alias for {@link mat3.multiply}
1080	 * @function
1081	 */
1082	mat3.mul = mat3.multiply;
1083
1084	/**
1085	 * Translate a mat3 by the given vector
1086	 *
1087	 * @param {mat3} out the receiving matrix
1088	 * @param {mat3} a the matrix to translate
1089	 * @param {vec2} v vector to translate by
1090	 * @returns {mat3} out
1091	 */
1092	mat3.translate = function(out, a, v) {
1093	    var a00 = a[0], a01 = a[1], a02 = a[2],
1094	        a10 = a[3], a11 = a[4], a12 = a[5],
1095	        a20 = a[6], a21 = a[7], a22 = a[8],
1096	        x = v[0], y = v[1];
1097
1098	    out[0] = a00;
1099	    out[1] = a01;
1100	    out[2] = a02;
1101
1102	    out[3] = a10;
1103	    out[4] = a11;
1104	    out[5] = a12;
1105
1106	    out[6] = x * a00 + y * a10 + a20;
1107	    out[7] = x * a01 + y * a11 + a21;
1108	    out[8] = x * a02 + y * a12 + a22;
1109	    return out;
1110	};
1111
1112	/**
1113	 * Rotates a mat3 by the given angle
1114	 *
1115	 * @param {mat3} out the receiving matrix
1116	 * @param {mat3} a the matrix to rotate
1117	 * @param {Number} rad the angle to rotate the matrix by
1118	 * @returns {mat3} out
1119	 */
1120	mat3.rotate = function (out, a, rad) {
1121	    var a00 = a[0], a01 = a[1], a02 = a[2],
1122	        a10 = a[3], a11 = a[4], a12 = a[5],
1123	        a20 = a[6], a21 = a[7], a22 = a[8],
1124
1125	        s = Math.sin(rad),
1126	        c = Math.cos(rad);
1127
1128	    out[0] = c * a00 + s * a10;
1129	    out[1] = c * a01 + s * a11;
1130	    out[2] = c * a02 + s * a12;
1131
1132	    out[3] = c * a10 - s * a00;
1133	    out[4] = c * a11 - s * a01;
1134	    out[5] = c * a12 - s * a02;
1135
1136	    out[6] = a20;
1137	    out[7] = a21;
1138	    out[8] = a22;
1139	    return out;
1140	};
1141
1142	/**
1143	 * Scales the mat3 by the dimensions in the given vec2
1144	 *
1145	 * @param {mat3} out the receiving matrix
1146	 * @param {mat3} a the matrix to rotate
1147	 * @param {vec2} v the vec2 to scale the matrix by
1148	 * @returns {mat3} out
1149	 **/
1150	mat3.scale = function(out, a, v) {
1151	    var x = v[0], y = v[1];
1152
1153	    out[0] = x * a[0];
1154	    out[1] = x * a[1];
1155	    out[2] = x * a[2];
1156
1157	    out[3] = y * a[3];
1158	    out[4] = y * a[4];
1159	    out[5] = y * a[5];
1160
1161	    out[6] = a[6];
1162	    out[7] = a[7];
1163	    out[8] = a[8];
1164	    return out;
1165	};
1166
1167	/**
1168	 * Creates a matrix from a vector translation
1169	 * This is equivalent to (but much faster than):
1170	 *
1171	 *     mat3.identity(dest);
1172	 *     mat3.translate(dest, dest, vec);
1173	 *
1174	 * @param {mat3} out mat3 receiving operation result
1175	 * @param {vec2} v Translation vector
1176	 * @returns {mat3} out
1177	 */
1178	mat3.fromTranslation = function(out, v) {
1179	    out[0] = 1;
1180	    out[1] = 0;
1181	    out[2] = 0;
1182	    out[3] = 0;
1183	    out[4] = 1;
1184	    out[5] = 0;
1185	    out[6] = v[0];
1186	    out[7] = v[1];
1187	    out[8] = 1;
1188	    return out;
1189	}
1190
1191	/**
1192	 * Creates a matrix from a given angle
1193	 * This is equivalent to (but much faster than):
1194	 *
1195	 *     mat3.identity(dest);
1196	 *     mat3.rotate(dest, dest, rad);
1197	 *
1198	 * @param {mat3} out mat3 receiving operation result
1199	 * @param {Number} rad the angle to rotate the matrix by
1200	 * @returns {mat3} out
1201	 */
1202	mat3.fromRotation = function(out, rad) {
1203	    var s = Math.sin(rad), c = Math.cos(rad);
1204
1205	    out[0] = c;
1206	    out[1] = s;
1207	    out[2] = 0;
1208
1209	    out[3] = -s;
1210	    out[4] = c;
1211	    out[5] = 0;
1212
1213	    out[6] = 0;
1214	    out[7] = 0;
1215	    out[8] = 1;
1216	    return out;
1217	}
1218
1219	/**
1220	 * Creates a matrix from a vector scaling
1221	 * This is equivalent to (but much faster than):
1222	 *
1223	 *     mat3.identity(dest);
1224	 *     mat3.scale(dest, dest, vec);
1225	 *
1226	 * @param {mat3} out mat3 receiving operation result
1227	 * @param {vec2} v Scaling vector
1228	 * @returns {mat3} out
1229	 */
1230	mat3.fromScaling = function(out, v) {
1231	    out[0] = v[0];
1232	    out[1] = 0;
1233	    out[2] = 0;
1234
1235	    out[3] = 0;
1236	    out[4] = v[1];
1237	    out[5] = 0;
1238
1239	    out[6] = 0;
1240	    out[7] = 0;
1241	    out[8] = 1;
1242	    return out;
1243	}
1244
1245	/**
1246	 * Copies the values from a mat2d into a mat3
1247	 *
1248	 * @param {mat3} out the receiving matrix
1249	 * @param {mat2d} a the matrix to copy
1250	 * @returns {mat3} out
1251	 **/
1252	mat3.fromMat2d = function(out, a) {
1253	    out[0] = a[0];
1254	    out[1] = a[1];
1255	    out[2] = 0;
1256
1257	    out[3] = a[2];
1258	    out[4] = a[3];
1259	    out[5] = 0;
1260
1261	    out[6] = a[4];
1262	    out[7] = a[5];
1263	    out[8] = 1;
1264	    return out;
1265	};
1266
1267	/**
1268	* Calculates a 3x3 matrix from the given quaternion
1269	*
1270	* @param {mat3} out mat3 receiving operation result
1271	* @param {quat} q Quaternion to create matrix from
1272	*
1273	* @returns {mat3} out
1274	*/
1275	mat3.fromQuat = function (out, q) {
1276	    var x = q[0], y = q[1], z = q[2], w = q[3],
1277	        x2 = x + x,
1278	        y2 = y + y,
1279	        z2 = z + z,
1280
1281	        xx = x * x2,
1282	        yx = y * x2,
1283	        yy = y * y2,
1284	        zx = z * x2,
1285	        zy = z * y2,
1286	        zz = z * z2,
1287	        wx = w * x2,
1288	        wy = w * y2,
1289	        wz = w * z2;
1290
1291	    out[0] = 1 - yy - zz;
1292	    out[3] = yx - wz;
1293	    out[6] = zx + wy;
1294
1295	    out[1] = yx + wz;
1296	    out[4] = 1 - xx - zz;
1297	    out[7] = zy - wx;
1298
1299	    out[2] = zx - wy;
1300	    out[5] = zy + wx;
1301	    out[8] = 1 - xx - yy;
1302
1303	    return out;
1304	};
1305
1306	/**
1307	* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
1308	*
1309	* @param {mat3} out mat3 receiving operation result
1310	* @param {mat4} a Mat4 to derive the normal matrix from
1311	*
1312	* @returns {mat3} out
1313	*/
1314	mat3.normalFromMat4 = function (out, a) {
1315	    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
1316	        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
1317	        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
1318	        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
1319
1320	        b00 = a00 * a11 - a01 * a10,
1321	        b01 = a00 * a12 - a02 * a10,
1322	        b02 = a00 * a13 - a03 * a10,
1323	        b03 = a01 * a12 - a02 * a11,
1324	        b04 = a01 * a13 - a03 * a11,
1325	        b05 = a02 * a13 - a03 * a12,
1326	        b06 = a20 * a31 - a21 * a30,
1327	        b07 = a20 * a32 - a22 * a30,
1328	        b08 = a20 * a33 - a23 * a30,
1329	        b09 = a21 * a32 - a22 * a31,
1330	        b10 = a21 * a33 - a23 * a31,
1331	        b11 = a22 * a33 - a23 * a32,
1332
1333	        // Calculate the determinant
1334	        det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1335
1336	    if (!det) {
1337	        return null;
1338	    }
1339	    det = 1.0 / det;
1340
1341	    out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
1342	    out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
1343	    out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
1344
1345	    out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
1346	    out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
1347	    out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
1348
1349	    out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
1350	    out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
1351	    out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
1352
1353	    return out;
1354	};
1355
1356	/**
1357	 * Returns a string representation of a mat3
1358	 *
1359	 * @param {mat3} mat matrix to represent as a string
1360	 * @returns {String} string representation of the matrix
1361	 */
1362	mat3.str = function (a) {
1363	    return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' +
1364	                    a[3] + ', ' + a[4] + ', ' + a[5] + ', ' +
1365	                    a[6] + ', ' + a[7] + ', ' + a[8] + ')';
1366	};
1367
1368	/**
1369	 * Returns Frobenius norm of a mat3
1370	 *
1371	 * @param {mat3} a the matrix to calculate Frobenius norm of
1372	 * @returns {Number} Frobenius norm
1373	 */
1374	mat3.frob = function (a) {
1375	    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)))
1376	};
1377
1378
1379	module.exports = mat3;
1380
1381
1382/***/ },
1383/* 5 */
1384/***/ function(module, exports, __webpack_require__) {
1385
1386	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
1387
1388	Permission is hereby granted, free of charge, to any person obtaining a copy
1389	of this software and associated documentation files (the "Software"), to deal
1390	in the Software without restriction, including without limitation the rights
1391	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1392	copies of the Software, and to permit persons to whom the Software is
1393	furnished to do so, subject to the following conditions:
1394
1395	The above copyright notice and this permission notice shall be included in
1396	all copies or substantial portions of the Software.
1397
1398	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1399	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1400	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1401	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1402	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1403	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1404	THE SOFTWARE. */
1405
1406	var glMatrix = __webpack_require__(1);
1407
1408	/**
1409	 * @class 4x4 Matrix
1410	 * @name mat4
1411	 */
1412	var mat4 = {};
1413
1414	/**
1415	 * Creates a new identity mat4
1416	 *
1417	 * @returns {mat4} a new 4x4 matrix
1418	 */
1419	mat4.create = function() {
1420	    var out = new glMatrix.ARRAY_TYPE(16);
1421	    out[0] = 1;
1422	    out[1] = 0;
1423	    out[2] = 0;
1424	    out[3] = 0;
1425	    out[4] = 0;
1426	    out[5] = 1;
1427	    out[6] = 0;
1428	    out[7] = 0;
1429	    out[8] = 0;
1430	    out[9] = 0;
1431	    out[10] = 1;
1432	    out[11] = 0;
1433	    out[12] = 0;
1434	    out[13] = 0;
1435	    out[14] = 0;
1436	    out[15] = 1;
1437	    return out;
1438	};
1439
1440	/**
1441	 * Creates a new mat4 initialized with values from an existing matrix
1442	 *
1443	 * @param {mat4} a matrix to clone
1444	 * @returns {mat4} a new 4x4 matrix
1445	 */
1446	mat4.clone = function(a) {
1447	    var out = new glMatrix.ARRAY_TYPE(16);
1448	    out[0] = a[0];
1449	    out[1] = a[1];
1450	    out[2] = a[2];
1451	    out[3] = a[3];
1452	    out[4] = a[4];
1453	    out[5] = a[5];
1454	    out[6] = a[6];
1455	    out[7] = a[7];
1456	    out[8] = a[8];
1457	    out[9] = a[9];
1458	    out[10] = a[10];
1459	    out[11] = a[11];
1460	    out[12] = a[12];
1461	    out[13] = a[13];
1462	    out[14] = a[14];
1463	    out[15] = a[15];
1464	    return out;
1465	};
1466
1467	/**
1468	 * Copy the values from one mat4 to another
1469	 *
1470	 * @param {mat4} out the receiving matrix
1471	 * @param {mat4} a the source matrix
1472	 * @returns {mat4} out
1473	 */
1474	mat4.copy = function(out, a) {
1475	    out[0] = a[0];
1476	    out[1] = a[1];
1477	    out[2] = a[2];
1478	    out[3] = a[3];
1479	    out[4] = a[4];
1480	    out[5] = a[5];
1481	    out[6] = a[6];
1482	    out[7] = a[7];
1483	    out[8] = a[8];
1484	    out[9] = a[9];
1485	    out[10] = a[10];
1486	    out[11] = a[11];
1487	    out[12] = a[12];
1488	    out[13] = a[13];
1489	    out[14] = a[14];
1490	    out[15] = a[15];
1491	    return out;
1492	};
1493
1494	/**
1495	 * Set a mat4 to the identity matrix
1496	 *
1497	 * @param {mat4} out the receiving matrix
1498	 * @returns {mat4} out
1499	 */
1500	mat4.identity = function(out) {
1501	    out[0] = 1;
1502	    out[1] = 0;
1503	    out[2] = 0;
1504	    out[3] = 0;
1505	    out[4] = 0;
1506	    out[5] = 1;
1507	    out[6] = 0;
1508	    out[7] = 0;
1509	    out[8] = 0;
1510	    out[9] = 0;
1511	    out[10] = 1;
1512	    out[11] = 0;
1513	    out[12] = 0;
1514	    out[13] = 0;
1515	    out[14] = 0;
1516	    out[15] = 1;
1517	    return out;
1518	};
1519
1520	/**
1521	 * Transpose the values of a mat4
1522	 *
1523	 * @param {mat4} out the receiving matrix
1524	 * @param {mat4} a the source matrix
1525	 * @returns {mat4} out
1526	 */
1527	mat4.transpose = function(out, a) {
1528	    // If we are transposing ourselves we can skip a few steps but have to cache some values
1529	    if (out === a) {
1530	        var a01 = a[1], a02 = a[2], a03 = a[3],
1531	            a12 = a[6], a13 = a[7],
1532	            a23 = a[11];
1533
1534	        out[1] = a[4];
1535	        out[2] = a[8];
1536	        out[3] = a[12];
1537	        out[4] = a01;
1538	        out[6] = a[9];
1539	        out[7] = a[13];
1540	        out[8] = a02;
1541	        out[9] = a12;
1542	        out[11] = a[14];
1543	        out[12] = a03;
1544	        out[13] = a13;
1545	        out[14] = a23;
1546	    } else {
1547	        out[0] = a[0];
1548	        out[1] = a[4];
1549	        out[2] = a[8];
1550	        out[3] = a[12];
1551	        out[4] = a[1];
1552	        out[5] = a[5];
1553	        out[6] = a[9];
1554	        out[7] = a[13];
1555	        out[8] = a[2];
1556	        out[9] = a[6];
1557	        out[10] = a[10];
1558	        out[11] = a[14];
1559	        out[12] = a[3];
1560	        out[13] = a[7];
1561	        out[14] = a[11];
1562	        out[15] = a[15];
1563	    }
1564
1565	    return out;
1566	};
1567
1568	/**
1569	 * Inverts a mat4
1570	 *
1571	 * @param {mat4} out the receiving matrix
1572	 * @param {mat4} a the source matrix
1573	 * @returns {mat4} out
1574	 */
1575	mat4.invert = function(out, a) {
1576	    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
1577	        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
1578	        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
1579	        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
1580
1581	        b00 = a00 * a11 - a01 * a10,
1582	        b01 = a00 * a12 - a02 * a10,
1583	        b02 = a00 * a13 - a03 * a10,
1584	        b03 = a01 * a12 - a02 * a11,
1585	        b04 = a01 * a13 - a03 * a11,
1586	        b05 = a02 * a13 - a03 * a12,
1587	        b06 = a20 * a31 - a21 * a30,
1588	        b07 = a20 * a32 - a22 * a30,
1589	        b08 = a20 * a33 - a23 * a30,
1590	        b09 = a21 * a32 - a22 * a31,
1591	        b10 = a21 * a33 - a23 * a31,
1592	        b11 = a22 * a33 - a23 * a32,
1593
1594	        // Calculate the determinant
1595	        det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1596
1597	    if (!det) {
1598	        return null;
1599	    }
1600	    det = 1.0 / det;
1601
1602	    out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
1603	    out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
1604	    out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
1605	    out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
1606	    out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
1607	    out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
1608	    out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
1609	    out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
1610	    out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
1611	    out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
1612	    out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
1613	    out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
1614	    out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
1615	    out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
1616	    out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
1617	    out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
1618
1619	    return out;
1620	};
1621
1622	/**
1623	 * Calculates the adjugate of a mat4
1624	 *
1625	 * @param {mat4} out the receiving matrix
1626	 * @param {mat4} a the source matrix
1627	 * @returns {mat4} out
1628	 */
1629	mat4.adjoint = function(out, a) {
1630	    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
1631	        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
1632	        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
1633	        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
1634
1635	    out[0]  =  (a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22));
1636	    out[1]  = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));
1637	    out[2]  =  (a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12));
1638	    out[3]  = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));
1639	    out[4]  = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));
1640	    out[5]  =  (a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22));
1641	    out[6]  = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));
1642	    out[7]  =  (a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12));
1643	    out[8]  =  (a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21));
1644	    out[9]  = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));
1645	    out[10] =  (a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11));
1646	    out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));
1647	    out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));
1648	    out[13] =  (a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21));
1649	    out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));
1650	    out[15] =  (a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11));
1651	    return out;
1652	};
1653
1654	/**
1655	 * Calculates the determinant of a mat4
1656	 *
1657	 * @param {mat4} a the source matrix
1658	 * @returns {Number} determinant of a
1659	 */
1660	mat4.determinant = function (a) {
1661	    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
1662	        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
1663	        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
1664	        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15],
1665
1666	        b00 = a00 * a11 - a01 * a10,
1667	        b01 = a00 * a12 - a02 * a10,
1668	        b02 = a00 * a13 - a03 * a10,
1669	        b03 = a01 * a12 - a02 * a11,
1670	        b04 = a01 * a13 - a03 * a11,
1671	        b05 = a02 * a13 - a03 * a12,
1672	        b06 = a20 * a31 - a21 * a30,
1673	        b07 = a20 * a32 - a22 * a30,
1674	        b08 = a20 * a33 - a23 * a30,
1675	        b09 = a21 * a32 - a22 * a31,
1676	        b10 = a21 * a33 - a23 * a31,
1677	        b11 = a22 * a33 - a23 * a32;
1678
1679	    // Calculate the determinant
1680	    return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
1681	};
1682
1683	/**
1684	 * Multiplies two mat4's
1685	 *
1686	 * @param {mat4} out the receiving matrix
1687	 * @param {mat4} a the first operand
1688	 * @param {mat4} b the second operand
1689	 * @returns {mat4} out
1690	 */
1691	mat4.multiply = function (out, a, b) {
1692	    var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3],
1693	        a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7],
1694	        a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11],
1695	        a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15];
1696
1697	    // Cache only the current line of the second matrix
1698	    var b0  = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
1699	    out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
1700	    out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
1701	    out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
1702	    out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
1703
1704	    b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7];
1705	    out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
1706	    out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
1707	    out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
1708	    out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
1709
1710	    b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11];
1711	    out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
1712	    out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
1713	    out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
1714	    out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
1715
1716	    b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15];
1717	    out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30;
1718	    out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31;
1719	    out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32;
1720	    out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33;
1721	    return out;
1722	};
1723
1724	/**
1725	 * Alias for {@link mat4.multiply}
1726	 * @function
1727	 */
1728	mat4.mul = mat4.multiply;
1729
1730	/**
1731	 * Translate a mat4 by the given vector
1732	 *
1733	 * @param {mat4} out the receiving matrix
1734	 * @param {mat4} a the matrix to translate
1735	 * @param {vec3} v vector to translate by
1736	 * @returns {mat4} out
1737	 */
1738	mat4.translate = function (out, a, v) {
1739	    var x = v[0], y = v[1], z = v[2],
1740	        a00, a01, a02, a03,
1741	        a10, a11, a12, a13,
1742	        a20, a21, a22, a23;
1743
1744	    if (a === out) {
1745	        out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
1746	        out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
1747	        out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
1748	        out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
1749	    } else {
1750	        a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];
1751	        a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];
1752	        a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];
1753
1754	        out[0] = a00; out[1] = a01; out[2] = a02; out[3] = a03;
1755	        out[4] = a10; out[5] = a11; out[6] = a12; out[7] = a13;
1756	        out[8] = a20; out[9] = a21; out[10] = a22; out[11] = a23;
1757
1758	        out[12] = a00 * x + a10 * y + a20 * z + a[12];
1759	        out[13] = a01 * x + a11 * y + a21 * z + a[13];
1760	        out[14] = a02 * x + a12 * y + a22 * z + a[14];
1761	        out[15] = a03 * x + a13 * y + a23 * z + a[15];
1762	    }
1763
1764	    return out;
1765	};
1766
1767	/**
1768	 * Scales the mat4 by the dimensions in the given vec3
1769	 *
1770	 * @param {mat4} out the receiving matrix
1771	 * @param {mat4} a the matrix to scale
1772	 * @param {vec3} v the vec3 to scale the matrix by
1773	 * @returns {mat4} out
1774	 **/
1775	mat4.scale = function(out, a, v) {
1776	    var x = v[0], y = v[1], z = v[2];
1777
1778	    out[0] = a[0] * x;
1779	    out[1] = a[1] * x;
1780	    out[2] = a[2] * x;
1781	    out[3] = a[3] * x;
1782	    out[4] = a[4] * y;
1783	    out[5] = a[5] * y;
1784	    out[6] = a[6] * y;
1785	    out[7] = a[7] * y;
1786	    out[8] = a[8] * z;
1787	    out[9] = a[9] * z;
1788	    out[10] = a[10] * z;
1789	    out[11] = a[11] * z;
1790	    out[12] = a[12];
1791	    out[13] = a[13];
1792	    out[14] = a[14];
1793	    out[15] = a[15];
1794	    return out;
1795	};
1796
1797	/**
1798	 * Rotates a mat4 by the given angle around the given axis
1799	 *
1800	 * @param {mat4} out the receiving matrix
1801	 * @param {mat4} a the matrix to rotate
1802	 * @param {Number} rad the angle to rotate the matrix by
1803	 * @param {vec3} axis the axis to rotate around
1804	 * @returns {mat4} out
1805	 */
1806	mat4.rotate = function (out, a, rad, axis) {
1807	    var x = axis[0], y = axis[1], z = axis[2],
1808	        len = Math.sqrt(x * x + y * y + z * z),
1809	        s, c, t,
1810	        a00, a01, a02, a03,
1811	        a10, a11, a12, a13,
1812	        a20, a21, a22, a23,
1813	        b00, b01, b02,
1814	        b10, b11, b12,
1815	        b20, b21, b22;
1816
1817	    if (Math.abs(len) < glMatrix.EPSILON) { return null; }
1818
1819	    len = 1 / len;
1820	    x *= len;
1821	    y *= len;
1822	    z *= len;
1823
1824	    s = Math.sin(rad);
1825	    c = Math.cos(rad);
1826	    t = 1 - c;
1827
1828	    a00 = a[0]; a01 = a[1]; a02 = a[2]; a03 = a[3];
1829	    a10 = a[4]; a11 = a[5]; a12 = a[6]; a13 = a[7];
1830	    a20 = a[8]; a21 = a[9]; a22 = a[10]; a23 = a[11];
1831
1832	    // Construct the elements of the rotation matrix
1833	    b00 = x * x * t + c; b01 = y * x * t + z * s; b02 = z * x * t - y * s;
1834	    b10 = x * y * t - z * s; b11 = y * y * t + c; b12 = z * y * t + x * s;
1835	    b20 = x * z * t + y * s; b21 = y * z * t - x * s; b22 = z * z * t + c;
1836
1837	    // Perform rotation-specific matrix multiplication
1838	    out[0] = a00 * b00 + a10 * b01 + a20 * b02;
1839	    out[1] = a01 * b00 + a11 * b01 + a21 * b02;
1840	    out[2] = a02 * b00 + a12 * b01 + a22 * b02;
1841	    out[3] = a03 * b00 + a13 * b01 + a23 * b02;
1842	    out[4] = a00 * b10 + a10 * b11 + a20 * b12;
1843	    out[5] = a01 * b10 + a11 * b11 + a21 * b12;
1844	    out[6] = a02 * b10 + a12 * b11 + a22 * b12;
1845	    out[7] = a03 * b10 + a13 * b11 + a23 * b12;
1846	    out[8] = a00 * b20 + a10 * b21 + a20 * b22;
1847	    out[9] = a01 * b20 + a11 * b21 + a21 * b22;
1848	    out[10] = a02 * b20 + a12 * b21 + a22 * b22;
1849	    out[11] = a03 * b20 + a13 * b21 + a23 * b22;
1850
1851	    if (a !== out) { // If the source and destination differ, copy the unchanged last row
1852	        out[12] = a[12];
1853	        out[13] = a[13];
1854	        out[14] = a[14];
1855	        out[15] = a[15];
1856	    }
1857	    return out;
1858	};
1859
1860	/**
1861	 * Rotates a matrix by the given angle around the X axis
1862	 *
1863	 * @param {mat4} out the receiving matrix
1864	 * @param {mat4} a the matrix to rotate
1865	 * @param {Number} rad the angle to rotate the matrix by
1866	 * @returns {mat4} out
1867	 */
1868	mat4.rotateX = function (out, a, rad) {
1869	    var s = Math.sin(rad),
1870	        c = Math.cos(rad),
1871	        a10 = a[4],
1872	        a11 = a[5],
1873	        a12 = a[6],
1874	        a13 = a[7],
1875	        a20 = a[8],
1876	        a21 = a[9],
1877	        a22 = a[10],
1878	        a23 = a[11];
1879
1880	    if (a !== out) { // If the source and destination differ, copy the unchanged rows
1881	        out[0]  = a[0];
1882	        out[1]  = a[1];
1883	        out[2]  = a[2];
1884	        out[3]  = a[3];
1885	        out[12] = a[12];
1886	        out[13] = a[13];
1887	        out[14] = a[14];
1888	        out[15] = a[15];
1889	    }
1890
1891	    // Perform axis-specific matrix multiplication
1892	    out[4] = a10 * c + a20 * s;
1893	    out[5] = a11 * c + a21 * s;
1894	    out[6] = a12 * c + a22 * s;
1895	    out[7] = a13 * c + a23 * s;
1896	    out[8] = a20 * c - a10 * s;
1897	    out[9] = a21 * c - a11 * s;
1898	    out[10] = a22 * c - a12 * s;
1899	    out[11] = a23 * c - a13 * s;
1900	    return out;
1901	};
1902
1903	/**
1904	 * Rotates a matrix by the given angle around the Y axis
1905	 *
1906	 * @param {mat4} out the receiving matrix
1907	 * @param {mat4} a the matrix to rotate
1908	 * @param {Number} rad the angle to rotate the matrix by
1909	 * @returns {mat4} out
1910	 */
1911	mat4.rotateY = function (out, a, rad) {
1912	    var s = Math.sin(rad),
1913	        c = Math.cos(rad),
1914	        a00 = a[0],
1915	        a01 = a[1],
1916	        a02 = a[2],
1917	        a03 = a[3],
1918	        a20 = a[8],
1919	        a21 = a[9],
1920	        a22 = a[10],
1921	        a23 = a[11];
1922
1923	    if (a !== out) { // If the source and destination differ, copy the unchanged rows
1924	        out[4]  = a[4];
1925	        out[5]  = a[5];
1926	        out[6]  = a[6];
1927	        out[7]  = a[7];
1928	        out[12] = a[12];
1929	        out[13] = a[13];
1930	        out[14] = a[14];
1931	        out[15] = a[15];
1932	    }
1933
1934	    // Perform axis-specific matrix multiplication
1935	    out[0] = a00 * c - a20 * s;
1936	    out[1] = a01 * c - a21 * s;
1937	    out[2] = a02 * c - a22 * s;
1938	    out[3] = a03 * c - a23 * s;
1939	    out[8] = a00 * s + a20 * c;
1940	    out[9] = a01 * s + a21 * c;
1941	    out[10] = a02 * s + a22 * c;
1942	    out[11] = a03 * s + a23 * c;
1943	    return out;
1944	};
1945
1946	/**
1947	 * Rotates a matrix by the given angle around the Z axis
1948	 *
1949	 * @param {mat4} out the receiving matrix
1950	 * @param {mat4} a the matrix to rotate
1951	 * @param {Number} rad the angle to rotate the matrix by
1952	 * @returns {mat4} out
1953	 */
1954	mat4.rotateZ = function (out, a, rad) {
1955	    var s = Math.sin(rad),
1956	        c = Math.cos(rad),
1957	        a00 = a[0],
1958	        a01 = a[1],
1959	        a02 = a[2],
1960	        a03 = a[3],
1961	        a10 = a[4],
1962	        a11 = a[5],
1963	        a12 = a[6],
1964	        a13 = a[7];
1965
1966	    if (a !== out) { // If the source and destination differ, copy the unchanged last row
1967	        out[8]  = a[8];
1968	        out[9]  = a[9];
1969	        out[10] = a[10];
1970	        out[11] = a[11];
1971	        out[12] = a[12];
1972	        out[13] = a[13];
1973	        out[14] = a[14];
1974	        out[15] = a[15];
1975	    }
1976
1977	    // Perform axis-specific matrix multiplication
1978	    out[0] = a00 * c + a10 * s;
1979	    out[1] = a01 * c + a11 * s;
1980	    out[2] = a02 * c + a12 * s;
1981	    out[3] = a03 * c + a13 * s;
1982	    out[4] = a10 * c - a00 * s;
1983	    out[5] = a11 * c - a01 * s;
1984	    out[6] = a12 * c - a02 * s;
1985	    out[7] = a13 * c - a03 * s;
1986	    return out;
1987	};
1988
1989	/**
1990	 * Creates a matrix from a vector translation
1991	 * This is equivalent to (but much faster than):
1992	 *
1993	 *     mat4.identity(dest);
1994	 *     mat4.translate(dest, dest, vec);
1995	 *
1996	 * @param {mat4} out mat4 receiving operation result
1997	 * @param {vec3} v Translation vector
1998	 * @returns {mat4} out
1999	 */
2000	mat4.fromTranslation = function(out, v) {
2001	    out[0] = 1;
2002	    out[1] = 0;
2003	    out[2] = 0;
2004	    out[3] = 0;
2005	    out[4] = 0;
2006	    out[5] = 1;
2007	    out[6] = 0;
2008	    out[7] = 0;
2009	    out[8] = 0;
2010	    out[9] = 0;
2011	    out[10] = 1;
2012	    out[11] = 0;
2013	    out[12] = v[0];
2014	    out[13] = v[1];
2015	    out[14] = v[2];
2016	    out[15] = 1;
2017	    return out;
2018	}
2019
2020	/**
2021	 * Creates a matrix from a vector scaling
2022	 * This is equivalent to (but much faster than):
2023	 *
2024	 *     mat4.identity(dest);
2025	 *     mat4.scale(dest, dest, vec);
2026	 *
2027	 * @param {mat4} out mat4 receiving operation result
2028	 * @param {vec3} v Scaling vector
2029	 * @returns {mat4} out
2030	 */
2031	mat4.fromScaling = function(out, v) {
2032	    out[0] = v[0];
2033	    out[1] = 0;
2034	    out[2] = 0;
2035	    out[3] = 0;
2036	    out[4] = 0;
2037	    out[5] = v[1];
2038	    out[6] = 0;
2039	    out[7] = 0;
2040	    out[8] = 0;
2041	    out[9] = 0;
2042	    out[10] = v[2];
2043	    out[11] = 0;
2044	    out[12] = 0;
2045	    out[13] = 0;
2046	    out[14] = 0;
2047	    out[15] = 1;
2048	    return out;
2049	}
2050
2051	/**
2052	 * Creates a matrix from a given angle around a given axis
2053	 * This is equivalent to (but much faster than):
2054	 *
2055	 *     mat4.identity(dest);
2056	 *     mat4.rotate(dest, dest, rad, axis);
2057	 *
2058	 * @param {mat4} out mat4 receiving operation result
2059	 * @param {Number} rad the angle to rotate the matrix by
2060	 * @param {vec3} axis the axis to rotate around
2061	 * @returns {mat4} out
2062	 */
2063	mat4.fromRotation = function(out, rad, axis) {
2064	    var x = axis[0], y = axis[1], z = axis[2],
2065	        len = Math.sqrt(x * x + y * y + z * z),
2066	        s, c, t;
2067
2068	    if (Math.abs(len) < glMatrix.EPSILON) { return null; }
2069
2070	    len = 1 / len;
2071	    x *= len;
2072	    y *= len;
2073	    z *= len;
2074
2075	    s = Math.sin(rad);
2076	    c = Math.cos(rad);
2077	    t = 1 - c;
2078
2079	    // Perform rotation-specific matrix multiplication
2080	    out[0] = x * x * t + c;
2081	    out[1] = y * x * t + z * s;
2082	    out[2] = z * x * t - y * s;
2083	    out[3] = 0;
2084	    out[4] = x * y * t - z * s;
2085	    out[5] = y * y * t + c;
2086	    out[6] = z * y * t + x * s;
2087	    out[7] = 0;
2088	    out[8] = x * z * t + y * s;
2089	    out[9] = y * z * t - x * s;
2090	    out[10] = z * z * t + c;
2091	    out[11] = 0;
2092	    out[12] = 0;
2093	    out[13] = 0;
2094	    out[14] = 0;
2095	    out[15] = 1;
2096	    return out;
2097	}
2098
2099	/**
2100	 * Creates a matrix from the given angle around the X axis
2101	 * This is equivalent to (but much faster than):
2102	 *
2103	 *     mat4.identity(dest);
2104	 *     mat4.rotateX(dest, dest, rad);
2105	 *
2106	 * @param {mat4} out mat4 receiving operation result
2107	 * @param {Number} rad the angle to rotate the matrix by
2108	 * @returns {mat4} out
2109	 */
2110	mat4.fromXRotation = function(out, rad) {
2111	    var s = Math.sin(rad),
2112	        c = Math.cos(rad);
2113
2114	    // Perform axis-specific matrix multiplication
2115	    out[0]  = 1;
2116	    out[1]  = 0;
2117	    out[2]  = 0;
2118	    out[3]  = 0;
2119	    out[4] = 0;
2120	    out[5] = c;
2121	    out[6] = s;
2122	    out[7] = 0;
2123	    out[8] = 0;
2124	    out[9] = -s;
2125	    out[10] = c;
2126	    out[11] = 0;
2127	    out[12] = 0;
2128	    out[13] = 0;
2129	    out[14] = 0;
2130	    out[15] = 1;
2131	    return out;
2132	}
2133
2134	/**
2135	 * Creates a matrix from the given angle around the Y axis
2136	 * This is equivalent to (but much faster than):
2137	 *
2138	 *     mat4.identity(dest);
2139	 *     mat4.rotateY(dest, dest, rad);
2140	 *
2141	 * @param {mat4} out mat4 receiving operation result
2142	 * @param {Number} rad the angle to rotate the matrix by
2143	 * @returns {mat4} out
2144	 */
2145	mat4.fromYRotation = function(out, rad) {
2146	    var s = Math.sin(rad),
2147	        c = Math.cos(rad);
2148
2149	    // Perform axis-specific matrix multiplication
2150	    out[0]  = c;
2151	    out[1]  = 0;
2152	    out[2]  = -s;
2153	    out[3]  = 0;
2154	    out[4] = 0;
2155	    out[5] = 1;
2156	    out[6] = 0;
2157	    out[7] = 0;
2158	    out[8] = s;
2159	    out[9] = 0;
2160	    out[10] = c;
2161	    out[11] = 0;
2162	    out[12] = 0;
2163	    out[13] = 0;
2164	    out[14] = 0;
2165	    out[15] = 1;
2166	    return out;
2167	}
2168
2169	/**
2170	 * Creates a matrix from the given angle around the Z axis
2171	 * This is equivalent to (but much faster than):
2172	 *
2173	 *     mat4.identity(dest);
2174	 *     mat4.rotateZ(dest, dest, rad);
2175	 *
2176	 * @param {mat4} out mat4 receiving operation result
2177	 * @param {Number} rad the angle to rotate the matrix by
2178	 * @returns {mat4} out
2179	 */
2180	mat4.fromZRotation = function(out, rad) {
2181	    var s = Math.sin(rad),
2182	        c = Math.cos(rad);
2183
2184	    // Perform axis-specific matrix multiplication
2185	    out[0]  = c;
2186	    out[1]  = s;
2187	    out[2]  = 0;
2188	    out[3]  = 0;
2189	    out[4] = -s;
2190	    out[5] = c;
2191	    out[6] = 0;
2192	    out[7] = 0;
2193	    out[8] = 0;
2194	    out[9] = 0;
2195	    out[10] = 1;
2196	    out[11] = 0;
2197	    out[12] = 0;
2198	    out[13] = 0;
2199	    out[14] = 0;
2200	    out[15] = 1;
2201	    return out;
2202	}
2203
2204	/**
2205	 * Creates a matrix from a quaternion rotation and vector translation
2206	 * This is equivalent to (but much faster than):
2207	 *
2208	 *     mat4.identity(dest);
2209	 *     mat4.translate(dest, vec);
2210	 *     var quatMat = mat4.create();
2211	 *     quat4.toMat4(quat, quatMat);
2212	 *     mat4.multiply(dest, quatMat);
2213	 *
2214	 * @param {mat4} out mat4 receiving operation result
2215	 * @param {quat4} q Rotation quaternion
2216	 * @param {vec3} v Translation vector
2217	 * @returns {mat4} out
2218	 */
2219	mat4.fromRotationTranslation = function (out, q, v) {
2220	    // Quaternion math
2221	    var x = q[0], y = q[1], z = q[2], w = q[3],
2222	        x2 = x + x,
2223	        y2 = y + y,
2224	        z2 = z + z,
2225
2226	        xx = x * x2,
2227	        xy = x * y2,
2228	        xz = x * z2,
2229	        yy = y * y2,
2230	        yz = y * z2,
2231	        zz = z * z2,
2232	        wx = w * x2,
2233	        wy = w * y2,
2234	        wz = w * z2;
2235
2236	    out[0] = 1 - (yy + zz);
2237	    out[1] = xy + wz;
2238	    out[2] = xz - wy;
2239	    out[3] = 0;
2240	    out[4] = xy - wz;
2241	    out[5] = 1 - (xx + zz);
2242	    out[6] = yz + wx;
2243	    out[7] = 0;
2244	    out[8] = xz + wy;
2245	    out[9] = yz - wx;
2246	    out[10] = 1 - (xx + yy);
2247	    out[11] = 0;
2248	    out[12] = v[0];
2249	    out[13] = v[1];
2250	    out[14] = v[2];
2251	    out[15] = 1;
2252
2253	    return out;
2254	};
2255
2256	/**
2257	 * Creates a matrix from a quaternion rotation, vector translation and vector scale
2258	 * This is equivalent to (but much faster than):
2259	 *
2260	 *     mat4.identity(dest);
2261	 *     mat4.translate(dest, vec);
2262	 *     var quatMat = mat4.create();
2263	 *     quat4.toMat4(quat, quatMat);
2264	 *     mat4.multiply(dest, quatMat);
2265	 *     mat4.scale(dest, scale)
2266	 *
2267	 * @param {mat4} out mat4 receiving operation result
2268	 * @param {quat4} q Rotation quaternion
2269	 * @param {vec3} v Translation vector
2270	 * @param {vec3} s Scaling vector
2271	 * @returns {mat4} out
2272	 */
2273	mat4.fromRotationTranslationScale = function (out, q, v, s) {
2274	    // Quaternion math
2275	    var x = q[0], y = q[1], z = q[2], w = q[3],
2276	        x2 = x + x,
2277	        y2 = y + y,
2278	        z2 = z + z,
2279
2280	        xx = x * x2,
2281	        xy = x * y2,
2282	        xz = x * z2,
2283	        yy = y * y2,
2284	        yz = y * z2,
2285	        zz = z * z2,
2286	        wx = w * x2,
2287	        wy = w * y2,
2288	        wz = w * z2,
2289	        sx = s[0],
2290	        sy = s[1],
2291	        sz = s[2];
2292
2293	    out[0] = (1 - (yy + zz)) * sx;
2294	    out[1] = (xy + wz) * sx;
2295	    out[2] = (xz - wy) * sx;
2296	    out[3] = 0;
2297	    out[4] = (xy - wz) * sy;
2298	    out[5] = (1 - (xx + zz)) * sy;
2299	    out[6] = (yz + wx) * sy;
2300	    out[7] = 0;
2301	    out[8] = (xz + wy) * sz;
2302	    out[9] = (yz - wx) * sz;
2303	    out[10] = (1 - (xx + yy)) * sz;
2304	    out[11] = 0;
2305	    out[12] = v[0];
2306	    out[13] = v[1];
2307	    out[14] = v[2];
2308	    out[15] = 1;
2309
2310	    return out;
2311	};
2312
2313	/**
2314	 * Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
2315	 * This is equivalent to (but much faster than):
2316	 *
2317	 *     mat4.identity(dest);
2318	 *     mat4.translate(dest, vec);
2319	 *     mat4.translate(dest, origin);
2320	 *     var quatMat = mat4.create();
2321	 *     quat4.toMat4(quat, quatMat);
2322	 *     mat4.multiply(dest, quatMat);
2323	 *     mat4.scale(dest, scale)
2324	 *     mat4.translate(dest, negativeOrigin);
2325	 *
2326	 * @param {mat4} out mat4 receiving operation result
2327	 * @param {quat4} q Rotation quaternion
2328	 * @param {vec3} v Translation vector
2329	 * @param {vec3} s Scaling vector
2330	 * @param {vec3} o The origin vector around which to scale and rotate
2331	 * @returns {mat4} out
2332	 */
2333	mat4.fromRotationTranslationScaleOrigin = function (out, q, v, s, o) {
2334	  // Quaternion math
2335	  var x = q[0], y = q[1], z = q[2], w = q[3],
2336	      x2 = x + x,
2337	      y2 = y + y,
2338	      z2 = z + z,
2339
2340	      xx = x * x2,
2341	      xy = x * y2,
2342	      xz = x * z2,
2343	      yy = y * y2,
2344	      yz = y * z2,
2345	      zz = z * z2,
2346	      wx = w * x2,
2347	      wy = w * y2,
2348	      wz = w * z2,
2349
2350	      sx = s[0],
2351	      sy = s[1],
2352	      sz = s[2],
2353
2354	      ox = o[0],
2355	      oy = o[1],
2356	      oz = o[2];
2357
2358	  out[0] = (1 - (yy + zz)) * sx;
2359	  out[1] = (xy + wz) * sx;
2360	  out[2] = (xz - wy) * sx;
2361	  out[3] = 0;
2362	  out[4] = (xy - wz) * sy;
2363	  out[5] = (1 - (xx + zz)) * sy;
2364	  out[6] = (yz + wx) * sy;
2365	  out[7] = 0;
2366	  out[8] = (xz + wy) * sz;
2367	  out[9] = (yz - wx) * sz;
2368	  out[10] = (1 - (xx + yy)) * sz;
2369	  out[11] = 0;
2370	  out[12] = v[0] + ox - (out[0] * ox + out[4] * oy + out[8] * oz);
2371	  out[13] = v[1] + oy - (out[1] * ox + out[5] * oy + out[9] * oz);
2372	  out[14] = v[2] + oz - (out[2] * ox + out[6] * oy + out[10] * oz);
2373	  out[15] = 1;
2374
2375	  return out;
2376	};
2377
2378	mat4.fromQuat = function (out, q) {
2379	    var x = q[0], y = q[1], z = q[2], w = q[3],
2380	        x2 = x + x,
2381	        y2 = y + y,
2382	        z2 = z + z,
2383
2384	        xx = x * x2,
2385	        yx = y * x2,
2386	        yy = y * y2,
2387	        zx = z * x2,
2388	        zy = z * y2,
2389	        zz = z * z2,
2390	        wx = w * x2,
2391	        wy = w * y2,
2392	        wz = w * z2;
2393
2394	    out[0] = 1 - yy - zz;
2395	    out[1] = yx + wz;
2396	    out[2] = zx - wy;
2397	    out[3] = 0;
2398
2399	    out[4] = yx - wz;
2400	    out[5] = 1 - xx - zz;
2401	    out[6] = zy + wx;
2402	    out[7] = 0;
2403
2404	    out[8] = zx + wy;
2405	    out[9] = zy - wx;
2406	    out[10] = 1 - xx - yy;
2407	    out[11] = 0;
2408
2409	    out[12] = 0;
2410	    out[13] = 0;
2411	    out[14] = 0;
2412	    out[15] = 1;
2413
2414	    return out;
2415	};
2416
2417	/**
2418	 * Generates a frustum matrix with the given bounds
2419	 *
2420	 * @param {mat4} out mat4 frustum matrix will be written into
2421	 * @param {Number} left Left bound of the frustum
2422	 * @param {Number} right Right bound of the frustum
2423	 * @param {Number} bottom Bottom bound of the frustum
2424	 * @param {Number} top Top bound of the frustum
2425	 * @param {Number} near Near bound of the frustum
2426	 * @param {Number} far Far bound of the frustum
2427	 * @returns {mat4} out
2428	 */
2429	mat4.frustum = function (out, left, right, bottom, top, near, far) {
2430	    var rl = 1 / (right - left),
2431	        tb = 1 / (top - bottom),
2432	        nf = 1 / (near - far);
2433	    out[0] = (near * 2) * rl;
2434	    out[1] = 0;
2435	    out[2] = 0;
2436	    out[3] = 0;
2437	    out[4] = 0;
2438	    out[5] = (near * 2) * tb;
2439	    out[6] = 0;
2440	    out[7] = 0;
2441	    out[8] = (right + left) * rl;
2442	    out[9] = (top + bottom) * tb;
2443	    out[10] = (far + near) * nf;
2444	    out[11] = -1;
2445	    out[12] = 0;
2446	    out[13] = 0;
2447	    out[14] = (far * near * 2) * nf;
2448	    out[15] = 0;
2449	    return out;
2450	};
2451
2452	/**
2453	 * Generates a perspective projection matrix with the given bounds
2454	 *
2455	 * @param {mat4} out mat4 frustum matrix will be written into
2456	 * @param {number} fovy Vertical field of view in radians
2457	 * @param {number} aspect Aspect ratio. typically viewport width/height
2458	 * @param {number} near Near bound of the frustum
2459	 * @param {number} far Far bound of the frustum
2460	 * @returns {mat4} out
2461	 */
2462	mat4.perspective = function (out, fovy, aspect, near, far) {
2463	    var f = 1.0 / Math.tan(fovy / 2),
2464	        nf = 1 / (near - far);
2465	    out[0] = f / aspect;
2466	    out[1] = 0;
2467	    out[2] = 0;
2468	    out[3] = 0;
2469	    out[4] = 0;
2470	    out[5] = f;
2471	    out[6] = 0;
2472	    out[7] = 0;
2473	    out[8] = 0;
2474	    out[9] = 0;
2475	    out[10] = (far + near) * nf;
2476	    out[11] = -1;
2477	    out[12] = 0;
2478	    out[13] = 0;
2479	    out[14] = (2 * far * near) * nf;
2480	    out[15] = 0;
2481	    return out;
2482	};
2483
2484	/**
2485	 * Generates a perspective projection matrix with the given field of view.
2486	 * This is primarily useful for generating projection matrices to be used
2487	 * with the still experiemental WebVR API.
2488	 *
2489	 * @param {mat4} out mat4 frustum matrix will be written into
2490	 * @param {number} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
2491	 * @param {number} near Near bound of the frustum
2492	 * @param {number} far Far bound of the frustum
2493	 * @returns {mat4} out
2494	 */
2495	mat4.perspectiveFromFieldOfView = function (out, fov, near, far) {
2496	    var upTan = Math.tan(fov.upDegrees * Math.PI/180.0),
2497	        downTan = Math.tan(fov.downDegrees * Math.PI/180.0),
2498	        leftTan = Math.tan(fov.leftDegrees * Math.PI/180.0),
2499	        rightTan = Math.tan(fov.rightDegrees * Math.PI/180.0),
2500	        xScale = 2.0 / (leftTan + rightTan),
2501	        yScale = 2.0 / (upTan + downTan);
2502
2503	    out[0] = xScale;
2504	    out[1] = 0.0;
2505	    out[2] = 0.0;
2506	    out[3] = 0.0;
2507	    out[4] = 0.0;
2508	    out[5] = yScale;
2509	    out[6] = 0.0;
2510	    out[7] = 0.0;
2511	    out[8] = -((leftTan - rightTan) * xScale * 0.5);
2512	    out[9] = ((upTan - downTan) * yScale * 0.5);
2513	    out[10] = far / (near - far);
2514	    out[11] = -1.0;
2515	    out[12] = 0.0;
2516	    out[13] = 0.0;
2517	    out[14] = (far * near) / (near - far);
2518	    out[15] = 0.0;
2519	    return out;
2520	}
2521
2522	/**
2523	 * Generates a orthogonal projection matrix with the given bounds
2524	 *
2525	 * @param {mat4} out mat4 frustum matrix will be written into
2526	 * @param {number} left Left bound of the frustum
2527	 * @param {number} right Right bound of the frustum
2528	 * @param {number} bottom Bottom bound of the frustum
2529	 * @param {number} top Top bound of the frustum
2530	 * @param {number} near Near bound of the frustum
2531	 * @param {number} far Far bound of the frustum
2532	 * @returns {mat4} out
2533	 */
2534	mat4.ortho = function (out, left, right, bottom, top, near, far) {
2535	    var lr = 1 / (left - right),
2536	        bt = 1 / (bottom - top),
2537	        nf = 1 / (near - far);
2538	    out[0] = -2 * lr;
2539	    out[1] = 0;
2540	    out[2] = 0;
2541	    out[3] = 0;
2542	    out[4] = 0;
2543	    out[5] = -2 * bt;
2544	    out[6] = 0;
2545	    out[7] = 0;
2546	    out[8] = 0;
2547	    out[9] = 0;
2548	    out[10] = 2 * nf;
2549	    out[11] = 0;
2550	    out[12] = (left + right) * lr;
2551	    out[13] = (top + bottom) * bt;
2552	    out[14] = (far + near) * nf;
2553	    out[15] = 1;
2554	    return out;
2555	};
2556
2557	/**
2558	 * Generates a look-at matrix with the given eye position, focal point, and up axis
2559	 *
2560	 * @param {mat4} out mat4 frustum matrix will be written into
2561	 * @param {vec3} eye Position of the viewer
2562	 * @param {vec3} center Point the viewer is looking at
2563	 * @param {vec3} up vec3 pointing up
2564	 * @returns {mat4} out
2565	 */
2566	mat4.lookAt = function (out, eye, center, up) {
2567	    var x0, x1, x2, y0, y1, y2, z0, z1, z2, len,
2568	        eyex = eye[0],
2569	        eyey = eye[1],
2570	        eyez = eye[2],
2571	        upx = up[0],
2572	        upy = up[1],
2573	        upz = up[2],
2574	        centerx = center[0],
2575	        centery = center[1],
2576	        centerz = center[2];
2577
2578	    if (Math.abs(eyex - centerx) < glMatrix.EPSILON &&
2579	        Math.abs(eyey - centery) < glMatrix.EPSILON &&
2580	        Math.abs(eyez - centerz) < glMatrix.EPSILON) {
2581	        return mat4.identity(out);
2582	    }
2583
2584	    z0 = eyex - centerx;
2585	    z1 = eyey - centery;
2586	    z2 = eyez - centerz;
2587
2588	    len = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
2589	    z0 *= len;
2590	    z1 *= len;
2591	    z2 *= len;
2592
2593	    x0 = upy * z2 - upz * z1;
2594	    x1 = upz * z0 - upx * z2;
2595	    x2 = upx * z1 - upy * z0;
2596	    len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
2597	    if (!len) {
2598	        x0 = 0;
2599	        x1 = 0;
2600	        x2 = 0;
2601	    } else {
2602	        len = 1 / len;
2603	        x0 *= len;
2604	        x1 *= len;
2605	        x2 *= len;
2606	    }
2607
2608	    y0 = z1 * x2 - z2 * x1;
2609	    y1 = z2 * x0 - z0 * x2;
2610	    y2 = z0 * x1 - z1 * x0;
2611
2612	    len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
2613	    if (!len) {
2614	        y0 = 0;
2615	        y1 = 0;
2616	        y2 = 0;
2617	    } else {
2618	        len = 1 / len;
2619	        y0 *= len;
2620	        y1 *= len;
2621	        y2 *= len;
2622	    }
2623
2624	    out[0] = x0;
2625	    out[1] = y0;
2626	    out[2] = z0;
2627	    out[3] = 0;
2628	    out[4] = x1;
2629	    out[5] = y1;
2630	    out[6] = z1;
2631	    out[7] = 0;
2632	    out[8] = x2;
2633	    out[9] = y2;
2634	    out[10] = z2;
2635	    out[11] = 0;
2636	    out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
2637	    out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
2638	    out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
2639	    out[15] = 1;
2640
2641	    return out;
2642	};
2643
2644	/**
2645	 * Returns a string representation of a mat4
2646	 *
2647	 * @param {mat4} mat matrix to represent as a string
2648	 * @returns {String} string representation of the matrix
2649	 */
2650	mat4.str = function (a) {
2651	    return 'mat4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' +
2652	                    a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' +
2653	                    a[8] + ', ' + a[9] + ', ' + a[10] + ', ' + a[11] + ', ' +
2654	                    a[12] + ', ' + a[13] + ', ' + a[14] + ', ' + a[15] + ')';
2655	};
2656
2657	/**
2658	 * Returns Frobenius norm of a mat4
2659	 *
2660	 * @param {mat4} a the matrix to calculate Frobenius norm of
2661	 * @returns {Number} Frobenius norm
2662	 */
2663	mat4.frob = function (a) {
2664	    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) + 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) ))
2665	};
2666
2667
2668	module.exports = mat4;
2669
2670
2671/***/ },
2672/* 6 */
2673/***/ function(module, exports, __webpack_require__) {
2674
2675	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
2676
2677	Permission is hereby granted, free of charge, to any person obtaining a copy
2678	of this software and associated documentation files (the "Software"), to deal
2679	in the Software without restriction, including without limitation the rights
2680	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2681	copies of the Software, and to permit persons to whom the Software is
2682	furnished to do so, subject to the following conditions:
2683
2684	The above copyright notice and this permission notice shall be included in
2685	all copies or substantial portions of the Software.
2686
2687	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2688	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2689	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2690	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2691	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2692	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2693	THE SOFTWARE. */
2694
2695	var glMatrix = __webpack_require__(1);
2696	var mat3 = __webpack_require__(4);
2697	var vec3 = __webpack_require__(7);
2698	var vec4 = __webpack_require__(8);
2699
2700	/**
2701	 * @class Quaternion
2702	 * @name quat
2703	 */
2704	var quat = {};
2705
2706	/**
2707	 * Creates a new identity quat
2708	 *
2709	 * @returns {quat} a new quaternion
2710	 */
2711	quat.create = function() {
2712	    var out = new glMatrix.ARRAY_TYPE(4);
2713	    out[0] = 0;
2714	    out[1] = 0;
2715	    out[2] = 0;
2716	    out[3] = 1;
2717	    return out;
2718	};
2719
2720	/**
2721	 * Sets a quaternion to represent the shortest rotation from one
2722	 * vector to another.
2723	 *
2724	 * Both vectors are assumed to be unit length.
2725	 *
2726	 * @param {quat} out the receiving quaternion.
2727	 * @param {vec3} a the initial vector
2728	 * @param {vec3} b the destination vector
2729	 * @returns {quat} out
2730	 */
2731	quat.rotationTo = (function() {
2732	    var tmpvec3 = vec3.create();
2733	    var xUnitVec3 = vec3.fromValues(1,0,0);
2734	    var yUnitVec3 = vec3.fromValues(0,1,0);
2735
2736	    return function(out, a, b) {
2737	        var dot = vec3.dot(a, b);
2738	        if (dot < -0.999999) {
2739	            vec3.cross(tmpvec3, xUnitVec3, a);
2740	            if (vec3.length(tmpvec3) < 0.000001)
2741	                vec3.cross(tmpvec3, yUnitVec3, a);
2742	            vec3.normalize(tmpvec3, tmpvec3);
2743	            quat.setAxisAngle(out, tmpvec3, Math.PI);
2744	            return out;
2745	        } else if (dot > 0.999999) {
2746	            out[0] = 0;
2747	            out[1] = 0;
2748	            out[2] = 0;
2749	            out[3] = 1;
2750	            return out;
2751	        } else {
2752	            vec3.cross(tmpvec3, a, b);
2753	            out[0] = tmpvec3[0];
2754	            out[1] = tmpvec3[1];
2755	            out[2] = tmpvec3[2];
2756	            out[3] = 1 + dot;
2757	            return quat.normalize(out, out);
2758	        }
2759	    };
2760	})();
2761
2762	/**
2763	 * Sets the specified quaternion with values corresponding to the given
2764	 * axes. Each axis is a vec3 and is expected to be unit length and
2765	 * perpendicular to all other specified axes.
2766	 *
2767	 * @param {vec3} view  the vector representing the viewing direction
2768	 * @param {vec3} right the vector representing the local "right" direction
2769	 * @param {vec3} up    the vector representing the local "up" direction
2770	 * @returns {quat} out
2771	 */
2772	quat.setAxes = (function() {
2773	    var matr = mat3.create();
2774
2775	    return function(out, view, right, up) {
2776	        matr[0] = right[0];
2777	        matr[3] = right[1];
2778	        matr[6] = right[2];
2779
2780	        matr[1] = up[0];
2781	        matr[4] = up[1];
2782	        matr[7] = up[2];
2783
2784	        matr[2] = -view[0];
2785	        matr[5] = -view[1];
2786	        matr[8] = -view[2];
2787
2788	        return quat.normalize(out, quat.fromMat3(out, matr));
2789	    };
2790	})();
2791
2792	/**
2793	 * Creates a new quat initialized with values from an existing quaternion
2794	 *
2795	 * @param {quat} a quaternion to clone
2796	 * @returns {quat} a new quaternion
2797	 * @function
2798	 */
2799	quat.clone = vec4.clone;
2800
2801	/**
2802	 * Creates a new quat initialized with the given values
2803	 *
2804	 * @param {Number} x X component
2805	 * @param {Number} y Y component
2806	 * @param {Number} z Z component
2807	 * @param {Number} w W component
2808	 * @returns {quat} a new quaternion
2809	 * @function
2810	 */
2811	quat.fromValues = vec4.fromValues;
2812
2813	/**
2814	 * Copy the values from one quat to another
2815	 *
2816	 * @param {quat} out the receiving quaternion
2817	 * @param {quat} a the source quaternion
2818	 * @returns {quat} out
2819	 * @function
2820	 */
2821	quat.copy = vec4.copy;
2822
2823	/**
2824	 * Set the components of a quat to the given values
2825	 *
2826	 * @param {quat} out the receiving quaternion
2827	 * @param {Number} x X component
2828	 * @param {Number} y Y component
2829	 * @param {Number} z Z component
2830	 * @param {Number} w W component
2831	 * @returns {quat} out
2832	 * @function
2833	 */
2834	quat.set = vec4.set;
2835
2836	/**
2837	 * Set a quat to the identity quaternion
2838	 *
2839	 * @param {quat} out the receiving quaternion
2840	 * @returns {quat} out
2841	 */
2842	quat.identity = function(out) {
2843	    out[0] = 0;
2844	    out[1] = 0;
2845	    out[2] = 0;
2846	    out[3] = 1;
2847	    return out;
2848	};
2849
2850	/**
2851	 * Sets a quat from the given angle and rotation axis,
2852	 * then returns it.
2853	 *
2854	 * @param {quat} out the receiving quaternion
2855	 * @param {vec3} axis the axis around which to rotate
2856	 * @param {Number} rad the angle in radians
2857	 * @returns {quat} out
2858	 **/
2859	quat.setAxisAngle = function(out, axis, rad) {
2860	    rad = rad * 0.5;
2861	    var s = Math.sin(rad);
2862	    out[0] = s * axis[0];
2863	    out[1] = s * axis[1];
2864	    out[2] = s * axis[2];
2865	    out[3] = Math.cos(rad);
2866	    return out;
2867	};
2868
2869	/**
2870	 * Adds two quat's
2871	 *
2872	 * @param {quat} out the receiving quaternion
2873	 * @param {quat} a the first operand
2874	 * @param {quat} b the second operand
2875	 * @returns {quat} out
2876	 * @function
2877	 */
2878	quat.add = vec4.add;
2879
2880	/**
2881	 * Multiplies two quat's
2882	 *
2883	 * @param {quat} out the receiving quaternion
2884	 * @param {quat} a the first operand
2885	 * @param {quat} b the second operand
2886	 * @returns {quat} out
2887	 */
2888	quat.multiply = function(out, a, b) {
2889	    var ax = a[0], ay = a[1], az = a[2], aw = a[3],
2890	        bx = b[0], by = b[1], bz = b[2], bw = b[3];
2891
2892	    out[0] = ax * bw + aw * bx + ay * bz - az * by;
2893	    out[1] = ay * bw + aw * by + az * bx - ax * bz;
2894	    out[2] = az * bw + aw * bz + ax * by - ay * bx;
2895	    out[3] = aw * bw - ax * bx - ay * by - az * bz;
2896	    return out;
2897	};
2898
2899	/**
2900	 * Alias for {@link quat.multiply}
2901	 * @function
2902	 */
2903	quat.mul = quat.multiply;
2904
2905	/**
2906	 * Scales a quat by a scalar number
2907	 *
2908	 * @param {quat} out the receiving vector
2909	 * @param {quat} a the vector to scale
2910	 * @param {Number} b amount to scale the vector by
2911	 * @returns {quat} out
2912	 * @function
2913	 */
2914	quat.scale = vec4.scale;
2915
2916	/**
2917	 * Rotates a quaternion by the given angle about the X axis
2918	 *
2919	 * @param {quat} out quat receiving operation result
2920	 * @param {quat} a quat to rotate
2921	 * @param {number} rad angle (in radians) to rotate
2922	 * @returns {quat} out
2923	 */
2924	quat.rotateX = function (out, a, rad) {
2925	    rad *= 0.5;
2926
2927	    var ax = a[0], ay = a[1], az = a[2], aw = a[3],
2928	        bx = Math.sin(rad), bw = Math.cos(rad);
2929
2930	    out[0] = ax * bw + aw * bx;
2931	    out[1] = ay * bw + az * bx;
2932	    out[2] = az * bw - ay * bx;
2933	    out[3] = aw * bw - ax * bx;
2934	    return out;
2935	};
2936
2937	/**
2938	 * Rotates a quaternion by the given angle about the Y axis
2939	 *
2940	 * @param {quat} out quat receiving operation result
2941	 * @param {quat} a quat to rotate
2942	 * @param {number} rad angle (in radians) to rotate
2943	 * @returns {quat} out
2944	 */
2945	quat.rotateY = function (out, a, rad) {
2946	    rad *= 0.5;
2947
2948	    var ax = a[0], ay = a[1], az = a[2], aw = a[3],
2949	        by = Math.sin(rad), bw = Math.cos(rad);
2950
2951	    out[0] = ax * bw - az * by;
2952	    out[1] = ay * bw + aw * by;
2953	    out[2] = az * bw + ax * by;
2954	    out[3] = aw * bw - ay * by;
2955	    return out;
2956	};
2957
2958	/**
2959	 * Rotates a quaternion by the given angle about the Z axis
2960	 *
2961	 * @param {quat} out quat receiving operation result
2962	 * @param {quat} a quat to rotate
2963	 * @param {number} rad angle (in radians) to rotate
2964	 * @returns {quat} out
2965	 */
2966	quat.rotateZ = function (out, a, rad) {
2967	    rad *= 0.5;
2968
2969	    var ax = a[0], ay = a[1], az = a[2], aw = a[3],
2970	        bz = Math.sin(rad), bw = Math.cos(rad);
2971
2972	    out[0] = ax * bw + ay * bz;
2973	    out[1] = ay * bw - ax * bz;
2974	    out[2] = az * bw + aw * bz;
2975	    out[3] = aw * bw - az * bz;
2976	    return out;
2977	};
2978
2979	/**
2980	 * Calculates the W component of a quat from the X, Y, and Z components.
2981	 * Assumes that quaternion is 1 unit in length.
2982	 * Any existing W component will be ignored.
2983	 *
2984	 * @param {quat} out the receiving quaternion
2985	 * @param {quat} a quat to calculate W component of
2986	 * @returns {quat} out
2987	 */
2988	quat.calculateW = function (out, a) {
2989	    var x = a[0], y = a[1], z = a[2];
2990
2991	    out[0] = x;
2992	    out[1] = y;
2993	    out[2] = z;
2994	    out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
2995	    return out;
2996	};
2997
2998	/**
2999	 * Calculates the dot product of two quat's
3000	 *
3001	 * @param {quat} a the first operand
3002	 * @param {quat} b the second operand
3003	 * @returns {Number} dot product of a and b
3004	 * @function
3005	 */
3006	quat.dot = vec4.dot;
3007
3008	/**
3009	 * Performs a linear interpolation between two quat's
3010	 *
3011	 * @param {quat} out the receiving quaternion
3012	 * @param {quat} a the first operand
3013	 * @param {quat} b the second operand
3014	 * @param {Number} t interpolation amount between the two inputs
3015	 * @returns {quat} out
3016	 * @function
3017	 */
3018	quat.lerp = vec4.lerp;
3019
3020	/**
3021	 * Performs a spherical linear interpolation between two quat
3022	 *
3023	 * @param {quat} out the receiving quaternion
3024	 * @param {quat} a the first operand
3025	 * @param {quat} b the second operand
3026	 * @param {Number} t interpolation amount between the two inputs
3027	 * @returns {quat} out
3028	 */
3029	quat.slerp = function (out, a, b, t) {
3030	    // benchmarks:
3031	    //    http://jsperf.com/quaternion-slerp-implementations
3032
3033	    var ax = a[0], ay = a[1], az = a[2], aw = a[3],
3034	        bx = b[0], by = b[1], bz = b[2], bw = b[3];
3035
3036	    var        omega, cosom, sinom, scale0, scale1;
3037
3038	    // calc cosine
3039	    cosom = ax * bx + ay * by + az * bz + aw * bw;
3040	    // adjust signs (if necessary)
3041	    if ( cosom < 0.0 ) {
3042	        cosom = -cosom;
3043	        bx = - bx;
3044	        by = - by;
3045	        bz = - bz;
3046	        bw = - bw;
3047	    }
3048	    // calculate coefficients
3049	    if ( (1.0 - cosom) > 0.000001 ) {
3050	        // standard case (slerp)
3051	        omega  = Math.acos(cosom);
3052	        sinom  = Math.sin(omega);
3053	        scale0 = Math.sin((1.0 - t) * omega) / sinom;
3054	        scale1 = Math.sin(t * omega) / sinom;
3055	    } else {
3056	        // "from" and "to" quaternions are very close
3057	        //  ... so we can do a linear interpolation
3058	        scale0 = 1.0 - t;
3059	        scale1 = t;
3060	    }
3061	    // calculate final values
3062	    out[0] = scale0 * ax + scale1 * bx;
3063	    out[1] = scale0 * ay + scale1 * by;
3064	    out[2] = scale0 * az + scale1 * bz;
3065	    out[3] = scale0 * aw + scale1 * bw;
3066
3067	    return out;
3068	};
3069
3070	/**
3071	 * Performs a spherical linear interpolation with two control points
3072	 *
3073	 * @param {quat} out the receiving quaternion
3074	 * @param {quat} a the first operand
3075	 * @param {quat} b the second operand
3076	 * @param {quat} c the third operand
3077	 * @param {quat} d the fourth operand
3078	 * @param {Number} t interpolation amount
3079	 * @returns {quat} out
3080	 */
3081	quat.sqlerp = (function () {
3082	  var temp1 = quat.create();
3083	  var temp2 = quat.create();
3084
3085	  return function (out, a, b, c, d, t) {
3086	    quat.slerp(temp1, a, d, t);
3087	    quat.slerp(temp2, b, c, t);
3088	    quat.slerp(out, temp1, temp2, 2 * t * (1 - t));
3089
3090	    return out;
3091	  };
3092	}());
3093
3094	/**
3095	 * Calculates the inverse of a quat
3096	 *
3097	 * @param {quat} out the receiving quaternion
3098	 * @param {quat} a quat to calculate inverse of
3099	 * @returns {quat} out
3100	 */
3101	quat.invert = function(out, a) {
3102	    var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
3103	        dot = a0*a0 + a1*a1 + a2*a2 + a3*a3,
3104	        invDot = dot ? 1.0/dot : 0;
3105
3106	    // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
3107
3108	    out[0] = -a0*invDot;
3109	    out[1] = -a1*invDot;
3110	    out[2] = -a2*invDot;
3111	    out[3] = a3*invDot;
3112	    return out;
3113	};
3114
3115	/**
3116	 * Calculates the conjugate of a quat
3117	 * If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
3118	 *
3119	 * @param {quat} out the receiving quaternion
3120	 * @param {quat} a quat to calculate conjugate of
3121	 * @returns {quat} out
3122	 */
3123	quat.conjugate = function (out, a) {
3124	    out[0] = -a[0];
3125	    out[1] = -a[1];
3126	    out[2] = -a[2];
3127	    out[3] = a[3];
3128	    return out;
3129	};
3130
3131	/**
3132	 * Calculates the length of a quat
3133	 *
3134	 * @param {quat} a vector to calculate length of
3135	 * @returns {Number} length of a
3136	 * @function
3137	 */
3138	quat.length = vec4.length;
3139
3140	/**
3141	 * Alias for {@link quat.length}
3142	 * @function
3143	 */
3144	quat.len = quat.length;
3145
3146	/**
3147	 * Calculates the squared length of a quat
3148	 *
3149	 * @param {quat} a vector to calculate squared length of
3150	 * @returns {Number} squared length of a
3151	 * @function
3152	 */
3153	quat.squaredLength = vec4.squaredLength;
3154
3155	/**
3156	 * Alias for {@link quat.squaredLength}
3157	 * @function
3158	 */
3159	quat.sqrLen = quat.squaredLength;
3160
3161	/**
3162	 * Normalize a quat
3163	 *
3164	 * @param {quat} out the receiving quaternion
3165	 * @param {quat} a quaternion to normalize
3166	 * @returns {quat} out
3167	 * @function
3168	 */
3169	quat.normalize = vec4.normalize;
3170
3171	/**
3172	 * Creates a quaternion from the given 3x3 rotation matrix.
3173	 *
3174	 * NOTE: The resultant quaternion is not normalized, so you should be sure
3175	 * to renormalize the quaternion yourself where necessary.
3176	 *
3177	 * @param {quat} out the receiving quaternion
3178	 * @param {mat3} m rotation matrix
3179	 * @returns {quat} out
3180	 * @function
3181	 */
3182	quat.fromMat3 = function(out, m) {
3183	    // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
3184	    // article "Quaternion Calculus and Fast Animation".
3185	    var fTrace = m[0] + m[4] + m[8];
3186	    var fRoot;
3187
3188	    if ( fTrace > 0.0 ) {
3189	        // |w| > 1/2, may as well choose w > 1/2
3190	        fRoot = Math.sqrt(fTrace + 1.0);  // 2w
3191	        out[3] = 0.5 * fRoot;
3192	        fRoot = 0.5/fRoot;  // 1/(4w)
3193	        out[0] = (m[5]-m[7])*fRoot;
3194	        out[1] = (m[6]-m[2])*fRoot;
3195	        out[2] = (m[1]-m[3])*fRoot;
3196	    } else {
3197	        // |w| <= 1/2
3198	        var i = 0;
3199	        if ( m[4] > m[0] )
3200	          i = 1;
3201	        if ( m[8] > m[i*3+i] )
3202	          i = 2;
3203	        var j = (i+1)%3;
3204	        var k = (i+2)%3;
3205
3206	        fRoot = Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k] + 1.0);
3207	        out[i] = 0.5 * fRoot;
3208	        fRoot = 0.5 / fRoot;
3209	        out[3] = (m[j*3+k] - m[k*3+j]) * fRoot;
3210	        out[j] = (m[j*3+i] + m[i*3+j]) * fRoot;
3211	        out[k] = (m[k*3+i] + m[i*3+k]) * fRoot;
3212	    }
3213
3214	    return out;
3215	};
3216
3217	/**
3218	 * Returns a string representation of a quatenion
3219	 *
3220	 * @param {quat} vec vector to represent as a string
3221	 * @returns {String} string representation of the vector
3222	 */
3223	quat.str = function (a) {
3224	    return 'quat(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
3225	};
3226
3227	module.exports = quat;
3228
3229
3230/***/ },
3231/* 7 */
3232/***/ function(module, exports, __webpack_require__) {
3233
3234	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
3235
3236	Permission is hereby granted, free of charge, to any person obtaining a copy
3237	of this software and associated documentation files (the "Software"), to deal
3238	in the Software without restriction, including without limitation the rights
3239	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3240	copies of the Software, and to permit persons to whom the Software is
3241	furnished to do so, subject to the following conditions:
3242
3243	The above copyright notice and this permission notice shall be included in
3244	all copies or substantial portions of the Software.
3245
3246	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3247	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3248	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3249	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3250	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3251	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3252	THE SOFTWARE. */
3253
3254	var glMatrix = __webpack_require__(1);
3255
3256	/**
3257	 * @class 3 Dimensional Vector
3258	 * @name vec3
3259	 */
3260	var vec3 = {};
3261
3262	/**
3263	 * Creates a new, empty vec3
3264	 *
3265	 * @returns {vec3} a new 3D vector
3266	 */
3267	vec3.create = function() {
3268	    var out = new glMatrix.ARRAY_TYPE(3);
3269	    out[0] = 0;
3270	    out[1] = 0;
3271	    out[2] = 0;
3272	    return out;
3273	};
3274
3275	/**
3276	 * Creates a new vec3 initialized with values from an existing vector
3277	 *
3278	 * @param {vec3} a vector to clone
3279	 * @returns {vec3} a new 3D vector
3280	 */
3281	vec3.clone = function(a) {
3282	    var out = new glMatrix.ARRAY_TYPE(3);
3283	    out[0] = a[0];
3284	    out[1] = a[1];
3285	    out[2] = a[2];
3286	    return out;
3287	};
3288
3289	/**
3290	 * Creates a new vec3 initialized with the given values
3291	 *
3292	 * @param {Number} x X component
3293	 * @param {Number} y Y component
3294	 * @param {Number} z Z component
3295	 * @returns {vec3} a new 3D vector
3296	 */
3297	vec3.fromValues = function(x, y, z) {
3298	    var out = new glMatrix.ARRAY_TYPE(3);
3299	    out[0] = x;
3300	    out[1] = y;
3301	    out[2] = z;
3302	    return out;
3303	};
3304
3305	/**
3306	 * Copy the values from one vec3 to another
3307	 *
3308	 * @param {vec3} out the receiving vector
3309	 * @param {vec3} a the source vector
3310	 * @returns {vec3} out
3311	 */
3312	vec3.copy = function(out, a) {
3313	    out[0] = a[0];
3314	    out[1] = a[1];
3315	    out[2] = a[2];
3316	    return out;
3317	};
3318
3319	/**
3320	 * Set the components of a vec3 to the given values
3321	 *
3322	 * @param {vec3} out the receiving vector
3323	 * @param {Number} x X component
3324	 * @param {Number} y Y component
3325	 * @param {Number} z Z component
3326	 * @returns {vec3} out
3327	 */
3328	vec3.set = function(out, x, y, z) {
3329	    out[0] = x;
3330	    out[1] = y;
3331	    out[2] = z;
3332	    return out;
3333	};
3334
3335	/**
3336	 * Adds two vec3's
3337	 *
3338	 * @param {vec3} out the receiving vector
3339	 * @param {vec3} a the first operand
3340	 * @param {vec3} b the second operand
3341	 * @returns {vec3} out
3342	 */
3343	vec3.add = function(out, a, b) {
3344	    out[0] = a[0] + b[0];
3345	    out[1] = a[1] + b[1];
3346	    out[2] = a[2] + b[2];
3347	    return out;
3348	};
3349
3350	/**
3351	 * Subtracts vector b from vector a
3352	 *
3353	 * @param {vec3} out the receiving vector
3354	 * @param {vec3} a the first operand
3355	 * @param {vec3} b the second operand
3356	 * @returns {vec3} out
3357	 */
3358	vec3.subtract = function(out, a, b) {
3359	    out[0] = a[0] - b[0];
3360	    out[1] = a[1] - b[1];
3361	    out[2] = a[2] - b[2];
3362	    return out;
3363	};
3364
3365	/**
3366	 * Alias for {@link vec3.subtract}
3367	 * @function
3368	 */
3369	vec3.sub = vec3.subtract;
3370
3371	/**
3372	 * Multiplies two vec3's
3373	 *
3374	 * @param {vec3} out the receiving vector
3375	 * @param {vec3} a the first operand
3376	 * @param {vec3} b the second operand
3377	 * @returns {vec3} out
3378	 */
3379	vec3.multiply = function(out, a, b) {
3380	    out[0] = a[0] * b[0];
3381	    out[1] = a[1] * b[1];
3382	    out[2] = a[2] * b[2];
3383	    return out;
3384	};
3385
3386	/**
3387	 * Alias for {@link vec3.multiply}
3388	 * @function
3389	 */
3390	vec3.mul = vec3.multiply;
3391
3392	/**
3393	 * Divides two vec3's
3394	 *
3395	 * @param {vec3} out the receiving vector
3396	 * @param {vec3} a the first operand
3397	 * @param {vec3} b the second operand
3398	 * @returns {vec3} out
3399	 */
3400	vec3.divide = function(out, a, b) {
3401	    out[0] = a[0] / b[0];
3402	    out[1] = a[1] / b[1];
3403	    out[2] = a[2] / b[2];
3404	    return out;
3405	};
3406
3407	/**
3408	 * Alias for {@link vec3.divide}
3409	 * @function
3410	 */
3411	vec3.div = vec3.divide;
3412
3413	/**
3414	 * Returns the minimum of two vec3's
3415	 *
3416	 * @param {vec3} out the receiving vector
3417	 * @param {vec3} a the first operand
3418	 * @param {vec3} b the second operand
3419	 * @returns {vec3} out
3420	 */
3421	vec3.min = function(out, a, b) {
3422	    out[0] = Math.min(a[0], b[0]);
3423	    out[1] = Math.min(a[1], b[1]);
3424	    out[2] = Math.min(a[2], b[2]);
3425	    return out;
3426	};
3427
3428	/**
3429	 * Returns the maximum of two vec3's
3430	 *
3431	 * @param {vec3} out the receiving vector
3432	 * @param {vec3} a the first operand
3433	 * @param {vec3} b the second operand
3434	 * @returns {vec3} out
3435	 */
3436	vec3.max = function(out, a, b) {
3437	    out[0] = Math.max(a[0], b[0]);
3438	    out[1] = Math.max(a[1], b[1]);
3439	    out[2] = Math.max(a[2], b[2]);
3440	    return out;
3441	};
3442
3443	/**
3444	 * Scales a vec3 by a scalar number
3445	 *
3446	 * @param {vec3} out the receiving vector
3447	 * @param {vec3} a the vector to scale
3448	 * @param {Number} b amount to scale the vector by
3449	 * @returns {vec3} out
3450	 */
3451	vec3.scale = function(out, a, b) {
3452	    out[0] = a[0] * b;
3453	    out[1] = a[1] * b;
3454	    out[2] = a[2] * b;
3455	    return out;
3456	};
3457
3458	/**
3459	 * Adds two vec3's after scaling the second operand by a scalar value
3460	 *
3461	 * @param {vec3} out the receiving vector
3462	 * @param {vec3} a the first operand
3463	 * @param {vec3} b the second operand
3464	 * @param {Number} scale the amount to scale b by before adding
3465	 * @returns {vec3} out
3466	 */
3467	vec3.scaleAndAdd = function(out, a, b, scale) {
3468	    out[0] = a[0] + (b[0] * scale);
3469	    out[1] = a[1] + (b[1] * scale);
3470	    out[2] = a[2] + (b[2] * scale);
3471	    return out;
3472	};
3473
3474	/**
3475	 * Calculates the euclidian distance between two vec3's
3476	 *
3477	 * @param {vec3} a the first operand
3478	 * @param {vec3} b the second operand
3479	 * @returns {Number} distance between a and b
3480	 */
3481	vec3.distance = function(a, b) {
3482	    var x = b[0] - a[0],
3483	        y = b[1] - a[1],
3484	        z = b[2] - a[2];
3485	    return Math.sqrt(x*x + y*y + z*z);
3486	};
3487
3488	/**
3489	 * Alias for {@link vec3.distance}
3490	 * @function
3491	 */
3492	vec3.dist = vec3.distance;
3493
3494	/**
3495	 * Calculates the squared euclidian distance between two vec3's
3496	 *
3497	 * @param {vec3} a the first operand
3498	 * @param {vec3} b the second operand
3499	 * @returns {Number} squared distance between a and b
3500	 */
3501	vec3.squaredDistance = function(a, b) {
3502	    var x = b[0] - a[0],
3503	        y = b[1] - a[1],
3504	        z = b[2] - a[2];
3505	    return x*x + y*y + z*z;
3506	};
3507
3508	/**
3509	 * Alias for {@link vec3.squaredDistance}
3510	 * @function
3511	 */
3512	vec3.sqrDist = vec3.squaredDistance;
3513
3514	/**
3515	 * Calculates the length of a vec3
3516	 *
3517	 * @param {vec3} a vector to calculate length of
3518	 * @returns {Number} length of a
3519	 */
3520	vec3.length = function (a) {
3521	    var x = a[0],
3522	        y = a[1],
3523	        z = a[2];
3524	    return Math.sqrt(x*x + y*y + z*z);
3525	};
3526
3527	/**
3528	 * Alias for {@link vec3.length}
3529	 * @function
3530	 */
3531	vec3.len = vec3.length;
3532
3533	/**
3534	 * Calculates the squared length of a vec3
3535	 *
3536	 * @param {vec3} a vector to calculate squared length of
3537	 * @returns {Number} squared length of a
3538	 */
3539	vec3.squaredLength = function (a) {
3540	    var x = a[0],
3541	        y = a[1],
3542	        z = a[2];
3543	    return x*x + y*y + z*z;
3544	};
3545
3546	/**
3547	 * Alias for {@link vec3.squaredLength}
3548	 * @function
3549	 */
3550	vec3.sqrLen = vec3.squaredLength;
3551
3552	/**
3553	 * Negates the components of a vec3
3554	 *
3555	 * @param {vec3} out the receiving vector
3556	 * @param {vec3} a vector to negate
3557	 * @returns {vec3} out
3558	 */
3559	vec3.negate = function(out, a) {
3560	    out[0] = -a[0];
3561	    out[1] = -a[1];
3562	    out[2] = -a[2];
3563	    return out;
3564	};
3565
3566	/**
3567	 * Returns the inverse of the components of a vec3
3568	 *
3569	 * @param {vec3} out the receiving vector
3570	 * @param {vec3} a vector to invert
3571	 * @returns {vec3} out
3572	 */
3573	vec3.inverse = function(out, a) {
3574	  out[0] = 1.0 / a[0];
3575	  out[1] = 1.0 / a[1];
3576	  out[2] = 1.0 / a[2];
3577	  return out;
3578	};
3579
3580	/**
3581	 * Normalize a vec3
3582	 *
3583	 * @param {vec3} out the receiving vector
3584	 * @param {vec3} a vector to normalize
3585	 * @returns {vec3} out
3586	 */
3587	vec3.normalize = function(out, a) {
3588	    var x = a[0],
3589	        y = a[1],
3590	        z = a[2];
3591	    var len = x*x + y*y + z*z;
3592	    if (len > 0) {
3593	        //TODO: evaluate use of glm_invsqrt here?
3594	        len = 1 / Math.sqrt(len);
3595	        out[0] = a[0] * len;
3596	        out[1] = a[1] * len;
3597	        out[2] = a[2] * len;
3598	    }
3599	    return out;
3600	};
3601
3602	/**
3603	 * Calculates the dot product of two vec3's
3604	 *
3605	 * @param {vec3} a the first operand
3606	 * @param {vec3} b the second operand
3607	 * @returns {Number} dot product of a and b
3608	 */
3609	vec3.dot = function (a, b) {
3610	    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
3611	};
3612
3613	/**
3614	 * Computes the cross product of two vec3's
3615	 *
3616	 * @param {vec3} out the receiving vector
3617	 * @param {vec3} a the first operand
3618	 * @param {vec3} b the second operand
3619	 * @returns {vec3} out
3620	 */
3621	vec3.cross = function(out, a, b) {
3622	    var ax = a[0], ay = a[1], az = a[2],
3623	        bx = b[0], by = b[1], bz = b[2];
3624
3625	    out[0] = ay * bz - az * by;
3626	    out[1] = az * bx - ax * bz;
3627	    out[2] = ax * by - ay * bx;
3628	    return out;
3629	};
3630
3631	/**
3632	 * Performs a linear interpolation between two vec3's
3633	 *
3634	 * @param {vec3} out the receiving vector
3635	 * @param {vec3} a the first operand
3636	 * @param {vec3} b the second operand
3637	 * @param {Number} t interpolation amount between the two inputs
3638	 * @returns {vec3} out
3639	 */
3640	vec3.lerp = function (out, a, b, t) {
3641	    var ax = a[0],
3642	        ay = a[1],
3643	        az = a[2];
3644	    out[0] = ax + t * (b[0] - ax);
3645	    out[1] = ay + t * (b[1] - ay);
3646	    out[2] = az + t * (b[2] - az);
3647	    return out;
3648	};
3649
3650	/**
3651	 * Performs a hermite interpolation with two control points
3652	 *
3653	 * @param {vec3} out the receiving vector
3654	 * @param {vec3} a the first operand
3655	 * @param {vec3} b the second operand
3656	 * @param {vec3} c the third operand
3657	 * @param {vec3} d the fourth operand
3658	 * @param {Number} t interpolation amount between the two inputs
3659	 * @returns {vec3} out
3660	 */
3661	vec3.hermite = function (out, a, b, c, d, t) {
3662	  var factorTimes2 = t * t,
3663	      factor1 = factorTimes2 * (2 * t - 3) + 1,
3664	      factor2 = factorTimes2 * (t - 2) + t,
3665	      factor3 = factorTimes2 * (t - 1),
3666	      factor4 = factorTimes2 * (3 - 2 * t);
3667
3668	  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
3669	  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
3670	  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
3671
3672	  return out;
3673	};
3674
3675	/**
3676	 * Performs a bezier interpolation with two control points
3677	 *
3678	 * @param {vec3} out the receiving vector
3679	 * @param {vec3} a the first operand
3680	 * @param {vec3} b the second operand
3681	 * @param {vec3} c the third operand
3682	 * @param {vec3} d the fourth operand
3683	 * @param {Number} t interpolation amount between the two inputs
3684	 * @returns {vec3} out
3685	 */
3686	vec3.bezier = function (out, a, b, c, d, t) {
3687	  var inverseFactor = 1 - t,
3688	      inverseFactorTimesTwo = inverseFactor * inverseFactor,
3689	      factorTimes2 = t * t,
3690	      factor1 = inverseFactorTimesTwo * inverseFactor,
3691	      factor2 = 3 * t * inverseFactorTimesTwo,
3692	      factor3 = 3 * factorTimes2 * inverseFactor,
3693	      factor4 = factorTimes2 * t;
3694
3695	  out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
3696	  out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
3697	  out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
3698
3699	  return out;
3700	};
3701
3702	/**
3703	 * Generates a random vector with the given scale
3704	 *
3705	 * @param {vec3} out the receiving vector
3706	 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
3707	 * @returns {vec3} out
3708	 */
3709	vec3.random = function (out, scale) {
3710	    scale = scale || 1.0;
3711
3712	    var r = glMatrix.RANDOM() * 2.0 * Math.PI;
3713	    var z = (glMatrix.RANDOM() * 2.0) - 1.0;
3714	    var zScale = Math.sqrt(1.0-z*z) * scale;
3715
3716	    out[0] = Math.cos(r) * zScale;
3717	    out[1] = Math.sin(r) * zScale;
3718	    out[2] = z * scale;
3719	    return out;
3720	};
3721
3722	/**
3723	 * Transforms the vec3 with a mat4.
3724	 * 4th vector component is implicitly '1'
3725	 *
3726	 * @param {vec3} out the receiving vector
3727	 * @param {vec3} a the vector to transform
3728	 * @param {mat4} m matrix to transform with
3729	 * @returns {vec3} out
3730	 */
3731	vec3.transformMat4 = function(out, a, m) {
3732	    var x = a[0], y = a[1], z = a[2],
3733	        w = m[3] * x + m[7] * y + m[11] * z + m[15];
3734	    w = w || 1.0;
3735	    out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
3736	    out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
3737	    out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
3738	    return out;
3739	};
3740
3741	/**
3742	 * Transforms the vec3 with a mat3.
3743	 *
3744	 * @param {vec3} out the receiving vector
3745	 * @param {vec3} a the vector to transform
3746	 * @param {mat4} m the 3x3 matrix to transform with
3747	 * @returns {vec3} out
3748	 */
3749	vec3.transformMat3 = function(out, a, m) {
3750	    var x = a[0], y = a[1], z = a[2];
3751	    out[0] = x * m[0] + y * m[3] + z * m[6];
3752	    out[1] = x * m[1] + y * m[4] + z * m[7];
3753	    out[2] = x * m[2] + y * m[5] + z * m[8];
3754	    return out;
3755	};
3756
3757	/**
3758	 * Transforms the vec3 with a quat
3759	 *
3760	 * @param {vec3} out the receiving vector
3761	 * @param {vec3} a the vector to transform
3762	 * @param {quat} q quaternion to transform with
3763	 * @returns {vec3} out
3764	 */
3765	vec3.transformQuat = function(out, a, q) {
3766	    // benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations
3767
3768	    var x = a[0], y = a[1], z = a[2],
3769	        qx = q[0], qy = q[1], qz = q[2], qw = q[3],
3770
3771	        // calculate quat * vec
3772	        ix = qw * x + qy * z - qz * y,
3773	        iy = qw * y + qz * x - qx * z,
3774	        iz = qw * z + qx * y - qy * x,
3775	        iw = -qx * x - qy * y - qz * z;
3776
3777	    // calculate result * inverse quat
3778	    out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
3779	    out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
3780	    out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
3781	    return out;
3782	};
3783
3784	/**
3785	 * Rotate a 3D vector around the x-axis
3786	 * @param {vec3} out The receiving vec3
3787	 * @param {vec3} a The vec3 point to rotate
3788	 * @param {vec3} b The origin of the rotation
3789	 * @param {Number} c The angle of rotation
3790	 * @returns {vec3} out
3791	 */
3792	vec3.rotateX = function(out, a, b, c){
3793	   var p = [], r=[];
3794		  //Translate point to the origin
3795		  p[0] = a[0] - b[0];
3796		  p[1] = a[1] - b[1];
3797	  	p[2] = a[2] - b[2];
3798
3799		  //perform rotation
3800		  r[0] = p[0];
3801		  r[1] = p[1]*Math.cos(c) - p[2]*Math.sin(c);
3802		  r[2] = p[1]*Math.sin(c) + p[2]*Math.cos(c);
3803
3804		  //translate to correct position
3805		  out[0] = r[0] + b[0];
3806		  out[1] = r[1] + b[1];
3807		  out[2] = r[2] + b[2];
3808
3809	  	return out;
3810	};
3811
3812	/**
3813	 * Rotate a 3D vector around the y-axis
3814	 * @param {vec3} out The receiving vec3
3815	 * @param {vec3} a The vec3 point to rotate
3816	 * @param {vec3} b The origin of the rotation
3817	 * @param {Number} c The angle of rotation
3818	 * @returns {vec3} out
3819	 */
3820	vec3.rotateY = function(out, a, b, c){
3821	  	var p = [], r=[];
3822	  	//Translate point to the origin
3823	  	p[0] = a[0] - b[0];
3824	  	p[1] = a[1] - b[1];
3825	  	p[2] = a[2] - b[2];
3826
3827	  	//perform rotation
3828	  	r[0] = p[2]*Math.sin(c) + p[0]*Math.cos(c);
3829	  	r[1] = p[1];
3830	  	r[2] = p[2]*Math.cos(c) - p[0]*Math.sin(c);
3831
3832	  	//translate to correct position
3833	  	out[0] = r[0] + b[0];
3834	  	out[1] = r[1] + b[1];
3835	  	out[2] = r[2] + b[2];
3836
3837	  	return out;
3838	};
3839
3840	/**
3841	 * Rotate a 3D vector around the z-axis
3842	 * @param {vec3} out The receiving vec3
3843	 * @param {vec3} a The vec3 point to rotate
3844	 * @param {vec3} b The origin of the rotation
3845	 * @param {Number} c The angle of rotation
3846	 * @returns {vec3} out
3847	 */
3848	vec3.rotateZ = function(out, a, b, c){
3849	  	var p = [], r=[];
3850	  	//Translate point to the origin
3851	  	p[0] = a[0] - b[0];
3852	  	p[1] = a[1] - b[1];
3853	  	p[2] = a[2] - b[2];
3854
3855	  	//perform rotation
3856	  	r[0] = p[0]*Math.cos(c) - p[1]*Math.sin(c);
3857	  	r[1] = p[0]*Math.sin(c) + p[1]*Math.cos(c);
3858	  	r[2] = p[2];
3859
3860	  	//translate to correct position
3861	  	out[0] = r[0] + b[0];
3862	  	out[1] = r[1] + b[1];
3863	  	out[2] = r[2] + b[2];
3864
3865	  	return out;
3866	};
3867
3868	/**
3869	 * Perform some operation over an array of vec3s.
3870	 *
3871	 * @param {Array} a the array of vectors to iterate over
3872	 * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
3873	 * @param {Number} offset Number of elements to skip at the beginning of the array
3874	 * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
3875	 * @param {Function} fn Function to call for each vector in the array
3876	 * @param {Object} [arg] additional argument to pass to fn
3877	 * @returns {Array} a
3878	 * @function
3879	 */
3880	vec3.forEach = (function() {
3881	    var vec = vec3.create();
3882
3883	    return function(a, stride, offset, count, fn, arg) {
3884	        var i, l;
3885	        if(!stride) {
3886	            stride = 3;
3887	        }
3888
3889	        if(!offset) {
3890	            offset = 0;
3891	        }
3892
3893	        if(count) {
3894	            l = Math.min((count * stride) + offset, a.length);
3895	        } else {
3896	            l = a.length;
3897	        }
3898
3899	        for(i = offset; i < l; i += stride) {
3900	            vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2];
3901	            fn(vec, vec, arg);
3902	            a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2];
3903	        }
3904
3905	        return a;
3906	    };
3907	})();
3908
3909	/**
3910	 * Get the angle between two 3D vectors
3911	 * @param {vec3} a The first operand
3912	 * @param {vec3} b The second operand
3913	 * @returns {Number} The angle in radians
3914	 */
3915	vec3.angle = function(a, b) {
3916
3917	    var tempA = vec3.fromValues(a[0], a[1], a[2]);
3918	    var tempB = vec3.fromValues(b[0], b[1], b[2]);
3919
3920	    vec3.normalize(tempA, tempA);
3921	    vec3.normalize(tempB, tempB);
3922
3923	    var cosine = vec3.dot(tempA, tempB);
3924
3925	    if(cosine > 1.0){
3926	        return 0;
3927	    } else {
3928	        return Math.acos(cosine);
3929	    }
3930	};
3931
3932	/**
3933	 * Returns a string representation of a vector
3934	 *
3935	 * @param {vec3} vec vector to represent as a string
3936	 * @returns {String} string representation of the vector
3937	 */
3938	vec3.str = function (a) {
3939	    return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
3940	};
3941
3942	module.exports = vec3;
3943
3944
3945/***/ },
3946/* 8 */
3947/***/ function(module, exports, __webpack_require__) {
3948
3949	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
3950
3951	Permission is hereby granted, free of charge, to any person obtaining a copy
3952	of this software and associated documentation files (the "Software"), to deal
3953	in the Software without restriction, including without limitation the rights
3954	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
3955	copies of the Software, and to permit persons to whom the Software is
3956	furnished to do so, subject to the following conditions:
3957
3958	The above copyright notice and this permission notice shall be included in
3959	all copies or substantial portions of the Software.
3960
3961	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3962	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
3963	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
3964	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
3965	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
3966	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
3967	THE SOFTWARE. */
3968
3969	var glMatrix = __webpack_require__(1);
3970
3971	/**
3972	 * @class 4 Dimensional Vector
3973	 * @name vec4
3974	 */
3975	var vec4 = {};
3976
3977	/**
3978	 * Creates a new, empty vec4
3979	 *
3980	 * @returns {vec4} a new 4D vector
3981	 */
3982	vec4.create = function() {
3983	    var out = new glMatrix.ARRAY_TYPE(4);
3984	    out[0] = 0;
3985	    out[1] = 0;
3986	    out[2] = 0;
3987	    out[3] = 0;
3988	    return out;
3989	};
3990
3991	/**
3992	 * Creates a new vec4 initialized with values from an existing vector
3993	 *
3994	 * @param {vec4} a vector to clone
3995	 * @returns {vec4} a new 4D vector
3996	 */
3997	vec4.clone = function(a) {
3998	    var out = new glMatrix.ARRAY_TYPE(4);
3999	    out[0] = a[0];
4000	    out[1] = a[1];
4001	    out[2] = a[2];
4002	    out[3] = a[3];
4003	    return out;
4004	};
4005
4006	/**
4007	 * Creates a new vec4 initialized with the given values
4008	 *
4009	 * @param {Number} x X component
4010	 * @param {Number} y Y component
4011	 * @param {Number} z Z component
4012	 * @param {Number} w W component
4013	 * @returns {vec4} a new 4D vector
4014	 */
4015	vec4.fromValues = function(x, y, z, w) {
4016	    var out = new glMatrix.ARRAY_TYPE(4);
4017	    out[0] = x;
4018	    out[1] = y;
4019	    out[2] = z;
4020	    out[3] = w;
4021	    return out;
4022	};
4023
4024	/**
4025	 * Copy the values from one vec4 to another
4026	 *
4027	 * @param {vec4} out the receiving vector
4028	 * @param {vec4} a the source vector
4029	 * @returns {vec4} out
4030	 */
4031	vec4.copy = function(out, a) {
4032	    out[0] = a[0];
4033	    out[1] = a[1];
4034	    out[2] = a[2];
4035	    out[3] = a[3];
4036	    return out;
4037	};
4038
4039	/**
4040	 * Set the components of a vec4 to the given values
4041	 *
4042	 * @param {vec4} out the receiving vector
4043	 * @param {Number} x X component
4044	 * @param {Number} y Y component
4045	 * @param {Number} z Z component
4046	 * @param {Number} w W component
4047	 * @returns {vec4} out
4048	 */
4049	vec4.set = function(out, x, y, z, w) {
4050	    out[0] = x;
4051	    out[1] = y;
4052	    out[2] = z;
4053	    out[3] = w;
4054	    return out;
4055	};
4056
4057	/**
4058	 * Adds two vec4's
4059	 *
4060	 * @param {vec4} out the receiving vector
4061	 * @param {vec4} a the first operand
4062	 * @param {vec4} b the second operand
4063	 * @returns {vec4} out
4064	 */
4065	vec4.add = function(out, a, b) {
4066	    out[0] = a[0] + b[0];
4067	    out[1] = a[1] + b[1];
4068	    out[2] = a[2] + b[2];
4069	    out[3] = a[3] + b[3];
4070	    return out;
4071	};
4072
4073	/**
4074	 * Subtracts vector b from vector a
4075	 *
4076	 * @param {vec4} out the receiving vector
4077	 * @param {vec4} a the first operand
4078	 * @param {vec4} b the second operand
4079	 * @returns {vec4} out
4080	 */
4081	vec4.subtract = function(out, a, b) {
4082	    out[0] = a[0] - b[0];
4083	    out[1] = a[1] - b[1];
4084	    out[2] = a[2] - b[2];
4085	    out[3] = a[3] - b[3];
4086	    return out;
4087	};
4088
4089	/**
4090	 * Alias for {@link vec4.subtract}
4091	 * @function
4092	 */
4093	vec4.sub = vec4.subtract;
4094
4095	/**
4096	 * Multiplies two vec4's
4097	 *
4098	 * @param {vec4} out the receiving vector
4099	 * @param {vec4} a the first operand
4100	 * @param {vec4} b the second operand
4101	 * @returns {vec4} out
4102	 */
4103	vec4.multiply = function(out, a, b) {
4104	    out[0] = a[0] * b[0];
4105	    out[1] = a[1] * b[1];
4106	    out[2] = a[2] * b[2];
4107	    out[3] = a[3] * b[3];
4108	    return out;
4109	};
4110
4111	/**
4112	 * Alias for {@link vec4.multiply}
4113	 * @function
4114	 */
4115	vec4.mul = vec4.multiply;
4116
4117	/**
4118	 * Divides two vec4's
4119	 *
4120	 * @param {vec4} out the receiving vector
4121	 * @param {vec4} a the first operand
4122	 * @param {vec4} b the second operand
4123	 * @returns {vec4} out
4124	 */
4125	vec4.divide = function(out, a, b) {
4126	    out[0] = a[0] / b[0];
4127	    out[1] = a[1] / b[1];
4128	    out[2] = a[2] / b[2];
4129	    out[3] = a[3] / b[3];
4130	    return out;
4131	};
4132
4133	/**
4134	 * Alias for {@link vec4.divide}
4135	 * @function
4136	 */
4137	vec4.div = vec4.divide;
4138
4139	/**
4140	 * Returns the minimum of two vec4's
4141	 *
4142	 * @param {vec4} out the receiving vector
4143	 * @param {vec4} a the first operand
4144	 * @param {vec4} b the second operand
4145	 * @returns {vec4} out
4146	 */
4147	vec4.min = function(out, a, b) {
4148	    out[0] = Math.min(a[0], b[0]);
4149	    out[1] = Math.min(a[1], b[1]);
4150	    out[2] = Math.min(a[2], b[2]);
4151	    out[3] = Math.min(a[3], b[3]);
4152	    return out;
4153	};
4154
4155	/**
4156	 * Returns the maximum of two vec4's
4157	 *
4158	 * @param {vec4} out the receiving vector
4159	 * @param {vec4} a the first operand
4160	 * @param {vec4} b the second operand
4161	 * @returns {vec4} out
4162	 */
4163	vec4.max = function(out, a, b) {
4164	    out[0] = Math.max(a[0], b[0]);
4165	    out[1] = Math.max(a[1], b[1]);
4166	    out[2] = Math.max(a[2], b[2]);
4167	    out[3] = Math.max(a[3], b[3]);
4168	    return out;
4169	};
4170
4171	/**
4172	 * Scales a vec4 by a scalar number
4173	 *
4174	 * @param {vec4} out the receiving vector
4175	 * @param {vec4} a the vector to scale
4176	 * @param {Number} b amount to scale the vector by
4177	 * @returns {vec4} out
4178	 */
4179	vec4.scale = function(out, a, b) {
4180	    out[0] = a[0] * b;
4181	    out[1] = a[1] * b;
4182	    out[2] = a[2] * b;
4183	    out[3] = a[3] * b;
4184	    return out;
4185	};
4186
4187	/**
4188	 * Adds two vec4's after scaling the second operand by a scalar value
4189	 *
4190	 * @param {vec4} out the receiving vector
4191	 * @param {vec4} a the first operand
4192	 * @param {vec4} b the second operand
4193	 * @param {Number} scale the amount to scale b by before adding
4194	 * @returns {vec4} out
4195	 */
4196	vec4.scaleAndAdd = function(out, a, b, scale) {
4197	    out[0] = a[0] + (b[0] * scale);
4198	    out[1] = a[1] + (b[1] * scale);
4199	    out[2] = a[2] + (b[2] * scale);
4200	    out[3] = a[3] + (b[3] * scale);
4201	    return out;
4202	};
4203
4204	/**
4205	 * Calculates the euclidian distance between two vec4's
4206	 *
4207	 * @param {vec4} a the first operand
4208	 * @param {vec4} b the second operand
4209	 * @returns {Number} distance between a and b
4210	 */
4211	vec4.distance = function(a, b) {
4212	    var x = b[0] - a[0],
4213	        y = b[1] - a[1],
4214	        z = b[2] - a[2],
4215	        w = b[3] - a[3];
4216	    return Math.sqrt(x*x + y*y + z*z + w*w);
4217	};
4218
4219	/**
4220	 * Alias for {@link vec4.distance}
4221	 * @function
4222	 */
4223	vec4.dist = vec4.distance;
4224
4225	/**
4226	 * Calculates the squared euclidian distance between two vec4's
4227	 *
4228	 * @param {vec4} a the first operand
4229	 * @param {vec4} b the second operand
4230	 * @returns {Number} squared distance between a and b
4231	 */
4232	vec4.squaredDistance = function(a, b) {
4233	    var x = b[0] - a[0],
4234	        y = b[1] - a[1],
4235	        z = b[2] - a[2],
4236	        w = b[3] - a[3];
4237	    return x*x + y*y + z*z + w*w;
4238	};
4239
4240	/**
4241	 * Alias for {@link vec4.squaredDistance}
4242	 * @function
4243	 */
4244	vec4.sqrDist = vec4.squaredDistance;
4245
4246	/**
4247	 * Calculates the length of a vec4
4248	 *
4249	 * @param {vec4} a vector to calculate length of
4250	 * @returns {Number} length of a
4251	 */
4252	vec4.length = function (a) {
4253	    var x = a[0],
4254	        y = a[1],
4255	        z = a[2],
4256	        w = a[3];
4257	    return Math.sqrt(x*x + y*y + z*z + w*w);
4258	};
4259
4260	/**
4261	 * Alias for {@link vec4.length}
4262	 * @function
4263	 */
4264	vec4.len = vec4.length;
4265
4266	/**
4267	 * Calculates the squared length of a vec4
4268	 *
4269	 * @param {vec4} a vector to calculate squared length of
4270	 * @returns {Number} squared length of a
4271	 */
4272	vec4.squaredLength = function (a) {
4273	    var x = a[0],
4274	        y = a[1],
4275	        z = a[2],
4276	        w = a[3];
4277	    return x*x + y*y + z*z + w*w;
4278	};
4279
4280	/**
4281	 * Alias for {@link vec4.squaredLength}
4282	 * @function
4283	 */
4284	vec4.sqrLen = vec4.squaredLength;
4285
4286	/**
4287	 * Negates the components of a vec4
4288	 *
4289	 * @param {vec4} out the receiving vector
4290	 * @param {vec4} a vector to negate
4291	 * @returns {vec4} out
4292	 */
4293	vec4.negate = function(out, a) {
4294	    out[0] = -a[0];
4295	    out[1] = -a[1];
4296	    out[2] = -a[2];
4297	    out[3] = -a[3];
4298	    return out;
4299	};
4300
4301	/**
4302	 * Returns the inverse of the components of a vec4
4303	 *
4304	 * @param {vec4} out the receiving vector
4305	 * @param {vec4} a vector to invert
4306	 * @returns {vec4} out
4307	 */
4308	vec4.inverse = function(out, a) {
4309	  out[0] = 1.0 / a[0];
4310	  out[1] = 1.0 / a[1];
4311	  out[2] = 1.0 / a[2];
4312	  out[3] = 1.0 / a[3];
4313	  return out;
4314	};
4315
4316	/**
4317	 * Normalize a vec4
4318	 *
4319	 * @param {vec4} out the receiving vector
4320	 * @param {vec4} a vector to normalize
4321	 * @returns {vec4} out
4322	 */
4323	vec4.normalize = function(out, a) {
4324	    var x = a[0],
4325	        y = a[1],
4326	        z = a[2],
4327	        w = a[3];
4328	    var len = x*x + y*y + z*z + w*w;
4329	    if (len > 0) {
4330	        len = 1 / Math.sqrt(len);
4331	        out[0] = x * len;
4332	        out[1] = y * len;
4333	        out[2] = z * len;
4334	        out[3] = w * len;
4335	    }
4336	    return out;
4337	};
4338
4339	/**
4340	 * Calculates the dot product of two vec4's
4341	 *
4342	 * @param {vec4} a the first operand
4343	 * @param {vec4} b the second operand
4344	 * @returns {Number} dot product of a and b
4345	 */
4346	vec4.dot = function (a, b) {
4347	    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
4348	};
4349
4350	/**
4351	 * Performs a linear interpolation between two vec4's
4352	 *
4353	 * @param {vec4} out the receiving vector
4354	 * @param {vec4} a the first operand
4355	 * @param {vec4} b the second operand
4356	 * @param {Number} t interpolation amount between the two inputs
4357	 * @returns {vec4} out
4358	 */
4359	vec4.lerp = function (out, a, b, t) {
4360	    var ax = a[0],
4361	        ay = a[1],
4362	        az = a[2],
4363	        aw = a[3];
4364	    out[0] = ax + t * (b[0] - ax);
4365	    out[1] = ay + t * (b[1] - ay);
4366	    out[2] = az + t * (b[2] - az);
4367	    out[3] = aw + t * (b[3] - aw);
4368	    return out;
4369	};
4370
4371	/**
4372	 * Generates a random vector with the given scale
4373	 *
4374	 * @param {vec4} out the receiving vector
4375	 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
4376	 * @returns {vec4} out
4377	 */
4378	vec4.random = function (out, scale) {
4379	    scale = scale || 1.0;
4380
4381	    //TODO: This is a pretty awful way of doing this. Find something better.
4382	    out[0] = glMatrix.RANDOM();
4383	    out[1] = glMatrix.RANDOM();
4384	    out[2] = glMatrix.RANDOM();
4385	    out[3] = glMatrix.RANDOM();
4386	    vec4.normalize(out, out);
4387	    vec4.scale(out, out, scale);
4388	    return out;
4389	};
4390
4391	/**
4392	 * Transforms the vec4 with a mat4.
4393	 *
4394	 * @param {vec4} out the receiving vector
4395	 * @param {vec4} a the vector to transform
4396	 * @param {mat4} m matrix to transform with
4397	 * @returns {vec4} out
4398	 */
4399	vec4.transformMat4 = function(out, a, m) {
4400	    var x = a[0], y = a[1], z = a[2], w = a[3];
4401	    out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
4402	    out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
4403	    out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
4404	    out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
4405	    return out;
4406	};
4407
4408	/**
4409	 * Transforms the vec4 with a quat
4410	 *
4411	 * @param {vec4} out the receiving vector
4412	 * @param {vec4} a the vector to transform
4413	 * @param {quat} q quaternion to transform with
4414	 * @returns {vec4} out
4415	 */
4416	vec4.transformQuat = function(out, a, q) {
4417	    var x = a[0], y = a[1], z = a[2],
4418	        qx = q[0], qy = q[1], qz = q[2], qw = q[3],
4419
4420	        // calculate quat * vec
4421	        ix = qw * x + qy * z - qz * y,
4422	        iy = qw * y + qz * x - qx * z,
4423	        iz = qw * z + qx * y - qy * x,
4424	        iw = -qx * x - qy * y - qz * z;
4425
4426	    // calculate result * inverse quat
4427	    out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
4428	    out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
4429	    out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
4430	    out[3] = a[3];
4431	    return out;
4432	};
4433
4434	/**
4435	 * Perform some operation over an array of vec4s.
4436	 *
4437	 * @param {Array} a the array of vectors to iterate over
4438	 * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
4439	 * @param {Number} offset Number of elements to skip at the beginning of the array
4440	 * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
4441	 * @param {Function} fn Function to call for each vector in the array
4442	 * @param {Object} [arg] additional argument to pass to fn
4443	 * @returns {Array} a
4444	 * @function
4445	 */
4446	vec4.forEach = (function() {
4447	    var vec = vec4.create();
4448
4449	    return function(a, stride, offset, count, fn, arg) {
4450	        var i, l;
4451	        if(!stride) {
4452	            stride = 4;
4453	        }
4454
4455	        if(!offset) {
4456	            offset = 0;
4457	        }
4458
4459	        if(count) {
4460	            l = Math.min((count * stride) + offset, a.length);
4461	        } else {
4462	            l = a.length;
4463	        }
4464
4465	        for(i = offset; i < l; i += stride) {
4466	            vec[0] = a[i]; vec[1] = a[i+1]; vec[2] = a[i+2]; vec[3] = a[i+3];
4467	            fn(vec, vec, arg);
4468	            a[i] = vec[0]; a[i+1] = vec[1]; a[i+2] = vec[2]; a[i+3] = vec[3];
4469	        }
4470
4471	        return a;
4472	    };
4473	})();
4474
4475	/**
4476	 * Returns a string representation of a vector
4477	 *
4478	 * @param {vec4} vec vector to represent as a string
4479	 * @returns {String} string representation of the vector
4480	 */
4481	vec4.str = function (a) {
4482	    return 'vec4(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ')';
4483	};
4484
4485	module.exports = vec4;
4486
4487
4488/***/ },
4489/* 9 */
4490/***/ function(module, exports, __webpack_require__) {
4491
4492	/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
4493
4494	Permission is hereby granted, free of charge, to any person obtaining a copy
4495	of this software and associated documentation files (the "Software"), to deal
4496	in the Software without restriction, including without limitation the rights
4497	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4498	copies of the Software, and to permit persons to whom the Software is
4499	furnished to do so, subject to the following conditions:
4500
4501	The above copyright notice and this permission notice shall be included in
4502	all copies or substantial portions of the Software.
4503
4504	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4505	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4506	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4507	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4508	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4509	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
4510	THE SOFTWARE. */
4511
4512	var glMatrix = __webpack_require__(1);
4513
4514	/**
4515	 * @class 2 Dimensional Vector
4516	 * @name vec2
4517	 */
4518	var vec2 = {};
4519
4520	/**
4521	 * Creates a new, empty vec2
4522	 *
4523	 * @returns {vec2} a new 2D vector
4524	 */
4525	vec2.create = function() {
4526	    var out = new glMatrix.ARRAY_TYPE(2);
4527	    out[0] = 0;
4528	    out[1] = 0;
4529	    return out;
4530	};
4531
4532	/**
4533	 * Creates a new vec2 initialized with values from an existing vector
4534	 *
4535	 * @param {vec2} a vector to clone
4536	 * @returns {vec2} a new 2D vector
4537	 */
4538	vec2.clone = function(a) {
4539	    var out = new glMatrix.ARRAY_TYPE(2);
4540	    out[0] = a[0];
4541	    out[1] = a[1];
4542	    return out;
4543	};
4544
4545	/**
4546	 * Creates a new vec2 initialized with the given values
4547	 *
4548	 * @param {Number} x X component
4549	 * @param {Number} y Y component
4550	 * @returns {vec2} a new 2D vector
4551	 */
4552	vec2.fromValues = function(x, y) {
4553	    var out = new glMatrix.ARRAY_TYPE(2);
4554	    out[0] = x;
4555	    out[1] = y;
4556	    return out;
4557	};
4558
4559	/**
4560	 * Copy the values from one vec2 to another
4561	 *
4562	 * @param {vec2} out the receiving vector
4563	 * @param {vec2} a the source vector
4564	 * @returns {vec2} out
4565	 */
4566	vec2.copy = function(out, a) {
4567	    out[0] = a[0];
4568	    out[1] = a[1];
4569	    return out;
4570	};
4571
4572	/**
4573	 * Set the components of a vec2 to the given values
4574	 *
4575	 * @param {vec2} out the receiving vector
4576	 * @param {Number} x X component
4577	 * @param {Number} y Y component
4578	 * @returns {vec2} out
4579	 */
4580	vec2.set = function(out, x, y) {
4581	    out[0] = x;
4582	    out[1] = y;
4583	    return out;
4584	};
4585
4586	/**
4587	 * Adds two vec2's
4588	 *
4589	 * @param {vec2} out the receiving vector
4590	 * @param {vec2} a the first operand
4591	 * @param {vec2} b the second operand
4592	 * @returns {vec2} out
4593	 */
4594	vec2.add = function(out, a, b) {
4595	    out[0] = a[0] + b[0];
4596	    out[1] = a[1] + b[1];
4597	    return out;
4598	};
4599
4600	/**
4601	 * Subtracts vector b from vector a
4602	 *
4603	 * @param {vec2} out the receiving vector
4604	 * @param {vec2} a the first operand
4605	 * @param {vec2} b the second operand
4606	 * @returns {vec2} out
4607	 */
4608	vec2.subtract = function(out, a, b) {
4609	    out[0] = a[0] - b[0];
4610	    out[1] = a[1] - b[1];
4611	    return out;
4612	};
4613
4614	/**
4615	 * Alias for {@link vec2.subtract}
4616	 * @function
4617	 */
4618	vec2.sub = vec2.subtract;
4619
4620	/**
4621	 * Multiplies two vec2's
4622	 *
4623	 * @param {vec2} out the receiving vector
4624	 * @param {vec2} a the first operand
4625	 * @param {vec2} b the second operand
4626	 * @returns {vec2} out
4627	 */
4628	vec2.multiply = function(out, a, b) {
4629	    out[0] = a[0] * b[0];
4630	    out[1] = a[1] * b[1];
4631	    return out;
4632	};
4633
4634	/**
4635	 * Alias for {@link vec2.multiply}
4636	 * @function
4637	 */
4638	vec2.mul = vec2.multiply;
4639
4640	/**
4641	 * Divides two vec2's
4642	 *
4643	 * @param {vec2} out the receiving vector
4644	 * @param {vec2} a the first operand
4645	 * @param {vec2} b the second operand
4646	 * @returns {vec2} out
4647	 */
4648	vec2.divide = function(out, a, b) {
4649	    out[0] = a[0] / b[0];
4650	    out[1] = a[1] / b[1];
4651	    return out;
4652	};
4653
4654	/**
4655	 * Alias for {@link vec2.divide}
4656	 * @function
4657	 */
4658	vec2.div = vec2.divide;
4659
4660	/**
4661	 * Returns the minimum of two vec2's
4662	 *
4663	 * @param {vec2} out the receiving vector
4664	 * @param {vec2} a the first operand
4665	 * @param {vec2} b the second operand
4666	 * @returns {vec2} out
4667	 */
4668	vec2.min = function(out, a, b) {
4669	    out[0] = Math.min(a[0], b[0]);
4670	    out[1] = Math.min(a[1], b[1]);
4671	    return out;
4672	};
4673
4674	/**
4675	 * Returns the maximum of two vec2's
4676	 *
4677	 * @param {vec2} out the receiving vector
4678	 * @param {vec2} a the first operand
4679	 * @param {vec2} b the second operand
4680	 * @returns {vec2} out
4681	 */
4682	vec2.max = function(out, a, b) {
4683	    out[0] = Math.max(a[0], b[0]);
4684	    out[1] = Math.max(a[1], b[1]);
4685	    return out;
4686	};
4687
4688	/**
4689	 * Scales a vec2 by a scalar number
4690	 *
4691	 * @param {vec2} out the receiving vector
4692	 * @param {vec2} a the vector to scale
4693	 * @param {Number} b amount to scale the vector by
4694	 * @returns {vec2} out
4695	 */
4696	vec2.scale = function(out, a, b) {
4697	    out[0] = a[0] * b;
4698	    out[1] = a[1] * b;
4699	    return out;
4700	};
4701
4702	/**
4703	 * Adds two vec2's after scaling the second operand by a scalar value
4704	 *
4705	 * @param {vec2} out the receiving vector
4706	 * @param {vec2} a the first operand
4707	 * @param {vec2} b the second operand
4708	 * @param {Number} scale the amount to scale b by before adding
4709	 * @returns {vec2} out
4710	 */
4711	vec2.scaleAndAdd = function(out, a, b, scale) {
4712	    out[0] = a[0] + (b[0] * scale);
4713	    out[1] = a[1] + (b[1] * scale);
4714	    return out;
4715	};
4716
4717	/**
4718	 * Calculates the euclidian distance between two vec2's
4719	 *
4720	 * @param {vec2} a the first operand
4721	 * @param {vec2} b the second operand
4722	 * @returns {Number} distance between a and b
4723	 */
4724	vec2.distance = function(a, b) {
4725	    var x = b[0] - a[0],
4726	        y = b[1] - a[1];
4727	    return Math.sqrt(x*x + y*y);
4728	};
4729
4730	/**
4731	 * Alias for {@link vec2.distance}
4732	 * @function
4733	 */
4734	vec2.dist = vec2.distance;
4735
4736	/**
4737	 * Calculates the squared euclidian distance between two vec2's
4738	 *
4739	 * @param {vec2} a the first operand
4740	 * @param {vec2} b the second operand
4741	 * @returns {Number} squared distance between a and b
4742	 */
4743	vec2.squaredDistance = function(a, b) {
4744	    var x = b[0] - a[0],
4745	        y = b[1] - a[1];
4746	    return x*x + y*y;
4747	};
4748
4749	/**
4750	 * Alias for {@link vec2.squaredDistance}
4751	 * @function
4752	 */
4753	vec2.sqrDist = vec2.squaredDistance;
4754
4755	/**
4756	 * Calculates the length of a vec2
4757	 *
4758	 * @param {vec2} a vector to calculate length of
4759	 * @returns {Number} length of a
4760	 */
4761	vec2.length = function (a) {
4762	    var x = a[0],
4763	        y = a[1];
4764	    return Math.sqrt(x*x + y*y);
4765	};
4766
4767	/**
4768	 * Alias for {@link vec2.length}
4769	 * @function
4770	 */
4771	vec2.len = vec2.length;
4772
4773	/**
4774	 * Calculates the squared length of a vec2
4775	 *
4776	 * @param {vec2} a vector to calculate squared length of
4777	 * @returns {Number} squared length of a
4778	 */
4779	vec2.squaredLength = function (a) {
4780	    var x = a[0],
4781	        y = a[1];
4782	    return x*x + y*y;
4783	};
4784
4785	/**
4786	 * Alias for {@link vec2.squaredLength}
4787	 * @function
4788	 */
4789	vec2.sqrLen = vec2.squaredLength;
4790
4791	/**
4792	 * Negates the components of a vec2
4793	 *
4794	 * @param {vec2} out the receiving vector
4795	 * @param {vec2} a vector to negate
4796	 * @returns {vec2} out
4797	 */
4798	vec2.negate = function(out, a) {
4799	    out[0] = -a[0];
4800	    out[1] = -a[1];
4801	    return out;
4802	};
4803
4804	/**
4805	 * Returns the inverse of the components of a vec2
4806	 *
4807	 * @param {vec2} out the receiving vector
4808	 * @param {vec2} a vector to invert
4809	 * @returns {vec2} out
4810	 */
4811	vec2.inverse = function(out, a) {
4812	  out[0] = 1.0 / a[0];
4813	  out[1] = 1.0 / a[1];
4814	  return out;
4815	};
4816
4817	/**
4818	 * Normalize a vec2
4819	 *
4820	 * @param {vec2} out the receiving vector
4821	 * @param {vec2} a vector to normalize
4822	 * @returns {vec2} out
4823	 */
4824	vec2.normalize = function(out, a) {
4825	    var x = a[0],
4826	        y = a[1];
4827	    var len = x*x + y*y;
4828	    if (len > 0) {
4829	        //TODO: evaluate use of glm_invsqrt here?
4830	        len = 1 / Math.sqrt(len);
4831	        out[0] = a[0] * len;
4832	        out[1] = a[1] * len;
4833	    }
4834	    return out;
4835	};
4836
4837	/**
4838	 * Calculates the dot product of two vec2's
4839	 *
4840	 * @param {vec2} a the first operand
4841	 * @param {vec2} b the second operand
4842	 * @returns {Number} dot product of a and b
4843	 */
4844	vec2.dot = function (a, b) {
4845	    return a[0] * b[0] + a[1] * b[1];
4846	};
4847
4848	/**
4849	 * Computes the cross product of two vec2's
4850	 * Note that the cross product must by definition produce a 3D vector
4851	 *
4852	 * @param {vec3} out the receiving vector
4853	 * @param {vec2} a the first operand
4854	 * @param {vec2} b the second operand
4855	 * @returns {vec3} out
4856	 */
4857	vec2.cross = function(out, a, b) {
4858	    var z = a[0] * b[1] - a[1] * b[0];
4859	    out[0] = out[1] = 0;
4860	    out[2] = z;
4861	    return out;
4862	};
4863
4864	/**
4865	 * Performs a linear interpolation between two vec2's
4866	 *
4867	 * @param {vec2} out the receiving vector
4868	 * @param {vec2} a the first operand
4869	 * @param {vec2} b the second operand
4870	 * @param {Number} t interpolation amount between the two inputs
4871	 * @returns {vec2} out
4872	 */
4873	vec2.lerp = function (out, a, b, t) {
4874	    var ax = a[0],
4875	        ay = a[1];
4876	    out[0] = ax + t * (b[0] - ax);
4877	    out[1] = ay + t * (b[1] - ay);
4878	    return out;
4879	};
4880
4881	/**
4882	 * Generates a random vector with the given scale
4883	 *
4884	 * @param {vec2} out the receiving vector
4885	 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
4886	 * @returns {vec2} out
4887	 */
4888	vec2.random = function (out, scale) {
4889	    scale = scale || 1.0;
4890	    var r = glMatrix.RANDOM() * 2.0 * Math.PI;
4891	    out[0] = Math.cos(r) * scale;
4892	    out[1] = Math.sin(r) * scale;
4893	    return out;
4894	};
4895
4896	/**
4897	 * Transforms the vec2 with a mat2
4898	 *
4899	 * @param {vec2} out the receiving vector
4900	 * @param {vec2} a the vector to transform
4901	 * @param {mat2} m matrix to transform with
4902	 * @returns {vec2} out
4903	 */
4904	vec2.transformMat2 = function(out, a, m) {
4905	    var x = a[0],
4906	        y = a[1];
4907	    out[0] = m[0] * x + m[2] * y;
4908	    out[1] = m[1] * x + m[3] * y;
4909	    return out;
4910	};
4911
4912	/**
4913	 * Transforms the vec2 with a mat2d
4914	 *
4915	 * @param {vec2} out the receiving vector
4916	 * @param {vec2} a the vector to transform
4917	 * @param {mat2d} m matrix to transform with
4918	 * @returns {vec2} out
4919	 */
4920	vec2.transformMat2d = function(out, a, m) {
4921	    var x = a[0],
4922	        y = a[1];
4923	    out[0] = m[0] * x + m[2] * y + m[4];
4924	    out[1] = m[1] * x + m[3] * y + m[5];
4925	    return out;
4926	};
4927
4928	/**
4929	 * Transforms the vec2 with a mat3
4930	 * 3rd vector component is implicitly '1'
4931	 *
4932	 * @param {vec2} out the receiving vector
4933	 * @param {vec2} a the vector to transform
4934	 * @param {mat3} m matrix to transform with
4935	 * @returns {vec2} out
4936	 */
4937	vec2.transformMat3 = function(out, a, m) {
4938	    var x = a[0],
4939	        y = a[1];
4940	    out[0] = m[0] * x + m[3] * y + m[6];
4941	    out[1] = m[1] * x + m[4] * y + m[7];
4942	    return out;
4943	};
4944
4945	/**
4946	 * Transforms the vec2 with a mat4
4947	 * 3rd vector component is implicitly '0'
4948	 * 4th vector component is implicitly '1'
4949	 *
4950	 * @param {vec2} out the receiving vector
4951	 * @param {vec2} a the vector to transform
4952	 * @param {mat4} m matrix to transform with
4953	 * @returns {vec2} out
4954	 */
4955	vec2.transformMat4 = function(out, a, m) {
4956	    var x = a[0],
4957	        y = a[1];
4958	    out[0] = m[0] * x + m[4] * y + m[12];
4959	    out[1] = m[1] * x + m[5] * y + m[13];
4960	    return out;
4961	};
4962
4963	/**
4964	 * Perform some operation over an array of vec2s.
4965	 *
4966	 * @param {Array} a the array of vectors to iterate over
4967	 * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
4968	 * @param {Number} offset Number of elements to skip at the beginning of the array
4969	 * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
4970	 * @param {Function} fn Function to call for each vector in the array
4971	 * @param {Object} [arg] additional argument to pass to fn
4972	 * @returns {Array} a
4973	 * @function
4974	 */
4975	vec2.forEach = (function() {
4976	    var vec = vec2.create();
4977
4978	    return function(a, stride, offset, count, fn, arg) {
4979	        var i, l;
4980	        if(!stride) {
4981	            stride = 2;
4982	        }
4983
4984	        if(!offset) {
4985	            offset = 0;
4986	        }
4987
4988	        if(count) {
4989	            l = Math.min((count * stride) + offset, a.length);
4990	        } else {
4991	            l = a.length;
4992	        }
4993
4994	        for(i = offset; i < l; i += stride) {
4995	            vec[0] = a[i]; vec[1] = a[i+1];
4996	            fn(vec, vec, arg);
4997	            a[i] = vec[0]; a[i+1] = vec[1];
4998	        }
4999
5000	        return a;
5001	    };
5002	})();
5003
5004	/**
5005	 * Returns a string representation of a vector
5006	 *
5007	 * @param {vec2} vec vector to represent as a string
5008	 * @returns {String} string representation of the vector
5009	 */
5010	vec2.str = function (a) {
5011	    return 'vec2(' + a[0] + ', ' + a[1] + ')';
5012	};
5013
5014	module.exports = vec2;
5015
5016
5017/***/ }
5018/******/ ])
5019});
5020;