-
Notifications
You must be signed in to change notification settings - Fork 13
/
bundle.js
4 lines (4 loc) · 124 KB
/
bundle.js
1
2
3
4
!function e(t,n,r){function a(o,f){if(!n[o]){if(!t[o]){var u="function"==typeof require&&require;if(!f&&u)return u(o,!0);if(i)return i(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return a(n?n:e)},c,c.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,n){"use strict";var r=e(29),a=e(14),i=e(30),o=6.283185307179586;t.exports=function(e){var t=i(1,1,2,2);return e({frag:"\n precision mediump float;\n varying vec3 vNormal;\n varying vec2 vUv;\n void main () {\n float brightness = 0.5 * min(1.0,\n 1.5 * (1.0 - length(2.0 * vUv - vec2(1.0)))\n );\n gl_FragColor = vec4(vec3(vUv, 1.0) * brightness, 1.0);\n }",vert:r(["\n //\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v)\n {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n }\n\n precision mediump float;\n#define GLSLIFY 1\n\n uniform mat4 proj;\n uniform mat4 model;\n uniform mat4 view;\n uniform float time;\n attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n varying vec2 vUv;\n varying vec3 vNormal;\n\n float NOISE_SPEED = 0.5;\n float NOISE_PERIOD = 3.0;\n float NOISE_AMPLITUDE = 0.05;\n\n void main () {\n vNormal = normal;\n vUv = uv;\n vec3 position2 = position;\n position2.z = 0.015;\n gl_Position = proj * view * model * vec4(position2, 1.0);\n }",""]),attributes:{position:t.positions,normal:t.normals,uv:t.uvs},elements:t.cells,uniforms:{time:function(e){var t=e.time;return t},proj:function(e){var t=e.viewportWidth,n=e.viewportHeight;return a.perspective([],.05*o,t/n,.01,1e3)},model:a.rotateX([],a.identity([]),.25*o),view:a.lookAt([],[1,.5,1],[0,0,0],[0,1,0])}})}},{14:14,29:29,30:30}],2:[function(e,t,n){"use strict";var r=e(29),a=e(14),i=e(30),o=6.283185307179586;t.exports=function(e){var t=i(1,1,30,30);return e({frag:"\n precision mediump float;\n varying vec3 vNormal;\n varying vec2 vUv;\n void main () {\n float brightness = min(1.0,\n 1.5 * (1.0 - length(2.0 * vUv - vec2(1.0)))\n );\n gl_FragColor = vec4(vec3(vUv, 1.0) * brightness, 1.0);\n }",vert:r(["\n //\n// Description : Array and textureless GLSL 2D/3D/4D simplex\n// noise functions.\n// Author : Ian McEwan, Ashima Arts.\n// Maintainer : ijm\n// Lastmod : 20110822 (ijm)\n// License : Copyright (C) 2011 Ashima Arts. All rights reserved.\n// Distributed under the MIT License. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec3 mod289(vec3 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x) {\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x) {\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nfloat snoise(vec3 v)\n {\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n }\n\n precision mediump float;\n#define GLSLIFY 1\n\n uniform mat4 proj;\n uniform mat4 model;\n uniform mat4 view;\n uniform float time;\n attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n varying vec2 vUv;\n varying vec3 vNormal;\n\n float NOISE_SPEED = 0.5;\n float NOISE_PERIOD = 3.0;\n float NOISE_AMPLITUDE = 0.05;\n\n void main () {\n vNormal = normal;\n vUv = uv;\n vec3 position3 = position;\n float noisePeriod = mix(0.8, 1.3, (sin(time) + 1.0)) * NOISE_PERIOD;\n position3.z = snoise(\n vec3(\n noisePeriod * position.x + time * 1.5,\n noisePeriod * position.y,\n time * NOISE_SPEED\n )\n ) * NOISE_AMPLITUDE;\n gl_Position = proj * view * model * vec4(position3, 1.0);\n }",""]),attributes:{position:t.positions,normal:t.normals,uv:t.uvs},elements:t.cells,uniforms:{time:function(e){var t=e.time;return t},proj:function(e){var t=e.viewportWidth,n=e.viewportHeight;return a.perspective([],.05*o,t/n,.01,1e3)},model:a.rotateX([],a.identity([]),.25*o),view:a.lookAt([],[1,.5,1],[0,0,0],[0,1,0])},primitive:"lines",lineWidth:Math.min(2*window.devicePixelRatio,e.limits.lineWidthDims[1])})}},{14:14,29:29,30:30}],3:[function(e,t,n){"use strict";var r=e(4)({container:document.querySelector(".header")}),a=e(1)(r),i=e(2)(r);r.frame(function(){r.clear({color:[0,0,0,1]}),i(),a(),window.frameDone()})},{1:1,2:2,4:4}],4:[function(e,t,n){"use strict";var r=e(31);t.exports=function(){var e=this,t=arguments,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=Object.assign({onDone:function(r){if("function"==typeof n.onDone&&n.onDone.apply(e,t),r){var a=document.createElement("div");document.body.appendChild(a),a.className="error";var i=document.createElement("div");i.innerText=r,a.appendChild(i)}}},n);return"function"==typeof headlessRegl?a=headlessRegl(a):window.frameDone=function(){},r(a)}},{31:31}],5:[function(e,t,n){function r(e,t){var n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],f=t[5],u=t[6],s=t[7],c=t[8],l=t[9],m=t[10],d=t[11],p=t[12],h=t[13],v=t[14],b=t[15];return e[0]=f*(m*b-d*v)-l*(u*b-s*v)+h*(u*d-s*m),e[1]=-(r*(m*b-d*v)-l*(a*b-i*v)+h*(a*d-i*m)),e[2]=r*(u*b-s*v)-f*(a*b-i*v)+h*(a*s-i*u),e[3]=-(r*(u*d-s*m)-f*(a*d-i*m)+l*(a*s-i*u)),e[4]=-(o*(m*b-d*v)-c*(u*b-s*v)+p*(u*d-s*m)),e[5]=n*(m*b-d*v)-c*(a*b-i*v)+p*(a*d-i*m),e[6]=-(n*(u*b-s*v)-o*(a*b-i*v)+p*(a*s-i*u)),e[7]=n*(u*d-s*m)-o*(a*d-i*m)+c*(a*s-i*u),e[8]=o*(l*b-d*h)-c*(f*b-s*h)+p*(f*d-s*l),e[9]=-(n*(l*b-d*h)-c*(r*b-i*h)+p*(r*d-i*l)),e[10]=n*(f*b-s*h)-o*(r*b-i*h)+p*(r*s-i*f),e[11]=-(n*(f*d-s*l)-o*(r*d-i*l)+c*(r*s-i*f)),e[12]=-(o*(l*v-m*h)-c*(f*v-u*h)+p*(f*m-u*l)),e[13]=n*(l*v-m*h)-c*(r*v-a*h)+p*(r*m-a*l),e[14]=-(n*(f*v-u*h)-o*(r*v-a*h)+p*(r*u-a*f)),e[15]=n*(f*m-u*l)-o*(r*m-a*l)+c*(r*u-a*f),e}t.exports=r},{}],6:[function(e,t,n){function r(e){var t=new Float32Array(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}t.exports=r},{}],7:[function(e,t,n){function r(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}t.exports=r},{}],8:[function(e,t,n){function r(){var e=new Float32Array(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}t.exports=r},{}],9:[function(e,t,n){function r(e){var t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],o=e[5],f=e[6],u=e[7],s=e[8],c=e[9],l=e[10],m=e[11],d=e[12],p=e[13],h=e[14],v=e[15],b=t*o-n*i,g=t*f-r*i,y=t*u-a*i,x=n*f-r*o,w=n*u-a*o,k=r*u-a*f,S=s*p-c*d,_=s*h-l*d,A=s*v-m*d,E=c*h-l*p,D=c*v-m*p,T=l*v-m*h;return b*T-g*D+y*E+x*A-w*_+k*S}t.exports=r},{}],10:[function(e,t,n){function r(e,t){var n=t[0],r=t[1],a=t[2],i=t[3],o=n+n,f=r+r,u=a+a,s=n*o,c=r*o,l=r*f,m=a*o,d=a*f,p=a*u,h=i*o,v=i*f,b=i*u;return e[0]=1-l-p,e[1]=c+b,e[2]=m-v,e[3]=0,e[4]=c-b,e[5]=1-s-p,e[6]=d+h,e[7]=0,e[8]=m+v,e[9]=d-h,e[10]=1-s-l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}t.exports=r},{}],11:[function(e,t,n){function r(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],f=r+r,u=a+a,s=i+i,c=r*f,l=r*u,m=r*s,d=a*u,p=a*s,h=i*s,v=o*f,b=o*u,g=o*s;return e[0]=1-(d+h),e[1]=l+g,e[2]=m-b,e[3]=0,e[4]=l-g,e[5]=1-(c+h),e[6]=p+v,e[7]=0,e[8]=m+b,e[9]=p-v,e[10]=1-(c+d),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}t.exports=r},{}],12:[function(e,t,n){function r(e,t,n,r,a,i,o){var f=1/(n-t),u=1/(a-r),s=1/(i-o);return e[0]=2*i*f,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*i*u,e[6]=0,e[7]=0,e[8]=(n+t)*f,e[9]=(a+r)*u,e[10]=(o+i)*s,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*s,e[15]=0,e}t.exports=r},{}],13:[function(e,t,n){function r(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}t.exports=r},{}],14:[function(e,t,n){t.exports={create:e(8),clone:e(6),copy:e(7),identity:e(13),transpose:e(28),invert:e(15),adjoint:e(5),determinant:e(9),multiply:e(17),translate:e(27),scale:e(25),rotate:e(21),rotateX:e(22),rotateY:e(23),rotateZ:e(24),fromRotationTranslation:e(11),fromQuat:e(10),frustum:e(12),perspective:e(19),perspectiveFromFieldOfView:e(20),ortho:e(18),lookAt:e(16),str:e(26)}},{10:10,11:11,12:12,13:13,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,5:5,6:6,7:7,8:8,9:9}],15:[function(e,t,n){function r(e,t){var n=t[0],r=t[1],a=t[2],i=t[3],o=t[4],f=t[5],u=t[6],s=t[7],c=t[8],l=t[9],m=t[10],d=t[11],p=t[12],h=t[13],v=t[14],b=t[15],g=n*f-r*o,y=n*u-a*o,x=n*s-i*o,w=r*u-a*f,k=r*s-i*f,S=a*s-i*u,_=c*h-l*p,A=c*v-m*p,E=c*b-d*p,D=l*v-m*h,T=l*b-d*h,j=m*b-d*v,C=g*j-y*T+x*D+w*E-k*A+S*_;return C?(C=1/C,e[0]=(f*j-u*T+s*D)*C,e[1]=(a*T-r*j-i*D)*C,e[2]=(h*S-v*k+b*w)*C,e[3]=(m*k-l*S-d*w)*C,e[4]=(u*E-o*j-s*A)*C,e[5]=(n*j-a*E+i*A)*C,e[6]=(v*x-p*S-b*y)*C,e[7]=(c*S-m*x+d*y)*C,e[8]=(o*T-f*E+s*_)*C,e[9]=(r*E-n*T-i*_)*C,e[10]=(p*k-h*x+b*g)*C,e[11]=(l*x-c*k-d*g)*C,e[12]=(f*A-o*D-u*_)*C,e[13]=(n*D-r*A+a*_)*C,e[14]=(h*y-p*w-v*g)*C,e[15]=(c*w-l*y+m*g)*C,e):null}t.exports=r},{}],16:[function(e,t,n){function r(e,t,n,r){var i,o,f,u,s,c,l,m,d,p,h=t[0],v=t[1],b=t[2],g=r[0],y=r[1],x=r[2],w=n[0],k=n[1],S=n[2];return Math.abs(h-w)<1e-6&&Math.abs(v-k)<1e-6&&Math.abs(b-S)<1e-6?a(e):(l=h-w,m=v-k,d=b-S,p=1/Math.sqrt(l*l+m*m+d*d),l*=p,m*=p,d*=p,i=y*d-x*m,o=x*l-g*d,f=g*m-y*l,p=Math.sqrt(i*i+o*o+f*f),p?(p=1/p,i*=p,o*=p,f*=p):(i=0,o=0,f=0),u=m*f-d*o,s=d*i-l*f,c=l*o-m*i,p=Math.sqrt(u*u+s*s+c*c),p?(p=1/p,u*=p,s*=p,c*=p):(u=0,s=0,c=0),e[0]=i,e[1]=u,e[2]=l,e[3]=0,e[4]=o,e[5]=s,e[6]=m,e[7]=0,e[8]=f,e[9]=c,e[10]=d,e[11]=0,e[12]=-(i*h+o*v+f*b),e[13]=-(u*h+s*v+c*b),e[14]=-(l*h+m*v+d*b),e[15]=1,e)}var a=e(13);t.exports=r},{13:13}],17:[function(e,t,n){function r(e,t,n){var r=t[0],a=t[1],i=t[2],o=t[3],f=t[4],u=t[5],s=t[6],c=t[7],l=t[8],m=t[9],d=t[10],p=t[11],h=t[12],v=t[13],b=t[14],g=t[15],y=n[0],x=n[1],w=n[2],k=n[3];return e[0]=y*r+x*f+w*l+k*h,e[1]=y*a+x*u+w*m+k*v,e[2]=y*i+x*s+w*d+k*b,e[3]=y*o+x*c+w*p+k*g,y=n[4],x=n[5],w=n[6],k=n[7],e[4]=y*r+x*f+w*l+k*h,e[5]=y*a+x*u+w*m+k*v,e[6]=y*i+x*s+w*d+k*b,e[7]=y*o+x*c+w*p+k*g,y=n[8],x=n[9],w=n[10],k=n[11],e[8]=y*r+x*f+w*l+k*h,e[9]=y*a+x*u+w*m+k*v,e[10]=y*i+x*s+w*d+k*b,e[11]=y*o+x*c+w*p+k*g,y=n[12],x=n[13],w=n[14],k=n[15],e[12]=y*r+x*f+w*l+k*h,e[13]=y*a+x*u+w*m+k*v,e[14]=y*i+x*s+w*d+k*b,e[15]=y*o+x*c+w*p+k*g,e}t.exports=r},{}],18:[function(e,t,n){function r(e,t,n,r,a,i,o){var f=1/(t-n),u=1/(r-a),s=1/(i-o);return e[0]=-2*f,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*s,e[11]=0,e[12]=(t+n)*f,e[13]=(a+r)*u,e[14]=(o+i)*s,e[15]=1,e}t.exports=r},{}],19:[function(e,t,n){function r(e,t,n,r,a){var i=1/Math.tan(t/2),o=1/(r-a);return e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(a+r)*o,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*a*r*o,e[15]=0,e}t.exports=r},{}],20:[function(e,t,n){function r(e,t,n,r){var a=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),f=Math.tan(t.rightDegrees*Math.PI/180),u=2/(o+f),s=2/(a+i);return e[0]=u,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=-((o-f)*u*.5),e[9]=(a-i)*s*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e}t.exports=r},{}],21:[function(e,t,n){function r(e,t,n,r){var a,i,o,f,u,s,c,l,m,d,p,h,v,b,g,y,x,w,k,S,_,A,E,D,T=r[0],j=r[1],C=r[2],O=Math.sqrt(T*T+j*j+C*C);return Math.abs(O)<1e-6?null:(O=1/O,T*=O,j*=O,C*=O,a=Math.sin(n),i=Math.cos(n),o=1-i,f=t[0],u=t[1],s=t[2],c=t[3],l=t[4],m=t[5],d=t[6],p=t[7],h=t[8],v=t[9],b=t[10],g=t[11],y=T*T*o+i,x=j*T*o+C*a,w=C*T*o-j*a,k=T*j*o-C*a,S=j*j*o+i,_=C*j*o+T*a,A=T*C*o+j*a,E=j*C*o-T*a,D=C*C*o+i,e[0]=f*y+l*x+h*w,e[1]=u*y+m*x+v*w,e[2]=s*y+d*x+b*w,e[3]=c*y+p*x+g*w,e[4]=f*k+l*S+h*_,e[5]=u*k+m*S+v*_,e[6]=s*k+d*S+b*_,e[7]=c*k+p*S+g*_,e[8]=f*A+l*E+h*D,e[9]=u*A+m*E+v*D,e[10]=s*A+d*E+b*D,e[11]=c*A+p*E+g*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}t.exports=r},{}],22:[function(e,t,n){function r(e,t,n){var r=Math.sin(n),a=Math.cos(n),i=t[4],o=t[5],f=t[6],u=t[7],s=t[8],c=t[9],l=t[10],m=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*a+s*r,e[5]=o*a+c*r,e[6]=f*a+l*r,e[7]=u*a+m*r,e[8]=s*a-i*r,e[9]=c*a-o*r,e[10]=l*a-f*r,e[11]=m*a-u*r,e}t.exports=r},{}],23:[function(e,t,n){function r(e,t,n){var r=Math.sin(n),a=Math.cos(n),i=t[0],o=t[1],f=t[2],u=t[3],s=t[8],c=t[9],l=t[10],m=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*a-s*r,e[1]=o*a-c*r,e[2]=f*a-l*r,e[3]=u*a-m*r,e[8]=i*r+s*a,e[9]=o*r+c*a,e[10]=f*r+l*a,e[11]=u*r+m*a,e}t.exports=r},{}],24:[function(e,t,n){function r(e,t,n){var r=Math.sin(n),a=Math.cos(n),i=t[0],o=t[1],f=t[2],u=t[3],s=t[4],c=t[5],l=t[6],m=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*a+s*r,e[1]=o*a+c*r,e[2]=f*a+l*r,e[3]=u*a+m*r,e[4]=s*a-i*r,e[5]=c*a-o*r,e[6]=l*a-f*r,e[7]=m*a-u*r,e}t.exports=r},{}],25:[function(e,t,n){function r(e,t,n){var r=n[0],a=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*a,e[5]=t[5]*a,e[6]=t[6]*a,e[7]=t[7]*a,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}t.exports=r},{}],26:[function(e,t,n){function r(e){return"mat4("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+", "+e[4]+", "+e[5]+", "+e[6]+", "+e[7]+", "+e[8]+", "+e[9]+", "+e[10]+", "+e[11]+", "+e[12]+", "+e[13]+", "+e[14]+", "+e[15]+")"}t.exports=r},{}],27:[function(e,t,n){function r(e,t,n){var r,a,i,o,f,u,s,c,l,m,d,p,h=n[0],v=n[1],b=n[2];return t===e?(e[12]=t[0]*h+t[4]*v+t[8]*b+t[12],e[13]=t[1]*h+t[5]*v+t[9]*b+t[13],e[14]=t[2]*h+t[6]*v+t[10]*b+t[14],e[15]=t[3]*h+t[7]*v+t[11]*b+t[15]):(r=t[0],a=t[1],i=t[2],o=t[3],f=t[4],u=t[5],s=t[6],c=t[7],l=t[8],m=t[9],d=t[10],p=t[11],e[0]=r,e[1]=a,e[2]=i,e[3]=o,e[4]=f,e[5]=u,e[6]=s,e[7]=c,e[8]=l,e[9]=m,e[10]=d,e[11]=p,e[12]=r*h+f*v+l*b+t[12],e[13]=a*h+u*v+m*b+t[13],e[14]=i*h+s*v+d*b+t[14],e[15]=o*h+c*v+p*b+t[15]),e}t.exports=r},{}],28:[function(e,t,n){function r(e,t){if(e===t){var n=t[1],r=t[2],a=t[3],i=t[6],o=t[7],f=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=a,e[13]=o,e[14]=f}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}t.exports=r},{}],29:[function(e,t,n){t.exports=function(e){"string"==typeof e&&(e=[e]);for(var t=[].slice.call(arguments,1),n=[],r=0;r<e.length-1;r++)n.push(e[r],t[r]||"");return n.push(e[r]),n.join("")}},{}],30:[function(e,t,n){function r(e,t,n,r,a){e=e||1,t=t||1,n=n||1,r=r||1;for(var i=!(!a||!a.quads)&&a.quads,o=[],f=[],u=[],s=[],c=0;c<=r;c++)for(var l=0;l<=n;l++){var m=l/n,d=c/r,p=-e/2+m*e,h=t/2-d*t;o.push([p,h,0]),f.push([m,d]),u.push([0,0,1]),c<r&&l<n&&(i?s.push([c*(n+1)+l,(c+1)*(n+1)+l,(c+1)*(n+1)+l+1,c*(n+1)+l+1]):(s.push([c*(n+1)+l,(c+1)*(n+1)+l+1,c*(n+1)+l+1]),s.push([(c+1)*(n+1)+l+1,c*(n+1)+l,(c+1)*(n+1)+l])))}return{positions:o,normals:u,uvs:f,cells:s}}t.exports=r},{}],31:[function(e,t,n){!function(e,r){"object"==typeof n&&"undefined"!=typeof t?t.exports=r():"function"==typeof define&&define.amd?define(r):e.createREGL=r()}(this,function(){"use strict";function e(e){return"undefined"!=typeof btoa?btoa(e):"base64:"+e}function t(e){var t=new Error("(regl) "+e);throw console.error(t),t}function n(e,n){e||t(n)}function r(e){return e?": "+e:""}function a(e,n,a){e in n||t("unknown parameter ("+e+")"+r(a)+". possible values: "+Object.keys(n).join())}function i(e,n){Je(e)||t("invalid parameter type"+r(n)+". must be a typed array")}function o(e,n,a){typeof e!==n&&t("invalid parameter type"+r(a)+". expected "+n+", got "+typeof e)}function f(e,n){e>=0&&(0|e)===e||t("invalid parameter type, ("+e+")"+r(n)+". must be a nonnegative integer")}function u(e,n,a){n.indexOf(e)<0&&t("invalid value"+r(a)+". must be one of: "+n)}function s(e){Object.keys(e).forEach(function(e){et.indexOf(e)<0&&t('invalid regl constructor argument "'+e+'". must be one of '+et)})}function c(e,t){for(e+="";e.length<t;)e=" "+e;return e}function l(){this.name="unknown",this.lines=[],this.index={},this.hasErrors=!1}function m(e,t){this.number=e,this.line=t,this.errors=[]}function d(e,t,n){this.file=e,this.line=t,this.message=n}function p(){var e=new Error,t=(e.stack||e).toString(),n=/compileProcedure.*\n\s*at.*\((.*)\)/.exec(t);if(n)return n[1];var r=/compileProcedure.*\n\s*at\s+(.*)(\n|$)/.exec(t);return r?r[1]:"unknown"}function h(){var e=new Error,t=(e.stack||e).toString(),n=/at REGLCommand.*\n\s+at.*\((.*)\)/.exec(t);if(n)return n[1];var r=/at REGLCommand.*\n\s+at\s+(.*)\n/.exec(t);return r?r[1]:"unknown"}function v(t,n){var r=t.split("\n"),a=1,i=0,o={unknown:new l,0:new l};o.unknown.name=o[0].name=n||p(),o.unknown.lines.push(new m(0,""));for(var f=0;f<r.length;++f){var u=r[f],s=/^\s*\#\s*(\w+)\s+(.+)\s*$/.exec(u);if(s)switch(s[1]){case"line":var c=/(\d+)(\s+\d+)?/.exec(s[2]);c&&(a=0|c[1],c[2]&&(i=0|c[2],i in o||(o[i]=new l)));break;case"define":var d=/SHADER_NAME(_B64)?\s+(.*)$/.exec(s[2]);d&&(o[i].name=d[1]?e(d[2]):d[2])}o[i].lines.push(new m(a++,u))}return Object.keys(o).forEach(function(e){var t=o[e];t.lines.forEach(function(e){t.index[e.number]=e})}),o}function b(e){var t=[];return e.split("\n").forEach(function(e){if(!(e.length<5)){var n=/^ERROR\:\s+(\d+)\:(\d+)\:\s*(.*)$/.exec(e);n?t.push(new d(0|n[1],0|n[2],n[3].trim())):e.length>0&&t.push(new d("unknown",0,e))}}),t}function g(e,t){t.forEach(function(t){var n=e[t.file];if(n){var r=n.index[t.line];if(r)return r.errors.push(t),void(n.hasErrors=!0)}e.unknown.hasErrors=!0,e.unknown.lines[0].errors.push(t)})}function y(e,t,r,a,i){if(!e.getShaderParameter(t,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(t),f=a===e.FRAGMENT_SHADER?"fragment":"vertex";E(r,"string",f+" shader source must be a string",i);var u=v(r,i),s=b(o);g(u,s),Object.keys(u).forEach(function(e){function t(e,t){r.push(e),a.push(t||"")}var n=u[e];if(n.hasErrors){var r=[""],a=[""];t("file number "+e+": "+n.name+"\n","color:red;text-decoration:underline;font-weight:bold"),n.lines.forEach(function(e){if(e.errors.length>0){t(c(e.number,4)+"| ","background-color:yellow; font-weight:bold"),t(e.line+"\n","color:red; background-color:yellow; font-weight:bold");var n=0;e.errors.forEach(function(r){var a=r.message,i=/^\s*\'(.*)\'\s*\:\s*(.*)$/.exec(a);if(i){var o=i[1];switch(a=i[2],o){case"assign":o="="}n=Math.max(e.line.indexOf(o,n),0)}else n=0;t(c("| ",6)),t(c("^^^",n+3)+"\n","font-weight:bold"),t(c("| ",6)),t(a+"\n","font-weight:bold")}),t(c("| ",6)+"\n")}else t(c(e.number,4)+"| "),t(e.line+"\n","color:red")}),"undefined"!=typeof document?(a[0]=r.join("%c"),console.log.apply(console,a)):console.log(r.join(""))}}),n.raise("Error compiling "+f+" shader, "+u[0].name)}}function x(e,t,r,a,i){if(!e.getProgramParameter(t,e.LINK_STATUS)){var o=e.getProgramInfoLog(t),f=v(r,i),u=v(a,i),s='Error linking program with vertex shader, "'+u[0].name+'", and fragment shader "'+f[0].name+'"';"undefined"!=typeof document?console.log("%c"+s+"\n%c"+o,"color:red;text-decoration:underline;font-weight:bold","color:red"):console.log(s+"\n"+o),n.raise(s)}}function w(e){e._commandRef=p()}function k(e,t,n,r){function a(e){return e?r.id(e):0}function i(e,t){Object.keys(t).forEach(function(t){e[r.id(t)]=!0})}w(e),e._fragId=a(e.static.frag),e._vertId=a(e.static.vert);var o=e._uniformSet={};i(o,t.static),i(o,t.dynamic);var f=e._attributeSet={};i(f,n.static),i(f,n.dynamic),e._hasCount="count"in e.static||"count"in e.dynamic||"elements"in e.static||"elements"in e.dynamic}function S(e,n){var r=h();t(e+" in command "+(n||p())+("unknown"===r?"":" called from "+r))}function _(e,t,n){e||S(t,n||p())}function A(e,t,n,a){e in t||S("unknown parameter ("+e+")"+r(n)+". possible values: "+Object.keys(t).join(),a||p())}function E(e,t,n,a){typeof e!==t&&S("invalid parameter type"+r(n)+". expected "+t+", got "+typeof e,a||p())}function D(e){e()}function T(e,t,n){e.texture?u(e.texture._texture.internalformat,t,"unsupported texture format for attachment"):u(e.renderbuffer._renderbuffer.format,n,"unsupported renderbuffer format for attachment")}function j(e,t){return e===ht||e===pt||e===vt?2:e===bt?4:yt[e]*t}function C(e){return!(e&e-1||!e)}function O(e,t,r){var a,i=t.width,o=t.height,f=t.channels;n(i>0&&i<=r.maxTextureSize&&o>0&&o<=r.maxTextureSize,"invalid texture shape"),e.wrapS===tt&&e.wrapT===tt||n(C(i)&&C(o),"incompatible wrap mode for texture, both width and height must be power of 2"),1===t.mipmask?1!==i&&1!==o&&n(e.minFilter!==rt&&e.minFilter!==it&&e.minFilter!==at&&e.minFilter!==ot,"min filter requires mipmap"):(n(C(i)&&C(o),"texture must be a square power of 2 to support mipmapping"),n(t.mipmask===(i<<1)-1,"missing or incomplete mipmap data")),t.type===dt&&(r.extensions.indexOf("oes_texture_float_linear")<0&&n(e.minFilter===nt&&e.magFilter===nt,"filter not supported, must enable oes_texture_float_linear"),n(!e.genMipmaps,"mipmap generation not supported with float textures"));var u=t.images;for(a=0;a<16;++a)if(u[a]){var s=i>>a,c=o>>a;n(t.mipmask&1<<a,"missing mipmap data");var l=u[a];if(n(l.width===s&&l.height===c,"invalid shape for mip images"),n(l.format===t.format&&l.internalformat===t.internalformat&&l.type===t.type,"incompatible type for mip image"),l.compressed);else if(l.data){var m=Math.ceil(j(l.type,f)*s/l.unpackAlignment)*l.unpackAlignment;n(l.data.byteLength===m*c,"invalid data for image, buffer size is inconsistent with image format")}else l.element||l.copy}else e.genMipmaps||n(0===(t.mipmask&1<<a),"extra mipmap data");t.compressed&&n(!e.genMipmaps,"mipmap generation for compressed images not supported")}function z(e,t,r,a){var i=e.width,o=e.height,f=e.channels;n(i>0&&i<=a.maxTextureSize&&o>0&&o<=a.maxTextureSize,"invalid texture shape"),n(i===o,"cube map must be square"),n(t.wrapS===tt&&t.wrapT===tt,"wrap mode not supported by cube map");for(var u=0;u<r.length;++u){var s=r[u];n(s.width===i&&s.height===o,"inconsistent cube map face shape"),t.genMipmaps&&(n(!s.compressed,"can not generate mipmap for compressed textures"),n(1===s.mipmask,"can not specify mipmaps and generate mipmaps"));for(var c=s.images,l=0;l<16;++l){var m=c[l];if(m){var d=i>>l,p=o>>l;n(s.mipmask&1<<l,"missing mipmap data"),n(m.width===d&&m.height===p,"invalid shape for mip images"),n(m.format===e.format&&m.internalformat===e.internalformat&&m.type===e.type,"incompatible type for mip image"),m.compressed||(m.data?n(m.data.byteLength===d*p*Math.max(j(m.type,f),m.unpackAlignment),"invalid data for image, buffer size is inconsistent with image format"):m.element||m.copy)}}}}function F(e,t){this.id=wt++,this.type=e,this.data=t}function M(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function P(e){if(0===e.length)return[];var t=e.charAt(0),n=e.charAt(e.length-1);if(e.length>1&&t===n&&('"'===t||"'"===t))return['"'+M(e.substr(1,e.length-2))+'"'];var r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(e);if(r)return P(e.substr(0,r.index)).concat(P(r[1])).concat(P(e.substr(r.index+r[0].length)));var a=e.split(".");if(1===a.length)return['"'+M(e)+'"'];for(var i=[],o=0;o<a.length;++o)i=i.concat(P(a[o]));return i}function I(e){return"["+P(e).join("][")+"]"}function L(e,t){return new F(e,I(t+""))}function B(e){return"function"==typeof e&&!e._reglType||e instanceof F}function R(e,t){return"function"==typeof e?new F(kt,e):e}function N(){var e={"":0},t=[""];return{id:function(n){var r=e[n];return r?r:(r=e[n]=t.length,t.push(n),r)},str:function(e){return t[e]}}}function U(e,t,n){function r(){var t=window.innerWidth,r=window.innerHeight;if(e!==document.body){var a=e.getBoundingClientRect();t=a.right-a.left,r=a.bottom-a.top}i.width=n*t,i.height=n*r,Ze(i.style,{width:t+"px",height:r+"px"})}function a(){window.removeEventListener("resize",r),e.removeChild(i)}var i=document.createElement("canvas");return Ze(i.style,{border:0,margin:0,padding:0,top:0,left:0}),e.appendChild(i),e===document.body&&(i.style.position="absolute",Ze(e.style,{margin:0,padding:0})),window.addEventListener("resize",r,!1),r(),{canvas:i,onDestroy:a}}function q(e,t){function n(n){try{return e.getContext(n,t)}catch(e){return null}}return n("webgl")||n("experimental-webgl")||n("webgl-experimental")}function W(e){return"string"==typeof e.nodeName&&"function"==typeof e.appendChild&&"function"==typeof e.getBoundingClientRect}function G(e){return"function"==typeof e.drawArrays||"function"==typeof e.drawElements}function H(e){return"string"==typeof e?e.split():(xt(Array.isArray(e),"invalid extension array"),e)}function Q(e){return"string"==typeof e?(xt("undefined"!=typeof document,"not supported outside of DOM"),document.querySelector(e)):e}function V(e){var t,n,r,a,i=e||{},o={},f=[],u=[],s="undefined"==typeof window?1:window.devicePixelRatio,c=!1,l=function(e){e&&xt.raise(e)},m=function(){};if("string"==typeof i?(xt("undefined"!=typeof document,"selector queries only supported in DOM enviroments"),t=document.querySelector(i),xt(t,"invalid query string for element")):"object"==typeof i?W(i)?t=i:G(i)?(a=i,r=a.canvas):(xt.constructor(i),"gl"in i?a=i.gl:"canvas"in i?r=Q(i.canvas):"container"in i&&(n=Q(i.container)),"attributes"in i&&(o=i.attributes,xt.type(o,"object","invalid context attributes")),"extensions"in i&&(f=H(i.extensions)),"optionalExtensions"in i&&(u=H(i.optionalExtensions)),"onDone"in i&&(xt.type(i.onDone,"function","invalid or missing onDone callback"),l=i.onDone),"profile"in i&&(c=!!i.profile),"pixelRatio"in i&&(s=+i.pixelRatio,xt(s>0,"invalid pixel ratio"))):xt.raise("invalid arguments to regl"),t&&("canvas"===t.nodeName.toLowerCase()?r=t:n=t),!a){if(!r){xt("undefined"!=typeof document,"must manually specify webgl context outside of DOM environments");var d=U(n||document.body,l,s);if(!d)return null;r=d.canvas,m=d.onDestroy}a=q(r,o)}return a?{gl:a,canvas:r,container:n,extensions:f,optionalExtensions:u,pixelRatio:s,profile:c,onDone:l,onDestroy:m}:(m(),l("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Y(e,t){function n(t){xt.type(t,"string","extension name must be string");var n,a=t.toLowerCase();try{n=r[a]=e.getExtension(a)}catch(e){}return!!n}for(var r={},a=0;a<t.extensions.length;++a){var i=t.extensions[a];if(!n(i))return t.onDestroy(),t.onDone('"'+i+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return t.optionalExtensions.forEach(n),{extensions:r,restore:function(){Object.keys(r).forEach(function(e){if(!n(e))throw new Error("(regl): error restoring extension "+e)})}}}function X(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)||Je(e.data));
}function $(e,t){for(var n=Array(e),r=0;r<e;++r)n[r]=t(r);return n}function K(e){for(var t=16;t<=1<<28;t*=16)if(e<=t)return t;return 0}function J(e){var t,n;return t=(e>65535)<<4,e>>>=t,n=(e>255)<<3,e>>>=n,t|=n,n=(e>15)<<2,e>>>=n,t|=n,n=(e>3)<<1,e>>>=n,t|=n,t|e>>1}function Z(e){var t=K(e),n=sn[J(t)>>2];return n.length>0?n.pop():new ArrayBuffer(t)}function ee(e){sn[J(e.byteLength)>>2].push(e)}function te(e,t){var n=null;switch(e){case tn:n=new Int8Array(Z(t),0,t);break;case nn:n=new Uint8Array(Z(t),0,t);break;case rn:n=new Int16Array(Z(2*t),0,t);break;case an:n=new Uint16Array(Z(2*t),0,t);break;case on:n=new Int32Array(Z(4*t),0,t);break;case fn:n=new Uint32Array(Z(4*t),0,t);break;case un:n=new Float32Array(Z(4*t),0,t);break;default:return null}return n.length!==t?n.subarray(0,t):n}function ne(e){ee(e.buffer)}function re(e,t,n){for(var r=0;r<t;++r)n[r]=e[r]}function ae(e,t,n,r){for(var a=0,i=0;i<t;++i)for(var o=e[i],f=0;f<n;++f)r[a++]=o[f]}function ie(e,t,n,r,a,i){for(var o=i,f=0;f<t;++f)for(var u=e[f],s=0;s<n;++s)for(var c=u[s],l=0;l<r;++l)a[o++]=c[l]}function oe(e,t,n,r,a){for(var i=1,o=n+1;o<t.length;++o)i*=t[o];var f=t[n];if(t.length-n===4){var u=t[n+1],s=t[n+2],c=t[n+3];for(o=0;o<f;++o)ie(e[o],u,s,c,r,a),a+=i}else for(o=0;o<f;++o)oe(e[o],t,n+1,r,a),a+=i}function fe(e,t,n,r){var a=1;if(t.length)for(var i=0;i<t.length;++i)a*=t[i];else a=0;var o=r||cn.allocType(n,a);switch(t.length){case 0:break;case 1:re(e,t[0],o);break;case 2:ae(e,t[0],t[1],o);break;case 3:ie(e,t[0],t[1],t[2],o,0);break;default:oe(e,t,0,o,0)}return o}function ue(e){for(var t=[],n=e;n.length;n=n[0])t.push(n.length);return t}function se(e){return 0|Ke[Object.prototype.toString.call(e)]}function ce(e,t){for(var n=0;n<t.length;++n)e[n]=t[n]}function le(e,t,n,r,a,i,o){for(var f=0,u=0;u<n;++u)for(var s=0;s<r;++s)e[f++]=t[a*u+i*s+o]}function me(e,t,n){function r(t){this.id=l++,this.buffer=e.createBuffer(),this.type=t,this.usage=En,this.byteLength=0,this.dimension=1,this.dtype=Tn,this.persistentData=null,n.profile&&(this.stats={size:0})}function a(e,t){var n=d.pop();return n||(n=new r(e)),n.bind(),f(n,t,Dn,0,1,!1),n}function i(e){d.push(e)}function o(t,n,r){t.byteLength=n.byteLength,e.bufferData(t.type,n,r)}function f(e,t,n,r,a,i){var f;if(e.usage=n,Array.isArray(t)){if(e.dtype=r||jn,t.length>0){var u;if(Array.isArray(t[0])){f=An(t);for(var s=1,c=1;c<f.length;++c)s*=f[c];e.dimension=s,u=_n(t,f,e.dtype),o(e,u,n),i?e.persistentData=u:cn.freeType(u)}else if("number"==typeof t[0]){e.dimension=a;var l=cn.allocType(e.dtype,t.length);ce(l,t),o(e,l,n),i?e.persistentData=l:cn.freeType(l)}else Je(t[0])?(e.dimension=t[0].length,e.dtype=r||se(t[0])||jn,u=_n(t,[t.length,t[0].length],e.dtype),o(e,u,n),i?e.persistentData=u:cn.freeType(u)):xt.raise("invalid buffer data")}}else if(Je(t))e.dtype=r||se(t),e.dimension=a,o(e,t,n),i&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(X(t)){f=t.shape;var m=t.stride,d=t.offset,p=0,h=0,v=0,b=0;1===f.length?(p=f[0],h=1,v=m[0],b=0):2===f.length?(p=f[0],h=f[1],v=m[0],b=m[1]):xt.raise("invalid shape"),e.dtype=r||se(t.data)||jn,e.dimension=h;var g=cn.allocType(e.dtype,p*h);le(g,t.data,p,h,v,b,d),o(e,g,n),i?e.persistentData=g:cn.freeType(g)}else xt.raise("invalid buffer data")}function u(n){t.bufferCount--;var r=n.buffer;xt(r,"buffer must not be deleted already"),e.deleteBuffer(r),n.buffer=null,delete m[n.id]}function s(a,i,o,s){function c(t){var r=En,a=null,i=0,o=0,u=1;return Array.isArray(t)||Je(t)||X(t)?a=t:"number"==typeof t?i=0|t:t&&(xt.type(t,"object","buffer arguments must be an object, a number or an array"),"data"in t&&(xt(null===a||Array.isArray(a)||Je(a)||X(a),"invalid data for buffer"),a=t.data),"usage"in t&&(xt.parameter(t.usage,Sn,"invalid buffer usage"),r=Sn[t.usage]),"type"in t&&(xt.parameter(t.type,xn,"invalid buffer type"),o=xn[t.type]),"dimension"in t&&(xt.type(t.dimension,"number","invalid dimension"),u=0|t.dimension),"length"in t&&(xt.nni(i,"buffer length must be a nonnegative integer"),i=0|t.length)),p.bind(),a?f(p,a,r,o,u,s):(e.bufferData(p.type,i,r),p.dtype=o||Tn,p.usage=r,p.dimension=u,p.byteLength=i),n.profile&&(p.stats.size=p.byteLength*Cn[p.dtype]),c}function l(t,n){xt(n+t.byteLength<=p.byteLength,"invalid buffer subdata call, buffer is too small. Can't write data of size "+t.byteLength+" starting from offset "+n+" to a buffer of size "+p.byteLength),e.bufferSubData(p.type,n,t)}function d(e,t){var n,r=0|(t||0);if(p.bind(),Array.isArray(e)){if(e.length>0)if("number"==typeof e[0]){var a=cn.allocType(p.dtype,e.length);ce(a,e),l(a,r),cn.freeType(a)}else if(Array.isArray(e[0])||Je(e[0])){n=An(e);var i=_n(e,n,p.dtype);l(i,r),cn.freeType(i)}else xt.raise("invalid buffer data")}else if(Je(e))l(e,r);else if(X(e)){n=e.shape;var o=e.stride,f=0,u=0,s=0,m=0;1===n.length?(f=n[0],u=1,s=o[0],m=0):2===n.length?(f=n[0],u=n[1],s=o[0],m=o[1]):xt.raise("invalid shape");var d=Array.isArray(e.data)?p.dtype:se(e.data),h=cn.allocType(d,f*u);le(h,e.data,f,u,s,m,e.offset),l(h,r),cn.freeType(h)}else xt.raise("invalid data for buffer subdata");return c}t.bufferCount++;var p=new r(i);return m[p.id]=p,o||c(a),c._reglType="buffer",c._buffer=p,c.subdata=d,n.profile&&(c.stats=p.stats),c.destroy=function(){u(p)},c}function c(){en(m).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})}var l=0,m={};r.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},r.prototype.destroy=function(){u(this)};var d=[];return n.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(m).forEach(function(t){e+=m[t].stats.size}),e}),{create:s,createStream:a,destroyStream:i,clear:function(){en(m).forEach(u),d.forEach(u)},getBuffer:function(e){return e&&e._buffer instanceof r?e._buffer:null},restore:c,_initBuffer:f}}function de(e,t,n,r){function a(e){this.id=l++,c[this.id]=this,this.buffer=e,this.primType=Nn,this.vertCount=0,this.type=0}function i(e){var t=d.pop();return t||(t=new a(n.create(null,Vn,!0,!1)._buffer)),f(t,e,Yn,-1,-1,0,0),t}function o(e){d.push(e)}function f(r,a,i,o,f,u,s){if(r.buffer.bind(),a){var c=s;s||Je(a)&&(!X(a)||Je(a.data))||(c=t.oes_element_index_uint?Qn:Gn),n._initBuffer(r.buffer,a,i,c,3)}else e.bufferData(Vn,u,i),r.buffer.dtype=l||qn,r.buffer.usage=i,r.buffer.dimension=3,r.buffer.byteLength=u;var l=s;if(!s){switch(r.buffer.dtype){case qn:case Un:l=qn;break;case Gn:case Wn:l=Gn;break;case Qn:case Hn:l=Qn;break;default:xt.raise("unsupported type for element array")}r.buffer.dtype=l}r.type=l,xt(l!==Qn||!!t.oes_element_index_uint,"32 bit element buffers not supported, enable oes_element_index_uint first");var m=f;m<0&&(m=r.buffer.byteLength,l===Gn?m>>=1:l===Qn&&(m>>=2)),r.vertCount=m;var d=o;if(o<0){d=Nn;var p=r.buffer.dimension;1===p&&(d=Bn),2===p&&(d=Rn),3===p&&(d=Nn)}r.primType=d}function u(e){r.elementsCount--,xt(null!==e.buffer,"must not double destroy elements"),delete c[e.id],e.buffer.destroy(),e.buffer=null}function s(e,t){function i(e){if(e)if("number"==typeof e)o(e),s.primType=Nn,s.vertCount=0|e,s.type=qn;else{var t=null,n=Xn,r=-1,a=-1,u=0,c=0;Array.isArray(e)||Je(e)||X(e)?t=e:(xt.type(e,"object","invalid arguments for elements"),"data"in e&&(t=e.data,xt(Array.isArray(t)||Je(t)||X(t),"invalid data for element buffer")),"usage"in e&&(xt.parameter(e.usage,Sn,"invalid element buffer usage"),n=Sn[e.usage]),"primitive"in e&&(xt.parameter(e.primitive,Ln,"invalid element buffer primitive"),r=Ln[e.primitive]),"count"in e&&(xt("number"==typeof e.count&&e.count>=0,"invalid vertex count for elements"),a=0|e.count),"type"in e&&(xt.parameter(e.type,m,"invalid buffer type"),c=m[e.type]),"length"in e?u=0|e.length:(u=a,c===Gn||c===Wn?u*=2:c!==Qn&&c!==Hn||(u*=4))),f(s,t,n,r,a,u,c)}else o(),s.primType=Nn,s.vertCount=0,s.type=qn;return i}var o=n.create(null,Vn,!0),s=new a(o._buffer);return r.elementsCount++,i(e),i._reglType="elements",i._elements=s,i.subdata=function(e,t){return o.subdata(e,t),i},i.destroy=function(){u(s)},i}var c={},l=0,m={uint8:qn,uint16:Gn};t.oes_element_index_uint&&(m.uint32=Qn),a.prototype.bind=function(){this.buffer.bind()};var d=[];return{create:s,createStream:i,destroyStream:o,getElements:function(e){return"function"==typeof e&&e._elements instanceof a?e._elements:null},clear:function(){en(c).forEach(u)}}}function pe(e){for(var t=cn.allocType(Jn,e.length),n=0;n<e.length;++n)if(isNaN(e[n]))t[n]=65535;else if(e[n]===1/0)t[n]=31744;else if(e[n]===-(1/0))t[n]=64512;else{$n[0]=e[n];var r=Kn[0],a=r>>>31<<15,i=(r<<1>>>24)-127,o=r>>13&1023;if(i<-24)t[n]=a;else if(i<-14){var f=-14-i;t[n]=a+(o+1024>>f)}else i>15?t[n]=a+31744:t[n]=a+(i+15<<10)+o}return t}function he(e){return Array.isArray(e)||Je(e)}function ve(e){return"[object "+e+"]"}function be(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function ge(e){if(!Array.isArray(e))return!1;var t=e.length;return!(0===t||!he(e[0]))}function ye(e){return Object.prototype.toString.call(e)}function xe(e){return ye(e)===sa}function we(e){return ye(e)===ca}function ke(e){return ye(e)===la}function Se(e){return ye(e)===ma}function _e(e){if(!e)return!1;var t=ye(e);return da.indexOf(t)>=0||(be(e)||ge(e)||X(e))}function Ae(e){return 0|Ke[Object.prototype.toString.call(e)]}function Ee(e,t){var n=t.length;switch(e.type){case zr:case Fr:case Mr:case Pr:var r=cn.allocType(e.type,n);r.set(t),e.data=r;break;case yr:e.data=pe(t);break;default:xt.raise("unsupported texture type, must specify a typed array")}}function De(e,t){return cn.allocType(e.type===yr?Pr:e.type,t)}function Te(e,t){e.type===yr?(e.data=pe(t),cn.freeType(t)):e.data=t}function je(e,t,n,r,a,i){for(var o=e.width,f=e.height,u=e.channels,s=o*f*u,c=De(e,s),l=0,m=0;m<f;++m)for(var d=0;d<o;++d)for(var p=0;p<u;++p)c[l++]=t[n*d+r*m+a*p+i];Te(e,c)}function Ce(e,t,n,r,a,i){var o;if(o="undefined"!=typeof ha[e]?ha[e]:ua[e]*pa[t],i&&(o*=6),a){for(var f=0,u=n;u>=1;)f+=o*u*u,u/=2;return f}return o*n*r}function Oe(e,t,n,r,a,i,o){function f(){this.internalformat=rr,this.format=rr,this.type=zr,this.compressed=!1,this.premultiplyAlpha=!1,this.flipY=!1,this.unpackAlignment=1,this.colorSpace=0,this.width=0,this.height=0,this.channels=0}function u(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 s(e,r){if("object"==typeof r&&r){if("premultiplyAlpha"in r&&(xt.type(r.premultiplyAlpha,"boolean","invalid premultiplyAlpha"),e.premultiplyAlpha=r.premultiplyAlpha),"flipY"in r&&(xt.type(r.flipY,"boolean","invalid texture flip"),e.flipY=r.flipY),"alignment"in r&&(xt.oneOf(r.alignment,[1,2,4,8],"invalid texture unpack alignment"),e.unpackAlignment=r.alignment),"colorSpace"in r&&(xt.parameter(r.colorSpace,B,"invalid colorSpace"),e.colorSpace=B[r.colorSpace]),"type"in r){var a=r.type;xt(t.oes_texture_float||!("float"===a||"float32"===a),"you must enable the OES_texture_float extension in order to use floating point textures."),xt(t.oes_texture_half_float||!("half float"===a||"float16"===a),"you must enable the OES_texture_half_float extension in order to use 16-bit floating point textures."),xt(t.webgl_depth_texture||!("uint16"===a||"uint32"===a||"depth stencil"===a),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),xt.parameter(a,R,"invalid texture type"),e.type=R[a]}var i=e.width,o=e.height,f=e.channels,u=!1;"shape"in r?(xt(Array.isArray(r.shape)&&r.shape.length>=2,"shape must be an array"),i=r.shape[0],o=r.shape[1],3===r.shape.length&&(f=r.shape[2],xt(f>0&&f<=4,"invalid number of channels"),u=!0),xt(i>=0&&i<=n.maxTextureSize,"invalid width"),xt(o>=0&&o<=n.maxTextureSize,"invalid height")):("radius"in r&&(i=o=r.radius,xt(i>=0&&i<=n.maxTextureSize,"invalid radius")),"width"in r&&(i=r.width,xt(i>=0&&i<=n.maxTextureSize,"invalid width")),"height"in r&&(o=r.height,xt(o>=0&&o<=n.maxTextureSize,"invalid height")),"channels"in r&&(f=r.channels,xt(f>0&&f<=4,"invalid number of channels"),u=!0)),e.width=0|i,e.height=0|o,e.channels=0|f;var s=!1;if("format"in r){var c=r.format;xt(t.webgl_depth_texture||!("depth"===c||"depth stencil"===c),"you must enable the WEBGL_depth_texture extension in order to use depth/stencil textures."),xt.parameter(c,N,"invalid texture format");var l=e.internalformat=N[c];e.format=$[l],c in R&&("type"in r||(e.type=R[c])),c in U&&(e.compressed=!0),s=!0}!u&&s?e.channels=ua[e.format]:u&&!s?e.channels!==fa[e.format]&&(e.format=e.internalformat=fa[e.channels]):s&&u&&xt(e.channels===ua[e.format],"number of channels inconsistent with specified format")}}function c(t){e.pixelStorei(ta,t.flipY),e.pixelStorei(na,t.premultiplyAlpha),e.pixelStorei(ra,t.colorSpace),e.pixelStorei(ea,t.unpackAlignment)}function l(){f.call(this),this.xOffset=0,this.yOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function m(e,t){var r=null;if(_e(t)?r=t:t&&(xt.type(t,"object","invalid pixel data type"),s(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),_e(t.data)&&(r=t.data)),xt(!e.compressed||r instanceof Uint8Array,"compressed texture data must be stored in a uint8array"),t.copy){xt(!r,"can not specify copy and data field for the same texture");var i=a.viewportWidth,o=a.viewportHeight;e.width=e.width||i-e.xOffset,e.height=e.height||o-e.yOffset,e.needsCopy=!0,xt(e.xOffset>=0&&e.xOffset<i&&e.yOffset>=0&&e.yOffset<o&&e.width>0&&e.width<=i&&e.height>0&&e.height<=o,"copy texture read out of bounds")}else if(r){if(Je(r))e.channels=e.channels||4,e.data=r,"type"in t||e.type!==zr||(e.type=Ae(r));else if(be(r))e.channels=e.channels||4,Ee(e,r),e.alignment=1,e.needsFree=!0;else if(X(r)){var f=r.data;Array.isArray(f)||e.type!==zr||(e.type=Ae(f));var u,c,l,m,d,p,h=r.shape,v=r.stride;3===h.length?(l=h[2],p=v[2]):(xt(2===h.length,"invalid ndarray pixel data, must be 2 or 3D"),l=1,p=1),u=h[0],c=h[1],m=v[0],d=v[1],e.alignment=1,e.width=u,e.height=c,e.channels=l,e.format=e.internalformat=fa[l],e.needsFree=!0,je(e,f,m,d,p,r.offset)}else if(xe(r)||we(r))xe(r)?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(ke(r))e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(Se(r))e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(ge(r)){var b=e.width||r[0].length,g=e.height||r.length,y=e.channels;y=he(r[0][0])?y||r[0][0].length:y||1;for(var x=ln.shape(r),w=1,k=0;k<x.length;++k)w*=x[k];var S=De(e,w);ln.flatten(r,x,"",S),Te(e,S),e.alignment=1,e.width=b,e.height=g,e.channels=y,e.format=e.internalformat=fa[y],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4;e.type===Pr?xt(n.extensions.indexOf("oes_texture_float")>=0,"oes_texture_float extension not enabled"):e.type===yr&&xt(n.extensions.indexOf("oes_texture_half_float")>=0,"oes_texture_half_float extension not enabled")}function d(t,n,a){var i=t.element,o=t.data,f=t.internalformat,u=t.format,s=t.type,l=t.width,m=t.height;c(t),i?e.texImage2D(n,a,u,u,s,i):t.compressed?e.compressedTexImage2D(n,a,f,l,m,0,o):t.needsCopy?(r(),e.copyTexImage2D(n,a,u,t.xOffset,t.yOffset,l,m,0)):e.texImage2D(n,a,u,l,m,0,u,s,o)}function p(t,n,a,i,o){var f=t.element,u=t.data,s=t.internalformat,l=t.format,m=t.type,d=t.width,p=t.height;c(t),f?e.texSubImage2D(n,o,a,i,l,m,f):t.compressed?e.compressedTexSubImage2D(n,o,a,i,s,d,p,u):t.needsCopy?(r(),e.copyTexSubImage2D(n,o,a,i,t.xOffset,t.yOffset,d,p)):e.texSubImage2D(n,o,a,i,d,p,l,m,u)}function h(){return K.pop()||new l}function v(e){e.needsFree&&cn.freeType(e.data),l.call(e),K.push(e)}function b(){f.call(this),this.genMipmaps=!1,this.mipmapHint=$r,this.mipmask=0,this.images=Array(16)}function g(e,t,n){var r=e.images[0]=h();e.mipmask=1,r.width=e.width=t,r.height=e.height=n,r.channels=e.channels=4}function y(e,t){var n=null;if(_e(t))n=e.images[0]=h(),u(n,e),m(n,t),e.mipmask=1;else if(s(e,t),Array.isArray(t.mipmap))for(var r=t.mipmap,a=0;a<r.length;++a)n=e.images[a]=h(),u(n,e),n.width>>=a,n.height>>=a,m(n,r[a]),e.mipmask|=1<<a;else n=e.images[0]=h(),u(n,e),m(n,t),e.mipmask=1;u(e,e.images[0]),(e.compressed&&e.internalformat===xr||e.internalformat===wr||e.internalformat===kr||e.internalformat===Sr)&&xt(e.width%4===0&&e.height%4===0,"for compressed texture formats, mipmap level 0 must have width and height that are a multiple of 4")}function x(e,t){for(var n=e.images,r=0;r<n.length;++r){if(!n[r])return;d(n[r],t,r)}}function w(){var e=J.pop()||new b;f.call(e),e.mipmask=0;for(var t=0;t<16;++t)e.images[t]=null;return e}function k(e){for(var t=e.images,n=0;n<t.length;++n)t[n]&&v(t[n]),t[n]=null;J.push(e)}function S(){this.minFilter=Wr,this.magFilter=Wr,this.wrapS=Rr,this.wrapT=Rr,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=$r}function _(e,t){if("min"in t){var r=t.min;xt.parameter(r,L),e.minFilter=L[r],oa.indexOf(e.minFilter)>=0&&(e.genMipmaps=!0)}if("mag"in t){var a=t.mag;xt.parameter(a,I),e.magFilter=I[a]}var i=e.wrapS,o=e.wrapT;if("wrap"in t){var f=t.wrap;"string"==typeof f?(xt.parameter(f,P),i=o=P[f]):Array.isArray(f)&&(xt.parameter(f[0],P),xt.parameter(f[1],P),i=P[f[0]],o=P[f[1]])}else{if("wrapS"in t){var u=t.wrapS;xt.parameter(u,P),i=P[u]}if("wrapT"in t){var s=t.wrapT;xt.parameter(s,P),o=P[s]}}if(e.wrapS=i,e.wrapT=o,"anisotropic"in t){var c=t.anisotropic;xt("number"==typeof c&&c>=1&&c<=n.maxAnisotropic,"aniso samples must be between 1 and "),e.anisotropic=t.anisotropic}if("mipmap"in t){var l=!1;switch(typeof t.mipmap){case"string":xt.parameter(t.mipmap,M,"invalid mipmap hint"),e.mipmapHint=M[t.mipmap],e.genMipmaps=!0,l=!0;break;case"boolean":l=e.genMipmaps=t.mipmap;break;case"object":xt(Array.isArray(t.mipmap),"invalid mipmap type"),e.genMipmaps=!1,l=!0;break;default:xt.raise("invalid mipmap type")}!l||"min"in t||(e.minFilter=Hr)}}function A(n,r){e.texParameteri(r,qr,n.minFilter),e.texParameteri(r,Ur,n.magFilter),e.texParameteri(r,Ir,n.wrapS),e.texParameteri(r,Lr,n.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(r,Zr,n.anisotropic),n.genMipmaps&&(e.hint(Xr,n.mipmapHint),e.generateMipmap(r))}function E(t){f.call(this),this.mipmask=0,this.internalformat=rr,this.id=Z++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new S,o.profile&&(this.stats={size:0})}function D(t){e.activeTexture(ia),e.bindTexture(t.target,t.texture)}function T(){var t=ne[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(er,null)}function j(t){var n=t.texture;xt(n,"must not double destroy texture");var r=t.unit,a=t.target;r>=0&&(e.activeTexture(ia+r),e.bindTexture(a,null),ne[r]=null),e.deleteTexture(n),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete ee[t.id],i.textureCount--}function C(t,r){function a(e,t){var r=c.texInfo;S.call(r);var i=w();return"number"==typeof e?"number"==typeof t?g(i,0|e,0|t):g(i,0|e,0|e):e?(xt.type(e,"object","invalid arguments to regl.texture"),_(r,e),y(i,e)):g(i,1,1),r.genMipmaps&&(i.mipmask=(i.width<<1)-1),c.mipmask=i.mipmask,u(c,i),xt.texture2D(r,i,n),c.internalformat=i.internalformat,a.width=i.width,a.height=i.height,D(c),x(i,er),A(r,er),T(),k(i),o.profile&&(c.stats.size=Ce(c.internalformat,c.type,i.width,i.height,r.genMipmaps,!1)),a.format=G[c.internalformat],a.type=H[c.type],a.mag=Q[r.magFilter],a.min=V[r.minFilter],a.wrapS=Y[r.wrapS],a.wrapT=Y[r.wrapT],a}function f(e,t,n,r){xt(!!e,"must specify image data");var i=0|t,o=0|n,f=0|r,s=h();return u(s,c),s.width=0,s.height=0,m(s,e),s.width=s.width||(c.width>>f)-i,s.height=s.height||(c.height>>f)-o,xt(c.type===s.type&&c.format===s.format&&c.internalformat===s.internalformat,"incompatible format for texture.subimage"),xt(i>=0&&o>=0&&i+s.width<=c.width&&o+s.height<=c.height,"texture.subimage write out of bounds"),xt(c.mipmask&1<<f,"missing mipmap data"),xt(s.data||s.element||s.needsCopy,"missing image data"),D(c),p(s,er,i,o,f),T(),v(s),a}function s(t,n){var r=0|t,i=0|n||r;if(r===c.width&&i===c.height)return a;a.width=c.width=r,a.height=c.height=i,D(c);for(var f=0;c.mipmask>>f;++f)e.texImage2D(er,f,c.format,r>>f,i>>f,0,c.format,c.type,null);return T(),o.profile&&(c.stats.size=Ce(c.internalformat,c.type,r,i,!1,!1)),a}var c=new E(er);return ee[c.id]=c,i.textureCount++,a(t,r),a.subimage=f,a.resize=s,a._reglType="texture2d",a._texture=c,o.profile&&(a.stats=c.stats),a.destroy=function(){c.decRef()},a}function O(t,r,a,f,c,l){function d(e,t,r,a,i,f){var c,l=C.texInfo;for(S.call(l),c=0;c<6;++c)O[c]=w();if("number"!=typeof e&&e)if("object"==typeof e)if(t)y(O[0],e),y(O[1],t),y(O[2],r),y(O[3],a),y(O[4],i),y(O[5],f);else if(_(l,e),s(C,e),"faces"in e){var m=e.faces;for(xt(Array.isArray(m)&&6===m.length,"cube faces must be a length 6 array"),c=0;c<6;++c)xt("object"==typeof m[c]&&!!m[c],"invalid input for cube map face"),u(O[c],C),y(O[c],m[c])}else for(c=0;c<6;++c)y(O[c],e);else xt.raise("invalid arguments to cube map");else{var p=0|e||1;for(c=0;c<6;++c)g(O[c],p,p)}for(u(C,O[0]),l.genMipmaps?C.mipmask=(O[0].width<<1)-1:C.mipmask=O[0].mipmask,xt.textureCube(C,l,O,n),C.internalformat=O[0].internalformat,d.width=O[0].width,d.height=O[0].height,D(C),c=0;c<6;++c)x(O[c],nr+c);for(A(l,tr),T(),o.profile&&(C.stats.size=Ce(C.internalformat,C.type,d.width,d.height,l.genMipmaps,!0)),d.format=G[C.internalformat],d.type=H[C.type],d.mag=Q[l.magFilter],d.min=V[l.minFilter],d.wrapS=Y[l.wrapS],d.wrapT=Y[l.wrapT],c=0;c<6;++c)k(O[c]);return d}function b(e,t,n,r,a){xt(!!t,"must specify image data"),xt("number"==typeof e&&e===(0|e)&&e>=0&&e<6,"invalid face");var i=0|n,o=0|r,f=0|a,s=h();return u(s,C),s.width=0,s.height=0,m(s,t),s.width=s.width||(C.width>>f)-i,s.height=s.height||(C.height>>f)-o,xt(C.type===s.type&&C.format===s.format&&C.internalformat===s.internalformat,"incompatible format for texture.subimage"),xt(i>=0&&o>=0&&i+s.width<=C.width&&o+s.height<=C.height,"texture.subimage write out of bounds"),xt(C.mipmask&1<<f,"missing mipmap data"),xt(s.data||s.element||s.needsCopy,"missing image data"),D(C),p(s,nr+e,i,o,f),T(),v(s),d}function j(t){var n=0|t;if(n!==C.width){d.width=C.width=n,d.height=C.height=n,D(C);for(var r=0;r<6;++r)for(var a=0;C.mipmask>>a;++a)e.texImage2D(nr+r,a,C.format,n>>a,n>>a,0,C.format,C.type,null);return T(),o.profile&&(C.stats.size=Ce(C.internalformat,C.type,d.width,d.height,!1,!0)),d}}var C=new E(tr);ee[C.id]=C,i.cubeCount++;var O=new Array(6);return d(t,r,a,f,c,l),d.subimage=b,d.resize=j,d._reglType="textureCube",d._texture=C,o.profile&&(d.stats=C.stats),d.destroy=function(){C.decRef()},d}function z(){for(var t=0;t<te;++t)e.activeTexture(ia+t),e.bindTexture(er,null),ne[t]=null;en(ee).forEach(j),i.cubeCount=0,i.textureCount=0}function F(){en(ee).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var n=0;n<32;++n)if(0!==(t.mipmask&1<<n))if(t.target===er)e.texImage2D(er,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);else for(var r=0;r<6;++r)e.texImage2D(nr+r,n,t.internalformat,t.width>>n,t.height>>n,0,t.internalformat,t.type,null);A(t.texInfo,t.target)})}var M={"don't care":$r,"dont care":$r,nice:Jr,fast:Kr},P={repeat:Br,clamp:Rr,mirror:Nr},I={nearest:Wr,linear:Gr},L=Ze({mipmap:Yr,"nearest mipmap nearest":Hr,"linear mipmap nearest":Qr,"nearest mipmap linear":Vr,"linear mipmap linear":Yr},I),B={none:0,browser:aa},R={uint8:zr,rgba4:lr,rgb565:dr,"rgb5 a1":mr},N={alpha:ar,luminance:or,"luminance alpha":fr,rgb:ir,rgba:rr,rgba4:ur,"rgb5 a1":sr,rgb565:cr},U={};t.ext_srgb&&(N.srgb=br,N.srgba=gr),t.oes_texture_float&&(R.float32=R.float=Pr),t.oes_texture_half_float&&(R.float16=R["half float"]=yr),t.webgl_depth_texture&&(Ze(N,{depth:hr,"depth stencil":vr}),Ze(R,{uint16:Fr,uint32:Mr,"depth stencil":pr})),t.webgl_compressed_texture_s3tc&&Ze(U,{"rgb s3tc dxt1":xr,"rgba s3tc dxt1":wr,"rgba s3tc dxt3":kr,"rgba s3tc dxt5":Sr}),t.webgl_compressed_texture_atc&&Ze(U,{"rgb atc":_r,"rgba atc explicit alpha":Ar,"rgba atc interpolated alpha":Er}),t.webgl_compressed_texture_pvrtc&&Ze(U,{"rgb pvrtc 4bppv1":Dr,"rgb pvrtc 2bppv1":Tr,"rgba pvrtc 4bppv1":jr,"rgba pvrtc 2bppv1":Cr}),t.webgl_compressed_texture_etc1&&(U["rgb etc1"]=Or);var q=Array.prototype.slice.call(e.getParameter(Zn));Object.keys(U).forEach(function(e){var t=U[e];q.indexOf(t)>=0&&(N[e]=t)});var W=Object.keys(N);n.textureFormats=W;var G=[];Object.keys(N).forEach(function(e){var t=N[e];G[t]=e});var H=[];Object.keys(R).forEach(function(e){var t=R[e];H[t]=e});var Q=[];Object.keys(I).forEach(function(e){var t=I[e];Q[t]=e});var V=[];Object.keys(L).forEach(function(e){var t=L[e];V[t]=e});var Y=[];Object.keys(P).forEach(function(e){var t=P[e];Y[t]=e});var $=W.reduce(function(e,t){var n=N[t];return n===or||n===ar||n===or||n===fr||n===hr||n===vr?e[n]=n:n===sr||t.indexOf("rgba")>=0?e[n]=rr:e[n]=ir,e},{}),K=[],J=[],Z=0,ee={},te=n.maxTextureUnits,ne=Array(te).map(function(){return null});return Ze(E.prototype,{bind:function(){var t=this;t.bindCount+=1;var n=t.unit;if(n<0){for(var r=0;r<te;++r){var a=ne[r];if(a){if(a.bindCount>0)continue;a.unit=-1}ne[r]=t,n=r;break}n>=te&&xt.raise("insufficient number of texture units"),o.profile&&i.maxTextureUnits<n+1&&(i.maxTextureUnits=n+1),t.unit=n,e.activeTexture(ia+n),e.bindTexture(t.target,t.texture)}return n},unbind:function(){this.bindCount-=1},decRef:function(){--this.refCount<=0&&j(this)}}),o.profile&&(i.getTotalTextureSize=function(){var e=0;return Object.keys(ee).forEach(function(t){e+=ee[t].stats.size}),e}),{create2D:C,createCube:O,clear:z,getTexture:function(e){return null},restore:F}}function ze(e,t,n){return Da[e]*t*n}function Fe(e,t,n,r,a,i){function o(e,t,n){this.target=e,this.texture=t,this.renderbuffer=n;var r=0,a=0;t?(r=t.width,a=t.height):n&&(r=n.width,a=n.height),this.width=r,this.height=a}function f(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,n){if(e)if(e.texture){var r=e.texture._texture,a=Math.max(1,r.width),i=Math.max(1,r.height);xt(a===t&&i===n,"inconsistent width/height for supplied texture"),r.refCount+=1}else{var o=e.renderbuffer._renderbuffer;xt(o.width===t&&o.height===n,"inconsistent width/height for renderbuffer"),o.refCount+=1}}function s(t,n){n&&(n.texture?e.framebufferTexture2D(ja,t,n.target,n.texture._texture.texture,0):e.framebufferRenderbuffer(ja,t,Ca,n.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=Oa,n=null,r=null,a=e;"object"==typeof e&&(a=e.data,"target"in e&&(t=0|e.target)),xt.type(a,"function","invalid attachment data");var i=a._reglType;return"texture2d"===i?(n=a,xt(t===Oa)):"textureCube"===i?(n=a,xt(t>=za&&t<za+6,"invalid cube map target")):"renderbuffer"===i?(r=a,t=Ca):xt.raise("invalid regl object for attachment"),new o(t,n,r)}function l(e,t,n,i,f){if(n){var u=r.create2D({width:e,height:t,format:i,type:f});return u._texture.refCount=0,new o(Oa,u,null)}var s=a.create({width:e,height:t,format:i});return s._renderbuffer.refCount=0,new o(Ca,null,s)}function m(e){return e&&(e.texture||e.renderbuffer)}function d(e,t,n){e&&(e.texture?e.texture.resize(t,n):e.renderbuffer&&e.renderbuffer.resize(t,n))}function p(){this.id=A++,E[this.id]=this,this.framebuffer=e.createFramebuffer(),this.width=0,this.height=0,this.colorAttachments=[],this.depthAttachment=null,this.stencilAttachment=null,this.depthStencilAttachment=null}function h(e){e.colorAttachments.forEach(f),f(e.depthAttachment),f(e.stencilAttachment),f(e.depthStencilAttachment)}function v(t){var n=t.framebuffer;xt(n,"must not double destroy framebuffer"),e.deleteFramebuffer(n),t.framebuffer=null,i.framebufferCount--,delete E[t.id]}function b(t){var r;e.bindFramebuffer(ja,t.framebuffer);var a=t.colorAttachments;for(r=0;r<a.length;++r)s(Fa+r,a[r]);for(r=a.length;r<n.maxColorAttachments;++r)e.framebufferTexture2D(ja,Fa+r,Oa,null,0);e.framebufferTexture2D(ja,Ia,Oa,null,0),e.framebufferTexture2D(ja,Ma,Oa,null,0),e.framebufferTexture2D(ja,Pa,Oa,null,0),s(Ma,t.depthAttachment),s(Pa,t.stencilAttachment),s(Ia,t.depthStencilAttachment);var i=e.checkFramebufferStatus(ja);i!==La&&xt.raise("framebuffer configuration not supported, status = "+fi[i]),e.bindFramebuffer(ja,w.next),w.cur=w.next,e.getError()}function g(e,r){function a(e,r){var i;xt(w.next!==f,"can not update framebuffer which is currently in use");var o=t.webgl_draw_buffers,s=0,d=0,p=!0,v=!0,g=null,y=!0,x="rgba",A="uint8",E=1,D=null,T=null,j=null,C=!1;if("number"==typeof e)s=0|e,d=0|r||s;else if(e){xt.type(e,"object","invalid arguments for framebuffer");var O=e;if("shape"in O){var z=O.shape;xt(Array.isArray(z)&&z.length>=2,"invalid shape for framebuffer"),s=z[0],d=z[1]}else"radius"in O&&(s=d=O.radius),"width"in O&&(s=O.width),"height"in O&&(d=O.height);("color"in O||"colors"in O)&&(g=O.color||O.colors,Array.isArray(g)&&xt(1===g.length||o,"multiple render targets not supported")),g||("colorCount"in O&&(E=0|O.colorCount,xt(E>0,"invalid color buffer count")),"colorTexture"in O&&(y=!!O.colorTexture,x="rgba4"),"colorType"in O&&(A=O.colorType,y?(xt(t.oes_texture_float||!("float"===A||"float32"===A),"you must enable OES_texture_float in order to use floating point framebuffer objects"),xt(t.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?(xt(t.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||(xt(t.webgl_color_buffer_float,"you must enable WEBGL_color_buffer_float in order to use 32-bit floating point renderbuffers"),x="rgba32f"),xt.oneOf(A,_,"invalid color type")),"colorFormat"in O&&(x=O.colorFormat,k.indexOf(x)>=0?y=!0:S.indexOf(x)>=0?y=!1:y?xt.oneOf(O.colorFormat,k,"invalid color format for texture"):xt.oneOf(O.colorFormat,S,"invalid color format for renderbuffer"))),("depthTexture"in O||"depthStencilTexture"in O)&&(C=!(!O.depthTexture&&!O.depthStencilTexture),xt(!C||t.webgl_depth_texture,"webgl_depth_texture extension not supported")),"depth"in O&&("boolean"==typeof O.depth?p=O.depth:(D=O.depth,v=!1)),"stencil"in O&&("boolean"==typeof O.stencil?v=O.stencil:(T=O.stencil,p=!1)),"depthStencil"in O&&("boolean"==typeof O.depthStencil?p=v=O.depthStencil:(j=O.depthStencil,p=!1,v=!1))}else s=d=1;var F=null,M=null,P=null,I=null;if(Array.isArray(g))F=g.map(c);else if(g)F=[c(g)];else for(F=new Array(E),i=0;i<E;++i)F[i]=l(s,d,y,x,A);xt(t.webgl_draw_buffers||F.length<=1,"you must enable the WEBGL_draw_buffers extension in order to use multiple color buffers."),xt(F.length<=n.maxColorAttachments,"too many color attachments, not supported"),s=s||F[0].width,d=d||F[0].height,D?M=c(D):p&&!v&&(M=l(s,d,C,"depth","uint32")),T?P=c(T):v&&!p&&(P=l(s,d,!1,"stencil","uint8")),j?I=c(j):!D&&!T&&v&&p&&(I=l(s,d,C,"depth stencil","depth stencil")),xt(!!D+!!T+!!j<=1,"invalid framebuffer configuration, can specify exactly one depth/stencil attachment");var L=null;for(i=0;i<F.length;++i)if(u(F[i],s,d),xt(!F[i]||F[i].texture&&Va.indexOf(F[i].texture._texture.format)>=0||F[i].renderbuffer&&oi.indexOf(F[i].renderbuffer._renderbuffer.format)>=0,"framebuffer color attachment "+i+" is invalid"),F[i]&&F[i].texture){var B=Ya[F[i].texture._texture.format]*Xa[F[i].texture._texture.type];null===L?L=B:xt(L===B,"all color attachments much have the same number of bits per pixel.")}return u(M,s,d),xt(!M||M.texture&&M.texture._texture.format===Qa||M.renderbuffer&&M.renderbuffer._renderbuffer.format===Za,"invalid depth attachment for framebuffer object"),u(P,s,d),xt(!P||P.renderbuffer&&P.renderbuffer._renderbuffer.format===ei,"invalid stencil attachment for framebuffer object"),u(I,s,d),xt(!I||I.texture&&I.texture._texture.format===ti||I.renderbuffer&&I.renderbuffer._renderbuffer.format===ti,"invalid depth-stencil attachment for framebuffer object"),h(f),f.width=s,f.height=d,f.colorAttachments=F,f.depthAttachment=M,f.stencilAttachment=P,f.depthStencilAttachment=I,a.color=F.map(m),a.depth=m(M),a.stencil=m(P),a.depthStencil=m(I),a.width=f.width,a.height=f.height,b(f),a}function o(e,t){xt(w.next!==f,"can not resize a framebuffer which is currently in use");
var n=0|e,r=0|t||n;if(n===f.width&&r===f.height)return a;for(var i=f.colorAttachments,o=0;o<i.length;++o)d(i[o],n,r);return d(f.depthAttachment,n,r),d(f.stencilAttachment,n,r),d(f.depthStencilAttachment,n,r),f.width=a.width=n,f.height=a.height=r,b(f),a}var f=new p;return i.framebufferCount++,a(e,r),Ze(a,{resize:o,_reglType:"framebuffer",_framebuffer:f,destroy:function(){v(f),h(f)},use:function(e){w.setFBO({framebuffer:a},e)}})}function y(e){function a(e){var n;xt(o.indexOf(w.next)<0,"can not update framebuffer which is currently in use");var i=t.webgl_draw_buffers,f={color:null},u=0,s=null,c="rgba",l="uint8",m=1;if("number"==typeof e)u=0|e;else if(e){xt.type(e,"object","invalid arguments for framebuffer");var d=e;if("shape"in d){var p=d.shape;xt(Array.isArray(p)&&p.length>=2,"invalid shape for framebuffer"),xt(p[0]===p[1],"cube framebuffer must be square"),u=p[0]}else"radius"in d&&(u=0|d.radius),"width"in d?(u=0|d.width,"height"in d&&xt(d.height===u,"must be square")):"height"in d&&(u=0|d.height);("color"in d||"colors"in d)&&(s=d.color||d.colors,Array.isArray(s)&&xt(1===s.length||i,"multiple render targets not supported")),s||("colorCount"in d&&(m=0|d.colorCount,xt(m>0,"invalid color buffer count")),"colorType"in d&&(xt.oneOf(d.colorType,_,"invalid color type"),l=d.colorType),"colorFormat"in d&&(c=d.colorFormat,xt.oneOf(d.colorFormat,k,"invalid color format for texture"))),"depth"in d&&(f.depth=d.depth),"stencil"in d&&(f.stencil=d.stencil),"depthStencil"in d&&(f.depthStencil=d.depthStencil)}else u=1;var h;if(s)if(Array.isArray(s))for(h=[],n=0;n<s.length;++n)h[n]=s[n];else h=[s];else{h=Array(m);var v={radius:u,format:c,type:l};for(n=0;n<m;++n)h[n]=r.createCube(v)}for(f.color=Array(h.length),n=0;n<h.length;++n){var b=h[n];xt("function"==typeof b&&"textureCube"===b._reglType,"invalid cube map"),u=u||b.width,xt(b.width===u&&b.height===u,"invalid cube map shape"),f.color[n]={target:za,data:h[n]}}for(n=0;n<6;++n){for(var y=0;y<h.length;++y)f.color[y].target=za+n;n>0&&(f.depth=o[0].depth,f.stencil=o[0].stencil,f.depthStencil=o[0].depthStencil),o[n]?o[n](f):o[n]=g(f)}return Ze(a,{width:u,height:u,color:h})}function i(e){var t,r=0|e;if(xt(r>0&&r<=n.maxCubeMapSize,"invalid radius for cube fbo"),r===a.width)return a;var i=a.color;for(t=0;t<i.length;++t)i[t].resize(r);for(t=0;t<6;++t)o[t].resize(r);return a.width=a.height=r,a}var o=Array(6);return a(e),Ze(a,{faces:o,resize:i,_reglType:"framebufferCube",destroy:function(){o.forEach(function(e){e.destroy()})}})}function x(){en(E).forEach(function(t){t.framebuffer=e.createFramebuffer(),b(t)})}var w={cur:null,next:null,dirty:!1,setFBO:null},k=["rgba"],S=["rgba4","rgb565","rgb5 a1"];t.ext_srgb&&S.push("srgba"),t.ext_color_buffer_half_float&&S.push("rgba16f","rgb16f"),t.webgl_color_buffer_float&&S.push("rgba32f");var _=["uint8"];t.oes_texture_half_float&&_.push("half float","float16"),t.oes_texture_float&&_.push("float","float32");var A=0,E={};return Ze(w,{getFramebuffer:function(e){if("function"==typeof e&&"framebuffer"===e._reglType){var t=e._framebuffer;if(t instanceof p)return t}return null},create:g,createCube:y,clear:function(){en(E).forEach(v)},restore:x})}function Me(){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=ui,this.offset=0,this.stride=0,this.divisor=0}function Pe(e,t,n,r,a){for(var i=n.maxAttributes,o=new Array(i),f=0;f<i;++f)o[f]=new Me;return{Record:Me,scope:{},state:o}}function Ie(e,t,n,r){function a(e,t,n,r){this.name=e,this.id=t,this.location=n,this.info=r}function i(e,t){for(var n=0;n<e.length;++n)if(e[n].id===t.id)return void(e[n].location=t.location);e.push(t)}function o(n,r,a){var i=n===si?c:l,o=i[r];if(!o){var f=t.str(r);o=e.createShader(n),e.shaderSource(o,f),e.compileShader(o),xt.shaderError(e,o,f,n,a),i[r]=o}return o}function f(e,t){this.id=p++,this.fragId=e,this.vertId=t,this.program=null,this.uniforms=[],this.attributes=[],r.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function u(n,f){var u,s,c=o(si,n.fragId),l=o(ci,n.vertId),m=n.program=e.createProgram();e.attachShader(m,c),e.attachShader(m,l),e.linkProgram(m),xt.linkError(e,m,t.str(n.fragId),t.str(n.vertId),f);var d=e.getProgramParameter(m,li);r.profile&&(n.stats.uniformsCount=d);var p=n.uniforms;for(u=0;u<d;++u)if(s=e.getActiveUniform(m,u))if(s.size>1)for(var h=0;h<s.size;++h){var v=s.name.replace("[0]","["+h+"]");i(p,new a(v,t.id(v),e.getUniformLocation(m,v),s))}else i(p,new a(s.name,t.id(s.name),e.getUniformLocation(m,s.name),s));var b=e.getProgramParameter(m,mi);r.profile&&(n.stats.attributesCount=b);var g=n.attributes;for(u=0;u<b;++u)s=e.getActiveAttrib(m,u),s&&i(g,new a(s.name,t.id(s.name),e.getAttribLocation(m,s.name),s))}function s(){c={},l={};for(var e=0;e<d.length;++e)u(d[e])}var c={},l={},m={},d=[],p=0;return r.profile&&(n.getMaxUniformsCount=function(){var e=0;return d.forEach(function(t){t.stats.uniformsCount>e&&(e=t.stats.uniformsCount)}),e},n.getMaxAttributesCount=function(){var e=0;return d.forEach(function(t){t.stats.attributesCount>e&&(e=t.stats.attributesCount)}),e}),{clear:function(){var t=e.deleteShader.bind(e);en(c).forEach(t),c={},en(l).forEach(t),l={},d.forEach(function(t){e.deleteProgram(t.program)}),d.length=0,m={},n.shaderCount=0},program:function(e,t,r){xt.command(e>=0,"missing vertex shader",r),xt.command(t>=0,"missing fragment shader",r);var a=m[t];a||(a=m[t]={});var i=a[e];return i||(i=new f(t,e),n.shaderCount++,u(i,r),a[e]=i,d.push(i)),i},restore:s,shader:o,frag:-1,vert:-1}}function Le(e,t,n,r,a,i){function o(o){var f;null===t.next?(xt(a.preserveDrawingBuffer,'you must create a webgl context with "preserveDrawingBuffer":true in order to read pixels from the drawing buffer'),f=pi):(xt(null!==t.next.colorAttachments[0].texture,"You cannot read from a renderbuffer"),f=t.next.colorAttachments[0].texture._texture.type,i.oes_texture_float?xt(f===pi||f===vi,"Reading from a framebuffer is only allowed for the types 'uint8' and 'float'"):xt(f===pi,"Reading from a framebuffer is only allowed for the type 'uint8'"));var u=0,s=0,c=r.framebufferWidth,l=r.framebufferHeight,m=null;Je(o)?m=o:o&&(xt.type(o,"object","invalid arguments to regl.read()"),u=0|o.x,s=0|o.y,xt(u>=0&&u<r.framebufferWidth,"invalid x offset for regl.read"),xt(s>=0&&s<r.framebufferHeight,"invalid y offset for regl.read"),c=0|(o.width||r.framebufferWidth-u),l=0|(o.height||r.framebufferHeight-s),m=o.data||null),m&&(f===pi?xt(m instanceof Uint8Array,"buffer must be 'Uint8Array' when reading from a framebuffer of type 'uint8'"):f===vi&&xt(m instanceof Float32Array,"buffer must be 'Float32Array' when reading from a framebuffer of type 'float'")),xt(c>0&&c+u<=r.framebufferWidth,"invalid width for read pixels"),xt(l>0&&l+s<=r.framebufferHeight,"invalid height for read pixels"),n();var d=c*l*4;return m||(f===pi?m=new Uint8Array(d):f===vi&&(m=m||new Float32Array(d))),xt.isTypedArray(m,"data buffer for regl.read() must be a typedarray"),xt(m.byteLength>=d,"data buffer for regl.read() too small"),e.pixelStorei(hi,4),e.readPixels(u,s,c,l,di,f,m),m}function f(e){var n;return t.setFBO({framebuffer:e.framebuffer},function(){n=o(e)}),n}function u(e){return e&&"framebuffer"in e?f(e):o(e)}return u}function Be(e){return Array.prototype.slice.call(e)}function Re(e){return Be(e).join("")}function Ne(){function e(e){for(var t=0;t<u.length;++t)if(u[t]===e)return f[t];var n="g"+o++;return f.push(n),u.push(e),n}function t(){function e(){n.push.apply(n,Be(arguments))}function t(){var e="v"+o++;return r.push(e),arguments.length>0&&(n.push(e,"="),n.push.apply(n,Be(arguments)),n.push(";")),e}var n=[],r=[];return Ze(e,{def:t,toString:function(){return Re([r.length>0?"var "+r+";":"",Re(n)])}})}function n(){function e(e,t){r(e,t,"=",n.def(e,t),";")}var n=t(),r=t(),a=n.toString,i=r.toString;return Ze(function(){n.apply(n,Be(arguments))},{def:n.def,entry:n,exit:r,save:e,set:function(t,r,a){e(t,r),n(t,r,"=",a,";")},toString:function(){return a()+i()}})}function r(){var e=Re(arguments),t=n(),r=n(),a=t.toString,i=r.toString;return Ze(t,{then:function(){return t.apply(t,Be(arguments)),this},else:function(){return r.apply(r,Be(arguments)),this},toString:function(){var t=i();return t&&(t="else{"+t+"}"),Re(["if(",e,"){",a(),"}",t])}})}function a(e,t){function r(){var e="a"+a.length;return a.push(e),e}var a=[];t=t||0;for(var i=0;i<t;++i)r();var o=n(),f=o.toString,u=c[e]=Ze(o,{arg:r,toString:function(){return Re(["function(",a.join(),"){",f(),"}"])}});return u}function i(){var e=['"use strict";',s,"return {"];Object.keys(c).forEach(function(t){e.push('"',t,'":',c[t].toString(),",")}),e.push("}");var t=Re(e).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n"),n=Function.apply(null,f.concat(t));return n.apply(null,u)}var o=0,f=[],u=[],s=t(),c={};return{global:s,link:e,block:t,proc:a,scope:n,cond:r,compile:i}}function Ue(e){return Array.isArray(e)||Je(e)||X(e)}function qe(e){return e.sort(function(e,t){return e===Ji?-1:t===Ji?1:e<t?-1:1})}function We(e,t,n,r){this.thisDep=e,this.contextDep=t,this.propDep=n,this.append=r}function Ge(e){return e&&!(e.thisDep||e.contextDep||e.propDep)}function He(e){return new We(!1,!1,!1,e)}function Qe(e,t){var n=e.type;if(n===wi){var r=e.data.length;return new We(!0,r>=1,r>=2,t)}if(n===Ai){var a=e.data;return new We(a.thisDep,a.contextDep,a.propDep,t)}return new We(n===_i,n===Si,n===ki,t)}function Ve(e,t,n,r,a,i,o,f,u,s,c,l,m,d,p){function h(e){return e.replace(".","_")}function v(e,t,n){var r=h(e);te.push(e),ee[r]=Z[r]=!!n,ne[r]=t}function b(e,t,n){var r=h(e);te.push(e),Array.isArray(n)?(Z[r]=n.slice(),ee[r]=n.slice()):Z[r]=ee[r]=n,re[r]=t}function g(){var e=Ne(),n=e.link,r=e.global;e.id=oe++,e.batchId="0";var a=n(ae),i=e.shared={props:"a0"};Object.keys(ae).forEach(function(e){i[e]=r.def(a,".",e)}),xt.optional(function(){e.CHECK=n(xt),e.commandStr=xt.guessCommand(),e.command=n(e.commandStr),e.assert=function(e,t,r){e("if(!(",t,"))",this.CHECK,".commandRaise(",n(r),",",this.command,");")},ie.invalidBlendCombinations=pf});var o=e.next={},f=e.current={};Object.keys(re).forEach(function(e){Array.isArray(Z[e])&&(o[e]=r.def(i.next,".",e),f[e]=r.def(i.current,".",e))});var u=e.constants={};Object.keys(ie).forEach(function(e){u[e]=r.def(JSON.stringify(ie[e]))}),e.invoke=function(t,r){switch(r.type){case wi:var a=["this",i.context,i.props,e.batchId];return t.def(n(r.data),".call(",a.slice(0,Math.max(r.data.length+1,4)),")");case ki:return t.def(i.props,r.data);case Si:return t.def(i.context,r.data);case _i:return t.def("this",r.data);case Ai:return r.data.append(e,t),r.data.ref}},e.attribCache={};var c={};return e.scopeAttrib=function(e){var r=t.id(e);if(r in c)return c[r];var a=s.scope[r];a||(a=s.scope[r]=new Y);var i=c[r]=n(a);return i},e}function y(e){var t,n=e.static,r=e.dynamic;if(Zi in n){var a=!!n[Zi];t=He(function(e,t){return a}),t.enable=a}else if(Zi in r){var i=r[Zi];t=Qe(i,function(e,t){return e.invoke(t,i)})}return t}function x(e,t){var n=e.static,r=e.dynamic;if(eo in n){var a=n[eo];return a?(a=f.getFramebuffer(a),xt.command(a,"invalid framebuffer object"),He(function(e,t){var n=e.link(a),r=e.shared;t.set(r.framebuffer,".next",n);var i=r.context;return t.set(i,"."+co,n+".width"),t.set(i,"."+lo,n+".height"),n})):He(function(e,t){var n=e.shared;t.set(n.framebuffer,".next","null");var r=n.context;return t.set(r,"."+co,r+"."+vo),t.set(r,"."+lo,r+"."+bo),"null"})}if(eo in r){var i=r[eo];return Qe(i,function(e,t){var n=e.invoke(t,i),r=e.shared,a=r.framebuffer,o=t.def(a,".getFramebuffer(",n,")");xt.optional(function(){e.assert(t,"!"+n+"||"+o,"invalid framebuffer object")}),t.set(a,".next",o);var f=r.context;return t.set(f,"."+co,o+"?"+o+".width:"+f+"."+vo),t.set(f,"."+lo,o+"?"+o+".height:"+f+"."+bo),o})}return null}function w(e,t,n){function r(e){if(e in a){var r=a[e];xt.commandType(r,"object","invalid "+e,n.commandStr);var o,f,u=!0,s=0|r.x,c=0|r.y;return"width"in r?(o=0|r.width,xt.command(o>=0,"invalid "+e,n.commandStr)):u=!1,"height"in r?(f=0|r.height,xt.command(f>=0,"invalid "+e,n.commandStr)):u=!1,new We(!u&&t&&t.thisDep,!u&&t&&t.contextDep,!u&&t&&t.propDep,function(e,t){var n=e.shared.context,a=o;"width"in r||(a=t.def(n,".",co,"-",s));var i=f;return"height"in r||(i=t.def(n,".",lo,"-",c)),[s,c,a,i]})}if(e in i){var l=i[e],m=Qe(l,function(t,n){var r=t.invoke(n,l);xt.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)});var a=t.shared.context,i=n.def(r,".x|0"),o=n.def(r,".y|0"),f=n.def('"width" in ',r,"?",r,".width|0:","(",a,".",co,"-",i,")"),u=n.def('"height" in ',r,"?",r,".height|0:","(",a,".",lo,"-",o,")");return xt.optional(function(){t.assert(n,f+">=0&&"+u+">=0","invalid "+e)}),[i,o,f,u]});return t&&(m.thisDep=m.thisDep||t.thisDep,m.contextDep=m.contextDep||t.contextDep,m.propDep=m.propDep||t.propDep),m}return t?new We(t.thisDep,t.contextDep,t.propDep,function(e,t){var n=e.shared.context;return[0,0,t.def(n,".",co),t.def(n,".",lo)]}):null}var a=e.static,i=e.dynamic,o=r(Ji);if(o){var f=o;o=new We(o.thisDep,o.contextDep,o.propDep,function(e,t){var n=f.append(e,t),r=e.shared.context;return t.set(r,"."+mo,n[2]),t.set(r,"."+po,n[3]),n})}return{viewport:o,scissor_box:r(Ki)}}function k(e){function n(e){if(e in a){var n=t.id(a[e]);xt.optional(function(){c.shader(bf[e],n,xt.guessCommand())});var r=He(function(){return n});return r.id=n,r}if(e in i){var o=i[e];return Qe(o,function(t,n){var r=t.invoke(n,o),a=n.def(t.shared.strings,".id(",r,")");return xt.optional(function(){n(t.shared.shader,".shader(",bf[e],",",a,",",t.command,");")}),a})}return null}var r,a=e.static,i=e.dynamic,o=n(no),f=n(to),u=null;return Ge(o)&&Ge(f)?(u=c.program(f.id,o.id),r=He(function(e,t){return e.link(u)})):r=new We(o&&o.thisDep||f&&f.thisDep,o&&o.contextDep||f&&f.contextDep,o&&o.propDep||f&&f.propDep,function(e,t){var n,r=e.shared.shader;n=o?o.append(e,t):t.def(r,".",no);var a;a=f?f.append(e,t):t.def(r,".",to);var i=r+".program("+a+","+n;return xt.optional(function(){i+=","+e.command}),t.def(i+")")}),{frag:o,vert:f,progVar:r,program:u}}function S(e,t){function n(){if(ro in f){var e=f[ro];Ue(e)?e=i.getElements(i.create(e,!0)):e&&(e=i.getElements(e),xt.command(e,"invalid elements",t.commandStr));var n=He(function(t,n){if(e){var r=t.link(e);return t.ELEMENTS=r,r}return t.ELEMENTS=null,null});return n.value=e,n}if(ro in u){var r=u[ro];return Qe(r,function(e,t){var n=e.shared,a=n.isBufferArgs,i=n.elements,o=e.invoke(t,r),f=t.def("null"),u=t.def(a,"(",o,")"),s=e.cond(u).then(f,"=",i,".createStream(",o,");").else(f,"=",i,".getElements(",o,");");return xt.optional(function(){e.assert(s.else,"!"+o+"||"+f,"invalid elements")}),t.entry(s),t.exit(e.cond(u).then(i,".destroyStream(",f,");")),e.ELEMENTS=f,f})}return null}function r(){if(ao in f){var e=f[ao];return xt.commandParameter(e,Ln,"invalid primitve",t.commandStr),He(function(t,n){return Ln[e]})}if(ao in u){var n=u[ao];return Qe(n,function(e,t){var r=e.constants.primTypes,a=e.invoke(t,n);return xt.optional(function(){e.assert(t,a+" in "+r,"invalid primitive, must be one of "+Object.keys(Ln))}),t.def(r,"[",a,"]")})}return s?Ge(s)?He(s.value?function(e,t){return t.def(e.ELEMENTS,".primType")}:function(){return Ko}):new We(s.thisDep,s.contextDep,s.propDep,function(e,t){var n=e.ELEMENTS;return t.def(n,"?",n,".primType:",Ko)}):null}function a(e,n){if(e in f){var r=0|f[e];return xt.command(!n||r>=0,"invalid "+e,t.commandStr),He(function(e,t){return n&&(e.OFFSET=r),r})}if(e in u){var a=u[e];return Qe(a,function(t,r){var i=t.invoke(r,a);return n&&(t.OFFSET=i,xt.optional(function(){t.assert(r,i+">=0","invalid "+e)})),i})}return n&&s?He(function(e,t){return e.OFFSET="0",0}):null}function o(){if(io in f){var e=0|f[io];return xt.command("number"==typeof e&&e>=0,"invalid vertex count",t.commandStr),He(function(){return e})}if(io in u){var n=u[io];return Qe(n,function(e,t){var r=e.invoke(t,n);return xt.optional(function(){e.assert(t,"typeof "+r+'==="number"&&'+r+">=0&&"+r+"===("+r+"|0)","invalid vertex count")}),r})}if(s){if(Ge(s)){if(s)return c?new We(c.thisDep,c.contextDep,c.propDep,function(e,t){var n=t.def(e.ELEMENTS,".vertCount-",e.OFFSET);return xt.optional(function(){e.assert(t,n+">=0","invalid vertex offset/element buffer too small")}),n}):He(function(e,t){return t.def(e.ELEMENTS,".vertCount")});var r=He(function(){return-1});return xt.optional(function(){r.MISSING=!0}),r}var a=new We(s.thisDep||c.thisDep,s.contextDep||c.contextDep,s.propDep||c.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 xt.optional(function(){a.DYNAMIC=!0}),a}return null}var f=e.static,u=e.dynamic,s=n(),c=a(oo,!0);return{elements:s,primitive:r(),count:o(),instances:a(fo,!1),offset:c}}function _(e,t){var n=e.static,a=e.dynamic,i={};return te.forEach(function(e){function o(t,r){if(e in n){var o=t(n[e]);i[f]=He(function(){return o})}else if(e in a){var u=a[e];i[f]=Qe(u,function(e,t){return r(e,t,e.invoke(t,u))})}}var f=h(e);switch(e){case Ii:case Di:case Ei:case Hi:case Oi:case $i:case Ni:case qi:case Wi:case Mi:return o(function(n){return xt.commandType(n,"boolean",e,t.commandStr),n},function(t,n,r){return xt.optional(function(){t.assert(n,"typeof "+r+'==="boolean"',"invalid flag "+e,t.commandStr)}),r});case zi:return o(function(n){return xt.commandParameter(n,hf,"invalid "+e,t.commandStr),hf[n]},function(t,n,r){var a=t.constants.compareFuncs;return xt.optional(function(){t.assert(n,r+" in "+a,"invalid "+e+", must be one of "+Object.keys(hf))}),n.def(a,"[",r,"]")});case Fi:return o(function(e){return xt.command(he(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){xt.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")});var r=t.def("+",n,"[0]"),a=t.def("+",n,"[1]");return[r,a]});case Ci:return o(function(e){xt.commandType(e,"object","blend.func",t.commandStr);var n="srcRGB"in e?e.srcRGB:e.src,r="srcAlpha"in e?e.srcAlpha:e.src,a="dstRGB"in e?e.dstRGB:e.dst,i="dstAlpha"in e?e.dstAlpha:e.dst;return xt.commandParameter(n,df,f+".srcRGB",t.commandStr),xt.commandParameter(r,df,f+".srcAlpha",t.commandStr),xt.commandParameter(a,df,f+".dstRGB",t.commandStr),xt.commandParameter(i,df,f+".dstAlpha",t.commandStr),xt.command(pf.indexOf(n+", "+a)===-1,"unallowed blending combination (srcRGB, dstRGB) = ("+n+", "+a+")",t.commandStr),[df[n],df[a],df[r],df[i]]},function(t,n,r){function a(a,o){var f=n.def('"',a,o,'" in ',r,"?",r,".",a,o,":",r,".",a);return xt.optional(function(){t.assert(n,f+" in "+i,"invalid "+e+"."+a+o+", must be one of "+Object.keys(df))}),f}var i=t.constants.blendFuncs;xt.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid blend func, must be an object")});var o=a("src","RGB"),f=a("dst","RGB");xt.optional(function(){var e=t.constants.invalidBlendCombinations;t.assert(n,e+".indexOf("+o+'+", "+'+f+") === -1 ","unallowed blending combination for (srcRGB, dstRGB)")});var u=n.def(i,"[",o,"]"),s=n.def(i,"[",a("src","Alpha"),"]"),c=n.def(i,"[",f,"]"),l=n.def(i,"[",a("dst","Alpha"),"]");return[u,c,s,l]});case ji:return o(function(n){return"string"==typeof n?(xt.commandParameter(n,X,"invalid "+e,t.commandStr),[X[n],X[n]]):"object"==typeof n?(xt.commandParameter(n.rgb,X,e+".rgb",t.commandStr),xt.commandParameter(n.alpha,X,e+".alpha",t.commandStr),[X[n.rgb],X[n.alpha]]):void xt.commandRaise("invalid blend.equation",t.commandStr)},function(t,n,r){var a=t.constants.blendEquations,i=n.def(),o=n.def(),f=t.cond("typeof ",r,'==="string"');return xt.optional(function(){function n(e,n,r){t.assert(e,r+" in "+a,"invalid "+n+", must be one of "+Object.keys(X))}n(f.then,e,r),t.assert(f.else,r+"&&typeof "+r+'==="object"',"invalid "+e),n(f.else,e+".rgb",r+".rgb"),n(f.else,e+".alpha",r+".alpha")}),f.then(i,"=",o,"=",a,"[",r,"];"),f.else(i,"=",a,"[",r,".rgb];",o,"=",a,"[",r,".alpha];"),n(f),[i,o]});case Ti:return o(function(e){return xt.command(he(e)&&4===e.length,"blend.color must be a 4d array",t.commandStr),$(4,function(t){return+e[t]})},function(e,t,n){return xt.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","blend.color must be a 4d array")}),$(4,function(e){return t.def("+",n,"[",e,"]")})});case Qi:return o(function(e){return xt.commandType(e,"number",f,t.commandStr),0|e},function(e,t,n){return xt.optional(function(){e.assert(t,"typeof "+n+'==="number"',"invalid stencil.mask")}),t.def(n,"|0")});case Vi:return o(function(n){xt.commandType(n,"object",f,t.commandStr);var r=n.cmp||"keep",a=n.ref||0,i="mask"in n?n.mask:-1;return xt.commandParameter(r,hf,e+".cmp",t.commandStr),xt.commandType(a,"number",e+".ref",t.commandStr),xt.commandType(i,"number",e+".mask",t.commandStr),[hf[r],a,i]},function(e,t,n){var r=e.constants.compareFuncs;xt.optional(function(){function a(){e.assert(t,Array.prototype.join.call(arguments,""),"invalid stencil.func")}a(n+"&&typeof ",n,'==="object"'),a('!("cmp" in ',n,")||(",n,".cmp in ",r,")")});var a=t.def('"cmp" in ',n,"?",r,"[",n,".cmp]",":",of),i=t.def(n,".ref|0"),o=t.def('"mask" in ',n,"?",n,".mask|0:-1");return[a,i,o]});case Yi:case Xi:return o(function(n){xt.commandType(n,"object",f,t.commandStr);var r=n.fail||"keep",a=n.zfail||"keep",i=n.zpass||"keep";return xt.commandParameter(r,vf,e+".fail",t.commandStr),xt.commandParameter(a,vf,e+".zfail",t.commandStr),xt.commandParameter(i,vf,e+".zpass",t.commandStr),[e===Xi?Zo:Jo,vf[r],vf[a],vf[i]]},function(t,n,r){function a(a){return xt.optional(function(){t.assert(n,'!("'+a+'" in '+r+")||("+r+"."+a+" in "+i+")","invalid "+e+"."+a+", must be one of "+Object.keys(vf))}),n.def('"',a,'" in ',r,"?",i,"[",r,".",a,"]:",of)}var i=t.constants.stencilOps;return xt.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)}),[e===Xi?Zo:Jo,a("fail"),a("zfail"),a("zpass")]});case Ui:return o(function(e){xt.commandType(e,"object",f,t.commandStr);var n=0|e.factor,r=0|e.units;return xt.commandType(n,"number",f+".factor",t.commandStr),xt.commandType(r,"number",f+".units",t.commandStr),[n,r]},function(t,n,r){xt.optional(function(){t.assert(n,r+"&&typeof "+r+'==="object"',"invalid "+e)});var a=n.def(r,".factor|0"),i=n.def(r,".units|0");return[a,i]});case Li:return o(function(e){var n=0;return"front"===e?n=Jo:"back"===e&&(n=Zo),xt.command(!!n,f,t.commandStr),n},function(e,t,n){return xt.optional(function(){e.assert(t,n+'==="front"||'+n+'==="back"',"invalid cull.face")}),t.def(n,'==="front"?',Jo,":",Zo)});case Ri:return o(function(e){return xt.command("number"==typeof e&&e>=r.lineWidthDims[0]&&e<=r.lineWidthDims[1],"invalid line width, must positive number between "+r.lineWidthDims[0]+" and "+r.lineWidthDims[1],t.commandStr),e},function(e,t,n){return xt.optional(function(){e.assert(t,"typeof "+n+'==="number"&&'+n+">="+r.lineWidthDims[0]+"&&"+n+"<="+r.lineWidthDims[1],"invalid line width")}),n});case Bi:return o(function(e){return xt.commandParameter(e,gf,f,t.commandStr),gf[e]},function(e,t,n){return xt.optional(function(){e.assert(t,n+'==="cw"||'+n+'==="ccw"',"invalid frontFace, must be one of cw,ccw")}),t.def(n+'==="cw"?'+ef+":"+tf)});case Pi:return o(function(e){return xt.command(he(e)&&4===e.length,"color.mask must be length 4 array",t.commandStr),e.map(function(e){return!!e})},function(e,t,n){return xt.optional(function(){e.assert(t,e.shared.isArrayLike+"("+n+")&&"+n+".length===4","invalid color.mask")}),$(4,function(e){return"!!"+n+"["+e+"]"})});case Gi:return o(function(e){xt.command("object"==typeof e&&e,f,t.commandStr);var n="value"in e?e.value:1,r=!!e.invert;return xt.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){xt.optional(function(){e.assert(t,n+"&&typeof "+n+'==="object"',"invalid sample.coverage")});var r=t.def('"value" in ',n,"?+",n,".value:1"),a=t.def("!!",n,".invert");return[r,a]})}}),i}function A(e,t){var n=e.static,r=e.dynamic,a={};return Object.keys(n).forEach(function(e){var r,i=n[e];if("number"==typeof i||"boolean"==typeof i)r=He(function(){return i});else if("function"==typeof i){var o=i._reglType;"texture2d"===o||"textureCube"===o?r=He(function(e){return e.link(i)}):"framebuffer"===o||"framebufferCube"===o?(xt.command(i.color.length>0,'missing color attachment for framebuffer sent to uniform "'+e+'"',t.commandStr),r=He(function(e){return e.link(i.color[0])})):xt.commandRaise('invalid data for uniform "'+e+'"',t.commandStr)}else he(i)?r=He(function(t){var n=t.global.def("[",$(i.length,function(n){return xt.command("number"==typeof i[n]||"boolean"==typeof i[n],"invalid uniform "+e,t.commandStr),i[n]}),"]");return n}):xt.commandRaise('invalid or missing data for uniform "'+e+'"',t.commandStr);r.value=i,a[e]=r}),Object.keys(r).forEach(function(e){var t=r[e];a[e]=Qe(t,function(e,n){return e.invoke(n,t)})}),a}function E(e,n){var r=e.static,i=e.dynamic,o={};return Object.keys(r).forEach(function(e){var i=r[e],f=t.id(e),u=new Y;if(Ue(i))u.state=yi,u.buffer=a.getBuffer(a.create(i,yo,!1,!0)),u.type=0;else{var s=a.getBuffer(i);if(s)u.state=yi,u.buffer=s,u.type=0;else if(xt.command("object"==typeof i&&i,"invalid data for attribute "+e,n.commandStr),i.constant){var c=i.constant;u.buffer="null",u.state=xi,"number"==typeof c?u.x=c:(xt.command(he(c)&&c.length>0&&c.length<=4,"invalid constant for attribute "+e,n.commandStr),bi.forEach(function(e,t){t<c.length&&(u[e]=c[t])}))}else{s=Ue(i.buffer)?a.getBuffer(a.create(i.buffer,yo,!1,!0)):a.getBuffer(i.buffer),xt.command(!!s,'missing buffer for attribute "'+e+'"',n.commandStr);var l=0|i.offset;xt.command(l>=0,'invalid offset for attribute "'+e+'"',n.commandStr);var m=0|i.stride;xt.command(m>=0&&m<256,'invalid stride for attribute "'+e+'", must be integer betweeen [0, 255]',n.commandStr);var d=0|i.size;xt.command(!("size"in i)||d>0&&d<=4,'invalid size for attribute "'+e+'", must be 1,2,3,4',n.commandStr);var p=!!i.normalized,h=0;"type"in i&&(xt.commandParameter(i.type,xn,"invalid type for attribute "+e,n.commandStr),h=xn[i.type]);var v=0|i.divisor;"divisor"in i&&(xt.command(0===v||K,'cannot specify divisor for attribute "'+e+'", instancing not supported',n.commandStr),xt.command(v>=0,'invalid divisor for attribute "'+e+'"',n.commandStr)),xt.optional(function(){var t=n.commandStr,r=["buffer","offset","divisor","normalized","type","size","stride"];Object.keys(i).forEach(function(n){xt.command(r.indexOf(n)>=0,'unknown parameter "'+n+'" for attribute pointer "'+e+'" (valid parameters are '+r+")",t)})}),u.buffer=s,u.state=yi,u.size=d,u.normalized=p,u.type=h||s.dtype,u.offset=l,u.stride=m,u.divisor=v}}o[e]=He(function(e,t){var n=e.attribCache;if(f in n)return n[f];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[f]=r,r})}),Object.keys(i).forEach(function(e){function t(t,r){function a(e){r(s[e],"=",i,".",e,"|0;")}var i=t.invoke(r,n),o=t.shared,f=o.isBufferArgs,u=o.buffer;xt.optional(function(){t.assert(r,i+"&&(typeof "+i+'==="object"||typeof '+i+'==="function")&&('+f+"("+i+")||"+u+".getBuffer("+i+")||"+u+".getBuffer("+i+".buffer)||"+f+"("+i+'.buffer)||("constant" in '+i+"&&(typeof "+i+'.constant==="number"||'+o.isArrayLike+"("+i+".constant))))",'invalid dynamic attribute "'+e+'"')});var s={isStream:r.def(!1)},c=new Y;c.state=yi,Object.keys(c).forEach(function(e){s[e]=r.def(""+c[e])});var l=s.buffer,m=s.type;return r("if(",f,"(",i,")){",s.isStream,"=true;",l,"=",u,".createStream(",yo,",",i,");",m,"=",l,".dtype;","}else{",l,"=",u,".getBuffer(",i,");","if(",l,"){",m,"=",l,".dtype;",'}else if("constant" in ',i,"){",s.state,"=",xi,";","if(typeof "+i+'.constant === "number"){',s[bi[0]],"=",i,".constant;",bi.slice(1).map(function(e){return s[e]}).join("="),"=0;","}else{",bi.map(function(e,t){return s[e]+"="+i+".constant.length>="+t+"?"+i+".constant["+t+"]:0;"}).join(""),"}}else{","if(",f,"(",i,".buffer)){",l,"=",u,".createStream(",yo,",",i,".buffer);","}else{",l,"=",u,".getBuffer(",i,".buffer);","}",m,'="type" in ',i,"?",o.glTypes,"[",i,".type]:",l,".dtype;",s.normalized,"=!!",i,".normalized;"),a("size"),a("offset"),a("stride"),a("divisor"),r("}}"),r.exit("if(",s.isStream,"){",u,".destroyStream(",l,");","}"),s}var n=i[e];o[e]=Qe(n,t)}),o}function D(e){var t=e.static,n=e.dynamic,r={};return Object.keys(t).forEach(function(e){var n=t[e];r[e]=He(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]=Qe(t,function(e,n){return e.invoke(n,t)})}),r}function T(e,t,n,r,a){function i(e){var t=s[e];t&&(l[e]=t)}var o=e.static,f=e.dynamic;xt.optional(function(){function e(e){Object.keys(e).forEach(function(e){xt.command(t.indexOf(e)>=0,'unknown parameter "'+e+'"',a.commandStr)})}var t=[eo,to,no,ro,ao,oo,io,fo,Zi].concat(te);e(o),e(f)});var u=x(e,a),s=w(e,u,a),c=S(e,a),l=_(e,a),m=k(e,a);i(Ji),i(h(Ki));var d=Object.keys(l).length>0,p={framebuffer:u,draw:c,shader:m,state:l,dirty:d};return p.profile=y(e,a),p.uniforms=A(n,a),p.attributes=E(t,a),p.context=D(r,a),p}function j(e,t,n){var r=e.shared,a=r.context,i=e.scope();Object.keys(n).forEach(function(r){t.save(a,"."+r);var o=n[r];i(a,".",r,"=",o.append(e,t),";")}),t(i)}function C(e,t,n,r){var a,i=e.shared,o=i.gl,f=i.framebuffer;J&&(a=t.def(i.extensions,".webgl_draw_buffers"));var u,s=e.constants,c=s.drawBuffer,l=s.backBuffer;u=n?n.append(e,t):t.def(f,".next"),r||t("if(",u,"!==",f,".cur){"),t("if(",u,"){",o,".bindFramebuffer(",lf,",",u,".framebuffer);"),J&&t(a,".drawBuffersWEBGL(",c,"[",u,".colorAttachments.length]);"),t("}else{",o,".bindFramebuffer(",lf,",null);"),J&&t(a,".drawBuffersWEBGL(",l,");"),t("}",f,".cur=",u,";"),r||t("}")}function O(e,t,n){var r=e.shared,a=r.gl,i=e.current,o=e.next,f=r.current,u=r.next,s=e.cond(f,".dirty");te.forEach(function(t){var r=h(t);if(!(r in n.state)){var c,l;if(r in o){c=o[r],l=i[r];var m=$(Z[r].length,function(e){return s.def(c,"[",e,"]")});s(e.cond(m.map(function(e,t){return e+"!=="+l+"["+t+"]"}).join("||")).then(a,".",re[r],"(",m,");",m.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";"))}else{c=s.def(u,".",r);var d=e.cond(c,"!==",f,".",r);s(d),r in ne?d(e.cond(c).then(a,".enable(",ne[r],");").else(a,".disable(",ne[r],");"),f,".",r,"=",c,";"):d(a,".",re[r],"(",c,");",f,".",r,"=",c,";")}}}),0===Object.keys(n.state).length&&s(f,".dirty=false;"),t(s)}function z(e,t,n,r){var a=e.shared,i=e.current,o=a.current,f=a.gl;qe(Object.keys(n)).forEach(function(a){var u=n[a];if(!r||r(u)){var s=u.append(e,t);if(ne[a]){var c=ne[a];Ge(u)?s?t(f,".enable(",c,");"):t(f,".disable(",c,");"):t(e.cond(s).then(f,".enable(",c,");").else(f,".disable(",c,");")),t(o,".",a,"=",s,";")}else if(he(s)){var l=i[a];t(f,".",re[a],"(",s,");",s.map(function(e,t){return l+"["+t+"]="+e}).join(";"),";")}else t(f,".",re[a],"(",s,");",o,".",a,"=",s,";")}})}function F(e,t){K&&(e.instancing=t.def(e.shared.extensions,".angle_instanced_arrays"))}function M(e,t,n,r,a){function i(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function o(e){s=t.def(),e(s,"=",i(),";"),"string"==typeof a?e(p,".count+=",a,";"):e(p,".count++;"),d&&(r?(c=t.def(),e(c,"=",v,".getNumPendingQueries();")):e(v,".beginQuery(",p,");"))}function f(e){e(p,".cpuTime+=",i(),"-",s,";"),d&&(r?e(v,".pushScopeStats(",c,",",v,".getNumPendingQueries(),",p,");"):e(v,".endQuery();"))}function u(e){var n=t.def(h,".profile");t(h,".profile=",e,";"),t.exit(h,".profile=",n,";")}var s,c,l,m=e.shared,p=e.stats,h=m.current,v=m.timer,b=n.profile;if(b){if(Ge(b))return void(b.enable?(o(t),f(t.exit),u("true")):u("false"));l=b.append(e,t),u(l)}else l=t.def(h,".profile");var g=e.block();o(g),t("if(",l,"){",g,"}");var y=e.block();f(y),t.exit("if(",l,"){",y,"}")}function P(e,t,n,r,a){function i(e){switch(e){case Po:case Ro:case Wo:return 2;case Io:case No:case Go:return 3;case Lo:case Uo:case Ho:return 4;default:return 1}}function o(n,r,a){function i(){t("if(!",c,".buffer){",u,".enableVertexAttribArray(",s,");}");var n,i=a.type;
if(n=a.size?t.def(a.size,"||",r):r,t("if(",c,".type!==",i,"||",c,".size!==",n,"||",p.map(function(e){return c+"."+e+"!=="+a[e]}).join("||"),"){",u,".bindBuffer(",yo,",",m,".buffer);",u,".vertexAttribPointer(",[s,n,i,a.normalized,a.stride,a.offset],");",c,".type=",i,";",c,".size=",n,";",p.map(function(e){return c+"."+e+"="+a[e]+";"}).join(""),"}"),K){var o=a.divisor;t("if(",c,".divisor!==",o,"){",e.instancing,".vertexAttribDivisorANGLE(",[s,o],");",c,".divisor=",o,";}")}}function o(){t("if(",c,".buffer){",u,".disableVertexAttribArray(",s,");","}if(",bi.map(function(e,t){return c+"."+e+"!=="+d[t]}).join("||"),"){",u,".vertexAttrib4f(",s,",",d,");",bi.map(function(e,t){return c+"."+e+"="+d[t]+";"}).join(""),"}")}var u=f.gl,s=t.def(n,".location"),c=t.def(f.attributes,"[",s,"]"),l=a.state,m=a.buffer,d=[a.x,a.y,a.z,a.w],p=["buffer","normalized","offset","stride"];l===yi?i():l===xi?o():(t("if(",l,"===",yi,"){"),i(),t("}else{"),o(),t("}"))}var f=e.shared;r.forEach(function(r){var f,u=r.name,s=n.attributes[u];if(s){if(!a(s))return;f=s.append(e,t)}else{if(!a(yf))return;var c=e.scopeAttrib(u);xt.optional(function(){e.assert(t,c+".state","missing attribute "+u)}),f={},Object.keys(new Y).forEach(function(e){f[e]=t.def(c,".",e)})}o(e.link(r),i(r.info.type),f)})}function I(e,n,r,a,i){for(var o,f=e.shared,u=f.gl,s=0;s<a.length;++s){var c,l=a[s],m=l.name,d=l.info.type,p=r.uniforms[m],h=e.link(l),v=h+".location";if(p){if(!i(p))continue;if(Ge(p)){var b=p.value;if(xt.command(null!==b&&"undefined"!=typeof b,'missing uniform "'+m+'"',e.commandStr),d===Xo||d===$o){xt.command("function"==typeof b&&(d===Xo&&("texture2d"===b._reglType||"framebuffer"===b._reglType)||d===$o&&("textureCube"===b._reglType||"framebufferCube"===b._reglType)),"invalid texture for uniform "+m,e.commandStr);var g=e.link(b._texture||b.color[0]._texture);n(u,".uniform1i(",v,",",g+".bind());"),n.exit(g,".unbind();")}else if(d===Qo||d===Vo||d===Yo){xt.optional(function(){xt.command(he(b),"invalid matrix for uniform "+m,e.commandStr),xt.command(d===Qo&&4===b.length||d===Vo&&9===b.length||d===Yo&&16===b.length,"invalid length for matrix uniform "+m,e.commandStr)});var y=e.global.def("new Float32Array(["+Array.prototype.slice.call(b)+"])"),x=2;d===Vo?x=3:d===Yo&&(x=4),n(u,".uniformMatrix",x,"fv(",v,",false,",y,");")}else{switch(d){case Mo:xt.commandType(b,"number","uniform "+m,e.commandStr),o="1f";break;case Po:xt.command(he(b)&&2===b.length,"uniform "+m,e.commandStr),o="2f";break;case Io:xt.command(he(b)&&3===b.length,"uniform "+m,e.commandStr),o="3f";break;case Lo:xt.command(he(b)&&4===b.length,"uniform "+m,e.commandStr),o="4f";break;case qo:xt.commandType(b,"boolean","uniform "+m,e.commandStr),o="1i";break;case Bo:xt.commandType(b,"number","uniform "+m,e.commandStr),o="1i";break;case Wo:xt.command(he(b)&&2===b.length,"uniform "+m,e.commandStr),o="2i";break;case Ro:xt.command(he(b)&&2===b.length,"uniform "+m,e.commandStr),o="2i";break;case Go:xt.command(he(b)&&3===b.length,"uniform "+m,e.commandStr),o="3i";break;case No:xt.command(he(b)&&3===b.length,"uniform "+m,e.commandStr),o="3i";break;case Ho:xt.command(he(b)&&4===b.length,"uniform "+m,e.commandStr),o="4i";break;case Uo:xt.command(he(b)&&4===b.length,"uniform "+m,e.commandStr),o="4i"}n(u,".uniform",o,"(",v,",",he(b)?Array.prototype.slice.call(b):b,");")}continue}c=p.append(e,n)}else{if(!i(yf))continue;c=n.def(f.uniforms,"[",t.id(m),"]")}d===Xo?n("if(",c,"&&",c,'._reglType==="framebuffer"){',c,"=",c,".color[0];","}"):d===$o&&n("if(",c,"&&",c,'._reglType==="framebufferCube"){',c,"=",c,".color[0];","}"),xt.optional(function(){function t(t,r){e.assert(n,t,'bad data or missing for uniform "'+m+'". '+r)}function r(e){t("typeof "+c+'==="'+e+'"',"invalid type, expected "+e)}function a(n,r){t(f.isArrayLike+"("+c+")&&"+c+".length==="+n,"invalid vector, should have length "+n,e.commandStr)}function i(n){t("typeof "+c+'==="function"&&'+c+'._reglType==="texture'+(n===So?"2d":"Cube")+'"',"invalid texture type",e.commandStr)}switch(d){case Bo:r("number");break;case Ro:a(2,"number");break;case No:a(3,"number");break;case Uo:a(4,"number");break;case Mo:r("number");break;case Po:a(2,"number");break;case Io:a(3,"number");break;case Lo:a(4,"number");break;case qo:r("boolean");break;case Wo:a(2,"boolean");break;case Go:a(3,"boolean");break;case Ho:a(4,"boolean");break;case Qo:a(4,"number");break;case Vo:a(9,"number");break;case Yo:a(16,"number");break;case Xo:i(So);break;case $o:i(_o)}});var w=1;switch(d){case Xo:case $o:var k=n.def(c,"._texture");n(u,".uniform1i(",v,",",k,".bind());"),n.exit(k,".unbind();");continue;case Bo:case qo:o="1i";break;case Ro:case Wo:o="2i",w=2;break;case No:case Go:o="3i",w=3;break;case Uo:case Ho:o="4i",w=4;break;case Mo:o="1f";break;case Po:o="2f",w=2;break;case Io:o="3f",w=3;break;case Lo:o="4f",w=4;break;case Qo:o="Matrix2fv";break;case Vo:o="Matrix3fv";break;case Yo:o="Matrix4fv"}if(n(u,".uniform",o,"(",v,","),"M"===o.charAt(0)){var S=Math.pow(d-Qo+2,2),_=e.global.def("new Float32Array(",S,")");n("false,(Array.isArray(",c,")||",c," instanceof Float32Array)?",c,":(",$(S,function(e){return _+"["+e+"]="+c+"["+e+"]"}),",",_,")")}else n(w>1?$(w,function(e){return c+"["+e+"]"}):c);n(");")}}function L(e,t,n,r){function a(){var a,i=m.elements,o=t;return i?((i.contextDep&&r.contextDynamic||i.propDep)&&(o=n),a=i.append(e,o)):a=o.def(l,".",ro),a&&o("if("+a+")"+c+".bindBuffer("+xo+","+a+".buffer.buffer);"),a}function i(){var a,i=m.count,o=t;return i?((i.contextDep&&r.contextDynamic||i.propDep)&&(o=n),a=i.append(e,o),xt.optional(function(){i.MISSING&&e.assert(t,"false","missing vertex count"),i.DYNAMIC&&e.assert(o,a+">=0","missing vertex count")})):(a=o.def(l,".",io),xt.optional(function(){e.assert(o,a+">=0","missing vertex count")})),a}function o(a){var i=m[a];return i?i.contextDep&&r.contextDynamic||i.propDep?i.append(e,n):i.append(e,t):t.def(l,".",a)}function f(){function e(){n(g,".drawElementsInstancedANGLE(",[p,v,y,h+"<<(("+y+"-"+gi+")>>1)",b],");")}function t(){n(g,".drawArraysInstancedANGLE(",[p,h,v,b],");")}d?x?e():(n("if(",d,"){"),e(),n("}else{"),t(),n("}")):t()}function u(){function e(){n(c+".drawElements("+[p,v,y,h+"<<(("+y+"-"+gi+")>>1)"]+");")}function t(){n(c+".drawArrays("+[p,h,v]+");")}d?x?e():(n("if(",d,"){"),e(),n("}else{"),t(),n("}")):t()}var s=e.shared,c=s.gl,l=s.draw,m=r.draw,d=a(),p=o(ao),h=o(oo),v=i();if("number"==typeof v){if(0===v)return}else n("if(",v,"){"),n.exit("}");var b,g;K&&(b=o(fo),g=e.instancing);var y=d+".type",x=m.elements&&Ge(m.elements);K&&("number"!=typeof b||b>=0)?"string"==typeof b?(n("if(",b,">0){"),f(),n("}else if(",b,"<0){"),u(),n("}")):f():u()}function B(e,t,n,r,a){var i=g(),o=i.proc("body",a);return xt.optional(function(){i.commandStr=t.commandStr,i.command=i.link(t.commandStr)}),K&&(i.instancing=o.def(i.shared.extensions,".angle_instanced_arrays")),e(i,o,n,r),i.compile().body}function R(e,t,n,r){F(e,t),P(e,t,n,r.attributes,function(){return!0}),I(e,t,n,r.uniforms,function(){return!0}),L(e,t,t,n)}function N(e,t){var n=e.proc("draw",1);F(e,n),j(e,n,t.context),C(e,n,t.framebuffer),O(e,n,t),z(e,n,t.state),M(e,n,t,!1,!0);var r=t.shader.progVar.append(e,n);if(n(e.shared.gl,".useProgram(",r,".program);"),t.shader.program)R(e,n,t,t.shader.program);else{var a=e.global.def("{}"),i=n.def(r,".id"),o=n.def(a,"[",i,"]");n(e.cond(o).then(o,".call(this,a0);").else(o,"=",a,"[",i,"]=",e.link(function(n){return B(R,e,t,n,1)}),"(",r,");",o,".call(this,a0);"))}Object.keys(t.state).length>0&&n(e.shared.current,".dirty=true;")}function U(e,t,n,r){function a(){return!0}e.batchId="a1",F(e,t),P(e,t,n,r.attributes,a),I(e,t,n,r.uniforms,a),L(e,t,t,n)}function q(e,t,n,r){function a(e){return e.contextDep&&o||e.propDep}function i(e){return!a(e)}F(e,t);var o=n.contextDep,f=t.def(),u="a0",s="a1",c=t.def();e.shared.props=c,e.batchId=f;var l=e.scope(),m=e.scope();if(t(l.entry,"for(",f,"=0;",f,"<",s,";++",f,"){",c,"=",u,"[",f,"];",m,"}",l.exit),n.needsContext&&j(e,m,n.context),n.needsFramebuffer&&C(e,m,n.framebuffer),z(e,m,n.state,a),n.profile&&a(n.profile)&&M(e,m,n,!1,!0),r)P(e,l,n,r.attributes,i),P(e,m,n,r.attributes,a),I(e,l,n,r.uniforms,i),I(e,m,n,r.uniforms,a),L(e,l,m,n);else{var d=e.global.def("{}"),p=n.shader.progVar.append(e,m),h=m.def(p,".id"),v=m.def(d,"[",h,"]");m(e.shared.gl,".useProgram(",p,".program);","if(!",v,"){",v,"=",d,"[",h,"]=",e.link(function(t){return B(U,e,n,t,2)}),"(",p,");}",v,".call(this,a0[",f,"],",f,");")}}function W(e,t){function n(e){return e.contextDep&&a||e.propDep}var r=e.proc("batch",2);e.batchId="0",F(e,r);var a=!1,i=!0;Object.keys(t.context).forEach(function(e){a=a||t.context[e].propDep}),a||(j(e,r,t.context),i=!1);var o=t.framebuffer,f=!1;o?(o.propDep?a=f=!0:o.contextDep&&a&&(f=!0),f||C(e,r,o)):C(e,r,null),t.state.viewport&&t.state.viewport.propDep&&(a=!0),O(e,r,t),z(e,r,t.state,function(e){return!n(e)}),t.profile&&n(t.profile)||M(e,r,t,!1,"a1"),t.contextDep=a,t.needsContext=i,t.needsFramebuffer=f;var u=t.shader.progVar;if(u.contextDep&&a||u.propDep)q(e,r,t,null);else{var s=u.append(e,r);if(r(e.shared.gl,".useProgram(",s,".program);"),t.shader.program)q(e,r,t,t.shader.program);else{var c=e.global.def("{}"),l=r.def(s,".id"),m=r.def(c,"[",l,"]");r(e.cond(m).then(m,".call(this,a0,a1);").else(m,"=",c,"[",l,"]=",e.link(function(n){return B(q,e,t,n,2)}),"(",s,");",m,".call(this,a0,a1);"))}}Object.keys(t.state).length>0&&r(e.shared.current,".dirty=true;")}function G(e,n){function r(t){var r=n.shader[t];r&&a.set(i.shader,"."+t,r.append(e,a))}var a=e.proc("scope",3);e.batchId="a2";var i=e.shared,o=i.current;j(e,a,n.context),n.framebuffer&&n.framebuffer.append(e,a),qe(Object.keys(n.state)).forEach(function(t){var r=n.state[t],o=r.append(e,a);he(o)?o.forEach(function(n,r){a.set(e.next[t],"["+r+"]",n)}):a.set(i.next,"."+t,o)}),M(e,a,n,!0,!0),[ro,oo,io,fo,ao].forEach(function(t){var r=n.draw[t];r&&a.set(i.draw,"."+t,""+r.append(e,a))}),Object.keys(n.uniforms).forEach(function(r){a.set(i.uniforms,"["+t.id(r)+"]",n.uniforms[r].append(e,a))}),Object.keys(n.attributes).forEach(function(t){var r=n.attributes[t].append(e,a),i=e.scopeAttrib(t);Object.keys(new Y).forEach(function(e){a.set(i,"."+e,r[e])})}),r(to),r(no),Object.keys(n.state).length>0&&(a(o,".dirty=true;"),a.exit(o,".dirty=true;")),a("a1(",e.shared.context,",a0,",e.batchId,");")}function H(e){if("object"==typeof e&&!he(e)){for(var t=Object.keys(e),n=0;n<t.length;++n)if(St.isDynamic(e[t[n]]))return!0;return!1}}function Q(e,t,n){function r(e,t){o.forEach(function(n){var r=a[n];if(St.isDynamic(r)){var i=e.invoke(t,r);t(c,".",n,"=",i,";")}})}var a=t.static[n];if(a&&H(a)){var i=e.global,o=Object.keys(a),f=!1,u=!1,s=!1,c=e.global.def("{}");o.forEach(function(t){var n=a[t];if(St.isDynamic(n)){"function"==typeof n&&(n=a[t]=St.unbox(n));var r=Qe(n,null);f=f||r.thisDep,s=s||r.propDep,u=u||r.contextDep}else{switch(i(c,".",t,"="),typeof n){case"number":i(n);break;case"string":i('"',n,'"');break;case"object":Array.isArray(n)&&i("[",n.join(),"]");break;default:i(e.link(n))}i(";")}}),t.dynamic[n]=new St.DynamicVariable(Ai,{thisDep:f,contextDep:u,propDep:s,ref:c,append:r}),delete t.static[n]}}function V(e,t,n,r,a){var i=g();i.stats=i.link(a),Object.keys(t.static).forEach(function(e){Q(i,t,e)}),go.forEach(function(t){Q(i,e,t)});var o=T(e,t,n,r,i);return N(i,o),G(i,o),W(i,o),i.compile()}var Y=s.Record,X={add:32774,subtract:32778,"reverse subtract":32779};n.ext_blend_minmax&&(X.min=nf,X.max=rf);var K=n.angle_instanced_arrays,J=n.webgl_draw_buffers,Z={dirty:!0,profile:p.profile},ee={},te=[],ne={},re={};v(Ei,Do),v(Di,Eo),b(Ti,"blendColor",[0,0,0,0]),b(ji,"blendEquationSeparate",[sf,sf]),b(Ci,"blendFuncSeparate",[uf,ff,uf,ff]),v(Oi,jo,!0),b(zi,"depthFunc",cf),b(Fi,"depthRange",[0,1]),b(Mi,"depthMask",!0),b(Pi,Pi,[!0,!0,!0,!0]),v(Ii,Ao),b(Li,"cullFace",Zo),b(Bi,Bi,tf),b(Ri,Ri,1),v(Ni,Oo),b(Ui,"polygonOffset",[0,0]),v(qi,zo),v(Wi,Fo),b(Gi,"sampleCoverage",[1,!1]),v(Hi,To),b(Qi,"stencilMask",-1),b(Vi,"stencilFunc",[af,0,-1]),b(Yi,"stencilOpSeparate",[Jo,of,of,of]),b(Xi,"stencilOpSeparate",[Zo,of,of,of]),v($i,Co),b(Ki,"scissor",[0,0,e.drawingBufferWidth,e.drawingBufferHeight]),b(Ji,Ji,[0,0,e.drawingBufferWidth,e.drawingBufferHeight]);var ae={gl:e,context:m,strings:t,next:ee,current:Z,draw:l,elements:i,buffer:a,shader:c,attributes:s.state,uniforms:u,framebuffer:f,extensions:n,timer:d,isBufferArgs:Ue},ie={primTypes:Ln,compareFuncs:hf,blendFuncs:df,blendEquations:X,stencilOps:vf,glTypes:xn,orientationType:gf};xt.optional(function(){ae.isArrayLike=he}),J&&(ie.backBuffer=[Zo],ie.drawBuffer=$(r.maxDrawbuffers,function(e){return 0===e?[0]:$(e,function(e){return mf+e})}));var oe=0;return{next:ee,current:Z,procs:function(){var t=g(),n=t.proc("poll"),a=t.proc("refresh"),i=t.block();n(i),a(i);var o=t.shared,f=o.gl,u=o.next,s=o.current;i(s,".dirty=false;"),C(t,n),C(t,a,null,!0);var c,l=e.getExtension("angle_instanced_arrays");l&&(c=t.link(l));for(var m=0;m<r.maxAttributes;++m){var d=a.def(o.attributes,"[",m,"]"),p=t.cond(d,".buffer");p.then(f,".enableVertexAttribArray(",m,");",f,".bindBuffer(",yo,",",d,".buffer.buffer);",f,".vertexAttribPointer(",m,",",d,".size,",d,".type,",d,".normalized,",d,".stride,",d,".offset);").else(f,".disableVertexAttribArray(",m,");",f,".vertexAttrib4f(",m,",",d,".x,",d,".y,",d,".z,",d,".w);",d,".buffer=null;"),a(p),l&&a(c,".vertexAttribDivisorANGLE(",m,",",d,".divisor);")}return Object.keys(ne).forEach(function(e){var r=ne[e],o=i.def(u,".",e),c=t.block();c("if(",o,"){",f,".enable(",r,")}else{",f,".disable(",r,")}",s,".",e,"=",o,";"),a(c),n("if(",o,"!==",s,".",e,"){",c,"}")}),Object.keys(re).forEach(function(e){var r,o,c=re[e],l=Z[e],m=t.block();if(m(f,".",c,"("),he(l)){var d=l.length;r=t.global.def(u,".",e),o=t.global.def(s,".",e),m($(d,function(e){return r+"["+e+"]"}),");",$(d,function(e){return o+"["+e+"]="+r+"["+e+"];"}).join("")),n("if(",$(d,function(e){return r+"["+e+"]!=="+o+"["+e+"]"}).join("||"),"){",m,"}")}else r=i.def(u,".",e),o=i.def(s,".",e),m(r,");",s,".",e,"=",r,";"),n("if(",r,"!==",o,"){",m,"}");a(m)}),t.compile()}(),compile:V}}function Ye(){return{bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0}}function Xe(e,t){for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1}function $e(e){function t(){if(0===G.length)return _&&_.update(),void($=null);$=_t.next(t),m();for(var e=G.length-1;e>=0;--e){var n=G[e];n&&n(T,null,0)}b.flush(),_&&_.update()}function n(){!$&&G.length>0&&($=_t.next(t))}function r(){$&&(_t.cancel(t),$=null)}function a(e){e.preventDefault(),y=!0,r(),H.forEach(function(e){e()})}function i(e){b.getError(),y=!1,x.restore(),P.restore(),z.restore(),I.restore(),L.restore(),B.restore(),_&&_.restore(),R.procs.refresh(),n(),Q.forEach(function(e){e()})}function o(){G.length=0,r(),W&&(W.removeEventListener(Tf,a),W.removeEventListener(jf,i)),P.clear(),B.clear(),L.clear(),I.clear(),F.clear(),z.clear(),_&&_.clear(),X.forEach(function(e){e()})}function f(e){function t(e){function t(e){if(e in n){var t=n[e];delete n[e],Object.keys(t).forEach(function(r){n[e+"."+r]=t[r]})}}var n=Ze({},e);return delete n.uniforms,delete n.attributes,delete n.context,"stencil"in n&&n.stencil.op&&(n.stencil.opBack=n.stencil.opFront=n.stencil.op,delete n.stencil.op),t("blend"),t("depth"),t("cull"),t("stencil"),t("polygonOffset"),t("scissor"),t("sample"),n}function n(e){var t={},n={};return Object.keys(e).forEach(function(r){var a=e[r];St.isDynamic(a)?n[r]=St.unbox(a,r):t[r]=a}),{dynamic:n,static:t}}function r(e){for(;p.length<e;)p.push(null);return p}function a(e,t){var n;if(y&&xt.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<e;++n)d.call(this,null,t,n);return}if(Array.isArray(e)){for(n=0;n<e.length;++n)d.call(this,e[n],t,n);return}return d.call(this,e,t,0)}if("number"==typeof e){if(e>0)return m.call(this,r(0|e),0|e)}else{if(!Array.isArray(e))return l.call(this,e);if(e.length)return m.call(this,e,e.length)}}xt(!!e,"invalid args to regl({...})"),xt.type(e,"object","invalid args to regl({...})");var i=n(e.context||{}),o=n(e.uniforms||{}),f=n(e.attributes||{}),u=n(t(e)),s={gpuTime:0,cpuTime:0,count:0},c=R.compile(u,f,o,i,s),l=c.draw,m=c.batch,d=c.scope,p=[];return Ze(a,{stats:s})}function u(e,t){var n=0;R.procs.poll();var r=t.color;r&&(b.clearColor(+r[0]||0,+r[1]||0,+r[2]||0,+r[3]||0),n|=_f),"depth"in t&&(b.clearDepth(+t.depth),n|=Af),"stencil"in t&&(b.clearStencil(0|t.stencil),n|=Ef),xt(!!n,"called regl.clear with no buffer specified"),b.clear(n)}function s(e){if(xt("object"==typeof e&&e,"regl.clear() takes an object as input"),"framebuffer"in e)if(e.framebuffer&&"framebufferCube"===e.framebuffer_reglType)for(var t=0;t<6;++t)K(Ze({framebuffer:e.framebuffer.faces[t]},e),u);else K(e,u);else u(null,e)}function c(e){function t(){function t(){var e=Xe(G,t);G[e]=G[G.length-1],G.length-=1,G.length<=0&&r()}var n=Xe(G,e);xt(n>=0,"cannot cancel a frame twice"),G[n]=t}return xt.type(e,"function","regl.frame() callback must be a function"),G.push(e),n(),{cancel:t}}function l(){var e=q.viewport,t=q.scissor_box;e[0]=e[1]=t[0]=t[1]=0,T.viewportWidth=T.framebufferWidth=T.drawingBufferWidth=e[2]=t[2]=b.drawingBufferWidth,T.viewportHeight=T.framebufferHeight=T.drawingBufferHeight=e[3]=t[3]=b.drawingBufferHeight}function m(){T.tick+=1,T.time=p(),l(),R.procs.poll()}function d(){l(),R.procs.refresh(),_&&_.update()}function p(){return(At()-A)/1e3}function h(e,t){xt.type(t,"function","listener callback must be a function");var n;switch(e){case"frame":return c(t);case"lost":n=H;break;case"restore":n=Q;break;case"destroy":n=X;break;default:xt.raise("invalid event, must be one of frame,lost,restore,destroy")}return n.push(t),{cancel:function(){for(var e=0;e<n.length;++e)if(n[e]===t)return n[e]=n[n.length-1],void n.pop()}}}var v=V(e);if(!v)return null;var b=v.gl,g=b.getContextAttributes(),y=b.isContextLost(),x=Y(b,v);if(!x)return null;var w=N(),k=Ye(),S=x.extensions,_=Sf(b,S),A=At(),E=b.drawingBufferWidth,D=b.drawingBufferHeight,T={tick:0,time:0,viewportWidth:E,viewportHeight:D,framebufferWidth:E,framebufferHeight:D,drawingBufferWidth:E,drawingBufferHeight:D,pixelRatio:v.pixelRatio},j={},C={elements:null,primitive:4,count:-1,offset:0,instances:-1},O=Zt(b,S),z=me(b,k,v),F=de(b,S,z,k),M=Pe(b,S,O,z,w),P=Ie(b,w,k,v),I=Oe(b,S,O,function(){R.procs.poll()},T,k,v),L=Ta(b,S,O,k,v),B=Fe(b,S,O,I,L,k),R=Ve(b,w,S,O,z,F,I,B,j,M,P,C,T,_,v),U=Le(b,B,R.procs.poll,T,g,S),q=R.next,W=b.canvas,G=[],H=[],Q=[],X=[v.onDestroy],$=null;W&&(W.addEventListener(Tf,a,!1),W.addEventListener(jf,i,!1));var K=B.setFBO=f({framebuffer:St.define.call(null,Cf,"framebuffer")});d();var J=Ze(f,{clear:s,prop:St.define.bind(null,Cf),context:St.define.bind(null,Of),this:St.define.bind(null,zf),draw:f({}),buffer:function(e){return z.create(e,Df,!1,!1)},elements:function(e){return F.create(e,!1)},texture:I.create2D,cube:I.createCube,renderbuffer:L.create,framebuffer:B.create,framebufferCube:B.createCube,attributes:g,frame:c,on:h,limits:O,hasExtension:function(e){return O.extensions.indexOf(e.toLowerCase())>=0},read:U,destroy:o,_gl:b,_refresh:d,poll:function(){m(),_&&_.update()},now:p,stats:k});return v.onDone(null,J),J}var Ke={"[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},Je=function(e){return Object.prototype.toString.call(e)in Ke},Ze=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;++r)e[n[r]]=t[n[r]];return e},et=["gl","canvas","container","attributes","pixelRatio","extensions","optionalExtensions","profile","onDone"],tt=33071,nt=9728,rt=9984,at=9985,it=9986,ot=9987,ft=5120,ut=5121,st=5122,ct=5123,lt=5124,mt=5125,dt=5126,pt=32819,ht=32820,vt=33635,bt=34042,gt=36193,yt={};yt[ft]=yt[ut]=1,yt[st]=yt[ct]=yt[gt]=yt[vt]=yt[pt]=yt[ht]=2,yt[lt]=yt[mt]=yt[dt]=yt[bt]=4;var xt=Ze(n,{optional:D,raise:t,commandRaise:S,command:_,parameter:a,commandParameter:A,constructor:s,type:o,commandType:E,isTypedArray:i,nni:f,oneOf:u,shaderError:y,linkError:x,callSite:h,saveCommandRef:w,saveDrawInfo:k,framebufferFormat:T,guessCommand:p,texture2D:O,textureCube:z}),wt=0,kt=0,St={DynamicVariable:F,define:L,isDynamic:B,unbox:R,accessor:I},_t={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},At="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},Et=3408,Dt=3410,Tt=3411,jt=3412,Ct=3413,Ot=3414,zt=3415,Ft=33901,Mt=33902,Pt=3379,It=3386,Lt=34921,Bt=36347,Rt=36348,Nt=35661,Ut=35660,qt=34930,Wt=36349,Gt=34076,Ht=34024,Qt=7936,Vt=7937,Yt=7938,Xt=35724,$t=34047,Kt=36063,Jt=34852,Zt=function(e,t){var n=1;t.ext_texture_filter_anisotropic&&(n=e.getParameter($t));var r=1,a=1;return t.webgl_draw_buffers&&(r=e.getParameter(Jt),a=e.getParameter(Kt)),{colorBits:[e.getParameter(Dt),e.getParameter(Tt),e.getParameter(jt),e.getParameter(Ct)],depthBits:e.getParameter(Ot),stencilBits:e.getParameter(zt),subpixelBits:e.getParameter(Et),extensions:Object.keys(t).filter(function(e){return!!t[e]}),maxAnisotropic:n,maxDrawbuffers:r,maxColorAttachments:a,pointSizeDims:e.getParameter(Ft),lineWidthDims:e.getParameter(Mt),maxViewportDims:e.getParameter(It),maxCombinedTextureUnits:e.getParameter(Nt),maxCubeMapSize:e.getParameter(Gt),maxRenderbufferSize:e.getParameter(Ht),maxTextureUnits:e.getParameter(qt),maxTextureSize:e.getParameter(Pt),maxAttributes:e.getParameter(Lt),maxVertexUniforms:e.getParameter(Bt),maxVertexTextureUnits:e.getParameter(Ut),maxVaryingVectors:e.getParameter(Rt),maxFragmentUniforms:e.getParameter(Wt),glsl:e.getParameter(Xt),renderer:e.getParameter(Vt),vendor:e.getParameter(Qt),version:e.getParameter(Yt)}},en=function(e){return Object.keys(e).map(function(t){return e[t]})},tn=5120,nn=5121,rn=5122,an=5123,on=5124,fn=5125,un=5126,sn=$(8,function(){return[]}),cn={alloc:Z,free:ee,allocType:te,freeType:ne},ln={shape:ue,flatten:fe},mn=5120,dn=5122,pn=5124,hn=5121,vn=5123,bn=5125,gn=5126,yn=5126,xn={int8:mn,int16:dn,int32:pn,uint8:hn,uint16:vn,uint32:bn,float:gn,float32:yn},wn=35048,kn=35040,Sn={dynamic:wn,stream:kn,static:35044},_n=ln.flatten,An=ln.shape,En=35044,Dn=35040,Tn=5121,jn=5126,Cn=[];Cn[5120]=1,Cn[5122]=2,Cn[5124]=4,Cn[5121]=1,Cn[5123]=2,Cn[5125]=4,Cn[5126]=4;var On=0,zn=0,Fn=1,Mn=1,Pn=4,In=4,Ln={points:On,point:zn,lines:Fn,line:Mn,triangles:Pn,triangle:In,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},Bn=0,Rn=1,Nn=4,Un=5120,qn=5121,Wn=5122,Gn=5123,Hn=5124,Qn=5125,Vn=34963,Yn=35040,Xn=35044,$n=new Float32Array(1),Kn=new Uint32Array($n.buffer),Jn=5123,Zn=34467,er=3553,tr=34067,nr=34069,rr=6408,ar=6406,ir=6407,or=6409,fr=6410,ur=32854,sr=32855,cr=36194,lr=32819,mr=32820,dr=33635,pr=34042,hr=6402,vr=34041,br=35904,gr=35906,yr=36193,xr=33776,wr=33777,kr=33778,Sr=33779,_r=35986,Ar=35987,Er=34798,Dr=35840,Tr=35841,jr=35842,Cr=35843,Or=36196,zr=5121,Fr=5123,Mr=5125,Pr=5126,Ir=10242,Lr=10243,Br=10497,Rr=33071,Nr=33648,Ur=10240,qr=10241,Wr=9728,Gr=9729,Hr=9984,Qr=9985,Vr=9986,Yr=9987,Xr=33170,$r=4352,Kr=4353,Jr=4354,Zr=34046,ea=3317,ta=37440,na=37441,ra=37443,aa=37444,ia=33984,oa=[Hr,Vr,Qr,Yr],fa=[0,or,fr,ir,rr],ua={};ua[or]=ua[ar]=ua[hr]=1,ua[vr]=ua[fr]=2,ua[ir]=ua[br]=3,ua[rr]=ua[gr]=4;var sa=ve("HTMLCanvasElement"),ca=ve("CanvasRenderingContext2D"),la=ve("HTMLImageElement"),ma=ve("HTMLVideoElement"),da=Object.keys(Ke).concat([sa,ca,la,ma]),pa=[];pa[zr]=1,pa[Pr]=4,pa[yr]=2,pa[Fr]=2,pa[Mr]=4;var ha=[];ha[ur]=2,ha[sr]=2,ha[cr]=2,ha[vr]=4,ha[xr]=.5,ha[wr]=.5,ha[kr]=1,ha[Sr]=1,ha[_r]=.5,ha[Ar]=1,ha[Er]=1,ha[Dr]=.5,ha[Tr]=.25,ha[jr]=.5,ha[Cr]=.25,ha[Or]=.5;var va=36161,ba=32854,ga=32855,ya=36194,xa=33189,wa=36168,ka=34041,Sa=35907,_a=34836,Aa=34842,Ea=34843,Da=[];Da[ba]=2,Da[ga]=2,Da[ya]=2,Da[xa]=2,Da[wa]=1,Da[ka]=4,Da[Sa]=4,Da[_a]=16,Da[Aa]=8,Da[Ea]=6;var Ta=function(e,t,n,r,a){function i(e){this.id=l++,this.refCount=1,this.renderbuffer=e,this.format=ba,this.width=0,this.height=0,a.profile&&(this.stats={size:0})}function o(t){var n=t.renderbuffer;xt(n,"must not double destroy renderbuffer"),e.bindRenderbuffer(va,null),e.deleteRenderbuffer(n),t.renderbuffer=null,t.refCount=0,delete m[t.id],r.renderbufferCount--}function f(t,o){function f(t,r){var i=0,o=0,u=ba;if("object"==typeof t&&t){var m=t;if("shape"in m){var d=m.shape;xt(Array.isArray(d)&&d.length>=2,"invalid renderbuffer shape"),i=0|d[0],o=0|d[1]}else"radius"in m&&(i=o=0|m.radius),"width"in m&&(i=0|m.width),"height"in m&&(o=0|m.height);"format"in m&&(xt.parameter(m.format,s,"invalid renderbuffer format"),u=s[m.format])}else"number"==typeof t?(i=0|t,o="number"==typeof r?0|r:i):t?xt.raise("invalid arguments to renderbuffer constructor"):i=o=1;if(xt(i>0&&o>0&&i<=n.maxRenderbufferSize&&o<=n.maxRenderbufferSize,"invalid renderbuffer size"),i!==l.width||o!==l.height||u!==l.format)return f.width=l.width=i,f.height=l.height=o,l.format=u,e.bindRenderbuffer(va,l.renderbuffer),e.renderbufferStorage(va,u,i,o),a.profile&&(l.stats.size=ze(l.format,l.width,l.height)),f.format=c[l.format],f}function u(t,r){var i=0|t,o=0|r||i;return i===l.width&&o===l.height?f:(xt(i>0&&o>0&&i<=n.maxRenderbufferSize&&o<=n.maxRenderbufferSize,"invalid renderbuffer size"),f.width=l.width=i,f.height=l.height=o,e.bindRenderbuffer(va,l.renderbuffer),e.renderbufferStorage(va,l.format,i,o),a.profile&&(l.stats.size=ze(l.format,l.width,l.height)),f)}var l=new i(e.createRenderbuffer());return m[l.id]=l,r.renderbufferCount++,f(t,o),f.resize=u,f._reglType="renderbuffer",f._renderbuffer=l,a.profile&&(f.stats=l.stats),f.destroy=function(){l.decRef()},f}function u(){en(m).forEach(function(t){t.renderbuffer=e.createRenderbuffer(),e.bindRenderbuffer(va,t.renderbuffer),e.renderbufferStorage(va,t.format,t.width,t.height)}),e.bindRenderbuffer(va,null)}var s={rgba4:ba,rgb565:ya,"rgb5 a1":ga,depth:xa,stencil:wa,"depth stencil":ka};t.ext_srgb&&(s.srgba=Sa),t.ext_color_buffer_half_float&&(s.rgba16f=Aa,s.rgb16f=Ea),t.webgl_color_buffer_float&&(s.rgba32f=_a);var c=[];Object.keys(s).forEach(function(e){var t=s[e];c[t]=e});var l=0,m={};return i.prototype.decRef=function(){--this.refCount<=0&&o(this)},a.profile&&(r.getTotalRenderbufferSize=function(){var e=0;return Object.keys(m).forEach(function(t){e+=m[t].stats.size}),e}),{create:f,clear:function(){en(m).forEach(o)},restore:u}},ja=36160,Ca=36161,Oa=3553,za=34069,Fa=36064,Ma=36096,Pa=36128,Ia=33306,La=36053,Ba=36054,Ra=36055,Na=36057,Ua=36061,qa=36193,Wa=5121,Ga=5126,Ha=6408,Qa=6402,Va=[Ha],Ya=[];Ya[Ha]=4;var Xa=[];Xa[Wa]=1,Xa[Ga]=4,Xa[qa]=2;var $a=32854,Ka=32855,Ja=36194,Za=33189,ei=36168,ti=34041,ni=35907,ri=34836,ai=34842,ii=34843,oi=[$a,Ka,Ja,ni,ai,ii,ri],fi={};fi[La]="complete",fi[Ba]="incomplete attachment",fi[Na]="incomplete dimensions",fi[Ra]="incomplete, missing attachment",fi[Ua]="unsupported";var ui=5126,si=35632,ci=35633,li=35718,mi=35721,di=6408,pi=5121,hi=3333,vi=5126,bi="xyzw".split(""),gi=5121,yi=1,xi=2,wi=0,ki=1,Si=2,_i=3,Ai=4,Ei="dither",Di="blend.enable",Ti="blend.color",ji="blend.equation",Ci="blend.func",Oi="depth.enable",zi="depth.func",Fi="depth.range",Mi="depth.mask",Pi="colorMask",Ii="cull.enable",Li="cull.face",Bi="frontFace",Ri="lineWidth",Ni="polygonOffset.enable",Ui="polygonOffset.offset",qi="sample.alpha",Wi="sample.enable",Gi="sample.coverage",Hi="stencil.enable",Qi="stencil.mask",Vi="stencil.func",Yi="stencil.opFront",Xi="stencil.opBack",$i="scissor.enable",Ki="scissor.box",Ji="viewport",Zi="profile",eo="framebuffer",to="vert",no="frag",ro="elements",ao="primitive",io="count",oo="offset",fo="instances",uo="Width",so="Height",co=eo+uo,lo=eo+so,mo=Ji+uo,po=Ji+so,ho="drawingBuffer",vo=ho+uo,bo=ho+so,go=[Ci,ji,Vi,Yi,Xi,Gi,Ji,Ki,Ui],yo=34962,xo=34963,wo=35632,ko=35633,So=3553,_o=34067,Ao=2884,Eo=3042,Do=3024,To=2960,jo=2929,Co=3089,Oo=32823,zo=32926,Fo=32928,Mo=5126,Po=35664,Io=35665,Lo=35666,Bo=5124,Ro=35667,No=35668,Uo=35669,qo=35670,Wo=35671,Go=35672,Ho=35673,Qo=35674,Vo=35675,Yo=35676,Xo=35678,$o=35680,Ko=4,Jo=1028,Zo=1029,ef=2304,tf=2305,nf=32775,rf=32776,af=519,of=7680,ff=0,uf=1,sf=32774,cf=513,lf=36160,mf=36064,df={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},pf=["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"],hf={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},vf={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},bf={frag:wo,vert:ko},gf={cw:ef,ccw:tf},yf=new We(!1,!1,!1,function(){}),xf=34918,wf=34919,kf=35007,Sf=function(e,t){function n(){return m.pop()||l.createQueryEXT()}function r(e){m.push(e)}function a(e){var t=n();l.beginQueryEXT(kf,t),d.push(t),s(d.length-1,d.length,e)}function i(){l.endQueryEXT(kf)}function o(){this.startQueryIndex=-1,this.endQueryIndex=-1,this.sum=0,this.stats=null}function f(){return p.pop()||new o}function u(e){p.push(e)}function s(e,t,n){var r=f();r.startQueryIndex=e,r.endQueryIndex=t,r.sum=0,r.stats=n,h.push(r)}function c(){var e,t,n=d.length;if(0!==n){b.length=Math.max(b.length,n+1),v.length=Math.max(v.length,n+1),v[0]=0,b[0]=0;var a=0;for(e=0,t=0;t<d.length;++t){var i=d[t];l.getQueryObjectEXT(i,wf)?(a+=l.getQueryObjectEXT(i,xf),r(i)):d[e++]=i,v[t+1]=a,b[t+1]=e}for(d.length=e,e=0,t=0;t<h.length;++t){var o=h[t],f=o.startQueryIndex,s=o.endQueryIndex;o.sum+=v[s]-v[f];var c=b[f],m=b[s];m===c?(o.stats.gpuTime+=o.sum/1e6,u(o)):(o.startQueryIndex=c,o.endQueryIndex=m,h[e++]=o)}h.length=e}}var l=t.ext_disjoint_timer_query;if(!l)return null;var m=[],d=[],p=[],h=[],v=[],b=[];return{beginQuery:a,endQuery:i,pushScopeStats:s,update:c,getNumPendingQueries:function(){return d.length},clear:function(){m.push.apply(m,d);for(var e=0;e<m.length;e++)l.deleteQueryEXT(m[e]);d.length=0,m.length=0},restore:function(){d.length=0,m.length=0}}},_f=16384,Af=256,Ef=1024,Df=34962,Tf="webglcontextlost",jf="webglcontextrestored",Cf=1,Of=2,zf=3;return $e})},{}]},{},[3]);