Automatically save\n values to localStorage
on exit.\n\n
localStorage
will\n override those passed to dat.GUI
\'s constructor. This makes it\n easier to work incrementally, but localStorage
is fragile,\n and your friends may not see the same values you do.\n\n 0)continue;r.unit=-1}K[t]=this,e=t;break}e>=Q&&R.raise("insufficient number of texture units"),u.profile&&s.maxTextureUnits>u)-a,c.height=c.height||(r.height>>u)-s,R(r.type===c.type&&r.format===c.format&&r.internalformat===c.internalformat,"incompatible format for texture.subimage"),R(a>=0&&s>=0&&a+c.width<=r.width&&s+c.height<=r.height,"texture.subimage write out of bounds"),R(r.mipmask&1<>s;++s){var c=i>>s,f=a>>s;if(!c||!f)break;n.texImage2D(Ne,s,r.format,c,f,0,r.format,r.type,null)}return $(),u.profile&&(r.stats.size=mn(r.internalformat,r.type,i,a,!1,!1)),o},o._reglType="texture2d",o._texture=r,u.profile&&(o.stats=r.stats),o.destroy=function(){r.decRef()},o},createCube:function(e,t,r,o,a,c){var f=new J(He);X[f.id]=f,s.cubeCount++;var l=new Array(6);function d(e,t,n,r,o,a){var s,c=f.texInfo;for(G.call(c),s=0;s<6;++s)l[s]=V();if("number"!=typeof e&&e)if("object"==typeof e)if(t)B(l[0],e),B(l[1],t),B(l[2],n),B(l[3],r),B(l[4],o),B(l[5],a);else if(W(c,e),T(f,e),"faces"in e){var p=e.faces;for(R(Array.isArray(p)&&6===p.length,"cube faces must be a length 6 array"),s=0;s<6;++s)R("object"==typeof p[s]&&!!p[s],"invalid input for cube map face"),S(l[s],f),B(l[s],p[s])}else for(s=0;s<6;++s)B(l[s],e);else R.raise("invalid arguments to cube map");else{var h=0|e||1;for(s=0;s<6;++s)L(l[s],h,h)}for(S(f,l[0]),i.npotTextureCube||R(Le(f.width)&&Le(f.height),"your browser does not support non power or two texture dimensions"),f.mipmask=c.genMipmaps?(l[0].width<<1)-1:l[0].mipmask,R.textureCube(f,c,l,i),f.internalformat=l[0].internalformat,d.width=l[0].width,d.height=l[0].height,Z(f),s=0;s<6;++s)N(l[s],Ve+s);for(q(c,He),$(),u.profile&&(f.stats.size=mn(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!0)),d.format=y[f.internalformat],d.type=_[f.type],d.mag=x[c.magFilter],d.min=w[c.minFilter],d.wrapS=A[c.wrapS],d.wrapT=A[c.wrapT],s=0;s<6;++s)U(l[s]);return d}return d(e,t,r,o,a,c),d.subimage=function(e,t,n,r,i){R(!!t,"must specify image data"),R("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var o=0|n,a=0|r,s=0|i,u=F();return S(u,f),u.width=0,u.height=0,D(u,t),u.width=u.width||(f.width>>s)-o,u.height=u.height||(f.height>>s)-a,R(f.type===u.type&&f.format===u.format&&f.internalformat===u.internalformat,"incompatible format for texture.subimage"),R(o>=0&&a>=0&&o+u.width<=f.width&&a+u.height<=f.height,"texture.subimage write out of bounds"),R(f.mipmask&1< >i;++i)n.texImage2D(Ve+r,i,f.format,t>>i,t>>i,0,f.format,f.type,null);return $(),u.profile&&(f.stats.size=mn(f.internalformat,f.type,d.width,d.height,!1,!0)),d}},d._reglType="textureCube",d._texture=f,u.profile&&(d.stats=f.stats),d.destroy=function(){f.decRef()},d},clear:function(){for(var e=0;e>t,e.height>>t,0,e.internalformat,e.type,null);else for(var r=0;r<6;++r)n.texImage2D(Ve+r,t,e.internalformat,e.width>>t,e.height>>t,0,e.internalformat,e.type,null);q(e.texInfo,e.target)})}}}on[Xe]=2,on[Qe]=2,on[Ke]=2,on[nt]=4,on[at]=.5,on[st]=.5,on[ut]=1,on[ct]=1,on[ft]=.5,on[lt]=1,on[dt]=1,on[pt]=.5,on[ht]=.25,on[mt]=.5,on[gt]=.25,on[vt]=.5;var vn=36161,bn=32854,yn=[];function _n(e,t,n){return yn[e]*t*n}yn[bn]=2,yn[32855]=2,yn[36194]=2,yn[33189]=2,yn[36168]=1,yn[34041]=4,yn[35907]=4,yn[34836]=16,yn[34842]=8,yn[34843]=6;var xn=function(e,t,n,r,i){var o={rgba4:bn,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041};t.ext_srgb&&(o.srgba=35907),t.ext_color_buffer_half_float&&(o.rgba16f=34842,o.rgb16f=34843),t.webgl_color_buffer_float&&(o.rgba32f=34836);var a=[];Object.keys(o).forEach(function(e){a[o[e]]=e});var s=0,u={};function c(e){this.id=s++,this.refCount=1,this.renderbuffer=e,this.format=bn,this.width=0,this.height=0,i.profile&&(this.stats={size:0})}function f(t){var n=t.renderbuffer;R(n,"must not double destroy renderbuffer"),e.bindRenderbuffer(vn,null),e.deleteRenderbuffer(n),t.renderbuffer=null,t.refCount=0,delete u[t.id],r.renderbufferCount--}return c.prototype.decRef=function(){--this.refCount<=0&&f(this)},i.profile&&(r.getTotalRenderbufferSize=function(){var e=0;return Object.keys(u).forEach(function(t){e+=u[t].stats.size}),e}),{create:function(t,s){var f=new c(e.createRenderbuffer());function l(t,r){var s=0,u=0,c=bn;if("object"==typeof t&&t){var d=t;if("shape"in d){var p=d.shape;R(Array.isArray(p)&&p.length>=2,"invalid renderbuffer shape"),s=0|p[0],u=0|p[1]}else"radius"in d&&(s=u=0|d.radius),"width"in d&&(s=0|d.width),"height"in d&&(u=0|d.height);"format"in d&&(R.parameter(d.format,o,"invalid renderbuffer format"),c=o[d.format])}else"number"==typeof t?(s=0|t,u="number"==typeof r?0|r:s):t?R.raise("invalid arguments to renderbuffer constructor"):s=u=1;if(R(s>0&&u>0&&s<=n.maxRenderbufferSize&&u<=n.maxRenderbufferSize,"invalid renderbuffer size"),s!==f.width||u!==f.height||c!==f.format)return l.width=f.width=s,l.height=f.height=u,f.format=c,e.bindRenderbuffer(vn,f.renderbuffer),e.renderbufferStorage(vn,c,s,u),R(0===e.getError(),"invalid render buffer format"),i.profile&&(f.stats.size=_n(f.format,f.width,f.height)),l.format=a[f.format],l}return u[f.id]=f,r.renderbufferCount++,l(t,s),l.resize=function(t,r){var o=0|t,a=0|r||o;return o===f.width&&a===f.height?l:(R(o>0&&a>0&&o<=n.maxRenderbufferSize&&a<=n.maxRenderbufferSize,"invalid renderbuffer size"),l.width=f.width=o,l.height=f.height=a,e.bindRenderbuffer(vn,f.renderbuffer),e.renderbufferStorage(vn,f.format,o,a),R(0===e.getError(),"invalid render buffer format"),i.profile&&(f.stats.size=_n(f.format,f.width,f.height)),l)},l._reglType="renderbuffer",l._renderbuffer=f,i.profile&&(l.stats=f.stats),l.destroy=function(){f.decRef()},l},clear:function(){ie(u).forEach(f)},restore:function(){ie(u).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(vn,t.renderbuffer),e.renderbufferStorage(vn,t.format,t.width,t.height)}),e.bindRenderbuffer(vn,null)}}},wn=36160,An=36161,En=3553,kn=34069,Sn=36064,Tn=36096,Cn=36128,On=33306,Dn=36053,Mn=6402,jn=[6407,6408],Rn=[];Rn[6408]=4,Rn[6407]=3;var Pn=[];Pn[5121]=1,Pn[5126]=4,Pn[36193]=2;var Fn=33189,In=36168,zn=34041,Ln=[32854,32855,36194,35907,34842,34843,34836],Bn={};Bn[Dn]="complete",Bn[36054]="incomplete attachment",Bn[36057]="incomplete dimensions",Bn[36055]="incomplete, missing attachment",Bn[36061]="unsupported";var Nn=5126,Hn=34962;function Vn(){this.state=0,this.x=0,this.y=0,this.z=0,this.w=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=Nn,this.offset=0,this.stride=0,this.divisor=0}var Un=35632,Gn=35633,Wn=35718,qn=35721,Yn=6408,Xn=5121,Qn=3333,Kn=5126;function Jn(t,n,r,i,o,a,s){function u(u){var c;null===n.next?(R(o.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),c=Xn):(R(null!==n.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),c=n.next.colorAttachments[0].texture._texture.type,a.oes_texture_float?(R(c===Xn||c===Kn,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"),c===Kn&&R(s.readFloat,"Reading 'float' values is not permitted in your browser. For a fallback, please see: https://www.npmjs.com/package/glsl-read-float")):R(c===Xn,"Reading from a framebuffer is only allowed for the type 'uint8'"));var f=0,l=0,d=i.framebufferWidth,p=i.framebufferHeight,h=null;e(u)?h=u:u&&(R.type(u,"object","invalid arguments to regl.read()"),l=0|u.y,R((f=0|u.x)>=0&&f=0&&l 0&&d+f<=i.framebufferWidth,"invalid width for read pixels"),R(p>0&&p+l<=i.framebufferHeight,"invalid height for read pixels"),r();var m=d*p*4;return h||(c===Xn?h=new Uint8Array(m):c===Kn&&(h=h||new Float32Array(m))),R.isTypedArray(h,"data buffer for regl.read() must be a typedarray"),R(h.byteLength>=m,"data buffer for regl.read() too small"),t.pixelStorei(Qn,4),t.readPixels(f,l,d,p,Yn,c,h),h}return function(e){return e&&"framebuffer"in e?function(e){var t;return n.setFBO({framebuffer:e.framebuffer},function(){t=u(e)}),t}(e):u(e)}}function Zn(e){return Array.prototype.slice.call(e)}function $n(e){return Zn(e).join("")}var er="xyzw".split(""),tr=5121,nr=1,rr=2,ir=0,or=1,ar=2,sr=3,ur=4,cr="dither",fr="blend.enable",lr="blend.color",dr="blend.equation",pr="blend.func",hr="depth.enable",mr="depth.func",gr="depth.range",vr="depth.mask",br="colorMask",yr="cull.enable",_r="cull.face",xr="frontFace",wr="lineWidth",Ar="polygonOffset.enable",Er="polygonOffset.offset",kr="sample.alpha",Sr="sample.enable",Tr="sample.coverage",Cr="stencil.enable",Or="stencil.mask",Dr="stencil.func",Mr="stencil.opFront",jr="stencil.opBack",Rr="scissor.enable",Pr="scissor.box",Fr="viewport",Ir="profile",zr="framebuffer",Lr="vert",Br="frag",Nr="elements",Hr="primitive",Vr="count",Ur="offset",Gr="instances",Wr="vao",qr=zr+"Width",Yr=zr+"Height",Xr=Fr+"Width",Qr=Fr+"Height",Kr="drawingBufferWidth",Jr="drawingBufferHeight",Zr=[pr,dr,Dr,Mr,jr,Tr,Fr,Pr,Er],$r=34962,ei=34963,ti=3553,ni=34067,ri=2884,ii=3042,oi=3024,ai=2960,si=2929,ui=3089,ci=32823,fi=32926,li=32928,di=5126,pi=35664,hi=35665,mi=35666,gi=5124,vi=35667,bi=35668,yi=35669,_i=35670,xi=35671,wi=35672,Ai=35673,Ei=35674,ki=35675,Si=35676,Ti=35678,Ci=35680,Oi=4,Di=1028,Mi=1029,ji=2304,Ri=2305,Pi=32775,Fi=32776,Ii=519,zi=7680,Li=0,Bi=1,Ni=32774,Hi=513,Vi=36160,Ui=36064,Gi={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},Wi=["constant color, constant alpha","one minus constant color, constant alpha","constant color, one minus constant alpha","one minus constant color, one minus constant alpha","constant alpha, constant color","constant alpha, one minus constant color","one minus constant alpha, constant color","one minus constant alpha, one minus constant color"],qi={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},Yi={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},Xi={frag:35632,vert:35633},Qi={cw:ji,ccw:Ri};function Ki(t){return Array.isArray(t)||e(t)||re(t)}function Ji(e){return e.sort(function(e,t){return e===Fr?-1:t===Fr?1:e =1,r>=2,t)}if(n===ur){var i=e.data;return new Zi(i.thisDep,i.contextDep,i.propDep,t)}return new Zi(n===sr,n===ar,n===or,t)}var no=new Zi(!1,!1,!1,function(){});function ro(e,n,r,i,o,a,s,u,c,f,l,d,p,h,m){var g=f.Record,v={add:32774,subtract:32778,"reverse subtract":32779};r.ext_blend_minmax&&(v.min=Pi,v.max=Fi);var b=r.angle_instanced_arrays,y=r.webgl_draw_buffers,_={dirty:!0,profile:m.profile},x={},w=[],A={},E={};function k(e){return e.replace(".","_")}function S(e,t,n){var r=k(e);w.push(e),x[r]=_[r]=!!n,A[r]=t}function T(e,t,n){var r=k(e);w.push(e),Array.isArray(n)?(_[r]=n.slice(),x[r]=n.slice()):_[r]=x[r]=n,E[r]=t}S(cr,oi),S(fr,ii),T(lr,"blendColor",[0,0,0,0]),T(dr,"blendEquationSeparate",[Ni,Ni]),T(pr,"blendFuncSeparate",[Bi,Li,Bi,Li]),S(hr,si,!0),T(mr,"depthFunc",Hi),T(gr,"depthRange",[0,1]),T(vr,"depthMask",!0),T(br,br,[!0,!0,!0,!0]),S(yr,ri),T(_r,"cullFace",Mi),T(xr,xr,Ri),T(wr,wr,1),S(Ar,ci),T(Er,"polygonOffset",[0,0]),S(kr,fi),S(Sr,li),T(Tr,"sampleCoverage",[1,!1]),S(Cr,ai),T(Or,"stencilMask",-1),T(Dr,"stencilFunc",[Ii,0,-1]),T(Mr,"stencilOpSeparate",[Di,zi,zi,zi]),T(jr,"stencilOpSeparate",[Mi,zi,zi,zi]),S(Rr,ui),T(Pr,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),T(Fr,Fr,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var C={gl:e,context:p,strings:n,next:x,current:_,draw:d,elements:a,buffer:o,shader:l,attributes:f.state,vao:f,uniforms:c,framebuffer:u,extensions:r,timer:h,isBufferArgs:Ki},O={primTypes:_e,compareFuncs:qi,blendFuncs:Gi,blendEquations:v,stencilOps:Yi,glTypes:ue,orientationType:Qi};R.optional(function(){C.isArrayLike=ze}),y&&(O.backBuffer=[Mi],O.drawBuffer=W(i.maxDrawbuffers,function(e){return 0===e?[0]:W(e,function(e){return Ui+e})}));var D=0;function M(){var e=function(){var e=0,n=[],r=[];function i(){var n=[],r=[];return t(function(){n.push.apply(n,Zn(arguments))},{def:function(){var t="v"+e++;return r.push(t),arguments.length>0&&(n.push(t,"="),n.push.apply(n,Zn(arguments)),n.push(";")),t},toString:function(){return $n([r.length>0?"var "+r.join(",")+";":"",$n(n)])}})}function o(){var e=i(),n=i(),r=e.toString,o=n.toString;function a(t,r){n(t,r,"=",e.def(t,r),";")}return t(function(){e.apply(e,Zn(arguments))},{def:e.def,entry:e,exit:n,save:a,set:function(t,n,r){a(t,n),e(t,n,"=",r,";")},toString:function(){return r()+o()}})}var a=i(),s={};return{global:a,link:function(t){for(var i=0;i =0,'unknown parameter "'+t+'"',d.commandStr)})}t(p),t(h)});var m=function(e,t){var n=e.static;if("string"==typeof n[Br]&&"string"==typeof n[Lr]){if(Object.keys(t.dynamic).length>0)return null;var r=t.static,i=Object.keys(r);if(i.length>0&&"number"==typeof r[i[0]]){for(var o=[],a=0;a =0,"invalid "+e,n.commandStr):u=!1,"height"in o?R.command((s=0|o.height)>=0,"invalid "+e,n.commandStr):u=!1,new Zi(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,function(e,t){var n=e.shared.context,r=a;"width"in o||(r=t.def(n,".",qr,"-",c));var i=s;return"height"in o||(i=t.def(n,".",Yr,"-",f)),[c,f,r,i]})}if(e in i){var l=i[e],d=to(l,function(t,n){var r=t.invoke(n,l);R.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)});var i=t.shared.context,o=n.def(r,".x|0"),a=n.def(r,".y|0"),s=n.def('"width" in ',r,"?",r,".width|0:","(",i,".",qr,"-",o,")"),u=n.def('"height" in ',r,"?",r,".height|0:","(",i,".",Yr,"-",a,")");return R.optional(function(){t.assert(n,s+">=0&&"+u+">=0","invalid "+e)}),[o,a,s,u]});return t&&(d.thisDep=d.thisDep||t.thisDep,d.contextDep=d.contextDep||t.contextDep,d.propDep=d.propDep||t.propDep),d}return t?new Zi(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",qr),t.def(n,".",Yr)]}):null}var a=o(Fr);if(a){var s=a;a=new Zi(a.thisDep,a.contextDep,a.propDep,function(e,t){var n=s.append(e,t),r=e.shared.context;return t.set(r,"."+Xr,n[2]),t.set(r,"."+Qr,n[3]),n})}return{viewport:a,scissor_box:o(Pr)}}(e,y,d),x=function(e,t){var n=e.static,r=e.dynamic,i=function(){if(Nr in n){var e=n[Nr];Ki(e)?e=a.getElements(a.create(e,!0)):e&&(e=a.getElements(e),R.command(e,"invalid elements",t.commandStr));var i=eo(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r,r}return t.ELEMENTS=null,null});return i.value=e,i}if(Nr in r){var o=r[Nr];return to(o,function(e,t){var n=e.shared,r=n.isBufferArgs,i=n.elements,a=e.invoke(t,o),s=t.def("null"),u=t.def(r,"(",a,")"),c=e.cond(u).then(s,"=",i,".createStream(",a,");").else(s,"=",i,".getElements(",a,");");return R.optional(function(){e.assert(c.else,"!"+a+"||"+s,"invalid elements")}),t.entry(c),t.exit(e.cond(u).then(i,".destroyStream(",s,");")),e.ELEMENTS=s,s})}return null}();function o(e,o){if(e in n){var a=0|n[e];return R.command(!o||a>=0,"invalid "+e,t.commandStr),eo(function(e,t){return o&&(e.OFFSET=a),a})}if(e in r){var s=r[e];return to(s,function(t,n){var r=t.invoke(n,s);return o&&(t.OFFSET=r,R.optional(function(){t.assert(n,r+">=0","invalid "+e)})),r})}return o&&i?eo(function(e,t){return e.OFFSET="0",0}):null}var s=o(Ur,!0);return{elements:i,primitive:function(){if(Hr in n){var e=n[Hr];return R.commandParameter(e,_e,"invalid primitve",t.commandStr),eo(function(t,n){return _e[e]})}if(Hr in r){var o=r[Hr];return to(o,function(e,t){var n=e.constants.primTypes,r=e.invoke(t,o);return R.optional(function(){e.assert(t,r+" in "+n,"invalid primitive, must be one of "+Object.keys(_e))}),t.def(n,"[",r,"]")})}return i?$i(i)?eo(i.value?function(e,t){return t.def(e.ELEMENTS,".primType")}:function(){return Oi}):new Zi(i.thisDep,i.contextDep,i.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",Oi)}):null}(),count:function(){if(Vr in n){var e=0|n[Vr];return R.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),eo(function(){return e})}if(Vr in r){var o=r[Vr];return to(o,function(e,t){var n=e.invoke(t,o);return R.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">=0&&"+n+"===("+n+"|0)","invalid vertex count")}),n})}if(i){if($i(i)){if(i)return s?new Zi(s.thisDep,s.contextDep,s.propDep,function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return R.optional(function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")}),n}):eo(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var a=eo(function(){return-1});return R.optional(function(){a.MISSING=!0}),a}var u=new Zi(i.thisDep||s.thisDep,i.contextDep||s.contextDep,i.propDep||s.propDep,function(e,t){var n=e.ELEMENTS;return e.OFFSET?t.def(n,"?",n,".vertCount-",e.OFFSET,":-1"):t.def(n,"?",n,".vertCount:-1")});return R.optional(function(){u.DYNAMIC=!0}),u}return null}(),instances:o(Gr,!1),offset:s}}(e,d),A=function(e,t){var n=e.static,r=e.dynamic,o={};return w.forEach(function(e){var a=k(e);function s(t,i){if(e in n){var s=t(n[e]);o[a]=eo(function(){return s})}else if(e in r){var u=r[e];o[a]=to(u,function(e,t){return i(e,t,e.invoke(t,u))})}}switch(e){case yr:case fr:case cr:case Cr:case hr:case Rr:case Ar:case kr:case Sr:case vr:return s(function(n){return R.commandType(n,"boolean",e,t.commandStr),n},function(t,n,r){return R.optional(function(){t.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+e,t.commandStr)}),r});case mr:return s(function(n){return R.commandParameter(n,qi,"invalid "+e,t.commandStr),qi[n]},function(t,n,r){var i=t.constants.compareFuncs;return R.optional(function(){t.assert(n,r+" in "+i,"invalid "+e+", must be one of "+Object.keys(qi))}),n.def(i,"[",r,"]")});case gr:return s(function(e){return R.command(ze(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]&&e[0]<=e[1],"depth range is 2d array",t.commandStr),e},function(e,t,n){return R.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===2&&typeof "+n+'[0]==="number"&&typeof '+n+'[1]==="number"&&'+n+"[0]<="+n+"[1]","depth range must be a 2d array")}),[t.def("+",n,"[0]"),t.def("+",n,"[1]")]});case pr:return s(function(e){R.commandType(e,"object","blend.func",t.commandStr);var n="srcRGB"in e?e.srcRGB:e.src,r="srcAlpha"in e?e.srcAlpha:e.src,i="dstRGB"in e?e.dstRGB:e.dst,o="dstAlpha"in e?e.dstAlpha:e.dst;return R.commandParameter(n,Gi,a+".srcRGB",t.commandStr),R.commandParameter(r,Gi,a+".srcAlpha",t.commandStr),R.commandParameter(i,Gi,a+".dstRGB",t.commandStr),R.commandParameter(o,Gi,a+".dstAlpha",t.commandStr),R.command(-1===Wi.indexOf(n+", "+i),"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+i+")",t.commandStr),[Gi[n],Gi[i],Gi[r],Gi[o]]},function(t,n,r){var i=t.constants.blendFuncs;function o(o,a){var s=n.def('"',o,a,'" in ',r,"?",r,".",o,a,":",r,".",o);return R.optional(function(){t.assert(n,s+" in "+i,"invalid "+e+"."+o+a+", must be one of "+Object.keys(Gi))}),s}R.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")});var a=o("src","RGB"),s=o("dst","RGB");R.optional(function(){t.assert(n,t.constants.invalidBlendCombinations+".indexOf("+a+'+", "+'+s+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var u=n.def(i,"[",a,"]"),c=n.def(i,"[",o("src","Alpha"),"]");return[u,n.def(i,"[",s,"]"),c,n.def(i,"[",o("dst","Alpha"),"]")]});case dr:return s(function(n){return"string"==typeof n?(R.commandParameter(n,v,"invalid "+e,t.commandStr),[v[n],v[n]]):"object"==typeof n?(R.commandParameter(n.rgb,v,e+".rgb",t.commandStr),R.commandParameter(n.alpha,v,e+".alpha",t.commandStr),[v[n.rgb],v[n.alpha]]):void R.commandRaise("invalid blend.equation",t.commandStr)},function(t,n,r){var i=t.constants.blendEquations,o=n.def(),a=n.def(),s=t.cond("typeof ",r,'==="string"');return R.optional(function(){function n(e,n,r){t.assert(e,r+" in "+i,"invalid "+n+", must be one of "+Object.keys(v))}n(s.then,e,r),t.assert(s.else,r+"&&typeof "+r+'==="object"',"invalid "+e),n(s.else,e+".rgb",r+".rgb"),n(s.else,e+".alpha",r+".alpha")}),s.then(o,"=",a,"=",i,"[",r,"];"),s.else(o,"=",i,"[",r,".rgb];",a,"=",i,"[",r,".alpha];"),n(s),[o,a]});case lr:return s(function(e){return R.command(ze(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),W(4,function(t){return+e[t]})},function(e,t,n){return R.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")}),W(4,function(e){return t.def("+",n,"[",e,"]")})});case Or:return s(function(e){return R.commandType(e,"number",a,t.commandStr),0|e},function(e,t,n){return R.optional(function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")}),t.def(n,"|0")});case Dr:return s(function(n){R.commandType(n,"object",a,t.commandStr);var r=n.cmp||"keep",i=n.ref||0,o="mask"in n?n.mask:-1;return R.commandParameter(r,qi,e+".cmp",t.commandStr),R.commandType(i,"number",e+".ref",t.commandStr),R.commandType(o,"number",e+".mask",t.commandStr),[qi[r],i,o]},function(e,t,n){var r=e.constants.compareFuncs;return R.optional(function(){function i(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}i(n+"&&typeof ",n,'==="object"'),i('!("cmp" in ',n,")||(",n,".cmp in ",r,")")}),[t.def('"cmp" in ',n,"?",r,"[",n,".cmp]",":",zi),t.def(n,".ref|0"),t.def('"mask" in ',n,"?",n,".mask|0:-1")]});case Mr:case jr:return s(function(n){R.commandType(n,"object",a,t.commandStr);var r=n.fail||"keep",i=n.zfail||"keep",o=n.zpass||"keep";return R.commandParameter(r,Yi,e+".fail",t.commandStr),R.commandParameter(i,Yi,e+".zfail",t.commandStr),R.commandParameter(o,Yi,e+".zpass",t.commandStr),[e===jr?Mi:Di,Yi[r],Yi[i],Yi[o]]},function(t,n,r){var i=t.constants.stencilOps;function o(o){return R.optional(function(){t.assert(n,'!("'+o+'" in '+r+")||("+r+"."+o+" in "+i+")","invalid "+e+"."+o+", must be one of "+Object.keys(Yi))}),n.def('"',o,'" in ',r,"?",i,"[",r,".",o,"]:",zi)}return R.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[e===jr?Mi:Di,o("fail"),o("zfail"),o("zpass")]});case Er:return s(function(e){R.commandType(e,"object",a,t.commandStr);var n=0|e.factor,r=0|e.units;return R.commandType(n,"number",a+".factor",t.commandStr),R.commandType(r,"number",a+".units",t.commandStr),[n,r]},function(t,n,r){return R.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[n.def(r,".factor|0"),n.def(r,".units|0")]});case _r:return s(function(e){var n=0;return"front"===e?n=Di:"back"===e&&(n=Mi),R.command(!!n,a,t.commandStr),n},function(e,t,n){return R.optional(function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")}),t.def(n,'==="front"?',Di,":",Mi)});case wr:return s(function(e){return R.command("number"==typeof e&&e>=i.lineWidthDims[0]&&e<=i.lineWidthDims[1],"invalid line width, must be a positive number between "+i.lineWidthDims[0]+" and "+i.lineWidthDims[1],t.commandStr),e},function(e,t,n){return R.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+i.lineWidthDims[0]+"&&"+n+"<="+i.lineWidthDims[1],"invalid line width")}),n});case xr:return s(function(e){return R.commandParameter(e,Qi,a,t.commandStr),Qi[e]},function(e,t,n){return R.optional(function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(n+'==="cw"?'+ji+":"+Ri)});case br:return s(function(e){return R.command(ze(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,n){return R.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")}),W(4,function(e){return"!!"+n+"["+e+"]"})});case Tr:return s(function(e){R.command("object"==typeof e&&e,a,t.commandStr);var n="value"in e?e.value:1,r=!!e.invert;return R.command("number"==typeof n&&n>=0&&n<=1,"sample.coverage.value must be a number between 0 and 1",t.commandStr),[n,r]},function(e,t,n){return R.optional(function(){e.assert(t,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")}),[t.def('"value" in ',n,"?+",n,".value:1"),t.def("!!",n,".invert")]})}}),o}(e,d),E=function(e,t,r){var i=e.static,o=e.dynamic;function a(e){if(e in i){var t=n.id(i[e]);R.optional(function(){l.shader(Xi[e],t,R.guessCommand())});var r=eo(function(){return t});return r.id=t,r}if(e in o){var a=o[e];return to(a,function(t,n){var r=t.invoke(n,a),i=n.def(t.shared.strings,".id(",r,")");return R.optional(function(){n(t.shared.shader,".shader(",Xi[e],",",i,",",t.command,");")}),i})}return null}var s,u=a(Br),c=a(Lr),f=null;return $i(u)&&$i(c)?(f=l.program(c.id,u.id,null,r),s=eo(function(e,t){return e.link(f)})):s=new Zi(u&&u.thisDep||c&&c.thisDep,u&&u.contextDep||c&&c.contextDep,u&&u.propDep||c&&c.propDep,function(e,t){var n,r=e.shared.shader;n=u?u.append(e,t):t.def(r,".",Br);var i=r+".program("+(c?c.append(e,t):t.def(r,".",Lr))+","+n;return R.optional(function(){i+=","+e.command}),t.def(i+")")}),{frag:u,vert:c,progVar:s,program:f}}(e,0,m);function S(e){var t=_[e];t&&(A[e]=t)}S(Fr),S(k(Pr));var T=Object.keys(A).length>0,C={framebuffer:y,draw:x,shader:E,state:A,dirty:T,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}};if(C.profile=function(e){var t,n=e.static,r=e.dynamic;if(Ir in n){var i=!!n[Ir];(t=eo(function(e,t){return i})).enable=i}else if(Ir in r){var o=r[Ir];t=to(o,function(e,t){return e.invoke(t,o)})}return t}(e),C.uniforms=function(e,t){var n=e.static,r=e.dynamic,i={};return Object.keys(n).forEach(function(e){var r,o=n[e];if("number"==typeof o||"boolean"==typeof o)r=eo(function(){return o});else if("function"==typeof o){var a=o._reglType;"texture2d"===a||"textureCube"===a?r=eo(function(e){return e.link(o)}):"framebuffer"===a||"framebufferCube"===a?(R.command(o.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),r=eo(function(e){return e.link(o.color[0])})):R.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else ze(o)?r=eo(function(t){return t.global.def("[",W(o.length,function(n){return R.command("number"==typeof o[n]||"boolean"==typeof o[n],"invalid uniform "+e,t.commandStr),o[n]}),"]")}):R.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);r.value=o,i[e]=r}),Object.keys(r).forEach(function(e){var t=r[e];i[e]=to(t,function(e,n){return e.invoke(n,t)})}),i}(s,d),C.drawVAO=C.scopeVAO=function(e,t){var n=e.static,r=e.dynamic;if(Wr in n){var i=n[Wr];return null!==i&&null===f.getVAO(i)&&(i=f.createVAO(i)),eo(function(e){return e.link(f.getVAO(i))})}if(Wr in r){var o=r[Wr];return to(o,function(e,t){var n=e.invoke(t,o);return t.def(e.shared.vao+".getVAO("+n+")")})}return null}(e),!C.drawVAO&&E.program&&!m&&r.angle_instanced_arrays){var O=!0,D=E.program.attributes.map(function(e){var n=t.static[e];return O=O&&!!n,n});if(O&&D.length>0){var M=f.getVAO(f.createVAO(D));C.drawVAO=new Zi(null,null,null,function(e,t){return e.link(M)}),C.useVAO=!0}}return m?C.useVAO=!0:C.attributes=function(e,t){var r=e.static,i=e.dynamic,a={};return Object.keys(r).forEach(function(e){var i=r[e],s=n.id(e),u=new g;if(Ki(i))u.state=nr,u.buffer=o.getBuffer(o.create(i,$r,!1,!0)),u.type=0;else{var c=o.getBuffer(i);if(c)u.state=nr,u.buffer=c,u.type=0;else if(R.command("object"==typeof i&&i,"invalid data for attribute "+e,t.commandStr),"constant"in i){var f=i.constant;u.buffer="null",u.state=rr,"number"==typeof f?u.x=f:(R.command(ze(f)&&f.length>0&&f.length<=4,"invalid constant for attribute "+e,t.commandStr),er.forEach(function(e,t){t =0,'invalid offset for attribute "'+e+'"',t.commandStr);var d=0|i.stride;R.command(d>=0&&d<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',t.commandStr);var p=0|i.size;R.command(!("size"in i)||p>0&&p<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',t.commandStr);var h=!!i.normalized,m=0;"type"in i&&(R.commandParameter(i.type,ue,"invalid type for attribute "+e,t.commandStr),m=ue[i.type]);var v=0|i.divisor;"divisor"in i&&(R.command(0===v||b,'cannot specify divisor for attribute "'+e+'", instancing not supported',t.commandStr),R.command(v>=0,'invalid divisor for attribute "'+e+'"',t.commandStr)),R.optional(function(){var n=t.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(t){R.command(r.indexOf(t)>=0,'unknown parameter "'+t+'" for attribute pointer "'+e+'" (valid parameters are '+r+")",n)})}),u.buffer=c,u.state=nr,u.size=p,u.normalized=h,u.type=m||c.dtype,u.offset=l,u.stride=d,u.divisor=v}}a[e]=eo(function(e,t){var n=e.attribCache;if(s in n)return n[s];var r={isStream:!1};return Object.keys(u).forEach(function(e){r[e]=u[e]}),u.buffer&&(r.buffer=e.link(u.buffer),r.type=r.type||r.buffer+".dtype"),n[s]=r,r})}),Object.keys(i).forEach(function(e){var t=i[e];a[e]=to(t,function(n,r){var i=n.invoke(r,t),o=n.shared,a=n.constants,s=o.isBufferArgs,u=o.buffer;R.optional(function(){n.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+s+"("+i+")||"+u+".getBuffer("+i+")||"+u+".getBuffer("+i+".buffer)||"+s+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var c={isStream:r.def(!1)},f=new g;f.state=nr,Object.keys(f).forEach(function(e){c[e]=r.def(""+f[e])});var l=c.buffer,d=c.type;function p(e){r(c[e],"=",i,".",e,"|0;")}return r("if(",s,"(",i,")){",c.isStream,"=true;",l,"=",u,".createStream(",$r,",",i,");",d,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",i,");","if(",l,"){",d,"=",l,".dtype;",'}else if("constant" in ',i,"){",c.state,"=",rr,";","if(typeof "+i+'.constant === "number"){',c[er[0]],"=",i,".constant;",er.slice(1).map(function(e){return c[e]}).join("="),"=0;","}else{",er.map(function(e,t){return c[e]+"="+i+".constant.length>"+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",s,"(",i,".buffer)){",l,"=",u,".createStream(",$r,",",i,".buffer);","}else{",l,"=",u,".getBuffer(",i,".buffer);","}",d,'="type" in ',i,"?",a.glTypes,"[",i,".type]:",l,".dtype;",c.normalized,"=!!",i,".normalized;"),p("size"),p("offset"),p("stride"),p("divisor"),r("}}"),r.exit("if(",c.isStream,"){",u,".destroyStream(",l,");","}"),c})}),a}(t,d),C.context=function(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=eo(function(e,t){return"number"==typeof n||"boolean"==typeof n?""+n:e.link(n)})}),Object.keys(n).forEach(function(e){var t=n[e];r[e]=to(t,function(e,n){return e.invoke(n,t)})}),r}(c),C}function P(e,t,n){var r=e.shared.context,i=e.scope();Object.keys(n).forEach(function(o){t.save(r,"."+o),i(r,".",o,"=",n[o].append(e,t),";")}),t(i)}function F(e,t,n,r){var i,o=e.shared,a=o.gl,s=o.framebuffer;y&&(i=t.def(o.extensions,".webgl_draw_buffers"));var u,c=e.constants,f=c.drawBuffer,l=c.backBuffer;u=n?n.append(e,t):t.def(s,".next"),r||t("if(",u,"!==",s,".cur){"),t("if(",u,"){",a,".bindFramebuffer(",Vi,",",u,".framebuffer);"),y&&t(i,".drawBuffersWEBGL(",f,"[",u,".colorAttachments.length]);"),t("}else{",a,".bindFramebuffer(",Vi,",null);"),y&&t(i,".drawBuffersWEBGL(",l,");"),t("}",s,".cur=",u,";"),r||t("}")}function I(e,t,n){var r=e.shared,i=r.gl,o=e.current,a=e.next,s=r.current,u=r.next,c=e.cond(s,".dirty");w.forEach(function(t){var r,f,l=k(t);if(!(l in n.state))if(l in a){r=a[l],f=o[l];var d=W(_[l].length,function(e){return c.def(r,"[",e,"]")});c(e.cond(d.map(function(e,t){return e+"!=="+f+"["+t+"]"}).join("||")).then(i,".",E[l],"(",d,");",d.map(function(e,t){return f+"["+t+"]="+e}).join(";"),";"))}else{r=c.def(u,".",l);var p=e.cond(r,"!==",s,".",l);c(p),l in A?p(e.cond(r).then(i,".enable(",A[l],");").else(i,".disable(",A[l],");"),s,".",l,"=",r,";"):p(i,".",E[l],"(",r,");",s,".",l,"=",r,";")}}),0===Object.keys(n.state).length&&c(s,".dirty=false;"),t(c)}function z(e,t,n,r){var i=e.shared,o=e.current,a=i.current,s=i.gl;Ji(Object.keys(n)).forEach(function(i){var u=n[i];if(!r||r(u)){var c=u.append(e,t);if(A[i]){var f=A[i];$i(u)?t(s,c?".enable(":".disable(",f,");"):t(e.cond(c).then(s,".enable(",f,");").else(s,".disable(",f,");")),t(a,".",i,"=",c,";")}else if(ze(c)){var l=o[i];t(s,".",E[i],"(",c,");",c.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(s,".",E[i],"(",c,");",a,".",i,"=",c,";")}})}function L(e,t){b&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function N(e,t,n,r,i){var o,a,s,u=e.shared,c=e.stats,f=u.current,l=u.timer,d=n.profile;function p(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function m(e){e(o=t.def(),"=",p(),";"),"string"==typeof i?e(c,".count+=",i,";"):e(c,".count++;"),h&&(r?e(a=t.def(),"=",l,".getNumPendingQueries();"):e(l,".beginQuery(",c,");"))}function g(e){e(c,".cpuTime+=",p(),"-",o,";"),h&&(r?e(l,".pushScopeStats(",a,",",l,".getNumPendingQueries(),",c,");"):e(l,".endQuery();"))}function v(e){var n=t.def(f,".profile");t(f,".profile=",e,";"),t.exit(f,".profile=",n,";")}if(d){if($i(d))return void(d.enable?(m(t),g(t.exit),v("true")):v("false"));v(s=d.append(e,t))}else s=t.def(f,".profile");var b=e.block();m(b),t("if(",s,"){",b,"}");var y=e.block();g(y),t.exit("if(",s,"){",y,"}")}function H(e,t,n,r,i){var o=e.shared;r.forEach(function(r){var a,s=r.name,u=n.attributes[s];if(u){if(!i(u))return;a=u.append(e,t)}else{if(!i(no))return;var c=e.scopeAttrib(s);R.optional(function(){e.assert(t,c+".state","missing attribute "+s)}),a={},Object.keys(new g).forEach(function(e){a[e]=t.def(c,".",e)})}!function(n,r,i){var a=o.gl,s=t.def(n,".location"),u=t.def(o.attributes,"[",s,"]"),c=i.state,f=i.buffer,l=[i.x,i.y,i.z,i.w],d=["buffer","normalized","offset","stride"];function p(){t("if(!",u,".buffer){",a,".enableVertexAttribArray(",s,");}");var n,o=i.type;if(n=i.size?t.def(i.size,"||",r):r,t("if(",u,".type!==",o,"||",u,".size!==",n,"||",d.map(function(e){return u+"."+e+"!=="+i[e]}).join("||"),"){",a,".bindBuffer(",$r,",",f,".buffer);",a,".vertexAttribPointer(",[s,n,o,i.normalized,i.stride,i.offset],");",u,".type=",o,";",u,".size=",n,";",d.map(function(e){return u+"."+e+"="+i[e]+";"}).join(""),"}"),b){var c=i.divisor;t("if(",u,".divisor!==",c,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,c],");",u,".divisor=",c,";}")}}function h(){t("if(",u,".buffer){",a,".disableVertexAttribArray(",s,");",u,".buffer=null;","}if(",er.map(function(e,t){return u+"."+e+"!=="+l[t]}).join("||"),"){",a,".vertexAttrib4f(",s,",",l,");",er.map(function(e,t){return u+"."+e+"="+l[t]+";"}).join(""),"}")}c===nr?p():c===rr?h():(t("if(",c,"===",nr,"){"),p(),t("}else{"),h(),t("}"))}(e.link(r),function(e){switch(e){case pi:case vi:case xi:return 2;case hi:case bi:case wi:return 3;case mi:case yi:case Ai:return 4;default:return 1}}(r.info.type),a)})}function V(e,t,r,i,o){for(var a,s=e.shared,u=s.gl,c=0;c 1?W(_,function(e){return f+"["+e+"]"}):f);t(");")}}function U(e,t,n,r){var i=e.shared,o=i.gl,a=i.draw,s=r.draw;var u=function(){var i,u=s.elements,c=t;return u?((u.contextDep&&r.contextDynamic||u.propDep)&&(c=n),i=u.append(e,c)):i=c.def(a,".",Nr),i&&c("if("+i+")"+o+".bindBuffer("+ei+","+i+".buffer.buffer);"),i}();function c(i){var o=s[i];return o?o.append(e,o.contextDep&&r.contextDynamic||o.propDep?n:t):t.def(a,".",i)}var f,l,d=c(Hr),p=c(Ur),h=function(){var i,o=s.count,u=t;return o?((o.contextDep&&r.contextDynamic||o.propDep)&&(u=n),i=o.append(e,u),R.optional(function(){o.MISSING&&e.assert(t,"false","missing vertex count"),o.DYNAMIC&&e.assert(u,i+">=0","missing vertex count")})):(i=u.def(a,".",Vr),R.optional(function(){e.assert(u,i+">=0","missing vertex count")})),i}();if("number"==typeof h){if(0===h)return}else n("if(",h,"){"),n.exit("}");b&&(f=c(Gr),l=e.instancing);var m=u+".type",g=s.elements&&$i(s.elements);function v(){function e(){n(l,".drawElementsInstancedANGLE(",[d,h,m,p+"<<(("+m+"-"+tr+")>>1)",f],");")}function t(){n(l,".drawArraysInstancedANGLE(",[d,p,h,f],");")}u?g?e():(n("if(",u,"){"),e(),n("}else{"),t(),n("}")):t()}function y(){function e(){n(o+".drawElements("+[d,h,m,p+"<<(("+m+"-"+tr+")>>1)"]+");")}function t(){n(o+".drawArrays("+[d,p,h]+");")}u?g?e():(n("if(",u,"){"),e(),n("}else{"),t(),n("}")):t()}b&&("number"!=typeof f||f>=0)?"string"==typeof f?(n("if(",f,">0){"),v(),n("}else if(",f,"<0){"),y(),n("}")):v():y()}function G(e,t,n,r,i){var o=M(),a=o.proc("body",i);return R.optional(function(){o.commandStr=t.commandStr,o.command=o.link(t.commandStr)}),b&&(o.instancing=a.def(o.shared.extensions,".angle_instanced_arrays")),e(o,a,n,r),o.compile().body}function q(e,t,n,r){L(e,t),n.useVAO?n.drawVAO?t(e.shared.vao,".setVAO(",n.drawVAO.append(e,t),");"):t(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(t(e.shared.vao,".setVAO(null);"),H(e,t,n,r.attributes,function(){return!0})),V(e,t,n,r.uniforms,function(){return!0}),U(e,t,t,n)}function Y(e,t,n,r){function i(){return!0}e.batchId="a1",L(e,t),H(e,t,n,r.attributes,i),V(e,t,n,r.uniforms,i),U(e,t,t,n)}function X(e,t,n,r){L(e,t);var i=n.contextDep,o=t.def(),a=t.def();e.shared.props=a,e.batchId=o;var s=e.scope(),u=e.scope();function c(e){return e.contextDep&&i||e.propDep}function f(e){return!c(e)}if(t(s.entry,"for(",o,"=0;",o,"<","a1",";++",o,"){",a,"=","a0","[",o,"];",u,"}",s.exit),n.needsContext&&P(e,u,n.context),n.needsFramebuffer&&F(e,u,n.framebuffer),z(e,u,n.state,c),n.profile&&c(n.profile)&&N(e,u,n,!1,!0),r)n.useVAO?n.drawVAO?c(n.drawVAO)?u(e.shared.vao,".setVAO(",n.drawVAO.append(e,u),");"):s(e.shared.vao,".setVAO(",n.drawVAO.append(e,s),");"):s(e.shared.vao,".setVAO(",e.shared.vao,".targetVAO);"):(s(e.shared.vao,".setVAO(null);"),H(e,s,n,r.attributes,f),H(e,u,n,r.attributes,c)),V(e,s,n,r.uniforms,f),V(e,u,n,r.uniforms,c),U(e,s,u,n);else{var l=e.global.def("{}"),d=n.shader.progVar.append(e,u),p=u.def(d,".id"),h=u.def(l,"[",p,"]");u(e.shared.gl,".useProgram(",d,".program);","if(!",h,"){",h,"=",l,"[",p,"]=",e.link(function(t){return G(Y,e,n,t,2)}),"(",d,");}",h,".call(this,a0[",o,"],",o,");")}}function Q(e,t,n){var r=t.static[n];if(r&&function(e){if("object"==typeof e&&!ze(e)){for(var t=Object.keys(e),n=0;n 0&&n(e.shared.current,".dirty=true;")}(a,s),function(e,t){var r=e.proc("scope",3);e.batchId="a2";var i=e.shared,o=i.current;function a(n){var o=t.shader[n];o&&r.set(i.shader,"."+n,o.append(e,r))}P(e,r,t.context),t.framebuffer&&t.framebuffer.append(e,r),Ji(Object.keys(t.state)).forEach(function(n){var o=t.state[n].append(e,r);ze(o)?o.forEach(function(t,i){r.set(e.next[n],"["+i+"]",t)}):r.set(i.next,"."+n,o)}),N(e,r,t,!0,!0),[Nr,Ur,Vr,Gr,Hr].forEach(function(n){var o=t.draw[n];o&&r.set(i.draw,"."+n,""+o.append(e,r))}),Object.keys(t.uniforms).forEach(function(o){r.set(i.uniforms,"["+n.id(o)+"]",t.uniforms[o].append(e,r))}),Object.keys(t.attributes).forEach(function(n){var i=t.attributes[n].append(e,r),o=e.scopeAttrib(n);Object.keys(new g).forEach(function(e){r.set(o,"."+e,i[e])})}),t.scopeVAO&&r.set(i.vao,".targetVAO",t.scopeVAO.append(e,r)),a(Lr),a(Br),Object.keys(t.state).length>0&&(r(o,".dirty=true;"),r.exit(o,".dirty=true;")),r("a1(",e.shared.context,",a0,",e.batchId,");")}(a,s),function(e,t){var n=e.proc("batch",2);e.batchId="0",L(e,n);var r=!1,i=!0;Object.keys(t.context).forEach(function(e){r=r||t.context[e].propDep}),r||(P(e,n,t.context),i=!1);var o=t.framebuffer,a=!1;function s(e){return e.contextDep&&r||e.propDep}o?(o.propDep?r=a=!0:o.contextDep&&r&&(a=!0),a||F(e,n,o)):F(e,n,null),t.state.viewport&&t.state.viewport.propDep&&(r=!0),I(e,n,t),z(e,n,t.state,function(e){return!s(e)}),t.profile&&s(t.profile)||N(e,n,t,!1,"a1"),t.contextDep=r,t.needsContext=i,t.needsFramebuffer=a;var u=t.shader.progVar;if(u.contextDep&&r||u.propDep)X(e,n,t,null);else{var c=u.append(e,n);if(n(e.shared.gl,".useProgram(",c,".program);"),t.shader.program)X(e,n,t,t.shader.program);else{n(e.shared.vao,".setVAO(null);");var f=e.global.def("{}"),l=n.def(c,".id"),d=n.def(f,"[",l,"]");n(e.cond(d).then(d,".call(this,a0,a1);").else(d,"=",f,"[",l,"]=",e.link(function(n){return G(X,e,t,n,2)}),"(",c,");",d,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}(a,s),a.compile()}}}var io=34918,oo=34919,ao=35007,so=function(e,t){if(!t.ext_disjoint_timer_query)return null;var n=[];function r(e){n.push(e)}var i=[];function o(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}var a=[];function s(e){a.push(e)}var u=[];function c(e,t,n){var r=a.pop()||new o;r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,u.push(r)}var f=[],l=[];return{beginQuery:function(e){var r=n.pop()||t.ext_disjoint_timer_query.createQueryEXT();t.ext_disjoint_timer_query.beginQueryEXT(ao,r),i.push(r),c(i.length-1,i.length,e)},endQuery:function(){t.ext_disjoint_timer_query.endQueryEXT(ao)},pushScopeStats:c,update:function(){var e,n,o=i.length;if(0!==o){l.length=Math.max(l.length,o+1),f.length=Math.max(f.length,o+1),f[0]=0,l[0]=0;var a=0;for(e=0,n=0;n 0)if(Array.isArray(n[0])){s=le(n);for(var f=1,l=1;l 0)if("number"==typeof t[0]){var o=te.allocType(d.dtype,t.length);be(o,t),h(o,i),te.freeType(o)}else if(Array.isArray(t[0])||e(t[0])){r=le(t);var a=fe(t,r,d.dtype);h(a,i),te.freeType(a)}else R.raise("invalid buffer data")}else if(re(t)){var s=t.stride,u=0,c=0,f=0,l=0;1===(r=t.shape).length?(u=r[0],c=1,f=s[0],l=0):2===r.length?(u=r[0],c=r[1],f=s[0],l=s[1]):R.raise("invalid shape");var m=Array.isArray(t.data)?d.dtype:ve(t.data),g=te.allocType(m,u*c);ye(g,t.data,u,c,f,l,t.offset),h(g,i),te.freeType(g)}else R.raise("invalid data for buffer subdata");return p},r.profile&&(p.stats=d.stats),p.destroy=function(){l(d)},p},createStream:function(e,t){var n=u.pop();return n||(n=new s(e)),n.bind(),f(n,t,pe,0,1,!1),n},destroyStream:function(e){u.push(e)},clear:function(){ie(a).forEach(l),u.forEach(l)},getBuffer:function(e){return e&&e._buffer instanceof s?e._buffer:null},restore:function(){ie(a).forEach(function(e){e.buffer=t.createBuffer(),t.bindBuffer(e.type,e.buffer),t.bufferData(e.type,e.persistentData||e.byteLength,e.usage)})},_initBuffer:f}}(i,l,r,function(e){return _.destroyBuffer(e)}),_=function(t,n,r,i,o){for(var a=r.maxAttributes,s=new Array(a),u=0;u0,"must specify at least one attribute");for(var i=0;i =1&&l.size<=4,"size must be between 1 and 4"),R(l.offset>=0,"invalid offset"),R(l.stride>=0&&l.stride<=255,"stride must be between 0 and 255"),R(l.divisor>=0,"divisor must be positive"),R(!l.divisor||!!n.angle_instanced_arrays,"ANGLE_instanced_arrays must be enabled to use divisor")):"x"in f?(R(c>0,"first attribute must not be a constant"),l.x=+f.x||0,l.y=+f.y||0,l.z=+f.z||0,l.w=+f.w||0,l.state=2):R(!1,"invalid attribute spec for location "+c)}return r.refresh(),s}return i.vaoCount+=1,s.destroy=function(){r.destroy()},s._vao=r,s._reglType="vao",s(t)},getVAO:function(e){return"function"==typeof e&&e._vao?e._vao:null},destroyBuffer:function(e){for(var n=0;n >=1:l===Oe&&(p>>=2)),i.vertCount=p;var h=s;if(s<0){h=Ae;var m=i.buffer.dimension;1===m&&(h=xe),2===m&&(h=we),3===m&&(h=Ae)}i.primType=h}function l(e){i.elementsCount--,R(null!==e.buffer,"must not double destroy elements"),delete o[e.id],e.buffer.destroy(),e.buffer=null}return{create:function(t,n){var o=r.create(null,De,!0),a=new u(o._buffer);function c(t){if(t)if("number"==typeof t)o(t),a.primType=Ae,a.vertCount=0|t,a.type=ke;else{var n=null,r=je,i=-1,u=-1,l=0,d=0;Array.isArray(t)||e(t)||re(t)?n=t:(R.type(t,"object","invalid arguments for elements"),"data"in t&&(n=t.data,R(Array.isArray(n)||e(n)||re(n),"invalid data for element buffer")),"usage"in t&&(R.parameter(t.usage,ce,"invalid element buffer usage"),r=ce[t.usage]),"primitive"in t&&(R.parameter(t.primitive,_e,"invalid element buffer primitive"),i=_e[t.primitive]),"count"in t&&(R("number"==typeof t.count&&t.count>=0,"invalid vertex count for elements"),u=0|t.count),"type"in t&&(R.parameter(t.type,s,"invalid buffer type"),d=s[t.type]),"length"in t?l=0|t.length:(l=u,d===Te||d===Se?l*=2:d!==Oe&&d!==Ce||(l*=4))),f(a,n,r,i,u,l,d)}else o(),a.primType=Ae,a.vertCount=0,a.type=ke;return c}return i.elementsCount++,c(t),c._reglType="elements",c._elements=a,c.subdata=function(e,t){return o.subdata(e,t),c},c.destroy=function(){l(a)},c},createStream:function(e){var t=c.pop();return t||(t=new u(r.create(null,De,!0,!1)._buffer)),f(t,e,Me,-1,-1,0,0),t},destroyStream:function(e){c.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof u?e._elements:null},clear:function(){ie(o).forEach(l)}}}(i,d,y,l),w=function(e,t,n,r){var i={},o={};function a(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function s(e,t){for(var n=0;n 1)for(var v=0;v e&&(e=t.stats.uniformsCount)}),e},n.getMaxAttributesCount=function(){var e=0;return f.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);ie(i).forEach(t),i={},ie(o).forEach(t),o={},f.forEach(function(t){e.deleteProgram(t.program)}),f.length=0,c={},n.shaderCount=0},program:function(e,t,r,i){R.command(e>=0,"missing vertex shader",r),R.command(t>=0,"missing fragment shader",r);var o=c[t];o||(o=c[t]={});var a=o[e];if(a&&!i)return a;var s=new d(t,e);return n.shaderCount++,p(s,r,i),a||(o[e]=s),f.push(s),s},restore:function(){i={},o={};for(var e=0;e =kn&&t =2,"invalid shape for framebuffer"),a=M[0],d=M[1]}else"radius"in D&&(a=d=D.radius),"width"in D&&(a=D.width),"height"in D&&(d=D.height);("color"in D||"colors"in D)&&(y=D.color||D.colors,Array.isArray(y)&&R(1===y.length||n.webgl_draw_buffers,"multiple render targets not supported")),y||("colorCount"in D&&R((k=0|D.colorCount)>0,"invalid color buffer count"),"colorTexture"in D&&(_=!!D.colorTexture,x="rgba4"),"colorType"in D&&(A=D.colorType,_?(R(n.oes_texture_float||!("float"===A||"float32"===A),"you must enable OES_texture_float in order to use floating point framebuffer objects"),R(n.oes_texture_half_float||!("half float"===A||"float16"===A),"you must enable OES_texture_half_float in order to use 16-bit floating point framebuffer objects")):"half float"===A||"float16"===A?(R(n.ext_color_buffer_half_float,"you must enable EXT_color_buffer_half_float to use 16-bit render buffers"),x="rgba16f"):"float"!==A&&"float32"!==A||(R(n.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),x="rgba32f"),R.oneOf(A,f,"invalid color type")),"colorFormat"in D&&(u.indexOf(x=D.colorFormat)>=0?_=!0:c.indexOf(x)>=0?_=!1:_?R.oneOf(D.colorFormat,u,"invalid color format for texture"):R.oneOf(D.colorFormat,c,"invalid color format for renderbuffer"))),("depthTexture"in D||"depthStencilTexture"in D)&&R(!(O=!(!D.depthTexture&&!D.depthStencilTexture))||n.webgl_depth_texture,"webgl_depth_texture extension not supported"),"depth"in D&&("boolean"==typeof D.depth?h=D.depth:(S=D.depth,b=!1)),"stencil"in D&&("boolean"==typeof D.stencil?b=D.stencil:(T=D.stencil,h=!1)),"depthStencil"in D&&("boolean"==typeof D.depthStencil?h=b=D.depthStencil:(C=D.depthStencil,h=!1,b=!1))}else a=d=1;var j=null,P=null,F=null,I=null;if(Array.isArray(y))j=y.map(m);else if(y)j=[m(y)];else for(j=new Array(k),i=0;i =0||j[i].renderbuffer&&Ln.indexOf(j[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),j[i]&&j[i].texture){var L=Rn[j[i].texture._texture.format]*Pn[j[i].texture._texture.type];null===z?z=L:R(z===L,"all color attachments much have the same number of bits per pixel.")}return p(P,a,d),R(!P||P.texture&&P.texture._texture.format===Mn||P.renderbuffer&&P.renderbuffer._renderbuffer.format===Fn,"invalid depth attachment for framebuffer object"),p(F,a,d),R(!F||F.renderbuffer&&F.renderbuffer._renderbuffer.format===In,"invalid stencil attachment for framebuffer object"),p(I,a,d),R(!I||I.texture&&I.texture._texture.format===zn||I.renderbuffer&&I.renderbuffer._renderbuffer.format===zn,"invalid depth-stencil attachment for framebuffer object"),w(o),o.width=a,o.height=d,o.colorAttachments=j,o.depthAttachment=P,o.stencilAttachment=F,o.depthStencilAttachment=I,l.color=j.map(v),l.depth=v(P),l.stencil=v(F),l.depthStencil=v(I),l.width=o.width,l.height=o.height,E(o),l}return a.framebufferCount++,l(e,i),t(l,{resize:function(e,t){R(s.next!==o,"can not resize a framebuffer which is currently in use");var n=Math.max(0|e,1),r=Math.max(0|t||n,1);if(n===o.width&&r===o.height)return l;for(var i=o.colorAttachments,a=0;a =2,"invalid shape for framebuffer"),R(b[0]===b[1],"cube framebuffer must be square"),d=b[0]}else"radius"in v&&(d=0|v.radius),"width"in v?(d=0|v.width,"height"in v&&R(v.height===d,"must be square")):"height"in v&&(d=0|v.height);("color"in v||"colors"in v)&&(p=v.color||v.colors,Array.isArray(p)&&R(1===p.length||n.webgl_draw_buffers,"multiple render targets not supported")),p||("colorCount"in v&&R((g=0|v.colorCount)>0,"invalid color buffer count"),"colorType"in v&&(R.oneOf(v.colorType,f,"invalid color type"),m=v.colorType),"colorFormat"in v&&(h=v.colorFormat,R.oneOf(v.colorFormat,u,"invalid color format for texture"))),"depth"in v&&(l.depth=v.depth),"stencil"in v&&(l.stencil=v.stencil),"depthStencil"in v&&(l.depthStencil=v.depthStencil)}else d=1;if(p)if(Array.isArray(p))for(c=[],r=0;r 0&&(l.depth=o[0].depth,l.stencil=o[0].stencil,l.depthStencil=o[0].depthStencil),o[r]?o[r](l):o[r]=k(l)}return t(a,{width:d,height:d,color:c})}return a(e),t(a,{faces:o,resize:function(e){var t,n=0|e;if(R(n>0&&n<=r.maxCubeMapSize,"invalid radius for cube fbo"),n===a.width)return a;var i=a.color;for(t=0;t =0;--e){var t=D[e];t&&t(v,null,0)}i.flush(),p&&p.update()}function z(){!F&&D.length>0&&(F=N.next(I))}function L(){F&&(N.cancel(I),F=null)}function V(e){e.preventDefault(),a=!0,L(),M.forEach(function(e){e()})}function U(e){i.getError(),a=!1,s.restore(),w.restore(),y.restore(),A.restore(),E.restore(),k.restore(),_.restore(),p&&p.restore(),S.procs.refresh(),z(),j.forEach(function(e){e()})}function W(e){function n(e){var t={},n={};return Object.keys(e).forEach(function(r){var i=e[r];B.isDynamic(i)?n[r]=B.unbox(i,r):t[r]=i}),{dynamic:n,static:t}}R(!!e,"invalid args to regl({...})"),R.type(e,"object","invalid args to regl({...})");var r=n(e.context||{}),i=n(e.uniforms||{}),o=n(e.attributes||{}),s=n(function(e){var n=t({},e);function r(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach(function(r){n[e+"."+r]=t[r]})}}return delete n.uniforms,delete n.attributes,delete n.context,delete n.vao,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),r("blend"),r("depth"),r("cull"),r("stencil"),r("polygonOffset"),r("scissor"),r("sample"),"vao"in e&&(n.vao=e.vao),n}(e)),u={gpuTime:0,cpuTime:0,count:0},c=S.compile(s,o,i,r,u),f=c.draw,l=c.batch,d=c.scope,p=[];return t(function(e,t){var n;if(a&&R.raise("context lost"),"function"==typeof e)return d.call(this,null,e,0);if("function"==typeof t)if("number"==typeof e)for(n=0;n 0)return l.call(this,function(e){for(;p.length =0,"cannot cancel a frame twice"),D[t]=function e(){var t=bo(D,e);D[t]=D[D.length-1],D.length-=1,D.length<=0&&L()}}}}function Q(){var e=C.viewport,t=C.scissor_box;e[0]=e[1]=t[0]=t[1]=0,v.viewportWidth=v.framebufferWidth=v.drawingBufferWidth=e[2]=t[2]=i.drawingBufferWidth,v.viewportHeight=v.framebufferHeight=v.drawingBufferHeight=e[3]=t[3]=i.drawingBufferHeight}function K(){v.tick+=1,v.time=Z(),Q(),S.procs.poll()}function J(){Q(),S.procs.refresh(),p&&p.update()}function Z(){return(H()-h)/1e3}J();var $=t(W,{clear:function(e){if(R("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var n=0;n<6;++n)q(t({framebuffer:e.framebuffer.faces[n]},e),Y);else q(e,Y);else Y(0,e)},prop:B.define.bind(null,mo),context:B.define.bind(null,go),this:B.define.bind(null,vo),draw:W({}),buffer:function(e){return y.create(e,lo,!1,!1)},elements:function(e){return x.create(e,!1)},texture:A.create2D,cube:A.createCube,renderbuffer:E.create,framebuffer:k.create,framebufferCube:k.createCube,vao:_.createVAO,attributes:o,frame:X,on:function(e,t){var n;switch(R.type(t,"function","listener callback must be a function"),e){case"frame":return X(t);case"lost":n=M;break;case"restore":n=j;break;case"destroy":n=P;break;default:R.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(t),{cancel:function(){for(var e=0;e =0},read:T,destroy:function(){D.length=0,L(),O&&(O.removeEventListener(po,V),O.removeEventListener(ho,U)),w.clear(),k.clear(),E.clear(),A.clear(),x.clear(),y.clear(),_.clear(),p&&p.clear(),P.forEach(function(e){e()})},_gl:i,_refresh:J,poll:function(){K(),p&&p.update()},now:Z,stats:l});return r.onDone(null,$),$}},"object"==typeof n&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):r.createREGL=i()},{}],9:[function(e,t,n){(function(e){"use strict";var n=256,r=[],i=void 0===e?window:e,o=Math.pow(n,6),a=Math.pow(2,52),s=2*a,u=n-1,c=Math.random;function f(e){var t,r=e.length,i=this,o=0,a=i.i=i.j=0,s=i.S=[];for(r||(e=[r++]);o =s;)e/=2,t/=2,r>>>=1;return(e+r)/t}},t.exports.resetGlobal=function(){Math.random=c},l(Math.random(),r)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,n){!function(){"use strict";var e=.5*(Math.sqrt(3)-1),r=(3-Math.sqrt(3))/6,i=1/6,o=(Math.sqrt(5)-1)/4,a=(5-Math.sqrt(5))/20;function s(e){var t;t="function"==typeof e?e:e?function(){var e=0,t=0,n=0,r=1,i=(o=4022871197,function(e){e=e.toString();for(var t=0;t >>0,o=(n*=o)>>>0,o+=4294967296*(n-=o)}return 2.3283064365386963e-10*(o>>>0)});var o;e=i(" "),t=i(" "),n=i(" ");for(var a=0;a v?(i=1,o=0):(i=0,o=1);var b=g-i+r,y=v-o+r,_=g-1+2*r,x=v-1+2*r,w=255&p,A=255&h,E=.5-g*g-v*v;if(E>=0){var k=3*a[w+s[A]];c=(E*=E)*E*(u[k]*g+u[k+1]*v)}var S=.5-b*b-y*y;if(S>=0){var T=3*a[w+i+s[A+o]];f=(S*=S)*S*(u[T]*b+u[T+1]*y)}var C=.5-_*_-x*x;if(C>=0){var O=3*a[w+1+s[A+1]];l=(C*=C)*C*(u[O]*_+u[O+1]*x)}return 70*(c+f+l)},noise3D:function(e,t,n){var r,o,a,s,u,c,f,l,d,p,h=this.permMod12,m=this.perm,g=this.grad3,v=(e+t+n)*(1/3),b=Math.floor(e+v),y=Math.floor(t+v),_=Math.floor(n+v),x=(b+y+_)*i,w=e-(b-x),A=t-(y-x),E=n-(_-x);w>=A?A>=E?(u=1,c=0,f=0,l=1,d=1,p=0):w>=E?(u=1,c=0,f=0,l=1,d=0,p=1):(u=0,c=0,f=1,l=1,d=0,p=1):A j?F++:I++,M>R?F++:z++,M>P?F++:L++,j>R?I++:z++,j>P?I++:L++,R>P?z++:L++;var B=M-(l=F>=3?1:0)+a,N=j-(d=I>=3?1:0)+a,H=R-(p=z>=3?1:0)+a,V=P-(h=L>=3?1:0)+a,U=M-(m=F>=2?1:0)+2*a,G=j-(g=I>=2?1:0)+2*a,W=R-(v=z>=2?1:0)+2*a,q=P-(b=L>=2?1:0)+2*a,Y=M-(y=F>=1?1:0)+3*a,X=j-(_=I>=1?1:0)+3*a,Q=R-(x=z>=1?1:0)+3*a,K=P-(w=L>=1?1:0)+3*a,J=M-1+4*a,Z=j-1+4*a,$=R-1+4*a,ee=P-1+4*a,te=255&S,ne=255&T,re=255&C,ie=255&O,oe=.6-M*M-j*j-R*R-P*P;if(oe<0)i=0;else{var ae=A[te+A[ne+A[re+A[ie]]]]%32*4;i=(oe*=oe)*oe*(E[ae]*M+E[ae+1]*j+E[ae+2]*R+E[ae+3]*P)}var se=.6-B*B-N*N-H*H-V*V;if(se<0)s=0;else{var ue=A[te+l+A[ne+d+A[re+p+A[ie+h]]]]%32*4;s=(se*=se)*se*(E[ue]*B+E[ue+1]*N+E[ue+2]*H+E[ue+3]*V)}var ce=.6-U*U-G*G-W*W-q*q;if(ce<0)u=0;else{var fe=A[te+m+A[ne+g+A[re+v+A[ie+b]]]]%32*4;u=(ce*=ce)*ce*(E[fe]*U+E[fe+1]*G+E[fe+2]*W+E[fe+3]*q)}var le=.6-Y*Y-X*X-Q*Q-K*K;if(le<0)c=0;else{var de=A[te+y+A[ne+_+A[re+x+A[ie+w]]]]%32*4;c=(le*=le)*le*(E[de]*Y+E[de+1]*X+E[de+2]*Q+E[de+3]*K)}var pe=.6-J*J-Z*Z-$*$-ee*ee;if(pe<0)f=0;else{var he=A[te+1+A[ne+1+A[re+1+A[ie+1]]]]%32*4;f=(pe*=pe)*pe*(E[he]*J+E[he+1]*Z+E[he+2]*$+E[he+3]*ee)}return 27*(i+s+u+c+f)}},s._buildPermutationTable=u,"undefined"!=typeof define&&define.amd&&define(function(){return s}),void 0!==n?n.SimplexNoise=s:"undefined"!=typeof window&&(window.SimplexNoise=s),void 0!==t&&(t.exports=s)}()},{}],11:[function(e,t,n){var r,i;r=this,i=function(){var e=function(){function t(e){return i.appendChild(e.dom),e}function n(e){for(var t=0;t a+1e3&&(u.update(1e3*s/(e-a),100),a=e,s=0,f)){var t=performance.memory;f.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:i,setMode:n}};return e.Panel=function(e,t,n){var r=Infinity,i=0,o=Math.round,a=o(window.devicePixelRatio||1),s=80*a,u=48*a,c=3*a,f=2*a,l=3*a,d=15*a,p=74*a,h=30*a,m=document.createElement("canvas");m.width=s,m.height=u,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,s,u),g.fillStyle=t,g.fillText(e,c,f),g.fillRect(l,d,p,h),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(l,d,p,h),{dom:m,update:function(u,v){r=Math.min(r,u),i=Math.max(i,u),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,d),g.fillStyle=t,g.fillText(o(u)+" "+e+" ("+o(r)+"-"+o(i)+")",c,f),g.drawImage(m,l+a,d,p-a,h,l,d,p-a,h),g.fillRect(l+p-a,d,a,h),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(l+p-a,d,a,o((1-u/v)*h))}}},e},"object"==typeof n&&void 0!==t?t.exports=i():"function"==typeof define&&define.amd?define(i):r.Stats=i()},{}],12:[function(e,t,n){var r=arguments[3],i=arguments[4],o=arguments[5],a=JSON.stringify;t.exports=function(e,t){for(var n,s=Object.keys(o),u=0,c=s.length;u 0){if(v.clear({color:[0,0,0,1]}),S.animate&&(S.lerpPercent=(1+Math.cos(t/4))*(1+Math.sin(t))/4,S.bgIndex=(1+Math.sin(1/3*t))/2,j=!0),j){for(var n=0,r=1,i=0;i n&&(n=a),a f){var w=!1;v&&(w=i(v,m)<0),d.push({pos:m,radius:g,id:d.length,touched:v?v.id:-1,inside:w}),h.push(g),g,h.length>50&&h.shift(),p=0;d.length%10==0&&e.postMessage({type:"LOADING",num:d.length,total:u})}p++}for(var A=d.length,E=[],k=new Float32Array(A),S=new Int32Array(A),T=0;T