mirror of
https://github.com/rreusser/rreusser.github.io.git
synced 2026-01-18 16:13:07 +00:00
1 line
86 KiB
JavaScript
1 line
86 KiB
JavaScript
!function(){return function e(t,n,r){function i(o,f){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!f&&u)return u(o,!0);if(a)return a(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return i(n||e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(e,t,n){"use strict";var r=e("h");t.exports=function(e,t){return t=t||{},function(n,i){if(!n)return e&&e(i);if(n instanceof Error)n=n.name+": "+n.message;else if("string"!=typeof n)throw new Error("fail-nicely: Oops! the message must be a String or an Error. How ironic.");var a=void 0===t.zIndex?9999:parseInt(t.zIndex),o=void 0===t.bg?"#333":t.bg,f=void 0===t.fg?"#fff":t.fg,u=void 0===t.title?"Sorry!":t.title,s=void 0===t.fontFamily?"Helvetica, Arial, sans-serif":t.fontFamily,c=void 0===t.position?"fixed":t.position;if(void 0!==t.invert&&t.invert){var l=f;f=o,o=l}var p={position:c,top:0,right:0,bottom:0,left:0,"background-color":o,color:f,"text-align":"center","z-index":a},d={"font-family":s},h={"font-family":s,"max-width":"640px","margin-left":"auto","margin-right":"auto","line-height":"1.4",padding:"0 15px"};document.body.appendChild(r("div",{style:p},[r("div",{style:{transform:"translate(0, -50%)","margin-top":"50vh"}},[r("h1",u,{style:d}),r("p",n,{style:h})])]))}}},{h:3}],2:[function(e,t,n){t.exports=function(e){"string"==typeof e&&(e=[e]);for(var t=[].slice.call(arguments,1),n=[],r=0;r<e.length-1;r++)n.push(e[r],t[r]||"");return n.push(e[r]),n.join("")}},{}],3:[function(e,t,n){!function(){function e(){var e=[].slice.call(arguments),t=null;function n(e){if(null==e);else if("string"==typeof e)t?t.appendChild(document.createTextNode(e)):e.split(/([\.#]?[a-zA-Z0-9_-]+)/).forEach(function(e){var n=e.substring(1,e.length);e&&(t?"."===e[0]?t.classList.add(n):"#"===e[0]&&t.setAttribute("id",n):t=document.createElement(e))});else if("number"==typeof e||"boolean"==typeof e||e instanceof Date||e instanceof RegExp)t.appendChild(document.createTextNode(e.toString()));else if(Array.isArray(e))e.forEach(n);else if(e instanceof HTMLElement)t.appendChild(e);else if("object"==typeof e)for(var r in e)if("function"==typeof e[r])t.addEventListener(r,e[r]);else if("style"===r)for(var i in e[r])t.style.setProperty(i,e[r][i]);else t.setAttribute(r,e[r])}for(;e.length;)n(e.shift());return t}"object"==typeof t?t.exports=e:this.h=e}()},{}],4:[function(e,t,n){var r=[],i=[],a="insert-css: You need to provide a CSS string. Usage: insertCss(cssString[, options]).";function o(e,t){if(t=t||{},void 0===e)throw new Error(a);var n,o=!0===t.prepend?"prepend":"append",f=void 0!==t.container?t.container:document.querySelector("head"),u=r.indexOf(f);return-1===u&&(u=r.push(f)-1,i[u]={}),void 0!==i[u]&&void 0!==i[u][o]?n=i[u][o]:(n=i[u][o]=function(){var e=document.createElement("style");return e.setAttribute("type","text/css"),e}(),"prepend"===o?f.insertBefore(n,f.childNodes[0]):f.appendChild(n)),65279===e.charCodeAt(0)&&(e=e.substr(1,e.length)),n.styleSheet?n.styleSheet.cssText+=e:n.textContent+=e,n}t.exports=o,t.exports.insertCss=o},{}],5:[function(e,t,n){"use strict";t.exports=function(e,t){t||(t=e,e=window);var n=0,i=0,a=0,o={shift:!1,alt:!1,control:!1,meta:!1},f=!1;function u(e){var t=!1;return"altKey"in e&&(t=t||e.altKey!==o.alt,o.alt=!!e.altKey),"shiftKey"in e&&(t=t||e.shiftKey!==o.shift,o.shift=!!e.shiftKey),"ctrlKey"in e&&(t=t||e.ctrlKey!==o.control,o.control=!!e.ctrlKey),"metaKey"in e&&(t=t||e.metaKey!==o.meta,o.meta=!!e.metaKey),t}function s(e,f){var s=r.x(f),c=r.y(f);"buttons"in f&&(e=0|f.buttons),(e!==n||s!==i||c!==a||u(f))&&(n=0|e,i=s||0,a=c||0,t&&t(n,i,a,o))}function c(e){s(0,e)}function l(){(n||i||a||o.shift||o.alt||o.meta||o.control)&&(i=a=0,n=0,o.shift=o.alt=o.control=o.meta=!1,t&&t(0,0,0,o))}function p(e){u(e)&&t&&t(n,i,a,o)}function d(e){0===r.buttons(e)?s(0,e):s(n,e)}function h(e){s(n|r.buttons(e),e)}function m(e){s(n&~r.buttons(e),e)}function b(){f||(f=!0,e.addEventListener("mousemove",d),e.addEventListener("mousedown",h),e.addEventListener("mouseup",m),e.addEventListener("mouseleave",c),e.addEventListener("mouseenter",c),e.addEventListener("mouseout",c),e.addEventListener("mouseover",c),e.addEventListener("blur",l),e.addEventListener("keyup",p),e.addEventListener("keydown",p),e.addEventListener("keypress",p),e!==window&&(window.addEventListener("blur",l),window.addEventListener("keyup",p),window.addEventListener("keydown",p),window.addEventListener("keypress",p)))}b();var g={element:e};return Object.defineProperties(g,{enabled:{get:function(){return f},set:function(t){t?b():f&&(f=!1,e.removeEventListener("mousemove",d),e.removeEventListener("mousedown",h),e.removeEventListener("mouseup",m),e.removeEventListener("mouseleave",c),e.removeEventListener("mouseenter",c),e.removeEventListener("mouseout",c),e.removeEventListener("mouseover",c),e.removeEventListener("blur",l),e.removeEventListener("keyup",p),e.removeEventListener("keydown",p),e.removeEventListener("keypress",p),e!==window&&(window.removeEventListener("blur",l),window.removeEventListener("keyup",p),window.removeEventListener("keydown",p),window.removeEventListener("keypress",p)))},enumerable:!0},buttons:{get:function(){return n},enumerable:!0},x:{get:function(){return i},enumerable:!0},y:{get:function(){return a},enumerable:!0},mods:{get:function(){return o},enumerable:!0}}),g};var r=e("mouse-event")},{"mouse-event":6}],6:[function(e,t,n){"use strict";function r(e){return e.target||e.srcElement||window}n.buttons=function(e){if("object"==typeof e){if("buttons"in e)return e.buttons;if("which"in e){if(2===(t=e.which))return 4;if(3===t)return 2;if(t>0)return 1<<t-1}else if("button"in e){var t;if(1===(t=e.button))return 4;if(2===t)return 2;if(t>=0)return 1<<t}}return 0},n.element=r,n.x=function(e){if("object"==typeof e){if("offsetX"in e)return e.offsetX;var t=r(e).getBoundingClientRect();return e.clientX-t.left}return 0},n.y=function(e){if("object"==typeof e){if("offsetY"in e)return e.offsetY;var t=r(e).getBoundingClientRect();return e.clientY-t.top}return 0}},{}],7:[function(e,t,n){"use strict";var r=e("to-px");t.exports=function(e,t,n){"function"==typeof e&&(n=!!t,t=e,e=window);var i=r("ex",e),a=function(e){n&&e.preventDefault();var r=e.deltaX||0,a=e.deltaY||0,o=e.deltaZ||0,f=e.deltaMode,u=1;switch(f){case 1:u=i;break;case 2:u=window.innerHeight}if(a*=u,o*=u,(r*=u)||a||o)return t(r,a,o,e)};return e.addEventListener("wheel",a),a}},{"to-px":10}],8:[function(e,t,n){t.exports=function(e,t){t||(t=[0,""]),e=String(e);var n=parseFloat(e,10);return t[0]=n,t[1]=e.match(/[\d.\-\+]*\s*(.*)/)[1]||"",t}},{}],9:[function(e,t,n){var r,i;r=this,i=function(){function e(e,t){this.id=W++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var n=t.charAt(0),r=t.charAt(t.length-1);if(1<t.length&&n===r&&('"'===n||"'"===n))return['"'+t.substr(1,t.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(n=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t))return e(t.substr(0,n.index)).concat(e(n[1])).concat(e(t.substr(n.index+n[0].length)));if(1===(n=t.split(".")).length)return['"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(t=[],r=0;r<n.length;++r)t=t.concat(e(n[r]));return t}(e).join("][")+"]"}function n(e){return"string"==typeof e?e.split():e}function r(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t,i,a,o,f=e||{};e={};var u=[],s=[],c="undefined"==typeof window?1:window.devicePixelRatio,l=!1,p=function(e){},d=function(){};if("string"==typeof f?t=document.querySelector(f):"object"==typeof f&&("string"==typeof f.nodeName&&"function"==typeof f.appendChild&&"function"==typeof f.getBoundingClientRect?t=f:"function"==typeof f.drawArrays||"function"==typeof f.drawElements?a=(o=f).canvas:("gl"in f?o=f.gl:"canvas"in f?a=r(f.canvas):"container"in f&&(i=r(f.container)),"attributes"in f&&(e=f.attributes),"extensions"in f&&(u=n(f.extensions)),"optionalExtensions"in f&&(s=n(f.optionalExtensions)),"onDone"in f&&(p=f.onDone),"profile"in f&&(l=!!f.profile),"pixelRatio"in f&&(c=+f.pixelRatio))),t&&("canvas"===t.nodeName.toLowerCase()?a=t:i=t),!o){if(!a){if(!(t=function(e,t,n){function r(){var t=window.innerWidth,r=window.innerHeight;e!==document.body&&(t=(r=e.getBoundingClientRect()).right-r.left,r=r.bottom-r.top),i.width=n*t,i.height=n*r,R(i.style,{width:t+"px",height:r+"px"})}var i=document.createElement("canvas");return R(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",R(e.style,{margin:0,padding:0})),window.addEventListener("resize",r,!1),r(),{canvas:i,onDestroy:function(){window.removeEventListener("resize",r),e.removeChild(i)}}}(i||document.body,0,c)))return null;a=t.canvas,d=t.onDestroy}o=function(e,t){function n(n){try{return e.getContext(n,t)}catch(e){return null}}return n("webgl")||n("experimental-webgl")||n("webgl-experimental")}(a,e)}return o?{gl:o,canvas:a,container:i,extensions:u,optionalExtensions:s,pixelRatio:c,profile:l,onDone:p,onDestroy:d}:(d(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function a(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||Q(e.data))}function o(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=t(r);return n}function f(e){var t,n;return t=(65535<e)<<4,t|=n=(255<(e>>>=t))<<3,(t|=n=(15<(e>>>=n))<<2)|(n=(3<(e>>>=n))<<1)|e>>>n>>1}function u(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=G[f(e)>>2]).length?t.pop():new ArrayBuffer(e)}function s(e){G[f(e.byteLength)>>2].push(e)}function c(e,t,n,r,i,a){for(var o=0;o<t;++o)for(var f=e[o],u=0;u<n;++u)for(var s=f[u],c=0;c<r;++c)i[a++]=s[c]}function l(e){return 0|X[Object.prototype.toString.call(e)]}function p(e,t){for(var n=0;n<t.length;++n)e[n]=t[n]}function d(e,t,n,r,i,a,o){for(var f=0,u=0;u<n;++u)for(var s=0;s<r;++s)e[f++]=t[i*u+a*s+o]}function h(e,t,n){function r(t){this.id=u++,this.buffer=e.createBuffer(),this.type=t,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,n.profile&&(this.stats={size:0})}function i(t,n,r){t.byteLength=n.byteLength,e.bufferData(t.type,n,r)}function o(e,t,n,r,o,f){if(e.usage=n,Array.isArray(t)){if(e.dtype=r||5126,0<t.length)if(Array.isArray(t[0])){o=ee(t);for(var u=r=1;u<o.length;++u)r*=o[u];e.dimension=r,i(e,t=$(t,o,e.dtype),n),f?e.persistentData=t:K.freeType(t)}else"number"==typeof t[0]?(e.dimension=o,p(o=K.allocType(e.dtype,t.length),t),i(e,o,n),f?e.persistentData=o:K.freeType(o)):Q(t[0])&&(e.dimension=t[0].length,e.dtype=r||l(t[0])||5126,i(e,t=$(t,[t.length,t[0].length],e.dtype),n),f?e.persistentData=t:K.freeType(t))}else if(Q(t))e.dtype=r||l(t),e.dimension=o,i(e,t,n),f&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(a(t)){o=t.shape;var s=t.stride,c=(u=t.offset,0),h=0,m=0,b=0;1===o.length?(c=o[0],h=1,m=s[0],b=0):2===o.length&&(c=o[0],h=o[1],m=s[0],b=s[1]),e.dtype=r||l(t.data)||5126,e.dimension=h,d(o=K.allocType(e.dtype,c*h),t.data,c,h,m,b,u),i(e,o,n),f?e.persistentData=o:K.freeType(o)}}function f(n){t.bufferCount--,e.deleteBuffer(n.buffer),n.buffer=null,delete s[n.id]}var u=0,s={};r.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},r.prototype.destroy=function(){f(this)};var c=[];return n.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(s).forEach(function(t){e+=s[t].stats.size}),e}),{create:function(i,u,c,h){function m(t){var r=35044,i=null,f=0,u=0,s=1;return Array.isArray(t)||Q(t)||a(t)?i=t:"number"==typeof t?f=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(r=J[t.usage]),"type"in t&&(u=Z[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(f=0|t.length)),b.bind(),i?o(b,i,r,u,s,h):(e.bufferData(b.type,f,r),b.dtype=u||5121,b.usage=r,b.dimension=s,b.byteLength=f),n.profile&&(b.stats.size=b.byteLength*te[b.dtype]),m}t.bufferCount++;var b=new r(u);return s[b.id]=b,c||m(i),m._reglType="buffer",m._buffer=b,m.subdata=function(t,n){var r,i=0|(n||0);if(b.bind(),Q(t))e.bufferSubData(b.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var o=K.allocType(b.dtype,t.length);p(o,t),e.bufferSubData(b.type,i,o),K.freeType(o)}else(Array.isArray(t[0])||Q(t[0]))&&(r=ee(t),o=$(t,r,b.dtype),e.bufferSubData(b.type,i,o),K.freeType(o))}else if(a(t)){r=t.shape;var f=t.stride,u=o=0,s=0,c=0;1===r.length?(o=r[0],u=1,s=f[0],c=0):2===r.length&&(o=r[0],u=r[1],s=f[0],c=f[1]),r=Array.isArray(t.data)?b.dtype:l(t.data),d(r=K.allocType(r,o*u),t.data,o,u,s,c,t.offset),e.bufferSubData(b.type,i,r),K.freeType(r)}return m},n.profile&&(m.stats=b.stats),m.destroy=function(){f(b)},m},createStream:function(e,t){var n=c.pop();return n||(n=new r(e)),n.bind(),o(n,t,35040,0,1,!1),n},destroyStream:function(e){c.push(e)},clear:function(){V(s).forEach(f),c.forEach(f)},getBuffer:function(e){return e&&e._buffer instanceof r?e._buffer:null},restore:function(){V(s).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:o}}function m(e,t,n,r){function i(e){this.id=s++,u[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function o(r,i,o,f,u,s,c){if(r.buffer.bind(),i){var l=c;c||Q(i)&&(!a(i)||Q(i.data))||(l=t.oes_element_index_uint?5125:5123),n._initBuffer(r.buffer,i,o,l,3)}else e.bufferData(34963,s,o),r.buffer.dtype=l||5121,r.buffer.usage=o,r.buffer.dimension=3,r.buffer.byteLength=s;if(l=c,!c){switch(r.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125}r.buffer.dtype=l}r.type=l,0>(i=u)&&(i=r.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),r.vertCount=i,i=f,0>f&&(i=4,1===(f=r.buffer.dimension)&&(i=0),2===f&&(i=1),3===f&&(i=4)),r.primType=i}function f(e){r.elementsCount--,delete u[e.id],e.buffer.destroy(),e.buffer=null}var u={},s=0,c={uint8:5121,uint16:5123};t.oes_element_index_uint&&(c.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var l=[];return{create:function(e,t){function u(e){if(e)if("number"==typeof e)s(e),l.primType=4,l.vertCount=0|e,l.type=5121;else{var t=null,n=35044,r=-1,i=-1,f=0,p=0;Array.isArray(e)||Q(e)||a(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(n=J[e.usage]),"primitive"in e&&(r=ne[e.primitive]),"count"in e&&(i=0|e.count),"type"in e&&(p=c[e.type]),"length"in e?f=0|e.length:(f=i,5123===p||5122===p?f*=2:5125!==p&&5124!==p||(f*=4))),o(l,t,n,r,i,f,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return u}var s=n.create(null,34963,!0),l=new i(s._buffer);return r.elementsCount++,u(e),u._reglType="elements",u._elements=l,u.subdata=function(e,t){return s.subdata(e,t),u},u.destroy=function(){f(l)},u},createStream:function(e){var t=l.pop();return t||(t=new i(n.create(null,34963,!0,!1)._buffer)),o(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){l.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){V(u).forEach(f)}}}function b(e){for(var t=K.allocType(5123,e.length),n=0;n<e.length;++n)if(isNaN(e[n]))t[n]=65535;else if(1/0===e[n])t[n]=31744;else if(-1/0===e[n])t[n]=64512;else{re[0]=e[n];var r=(a=ie[0])>>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[n]=-24>i?r:-14>i?r+(a+1024>>-14-i):15<i?r+31744:r+(i+15<<10)+a}return t}function g(e){return Array.isArray(e)||Q(e)}function v(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function y(e){return!(!Array.isArray(e)||0===e.length||!g(e[0]))}function x(e){return Object.prototype.toString.call(e)}function w(e){if(!e)return!1;var t=x(e);return 0<=ue.indexOf(t)||(v(e)||y(e)||a(e))}function A(e,t){36193===e.type?(e.data=b(t),K.freeType(t)):e.data=t}function k(e,t,n,r,i,a){if(e=void 0!==ce[e]?ce[e]:fe[e]*se[t],a&&(e*=6),i){for(r=0;1<=n;)r+=e*n*n,n/=2;return r}return e*n*r}function E(e,t,n,r,i,o,f){function u(){this.format=this.internalformat=6408,this.type=5121,this.flipY=this.premultiplyAlpha=this.compressed=!1,this.unpackAlignment=1,this.colorSpace=37444,this.channels=this.height=this.width=0}function s(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function c(e,t){if("object"==typeof t&&t){"premultiplyAlpha"in t&&(e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(e.flipY=t.flipY),"alignment"in t&&(e.unpackAlignment=t.alignment),"colorSpace"in t&&(e.colorSpace=U[t.colorSpace]),"type"in t&&(e.type=N[t.type]);var n=e.width,r=e.height,i=e.channels,a=!1;"shape"in t?(n=t.shape[0],r=t.shape[1],3===t.shape.length&&(i=t.shape[2],a=!0)):("radius"in t&&(n=r=t.radius),"width"in t&&(n=t.width),"height"in t&&(r=t.height),"channels"in t&&(i=t.channels,a=!0)),e.width=0|n,e.height=0|r,e.channels=0|i,n=!1,"format"in t&&(n=t.format,r=e.internalformat=q[n],e.format=ie[r],n in N&&!("type"in t)&&(e.type=N[n]),n in G&&(e.compressed=!0),n=!0),!a&&n?e.channels=fe[e.format]:a&&!n&&e.channels!==oe[e.format]&&(e.format=e.internalformat=oe[e.channels])}}function l(t){e.pixelStorei(37440,t.flipY),e.pixelStorei(37441,t.premultiplyAlpha),e.pixelStorei(37443,t.colorSpace),e.pixelStorei(3317,t.unpackAlignment)}function p(){u.call(this),this.yOffset=this.xOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var n=null;if(w(t)?n=t:t&&(c(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),w(t.data)&&(n=t.data)),t.copy){var r=i.viewportWidth,o=i.viewportHeight;e.width=e.width||r-e.xOffset,e.height=e.height||o-e.yOffset,e.needsCopy=!0}else if(n){if(Q(n))e.channels=e.channels||4,e.data=n,"type"in t||5121!==e.type||(e.type=0|X[Object.prototype.toString.call(n)]);else if(v(n)){switch(e.channels=e.channels||4,o=(r=n).length,e.type){case 5121:case 5123:case 5125:case 5126:(o=K.allocType(e.type,o)).set(r),e.data=o;break;case 36193:e.data=b(r)}e.alignment=1,e.needsFree=!0}else if(a(n)){r=n.data,Array.isArray(r)||5121!==e.type||(e.type=0|X[Object.prototype.toString.call(r)]);o=n.shape;var f,u,s,l,p=n.stride;3===o.length?(s=o[2],l=p[2]):l=s=1,f=o[0],u=o[1],o=p[0],p=p[1],e.alignment=1,e.width=f,e.height=u,e.channels=s,e.format=e.internalformat=oe[s],e.needsFree=!0,f=l,n=n.offset,s=e.width,l=e.height,u=e.channels;for(var d=K.allocType(36193===e.type?5126:e.type,s*l*u),h=0,m=0;m<l;++m)for(var k=0;k<s;++k)for(var E=0;E<u;++E)d[h++]=r[o*k+p*m+f*E+n];A(e,d)}else if("[object HTMLCanvasElement]"===x(n)||"[object CanvasRenderingContext2D]"===x(n))"[object HTMLCanvasElement]"===x(n)?e.element=n:e.element=n.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if("[object HTMLImageElement]"===x(n))e.element=n,e.width=n.naturalWidth,e.height=n.naturalHeight,e.channels=4;else if("[object HTMLVideoElement]"===x(n))e.element=n,e.width=n.videoWidth,e.height=n.videoHeight,e.channels=4;else if(y(n)){for(r=e.width||n[0].length,o=e.height||n.length,p=e.channels,p=g(n[0][0])?p||n[0][0].length:p||1,f=Y.shape(n),s=1,l=0;l<f.length;++l)s*=f[l];s=K.allocType(36193===e.type?5126:e.type,s),Y.flatten(n,f,"",s),A(e,s),e.alignment=1,e.width=r,e.height=o,e.channels=p,e.format=e.internalformat=oe[p],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4}function h(t,n,i,a,o){var f=t.element,u=t.data,s=t.internalformat,c=t.format,p=t.type,d=t.width,h=t.height;l(t),f?e.texSubImage2D(n,o,i,a,c,p,f):t.compressed?e.compressedTexSubImage2D(n,o,i,a,s,d,h,u):t.needsCopy?(r(),e.copyTexSubImage2D(n,o,i,a,t.xOffset,t.yOffset,d,h)):e.texSubImage2D(n,o,i,a,d,h,c,p,u)}function m(){return ue.pop()||new p}function E(e){e.needsFree&&K.freeType(e.data),p.call(e),ue.push(e)}function D(e,t,n){var r=e.images[0]=m();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function T(e,t){var n=null;if(w(t))s(n=e.images[0]=m(),e),d(n,t),e.mipmask=1;else if(c(e,t),Array.isArray(t.mipmap))for(var r=t.mipmap,i=0;i<r.length;++i)s(n=e.images[i]=m(),e),n.width>>=i,n.height>>=i,d(n,r[i]),e.mipmask|=1<<i;else s(n=e.images[0]=m(),e),d(n,t),e.mipmask=1;s(e,e.images[0])}function _(t,n){for(var i=t.images,a=0;a<i.length&&i[a];++a){var o=i[a],f=n,u=a,s=o.element,c=o.data,p=o.internalformat,d=o.format,h=o.type,m=o.width,b=o.height;l(o),s?e.texImage2D(f,u,d,d,h,s):o.compressed?e.compressedTexImage2D(f,u,p,m,b,0,c):o.needsCopy?(r(),e.copyTexImage2D(f,u,d,o.xOffset,o.yOffset,m,b,0)):e.texImage2D(f,u,d,m,b,0,d,h,c)}}function S(){var e=se.pop()||new function(){u.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)};u.call(e);for(var t=e.mipmask=0;16>t;++t)e.images[t]=null;return e}function C(e){for(var t=e.images,n=0;n<t.length;++n)t[n]&&E(t[n]),t[n]=null;se.push(e)}function j(){this.magFilter=this.minFilter=9728,this.wrapT=this.wrapS=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function O(e,t){"min"in t&&(e.minFilter=W[t.min],0<=ae.indexOf(e.minFilter)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=H[t.mag]);var n=e.wrapS,r=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?n=r=I[i]:Array.isArray(i)&&(n=I[i[0]],r=I[i[1]])}else"wrapS"in t&&(n=I[t.wrapS]),"wrapT"in t&&(r=I[t.wrapT]);if(e.wrapS=n,e.wrapT=r,"anisotropic"in t&&(e.anisotropic=t.anisotropic),"mipmap"in t){switch(n=!1,typeof t.mipmap){case"string":e.mipmapHint=P[t.mipmap],n=e.genMipmaps=!0;break;case"boolean":n=e.genMipmaps=t.mipmap;break;case"object":e.genMipmaps=!1,n=!0}!n||"min"in t||(e.minFilter=9984)}}function F(n,r){e.texParameteri(r,10241,n.minFilter),e.texParameteri(r,10240,n.magFilter),e.texParameteri(r,10242,n.wrapS),e.texParameteri(r,10243,n.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(r,34046,n.anisotropic),n.genMipmaps&&(e.hint(33170,n.mipmapHint),e.generateMipmap(r))}function L(t){u.call(this),this.mipmask=0,this.internalformat=6408,this.id=ce++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new j,f.profile&&(this.stats={size:0})}function z(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function B(){var t=de[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(3553,null)}function M(t){var n=t.texture,r=t.unit,i=t.target;0<=r&&(e.activeTexture(33984+r),e.bindTexture(i,null),de[r]=null),e.deleteTexture(n),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete le[t.id],o.textureCount--}var P={"don't care":4352,"dont care":4352,nice:4354,fast:4353},I={repeat:10497,clamp:33071,mirror:33648},H={nearest:9728,linear:9729},W=R({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},H),U={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},q={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},G={};t.ext_srgb&&(q.srgb=35904,q.srgba=35906),t.oes_texture_float&&(N.float32=N.float=5126),t.oes_texture_half_float&&(N.float16=N["half float"]=36193),t.webgl_depth_texture&&(R(q,{depth:6402,"depth stencil":34041}),R(N,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&R(G,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&R(G,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&R(G,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(G["rgb etc1"]=36196);var Z=Array.prototype.slice.call(e.getParameter(34467));Object.keys(G).forEach(function(e){var t=G[e];0<=Z.indexOf(t)&&(q[e]=t)});var J=Object.keys(q);n.textureFormats=J;var $=[];Object.keys(q).forEach(function(e){$[q[e]]=e});var ee=[];Object.keys(N).forEach(function(e){ee[N[e]]=e});var te=[];Object.keys(H).forEach(function(e){te[H[e]]=e});var ne=[];Object.keys(W).forEach(function(e){ne[W[e]]=e});var re=[];Object.keys(I).forEach(function(e){re[I[e]]=e});var ie=J.reduce(function(e,t){var n=q[t];return 6409===n||6406===n||6409===n||6410===n||6402===n||34041===n?e[n]=n:32855===n||0<=t.indexOf("rgba")?e[n]=6408:e[n]=6407,e},{}),ue=[],se=[],ce=0,le={},pe=n.maxTextureUnits,de=Array(pe).map(function(){return null});return R(L.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var n=0;n<pe;++n){var r=de[n];if(r){if(0<r.bindCount)continue;r.unit=-1}de[n]=this,t=n;break}f.profile&&o.maxTextureUnits<t+1&&(o.maxTextureUnits=t+1),this.unit=t,e.activeTexture(33984+t),e.bindTexture(this.target,this.texture)}return t},unbind:function(){--this.bindCount},decRef:function(){0>=--this.refCount&&M(this)}}),f.profile&&(o.getTotalTextureSize=function(){var e=0;return Object.keys(le).forEach(function(t){e+=le[t].stats.size}),e}),{create2D:function(t,n){function r(e,t){var n=i.texInfo;j.call(n);var a=S();return"number"==typeof e?D(a,0|e,"number"==typeof t?0|t:0|e):e?(O(n,e),T(a,e)):D(a,1,1),n.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,r.width=a.width,r.height=a.height,z(i),_(a,3553),F(n,3553),B(),C(a),f.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,n.genMipmaps,!1)),r.format=$[i.internalformat],r.type=ee[i.type],r.mag=te[n.magFilter],r.min=ne[n.minFilter],r.wrapS=re[n.wrapS],r.wrapT=re[n.wrapT],r}var i=new L(3553);return le[i.id]=i,o.textureCount++,r(t,n),r.subimage=function(e,t,n,a){t|=0,n|=0,a|=0;var o=m();return s(o,i),o.width=0,o.height=0,d(o,e),o.width=o.width||(i.width>>a)-t,o.height=o.height||(i.height>>a)-n,z(i),h(o,3553,t,n,a),B(),E(o),r},r.resize=function(t,n){var a=0|t,o=0|n||a;if(a===i.width&&o===i.height)return r;r.width=i.width=a,r.height=i.height=o,z(i);for(var u=0;i.mipmask>>u;++u)e.texImage2D(3553,u,i.format,a>>u,o>>u,0,i.format,i.type,null);return B(),f.profile&&(i.stats.size=k(i.internalformat,i.type,a,o,!1,!1)),r},r._reglType="texture2d",r._texture=i,f.profile&&(r.stats=i.stats),r.destroy=function(){i.decRef()},r},createCube:function(t,n,r,i,a,u){function l(e,t,n,r,i,a){var o,u=p.texInfo;for(j.call(u),o=0;6>o;++o)b[o]=S();if("number"!=typeof e&&e){if("object"==typeof e)if(t)T(b[0],e),T(b[1],t),T(b[2],n),T(b[3],r),T(b[4],i),T(b[5],a);else if(O(u,e),c(p,e),"faces"in e)for(e=e.faces,o=0;6>o;++o)s(b[o],p),T(b[o],e[o]);else for(o=0;6>o;++o)T(b[o],e)}else for(e=0|e||1,o=0;6>o;++o)D(b[o],e,e);for(s(p,b[0]),p.mipmask=u.genMipmaps?(b[0].width<<1)-1:b[0].mipmask,p.internalformat=b[0].internalformat,l.width=b[0].width,l.height=b[0].height,z(p),o=0;6>o;++o)_(b[o],34069+o);for(F(u,34067),B(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=$[p.internalformat],l.type=ee[p.type],l.mag=te[u.magFilter],l.min=ne[u.minFilter],l.wrapS=re[u.wrapS],l.wrapT=re[u.wrapT],o=0;6>o;++o)C(b[o]);return l}var p=new L(34067);le[p.id]=p,o.cubeCount++;var b=Array(6);return l(t,n,r,i,a,u),l.subimage=function(e,t,n,r,i){n|=0,r|=0,i|=0;var a=m();return s(a,p),a.width=0,a.height=0,d(a,t),a.width=a.width||(p.width>>i)-n,a.height=a.height||(p.height>>i)-r,z(p),h(a,34069+e,n,r,i),B(),E(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,z(p);for(var n=0;6>n;++n)for(var r=0;p.mipmask>>r;++r)e.texImage2D(34069+n,r,p.format,t>>r,t>>r,0,p.format,p.type,null);return B(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,f.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;t<pe;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),de[t]=null;V(le).forEach(M),o.cubeCount=0,o.textureCount=0},getTexture:function(e){return null},restore:function(){V(le).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var n=0;32>n;++n)if(0!=(t.mipmask&1<<n))if(3553===t.target)e.texImage2D(3553,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);else for(var r=0;6>r;++r)e.texImage2D(34069+r,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);F(t.texInfo,t.target)})}}}function D(e,t,n,r,i,a){function o(e,t,n){this.target=e,this.texture=t,this.renderbuffer=n;var r=e=0;t?(e=t.width,r=t.height):n&&(e=n.width,r=n.height),this.width=e,this.height=r}function f(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,n){e&&(e.texture?e.texture._texture.refCount+=1:e.renderbuffer._renderbuffer.refCount+=1)}function s(t,n){n&&(n.texture?e.framebufferTexture2D(36160,t,n.target,n.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,n.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=3553,n=null,r=null,i=e;return"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),"texture2d"===(e=i._reglType)?n=i:"textureCube"===e?n=i:"renderbuffer"===e&&(r=i,t=36161),new o(t,n,r)}function l(e,t,n,a,f){return n?((e=r.create2D({width:e,height:t,format:a,type:f}))._texture.refCount=0,new o(3553,e,null)):((e=i.create({width:e,height:t,format:a}))._renderbuffer.refCount=0,new o(36161,null,e))}function p(e){return e&&(e.texture||e.renderbuffer)}function d(e,t,n){e&&(e.texture?e.texture.resize(t,n):e.renderbuffer&&e.renderbuffer.resize(t,n))}function h(){this.id=k++,E[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function m(e){e.colorAttachments.forEach(f),f(e.depthAttachment),f(e.stencilAttachment),f(e.depthStencilAttachment)}function b(t){e.deleteFramebuffer(t.framebuffer),t.framebuffer=null,a.framebufferCount--,delete E[t.id]}function g(t){var r;e.bindFramebuffer(36160,t.framebuffer);var i=t.colorAttachments;for(r=0;r<i.length;++r)s(36064+r,i[r]);for(r=i.length;r<n.maxColorAttachments;++r)e.framebufferTexture2D(36160,36064+r,3553,null,0);e.framebufferTexture2D(36160,33306,3553,null,0),e.framebufferTexture2D(36160,36096,3553,null,0),e.framebufferTexture2D(36160,36128,3553,null,0),s(36096,t.depthAttachment),s(36128,t.stencilAttachment),s(33306,t.depthStencilAttachment),e.checkFramebufferStatus(36160),e.bindFramebuffer(36160,y.next),y.cur=y.next,e.getError()}function v(e,t){function n(e,t){var i,a=0,o=0,f=!0,s=!0;i=null;var d=!0,h="rgba",b="uint8",v=1,y=null,A=null,k=null,E=!1;"number"==typeof e?(a=0|e,o=0|t||a):e?("shape"in e?(a=(o=e.shape)[0],o=o[1]):("radius"in e&&(a=o=e.radius),"width"in e&&(a=e.width),"height"in e&&(o=e.height)),("color"in e||"colors"in e)&&(i=e.color||e.colors,Array.isArray(i)),i||("colorCount"in e&&(v=0|e.colorCount),"colorTexture"in e&&(d=!!e.colorTexture,h="rgba4"),"colorType"in e&&(b=e.colorType,!d)&&("half float"===b||"float16"===b?h="rgba16f":"float"!==b&&"float32"!==b||(h="rgba32f")),"colorFormat"in e&&(h=e.colorFormat,0<=x.indexOf(h)?d=!0:0<=w.indexOf(h)&&(d=!1))),("depthTexture"in e||"depthStencilTexture"in e)&&(E=!(!e.depthTexture&&!e.depthStencilTexture)),"depth"in e&&("boolean"==typeof e.depth?f=e.depth:(y=e.depth,s=!1)),"stencil"in e&&("boolean"==typeof e.stencil?s=e.stencil:(A=e.stencil,f=!1)),"depthStencil"in e&&("boolean"==typeof e.depthStencil?f=s=e.depthStencil:(k=e.depthStencil,s=f=!1))):a=o=1;var D=null,T=null,_=null,S=null;if(Array.isArray(i))D=i.map(c);else if(i)D=[c(i)];else for(D=Array(v),i=0;i<v;++i)D[i]=l(a,o,d,h,b);for(a=a||D[0].width,o=o||D[0].height,y?T=c(y):f&&!s&&(T=l(a,o,E,"depth","uint32")),A?_=c(A):s&&!f&&(_=l(a,o,!1,"stencil","uint8")),k?S=c(k):!y&&!A&&s&&f&&(S=l(a,o,E,"depth stencil","depth stencil")),f=null,i=0;i<D.length;++i)u(D[i]),D[i]&&D[i].texture&&(s=de[D[i].texture._texture.format]*he[D[i].texture._texture.type],null===f&&(f=s));return u(T),u(_),u(S),m(r),r.width=a,r.height=o,r.colorAttachments=D,r.depthAttachment=T,r.stencilAttachment=_,r.depthStencilAttachment=S,n.color=D.map(p),n.depth=p(T),n.stencil=p(_),n.depthStencil=p(S),n.width=r.width,n.height=r.height,g(r),n}var r=new h;return a.framebufferCount++,n(e,t),R(n,{resize:function(e,t){var i=0|e,a=0|t||i;if(i===r.width&&a===r.height)return n;for(var o=r.colorAttachments,f=0;f<o.length;++f)d(o[f],i,a);return d(r.depthAttachment,i,a),d(r.stencilAttachment,i,a),d(r.depthStencilAttachment,i,a),r.width=n.width=i,r.height=n.height=a,g(r),n},_reglType:"framebuffer",_framebuffer:r,destroy:function(){b(r),m(r)},use:function(e){y.setFBO({framebuffer:n},e)}})}var y={cur:null,next:null,dirty:!1,setFBO:null},x=["rgba"],w=["rgba4","rgb565","rgb5 a1"];t.ext_srgb&&w.push("srgba"),t.ext_color_buffer_half_float&&w.push("rgba16f","rgb16f"),t.webgl_color_buffer_float&&w.push("rgba32f");var A=["uint8"];t.oes_texture_half_float&&A.push("half float","float16"),t.oes_texture_float&&A.push("float","float32");var k=0,E={};return R(y,{getFramebuffer:function(e){return"function"==typeof e&&"framebuffer"===e._reglType&&(e=e._framebuffer)instanceof h?e:null},create:v,createCube:function(e){function t(e){var i,a={color:null},o=0,f=null;i="rgba";var u="uint8",s=1;if("number"==typeof e?o=0|e:e?("shape"in e?o=e.shape[0]:("radius"in e&&(o=0|e.radius),"width"in e?o=0|e.width:"height"in e&&(o=0|e.height)),("color"in e||"colors"in e)&&(f=e.color||e.colors,Array.isArray(f)),f||("colorCount"in e&&(s=0|e.colorCount),"colorType"in e&&(u=e.colorType),"colorFormat"in e&&(i=e.colorFormat)),"depth"in e&&(a.depth=e.depth),"stencil"in e&&(a.stencil=e.stencil),"depthStencil"in e&&(a.depthStencil=e.depthStencil)):o=1,f)if(Array.isArray(f))for(e=[],i=0;i<f.length;++i)e[i]=f[i];else e=[f];else for(e=Array(s),f={radius:o,format:i,type:u},i=0;i<s;++i)e[i]=r.createCube(f);for(a.color=Array(e.length),i=0;i<e.length;++i)s=e[i],o=o||s.width,a.color[i]={target:34069,data:e[i]};for(i=0;6>i;++i){for(s=0;s<e.length;++s)a.color[s].target=34069+i;0<i&&(a.depth=n[0].depth,a.stencil=n[0].stencil,a.depthStencil=n[0].depthStencil),n[i]?n[i](a):n[i]=v(a)}return R(t,{width:o,height:o,color:e})}var n=Array(6);return t(e),R(t,{faces:n,resize:function(e){var r=0|e;if(r===t.width)return t;var i=t.color;for(e=0;e<i.length;++e)i[e].resize(r);for(e=0;6>e;++e)n[e].resize(r);return t.width=t.height=r,t},_reglType:"framebufferCube",destroy:function(){n.forEach(function(e){e.destroy()})}})},clear:function(){V(E).forEach(b)},restore:function(){V(E).forEach(function(t){t.framebuffer=e.createFramebuffer(),g(t)})}})}function T(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function _(e,t,n,r){function i(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function a(e,t){for(var n=0;n<e.length;++n)if(e[n].id===t.id)return void(e[n].location=t.location);e.push(t)}function o(n,r,i){if(!(o=(i=35632===n?s:c)[r])){var a=t.str(r),o=e.createShader(n);e.shaderSource(o,a),e.compileShader(o),i[r]=o}return o}function f(e,t){this.id=d++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],r.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function u(n,f){var u,s;u=o(35632,n.fragId),s=o(35633,n.vertId);var c=n.program=e.createProgram();e.attachShader(c,u),e.attachShader(c,s),e.linkProgram(c);var l=e.getProgramParameter(c,35718);r.profile&&(n.stats.uniformsCount=l);var p=n.uniforms;for(u=0;u<l;++u)if(s=e.getActiveUniform(c,u))if(1<s.size)for(var d=0;d<s.size;++d){var h=s.name.replace("[0]","["+d+"]");a(p,new i(h,t.id(h),e.getUniformLocation(c,h),s))}else a(p,new i(s.name,t.id(s.name),e.getUniformLocation(c,s.name),s));for(l=e.getProgramParameter(c,35721),r.profile&&(n.stats.attributesCount=l),p=n.attributes,u=0;u<l;++u)(s=e.getActiveAttrib(c,u))&&a(p,new i(s.name,t.id(s.name),e.getAttribLocation(c,s.name),s))}var s={},c={},l={},p=[],d=0;return r.profile&&(n.getMaxUniformsCount=function(){var e=0;return p.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},n.getMaxAttributesCount=function(){var e=0;return p.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);V(s).forEach(t),s={},V(c).forEach(t),c={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,l={},n.shaderCount=0},program:function(e,t,r){var i=l[t];i||(i=l[t]={});var a=i[e];return a||(a=new f(t,e),n.shaderCount++,u(a),i[e]=a,p.push(a)),a},restore:function(){s={},c={};for(var e=0;e<p.length;++e)u(p[e])},shader:o,frag:-1,vert:-1}}function S(e,t,n,r,i,a){function o(i){var a;a=null===t.next?5121:t.next.colorAttachments[0].texture._texture.type;var o=0,f=0,u=r.framebufferWidth,s=r.framebufferHeight,c=null;return Q(i)?c=i:i&&(o=0|i.x,f=0|i.y,u=0|(i.width||r.framebufferWidth-o),s=0|(i.height||r.framebufferHeight-f),c=i.data||null),n(),i=u*s*4,c||(5121===a?c=new Uint8Array(i):5126===a&&(c=c||new Float32Array(i))),e.pixelStorei(3333,4),e.readPixels(o,f,u,s,6408,a,c),c}return function(e){return e&&"framebuffer"in e?function(e){var n;return t.setFBO({framebuffer:e.framebuffer},function(){n=o(e)}),n}(e):o(e)}}function C(e){return Array.prototype.slice.call(e)}function j(e){return C(e).join("")}function O(){function e(){var e=[],t=[];return R(function(){e.push.apply(e,C(arguments))},{def:function(){var r="v"+n++;return t.push(r),0<arguments.length&&(e.push(r,"="),e.push.apply(e,C(arguments)),e.push(";")),r},toString:function(){return j([0<t.length?"var "+t+";":"",j(e)])}})}function t(){function t(e,t){r(e,t,"=",n.def(e,t),";")}var n=e(),r=e(),i=n.toString,a=r.toString;return R(function(){n.apply(n,C(arguments))},{def:n.def,entry:n,exit:r,save:t,set:function(e,r,i){t(e,r),n(e,r,"=",i,";")},toString:function(){return i()+a()}})}var n=0,r=[],i=[],a=e(),o={};return{global:a,link:function(e){for(var t=0;t<i.length;++t)if(i[t]===e)return r[t];return t="g"+n++,r.push(t),i.push(e),t},block:e,proc:function(e,n){function r(){var e="a"+i.length;return i.push(e),e}var i=[];n=n||0;for(var a=0;a<n;++a)r();var f=(a=t()).toString;return o[e]=R(a,{arg:r,toString:function(){return j(["function(",i.join(),"){",f(),"}"])}})},scope:t,cond:function(){var e=j(arguments),n=t(),r=t(),i=n.toString,a=r.toString;return R(n,{then:function(){return n.apply(n,C(arguments)),this},else:function(){return r.apply(r,C(arguments)),this},toString:function(){var t=a();return t&&(t="else{"+t+"}"),j(["if(",e,"){",i(),"}",t])}})},compile:function(){var e=['"use strict";',a,"return {"];Object.keys(o).forEach(function(t){e.push('"',t,'":',o[t].toString(),",")}),e.push("}");var t=j(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,r.concat(t)).apply(null,i)}}}function F(e){return Array.isArray(e)||Q(e)||a(e)}function L(e){return e.sort(function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1})}function z(e,t,n,r){this.thisDep=e,this.contextDep=t,this.propDep=n,this.append=r}function B(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function M(e){return new z(!1,!1,!1,e)}function P(e,t){var n=e.type;return 0===n?new z(!0,1<=(n=e.data.length),2<=n,t):4===n?new z((n=e.data).thisDep,n.contextDep,n.propDep,t):new z(3===n,2===n,1===n,t)}function I(e,t,n,r,i,a,f,u,s,c,l,p,d,h,m){function b(e){return e.replace(".","_")}function v(e,t,n){var r=b(e);re.push(e),te[r]=ee[r]=!!n,ie[r]=t}function y(e,t,n){var r=b(e);re.push(e),Array.isArray(n)?(ee[r]=n.slice(),te[r]=n.slice()):ee[r]=te[r]=n,ae[r]=t}function x(){var e=O(),n=e.link,r=e.global;e.id=ue++,e.batchId="0";var i=n(oe),a=e.shared={props:"a0"};Object.keys(oe).forEach(function(e){a[e]=r.def(i,".",e)});var o=e.next={},f=e.current={};Object.keys(ae).forEach(function(e){Array.isArray(ee[e])&&(o[e]=r.def(a.next,".",e),f[e]=r.def(a.current,".",e))});var u=e.constants={};Object.keys(fe).forEach(function(e){u[e]=r.def(JSON.stringify(fe[e]))}),e.invoke=function(t,r){switch(r.type){case 0:var i=["this",a.context,a.props,e.batchId];return t.def(n(r.data),".call(",i.slice(0,Math.max(r.data.length+1,4)),")");case 1:return t.def(a.props,r.data);case 2:return t.def(a.context,r.data);case 3:return t.def("this",r.data);case 4:return r.data.append(e,t),r.data.ref}},e.attribCache={};var s={};return e.scopeAttrib=function(e){if((e=t.id(e))in s)return s[e];var r=c.scope[e];return r||(r=c.scope[e]=new Y),s[e]=n(r)},e}function w(e,t){var n=e.static,r=e.dynamic;if("framebuffer"in n){var i=n.framebuffer;return i?(i=u.getFramebuffer(i),M(function(e,t){var n=e.link(i),r=e.shared;return t.set(r.framebuffer,".next",n),r=r.context,t.set(r,".framebufferWidth",n+".width"),t.set(r,".framebufferHeight",n+".height"),n})):M(function(e,t){var n=e.shared;return t.set(n.framebuffer,".next","null"),n=n.context,t.set(n,".framebufferWidth",n+".drawingBufferWidth"),t.set(n,".framebufferHeight",n+".drawingBufferHeight"),"null"})}if("framebuffer"in r){var a=r.framebuffer;return P(a,function(e,t){var n=e.invoke(t,a),r=e.shared,i=r.framebuffer;n=t.def(i,".getFramebuffer(",n,")");return t.set(i,".next",n),r=r.context,t.set(r,".framebufferWidth",n+"?"+n+".width:"+r+".drawingBufferWidth"),t.set(r,".framebufferHeight",n+"?"+n+".height:"+r+".drawingBufferHeight"),n})}return null}function A(e){function n(e){if(e in r){var n=t.id(r[e]);return(e=M(function(){return n})).id=n,e}if(e in i){var a=i[e];return P(a,function(e,t){var n=e.invoke(t,a);return t.def(e.shared.strings,".id(",n,")")})}return null}var r=e.static,i=e.dynamic,a=n("frag"),o=n("vert"),f=null;return B(a)&&B(o)?(f=l.program(o.id,a.id),e=M(function(e,t){return e.link(f)})):e=new z(a&&a.thisDep||o&&o.thisDep,a&&a.contextDep||o&&o.contextDep,a&&a.propDep||o&&o.propDep,function(e,t){var n,r,i=e.shared.shader;return n=a?a.append(e,t):t.def(i,".","frag"),r=o?o.append(e,t):t.def(i,".","vert"),t.def(i+".program("+r+","+n+")")}),{frag:a,vert:o,progVar:e,program:f}}function k(e,t){function n(e,t){if(e in r){var n=0|r[e];return M(function(e,r){return t&&(e.OFFSET=n),n})}if(e in i){var a=i[e];return P(a,function(e,n){var r=e.invoke(n,a);return t&&(e.OFFSET=r),r})}return t&&o?M(function(e,t){return e.OFFSET="0",0}):null}var r=e.static,i=e.dynamic,o=function(){if("elements"in r){var e=r.elements;F(e)?e=a.getElements(a.create(e,!0)):e&&(e=a.getElements(e));var t=M(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r}return t.ELEMENTS=null});return t.value=e,t}if("elements"in i){var n=i.elements;return P(n,function(e,t){var r=(i=e.shared).isBufferArgs,i=i.elements,a=e.invoke(t,n),o=t.def("null");r=t.def(r,"(",a,")"),a=e.cond(r).then(o,"=",i,".createStream(",a,");").else(o,"=",i,".getElements(",a,");");return t.entry(a),t.exit(e.cond(r).then(i,".destroyStream(",o,");")),e.ELEMENTS=o})}return null}(),f=n("offset",!0);return{elements:o,primitive:function(){if("primitive"in r){var e=r.primitive;return M(function(t,n){return ne[e]})}if("primitive"in i){var t=i.primitive;return P(t,function(e,n){var r=e.constants.primTypes,i=e.invoke(n,t);return n.def(r,"[",i,"]")})}return o?B(o)?o.value?M(function(e,t){return t.def(e.ELEMENTS,".primType")}):M(function(){return 4}):new z(o.thisDep,o.contextDep,o.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",4)}):null}(),count:function(){if("count"in r){var e=0|r.count;return M(function(){return e})}if("count"in i){var t=i.count;return P(t,function(e,n){return e.invoke(n,t)})}return o?B(o)?o?f?new z(f.thisDep,f.contextDep,f.propDep,function(e,t){return t.def(e.ELEMENTS,".vertCount-",e.OFFSET)}):M(function(e,t){return t.def(e.ELEMENTS,".vertCount")}):M(function(){return-1}):new z(o.thisDep||f.thisDep,o.contextDep||f.contextDep,o.propDep||f.propDep,function(e,t){var n=e.ELEMENTS;return e.OFFSET?t.def(n,"?",n,".vertCount-",e.OFFSET,":-1"):t.def(n,"?",n,".vertCount:-1")}):null}(),instances:n("instances",!1),offset:f}}function E(e,n){var r=e.static,a=e.dynamic,o={};return Object.keys(r).forEach(function(e){var n=r[e],a=t.id(e),f=new Y;if(F(n))f.state=1,f.buffer=i.getBuffer(i.create(n,34962,!1,!0)),f.type=0;else if(s=i.getBuffer(n))f.state=1,f.buffer=s,f.type=0;else if(n.constant){var u=n.constant;f.buffer="null",f.state=2,"number"==typeof u?f.x=u:me.forEach(function(e,t){t<u.length&&(f[e]=u[t])})}else{var s=F(n.buffer)?i.getBuffer(i.create(n.buffer,34962,!1,!0)):i.getBuffer(n.buffer),c=0|n.offset,l=0|n.stride,p=0|n.size,d=!!n.normalized,h=0;"type"in n&&(h=Z[n.type]),n=0|n.divisor,f.buffer=s,f.state=1,f.size=p,f.normalized=d,f.type=h||s.dtype,f.offset=c,f.stride=l,f.divisor=n}o[e]=M(function(e,t){var n=e.attribCache;if(a in n)return n[a];var r={isStream:!1};return Object.keys(f).forEach(function(e){r[e]=f[e]}),f.buffer&&(r.buffer=e.link(f.buffer),r.type=r.type||r.buffer+".dtype"),n[a]=r})}),Object.keys(a).forEach(function(e){var t=a[e];o[e]=P(t,function(e,n){function r(e){n(u[e],"=",i,".",e,"|0;")}var i=e.invoke(n,t),a=e.shared,o=a.isBufferArgs,f=a.buffer,u={isStream:n.def(!1)},s=new Y;s.state=1,Object.keys(s).forEach(function(e){u[e]=n.def(""+s[e])});var c=u.buffer,l=u.type;return n("if(",o,"(",i,")){",u.isStream,"=true;",c,"=",f,".createStream(",34962,",",i,");",l,"=",c,".dtype;","}else{",c,"=",f,".getBuffer(",i,");","if(",c,"){",l,"=",c,".dtype;",'}else if("constant" in ',i,"){",u.state,"=",2,";","if(typeof "+i+'.constant === "number"){',u[me[0]],"=",i,".constant;",me.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",me.map(function(e,t){return u[e]+"="+i+".constant.length>="+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",o,"(",i,".buffer)){",c,"=",f,".createStream(",34962,",",i,".buffer);","}else{",c,"=",f,".getBuffer(",i,".buffer);","}",l,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",c,".dtype;",u.normalized,"=!!",i,".normalized;"),r("size"),r("offset"),r("stride"),r("divisor"),n("}}"),n.exit("if(",u.isStream,"){",f,".destroyStream(",c,");","}"),u})}),o}function D(e,t,n,r,i){var a=w(e),f=function(e,t,n){function r(e){if(e in i){var n=i[e];e=!0;var r,o,f=0|n.x,u=0|n.y;return"width"in n?r=0|n.width:e=!1,"height"in n?o=0|n.height:e=!1,new z(!e&&t&&t.thisDep,!e&&t&&t.contextDep,!e&&t&&t.propDep,function(e,t){var i=e.shared.context,a=r;"width"in n||(a=t.def(i,".","framebufferWidth","-",f));var s=o;return"height"in n||(s=t.def(i,".","framebufferHeight","-",u)),[f,u,a,s]})}if(e in a){var s=a[e];return e=P(s,function(e,t){var n=e.invoke(t,s),r=e.shared.context,i=t.def(n,".x|0"),a=t.def(n,".y|0");return[i,a,t.def('"width" in ',n,"?",n,".width|0:","(",r,".","framebufferWidth","-",i,")"),n=t.def('"height" in ',n,"?",n,".height|0:","(",r,".","framebufferHeight","-",a,")")]}),t&&(e.thisDep=e.thisDep||t.thisDep,e.contextDep=e.contextDep||t.contextDep,e.propDep=e.propDep||t.propDep),e}return t?new z(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".","framebufferWidth"),t.def(n,".","framebufferHeight")]}):null}var i=e.static,a=e.dynamic;if(e=r("viewport")){var o=e;e=new z(e.thisDep,e.contextDep,e.propDep,function(e,t){var n=o.append(e,t),r=e.shared.context;return t.set(r,".viewportWidth",n[2]),t.set(r,".viewportHeight",n[3]),n})}return{viewport:e,scissor_box:r("scissor.box")}}(e,a),u=k(e),s=function(e,t){var n=e.static,r=e.dynamic,i={};return re.forEach(function(e){function t(t,o){if(e in n){var f=t(n[e]);i[a]=M(function(){return f})}else if(e in r){var u=r[e];i[a]=P(u,function(e,t){return o(e,t,e.invoke(t,u))})}}var a=b(e);switch(e){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":return t(function(e){return e},function(e,t,n){return n});case"depth.func":return t(function(e){return ve[e]},function(e,t,n){return t.def(e.constants.compareFuncs,"[",n,"]")});case"depth.range":return t(function(e){return e},function(e,t,n){return[t.def("+",n,"[0]"),t=t.def("+",n,"[1]")]});case"blend.func":return t(function(e){return[ge["srcRGB"in e?e.srcRGB:e.src],ge["dstRGB"in e?e.dstRGB:e.dst],ge["srcAlpha"in e?e.srcAlpha:e.src],ge["dstAlpha"in e?e.dstAlpha:e.dst]]},function(e,t,n){function r(e,r){return t.def('"',e,r,'" in ',n,"?",n,".",e,r,":",n,".",e)}e=e.constants.blendFuncs;var i=r("src","RGB"),a=r("dst","RGB"),o=(i=t.def(e,"[",i,"]"),t.def(e,"[",r("src","Alpha"),"]"));return[i,a=t.def(e,"[",a,"]"),o,e=t.def(e,"[",r("dst","Alpha"),"]")]});case"blend.equation":return t(function(e){return"string"==typeof e?[X[e],X[e]]:"object"==typeof e?[X[e.rgb],X[e.alpha]]:void 0},function(e,t,n){var r=e.constants.blendEquations,i=t.def(),a=t.def();return(e=e.cond("typeof ",n,'==="string"')).then(i,"=",a,"=",r,"[",n,"];"),e.else(i,"=",r,"[",n,".rgb];",a,"=",r,"[",n,".alpha];"),t(e),[i,a]});case"blend.color":return t(function(e){return o(4,function(t){return+e[t]})},function(e,t,n){return o(4,function(e){return t.def("+",n,"[",e,"]")})});case"stencil.mask":return t(function(e){return 0|e},function(e,t,n){return t.def(n,"|0")});case"stencil.func":return t(function(e){return[ve[e.cmp||"keep"],e.ref||0,"mask"in e?e.mask:-1]},function(e,t,n){return[e=t.def('"cmp" in ',n,"?",e.constants.compareFuncs,"[",n,".cmp]",":",7680),t.def(n,".ref|0"),t=t.def('"mask" in ',n,"?",n,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return t(function(t){return["stencil.opBack"===e?1029:1028,ye[t.fail||"keep"],ye[t.zfail||"keep"],ye[t.zpass||"keep"]]},function(t,n,r){function i(e){return n.def('"',e,'" in ',r,"?",a,"[",r,".",e,"]:",7680)}var a=t.constants.stencilOps;return["stencil.opBack"===e?1029:1028,i("fail"),i("zfail"),i("zpass")]});case"polygonOffset.offset":return t(function(e){return[0|e.factor,0|e.units]},function(e,t,n){return[t.def(n,".factor|0"),t=t.def(n,".units|0")]});case"cull.face":return t(function(e){var t=0;return"front"===e?t=1028:"back"===e&&(t=1029),t},function(e,t,n){return t.def(n,'==="front"?',1028,":",1029)});case"lineWidth":return t(function(e){return e},function(e,t,n){return n});case"frontFace":return t(function(e){return xe[e]},function(e,t,n){return t.def(n+'==="cw"?2304:2305')});case"colorMask":return t(function(e){return e.map(function(e){return!!e})},function(e,t,n){return o(4,function(e){return"!!"+n+"["+e+"]"})});case"sample.coverage":return t(function(e){return["value"in e?e.value:1,!!e.invert]},function(e,t,n){return[t.def('"value" in ',n,"?+",n,".value:1"),t=t.def("!!",n,".invert")]})}}),i}(e),c=A(e),l=f.viewport;return l&&(s.viewport=l),(f=f[l=b("scissor.box")])&&(s[l]=f),(a={framebuffer:a,draw:u,shader:c,state:s,dirty:f=0<Object.keys(s).length}).profile=function(e){var t,n=e.static;if(e=e.dynamic,"profile"in n){var r=!!n.profile;(t=M(function(e,t){return r})).enable=r}else if("profile"in e){var i=e.profile;t=P(i,function(e,t){return e.invoke(t,i)})}return t}(e),a.uniforms=function(e,t){var n=e.static,r=e.dynamic,i={};return Object.keys(n).forEach(function(e){var t,r=n[e];if("number"==typeof r||"boolean"==typeof r)t=M(function(){return r});else if("function"==typeof r){var a=r._reglType;"texture2d"===a||"textureCube"===a?t=M(function(e){return e.link(r)}):"framebuffer"!==a&&"framebufferCube"!==a||(t=M(function(e){return e.link(r.color[0])}))}else g(r)&&(t=M(function(e){return e.global.def("[",o(r.length,function(e){return r[e]}),"]")}));t.value=r,i[e]=t}),Object.keys(r).forEach(function(e){var t=r[e];i[e]=P(t,function(e,n){return e.invoke(n,t)})}),i}(n),a.attributes=E(t),a.context=function(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=M(function(e,t){return"number"==typeof n||"boolean"==typeof n?""+n:e.link(n)})}),Object.keys(n).forEach(function(e){var t=n[e];r[e]=P(t,function(e,n){return e.invoke(n,t)})}),r}(r),a}function T(e,t,n){var r=e.shared.context,i=e.scope();Object.keys(n).forEach(function(a){t.save(r,"."+a),i(r,".",a,"=",n[a].append(e,t),";")}),t(i)}function _(e,t,n,r){var i,a=(f=e.shared).gl,o=f.framebuffer;$&&(i=t.def(f.extensions,".webgl_draw_buffers"));var f=(u=e.constants).drawBuffer,u=u.backBuffer;e=n?n.append(e,t):t.def(o,".next"),r||t("if(",e,"!==",o,".cur){"),t("if(",e,"){",a,".bindFramebuffer(",36160,",",e,".framebuffer);"),$&&t(i,".drawBuffersWEBGL(",f,"[",e,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",36160,",null);"),$&&t(i,".drawBuffersWEBGL(",u,");"),t("}",o,".cur=",e,";"),r||t("}")}function S(e,t,n){var r=e.shared,i=r.gl,a=e.current,f=e.next,u=r.current,s=r.next,c=e.cond(u,".dirty");re.forEach(function(t){var r,l;if(!((t=b(t))in n.state))if(t in f){r=f[t],l=a[t];var p=o(ee[t].length,function(e){return c.def(r,"[",e,"]")});c(e.cond(p.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(i,".",ae[t],"(",p,");",p.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else r=c.def(s,".",t),p=e.cond(r,"!==",u,".",t),c(p),t in ie?p(e.cond(r).then(i,".enable(",ie[t],");").else(i,".disable(",ie[t],");"),u,".",t,"=",r,";"):p(i,".",ae[t],"(",r,");",u,".",t,"=",r,";")}),0===Object.keys(n.state).length&&c(u,".dirty=false;"),t(c)}function C(e,t,n,r){var i=e.shared,a=e.current,o=i.current,f=i.gl;L(Object.keys(n)).forEach(function(i){var u=n[i];if(!r||r(u)){var s=u.append(e,t);if(ie[i]){var c=ie[i];B(u)?t(f,s?".enable(":".disable(",c,");"):t(e.cond(s).then(f,".enable(",c,");").else(f,".disable(",c,");")),t(o,".",i,"=",s,";")}else if(g(s)){var l=a[i];t(f,".",ae[i],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(f,".",ae[i],"(",s,");",o,".",i,"=",s,";")}})}function j(e,t){J&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function I(e,t,n,r,i){function a(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(e){e(s=t.def(),"=",a(),";"),"string"==typeof i?e(p,".count+=",i,";"):e(p,".count++;"),h&&(r?e(c=t.def(),"=",m,".getNumPendingQueries();"):e(m,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",a(),"-",s,";"),h&&(r?e(m,".pushScopeStats(",c,",",m,".getNumPendingQueries(),",p,");"):e(m,".endQuery();"))}function u(e){var n=t.def(d,".profile");t(d,".profile=",e,";"),t.exit(d,".profile=",n,";")}var s,c,l=e.shared,p=e.stats,d=l.current,m=l.timer;if(n=n.profile){if(B(n))return void(n.enable?(o(t),f(t.exit),u("true")):u("false"));u(n=n.append(e,t))}else n=t.def(d,".profile");o(l=e.block()),t("if(",n,"){",l,"}"),f(e=e.block()),t.exit("if(",n,"){",e,"}")}function H(e,t,n,r,i){function a(n,r,i){function a(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var n,a=i.type;n=i.size?t.def(i.size,"||",r):r,t("if(",c,".type!==",a,"||",c,".size!==",n,"||",d.map(function(e){return c+"."+e+"!=="+i[e]}).join("||"),"){",u,".bindBuffer(",34962,",",l,".buffer);",u,".vertexAttribPointer(",[s,n,a,i.normalized,i.stride,i.offset],");",c,".type=",a,";",c,".size=",n,";",d.map(function(e){return c+"."+e+"="+i[e]+";"}).join(""),"}"),J&&(a=i.divisor,t("if(",c,".divisor!==",a,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,a],");",c,".divisor=",a,";}"))}function f(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");","}if(",me.map(function(e,t){return c+"."+e+"!=="+p[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",p,");",me.map(function(e,t){return c+"."+e+"="+p[t]+";"}).join(""),"}")}var u=o.gl,s=t.def(n,".location"),c=t.def(o.attributes,"[",s,"]");n=i.state;var l=i.buffer,p=[i.x,i.y,i.z,i.w],d=["buffer","normalized","offset","stride"];1===n?a():2===n?f():(t("if(",n,"===",1,"){"),a(),t("}else{"),f(),t("}"))}var o=e.shared;r.forEach(function(r){var o,f=r.name,u=n.attributes[f];if(u){if(!i(u))return;o=u.append(e,t)}else{if(!i(we))return;var s=e.scopeAttrib(f);o={},Object.keys(new Y).forEach(function(e){o[e]=t.def(s,".",e)})}a(e.link(r),function(e){switch(e){case 35664:case 35667:case 35671:return 2;case 35665:case 35668:case 35672:return 3;case 35666:case 35669:case 35673:return 4;default:return 1}}(r.info.type),o)})}function R(e,n,r,i,a){for(var f,u=e.shared,s=u.gl,c=0;c<i.length;++c){var l,p=(m=i[c]).name,d=m.info.type,h=r.uniforms[p],m=e.link(m)+".location";if(h){if(!a(h))continue;if(B(h)){if(p=h.value,35678===d||35680===d)n(s,".uniform1i(",m,",",(d=e.link(p._texture||p.color[0]._texture))+".bind());"),n.exit(d,".unbind();");else if(35674===d||35675===d||35676===d)p=e.global.def("new Float32Array(["+Array.prototype.slice.call(p)+"])"),h=2,35675===d?h=3:35676===d&&(h=4),n(s,".uniformMatrix",h,"fv(",m,",false,",p,");");else{switch(d){case 5126:f="1f";break;case 35664:f="2f";break;case 35665:f="3f";break;case 35666:f="4f";break;case 35670:case 5124:f="1i";break;case 35671:case 35667:f="2i";break;case 35672:case 35668:f="3i";break;case 35673:f="4i";break;case 35669:f="4i"}n(s,".uniform",f,"(",m,",",g(p)?Array.prototype.slice.call(p):p,");")}continue}l=h.append(e,n)}else{if(!a(we))continue;l=n.def(u.uniforms,"[",t.id(p),"]")}switch(35678===d?n("if(",l,"&&",l,'._reglType==="framebuffer"){',l,"=",l,".color[0];","}"):35680===d&&n("if(",l,"&&",l,'._reglType==="framebufferCube"){',l,"=",l,".color[0];","}"),p=1,d){case 35678:case 35680:n(s,".uniform1i(",m,",",d=n.def(l,"._texture"),".bind());"),n.exit(d,".unbind();");continue;case 5124:case 35670:f="1i";break;case 35667:case 35671:f="2i",p=2;break;case 35668:case 35672:f="3i",p=3;break;case 35669:case 35673:f="4i",p=4;break;case 5126:f="1f";break;case 35664:f="2f",p=2;break;case 35665:f="3f",p=3;break;case 35666:f="4f",p=4;break;case 35674:f="Matrix2fv";break;case 35675:f="Matrix3fv";break;case 35676:f="Matrix4fv"}if(n(s,".uniform",f,"(",m,","),"M"===f.charAt(0)){m=Math.pow(d-35674+2,2);var b=e.global.def("new Float32Array(",m,")");n("false,(Array.isArray(",l,")||",l," instanceof Float32Array)?",l,":(",o(m,function(e){return b+"["+e+"]="+l+"["+e+"]"}),",",b,")")}else n(1<p?o(p,function(e){return l+"["+e+"]"}):l);n(");")}}function W(e,t,n,r){function i(i){var a=p[i];return a?a.contextDep&&r.contextDynamic||a.propDep?a.append(e,n):a.append(e,t):t.def(l,".",i)}function a(){function e(){n(u,".drawElementsInstancedANGLE(",[h,b,g,m+"<<(("+g+"-5121)>>1)",f],");")}function t(){n(u,".drawArraysInstancedANGLE(",[h,m,b,f],");")}d?v?e():(n("if(",d,"){"),e(),n("}else{"),t(),n("}")):t()}function o(){function e(){n(c+".drawElements("+[h,b,g,m+"<<(("+g+"-5121)>>1)"]+");")}function t(){n(c+".drawArrays("+[h,m,b]+");")}d?v?e():(n("if(",d,"){"),e(),n("}else{"),t(),n("}")):t()}var f,u,s=e.shared,c=s.gl,l=s.draw,p=r.draw,d=function(){var i=p.elements,a=t;return i?((i.contextDep&&r.contextDynamic||i.propDep)&&(a=n),i=i.append(e,a)):i=a.def(l,".","elements"),i&&a("if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),h=i("primitive"),m=i("offset"),b=function(){var i=p.count,a=t;return i?((i.contextDep&&r.contextDynamic||i.propDep)&&(a=n),i=i.append(e,a)):i=a.def(l,".","count"),i}();if("number"==typeof b){if(0===b)return}else n("if(",b,"){"),n.exit("}");J&&(f=i("instances"),u=e.instancing);var g=d+".type",v=p.elements&&B(p.elements);J&&("number"!=typeof f||0<=f)?"string"==typeof f?(n("if(",f,">0){"),a(),n("}else if(",f,"<0){"),o(),n("}")):a():o()}function N(e,t,n,r,i){return i=(t=x()).proc("body",i),J&&(t.instancing=i.def(t.shared.extensions,".angle_instanced_arrays")),e(t,i,n,r),t.compile().body}function q(e,t,n,r){j(e,t),H(e,t,n,r.attributes,function(){return!0}),R(e,t,n,r.uniforms,function(){return!0}),W(e,t,t,n)}function Q(e,t,n,r){function i(){return!0}e.batchId="a1",j(e,t),H(e,t,n,r.attributes,i),R(e,t,n,r.uniforms,i),W(e,t,t,n)}function V(e,t,n,r){function i(e){return e.contextDep&&o||e.propDep}function a(e){return!i(e)}j(e,t);var o=n.contextDep,f=t.def(),u=t.def();e.shared.props=u,e.batchId=f;var s=e.scope(),c=e.scope();t(s.entry,"for(",f,"=0;",f,"<","a1",";++",f,"){",u,"=","a0","[",f,"];",c,"}",s.exit),n.needsContext&&T(e,c,n.context),n.needsFramebuffer&&_(e,c,n.framebuffer),C(e,c,n.state,i),n.profile&&i(n.profile)&&I(e,c,n,!1,!0),r?(H(e,s,n,r.attributes,a),H(e,c,n,r.attributes,i),R(e,s,n,r.uniforms,a),R(e,c,n,r.uniforms,i),W(e,s,c,n)):(t=e.global.def("{}"),r=n.shader.progVar.append(e,c),u=c.def(r,".id"),s=c.def(t,"[",u,"]"),c(e.shared.gl,".useProgram(",r,".program);","if(!",s,"){",s,"=",t,"[",u,"]=",e.link(function(t){return N(Q,e,n,t,2)}),"(",r,");}",s,".call(this,a0[",f,"],",f,");"))}function G(e,n){function r(t){var r=n.shader[t];r&&i.set(a.shader,"."+t,r.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,o=a.current;T(e,i,n.context),n.framebuffer&&n.framebuffer.append(e,i),L(Object.keys(n.state)).forEach(function(t){var r=n.state[t].append(e,i);g(r)?r.forEach(function(n,r){i.set(e.next[t],"["+r+"]",n)}):i.set(a.next,"."+t,r)}),I(e,i,n,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(t){var r=n.draw[t];r&&i.set(a.draw,"."+t,""+r.append(e,i))}),Object.keys(n.uniforms).forEach(function(r){i.set(a.uniforms,"["+t.id(r)+"]",n.uniforms[r].append(e,i))}),Object.keys(n.attributes).forEach(function(t){var r=n.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new Y).forEach(function(e){i.set(a,"."+e,r[e])})}),r("vert"),r("frag"),0<Object.keys(n.state).length&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}function K(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!g(e)){for(var t=Object.keys(e),n=0;n<t.length;++n)if(U.isDynamic(e[t[n]]))return!0;return!1}}(r)){var i=e.global,a=Object.keys(r),o=!1,f=!1,u=!1,s=e.global.def("{}");a.forEach(function(t){var n=r[t];if(U.isDynamic(n))"function"==typeof n&&(n=r[t]=U.unbox(n)),t=P(n,null),o=o||t.thisDep,u=u||t.propDep,f=f||t.contextDep;else{switch(i(s,".",t,"="),typeof n){case"number":i(n);break;case"string":i('"',n,'"');break;case"object":Array.isArray(n)&&i("[",n.join(),"]");break;default:i(e.link(n))}i(";")}}),t.dynamic[n]=new U.DynamicVariable(4,{thisDep:o,contextDep:f,propDep:u,ref:s,append:function(e,t){a.forEach(function(n){var i=r[n];U.isDynamic(i)&&(i=e.invoke(t,i),t(s,".",n,"=",i,";"))})}}),delete t.static[n]}}var Y=c.Record,X={add:32774,subtract:32778,"reverse subtract":32779};n.ext_blend_minmax&&(X.min=32775,X.max=32776);var J=n.angle_instanced_arrays,$=n.webgl_draw_buffers,ee={dirty:!0,profile:m.profile},te={},re=[],ie={},ae={};v("dither",3024),v("blend.enable",3042),y("blend.color","blendColor",[0,0,0,0]),y("blend.equation","blendEquationSeparate",[32774,32774]),y("blend.func","blendFuncSeparate",[1,0,1,0]),v("depth.enable",2929,!0),y("depth.func","depthFunc",513),y("depth.range","depthRange",[0,1]),y("depth.mask","depthMask",!0),y("colorMask","colorMask",[!0,!0,!0,!0]),v("cull.enable",2884),y("cull.face","cullFace",1029),y("frontFace","frontFace",2305),y("lineWidth","lineWidth",1),v("polygonOffset.enable",32823),y("polygonOffset.offset","polygonOffset",[0,0]),v("sample.alpha",32926),v("sample.enable",32928),y("sample.coverage","sampleCoverage",[1,!1]),v("stencil.enable",2960),y("stencil.mask","stencilMask",-1),y("stencil.func","stencilFunc",[519,0,-1]),y("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),y("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),v("scissor.enable",3089),y("scissor.box","scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),y("viewport","viewport",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var oe={gl:e,context:d,strings:t,next:te,current:ee,draw:p,elements:a,buffer:i,shader:l,attributes:c.state,uniforms:s,framebuffer:u,extensions:n,timer:h,isBufferArgs:F},fe={primTypes:ne,compareFuncs:ve,blendFuncs:ge,blendEquations:X,stencilOps:ye,glTypes:Z,orientationType:xe};$&&(fe.backBuffer=[1029],fe.drawBuffer=o(r.maxDrawbuffers,function(e){return 0===e?[0]:o(e,function(e){return 36064+e})}));var ue=0;return{next:te,current:ee,procs:function(){var t=x(),n=t.proc("poll"),i=t.proc("refresh"),a=t.block();n(a),i(a);var f=t.shared,u=f.gl,s=f.next,c=f.current;a(c,".dirty=false;"),_(t,n),_(t,i,null,!0);var l,p=e.getExtension("angle_instanced_arrays");p&&(l=t.link(p));for(var d=0;d<r.maxAttributes;++d){var h=i.def(f.attributes,"[",d,"]"),m=t.cond(h,".buffer");m.then(u,".enableVertexAttribArray(",d,");",u,".bindBuffer(",34962,",",h,".buffer.buffer);",u,".vertexAttribPointer(",d,",",h,".size,",h,".type,",h,".normalized,",h,".stride,",h,".offset);").else(u,".disableVertexAttribArray(",d,");",u,".vertexAttrib4f(",d,",",h,".x,",h,".y,",h,".z,",h,".w);",h,".buffer=null;"),i(m),p&&i(l,".vertexAttribDivisorANGLE(",d,",",h,".divisor);")}return Object.keys(ie).forEach(function(e){var r=ie[e],o=a.def(s,".",e),f=t.block();f("if(",o,"){",u,".enable(",r,")}else{",u,".disable(",r,")}",c,".",e,"=",o,";"),i(f),n("if(",o,"!==",c,".",e,"){",f,"}")}),Object.keys(ae).forEach(function(e){var r,f,l=ae[e],p=ee[e],d=t.block();d(u,".",l,"("),g(p)?(l=p.length,r=t.global.def(s,".",e),f=t.global.def(c,".",e),d(o(l,function(e){return r+"["+e+"]"}),");",o(l,function(e){return f+"["+e+"]="+r+"["+e+"];"}).join("")),n("if(",o(l,function(e){return r+"["+e+"]!=="+f+"["+e+"]"}).join("||"),"){",d,"}")):(r=a.def(s,".",e),f=a.def(c,".",e),d(r,");",c,".",e,"=",r,";"),n("if(",r,"!==",f,"){",d,"}")),i(d)}),t.compile()}(),compile:function(e,t,n,r,i){var a=x();return a.stats=a.link(i),Object.keys(t.static).forEach(function(e){K(a,t,e)}),be.forEach(function(t){K(a,e,t)}),n=D(e,t,n,r),function(e,t){var n=e.proc("draw",1);j(e,n),T(e,n,t.context),_(e,n,t.framebuffer),S(e,n,t),C(e,n,t.state),I(e,n,t,!1,!0);var r=t.shader.progVar.append(e,n);if(n(e.shared.gl,".useProgram(",r,".program);"),t.shader.program)q(e,n,t,t.shader.program);else{var i=e.global.def("{}"),a=n.def(r,".id"),o=n.def(i,"[",a,"]");n(e.cond(o).then(o,".call(this,a0);").else(o,"=",i,"[",a,"]=",e.link(function(n){return N(q,e,t,n,1)}),"(",r,");",o,".call(this,a0);"))}0<Object.keys(t.state).length&&n(e.shared.current,".dirty=true;")}(a,n),G(a,n),function(e,t){function n(e){return e.contextDep&&i||e.propDep}var r=e.proc("batch",2);e.batchId="0",j(e,r);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(T(e,r,t.context),a=!1);var o=!1;if((f=t.framebuffer)?(f.propDep?i=o=!0:f.contextDep&&i&&(o=!0),o||_(e,r,f)):_(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),S(e,r,t),C(e,r,t.state,function(e){return!n(e)}),t.profile&&n(t.profile)||I(e,r,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=o,(a=t.shader.progVar).contextDep&&i||a.propDep)V(e,r,t,null);else if(a=a.append(e,r),r(e.shared.gl,".useProgram(",a,".program);"),t.shader.program)V(e,r,t,t.shader.program);else{var f=e.global.def("{}"),u=(o=r.def(a,".id"),r.def(f,"[",o,"]"));r(e.cond(u).then(u,".call(this,a0,a1);").else(u,"=",f,"[",o,"]=",e.link(function(n){return N(V,e,t,n,2)}),"(",a,");",u,".call(this,a0,a1);"))}0<Object.keys(t.state).length&&r(e.shared.current,".dirty=true;")}(a,n),a.compile()}}}function H(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}var R=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;++r)e[n[r]]=t[n[r]];return e},W=0,U={DynamicVariable:e,define:function(n,r){return new e(n,t(r+""))},isDynamic:function(t){return"function"==typeof t&&!t._reglType||t instanceof e},unbox:function(t,n){return"function"==typeof t?new e(0,t):t},accessor:t},N={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},q="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},Q=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},V=function(e){return Object.keys(e).map(function(t){return e[t]})},G=o(8,function(){return[]}),K={alloc:u,free:s,allocType:function(e,t){var n=null;switch(e){case 5120:n=new Int8Array(u(t),0,t);break;case 5121:n=new Uint8Array(u(t),0,t);break;case 5122:n=new Int16Array(u(2*t),0,t);break;case 5123:n=new Uint16Array(u(2*t),0,t);break;case 5124:n=new Int32Array(u(4*t),0,t);break;case 5125:n=new Uint32Array(u(4*t),0,t);break;case 5126:n=new Float32Array(u(4*t),0,t);break;default:return null}return n.length!==t?n.subarray(0,t):n},freeType:function(e){s(e.buffer)}},Y={shape:function(e){for(var t=[];e.length;e=e[0])t.push(e.length);return t},flatten:function(e,t,n,r){var i=1;if(t.length)for(var a=0;a<t.length;++a)i*=t[a];else i=0;switch(n=r||K.allocType(n,i),t.length){case 0:break;case 1:for(r=t[0],t=0;t<r;++t)n[t]=e[t];break;case 2:for(r=t[0],t=t[1],a=i=0;a<r;++a)for(var o=e[a],f=0;f<t;++f)n[i++]=o[f];break;case 3:c(e,t[0],t[1],t[2],n,0);break;default:!function e(t,n,r,i,a){for(var o=1,f=r+1;f<n.length;++f)o*=n[f];var u=n[r];if(4==n.length-r){var s=n[r+1],l=n[r+2];for(n=n[r+3],f=0;f<u;++f)c(t[f],s,l,n,i,a),a+=o}else for(f=0;f<u;++f)e(t[f],n,r+1,i,a),a+=o}(e,t,0,n,0)}return n}},X={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Z={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},J={dynamic:35048,stream:35040,static:35044},$=Y.flatten,ee=Y.shape,te=[];te[5120]=1,te[5122]=2,te[5124]=4,te[5121]=1,te[5123]=2,te[5125]=4,te[5126]=4;var ne={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},re=new Float32Array(1),ie=new Uint32Array(re.buffer),ae=[9984,9986,9985,9987],oe=[0,6409,6410,6407,6408],fe={};fe[6409]=fe[6406]=fe[6402]=1,fe[34041]=fe[6410]=2,fe[6407]=fe[35904]=3,fe[6408]=fe[35906]=4;var ue=Object.keys(X).concat(["[object HTMLCanvasElement]","[object CanvasRenderingContext2D]","[object HTMLImageElement]","[object HTMLVideoElement]"]),se=[];se[5121]=1,se[5126]=4,se[36193]=2,se[5123]=2,se[5125]=4;var ce=[];ce[32854]=2,ce[32855]=2,ce[36194]=2,ce[34041]=4,ce[33776]=.5,ce[33777]=.5,ce[33778]=1,ce[33779]=1,ce[35986]=.5,ce[35987]=1,ce[34798]=1,ce[35840]=.5,ce[35841]=.25,ce[35842]=.5,ce[35843]=.25,ce[36196]=.5;var le=[];le[32854]=2,le[32855]=2,le[36194]=2,le[33189]=2,le[36168]=1,le[34041]=4,le[35907]=4,le[34836]=16,le[34842]=8,le[34843]=6;var pe=function(e,t,n,r,i){function a(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=32854,this.height=this.width=0,i.profile&&(this.stats={size:0})}function o(t){var n=t.renderbuffer;e.bindRenderbuffer(36161,null),e.deleteRenderbuffer(n),t.renderbuffer=null,t.refCount=0,delete c[t.id],r.renderbufferCount--}var f={rgba4:32854,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(f.srgba=35907),t.ext_color_buffer_half_float&&(f.rgba16f=34842,f.rgb16f=34843),t.webgl_color_buffer_float&&(f.rgba32f=34836);var u=[];Object.keys(f).forEach(function(e){u[f[e]]=e});var s=0,c={};return a.prototype.decRef=function(){0>=--this.refCount&&o(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var e=0;return Object.keys(c).forEach(function(t){e+=c[t].stats.size}),e}),{create:function(t,n){function o(t,n){var r=0,a=0,c=32854;if("object"==typeof t&&t?("shape"in t?(r=0|(a=t.shape)[0],a=0|a[1]):("radius"in t&&(r=a=0|t.radius),"width"in t&&(r=0|t.width),"height"in t&&(a=0|t.height)),"format"in t&&(c=f[t.format])):"number"==typeof t?(r=0|t,a="number"==typeof n?0|n:r):t||(r=a=1),r!==s.width||a!==s.height||c!==s.format)return o.width=s.width=r,o.height=s.height=a,s.format=c,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,c,r,a),i.profile&&(s.stats.size=le[s.format]*s.width*s.height),o.format=u[s.format],o}var s=new a(e.createRenderbuffer());return c[s.id]=s,r.renderbufferCount++,o(t,n),o.resize=function(t,n){var r=0|t,a=0|n||r;return r===s.width&&a===s.height?o:(o.width=s.width=r,o.height=s.height=a,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,s.format,r,a),i.profile&&(s.stats.size=le[s.format]*s.width*s.height),o)},o._reglType="renderbuffer",o._renderbuffer=s,i.profile&&(o.stats=s.stats),o.destroy=function(){s.decRef()},o},clear:function(){V(c).forEach(o)},restore:function(){V(c).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(36161,t.renderbuffer),e.renderbufferStorage(36161,t.format,t.width,t.height)}),e.bindRenderbuffer(36161,null)}}},de=[];de[6408]=4;var he=[];he[5121]=1,he[5126]=4,he[36193]=2;var me=["x","y","z","w"],be="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),ge={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},ve={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},ye={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},xe={cw:2304,ccw:2305},we=new z(!1,!1,!1,function(){});return function(e){function t(){if(0===K.length)A&&A.update(),J=null;else{J=N.next(t),l();for(var e=K.length-1;0<=e;--e){var n=K[e];n&&n(O,null,0)}b.flush(),A&&A.update()}}function n(){!J&&0<K.length&&(J=N.next(t))}function r(){J&&(N.cancel(t),J=null)}function a(e){e.preventDefault(),r(),Y.forEach(function(e){e()})}function o(e){b.getError(),v.restore(),B.restore(),L.restore(),M.restore(),P.restore(),W.restore(),A&&A.restore(),Q.procs.refresh(),n(),X.forEach(function(e){e()})}function f(e){function t(e){var t={},n={};return Object.keys(e).forEach(function(r){var i=e[r];U.isDynamic(i)?n[r]=U.unbox(i,r):t[r]=i}),{dynamic:n,static:t}}var n=t(e.context||{}),r=t(e.uniforms||{}),i=t(e.attributes||{}),a=t(function(e){function t(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach(function(r){n[e+"."+r]=t[r]})}}var n=R({},e);return delete n.uniforms,delete n.attributes,delete n.context,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),n}(e));e={gpuTime:0,cpuTime:0,count:0};var o=(n=Q.compile(a,i,r,n,e)).draw,f=n.batch,u=n.scope,s=[];return R(function(e,t){var n;if("function"==typeof e)return u.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(n=0;n<e;++n)u.call(this,null,t,n);else{if(!Array.isArray(e))return u.call(this,e,t,0);for(n=0;n<e.length;++n)u.call(this,e[n],t,n)}else if("number"==typeof e){if(0<e)return f.call(this,function(e){for(;s.length<e;)s.push(null);return s}(0|e),0|e)}else{if(!Array.isArray(e))return o.call(this,e);if(e.length)return f.call(this,e,e.length)}},{stats:e})}function u(e,t){var n=0;Q.procs.poll();var r=t.color;r&&(b.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=16384),"depth"in t&&(b.clearDepth(+t.depth),n|=256),"stencil"in t&&(b.clearStencil(0|t.stencil),n|=1024),b.clear(n)}function s(e){return K.push(e),n(),{cancel:function(){var t=H(K,e);K[t]=function e(){var t=H(K,e);K[t]=K[K.length-1],--K.length,0>=K.length&&r()}}}}function c(){var e=V.viewport,t=V.scissor_box;e[0]=e[1]=t[0]=t[1]=0,O.viewportWidth=O.framebufferWidth=O.drawingBufferWidth=e[2]=t[2]=b.drawingBufferWidth,O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=e[3]=t[3]=b.drawingBufferHeight}function l(){O.tick+=1,O.time=d(),c(),Q.procs.poll()}function p(){c(),Q.procs.refresh(),A&&A.update()}function d(){return(q()-k)/1e3}if(!(e=i(e)))return null;var b=e.gl,g=b.getContextAttributes();b.isContextLost();var v=function(e,t){function n(t){var n;t=t.toLowerCase();try{n=r[t]=e.getExtension(t)}catch(e){}return!!n}for(var r={},i=0;i<t.extensions.length;++i){var a=t.extensions[i];if(!n(a))return t.onDestroy(),t.onDone('"'+a+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(n),{extensions:r,restore:function(){Object.keys(r).forEach(function(e){if(!n(e))throw Error("(regl): error restoring extension "+e)})}}}(b,e);if(!v)return null;var y=function(){var e={"":0},t=[""];return{id:function(n){var r=e[n];return r||(r=e[n]=t.length,t.push(n),r)},str:function(e){return t[e]}}}(),x={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},w=v.extensions,A=function(e,t){function n(e,t,n){var r=o.pop()||new function(){this.endQueryIndex=this.startQueryIndex=-1,this.sum=0,this.stats=null};r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,f.push(r)}var r=t.ext_disjoint_timer_query;if(!r)return null;var i=[],a=[],o=[],f=[],u=[],s=[];return{beginQuery:function(e){var t=i.pop()||r.createQueryEXT();r.beginQueryEXT(35007,t),a.push(t),n(a.length-1,a.length,e)},endQuery:function(){r.endQueryEXT(35007)},pushScopeStats:n,update:function(){var e,t;if(0!==(e=a.length)){s.length=Math.max(s.length,e+1),u.length=Math.max(u.length,e+1),u[0]=0;var n=s[0]=0;for(t=e=0;t<a.length;++t){var c=a[t];r.getQueryObjectEXT(c,34919)?(n+=r.getQueryObjectEXT(c,34918),i.push(c)):a[e++]=c,u[t+1]=n,s[t+1]=e}for(a.length=e,t=e=0;t<f.length;++t){var l=(n=f[t]).startQueryIndex;c=n.endQueryIndex,n.sum+=u[c]-u[l],l=s[l],(c=s[c])===l?(n.stats.gpuTime+=n.sum/1e6,o.push(n)):(n.startQueryIndex=l,n.endQueryIndex=c,f[e++]=n)}f.length=e}},getNumPendingQueries:function(){return a.length},clear:function(){i.push.apply(i,a);for(var e=0;e<i.length;e++)r.deleteQueryEXT(i[e]);a.length=0,i.length=0},restore:function(){a.length=0,i.length=0}}}(0,w),k=q(),C=b.drawingBufferWidth,j=b.drawingBufferHeight,O={tick:0,time:0,viewportWidth:C,viewportHeight:j,framebufferWidth:C,framebufferHeight:j,drawingBufferWidth:C,drawingBufferHeight:j,pixelRatio:e.pixelRatio},F=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter(34047));var r=1,i=1;return t.webgl_draw_buffers&&(r=e.getParameter(34852),i=e.getParameter(36063)),{colorBits:[e.getParameter(3410),e.getParameter(3411),e.getParameter(3412),e.getParameter(3413)],depthBits:e.getParameter(3414),stencilBits:e.getParameter(3415),subpixelBits:e.getParameter(3408),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:i,pointSizeDims:e.getParameter(33901),lineWidthDims:e.getParameter(33902),maxViewportDims:e.getParameter(3386),maxCombinedTextureUnits:e.getParameter(35661),maxCubeMapSize:e.getParameter(34076),maxRenderbufferSize:e.getParameter(34024),maxTextureUnits:e.getParameter(34930),maxTextureSize:e.getParameter(3379),maxAttributes:e.getParameter(34921),maxVertexUniforms:e.getParameter(36347),maxVertexTextureUnits:e.getParameter(35660),maxVaryingVectors:e.getParameter(36348),maxFragmentUniforms:e.getParameter(36349),glsl:e.getParameter(35724),renderer:e.getParameter(7937),vendor:e.getParameter(7936),version:e.getParameter(7938)}}(b,w),L=h(b,x,e),z=m(b,w,L,x),B=(C=function(e,t,n,r,i){for(e=n.maxAttributes,t=Array(e),n=0;n<e;++n)t[n]=new T;return{Record:T,scope:{},state:t}}(b,w,F),_(b,y,x,e)),M=E(b,w,F,function(){Q.procs.poll()},O,x,e),P=pe(b,w,0,x,e),W=D(b,w,F,M,P,x),Q=I(b,y,w,F,L,z,0,W,{},C,B,{elements:null,primitive:4,count:-1,offset:0,instances:-1},O,A,e),V=(y=S(b,W,Q.procs.poll,O),Q.next),G=b.canvas,K=[],Y=[],X=[],Z=[e.onDestroy],J=null;G&&(G.addEventListener("webglcontextlost",a,!1),G.addEventListener("webglcontextrestored",o,!1));var $=W.setFBO=f({framebuffer:U.define.call(null,1,"framebuffer")});return p(),g=R(f,{clear:function(e){if("framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;6>t;++t)$(R({framebuffer:e.framebuffer.faces[t]},e),u);else $(e,u);else u(0,e)},prop:U.define.bind(null,1),context:U.define.bind(null,2),this:U.define.bind(null,3),draw:f({}),buffer:function(e){return L.create(e,34962,!1,!1)},elements:function(e){return z.create(e,!1)},texture:M.create2D,cube:M.createCube,renderbuffer:P.create,framebuffer:W.create,framebufferCube:W.createCube,attributes:g,frame:s,on:function(e,t){var n;switch(e){case"frame":return s(t);case"lost":n=Y;break;case"restore":n=X;break;case"destroy":n=Z}return n.push(t),{cancel:function(){for(var e=0;e<n.length;++e)if(n[e]===t){n[e]=n[n.length-1],n.pop();break}}}},limits:F,hasExtension:function(e){return 0<=F.extensions.indexOf(e.toLowerCase())},read:y,destroy:function(){K.length=0,r(),G&&(G.removeEventListener("webglcontextlost",a),G.removeEventListener("webglcontextrestored",o)),B.clear(),W.clear(),P.clear(),M.clear(),z.clear(),L.clear(),A&&A.clear(),Z.forEach(function(e){e()})},_gl:b,_refresh:p,poll:function(){l(),A&&A.update()},now:d,stats:x}),e.onDone(null,g),g}},"object"==typeof n&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):r.createREGL=i()},{}],10:[function(e,t,n){"use strict";var r=e("parse-unit");t.exports=o;var i=96;function a(e,t){var n=r(getComputedStyle(e).getPropertyValue(t));return n[0]*o(n[1],e)}function o(e,t){switch(t=t||document.body,e=(e||"px").trim().toLowerCase(),t!==window&&t!==document||(t=document.body),e){case"%":return t.clientHeight/100;case"ch":case"ex":return function(e,t){var n=document.createElement("div");n.style["font-size"]="128"+e,t.appendChild(n);var r=a(n,"font-size")/128;return t.removeChild(n),r}(e,t);case"em":return a(t,"font-size");case"rem":return a(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return i;case"cm":return i/2.54;case"mm":return i/25.4;case"pt":return i/72;case"pc":return i/6}return 1}},{"parse-unit":8}],11:[function(e,t,n){var r=e("h");e("insert-css")("\n.explanation {\n position: absolute;\n z-index: 100;\n top: 5px;\n left: 5px;\n font-family: sans-serif;\n font-style: italic;\n}\n.explanation h4 {\n margin: 0;\n}\n");e("glslify");var i=e("mouse-event"),a=e("mouse-wheel"),o=e("mouse-change");e("regl")({extensions:["OES_texture_float"],onDone:function(t,n){if(t)return e("fail-nicely")(t);document.querySelector("canvas").addEventListener("mousewheel",function(e){return e.preventDefault()}),function(e){var t=r("div.explanation",[r("h4","Logistic Map"),r("div","Drag and scroll to pan/zoom. Shift to zoom vertically")]);document.body.appendChild(t);for(var n=0,f=new Float32Array(1048576),u=0;u<512;u++)for(var s=0;s<512;s++){var c=s+512*u;f[4*c]=2*Math.random()-1,f[4*c+1]=Math.random(),f[4*c+2]=2*Math.random()-1,f[4*c+3]=Math.random()}var l={xmin:1,xmax:4,ymin:0,ymax:1},p=void 0,d=void 0,h=!1;o(function(e,t,n,r){if(h=r.shift,1===e&&void 0!==p){var i=(l.xmax-l.xmin)*(t-p)/window.innerWidth,a=-(l.ymax-l.ymin)*(n-d)/window.innerHeight,o=l.xmin,f=l.xmax,u=l.ymin,s=l.ymax,c=Math.max(1,o-i),m=Math.min(4,f-i),b=Math.max(0,u-a),g=Math.min(1,s-a);l.xmin=Math.max(0,c),l.xmax=Math.min(4,m),l.ymin=Math.max(0,b),l.ymax=Math.min(1,g),c===o&&m===f&&b===u&&g===s||(_=!1,T=!0)}p=t,d=n}),a(function(e,t,n,r){if(h){var a=l.ymin+(l.ymax-l.ymin)*(1-i.y(r)/window.innerHeight),o=l.ymin,f=l.ymax,u=l.ymax-a,s=a-l.ymin,c=Math.exp(t/50);s*=c,u*=c,l.ymin=Math.max(0,a-s),l.ymax=Math.min(1,a+u),l.ymin===o&&l.ymax===f||(_=!1,T=!0)}else{var p=l.xmin+(l.xmax-l.xmin)*i.x(r)/window.innerWidth,d=l.xmin,m=l.xmax,b=l.xmax-p,g=p-l.xmin,v=Math.exp(t/50);g*=v,b*=v,l.xmin=Math.max(1,p-g),l.xmax=Math.min(4,p+b),l.xmin===d&&l.xmax===m||(_=!1,T=!0)}});var m=e.buffer(new Array(262144).fill(0).map(function(e,t){return[t%512/Math.max(1,511),Math.floor(t/512)/Math.max(1,511)]})),b=e.texture({width:512,height:512,data:f,type:"float32"}),g=new Array(2).fill(0).map(function(t,n){return e.framebuffer({color:e.texture({width:512,height:512,data:f,type:"float32"}),depth:!1})}),v=e({vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = 0.5 * (1.0 + xy);\n gl_Position = vec4(xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n void main () {\n gl_FragColor = texture2D(src, uv);\n }\n ",framebuffer:e.prop("dest"),uniforms:{src:b},attributes:{xy:[[-4,-4],[0,4],[4,-4]]},depth:{enable:!1},count:3}),y=e({vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = 0.5 * (1.0 + xy);\n gl_Position = vec4(xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n uniform vec4 viewport;\n void main () {\n vec4 p = texture2D(src, uv);\n float r = viewport.x + viewport.y * p.x;\n p.y = r * p.y * (1.0 - p.y);\n r = viewport.x + viewport.y * p.z;\n p.w = r * p.w * (1.0 - p.w);\n gl_FragColor = p;\n }\n ",framebuffer:e.prop("dest"),uniforms:{src:e.prop("src")},attributes:{xy:[[-4,-4],[0,4],[4,-4]]},depth:{enable:!1},count:3}),x=e({vert:"\n precision mediump float;\n attribute vec2 uv;\n uniform sampler2D data;\n uniform float select;\n uniform vec4 viewport;\n void main () {\n vec4 p = texture2D(data, uv);\n vec2 y = p.xy * select + p.zw * (1.0 - select);\n gl_Position = vec4(y.x, y.y * viewport.z + viewport.w, 0, 1);\n gl_PointSize = 1.0;\n }\n ",frag:"\n precision mediump float;\n void main () {\n gl_FragColor = vec4(1);\n }\n ",blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:1,dstAlpha:1},equation:{rgb:"add",alpha:"add"}},uniforms:{data:e.prop("src"),select:e.prop("select")},framebuffer:e.prop("dest"),attributes:{uv:m},primitive:"points",count:262144}),w=function(e){var t=e[0];e[0]=e[1],e[1]=t},A=new Array(2).fill(0).map(function(){return e.framebuffer({width:e._gl.canvas.width,height:e._gl.canvas.height,colorType:"float",depth:!1})}),k=e({vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = 0.5 * (1.0 + xy);\n gl_Position = vec4(xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n uniform sampler2D src;\n varying vec2 uv;\n uniform float decay;\n void main () {\n float col = texture2D(src, uv).x;\n gl_FragColor = vec4(col * decay, 0, 0, 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:e.prop("src"),decay:function(){return S}},framebuffer:e.prop("dest"),depth:{enable:!1},count:3}),E=e({vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = 0.5 * (1.0 + xy);\n gl_Position = vec4(xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n uniform sampler2D src;\n uniform float scalar;\n varying vec2 uv;\n void main () {\n float value = texture2D(src, uv).x;\n gl_FragColor = vec4(vec3(1.0 - value * scalar), 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:e.prop("src")},depth:{enable:!1},count:3}),D=e({uniforms:{scalar:function(e){var t=.1/n;return t*=1,t/=49e4/e.viewportWidth/e.viewportHeight,t/=Math.sqrt(l.ymax-l.ymin)},viewport:function(){return[.5*(l.xmin+l.xmax),.5*(l.xmax-l.xmin),1/(l.ymax-l.ymin)*2,-l.ymin/(l.ymax-l.ymin)*2-1]}}}),T=!1,_=!0,S=.98,C=function(){v({dest:g[0]}),A[0].use(function(){return e.clear({color:[0,0,0,1]})}),n=0};C(),e.frame(function(e){e.tick;D(function(){!function(){var e=_?100:T?20:1;(T||_)&&C();for(var t=e;t>=0;t--)y({src:g[0],dest:g[1]}),w(g);n*=S,n++,T?(T=!1,_=!0):_&&(_=!1,T=!1)}(),x([{src:g[0],select:0,dest:A[0]},{src:g[0],select:1,dest:A[0]}]),k({src:A[0],dest:A[1]}),E({src:A[0]})}),w(A)})}(n)}})},{"fail-nicely":1,glslify:2,h:3,"insert-css":4,"mouse-change":5,"mouse-event":6,"mouse-wheel":7,regl:9}]},{},[11]); |