mirror of
https://github.com/rreusser/rreusser.github.io.git
synced 2026-01-18 16:13:07 +00:00
1 line
120 KiB
JavaScript
1 line
120 KiB
JavaScript
!function(){return function e(t,r,n){function i(o,f){if(!r[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=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return i(r||e)},c,c.exports,e,t,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}}()({1:[function(e,t,r){"use strict";var n=e("h");t.exports=function(e,t){return t=t||{},function(r,i){if(!r)return e&&e(i);if(r instanceof Error)r=r.name+": "+r.message;else if("string"!=typeof r)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},h={"font-family":s},d={"font-family":s,"max-width":"640px","margin-left":"auto","margin-right":"auto","line-height":"1.4",padding:"0 15px"};document.body.appendChild(n("div",{style:p},[n("div",{style:{transform:"translate(0, -50%)","margin-top":"50vh"}},[n("h1",u,{style:h}),n("p",r,{style:d})])]))}}},{h:13}],2:[function(e,t,r){var n=e("./lib/index");t.exports=function(e){for(var t=n(),r=0;r<e.length;r++)t(e[r]);return t(null)}},{"./lib/index":4}],3:[function(e,t,r){var n,i,a,o,f={nud:function(){return this.children&&this.children.length?this:v("unexpected")()},led:v("missing operator")},u={};function s(){return this}function c(e,t){var r=u[e];return t=t||0,r?t>r.lbp&&(r.lbp=t):((r=Object.create(f)).id=e,r.lbp=t,u[e]=r),r}function l(e){var t,r=i;for(y(),t=r.nud();e<i.lbp;)r=i,y(),t=r.led(t);return t}function p(e,t,r){c(e,t).led=r||function(e){return this.children=[e,l(t)],this.type="binary",this}}function h(e,t,r){var n=c(e,t);return n.led=r||function(e){return this.children=[e,l(t-1)],this.type="binary",this},n}function d(e,t){var r=c(e);return r.nud=t||function(){return this.children=[l(70)],this.type="unary",this},r}function g(e){c(e,150).led=function(e){return this.children=[e],this.type="suffix",this}}function m(e){return h(e,10,function(e){return this.children=[e,l(9)],this.assignment=!0,this.type="assign",this})}function y(e){var t,r,f,c;if(e&&i.data!==e)return n.unexpected("expected `"+e+"`, got `"+i.data+"`");if(!(o>=a.length)){if(r=(t=a[o++]).data,"ident"===(f=t.type))f=(c=n.scope.find(r)||n.create_node()).type;else if("builtin"===f)c=u["(builtin)"];else if("keyword"===f)c=u["(keyword)"];else if("operator"===f){if(!(c=u[r]))return n.unexpected("unknown operator `"+r+"`")}else{if("float"!==f&&"integer"!==f)return n.unexpected("unexpected token.");f="literal",c=u["(literal)"]}return c&&(c.nud||(c.nud=s),c.children||(c.children=[])),(c=Object.create(c)).token=t,c.type=f,c.data||(c.data=r),i=c}i=u["(end)"]}function v(e){return function(){return n.unexpected(e)}}c("(ident)").nud=s,c("(keyword)").nud=s,c("(builtin)").nud=s,c("(literal)").nud=s,c("(end)"),c(":"),c(";"),c(","),c(")"),c("]"),c("}"),h("&&",30),h("||",30),p("|",43),p("^",44),p("&",45),p("==",46),p("!=",46),p("<",47),p("<=",47),p(">",47),p(">=",47),p(">>",48),p("<<",48),p("+",50),p("-",50),p("*",60),p("/",60),p("%",60),p("?",20,function(e){return this.children=[e,l(0),(y(":"),l(0))],this.type="ternary",this}),p(".",80,function(e){return i.type="literal",n.fake(i),this.children=[e,i],y(),this}),p("[",80,function(e){return this.children=[e,l(0)],this.type="binary",y("]"),this}),p("(",80,function(e){if(this.children=[e],this.type="call",")"!==i.data)for(;this.children.push(l(0)),","===i.data;)y(",");return y(")"),this}),d("-"),d("+"),d("!"),d("~"),d("defined"),d("(",function(){return this.type="group",this.children=[l(0)],y(")"),this}),d("++"),d("--"),g("++"),g("--"),m("="),m("+="),m("-="),m("*="),m("/="),m("%="),m("&="),m("|="),m("^="),m(">>="),m("<<="),t.exports=function(e,t){var r;if(n=e,o=0,(a=t).length){if(y(),(r=l(0)).parent=n[0],function e(t){n.unshift(t,!1);for(var r=0,i=t.children.length;r<i;++r)e(t.children[r]);n.shift()}(r),o<a.length)throw new Error("did not use all tokens");r.parent.children=[r]}}},{}],4:[function(e,t,r){t.exports=function(){var e,t,r,f,w,k,q,G,Q,X,Y,J,Z,K=Se(c),$=Se(s),ee=Se(g),te=Se(x),re=Se(u),ne=(Se(A),Se(p)),ie=Se(h),ae=Se(m),oe=Se(v),fe=Se(y),ue=Se(D),se=Se(S),ce=Se(O),le=arguments.length?[].slice.call(arguments):[],pe=!1,he=[],de=[],ge=[],me=[],ye=!1;return he.shift=function(){var e=[].shift.call(this),t=le[this.length],r=!1;if(o){for(var n="",i=0,a=this.length;i<a;++i)n+=" |";console.log(n,"/"+e.type)}return le.length?"function"==typeof le[0]?r=le[0](e):void 0!==t&&(r=t.test?t.test(e.type):t===e.type):r=!0,r&&!ye&&de.push(e),Z=e.parent,e},he.unshift=function(e,t){e.parent=he[0];var r=[].unshift.call(this,e);if(t=void 0===t||t,o){for(var n="",i=0,a=this.length-1;i<a;++i)n+=" |";console.log(n,"\\"+e.type,e.token.data)}return t&&Z!==e&&Z.children.push(e),Z=e,r},he.fake=function(e){he.unshift(e),he.shift()},he.unexpected=Be,he.scope=new i(he),he.create_node=function(){var e=W(u,J);return e.parent=ve.program,e},e=Re(Le("struct","keyword"),function(){return"{"===J.data?(he.fake(W(u,{data:"",position:J.position,type:"ident"})),a):(e=J.data,ze("ident")&&(he.unshift(re()),he.scope.define(e),a));var e},function(){return he.scope.enter(),a},Le("{"),function(){return"preprocessor"===J.type?(he.fake(Ce()),void ge.shift()):"}"===J.data?(he.scope.exit(),ge.shift(),he.shift()):void(";"!==J.data?he.unshift(Oe(U)):ge.shift())}),t=Re(function(){return ge.shift(),a},function(){return ze("keyword",["lowp","mediump","highp"])&&(he.unshift(Pe()),a)},function(){return he.unshift(Pe()),a},function(){return he.shift()}),r=Re(Le("["),Ue("]"),Le("]"),function(){return he.shift()}),f=Re(Le("for","keyword"),Le("("),function(){var e;if("ident"===J.type){if((e=he.scope.find(J.data))||(e=he.create_node()),"struct"===e.parent.type)return he.unshift(Oe(R)),a}else if("builtin"===J.type||"keyword"===J.type)return he.unshift(Oe(R)),a;return Ue(";")()},Le(";"),Ue(";"),Le(";"),Ue(")"),Le(")"),Ve(3),Ne(),Le("}"),He()),w=Re(Le("if","keyword"),Le("("),Ue(")"),Le(")"),Ve(3),Ne(),Le("}"),function(){return"else"===J.data?(ge.shift(),he.unshift($()),a):He()()},He()),k=Re(Le("return","keyword"),function(){return";"===J.data?a:(he.unshift(Me(";")),a)},function(){ge.shift(),He()()}),q=Re(Le("while","keyword"),Le("("),Ue(")"),Le(")"),Ve(3),Ne(),Le("}"),He()),G=Re(Le("do","keyword"),Ve(3),Ne(),Le("}"),Le("while","keyword"),Le("("),Ue(")"),Le(")"),He()),Q=Re(function(){for(var e=1,t=he.length;e<t;++e)if(he[e].mode===p)return Be("function definition is not allowed within another function");return a},function(){if(ze("ident")){var e=J.data,t=he.scope.find(e);return he.unshift(re()),he.scope.define(e),he.scope.enter(t?t.scope:null),a}},Le("("),function(){return he.unshift(ie()),a},Le(")"),function(){return";"===J.data?(he.scope.exit(),he.shift(),he.shift()):a},Le("{"),Ne(),Le("}"),function(){return he.scope.exit(),a},function(){return he.shift(),he.shift(),he.shift()}),X=Re(function(){return"void"===J.data?(he.fake(Pe()),ge.shift(),a):")"!==J.data?"struct"===J.data?(he.unshift(Fe(N,V)),a):(he.unshift(Oe(L)),a):void he.shift()},function(){if(","===J.data)return ge.shift(),0;")"!==J.data?Be("expected one of `,` or `)`, got "+J.data):he.shift()}),(Z=K()).expecting="(eof)",Z.mode=c,Z.token={type:"(program)",data:"(program)"},Y=Z,ve.program=Y,ve.scope=function(e){return 1===arguments.length&&(he.scope=e),he.scope},he.unshift(Z),ve;function ve(e){return null===e?(function(e){arguments.length&&be(e);if(he.length>1)return void Be("unexpected EOF");!0}(),Y):(de=[],be(e),de)}function be(n){if("whitespace"!==n.type&&"line-comment"!==n.type&&"block-comment"!==n.type)for(ge.push(n),(J=J||ge[0])&&me.length&&(J.preceding=J.preceding||[],J.preceding=J.preceding.concat(me),me=[]);xe();)switch(he[0].mode){case s:ke();break;case c:we();break;case d:_e();break;case g:Ae();break;case b:Ee();break;case l:e(!0,!0);break;case x:t();break;case u:je();break;case _:Te();break;case A:De();break;case p:Q();break;case h:X();break;case m:f();break;case y:q();break;case S:G();break;case D:k();break;case v:w();break;case O:r()}else me.push(n)}function xe(){return!(ye||!he.length)&&(J=ge[0])}function we(){return Re(function(){return he.scope.enter(),a},function(){if(J.data===he[0].expecting)return he.scope.exit(),he.shift();switch(J.type){case"preprocessor":return he.fake(Ce()),void ge.shift();default:return void he.unshift($())}})()}function ke(){if(he[0].brace)return"}"!==J.data?Be("expected `}`, got "+J.data):(he[0].brace=!1,ge.shift(),he.shift());switch(J.type){case"eof":return function(){pe&&(ye=!0);return pe=!0,he.shift()}();case"keyword":switch(J.data){case"for":return he.unshift(ae());case"if":return he.unshift(oe());case"while":return he.unshift(fe());case"do":return he.unshift(se());case"break":return he.fake(W(T,J)),ge.shift();case"continue":return he.fake(W(j,J)),ge.shift();case"discard":return he.fake(W(E,J)),ge.shift();case"return":return he.unshift(ue());case"precision":return he.unshift(te())}return he.unshift(Oe(R));case"ident":var e;if(e=he.scope.find(J.data))return"struct"===e.parent.type?he.unshift(Oe(R)):he.unshift(Me(";"));case"operator":if("{"===J.data){he[0].brace=!0;var t=K();return t.expecting="}",ge.shift(),he.unshift(t)}if(";"===J.data)return ge.shift(),he.shift();default:return he.unshift(Me(";"))}}function _e(){var e=he[0];return Re(function(){return"invariant"===J.data?e.flags&P?(he.unshift(Pe()),a):Be("`invariant` is not allowed here"):(he.fake(W(C,{data:"",position:J.position})),a)},function(){return function(e){return"const"===e.data||"attribute"===e.data||"uniform"===e.data||"varying"===e.data}(J)?e.flags&B?(he.unshift(Pe()),a):Be("storage is not allowed here"):(he.fake(W(C,{data:"",position:J.position})),a)},function(){return function(e){return"in"===e.data||"inout"===e.data||"out"===e.data}(J)?e.flags&z?Be("parameter is not allowed here"):(he.unshift(Pe()),a):(he.fake(W(C,{data:"",position:J.position})),a)},function(){return function(e){return"highp"===e.data||"mediump"===e.data||"lowp"===e.data}(J)?(he.unshift(Pe()),a):(he.fake(W(C,{data:"",position:J.position})),a)},function(){if("struct"===J.data)return e.flags&I?(he.unshift(Fe()),a):Be("cannot nest structs");if("keyword"===J.type)return he.unshift(Pe()),a;var t=he.scope.find(J.data);if(t)return he.fake(Object.create(t)),ge.shift(),a;return Be("expected user defined type, struct or keyword, got "+J.data)},function(){if(","===J.data&&!(e.flags&M))return he.shift();if("["===J.data)return void he.unshift(ce());if(")"===J.data)return he.shift();if(";"===J.data)return e.stage+3;if("ident"!==J.type&&"builtin"!==J.type)return Be("expected identifier, got "+J.data);return e.collected_name=ge.shift(),a},function(){if("("===J.data)return ge.unshift(e.collected_name),delete e.collected_name,he.unshift(ne()),e.stage+2;return a},function(){return ge.unshift(e.collected_name),delete e.collected_name,he.unshift(ee()),a},function(){return he.shift()})()}function Ae(){if("ident"===J.type){var e=J.data;return he.unshift(re()),void he.scope.define(e)}if("operator"===J.type){if(","===J.data)return he[1].flags&M?ge.shift():he.shift();if("="===J.data)return he[1].flags&F?(ge.shift(),void he.unshift(Me(",",";"))):Be("`=` is not allowed here.");if("["===J.data)return void he.unshift(ce())}return he.shift()}function De(){return"keyword"===J.type?(he[0].type="keyword",void(he[0].mode=_)):"ident"===J.type?(he[0].type="ident",void(he[0].mode=u)):Be("expected keyword or user-defined name, got "+J.data)}function Te(){return"keyword"!==J.type?Be("expected keyword, got "+J.data):(he.shift(),ge.shift())}function je(){return"ident"!==J.type?Be("expected user-defined name, got "+J.data):(he[0].data=J.data,he.shift(),ge.shift())}function Ee(){var e=he[0].expecting;if(he[0].tokens=he[0].tokens||[],void 0===he[0].parenlevel&&(he[0].parenlevel=0,he[0].bracelevel=0),he[0].parenlevel<1&&e.indexOf(J.data)>-1)return function(e){try{n(he,e)}catch(e){throw ye=!0,e}return he.shift()}(he[0].tokens);switch("("===J.data?++he[0].parenlevel:")"===J.data&&--he[0].parenlevel,J.data){case"{":++he[0].bracelevel;break;case"}":--he[0].bracelevel;break;case"(":++he[0].parenlevel;break;case")":--he[0].parenlevel}return he[0].parenlevel<0?Be("unexpected `)`"):he[0].bracelevel<0?Be("unexpected `}`"):void he[0].tokens.push(ge.shift())}function Se(e){return function(){return W(e,J)}}function Ce(){return W(H[J.type],J)}function Oe(e){var t=W(d,J);return t.flags=e,t}function Fe(e,t){var r=W(l,J);return r.allow_assign=void 0===e||e,r.allow_comma=void 0===t||t,r}function Me(){var e=W(b,J);return e.expecting=[].slice.call(arguments),e}function Pe(e){var t=J;return e&&(t={type:"(implied)",data:"(default)",position:t.position}),W(_,t)}function Be(e){throw ye=!0,new Error((e||"unexpected "+he)+" at line "+he[0].token.line)}function ze(e,t){return Ie(e,J.type)&&Ie(t,J.data)}function Ie(e,t){switch(typeof e){case"string":return t!==e&&Be("expected `"+e+"`, got "+t+"\n"+J.data),!ye;case"object":return e&&-1===e.indexOf(t)&&Be("expected one of `"+e.join("`, `")+"`, got "+t),!ye}return!0}function Re(){var e,t,r=[].slice.call(arguments);return function(){var n=he[0];return n.stage||(n.stage=0),(e=r[n.stage])?(t=e())===a?++n.stage:void(void 0!==t&&(n.stage=t)):Be("parser in undefined state!")}}function Le(e,t){return t=t||"operator",function(){if(ze(t,e)){var r=ge.shift(),n=he[0].children,i=n[n.length-1];return i&&i.token&&r.preceding&&(i.token.succeeding=i.token.succeeding||[],i.token.succeeding=i.token.succeeding.concat(r.preceding)),a}}}function Ue(e){return function(){return he.unshift(Me(e)),a}}function Ne(){return function(){var e=K();return e.expecting="}",he.unshift(e),a}}function Ve(e){return function(){var t=he[0].stage;return"{"!==J.data?(he.unshift($()),t+e):(ge.shift(),a)}}function He(){return function(){return he.shift(),he.shift()}}};var n=e("./expr"),i=e("./scope"),a=new Object,o=!1,f=0,u=f++,s=f++,c=f++,l=f++,p=f++,h=f++,d=f++,g=f++,m=f++,y=f++,v=f++,b=f++,x=f++,w=f++,k=f++,_=f++,A=f++,D=f++,T=f++,j=f++,E=f++,S=f++,C=f++,O=f++,F=1,M=2,P=8,B=16,z=32,I=64,R=255,L=R&~(F|M|z|P|4),U=R&~(F|P|B|I),N=!1,V=!1,H={"block-comment":w,"line-comment":w,preprocessor:k},q=f=["ident","stmt","stmtlist","struct","function","functionargs","decl","decllist","forloop","whileloop","if","expr","precision","comment","preprocessor","keyword","keyword_or_ident","return","break","continue","discard","do-while","placeholder","quantifier"];function W(e,t){return{mode:e,token:t,children:[],type:q[e],id:(4294967295*Math.random()).toString(16)}}},{"./expr":3,"./scope":5}],5:[function(e,t,r){function n(e){if(this.constructor!==n)return new n(e);this.state=e,this.scopes=[],this.current=null}t.exports=n;var i=n.prototype;i.enter=function(e){this.scopes.push(this.current=this.state[0].scope=e||{})},i.exit=function(){this.scopes.pop(),this.current=this.scopes[this.scopes.length-1]},i.define=function(e){this.current[e]=this.state[0]},i.find=function(e,t){for(var r=this.scopes.length-1;r>-1;--r)if(this.scopes[r].hasOwnProperty(e))return this.scopes[r][e];return null}},{}],6:[function(e,t,r){t.exports=function(e){var t,r,_,A=0,D=0,T=u,j=[],E=[],S=1,C=0,O=0,F=!1,M=!1,P="",B=a,z=n;"300 es"===(e=e||{}).version&&(B=f,z=o);return function(e){return E=[],null!==e?function(e){var r;A=0,_=(P+=e).length;for(;t=P[A],A<_;){switch(r=A,T){case c:A=N();break;case l:case p:A=U();break;case h:A=V();break;case d:A=W();break;case w:A=q();break;case g:A=G();break;case s:A=Q();break;case b:A=L();break;case u:A=R()}if(r!==A)switch(P[r]){case"\n":C=0,++S;break;default:++C}}return D+=A,P=P.slice(A),E}(e.replace?e.replace(/\r\n/g,"\n"):e):function(e){j.length&&I(j.join(""));return T=x,I("(eof)"),E}()};function I(e){e.length&&E.push({type:k[T],data:e,position:O,line:S,column:C})}function R(){return j=j.length?[]:j,"/"===r&&"*"===t?(O=D+A-1,T=c,r=t,A+1):"/"===r&&"/"===t?(O=D+A-1,T=l,r=t,A+1):"#"===t?(T=p,O=D+A,A):/\s/.test(t)?(T=b,O=D+A,A):(F=/\d/.test(t),M=/[^\w_]/.test(t),O=D+A,T=F?d:M?h:s,A)}function L(){return/[^\s]/g.test(t)?(I(j.join("")),T=u,A):(j.push(t),r=t,A+1)}function U(){return"\r"!==t&&"\n"!==t||"\\"===r?(j.push(t),r=t,A+1):(I(j.join("")),T=u,A)}function N(){return"/"===t&&"*"===r?(j.push(t),I(j.join("")),T=u,A+1):(j.push(t),r=t,A+1)}function V(){if("."===r&&/\d/.test(t))return T=g,A;if("/"===r&&"*"===t)return T=c,A;if("/"===r&&"/"===t)return T=l,A;if("."===t&&j.length){for(;H(j););return T=g,A}if(";"===t||")"===t||"("===t){if(j.length)for(;H(j););return I(t),T=u,A+1}var e=2===j.length&&"="!==t;if(/[\w_\d\s]/.test(t)||e){for(;H(j););return T=u,A}return j.push(t),r=t,A+1}function H(e){for(var t,r,n=0;;){if(t=i.indexOf(e.slice(0,e.length+n).join("")),r=i[t],-1===t){if(n--+e.length>0)continue;r=e.slice(0,1).join("")}return I(r),O+=r.length,(j=j.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(t)?(I(j.join("")),T=u,A):(j.push(t),r=t,A+1)}function W(){return"."===t?(j.push(t),T=g,r=t,A+1):/[eE]/.test(t)?(j.push(t),T=g,r=t,A+1):"x"===t&&1===j.length&&"0"===j[0]?(T=w,j.push(t),r=t,A+1):/[^\d]/.test(t)?(I(j.join("")),T=u,A):(j.push(t),r=t,A+1)}function G(){return"f"===t&&(j.push(t),r=t,A+=1),/[eE]/.test(t)?(j.push(t),r=t,A+1):"-"===t&&/[eE]/.test(r)?(j.push(t),r=t,A+1):/[^\d]/.test(t)?(I(j.join("")),T=u,A):(j.push(t),r=t,A+1)}function Q(){if(/[^\d\w_]/.test(t)){var e=j.join("");return T=z.indexOf(e)>-1?v:B.indexOf(e)>-1?y:m,I(j.join("")),T=u,A}return j.push(t),r=t,A+1}};var n=e("./lib/literals"),i=e("./lib/operators"),a=e("./lib/builtins"),o=e("./lib/literals-300es"),f=e("./lib/builtins-300es"),u=999,s=9999,c=0,l=1,p=2,h=3,d=4,g=5,m=6,y=7,v=8,b=9,x=10,w=11,k=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"]},{"./lib/builtins":8,"./lib/builtins-300es":7,"./lib/literals":10,"./lib/literals-300es":9,"./lib/operators":11}],7:[function(e,t,r){var n=e("./builtins");n=n.slice().filter(function(e){return!/^(gl\_|texture)/.test(e)}),t.exports=n.concat(["gl_VertexID","gl_InstanceID","gl_Position","gl_PointSize","gl_FragCoord","gl_FrontFacing","gl_FragDepth","gl_PointCoord","gl_MaxVertexAttribs","gl_MaxVertexUniformVectors","gl_MaxVertexOutputVectors","gl_MaxFragmentInputVectors","gl_MaxVertexTextureImageUnits","gl_MaxCombinedTextureImageUnits","gl_MaxTextureImageUnits","gl_MaxFragmentUniformVectors","gl_MaxDrawBuffers","gl_MinProgramTexelOffset","gl_MaxProgramTexelOffset","gl_DepthRangeParameters","gl_DepthRange","trunc","round","roundEven","isnan","isinf","floatBitsToInt","floatBitsToUint","intBitsToFloat","uintBitsToFloat","packSnorm2x16","unpackSnorm2x16","packUnorm2x16","unpackUnorm2x16","packHalf2x16","unpackHalf2x16","outerProduct","transpose","determinant","inverse","texture","textureSize","textureProj","textureLod","textureOffset","texelFetch","texelFetchOffset","textureProjOffset","textureLodOffset","textureProjLod","textureProjLodOffset","textureGrad","textureGradOffset","textureProjGrad","textureProjGradOffset"])},{"./builtins":8}],8:[function(e,t,r){t.exports=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT"]},{}],9:[function(e,t,r){var n=e("./literals");t.exports=n.slice().concat(["layout","centroid","smooth","case","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4","uint","uvec2","uvec3","uvec4","samplerCubeShadow","sampler2DArray","sampler2DArrayShadow","isampler2D","isampler3D","isamplerCube","isampler2DArray","usampler2D","usampler3D","usamplerCube","usampler2DArray","coherent","restrict","readonly","writeonly","resource","atomic_uint","noperspective","patch","sample","subroutine","common","partition","active","filter","image1D","image2D","image3D","imageCube","iimage1D","iimage2D","iimage3D","iimageCube","uimage1D","uimage2D","uimage3D","uimageCube","image1DArray","image2DArray","iimage1DArray","iimage2DArray","uimage1DArray","uimage2DArray","image1DShadow","image2DShadow","image1DArrayShadow","image2DArrayShadow","imageBuffer","iimageBuffer","uimageBuffer","sampler1DArray","sampler1DArrayShadow","isampler1D","isampler1DArray","usampler1D","usampler1DArray","isampler2DRect","usampler2DRect","samplerBuffer","isamplerBuffer","usamplerBuffer","sampler2DMS","isampler2DMS","usampler2DMS","sampler2DMSArray","isampler2DMSArray","usampler2DMSArray"])},{"./literals":10}],10:[function(e,t,r){t.exports=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"]},{}],11:[function(e,t,r){t.exports=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"]},{}],12:[function(e,t,r){var n=e("./index");t.exports=function(e,t){var r=n(t),i=[];return i=(i=i.concat(r(e))).concat(r(null))}},{"./index":6}],13:[function(e,t,r){!function(){function e(){var e=[].slice.call(arguments),t=null;function r(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 r=e.substring(1,e.length);e&&(t?"."===e[0]?t.classList.add(r):"#"===e[0]&&t.setAttribute("id",r):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(r);else if(e instanceof HTMLElement)t.appendChild(e);else if("object"==typeof e)for(var n in e)if("function"==typeof e[n])t.addEventListener(n,e[n]);else if("style"===n)for(var i in e[n])t.style.setProperty(i,e[n][i]);else t.setAttribute(n,e[n])}for(;e.length;)r(e.shift());return t}"object"==typeof t?t.exports=e:this.h=e}()},{}],14:[function(e,t,r){var n=[],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 r,o=!0===t.prepend?"prepend":"append",f=void 0!==t.container?t.container:document.querySelector("head"),u=n.indexOf(f);return-1===u&&(u=n.push(f)-1,i[u]={}),void 0!==i[u]&&void 0!==i[u][o]?r=i[u][o]:(r=i[u][o]=function(){var e=document.createElement("style");return e.setAttribute("type","text/css"),e}(),"prepend"===o?f.insertBefore(r,f.childNodes[0]):f.appendChild(r)),65279===e.charCodeAt(0)&&(e=e.substr(1,e.length)),r.styleSheet?r.styleSheet.cssText+=e:r.textContent+=e,r}t.exports=o,t.exports.insertCss=o},{}],15:[function(e,t,r){"use strict";t.exports=function(e){for(var t=new Array(e),r=0;r<e;++r)t[r]=r;return t}},{}],16:[function(e,t,r){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}t.exports=function(e){return null!=e&&(n(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}(e)||!!e._isBuffer)}},{}],17:[function(e,t,r){t.exports=function(e){return!!e&&(!!e.dtype&&new RegExp("function View[0-9]+d(:?"+e.dtype+")+").test(String(e.constructor)))}},{}],18:[function(e,t,r){var n=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,r=new Array(t.length);for(e=0;e<r.length;++e)r[e]=[Math.abs(t[e]),e];r.sort(o);var n=new Array(r.length);for(e=0;e<n.length;++e)n[e]=r[e][1];return n}function u(e,t){var r=["View",t,"d",e].join("");t<0&&(r="View_Nil"+e);var i="generic"===e;if(-1===t){var a="function "+r+"(a){this.data=a;};var proto="+r+".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 "+r+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+r+"(a){return new "+r+"(a);}";return new Function(a)()}if(0===t){a="function "+r+"(a,d) {this.data = a;this.offset = d};var proto="+r+".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 "+r+"_copy() {return new "+r+"(this.data,this.offset)};proto.pick=function "+r+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+r+"_get(){return "+(i?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+r+"_set(v){return "+(i?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+r+"(a,b,c,d){return new "+r+"(a,d)}";return new Function("TrivialArray",a)(s[e][0])}a=["'use strict'"];var o=n(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 "+r+"(a,"+l+","+p+",d){this.data=a","this.shape=["+l+"]","this.stride=["+p+"]","this.offset=d|0}","var proto="+r+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),a.push("Object.defineProperty(proto,'size',{get:function "+r+"_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 "+r+"_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 "+r+"_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 "+r+"_get("+u.join(",")+"){"),i?a.push("return this.data.get("+c+")}"):a.push("return this.data["+c+"]}"),a.push("proto.index=function "+r+"_index(",u.join(),"){return "+c+"}"),a.push("proto.hi=function "+r+"_hi("+u.join(",")+"){return new "+r+"(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 h=o.map(function(e){return"a"+e+"=this.shape["+e+"]"}),d=o.map(function(e){return"c"+e+"=this.stride["+e+"]"});a.push("proto.lo=function "+r+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+h.join(",")+","+d.join(","));for(var g=0;g<t;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){d=i"+g+"|0;b+=c"+g+"*d;a"+g+"-=d}");a.push("return new "+r+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"c"+e}).join(",")+",b)}"),a.push("proto.step=function "+r+"_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(g=0;g<t;++g)a.push("if(typeof i"+g+"==='number'){d=i"+g+"|0;if(d<0){c+=b"+g+"*(a"+g+"-1);a"+g+"=ceil(-a"+g+"/d)}else{a"+g+"=ceil(a"+g+"/d)}b"+g+"*=d}");a.push("return new "+r+"(this.data,"+o.map(function(e){return"a"+e}).join(",")+","+o.map(function(e){return"b"+e}).join(",")+",c)}");var m=new Array(t),y=new Array(t);for(g=0;g<t;++g)m[g]="a[i"+g+"]",y[g]="b[i"+g+"]";a.push("proto.transpose=function "+r+"_transpose("+u+"){"+u.map(function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+r+"(this.data,"+m.join(",")+","+y.join(",")+",this.offset)}"),a.push("proto.pick=function "+r+"_pick("+u+"){var a=[],b=[],c=this.offset");for(g=0;g<t;++g)a.push("if(typeof i"+g+"==='number'&&i"+g+">=0){c=(c+this.stride["+g+"]*i"+g+")|0}else{a.push(this.shape["+g+"]);b.push(this.stride["+g+"])}");return a.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),a.push("return function construct_"+r+"(data,shape,stride,offset){return new "+r+"(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,r,n){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===r){r=new Array(o);for(var f=o-1,c=1;f>=0;--f)r[f]=c,c*=t[f]}if(void 0===n)for(n=0,f=0;f<o;++f)r[f]<0&&(n-=(t[f]-1)*r[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,r,n)}},{"iota-array":15,"is-buffer":16}],19:[function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;t.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,o,f=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),u=1;u<arguments.length;u++){for(var s in r=Object(arguments[u]))i.call(r,s)&&(f[s]=r[s]);if(n){o=n(r);for(var c=0;c<o.length;c++)a.call(r,o[c])&&(f[o[c]]=r[o[c]])}}return f}},{}],20:[function(e,t,r){"use strict";var n=e("object-assign");function i(e){if(e=n({mean:0,dev:1,pool:[]},e),Array.isArray(e.pool)&&e.pool.length>0)return function(e){var t=0;do{var r=Math.round(i({mean:e.mean,dev:e.dev}));if(r<e.pool.length&&r>=0)return e.pool[r];t++}while(t<100)}(e);var t,r,a,o=e.mean,f=e.dev;do{t=(r=2*Math.random()-1)*r+(a=2*Math.random()-1)*a}while(t>=1);return f*(r*Math.sqrt(-2*Math.log(t)/t))+o}t.exports=i},{"object-assign":19}],21:[function(e,t,r){var n,i;n=this,i=function(){function e(e,t){this.id=N++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(1<t.length&&r===n&&('"'===r||"'"===r))return['"'+t.substr(1,t.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t))return e(t.substr(0,r.index)).concat(e(r[1])).concat(e(t.substr(r.index+r[0].length)));if(1===(r=t.split(".")).length)return['"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(t=[],n=0;n<r.length;++n)t=t.concat(e(r[n]));return t}(e).join("][")+"]"}function r(e){return"string"==typeof e?e.split():e}function n(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){},h=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=n(f.canvas):"container"in f&&(i=n(f.container)),"attributes"in f&&(e=f.attributes),"extensions"in f&&(u=r(f.extensions)),"optionalExtensions"in f&&(s=r(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,r){function n(){var t=window.innerWidth,n=window.innerHeight;e!==document.body&&(t=(n=e.getBoundingClientRect()).right-n.left,n=n.bottom-n.top),i.width=r*t,i.height=r*n,U(i.style,{width:t+"px",height:n+"px"})}var i=document.createElement("canvas");return U(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",U(e.style,{margin:0,padding:0})),window.addEventListener("resize",n,!1),n(),{canvas:i,onDestroy:function(){window.removeEventListener("resize",n),e.removeChild(i)}}}(i||document.body,0,c)))return null;a=t.canvas,h=t.onDestroy}o=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,e)}return o?{gl:o,canvas:a,container:i,extensions:u,optionalExtensions:s,pixelRatio:c,profile:l,onDone:p,onDestroy:h}:(h(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function a(e,t){for(var r=Array(e),n=0;n<e;++n)r[n]=t(n);return r}function o(e){var t,r;return t=(65535<e)<<4,t|=r=(255<(e>>>=t))<<3,(t|=r=(15<(e>>>=r))<<2)|(r=(3<(e>>>=r))<<1)|e>>>r>>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=r[o(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){r[o(e.byteLength)>>2].push(e)}var r=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,r){var n=null;switch(t){case 5120:n=new Int8Array(e(r),0,r);break;case 5121:n=new Uint8Array(e(r),0,r);break;case 5122:n=new Int16Array(e(2*r),0,r);break;case 5123:n=new Uint16Array(e(2*r),0,r);break;case 5124:n=new Int32Array(e(4*r),0,r);break;case 5125:n=new Uint32Array(e(4*r),0,r);break;case 5126:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},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)||Q(e.data))}function s(e,t,r,n,i,a){for(var o=0;o<t;++o)for(var f=e[o],u=0;u<r;++u)for(var s=f[u],c=0;c<n;++c)i[a++]=s[c]}function c(e){return 0|J[Object.prototype.toString.call(e)]}function l(e,t){for(var r=0;r<t.length;++r)e[r]=t[r]}function p(e,t,r,n,i,a,o){for(var f=0,u=0;u<r;++u)for(var s=0;s<n;++s)e[f++]=t[i*u+a*s+o]}function h(e,t,r,n){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,r.profile&&(this.stats={size:0})}function a(t,r,n){t.byteLength=r.byteLength,e.bufferData(t.type,r,n)}function o(e,t,r,n,i,o){if(e.usage=r,Array.isArray(t)){if(e.dtype=n||5126,0<t.length)if(Array.isArray(t[0])){i=ee(t);for(var f=n=1;f<i.length;++f)n*=i[f];e.dimension=n,a(e,t=$(t,i,e.dtype),r),o?e.persistentData=t:W.freeType(t)}else"number"==typeof t[0]?(e.dimension=i,l(i=W.allocType(e.dtype,t.length),t),a(e,i,r),o?e.persistentData=i:W.freeType(i)):Q(t[0])&&(e.dimension=t[0].length,e.dtype=n||c(t[0])||5126,a(e,t=$(t,[t.length,t[0].length],e.dtype),r),o?e.persistentData=t:W.freeType(t))}else if(Q(t))e.dtype=n||c(t),e.dimension=i,a(e,t,r),o&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(u(t)){i=t.shape;var s=t.stride,h=(f=t.offset,0),d=0,g=0,m=0;1===i.length?(h=i[0],d=1,g=s[0],m=0):2===i.length&&(h=i[0],d=i[1],g=s[0],m=s[1]),e.dtype=n||c(t.data)||5126,e.dimension=d,p(i=W.allocType(e.dtype,h*d),t.data,h,d,g,m,f),a(e,i,r),o?e.persistentData=i:W.freeType(i)}}function f(r){t.bufferCount--;for(var i=0;i<n.state.length;++i){var a=n.state[i];a.buffer===r&&(e.disableVertexAttribArray(i),a.buffer=null)}e.deleteBuffer(r.buffer),r.buffer=null,delete h[r.id]}var s=0,h={};i.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},i.prototype.destroy=function(){f(this)};var d=[];return r.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(h).forEach(function(t){e+=h[t].stats.size}),e}),{create:function(n,a,s,d){function g(t){var n=35044,i=null,a=0,f=0,s=1;return Array.isArray(t)||Q(t)||u(t)?i=t:"number"==typeof t?a=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(n=K[t.usage]),"type"in t&&(f=Z[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(a=0|t.length)),m.bind(),i?o(m,i,n,f,s,d):(a&&e.bufferData(m.type,a,n),m.dtype=f||5121,m.usage=n,m.dimension=s,m.byteLength=a),r.profile&&(m.stats.size=m.byteLength*te[m.dtype]),g}t.bufferCount++;var m=new i(a);return h[m.id]=m,s||g(n),g._reglType="buffer",g._buffer=m,g.subdata=function(t,r){var n,i=0|(r||0);if(m.bind(),Q(t))e.bufferSubData(m.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var a=W.allocType(m.dtype,t.length);l(a,t),e.bufferSubData(m.type,i,a),W.freeType(a)}else(Array.isArray(t[0])||Q(t[0]))&&(n=ee(t),a=$(t,n,m.dtype),e.bufferSubData(m.type,i,a),W.freeType(a))}else if(u(t)){n=t.shape;var o=t.stride,f=a=0,s=0,h=0;1===n.length?(a=n[0],f=1,s=o[0],h=0):2===n.length&&(a=n[0],f=n[1],s=o[0],h=o[1]),n=Array.isArray(t.data)?m.dtype:c(t.data),p(n=W.allocType(n,a*f),t.data,a,f,s,h,t.offset),e.bufferSubData(m.type,i,n),W.freeType(n)}return g},r.profile&&(g.stats=m.stats),g.destroy=function(){f(m)},g},createStream:function(e,t){var r=d.pop();return r||(r=new i(e)),r.bind(),o(r,t,35040,0,1,!1),r},destroyStream:function(e){d.push(e)},clear:function(){X(h).forEach(f),d.forEach(f)},getBuffer:function(e){return e&&e._buffer instanceof i?e._buffer:null},restore:function(){X(h).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 d(e,t,r,n){function i(e){this.id=s++,f[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function a(n,i,a,o,f,s,c){if(n.buffer.bind(),i){var l=c;c||Q(i)&&(!u(i)||Q(i.data))||(l=t.oes_element_index_uint?5125:5123),r._initBuffer(n.buffer,i,a,l,3)}else e.bufferData(34963,s,a),n.buffer.dtype=l||5121,n.buffer.usage=a,n.buffer.dimension=3,n.buffer.byteLength=s;if(l=c,!c){switch(n.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125}n.buffer.dtype=l}n.type=l,0>(i=f)&&(i=n.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),n.vertCount=i,i=o,0>o&&(i=4,1===(o=n.buffer.dimension)&&(i=0),2===o&&(i=1),3===o&&(i=4)),n.primType=i}function o(e){n.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,r=35044,n=-1,i=-1,o=0,p=0;Array.isArray(e)||Q(e)||u(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(r=K[e.usage]),"primitive"in e&&(n=re[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,r,n,i,o,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return f}var s=r.create(null,34963,!0),l=new i(s._buffer);return n.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(r.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(){X(f).forEach(o)}}}function g(e){for(var t=W.allocType(5123,e.length),r=0;r<e.length;++r)if(isNaN(e[r]))t[r]=65535;else if(1/0===e[r])t[r]=31744;else if(-1/0===e[r])t[r]=64512;else{ne[0]=e[r];var n=(a=ie[0])>>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15<i?n+31744:n+(i+15<<10)+a}return t}function m(e){return Array.isArray(e)||Q(e)}function y(e){return"[object "+e+"]"}function v(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function b(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<=he.indexOf(t)||(v(e)||b(e)||u(e))}function k(e,t){36193===e.type?(e.data=g(t),W.freeType(t)):e.data=t}function _(e,t,r,n,i,a){if(e=void 0!==ge[e]?ge[e]:fe[e]*de[t],a&&(e*=6),i){for(n=0;1<=r;)n+=e*r*r,r/=2;return n}return e*r*n}function A(e,t,r,n,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=V[t.colorSpace]),"type"in t&&(e.type=H[t.type]);var r=e.width,n=e.height,i=e.channels,a=!1;"shape"in t?(r=t.shape[0],n=t.shape[1],3===t.shape.length&&(i=t.shape[2],a=!0)):("radius"in t&&(r=n=t.radius),"width"in t&&(r=t.width),"height"in t&&(n=t.height),"channels"in t&&(i=t.channels,a=!0)),e.width=0|r,e.height=0|n,e.channels=0|i,r=!1,"format"in t&&(r=t.format,n=e.internalformat=q[r],e.format=ie[n],r in H&&!("type"in t)&&(e.type=H[r]),r in G&&(e.compressed=!0),r=!0),!a&&r?e.channels=fe[e.format]:a&&!r&&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 h(e,t){var r=null;if(w(t)?r=t:t&&(c(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),w(t.data)&&(r=t.data)),t.copy){var n=i.viewportWidth,a=i.viewportHeight;e.width=e.width||n-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0}else if(r){if(Q(r))e.channels=e.channels||4,e.data=r,"type"in t||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(r)]);else if(v(r)){switch(e.channels=e.channels||4,a=(n=r).length,e.type){case 5121:case 5123:case 5125:case 5126:(a=W.allocType(e.type,a)).set(n),e.data=a;break;case 36193:e.data=g(n)}e.alignment=1,e.needsFree=!0}else if(u(r)){n=r.data,Array.isArray(n)||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(n)]);a=r.shape;var o,f,s,l,p=r.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,r=r.offset,s=e.width,l=e.height,f=e.channels;for(var h=W.allocType(36193===e.type?5126:e.type,s*l*f),d=0,y=0;y<l;++y)for(var _=0;_<s;++_)for(var A=0;A<f;++A)h[d++]=n[a*_+p*y+o*A+r];k(e,h)}else if(x(r)===ue||x(r)===se)x(r)===ue?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(x(r)===ce)e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(x(r)===le)e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(x(r)===pe)e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(b(r)){for(n=e.width||r[0].length,a=e.height||r.length,p=e.channels,p=m(r[0][0])?p||r[0][0].length:p||1,o=Y.shape(r),s=1,l=0;l<o.length;++l)s*=o[l];s=W.allocType(36193===e.type?5126:e.type,s),Y.flatten(r,o,"",s),k(e,s),e.alignment=1,e.width=n,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 d(t,r,i,a,o){var f=t.element,u=t.data,s=t.internalformat,c=t.format,p=t.type,h=t.width,d=t.height;l(t),f?e.texSubImage2D(r,o,i,a,c,p,f):t.compressed?e.compressedTexSubImage2D(r,o,i,a,s,h,d,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,o,i,a,t.xOffset,t.yOffset,h,d)):e.texSubImage2D(r,o,i,a,h,d,c,p,u)}function y(){return he.pop()||new p}function A(e){e.needsFree&&W.freeType(e.data),p.call(e),he.push(e)}function D(e,t,r){var n=e.images[0]=y();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function T(e,t){var r=null;if(w(t))s(r=e.images[0]=y(),e),h(r,t),e.mipmask=1;else if(c(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,i=0;i<n.length;++i)s(r=e.images[i]=y(),e),r.width>>=i,r.height>>=i,h(r,n[i]),e.mipmask|=1<<i;else s(r=e.images[0]=y(),e),h(r,t),e.mipmask=1;s(e,e.images[0])}function j(t,r){for(var i=t.images,a=0;a<i.length&&i[a];++a){var o=i[a],f=r,u=a,s=o.element,c=o.data,p=o.internalformat,h=o.format,d=o.type,g=o.width,m=o.height,y=o.channels;l(o),s?e.texImage2D(f,u,h,h,d,s):o.compressed?e.compressedTexImage2D(f,u,p,g,m,0,c):o.needsCopy?(n(),e.copyTexImage2D(f,u,h,o.xOffset,o.yOffset,g,m,0)):((o=!c)&&(c=W.zero.allocType(d,g*m*y)),e.texImage2D(f,u,h,g,m,0,h,d,c),o&&c&&W.zero.freeType(c))}}function E(){var e=de.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,r=0;r<t.length;++r)t[r]&&A(t[r]),t[r]=null;de.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=N[t.min],0<=ae.indexOf(e.minFilter)&&!("faces"in t)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=L[t.mag]);var r=e.wrapS,n=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?r=n=R[i]:Array.isArray(i)&&(r=R[i[0]],n=R[i[1]])}else"wrapS"in t&&(r=R[t.wrapS]),"wrapT"in t&&(n=R[t.wrapT]);if(e.wrapS=r,e.wrapT=n,"anisotropic"in t&&(e.anisotropic=t.anisotropic),"mipmap"in t){switch(r=!1,typeof t.mipmap){case"string":e.mipmapHint=I[t.mipmap],r=e.genMipmaps=!0;break;case"boolean":r=e.genMipmaps=t.mipmap;break;case"object":e.genMipmaps=!1,r=!0}!r||"min"in t||(e.minFilter=9984)}}function F(r,n){e.texParameteri(n,10241,r.minFilter),e.texParameteri(n,10240,r.magFilter),e.texParameteri(n,10242,r.wrapS),e.texParameteri(n,10243,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,34046,r.anisotropic),r.genMipmaps&&(e.hint(33170,r.mipmapHint),e.generateMipmap(n))}function M(t){f.call(this),this.mipmask=0,this.internalformat=6408,this.id=ge++,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 P(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function B(){var t=ve[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(3553,null)}function z(t){var r=t.texture,n=t.unit,i=t.target;0<=n&&(e.activeTexture(33984+n),e.bindTexture(i,null),ve[n]=null),e.deleteTexture(r),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},R={repeat:10497,clamp:33071,mirror:33648},L={nearest:9728,linear:9729},N=U({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},L),V={none:0,browser:37444},H={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},q={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},G={};t.ext_srgb&&(q.srgb=35904,q.srgba=35906),t.oes_texture_float&&(H.float32=H.float=5126),t.oes_texture_half_float&&(H.float16=H["half float"]=36193),t.webgl_depth_texture&&(U(q,{depth:6402,"depth stencil":34041}),U(H,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&U(G,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&U(G,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&U(G,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(G["rgb etc1"]=36196);var Z=Array.prototype.slice.call(e.getParameter(34467));Object.keys(G).forEach(function(e){var t=G[e];0<=Z.indexOf(t)&&(q[e]=t)});var K=Object.keys(q);r.textureFormats=K;var $=[];Object.keys(q).forEach(function(e){$[q[e]]=e});var ee=[];Object.keys(H).forEach(function(e){ee[H[e]]=e});var te=[];Object.keys(L).forEach(function(e){te[L[e]]=e});var re=[];Object.keys(N).forEach(function(e){re[N[e]]=e});var ne=[];Object.keys(R).forEach(function(e){ne[R[e]]=e});var ie=K.reduce(function(e,t){var r=q[t];return 6409===r||6406===r||6409===r||6410===r||6402===r||34041===r?e[r]=r:32855===r||0<=t.indexOf("rgba")?e[r]=6408:e[r]=6407,e},{}),he=[],de=[],ge=0,me={},ye=r.maxTextureUnits,ve=Array(ye).map(function(){return null});return U(M.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var r=0;r<ye;++r){var n=ve[r];if(n){if(0<n.bindCount)continue;n.unit=-1}ve[r]=this,t=r;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&&z(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,r){function n(e,t){var r=i.texInfo;C.call(r);var a=E();return"number"==typeof e?D(a,0|e,"number"==typeof t?0|t:0|e):e?(O(r,e),T(a,e)):D(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,P(i),j(a,3553),F(r,3553),B(),S(a),o.profile&&(i.stats.size=_(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=$[i.internalformat],n.type=ee[i.type],n.mag=te[r.magFilter],n.min=re[r.minFilter],n.wrapS=ne[r.wrapS],n.wrapT=ne[r.wrapT],n}var i=new M(3553);return me[i.id]=i,a.textureCount++,n(t,r),n.subimage=function(e,t,r,a){t|=0,r|=0,a|=0;var o=y();return s(o,i),o.width=0,o.height=0,h(o,e),o.width=o.width||(i.width>>a)-t,o.height=o.height||(i.height>>a)-r,P(i),d(o,3553,t,r,a),B(),A(o),n},n.resize=function(t,r){var a=0|t,f=0|r||a;if(a===i.width&&f===i.height)return n;n.width=i.width=a,n.height=i.height=f,P(i);for(var u,s=i.channels,c=i.type,l=0;i.mipmask>>l;++l){var p=a>>l,h=f>>l;if(!p||!h)break;u=W.zero.allocType(c,p*h*s),e.texImage2D(3553,l,i.format,p,h,0,i.format,i.type,u),u&&W.zero.freeType(u)}return B(),o.profile&&(i.stats.size=_(i.internalformat,i.type,a,f,!1,!1)),n},n._reglType="texture2d",n._texture=i,o.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(t,r,n,i,f,u){function l(e,t,r,n,i,a){var f,u=p.texInfo;for(C.call(u),f=0;6>f;++f)g[f]=E();if("number"!=typeof e&&e){if("object"==typeof e)if(t)T(g[0],e),T(g[1],t),T(g[2],r),T(g[3],n),T(g[4],i),T(g[5],a);else if(O(u,e),c(p,e),"faces"in e)for(e=e.faces,f=0;6>f;++f)s(g[f],p),T(g[f],e[f]);else for(f=0;6>f;++f)T(g[f],e)}else for(e=0|e||1,f=0;6>f;++f)D(g[f],e,e);for(s(p,g[0]),p.mipmask=u.genMipmaps?(g[0].width<<1)-1:g[0].mipmask,p.internalformat=g[0].internalformat,l.width=g[0].width,l.height=g[0].height,P(p),f=0;6>f;++f)j(g[f],34069+f);for(F(u,34067),B(),o.profile&&(p.stats.size=_(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=$[p.internalformat],l.type=ee[p.type],l.mag=te[u.magFilter],l.min=re[u.minFilter],l.wrapS=ne[u.wrapS],l.wrapT=ne[u.wrapT],f=0;6>f;++f)S(g[f]);return l}var p=new M(34067);me[p.id]=p,a.cubeCount++;var g=Array(6);return l(t,r,n,i,f,u),l.subimage=function(e,t,r,n,i){r|=0,n|=0,i|=0;var a=y();return s(a,p),a.width=0,a.height=0,h(a,t),a.width=a.width||(p.width>>i)-r,a.height=a.height||(p.height>>i)-n,P(p),d(a,34069+e,r,n,i),B(),A(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,P(p);for(var r=0;6>r;++r)for(var n=0;p.mipmask>>n;++n)e.texImage2D(34069+r,n,p.format,t>>n,t>>n,0,p.format,p.type,null);return B(),o.profile&&(p.stats.size=_(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<ye;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),ve[t]=null;X(me).forEach(z),a.cubeCount=0,a.textureCount=0},getTexture:function(e){return null},restore:function(){X(me).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var r=0;32>r;++r)if(0!=(t.mipmask&1<<r))if(3553===t.target)e.texImage2D(3553,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;6>n;++n)e.texImage2D(34069+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);F(t.texInfo,t.target)})}}}function D(e,t,r,n,i,a){function o(e,t,r){this.target=e,this.texture=t,this.renderbuffer=r;var n=e=0;t?(e=t.width,n=t.height):r&&(e=r.width,n=r.height),this.width=e,this.height=n}function f(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,r){e&&(e.texture?e.texture._texture.refCount+=1:e.renderbuffer._renderbuffer.refCount+=1)}function s(t,r){r&&(r.texture?e.framebufferTexture2D(36160,t,r.target,r.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=3553,r=null,n=null,i=e;return"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),"texture2d"===(e=i._reglType)?r=i:"textureCube"===e?r=i:"renderbuffer"===e&&(n=i,t=36161),new o(t,r,n)}function l(e,t,r,a,f){return r?((e=n.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 h(e,t,r){e&&(e.texture?e.texture.resize(t,r):e.renderbuffer&&e.renderbuffer.resize(t,r))}function d(){this.id=_++,A[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(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 A[t.id]}function y(t){var n;e.bindFramebuffer(36160,t.framebuffer);var i=t.colorAttachments;for(n=0;n<i.length;++n)s(36064+n,i[n]);for(n=i.length;n<r.maxColorAttachments;++n)e.framebufferTexture2D(36160,36064+n,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,b.next?b.next.framebuffer:null),b.cur=b.next,e.getError()}function v(e,t){function r(e,t){var i,a=0,o=0,f=!0,s=!0;i=null;var h=!0,d="rgba",m="uint8",v=1,b=null,k=null,_=null,A=!1;"number"==typeof e?(a=0|e,o=0|t||a):e?("shape"in e?(a=(o=e.shape)[0],o=o[1]):("radius"in e&&(a=o=e.radius),"width"in e&&(a=e.width),"height"in e&&(o=e.height)),("color"in e||"colors"in e)&&(i=e.color||e.colors,Array.isArray(i)),i||("colorCount"in e&&(v=0|e.colorCount),"colorTexture"in e&&(h=!!e.colorTexture,d="rgba4"),"colorType"in e&&(m=e.colorType,!h)&&("half float"===m||"float16"===m?d="rgba16f":"float"!==m&&"float32"!==m||(d="rgba32f")),"colorFormat"in e&&(d=e.colorFormat,0<=x.indexOf(d)?h=!0:0<=w.indexOf(d)&&(h=!1))),("depthTexture"in e||"depthStencilTexture"in e)&&(A=!(!e.depthTexture&&!e.depthStencilTexture)),"depth"in e&&("boolean"==typeof e.depth?f=e.depth:(b=e.depth,s=!1)),"stencil"in e&&("boolean"==typeof e.stencil?s=e.stencil:(k=e.stencil,f=!1)),"depthStencil"in e&&("boolean"==typeof e.depthStencil?f=s=e.depthStencil:(_=e.depthStencil,s=f=!1))):a=o=1;var D=null,T=null,j=null,E=null;if(Array.isArray(i))D=i.map(c);else if(i)D=[c(i)];else for(D=Array(v),i=0;i<v;++i)D[i]=l(a,o,h,d,m);for(a=a||D[0].width,o=o||D[0].height,b?T=c(b):f&&!s&&(T=l(a,o,A,"depth","uint32")),k?j=c(k):s&&!f&&(j=l(a,o,!1,"stencil","uint8")),_?E=c(_):!b&&!k&&s&&f&&(E=l(a,o,A,"depth stencil","depth stencil")),f=null,i=0;i<D.length;++i)u(D[i]),D[i]&&D[i].texture&&(s=ve[D[i].texture._texture.format]*be[D[i].texture._texture.type],null===f&&(f=s));return u(T),u(j),u(E),g(n),n.width=a,n.height=o,n.colorAttachments=D,n.depthAttachment=T,n.stencilAttachment=j,n.depthStencilAttachment=E,r.color=D.map(p),r.depth=p(T),r.stencil=p(j),r.depthStencil=p(E),r.width=n.width,r.height=n.height,y(n),r}var n=new d;return a.framebufferCount++,r(e,t),U(r,{resize:function(e,t){var i=0|e,a=0|t||i;if(i===n.width&&a===n.height)return r;for(var o=n.colorAttachments,f=0;f<o.length;++f)h(o[f],i,a);return h(n.depthAttachment,i,a),h(n.stencilAttachment,i,a),h(n.depthStencilAttachment,i,a),n.width=r.width=i,n.height=r.height=a,y(n),r},_reglType:"framebuffer",_framebuffer:n,destroy:function(){m(n),g(n)},use:function(e){b.setFBO({framebuffer:r},e)}})}var b={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 k=["uint8"];t.oes_texture_half_float&&k.push("half float","float16"),t.oes_texture_float&&k.push("float","float32");var _=0,A={};return U(b,{getFramebuffer:function(e){return"function"==typeof e&&"framebuffer"===e._reglType&&(e=e._framebuffer)instanceof d?e:null},create:v,createCube:function(e){function t(e){var i,a={color:null},o=0,f=null;i="rgba";var u="uint8",s=1;if("number"==typeof e?o=0|e:e?("shape"in e?o=e.shape[0]:("radius"in e&&(o=0|e.radius),"width"in e?o=0|e.width:"height"in e&&(o=0|e.height)),("color"in e||"colors"in e)&&(f=e.color||e.colors,Array.isArray(f)),f||("colorCount"in e&&(s=0|e.colorCount),"colorType"in e&&(u=e.colorType),"colorFormat"in e&&(i=e.colorFormat)),"depth"in e&&(a.depth=e.depth),"stencil"in e&&(a.stencil=e.stencil),"depthStencil"in e&&(a.depthStencil=e.depthStencil)):o=1,f)if(Array.isArray(f))for(e=[],i=0;i<f.length;++i)e[i]=f[i];else e=[f];else for(e=Array(s),f={radius:o,format:i,type:u},i=0;i<s;++i)e[i]=n.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=r[0].depth,a.stencil=r[0].stencil,a.depthStencil=r[0].depthStencil),r[i]?r[i](a):r[i]=v(a)}return U(t,{width:o,height:o,color:e})}var r=Array(6);return t(e),U(t,{faces:r,resize:function(e){var n=0|e;if(n===t.width)return t;var i=t.color;for(e=0;e<i.length;++e)i[e].resize(n);for(e=0;6>e;++e)r[e].resize(n);return t.width=t.height=n,t},_reglType:"framebufferCube",destroy:function(){r.forEach(function(e){e.destroy()})}})},clear:function(){X(A).forEach(m)},restore:function(){X(A).forEach(function(t){t.framebuffer=e.createFramebuffer(),y(t)})}})}function T(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function j(e,t,r,n){function i(e,t,r,n){this.name=e,this.id=t,this.location=r,this.info=n}function a(e,t){for(var r=0;r<e.length;++r)if(e[r].id===t.id)return void(e[r].location=t.location);e.push(t)}function o(r,n,i){if(!(o=(i=35632===r?s:c)[n])){var a=t.str(n),o=e.createShader(r);e.shaderSource(o,a),e.compileShader(o),i[n]=o}return o}function f(e,t){this.id=h++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],n.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function u(r,f){var u,s;u=o(35632,r.fragId),s=o(35633,r.vertId);var c=r.program=e.createProgram();e.attachShader(c,u),e.attachShader(c,s),e.linkProgram(c);var l=e.getProgramParameter(c,35718);n.profile&&(r.stats.uniformsCount=l);var p=r.uniforms;for(u=0;u<l;++u)if(s=e.getActiveUniform(c,u))if(1<s.size)for(var h=0;h<s.size;++h){var d=s.name.replace("[0]","["+h+"]");a(p,new i(d,t.id(d),e.getUniformLocation(c,d),s))}else a(p,new i(s.name,t.id(s.name),e.getUniformLocation(c,s.name),s));for(l=e.getProgramParameter(c,35721),n.profile&&(r.stats.attributesCount=l),p=r.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=[],h=0;return n.profile&&(r.getMaxUniformsCount=function(){var e=0;return p.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},r.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);X(s).forEach(t),s={},X(c).forEach(t),c={},p.forEach(function(t){e.deleteProgram(t.program)}),p.length=0,l={},r.shaderCount=0},program:function(e,t,n){var i=l[t];i||(i=l[t]={});var a=i[e];return a||(a=new f(t,e),r.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 E(e,t,r,n,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=n.framebufferWidth,s=n.framebufferHeight,c=null;return Q(i)?c=i:i&&(o=0|i.x,f=0|i.y,u=0|(i.width||n.framebufferWidth-o),s=0|(i.height||n.framebufferHeight-f),c=i.data||null),r(),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 r;return t.setFBO({framebuffer:e.framebuffer},function(){r=f(e)}),r}(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 U(function(){e.push.apply(e,S(arguments))},{def:function(){var n="v"+r++;return t.push(n),0<arguments.length&&(e.push(n,"="),e.push.apply(e,S(arguments)),e.push(";")),n},toString:function(){return C([0<t.length?"var "+t+";":"",C(e)])}})}function t(){function t(e,t){n(e,t,"=",r.def(e,t),";")}var r=e(),n=e(),i=r.toString,a=n.toString;return U(function(){r.apply(r,S(arguments))},{def:r.def,entry:r,exit:n,save:t,set:function(e,n,i){t(e,n),r(e,n,"=",i,";")},toString:function(){return i()+a()}})}var r=0,n=[],i=[],a=e(),o={};return{global:a,link:function(e){for(var t=0;t<i.length;++t)if(i[t]===e)return n[t];return t="g"+r++,n.push(t),i.push(e),t},block:e,proc:function(e,r){function n(){var e="a"+i.length;return i.push(e),e}var i=[];r=r||0;for(var a=0;a<r;++a)n();var f=(a=t()).toString;return o[e]=U(a,{arg:n,toString:function(){return C(["function(",i.join(),"){",f(),"}"])}})},scope:t,cond:function(){var e=C(arguments),r=t(),n=t(),i=r.toString,a=n.toString;return U(r,{then:function(){return r.apply(r,S(arguments)),this},else:function(){return n.apply(n,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,n.concat(t)).apply(null,i)}}}function F(e){return Array.isArray(e)||Q(e)||u(e)}function M(e){return e.sort(function(e,t){return"viewport"===e?-1:"viewport"===t?1:e<t?-1:1})}function P(e,t,r,n){this.thisDep=e,this.contextDep=t,this.propDep=r,this.append=n}function B(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function z(e){return new P(!1,!1,!1,e)}function I(e,t){var r=e.type;return 0===r?new P(!0,1<=(r=e.data.length),2<=r,t):4===r?new P((r=e.data).thisDep,r.contextDep,r.propDep,t):new P(3===r,2===r,1===r,t)}function R(e,t,r,n,i,o,f,u,s,c,l,p,h,d,g){function y(e){return e.replace(".","_")}function v(e,t,r){var n=y(e);ne.push(e),te[n]=ee[n]=!!r,ie[n]=t}function b(e,t,r){var n=y(e);ne.push(e),Array.isArray(r)?(ee[n]=r.slice(),te[n]=r.slice()):ee[n]=te[n]=r,ae[n]=t}function x(){var e=O(),r=e.link,n=e.global;e.id=ue++,e.batchId="0";var i=r(oe),a=e.shared={props:"a0"};Object.keys(oe).forEach(function(e){a[e]=n.def(i,".",e)});var o=e.next={},f=e.current={};Object.keys(ae).forEach(function(e){Array.isArray(ee[e])&&(o[e]=n.def(a.next,".",e),f[e]=n.def(a.current,".",e))});var u=e.constants={};Object.keys(fe).forEach(function(e){u[e]=n.def(JSON.stringify(fe[e]))}),e.invoke=function(t,n){switch(n.type){case 0:var i=["this",a.context,a.props,e.batchId];return t.def(r(n.data),".call(",i.slice(0,Math.max(n.data.length+1,4)),")");case 1:return t.def(a.props,n.data);case 2:return t.def(a.context,n.data);case 3:return t.def("this",n.data);case 4:return n.data.append(e,t),n.data.ref}},e.attribCache={};var s={};return e.scopeAttrib=function(e){if((e=t.id(e))in s)return s[e];var n=c.scope[e];return n||(n=c.scope[e]=new Y),s[e]=r(n)},e}function w(e,t){var r=e.static,n=e.dynamic;if("framebuffer"in r){var i=r.framebuffer;return i?(i=u.getFramebuffer(i),z(function(e,t){var r=e.link(i),n=e.shared;return t.set(n.framebuffer,".next",r),n=n.context,t.set(n,".framebufferWidth",r+".width"),t.set(n,".framebufferHeight",r+".height"),r})):z(function(e,t){var r=e.shared;return t.set(r.framebuffer,".next","null"),r=r.context,t.set(r,".framebufferWidth",r+".drawingBufferWidth"),t.set(r,".framebufferHeight",r+".drawingBufferHeight"),"null"})}if("framebuffer"in n){var a=n.framebuffer;return I(a,function(e,t){var r=e.invoke(t,a),n=e.shared,i=n.framebuffer;r=t.def(i,".getFramebuffer(",r,")");return t.set(i,".next",r),n=n.context,t.set(n,".framebufferWidth",r+"?"+r+".width:"+n+".drawingBufferWidth"),t.set(n,".framebufferHeight",r+"?"+r+".height:"+n+".drawingBufferHeight"),r})}return null}function k(e){function r(e){if(e in n){var r=t.id(n[e]);return(e=z(function(){return r})).id=r,e}if(e in i){var a=i[e];return I(a,function(e,t){var r=e.invoke(t,a);return t.def(e.shared.strings,".id(",r,")")})}return null}var n=e.static,i=e.dynamic,a=r("frag"),o=r("vert"),f=null;return B(a)&&B(o)?(f=l.program(o.id,a.id),e=z(function(e,t){return e.link(f)})):e=new P(a&&a.thisDep||o&&o.thisDep,a&&a.contextDep||o&&o.contextDep,a&&a.propDep||o&&o.propDep,function(e,t){var r,n,i=e.shared.shader;return r=a?a.append(e,t):t.def(i,".","frag"),n=o?o.append(e,t):t.def(i,".","vert"),t.def(i+".program("+n+","+r+")")}),{frag:a,vert:o,progVar:e,program:f}}function _(e,t){function r(e,t){if(e in n){var r=0|n[e];return z(function(e,n){return t&&(e.OFFSET=r),r})}if(e in i){var o=i[e];return I(o,function(e,r){var n=e.invoke(r,o);return t&&(e.OFFSET=n),n})}return t&&a?z(function(e,t){return e.OFFSET="0",0}):null}var n=e.static,i=e.dynamic,a=function(){if("elements"in n){var e=n.elements;F(e)?e=o.getElements(o.create(e,!0)):e&&(e=o.getElements(e));var t=z(function(t,r){if(e){var n=t.link(e);return t.ELEMENTS=n}return t.ELEMENTS=null});return t.value=e,t}if("elements"in i){var r=i.elements;return I(r,function(e,t){var n=(i=e.shared).isBufferArgs,i=i.elements,a=e.invoke(t,r),o=t.def("null");n=t.def(n,"(",a,")"),a=e.cond(n).then(o,"=",i,".createStream(",a,");").else(o,"=",i,".getElements(",a,");");return t.entry(a),t.exit(e.cond(n).then(i,".destroyStream(",o,");")),e.ELEMENTS=o})}return null}(),f=r("offset",!0);return{elements:a,primitive:function(){if("primitive"in n){var e=n.primitive;return z(function(t,r){return re[e]})}if("primitive"in i){var t=i.primitive;return I(t,function(e,r){var n=e.constants.primTypes,i=e.invoke(r,t);return r.def(n,"[",i,"]")})}return a?B(a)?a.value?z(function(e,t){return t.def(e.ELEMENTS,".primType")}):z(function(){return 4}):new P(a.thisDep,a.contextDep,a.propDep,function(e,t){var r=e.ELEMENTS;return t.def(r,"?",r,".primType:",4)}):null}(),count:function(){if("count"in n){var e=0|n.count;return z(function(){return e})}if("count"in i){var t=i.count;return I(t,function(e,r){return e.invoke(r,t)})}return a?B(a)?a?f?new P(f.thisDep,f.contextDep,f.propDep,function(e,t){return t.def(e.ELEMENTS,".vertCount-",e.OFFSET)}):z(function(e,t){return t.def(e.ELEMENTS,".vertCount")}):z(function(){return-1}):new P(a.thisDep||f.thisDep,a.contextDep||f.contextDep,a.propDep||f.propDep,function(e,t){var r=e.ELEMENTS;return e.OFFSET?t.def(r,"?",r,".vertCount-",e.OFFSET,":-1"):t.def(r,"?",r,".vertCount:-1")}):null}(),instances:r("instances",!1),offset:f}}function A(e,r){var n=e.static,a=e.dynamic,o={};return Object.keys(n).forEach(function(e){var r=n[e],a=t.id(e),f=new Y;if(F(r))f.state=1,f.buffer=i.getBuffer(i.create(r,34962,!1,!0)),f.type=0;else if(s=i.getBuffer(r))f.state=1,f.buffer=s,f.type=0;else if("constant"in r){var u=r.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(r.buffer)?i.getBuffer(i.create(r.buffer,34962,!1,!0)):i.getBuffer(r.buffer),c=0|r.offset,l=0|r.stride,p=0|r.size,h=!!r.normalized,d=0;"type"in r&&(d=Z[r.type]),r=0|r.divisor,f.buffer=s,f.state=1,f.size=p,f.normalized=h,f.type=d||s.dtype,f.offset=c,f.stride=l,f.divisor=r}o[e]=z(function(e,t){var r=e.attribCache;if(a in r)return r[a];var n={isStream:!1};return Object.keys(f).forEach(function(e){n[e]=f[e]}),f.buffer&&(n.buffer=e.link(f.buffer),n.type=n.type||n.buffer+".dtype"),r[a]=n})}),Object.keys(a).forEach(function(e){var t=a[e];o[e]=I(t,function(e,r){function n(e){r(u[e],"=",i,".",e,"|0;")}var i=e.invoke(r,t),a=e.shared,o=a.isBufferArgs,f=a.buffer,u={isStream:r.def(!1)},s=new Y;s.state=1,Object.keys(s).forEach(function(e){u[e]=r.def(""+s[e])});var c=u.buffer,l=u.type;return r("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;"),n("size"),n("offset"),n("stride"),n("divisor"),r("}}"),r.exit("if(",u.isStream,"){",f,".destroyStream(",c,");","}"),u})}),o}function D(e,t,r,n,i){var o=w(e),f=function(e,t,r){function n(e){if(e in i){var r=i[e];e=!0;var n,o,f=0|r.x,u=0|r.y;return"width"in r?n=0|r.width:e=!1,"height"in r?o=0|r.height:e=!1,new P(!e&&t&&t.thisDep,!e&&t&&t.contextDep,!e&&t&&t.propDep,function(e,t){var i=e.shared.context,a=n;"width"in r||(a=t.def(i,".","framebufferWidth","-",f));var s=o;return"height"in r||(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 r=e.invoke(t,s),n=e.shared.context,i=t.def(r,".x|0"),a=t.def(r,".y|0");return[i,a,t.def('"width" in ',r,"?",r,".width|0:","(",n,".","framebufferWidth","-",i,")"),r=t.def('"height" in ',r,"?",r,".height|0:","(",n,".","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 P(t.thisDep,t.contextDep,t.propDep,function(e,t){var r=e.shared.context;return[0,0,t.def(r,".","framebufferWidth"),t.def(r,".","framebufferHeight")]}):null}var i=e.static,a=e.dynamic;if(e=n("viewport")){var o=e;e=new P(e.thisDep,e.contextDep,e.propDep,function(e,t){var r=o.append(e,t),n=e.shared.context;return t.set(n,".viewportWidth",r[2]),t.set(n,".viewportHeight",r[3]),r})}return{viewport:e,scissor_box:n("scissor.box")}}(e,o),u=_(e),s=function(e,t){var r=e.static,n=e.dynamic,i={};return ne.forEach(function(e){function t(t,a){if(e in r){var f=t(r[e]);i[o]=z(function(){return f})}else if(e in n){var u=n[e];i[o]=I(u,function(e,t){return a(e,t,e.invoke(t,u))})}}var o=y(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,r){return r});case"depth.func":return t(function(e){return _e[e]},function(e,t,r){return t.def(e.constants.compareFuncs,"[",r,"]")});case"depth.range":return t(function(e){return e},function(e,t,r){return[t.def("+",r,"[0]"),t=t.def("+",r,"[1]")]});case"blend.func":return t(function(e){return[ke["srcRGB"in e?e.srcRGB:e.src],ke["dstRGB"in e?e.dstRGB:e.dst],ke["srcAlpha"in e?e.srcAlpha:e.src],ke["dstAlpha"in e?e.dstAlpha:e.dst]]},function(e,t,r){function n(e,n){return t.def('"',e,n,'" in ',r,"?",r,".",e,n,":",r,".",e)}e=e.constants.blendFuncs;var i=n("src","RGB"),a=n("dst","RGB"),o=(i=t.def(e,"[",i,"]"),t.def(e,"[",n("src","Alpha"),"]"));return[i,a=t.def(e,"[",a,"]"),o,e=t.def(e,"[",n("dst","Alpha"),"]")]});case"blend.equation":return t(function(e){return"string"==typeof e?[J[e],J[e]]:"object"==typeof e?[J[e.rgb],J[e.alpha]]:void 0},function(e,t,r){var n=e.constants.blendEquations,i=t.def(),a=t.def();return(e=e.cond("typeof ",r,'==="string"')).then(i,"=",a,"=",n,"[",r,"];"),e.else(i,"=",n,"[",r,".rgb];",a,"=",n,"[",r,".alpha];"),t(e),[i,a]});case"blend.color":return t(function(e){return a(4,function(t){return+e[t]})},function(e,t,r){return a(4,function(e){return t.def("+",r,"[",e,"]")})});case"stencil.mask":return t(function(e){return 0|e},function(e,t,r){return t.def(r,"|0")});case"stencil.func":return t(function(e){return[_e[e.cmp||"keep"],e.ref||0,"mask"in e?e.mask:-1]},function(e,t,r){return[e=t.def('"cmp" in ',r,"?",e.constants.compareFuncs,"[",r,".cmp]",":",7680),t.def(r,".ref|0"),t=t.def('"mask" in ',r,"?",r,".mask|0:-1")]});case"stencil.opFront":case"stencil.opBack":return t(function(t){return["stencil.opBack"===e?1029:1028,Ae[t.fail||"keep"],Ae[t.zfail||"keep"],Ae[t.zpass||"keep"]]},function(t,r,n){function i(e){return r.def('"',e,'" in ',n,"?",a,"[",n,".",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,r){return[t.def(r,".factor|0"),t=t.def(r,".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,r){return t.def(r,'==="front"?',1028,":",1029)});case"lineWidth":return t(function(e){return e},function(e,t,r){return r});case"frontFace":return t(function(e){return De[e]},function(e,t,r){return t.def(r+'==="cw"?2304:2305')});case"colorMask":return t(function(e){return e.map(function(e){return!!e})},function(e,t,r){return a(4,function(e){return"!!"+r+"["+e+"]"})});case"sample.coverage":return t(function(e){return["value"in e?e.value:1,!!e.invert]},function(e,t,r){return[t.def('"value" in ',r,"?+",r,".value:1"),t=t.def("!!",r,".invert")]})}}),i}(e),c=k(e),l=f.viewport;return l&&(s.viewport=l),(f=f[l=y("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,r=e.static;if(e=e.dynamic,"profile"in r){var n=!!r.profile;(t=z(function(e,t){return n})).enable=n}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 r=e.static,n=e.dynamic,i={};return Object.keys(r).forEach(function(e){var t,n=r[e];if("number"==typeof n||"boolean"==typeof n)t=z(function(){return n});else if("function"==typeof n){var o=n._reglType;"texture2d"===o||"textureCube"===o?t=z(function(e){return e.link(n)}):"framebuffer"!==o&&"framebufferCube"!==o||(t=z(function(e){return e.link(n.color[0])}))}else m(n)&&(t=z(function(e){return e.global.def("[",a(n.length,function(e){return n[e]}),"]")}));t.value=n,i[e]=t}),Object.keys(n).forEach(function(e){var t=n[e];i[e]=I(t,function(e,r){return e.invoke(r,t)})}),i}(r),o.attributes=A(t),o.context=function(e){var t=e.static,r=e.dynamic,n={};return Object.keys(t).forEach(function(e){var r=t[e];n[e]=z(function(e,t){return"number"==typeof r||"boolean"==typeof r?""+r:e.link(r)})}),Object.keys(r).forEach(function(e){var t=r[e];n[e]=I(t,function(e,r){return e.invoke(r,t)})}),n}(n),o}function T(e,t,r){var n=e.shared.context,i=e.scope();Object.keys(r).forEach(function(a){t.save(n,"."+a),i(n,".",a,"=",r[a].append(e,t),";")}),t(i)}function j(e,t,r,n){var i,a=(f=e.shared).gl,o=f.framebuffer;$&&(i=t.def(f.extensions,".webgl_draw_buffers"));var f=(u=e.constants).drawBuffer,u=u.backBuffer;e=r?r.append(e,t):t.def(o,".next"),n||t("if(",e,"!==",o,".cur){"),t("if(",e,"){",a,".bindFramebuffer(",36160,",",e,".framebuffer);"),$&&t(i,".drawBuffersWEBGL(",f,"[",e,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",36160,",null);"),$&&t(i,".drawBuffersWEBGL(",u,");"),t("}",o,".cur=",e,";"),n||t("}")}function E(e,t,r){var n=e.shared,i=n.gl,o=e.current,f=e.next,u=n.current,s=n.next,c=e.cond(u,".dirty");ne.forEach(function(t){var n,l;if(!((t=y(t))in r.state))if(t in f){n=f[t],l=o[t];var p=a(ee[t].length,function(e){return c.def(n,"[",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 n=c.def(s,".",t),p=e.cond(n,"!==",u,".",t),c(p),t in ie?p(e.cond(n).then(i,".enable(",ie[t],");").else(i,".disable(",ie[t],");"),u,".",t,"=",n,";"):p(i,".",ae[t],"(",n,");",u,".",t,"=",n,";")}),0===Object.keys(r.state).length&&c(u,".dirty=false;"),t(c)}function S(e,t,r,n){var i=e.shared,a=e.current,o=i.current,f=i.gl;M(Object.keys(r)).forEach(function(i){var u=r[i];if(!n||n(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){K&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function R(e,t,r,n,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++;"),d&&(n?e(c=t.def(),"=",g,".getNumPendingQueries();"):e(g,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",a(),"-",s,";"),d&&(n?e(g,".pushScopeStats(",c,",",g,".getNumPendingQueries(),",p,");"):e(g,".endQuery();"))}function u(e){var r=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",r,";")}var s,c,l=e.shared,p=e.stats,h=l.current,g=l.timer;if(r=r.profile){if(B(r))return void(r.enable?(o(t),f(t.exit),u("true")):u("false"));u(r=r.append(e,t))}else r=t.def(h,".profile");o(l=e.block()),t("if(",r,"){",l,"}"),f(e=e.block()),t.exit("if(",r,"){",e,"}")}function L(e,t,r,n,i){function a(r,n,i){function a(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var r,a=i.type;r=i.size?t.def(i.size,"||",n):n,t("if(",c,".type!==",a,"||",c,".size!==",r,"||",h.map(function(e){return c+"."+e+"!=="+i[e]}).join("||"),"){",u,".bindBuffer(",34962,",",l,".buffer);",u,".vertexAttribPointer(",[s,r,a,i.normalized,i.stride,i.offset],");",c,".type=",a,";",c,".size=",r,";",h.map(function(e){return c+"."+e+"="+i[e]+";"}).join(""),"}"),K&&(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(r,".location"),c=t.def(o.attributes,"[",s,"]");r=i.state;var l=i.buffer,p=[i.x,i.y,i.z,i.w],h=["buffer","normalized","offset","stride"];1===r?a():2===r?f():(t("if(",r,"===",1,"){"),a(),t("}else{"),f(),t("}"))}var o=e.shared;n.forEach(function(n){var o,f=n.name,u=r.attributes[f];if(u){if(!i(u))return;o=u.append(e,t)}else{if(!i(Te))return;var s=e.scopeAttrib(f);o={},Object.keys(new Y).forEach(function(e){o[e]=t.def(s,".",e)})}a(e.link(n),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}}(n.info.type),o)})}function U(e,r,n,i,o){for(var f,u=e.shared,s=u.gl,c=0;c<i.length;++c){var l,p=(g=i[c]).name,h=g.info.type,d=n.uniforms[p],g=e.link(g)+".location";if(d){if(!o(d))continue;if(B(d)){if(p=d.value,35678===h||35680===h)r(s,".uniform1i(",g,",",(h=e.link(p._texture||p.color[0]._texture))+".bind());"),r.exit(h,".unbind();");else if(35674===h||35675===h||35676===h)p=e.global.def("new Float32Array(["+Array.prototype.slice.call(p)+"])"),d=2,35675===h?d=3:35676===h&&(d=4),r(s,".uniformMatrix",d,"fv(",g,",false,",p,");");else{switch(h){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"}r(s,".uniform",f,"(",g,",",m(p)?Array.prototype.slice.call(p):p,");")}continue}l=d.append(e,r)}else{if(!o(Te))continue;l=r.def(u.uniforms,"[",t.id(p),"]")}switch(35678===h?r("if(",l,"&&",l,'._reglType==="framebuffer"){',l,"=",l,".color[0];","}"):35680===h&&r("if(",l,"&&",l,'._reglType==="framebufferCube"){',l,"=",l,".color[0];","}"),p=1,h){case 35678:case 35680:r(s,".uniform1i(",g,",",h=r.def(l,"._texture"),".bind());"),r.exit(h,".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(r(s,".uniform",f,"(",g,","),"M"===f.charAt(0)){g=Math.pow(h-35674+2,2);var y=e.global.def("new Float32Array(",g,")");r("false,(Array.isArray(",l,")||",l," instanceof Float32Array)?",l,":(",a(g,function(e){return y+"["+e+"]="+l+"["+e+"]"}),",",y,")")}else r(1<p?a(p,function(e){return l+"["+e+"]"}):l);r(");")}}function N(e,t,r,n){function i(i){var a=p[i];return a?a.contextDep&&n.contextDynamic||a.propDep?a.append(e,r):a.append(e,t):t.def(l,".",i)}function a(){function e(){r(u,".drawElementsInstancedANGLE(",[d,m,y,g+"<<(("+y+"-5121)>>1)",f],");")}function t(){r(u,".drawArraysInstancedANGLE(",[d,g,m,f],");")}h?v?e():(r("if(",h,"){"),e(),r("}else{"),t(),r("}")):t()}function o(){function e(){r(c+".drawElements("+[d,m,y,g+"<<(("+y+"-5121)>>1)"]+");")}function t(){r(c+".drawArrays("+[d,g,m]+");")}h?v?e():(r("if(",h,"){"),e(),r("}else{"),t(),r("}")):t()}var f,u,s=e.shared,c=s.gl,l=s.draw,p=n.draw,h=function(){var i=p.elements,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","elements"),i&&a("if("+i+")"+c+".bindBuffer(34963,"+i+".buffer.buffer);"),i}(),d=i("primitive"),g=i("offset"),m=function(){var i=p.count,a=t;return i?((i.contextDep&&n.contextDynamic||i.propDep)&&(a=r),i=i.append(e,a)):i=a.def(l,".","count"),i}();if("number"==typeof m){if(0===m)return}else r("if(",m,"){"),r.exit("}");K&&(f=i("instances"),u=e.instancing);var y=h+".type",v=p.elements&&B(p.elements);K&&("number"!=typeof f||0<=f)?"string"==typeof f?(r("if(",f,">0){"),a(),r("}else if(",f,"<0){"),o(),r("}")):a():o()}function H(e,t,r,n,i){return i=(t=x()).proc("body",i),K&&(t.instancing=i.def(t.shared.extensions,".angle_instanced_arrays")),e(t,i,r,n),t.compile().body}function q(e,t,r,n){C(e,t),L(e,t,r,n.attributes,function(){return!0}),U(e,t,r,n.uniforms,function(){return!0}),N(e,t,t,r)}function W(e,t,r,n){function i(){return!0}e.batchId="a1",C(e,t),L(e,t,r,n.attributes,i),U(e,t,r,n.uniforms,i),N(e,t,t,r)}function G(e,t,r,n){function i(e){return e.contextDep&&o||e.propDep}function a(e){return!i(e)}C(e,t);var o=r.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),r.needsContext&&T(e,c,r.context),r.needsFramebuffer&&j(e,c,r.framebuffer),S(e,c,r.state,i),r.profile&&i(r.profile)&&R(e,c,r,!1,!0),n?(L(e,s,r,n.attributes,a),L(e,c,r,n.attributes,i),U(e,s,r,n.uniforms,a),U(e,c,r,n.uniforms,i),N(e,s,c,r)):(t=e.global.def("{}"),n=r.shader.progVar.append(e,c),u=c.def(n,".id"),s=c.def(t,"[",u,"]"),c(e.shared.gl,".useProgram(",n,".program);","if(!",s,"){",s,"=",t,"[",u,"]=",e.link(function(t){return H(W,e,r,t,2)}),"(",n,");}",s,".call(this,a0[",f,"],",f,");"))}function Q(e,r){function n(t){var n=r.shader[t];n&&i.set(a.shader,"."+t,n.append(e,i))}var i=e.proc("scope",3);e.batchId="a2";var a=e.shared,o=a.current;T(e,i,r.context),r.framebuffer&&r.framebuffer.append(e,i),M(Object.keys(r.state)).forEach(function(t){var n=r.state[t].append(e,i);m(n)?n.forEach(function(r,n){i.set(e.next[t],"["+n+"]",r)}):i.set(a.next,"."+t,n)}),R(e,i,r,!0,!0),["elements","offset","count","instances","primitive"].forEach(function(t){var n=r.draw[t];n&&i.set(a.draw,"."+t,""+n.append(e,i))}),Object.keys(r.uniforms).forEach(function(n){i.set(a.uniforms,"["+t.id(n)+"]",r.uniforms[n].append(e,i))}),Object.keys(r.attributes).forEach(function(t){var n=r.attributes[t].append(e,i),a=e.scopeAttrib(t);Object.keys(new Y).forEach(function(e){i.set(a,"."+e,n[e])})}),n("vert"),n("frag"),0<Object.keys(r.state).length&&(i(o,".dirty=true;"),i.exit(o,".dirty=true;")),i("a1(",e.shared.context,",a0,",e.batchId,");")}function X(e,t,r){var n=t.static[r];if(n&&function(e){if("object"==typeof e&&!m(e)){for(var t=Object.keys(e),r=0;r<t.length;++r)if(V.isDynamic(e[t[r]]))return!0;return!1}}(n)){var i=e.global,a=Object.keys(n),o=!1,f=!1,u=!1,s=e.global.def("{}");a.forEach(function(t){var r=n[t];if(V.isDynamic(r))"function"==typeof r&&(r=n[t]=V.unbox(r)),t=I(r,null),o=o||t.thisDep,u=u||t.propDep,f=f||t.contextDep;else{switch(i(s,".",t,"="),typeof r){case"number":i(r);break;case"string":i('"',r,'"');break;case"object":Array.isArray(r)&&i("[",r.join(),"]");break;default:i(e.link(r))}i(";")}}),t.dynamic[r]=new V.DynamicVariable(4,{thisDep:o,contextDep:f,propDep:u,ref:s,append:function(e,t){a.forEach(function(r){var i=n[r];V.isDynamic(i)&&(i=e.invoke(t,i),t(s,".",r,"=",i,";"))})}}),delete t.static[r]}}var Y=c.Record,J={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(J.min=32775,J.max=32776);var K=r.angle_instanced_arrays,$=r.webgl_draw_buffers,ee={dirty:!0,profile:g.profile},te={},ne=[],ie={},ae={};v("dither",3024),v("blend.enable",3042),b("blend.color","blendColor",[0,0,0,0]),b("blend.equation","blendEquationSeparate",[32774,32774]),b("blend.func","blendFuncSeparate",[1,0,1,0]),v("depth.enable",2929,!0),b("depth.func","depthFunc",513),b("depth.range","depthRange",[0,1]),b("depth.mask","depthMask",!0),b("colorMask","colorMask",[!0,!0,!0,!0]),v("cull.enable",2884),b("cull.face","cullFace",1029),b("frontFace","frontFace",2305),b("lineWidth","lineWidth",1),v("polygonOffset.enable",32823),b("polygonOffset.offset","polygonOffset",[0,0]),v("sample.alpha",32926),v("sample.enable",32928),b("sample.coverage","sampleCoverage",[1,!1]),v("stencil.enable",2960),b("stencil.mask","stencilMask",-1),b("stencil.func","stencilFunc",[519,0,-1]),b("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),b("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),v("scissor.enable",3089),b("scissor.box","scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),b("viewport","viewport",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var oe={gl:e,context:h,strings:t,next:te,current:ee,draw:p,elements:o,buffer:i,shader:l,attributes:c.state,uniforms:s,framebuffer:u,extensions:r,timer:d,isBufferArgs:F},fe={primTypes:re,compareFuncs:_e,blendFuncs:ke,blendEquations:J,stencilOps:Ae,glTypes:Z,orientationType:De};$&&(fe.backBuffer=[1029],fe.drawBuffer=a(n.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"),r=e.proc("refresh"),i=e.block();t(i),r(i);var o,f=e.shared,u=f.gl,s=f.next,c=f.current;i(c,".dirty=false;"),j(e,t),j(e,r,null,!0),K&&(o=e.link(K));for(var l=0;l<n.maxAttributes;++l){var p=r.def(f.attributes,"[",l,"]"),h=e.cond(p,".buffer");h.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;"),r(h),K&&r(o,".vertexAttribDivisorANGLE(",l,",",p,".divisor);")}return Object.keys(ie).forEach(function(n){var a=ie[n],o=i.def(s,".",n),f=e.block();f("if(",o,"){",u,".enable(",a,")}else{",u,".disable(",a,")}",c,".",n,"=",o,";"),r(f),t("if(",o,"!==",c,".",n,"){",f,"}")}),Object.keys(ae).forEach(function(n){var o,f,l=ae[n],p=ee[n],h=e.block();h(u,".",l,"("),m(p)?(l=p.length,o=e.global.def(s,".",n),f=e.global.def(c,".",n),h(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("||"),"){",h,"}")):(o=i.def(s,".",n),f=i.def(c,".",n),h(o,");",c,".",n,"=",o,";"),t("if(",o,"!==",f,"){",h,"}")),r(h)}),e.compile()}(),compile:function(e,t,r,n,i){var a=x();return a.stats=a.link(i),Object.keys(t.static).forEach(function(e){X(a,t,e)}),we.forEach(function(t){X(a,e,t)}),r=D(e,t,r,n),function(e,t){var r=e.proc("draw",1);C(e,r),T(e,r,t.context),j(e,r,t.framebuffer),E(e,r,t),S(e,r,t.state),R(e,r,t,!1,!0);var n=t.shader.progVar.append(e,r);if(r(e.shared.gl,".useProgram(",n,".program);"),t.shader.program)q(e,r,t,t.shader.program);else{var i=e.global.def("{}"),a=r.def(n,".id"),o=r.def(i,"[",a,"]");r(e.cond(o).then(o,".call(this,a0);").else(o,"=",i,"[",a,"]=",e.link(function(r){return H(q,e,t,r,1)}),"(",n,");",o,".call(this,a0);"))}0<Object.keys(t.state).length&&r(e.shared.current,".dirty=true;")}(a,r),Q(a,r),function(e,t){function r(e){return e.contextDep&&i||e.propDep}var n=e.proc("batch",2);e.batchId="0",C(e,n);var i=!1,a=!0;Object.keys(t.context).forEach(function(e){i=i||t.context[e].propDep}),i||(T(e,n,t.context),a=!1);var o=!1;if((f=t.framebuffer)?(f.propDep?i=o=!0:f.contextDep&&i&&(o=!0),o||j(e,n,f)):j(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(i=!0),E(e,n,t),S(e,n,t.state,function(e){return!r(e)}),t.profile&&r(t.profile)||R(e,n,t,!1,"a1"),t.contextDep=i,t.needsContext=a,t.needsFramebuffer=o,(a=t.shader.progVar).contextDep&&i||a.propDep)G(e,n,t,null);else if(a=a.append(e,n),n(e.shared.gl,".useProgram(",a,".program);"),t.shader.program)G(e,n,t,t.shader.program);else{var f=e.global.def("{}"),u=(o=n.def(a,".id"),n.def(f,"[",o,"]"));n(e.cond(u).then(u,".call(this,a0,a1);").else(u,"=",f,"[",o,"]=",e.link(function(r){return H(G,e,t,r,2)}),"(",a,");",u,".call(this,a0,a1);"))}0<Object.keys(t.state).length&&n(e.shared.current,".dirty=true;")}(a,r),a.compile()}}}function L(e,t){for(var r=0;r<e.length;++r)if(e[r]===t)return r;return-1}var U=function(e,t){for(var r=Object.keys(t),n=0;n<r.length;++n)e[r[n]]=t[r[n]];return e},N=0,V={DynamicVariable:e,define:function(r,n){return new e(r,t(n+""))},isDynamic:function(t){return"function"==typeof t&&!t._reglType||t instanceof e},unbox:function(t,r){return"function"==typeof t?new e(0,t):t},accessor:t},H={next:"function"==typeof requestAnimationFrame?function(e){return requestAnimationFrame(e)}:function(e){return setTimeout(e,16)},cancel:"function"==typeof cancelAnimationFrame?function(e){return cancelAnimationFrame(e)}:clearTimeout},q="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},W=f();W.zero=f();var G=function(e,t){var r=1;t.ext_texture_filter_anisotropic&&(r=e.getParameter(34047));var n=1,i=1;t.webgl_draw_buffers&&(n=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=W.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]),W.freeType(f)}}return f=!0,f=e.createTexture(),o=W.allocType(5121,36),e.activeTexture(33984),e.bindTexture(34067,f),e.texImage2D(34069,0,6408,3,3,0,6408,5121,o),W.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:r,maxDrawbuffers:n,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}},Q=function(e){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof Uint8ClampedArray},X=function(e){return Object.keys(e).map(function(t){return e[t]})},Y={shape:function(e){for(var t=[];e.length;e=e[0])t.push(e.length);return t},flatten:function(e,t,r,n){var i=1;if(t.length)for(var a=0;a<t.length;++a)i*=t[a];else i=0;switch(r=n||W.allocType(r,i),t.length){case 0:break;case 1:for(n=t[0],t=0;t<n;++t)r[t]=e[t];break;case 2:for(n=t[0],t=t[1],a=i=0;a<n;++a)for(var o=e[a],f=0;f<t;++f)r[i++]=o[f];break;case 3:s(e,t[0],t[1],t[2],r,0);break;default:!function e(t,r,n,i,a){for(var o=1,f=n+1;f<r.length;++f)o*=r[f];var u=r[n];if(4==r.length-n){var c=r[n+1],l=r[n+2];for(r=r[n+3],f=0;f<u;++f)s(t[f],c,l,r,i,a),a+=o}else for(f=0;f<u;++f)e(t[f],r,n+1,i,a),a+=o}(e,t,0,r,0)}return r}},J={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Z={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},K={dynamic:35048,stream:35040,static:35044},$=Y.flatten,ee=Y.shape,te=[];te[5120]=1,te[5122]=2,te[5124]=4,te[5121]=1,te[5123]=2,te[5125]=4,te[5126]=4;var re={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},ne=new Float32Array(1),ie=new Uint32Array(ne.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=y("HTMLCanvasElement"),se=y("CanvasRenderingContext2D"),ce=y("ImageBitmap"),le=y("HTMLImageElement"),pe=y("HTMLVideoElement"),he=Object.keys(J).concat([ue,se,ce,le,pe]),de=[];de[5121]=1,de[5126]=4,de[36193]=2,de[5123]=2,de[5125]=4;var ge=[];ge[32854]=2,ge[32855]=2,ge[36194]=2,ge[34041]=4,ge[33776]=.5,ge[33777]=.5,ge[33778]=1,ge[33779]=1,ge[35986]=.5,ge[35987]=1,ge[34798]=1,ge[35840]=.5,ge[35841]=.25,ge[35842]=.5,ge[35843]=.25,ge[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 ye=function(e,t,r,n,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 r=t.renderbuffer;e.bindRenderbuffer(36161,null),e.deleteRenderbuffer(r),t.renderbuffer=null,t.refCount=0,delete c[t.id],n.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&&(n.getTotalRenderbufferSize=function(){var e=0;return Object.keys(c).forEach(function(t){e+=c[t].stats.size}),e}),{create:function(t,r){function o(t,r){var n=0,a=0,c=32854;if("object"==typeof t&&t?("shape"in t?(n=0|(a=t.shape)[0],a=0|a[1]):("radius"in t&&(n=a=0|t.radius),"width"in t&&(n=0|t.width),"height"in t&&(a=0|t.height)),"format"in t&&(c=f[t.format])):"number"==typeof t?(n=0|t,a="number"==typeof r?0|r:n):t||(n=a=1),n!==s.width||a!==s.height||c!==s.format)return o.width=s.width=n,o.height=s.height=a,s.format=c,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,c,n,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,n.renderbufferCount++,o(t,r),o.resize=function(t,r){var n=0|t,a=0|r||n;return n===s.width&&a===s.height?o:(o.width=s.width=n,o.height=s.height=a,e.bindRenderbuffer(36161,s.renderbuffer),e.renderbufferStorage(36161,s.format,n,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(){X(c).forEach(o)},restore:function(){X(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)}}},ve=[];ve[6408]=4,ve[6407]=3;var be=[];be[5121]=1,be[5126]=4,be[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(" "),ke={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},_e={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},Ae={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},De={cw:2304,ccw:2305},Te=new P(!1,!1,!1,function(){});return function(e){function t(){if(0===Y.length)k&&k.update(),$=null;else{$=H.next(t),l();for(var e=Y.length-1;0<=e;--e){var r=Y[e];r&&r(O,null,0)}m.flush(),k&&k.update()}}function r(){!$&&0<Y.length&&($=H.next(t))}function n(){$&&(H.cancel(t),$=null)}function a(e){e.preventDefault(),n(),J.forEach(function(e){e()})}function o(e){m.getError(),v.restore(),B.restore(),M.restore(),z.restore(),I.restore(),N.restore(),k&&k.restore(),W.procs.refresh(),r(),Z.forEach(function(e){e()})}function f(e){function t(e){var t={},r={};return Object.keys(e).forEach(function(n){var i=e[n];V.isDynamic(i)?r[n]=V.unbox(i,n):t[n]=i}),{dynamic:r,static:t}}var r=t(e.context||{}),n=t(e.uniforms||{}),i=t(e.attributes||{}),a=t(function(e){function t(e){if(e in r){var t=r[e];delete r[e],Object.keys(t).forEach(function(n){r[e+"."+n]=t[n]})}}var r=U({},e);return delete r.uniforms,delete r.attributes,delete r.context,"stencil"in r&&r.stencil.op&&(r.stencil.opBack=r.stencil.opFront=r.stencil.op,delete r.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),r}(e));e={gpuTime:0,cpuTime:0,count:0};var o=(r=W.compile(a,i,n,r,e)).draw,f=r.batch,u=r.scope,s=[];return U(function(e,t){var r;if("function"==typeof e)return u.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(r=0;r<e;++r)u.call(this,null,t,r);else{if(!Array.isArray(e))return u.call(this,e,t,0);for(r=0;r<e.length;++r)u.call(this,e[r],t,r)}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 r=0;W.procs.poll();var n=t.color;n&&(m.clearColor(+n[0]||0,+n[1]||0,+n[2]||0,+n[3]||0),r|=16384),"depth"in t&&(m.clearDepth(+t.depth),r|=256),"stencil"in t&&(m.clearStencil(0|t.stencil),r|=1024),m.clear(r)}function s(e){return Y.push(e),r(),{cancel:function(){var t=L(Y,e);Y[t]=function e(){var t=L(Y,e);Y[t]=Y[Y.length-1],--Y.length,0>=Y.length&&n()}}}}function c(){var e=Q.viewport,t=Q.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=g(),c(),W.procs.poll()}function p(){c(),W.procs.refresh(),k&&k.update()}function g(){return(q()-_)/1e3}if(!(e=i(e)))return null;var m=e.gl,y=m.getContextAttributes();m.isContextLost();var v=function(e,t){function r(t){var r;t=t.toLowerCase();try{r=n[t]=e.getExtension(t)}catch(e){}return!!r}for(var n={},i=0;i<t.extensions.length;++i){var a=t.extensions[i];if(!r(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(r),{extensions:n,restore:function(){Object.keys(n).forEach(function(e){if(!r(e))throw Error("(regl): error restoring extension "+e)})}}}(m,e);if(!v)return null;var b=function(){var e={"":0},t=[""];return{id:function(r){var n=e[r];return n||(n=e[r]=t.length,t.push(r),n)},str:function(e){return t[e]}}}(),x={bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},w=v.extensions,k=function(e,t){function r(e,t,r){var n=o.pop()||new function(){this.endQueryIndex=this.startQueryIndex=-1,this.sum=0,this.stats=null};n.startQueryIndex=e,n.endQueryIndex=t,n.sum=0,n.stats=r,f.push(n)}var n=t.ext_disjoint_timer_query;if(!n)return null;var i=[],a=[],o=[],f=[],u=[],s=[];return{beginQuery:function(e){var t=i.pop()||n.createQueryEXT();n.beginQueryEXT(35007,t),a.push(t),r(a.length-1,a.length,e)},endQuery:function(){n.endQueryEXT(35007)},pushScopeStats:r,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 r=s[0]=0;for(t=e=0;t<a.length;++t){var c=a[t];n.getQueryObjectEXT(c,34919)?(r+=n.getQueryObjectEXT(c,34918),i.push(c)):a[e++]=c,u[t+1]=r,s[t+1]=e}for(a.length=e,t=e=0;t<f.length;++t){var l=(r=f[t]).startQueryIndex;c=r.endQueryIndex,r.sum+=u[c]-u[l],l=s[l],(c=s[c])===l?(r.stats.gpuTime+=r.sum/1e6,o.push(r)):(r.startQueryIndex=l,r.endQueryIndex=c,f[e++]=r)}f.length=e}},getNumPendingQueries:function(){return a.length},clear:function(){i.push.apply(i,a);for(var e=0;e<i.length;e++)n.deleteQueryEXT(i[e]);a.length=0,i.length=0},restore:function(){a.length=0,i.length=0}}}(0,w),_=q(),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=G(m,w),M=(S=function(e,t,r,n){for(e=r.maxAttributes,t=Array(e),r=0;r<e;++r)t[r]=new T;return{Record:T,scope:{},state:t}}(m,w,F),h(m,x,e,S)),P=d(m,w,M,x),B=j(m,b,x,e),z=A(m,w,F,function(){W.procs.poll()},O,x,e),I=ye(m,w,0,x,e),N=D(m,w,F,z,I,x),W=R(m,b,w,F,M,P,0,N,{},S,B,{elements:null,primitive:4,count:-1,offset:0,instances:-1},O,k,e),Q=(b=E(m,N,W.procs.poll,O),W.next),X=m.canvas,Y=[],J=[],Z=[],K=[e.onDestroy],$=null;X&&(X.addEventListener("webglcontextlost",a,!1),X.addEventListener("webglcontextrestored",o,!1));var ee=N.setFBO=f({framebuffer:V.define.call(null,1,"framebuffer")});return p(),y=U(f,{clear:function(e){if("framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;6>t;++t)ee(U({framebuffer:e.framebuffer.faces[t]},e),u);else ee(e,u);else u(0,e)},prop:V.define.bind(null,1),context:V.define.bind(null,2),this:V.define.bind(null,3),draw:f({}),buffer:function(e){return M.create(e,34962,!1,!1)},elements:function(e){return P.create(e,!1)},texture:z.create2D,cube:z.createCube,renderbuffer:I.create,framebuffer:N.create,framebufferCube:N.createCube,attributes:y,frame:s,on:function(e,t){var r;switch(e){case"frame":return s(t);case"lost":r=J;break;case"restore":r=Z;break;case"destroy":r=K}return r.push(t),{cancel:function(){for(var e=0;e<r.length;++e)if(r[e]===t){r[e]=r[r.length-1],r.pop();break}}}},limits:F,hasExtension:function(e){return 0<=F.extensions.indexOf(e.toLowerCase())},read:b,destroy:function(){Y.length=0,n(),X&&(X.removeEventListener("webglcontextlost",a),X.removeEventListener("webglcontextrestored",o)),B.clear(),N.clear(),I.clear(),z.clear(),P.clear(),M.clear(),k&&k.clear(),K.forEach(function(e){e()})},_gl:m,_refresh:p,poll:function(){l(),k&&k.update()},now:g,stats:x}),e.onDone(null,y),y}},"object"==typeof r&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):n.createREGL=i()},{}],22:[function(e,t,r){var n=e("insert-css");e("h");n("html, body {\n background-color: #000;\n text-align: center;\n}\ncanvas {\n margin-left: auto;\n margin-right: auto;\n}\n");var i,a=e("regl")({extensions:["OES_texture_float","OES_texture_float_linear"],pixelRatio:1,onDone:function(t){return t&&e("fail-nicely")(t)}}),o=e("./regl-cwise")(a),f=e("random-normal"),u=e("./swap"),s={xboundary:"repeat",yboundary:"repeat",magfilter:"linear",minfilter:"linear"};i=function(){return[Math.random(),Math.random(),.02*f(),.02*f()]};var c=[1024,1024,4],l=c[0]*c[1],p=[o.array(i,c),y2=o.array(null,c)],h=p[0].samplerCoords(),d=[256,256,4],g=1/d[0],m=o.array(function(){return[0,0,0,0]},d,s),y=[o.array(function(){return[0,0,0,0]},d,s),o.array(function(){return[0,0,0,0]},d,s)],v=(o.array(function(){return[0,0,0,0]},d,s),o.array(function(){return[0,0,0,0]},d,s),o.array(null,[512,512,4])),b=a({frag:"\n precision mediump float;\n varying vec2 uv;\n void main () {\n gl_FragColor = vec4(1, uv, 0);\n }",vert:"\n attribute vec2 xy;\n uniform sampler2D src;\n varying vec2 uv;\n void main () {\n vec4 val = texture2D(src, xy);\n uv = val.zw;\n gl_Position = vec4(val.xy * 2.0 - 1.0, 0, 1);\n gl_PointSize = 1.0;\n }\n ",attributes:{xy:h},uniforms:{src:a.prop("src")},framebuffer:a.prop("dest"),count:l,primitive:"points",blend:{enable:!0,func:{srcRGB:1,srcAlpha:1,dstRGB:1,dstAlpha:1}},depth:{enable:!1}}),x=a({frag:"\n precision mediump float;\n uniform float alpha;\n varying vec4 state;\n uniform float viscosity;\n varying vec4 dens;\n void main () {\n vec2 vavg = dens.yz / max(dens.x, 1.0);\n float heating = length(state.zw - vavg) * exp(-dens.x * viscosity);\n gl_FragColor = vec4(\n 0.2 * (1.0 - heating) + 0.8 * heating,\n 0.1,\n 0.8 + 0.2 * (1.0 - heating),\n 1.0\n ) * alpha * 0.5;\n }",vert:"\n attribute vec2 xy;\n uniform sampler2D src;\n uniform sampler2D rho;\n varying vec4 dens;\n varying vec4 state;\n void main () {\n state = texture2D(src, xy);\n dens = texture2D(rho, state.xy);\n state.xy = state.xy * 2.0 - 1.0;\n gl_Position = vec4(state.xy, 0, 1);\n gl_PointSize = 1.0;\n }\n ",attributes:{xy:h},uniforms:{src:a.prop("src"),rho:a.prop("rho"),alpha:function(e,t){return.05/Math.sqrt(l)*Math.sqrt(d[0]*d[0])*(t.multiplier||1)},viscosity:function(e,t){return.001/64}},framebuffer:a.prop("dest"),count:l,primitive:"points",blend:{enable:!0,func:{srcRGB:1,srcAlpha:1,dstRGB:1,dstAlpha:1}},depth:{enable:!1}}),w=(a({frag:"\n precision mediump float;\n uniform float alpha;\n void main () {\n gl_FragColor = vec4(1, 1, 1, alpha);\n }",vert:"\n attribute vec2 xy;\n uniform sampler2D src;\n void main () {\n gl_Position = vec4(texture2D(src, xy).xy * 2.0 - 1.0, 0, 1);\n gl_PointSize = 1.0;\n }\n ",attributes:{xy:h},uniforms:{src:a.prop("src"),alpha:function(e,t){return.05/Math.sqrt(l)*Math.sqrt(d[0]*d[0])*(t.multiplier||1)}},framebuffer:a.prop("dest"),count:l,primitive:"points",blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:1}},depth:{enable:!1}}),o.map({args:["array","array","scalar",{array:0,offset:[0,1]},{array:0,offset:[0,-1]},{array:0,offset:[1,0]},{array:0,offset:[-1,0]}],permute:[1,0,2,3],body:"\n #define G "+1..toFixed(5)+"\n #define PI 3.14159265358979\n vec4 compute (vec4 phi, vec4 rho, float h2, vec4 phin, vec4 phis, vec4 phie, vec4 phiw) {\n return vec4(0.25 * (phin.x + phis.x + phie.x + phiw.x) - PI * G * rho.x * h2, 0.0, 0.0, 0.0);\n }\n "})),k=a({frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n uniform sampler2D phi;\n uniform sampler2D rho;\n uniform float h;\n uniform float dt;\n uniform float globalDecay;\n uniform float viscosity;\n void main () {\n vec4 y = texture2D(src, uv);\n float dphidx = (texture2D(phi, y.xy + vec2(h, 0)).x - texture2D(phi, y.xy - vec2(h, 0)).x) * 0.5 / h;\n float dphidy = (texture2D(phi, y.xy + vec2(0, h)).x - texture2D(phi, y.xy - vec2(0, h)).x) * 0.5 / h;\n vec3 rho = texture2D(rho, y.xy).xyz;\n vec2 vavg = rho.yz / max(rho.x, 1.0) * 2.0;\n y += vec4(y.z, y.w, -dphidx, -dphidy) * dt;\n y.xy = mod(y.xy, vec2(1, 1));\n float viscousDecay = exp(-rho.x * viscosity);\n y.zw = y.zw * viscousDecay + (vavg - y.zw) * (1.0 - viscousDecay);\n y.zw *= globalDecay;\n gl_FragColor = y;\n }",vert:"\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = (xy + 1.0) * 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:a.prop("src"),phi:a.prop("phi"),dt:a.prop("dt"),rho:a.prop("rho"),h:g,viscosity:function(e,t){return.001/64},globalDecay:function(e,t){return Math.exp(-.001/t.decayTime)}},framebuffer:a.prop("dest"),depth:{enable:!1},count:3}),_=a({frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n uniform float xmul, ymul;\n void main () {\n vec2 uvloop = mod(uv / vec2(xmul, ymul), 1.0);\n vec3 col = texture2D(src, uvloop).xyz;\n gl_FragColor = vec4(col, 1);\n }\n ",vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = (xy + 1.0) * 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:a.prop("src"),xmul:function(e,t){return t.src.width/e.viewportWidth},ymul:function(e,t){return t.src.height/e.viewportHeight}},depth:{enable:!1},count:3}),A=(a({frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n void main () {gl_FragColor = texture2D(src, uv);}\n ",vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = (xy + 1.0) * 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:a.prop("src")},depth:{enable:!1},count:3}),a({frag:"\n precision mediump float;\n varying vec2 uv;\n uniform sampler2D src;\n uniform float xmul, ymul;\n void main () {\n float offset = texture2D(src, vec2(0, 0)).x;\n gl_FragColor = vec4(texture2D(src, uv).xyz - offset, 1);\n }\n ",vert:"\n precision mediump float;\n attribute vec2 xy;\n varying vec2 uv;\n void main () {\n uv = (xy + 1.0) * 0.5;\n gl_Position = vec4(xy, 0, 1);\n }\n ",attributes:{xy:[[-4,-4],[0,4],[4,-4]]},uniforms:{src:a.prop("src")},depth:{enable:!1},count:3}));new Float32Array(4);var D=[y[0],y[1],m,g*g];a.frame(function(e){var t=e.tick;a.clear({color:[0,0,0,1]}),w(D,1===t?200:50),A({dest:D[1],src:D[0]}),u(D,1,0),k({dest:p[1],src:p[0],rho:m,phi:D[0],dt:.001,decayTime:1e3}),u(p,0,1),v.use(function(){return a.clear({color:[0,0,0,1]})}),m.use(function(){return a.clear({color:[0,0,0,1]})}),b({dest:m,src:p[1]}),x({dest:v,rho:m,src:p[1],multiplier:.014*Math.pow(32,2)}),_({src:v})})},{"./regl-cwise":24,"./swap":29,"fail-nicely":1,h:13,"insert-css":14,"random-normal":20,regl:21}],23:[function(e,t,r){"use strict";t.exports=function(e,t){var r={};r[t.attrName]=[[-4,-4],[4,-4],[0,4]];for(var n={},i=t.invokeArgs,a=0;a<i.length;a++)n[i[a]]=e.prop(i[a]);n[t.duProp]=function(e){return 1/e.framebufferWidth},n[t.dvProp]=function(e){return 1/e.framebufferHeight};var o=e({frag:t.frag,vert:t.vert,framebuffer:e.prop(t.destProp),attributes:r,uniforms:n,depth:{enable:!1},count:3});function f(e,r){e.length-1!==i.length&&function(e){throw new Error("regl-gpgpu-parser:map: "+e)}("Number of args provided ("+e.length+") does not equal number of args expected ("+(i.length+1)+").");var n={};r=r||1;for(var a=0;a<r;a++){n[t.destProp]=e[0];for(var f=1;f<e.length;f++)n[i[f-1]]=e[f];if(o(n),t.permute){var u=t.permute,s=[];for(f=0;f<u.length;f++)s[f]=e[u[f]];for(f=0;f<u.length;f++)e[f]=s[f]}}}return f.destroy=function(){o&&(o.destroy(),o=null)},f}},{}],24:[function(e,t,r){"use strict";var n=e("./parsers/map"),i=e("./compilers/map"),a=e("./lib/array");t.exports=function(e){return{map:function(t){return i(e,n(t))},array:function(t,r,n){return a(e,t,r,n)}}}},{"./compilers/map":23,"./lib/array":25,"./parsers/map":28}],25:[function(e,t,r){"use strict";t.exports=function e(t,r,a,o){o=o||{};var f="float";if(!(this instanceof e))return new e(t,r,a,o);Array.isArray(r)&&(r=new Float32Array(r));if(n(r)&&!Array.isArray(a))if(a=r.shape,"float32"===r.dtype)f="float",r=i(new Float32Array(r.data),r.shape,r.stride,r.offset);else{if(!(r.dtype="uint8"))throw new Error("data must be uint8 or float32");f="uint8",r=i(r.data,r.shape,r.stride,r.offset)}if(3!==a.length||4!==a[2])throw new Error("gpuArray shape must be m x n x 4");var u=a.slice(0,2).reduce(function(e,t){return e*t},1);if(!r||"function"==typeof r){var s=r;r=new Float32Array(4*u)}if("function"==typeof s)for(var c=a[0],l=a[1],p=0;p<l;p++)for(var h=0;h<c;h++){var d=s(h,p),g=4*(h+c*p);r[g]=d[0],r[g+1]=d[1],r[g+2]=d[2],r[g+3]=d[3]}var m=a.slice(0,2).concat([4]);var y=t.texture({data:r,width:a[0],height:a[1],wrapS:o.xboundary||"clamp",wrapT:o.yboundary||"clamp",mag:o.magfilter||"nearest",min:o.minfilter||"nearest"});var v=t.framebuffer({color:y,colorFormat:"rgba",colorType:f});var b=v.destroy.bind(v);v.update=function(e){y({data:e})};v.read=function(e){var r;return v.use(function(){r=t.read(e)}),i(r,m)};v.readraw=function(e){var r;return v.use(function(){r=t.read(e)}),r};v.destroy=function(){b(),y.destroy()};v.texture=y;v.samplerCoords=function(){for(var e=[],r=0;r<u;r++)e.push([r%a[0]/Math.max(1,a[0]-1),Math.floor(r/a[0])/Math.max(1,a[1]-1)]);return t.buffer(e)};return v};var n=e("isndarray"),i=e("ndarray")},{isndarray:17,ndarray:18}],26:[function(e,t,r){"use strict";var n=e("glsl-tokenizer/string"),i=e("glsl-parser/direct");function a(e,t){for(var r=e.children,n=Object.keys(t),i=0;i<r.length;i++)for(var a=0;a<n.length;a++)if(r[i][n[a]]===t[n[a]])return r[i]}t.exports=function(e,t){var r=n(e),o=function e(t,r){var n=void 0;if("ident"===t.type&&t.token.data===r&&t.parent&&"function"===t.parent.type)return t.parent;for(var i=0;i<t.children.length&&!(n=e(t.children[i],r));i++);return n}(i(r),t);if(!o)throw Error("fragment shader was expected to define a "+t+"() function");return function(e){for(var t=[],r=function(e,t){for(var r=[],n=e.children,i=Object.keys(t),a=0;a<n.length;a++)for(var o=0;o<i.length;o++)n[a][i[o]]===t[i[o]]&&r.push(n[a]);return r}(a(e,{type:"functionargs"}),{type:"decl"}),n=0;n<r.length;n++){var i=r[n],o=a(i,{type:"keyword"}),f=a(i,{type:"decllist"}),u=a(f,{type:"ident"});t.push({type:o.token.data,name:u.token.data})}return t}(o)}},{"glsl-parser/direct":2,"glsl-tokenizer/string":12}],27:[function(e,t,r){"use strict";t.exports=function(e){function t(){for(var t="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=0;n<e;n++)t+=r.charAt(Math.floor(Math.random()*r.length));return t}var r={};return function(n){var i;do{r[i]=i=n+(e>0?"_"+t():"")}while(!i&&(i=r[i]));return i}}},{}],28:[function(e,t,r){"use strict";t.exports=function(e){e||a("expected options");var t=void 0===e.functionName?"compute":e.functionName,r=void 0===e.hashLength?14:e.hashLength,o=i(e.body,t),f=function(e,t){var r,i=n(t),a={xy:i("xy"),uv:i("uv"),du:i("du"),dv:i("dv"),dest:i("dest")},o=[],f=[],u=[],s=[],c=[];u.push("varying vec2 "+a.uv+";"),f.push("uniform float "+a.du+";"),f.push("uniform float "+a.dv+";");for(var l={},p=0;p<e.length;p++){var h=e[p];if(h.isRef,l[h.baseName]?r=l[h.baseName]:l[h.baseName]=r=i(h.baseName),h.isArray){h.isRef||f.push("uniform sampler2D "+r+";");var d=[a.uv];if(h.hasOffset){var g=["vec2("];0!==h.offset[0]?g.push(h.offset[0].toFixed(8)+" * "+a.du):g.push("0.0"),g.push(", "),0!==h.offset[1]?g.push(h.offset[1].toFixed(8)+" * "+a.dv):g.push("0.0"),g.push(")"),d.push(g.join(""))}o.push(" vec4 "+h.argName+" = texture2D("+r+", "+d.join(" + ")+");"),s.push(h.argName)}(h.isScalar||h.isArray&&!h.isRef)&&c.push(r),h.isScalar&&(f.push("uniform "+h.argType+" "+r+";"),s.push(r))}return{uniforms:f,sampleLookups:o,varying:u,computeArgs:s,invokeArgs:c,vars:a}}(function(e,t){e.length!==t.length&&a("number of defined args ("+e.length+") does not match map function arity ("+t.length+")");var r,n,i,o=[];for(r=0;r<e.length;r++)n=e[r],i=t[r],n.isRef||(o[r]={argName:i.name,isRef:!1,baseName:i.name+(n.isArray?"Texture":""),isArray:n.isArray,isScalar:!n.isArray},n.isScalar&&(o[r].argType=i.type));for(r=0;r<e.length;r++)if(n=e[r],i=t[r],n.isRef){var f=o[n.ref];f.isRef&&a("argument "+r+" references argument "+f.ref+". Recursive references are not supported."),o[r]={argName:i.name,baseName:f.baseName,isArray:f.isArray,isRef:!0,ref:n.ref,hasOffset:n.hasOffset,offset:n.offset}}return o}(function(e){for(var t,r,n=[],i=0,a=0;a<e.length;a++)r=e[a],(t={isScalar:"scalar"===r,isRef:"number"==typeof r.array&&r.array!==a,hasOffset:Array.isArray(r.offset)}).isArray="array"===r||!t.isScalar&&!t.isRef&&"object"==typeof r,t.isRef&&(t.ref=r.array),t.hasOffset&&(t.offset=r.offset),(t.isScalar||t.isArray&&!t.isRef)&&(t.inputIdx=i++),n.push(t);return n}(e.args),o),r);return{frag:["precision mediump float;",f.varying.join("\n"),f.uniforms.join("\n"),e.body,"void main () {",f.sampleLookups.join("\n")," gl_FragColor = "+t+"("+f.computeArgs.join(", ")+");","}"].join("\n"),vert:["precision mediump float;","attribute vec2 "+f.vars.xy+";","varying vec2 "+f.vars.uv+";","void main () {"," "+f.vars.uv+" = 0.5 * ("+f.vars.xy+" + 1.0);"," gl_Position = vec4("+f.vars.xy+", 0, 1);","}"].join("\n"),attrName:f.vars.xy,destProp:f.vars.dest,invokeArgs:f.invokeArgs,duProp:f.vars.du,dvProp:f.vars.dv,permute:e.permute}};var n=e("../lib/uniq-attr"),i=e("../lib/parse-function");function a(e){throw new Error("regl-gpgpu-parser:map: "+e)}},{"../lib/parse-function":26,"../lib/uniq-attr":27}],29:[function(e,t,r){"use strict";t.exports=function(e,t,r,n){if(3===arguments.length){var i=e[t];e[t]=e[r],e[r]=i}else e[r]=t[n],e[n]=t[r];return e}},{}]},{},[22]); |