=0&&(o.getDrawableByID(t).dispose(),this._drawables.splice(n,1),!0)},a.prototype.draw=function(){var t=this._gl;i.bindFramebufferInfo(t,null),t.viewport(0,0,t.canvas.width,t.canvas.height),t.clearColor.apply(t,this._backgroundColor),t.clear(t.COLOR_BUFFER_BIT),this._drawThese(this._drawables,u.DRAW_MODE["default"],this._projection)},a.prototype.isTouchingColor=function(t,r,e){var o=this._gl;i.bindFramebufferInfo(o,this._queryBufferInfo),o.viewport(0,0,this._nativeSize[0],this._nativeSize[1]),o.clearColor.apply(o,this._backgroundColor),o.clear(o.COLOR_BUFFER_BIT|o.STENCIL_BUFFER_BIT);var f;e&&(f={u_colorMask:[e[0]/255,e[1]/255,e[2]/255],u_colorMaskTolerance:a.TOLERANCE_TOUCHING_COLOR/255});try{o.enable(o.STENCIL_TEST),o.stencilFunc(o.ALWAYS,1,1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),o.colorMask(!1,!1,!1,!1),this._drawThese([t],e?u.DRAW_MODE.colorMask:u.DRAW_MODE.silhouette,this._projection,void 0,f),o.stencilFunc(o.EQUAL,1,1),o.stencilOp(o.KEEP,o.KEEP,o.KEEP),o.colorMask(!0,!0,!0,!0),this._drawThese(this._drawables,u.DRAW_MODE["default"],this._projection,function(n){return n!=t})}finally{o.colorMask(!0,!0,!0,!0),o.disable(o.STENCIL_TEST)}var c=new n(this._nativeSize[0]*this._nativeSize[1]*4);if(o.readPixels(0,0,this._nativeSize[0],this._nativeSize[1],o.RGBA,o.UNSIGNED_BYTE,c),this._debugCanvas){this._debugCanvas.width=this._nativeSize[0],this._debugCanvas.height=this._nativeSize[1];for(var s=this._debugCanvas.getContext("2d"),l=s.getImageData(0,0,this._nativeSize[0],this._nativeSize[1]),h=0,p=c.length;hP[B]&&(B=U);return 0|B},a.prototype.updateDrawableProperties=function(t,n){var r=o.getDrawableByID(t);r.updateProperties(n)},a.prototype._createGeometry=function(){var t={a_position:{numComponents:2,data:[-.5,-.5,.5,-.5,-.5,.5,-.5,.5,.5,-.5,.5,.5]},a_texCoord:{numComponents:2,data:[1,0,0,0,1,1,1,1,0,0,0,1]}};this._bufferInfo=i.createBufferInfoFromArrays(this._gl,t)},a.prototype._createQueryBuffers=function(){var t=this._gl,n=[{format:t.RGBA},{format:t.DEPTH_STENCIL}];this._pickBufferInfo=i.createFramebufferInfo(t,n,a.MAX_TOUCH_SIZE[0],a.MAX_TOUCH_SIZE[1]),this._queryBufferInfo=i.createFramebufferInfo(t,n,this._nativeSize[0],this._nativeSize[1])},a.prototype._drawThese=function(t,n,r,e,u){for(var a=this._gl,f=null,c=t.length,s=0;s
- * @license MIT
- */
-"use strict";function i(){function t(){}try{var n=new Uint8Array(1);return n.foo=function(){return 42},n.constructor=t,42===n.foo()&&n.constructor===t&&"function"==typeof n.subarray&&0===n.subarray(1,1).byteLength}catch(r){return!1}}function o(){return t.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function t(n){return this instanceof t?(t.TYPED_ARRAY_SUPPORT||(this.length=0,this.parent=void 0),"number"==typeof n?u(this,n):"string"==typeof n?a(this,n,arguments.length>1?arguments[1]:"utf8"):f(this,n)):arguments.length>1?new t(n,arguments[1]):new t(n)}function u(n,r){if(n=d(n,r<0?0:0|g(r)),!t.TYPED_ARRAY_SUPPORT)for(var e=0;e>>1;return e&&(n.parent=J),n}function g(t){if(t>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|t}function y(n,r){if(!(this instanceof y))return new y(n,r);var e=new t(n,r);return delete e.parent,e}function m(t,n){"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var e=!1;;)switch(n){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return W(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return X(t).length;default:if(e)return W(t).length;n=(""+n).toLowerCase(),e=!0}}function _(t,n,r){var e=!1;if(n=0|n,r=void 0===r||r===1/0?this.length:0|r,t||(t="utf8"),n<0&&(n=0),r>this.length&&(r=this.length),r<=n)return"";for(;;)switch(t){case"hex":return M(this,n,r);case"utf8":case"utf-8":return R(this,n,r);case"ascii":return O(this,n,r);case"binary":return P(this,n,r);case"base64":return T(this,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return F(this,n,r);default:if(e)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),e=!0}}function E(t,n,r,e){r=Number(r)||0;var i=t.length-r;e?(e=Number(e),e>i&&(e=i)):e=i;var o=n.length;if(o%2!==0)throw new Error("Invalid hex string");e>o/2&&(e=o/2);for(var u=0;u239?4:o>223?3:o>191?2:1;if(i+a<=r){var f,c,s,l;switch(a){case 1:o<128&&(u=o);break;case 2:f=t[i+1],128===(192&f)&&(l=(31&o)<<6|63&f,l>127&&(u=l));break;case 3:f=t[i+1],c=t[i+2],128===(192&f)&&128===(192&c)&&(l=(15&o)<<12|(63&f)<<6|63&c,l>2047&&(l<55296||l>57343)&&(u=l));break;case 4:f=t[i+1],c=t[i+2],s=t[i+3],128===(192&f)&&128===(192&c)&&128===(192&s)&&(l=(15&o)<<18|(63&f)<<12|(63&c)<<6|63&s,l>65535&&l<1114112&&(u=l))}}null===u?(u=65533,a=1):u>65535&&(u-=65536,e.push(u>>>10&1023|55296),u=56320|1023&u),e.push(u),i+=a}return I(e)}function I(t){var n=t.length;if(n<=Q)return String.fromCharCode.apply(String,t);for(var r="",e=0;ee)&&(r=e);for(var i="",o=n;or)throw new RangeError("Trying to access beyond buffer length")}function U(n,r,e,i,o,u){if(!t.isBuffer(n))throw new TypeError("buffer must be a Buffer instance");if(r>o||rn.length)throw new RangeError("index out of range")}function L(t,n,r,e){n<0&&(n=65535+n+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(e?i:1-i)}function N(t,n,r,e){n<0&&(n=4294967295+n+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(e?i:3-i)&255}function C(t,n,r,e,i,o){if(n>i||nt.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function D(t,n,r,e,i){return i||C(t,n,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(t,n,r,e,23,4),r+4}function k(t,n,r,e,i){return i||C(t,n,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(t,n,r,e,52,8),r+8}function j(t){if(t=z(t).replace(tt,""),t.length<2)return"";for(;t.length%4!==0;)t+="=";return t}function z(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function G(t){return t<16?"0"+t.toString(16):t.toString(16)}function W(t,n){n=n||1/0;for(var r,e=t.length,i=null,o=[],u=0;u55295&&r<57344){if(!i){if(r>56319){(n-=3)>-1&&o.push(239,191,189);continue}if(u+1===e){(n-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(n-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(n-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((n-=1)<0)break;o.push(r)}else if(r<2048){if((n-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((n-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((n-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Y(t){for(var n=[],r=0;r>8,i=r%256,o.push(i),o.push(e);return o}function X(t){return q.toByteArray(j(t))}function H(t,n,r,e){for(var i=0;i=n.length||i>=t.length);i++)n[i+r]=t[i];return i}var q=r(300),K=r(301),Z=r(302);n.Buffer=t,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50,t.poolSize=8192;var J={};t.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:i(),t.TYPED_ARRAY_SUPPORT?(t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array):(t.prototype.length=void 0,t.prototype.parent=void 0),t.isBuffer=function(t){return!(null==t||!t._isBuffer)},t.compare=function(n,r){if(!t.isBuffer(n)||!t.isBuffer(r))throw new TypeError("Arguments must be Buffers");if(n===r)return 0;for(var e=n.length,i=r.length,o=0,u=Math.min(e,i);o0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},t.prototype.compare=function(n){if(!t.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?0:t.compare(this,n)},t.prototype.indexOf=function(n,r){function e(t,n,r){for(var e=-1,i=0;r+i2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r>>=0,0===this.length)return-1;if(r>=this.length)return-1;if(r<0&&(r=Math.max(this.length+r,0)),"string"==typeof n)return 0===n.length?-1:String.prototype.indexOf.call(this,n,r);if(t.isBuffer(n))return e(this,n,r);if("number"==typeof n)return t.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,n,r):e(this,[n],r);throw new TypeError("val must be string, number or Buffer")},t.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},t.prototype.set=function(t,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,n)},t.prototype.write=function(t,n,r,e){if(void 0===n)e="utf8",r=this.length,n=0;else if(void 0===r&&"string"==typeof n)e=n,r=this.length,n=0;else if(isFinite(n))n=0|n,isFinite(r)?(r=0|r,void 0===e&&(e="utf8")):(e=r,r=void 0);else{var i=e;e=n,n=0|r,r=i}var o=this.length-n;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||n<0)||n>this.length)throw new RangeError("attempt to write outside buffer bounds");e||(e="utf8");for(var u=!1;;)switch(e){case"hex":return E(this,t,n,r);case"utf8":case"utf-8":return w(this,t,n,r);case"ascii":return b(this,t,n,r);case"binary":return A(this,t,n,r);case"base64":return x(this,t,n,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,n,r);default:if(u)throw new TypeError("Unknown encoding: "+e);e=(""+e).toLowerCase(),u=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;t.prototype.slice=function(n,r){var e=this.length;n=~~n,r=void 0===r?e:~~r,n<0?(n+=e,n<0&&(n=0)):n>e&&(n=e),r<0?(r+=e,r<0&&(r=0)):r>e&&(r=e),r0&&(i*=256);)e+=this[t+--n]*i;return e},t.prototype.readUInt8=function(t,n){return n||B(t,1,this.length),this[t]},t.prototype.readUInt16LE=function(t,n){return n||B(t,2,this.length),this[t]|this[t+1]<<8},t.prototype.readUInt16BE=function(t,n){return n||B(t,2,this.length),this[t]<<8|this[t+1]},t.prototype.readUInt32LE=function(t,n){return n||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},t.prototype.readUInt32BE=function(t,n){return n||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},t.prototype.readIntLE=function(t,n,r){t=0|t,n=0|n,r||B(t,n,this.length);for(var e=this[t],i=1,o=0;++o=i&&(e-=Math.pow(2,8*n)),e},t.prototype.readIntBE=function(t,n,r){t=0|t,n=0|n,r||B(t,n,this.length);for(var e=n,i=1,o=this[t+--e];e>0&&(i*=256);)o+=this[t+--e]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*n)),o},t.prototype.readInt8=function(t,n){return n||B(t,1,this.length),128&this[t]?(255-this[t]+1)*-1:this[t]},t.prototype.readInt16LE=function(t,n){n||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(t,n){n||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(t,n){return n||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},t.prototype.readInt32BE=function(t,n){return n||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},t.prototype.readFloatLE=function(t,n){return n||B(t,4,this.length),K.read(this,t,!0,23,4)},t.prototype.readFloatBE=function(t,n){return n||B(t,4,this.length),K.read(this,t,!1,23,4)},t.prototype.readDoubleLE=function(t,n){return n||B(t,8,this.length),K.read(this,t,!0,52,8)},t.prototype.readDoubleBE=function(t,n){return n||B(t,8,this.length),K.read(this,t,!1,52,8)},t.prototype.writeUIntLE=function(t,n,r,e){t=+t,n=0|n,r=0|r,e||U(this,t,n,r,Math.pow(2,8*r),0);var i=1,o=0;for(this[n]=255&t;++o=0&&(o*=256);)this[n+i]=t/o&255;return n+r},t.prototype.writeUInt8=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,1,255,0),t.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),this[r]=255&n,r+1},t.prototype.writeUInt16LE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=255&n,this[r+1]=n>>>8):L(this,n,r,!0),r+2},t.prototype.writeUInt16BE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,2,65535,0),t.TYPED_ARRAY_SUPPORT?(this[r]=n>>>8,this[r+1]=255&n):L(this,n,r,!1),r+2},t.prototype.writeUInt32LE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r+3]=n>>>24,this[r+2]=n>>>16,this[r+1]=n>>>8,this[r]=255&n):N(this,n,r,!0),r+4},t.prototype.writeUInt32BE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,4,4294967295,0),t.TYPED_ARRAY_SUPPORT?(this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=255&n):N(this,n,r,!1),r+4},t.prototype.writeIntLE=function(t,n,r,e){if(t=+t,n=0|n,!e){var i=Math.pow(2,8*r-1);U(this,t,n,r,i-1,-i)}var o=0,u=1,a=t<0?1:0;for(this[n]=255&t;++o>0)-a&255;return n+r},t.prototype.writeIntBE=function(t,n,r,e){if(t=+t,n=0|n,!e){var i=Math.pow(2,8*r-1);U(this,t,n,r,i-1,-i)}var o=r-1,u=1,a=t<0?1:0;for(this[n+o]=255&t;--o>=0&&(u*=256);)this[n+o]=(t/u>>0)-a&255;return n+r},t.prototype.writeInt8=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,1,127,-128),t.TYPED_ARRAY_SUPPORT||(n=Math.floor(n)),n<0&&(n=255+n+1),this[r]=255&n,r+1},t.prototype.writeInt16LE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=255&n,this[r+1]=n>>>8):L(this,n,r,!0),r+2},t.prototype.writeInt16BE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,2,32767,-32768),t.TYPED_ARRAY_SUPPORT?(this[r]=n>>>8,this[r+1]=255&n):L(this,n,r,!1),r+2},t.prototype.writeInt32LE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,4,2147483647,-2147483648),t.TYPED_ARRAY_SUPPORT?(this[r]=255&n,this[r+1]=n>>>8,this[r+2]=n>>>16,this[r+3]=n>>>24):N(this,n,r,!0),r+4},t.prototype.writeInt32BE=function(n,r,e){return n=+n,r=0|r,e||U(this,n,r,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),t.TYPED_ARRAY_SUPPORT?(this[r]=n>>>24,this[r+1]=n>>>16,this[r+2]=n>>>8,this[r+3]=255&n):N(this,n,r,!1),r+4},t.prototype.writeFloatLE=function(t,n,r){return D(this,t,n,!0,r)},t.prototype.writeFloatBE=function(t,n,r){return D(this,t,n,!1,r)},t.prototype.writeDoubleLE=function(t,n,r){return k(this,t,n,!0,r)},t.prototype.writeDoubleBE=function(t,n,r){return k(this,t,n,!1,r)},t.prototype.copy=function(n,r,e,i){if(e||(e=0),i||0===i||(i=this.length),r>=n.length&&(r=n.length),r||(r=0),i>0&&i=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),n.length-r=0;o--)n[o+r]=this[o+e];else if(u<1e3||!t.TYPED_ARRAY_SUPPORT)for(o=0;o=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var e;if("number"==typeof t)for(e=n;e0)throw new Error("Invalid string. Length must be a multiple of 4");var s=t.length;f="="===t.charAt(s-2)?2:"="===t.charAt(s-1)?1:0,c=new o(3*t.length/4-f),u=f>0?t.length-4:t.length;var l=0;for(e=0,i=0;e>16),r((65280&a)>>8),r(255&a);return 2===f?(a=n(t.charAt(e))<<2|n(t.charAt(e+1))>>4,r(255&a)):1===f&&(a=n(t.charAt(e))<<10|n(t.charAt(e+1))<<4|n(t.charAt(e+2))>>2,r(a>>8&255),r(255&a)),c}function i(t){function n(t){return e.charAt(t)}function r(t){return n(t>>18&63)+n(t>>12&63)+n(t>>6&63)+n(63&t)}var i,o,u,a=t.length%3,f="";for(i=0,u=t.length-a;i>2),f+=n(o<<4&63),f+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],f+=n(o>>10),f+=n(o>>4&63),f+=n(o<<2&63),f+="="}return f}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,u="+".charCodeAt(0),a="/".charCodeAt(0),f="0".charCodeAt(0),c="a".charCodeAt(0),s="A".charCodeAt(0),l="-".charCodeAt(0),h="_".charCodeAt(0);t.toByteArray=r,t.fromByteArray=i}(n)},function(t,n){n.read=function(t,n,r,e,i){var o,u,a=8*i-e-1,f=(1<>1,s=-7,l=r?i-1:0,h=r?-1:1,p=t[n+l];for(l+=h,o=p&(1<<-s)-1,p>>=-s,s+=a;s>0;o=256*o+t[n+l],l+=h,s-=8);for(u=o&(1<<-s)-1,o>>=-s,s+=e;s>0;u=256*u+t[n+l],l+=h,s-=8);if(0===o)o=1-c;else{if(o===f)return u?NaN:(p?-1:1)*(1/0);u+=Math.pow(2,e),o-=c}return(p?-1:1)*u*Math.pow(2,o-e)},n.write=function(t,n,r,e,i,o){var u,a,f,c=8*o-i-1,s=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=e?0:o-1,v=e?1:-1,d=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(a=isNaN(n)?1:0,u=s):(u=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-u))<1&&(u--,f*=2),n+=u+l>=1?h/f:h*Math.pow(2,1-l),n*f>=2&&(u++,f/=2),u+l>=s?(a=0,u=s):u+l>=1?(a=(n*f-1)*Math.pow(2,i),u+=l):(a=n*Math.pow(2,l-1)*Math.pow(2,i),u=0));i>=8;t[r+p]=255&a,p+=v,a/=256,i-=8);for(u=u<0;t[r+p]=255&u,p+=v,u/=256,c-=8);t[r+p-v]|=128*d}},function(t,n){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,n,r){var e,i,o;/**
- * @license twgl.js 1.5.2 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
- * Available via the MIT license.
- * see: http://github.com/greggman/twgl.js for details
- */
-/**
- * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/almond for details
- */
-!function(r,u){i=[],e=u,o="function"==typeof e?e.apply(n,i):e,!(void 0!==o&&(t.exports=o)),"undefined"!=typeof t&&t.exports?t.exports=u():r.twgl=u()}(this,function(){/**
- * @license almond 0.3.1 Copyright (c) 2011-2014, The Dojo Foundation All Rights Reserved.
- * Available via the MIT or new BSD license.
- * see: http://github.com/jrburke/almond for details
- */
-var t,n,r;return function(e){function i(t,n){return E.call(t,n)}function o(t,n){var r,e,i,o,u,a,f,c,s,l,h,p=n&&n.split("/"),v=m.map,d=v&&v["*"]||{};if(t&&"."===t.charAt(0))if(n){for(t=t.split("/"),u=t.length-1,m.nodeIdCompat&&b.test(t[u])&&(t[u]=t[u].replace(b,"")),t=p.slice(0,p.length-1).concat(t),s=0;s0&&(t.splice(s-1,2),s-=2)}t=t.join("/")}else 0===t.indexOf("./")&&(t=t.substring(2));if((p||d)&&v){for(r=t.split("/"),s=r.length;s>0;s-=1){if(e=r.slice(0,s).join("/"),p)for(l=p.length;l>0;l-=1)if(i=v[p.slice(0,l).join("/")],i&&(i=i[e])){o=i,a=s;break}if(o)break;!f&&d&&d[e]&&(f=d[e],c=s)}!o&&f&&(o=f,a=c),o&&(r.splice(0,a,o),t=r.join("/"))}return t}function u(t,n){return function(){var r=w.call(arguments,0);return"string"!=typeof r[0]&&1===r.length&&r.push(null),p.apply(e,r.concat([t,n]))}}function a(t){return function(n){return o(n,t)}}function f(t){return function(n){g[t]=n}}function c(t){if(i(y,t)){var n=y[t];delete y[t],_[t]=!0,h.apply(e,n)}if(!i(g,t)&&!i(_,t))throw new Error("No "+t);return g[t]}function s(t){var n,r=t?t.indexOf("!"):-1;return r>-1&&(n=t.substring(0,r),t=t.substring(r+1,t.length)),[n,t]}function l(t){return function(){return m&&m.config&&m.config[t]||{}}}var h,p,v,d,g={},y={},m={},_={},E=Object.prototype.hasOwnProperty,w=[].slice,b=/\.js$/;v=function(t,n){var r,e=s(t),i=e[0];return t=e[1],i&&(i=o(i,n),r=c(i)),i?t=r&&r.normalize?r.normalize(t,a(n)):o(t,n):(t=o(t,n),e=s(t),i=e[0],t=e[1],i&&(r=c(i))),{f:i?i+"!"+t:t,n:t,pr:i,p:r}},d={notrequirebecasebrowserifymessesup:function(t){return u(t)},exports:function(t){var n=g[t];return"undefined"!=typeof n?n:g[t]={}},module:function(t){return{id:t,uri:"",exports:g[t],config:l(t)}}},h=function(t,n,r,o){var a,s,l,h,p,m,E=[],w=typeof r;if(o=o||t,"undefined"===w||"function"===w){for(n=!n.length&&r.length?["notrequirebecasebrowserifymessesup","exports","module"]:n,p=0;p=0?2:t.indexOf("color")>=0?4:3,n%r>0)throw"can not guess numComponents. You should specify it.";return r}function s(t,n){return t.numComponents||t.size||c(n,f(t).length)}function l(n,r){if(t.isArrayBuffer(n))return n;if(t.isArrayBuffer(n.data))return n.data;Array.isArray(n)&&(n={data:n});var e=n.type;return e||(e="indices"===r?Uint16Array:Float32Array),new e(n.data)}function h(n,r){var e={};return Object.keys(r).forEach(function(i){if(!u(i)){var f=r[i],c=f.attrib||f.name||f.attribName||m.attribPrefix+i,h=l(f,i);e[c]={buffer:o(n,h,void 0,f.drawType),numComponents:s(f,i),type:t.getGLTypeForTypedArray(h),normalize:void 0!==f.normalize?f.normalize:a(h),stride:f.stride||0,offset:f.offset||0,drawType:f.drawType}}}),e}function p(t,n,r,e){r=l(r),e?(t.bindBuffer(t.ARRAY_BUFFER,n.buffer),t.bufferSubData(t.ARRAY_BUFFER,e,r)):i(t,t.ARRAY_BUFFER,n.buffer,r,n.drawType)}function v(n,r){var e={attribs:h(n,r)},i=r.indices;return i?(i=l(i,"indices"),e.indices=o(n,i,n.ELEMENT_ARRAY_BUFFER),e.numElements=i.length,e.elementType=t.getGLTypeForTypedArray(i)):e.numElements=_(r),e}function d(t,n,r){var e="indices"===r?t.ELEMENT_ARRAY_BUFFER:t.ARRAY_BUFFER,i=l(n,r);return o(t,i,e)}function g(t,n){var r={};return Object.keys(n).forEach(function(e){r[e]=d(t,n[e],e)}),r}function y(t,n,r){var e=t.createVertexArray();return t.bindVertexArray(e),n.length||(n=[n]),n.forEach(function(n){twgl.setBuffersAndAttributes(t,n,r)}),t.bindVertexArray(null),{numElements:r.numElements,elementType:r.elementType,vertexArrayObject:e}}var m={attribPrefix:""},_=function(){var t=["position","positions","a_position"];return function(n){for(var r,e=0;e0)throw"numComponents "+u+" not correct for length "+o;return a}}();return{createAttribsFromArrays:h,createBuffersFromArrays:g,createBufferFromArray:d,createBufferFromTypedArray:o,createBufferInfoFromArrays:v,setAttribInfoBufferFromArray:p,createVertexArrayInfo:y,setAttributePrefix:r,setDefaults_:e,getNumComponents_:s,getArray_:f}}),r("twgl/programs",["./utils"],function(t){function n(t,n){return kt[n].bindPoint}function r(t,n){return function(r){t.uniform1f(n,r)}}function e(t,n){return function(r){t.uniform1fv(n,r)}}function i(t,n){return function(r){t.uniform2fv(n,r)}}function o(t,n){return function(r){t.uniform3fv(n,r)}}function u(t,n){return function(r){t.uniform4fv(n,r)}}function a(t,n){return function(r){t.uniform1i(n,r)}}function f(t,n){return function(r){t.uniform1iv(n,r)}}function c(t,n){return function(r){t.uniform2iv(n,r)}}function s(t,n){return function(r){t.uniform3iv(n,r)}}function l(t,n){return function(r){t.uniform4iv(n,r)}}function h(t,n){return function(r){t.uniform1ui(n,r)}}function p(t,n){return function(r){t.uniform1uiv(n,r)}}function v(t,n){return function(r){t.uniform2uiv(n,r)}}function d(t,n){return function(r){t.uniform3uiv(n,r)}}function g(t,n){return function(r){t.uniform4uiv(n,r)}}function y(t,n){return function(r){t.uniformMatrix2fv(n,!1,r)}}function m(t,n){return function(r){t.uniformMatrix3fv(n,!1,r)}}function _(t,n){return function(r){t.uniformMatrix4fv(n,!1,r)}}function E(t,n){return function(r){t.uniformMatrix2x3fv(n,!1,r)}}function w(t,n){return function(r){t.uniformMatrix3x2fv(n,!1,r)}}function b(t,n){return function(r){t.uniformMatrix2x4fv(n,!1,r)}}function A(t,n){return function(r){t.uniformMatrix4x2fv(n,!1,r)}}function x(t,n){return function(r){t.uniformMatrix3x4fv(n,!1,r)}}function S(t,n){return function(r){t.uniformMatrix4x3fv(n,!1,r)}}function T(t,r,e,i){var o=n(t,r);return function(n){t.uniform1i(i,e),t.activeTexture(t.TEXTURE0+e),t.bindTexture(o,n)}}function R(t,r,e,i,o){for(var u=n(t,r),a=new Int32Array(o),f=0;f1&&"[0]"===r.name.substr(-3),u=r.type,a=kt[u];if(!a)throw"unknown type: 0x"+u.toString(16);if(a.bindPoint){var f=e;return e+=r.size,o?a.arraySetter(t,u,f,i,r.size):a.setter(t,u,f,i,r.size)}return a.arraySetter&&o?a.arraySetter(t,i):a.setter(t,i)}for(var e=0,i={},o=t.getProgramParameter(n,t.ACTIVE_UNIFORMS),u=0;u1e-5?(n[0]=t[0]/e,n[1]=t[1]/e,n[2]=t[2]/e):(n[0]=0,n[1]=0,n[2]=0),n}function h(t,n){return n=n||new g(3),n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n}function p(t,n){return n=n||new g(3),n[0]=t[0],n[1]=t[1],n[2]=t[2],n}function v(t,n,r){return r=r||new g(3),r[0]=t[0]*n[0],r[1]=t[1]*n[1],r[2]=t[2]*n[2],r}function d(t,n,r){return r=r||new g(3),r[0]=t[0]/n[0],r[1]=t[1]/n[1],r[2]=t[2]/n[2],r}var g=Float32Array;return{add:r,copy:p,create:n,cross:a,divide:d,divScalar:u,dot:f,lerp:i,length:c,lengthSq:s,mulScalar:o,multiply:v,negate:h,normalize:l,setDefaultType:t,subtract:e}}),r("twgl/m4",["./v3"],function(t){function n(t){var n=M;return M=t,n}function r(t,n){return n=n||new M(16),n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=-t[3],n[4]=-t[4],n[5]=-t[5],n[6]=-t[6],n[7]=-t[7],n[8]=-t[8],n[9]=-t[9],n[10]=-t[10],n[11]=-t[11],n[12]=-t[12],n[13]=-t[13],n[14]=-t[14],n[15]=-t[15],n}function e(t,n){return n=n||new M(16),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}function i(t){return t=t||new M(16),t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function o(t,n){if(n=n||new M(16),n===t){var r;return r=t[1],t[1]=t[4],t[4]=r,r=t[2],t[2]=t[8],t[8]=r,r=t[3],t[3]=t[12],t[12]=r,r=t[6],t[6]=t[9],t[9]=r,r=t[7],t[7]=t[13],t[13]=r,r=t[11],t[11]=t[14],t[14]=r,n}var e=t[0],i=t[1],o=t[2],u=t[3],a=t[4],f=t[5],c=t[6],s=t[7],l=t[8],h=t[9],p=t[10],v=t[11],d=t[12],g=t[13],y=t[14],m=t[15];return n[0]=e,n[1]=a,n[2]=l,n[3]=d,n[4]=i,n[5]=f,n[6]=h,n[7]=g,n[8]=o,n[9]=c,n[10]=p,n[11]=y,n[12]=u,n[13]=s,n[14]=v,n[15]=m,n}function u(t,n){n=n||new M(16);var r=t[0],e=t[1],i=t[2],o=t[3],u=t[4],a=t[5],f=t[6],c=t[7],s=t[8],l=t[9],h=t[10],p=t[11],v=t[12],d=t[13],g=t[14],y=t[15],m=h*y,_=g*p,E=f*y,w=g*c,b=f*p,A=h*c,x=i*y,S=g*o,T=i*p,R=h*o,I=i*c,O=f*o,P=s*d,F=v*l,B=u*d,U=v*a,L=u*l,N=s*a,C=r*d,D=v*e,k=r*l,j=s*e,z=r*a,G=u*e,W=m*a+w*l+b*d-(_*a+E*l+A*d),Y=_*e+x*l+R*d-(m*e+S*l+T*d),V=E*e+S*a+I*d-(w*e+x*a+O*d),X=A*e+T*a+O*l-(b*e+R*a+I*l),H=1/(r*W+u*Y+s*V+v*X);return n[0]=H*W,n[1]=H*Y,n[2]=H*V,n[3]=H*X,n[4]=H*(_*u+E*s+A*v-(m*u+w*s+b*v)),n[5]=H*(m*r+S*s+T*v-(_*r+x*s+R*v)),n[6]=H*(w*r+x*u+O*v-(E*r+S*u+I*v)),n[7]=H*(b*r+R*u+I*s-(A*r+T*u+O*s)),n[8]=H*(P*c+U*p+L*y-(F*c+B*p+N*y)),n[9]=H*(F*o+C*p+j*y-(P*o+D*p+k*y)),n[10]=H*(B*o+D*c+z*y-(U*o+C*c+G*y)),n[11]=H*(N*o+k*c+G*p-(L*o+j*c+z*p)),n[12]=H*(B*h+N*g+F*f-(L*g+P*f+U*h)),n[13]=H*(k*g+P*i+D*h-(C*h+j*g+F*i)),
-n[14]=H*(C*f+G*g+U*i-(z*g+B*i+D*f)),n[15]=H*(z*h+L*i+j*f-(k*f+G*h+N*i)),n}function a(t,n,r){r=r||new M(16);var e=t[0],i=t[1],o=t[2],u=t[3],a=t[4],f=t[5],c=t[6],s=t[7],l=t[8],h=t[9],p=t[10],v=t[11],d=t[12],g=t[13],y=t[14],m=t[15],_=n[0],E=n[1],w=n[2],b=n[3],A=n[4],x=n[5],S=n[6],T=n[7],R=n[8],I=n[9],O=n[10],P=n[11],F=n[12],B=n[13],U=n[14],L=n[15];return r[0]=e*_+i*A+o*R+u*F,r[1]=e*E+i*x+o*I+u*B,r[2]=e*w+i*S+o*O+u*U,r[3]=e*b+i*T+o*P+u*L,r[4]=a*_+f*A+c*R+s*F,r[5]=a*E+f*x+c*I+s*B,r[6]=a*w+f*S+c*O+s*U,r[7]=a*b+f*T+c*P+s*L,r[8]=l*_+h*A+p*R+v*F,r[9]=l*E+h*x+p*I+v*B,r[10]=l*w+h*S+p*O+v*U,r[11]=l*b+h*T+p*P+v*L,r[12]=d*_+g*A+y*R+m*F,r[13]=d*E+g*x+y*I+m*B,r[14]=d*w+g*S+y*O+m*U,r[15]=d*b+g*T+y*P+m*L,r}function f(t,n,r){return r=r||i(),t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11]),r[12]=n[0],r[13]=n[1],r[14]=n[2],r[15]=1,r}function c(n,r){return r=r||t.create(),r[0]=n[12],r[1]=n[13],r[2]=n[14],r}function s(n,r,e){e=e||t.create();var i=4*r;return e[0]=n[i+0],e[1]=n[i+1],e[2]=n[i+2],e}function l(t,n,r,i){i!==t&&(i=e(t,i));var o=4*r;return i[o+0]=n[0],i[o+1]=n[1],i[o+2]=n[2],i}function h(t,n,r,e,i){i=i||new M(16);var o=Math.tan(.5*Math.PI-.5*t),u=1/(r-e);return i[0]=o/n,i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[5]=o,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[10]=(r+e)*u,i[11]=-1,i[12]=0,i[13]=0,i[14]=r*e*u*2,i[15]=0,i}function p(t,n,r,e,i,o,u){return u=u||new M(16),u[0]=2/(n-t),u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=2/(e-r),u[6]=0,u[7]=0,u[8]=0,u[9]=0,u[10]=-1/(o-i),u[11]=0,u[12]=(n+t)/(t-n),u[13]=(e+r)/(r-e),u[14]=-i/(i-o),u[15]=1,u}function v(t,n,r,e,i,o,u){u=u||new M(16);var a=n-t,f=e-r,c=i-o;return u[0]=2*i/a,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=2*i/f,u[6]=0,u[7]=0,u[8]=(t+n)/a,u[9]=(e+r)/f,u[10]=o/c,u[11]=-1,u[12]=0,u[13]=0,u[14]=i*o/c,u[15]=0,u}function d(n,r,e,i){i=i||new M(16);var o=F,u=B,a=U;return t.normalize(t.subtract(n,r,a),a),t.normalize(t.cross(e,a,o),o),t.normalize(t.cross(a,o,u),u),i[0]=o[0],i[1]=o[1],i[2]=o[2],i[3]=0,i[4]=u[0],i[5]=u[1],i[6]=u[2],i[7]=0,i[8]=a[0],i[9]=a[1],i[10]=a[2],i[11]=0,i[12]=n[0],i[13]=n[1],i[14]=n[2],i[15]=1,i}function g(t,n){return n=n||new M(16),n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n}function y(t,n,r){r=r||new M(16);var e=n[0],i=n[1],o=n[2],u=t[0],a=t[1],f=t[2],c=t[3],s=t[4],l=t[5],h=t[6],p=t[7],v=t[8],d=t[9],g=t[10],y=t[11],m=t[12],_=t[13],E=t[14],w=t[15];return t!==r&&(r[0]=u,r[1]=a,r[2]=f,r[3]=c,r[4]=s,r[5]=l,r[6]=h,r[7]=p,r[8]=v,r[9]=d,r[10]=g,r[11]=y),r[12]=u*e+s*i+v*o+m,r[13]=a*e+l*i+d*o+_,r[14]=f*e+h*i+g*o+E,r[15]=c*e+p*i+y*o+w,r}function m(t,n){n=n||new M(16);var r=Math.cos(t),e=Math.sin(t);return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=r,n[6]=e,n[7]=0,n[8]=0,n[9]=-e,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function _(t,n,r){r=r||new M(16);var e=t[4],i=t[5],o=t[6],u=t[7],a=t[8],f=t[9],c=t[10],s=t[11],l=Math.cos(n),h=Math.sin(n);return r[4]=l*e+h*a,r[5]=l*i+h*f,r[6]=l*o+h*c,r[7]=l*u+h*s,r[8]=l*a-h*e,r[9]=l*f-h*i,r[10]=l*c-h*o,r[11]=l*s-h*u,t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r}function E(t,n){n=n||new M(16);var r=Math.cos(t),e=Math.sin(t);return n[0]=r,n[1]=0,n[2]=-e,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=e,n[9]=0,n[10]=r,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function w(t,n,r){r=r||new M(16);var e=t[0],i=t[1],o=t[2],u=t[3],a=t[8],f=t[9],c=t[10],s=t[11],l=Math.cos(n),h=Math.sin(n);return r[0]=l*e-h*a,r[1]=l*i-h*f,r[2]=l*o-h*c,r[3]=l*u-h*s,r[8]=l*a+h*e,r[9]=l*f+h*i,r[10]=l*c+h*o,r[11]=l*s+h*u,t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r}function b(t,n){n=n||new M(16);var r=Math.cos(t),e=Math.sin(t);return n[0]=r,n[1]=e,n[2]=0,n[3]=0,n[4]=-e,n[5]=r,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function A(t,n,r){r=r||new M(16);var e=t[0],i=t[1],o=t[2],u=t[3],a=t[4],f=t[5],c=t[6],s=t[7],l=Math.cos(n),h=Math.sin(n);return r[0]=l*e+h*a,r[1]=l*i+h*f,r[2]=l*o+h*c,r[3]=l*u+h*s,r[4]=l*a-h*e,r[5]=l*f-h*i,r[6]=l*c-h*o,r[7]=l*s-h*u,t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r}function x(t,n,r){r=r||new M(16);var e=t[0],i=t[1],o=t[2],u=Math.sqrt(e*e+i*i+o*o);e/=u,i/=u,o/=u;var a=e*e,f=i*i,c=o*o,s=Math.cos(n),l=Math.sin(n),h=1-s;return r[0]=a+(1-a)*s,r[1]=e*i*h+o*l,r[2]=e*o*h-i*l,r[3]=0,r[4]=e*i*h-o*l,r[5]=f+(1-f)*s,r[6]=i*o*h+e*l,r[7]=0,r[8]=e*o*h+i*l,r[9]=i*o*h-e*l,r[10]=c+(1-c)*s,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function S(t,n,r,e){e=e||new M(16);var i=n[0],o=n[1],u=n[2],a=Math.sqrt(i*i+o*o+u*u);i/=a,o/=a,u/=a;var f=i*i,c=o*o,s=u*u,l=Math.cos(r),h=Math.sin(r),p=1-l,v=f+(1-f)*l,d=i*o*p+u*h,g=i*u*p-o*h,y=i*o*p-u*h,m=c+(1-c)*l,_=o*u*p+i*h,E=i*u*p+o*h,w=o*u*p-i*h,b=s+(1-s)*l,A=t[0],x=t[1],S=t[2],T=t[3],R=t[4],I=t[5],O=t[6],P=t[7],F=t[8],B=t[9],U=t[10],L=t[11];return e[0]=v*A+d*R+g*F,e[1]=v*x+d*I+g*B,e[2]=v*S+d*O+g*U,e[3]=v*T+d*P+g*L,e[4]=y*A+m*R+_*F,e[5]=y*x+m*I+_*B,e[6]=y*S+m*O+_*U,e[7]=y*T+m*P+_*L,e[8]=E*A+w*R+b*F,e[9]=E*x+w*I+b*B,e[10]=E*S+w*O+b*U,e[11]=E*T+w*P+b*L,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e}function T(t,n){return n=n||new M(16),n[0]=t[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=t[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=t[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}function R(t,n,r){r=r||new M(16);var e=n[0],i=n[1],o=n[2];return r[0]=e*t[0],r[1]=e*t[1],r[2]=e*t[2],r[3]=e*t[3],r[4]=i*t[4],r[5]=i*t[5],r[6]=i*t[6],r[7]=i*t[7],r[8]=o*t[8],r[9]=o*t[9],r[10]=o*t[10],r[11]=o*t[11],t!==r&&(r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r}function I(n,r,e){e=e||t.create();var i=r[0],o=r[1],u=r[2],a=i*n[3]+o*n[7]+u*n[11]+n[15];return e[0]=(i*n[0]+o*n[4]+u*n[8]+n[12])/a,e[1]=(i*n[1]+o*n[5]+u*n[9]+n[13])/a,e[2]=(i*n[2]+o*n[6]+u*n[10]+n[14])/a,e}function O(n,r,e){e=e||t.create();var i=r[0],o=r[1],u=r[2];return e[0]=i*n[0]+o*n[4]+u*n[8],e[1]=i*n[1]+o*n[5]+u*n[9],e[2]=i*n[2]+o*n[6]+u*n[10],e}function P(n,r,e){e=e||t.create();var i=u(n),o=r[0],a=r[1],f=r[2];return e[0]=o*i[0]+a*i[1]+f*i[2],e[1]=o*i[4]+a*i[5]+f*i[6],e[2]=o*i[8]+a*i[9]+f*i[10],e}var M=Float32Array,F=t.create(),B=t.create(),U=t.create();return{axisRotate:S,axisRotation:x,create:i,copy:e,frustum:v,getAxis:s,getTranslation:c,identity:i,inverse:u,lookAt:d,multiply:a,negate:r,ortho:p,perspective:h,rotateX:_,rotateY:w,rotateZ:A,rotateAxis:S,rotationX:m,rotationY:E,rotationZ:b,scale:R,scaling:T,setAxis:l,setDefaultType:n,setTranslation:f,transformDirection:O,transformNormal:P,transformPoint:I,translate:y,translation:g,transpose:o}}),r("twgl/primitives",["./attributes","./twgl","./utils","./m4","./v3"],function(t,n,r,e,i){function o(t,n){var r=0;return t.push=function(){for(var n=0;n=0?v(e,n):r.indexOf("tan")>=0||r.indexOf("binorm")>=0?h(e,n):r.indexOf("norm")>=0&&p(e,n)}),t}function g(t,n,r){return t=t||2,n=n||0,r=r||0,t*=.5,{position:{numComponents:2,data:[n+-1*t,r+-1*t,n+1*t,r+-1*t,n+-1*t,r+1*t,n+1*t,r+1*t]},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 y(t,n,r,i,o){t=t||1,n=n||1,r=r||1,i=i||1,o=o||e.identity();for(var a=(r+1)*(i+1),f=u(3,a),c=u(3,a),s=u(2,a),l=0;l<=i;l++)for(var h=0;h<=r;h++){var p=h/r,v=l/i;f.push(t*p-.5*t,0,n*v-.5*n),c.push(0,1,0),s.push(p,v)}for(var g=r+1,y=u(3,r*i*2,Uint16Array),l=0;l 0");e=e||0,i=i||Math.PI,o=o||0,a=a||2*Math.PI;for(var f=i-e,c=a-o,s=(n+1)*(r+1),l=u(3,s),h=u(3,s),p=u(2,s),v=0;v<=r;v++)for(var d=0;d<=n;d++){var g=d/n,y=v/r,m=c*g,_=f*y,E=Math.sin(m),w=Math.cos(m),b=Math.sin(_),A=Math.cos(_),x=w*b,S=A,T=E*b;l.push(t*x,t*S,t*T),h.push(x,S,T),p.push(1-g,y)}for(var R=n+1,I=u(3,n*r*2,Uint16Array),d=0;di?(S=r,x=1,A=n):A=t+(n-t)*(b/i),b!==-2&&b!==i+2||(A=0,x=0),S-=r/2;for(var T=0;Ti?0:R*m,b<0?-1:b>i?1:_,b<0||b>i?0:I*m),v.push(T/e,1-x)}}for(var b=0;b 0");a=a||0,f=f||1;for(var h=2,p=f-a,v=2*(o+1)*(2+h),d=u(3,v),g=u(3,v),y=u(2,v),m=0;m0&&g!==n){var E=l+(g+1),w=l+g,b=l+g-p,A=l+(g+1)-p;s.push(E,w,b),s.push(E,b,A)}}l+=n+1}return{position:a,normal:f,texcoord:c,indices:s}}function R(t){return Math.random()*t|0}function I(t,n){n=n||{};var r=t.position.numElements,e=u(4,r,Uint8Array),i=n.rand||function(t,n){return n<3?R(256):255};if(t.color=e,t.indices)for(var o=0;o=0&&delete f[this._id]},f.prototype.setTransformDirty=function(){this._transformDirty=!0},f.prototype.getID=function(){return this._id},f.prototype.setSkin=function(t){if(t){var n=t.substring(t.lastIndexOf(".")+1);switch(n){case"svg":case"svg/get/":case"svgz":case"svgz/get/":this._setSkinSVG(t);break;default:this._setSkinBitmap(t)}}else this._useSkin(null,0,0,1,!0)},f.prototype._useSkin=function(t,n,r,e,i){(i||t==this._pendingSkin)&&(this._pendingSkin=null,this._uniforms.u_skin&&this._uniforms.u_skin!=t&&this._gl.deleteTexture(this._uniforms.u_skin),this._setSkinSize(n,r,e),this._uniforms.u_skin=t)},f.prototype.getEnabledEffects=function(){return this._effectBits},f.prototype._setSkinBitmap=function(t){var n=t;this._setSkinCore(n,2)},f.prototype._setSkinSVG=function(t){function n(t,n,e){t||o(e,r)}function r(t,n){t||i._setSkinCore(n,1)}var e=t,i=this;u.get({useXDR:!0,url:e},n)},f.prototype._setSkinCore=function(t,n){var r=this,e=function(t,e,i){t||r._pendingSkin!=e||r._useSkin(e,i.width,i.height,n)},o=this._gl,u={auto:!0,mag:o.NEAREST,min:o.NEAREST,wrap:o.CLAMP_TO_EDGE,src:t},a="string"==typeof t;r._pendingSkin=i.createTexture(o,u,a?e:null),a||e(null,r._pendingSkin,t)},f.prototype.getUniforms=function(){return this._transformDirty&&this._calculateTransform(),this._uniforms},f.prototype.getVisible=function(){return this._visible},f.prototype.updateProperties=function(t){var n=!1;"skin"in t&&this.setSkin(t.skin),"position"in t&&(this._position[0]!=t.position[0]||this._position[1]!=t.position[1])&&(this._position[0]=t.position[0],this._position[1]=t.position[1],n=!0),"direction"in t&&this._direction!=t.direction&&(this._direction=t.direction,n=!0),"scale"in t&&(this._scale[0]!=t.scale[0]||this._scale[1]!=t.scale[1])&&(this._scale[0]=t.scale[0],this._scale[1]=t.scale[1],n=!0),"visible"in t&&(this._visible=t.visible),n&&this.setTransformDirty();for(var r=a.EFFECTS.length,e=0;e>0&255)/255,r=(t>>8&255)/255,e=(t>>16&255)/255;return[n,r,e,1]},f.color4bToID=function(t,n,r,e){var i;return i=(255&t)<<0,i|=(255&n)<<8,i|=(255&r)<<16,i+f.NONE}},function(t,n,r){(function(n){function e(t,r,e){function a(t){n.nextTick(function(){e(new Error(t))})}if("function"==typeof r&&(e=r,r={}),e=e||u,r=r||{},"undefined"==typeof window)return a("window global is undefined; not in a browser");var f=i();if(!f||"function"!=typeof f.createObjectURL||"function"!=typeof f.revokeObjectURL)return a("browser does not support URL.createObjectURL");if("undefined"==typeof window.Blob)return a("browser does not support Blob constructor");Array.isArray(t)||(t=[t]);var c;try{c=new window.Blob(t,{type:"image/svg+xml;charset=utf-8"})}catch(s){return a(s)}var l=f.createObjectURL(c);o(l,r,function(n,i){if(f.revokeObjectURL(l),n){var u="data:image/svg+xml,"+encodeURIComponent(t.join(""));return o(u,r,e)}e(n,i)})}function i(){return window.URL||window.webkitURL||window.mozURL||window.msURL}var o=r(306),u=function(){};t.exports=e}).call(n,r(294))},function(t,n){function r(t,n,r){"function"==typeof n&&(r=n,n=null);var e,i=document.createElement("img");return i.onload=function(){e||(e=!0,r&&r(void 0,i))},i.onerror=function(){e||(e=!0,r&&r(new Error('Unable to load "'+t+'"'),i))},n&&n.crossOrigin&&(i.crossOrigin=n.crossOrigin),i.src=t,i}t.exports=r},function(t,n,r){"use strict";function e(t,n){for(var r=0;r0&&(v=setTimeout(function(){p=!0,c.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",e(t)},t.timeout)),c.setRequestHeader)for(l in m)m.hasOwnProperty(l)&&c.setRequestHeader(l,m[l]);else if(t.headers&&!i(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(c.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(c),c.send(y),c}function f(){}var c=r(308),s=r(309),l=r(310),h=r(311),p=r(314);t.exports=u,u.XMLHttpRequest=c.XMLHttpRequest||f,u.XDomainRequest="withCredentials"in new u.XMLHttpRequest?u.XMLHttpRequest:c.XDomainRequest,e(["get","put","post","patch","head","delete"],function(t){u["delete"===t?"del":t]=function(n,r,e){return r=o(n,r,e),r.method=t.toUpperCase(),a(r)}})},function(t,n){(function(n){"undefined"!=typeof window?t.exports=window:"undefined"!=typeof n?t.exports=n:"undefined"!=typeof self?t.exports=self:t.exports={}}).call(n,function(){return this}())},function(t,n){function r(t){var n=!1;return function(){if(!n)return n=!0,t.apply(this,arguments)}}t.exports=r,r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0})})},function(t,n){function r(t){var n=e.call(t);return"[object Function]"===n||"function"==typeof t&&"[object RegExp]"!==n||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}t.exports=r;var e=Object.prototype.toString},function(t,n,r){var e=r(312),i=r(313),o=function(t){return"[object Array]"===Object.prototype.toString.call(t)};t.exports=function(t){if(!t)return{};var n={};return i(e(t).split("\n"),function(t){var r=t.indexOf(":"),i=e(t.slice(0,r)).toLowerCase(),u=e(t.slice(r+1));"undefined"==typeof n[i]?n[i]=u:o(n[i])?n[i].push(u):n[i]=[n[i],u]}),n}},function(t,n){function r(t){return t.replace(/^\s*|\s*$/g,"")}n=t.exports=r,n.left=function(t){return t.replace(/^\s*/,"")},n.right=function(t){return t.replace(/\s*$/,"")}},function(t,n,r){function e(t,n,r){if(!a(n))throw new TypeError("iterator must be a function");arguments.length<3&&(r=this),"[object Array]"===f.call(t)?i(t,n,r):"string"==typeof t?o(t,n,r):u(t,n,r)}function i(t,n,r){for(var e=0,i=t.length;e