0x77b35947…cc7dsent to0x2758442e…81ae·#25,448,157·view on Etherscan
s);\n\n if (vCap > 0.) {\n if (\n uStrokeCap == STROKE_CAP_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (\n uStrokeCap == STROKE_CAP_SQUARE &&\n HOOK_shouldDiscard(dot(inputs.position - inputs.center, inputs.tangent) > 0.)\n ) {\n discard;\n // Use full area for PROJECT\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n } else if (vJoin > 0.) {\n if (\n uStrokeJoin == STROKE_JOIN_ROUND &&\n HOOK_shouldDiscard(distSquared(inputs.position, inputs.center) > inputs.strokeWeight * inputs.strokeWeight * 0.25)\n ) {\n discard;\n } else if (uStrokeJoin == STROKE_JOIN_BEVEL) {\n vec2 normal = vec2(-inputs.tangent.y, inputs.tangent.x);\n if (HOOK_shouldDiscard(abs(dot(inputs.position - inputs.center, normal)) > vMaxDist)) {\n discard;\n }\n // Use full area for MITER\n } else if (HOOK_shouldDiscard(false)) {\n discard;\n }\n }\n OUT_COLOR = HOOK_getFinalColor(vec4(inputs.color.rgb, 1.) * inputs.color.a);\n HOOK_afterFragment();\n}\n",pointVert:"IN vec3 aPosition;\nIN vec4 aVertexColor;\nuniform float uPointSize;\nuniform bool uUseVertexColor;\nuniform vec4 uMaterialColor;\nOUT float vStrokeWeight;\nOUT vec4 vColor;\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nvoid main() {\n HOOK_beforeVertex();\n vec4 viewModelPosition = vec4(HOOK_getWorldPosition(\n (uModelViewMatrix * vec4(HOOK_getLocalPosition(aPosition), 1.0)).xyz\n ), 1.);\n gl_Position = uProjectionMatrix * viewModelPosition; \n\n float pointSize = HOOK_getPointSize(uPointSize);\n\n\tgl_PointSize = pointSize;\n\tvStrokeWeight = pointSize;\n\n // Choose per-vertex stroke color when available; otherwise use uniform stroke color\n vec4 baseColor = uUseVertexColor ? aVertexColor : uMaterialColor;\n vColor = HOOK_getVertexColor(baseColor);\n HOOK_afterVertex();\n}\n",pointFrag:"precision mediump int;\nuniform vec4 uMaterialColor;\nIN float vStrokeWeight;\nIN vec4 vColor;\n\nvoid main(){\n HOOK_beforeFragment();\n float mask = 0.0;\n\n // make a circular mask using the gl_PointCoord (goes from 0 - 1 on a point)\n // might be able to get a nicer edge on big strokeweights with smoothstep but slightly less performant\n\n mask = step(0.98, length(gl_PointCoord * 2.0 - 1.0));\n\n // if strokeWeight is 1 or less lets just draw a square\n // this prevents weird artifacting from carving circles when our points are really small\n // if strokeWeight is larger than 1, we just use it as is\n\n mask = mix(0.0, mask, clamp(floor(vStrokeWeight - 0.5),0.0,1.0));\n\n // throw away the borders of the mask\n // otherwise we get weird alpha blending issues\n\n if(HOOK_shouldDiscard(mask > 0.98)){\n discard;\n }\n\n // Use the interpolated vertex color (set in vertex shader)\n vec4 baseColor = vColor;\n OUT_COLOR = HOOK_getFinalColor(vec4(baseColor.rgb, 1.) * baseColor.a);\n HOOK_afterFragment();\n}\n",imageLightVert:"precision highp float;\nattribute vec3 aPosition;\nattribute vec3 aNormal;\nattribute vec2 aTexCoord;\n\nvarying vec3 localPos;\nvarying vec3 vWorldNormal;\nvarying vec3 vWorldPosition;\nvarying vec2 vTexCoord;\n\nuniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\nuniform mat3 uNormalMatrix;\n\nvoid main() {\n // Multiply the position by the matrix.\n vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);\n gl_Position = uProjectionMatrix * viewModelPosition; \n \n // orient the normals and pass to the fragment shader\n vWorldNormal = uNormalMatrix * aNormal;\n \n // send the view position to the fragment shader\n vWorldPosition = (uModelViewMatrix * vec4(aPosition, 1.0)).xyz;\n \n localPos = vWorldPosition;\n vTexCoord = aTexCoord;\n}\n\n\n/*\nin the vertex shader we'll compute the world position and world oriented normal of the vertices and pass those to the fragment shader as varyings.\n*/\n",imageLightDiffusedFrag:"precision highp float;\nvarying vec3 localPos;\n\n// the HDR cubemap converted (can be from an equirectangular environment map.)\nuniform sampler2D environmentMap;\nvarying vec2 vTexCoord;\n\nconst float PI = 3.14159265359;\n\nvec2 nTOE( vec3 v ){\n // x = r sin(phi) cos(theta) \n // y = r cos(phi) \n // z = r sin(phi) sin(theta)\n float phi = acos( v.y );\n // if phi is 0, then there are no x, z components\n float theta = 0.0;\n // else \n theta = acos(v.x / sin(phi));\n float sinTheta = v.z / sin(phi);\n if (sinTheta < 0.0) {\n // Turn it into -theta, but in the 0-2PI range\n theta = 2.0 * PI - theta;\n }\n theta = theta / (2.0 * 3.14159);\n phi = phi / 3.14159 ;\n \n vec2 angles = vec2( phi, theta );\n return angles;\n}\n\nfloat random(vec2 p) {\n vec3 p3 = fract(vec3(p.xyx) * .1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n}\n\nvoid main()\n{ \t \n\t// the sample direction equals the hemisphere's orientation\n float phi = vTexCoord.x * 2.0 * PI;\n float theta = vTexCoord.y * PI;\n float x = sin(theta) * cos(phi);\n float y = sin(theta) * sin(phi);\n float z = cos(theta);\n vec3 normal = vec3( x, y, z);\n\n\t// Discretely sampling the hemisphere given the integral's\n // spherical coordinates translates to the following fragment code:\n\tvec3 irradiance = vec3(0.0); \n\tvec3 up\t= vec3(0.0, 1.0, 0.0);\n\tvec3 right = normalize(cross(up, normal));\n\tup = normalize(cross(normal, right));\n\n\t// We specify a fixed sampleDelta delta value to traverse\n // the hemisphere; decreasing or increasing the sample delta\n // will increase or decrease the accuracy respectively.\n\tconst float sampleDelta = 0.100;\n\tfloat nrSamples = 0.0;\n float randomOffset = random(gl_FragCoord.xy) * sampleDelta;\n\tfor(float rawPhi = 0.0; rawPhi < 2.0 * PI; rawPhi += sampleDelta)\n\t{\n float phi = rawPhi + randomOffset;\n for(float rawTheta = 0.0; rawTheta < ( 0.5 ) * PI; rawTheta += sampleDelta)\n {\n float theta = rawTheta + randomOffset;\n // spherical to cartesian (in tangent space) // tangent space to world // add each sample result to irradiance\n float x = sin(theta) * cos(phi);\n float y = sin(theta) * sin(phi);\n float z = cos(theta);\n vec3 tangentSample = vec3( x, y, z);\n \n vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * normal;\n irradiance += (texture2D(environmentMap, nTOE(sampleVec)).xyz) * cos(theta) * sin(theta);\n nrSamples++;\n }\n\t}\n\t// divide by the total number of samples taken, giving us the average sampled irradiance.\n\tirradiance = PI * irradiance * (1.0 / float(nrSamples )) ;\n \n \n\tgl_FragColor = vec4(irradiance, 1.0);\n}",imageLightSpecularFrag:"precision highp float;\r\nvarying vec3 localPos;\r\nvarying vec2 vTexCoord;\r\n\r\n// our texture\r\nuniform sampler2D environmentMap;\r\nuniform float roughness;\r\n\r\nconst float PI = 3.14159265359;\r\n\r\nfloat VanDerCorput(int bits);\r\nvec2 HammersleyNoBitOps(int i, int N);\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness);\r\n\r\n\r\nvec2 nTOE( vec3 v ){\r\n // x = r sin(phi) cos(theta) \r\n // y = r cos(phi) \r\n // z = r sin(phi) sin(theta)\r\n float phi = acos( v.y );\r\n // if phi is 0, then there are no x, z components\r\n float theta = 0.0;\r\n // else \r\n theta = acos(v.x / sin(phi));\r\n float sinTheta = v.z / sin(phi);\r\n if (sinTheta < 0.0) {\r\n // Turn it into -theta, but in the 0-2PI range\r\n theta = 2.0 * PI - theta;\r\n }\r\n theta = theta / (2.0 * 3.14159);\r\n phi = phi / 3.14159 ;\r\n \r\n vec2 angles = vec2( phi, theta );\r\n return angles;\r\n}\r\n\r\n\r\nvoid main(){\r\n const int SAMPLE_COUNT = 400; // 4096\r\n int lowRoughnessLimit = int(pow(2.0,(roughness+0.1)*20.0));\r\n float totalWeight = 0.0;\r\n vec3 prefilteredColor = vec3(0.0);\r\n float phi = vTexCoord.x * 2.0 * PI;\r\n float theta = vTexCoord.y * PI;\r\n float x = sin(theta) * cos(phi);\r\n float y = sin(theta) * sin(phi);\r\n float z = cos(theta);\r\n vec3 N = vec3(x,y,z);\r\n vec3 V = N;\r\n for (int i = 0; i < SAMPLE_COUNT; ++i)\r\n {\r\n // break at smaller sample numbers for low roughness levels\r\n if(i == lowRoughnessLimit)\r\n {\r\n break;\r\n }\r\n vec2 Xi = HammersleyNoBitOps(i, SAMPLE_COUNT);\r\n vec3 H = ImportanceSampleGGX(Xi, N, roughness);\r\n vec3 L = normalize(2.0 * dot(V, H) * H - V);\r\n\r\n float NdotL = max(dot(N, L), 0.0);\r\n if (NdotL > 0.0)\r\n {\r\n prefilteredColor += texture2D(environmentMap, nTOE(L)).xyz * NdotL;\r\n totalWeight += NdotL;\r\n }\r\n }\r\n prefilteredColor = prefilteredColor / totalWeight;\r\n\r\n gl_FragColor = vec4(prefilteredColor, 1.0);\r\n}\r\n\r\nvec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness){\r\n float a = roughness * roughness;\r\n\r\n float phi = 2.0 * PI * Xi.x;\r\n float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y));\r\n float sinTheta = sqrt(1.0 - cosTheta * cosTheta);\r\n // from spherical coordinates to cartesian coordinates\r\n vec3 H;\r\n H.x = cos(phi) * sinTheta;\r\n H.y = sin(phi) * sinTheta;\r\n H.z = cosTheta;\r\n\r\n // from tangent-space vector to world-space sample vector\r\n vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\r\n vec3 tangent = normalize(cross(up, N));\r\n vec3 bitangent = cross(N, tangent);\r\n\r\n vec3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z;\r\n return normalize(sampleVec);\r\n}\r\n\r\n\r\nfloat VanDerCorput(int n, int base)\r\n{\r\n#ifdef WEBGL2\r\n\r\n uint bits = uint(n);\r\n bits = (bits << 16u) | (bits >> 16u);\r\n bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\r\n bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\r\n bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\r\n bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\r\n return float(bits) * 2.3283064365386963e-10; // / 0x100000000\r\n\r\n#else\r\n\r\n float invBase = 1.0 / float(base);\r\n float denom = 1.0;\r\n float result = 0.0;\r\n\r\n\r\n for (int i = 0; i < 32; ++i)\r\n {\r\n if (n > 0)\r\n {\r\n denom = mod(float(n), 2.0);\r\n result += denom * invBase;\r\n invBase = invBase / 2.0;\r\n n = int(float(n) / 2.0);\r\n }\r\n }\r\n\r\n\r\n return result;\r\n\r\n#endif\r\n}\r\n\r\nvec2 HammersleyNoBitOps(int i, int N)\r\n{\r\n return vec2(float(i) / float(N), VanDerCorput(i, 2));\r\n}\r\n"},M=E.sphereMappingFrag;for(x in E)E[x]="#ifdef WEBGL2\n\n#define IN in\n#define OUT out\n\n#ifdef FRAGMENT_SHADER\nout vec4 outColor;\n#define OUT_COLOR outColor\n#endif\n#define TEXTURE texture\n\n#else\n\n#ifdef FRAGMENT_SHADER\n#define IN varying\n#else\n#define IN attribute\n#endif\n#define OUT varying\n#define TEXTURE texture2D\n\n#ifdef FRAGMENT_SHADER\n#define OUT_COLOR gl_FragColor\n#endif\n\n#endif\n"+E[x];_(e={},l.GRAY,"precision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\n\nfloat luma(vec3 color) {\n // weighted grayscale with luminance values\n return dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\n\nvoid main() {\n vec4 tex = texture2D(tex0, vTexCoord);\n float gray = luma(tex.rgb);\n gl_FragColor = vec4(gray, gray, gray, tex.a);\n}\n"),_(e,l.ERODE,"// Reduces the bright areas in an image\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\nuniform vec2 texelSize;\n\nfloat luma(vec3 color) {\n // weighted grayscale with luminance values\n // weights 77, 151, 28 taken from src/image/filters.js\n return dot(color, vec3(0.300781, 0.589844, 0.109375));\n}\n\nvoid main() {\n vec4 color = texture2D(tex0, vTexCoord);\n float lum = luma(color.rgb);\n\n // set current color as the darkest neighbor color\n\n vec4 neighbors[4];\n neighbors[0] = texture2D(tex0, vTexCoord + vec2( texelSize.x, 0.0));\n neighbors[1] = texture2D(tex0, vTexCoord + vec2(-texelSize.x, 0.0));\n neighbors[2] = texture2D(tex0, vTexCoord + vec2(0.0, texelSize.y));\n neighbors[3] = texture2D(tex0, vTexCoord + vec2(0.0, -texelSize.y));\n\n for (int i = 0; i < 4; i++) {\n vec4 neighborColor = neighbors[i];\n float neighborLum = luma(neighborColor.rgb);\n\n if (neighborLum < lum) {\n color = neighborColor;\n lum = neighborLum;\n }\n }\n\n gl_FragColor = color;\n}\n"),_(e,l.DILATE,"// Increase the bright areas in an image\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\nuniform vec2 texelSize;\n\nfloat luma(vec3 color) {\n // weighted grayscale with luminance values\n // weights 77, 151, 28 taken from src/image/filters.js\n return dot(color, vec3(0.300781, 0.589844, 0.109375));\n}\n\nvoid main() {\n vec4 color = texture2D(tex0, vTexCoord);\n float lum = luma(color.rgb);\n\n // set current color as the brightest neighbor color\n\n vec4 neighbors[4];\n neighbors[0] = texture2D(tex0, vTexCoord + vec2( texelSize.x, 0.0));\n neighbors[1] = texture2D(tex0, vTexCoord + vec2(-texelSize.x, 0.0));\n neighbors[2] = texture2D(tex0, vTexCoord + vec2(0.0, texelSize.y));\n neighbors[3] = texture2D(tex0, vTexCoord + vec2(0.0, -texelSize.y));\n\n for (int i = 0; i < 4; i++) {\n vec4 neighborColor = neighbors[i];\n float neighborLum = luma(neighborColor.rgb);\n\n if (neighborLum > lum) {\n color = neighborColor;\n lum = neighborLum;\n }\n }\n\n gl_FragColor = color;\n}\n"),_(e,l.BLUR,"precision highp float;\n\n// Two-pass blur filter, unweighted kernel.\n// See also a similar blur at Adam Ferriss' repo of shader examples:\n// https://github.com/aferriss/p5jsShaderExamples/blob/gh-pages/4_image-effects/4-9_single-pass-blur/effect.frag\n\n\nuniform sampler2D tex0;\nvarying vec2 vTexCoord;\nuniform vec2 direction;\nuniform vec2 canvasSize;\nuniform float radius;\n\nfloat random(vec2 p) {\n vec3 p3 = fract(vec3(p.xyx) * .1031);\n p3 += dot(p3, p3.yzx + 33.33);\n return fract((p3.x + p3.y) * p3.z);\n}\n\n// This isn't a real Gaussian weight, it's a quadratic weight. It's what the\n// CPU mode's blur uses though, so we also use it here to match.\nfloat quadWeight(float x, float e) {\n return pow(e-abs(x), 2.);\n}\n\nvoid main(){\n vec2 uv = vTexCoord;\n\n // A reasonable maximum number of samples\n const float maxSamples = 64.0;\n\n float numSamples = floor(7. * radius);\n if (fract(numSamples / 2.) == 0.) {\n numSamples++;\n }\n vec4 avg = vec4(0.0);\n float total = 0.0;\n\n // Calculate the spacing to avoid skewing if numSamples > maxSamples\n float spacing = 1.0;\n if (numSamples > maxSamples) {\n spacing = numSamples / maxSamples;\n numSamples = maxSamples;\n }\n\n float randomOffset = (spacing - 1.0) * mix(-0.5, 0.5, random(gl_FragCoord.xy));\n for (float i = 0.0; i < maxSamples; i++) {\n if (i >= numSamples) break;\n\n float sample = i * spacing - (numSamples - 1.0) * 0.5 * spacing + randomOffset;\n vec2 sampleCoord = uv + vec2(sample, sample) / canvasSize * direction;\n float weight = quadWeight(sample, (numSamples - 1.0) * 0.5 * spacing);\n\n avg += weight * texture2D(tex0, sampleCoord);\n total += weight;\n }\n\n avg /= total;\n gl_FragColor = avg;\n}\n"),_(e,l.POSTERIZE,"// Limit color space for a stylized cartoon / poster effect\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\nuniform float filterParameter;\n\nvec3 quantize(vec3 color, float n) {\n // restrict values to N options/bins\n // and floor each channel to nearest value\n //\n // eg. when N = 5, values = 0.0, 0.25, 0.50, 0.75, 1.0\n // then quantize (0.1, 0.7, 0.9) -> (0.0, 0.5, 1.0)\n\n color = color * n;\n color = floor(color);\n color = color / (n - 1.0);\n return color;\n}\n\nvoid main() {\n vec4 color = texture2D(tex0, vTexCoord);\n\n vec3 restrictedColor = quantize(color.rgb / color.a, filterParameter);\n\n gl_FragColor = vec4(restrictedColor.rgb * color.a, color.a);\n}\n"),_(e,l.OPAQUE,"// Set alpha channel to entirely opaque\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\n\nvoid main() {\n vec4 color = texture2D(tex0, vTexCoord);\n gl_FragColor = vec4(color.rgb / color.a, 1.0);\n}\n"),_(e,l.INVERT,"// Set each pixel to inverse value\n// Note that original INVERT does not change the opacity, so this follows suit\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\n\nvoid main() {\nvec4 color = texture2D(tex0, vTexCoord);\nvec3 origColor = color.rgb / color.a;\nvec3 invertedColor = vec3(1.0) - origColor;\ngl_FragColor = vec4(invertedColor * color.a, color.a);\n}\n"),_(e,l.THRESHOLD,"// Convert pixels to either white or black, \n// depending on if their luma is above or below filterParameter\n\nprecision highp float;\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D tex0;\nuniform float filterParameter;\n\nfloat luma(vec3 color) {\n // weighted grayscale with luminance values\n return dot(color, vec3(0.2126, 0.7152, 0.0722));\n}\n\nvoid main() {\n vec4 color = texture2D(tex0, vTexCoord);\n float gray = luma(color.rgb / color.a);\n // floor() used to match src/image/filters.js\n float threshold = floor(filterParameter * 255.0) / 255.0;\n float blackOrWhite = step(threshold, gray);\n gl_FragColor = vec4(vec3(blackOrWhite) * color.a, color.a);\n}\n");var k=e;function O(e,t,r,o,n,s,i,a,l,u){var c=t.getParameter(t.FRAMEBUFFER_BINDING),r=(t.bindFramebuffer(t.FRAMEBUFFER,r),a===t.RGBA?4:3),d=s*i*r,h=l===t.UNSIGNED_BYTE?Uint8Array:Float32Array;if(e instanceof h&&e.length===d||(e=new h(d)),t.readPixels(o,u?u-n-i:n,s,i,a,l,e),t.bindFramebuffer(t.FRAMEBUFFER,c),u)for(var f=Math.floor(i/2),p=new h(s*r),m=0;m<f;m++){var y=m*s*4,g=(i-m-1)*s*4;p.set(e.subarray(y,y+4*s)),e.copyWithin(y,g,g+4*s),e.set(p,g)}return e}function C(e,t,r,o,n,s,i){var a=e.getParameter(e.FRAMEBUFFER_BINDING),t=(e.bindFramebuffer(e.FRAMEBUFFER,t),n===e.RGBA?4:3),t=new(s===e.UNSIGNED_BYTE?Uint8Array:Float32Array)(t);return e.readPixels(r,i?i-o-1:o,1,1,n,s,t),e.bindFramebuffer(e.FRAMEBUFFER,a),Array.from(t)}g.default.prototype.setAttributes=function(e,t){if(void 0===this._glAttributes)console.log("You are trying to use setAttributes on a p5.Graphics object that does not use a WEBGL renderer.");else{var r=!0;if(void 0!==t?(null===this._glAttributes&&(this._glAttributes={}),this._glAttributes[e]!==t&&(this._glAttributes[e]=t,r=!1)):e instanceof Object&&this._glAttributes!==e&&(this._glAttributes=e,r=!1),this._renderer.isP3D&&!r){if(!this._setupDone)for(var o in this._renderer.retainedMode.geometry)if(this._renderer.retainedMode.geometry.hasOwnProperty(o))return void g.default._friendlyError("Sorry, Could not set the attributes, you need to call setAttributes() before calling the other drawing methods in setup()");this.push(),this._renderer._resetContext(),this.pop(),this._renderer._curCamera&&(this._renderer._curCamera._renderer=this._renderer)}}},g.default.RendererGL=function(e){var t=s;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&m(t,e);var r,n=y(s);function s(e,t,r,o){if(this instanceof s)return(e=n.call(this,e,t,r))._setAttributeDefaults(t),e._initContext(),e.isP3D=!0,e.geometryBuilder=void 0,e.GL=e.drawingContext,e._pInst._setProperty("drawingContext",e.drawingContext),e._isErasing=!1,e._clipDepths=[],e._isClipApplied=!1,e._stencilTestOn=!1,e._enableLighting=!1,e.ambientLightColors=[],e.mixedAmbientLight=[],e.mixedSpecularColor=[],e.specularColors=[1,1,1],e.directionalLightDirections=[],e.directionalLightDiffuseColors=[],e.directionalLightSpecularColors=[],e.pointLightPositions=[],e.pointLightDiffuseColors=[],e.pointLightSpecularColors=[],e.spotLightPositions=[],e.spotLightDirections=[],e.spotLightDiffuseColors=[],e.spotLightSpecularColors=[],e.spotLightAngle=[],e.spotLightConc=[],e.activeImageLight=null,e.diffusedTextures=new Map,e.specularTextures=new Map,e.drawMode=l.FILL,e.curFillColor=e._cachedFillStyle=[1,1,1,1],e.curAmbientColor=e._cachedFillStyle=[1,1,1,1],e.curSpecularColor=e._cachedFillStyle=[0,0,0,0],e.curEmissiveColor=e._cachedFillStyle=[0,0,0,0],e.curStrokeColor=e._cachedStrokeStyle=[0,0,0,1],e.curBlendMode=l.BLEND,e.preEraseBlend=void 0,e._cachedBlendMode=void 0,e.webglVersion===l.WEBGL2?e.blendExt=e.GL:e.blendExt=e.GL.getExtension("EXT_blend_minmax"),e._isBlending=!1,e._hasSetAmbient=!1,e._useSpecularMaterial=!1,e._useEmissiveMaterial=!1,e._useNormalMaterial=!1,e._useShininess=1,e._useMetalness=0,e._useLineColor=!1,e._useVertexColor=!1,e.registerEnabled=new Set,e._tint=[255,255,255,255],e.constantAttenuation=1,e.linearAttenuation=0,e.quadraticAttenuation=0,e.uModelMatrix=new g.default.Matrix,e.uViewMatrix=new g.default.Matrix,e.uMVMatrix=new g.default.Matrix,e.uPMatrix=new g.default.Matrix,e.uNMatrix=new g.default.Matrix("mat3"),e.curMatrix=new g.default.Matrix("mat3"),e._currentNormal=new g.default.Vector(0,0,1),e._curCamera=new g.default.Camera(v(e)),e._curCamera._computeCameraDefaultSettings(),e._curCamera._setDefaultCamera(),e.filterCamera=new g.default.Camera(v(e)),e.filterCamera._computeCameraDefaultSettings(),e.filterCamera._setDefaultCamera(),e.prevTouches=[],e.zoomVelocity=0,e.rotateVelocity=new g.default.Vector(0,0),e.moveVelocity=new g.default.Vector(0,0),e.executeZoom=!1,e.executeRotateAndMove=!1,e.specularShader=void 0,e.sphereMapping=void 0,e.diffusedShader=void 0,e._defaultLightShader=void 0,e._defaultImmediateModeShader=void 0,e._defaultNormalShader=void 0,e._defaultColorShader=void 0,e._defaultPointShader=void 0,e.userFillShader=void 0,e.userStrokeShader=void 0,e.userPointShader=void 0,e.retainedMode={geometry:{},buffers:{stroke:[new g.default.RenderBuffer(4,"lineVertexColors","lineColorBuffer","aVertexColor",v(e)),new g.default.RenderBuffer(3,"lineVertices","lineVerticesBuffer","aPosition",v(e)),new g.default.RenderBuffer(3,"lineTangentsIn","lineTangentsInBuffer","aTangentIn",v(e)),new g.default.RenderBuffer(3,"lineTangentsOut","lineTangentsOutBuffer","aTangentOut",v(e)),new g.default.RenderBuffer(1,"lineSides","lineSidesBuffer","aSide",v(e))],fill:[new g.default.RenderBuffer(3,"vertices","vertexBuffer","aPosition",v(e),e._vToNArray),new g.default.RenderBuffer(3,"vertexNormals","normalBuffer","aNormal",v(e),e._vToNArray),new g.default.RenderBuffer(4,"vertexColors","colorBuffer","aVertexColor",v(e)),new g.default.RenderBuffer(3,"vertexAmbients","ambientBuffer","aAmbientColor",v(e)),new g.default.RenderBuffer(2,"uvs","uvBuffer","aTexCoord",v(e),e._flatten)],text:[new g.default.RenderBuffer(3,"vertices","vertexBuffer","aPosition",v(e),e._vToNArray),new g.default.RenderBuffer(2,"uvs","uvBuffer","aTexCoord",v(e),e._flatten)]}},e.immediateMode={geometry:new g.default.Geometry,shapeMode:l.TRIANGLE_FAN,contourIndices:[],_bezierVertex:[],_quadraticVertex:[],_curveVertex:[],buffers:{fill:[new g.default.RenderBuffer(3,"vertices","vertexBuffer","aPosition",v(e),e._vToNArray),new g.default.RenderBuffer(3,"vertexNormals","normalBuffer","aNormal",v(e),e._vToNArray),new g.default.RenderBuffer(4,"vertexColors","colorBuffer","aVertexColor",v(e)),new g.default.RenderBuffer(3,"vertexAmbients","ambientBuffer","aAmbientColor",v(e)),new g.default.RenderBuffer(2,"uvs","uvBuffer","aTexCoord",v(e),e._flatten)],stroke:[new g.default.RenderBuffer(4,"lineVertexColors","lineColorBuffer","aVertexColor",v(e)),new g.default.RenderBuffer(3,"lineVertices","lineVerticesBuffer","aPosition",v(e)),new g.default.RenderBuffer(3,"lineTangentsIn","lineTangentsInBuffer","aTangentIn",v(e)),new g.default.RenderBuffer(3,"lineTangentsOut","lineTangentsOutBuffer","aTangentOut",v(e)),new g.default.RenderBuffer(1,"lineSides","lineSidesBuffer","aSide",v(e))],point:[new g.default.RenderBuffer(3,"vertices","pointVertexBuffer","aPosition",v(e),e._vToNArray),new g.default.RenderBuffer(4,"vertexStrokeColors","pointColorBuffer","aVertexColor",v(e))]}},e.curStrokeWeight=1,e.pointSize=e.curStrokeWeight,e.curStrokeCap=l.ROUND,e.curStrokeJoin=l.ROUND,e.textures=new Map,e.framebuffers=new Set,e.activeFramebuffers=[],e.filterShader=void 0,e.filterLayer=void 0,e.filterLayerTemp=void 0,e.defaultFilterShaders={},e.textureMode=l.IMAGE,e.textureWrapX=l.CLAMP,e.textureWrapY=l.CLAMP,e._tex=null,e._curveTightness=6,e._lookUpTableBezier=[],e._lookUpTableQuadratic=[],e._lutBezierDetail=0,e._lutQuadraticDetail=0,e.isProcessingVertices=!1,e._tessy=e._initTessy(),e.fontInfos={},e._curShader=void 0,e._pInst instanceof g.default.Graphics||!e._pInst||"function"!=typeof e._pInst.registerMethod||e._pInst.registerMethod("remove",e.remove.bind(v(e))),e;throw new TypeError("Cannot call a class as a function")}return t=s,(e=[{key:"remove",value:function(){var e=[this._defaultLightShader,this._defaultImmediateModeShader,this._defaultNormalShader,this._defaultColorShader,this._defaultPointShader,this.userFillShader,this.userStrokeShader,this.userPointShader,this._curShader,this.specularShader,this.diffusedShader,this.filterShader];if(this.defaultFilterShaders)for(var t in this.defaultFilterShaders)e.push(this.defaultFilterShaders[t]);for(var r=0,o=e;r<o.length;r++){var n=o[r];n&&"function"==typeof n.remove&&n.remove()}if(this.textures){var s=!0,i=!1,a=void 0;try{for(var l,u=this.textures.values()[Symbol.iterator]();!(s=(l=u.next()).done);s=!0){var c=l.value;c&&"function"==typeof c.remove&&c.remove()}}catch(e){i=!0,a=e}finally{try{s||null==u.return||u.return()}finally{if(i)throw a}}this.textures.clear()}if(this.framebuffers){var d=!0,i=!1,a=void 0;try{for(var h,f=this.framebuffers[Symbol.iterator]();!(d=(h=f.next()).done);d=!0){var p=h.value;p&&"function"==typeof p.remove&&p.remove()}}catch(e){i=!0,a=e}finally{try{d||null==f.return||f.return()}finally{if(i)throw a}}this.framebuffers.clear()}if(this.diffusedTextures){var m=!0,i=!1,a=void 0;try{for(var y,g=this.diffusedTextures.values()[Symbol.iterator]();!(m=(y=g.next()).done);m=!0){var v=y.value;v&&"function"==typeof v.remove&&v.remove()}}catch(e){i=!0,a=e}finally{try{m||null==g.return||g.return()}finally{if(i)throw a}}this.diffusedTextures.clear()}if(this.specularTextures){var b=!0,i=!1,a=void 0;try{for(var _,j=this.specularTextures.values()[Symbol.iterator]();!(b=(_=j.next()).done);b=!0){var x=_.value;x&&"function"==typeof x.remove&&x.remove()}}catch(e){i=!0,a=e}finally{try{b||null==j.return||j.return()}finally{if(i)throw a}}this.specularTextures.clear()}if(this._emptyTexture&&("function"==typeof this._emptyTexture.remove&&this._emptyTexture.remove(),this._emptyTexture=null),this.retainedMode&&this.retainedMode.geometry)for(var w in this.retainedMode.geometry)this._freeBuffers(w);this.filterLayer&&"function"==typeof this.filterLayer.remove&&(this.filterLayer.remove(),this.filterLayer=void 0),this.filterLayerTemp&&"function"==typeof this.filterLayerTemp.remove&&(this.filterLayerTemp.remove(),this.filterLayerTemp=void 0),this._defaultLightShader=void 0,this._defaultImmediateModeShader=void 0,this._defaultNormalShader=void 0,this._defaultColorShader=void 0,this._defaultPointShader=void 0,this.userFillShader=void 0,this.userStrokeShader=void 0,this.userPointShader=void 0,this._curShader=void 0,this.specularShader=void 0,this.diffusedShader=void 0,this.filterShader=void 0,this.defaultFilterShaders={}}},{key:"beginGeometry",value:function(){if(this.geometryBuilder)throw new Error("It looks like `beginGeometry()` is being called while another p5.Geometry is already being build.");this.geometryBuilder=new a.default(this)}},{key:"endGeometry",value:function(){var e;if(this.geometryBuilder)return e=this.geometryBuilder.finish(),this.geometryBuilder=void 0,e;throw new Error("Make sure you call beginGeometry() before endGeometry()!")}},{key:"buildGeometry",value:function(e){return this.beginGeometry(),e(),this.endGeometry()}},{key:"_setAttributeDefaults",value:function(e){var t={alpha:!0,depth:!0,stencil:!0,antialias:navigator.userAgent.toLowerCase().includes("safari"),premultipliedAlpha:!0,preserveDrawingBuffer:!0,perPixelLighting:!0,version:2};null===e._glAttributes?e._glAttributes=t:e._glAttributes=Object.assign(t,e._glAttributes)}},{key:"_initContext",value:function(){if(1!==this._pInst._glAttributes.version&&(this.drawingContext=this.canvas.getContext("webgl2",this._pInst._glAttributes)),this.webglVersion=this.drawingContext?l.WEBGL2:l.WEBGL,this._pInst._setProperty("webglVersion",this.webglVersion),this.drawingContext||(this.drawingContext=this.canvas.getContext("webgl",this._pInst._glAttributes)||this.canvas.getContext("experimental-webgl",this._pInst._glAttributes)),null===this.drawingContext)throw new Error("Error creating webgl context");var e=this.drawingContext;e.enable(e.DEPTH_TEST),e.depthFunc(e.LEQUAL),e.viewport(0,0,e.drawingBufferWidth,e.drawingBufferHeight),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this._viewport=this.drawingContext.getParameter(this.drawingContext.VIEWPORT)}},{key:"_getParam",value:function(){var e=this.drawingContext;return e.getParameter(e.MAX_TEXTURE_SIZE)}},{key:"_adjustDimensions",value:function(e,t){this._maxTextureSize||(this._maxTextureSize=this._getParam());var r=this._maxTextureSize,r=(g.default.prototype._maxAllowedPixelDimensions,Math.floor(r/this.pixelDensity())),o=Math.min(e,r),r=Math.min(t,r);return o===e&&r===t||console.warn("Warning: The requested width/height exceeds hardware limits. "+"Adjusting dimensions to width: ".concat(o,", height: ").concat(r,".")),{adjustedWidth:o,adjustedHeight:r}}},{key:"_resetContext",value:function(e,t){var r,o=this.width,n=this.height,s=this.canvas.id,i=this._pInst instanceof g.default.Graphics,s=(i?((r=this._pInst).canvas.parentNode.removeChild(r.canvas),r.canvas=document.createElement("canvas"),(r._pInst._userNode||document.body).appendChild(r.canvas),g.default.Element.call(r,r.canvas,r._pInst),r.width=o,r.height=n):((r=this.canvas)&&r.parentNode.removeChild(r),(r=document.createElement("canvas")).id=s,(this._pInst._userNode||document.body).appendChild(r),this._pInst.canvas=r,this.canvas=r),new g.default.RendererGL(this._pInst.canvas,this._pInst,!i));this._pInst._setProperty("_renderer",s),s.resize(o,n),s._applyDefaults(),i||this._pInst._elements.push(s),"function"==typeof t&&setTimeout(function(){t.apply(window._renderer,e)},0)}},{key:"_update",value:function(){this.uModelMatrix.reset(),this.uViewMatrix.set(this._curCamera.cameraMatrix),this.ambientLightColors.length=0,this.specularColors=[1,1,1],this.directionalLightDirections.length=0,this.directionalLightDiffuseColors.length=0,this.directionalLightSpecularColors.length=0,this.pointLightPositions.length=0,this.pointLightDiffuseColors.length=0,this.pointLightSpecularColors.length=0,this.spotLightPositions.length=0,this.spotLightDirections.length=0,this.spotLightDiffuseColors.length=0,this.spotLightSpecularColors.length=0,this.spotLightAngle.length=0,this.spotLightConc.length=0,this._enableLighting=!1,this._tint=[255,255,255,255],this.GL.clearStencil(0),this.GL.clear(this.GL.DEPTH_BUFFER_BIT|this.GL.STENCIL_BUFFER_BIT),this.GL.disable(this.GL.STENCIL_TEST)}},{key:"background",value:function(){var e,t,r=arguments.length<=0?void 0:arguments[0],o=r instanceof g.default.Image||r instanceof g.default.Graphics||"undefined"!=typeof HTMLImageElement&&r instanceof HTMLImageElement||"undefined"!=typeof HTMLVideoElement&&r instanceof HTMLVideoElement||void 0!==g.default.MediaElement&&r instanceof g.default.MediaElement;0<arguments.length&&o?(this._pInst.clear(),this._pInst.push(),this._pInst.resetMatrix(),this._pInst.imageMode(this._pInst.CENTER),this._pInst.image(r,0,0,this._pInst.width,this._pInst.height),this._pInst.pop()):(o=(r=(o=this._pInst).color.apply(o,arguments)).levels[0]/255,e=r.levels[1]/255,t=r.levels[2]/255,r=r.levels[3]/255,this.clear(o,e,t,r))}},{key:"fill",value:function(e,t,r,o){var n=g.default.prototype.color.apply(this._pInst,arguments);this.curFillColor=n._array,this.drawMode=l.FILL,this._useNormalMaterial=!1,this._tex=null}},{key:"stroke",value:function(e,t,r,o){var n=g.default.prototype.color.apply(this._pInst,arguments);this.curStrokeColor=n._array}},{key:"strokeCap",value:function(e){this.curStrokeCap=e}},{key:"strokeJoin",value:function(e){this.curStrokeJoin=e}},{key:"getFilterLayer",value:function(){return this.filterLayer||(this.filterLayer=this._pInst.createFramebuffer()),this.filterLayer}},{key:"getFilterLayerTemp",value:function(){return this.filterLayerTemp||(this.filterLayerTemp=this._pInst.createFramebuffer()),this.filterLayerTemp}},{key:"matchSize",value:function(e,t){e.width===t.width&&e.height===t.height||e.resize(t.width,t.height),e.pixelDensity()!==t.pixelDensity()&&e.pixelDensity(t.pixelDensity())}},{key:"filter",value:function(){var e,t,r=this,o=this.getFilterLayer(),n=void 0,s=void 0,i=("string"==typeof(arguments.length<=0?void 0:arguments[0])?(s=arguments.length<=0?void 0:arguments[0],_(e={},l.BLUR,3),_(e,l.POSTERIZE,4),_(e,l.THRESHOLD,.5),n=s in(e=e)&&void 0===(arguments.length<=1?void 0:arguments[1])?e[s]:arguments.length<=1?void 0:arguments[1],s in this.defaultFilterShaders||(this.defaultFilterShaders[s]=new g.default.Shader(o._renderer,"uniform mat4 uModelViewMatrix;\nuniform mat4 uProjectionMatrix;\n\nattribute vec3 aPosition;\n// texcoords only come from p5 to vertex shader\n// so pass texcoords on to the fragment shader in a varying variable\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n\nvoid main() {\n // transferring texcoords for the frag shader\n vTexCoord = aTexCoord;\n\n // copy position with a fourth coordinate for projection (1.0 is normal)\n vec4 positionVec4 = vec4(aPosition, 1.0);\n\n gl_Position = uProjectionMatrix * uModelViewMatrix * positionVec4;\n}\n",k[s])),this.filterShader=this.defaultFilterShaders[s]):this.filterShader=arguments.length<=0?void 0:arguments[0],this.activeFramebuffer()||this),a=(this.matchSize(o,i),o.draw(function(){return r._pInst.clear()}),[1/(i.width*i.pixelDensity()),1/(i.height*i.pixelDensity())]);s===l.BLUR?(t=this.getFilterLayerTemp(),this.matchSize(t,i),this._pInst.push(),this._pInst.noStroke(),this._pInst.blendMode(l.BLEND),this._pInst.shader(this.filterShader),this.filterShader.setUniform("texelSize",a),this.filterShader.setUniform("canvasSize",[i.width,i.height]),this.filterShader.setUniform("radius",Math.max(1,n)),t.draw(function(){r.filterShader.setUniform("direction",[1,0]),r.filterShader.setUniform("tex0",i),r._pInst.clear(),r._pInst.shader(r.filterShader),r._pInst.noLights(),r._pInst.plane(i.width,i.height)}),o.draw(function(){r.filterShader.setUniform("direction",[0,1]),r.filterShader.setUniform("tex0",t),r._pInst.clear(),r._pInst.shader(r.filterShader),r._pInst.noLights(),r._pInst.plane(i.width,i.height)}),this._pInst.pop()):o.draw(function(){r._pInst.noStroke(),r._pInst.blendMode(l.BLEND),r._pInst.shader(r.filterShader),r.filterShader.setUniform("tex0",i),r.filterShader.setUniform("texelSize",a),r.filterShader.setUniform("canvasSize",[i.width,i.height]),r.filterShader.setUniform("filterParameter",n),r._pInst.noLights(),r._pInst.plane(i.width,i.height)}),this._pInst.push(),this._pInst.noStroke(),this.clear(),this._pInst.push(),this._pInst.imageMode(l.CORNER),this._pInst.blendMode(l.BLEND),i.filterCamera._resize(),this._pInst.setCamera(i.filterCamera),this._pInst.resetMatrix(),this._pInst.image(o,-i.width/2,-i.height/2,i.width,i.height),this._pInst.clearDepth(),this._pInst.pop(),this._pInst.pop()}},{key:"pixelDensity",value:function(e){return e?this._pInst.pixelDensity(e):this._pInst.pixelDensity()}},{key:"blendMode",value:function(e){e===l.DARKEST||e===l.LIGHTEST||e===l.ADD||e===l.BLEND||e===l.SUBTRACT||e===l.SCREEN||e===l.EXCLUSION||e===l.REPLACE||e===l.MULTIPLY||e===l.REMOVE?this.curBlendMode=e:e!==l.BURN&&e!==l.OVERLAY&&e!==l.HARD_LIGHT&&e!==l.SOFT_LIGHT&&e!==l.DODGE||console.warn("BURN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, and DODGE only work for blendMode in 2D mode.")}},{key:"erase",value:function(e,t){this._isErasing||(this.preEraseBlend=this.curBlendMode,this._isErasing=!0,this.blendMode(l.REMOVE),this._cachedFillStyle=this.curFillColor.slice(),this.curFillColor=[1,1,1,e/255],this._cachedStrokeStyle=this.curStrokeColor.slice(),this.curStrokeColor=[1,1,1,t/255])}},{key:"noErase",value:function(){this._isErasing&&(this.curFillColor=this._cachedFillStyle.slice(),this.curStrokeColor=this._cachedStrokeStyle.slice(),this.curBlendMode=this.preEraseBlend,this.blendMode(this.preEraseBlend),this._isErasing=!1,this._applyBlendMode())}},{key:"drawTarget",value:function(){return this.activeFramebuffers[this.activeFramebuffers.length-1]||this}},{key:"beginClip",value:function(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=(p(b(s.prototype),"beginClip",this).call(this,e),this.drawTarget()._isClipApplied=!0,this.GL);e.clearStencil(0),e.clear(e.STENCIL_BUFFER_BIT),e.enable(e.STENCIL_TEST),this._stencilTestOn=!0,e.stencilFunc(e.ALWAYS,1,255),e.stencilOp(e.KEEP,e.KEEP,e.REPLACE),e.disable(e.DEPTH_TEST),this._pInst.push(),this._pInst.resetShader(),this._doFill&&this._pInst.fill(0,0),this._doStroke&&this._pInst.stroke(0,0)}},{key:"endClip",value:function(){this._pInst.pop();var e=this.GL;e.stencilOp(e.KEEP,e.KEEP,e.KEEP),e.stencilFunc(this._clipInvert?e.EQUAL:e.NOTEQUAL,0,255),e.enable(e.DEPTH_TEST),this._clipDepths.push(this._pushPopDepth),p(b(s.prototype),"endClip",this).call(this)}},{key:"_clearClip",value:function(){this.GL.clearStencil(1),this.GL.clear(this.GL.STENCIL_BUFFER_BIT),0<this._clipDepths.length&&this._clipDepths.pop(),this.drawTarget()._isClipApplied=!1}},{key:"strokeWeight",value:function(e){this.curStrokeWeight!==e&&(this.pointSize=e,this.curStrokeWeight=e)}},{key:"_getPixel",value:function(e,t){var r=this.GL;return C(r,null,e,t,r.RGBA,r.UNSIGNED_BYTE,this._pInst.height*this._pInst.pixelDensity())}},{key:"loadPixels",value:function(){var e,t,r=this._pixelsState;!0!==this._pInst._glAttributes.preserveDrawingBuffer?console.log("loadPixels only works in WebGL when preserveDrawingBuffer is true."):(e=this._pInst._pixelDensity,t=this.GL,r._setProperty("pixels",O(r.pixels,t,null,0,0,this.width*e,this.height*e,t.RGBA,t.UNSIGNED_BYTE,this.height*e)))}},{key:"updatePixels",value:function(){var e=this._getTempFramebuffer();e.pixels=this._pixelsState.pixels,e.updatePixels(),this._pInst.push(),this._pInst.resetMatrix(),this._pInst.clear(),this._pInst.imageMode(l.CENTER),this._pInst.image(e,0,0),this._pInst.pop(),this.GL.clearDepth(1),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}},{key:"_getTempFramebuffer",value:function(){return this._tempFramebuffer||(this._tempFramebuffer=this._pInst.createFramebuffer({format:l.UNSIGNED_BYTE,useDepth:this._pInst._glAttributes.depth,depthFormat:l.UNSIGNED_INT,antialias:this._pInst._glAttributes.antialias})),this._tempFramebuffer}},{key:"geometryInHash",value:function(e){return void 0!==this.retainedMode.geometry[e]}},{key:"viewport",value:function(e,t){this._viewport=[0,0,e,t],this.GL.viewport(0,0,e,t)}},{key:"resize",value:function(t,r){g.default.Renderer.prototype.resize.call(this,t,r),this._origViewport={width:this.GL.drawingBufferWidth,height:this.GL.drawingBufferHeight},this.viewport(this._origViewport.width,this._origViewport.height),this._curCamera._resize();var t=this._pixelsState,e=(void 0!==t.pixels&&t._setProperty("pixels",new Uint8Array(this.GL.drawingBufferWidth*this.GL.drawingBufferHeight*4)),!0),r=!1,t=void 0;try{for(var o,n=this.framebuffers[Symbol.iterator]();!(e=(o=n.next()).done);e=!0)o.value._canvasSizeChanged()}catch(e){r=!0,t=e}finally{try{e||null==n.return||n.return()}finally{if(r)throw t}}}},{key:"clear",value:function(){var e=(arguments.length<=0?void 0:arguments[0])||0,t=(arguments.length<=1?void 0:arguments[1])||0,r=(arguments.length<=2?void 0:arguments[2])||0,o=(arguments.length<=3?void 0:arguments[3])||0,n=this.activeFramebuffer();n&&n.format===l.UNSIGNED_BYTE&&!n.antialias&&0===o&&(o=1e-10),this.GL.clearColor(e*o,t*o,r*o,o),this.GL.clearDepth(1),this.GL.clear(this.GL.COLOR_BUFFER_BIT|this.GL.DEPTH_BUFFER_BIT)}},{key:"clearDepth",value:function(){this.GL.clearDepth(0<arguments.length&&void 0!==arguments[0]?arguments[0]:1),this.GL.clear(this.GL.DEPTH_BUFFER_BIT)}},{key:"applyMatrix",value:function(e,t,r,o,n,s){16===arguments.length?g.default.Matrix.prototype.apply.apply(this.uModelMatrix,arguments):this.uModelMatrix.apply([e,t,0,0,r,o,0,0,0,0,1,0,n,s,0,1])}},{key:"translate",value:function(e,t,r){return e instanceof g.default.Vector&&(r=e.z,t=e.y,e=e.x),this.uModelMatrix.translate([e,t,r]),this}},{key:"scale",value:function(e,t,r){return this.uModelMatrix.scale(e,t,r),this}},{key:"rotate",value:function(e,t){return void 0===t?this.rotateZ(e):(g.default.Matrix.prototype.rotate.apply(this.uModelMatrix,arguments),this)}},{key:"rotateX",value:function(e){return this.rotate(e,1,0,0),this}},{key:"rotateY",value:function(e){return this.rotate(e,0,1,0),this}},{key:"rotateZ",value:function(e){return this.rotate(e,0,0,1),this}},{key:"push",value:function(){var e=g.default.Renderer.prototype.push.apply(this),t=e.properties;return t.uModelMatrix=this.uModelMatrix.copy(),t.uViewMatrix=this.uViewMatrix.copy(),t.uPMatrix=this.uPMatrix.copy(),t._curCamera=this._curCamera,this._curCamera=this._curCamera.copy(),t.ambientLightColors=this.ambientLightColors.slice(),t.specularColors=this.specularColors.slice(),t.directionalLightDirections=this.directionalLightDirections.slice(),t.directionalLightDiffuseColors=this.directionalLightDiffuseColors.slice(),t.directionalLightSpecularColors=this.directionalLightSpecularColors.slice(),t.pointLightPositions=this.pointLightPositions.slice(),t.pointLightDiffuseColors=this.pointLightDiffuseColors.slice(),t.pointLightSpecularColors=this.pointLightSpecularColors.slice(),t.spotLightPositions=this.spotLightPositions.slice(),t.spotLightDirections=this.spotLightDirections.slice(),t.spotLightDiffuseColors=this.spotLightDiffuseColors.slice(),t.spotLightSpecularColors=this.spotLightSpecularColors.slice(),t.spotLightAngle=this.spotLightAngle.slice(),t.spotLightConc=this.spotLightConc.slice(),t.userFillShader=this.userFillShader,t.userStrokeShader=this.userStrokeShader,t.userPointShader=this.userPointShader,t.pointSize=this.pointSize,t.curStrokeWeight=this.curStrokeWeight,t.curStrokeColor=this.curStrokeColor,t.curFillColor=this.curFillColor,t.curAmbientColor=this.curAmbientColor,t.curSpecularColor=this.curSpecularColor,t.curEmissiveColor=this.curEmissiveColor,t._hasSetAmbient=this._hasSetAmbient,t._useSpecularMaterial=this._useSpecularMaterial,t._useEmissiveMaterial=this._useEmissiveMaterial,t._useShininess=this._useShininess,t._useMetalness=this._useMetalness,t.constantAttenuation=this.constantAttenuation,t.linearAttenuation=this.linearAttenuation,t.quadraticAttenuation=this.quadraticAttenuation,t._enableLighting=this._enableLighting,t._useNormalMaterial=this._useNormalMaterial,t._tex=this._tex,t.drawMode=this.drawMode,t._currentNormal=this._currentNormal,t.curBlendMode=this.curBlendMode,t.activeImageLight=this.activeImageLight,t.textureMode=this.textureMode,e}},{key:"pop",value:function(){var e;0<this._clipDepths.length&&this._pushPopDepth===this._clipDepths[this._clipDepths.length-1]&&this._clearClip();for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];(e=p(b(s.prototype),"pop",this)).call.apply(e,[this].concat(r)),this._applyStencilTestIfClipping()}},{key:"_applyStencilTestIfClipping",value:function(){var e=this.drawTarget();e._isClipApplied!==this._stencilTestOn&&(e._isClipApplied?(this.GL.enable(this.GL.STENCIL_TEST),this._stencilTestOn=!0):(this.GL.disable(this.GL.STENCIL_TEST),this._stencilTestOn=!1))}},{key:"resetMatrix",value:function(){return this.uModelMatrix.reset(),this.uViewMatrix.set(this._curCamera.cameraMatrix),this}},{key:"_getImmediateStrokeShader",value:function(){var e=this.userStrokeShader;return e&&e.isStrokeShader()?e:this._getLineShader()}},{key:"_getRetainedStrokeShader",value:function(){return this._getImmediateStrokeShader()}},{key:"_getSphereMapping",value:function(e){return this.sphereMapping||(this.sphereMapping=this._pInst.createFilterShader(M)),this.uNMatrix.inverseTranspose(this.uViewMatrix),this.uNMatrix.invert3x3(this.uNMatrix),this.sphereMapping.setUniform("uFovY",this._curCamera.cameraFOV),this.sphereMapping.setUniform("uAspect",this._curCamera.aspectRatio),this.sphereMapping.setUniform("uNewNormalMatrix",this.uNMatrix.mat3),this.sphereMapping.setUniform("uSampler",e),this.sphereMapping}},{key:"_getImmediateFillShader",value:function(){var e=this.userFillShader;if(this._useNormalMaterial&&(!e||!e.isNormalShader()))return this._getNormalShader();if(this._enableLighting){if(!e||!e.isLightShader())return this._getLightShader()}else if(this._tex){if(!e||!e.isTextureShader())return this._getLightShader()}else if(!e)return this._getImmediateModeShader();return e}},{key:"_getRetainedFillShader",value:function(){if(this._useNormalMaterial)return this._getNormalShader();var e=this.userFillShader;if(this._enableLighting){if(!e||!e.isLightShader())return this._getLightShader()}else if(this._tex){if(!e||!e.isTextureShader())return this._getLightShader()}else if(!e)return this._getColorShader();return e}},{key:"_getImmediatePointShader",value:function(){var e=this.userPointShader;return e&&e.isPointShader()?e:this._getPointShader()}},{key:"_getRetainedLineShader",value:function(){return this._getImmediateLineShader()}},{key:"baseMaterialShader",value:function(){if(this._pInst._glAttributes.perPixelLighting)return this._getLightShader();throw new Error("The material shader does not support hooks without perPixelLighting. Try turning it back on.")}},{key:"_getLightShader",value:function(){return this._defaultLightShader||(this._pInst._glAttributes.perPixelLighting?this._defaultLightShader=new g.default.Shader(this,this._webGL2CompatibilityPrefix("vert","highp")+E.phongVert,this._webGL2CompatibilityPrefix("frag","highp")+E.phongFrag,{vertex:{"void beforeVertex":"() {}","vec3 getLocalPosition":"(vec3 position) { return position; }","vec3 getWorldPosition":"(vec3 position) { return position; }","vec3 getLocalNormal":"(vec3 normal) { return normal; }","vec3 getWorldNormal":"(vec3 normal) { return normal; }","vec2 getUV":"(vec2 uv) { return uv; }","vec4 getVertexColor":"(vec4 color) { return color; }","void afterVertex":"() {}"},fragment:{"void beforeFragment":"() {}","Inputs getPixelInputs":"(Inputs inputs) { return inputs; }","vec4 combineColors":"(ColorComponents components) {\n vec4 color = vec4(0.);\n color.rgb += components.diffuse * components.baseColor;\n color.rgb += components.ambient * components.ambientColor;\n color.rgb += components.specular * components.specularColor;\n color.rgb += components.emissive;\n color.a = components.opacity;\n return color;\n }","vec4 getFinalColor":"(vec4 color) { return color; }","void afterFragment":"() {}"}}):this._defaultLightShader=new g.default.Shader(this,this._webGL2CompatibilityPrefix("vert","highp")+E.lightVert,this._webGL2CompatibilityPrefix("frag","highp")+E.lightTextureFrag)),this._defaultLightShader}},{key:"_getImmediateModeShader",value:function(){return this._defaultImmediateModeShader||(this._defaultImmediateModeShader=new g.default.Shader(this,this._webGL2CompatibilityPrefix("vert","mediump")+E.immediateVert,this._webGL2CompatibilityPrefix("frag","mediump")+E.vertexColorFrag)),this._defaultImmediateModeShader}},{key:"baseNormalShader",value:function(){return this._getNormalShader()}},{key:"_getNormalShader",value:function(){return this._defaultNormalShader||(this._defaultNormalShader=new g.default.Shader(this,this._webGL2CompatibilityPrefix("vert","mediump")+E.normalVert,this._webGL2CompatibilityPrefix("frag","mediump")+E.normalFrag,{vertex:{"void beforeVertex":"() {}","vec3 getLocalPosition":"(vec3 position) { return position; }","vec3