Comparing version 0.0.41 to 0.0.42
{ | ||
"name": "twgl.js", | ||
"version": "0.0.41", | ||
"version": "0.0.42", | ||
"homepage": "http://twgljs.org", | ||
@@ -5,0 +5,0 @@ "authors": [ |
/** | ||
* @license twgl.js 0.0.41 Copyright (c) 2015, Gregg Tavares All Rights Reserved. | ||
* @license twgl.js 0.0.42 Copyright (c) 2015, Gregg Tavares All Rights Reserved. | ||
* Available via the MIT license. | ||
@@ -11,3 +11,3 @@ * see: http://github.com/greggman/twgl.js for details | ||
*/ | ||
!function(a,b){"function"==typeof define&&define.amd&&define([],b),"undefined"!=typeof module&&module.exports?module.exports=b():a.twgl=b()}(this,function(){var a,b,c;return function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){var c=v.call(arguments,0);return"string"!=typeof c[0]&&1===c.length&&c.push(null),n.apply(d,c.concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={notrequirebecasebrowserifymessesup:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["notrequirebecasebrowserifymessesup","exports","module"]:b,n=0;n<b.length;n+=1)if(m=o(b[n],f),k=m.f,"notrequirebecasebrowserifymessesup"===k)u[n]=p.notrequirebecasebrowserifymessesup(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=c?c.apply(q[a],u):void 0,a&&(h&&h.exports!==d&&h.exports!==q[a]?q[a]=h.exports:l===d&&s||(q[a]=l))}else a&&(q[a]=c)},a=b=n=function(a,b,c,e,f){if("string"==typeof a)return p[a]?p[a](b):j(o(a,b).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!b)return;b.splice?(a=b,b=c,c=null):a=d}return b=b||function(){},"function"==typeof c&&(c=e,e=f),e?m(d,a,b,c):setTimeout(function(){m(d,a,b,c)},4),n},n.config=function(a){return n(a)},a._defined=q,c=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},c.amd={jQuery:!0}}(),c("node_modules/almond/almond.js",function(){}),c("twgl/typedarrays",[],function(){function a(a){if(a instanceof Int8Array)return d;if(a instanceof Uint8Array)return e;if(a instanceof Int16Array)return f;if(a instanceof Uint16Array)return g;if(a instanceof Int32Array)return h;if(a instanceof Uint32Array)return i;if(a instanceof Float32Array)return j;throw"unsupported typed array type"}function b(a){switch(a){case d:return Int8Array;case e:return Uint8Array;case f:return Int16Array;case g:return Uint16Array;case h:return Int32Array;case i:return Uint32Array;case j:return Float32Array;default:throw"unknown gl type"}}function c(a){return a&&a.buffer&&a.buffer instanceof ArrayBuffer}var d=5120,e=5121,f=5122,g=5123,h=5124,i=5125,j=5126;return{getGLTypeForTypedArray:a,getTypedArrayTypeForGLType:b,isArrayBuffer:c}}),c("twgl/attributes",["./typedarrays"],function(a){function b(a){o.attribPrefix=a}function c(a){Object.keys(a).forEach(function(b){o[b]=a[b]})}function d(a,b,c,d,e){a.bindBuffer(b,c),a.bufferData(b,d,e||a.STATIC_DRAW)}function e(a,b,c,e){if(b instanceof WebGLBuffer)return b;c=c||a.ARRAY_BUFFER;var f=a.createBuffer();return d(a,c,f,b,e),f}function f(a){return"indices"===a}function g(a){return a instanceof Int8Array?!0:a instanceof Uint8Array?!0:!1}function h(a,b){var c;if(c=a.indexOf("coord")>=0?2:a.indexOf("color")>=0?4:3,b%c>0)throw"can not guess numComponents. You should specify it.";return c}function i(b,c){if(a.isArrayBuffer(b))return b;if(a.isArrayBuffer(b.data))return b.data;Array.isArray(b)&&(b={data:b});var d=b.type;return d||(d="indices"===c?Uint16Array:Float32Array),new d(b.data)}function j(b,c){var d={};return Object.keys(c).forEach(function(j){if(!f(j)){var k=c[j],l=k.attrib||k.name||k.attribName||o.attribPrefix+j,m=i(k,j);d[l]={buffer:e(b,m,void 0,k.drawType),numComponents:k.numComponents||k.size||h(j),type:a.getGLTypeForTypedArray(m),normalize:void 0!==k.normalize?k.normalize:g(m),stride:k.stride||0,offset:k.offset||0,drawType:k.drawType}}}),d}function k(a,b,c,e){c=i(c),e?(a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.bufferSubData(a.ARRAY_BUFFER,e,c)):d(a,a.ARRAY_BUFFER,b.buffer,c,b.drawType)}function l(a,b){var c={attribs:j(a,b)},d=b.indices;return d?(d=i(d,"indices"),c.indices=e(a,d,a.ELEMENT_ARRAY_BUFFER),c.numElements=d.length,c.elementType=d instanceof Uint32Array?a.UNSIGNED_INT:a.UNSIGNED_SHORT):c.numElements=p(b),c}function m(a,b,c){var d="indices"===c?a.ELEMENT_ARRAY_BUFFER:a.ARRAY_BUFFER,f=i(b,c);return e(a,f,d)}function n(a,b){var c={};return Object.keys(b).forEach(function(d){c[d]=m(a,b[d],d)}),c}var o={attribPrefix:""},p=function(){var a=["position","positions","a_position"];return function(b){for(var c,d=0;d<a.length&&(c=a[d],!(c in b));++d);d===a.length&&(c=Object.keys(b)[0]);var e=b[c],f=e.length||e.data.length,g=e.numComponents||h(c,f),i=f/g;if(f%g>0)throw"numComponents "+g+" not correct for length "+f;return i}}();return{createAttribsFromArrays:j,createBuffersFromArrays:n,createBufferFromArray:m,createBufferFromTypedArray:e,createBufferInfoFromArrays:l,setAttribInfoBufferFromArray:k,setAttributePrefix:b,setDefaults_:c}}),c("twgl/programs",[],function(){function a(a){return a.split("\n").map(function(a,b){return b+1+": "+a}).join("\n")}function b(b,c,d,e){var f=e||o,g=b.createShader(d);b.shaderSource(g,c),b.compileShader(g);var h=b.getShaderParameter(g,b.COMPILE_STATUS);if(!h){var i=b.getShaderInfoLog(g);return f(a(c)+"\n*** Error compiling shader: "+i),b.deleteShader(g),null}return g}function c(a,b,c,d,e){var f=e||o,g=a.createProgram();b.forEach(function(b){a.attachShader(g,b)}),c&&c.forEach(function(b,c){a.bindAttribLocation(g,d?d[c]:c,b)}),a.linkProgram(g);var h=a.getProgramParameter(g,a.LINK_STATUS);if(!h){var i=a.getProgramInfoLog(g);return f("Error in program linking:"+i),a.deleteProgram(g),null}return g}function d(a,c,d,e){var f,g="",h=document.getElementById(c);if(!h)throw"*** Error: unknown script element"+c;if(g=h.text,!d)if("x-shader/x-vertex"===h.type)f=a.VERTEX_SHADER;else if("x-shader/x-fragment"===h.type)f=a.FRAGMENT_SHADER;else if(f!==a.VERTEX_SHADER&&f!==a.FRAGMENT_SHADER)throw"*** Error: unknown shader type";return b(a,g,d?d:f,e)}function e(a,b,e,f,g){for(var h=[],i=0;i<b.length;++i){var j=d(a,b[i],a[p[i]],g);if(!j)return null;h.push(j)}return c(a,h,e,f,g)}function f(a,d,e,f,g){for(var h=[],i=0;i<d.length;++i){var j=b(a,d[i],a[p[i]],g);if(!j)return null;h.push(j)}return c(a,h,e,f,g)}function g(a,b){return b===a.SAMPLER_2D?a.TEXTURE_2D:b===a.SAMPLER_CUBE?a.TEXTURE_CUBE_MAP:void 0}function h(a,b){function c(b,c){var e=a.getUniformLocation(b,c.name),f=c.type,h=c.size>1&&"[0]"===c.name.substr(-3);if(f===a.FLOAT&&h)return function(b){a.uniform1fv(e,b)};if(f===a.FLOAT)return function(b){a.uniform1f(e,b)};if(f===a.FLOAT_VEC2)return function(b){a.uniform2fv(e,b)};if(f===a.FLOAT_VEC3)return function(b){a.uniform3fv(e,b)};if(f===a.FLOAT_VEC4)return function(b){a.uniform4fv(e,b)};if(f===a.INT&&h)return function(b){a.uniform1iv(e,b)};if(f===a.INT)return function(b){a.uniform1i(e,b)};if(f===a.INT_VEC2)return function(b){a.uniform2iv(e,b)};if(f===a.INT_VEC3)return function(b){a.uniform3iv(e,b)};if(f===a.INT_VEC4)return function(b){a.uniform4iv(e,b)};if(f===a.BOOL&&h)return function(b){a.uniform1iv(e,b)};if(f===a.BOOL)return function(b){a.uniform1i(e,b)};if(f===a.BOOL_VEC2)return function(b){a.uniform2iv(e,b)};if(f===a.BOOL_VEC3)return function(b){a.uniform3iv(e,b)};if(f===a.BOOL_VEC4)return function(b){a.uniform4iv(e,b)};if(f===a.FLOAT_MAT2)return function(b){a.uniformMatrix2fv(e,!1,b)};if(f===a.FLOAT_MAT3)return function(b){a.uniformMatrix3fv(e,!1,b)};if(f===a.FLOAT_MAT4)return function(b){a.uniformMatrix4fv(e,!1,b)};if((f===a.SAMPLER_2D||f===a.SAMPLER_CUBE)&&h){for(var i=[],j=0;j<c.size;++j)i.push(d++);return function(b,c){return function(d){a.uniform1iv(e,c),d.forEach(function(d,e){a.activeTexture(a.TEXTURE0+c[e]),a.bindTexture(b,d)})}}(g(a,f),i)}if(f===a.SAMPLER_2D||f===a.SAMPLER_CUBE)return function(b,c){return function(d){a.uniform1i(e,c),a.activeTexture(a.TEXTURE0+c),a.bindTexture(b,d)}}(g(a,f),d++);throw"unknown type: 0x"+f.toString(16)}for(var d=0,e={},f=a.getProgramParameter(b,a.ACTIVE_UNIFORMS),h=0;f>h;++h){var i=a.getActiveUniform(b,h);if(!i)break;var j=i.name;"[0]"===j.substr(-3)&&(j=j.substr(0,j.length-3));var k=c(b,i);e[j]=k}return e}function i(a,b){for(var c=a.uniformSetters||a,d=arguments.length,e=1;d>e;++e){var f=arguments[e];if(Array.isArray(f))for(var g=f.length,h=0;g>h;++h)i(c,f[h]);else for(var j in f){var k=c[j];k&&k(f[j])}}}function j(a,b){function c(b){return function(c){a.bindBuffer(a.ARRAY_BUFFER,c.buffer),a.enableVertexAttribArray(b),a.vertexAttribPointer(b,c.numComponents||c.size,c.type||a.FLOAT,c.normalize||!1,c.stride||0,c.offset||0)}}for(var d={},e=a.getProgramParameter(b,a.ACTIVE_ATTRIBUTES),f=0;e>f;++f){var g=a.getActiveAttrib(b,f);if(!g)break;var h=a.getAttribLocation(b,g.name);d[g.name]=c(h)}return d}function k(a,b){for(var c in b){var d=a[c];d&&d(b[c])}}function l(a,b,c){k(b.attribSetters||b,c.attribs),c.indices&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,c.indices)}function m(a,b){var c=h(a,b),d=j(a,b);return{program:b,uniformSetters:c,attribSetters:d}}function n(a,b,c,d,e){b=b.map(function(a){var b=document.getElementById(a);return b?b.text:a});var g=f(a,b,c,d,e);return g?m(a,g):null}var o=window.console&&window.console.error&&"function"==typeof window.console.error?window.console.error.bind(window.console):function(){},p=["VERTEX_SHADER","FRAGMENT_SHADER"];return{createAttributeSetters:j,createProgram:c,createProgramFromScripts:e,createProgramFromSources:f,createProgramInfo:n,createProgramInfoFromProgram:m,createUniformSetters:h,setAttributes:k,setBuffersAndAttributes:l,setUniforms:i}}),c("twgl/draw",["./programs"],function(a){function b(a,b,c,d,e){var f=c.indices,g=void 0===d?c.numElements:d;e=void 0===e?0:e,f?a.drawElements(b,g,void 0===c.elementType?a.UNSIGNED_SHORT:c.elementType,e):a.drawArrays(b,e,g)}function c(c,d){var e=null,f=null;d.forEach(function(d){if(d.active!==!1){var g=d.programInfo,h=d.bufferInfo,i=!1;g!==e&&(e=g,c.useProgram(g.program),i=!0),(i||h!==f)&&(f=h,a.setBuffersAndAttributes(c,g,h)),a.setUniforms(g,d.uniforms),b(c,d.type||c.TRIANGLES,h,d.count,d.offset)}})}return{drawBufferInfo:b,drawObjectList:c}}),c("twgl/utils",[],function(){function a(a){var b={};return Object.keys(a).forEach(function(c){b[c]=a[c]}),b}return{shallowCopy:a}}),c("twgl/textures",["./typedarrays","./utils"],function(a,b){function c(a){A.textureColor=new Uint8Array([255*a[0],255*a[1],255*a[2],255*a[3]])}function d(a){return!H.test(a)}function e(a){a.textureColor&&c(a.textureColor),Object.keys(a).filter(d).forEach(function(b){A[b]=a[b]})}function f(a,b){void 0!==b.colorspaceConversion&&(J.colorSpaceConversion=a.getParameter(a.UNPACK_COLORSPACE_CONVERSION_WEBGL)),void 0!==b.premultiplyAlpha&&(J.premultiplyAlpha=a.getParameter(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL)),void 0!==b.flipY&&(J.flipY=a.getParameter(a.UNPACK_FLIP_Y_WEBGL))}function g(a,b){void 0!==b.colorspaceConversion&&a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,J.colorSpaceConversion),void 0!==b.premultiplyAlpha&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),void 0!==b.flipY&&a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,J.flipY)}function h(a,b,c){var d=c.target||a.TEXTURE_2D;a.bindTexture(d,b),c.min&&a.texParameteri(d,a.TEXTURE_MIN_FILTER,c.min),c.mag&&a.texParameteri(d,a.TEXTURE_MAG_FILTER,c.mag),c.wrap&&(a.texParameteri(d,a.TEXTURE_WRAP_S,c.wrap),a.texParameteri(d,a.TEXTURE_WRAP_T,c.wrap)),c.wrapS&&a.texParameteri(d,a.TEXTURE_WRAP_S,c.wrapS),c.wrapT&&a.texParameteri(d,a.TEXTURE_WRAP_T,c.wrapT)}function i(a){return a=a||A.textureColor,B(a)?a:new Uint8Array([255*a[0],255*a[1],255*a[2],255*a[3]])}function j(a){return 0===(a&a-1)}function k(a,b,c,d,e){c=c||A.textureOptions;var f=c.target||a.TEXTURE_2D;d=d||c.width,e=e||c.height,a.bindTexture(f,b),j(d)&&j(e)?a.generateMipmap(f):(a.texParameteri(f,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(f,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(f,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE))}function l(a,b){return b=b||{},b.cubeFaceOrder||[a.TEXTURE_CUBE_MAP_POSITIVE_X,a.TEXTURE_CUBE_MAP_NEGATIVE_X,a.TEXTURE_CUBE_MAP_POSITIVE_Y,a.TEXTURE_CUBE_MAP_NEGATIVE_Y,a.TEXTURE_CUBE_MAP_POSITIVE_Z,a.TEXTURE_CUBE_MAP_NEGATIVE_Z]}function m(a,b){var c=l(a,b),d=c.map(function(a,b){return{face:a,ndx:b}});return d.sort(function(a,b){return a.face-b.face}),d}function n(){}function o(a,b,c){c=c||n;var d=new Image;return b=void 0!==b?b:A.crossOrigin,void 0!==b&&(d.crossOrigin=b),d.onerror=function(){var b="couldn't load image: "+a;error(b),c(b,d)},d.onload=function(){c(null,d)},d.src=a,d}function p(a,b,c){c=c||A.textureOptions;var d=c.target||a.TEXTURE_2D;if(a.bindTexture(d,b),c.color!==!1){var e=i(c.color);if(d===a.TEXTURE_CUBE_MAP)for(var f=0;6>f;++f)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e);else a.texImage2D(d,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e)}}function q(a,c,d,e){e=e||n,d=d||A.textureOptions,p(a,c,d),d=b.shallowCopy(d);var f=o(d.src,d.crossOrigin,function(b,f){b?e(b,c,f):(K(a,c,f,d),e(null,c,f))});return f}function r(a,c,d,e){function h(b){return function(h,i){--r,h?s.push(h):i.width!==i.height?s.push("cubemap face img is not a square: "+i.src):(f(a,d),a.bindTexture(m,c),5===r?l(a).forEach(function(b){a.texImage2D(b,0,j,j,k,i)}):a.texImage2D(b,0,j,j,k,i),g(a,d),a.generateMipmap(m)),0===r&&e(s.length?s:void 0,q,c)}}e=e||n;var i=d.src;if(6!==i.length)throw"there must be 6 urls for a cubemap";var j=d.format||a.RGBA,k=d.type||a.UNSIGNED_BYTE,m=d.target||a.TEXTURE_2D;if(m!==a.TEXTURE_CUBE_MAP)throw"target must be TEXTURE_CUBE_MAP";p(a,c,d),d=b.shallowCopy(d);var q,r=6,s=[],t=l(a,d);q=i.map(function(a,b){return o(a,d.crossOrigin,h(t[b]))})}function s(a){switch(a){case C:case F:return 1;case G:return 2;case D:return 3;case E:return 4;default:throw"unknown type: "+a}}function t(b,c){return B(c)?a.getGLTypeForTypedArray(c):b.UNSIGNED_BYTE}function u(b,c,d,e){e=e||A.textureOptions;var h=e.target||b.TEXTURE_2D;b.bindTexture(h,c);var i=e.width,j=e.height,k=e.format||b.RGBA,l=e.type||t(b,d),n=s(k),o=d.length/n;if(o%1)throw"length wrong size for format: "+I(b,k);if(i||j){if(j){if(!i&&(i=o/j,i%1))throw"can't guess width"}else if(j=o/i,j%1)throw"can't guess height"}else{var p=Math.sqrt(o/(h===b.TEXTURE_CUBE_MAP?6:1));p%1===0?(i=p,j=p):(i=o,j=1)}if(!B(d)){var q=a.getTypedArrayTypeForGLType(l);d=new q(d)}if(b.pixelStorei(b.UNPACK_ALIGNMENT,e.unpackAlignment||1),f(b,e),h===b.TEXTURE_CUBE_MAP){var r=o/6*n;m(b,e).forEach(function(a){var c=r*a.ndx,e=d.subarray(c,c+r);b.texImage2D(a.face,0,k,i,j,0,k,l,e)})}else b.texImage2D(h,0,k,i,j,0,k,l,d);return g(b,e),{width:i,height:j}}function v(a,b,c){var d=c.target||a.TEXTURE_2D;a.bindTexture(d,b);var e=c.format||a.RGBA,g=c.type||a.UNSIGNED_BYTE;if(f(a,c),d===a.TEXTURE_CUBE_MAP)for(var h=0;6>h;++h)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,e,c.width,c.height,0,e,g,null);else a.texImage2D(d,0,e,c.width,c.height,0,e,g,null)}function w(a,b,c){c=c||n,b=b||A.textureOptions;var d=a.createTexture(),e=b.target||a.TEXTURE_2D,f=b.width||1,g=b.height||1;a.bindTexture(e,d),e===a.TEXTURE_CUBE_MAP&&(a.texParameteri(e,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(e,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE));var i=b.src;if(i)if("function"==typeof i&&(i=i(a,b)),"string"==typeof i)q(a,d,b,c);else if(B(i)||Array.isArray(i)&&("number"==typeof i[0]||Array.isArray(i[0])||B(i[0]))){var j=u(a,d,i,b);f=j.width,g=j.height}else if(Array.isArray(i)&&"string"==typeof i[0])r(a,d,b,c);else{if(!(i instanceof HTMLElement))throw"unsupported src type";K(a,d,i,b),f=i.width,g=i.height}else v(a,d,b);return b.auto!==!1&&k(a,d,b,f,g),h(a,d,b),d}function x(a,b,c,d,e){d=d||c.width,e=e||c.height;var f=c.target||a.TEXTURE_2D;a.bindTexture(f,b);var g,h=c.format||a.RGBA,i=c.src;if(g=i&&(B(i)||Array.isArray(i)&&"number"==typeof i[0])?c.type||t(a,i):c.type||a.UNSIGNED_BYTE,f===a.TEXTURE_CUBE_MAP)for(var j=0;6>j;++j)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,h,d,e,0,h,g,null);else a.texImage2D(f,0,h,d,e,0,h,g,null)}function y(a){return"string"==typeof a||Array.isArray(a)&&"string"==typeof a[0]}function z(a,b,c){function d(){0===e&&setTimeout(function(){c(f.length?f:void 0,g,h)},0)}c=c||n;var e=0,f=[],g={},h={};return Object.keys(b).forEach(function(c){var i=b[c],j=void 0;y(i.src)&&(j=function(a,b,g){h[c]=g,--e,a&&f.push(a),d()},++e),g[c]=w(a,i,j)}),d(),g}var A={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{}},B=a.isArrayBuffer,C=6406,D=6407,E=6408,F=6409,G=6410,H=/^textureColor$/,I=function(){function a(a){b||(b={},Object.keys(a).forEach(function(c){"number"==typeof a[c]&&(b[a[c]]=c)}))}var b;return function(c,d){return a(),b[d]||"0x"+d.toString(16)}}(),J={},K=function(){var a=document.createElement("canvas").getContext("2d");return function(b,c,d,e){e=e||A.textureOptions;var i=e.target||b.TEXTURE_2D,j=d.width,l=d.height,n=e.format||b.RGBA,o=e.type||b.UNSIGNED_BYTE;if(f(b,e),b.bindTexture(i,c),i===b.TEXTURE_CUBE_MAP){var p,q,r=d.width,s=d.height;if(r/6===s)p=s,q=[0,0,1,0,2,0,3,0,4,0,5,0];else if(s/6===r)p=r,q=[0,0,0,1,0,2,0,3,0,4,0,5];else if(r/3===s/2)p=r/3,q=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(r/2!==s/3)throw"can't figure out cube map from element: "+(d.src?d.src:d.nodeName);p=r/2,q=[0,0,1,0,0,1,1,1,0,2,1,2]}a.canvas.width=p,a.canvas.height=p,j=p,l=p,m(b,e).forEach(function(c){var e=q[2*c.ndx+0]*p,f=q[2*c.ndx+1]*p;a.drawImage(d,e,f,p,p,0,0,p,p),b.texImage2D(c.face,0,n,n,o,a.canvas)}),a.canvas.width=1,a.canvas.height=1}else b.texImage2D(i,0,n,n,o,d);g(b,e),e.auto!==!1&&k(b,c,e,j,l),h(b,c,e)}}();return{setDefaults_:e,createTexture:w,setEmptyTexture:v,setTextureFromArray:u,loadTextureFromUrl:q,setTextureFromElement:K,setTextureFilteringForSize:k,setTextureParameters:h,setDefaultTextureColor:c,createTextures:z,resizeTexture:x,getNumComponentsForFormat:s}}),c("twgl/framebuffers",["./textures","./utils"],function(a,b){function c(a){return y[a]}function d(a){return z[a]}function e(e,f,g,h){var i=e.FRAMEBUFFER,j=e.createFramebuffer();e.bindFramebuffer(i,j),g=g||e.drawingBufferWidth,h=h||e.drawingBufferHeight,f=f||x;var k=0,l={framebuffer:j,attachments:[],width:g,height:h};return f.forEach(function(f){var j=f.attachment,m=f.format,n=c(m);if(n||(n=r+k++),!j)if(d(m))j=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,j),e.renderbufferStorage(e.RENDERBUFFER,m,g,h);else{var o=b.shallowCopy(f);o.width=g,o.height=h,o.auto=void 0===f.auto?!1:f.auto,j=a.createTexture(e,o)}if(j instanceof WebGLRenderbuffer)e.framebufferRenderbuffer(i,n,e.RENDERBUFFER,j);else{if(!(j instanceof WebGLTexture))throw"unknown attachment type";e.framebufferTexture2D(i,n,f.texTarget||e.TEXTURE_2D,j,f.level||0)}l.attachments.push(j)}),l}function f(b,c,d,e,f){e=e||b.drawingBufferWidth,f=f||b.drawingBufferHeight,c.width=e,c.height=f,d=d||x,d.forEach(function(d,g){var h=c.attachments[g],i=d.format;if(h instanceof WebGLRenderbuffer)b.bindRenderbuffer(b.RENDERBUFFER,h),b.renderbufferStorage(b.RENDERBUFFER,i,e,f);else{if(!(h instanceof WebGLTexture))throw"unknown attachment type";a.resizeTexture(b,h,d,e,f)}})}function g(a,b,c){c=c||a.FRAMEBUFFER,b?(a.bindFramebuffer(c,b.framebuffer),a.viewport(0,0,b.width,b.height)):(a.bindFramebuffer(c,null),a.viewport(0,0,a.drawingBufferWidth,a.drawingBufferHeight))}var h=5121,i=6402,j=6408,k=32854,l=32855,m=36194,n=33189,o=6401,p=36168,q=34041,r=36064,s=36096,t=36128,u=33306,v=33071,w=9729,x=[{format:j,type:h,min:w,wrap:v},{format:q}],y={};y[q]=u,y[o]=t,y[p]=t,y[i]=s,y[n]=s;var z={};return z[k]=!0,z[l]=!0,z[m]=!0,z[q]=!0,z[n]=!0,z[o]=!0,z[p]=!0,{bindFramebufferInfo:g,createFramebufferInfo:e,resizeFramebufferInfo:f}}),c("twgl/twgl",["./attributes","./draw","./framebuffers","./programs","./textures","./typedarrays"],function(a,b,c,d,e,f){function g(b){a.setDefaults_(b),e.setDefaults_(b)}function h(a,b){for(var c=["webgl","experimental-webgl"],d=null,e=0;e<c.length;++e){try{d=a.getContext(c[e],b)}catch(f){}if(d)break}return d}function i(a,b){var c=h(a,b);return c}function j(a,b){b=b||1,b=Math.max(1,b);var c=a.clientWidth*b|0,d=a.clientHeight*b|0;return a.width!==c||a.height!==d?(a.width=c,a.height=d,!0):!1}function k(a){return"_"!==a[a.length-1]}function l(a,b){Object.keys(a).filter(k).forEach(function(c){b[c]=a[c]})}var m={getWebGLContext:i,resizeCanvasToDisplaySize:j,setDefaults:g};return[a,b,c,d,e,f].forEach(function(a){l(a,m)}),m}),c("twgl/v3",[],function(){function a(a){q=a}function b(a,b,c){var d=new q(3);return a&&(d[0]=a),b&&(d[1]=b),c&&(d[2]=c),d}function c(a,b,c){return c=c||new q(3),c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2],c}function d(a,b,c){return c=c||new q(3),c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2],c}function e(a,b,c,d){return d=d||new q(3),d[0]=(1-c)*a[0]+c*b[0],d[1]=(1-c)*a[1]+c*b[1],d[2]=(1-c)*a[2]+c*b[2],d}function f(a,b,c){return c=c||new q(3),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function g(a,b,c){return c=c||new q(3),c[0]=a[0]/b,c[1]=a[1]/b,c[2]=a[2]/b,c}function h(a,b,c){return c=c||new q(3),c[0]=a[1]*b[2]-a[2]*b[1],c[1]=a[2]*b[0]-a[0]*b[2],c[2]=a[0]*b[1]-a[1]*b[0],c}function i(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function j(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])}function k(a){return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]}function l(a,b){b=b||new q(3);var c=a[0]*a[0]+a[1]*a[1]+a[2]*a[2],d=Math.sqrt(c);return d>1e-5?(b[0]=a[0]/d,b[1]=a[1]/d,b[2]=a[2]/d):(b[0]=0,b[1]=0,b[2]=0),b}function m(a,b){return b=b||new q(3),b[0]=-a[0],b[1]=-a[1],b[2]=-a[2],b}function n(a,b){return b=b||new q(3),b[0]=a[0],b[1]=a[1],b[2]=a[2],b}function o(a,b,c){return c=c||new q(3),c[0]=a[0]*b[0],c[1]=a[1]*b[1],c[2]=a[2]*b[2],c}function p(a,b,c){return c=c||new q(3),c[0]=a[0]/b[0],c[1]=a[1]/b[1],c[2]=a[2]/b[2],c}var q=Float32Array;return{add:c,copy:n,create:b,cross:h,divide:p,divScalar:g,dot:i,lerp:e,length:j,lengthSq:k,mulScalar:f,multiply:o,negate:m,normalize:l,setDefaultType:a,subtract:d}}),c("twgl/m4",["./v3"],function(a){function b(a){VecType=a}function c(a,b){return b=b||new E(16),b[0]=-a[0],b[1]=-a[1],b[2]=-a[2],b[3]=-a[3],b[4]=-a[4],b[5]=-a[5],b[6]=-a[6],b[7]=-a[7],b[8]=-a[8],b[9]=-a[9],b[10]=-a[10],b[11]=-a[11],b[12]=-a[12],b[13]=-a[13],b[14]=-a[14],b[15]=-a[15],b}function d(a,b){return b=b||new E(16),b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b}function e(a){return a=a||new E(16),a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function f(a,b){if(b=b||new E(16),b===a){var c;return c=a[1],a[1]=a[4],a[4]=c,c=a[2],a[2]=a[8],a[8]=c,c=a[3],a[3]=a[12],a[12]=c,c=a[6],a[6]=a[9],a[9]=c,c=a[7],a[7]=a[13],a[13]=c,c=a[11],a[11]=a[14],a[14]=c,b}var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15];return b[0]=d,b[1]=h,b[2]=l,b[3]=p,b[4]=e,b[5]=i,b[6]=m,b[7]=q,b[8]=f,b[9]=j,b[10]=n,b[11]=r,b[12]=g,b[13]=k,b[14]=o,b[15]=s,b}function g(a,b){b=b||new E(16);var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=m*r,t=q*n,u=i*r,v=q*j,w=i*n,x=m*j,y=e*r,z=q*f,A=e*n,B=m*f,C=e*j,D=i*f,F=k*p,G=o*l,H=g*p,I=o*h,J=g*l,K=k*h,L=c*p,M=o*d,N=c*l,O=k*d,P=c*h,Q=g*d,R=s*h+v*l+w*p-(t*h+u*l+x*p),S=t*d+y*l+B*p-(s*d+z*l+A*p),T=u*d+z*h+C*p-(v*d+y*h+D*p),U=x*d+A*h+D*l-(w*d+B*h+C*l),V=1/(c*R+g*S+k*T+o*U);return b[0]=V*R,b[1]=V*S,b[2]=V*T,b[3]=V*U,b[4]=V*(t*g+u*k+x*o-(s*g+v*k+w*o)),b[5]=V*(s*c+z*k+A*o-(t*c+y*k+B*o)),b[6]=V*(v*c+y*g+D*o-(u*c+z*g+C*o)),b[7]=V*(w*c+B*g+C*k-(x*c+A*g+D*k)),b[8]=V*(F*j+I*n+J*r-(G*j+H*n+K*r)),b[9]=V*(G*f+L*n+O*r-(F*f+M*n+N*r)),b[10]=V*(H*f+M*j+P*r-(I*f+L*j+Q*r)),b[11]=V*(K*f+N*j+Q*n-(J*f+O*j+P*n)),b[12]=V*(H*m+K*q+G*i-(J*q+F*i+I*m)),b[13]=V*(N*q+F*e+M*m-(L*m+O*q+G*e)),b[14]=V*(L*i+Q*q+I*e-(P*q+H*e+M*i)),b[15]=V*(P*m+J*e+O*i-(N*i+Q*m+K*e)),b}function h(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],C=b[9],D=b[10],F=b[11],G=b[12],H=b[13],I=b[14],J=b[15];return c[0]=d*t+e*x+f*B+g*G,c[1]=d*u+e*y+f*C+g*H,c[2]=d*v+e*z+f*D+g*I,c[3]=d*w+e*A+f*F+g*J,c[4]=h*t+i*x+j*B+k*G,c[5]=h*u+i*y+j*C+k*H,c[6]=h*v+i*z+j*D+k*I,c[7]=h*w+i*A+j*F+k*J,c[8]=l*t+m*x+n*B+o*G,c[9]=l*u+m*y+n*C+o*H,c[10]=l*v+m*z+n*D+o*I,c[11]=l*w+m*A+n*F+o*J,c[12]=p*t+q*x+r*B+s*G,c[13]=p*u+q*y+r*C+s*H,c[14]=p*v+q*z+r*D+s*I,c[15]=p*w+q*A+r*F+s*J,c}function i(a,b,c){return c=c||e(),a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11]),c[12]=b[0],c[13]=b[1],c[14]=b[2],c[15]=1,c}function j(b,c){return c=c||a.create(),c[0]=b[12],c[1]=b[13],c[2]=b[14],c}function k(b,c,d){d=d||a.create();var e=4*c;return d[0]=b[e+0],d[1]=b[e+1],d[2]=b[e+2],d}function l(a,b,c,d,e){e=e||new E(16);var f=Math.tan(.5*Math.PI-.5*a),g=1/(c-d);return e[0]=f/b,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=f,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(c+d)*g,e[11]=-1,e[12]=0,e[13]=0,e[14]=c*d*g*2,e[15]=0,e}function m(a,b,c,d,e,f,g){return g=g||new E(16),g[0]=2/(b-a),g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=2/(d-c),g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=-1/(f-e),g[11]=0,g[12]=(b+a)/(a-b),g[13]=(d+c)/(c-d),g[14]=-e/(e-f),g[15]=1,g}function n(a,b,c,d,e,f,g){g=g||new E(16);var h=b-a,i=d-c,j=e-f;return g[0]=2*e/h,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=2*e/i,g[6]=0,g[7]=0,g[8]=(a+b)/h,g[9]=(d+c)/i,g[10]=f/j,g[11]=-1,g[12]=0,g[13]=0,g[14]=e*f/j,g[15]=0,g}function o(b,c,d,e){e=e||new E(16);var f=F,g=G,h=H;return a.normalize(a.subtract(b,c,h),h),a.normalize(a.cross(d,h,f),f),a.normalize(a.cross(h,f,g),g),e[0]=f[0],e[1]=f[1],e[2]=f[2],e[3]=0,e[4]=g[0],e[5]=g[1],e[6]=g[2],e[7]=0,e[8]=h[0],e[9]=h[1],e[10]=h[2],e[11]=0,e[12]=b[0],e[13]=b[1],e[14]=b[2],e[15]=1,e}function p(a,b){return b=b||new E(16),b[0]=1,b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=1,b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=1,b[11]=0,b[12]=a[0],b[13]=a[1],b[14]=a[2],b[15]=1,b}function q(a,b,c){c=c||new E(16);var d=b[0],e=b[1],f=b[2],g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],s=a[12],t=a[13],u=a[14],v=a[15];return a!==c&&(c[0]=g,c[1]=h,c[2]=i,c[3]=j,c[4]=k,c[5]=l,c[6]=m,c[7]=n,c[8]=o,c[9]=p,c[10]=q,c[11]=r),c[12]=g*d+k*e+o*f+s,c[13]=h*d+l*e+p*f+t,c[14]=i*d+m*e+q*f+u,c[15]=j*d+n*e+r*f+v,c}function r(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=1,b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=c,b[6]=d,b[7]=0,b[8]=0,b[9]=-d,b[10]=c,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function s(a,b,c){c=c||new E(16);var d=a[4],e=a[5],f=a[6],g=a[7],h=a[8],i=a[9],j=a[10],k=a[11],l=Math.cos(b),m=Math.sin(b);return c[4]=l*d+m*h,c[5]=l*e+m*i,c[6]=l*f+m*j,c[7]=l*g+m*k,c[8]=l*h-m*d,c[9]=l*i-m*e,c[10]=l*j-m*f,c[11]=l*k-m*g,a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function t(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=c,b[1]=0,b[2]=-d,b[3]=0,b[4]=0,b[5]=1,b[6]=0,b[7]=0,b[8]=d,b[9]=0,b[10]=c,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function u(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[8],i=a[9],j=a[10],k=a[11],l=Math.cos(b),m=Math.sin(b);return c[0]=l*d-m*h,c[1]=l*e-m*i,c[2]=l*f-m*j,c[3]=l*g-m*k,c[8]=l*h+m*d,c[9]=l*i+m*e,c[10]=l*j+m*f,c[11]=l*k+m*g,a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function v(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=c,b[1]=d,b[2]=0,b[3]=0,b[4]=-d,b[5]=c,b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=1,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function w(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=Math.cos(b),m=Math.sin(b);return c[0]=l*d+m*h,c[1]=l*e+m*i,c[2]=l*f+m*j,c[3]=l*g+m*k,c[4]=l*h-m*d,c[5]=l*i-m*e,c[6]=l*j-m*f,c[7]=l*k-m*g,a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function x(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=Math.sqrt(d*d+e*e+f*f);d/=g,e/=g,f/=g;var h=d*d,i=e*e,j=f*f,k=Math.cos(b),l=Math.sin(b),m=1-k;return c[0]=h+(1-h)*k,c[1]=d*e*m+f*l,c[2]=d*f*m-e*l,c[3]=0,c[4]=d*e*m-f*l,c[5]=i+(1-i)*k,c[6]=e*f*m+d*l,c[7]=0,c[8]=d*f*m+e*l,c[9]=e*f*m-d*l,c[10]=j+(1-j)*k,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,c}function y(a,b,c,d){d=d||new E(16);var e=b[0],f=b[1],g=b[2],h=Math.sqrt(e*e+f*f+g*g);e/=h,f/=h,g/=h;var i=e*e,j=f*f,k=g*g,l=Math.cos(c),m=Math.sin(c),n=1-l,o=i+(1-i)*l,p=e*f*n+g*m,q=e*g*n-f*m,r=e*f*n-g*m,s=j+(1-j)*l,t=f*g*n+e*m,u=e*g*n+f*m,v=f*g*n-e*m,w=k+(1-k)*l,x=a[0],y=a[1],z=a[2],A=a[3],B=a[4],C=a[5],D=a[6],F=a[7],G=a[8],H=a[9],I=a[10],J=a[11];return d[0]=o*x+p*B+q*G,d[1]=o*y+p*C+q*H,d[2]=o*z+p*D+q*I,d[3]=o*A+p*F+q*J,d[4]=r*x+s*B+t*G,d[5]=r*y+s*C+t*H,d[6]=r*z+s*D+t*I,d[7]=r*A+s*F+t*J,d[8]=u*x+v*B+w*G,d[9]=u*y+v*C+w*H,d[10]=u*z+v*D+w*I,d[11]=u*A+v*F+w*J,a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]),d}function z(a,b){return b=b||new E(16),b[0]=a[0],b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=a[1],b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=a[2],b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function A(a,b,c){c=c||new E(16);var d=b[0],e=b[1],f=b[2];return c[0]=d*a[0],c[1]=d*a[1],c[2]=d*a[2],c[3]=d*a[3],c[4]=e*a[4],c[5]=e*a[5],c[6]=e*a[6],c[7]=e*a[7],c[8]=f*a[8],c[9]=f*a[9],c[10]=f*a[10],c[11]=f*a[11],a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),a}function B(b,c,d){d=d||a.create();var e=c[0],f=c[1],g=c[2],h=e*b[3]+f*b[7]+g*b[11]+b[15];return d[0]=(e*b[0]+f*b[4]+g*b[8]+b[12])/h,d[1]=(e*b[1]+f*b[5]+g*b[9]+b[13])/h,d[2]=(e*b[2]+f*b[6]+g*b[10]+b[14])/h,d}function C(b,c,d){d=d||a.create();var e=c[0],f=c[1],g=c[2];return d[0]=e*b[0]+f*b[4]+g*b[8],d[1]=e*b[1]+f*b[5]+g*b[9],d[2]=e*b[2]+f*b[6]+g*b[10],d}function D(b,c,d){d=d||a.create();var e=g(b),f=c[0],h=c[1],i=c[2];return d[0]=f*e[0]+h*e[1]+i*e[2],d[1]=f*e[4]+h*e[5]+i*e[6],d[2]=f*e[8]+h*e[9]+i*e[10],d}var E=Float32Array,F=a.create(),G=a.create(),H=a.create();return{axisRotate:y,axisRotation:x,create:e,copy:d,frustum:n,getAxis:k,getTranslation:j,identity:e,inverse:g,lookAt:o,multiply:h,negate:c,ortho:m,perspective:l,rotateX:s,rotateY:u,rotateZ:w,rotateAxis:y,rotationX:r,rotationY:t,rotationZ:v,scale:A,scaling:z,setDefaultType:b,setTranslation:i,transformDirection:C,transformNormal:D,transformPoint:B,translate:q,translation:p,transpose:f}}),c("twgl/primitives",["./twgl","./m4","./v3"],function(a,b,c){function d(a,b){var c=0;return a.push=function(){for(var b=0;b<arguments.length;++b){var d=arguments[b];if(d instanceof Array||d.buffer&&d.buffer instanceof ArrayBuffer)for(var e=0;e<d.length;++e)a[c++]=d[e];else a[c++]=d}},a.reset=function(a){c=a||0},a.numComponents=b,Object.defineProperty(a,"numElements",{get:function(){return this.length/this.numComponents|0}}),a}function e(a,b,c){var e=c||Float32Array;return d(new e(a*b),a)}function f(a){return"indices"!==a}function g(a){function b(b){for(var f=a[b],h=f.numComponents,i=e(h,g,f.constructor),j=0;g>j;++j)for(var k=c[j],l=k*h,m=0;h>m;++m)i.push(f[l+m]); | ||
!function(a,b){"function"==typeof define&&define.amd&&define([],b),"undefined"!=typeof module&&module.exports?module.exports=b():a.twgl=b()}(this,function(){var a,b,c;return function(d){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.slice(0,n.length-1).concat(a),k=0;k<a.length;k+=1)if(m=a[k],"."===m)a.splice(k,1),k-=1;else if(".."===m){if(1===k&&(".."===a[2]||".."===a[0]))break;k>0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,b){return function(){var c=v.call(arguments,0);return"string"!=typeof c[0]&&1===c.length&&c.push(null),n.apply(d,c.concat([a,b]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var b=r[a];delete r[a],t[a]=!0,m.apply(d,b)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={notrequirebecasebrowserifymessesup:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,b,c,f){var h,k,l,m,n,s,u=[],v=typeof c;if(f=f||a,"undefined"===v||"function"===v){for(b=!b.length&&c.length?["notrequirebecasebrowserifymessesup","exports","module"]:b,n=0;n<b.length;n+=1)if(m=o(b[n],f),k=m.f,"notrequirebecasebrowserifymessesup"===k)u[n]=p.notrequirebecasebrowserifymessesup(a);else if("exports"===k)u[n]=p.exports(a),s=!0;else if("module"===k)h=u[n]=p.module(a);else if(e(q,k)||e(r,k)||e(t,k))u[n]=j(k);else{if(!m.p)throw new Error(a+" missing "+k);m.p.load(m.n,g(f,!0),i(k),{}),u[n]=q[k]}l=c?c.apply(q[a],u):void 0,a&&(h&&h.exports!==d&&h.exports!==q[a]?q[a]=h.exports:l===d&&s||(q[a]=l))}else a&&(q[a]=c)},a=b=n=function(a,b,c,e,f){if("string"==typeof a)return p[a]?p[a](b):j(o(a,b).f);if(!a.splice){if(s=a,s.deps&&n(s.deps,s.callback),!b)return;b.splice?(a=b,b=c,c=null):a=d}return b=b||function(){},"function"==typeof c&&(c=e,e=f),e?m(d,a,b,c):setTimeout(function(){m(d,a,b,c)},4),n},n.config=function(a){return n(a)},a._defined=q,c=function(a,b,c){if("string"!=typeof a)throw new Error("See almond README: incorrect module build, no module name");b.splice||(c=b,b=[]),e(q,a)||e(r,a)||(r[a]=[a,b,c])},c.amd={jQuery:!0}}(),c("node_modules/almond/almond.js",function(){}),c("twgl/typedarrays",[],function(){function a(a){if(a instanceof Int8Array)return d;if(a instanceof Uint8Array)return e;if(a instanceof Int16Array)return f;if(a instanceof Uint16Array)return g;if(a instanceof Int32Array)return h;if(a instanceof Uint32Array)return i;if(a instanceof Float32Array)return j;throw"unsupported typed array type"}function b(a){switch(a){case d:return Int8Array;case e:return Uint8Array;case f:return Int16Array;case g:return Uint16Array;case h:return Int32Array;case i:return Uint32Array;case j:return Float32Array;default:throw"unknown gl type"}}function c(a){return a&&a.buffer&&a.buffer instanceof ArrayBuffer}var d=5120,e=5121,f=5122,g=5123,h=5124,i=5125,j=5126;return{getGLTypeForTypedArray:a,getTypedArrayTypeForGLType:b,isArrayBuffer:c}}),c("twgl/attributes",["./typedarrays"],function(a){function b(a){o.attribPrefix=a}function c(a){Object.keys(a).forEach(function(b){o[b]=a[b]})}function d(a,b,c,d,e){a.bindBuffer(b,c),a.bufferData(b,d,e||a.STATIC_DRAW)}function e(a,b,c,e){if(b instanceof WebGLBuffer)return b;c=c||a.ARRAY_BUFFER;var f=a.createBuffer();return d(a,c,f,b,e),f}function f(a){return"indices"===a}function g(a){return a instanceof Int8Array?!0:a instanceof Uint8Array?!0:!1}function h(a,b){var c;if(c=a.indexOf("coord")>=0?2:a.indexOf("color")>=0?4:3,b%c>0)throw"can not guess numComponents. You should specify it.";return c}function i(b,c){if(a.isArrayBuffer(b))return b;if(a.isArrayBuffer(b.data))return b.data;Array.isArray(b)&&(b={data:b});var d=b.type;return d||(d="indices"===c?Uint16Array:Float32Array),new d(b.data)}function j(b,c){var d={};return Object.keys(c).forEach(function(j){if(!f(j)){var k=c[j],l=k.attrib||k.name||k.attribName||o.attribPrefix+j,m=i(k,j);d[l]={buffer:e(b,m,void 0,k.drawType),numComponents:k.numComponents||k.size||h(j),type:a.getGLTypeForTypedArray(m),normalize:void 0!==k.normalize?k.normalize:g(m),stride:k.stride||0,offset:k.offset||0,drawType:k.drawType}}}),d}function k(a,b,c,e){c=i(c),e?(a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.bufferSubData(a.ARRAY_BUFFER,e,c)):d(a,a.ARRAY_BUFFER,b.buffer,c,b.drawType)}function l(a,b){var c={attribs:j(a,b)},d=b.indices;return d?(d=i(d,"indices"),c.indices=e(a,d,a.ELEMENT_ARRAY_BUFFER),c.numElements=d.length,c.elementType=d instanceof Uint32Array?a.UNSIGNED_INT:a.UNSIGNED_SHORT):c.numElements=p(b),c}function m(a,b,c){var d="indices"===c?a.ELEMENT_ARRAY_BUFFER:a.ARRAY_BUFFER,f=i(b,c);return e(a,f,d)}function n(a,b){var c={};return Object.keys(b).forEach(function(d){c[d]=m(a,b[d],d)}),c}var o={attribPrefix:""},p=function(){var a=["position","positions","a_position"];return function(b){for(var c,d=0;d<a.length&&(c=a[d],!(c in b));++d);d===a.length&&(c=Object.keys(b)[0]);var e=b[c],f=e.length||e.data.length,g=e.numComponents||h(c,f),i=f/g;if(f%g>0)throw"numComponents "+g+" not correct for length "+f;return i}}();return{createAttribsFromArrays:j,createBuffersFromArrays:n,createBufferFromArray:m,createBufferFromTypedArray:e,createBufferInfoFromArrays:l,setAttribInfoBufferFromArray:k,setAttributePrefix:b,setDefaults_:c}}),c("twgl/programs",[],function(){function a(a){return a.split("\n").map(function(a,b){return b+1+": "+a}).join("\n")}function b(b,c,d,e){var f=e||o,g=b.createShader(d);b.shaderSource(g,c),b.compileShader(g);var h=b.getShaderParameter(g,b.COMPILE_STATUS);if(!h){var i=b.getShaderInfoLog(g);return f(a(c)+"\n*** Error compiling shader: "+i),b.deleteShader(g),null}return g}function c(a,b,c,d,e){var f=e||o,g=a.createProgram();b.forEach(function(b){a.attachShader(g,b)}),c&&c.forEach(function(b,c){a.bindAttribLocation(g,d?d[c]:c,b)}),a.linkProgram(g);var h=a.getProgramParameter(g,a.LINK_STATUS);if(!h){var i=a.getProgramInfoLog(g);return f("Error in program linking:"+i),a.deleteProgram(g),null}return g}function d(a,c,d,e){var f,g="",h=document.getElementById(c);if(!h)throw"*** Error: unknown script element"+c;if(g=h.text,!d)if("x-shader/x-vertex"===h.type)f=a.VERTEX_SHADER;else if("x-shader/x-fragment"===h.type)f=a.FRAGMENT_SHADER;else if(f!==a.VERTEX_SHADER&&f!==a.FRAGMENT_SHADER)throw"*** Error: unknown shader type";return b(a,g,d?d:f,e)}function e(a,b,e,f,g){for(var h=[],i=0;i<b.length;++i){var j=d(a,b[i],a[p[i]],g);if(!j)return null;h.push(j)}return c(a,h,e,f,g)}function f(a,d,e,f,g){for(var h=[],i=0;i<d.length;++i){var j=b(a,d[i],a[p[i]],g);if(!j)return null;h.push(j)}return c(a,h,e,f,g)}function g(a,b){return b===a.SAMPLER_2D?a.TEXTURE_2D:b===a.SAMPLER_CUBE?a.TEXTURE_CUBE_MAP:void 0}function h(a,b){function c(b,c){var e=a.getUniformLocation(b,c.name),f=c.type,h=c.size>1&&"[0]"===c.name.substr(-3);if(f===a.FLOAT&&h)return function(b){a.uniform1fv(e,b)};if(f===a.FLOAT)return function(b){a.uniform1f(e,b)};if(f===a.FLOAT_VEC2)return function(b){a.uniform2fv(e,b)};if(f===a.FLOAT_VEC3)return function(b){a.uniform3fv(e,b)};if(f===a.FLOAT_VEC4)return function(b){a.uniform4fv(e,b)};if(f===a.INT&&h)return function(b){a.uniform1iv(e,b)};if(f===a.INT)return function(b){a.uniform1i(e,b)};if(f===a.INT_VEC2)return function(b){a.uniform2iv(e,b)};if(f===a.INT_VEC3)return function(b){a.uniform3iv(e,b)};if(f===a.INT_VEC4)return function(b){a.uniform4iv(e,b)};if(f===a.BOOL&&h)return function(b){a.uniform1iv(e,b)};if(f===a.BOOL)return function(b){a.uniform1i(e,b)};if(f===a.BOOL_VEC2)return function(b){a.uniform2iv(e,b)};if(f===a.BOOL_VEC3)return function(b){a.uniform3iv(e,b)};if(f===a.BOOL_VEC4)return function(b){a.uniform4iv(e,b)};if(f===a.FLOAT_MAT2)return function(b){a.uniformMatrix2fv(e,!1,b)};if(f===a.FLOAT_MAT3)return function(b){a.uniformMatrix3fv(e,!1,b)};if(f===a.FLOAT_MAT4)return function(b){a.uniformMatrix4fv(e,!1,b)};if((f===a.SAMPLER_2D||f===a.SAMPLER_CUBE)&&h){for(var i=[],j=0;j<c.size;++j)i.push(d++);return function(b,c){return function(d){a.uniform1iv(e,c),d.forEach(function(d,e){a.activeTexture(a.TEXTURE0+c[e]),a.bindTexture(b,d)})}}(g(a,f),i)}if(f===a.SAMPLER_2D||f===a.SAMPLER_CUBE)return function(b,c){return function(d){a.uniform1i(e,c),a.activeTexture(a.TEXTURE0+c),a.bindTexture(b,d)}}(g(a,f),d++);throw"unknown type: 0x"+f.toString(16)}for(var d=0,e={},f=a.getProgramParameter(b,a.ACTIVE_UNIFORMS),h=0;f>h;++h){var i=a.getActiveUniform(b,h);if(!i)break;var j=i.name;"[0]"===j.substr(-3)&&(j=j.substr(0,j.length-3));var k=c(b,i);e[j]=k}return e}function i(a,b){for(var c=a.uniformSetters||a,d=arguments.length,e=1;d>e;++e){var f=arguments[e];if(Array.isArray(f))for(var g=f.length,h=0;g>h;++h)i(c,f[h]);else for(var j in f){var k=c[j];k&&k(f[j])}}}function j(a,b){function c(b){return function(c){a.bindBuffer(a.ARRAY_BUFFER,c.buffer),a.enableVertexAttribArray(b),a.vertexAttribPointer(b,c.numComponents||c.size,c.type||a.FLOAT,c.normalize||!1,c.stride||0,c.offset||0)}}for(var d={},e=a.getProgramParameter(b,a.ACTIVE_ATTRIBUTES),f=0;e>f;++f){var g=a.getActiveAttrib(b,f);if(!g)break;var h=a.getAttribLocation(b,g.name);d[g.name]=c(h)}return d}function k(a,b){for(var c in b){var d=a[c];d&&d(b[c])}}function l(a,b,c){k(b.attribSetters||b,c.attribs),c.indices&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,c.indices)}function m(a,b){var c=h(a,b),d=j(a,b);return{program:b,uniformSetters:c,attribSetters:d}}function n(a,b,c,d,e){b=b.map(function(a){var b=document.getElementById(a);return b?b.text:a});var g=f(a,b,c,d,e);return g?m(a,g):null}var o=window.console&&window.console.error&&"function"==typeof window.console.error?window.console.error.bind(window.console):function(){},p=["VERTEX_SHADER","FRAGMENT_SHADER"];return{createAttributeSetters:j,createProgram:c,createProgramFromScripts:e,createProgramFromSources:f,createProgramInfo:n,createProgramInfoFromProgram:m,createUniformSetters:h,setAttributes:k,setBuffersAndAttributes:l,setUniforms:i}}),c("twgl/draw",["./programs"],function(a){function b(a,b,c,d,e){var f=c.indices,g=void 0===d?c.numElements:d;e=void 0===e?0:e,f?a.drawElements(b,g,void 0===c.elementType?a.UNSIGNED_SHORT:c.elementType,e):a.drawArrays(b,e,g)}function c(c,d){var e=null,f=null;d.forEach(function(d){if(d.active!==!1){var g=d.programInfo,h=d.bufferInfo,i=!1;g!==e&&(e=g,c.useProgram(g.program),i=!0),(i||h!==f)&&(f=h,a.setBuffersAndAttributes(c,g,h)),a.setUniforms(g,d.uniforms),b(c,d.type||c.TRIANGLES,h,d.count,d.offset)}})}return{drawBufferInfo:b,drawObjectList:c}}),c("twgl/utils",[],function(){function a(a){var b={};return Object.keys(a).forEach(function(c){b[c]=a[c]}),b}return{shallowCopy:a}}),c("twgl/textures",["./typedarrays","./utils"],function(a,b){function c(a){A.textureColor=new Uint8Array([255*a[0],255*a[1],255*a[2],255*a[3]])}function d(a){return!H.test(a)}function e(a){a.textureColor&&c(a.textureColor),Object.keys(a).filter(d).forEach(function(b){A[b]=a[b]})}function f(a,b){void 0!==b.colorspaceConversion&&(J.colorSpaceConversion=a.getParameter(a.UNPACK_COLORSPACE_CONVERSION_WEBGL)),void 0!==b.premultiplyAlpha&&(J.premultiplyAlpha=a.getParameter(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL)),void 0!==b.flipY&&(J.flipY=a.getParameter(a.UNPACK_FLIP_Y_WEBGL))}function g(a,b){void 0!==b.colorspaceConversion&&a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,J.colorSpaceConversion),void 0!==b.premultiplyAlpha&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,J.premultiplyAlpha),void 0!==b.flipY&&a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,J.flipY)}function h(a,b,c){var d=c.target||a.TEXTURE_2D;a.bindTexture(d,b),c.min&&a.texParameteri(d,a.TEXTURE_MIN_FILTER,c.min),c.mag&&a.texParameteri(d,a.TEXTURE_MAG_FILTER,c.mag),c.wrap&&(a.texParameteri(d,a.TEXTURE_WRAP_S,c.wrap),a.texParameteri(d,a.TEXTURE_WRAP_T,c.wrap)),c.wrapS&&a.texParameteri(d,a.TEXTURE_WRAP_S,c.wrapS),c.wrapT&&a.texParameteri(d,a.TEXTURE_WRAP_T,c.wrapT)}function i(a){return a=a||A.textureColor,B(a)?a:new Uint8Array([255*a[0],255*a[1],255*a[2],255*a[3]])}function j(a){return 0===(a&a-1)}function k(a,b,c,d,e){c=c||A.textureOptions;var f=c.target||a.TEXTURE_2D;d=d||c.width,e=e||c.height,a.bindTexture(f,b),j(d)&&j(e)?a.generateMipmap(f):(a.texParameteri(f,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(f,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(f,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE))}function l(a,b){return b=b||{},b.cubeFaceOrder||[a.TEXTURE_CUBE_MAP_POSITIVE_X,a.TEXTURE_CUBE_MAP_NEGATIVE_X,a.TEXTURE_CUBE_MAP_POSITIVE_Y,a.TEXTURE_CUBE_MAP_NEGATIVE_Y,a.TEXTURE_CUBE_MAP_POSITIVE_Z,a.TEXTURE_CUBE_MAP_NEGATIVE_Z]}function m(a,b){var c=l(a,b),d=c.map(function(a,b){return{face:a,ndx:b}});return d.sort(function(a,b){return a.face-b.face}),d}function n(){}function o(a,b,c){c=c||n;var d=new Image;return b=void 0!==b?b:A.crossOrigin,void 0!==b&&(d.crossOrigin=b),d.onerror=function(){var b="couldn't load image: "+a;error(b),c(b,d)},d.onload=function(){c(null,d)},d.src=a,d}function p(a,b,c){c=c||A.textureOptions;var d=c.target||a.TEXTURE_2D;if(a.bindTexture(d,b),c.color!==!1){var e=i(c.color);if(d===a.TEXTURE_CUBE_MAP)for(var f=0;6>f;++f)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e);else a.texImage2D(d,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,e)}}function q(a,c,d,e){e=e||n,d=d||A.textureOptions,p(a,c,d),d=b.shallowCopy(d);var f=o(d.src,d.crossOrigin,function(b,f){b?e(b,c,f):(K(a,c,f,d),e(null,c,f))});return f}function r(a,c,d,e){function h(b){return function(h,i){--r,h?s.push(h):i.width!==i.height?s.push("cubemap face img is not a square: "+i.src):(f(a,d),a.bindTexture(m,c),5===r?l(a).forEach(function(b){a.texImage2D(b,0,j,j,k,i)}):a.texImage2D(b,0,j,j,k,i),g(a,d),a.generateMipmap(m)),0===r&&e(s.length?s:void 0,q,c)}}e=e||n;var i=d.src;if(6!==i.length)throw"there must be 6 urls for a cubemap";var j=d.format||a.RGBA,k=d.type||a.UNSIGNED_BYTE,m=d.target||a.TEXTURE_2D;if(m!==a.TEXTURE_CUBE_MAP)throw"target must be TEXTURE_CUBE_MAP";p(a,c,d),d=b.shallowCopy(d);var q,r=6,s=[],t=l(a,d);q=i.map(function(a,b){return o(a,d.crossOrigin,h(t[b]))})}function s(a){switch(a){case C:case F:return 1;case G:return 2;case D:return 3;case E:return 4;default:throw"unknown type: "+a}}function t(b,c){return B(c)?a.getGLTypeForTypedArray(c):b.UNSIGNED_BYTE}function u(b,c,d,e){e=e||A.textureOptions;var h=e.target||b.TEXTURE_2D;b.bindTexture(h,c);var i=e.width,j=e.height,k=e.format||b.RGBA,l=e.type||t(b,d),n=s(k),o=d.length/n;if(o%1)throw"length wrong size for format: "+I(b,k);if(i||j){if(j){if(!i&&(i=o/j,i%1))throw"can't guess width"}else if(j=o/i,j%1)throw"can't guess height"}else{var p=Math.sqrt(o/(h===b.TEXTURE_CUBE_MAP?6:1));p%1===0?(i=p,j=p):(i=o,j=1)}if(!B(d)){var q=a.getTypedArrayTypeForGLType(l);d=new q(d)}if(b.pixelStorei(b.UNPACK_ALIGNMENT,e.unpackAlignment||1),f(b,e),h===b.TEXTURE_CUBE_MAP){var r=o/6*n;m(b,e).forEach(function(a){var c=r*a.ndx,e=d.subarray(c,c+r);b.texImage2D(a.face,0,k,i,j,0,k,l,e)})}else b.texImage2D(h,0,k,i,j,0,k,l,d);return g(b,e),{width:i,height:j}}function v(a,b,c){var d=c.target||a.TEXTURE_2D;a.bindTexture(d,b);var e=c.format||a.RGBA,g=c.type||a.UNSIGNED_BYTE;if(f(a,c),d===a.TEXTURE_CUBE_MAP)for(var h=0;6>h;++h)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,e,c.width,c.height,0,e,g,null);else a.texImage2D(d,0,e,c.width,c.height,0,e,g,null)}function w(a,b,c){c=c||n,b=b||A.textureOptions;var d=a.createTexture(),e=b.target||a.TEXTURE_2D,f=b.width||1,g=b.height||1;a.bindTexture(e,d),e===a.TEXTURE_CUBE_MAP&&(a.texParameteri(e,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(e,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE));var i=b.src;if(i)if("function"==typeof i&&(i=i(a,b)),"string"==typeof i)q(a,d,b,c);else if(B(i)||Array.isArray(i)&&("number"==typeof i[0]||Array.isArray(i[0])||B(i[0]))){var j=u(a,d,i,b);f=j.width,g=j.height}else if(Array.isArray(i)&&"string"==typeof i[0])r(a,d,b,c);else{if(!(i instanceof HTMLElement))throw"unsupported src type";K(a,d,i,b),f=i.width,g=i.height}else v(a,d,b);return b.auto!==!1&&k(a,d,b,f,g),h(a,d,b),d}function x(a,b,c,d,e){d=d||c.width,e=e||c.height;var f=c.target||a.TEXTURE_2D;a.bindTexture(f,b);var g,h=c.format||a.RGBA,i=c.src;if(g=i&&(B(i)||Array.isArray(i)&&"number"==typeof i[0])?c.type||t(a,i):c.type||a.UNSIGNED_BYTE,f===a.TEXTURE_CUBE_MAP)for(var j=0;6>j;++j)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,h,d,e,0,h,g,null);else a.texImage2D(f,0,h,d,e,0,h,g,null)}function y(a){return"string"==typeof a||Array.isArray(a)&&"string"==typeof a[0]}function z(a,b,c){function d(){0===e&&setTimeout(function(){c(f.length?f:void 0,g,h)},0)}c=c||n;var e=0,f=[],g={},h={};return Object.keys(b).forEach(function(c){var i=b[c],j=void 0;y(i.src)&&(j=function(a,b,g){h[c]=g,--e,a&&f.push(a),d()},++e),g[c]=w(a,i,j)}),d(),g}var A={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{}},B=a.isArrayBuffer,C=6406,D=6407,E=6408,F=6409,G=6410,H=/^textureColor$/,I=function(){function a(a){b||(b={},Object.keys(a).forEach(function(c){"number"==typeof a[c]&&(b[a[c]]=c)}))}var b;return function(c,d){return a(),b[d]||"0x"+d.toString(16)}}(),J={},K=function(){var a=document.createElement("canvas").getContext("2d");return function(b,c,d,e){e=e||A.textureOptions;var i=e.target||b.TEXTURE_2D,j=d.width,l=d.height,n=e.format||b.RGBA,o=e.type||b.UNSIGNED_BYTE;if(f(b,e),b.bindTexture(i,c),i===b.TEXTURE_CUBE_MAP){var p,q,r=d.width,s=d.height;if(r/6===s)p=s,q=[0,0,1,0,2,0,3,0,4,0,5,0];else if(s/6===r)p=r,q=[0,0,0,1,0,2,0,3,0,4,0,5];else if(r/3===s/2)p=r/3,q=[0,0,1,0,2,0,0,1,1,1,2,1];else{if(r/2!==s/3)throw"can't figure out cube map from element: "+(d.src?d.src:d.nodeName);p=r/2,q=[0,0,1,0,0,1,1,1,0,2,1,2]}a.canvas.width=p,a.canvas.height=p,j=p,l=p,m(b,e).forEach(function(c){var e=q[2*c.ndx+0]*p,f=q[2*c.ndx+1]*p;a.drawImage(d,e,f,p,p,0,0,p,p),b.texImage2D(c.face,0,n,n,o,a.canvas)}),a.canvas.width=1,a.canvas.height=1}else b.texImage2D(i,0,n,n,o,d);g(b,e),e.auto!==!1&&k(b,c,e,j,l),h(b,c,e)}}();return{setDefaults_:e,createTexture:w,setEmptyTexture:v,setTextureFromArray:u,loadTextureFromUrl:q,setTextureFromElement:K,setTextureFilteringForSize:k,setTextureParameters:h,setDefaultTextureColor:c,createTextures:z,resizeTexture:x,getNumComponentsForFormat:s}}),c("twgl/framebuffers",["./textures","./utils"],function(a,b){function c(a){return y[a]}function d(a){return z[a]}function e(e,f,g,h){var i=e.FRAMEBUFFER,j=e.createFramebuffer();e.bindFramebuffer(i,j),g=g||e.drawingBufferWidth,h=h||e.drawingBufferHeight,f=f||x;var k=0,l={framebuffer:j,attachments:[],width:g,height:h};return f.forEach(function(f){var j=f.attachment,m=f.format,n=c(m);if(n||(n=r+k++),!j)if(d(m))j=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,j),e.renderbufferStorage(e.RENDERBUFFER,m,g,h);else{var o=b.shallowCopy(f);o.width=g,o.height=h,o.auto=void 0===f.auto?!1:f.auto,j=a.createTexture(e,o)}if(j instanceof WebGLRenderbuffer)e.framebufferRenderbuffer(i,n,e.RENDERBUFFER,j);else{if(!(j instanceof WebGLTexture))throw"unknown attachment type";e.framebufferTexture2D(i,n,f.texTarget||e.TEXTURE_2D,j,f.level||0)}l.attachments.push(j)}),l}function f(b,c,d,e,f){e=e||b.drawingBufferWidth,f=f||b.drawingBufferHeight,c.width=e,c.height=f,d=d||x,d.forEach(function(d,g){var h=c.attachments[g],i=d.format;if(h instanceof WebGLRenderbuffer)b.bindRenderbuffer(b.RENDERBUFFER,h),b.renderbufferStorage(b.RENDERBUFFER,i,e,f);else{if(!(h instanceof WebGLTexture))throw"unknown attachment type";a.resizeTexture(b,h,d,e,f)}})}function g(a,b,c){c=c||a.FRAMEBUFFER,b?(a.bindFramebuffer(c,b.framebuffer),a.viewport(0,0,b.width,b.height)):(a.bindFramebuffer(c,null),a.viewport(0,0,a.drawingBufferWidth,a.drawingBufferHeight))}var h=5121,i=6402,j=6408,k=32854,l=32855,m=36194,n=33189,o=6401,p=36168,q=34041,r=36064,s=36096,t=36128,u=33306,v=33071,w=9729,x=[{format:j,type:h,min:w,wrap:v},{format:q}],y={};y[q]=u,y[o]=t,y[p]=t,y[i]=s,y[n]=s;var z={};return z[k]=!0,z[l]=!0,z[m]=!0,z[q]=!0,z[n]=!0,z[o]=!0,z[p]=!0,{bindFramebufferInfo:g,createFramebufferInfo:e,resizeFramebufferInfo:f}}),c("twgl/twgl",["./attributes","./draw","./framebuffers","./programs","./textures","./typedarrays"],function(a,b,c,d,e,f){function g(b){a.setDefaults_(b),e.setDefaults_(b)}function h(a,b){for(var c=["webgl","experimental-webgl"],d=null,e=0;e<c.length;++e){try{d=a.getContext(c[e],b)}catch(f){}if(d)break}return d}function i(a,b){var c=h(a,b);return c}function j(a,b){b=b||1,b=Math.max(1,b);var c=a.clientWidth*b|0,d=a.clientHeight*b|0;return a.width!==c||a.height!==d?(a.width=c,a.height=d,!0):!1}function k(a){return"_"!==a[a.length-1]}function l(a,b){Object.keys(a).filter(k).forEach(function(c){b[c]=a[c]})}var m={getWebGLContext:i,resizeCanvasToDisplaySize:j,setDefaults:g};return[a,b,c,d,e,f].forEach(function(a){l(a,m)}),m}),c("twgl/v3",[],function(){function a(a){q=a}function b(a,b,c){var d=new q(3);return a&&(d[0]=a),b&&(d[1]=b),c&&(d[2]=c),d}function c(a,b,c){return c=c||new q(3),c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2],c}function d(a,b,c){return c=c||new q(3),c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2],c}function e(a,b,c,d){return d=d||new q(3),d[0]=(1-c)*a[0]+c*b[0],d[1]=(1-c)*a[1]+c*b[1],d[2]=(1-c)*a[2]+c*b[2],d}function f(a,b,c){return c=c||new q(3),c[0]=a[0]*b,c[1]=a[1]*b,c[2]=a[2]*b,c}function g(a,b,c){return c=c||new q(3),c[0]=a[0]/b,c[1]=a[1]/b,c[2]=a[2]/b,c}function h(a,b,c){return c=c||new q(3),c[0]=a[1]*b[2]-a[2]*b[1],c[1]=a[2]*b[0]-a[0]*b[2],c[2]=a[0]*b[1]-a[1]*b[0],c}function i(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function j(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])}function k(a){return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]}function l(a,b){b=b||new q(3);var c=a[0]*a[0]+a[1]*a[1]+a[2]*a[2],d=Math.sqrt(c);return d>1e-5?(b[0]=a[0]/d,b[1]=a[1]/d,b[2]=a[2]/d):(b[0]=0,b[1]=0,b[2]=0),b}function m(a,b){return b=b||new q(3),b[0]=-a[0],b[1]=-a[1],b[2]=-a[2],b}function n(a,b){return b=b||new q(3),b[0]=a[0],b[1]=a[1],b[2]=a[2],b}function o(a,b,c){return c=c||new q(3),c[0]=a[0]*b[0],c[1]=a[1]*b[1],c[2]=a[2]*b[2],c}function p(a,b,c){return c=c||new q(3),c[0]=a[0]/b[0],c[1]=a[1]/b[1],c[2]=a[2]/b[2],c}var q=Float32Array;return{add:c,copy:n,create:b,cross:h,divide:p,divScalar:g,dot:i,lerp:e,length:j,lengthSq:k,mulScalar:f,multiply:o,negate:m,normalize:l,setDefaultType:a,subtract:d}}),c("twgl/m4",["./v3"],function(a){function b(a){VecType=a}function c(a,b){return b=b||new E(16),b[0]=-a[0],b[1]=-a[1],b[2]=-a[2],b[3]=-a[3],b[4]=-a[4],b[5]=-a[5],b[6]=-a[6],b[7]=-a[7],b[8]=-a[8],b[9]=-a[9],b[10]=-a[10],b[11]=-a[11],b[12]=-a[12],b[13]=-a[13],b[14]=-a[14],b[15]=-a[15],b}function d(a,b){return b=b||new E(16),b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b}function e(a){return a=a||new E(16),a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a}function f(a,b){if(b=b||new E(16),b===a){var c;return c=a[1],a[1]=a[4],a[4]=c,c=a[2],a[2]=a[8],a[8]=c,c=a[3],a[3]=a[12],a[12]=c,c=a[6],a[6]=a[9],a[9]=c,c=a[7],a[7]=a[13],a[13]=c,c=a[11],a[11]=a[14],a[14]=c,b}var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15];return b[0]=d,b[1]=h,b[2]=l,b[3]=p,b[4]=e,b[5]=i,b[6]=m,b[7]=q,b[8]=f,b[9]=j,b[10]=n,b[11]=r,b[12]=g,b[13]=k,b[14]=o,b[15]=s,b}function g(a,b){b=b||new E(16);var c=a[0],d=a[1],e=a[2],f=a[3],g=a[4],h=a[5],i=a[6],j=a[7],k=a[8],l=a[9],m=a[10],n=a[11],o=a[12],p=a[13],q=a[14],r=a[15],s=m*r,t=q*n,u=i*r,v=q*j,w=i*n,x=m*j,y=e*r,z=q*f,A=e*n,B=m*f,C=e*j,D=i*f,F=k*p,G=o*l,H=g*p,I=o*h,J=g*l,K=k*h,L=c*p,M=o*d,N=c*l,O=k*d,P=c*h,Q=g*d,R=s*h+v*l+w*p-(t*h+u*l+x*p),S=t*d+y*l+B*p-(s*d+z*l+A*p),T=u*d+z*h+C*p-(v*d+y*h+D*p),U=x*d+A*h+D*l-(w*d+B*h+C*l),V=1/(c*R+g*S+k*T+o*U);return b[0]=V*R,b[1]=V*S,b[2]=V*T,b[3]=V*U,b[4]=V*(t*g+u*k+x*o-(s*g+v*k+w*o)),b[5]=V*(s*c+z*k+A*o-(t*c+y*k+B*o)),b[6]=V*(v*c+y*g+D*o-(u*c+z*g+C*o)),b[7]=V*(w*c+B*g+C*k-(x*c+A*g+D*k)),b[8]=V*(F*j+I*n+J*r-(G*j+H*n+K*r)),b[9]=V*(G*f+L*n+O*r-(F*f+M*n+N*r)),b[10]=V*(H*f+M*j+P*r-(I*f+L*j+Q*r)),b[11]=V*(K*f+N*j+Q*n-(J*f+O*j+P*n)),b[12]=V*(H*m+K*q+G*i-(J*q+F*i+I*m)),b[13]=V*(N*q+F*e+M*m-(L*m+O*q+G*e)),b[14]=V*(L*i+Q*q+I*e-(P*q+H*e+M*i)),b[15]=V*(P*m+J*e+O*i-(N*i+Q*m+K*e)),b}function h(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=a[8],m=a[9],n=a[10],o=a[11],p=a[12],q=a[13],r=a[14],s=a[15],t=b[0],u=b[1],v=b[2],w=b[3],x=b[4],y=b[5],z=b[6],A=b[7],B=b[8],C=b[9],D=b[10],F=b[11],G=b[12],H=b[13],I=b[14],J=b[15];return c[0]=d*t+e*x+f*B+g*G,c[1]=d*u+e*y+f*C+g*H,c[2]=d*v+e*z+f*D+g*I,c[3]=d*w+e*A+f*F+g*J,c[4]=h*t+i*x+j*B+k*G,c[5]=h*u+i*y+j*C+k*H,c[6]=h*v+i*z+j*D+k*I,c[7]=h*w+i*A+j*F+k*J,c[8]=l*t+m*x+n*B+o*G,c[9]=l*u+m*y+n*C+o*H,c[10]=l*v+m*z+n*D+o*I,c[11]=l*w+m*A+n*F+o*J,c[12]=p*t+q*x+r*B+s*G,c[13]=p*u+q*y+r*C+s*H,c[14]=p*v+q*z+r*D+s*I,c[15]=p*w+q*A+r*F+s*J,c}function i(a,b,c){return c=c||e(),a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11]),c[12]=b[0],c[13]=b[1],c[14]=b[2],c[15]=1,c}function j(b,c){return c=c||a.create(),c[0]=b[12],c[1]=b[13],c[2]=b[14],c}function k(b,c,d){d=d||a.create();var e=4*c;return d[0]=b[e+0],d[1]=b[e+1],d[2]=b[e+2],d}function l(a,b,c,d,e){e=e||new E(16);var f=Math.tan(.5*Math.PI-.5*a),g=1/(c-d);return e[0]=f/b,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=f,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(c+d)*g,e[11]=-1,e[12]=0,e[13]=0,e[14]=c*d*g*2,e[15]=0,e}function m(a,b,c,d,e,f,g){return g=g||new E(16),g[0]=2/(b-a),g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=2/(d-c),g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[10]=-1/(f-e),g[11]=0,g[12]=(b+a)/(a-b),g[13]=(d+c)/(c-d),g[14]=-e/(e-f),g[15]=1,g}function n(a,b,c,d,e,f,g){g=g||new E(16);var h=b-a,i=d-c,j=e-f;return g[0]=2*e/h,g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[5]=2*e/i,g[6]=0,g[7]=0,g[8]=(a+b)/h,g[9]=(d+c)/i,g[10]=f/j,g[11]=-1,g[12]=0,g[13]=0,g[14]=e*f/j,g[15]=0,g}function o(b,c,d,e){e=e||new E(16);var f=F,g=G,h=H;return a.normalize(a.subtract(b,c,h),h),a.normalize(a.cross(d,h,f),f),a.normalize(a.cross(h,f,g),g),e[0]=f[0],e[1]=f[1],e[2]=f[2],e[3]=0,e[4]=g[0],e[5]=g[1],e[6]=g[2],e[7]=0,e[8]=h[0],e[9]=h[1],e[10]=h[2],e[11]=0,e[12]=b[0],e[13]=b[1],e[14]=b[2],e[15]=1,e}function p(a,b){return b=b||new E(16),b[0]=1,b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=1,b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=1,b[11]=0,b[12]=a[0],b[13]=a[1],b[14]=a[2],b[15]=1,b}function q(a,b,c){c=c||new E(16);var d=b[0],e=b[1],f=b[2],g=a[0],h=a[1],i=a[2],j=a[3],k=a[4],l=a[5],m=a[6],n=a[7],o=a[8],p=a[9],q=a[10],r=a[11],s=a[12],t=a[13],u=a[14],v=a[15];return a!==c&&(c[0]=g,c[1]=h,c[2]=i,c[3]=j,c[4]=k,c[5]=l,c[6]=m,c[7]=n,c[8]=o,c[9]=p,c[10]=q,c[11]=r),c[12]=g*d+k*e+o*f+s,c[13]=h*d+l*e+p*f+t,c[14]=i*d+m*e+q*f+u,c[15]=j*d+n*e+r*f+v,c}function r(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=1,b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=c,b[6]=d,b[7]=0,b[8]=0,b[9]=-d,b[10]=c,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function s(a,b,c){c=c||new E(16);var d=a[4],e=a[5],f=a[6],g=a[7],h=a[8],i=a[9],j=a[10],k=a[11],l=Math.cos(b),m=Math.sin(b);return c[4]=l*d+m*h,c[5]=l*e+m*i,c[6]=l*f+m*j,c[7]=l*g+m*k,c[8]=l*h-m*d,c[9]=l*i-m*e,c[10]=l*j-m*f,c[11]=l*k-m*g,a!==c&&(c[0]=a[0],c[1]=a[1],c[2]=a[2],c[3]=a[3],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function t(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=c,b[1]=0,b[2]=-d,b[3]=0,b[4]=0,b[5]=1,b[6]=0,b[7]=0,b[8]=d,b[9]=0,b[10]=c,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function u(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[8],i=a[9],j=a[10],k=a[11],l=Math.cos(b),m=Math.sin(b);return c[0]=l*d-m*h,c[1]=l*e-m*i,c[2]=l*f-m*j,c[3]=l*g-m*k,c[8]=l*h+m*d,c[9]=l*i+m*e,c[10]=l*j+m*f,c[11]=l*k+m*g,a!==c&&(c[4]=a[4],c[5]=a[5],c[6]=a[6],c[7]=a[7],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function v(a,b){b=b||new E(16);var c=Math.cos(a),d=Math.sin(a);return b[0]=c,b[1]=d,b[2]=0,b[3]=0,b[4]=-d,b[5]=c,b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=1,b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function w(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=a[3],h=a[4],i=a[5],j=a[6],k=a[7],l=Math.cos(b),m=Math.sin(b);return c[0]=l*d+m*h,c[1]=l*e+m*i,c[2]=l*f+m*j,c[3]=l*g+m*k,c[4]=l*h-m*d,c[5]=l*i-m*e,c[6]=l*j-m*f,c[7]=l*k-m*g,a!==c&&(c[8]=a[8],c[9]=a[9],c[10]=a[10],c[11]=a[11],c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function x(a,b,c){c=c||new E(16);var d=a[0],e=a[1],f=a[2],g=Math.sqrt(d*d+e*e+f*f);d/=g,e/=g,f/=g;var h=d*d,i=e*e,j=f*f,k=Math.cos(b),l=Math.sin(b),m=1-k;return c[0]=h+(1-h)*k,c[1]=d*e*m+f*l,c[2]=d*f*m-e*l,c[3]=0,c[4]=d*e*m-f*l,c[5]=i+(1-i)*k,c[6]=e*f*m+d*l,c[7]=0,c[8]=d*f*m+e*l,c[9]=e*f*m-d*l,c[10]=j+(1-j)*k,c[11]=0,c[12]=0,c[13]=0,c[14]=0,c[15]=1,c}function y(a,b,c,d){d=d||new E(16);var e=b[0],f=b[1],g=b[2],h=Math.sqrt(e*e+f*f+g*g);e/=h,f/=h,g/=h;var i=e*e,j=f*f,k=g*g,l=Math.cos(c),m=Math.sin(c),n=1-l,o=i+(1-i)*l,p=e*f*n+g*m,q=e*g*n-f*m,r=e*f*n-g*m,s=j+(1-j)*l,t=f*g*n+e*m,u=e*g*n+f*m,v=f*g*n-e*m,w=k+(1-k)*l,x=a[0],y=a[1],z=a[2],A=a[3],B=a[4],C=a[5],D=a[6],F=a[7],G=a[8],H=a[9],I=a[10],J=a[11];return d[0]=o*x+p*B+q*G,d[1]=o*y+p*C+q*H,d[2]=o*z+p*D+q*I,d[3]=o*A+p*F+q*J,d[4]=r*x+s*B+t*G,d[5]=r*y+s*C+t*H,d[6]=r*z+s*D+t*I,d[7]=r*A+s*F+t*J,d[8]=u*x+v*B+w*G,d[9]=u*y+v*C+w*H,d[10]=u*z+v*D+w*I,d[11]=u*A+v*F+w*J,a!==d&&(d[12]=a[12],d[13]=a[13],d[14]=a[14],d[15]=a[15]),d}function z(a,b){return b=b||new E(16),b[0]=a[0],b[1]=0,b[2]=0,b[3]=0,b[4]=0,b[5]=a[1],b[6]=0,b[7]=0,b[8]=0,b[9]=0,b[10]=a[2],b[11]=0,b[12]=0,b[13]=0,b[14]=0,b[15]=1,b}function A(a,b,c){c=c||new E(16);var d=b[0],e=b[1],f=b[2];return c[0]=d*a[0],c[1]=d*a[1],c[2]=d*a[2],c[3]=d*a[3],c[4]=e*a[4],c[5]=e*a[5],c[6]=e*a[6],c[7]=e*a[7],c[8]=f*a[8],c[9]=f*a[9],c[10]=f*a[10],c[11]=f*a[11],a!==c&&(c[12]=a[12],c[13]=a[13],c[14]=a[14],c[15]=a[15]),c}function B(b,c,d){d=d||a.create();var e=c[0],f=c[1],g=c[2],h=e*b[3]+f*b[7]+g*b[11]+b[15];return d[0]=(e*b[0]+f*b[4]+g*b[8]+b[12])/h,d[1]=(e*b[1]+f*b[5]+g*b[9]+b[13])/h,d[2]=(e*b[2]+f*b[6]+g*b[10]+b[14])/h,d}function C(b,c,d){d=d||a.create();var e=c[0],f=c[1],g=c[2];return d[0]=e*b[0]+f*b[4]+g*b[8],d[1]=e*b[1]+f*b[5]+g*b[9],d[2]=e*b[2]+f*b[6]+g*b[10],d}function D(b,c,d){d=d||a.create();var e=g(b),f=c[0],h=c[1],i=c[2];return d[0]=f*e[0]+h*e[1]+i*e[2],d[1]=f*e[4]+h*e[5]+i*e[6],d[2]=f*e[8]+h*e[9]+i*e[10],d}var E=Float32Array,F=a.create(),G=a.create(),H=a.create();return{axisRotate:y,axisRotation:x,create:e,copy:d,frustum:n,getAxis:k,getTranslation:j,identity:e,inverse:g,lookAt:o,multiply:h,negate:c,ortho:m,perspective:l,rotateX:s,rotateY:u,rotateZ:w,rotateAxis:y,rotationX:r,rotationY:t,rotationZ:v,scale:A,scaling:z,setDefaultType:b,setTranslation:i,transformDirection:C,transformNormal:D,transformPoint:B,translate:q,translation:p,transpose:f}}),c("twgl/primitives",["./twgl","./m4","./v3"],function(a,b,c){function d(a,b){var c=0;return a.push=function(){for(var b=0;b<arguments.length;++b){var d=arguments[b];if(d instanceof Array||d.buffer&&d.buffer instanceof ArrayBuffer)for(var e=0;e<d.length;++e)a[c++]=d[e];else a[c++]=d}},a.reset=function(a){c=a||0},a.numComponents=b,Object.defineProperty(a,"numElements",{get:function(){return this.length/this.numComponents|0}}),a}function e(a,b,c){var e=c||Float32Array;return d(new e(a*b),a)}function f(a){return"indices"!==a}function g(a){function b(b){for(var f=a[b],h=f.numComponents,i=e(h,g,f.constructor),j=0;g>j;++j)for(var k=c[j],l=k*h,m=0;h>m;++m)i.push(f[l+m]); | ||
d[b]=i}var c=a.indices,d={},g=c.length;return Object.keys(a).filter(f).forEach(b),d}function h(a){if(a.indices)throw"can't flatten normals of indexed vertices. deindex them first";for(var b=a.normal,c=b.length,d=0;c>d;d+=9){var e=b[d+0],f=b[d+1],g=b[d+2],h=b[d+3],i=b[d+4],j=b[d+5],k=b[d+6],l=b[d+7],m=b[d+8],n=e+h+k,o=f+i+l,p=g+j+m,q=Math.sqrt(n*n+o*o+p*p);n/=q,o/=q,p/=q,b[d+0]=n,b[d+1]=o,b[d+2]=p,b[d+3]=n,b[d+4]=o,b[d+5]=p,b[d+6]=n,b[d+7]=o,b[d+8]=p}return a}function i(a,b,c){for(var d=a.length,e=new Float32Array(3),f=0;d>f;f+=3)c(b,[a[f],a[f+1],a[f+2]],e),a[f]=e[0],a[f+1]=e[1],a[f+2]=e[2]}function j(a,b,d){d=d||c.create();var e=b[0],f=b[1],g=b[2];return d[0]=e*a[0]+f*a[1]+g*a[2],d[1]=e*a[4]+f*a[5]+g*a[6],d[2]=e*a[8]+f*a[9]+g*a[10],d}function k(a,c){return i(a,c,b.transformDirection),a}function l(a,c){return i(a,b.inverse(c),j),a}function m(a,c){return i(a,c,b.transformPoint),a}function n(a,b){return Object.keys(a).forEach(function(c){var d=a[c];c.indexOf("pos")>=0?m(d,b):c.indexOf("tan")>=0||c.indexOf("binorm")>=0?k(d,b):c.indexOf("norm")>=0&&l(d,b)}),a}function o(a,b,c){return a=a||2,b=b||0,c=c||0,a*=.5,{position:{numComponents:2,data:[b+-1*a,c+-1*a,b+1*a,c+-1*a,b+-1*a,c+1*a,b+1*a,c+1*a]},normal:[0,0,1,0,0,1,0,0,1,0,0,1],texcoord:[0,0,1,0,0,1,1,1],indices:[0,1,2,2,1,3]}}function p(a,c,d,f,g){a=a||1,c=c||1,d=d||1,f=f||1,g=g||b.identity();for(var h=(d+1)*(f+1),i=e(3,h),j=e(3,h),k=e(2,h),l=0;f>=l;l++)for(var m=0;d>=m;m++){var o=m/d,p=l/f;i.push(a*o-.5*a,0,c*p-.5*c),j.push(0,1,0),k.push(o,p)}for(var q=d+1,r=e(3,d*f*2,Uint16Array),l=0;f>l;l++)for(var m=0;d>m;m++)r.push((l+0)*q+m,(l+1)*q+m,(l+0)*q+m+1),r.push((l+1)*q+m,(l+1)*q+m+1,(l+0)*q+m+1);var s=n({position:i,normal:j,texcoord:k,indices:r},g);return s}function q(a,b,c,d,f,g,h){if(0>=b||0>=c)throw Error("subdivisionAxis and subdivisionHeight must be > 0");d=d||0,f=f||Math.PI,g=g||0,h=h||2*Math.PI;for(var i=f-d,j=h-g,k=(b+1)*(c+1),l=e(3,k),m=e(3,k),n=e(2,k),o=0;c>=o;o++)for(var p=0;b>=p;p++){var q=p/b,r=o/c,s=j*q,t=i*r,u=Math.sin(s),v=Math.cos(s),w=Math.sin(t),x=Math.cos(t),y=v*w,z=x,A=u*w;l.push(a*y,a*z,a*A),m.push(y,z,A),n.push(1-q,r)}for(var B=b+1,C=e(3,b*c*2,Uint16Array),p=0;b>p;p++)for(var o=0;c>o;o++)C.push((o+0)*B+p,(o+0)*B+p+1,(o+1)*B+p),C.push((o+1)*B+p,(o+0)*B+p+1,(o+1)*B+p+1);return{position:l,normal:m,texcoord:n,indices:C}}function r(a){a=a||1;for(var b=a/2,c=[[-b,-b,-b],[+b,-b,-b],[-b,+b,-b],[+b,+b,-b],[-b,-b,+b],[+b,-b,+b],[-b,+b,+b],[+b,+b,+b]],d=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],f=[[1,0],[0,0],[0,1],[1,1]],g=24,h=e(3,g),i=e(3,g),j=e(2,g),k=e(3,12,Uint16Array),l=0;6>l;++l){for(var m=D[l],n=0;4>n;++n){var o=c[m[n]],p=d[l],q=f[n];h.push(o),i.push(p),j.push(q)}var r=4*l;k.push(r+0,r+1,r+2),k.push(r+0,r+2,r+3)}return{position:h,normal:i,texcoord:j,indices:k}}function s(a,b,c,d,f,g,h){if(3>d)throw Error("radialSubdivisions must be 3 or greater");if(1>f)throw Error("verticalSubdivisions must be 1 or greater");for(var i=void 0===g?!0:g,j=void 0===h?!0:h,k=(i?2:0)+(j?2:0),l=(d+1)*(f+1+k),m=e(3,l),n=e(3,l),o=e(2,l),p=e(3,d*(f+k)*2,Uint16Array),q=d+1,r=Math.atan2(a-b,c),s=Math.cos(r),t=Math.sin(r),u=i?-2:0,v=f+(j?2:0),w=u;v>=w;++w){var x,y=w/f,z=c*y;0>w?(z=0,y=1,x=a):w>f?(z=c,y=1,x=b):x=a+(b-a)*(w/f),(-2===w||w===f+2)&&(x=0,y=0),z-=c/2;for(var A=0;q>A;++A){var B=Math.sin(A*Math.PI*2/d),C=Math.cos(A*Math.PI*2/d);m.push(B*x,z,C*x),n.push(0>w||w>f?0:B*s,0>w?-1:w>f?1:t,0>w||w>f?0:C*s),o.push(A/d,1-y)}}for(var w=0;f+k>w;++w)for(var A=0;d>A;++A)p.push(q*(w+0)+0+A,q*(w+0)+1+A,q*(w+1)+1+A),p.push(q*(w+0)+0+A,q*(w+1)+1+A,q*(w+1)+0+A);return{position:m,normal:n,texcoord:o,indices:p}}function t(a,b){b=b||[];for(var c=[],d=0;d<a.length;d+=4){var e=a[d],f=a.slice(d+1,d+4);f.push.apply(f,b);for(var g=0;e>g;++g)c.push.apply(c,f)}return c}function u(){var a=[0,0,0,0,150,0,30,0,0,0,150,0,30,150,0,30,0,0,30,0,0,30,30,0,100,0,0,30,30,0,100,30,0,100,0,0,30,60,0,30,90,0,67,60,0,30,90,0,67,90,0,67,60,0,0,0,30,30,0,30,0,150,30,0,150,30,30,0,30,30,150,30,30,0,30,100,0,30,30,30,30,30,30,30,100,0,30,100,30,30,30,60,30,67,60,30,30,90,30,30,90,30,67,60,30,67,90,30,0,0,0,100,0,0,100,0,30,0,0,0,100,0,30,0,0,30,100,0,0,100,30,0,100,30,30,100,0,0,100,30,30,100,0,30,30,30,0,30,30,30,100,30,30,30,30,0,100,30,30,100,30,0,30,30,0,30,60,30,30,30,30,30,30,0,30,60,0,30,60,30,30,60,0,67,60,30,30,60,30,30,60,0,67,60,0,67,60,30,67,60,0,67,90,30,67,60,30,67,60,0,67,90,0,67,90,30,30,90,0,30,90,30,67,90,30,30,90,0,67,90,30,67,90,0,30,90,0,30,150,30,30,90,30,30,90,0,30,150,0,30,150,30,0,150,0,0,150,30,30,150,30,0,150,0,30,150,30,30,150,0,0,0,0,0,0,30,0,150,30,0,0,0,0,150,30,0,150,0],b=[.22,.19,.22,.79,.34,.19,.22,.79,.34,.79,.34,.19,.34,.19,.34,.31,.62,.19,.34,.31,.62,.31,.62,.19,.34,.43,.34,.55,.49,.43,.34,.55,.49,.55,.49,.43,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,0,1,0,1,1,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,1,0],c=t([18,0,0,1,18,0,0,-1,6,0,1,0,6,1,0,0,6,0,-1,0,6,1,0,0,6,0,1,0,6,1,0,0,6,0,-1,0,6,1,0,0,6,0,-1,0,6,-1,0,0]),d=t([18,200,70,120,18,80,70,200,6,70,200,210,6,200,200,70,6,210,100,70,6,210,160,70,6,70,180,210,6,100,70,210,6,76,210,100,6,140,210,80,6,90,130,110,6,160,160,220],[255]),f=a.length/3,g={position:e(3,f),texcoord:e(2,f),normal:e(3,f),color:e(4,f,Uint8Array),indices:e(3,f/3,Uint16Array)};g.position.push(a),g.texcoord.push(b),g.normal.push(c),g.color.push(d);for(var h=0;f>h;++h)g.indices.push(h);return g}function v(a,b,d,f,g,h,i){function j(a,b,c){return a+(b-a)*c}function k(b,d,e,i,k,l){for(var o=0;g>=o;o++){var s=d/(m-1),t=o/g,u=2*(s-.5),v=(h+t*n)*Math.PI,w=Math.sin(v),x=Math.cos(v),y=j(a,b,w),z=u*f,A=x*a,B=w*y;p.push(z,A,B);var C=c.add(c.multiply([0,w,x],e),i);q.push(C),r.push(s*k+l,t)}}function l(a,b){for(var c=0;g>c;++c)u.push(a+c+0,a+c+1,b+c+0),u.push(a+c+1,b+c+1,b+c+0)}if(0>=g)throw Error("subdivisionDown must be > 0");h=h||0,i=i||1;for(var m=2,n=i-h,o=2*(g+1)*(2+m),p=e(3,o),q=e(3,o),r=e(2,o),s=0;m>s;s++){var t=2*(s/(m-1)-.5);k(b,s,[1,1,1],[0,0,0],1,0),k(b,s,[0,0,0],[t,0,0],0,0),k(d,s,[1,1,1],[0,0,0],1,0),k(d,s,[0,0,0],[t,0,0],0,1)}var u=e(3,2*g*(2+m),Uint16Array),v=g+1;return l(0*v,4*v),l(5*v,7*v),l(6*v,2*v),l(3*v,1*v),{position:p,normal:q,texcoord:r,indices:u}}function w(a,b,c,d,e,f){return s(a,a,b,c,d,e,f)}function x(a,b,c,d,f,g){if(3>c)throw Error("radialSubdivisions must be 3 or greater");if(3>d)throw Error("verticalSubdivisions must be 3 or greater");f=f||0,g=g||2*Math.PI,range=g-f;for(var h=c+1,i=d+1,j=h*i,k=e(3,j),l=e(3,j),m=e(2,j),n=e(3,c*d*2,Uint16Array),o=0;i>o;++o)for(var p=o/d,q=p*Math.PI*2,r=Math.sin(q),s=a+r*b,t=Math.cos(q),u=t*b,v=0;h>v;++v){var w=v/c,x=f+w*range,y=Math.sin(x),z=Math.cos(x),A=y*s,B=z*s,C=y*r,D=z*r;k.push(A,u,B),l.push(C,t,D),m.push(w,1-p)}for(var o=0;d>o;++o)for(var v=0;c>v;++v){var E=1+v,F=1+o;n.push(h*o+v,h*F+v,h*o+E),n.push(h*F+v,h*F+E,h*o+E)}return{position:k,normal:l,texcoord:m,indices:n}}function y(a,b,c,d,f){if(3>b)throw Error("divisions must be at least 3");c=c?c:1,f=f?f:1,d=d?d:0;for(var g=(b+1)*(c+1),h=e(3,g),i=e(3,g),j=e(2,g),k=e(3,c*b*2,Uint16Array),l=0,m=a-d,n=0;c>=n;++n){for(var o=d+m*Math.pow(n/c,f),p=0;b>=p;++p){var q=2*Math.PI*p/b,r=o*Math.cos(q),s=o*Math.sin(q);if(h.push(r,0,s),i.push(0,1,0),j.push(1-p/b,n/c),n>0&&p!==b){var t=l+(p+1),u=l+p,v=l+p-b,w=l+(p+1)-b;k.push(t,u,v),k.push(t,v,w)}}l+=b+1}return{position:h,normal:i,texcoord:j,indices:k}}function z(a){return Math.random()*a|0}function A(a,b){b=b||{};var c=a.position.numElements,d=e(4,c,Uint8Array),f=b.rand||function(a,b){return 3>b?z(256):255};if(a.color=d,a.indices)for(var g=0;c>g;++g)d.push(f(g,0),f(g,1),f(g,2),f(g,3));else for(var h=b.vertsPerColor||3,i=c/h,g=0;i>g;++g)for(var j=[f(g,0),f(g,1),f(g,2),f(g,3)],k=0;h>k;++k)d.push(j);return a}function B(b){return function(c){var d=b.apply(this,Array.prototype.slice.call(arguments,1));return a.createBuffersFromArrays(c,d)}}function C(b){return function(c){var d=b.apply(null,Array.prototype.slice.call(arguments,1));return a.createBufferInfoFromArrays(c,d)}}var D=[[3,7,5,1],[6,2,0,4],[6,7,3,2],[0,1,5,4],[7,6,4,5],[2,3,1,0]];return{create3DFBufferInfo:C(u),create3DFBuffers:B(u),create3DFVertices:u,createAugmentedTypedArray:e,createCubeBufferInfo:C(r),createCubeBuffers:B(r),createCubeVertices:r,createPlaneBufferInfo:C(p),createPlaneBuffers:B(p),createPlaneVertices:p,createSphereBufferInfo:C(q),createSphereBuffers:B(q),createSphereVertices:q,createTruncatedConeBufferInfo:C(s),createTruncatedConeBuffers:B(s),createTruncatedConeVertices:s,createXYQuadBufferInfo:C(o),createXYQuadBuffers:B(o),createXYQuadVertices:o,createCresentBufferInfo:C(v),createCresentBuffers:B(v),createCresentVertices:v,createCylinderBufferInfo:C(w),createCylinderBuffers:B(w),createCylinderVertices:w,createTorusBufferInfo:C(x),createTorusBuffers:B(x),createTorusVertices:x,createDiscBufferInfo:C(y),createDiscBuffers:B(y),createDiscVertices:y,deindexVertices:g,flattenNormals:h,makeRandomVertexColors:A,reorientDirections:k,reorientNormals:l,reorientPositions:m,reorientVertices:n}}),c("main",["twgl/twgl","twgl/m4","twgl/v3","twgl/primitives"],function(a,b,c,d){return a.m4=b,a.v3=c,a.primitives=d,a}),b(["main"],function(a){return a},void 0,!0),c("build/js/twgl-includer-full",function(){}),b("main")}); |
/** | ||
* @license twgl.js 0.0.41 Copyright (c) 2015, Gregg Tavares All Rights Reserved. | ||
* @license twgl.js 0.0.42 Copyright (c) 2015, Gregg Tavares All Rights Reserved. | ||
* Available via the MIT license. | ||
@@ -4,0 +4,0 @@ * see: http://github.com/greggman/twgl.js for details |
{ | ||
"name": "twgl.js", | ||
"version": "0.0.41", | ||
"version": "0.0.42", | ||
"description": "A Tiny WebGL helper library", | ||
@@ -5,0 +5,0 @@ "main": "dist/twgl-full.js", |
@@ -1169,3 +1169,3 @@ /* | ||
return m; | ||
return dst; | ||
} | ||
@@ -1172,0 +1172,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19587511