mirror of
https://github.com/rreusser/rreusser.github.io.git
synced 2026-01-18 16:13:07 +00:00
1 line
103 KiB
JavaScript
1 line
103 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:4}],2:[function(e,t,n){var r=e("sprintf");function i(e,t){var n,i=Math.max(1,o(Math.abs(e))),f=o(Math.abs(i)),u=Math.pow(10,t+1);if(Math.abs(e)<1)e=Math.round(e*u)/u;else{var s=Math.pow(10,i+1);e=Math.round(e/s*u)/u*s}if(t-f-6==-1)e=Math.round(e/Math.pow(10,i)),e*=Math.pow(10,i),n=r("%1e",e).replace(/\.[^e]+/,"");else{if(t-f-6<0)return;n=r("%."+(t-f-6)+"e",e)}return e>0&&(n=" "+n),a(n,t)}function a(e,t){return Array(Math.max(0,t-e.length+1)).join(" ")+e}function o(e){return Math.floor(Math.log(e)/Math.log(10))}t.exports=function(e,t){void 0===t&&(t=8);var n="%"+t+"."+t+"s";if(t<=0)return;if(isNaN(e))return r(n,"NaN");if(e===1/0){if(1===t)return;return r(n,t>=9?"Infinity":" Inf").slice(0,t)}if(e===-1/0){if(1===t)return;return r(n,t>=9?"-Infinity":"-Inf").slice(0,t)}return function(e,t){var n=Math.max(1,Math.floor((t-2)/2)),f=t-n-2;if(0===e&&t<4)return a("0",t);if(0===e)return a("0."+Array(f+1).join("0"),t);if(f<=0){var u=r("%"+n+"f",e);if(e>=0&&(u=" "+u),u.length>t)return;return a(u,t)}if(Math.abs(e)<Math.pow(10,1-f))return i(e,t);var s=Math.pow(10,t-3),c=Math.pow(10,o(Math.abs(e))),l=Math.round(e/c*s)/s*c,u=r("%"+n+"."+f+"f",l);l>0&&(u=" "+u);var p=(u=u.slice(0,t)).split(".")[1];return!p||p.length<1?i(l,t):a(u,t).slice(0,t)}(e,t)}},{sprintf:13}],3:[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("")}},{}],4:[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}()},{}],5:[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},{}],6:[function(e,t,n){"use strict";t.exports=function(e){for(var t=new Array(e),n=0;n<e;++n)t[n]=n;return t}},{}],7:[function(e,t,n){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}t.exports=function(e){return null!=e&&(r(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],8:[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 v(e){s(n&~r.buttons(e),e)}function m(){f||(f=!0,e.addEventListener("mousemove",d),e.addEventListener("mousedown",h),e.addEventListener("mouseup",v),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)))}m();var g={element:e};return Object.defineProperties(g,{enabled:{get:function(){return f},set:function(t){t?m():f&&(f=!1,e.removeEventListener("mousemove",d),e.removeEventListener("mousedown",h),e.removeEventListener("mouseup",v),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":9}],9:[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}},{}],10:[function(e,t,n){var r=e("fixed-width-float"),i=e("ndarray");function a(e,t){for(var n=[],i=0;i<e.shape[0];i++)n.push(r(e.get(i),t.width));return n.join(" ")}function o(e,t){for(var n=[],r=0;r<e.shape[0];r++)n.push(a(e.pick(r,null),t));return n.join("\n")}function f(e,t){for(var n=[],r=0;r<e.shape[0];r++)n.push(o(e.pick(r,null,null),t),"");return n.join("\n")}t.exports=function(e,t){return t||(t={}),"number"==typeof t&&(t={width:t}),t.width||(t.width=8),void 0===e.dimension&&(e=i(e)),1===e.dimension?a(e,t):2===e.dimension?o(e,t):3===e.dimension?f(e,t):4===e.dimension?function(e,t){for(var n=[],r=3,i=0;i<e.shape[0];i++){var a=f(e.pick(i,null,null,null),t);n.push(a);for(var o=a.split("\n"),u=0;u<o.length;u++)r=Math.max(r,o[u].length)}return n.join("\n"+Array(r+1).join("-")+"\n\n")}(e,t):void 0}},{"fixed-width-float":2,ndarray:11}],11:[function(e,t,n){var r=e("iota-array"),i=e("is-buffer"),a="undefined"!=typeof Float64Array;function o(e,t){return e[0]-t[0]}function f(){var e,t=this.stride,n=new Array(t.length);for(e=0;e<n.length;++e)n[e]=[Math.abs(t[e]),e];n.sort(o);var r=new Array(n.length);for(e=0;e<r.length;++e)r[e]=n[e][1];return r}function u(e,t){var n=["View",t,"d",e].join("");t<0&&(n="View_Nil"+e);var i="generic"===e;if(-1===t){var a="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}";return new Function(a)()}if(0===t){a="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}";return new Function("TrivialArray",a)(s[e][0])}a=["'use strict'"];var o=r(t),u=o.map(function(e){return"i"+e}),c="this.offset+"+o.map(function(e){return"this.stride["+e+"]*i"+e}).join("+"),l=o.map(function(e){return"b"+e}).join(","),p=o.map(function(e){return"c"+e}).join(",");a.push("function "+n+"(a,"+l+","+p+",d){this.data=a","this.shape=["+l+"]","this.stride=["+p+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),a.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+o.map(function(e){return"this.shape["+e+"]"}).join("*"),"}})"),1===t?a.push("proto.order=[0]"):(a.push("Object.defineProperty(proto,'order',{get:"),t<4?(a.push("function "+n+"_order(){"),2===t?a.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&a.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):a.push("ORDER})")),a.push("proto.set=function "+n+"_set("+u.join(",")+",v){"),i?a.push("return this.data.set("+c+",v)}"):a.push("return this.data["+c+"]=v}"),a.push("proto.get=function "+n+"_get("+u.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+n+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+n+"_hi("+u.join(",")+"){return new "+n+"(this.data,"+o.map(function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")}).join(",")+","+o.map(function(e){return"this.stride["+e+"]"}).join(",")+",this.offset)}");var d=o.map(function(e){return"a"+e+"=this.shape["+e+"]"}),h=o.map(function(e){return"c"+e+"=this.stride["+e+"]"});a.push("proto.lo=function "+n+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+d.join(",")+","+h.join(","));for(var v=0;v<t;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){d=i"+v+"|0;b+=c"+v+"*d;a"+v+"-=d}");a.push("return new "+n+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"c"+e}).join(",")+",b)}"),a.push("proto.step=function "+n+"_step("+u.join(",")+"){var "+o.map(function(e){return"a"+e+"=this.shape["+e+"]"}).join(",")+","+o.map(function(e){return"b"+e+"=this.stride["+e+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(v=0;v<t;++v)a.push("if(typeof i"+v+"==='number'){d=i"+v+"|0;if(d<0){c+=b"+v+"*(a"+v+"-1);a"+v+"=ceil(-a"+v+"/d)}else{a"+v+"=ceil(a"+v+"/d)}b"+v+"*=d}");a.push("return new "+n+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"b"+e}).join(",")+",c)}");var m=new Array(t),g=new Array(t);for(v=0;v<t;++v)m[v]="a[i"+v+"]",g[v]="b[i"+v+"]";a.push("proto.transpose=function "+n+"_transpose("+u+"){"+u.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+m.join(",")+","+g.join(",")+",this.offset)}"),a.push("proto.pick=function "+n+"_pick("+u+"){var a=[],b=[],c=this.offset");for(v=0;v<t;++v)a.push("if(typeof i"+v+"==='number'&&i"+v+">=0){c=(c+this.stride["+v+"]*i"+v+")|0}else{a.push(this.shape["+v+"]);b.push(this.stride["+v+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+o.map(function(e){return"shape["+e+"]"}).join(",")+","+o.map(function(e){return"stride["+e+"]"}).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",a.join("\n"))(s[e],f)}var s={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],buffer:[],generic:[]};t.exports=function(e,t,n,r){if(void 0===e)return(0,s.array[0])([]);"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var o=t.length;if(void 0===n){n=new Array(o);for(var f=o-1,c=1;f>=0;--f)n[f]=c,c*=t[f]}if(void 0===r)for(r=0,f=0;f<o;++f)n[f]<0&&(r-=(t[f]-1)*n[f]);for(var l=function(e){if(i(e))return"buffer";if(a)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped"}return Array.isArray(e)?"array":"generic"}(e),p=s[l];p.length<=o+1;)p.push(u(l,p.length-1));return(0,p[o+1])(e,t,n,r)}},{"iota-array":6,"is-buffer":7}],12:[function(e,t,n){var r,i;r=this,i=function(){function e(e,t){this.id=U++,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,H(i.style,{width:t+"px",height:r+"px"})}var i=document.createElement("canvas");return H(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",H(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,t){for(var n=Array(e),r=0;r<e;++r)n[r]=t(r);return n}function o(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 f(){function e(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=n[o(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){n[o(e.byteLength)>>2].push(e)}var n=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,n){var r=null;switch(t){case 5120:r=new Int8Array(e(n),0,n);break;case 5121:r=new Uint8Array(e(n),0,n);break;case 5122:r=new Int16Array(e(2*n),0,n);break;case 5123:r=new Uint16Array(e(2*n),0,n);break;case 5124:r=new Int32Array(e(4*n),0,n);break;case 5125:r=new Uint32Array(e(4*n),0,n);break;case 5126:r=new Float32Array(e(4*n),0,n);break;default:return null}return r.length!==n?r.subarray(0,n):r},freeType:function(e){t(e.buffer)}}}function u(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)||V(e.data))}function s(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 c(e){return 0|X[Object.prototype.toString.call(e)]}function l(e,t){for(var n=0;n<t.length;++n)e[n]=t[n]}function p(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 d(e,t,n,r){function i(t){this.id=s++,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 a(t,n,r){t.byteLength=n.byteLength,e.bufferData(t.type,n,r)}function o(e,t,n,r,i,o){if(e.usage=n,Array.isArray(t)){if(e.dtype=r||5126,0<t.length)if(Array.isArray(t[0])){i=ee(t);for(var f=r=1;f<i.length;++f)r*=i[f];e.dimension=r,a(e,t=Z(t,i,e.dtype),n),o?e.persistentData=t:q.freeType(t)}else"number"==typeof t[0]?(e.dimension=i,l(i=q.allocType(e.dtype,t.length),t),a(e,i,n),o?e.persistentData=i:q.freeType(i)):V(t[0])&&(e.dimension=t[0].length,e.dtype=r||c(t[0])||5126,a(e,t=Z(t,[t.length,t[0].length],e.dtype),n),o?e.persistentData=t:q.freeType(t))}else if(V(t))e.dtype=r||c(t),e.dimension=i,a(e,t,n),o&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(u(t)){i=t.shape;var s=t.stride,d=(f=t.offset,0),h=0,v=0,m=0;1===i.length?(d=i[0],h=1,v=s[0],m=0):2===i.length&&(d=i[0],h=i[1],v=s[0],m=s[1]),e.dtype=r||c(t.data)||5126,e.dimension=h,p(i=q.allocType(e.dtype,d*h),t.data,d,h,v,m,f),a(e,i,n),o?e.persistentData=i:q.freeType(i)}}function f(n){t.bufferCount--;for(var i=0;i<r.state.length;++i){var a=r.state[i];a.buffer===n&&(e.disableVertexAttribArray(i),a.buffer=null)}e.deleteBuffer(n.buffer),n.buffer=null,delete d[n.id]}var s=0,d={};i.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},i.prototype.destroy=function(){f(this)};var h=[];return n.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(d).forEach(function(t){e+=d[t].stats.size}),e}),{create:function(r,a,s,h){function v(t){var r=35044,i=null,a=0,f=0,s=1;return Array.isArray(t)||V(t)||u(t)?i=t:"number"==typeof t?a=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(r=J[t.usage]),"type"in t&&(f=$[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(a=0|t.length)),m.bind(),i?o(m,i,r,f,s,h):(a&&e.bufferData(m.type,a,r),m.dtype=f||5121,m.usage=r,m.dimension=s,m.byteLength=a),n.profile&&(m.stats.size=m.byteLength*te[m.dtype]),v}t.bufferCount++;var m=new i(a);return d[m.id]=m,s||v(r),v._reglType="buffer",v._buffer=m,v.subdata=function(t,n){var r,i=0|(n||0);if(m.bind(),V(t))e.bufferSubData(m.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var a=q.allocType(m.dtype,t.length);l(a,t),e.bufferSubData(m.type,i,a),q.freeType(a)}else(Array.isArray(t[0])||V(t[0]))&&(r=ee(t),a=Z(t,r,m.dtype),e.bufferSubData(m.type,i,a),q.freeType(a))}else if(u(t)){r=t.shape;var o=t.stride,f=a=0,s=0,d=0;1===r.length?(a=r[0],f=1,s=o[0],d=0):2===r.length&&(a=r[0],f=r[1],s=o[0],d=o[1]),r=Array.isArray(t.data)?m.dtype:c(t.data),p(r=q.allocType(r,a*f),t.data,a,f,s,d,t.offset),e.bufferSubData(m.type,i,r),q.freeType(r)}return v},n.profile&&(v.stats=m.stats),v.destroy=function(){f(m)},v},createStream:function(e,t){var n=h.pop();return n||(n=new i(e)),n.bind(),o(n,t,35040,0,1,!1),n},destroyStream:function(e){h.push(e)},clear:function(){Y(d).forEach(f),h.forEach(f)},getBuffer:function(e){return e&&e._buffer instanceof i?e._buffer:null},restore:function(){Y(d).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 h(e,t,n,r){function i(e){this.id=s++,f[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function a(r,i,a,o,f,s,c){if(r.buffer.bind(),i){var l=c;c||V(i)&&(!u(i)||V(i.data))||(l=t.oes_element_index_uint?5125:5123),n._initBuffer(r.buffer,i,a,l,3)}else e.bufferData(34963,s,a),r.buffer.dtype=l||5121,r.buffer.usage=a,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=f)&&(i=r.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),r.vertCount=i,i=o,0>o&&(i=4,1===(o=r.buffer.dimension)&&(i=0),2===o&&(i=1),3===o&&(i=4)),r.primType=i}function o(e){r.elementsCount--,delete f[e.id],e.buffer.destroy(),e.buffer=null}var f={},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 f(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,o=0,p=0;Array.isArray(e)||V(e)||u(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?o=0|e.length:(o=i,5123===p||5122===p?o*=2:5125!==p&&5124!==p||(o*=4))),a(l,t,n,r,i,o,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return f}var s=n.create(null,34963,!0),l=new i(s._buffer);return r.elementsCount++,f(e),f._reglType="elements",f._elements=l,f.subdata=function(e,t){return s.subdata(e,t),f},f.destroy=function(){o(l)},f},createStream:function(e){var t=l.pop();return t||(t=new i(n.create(null,34963,!0,!1)._buffer)),a(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(){Y(f).forEach(o)}}}function v(e){for(var t=q.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 m(e){return Array.isArray(e)||V(e)}function g(e){return"[object "+e+"]"}function b(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function y(e){return!(!Array.isArray(e)||0===e.length||!m(e[0]))}function x(e){return Object.prototype.toString.call(e)}function w(e){if(!e)return!1;var t=x(e);return 0<=de.indexOf(t)||(b(e)||y(e)||u(e))}function A(e,t){36193===e.type?(e.data=v(t),q.freeType(t)):e.data=t}function k(e,t,n,r,i,a){if(e=void 0!==ve[e]?ve[e]:fe[e]*he[t],a&&(e*=6),i){for(r=0;1<=n;)r+=e*n*n,n/=2;return r}return e*n*r}function _(e,t,n,r,i,a,o){function f(){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=W[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=G[n],e.format=ie[r],n in N&&!("type"in t)&&(e.type=N[n]),n in Q&&(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(){f.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,a=i.viewportHeight;e.width=e.width||r-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0}else if(n){if(V(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(b(n)){switch(e.channels=e.channels||4,a=(r=n).length,e.type){case 5121:case 5123:case 5125:case 5126:(a=q.allocType(e.type,a)).set(r),e.data=a;break;case 36193:e.data=v(r)}e.alignment=1,e.needsFree=!0}else if(u(n)){r=n.data,Array.isArray(r)||5121!==e.type||(e.type=0|X[Object.prototype.toString.call(r)]);a=n.shape;var o,f,s,l,p=n.stride;3===a.length?(s=a[2],l=p[2]):l=s=1,o=a[0],f=a[1],a=p[0],p=p[1],e.alignment=1,e.width=o,e.height=f,e.channels=s,e.format=e.internalformat=oe[s],e.needsFree=!0,o=l,n=n.offset,s=e.width,l=e.height,f=e.channels;for(var d=q.allocType(36193===e.type?5126:e.type,s*l*f),h=0,g=0;g<l;++g)for(var k=0;k<s;++k)for(var _=0;_<f;++_)d[h++]=r[a*k+p*g+o*_+n];A(e,d)}else if(x(n)===ue||x(n)===se)x(n)===ue?e.element=n:e.element=n.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(x(n)===ce)e.element=n,e.width=n.width,e.height=n.height,e.channels=4;else if(x(n)===le)e.element=n,e.width=n.naturalWidth,e.height=n.naturalHeight,e.channels=4;else if(x(n)===pe)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,a=e.height||n.length,p=e.channels,p=m(n[0][0])?p||n[0][0].length:p||1,o=K.shape(n),s=1,l=0;l<o.length;++l)s*=o[l];s=q.allocType(36193===e.type?5126:e.type,s),K.flatten(n,o,"",s),A(e,s),e.alignment=1,e.width=r,e.height=a,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 g(){return de.pop()||new p}function _(e){e.needsFree&&q.freeType(e.data),p.call(e),de.push(e)}function E(e,t,n){var r=e.images[0]=g();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function D(e,t){var n=null;if(w(t))s(n=e.images[0]=g(),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]=g(),e),n.width>>=i,n.height>>=i,d(n,r[i]),e.mipmask|=1<<i;else s(n=e.images[0]=g(),e),d(n,t),e.mipmask=1;s(e,e.images[0])}function T(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,v=o.width,m=o.height,g=o.channels;l(o),s?e.texImage2D(f,u,d,d,h,s):o.compressed?e.compressedTexImage2D(f,u,p,v,m,0,c):o.needsCopy?(r(),e.copyTexImage2D(f,u,d,o.xOffset,o.yOffset,v,m,0)):((o=!c)&&(c=q.zero.allocType(h,v*m*g)),e.texImage2D(f,u,d,v,m,0,d,h,c),o&&c&&q.zero.freeType(c))}}function j(){var e=he.pop()||new function(){f.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)};f.call(e);for(var t=e.mipmask=0;16>t;++t)e.images[t]=null;return e}function S(e){for(var t=e.images,n=0;n<t.length;++n)t[n]&&_(t[n]),t[n]=null;he.push(e)}function C(){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=U[t.min],0<=ae.indexOf(e.minFilter)&&!("faces"in t)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=R[t.mag]);var n=e.wrapS,r=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?n=r=P[i]:Array.isArray(i)&&(n=P[i[0]],r=P[i[1]])}else"wrapS"in t&&(n=P[t.wrapS]),"wrapT"in t&&(r=P[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=I[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 z(t){f.call(this),this.mipmask=0,this.internalformat=6408,this.id=ve++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new C,o.profile&&(this.stats={size:0})}function L(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function B(){var t=be[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),be[r]=null),e.deleteTexture(n),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete me[t.id],a.textureCount--}var I={"don't care":4352,"dont care":4352,nice:4354,fast:4353},P={repeat:10497,clamp:33071,mirror:33648},R={nearest:9728,linear:9729},U=H({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},R),W={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},G={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},Q={};t.ext_srgb&&(G.srgb=35904,G.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&&(H(G,{depth:6402,"depth stencil":34041}),H(N,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&H(Q,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&H(Q,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&H(Q,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(Q["rgb etc1"]=36196);var $=Array.prototype.slice.call(e.getParameter(34467));Object.keys(Q).forEach(function(e){var t=Q[e];0<=$.indexOf(t)&&(G[e]=t)});var J=Object.keys(G);n.textureFormats=J;var Z=[];Object.keys(G).forEach(function(e){Z[G[e]]=e});var ee=[];Object.keys(N).forEach(function(e){ee[N[e]]=e});var te=[];Object.keys(R).forEach(function(e){te[R[e]]=e});var ne=[];Object.keys(U).forEach(function(e){ne[U[e]]=e});var re=[];Object.keys(P).forEach(function(e){re[P[e]]=e});var ie=J.reduce(function(e,t){var n=G[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},{}),de=[],he=[],ve=0,me={},ge=n.maxTextureUnits,be=Array(ge).map(function(){return null});return H(z.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var n=0;n<ge;++n){var r=be[n];if(r){if(0<r.bindCount)continue;r.unit=-1}be[n]=this,t=n;break}o.profile&&a.maxTextureUnits<t+1&&(a.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)}}),o.profile&&(a.getTotalTextureSize=function(){var e=0;return Object.keys(me).forEach(function(t){e+=me[t].stats.size}),e}),{create2D:function(t,n){function r(e,t){var n=i.texInfo;C.call(n);var a=j();return"number"==typeof e?E(a,0|e,"number"==typeof t?0|t:0|e):e?(O(n,e),D(a,e)):E(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,L(i),T(a,3553),F(n,3553),B(),S(a),o.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,n.genMipmaps,!1)),r.format=Z[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 z(3553);return me[i.id]=i,a.textureCount++,r(t,n),r.subimage=function(e,t,n,a){t|=0,n|=0,a|=0;var o=g();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,L(i),h(o,3553,t,n,a),B(),_(o),r},r.resize=function(t,n){var a=0|t,f=0|n||a;if(a===i.width&&f===i.height)return r;r.width=i.width=a,r.height=i.height=f,L(i);for(var u,s=i.channels,c=i.type,l=0;i.mipmask>>l;++l){var p=a>>l,d=f>>l;if(!p||!d)break;u=q.zero.allocType(c,p*d*s),e.texImage2D(3553,l,i.format,p,d,0,i.format,i.type,u),u&&q.zero.freeType(u)}return B(),o.profile&&(i.stats.size=k(i.internalformat,i.type,a,f,!1,!1)),r},r._reglType="texture2d",r._texture=i,o.profile&&(r.stats=i.stats),r.destroy=function(){i.decRef()},r},createCube:function(t,n,r,i,f,u){function l(e,t,n,r,i,a){var f,u=p.texInfo;for(C.call(u),f=0;6>f;++f)v[f]=j();if("number"!=typeof e&&e){if("object"==typeof e)if(t)D(v[0],e),D(v[1],t),D(v[2],n),D(v[3],r),D(v[4],i),D(v[5],a);else if(O(u,e),c(p,e),"faces"in e)for(e=e.faces,f=0;6>f;++f)s(v[f],p),D(v[f],e[f]);else for(f=0;6>f;++f)D(v[f],e)}else for(e=0|e||1,f=0;6>f;++f)E(v[f],e,e);for(s(p,v[0]),p.mipmask=u.genMipmaps?(v[0].width<<1)-1:v[0].mipmask,p.internalformat=v[0].internalformat,l.width=v[0].width,l.height=v[0].height,L(p),f=0;6>f;++f)T(v[f],34069+f);for(F(u,34067),B(),o.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=Z[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],f=0;6>f;++f)S(v[f]);return l}var p=new z(34067);me[p.id]=p,a.cubeCount++;var v=Array(6);return l(t,n,r,i,f,u),l.subimage=function(e,t,n,r,i){n|=0,r|=0,i|=0;var a=g();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,L(p),h(a,34069+e,n,r,i),B(),_(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,L(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(),o.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,o.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;t<ge;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),be[t]=null;Y(me).forEach(M),a.cubeCount=0,a.textureCount=0},getTexture:function(e){return null},restore:function(){Y(me).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 E(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++,_[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function v(e){e.colorAttachments.forEach(f),f(e.depthAttachment),f(e.stencilAttachment),f(e.depthStencilAttachment)}function m(t){e.deleteFramebuffer(t.framebuffer),t.framebuffer=null,a.framebufferCount--,delete _[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.next.framebuffer:null),y.cur=y.next,e.getError()}function b(e,t){function n(e,t){var i,a=0,o=0,f=!0,s=!0;i=null;var d=!0,h="rgba",m="uint8",b=1,y=null,A=null,k=null,_=!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&&(b=0|e.colorCount),"colorTexture"in e&&(d=!!e.colorTexture,h="rgba4"),"colorType"in e&&(m=e.colorType,!d)&&("half float"===m||"float16"===m?h="rgba16f":"float"!==m&&"float32"!==m||(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.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 E=null,D=null,T=null,j=null;if(Array.isArray(i))E=i.map(c);else if(i)E=[c(i)];else for(E=Array(b),i=0;i<b;++i)E[i]=l(a,o,d,h,m);for(a=a||E[0].width,o=o||E[0].height,y?D=c(y):f&&!s&&(D=l(a,o,_,"depth","uint32")),A?T=c(A):s&&!f&&(T=l(a,o,!1,"stencil","uint8")),k?j=c(k):!y&&!A&&s&&f&&(j=l(a,o,_,"depth stencil","depth stencil")),f=null,i=0;i<E.length;++i)u(E[i]),E[i]&&E[i].texture&&(s=be[E[i].texture._texture.format]*ye[E[i].texture._texture.type],null===f&&(f=s));return u(D),u(T),u(j),v(r),r.width=a,r.height=o,r.colorAttachments=E,r.depthAttachment=D,r.stencilAttachment=T,r.depthStencilAttachment=j,n.color=E.map(p),n.depth=p(D),n.stencil=p(T),n.depthStencil=p(j),n.width=r.width,n.height=r.height,g(r),n}var r=new h;return a.framebufferCount++,n(e,t),H(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(){m(r),v(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,_={};return H(y,{getFramebuffer:function(e){return"function"==typeof e&&"framebuffer"===e._reglType&&(e=e._framebuffer)instanceof h?e:null},create:b,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]=b(a)}return H(t,{width:o,height:o,color:e})}var n=Array(6);return t(e),H(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(){Y(_).forEach(m)},restore:function(){Y(_).forEach(function(t){t.framebuffer=e.createFramebuffer(),g(t)})}})}function D(){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 T(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);Y(s).forEach(t),s={},Y(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 j(e,t,n,r,i,a,o){function f(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 V(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=f(e)}),n}(e):f(e)}}function S(e){return Array.prototype.slice.call(e)}function C(e){return S(e).join("")}function O(){function e(){var e=[],t=[];return H(function(){e.push.apply(e,S(arguments))},{def:function(){var r="v"+n++;return t.push(r),0<arguments.length&&(e.push(r,"="),e.push.apply(e,S(arguments)),e.push(";")),r},toString:function(){return C([0<t.length?"var "+t+";":"",C(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 H(function(){n.apply(n,S(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]=H(a,{arg:r,toString:function(){return C(["function(",i.join(),"){",f(),"}"])}})},scope:t,cond:function(){var e=C(arguments),n=t(),r=t(),i=n.toString,a=r.toString;return H(n,{then:function(){return n.apply(n,S(arguments)),this},else:function(){return r.apply(r,S(arguments)),this},toString:function(){var t=a();return t&&(t="else{"+t+"}"),C(["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=C(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)||V(e)||u(e)}function z(e){return e.sort(function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1})}function L(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 L(!1,!1,!1,e)}function I(e,t){var n=e.type;return 0===n?new L(!0,1<=(n=e.data.length),2<=n,t):4===n?new L((n=e.data).thisDep,n.contextDep,n.propDep,t):new L(3===n,2===n,1===n,t)}function P(e,t,n,r,i,o,f,u,s,c,l,p,d,h,v){function g(e){return e.replace(".","_")}function b(e,t,n){var r=g(e);re.push(e),te[r]=ee[r]=!!n,ie[r]=t}function y(e,t,n){var r=g(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 K),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 I(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 I(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 L(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 o=i[e];return I(o,function(e,n){var r=e.invoke(n,o);return t&&(e.OFFSET=r),r})}return t&&a?M(function(e,t){return e.OFFSET="0",0}):null}var r=e.static,i=e.dynamic,a=function(){if("elements"in r){var e=r.elements;F(e)?e=o.getElements(o.create(e,!0)):e&&(e=o.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 I(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:a,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 I(t,function(e,n){var r=e.constants.primTypes,i=e.invoke(n,t);return n.def(r,"[",i,"]")})}return a?B(a)?a.value?M(function(e,t){return t.def(e.ELEMENTS,".primType")}):M(function(){return 4}):new L(a.thisDep,a.contextDep,a.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 I(t,function(e,n){return e.invoke(n,t)})}return a?B(a)?a?f?new L(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 L(a.thisDep||f.thisDep,a.contextDep||f.contextDep,a.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,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 K;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("constant"in n){var u=n.constant;f.buffer="null",f.state=2,"number"==typeof u?f.x=u:xe.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=$[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]=I(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 K;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[xe[0]],"=",i,".constant;",xe.slice(1).map(function(e){return u[e]}).join("="),"=0;","}else{",xe.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 E(e,t,n,r,i){var o=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 L(!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=I(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 L(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 L(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,o),u=k(e),s=function(e,t){var n=e.static,r=e.dynamic,i={};return re.forEach(function(e){function t(t,a){if(e in n){var f=t(n[e]);i[o]=M(function(){return f})}else if(e in r){var u=r[e];i[o]=I(u,function(e,t){return a(e,t,e.invoke(t,u))})}}var o=g(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 ke[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[Ae["srcRGB"in e?e.srcRGB:e.src],Ae["dstRGB"in e?e.dstRGB:e.dst],Ae["srcAlpha"in e?e.srcAlpha:e.src],Ae["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 a(4,function(t){return+e[t]})},function(e,t,n){return a(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[ke[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,_e[t.fail||"keep"],_e[t.zfail||"keep"],_e[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 Ee[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 a(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=g("scissor.box")])&&(s[l]=f),(o={framebuffer:o,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=I(i,function(e,t){return e.invoke(t,i)})}return t}(e),o.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 o=r._reglType;"texture2d"===o||"textureCube"===o?t=M(function(e){return e.link(r)}):"framebuffer"!==o&&"framebufferCube"!==o||(t=M(function(e){return e.link(r.color[0])}))}else m(r)&&(t=M(function(e){return e.global.def("[",a(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]=I(t,function(e,n){return e.invoke(n,t)})}),i}(n),o.attributes=_(t),o.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]=I(t,function(e,n){return e.invoke(n,t)})}),r}(r),o}function D(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 T(e,t,n,r){var i,a=(f=e.shared).gl,o=f.framebuffer;Z&&(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);"),Z&&t(i,".drawBuffersWEBGL(",f,"[",e,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",36160,",null);"),Z&&t(i,".drawBuffersWEBGL(",u,");"),t("}",o,".cur=",e,";"),r||t("}")}function j(e,t,n){var r=e.shared,i=r.gl,o=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=g(t))in n.state))if(t in f){r=f[t],l=o[t];var p=a(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 S(e,t,n,r){var i=e.shared,a=e.current,o=i.current,f=i.gl;z(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(m(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 C(e,t){J&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function P(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(),"=",v,".getNumPendingQueries();"):e(v,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",a(),"-",s,";"),h&&(r?e(v,".pushScopeStats(",c,",",v,".getNumPendingQueries(),",p,");"):e(v,".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,v=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 R(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(",xe.map(function(e,t){return c+"."+e+"!=="+p[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",p,");",xe.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(De))return;var s=e.scopeAttrib(f);o={},Object.keys(new K).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 H(e,n,r,i,o){for(var f,u=e.shared,s=u.gl,c=0;c<i.length;++c){var l,p=(v=i[c]).name,d=v.info.type,h=r.uniforms[p],v=e.link(v)+".location";if(h){if(!o(h))continue;if(B(h)){if(p=h.value,35678===d||35680===d)n(s,".uniform1i(",v,",",(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(",v,",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,"(",v,",",m(p)?Array.prototype.slice.call(p):p,");")}continue}l=h.append(e,n)}else{if(!o(De))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(",v,",",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,"(",v,","),"M"===f.charAt(0)){v=Math.pow(d-35674+2,2);var g=e.global.def("new Float32Array(",v,")");n("false,(Array.isArray(",l,")||",l," instanceof Float32Array)?",l,":(",a(v,function(e){return g+"["+e+"]="+l+"["+e+"]"}),",",g,")")}else n(1<p?a(p,function(e){return l+"["+e+"]"}):l);n(");")}}function U(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,m,g,v+"<<(("+g+"-5121)>>1)",f],");")}function t(){n(u,".drawArraysInstancedANGLE(",[h,v,m,f],");")}d?b?e():(n("if(",d,"){"),e(),n("}else{"),t(),n("}")):t()}function o(){function e(){n(c+".drawElements("+[h,m,g,v+"<<(("+g+"-5121)>>1)"]+");")}function t(){n(c+".drawArrays("+[h,v,m]+");")}d?b?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"),v=i("offset"),m=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 m){if(0===m)return}else n("if(",m,"){"),n.exit("}");J&&(f=i("instances"),u=e.instancing);var g=d+".type",b=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 G(e,t,n,r){C(e,t),R(e,t,n,r.attributes,function(){return!0}),H(e,t,n,r.uniforms,function(){return!0}),U(e,t,t,n)}function q(e,t,n,r){function i(){return!0}e.batchId="a1",C(e,t),R(e,t,n,r.attributes,i),H(e,t,n,r.uniforms,i),U(e,t,t,n)}function Q(e,t,n,r){function i(e){return e.contextDep&&o||e.propDep}function a(e){return!i(e)}C(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&&D(e,c,n.context),n.needsFramebuffer&&T(e,c,n.framebuffer),S(e,c,n.state,i),n.profile&&i(n.profile)&&P(e,c,n,!1,!0),r?(R(e,s,n,r.attributes,a),R(e,c,n,r.attributes,i),H(e,s,n,r.uniforms,a),H(e,c,n,r.uniforms,i),U(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 V(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;D(e,i,n.context),n.framebuffer&&n.framebuffer.append(e,i),z(Object.keys(n.state)).forEach(function(t){var r=n.state[t].append(e,i);m(r)?r.forEach(function(n,r){i.set(e.next[t],"["+r+"]",n)}):i.set(a.next,"."+t,r)}),P(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 K).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 Y(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!m(e)){for(var t=Object.keys(e),n=0;n<t.length;++n)if(W.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(W.isDynamic(n))"function"==typeof n&&(n=r[t]=W.unbox(n)),t=I(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 W.DynamicVariable(4,{thisDep:o,contextDep:f,propDep:u,ref:s,append:function(e,t){a.forEach(function(n){var i=r[n];W.isDynamic(i)&&(i=e.invoke(t,i),t(s,".",n,"=",i,";"))})}}),delete t.static[n]}}var K=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,Z=n.webgl_draw_buffers,ee={dirty:!0,profile:v.profile},te={},re=[],ie={},ae={};b("dither",3024),b("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]),b("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]),b("cull.enable",2884),y("cull.face","cullFace",1029),y("frontFace","frontFace",2305),y("lineWidth","lineWidth",1),b("polygonOffset.enable",32823),y("polygonOffset.offset","polygonOffset",[0,0]),b("sample.alpha",32926),b("sample.enable",32928),y("sample.coverage","sampleCoverage",[1,!1]),b("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]),b("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:o,buffer:i,shader:l,attributes:c.state,uniforms:s,framebuffer:u,extensions:n,timer:h,isBufferArgs:F},fe={primTypes:ne,compareFuncs:ke,blendFuncs:Ae,blendEquations:X,stencilOps:_e,glTypes:$,orientationType:Ee};Z&&(fe.backBuffer=[1029],fe.drawBuffer=a(r.maxDrawbuffers,function(e){return 0===e?[0]:a(e,function(e){return 36064+e})}));var ue=0;return{next:te,current:ee,procs:function(){var e=x(),t=e.proc("poll"),n=e.proc("refresh"),i=e.block();t(i),n(i);var o,f=e.shared,u=f.gl,s=f.next,c=f.current;i(c,".dirty=false;"),T(e,t),T(e,n,null,!0),J&&(o=e.link(J));for(var l=0;l<r.maxAttributes;++l){var p=n.def(f.attributes,"[",l,"]"),d=e.cond(p,".buffer");d.then(u,".enableVertexAttribArray(",l,");",u,".bindBuffer(",34962,",",p,".buffer.buffer);",u,".vertexAttribPointer(",l,",",p,".size,",p,".type,",p,".normalized,",p,".stride,",p,".offset);").else(u,".disableVertexAttribArray(",l,");",u,".vertexAttrib4f(",l,",",p,".x,",p,".y,",p,".z,",p,".w);",p,".buffer=null;"),n(d),J&&n(o,".vertexAttribDivisorANGLE(",l,",",p,".divisor);")}return Object.keys(ie).forEach(function(r){var a=ie[r],o=i.def(s,".",r),f=e.block();f("if(",o,"){",u,".enable(",a,")}else{",u,".disable(",a,")}",c,".",r,"=",o,";"),n(f),t("if(",o,"!==",c,".",r,"){",f,"}")}),Object.keys(ae).forEach(function(r){var o,f,l=ae[r],p=ee[r],d=e.block();d(u,".",l,"("),m(p)?(l=p.length,o=e.global.def(s,".",r),f=e.global.def(c,".",r),d(a(l,function(e){return o+"["+e+"]"}),");",a(l,function(e){return f+"["+e+"]="+o+"["+e+"];"}).join("")),t("if(",a(l,function(e){return o+"["+e+"]!=="+f+"["+e+"]"}).join("||"),"){",d,"}")):(o=i.def(s,".",r),f=i.def(c,".",r),d(o,");",c,".",r,"=",o,";"),t("if(",o,"!==",f,"){",d,"}")),n(d)}),e.compile()}(),compile:function(e,t,n,r,i){var a=x();return a.stats=a.link(i),Object.keys(t.static).forEach(function(e){Y(a,t,e)}),we.forEach(function(t){Y(a,e,t)}),n=E(e,t,n,r),function(e,t){var n=e.proc("draw",1);C(e,n),D(e,n,t.context),T(e,n,t.framebuffer),j(e,n,t),S(e,n,t.state),P(e,n,t,!1,!0);var r=t.shader.progVar.append(e,n);if(n(e.shared.gl,".useProgram(",r,".program);"),t.shader.program)G(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(G,e,t,n,1)}),"(",r,");",o,".call(this,a0);"))}0<Object.keys(t.state).length&&n(e.shared.current,".dirty=true;")}(a,n),V(a,n),function(e,t){function n(e){return e.contextDep&&i||e.propDep}var r=e.proc("batch",2);e.batchId="0",C(e,r);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(D(e,r,t.context),a=!1);var o=!1;if((f=t.framebuffer)?(f.propDep?i=o=!0:f.contextDep&&i&&(o=!0),o||T(e,r,f)):T(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),j(e,r,t),S(e,r,t.state,function(e){return!n(e)}),t.profile&&n(t.profile)||P(e,r,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=o,(a=t.shader.progVar).contextDep&&i||a.propDep)Q(e,r,t,null);else if(a=a.append(e,r),r(e.shared.gl,".useProgram(",a,".program);"),t.shader.program)Q(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(Q,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 R(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}var H=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;++r)e[n[r]]=t[n[r]];return e},U=0,W={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},G="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},q=f();q.zero=f();var Q=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter(34047));var r=1,i=1;t.webgl_draw_buffers&&(r=e.getParameter(34852),i=e.getParameter(36063));var a=!!t.oes_texture_float;if(a){a=e.createTexture(),e.bindTexture(3553,a),e.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var o=e.createFramebuffer();if(e.bindFramebuffer(36160,o),e.framebufferTexture2D(36160,36064,3553,a,0),e.bindTexture(3553,null),36053!==e.checkFramebufferStatus(36160))a=!1;else{e.viewport(0,0,1,1),e.clearColor(1,0,0,1),e.clear(16384);var f=q.allocType(5126,4);e.readPixels(0,0,1,1,6408,5126,f),e.getError()?a=!1:(e.deleteFramebuffer(o),e.deleteTexture(a),a=1===f[0]),q.freeType(f)}}return f=!0,f=e.createTexture(),o=q.allocType(5121,36),e.activeTexture(33984),e.bindTexture(34067,f),e.texImage2D(34069,0,6408,3,3,0,6408,5121,o),q.freeType(o),e.bindTexture(34067,null),e.deleteTexture(f),f=!e.getError(),{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),readFloat:a,npotTextureCube:f}},V=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},Y=function(e){return Object.keys(e).map(function(t){return e[t]})},K={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||q.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:s(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 c=n[r+1],l=n[r+2];for(n=n[r+3],f=0;f<u;++f)s(t[f],c,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},$={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},J={dynamic:35048,stream:35040,static:35044},Z=K.flatten,ee=K.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=g("HTMLCanvasElement"),se=g("CanvasRenderingContext2D"),ce=g("ImageBitmap"),le=g("HTMLImageElement"),pe=g("HTMLVideoElement"),de=Object.keys(X).concat([ue,se,ce,le,pe]),he=[];he[5121]=1,he[5126]=4,he[36193]=2,he[5123]=2,he[5125]=4;var ve=[];ve[32854]=2,ve[32855]=2,ve[36194]=2,ve[34041]=4,ve[33776]=.5,ve[33777]=.5,ve[33778]=1,ve[33779]=1,ve[35986]=.5,ve[35987]=1,ve[34798]=1,ve[35840]=.5,ve[35841]=.25,ve[35842]=.5,ve[35843]=.25,ve[36196]=.5;var me=[];me[32854]=2,me[32855]=2,me[36194]=2,me[33189]=2,me[36168]=1,me[34041]=4,me[35907]=4,me[34836]=16,me[34842]=8,me[34843]=6;var ge=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=me[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=me[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(){Y(c).forEach(o)},restore:function(){Y(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)}}},be=[];be[6408]=4,be[6407]=3;var ye=[];ye[5121]=1,ye[5126]=4,ye[36193]=2;var xe=["x","y","z","w"],we="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ae={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},ke={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},_e={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Ee={cw:2304,ccw:2305},De=new L(!1,!1,!1,function(){});return function(e){function t(){if(0===K.length)A&&A.update(),Z=null;else{Z=N.next(t),l();for(var e=K.length-1;0<=e;--e){var n=K[e];n&&n(O,null,0)}m.flush(),A&&A.update()}}function n(){!Z&&0<K.length&&(Z=N.next(t))}function r(){Z&&(N.cancel(t),Z=null)}function a(e){e.preventDefault(),r(),X.forEach(function(e){e()})}function o(e){m.getError(),b.restore(),B.restore(),z.restore(),M.restore(),I.restore(),U.restore(),A&&A.restore(),q.procs.refresh(),n(),$.forEach(function(e){e()})}function f(e){function t(e){var t={},n={};return Object.keys(e).forEach(function(r){var i=e[r];W.isDynamic(i)?n[r]=W.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=H({},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 H(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&&(m.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=16384),"depth"in t&&(m.clearDepth(+t.depth),n|=256),"stencil"in t&&(m.clearStencil(0|t.stencil),n|=1024),m.clear(n)}function s(e){return K.push(e),n(),{cancel:function(){var t=R(K,e);K[t]=function e(){var t=R(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]=m.drawingBufferWidth,O.viewportHeight=O.framebufferHeight=O.drawingBufferHeight=e[3]=t[3]=m.drawingBufferHeight}function l(){O.tick+=1,O.time=v(),c(),q.procs.poll()}function p(){c(),q.procs.refresh(),A&&A.update()}function v(){return(G()-k)/1e3}if(!(e=i(e)))return null;var m=e.gl,g=m.getContextAttributes();m.isContextLost();var b=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)})}}}(m,e);if(!b)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=b.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=G(),S=m.drawingBufferWidth,C=m.drawingBufferHeight,O={tick:0,time:0,viewportWidth:S,viewportHeight:C,framebufferWidth:S,framebufferHeight:C,drawingBufferWidth:S,drawingBufferHeight:C,pixelRatio:e.pixelRatio},F=Q(m,w),z=(S=function(e,t,n,r){for(e=n.maxAttributes,t=Array(e),n=0;n<e;++n)t[n]=new D;return{Record:D,scope:{},state:t}}(m,w,F),d(m,x,e,S)),L=h(m,w,z,x),B=T(m,y,x,e),M=_(m,w,F,function(){q.procs.poll()},O,x,e),I=ge(m,w,0,x,e),U=E(m,w,F,M,I,x),q=P(m,y,w,F,z,L,0,U,{},S,B,{elements:null,primitive:4,count:-1,offset:0,instances:-1},O,A,e),V=(y=j(m,U,q.procs.poll,O),q.next),Y=m.canvas,K=[],X=[],$=[],J=[e.onDestroy],Z=null;Y&&(Y.addEventListener("webglcontextlost",a,!1),Y.addEventListener("webglcontextrestored",o,!1));var ee=U.setFBO=f({framebuffer:W.define.call(null,1,"framebuffer")});return p(),g=H(f,{clear:function(e){if("framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;6>t;++t)ee(H({framebuffer:e.framebuffer.faces[t]},e),u);else ee(e,u);else u(0,e)},prop:W.define.bind(null,1),context:W.define.bind(null,2),this:W.define.bind(null,3),draw:f({}),buffer:function(e){return z.create(e,34962,!1,!1)},elements:function(e){return L.create(e,!1)},texture:M.create2D,cube:M.createCube,renderbuffer:I.create,framebuffer:U.create,framebufferCube:U.createCube,attributes:g,frame:s,on:function(e,t){var n;switch(e){case"frame":return s(t);case"lost":n=X;break;case"restore":n=$;break;case"destroy":n=J}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(),Y&&(Y.removeEventListener("webglcontextlost",a),Y.removeEventListener("webglcontextrestored",o)),B.clear(),U.clear(),I.clear(),M.clear(),L.clear(),z.clear(),A&&A.clear(),J.forEach(function(e){e()})},_gl:m,_refresh:p,poll:function(){l(),A&&A.update()},now:v,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()},{}],13:[function(e,t,n){var r=function(){function e(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function t(e,t){for(var n=[];t>0;n[--t]=e);return n.join("")}var n=function(){return n.cache.hasOwnProperty(arguments[0])||(n.cache[arguments[0]]=n.parse(arguments[0])),n.format.call(null,n.cache[arguments[0]],arguments)};return n.object_stringify=function(e,t,r,i){var a="";if(null!=e)switch(typeof e){case"function":return"[Function"+(e.name?": "+e.name:"")+"]";case"object":if(e instanceof Error)return"["+e.toString()+"]";if(t>=r)return"[Object]";if(i&&(i=i.slice(0)).push(e),null!=e.length){a+="[";var o=[];for(var f in e)i&&i.indexOf(e[f])>=0?o.push("[Circular]"):o.push(n.object_stringify(e[f],t+1,r,i));a+=o.join(", ")+"]"}else{if("getMonth"in e)return"Date("+e+")";a+="{";o=[];for(var u in e)e.hasOwnProperty(u)&&(i&&i.indexOf(e[u])>=0?o.push(u+": [Circular]"):o.push(u+": "+n.object_stringify(e[u],t+1,r,i)));a+=o.join(", ")+"}"}return a;case"string":return'"'+e+'"'}return""+e},n.format=function(i,a){var o,f,u,s,c,l,p,d=1,h=i.length,v="",m=[];for(f=0;f<h;f++)if("string"===(v=e(i[f])))m.push(i[f]);else if("array"===v){if((s=i[f])[2])for(o=a[d],u=0;u<s[2].length;u++){if(!o.hasOwnProperty(s[2][u]))throw new Error(r('[sprintf] property "%s" does not exist',s[2][u]));o=o[s[2][u]]}else o=s[1]?a[s[1]]:a[d++];if(/[^sO]/.test(s[8])&&"number"!=e(o))throw new Error(r('[sprintf] expecting number but found %s "'+o+'"',e(o)));switch(s[8]){case"b":o=o.toString(2);break;case"c":o=String.fromCharCode(o);break;case"d":o=parseInt(o,10);break;case"e":o=s[7]?o.toExponential(s[7]):o.toExponential();break;case"f":o=s[7]?parseFloat(o).toFixed(s[7]):parseFloat(o);break;case"O":o=n.object_stringify(o,0,parseInt(s[7])||5);break;case"o":o=o.toString(8);break;case"s":o=(o=String(o))&&s[7]?o.substring(0,s[7]):o;break;case"u":o=Math.abs(o);break;case"x":o=o.toString(16);break;case"X":o=o.toString(16).toUpperCase()}o=/[def]/.test(s[8])&&s[3]&&o>=0?"+"+o:o,l=s[4]?"0"==s[4]?"0":s[4].charAt(1):" ",p=s[6]-String(o).length,c=s[6]?t(l,p):"",m.push(s[5]?o+c:c+o)}return m.join("")},n.cache={},n.parse=function(e){for(var t=e,n=[],r=[],i=0;t;){if(null!==(n=/^[^\x25]+/.exec(t)))r.push(n[0]);else if(null!==(n=/^\x25{2}/.exec(t)))r.push("%");else{if(null===(n=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosOuxX])/.exec(t)))throw new Error("[sprintf] "+t);if(n[2]){i|=1;var a=[],o=n[2],f=[];if(null===(f=/^([a-z_][a-z_\d]*)/i.exec(o)))throw new Error("[sprintf] "+o);for(a.push(f[1]);""!==(o=o.substring(f[0].length));)if(null!==(f=/^\.([a-z_][a-z_\d]*)/i.exec(o)))a.push(f[1]);else{if(null===(f=/^\[(\d+)\]/.exec(o)))throw new Error("[sprintf] "+o);a.push(f[1])}n[2]=a}else i|=2;if(3===i)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");r.push(n)}t=t.substring(n[0].length)}return r},n}();t.exports=r,r.sprintf=r,r.vsprintf=function(e,t){var n=t.slice();return n.unshift(e),r.apply(null,n)}},{}],14:[function(e,t,n){var r=e("glslify");t.exports=function(e){return e({vert:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n\n attribute vec2 cl;\n varying vec2 uv;\n uniform vec4 cl2uv;\n\n vec2 transform (vec2 x, vec4 t) {\n return x * t.xy + t.zw;\n}\n\n void main () {\n uv = transform(cl, cl2uv);\n gl_Position = vec4(cl, 0, 1);\n }\n "]),frag:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n varying vec2 uv;\n uniform sampler2D u, src;\n uniform vec4 uv2xy, xy2uv;\n uniform float dt;\n\n vec2 transform (vec2 x_0, vec4 t) {\n return x_0 * t.xy + t.zw;\n}\n\n uniform vec4 mouse;\nuniform vec2 duv, der1;\nuniform sampler2D vorticity;\n\nvec3 force (vec2 xy_0, vec2 uv_0, float T_0) {\n float wz = texture2D(vorticity, uv_0).x;\n float wn = texture2D(vorticity, vec2(uv_0.x, uv_0.y + duv.y)).x;\n float ws = texture2D(vorticity, vec2(uv_0.x, uv_0.y - duv.y)).x;\n float we = texture2D(vorticity, vec2(uv_0.x + duv.x, uv_0.y)).x;\n float ww = texture2D(vorticity, vec2(uv_0.x - duv.x, uv_0.y)).x;\n\n // Gradient of absolute value of omega:\n vec2 gaw = vec2(abs(we) - abs(ww), abs(wn) - abs(ws)) * der1;\n\n // Normalized:\n vec2 N = gaw / (length(gaw) + 1.0e-8);\n\n vec2 confinement = duv * vec2(N.y, -N.x) * wz;\n\n float r2 = length(xy_0 - mouse.xy);\n float spot = 1.0 / (1.0 + 50.0 * r2);\n return vec3(\n 0.0,\n T_0 * 10.0,\n 20000.0 * spot * (0.01 + 2.0 * length(mouse.zw)) - 1.0 * T_0\n ) +\n vec3(confinement * 60.0, 0.0)\n /*vec3(\n spot * mouse.zw * 100000.0,\n 0.0\n )*/\n ;\n}\n\n void main () {\n // Sample the velocity at this point:\n vec3 u = texture2D(u, uv).xyz;\n float T = u.z;\n vec2 xy = transform(uv, uv2xy);\n vec2 uvd = transform(xy - u.xy * dt, xy2uv);\n\n vec3 f = force(xy, uv, T);\n\n gl_FragColor = vec4(texture2D(src, uvd).xyz + f * dt, 1);\n }\n "]),attributes:{cl:[[-4,-4],[0,4],[4,-4]]},scissor:{enable:!0,box:{x:1,y:1,width:function(e){return e.framebufferWidth-2},height:function(e){return e.framebufferHeight-2}}},uniforms:{u:e.prop("u"),src:e.prop("src"),vorticity:e.prop("vorticity")},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{glslify:3}],15:[function(e,t,n){var r=e("glslify");t.exports=function(e){return e({vert:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n\n #pragma glslify\n\n attribute vec2 xy;\n varying vec2 uv;\n\n void main () {\n uv = xy * 0.5 + 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n "]),frag:"\n precision mediump float;\n\n varying vec2 uv;\n uniform vec2 duv;\n uniform sampler2D src;\n uniform vec2 der1;\n\n void main () {\n float vn = texture2D(src, vec2(uv.x, uv.y + duv.y)).y;\n float vs = texture2D(src, vec2(uv.x, uv.y - duv.y)).y;\n float ue = texture2D(src, vec2(uv.x + duv.x, uv.y)).x;\n float uw = texture2D(src, vec2(uv.x - duv.x, uv.y)).x;\n gl_FragColor = vec4(dot(vec2(ue - uw, vn - vs), der1), 0, 0, 1);\n }\n ",attributes:{xy:[-4,-4,0,4,4,-4]},uniforms:{src:e.prop("src")},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{glslify:3}],16:[function(e,t,n){t.exports=function(e){return e({vert:"\n precision mediump float;\n attribute vec2 cl;\n varying vec2 uv;\n void main () {\n uv = cl * 0.5 + 0.5;\n gl_Position = vec4(cl, 0, 1);\n }\n ",frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D u;\n void main () {\n vec4 color = texture2D(u, uv) * 0.05 + 0.5;\n gl_FragColor = vec4(\n color.x * color.z,\n color.z - 0.5,\n color.y * color.z,\n 1.0\n );\n }\n ",attributes:{cl:[-4,-4,0,4,4,-4]},uniforms:{u:function(e,t){return t.src.u0}},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{}],17:[function(e,t,n){t.exports=function(e,t){var n=t.n[0],r=t.n[1];function i(n,r){return e.framebuffer({color:e.texture({type:t.type,mag:"linear",min:"linear",width:n,height:r})})}return{u0:i(n,r),u1:i(n,r),u2:i(n,r),phi0:i(n,r),phi1:i(n,r),div:i(n,r)}}},{}],18:[function(e,t,n){var r=document.createElement("canvas");r.width=384,r.height=384,r.style.width="768px",r.style.height="768px",document.body.appendChild(r),e("insert-css")("\nhtml, body {\n margin: 0;\n padding: 0;\n text-align: center;\n}\nbody {\n background-color: black;\n}\ncanvas {\n position: relative;\n top: 50vh;\n transform: translate(0, -50%);\n}\n");e("regl")({canvas:r,pixelRatio:1,extensions:["oes_texture_half_float","oes_texture_half_float_linear"],optionalExtensions:["oes_texture_float","oes_texture_float_linear"],onDone:e("fail-nicely")(function(t){var n=-1!==t.limits.extensions.indexOf("oes_texture_float"),r=-1!==t.limits.extensions.indexOf("oes_texture_float_linear"),i=e("./swap"),a=e("./advect")(t),o=e("./relax")(t),f=(e("./log")(t),e("./draw")(t)),u=e("./divergence")(t),s=e("./vorticity")(t),c=e("./project")(t),l=[384,384],p=e("./grid")(t,{n:l,type:n&&r?"float":"half float"}),d=e("./uniforms")(t,{n:l,xrange:[-1,1],yrange:[-1,1],dt:.001}),h=(e("./lines")(t,{n:l}),e("./initialize")(t,{u:"vec4 f(vec2 xy) {\n float r = length(xy);\n return vec4(exp(-r * r * 50.0), 0.0, 0.0, 1.0);\n }",T:"vec4 f(vec2 xy) {\n vec2 cen = vec2(1.0, 0.5);\n vec2 xrel = (xy - cen) * vec2(4.0, 4.0);\n return vec4(1.0 / (1.0 + 2.0 * dot(xrel, xrel)), 0, 0, 1);\n }"}));function v(){d(function(){s({src:p.u0,dst:p.div}),a({src:p.u0,dst:p.u1,vorticity:p.div,u:p.u0}),u({src:p.u0,dst:p.div});for(var e=0;e<15;e++)o({src:p.phi0,dst:p.phi1,div:p.div}),i(p,"phi0","phi1");c({src:p.u1,dst:p.u0,phi:p.phi0}),f({src:p})})}d(function(){h(p)}),t.frame(function(e){e.tick;v()})})})},{"./advect":14,"./divergence":15,"./draw":16,"./grid":17,"./initialize":19,"./lines":20,"./log":21,"./project":22,"./relax":23,"./swap":24,"./uniforms":25,"./vorticity":26,"fail-nicely":1,"insert-css":5,regl:12}],19:[function(e,t,n){var r=e("glslify");t.exports=function(e,t){var n,i=(t.u,n=e({vert:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n attribute vec2 cl;\n varying vec2 xy;\n uniform vec4 cl2xy;\n\n vec2 transform (vec2 x, vec4 t) {\n return x * t.xy + t.zw;\n}\n\n void main () {\n xy = transform(cl, cl2xy);\n gl_Position = vec4(cl, 0, 1);\n }\n "]),frag:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n varying vec2 xy;\n\n vec3 u0 (vec2 xy_0) {\n return vec3(0.0);\n //vec2 r = xy - vec2(0.0, -0.75);\n //float r2 = dot(r, r);\n //return vec3(0.0, 0.0, 100.0 / (1.0 + 400.0 * r2));\n}\n\n void main () {\n gl_FragColor = vec4(u0(xy), 1);\n }\n "]),attributes:{cl:[-4,-4,0,4,4,-4]},framebuffer:e.prop("dst"),depth:{enable:!1},count:3}),function(e){n({dst:e})});return function(e){i(e.u0)}}},{glslify:3}],20:[function(e,t,n){var r=e("glslify");t.exports=function(e,t){for(var n=t.n[0],i=t.n[1],a=[],o=0;o<i;o++)for(var f=0;f<n;f++)a.push([(f+.5)/n,(o+.5)/i,-1]),a.push([(f+.5)/n,(o+.5)/i,1]);return e({vert:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n\n vec2 transform (vec2 x, vec4 t) {\n return x * t.xy + t.zw;\n}\n\n attribute vec3 uv;\n uniform vec4 uv2cl, uv2xy, xy2cl;\n uniform sampler2D src;\n uniform float maxLen;\n\n void main () {\n vec2 u = texture2D(src, uv.xy).xy;\n float mag = length(u);\n u /= mag;\n u *= min(mag * 0.01, maxLen);\n vec2 xy = transform(uv.xy, uv2xy) + u * uv.z;\n vec2 cl = transform(xy, xy2cl);\n gl_Position = vec4(cl, 0, 1);\n }\n "]),frag:"\n precision mediump float;\n void main () {\n gl_FragColor = vec4(vec3(1.0), 0.4);\n }\n ",blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:1,dstAlpha:1},equation:{rgb:"add",alpha:"add"}},depth:{enable:!1},attributes:{uv:a,l:[]},uniforms:{src:e.prop("src"),maxLen:function(e,t){return 1.3/t.src.width}},primitive:"lines",count:a.length})}},{glslify:3}],21:[function(e,t,n){var r=e("ndarray"),a=e("ndarray-show");t.exports=function(e){return function(t,n,o){o=o||"xyzw";var f=t.width,u=t.height,s=void 0;t.use(function(){s=r(e.read(),[u,f,4])});var c=["x","y","z","w"];for(i=0;i<c.length;i++){var l=c[i];-1!==o.indexOf(l)&&console.log((n?n+".":"")+l+":\n"+a(s.pick(null,null,i)))}}}},{ndarray:11,"ndarray-show":10}],22:[function(e,t,n){t.exports=function(e){return e({vert:"\n precision mediump float;\n attribute vec2 cl;\n varying vec2 uv;\n void main () {\n uv = cl * 0.5 + 0.5;\n gl_Position = vec4(cl, 0, 1);\n }\n ",frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src, phi;\n uniform vec2 der1, duv;\n void main () {\n vec3 u = texture2D(src, uv).xyz;\n float phin = texture2D(phi, vec2(uv.x, uv.y + duv.y)).x;\n float phis = texture2D(phi, vec2(uv.x, uv.y - duv.y)).x;\n float phie = texture2D(phi, vec2(uv.x + duv.x, uv.y)).x;\n float phiw = texture2D(phi, vec2(uv.x - duv.x, uv.y)).x;\n gl_FragColor = vec4(\n u.xy + der1 * vec2(phie - phiw, phin - phis),\n u.z, 1\n );\n }\n ",attributes:{cl:[-4,-4,0,4,4,-4]},uniforms:{phi:e.prop("phi"),src:e.prop("src")},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{}],23:[function(e,t,n){t.exports=function(e){return e({vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = xy * 0.5 + 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n ",frag:"\n precision mediump float;\n varying vec2 uv;\n uniform vec2 duv;\n uniform sampler2D div, src;\n uniform vec3 lap;\n void main () {\n float phin = texture2D(src, vec2(uv.x, uv.y + duv.y)).x;\n float phis = texture2D(src, vec2(uv.x, uv.y - duv.y)).x;\n float phie = texture2D(src, vec2(uv.x + duv.x, uv.y)).x;\n float phiw = texture2D(src, vec2(uv.x - duv.x, uv.y)).x;\n float div = texture2D(div, uv).x;\n gl_FragColor = vec4(\n dot(lap, vec3(phie + phiw, phin + phis, -div)),\n 0, 0, 1\n );\n }\n ",attributes:{xy:[-4,-4,0,4,4,-4]},uniforms:{div:e.prop("div"),src:e.prop("src")},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{}],24:[function(e,t,n){t.exports=function(e,t,n){var r=e[n];return e[n]=e[t],e[t]=r,e}},{}],25:[function(e,t,n){var r=e("mouse-change");t.exports=function(e,t){var n=t.n[0],i=t.n[1];window.regl=e;var a=e._gl.canvas,o=[.5*a.offsetWidth,.95*a.offsetHeight],f=[0,0,0,0];function u(e,t){return[e[0]*t[0],e[1]*t[1],t[0]*e[2]+t[2],t[1]*e[3]+t[3]]}function s(e){return[1/e[0],1/e[1],-e[2]/e[0],-e[3]/e[1]]}r(function(e,t,n){o[0]=t,o[1]=n});var c=[.5,.5,.5,.5],l=[n/(n-1),i/(i-1),-.5/(n-1),-.5/(i-1)],p=t.xrange[1]-t.xrange[0],d=t.yrange[1]-t.yrange[0],h=1/(n-1),v=1/(i-1),m=p*h,g=d*v,b=.5/(m*m+g*g),y=[p,d,t.xrange[0],t.yrange[0]],x=s(c),w=s(l),A=s(y);return e({uniforms:{cl2uv:c,uv2cl:x,uv2st:l,st2uv:w,st2xy:y,xy2st:y,uv2xy:u(l,y),xy2uv:u(A,w),cl2st:u(c,l),st2cl:u(w,x),cl2xy:u(u(c,l),y),xy2cl:u(u(A,w),x),di:[h,v],duv:[1/n,1/i],h:[m,g],der1:[.5/m,.5/g],lap:[g*g*b,m*m*b,-m*m*g*g*b],mouse:function(e){var t=o[0]/a.offsetWidth*2-1,n=-(o[1]/a.offsetHeight*2-1);return f[2]*=.9,f[3]*=.9,f[2]+=(1-.9)*(t-f[0]),f[3]+=(1-.9)*(n-f[1]),f[0]=t,f[1]=n,f},dt:t.dt}})}},{"mouse-change":8}],26:[function(e,t,n){var r=e("glslify");t.exports=function(e){return e({vert:r(["\n precision mediump float;\n#define GLSLIFY 1\n\n\n #pragma glslify\n\n attribute vec2 xy;\n varying vec2 uv;\n\n void main () {\n uv = xy * 0.5 + 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n "]),frag:"\n precision mediump float;\n\n varying vec2 uv;\n uniform vec2 duv;\n uniform sampler2D src;\n uniform vec2 der1;\n\n void main () {\n float ve = texture2D(src, vec2(uv.x + duv.x, uv.y)).y;\n float vw = texture2D(src, vec2(uv.x - duv.x, uv.y)).y;\n float un = texture2D(src, vec2(uv.x, uv.y + duv.y)).x;\n float us = texture2D(src, vec2(uv.x, uv.y - duv.y)).x;\n gl_FragColor = vec4(dot(vec2(ve - vw, -(un - us)), der1), 0, 0, 1);\n }\n ",attributes:{xy:[-4,-4,0,4,4,-4]},uniforms:{src:e.prop("src")},framebuffer:e.prop("dst"),depth:{enable:!1},count:3})}},{glslify:3}]},{},[18]); |