@antv/g-webgpu 2.0.19 → 2.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var f=function(e){return null==e},d={}.toString,p=function(e,t){return d.call(e)==="[object "+t+"]"},_=function(e){return p(e,"String")},h=function(e,t,r){return t>e?t:e>r?r:e},E=function(e){return p(e,"Number")},R=1e-6,v="undefined"!=typeof Float32Array?Float32Array:Array;function T(){var e=new v(16);return v!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function m(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}function A(e,t,r,n,i,o,a,s,l,u,c,f,d,p,_,h){var E=new v(16);return E[0]=e,E[1]=t,E[2]=r,E[3]=n,E[4]=i,E[5]=o,E[6]=a,E[7]=s,E[8]=l,E[9]=u,E[10]=c,E[11]=f,E[12]=d,E[13]=p,E[14]=_,E[15]=h,E}function g(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}function y(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],f=t[9],d=t[10],p=t[11],_=t[12],h=t[13],E=t[14],R=t[15],v=r*s-n*a,T=r*l-i*a,m=r*u-o*a,A=n*l-i*s,g=n*u-o*s,y=i*u-o*l,S=c*h-f*_,C=c*E-d*_,P=c*R-p*_,N=f*E-d*h,M=f*R-p*h,I=d*R-p*E,O=v*I-T*M+m*N+A*P-g*C+y*S;return O?(e[0]=(s*I-l*M+u*N)*(O=1/O),e[1]=(i*M-n*I-o*N)*O,e[2]=(h*y-E*g+R*A)*O,e[3]=(d*g-f*y-p*A)*O,e[4]=(l*P-a*I-u*C)*O,e[5]=(r*I-i*P+o*C)*O,e[6]=(E*m-_*y-R*T)*O,e[7]=(c*y-d*m+p*T)*O,e[8]=(a*M-s*P+u*S)*O,e[9]=(n*P-r*M-o*S)*O,e[10]=(_*g-h*m+R*v)*O,e[11]=(f*m-c*g-p*v)*O,e[12]=(s*C-a*N-l*S)*O,e[13]=(r*N-n*C+i*S)*O,e[14]=(h*T-_*A-E*v)*O,e[15]=(c*A-f*T+d*v)*O,e):null}function S(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],h=t[12],E=t[13],R=t[14],v=t[15],T=r[0],m=r[1],A=r[2],g=r[3];return e[0]=T*n+m*s+A*f+g*h,e[1]=T*i+m*l+A*d+g*E,e[2]=T*o+m*u+A*p+g*R,e[3]=T*a+m*c+A*_+g*v,e[4]=(T=r[4])*n+(m=r[5])*s+(A=r[6])*f+(g=r[7])*h,e[5]=T*i+m*l+A*d+g*E,e[6]=T*o+m*u+A*p+g*R,e[7]=T*a+m*c+A*_+g*v,e[8]=(T=r[8])*n+(m=r[9])*s+(A=r[10])*f+(g=r[11])*h,e[9]=T*i+m*l+A*d+g*E,e[10]=T*o+m*u+A*p+g*R,e[11]=T*a+m*c+A*_+g*v,e[12]=(T=r[12])*n+(m=r[13])*s+(A=r[14])*f+(g=r[15])*h,e[13]=T*i+m*l+A*d+g*E,e[14]=T*o+m*u+A*p+g*R,e[15]=T*a+m*c+A*_+g*v,e}function C(e,t,r){var n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function P(e,t){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]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function N(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=n+n,l=i+i,u=o+o,c=n*s,f=n*l,d=n*u,p=i*l,_=i*u,h=o*u,E=a*s,R=a*l,v=a*u;return e[0]=1-(p+h),e[1]=f+v,e[2]=d-R,e[3]=0,e[4]=f-v,e[5]=1-(c+h),e[6]=_+E,e[7]=0,e[8]=d+R,e[9]=_-E,e[10]=1-(c+p),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function M(e,t){var r=t[4],n=t[5],i=t[6],o=t[8],a=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(r,n,i),e[2]=Math.hypot(o,a,s),e}function I(e,t,r,n,i){var o,a=1/Math.tan(t/2);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+n)*(o=1/(n-i)),e[14]=2*i*n*o):(e[10]=-1,e[14]=-2*n),e}function O(e,t,r,n,i,o,a){var s=1/(t-r),l=1/(n-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*l,e[14]=(a+o)*u,e[15]=1,e}function x(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var B,D=S,b=Object.freeze({__proto__:null,add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],f=t[9],d=t[10],p=t[11],_=t[12],h=t[13],E=t[14],R=t[15];return e[0]=s*(d*R-p*E)-f*(l*R-u*E)+h*(l*p-u*d),e[1]=-(n*(d*R-p*E)-f*(i*R-o*E)+h*(i*p-o*d)),e[2]=n*(l*R-u*E)-s*(i*R-o*E)+h*(i*u-o*l),e[3]=-(n*(l*p-u*d)-s*(i*p-o*d)+f*(i*u-o*l)),e[4]=-(a*(d*R-p*E)-c*(l*R-u*E)+_*(l*p-u*d)),e[5]=r*(d*R-p*E)-c*(i*R-o*E)+_*(i*p-o*d),e[6]=-(r*(l*R-u*E)-a*(i*R-o*E)+_*(i*u-o*l)),e[7]=r*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(f*R-p*h)-c*(s*R-u*h)+_*(s*p-u*f),e[9]=-(r*(f*R-p*h)-c*(n*R-o*h)+_*(n*p-o*f)),e[10]=r*(s*R-u*h)-a*(n*R-o*h)+_*(n*u-o*s),e[11]=-(r*(s*p-u*f)-a*(n*p-o*f)+c*(n*u-o*s)),e[12]=-(a*(f*E-d*h)-c*(s*E-l*h)+_*(s*d-l*f)),e[13]=r*(f*E-d*h)-c*(n*E-i*h)+_*(n*d-i*f),e[14]=-(r*(s*E-l*h)-a*(n*E-i*h)+_*(n*l-i*s)),e[15]=r*(s*d-l*f)-a*(n*d-i*f)+c*(n*l-i*s),e},clone:function(e){var t=new v(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},copy:m,create:T,determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],f=e[10],d=e[11],p=e[12],_=e[13],h=e[14],E=e[15];return(t*a-r*o)*(f*E-d*h)-(t*s-n*o)*(c*E-d*_)+(t*l-i*o)*(c*h-f*_)+(r*s-n*a)*(u*E-d*p)-(r*l-i*a)*(u*h-f*p)+(n*l-i*s)*(u*_-c*p)},equals:function(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],d=e[10],p=e[11],_=e[12],h=e[13],E=e[14],v=e[15],T=t[0],m=t[1],A=t[2],g=t[3],y=t[4],S=t[5],C=t[6],P=t[7],N=t[8],M=t[9],I=t[10],O=t[11],x=t[12],B=t[13],D=t[14],b=t[15];return!(Math.abs(r-T)>R*Math.max(1,Math.abs(r),Math.abs(T))||Math.abs(n-m)>R*Math.max(1,Math.abs(n),Math.abs(m))||Math.abs(i-A)>R*Math.max(1,Math.abs(i),Math.abs(A))||Math.abs(o-g)>R*Math.max(1,Math.abs(o),Math.abs(g))||Math.abs(a-y)>R*Math.max(1,Math.abs(a),Math.abs(y))||Math.abs(s-S)>R*Math.max(1,Math.abs(s),Math.abs(S))||Math.abs(l-C)>R*Math.max(1,Math.abs(l),Math.abs(C))||Math.abs(u-P)>R*Math.max(1,Math.abs(u),Math.abs(P))||Math.abs(c-N)>R*Math.max(1,Math.abs(c),Math.abs(N))||Math.abs(f-M)>R*Math.max(1,Math.abs(f),Math.abs(M))||Math.abs(d-I)>R*Math.max(1,Math.abs(d),Math.abs(I))||Math.abs(p-O)>R*Math.max(1,Math.abs(p),Math.abs(O))||Math.abs(_-x)>R*Math.max(1,Math.abs(_),Math.abs(x))||Math.abs(h-B)>R*Math.max(1,Math.abs(h),Math.abs(B))||Math.abs(E-D)>R*Math.max(1,Math.abs(E),Math.abs(D))||Math.abs(v-b)>R*Math.max(1,Math.abs(v),Math.abs(b)))},exactEquals:function(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]},frob:function(e){return Math.hypot(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])},fromQuat:function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=r+r,s=n+n,l=i+i,u=r*a,c=n*a,f=n*s,d=i*a,p=i*s,_=i*l,h=o*a,E=o*s,R=o*l;return e[0]=1-f-_,e[1]=c+R,e[2]=d-E,e[3]=0,e[4]=c-R,e[5]=1-u-_,e[6]=p+h,e[7]=0,e[8]=d+E,e[9]=p-h,e[10]=1-u-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromQuat2:function(e,t){var r=new v(3),n=-t[0],i=-t[1],o=-t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=n*n+i*i+o*o+a*a;return f>0?(r[0]=2*(s*a+c*n+l*o-u*i)/f,r[1]=2*(l*a+c*i+u*n-s*o)/f,r[2]=2*(u*a+c*o+s*i-l*n)/f):(r[0]=2*(s*a+c*n+l*o-u*i),r[1]=2*(l*a+c*i+u*n-s*o),r[2]=2*(u*a+c*o+s*i-l*n)),N(e,t,r),e},fromRotation:function(e,t,r){var n,i,o,a=r[0],s=r[1],l=r[2],u=Math.hypot(a,s,l);return R>u?null:(a*=u=1/u,s*=u,l*=u,n=Math.sin(t),e[0]=a*a*(o=1-(i=Math.cos(t)))+i,e[1]=s*a*o+l*n,e[2]=l*a*o-s*n,e[3]=0,e[4]=a*s*o-l*n,e[5]=s*s*o+i,e[6]=l*s*o+a*n,e[7]=0,e[8]=a*l*o+s*n,e[9]=s*l*o-a*n,e[10]=l*l*o+i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromRotationTranslation:N,fromRotationTranslationScale:function(e,t,r,n){var i=t[0],o=t[1],a=t[2],s=t[3],l=i+i,u=o+o,c=a+a,f=i*l,d=i*u,p=i*c,_=o*u,h=o*c,E=a*c,R=s*l,v=s*u,T=s*c,m=n[0],A=n[1],g=n[2];return e[0]=(1-(_+E))*m,e[1]=(d+T)*m,e[2]=(p-v)*m,e[3]=0,e[4]=(d-T)*A,e[5]=(1-(f+E))*A,e[6]=(h+R)*A,e[7]=0,e[8]=(p+v)*g,e[9]=(h-R)*g,e[10]=(1-(f+_))*g,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},fromRotationTranslationScaleOrigin:function(e,t,r,n,i){var o=t[0],a=t[1],s=t[2],l=t[3],u=o+o,c=a+a,f=s+s,d=o*u,p=o*c,_=o*f,h=a*c,E=a*f,R=s*f,v=l*u,T=l*c,m=l*f,A=n[0],g=n[1],y=n[2],S=i[0],C=i[1],P=i[2],N=(1-(h+R))*A,M=(p+m)*A,I=(_-T)*A,O=(p-m)*g,x=(1-(d+R))*g,B=(E+v)*g,D=(_+T)*y,b=(E-v)*y,L=(1-(d+h))*y;return e[0]=N,e[1]=M,e[2]=I,e[3]=0,e[4]=O,e[5]=x,e[6]=B,e[7]=0,e[8]=D,e[9]=b,e[10]=L,e[11]=0,e[12]=r[0]+S-(N*S+O*C+D*P),e[13]=r[1]+C-(M*S+x*C+b*P),e[14]=r[2]+P-(I*S+B*C+L*P),e[15]=1,e},fromScaling:function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromTranslation:P,fromValues:A,fromXRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,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},frustum:function(e,t,r,n,i,o,a){var s=1/(r-t),l=1/(i-n),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},getRotation:function(e,t){var r=new v(3);M(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],a=t[0]*n,s=t[1]*i,l=t[2]*o,u=t[4]*n,c=t[5]*i,f=t[6]*o,d=t[8]*n,p=t[9]*i,_=t[10]*o,h=a+c+_,E=0;return h>0?(e[3]=.25*(E=2*Math.sqrt(h+1)),e[0]=(f-p)/E,e[1]=(d-l)/E,e[2]=(s-u)/E):a>c&&a>_?(e[3]=(f-p)/(E=2*Math.sqrt(1+a-c-_)),e[0]=.25*E,e[1]=(s+u)/E,e[2]=(d+l)/E):c>_?(e[3]=(d-l)/(E=2*Math.sqrt(1+c-a-_)),e[0]=(s+u)/E,e[1]=.25*E,e[2]=(f+p)/E):(e[3]=(s-u)/(E=2*Math.sqrt(1+_-a-c)),e[0]=(d+l)/E,e[1]=(f+p)/E,e[2]=.25*E),e},getScaling:M,getTranslation:function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},identity:g,invert:y,lookAt:function(e,t,r,n){var i,o,a,s,l,u,c,f,d,p,_=t[0],h=t[1],E=t[2],v=n[0],T=n[1],m=n[2],A=r[0],y=r[1],S=r[2];return R>Math.abs(_-A)&&R>Math.abs(h-y)&&R>Math.abs(E-S)?g(e):(p=1/Math.hypot(c=_-A,f=h-y,d=E-S),(p=Math.hypot(i=T*(d*=p)-m*(f*=p),o=m*(c*=p)-v*d,a=v*f-T*c))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),(p=Math.hypot(s=f*a-d*o,l=d*i-c*a,u=c*o-f*i))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*_+o*h+a*E),e[13]=-(s*_+l*h+u*E),e[14]=-(c*_+f*h+d*E),e[15]=1,e)},mul:D,multiply:S,multiplyScalar:function(e,t,r){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]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},multiplyScalarAndAdd:function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},ortho:O,orthoNO:O,orthoZO:function(e,t,r,n,i,o,a){var s=1/(t-r),l=1/(n-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=u,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*l,e[14]=o*u,e[15]=1,e},perspective:I,perspectiveFromFieldOfView:function(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(a+s),u=2/(i+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=-(a-s)*l*.5,e[9]=(i-o)*u*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},perspectiveNO:I,perspectiveZO:function(e,t,r,n,i){var o,a=1/Math.tan(t/2);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=i*(o=1/(n-i)),e[14]=i*n*o):(e[10]=-1,e[14]=-n),e},rotate:function(e,t,r,n){var i,o,a,s,l,u,c,f,d,p,_,h,E,v,T,m,A,g,y,S,C,P,N,M,I=n[0],O=n[1],x=n[2],B=Math.hypot(I,O,x);return R>B?null:(I*=B=1/B,O*=B,x*=B,i=Math.sin(r),l=t[1],u=t[2],c=t[3],d=t[5],p=t[6],_=t[7],E=t[9],v=t[10],T=t[11],y=I*O*(a=1-(o=Math.cos(r)))-x*i,S=O*O*a+o,C=x*O*a+I*i,P=I*x*a+O*i,N=O*x*a-I*i,M=x*x*a+o,e[0]=(s=t[0])*(m=I*I*a+o)+(f=t[4])*(A=O*I*a+x*i)+(h=t[8])*(g=x*I*a-O*i),e[1]=l*m+d*A+E*g,e[2]=u*m+p*A+v*g,e[3]=c*m+_*A+T*g,e[4]=s*y+f*S+h*C,e[5]=l*y+d*S+E*C,e[6]=u*y+p*S+v*C,e[7]=c*y+_*S+T*C,e[8]=s*P+f*N+h*M,e[9]=l*P+d*N+E*M,e[10]=u*P+p*N+v*M,e[11]=c*P+_*N+T*M,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],f=t[10],d=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]=o*i+u*n,e[5]=a*i+c*n,e[6]=s*i+f*n,e[7]=l*i+d*n,e[8]=u*i-o*n,e[9]=c*i-a*n,e[10]=f*i-s*n,e[11]=d*i-l*n,e},rotateY:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],f=t[10],d=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]=o*i-u*n,e[1]=a*i-c*n,e[2]=s*i-f*n,e[3]=l*i-d*n,e[8]=o*n+u*i,e[9]=a*n+c*i,e[10]=s*n+f*i,e[11]=l*n+d*i,e},rotateZ:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],f=t[6],d=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]=o*i+u*n,e[1]=a*i+c*n,e[2]=s*i+f*n,e[3]=l*i+d*n,e[4]=u*i-o*n,e[5]=c*i-a*n,e[6]=f*i-s*n,e[7]=d*i-l*n,e},scale:C,set:function(e,t,r,n,i,o,a,s,l,u,c,f,d,p,_,h,E){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=u,e[9]=c,e[10]=f,e[11]=d,e[12]=p,e[13]=_,e[14]=h,e[15]=E,e},str:function(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]+")"},sub:x,subtract:x,targetTo:function(e,t,r,n){var i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=n[2],c=i-r[0],f=o-r[1],d=a-r[2],p=c*c+f*f+d*d;p>0&&(c*=p=1/Math.sqrt(p),f*=p,d*=p);var _=l*d-u*f,h=u*c-s*d,E=s*f-l*c;return(p=_*_+h*h+E*E)>0&&(_*=p=1/Math.sqrt(p),h*=p,E*=p),e[0]=_,e[1]=h,e[2]=E,e[3]=0,e[4]=f*E-d*h,e[5]=d*_-c*E,e[6]=c*h-f*_,e[7]=0,e[8]=c,e[9]=f,e[10]=d,e[11]=0,e[12]=i,e[13]=o,e[14]=a,e[15]=1,e},translate:function(e,t,r){var n,i,o,a,s,l,u,c,f,d,p,_,h=r[0],E=r[1],R=r[2];return t===e?(e[12]=t[0]*h+t[4]*E+t[8]*R+t[12],e[13]=t[1]*h+t[5]*E+t[9]*R+t[13],e[14]=t[2]*h+t[6]*E+t[10]*R+t[14],e[15]=t[3]*h+t[7]*E+t[11]*R+t[15]):(i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],e[0]=n=t[0],e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=f,e[9]=d,e[10]=p,e[11]=_,e[12]=n*h+s*E+f*R+t[12],e[13]=i*h+l*E+d*R+t[13],e[14]=o*h+u*E+p*R+t[14],e[15]=a*h+c*E+_*R+t[15]),e},transpose:function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}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}});function L(e,t,r){var n=new v(3);return n[0]=e,n[1]=t,n[2]=r,n}function F(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function U(e,t,r,n,i,o,a,s,l,u){var c,f,d,p,_,h=e,E=t,R=r,v=n,T=s,m=l,A=120*Math.PI/180,g=Math.PI/180*(+i||0),y=[];if(u)f=u[0],d=u[1],p=u[2],_=u[3];else{E=(c=F(h,E,-g)).y;var S=((h=c.x)-(T=(c=F(T,m,-g)).x))/2,C=(E-(m=c.y))/2,P=S*S/(R*R)+C*C/(v*v);P>1&&(R*=P=Math.sqrt(P),v*=P);var N=R*R,M=v*v,I=(o===a?-1:1)*Math.sqrt(Math.abs((N*M-N*C*C-M*S*S)/(N*C*C+M*S*S)));p=I*R*C/v+(h+T)/2,f=Math.asin(((E-(_=I*-v*S/R+(E+m)/2))/v*1e9>>0)/1e9),d=Math.asin(((m-_)/v*1e9>>0)/1e9),0>(f=p>h?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=p>T?Math.PI-d:d)&&(d=2*Math.PI+d),a&&f>d&&(f-=2*Math.PI),!a&&d>f&&(d-=2*Math.PI)}var O=d-f;if(Math.abs(O)>A){var x=d,B=T,D=m;y=U(T=p+R*Math.cos(d=f+A*(a&&d>f?1:-1)),m=_+v*Math.sin(d),R,v,i,0,a,B,D,[d,x,p,_])}O=d-f;var b=Math.cos(f),L=Math.sin(f),w=Math.cos(d),G=Math.sin(d),k=Math.tan(O/4),V=4/3*R*k,X=4/3*v*k,W=[h,E],H=[h+V*L,E-X*b],Y=[T+V*G,m-X*w],z=[T,m];if(H[0]=2*W[0]-H[0],H[1]=2*W[1]-H[1],u)return H.concat(Y,z,y);for(var K=[],j=0,Z=(y=H.concat(Y,z,y)).length;Z>j;j+=1)K[j]=j%2?F(y[j-1],y[j],g).y:F(y[j],y[j+1],g).x;return K}B=new v(3),v!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0);var w={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var l,u,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(u=1,l=Array(f-1);f>u;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,i);break;default:if(!l)for(d=1,l=Array(f-1);f>d;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var l=0,u=[],c=s.length;c>l;l++)(s[l].fn!==t||i&&!s[l].once||n&&s[l].context!==n)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(w);var G,k,V,X,W,H,Y,z,K,j,Z,q,Q,$,J,ee,te,re,ne,ie,oe,ae,se,le,ue,ce,fe,de=w.exports;function pe(e,t,r,n){return{dimension:ee.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:te.SAMPLED}}function _e(e,t,r){return e<<16|t<<8|r}function he(e){return e>>>8&255}function Ee(e){return e>>>16&255}function Re(e){return 255&e}function ve(e){switch(e){case le.F32:case le.U32:case le.S32:return 4;case le.U16:case le.S16:case le.F16:return 2;case le.U8:case le.S8:return 1;default:throw Error("whoops")}}function Te(e){return ve(Ee(e))}function me(e){var t=Re(e);if(t&ce.Depth)return ie.Depth;if(t&ce.Normalized)return ie.Float;var r=Ee(e);if(r===le.F16||r===le.F32)return ie.Float;if(r===le.U8||r===le.U16||r===le.U32)return ie.Uint;if(r===le.S8||r===le.S16||r===le.S32)return ie.Sint;throw Error("whoops")}function Ae(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function ge(e){if(null!=e)return e;throw Error("Missing object")}function ye(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Se(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(G||(G={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool",e[e.RenderBundle=11]="RenderBundle"}(k||(k={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(V||(V={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(X||(X={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(W||(W={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(H||(H={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(Y||(Y={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(z||(z={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(K||(K={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(j||(j={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(Z||(Z={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(q||(q={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(Q||(Q={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}($||($={})),function(e){e.LOADED="loaded"}(J||(J={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(ee||(ee={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET",e[e.STORAGE=4]="STORAGE"}(te||(te={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(re||(re={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(ne||(ne={})),function(e){e[e.Float=0]="Float",e[e.UnfilterableFloat=1]="UnfilterableFloat",e[e.Uint=2]="Uint",e[e.Sint=3]="Sint",e[e.Depth=4]="Depth"}(ie||(ie={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(oe||(oe={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(ae||(ae={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(se||(se={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(le||(le={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(ue||(ue={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget",e[e.Luminance=32]="Luminance"}(ce||(ce={})),function(e){e[e.ALPHA=_e(le.U8,ue.A,ce.None)]="ALPHA",e[e.U8_LUMINANCE=_e(le.U8,ue.A,ce.Luminance)]="U8_LUMINANCE",e[e.F16_LUMINANCE=_e(le.F16,ue.A,ce.Luminance)]="F16_LUMINANCE",e[e.F32_LUMINANCE=_e(le.F32,ue.A,ce.Luminance)]="F32_LUMINANCE",e[e.F16_R=_e(le.F16,ue.R,ce.None)]="F16_R",e[e.F16_RG=_e(le.F16,ue.RG,ce.None)]="F16_RG",e[e.F16_RGB=_e(le.F16,ue.RGB,ce.None)]="F16_RGB",e[e.F16_RGBA=_e(le.F16,ue.RGBA,ce.None)]="F16_RGBA",e[e.F32_R=_e(le.F32,ue.R,ce.None)]="F32_R",e[e.F32_RG=_e(le.F32,ue.RG,ce.None)]="F32_RG",e[e.F32_RGB=_e(le.F32,ue.RGB,ce.None)]="F32_RGB",e[e.F32_RGBA=_e(le.F32,ue.RGBA,ce.None)]="F32_RGBA",e[e.U8_R=_e(le.U8,ue.R,ce.None)]="U8_R",e[e.U8_R_NORM=_e(le.U8,ue.R,ce.Normalized)]="U8_R_NORM",e[e.U8_RG=_e(le.U8,ue.RG,ce.None)]="U8_RG",e[e.U8_RG_NORM=_e(le.U8,ue.RG,ce.Normalized)]="U8_RG_NORM",e[e.U8_RGB=_e(le.U8,ue.RGB,ce.None)]="U8_RGB",e[e.U8_RGB_NORM=_e(le.U8,ue.RGB,ce.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=_e(le.U8,ue.RGB,ce.sRGB|ce.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=_e(le.U8,ue.RGBA,ce.None)]="U8_RGBA",e[e.U8_RGBA_NORM=_e(le.U8,ue.RGBA,ce.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=_e(le.U8,ue.RGBA,ce.sRGB|ce.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=_e(le.U16,ue.R,ce.None)]="U16_R",e[e.U16_R_NORM=_e(le.U16,ue.R,ce.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=_e(le.U16,ue.RG,ce.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=_e(le.U16,ue.RGBA,ce.Normalized)]="U16_RGBA_NORM",e[e.U16_RGBA=_e(le.U16,ue.RGBA,ce.None)]="U16_RGBA",e[e.U16_RGB=_e(le.U16,ue.RGB,ce.None)]="U16_RGB",e[e.U16_RG=_e(le.U16,ue.RG,ce.None)]="U16_RG",e[e.U32_R=_e(le.U32,ue.R,ce.None)]="U32_R",e[e.U32_RG=_e(le.U32,ue.RG,ce.None)]="U32_RG",e[e.U32_RGB=_e(le.U32,ue.RGB,ce.None)]="U32_RGB",e[e.U32_RGBA=_e(le.U32,ue.RGBA,ce.None)]="U32_RGBA",e[e.S8_R=_e(le.S8,ue.R,ce.None)]="S8_R",e[e.S8_R_NORM=_e(le.S8,ue.R,ce.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=_e(le.S8,ue.RG,ce.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=_e(le.S8,ue.RGB,ce.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=_e(le.S8,ue.RGBA,ce.Normalized)]="S8_RGBA_NORM",e[e.S16_R=_e(le.S16,ue.R,ce.None)]="S16_R",e[e.S16_RG=_e(le.S16,ue.RG,ce.None)]="S16_RG",e[e.S16_RG_NORM=_e(le.S16,ue.RG,ce.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=_e(le.S16,ue.RGB,ce.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=_e(le.S16,ue.RGBA,ce.None)]="S16_RGBA",e[e.S16_RGBA_NORM=_e(le.S16,ue.RGBA,ce.Normalized)]="S16_RGBA_NORM",e[e.S32_R=_e(le.S32,ue.R,ce.None)]="S32_R",e[e.S32_RG=_e(le.S32,ue.RG,ce.None)]="S32_RG",e[e.S32_RGB=_e(le.S32,ue.RGB,ce.None)]="S32_RGB",e[e.S32_RGBA=_e(le.S32,ue.RGBA,ce.None)]="S32_RGBA",e[e.U16_RGBA_5551=_e(le.U16_PACKED_5551,ue.RGBA,ce.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=_e(le.U16_PACKED_565,ue.RGB,ce.Normalized)]="U16_RGB_565",e[e.BC1=_e(le.BC1,ue.RGBA,ce.Normalized)]="BC1",e[e.BC1_SRGB=_e(le.BC1,ue.RGBA,ce.Normalized|ce.sRGB)]="BC1_SRGB",e[e.BC2=_e(le.BC2,ue.RGBA,ce.Normalized)]="BC2",e[e.BC2_SRGB=_e(le.BC2,ue.RGBA,ce.Normalized|ce.sRGB)]="BC2_SRGB",e[e.BC3=_e(le.BC3,ue.RGBA,ce.Normalized)]="BC3",e[e.BC3_SRGB=_e(le.BC3,ue.RGBA,ce.Normalized|ce.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=_e(le.BC4_UNORM,ue.R,ce.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=_e(le.BC4_SNORM,ue.R,ce.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=_e(le.BC5_UNORM,ue.RG,ce.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=_e(le.BC5_SNORM,ue.RG,ce.Normalized)]="BC5_SNORM",e[e.D24=_e(le.D24,ue.R,ce.Depth)]="D24",e[e.D24_S8=_e(le.D24S8,ue.RG,ce.Depth|ce.Stencil)]="D24_S8",e[e.D32F=_e(le.D32F,ue.R,ce.Depth)]="D32F",e[e.D32F_S8=_e(le.D32FS8,ue.RG,ce.Depth|ce.Stencil)]="D32F_S8",e[e.U8_RGB_RT=_e(le.U8,ue.RGB,ce.RenderTarget|ce.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=_e(le.U8,ue.RGBA,ce.RenderTarget|ce.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=_e(le.U8,ue.RGBA,ce.RenderTarget|ce.Normalized|ce.sRGB)]="U8_RGBA_RT_SRGB"}(fe||(fe={}));var Ce=Se(0,0,0,0),Pe=Se(0,0,0,1),Ne=Se(1,1,1,0),Me=Se(1,1,1,1);function Ie(e){return!(!e||0!=(e&e-1))}function Oe(e,t){return null!=e?e:t}function xe(e,t,r){e.length=t,e.fill(r)}function Be(e,t){var r=t-1;return e+r&~r}function De(e,t){return((e+t-1)/t|0)*t}function be(e,t,r){return r?e|=t:e&=~t,e}function Le(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Fe(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Ue(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e.mask=t.mask,e}function we(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Fe(e.rgbBlendState,t.rgbBlendState),Fe(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Ge(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=we(e[r],t[r])}function ke(e,t){void 0!==t.attachmentsState&&Ge(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=Oe(t.depthCompare,e.depthCompare),e.depthWrite=Oe(t.depthWrite,e.depthWrite),e.stencilWrite=Oe(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&Ue(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&Ue(e.stencilBack,t.stencilBack),e.cullMode=Oe(t.cullMode,e.cullMode),e.frontFace=Oe(t.frontFace,e.frontFace),e.polygonOffset=Oe(t.polygonOffset,e.polygonOffset)}function Ve(e){var t=Object.assign({},e);return t.attachmentsState=[],Ge(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&ye(t.blendConstant),t.stencilFront=Ue(void 0,e.stencilFront),t.stencilBack=Ue(void 0,e.stencilBack),t}var Xe={blendMode:Y.ADD,blendSrcFactor:H.ONE,blendDstFactor:H.ZERO},We={attachmentsState:[{channelWriteMask:re.ALL,rgbBlendState:Xe,alphaBlendState:Xe}],blendConstant:ye(Ce),depthWrite:!0,depthCompare:V.LEQUAL,stencilWrite:!1,stencilFront:{compare:V.ALWAYS,passOp:ne.KEEP,depthFailOp:ne.KEEP,failOp:ne.KEEP},stencilBack:{compare:V.ALWAYS,passOp:ne.KEEP,depthFailOp:ne.KEEP,failOp:ne.KEEP},cullMode:W.NONE,frontFace:X.CCW,polygonOffset:!1};var He=function(e,t){void 0===e&&(e=null),void 0===t&&(t=We);var r=Ve(t);return null!==e&&ke(r,e),r}({depthCompare:V.ALWAYS,depthWrite:!1},We);function Ye(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Ge(e.attachmentsState,We.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var ze,Ke={texture:null,sampler:null,formatKind:ie.Float,dimension:ee.TEXTURE_2D};function je(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Ze(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function qe(e,t){return e.texture===t.texture&&e.binding===t.binding}function Qe(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function $e(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function Je(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!je(e.samplerBindings,t.samplerBindings,$e)&&(!!je(e.uniformBufferBindings,t.uniformBufferBindings,Qe)&&(!!je(e.storageBufferBindings,t.storageBufferBindings,Qe)&&!!je(e.storageTextureBindings,t.storageTextureBindings,qe))))}function et(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function tt(e,t){return!!et(e.rgbBlendState,t.rgbBlendState)&&(!!et(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function rt(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp&&e.mask===t.mask}function nt(e,t){return e.id===t.id}function it(e,t){return e===t}function ot(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!je(e.attachmentsState,t.attachmentsState,tt)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!rt(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!rt(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!nt(e.program,t.program)&&(!!je(e.colorAttachmentFormats,t.colorAttachmentFormats,it)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function at(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function st(e,t){return f(e)?f(t):!f(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&je(e.attributes,t.attributes,at))}function lt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!je(e.vertexBufferDescriptors,t.vertexBufferDescriptors,st)&&!!nt(e.program,t.program))}function ut(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function ct(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function ft(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function dt(e){return{binding:e.binding,texture:e.texture}}function pt(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function _t(e){return f(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:Ze(e.attributes,pt)}}var ht=/([^[]*)(\[[0-9]+\])?/;function Et(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(ht);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function Rt(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function vt(e,t,r,n){var i=null,o=null;return function(a,s,l){var u=t(l,r),c=u.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Ae(o===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(u[d]!==i[d]){f=!0;break}}return f&&(n(a,e,s,u),i.set(u)),f}}function Tt(e,t,r,n){e[t](r,n)}function mt(e,t,r,n){e[t](r,!1,n)}var At={},gt={},yt={},St=[0];function Ct(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(St[0]=e,e=St);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function Pt(e,t){return Ct(e,t,Float32Array,At)}function Nt(e,t){return Ct(e,t,Int32Array,gt)}function Mt(e,t){return Ct(e,t,Uint32Array,yt)}var It=((ze={})[G.FLOAT]=vt.bind(null,"uniform1fv",Pt,1,Tt),ze[G.FLOAT_VEC2]=vt.bind(null,"uniform2fv",Pt,2,Tt),ze[G.FLOAT_VEC3]=vt.bind(null,"uniform3fv",Pt,3,Tt),ze[G.FLOAT_VEC4]=vt.bind(null,"uniform4fv",Pt,4,Tt),ze[G.INT]=vt.bind(null,"uniform1iv",Nt,1,Tt),ze[G.INT_VEC2]=vt.bind(null,"uniform2iv",Nt,2,Tt),ze[G.INT_VEC3]=vt.bind(null,"uniform3iv",Nt,3,Tt),ze[G.INT_VEC4]=vt.bind(null,"uniform4iv",Nt,4,Tt),ze[G.BOOL]=vt.bind(null,"uniform1iv",Nt,1,Tt),ze[G.BOOL_VEC2]=vt.bind(null,"uniform2iv",Nt,2,Tt),ze[G.BOOL_VEC3]=vt.bind(null,"uniform3iv",Nt,3,Tt),ze[G.BOOL_VEC4]=vt.bind(null,"uniform4iv",Nt,4,Tt),ze[G.FLOAT_MAT2]=vt.bind(null,"uniformMatrix2fv",Pt,4,mt),ze[G.FLOAT_MAT3]=vt.bind(null,"uniformMatrix3fv",Pt,9,mt),ze[G.FLOAT_MAT4]=vt.bind(null,"uniformMatrix4fv",Pt,16,mt),ze[G.UNSIGNED_INT]=vt.bind(null,"uniform1uiv",Mt,1,Tt),ze[G.UNSIGNED_INT_VEC2]=vt.bind(null,"uniform2uiv",Mt,2,Tt),ze[G.UNSIGNED_INT_VEC3]=vt.bind(null,"uniform3uiv",Mt,3,Tt),ze[G.UNSIGNED_INT_VEC4]=vt.bind(null,"uniform4uiv",Mt,4,Tt),ze[G.FLOAT_MAT2x3]=vt.bind(null,"uniformMatrix2x3fv",Pt,6,mt),ze[G.FLOAT_MAT2x4]=vt.bind(null,"uniformMatrix2x4fv",Pt,8,mt),ze[G.FLOAT_MAT3x2]=vt.bind(null,"uniformMatrix3x2fv",Pt,6,mt),ze[G.FLOAT_MAT3x4]=vt.bind(null,"uniformMatrix3x4fv",Pt,12,mt),ze[G.FLOAT_MAT4x2]=vt.bind(null,"uniformMatrix4x2fv",Pt,8,mt),ze[G.FLOAT_MAT4x3]=vt.bind(null,"uniformMatrix4x3fv",Pt,12,mt),ze[G.SAMPLER_2D]=Rt,ze[G.SAMPLER_CUBE]=Rt,ze[G.SAMPLER_3D]=Rt,ze[G.SAMPLER_2D_SHADOW]=Rt,ze[G.SAMPLER_2D_ARRAY]=Rt,ze[G.SAMPLER_2D_ARRAY_SHADOW]=Rt,ze[G.SAMPLER_CUBE_SHADOW]=Rt,ze[G.INT_SAMPLER_2D]=Rt,ze[G.INT_SAMPLER_3D]=Rt,ze[G.INT_SAMPLER_CUBE]=Rt,ze[G.INT_SAMPLER_2D_ARRAY]=Rt,ze[G.UNSIGNED_INT_SAMPLER_2D]=Rt,ze[G.UNSIGNED_INT_SAMPLER_3D]=Rt,ze[G.UNSIGNED_INT_SAMPLER_CUBE]=Rt,ze[G.UNSIGNED_INT_SAMPLER_2D_ARRAY]=Rt,ze);function Ot(e,t,r){var n=It[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var xt={"[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};function Bt(e,t){return"#define ".concat(e," ").concat(t)}function Dt(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function bt(e){return[e,""]}function Lt(e,t,r,n,i){var o;void 0===n&&(n=null),void 0===i&&(i=!0);var a="#version 100"===e.glslVersion,s="frag"===t&&(null===(o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===o?void 0:o.length)>1,l=r.replace("\r\n","\n").split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),c="";null!==n&&(c=Object.keys(n).map((function(e){return Bt(e,n[e])})).join("\n"));var f=l.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=i?l.filter((function(e){return!e.startsWith("precision")})).join("\n"):l.join("\n"),p="";if(e.viewportOrigin===oe.UPPER_LEFT&&(p+="".concat(Bt("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===ae.ZERO&&(p+="".concat(Bt("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,h=0,E=0;d=d.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(h++,") uniform ").concat(n)})),_++,h=0,Ae(e.separateSamplerTextures),d=d.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,r,n,i,o){var a=Dt(n);null===a&&(a=h++);var s=u(bt(i),2),l=s[0],c=s[1];return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(2*a+0,") uniform texture").concat(l," T_").concat(o,";\nlayout(set = ").concat(_,", binding = ").concat(2*a+1,") uniform sampler").concat(c," S_").concat(o,";").trim():""})),d=d.replace("frag"===t?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(E++,") ").concat(t)})),p+="".concat(Bt("gl_VertexID","gl_VertexIndex"),"\n"),p+="".concat(Bt("gl_InstanceID","gl_InstanceIndex"),"\n"),f=f.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var R=0;d=d.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,t,r,n,i){var o=Dt(r);return null===o&&(o=R++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(o)}))}if(d=(d=(d=d.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"SAMPLER_".concat(t,"(P_").concat(r,")")}))).replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"PP_SAMPLER_".concat(t,"(P_").concat(r,")")}))).replace(/\bPU_TEXTURE\((.*?)\)/g,(function(e,t){return"TEXTURE(P_".concat(t,")")})),e.separateSamplerTextures)d=d.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){var n=u(bt(t),2),i=n[1];return"texture".concat(n[0]," T_P_").concat(r,", sampler").concat(i," S_P_").concat(r)})),d=(d=(d=d.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"T_".concat(r,", S_").concat(r)}))).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")}))).replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return"T_".concat(t)}));else{var v=[];d=(d=(d=d.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t," P_").concat(r)}))).replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return r}))).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return v.push([r,t]),r})),a&&v.forEach((function(e){var t=u(e,2),r=t[0],n=t[1];d=d.replace(RegExp("texture\\(".concat(r),"g"),(function(){return"texture".concat(n,"(").concat(r)}))})),d=d.replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return t}))}var T="".concat(a?"":e.glslVersion,"\n").concat(a&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(a&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?f:"","\n").concat(p||"").concat(c?c+"\n":"","\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(T=T.replace(/^\b(out)\b/g,(function(e,t){return"layout(location = 0) ".concat(t)}))),a){if("frag"===t&&(T=T.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(T=(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")}))),T=T.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,t){return t.trim().replace(/^.*$/gm,(function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""}))})),"frag"===t)if(s){var m=[];T=T.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,(function(e,t){return m.push(t),"vec4 ".concat(t,";\n")}));var A=T.lastIndexOf("}");T=T.substring(0,A)+"\n ".concat(m.map((function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")})).join("\n"))+T.substring(A)}else{var g;if(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return g=r,"".concat(t," ").concat(r,";\n")})),g){A=T.lastIndexOf("}");T=T.substring(0,A)+"\n gl_FragColor = vec4(".concat(g,");\n")+T.substring(A)}}T=T.replace(/^\s*layout\((.*)\)/gm,"")}return T}var Ft=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return n(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(de);function Ut(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||!(!e||2!==e._version)}function wt(e){if(Re(e)&ce.Normalized)return!1;var t=Ee(e);return t===le.S8||t===le.S16||t===le.S32||(t===le.U8||t===le.U16||t===le.U32)}function Gt(e){return e&q.INDEX?G.ELEMENT_ARRAY_BUFFER:e&q.VERTEX?G.ARRAY_BUFFER:e&q.UNIFORM?G.UNIFORM_BUFFER:void 0}function kt(e){var t=Ee(e),r=he(e),n=Re(e),i=function(e){switch(e){case le.U8:return G.UNSIGNED_BYTE;case le.U16:return G.UNSIGNED_SHORT;case le.U32:return G.UNSIGNED_INT;case le.S8:return G.BYTE;case le.S16:return G.SHORT;case le.S32:return G.INT;case le.F16:return G.HALF_FLOAT;case le.F32:return G.FLOAT;default:throw Error("whoops")}}(t),o=function(e){switch(e){case ue.R:return 1;case ue.RG:return 2;case ue.RGB:return 3;case ue.RGBA:return 4;default:return 1}}(r);return{size:o,type:i,normalized:!!(n&ce.Normalized)}}function Vt(e){switch(e){case z.CLAMP_TO_EDGE:return G.CLAMP_TO_EDGE;case z.REPEAT:return G.REPEAT;case z.MIRRORED_REPEAT:return G.MIRRORED_REPEAT;default:throw Error("whoops")}}function Xt(e,t){if(t===j.LINEAR&&e===K.BILINEAR)return G.LINEAR_MIPMAP_LINEAR;if(t===j.LINEAR&&e===K.POINT)return G.NEAREST_MIPMAP_LINEAR;if(t===j.NEAREST&&e===K.BILINEAR)return G.LINEAR_MIPMAP_NEAREST;if(t===j.NEAREST&&e===K.POINT)return G.NEAREST_MIPMAP_NEAREST;if(t===j.NO_MIP&&e===K.BILINEAR)return G.LINEAR;if(t===j.NO_MIP&&e===K.POINT)return G.NEAREST;throw Error("Unknown texture filter mode")}function Wt(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}n(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(Ft),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=k.Buffer;var o=n.viewOrSize,a=n.usage,s=n.hint,l=void 0===s?Q.STATIC:s,u=r.uniformBufferMaxPageByteSize,c=r.gl,f=a&q.UNIFORM;f||(Ut(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,p=E(o)?Be(o,4):Be(o.byteLength,4);if(i.gl_buffer_pages=[],f){for(var _=p;_>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(_,u),a,l)),_-=u;d=u}else i.gl_buffer_pages.push(i.createBufferPage(p,a,l)),d=p;return i.pageByteSize=d,i.byteSize=p,i.usage=a,i.gl_target=Gt(a),E(o)||i.setSubData(0,new Uint8Array(o.buffer)),f||(Ut(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,o=this.pageByteSize,a=e+n,s=e,l=e%o;a>s;){var u=Ut(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=Wt(this,s);if(c.ubo)return;i.bindBuffer(u,c),Ut(i)?i.bufferSubData(u,l,t,r,Math.min(a-s,o)):i.bufferSubData(u,l,t),s+=o,l=0,r+=o,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&q.UNIFORM;if(!Ut(n)&&i)return{ubo:!0};var o=this.device.ensureResourceExists(n.createBuffer()),a=Gt(t),s=function(e){switch(e){case Q.STATIC:return G.STATIC_DRAW;case Q.DYNAMIC:return G.DYNAMIC_DRAW}}(r);return n.bindBuffer(a,o),n.bufferData(a,e,s),o}}(Ft),function(e){function t(t){var r,n,i,o,a,s=t.device,u=t.descriptor,c=e.call(this,{id:t.id,device:s})||this;c.type=k.InputLayout;var d=u.vertexBufferDescriptors,p=u.indexBufferFormat,_=u.program;Ae(p===fe.U16_R||p===fe.U32_R||null===p);var h=null!==p?function(e){switch(e){case fe.U8_R:return G.UNSIGNED_BYTE;case fe.U16_R:return G.UNSIGNED_SHORT;case fe.U32_R:return G.UNSIGNED_INT;default:throw Error("whoops")}}(p):null,E=null!==p?Te(p):null,R=c.device.gl,v=c.device.ensureResourceExists(Ut(R)?R.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());Ut(R)?R.bindVertexArray(v):s.OES_vertex_array_object.bindVertexArrayOES(v),R.bindBuffer(R.ARRAY_BUFFER,Wt(c.device.fallbackVertexBuffer));try{for(var T=l(u.vertexBufferDescriptors),m=T.next();!m.done;m=T.next()){var A=m.value,g=A.stepMode,y=A.attributes;try{for(var S=(i=void 0,l(y)),C=S.next();!C.done;C=S.next()){var P=C.value,N=P.shaderLocation,M=P.format,I=P.divisor,O=void 0===I?1:I,x=Ut(R)?N:null===(a=_.attributes[N])||void 0===a?void 0:a.location,B=kt(M);if(P.vertexFormat=B,!f(x))wt(M),R.vertexAttribPointer(x,B.size,B.type,B.normalized,0,0),g===$.INSTANCE&&(Ut(R)?R.vertexAttribDivisor(x,O):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(x,O)),R.enableVertexAttribArray(x)}}catch(e){i={error:e}}finally{try{C&&!C.done&&(o=S.return)&&o.call(S)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{m&&!m.done&&(n=T.return)&&n.call(T)}finally{if(r)throw r.error}}return Ut(R)?R.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),c.vertexBufferDescriptors=d,c.vao=v,c.indexBufferFormat=p,c.indexBufferType=h,c.indexBufferCompByteSize=E,c.program=_,c}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(Ut(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(Ft);var Ht,Yt=function(e){function t(t){var r=t.device,n=t.descriptor,o=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=k.Texture,n=i({dimension:ee.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var s,l,u=a.device.gl,c=a.clampmipLevelCount(n);if(a.immutable=n.usage===te.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=me(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=c>=1,!o){l=a.device.ensureResourceExists(u.createTexture());var f=a.device.translateTextureType(n.format),d=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===ee.TEXTURE_2D){if(u.bindTexture(s=G.TEXTURE_2D,l),a.immutable)if(Ut(u))u.texStorage2D(s,c,d,n.width,n.height);else{var p=(d===G.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==fe.D32F&&a.format!==fe.D24_S8||Ut(u)||r.WEBGL_depth_texture)&&(u.texImage2D(s,p,d,n.width,n.height,0,d,f,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.LINEAR),u.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_S,G.CLAMP_TO_EDGE),u.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_T,G.CLAMP_TO_EDGE)))}Ae(1===n.depthOrArrayLayers)}else if(n.dimension===ee.TEXTURE_2D_ARRAY)u.bindTexture(s=G.TEXTURE_2D_ARRAY,l),a.immutable&&Ut(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===ee.TEXTURE_3D)u.bindTexture(s=G.TEXTURE_3D,l),a.immutable&&Ut(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==ee.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(s=G.TEXTURE_CUBE_MAP,l),a.immutable&&Ut(u)&&u.texStorage2D(s,c,d,n.width,n.height),Ae(6===n.depthOrArrayLayers)}}return a.gl_texture=l,a.gl_target=s,a.mipLevelCount=c,a}return n(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_UNORM:case le.BC4_SNORM:case le.BC5_UNORM:case le.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===G.TEXTURE_3D||this.gl_target===G.TEXTURE_2D_ARRAY,i=this.gl_target===G.TEXTURE_CUBE_MAP,o=Object.prototype.toString.call(e[0])in xt;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var a,s,l=e[0];o?(a=this.width,s=this.height):(s=l.height,this.width=a=l.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var u=this.device.translateTextureFormat(this.format),c=Ut(r)?this.device.translateInternalTextureFormat(this.format):u,f=this.device.translateTextureType(this.format);this.preprocessImage();for(var d=0;this.depthOrArrayLayers>d;d++){var p=e[d],_=this.gl_target;i&&(_=G.TEXTURE_CUBE_MAP_POSITIVE_X+d%6),this.immutable?r.texSubImage2D(_,t,0,0,a,s,u,f,p):Ut(r)?n?r.texImage3D(_,t,c,a,s,this.depthOrArrayLayers,0,u,f,p):r.texImage2D(_,t,c,a,s,0,u,f,p):o?r.texImage2D(_,t,u,a,s,0,u,f,p):r.texImage2D(_,t,u,u,f,p)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===ee.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&Ee(e.format)===le.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(G.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(G.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!Ut(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,G.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,G.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,G.TEXTURE_MIN_FILTER,G.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,G.TEXTURE_MAG_FILTER,G.LINEAR)):t.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!Ut(this.device.gl)&&(!Ie(this.width)||!Ie(this.height))},t}(Ft);let zt;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=k.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var o=i.device.gl,a=n.format,s=n.width,l=n.height,u=n.sampleCount,c=void 0===u?1:u,f=n.texture,d=!1;if(a!==fe.D32F&&a!==fe.D24_S8||!f||Ut(o)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,i.gl_renderbuffer);var p=i.device.translateTextureInternalFormat(a,!0);Ut(o)&&c>1?o.renderbufferStorageMultisample(G.RENDERBUFFER,c,p,s,l):o.renderbufferStorage(G.RENDERBUFFER,p,s,l)}return i.format=a,i.width=s,i.height=l,i.sampleCount=c,i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(Ft),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(Ht||(Ht={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=k.Program,i.uniformSetters={},i.attributes=[];var o=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(o.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=Ht.NeedsCompile,i.tryCompileProgram(),i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){Ae(this.compileState===Ht.NeedsCompile);var e=this.descriptor,t=e.vertex,r=e.fragment,n=this.device.gl;(null==t?void 0:t.glsl)&&(null==r?void 0:r.glsl)&&(this.gl_shader_vert=this.compileShader(t.postprocess?t.postprocess(t.glsl):t.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.postprocess?r.postprocess(r.glsl):r.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=Ht.Compiling,Ut(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r}(this.rawVertexGLSL,n),o=function(r){var n=t.getActiveAttrib(a.gl_program,r),o=n.name,s=n.type,l=n.size,u=t.getAttribLocation(a.gl_program,o),c=null===(e=i.find((function(e){return e.name===o})))||void 0===e?void 0:e.location;0>u||f(c)||(a.attributes[c]={name:o,location:u,type:s,size:l})},a=this,s=0;r>s;s++)o(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=Et(n.name).name,o=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=Ot(e,o,n),n&&n.size>1)for(var a=0;n.size>a;a++)o=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(a,"]")),this.uniformSetters["".concat(i,"[").concat(a,"]")]=Ot(e,o,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!Ut(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var o=e[n];o instanceof Yt&&(o=o.textureIndex),i(o)}}}return this}}(Ft),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.QueryPool;var i=n.device.gl;if(Ut(i)){var o=r.type;n.gl_query=Le(r.elemCount,(function(){return n.device.ensureResourceExists(i.createQuery())})),n.gl_query_type=function(e){if(e===se.OcclusionConservative)return G.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(o)}return n}n(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(Ut(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(Ut(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(Ft),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.Readback,r.gl_pbo=null,r.gl_sync=null,r}n(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise((function(i,o){!function a(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(a,h(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):o()}()}))},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,o){return a(this,void 0,void 0,(function(){var a;return s(this,(function(s){switch(s.label){case 0:return Ut(a=this.device.gl)?(this.gl_sync=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0),a.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),a.bindBuffer(e,t),a.getBufferSubData(e,r,n,i,o),a.bindBuffer(e,null),[2,n];case 2:return[2]}}))}))},t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),void 0===u&&(u=o.byteLength||0),a(this,void 0,void 0,(function(){var a,c,f,d,p;return s(this,(function(s){var _;return a=this.device.gl,f=this.device.translateTextureFormat((c=e).format),d=this.device.translateTextureType(c.format),p=ve(Ee(_=c.format))*he(_),Ut(a)?(this.gl_pbo=this.device.ensureResourceExists(a.createBuffer()),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.bufferData(a.PIXEL_PACK_BUFFER,u,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.bindFramebuffer(G.READ_FRAMEBUFFER,this.device.readbackFramebuffer),a.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,c.gl_texture,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.readPixels(t,r,n,i,f,d,l*p),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(a.PIXEL_PACK_BUFFER,this.gl_pbo,0,o,l,0)]):[2,this.readTextureSync(e,t,r,n,i,o,l,u)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){void 0===s&&(s=o.byteLength||0);var l=this.device.gl,u=e,c=this.device.translateTextureType(u.format);return l.bindFramebuffer(G.FRAMEBUFFER,this.device.readbackFramebuffer),l.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,u.gl_texture,0),l.pixelStorei(l.PACK_ALIGNMENT,4),l.readPixels(t,r,n,i,l.RGBA,c,o),o},t.prototype.readBuffer=function(e,t,r,n,i){return a(this,void 0,void 0,(function(){var o;return s(this,(function(a){return Ut(o=this.device.gl)?[2,this.getBufferSubDataAsync(o.ARRAY_BUFFER,Wt(e,t),t,r,n,i)]:[2,Promise.reject()]}))}))},t.prototype.destroy=function(){e.prototype.destroy.call(this),Ut(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(Ft),function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=k.RenderPipeline,a.drawMode=function(e){switch(e){case Z.TRIANGLES:return G.TRIANGLES;case Z.POINTS:return G.POINTS;case Z.TRIANGLE_STRIP:return G.TRIANGLE_STRIP;case Z.LINES:return G.LINES;case Z.LINE_STRIP:return G.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=o.topology)&&void 0!==r?r:Z.TRIANGLES),a.program=o.program,a.inputLayout=o.inputLayout,a.megaState=i(i({},Ve(We)),o.megaStateDescriptor),a.colorAttachmentFormats=o.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=o.depthStencilAttachmentFormat,a.sampleCount=null!==(n=o.sampleCount)&&void 0!==n?n:1,a}n(t,e)}(Ft),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.ComputePipeline,n.descriptor=r,n}n(t,e)}(Ft),function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Sampler;var a=o.device.gl;if(Ut(a)){var s=o.device.ensureResourceExists(a.createSampler());a.samplerParameteri(s,G.TEXTURE_WRAP_S,Vt(i.addressModeU)),a.samplerParameteri(s,G.TEXTURE_WRAP_T,Vt(i.addressModeV)),a.samplerParameteri(s,G.TEXTURE_WRAP_R,Vt(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),a.samplerParameteri(s,G.TEXTURE_MIN_FILTER,Xt(i.minFilter,i.mipmapFilter)),a.samplerParameteri(s,G.TEXTURE_MAG_FILTER,Xt(i.magFilter,j.NO_MIP)),void 0!==i.lodMinClamp&&a.samplerParameterf(s,G.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&a.samplerParameterf(s,G.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(a.samplerParameteri(s,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.samplerParameteri(s,a.TEXTURE_COMPARE_FUNC,i.compareFunction));var l=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;l>1&&null!==o.device.EXT_texture_filter_anisotropic&&(Ae(i.minFilter===K.BILINEAR&&i.magFilter===K.BILINEAR&&i.mipmapFilter===j.LINEAR),a.samplerParameterf(s,o.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l)),o.gl_sampler=s}else o.descriptor=i;return o}n(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,o=this.descriptor;this.isNPOT(t,r)?i.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.LINEAR):i.texParameteri(e,G.TEXTURE_MIN_FILTER,Xt(o.minFilter,o.mipmapFilter)),i.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_S,Vt(o.addressModeU)),i.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_T,Vt(o.addressModeV)),i.texParameteri(e,G.TEXTURE_MAG_FILTER,Xt(o.magFilter,j.NO_MIP));var a=null!==(n=o.maxAnisotropy)&&void 0!==n?n:1;a>1&&null!==this.device.EXT_texture_filter_anisotropic&&(Ae(o.minFilter===K.BILINEAR&&o.magFilter===K.BILINEAR&&o.mipmapFilter===j.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a))},t.prototype.destroy=function(){e.prototype.destroy.call(this),Ut(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!Ie(e)||!Ie(t)}}(Ft),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=k.RenderBundle,t.commands=[],t}n(t,e),t.prototype.push=function(e){this.commands.push(e)},t.prototype.replay=function(){this.commands.forEach((function(e){return e()}))}}(Ft);const Kt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Kt.decode();let jt=null;function Zt(){return null!==jt&&0!==jt.byteLength||(jt=new Uint8Array(zt.memory.buffer)),jt}function qt(e,t){return e>>>=0,Kt.decode(Zt().subarray(e,e+t))}const Qt=Array(128).fill(void 0);Qt.push(void 0,null,!0,!1);let $t=Qt.length;function Jt(e){return Qt[e]}function er(e){const t=Jt(e);return function(e){132>e||(Qt[e]=$t,$t=e)}(e),t}let tr=0;const rr="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},nr="function"==typeof rr.encodeInto?function(e,t){return rr.encodeInto(e,t)}:function(e,t){const r=rr.encode(e);return t.set(r),{read:e.length,written:r.length}};function ir(e,t,r){if(void 0===r){const r=rr.encode(e),n=t(r.length,1)>>>0;return Zt().subarray(n,n+r.length).set(r),tr=r.length,n}let n=e.length,i=t(n,1)>>>0;const o=Zt();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length,1)>>>0;const t=Zt().subarray(i+a,i+n);a+=nr(e,t).written}return tr=a,i}let or=null;function ar(){return null!==or&&0!==or.byteLength||(or=new Int32Array(zt.memory.buffer)),or}function sr(e,t,r){let n,i;try{const s=zt.__wbindgen_add_to_stack_pointer(-16),l=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc),u=tr,c=ir(t,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.glsl_compile(s,l,u,c,tr,r);var o=ar()[s/4+0],a=ar()[s/4+1];return n=o,i=a,qt(o,a)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(n,i,1)}}class lr{static __wrap(e){e>>>=0;const t=Object.create(lr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();zt.__wbg_wgslcomposer_free(e)}constructor(){const e=zt.wgslcomposer_new();return lr.__wrap(e)}load_composable(e){const t=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.wgslcomposer_load_composable(this.__wbg_ptr,t,tr)}wgsl_compile(e){let t,r;try{const o=zt.__wbindgen_add_to_stack_pointer(-16),a=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.wgslcomposer_wgsl_compile(o,this.__wbg_ptr,a,tr);var n=ar()[o/4+0],i=ar()[o/4+1];return t=n,r=i,qt(n,i)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(t,r,1)}}}function ur(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){$t===Qt.length&&Qt.push(Qt.length+1);const t=$t;return $t=Qt[t],Qt[t]=e,t}(qt(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){er(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(Jt(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(Jt(e),Jt(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(qt(e,t))},e}async function cr(e){if(void 0!==zt)return zt;const t=ur();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return zt=e.exports,cr.__wbindgen_wasm_module=t,or=null,jt=null,zt}(r,n)}var fr,dr;function pr(e){if(e===fe.U8_R_NORM)return"r8unorm";if(e===fe.S8_R_NORM)return"r8snorm";if(e===fe.U8_RG_NORM)return"rg8unorm";if(e===fe.S8_RG_NORM)return"rg8snorm";if(e===fe.U32_R)return"r32uint";if(e===fe.S32_R)return"r32sint";if(e===fe.F32_R)return"r32float";if(e===fe.U16_RG)return"rg16uint";if(e===fe.S16_RG)return"rg16sint";if(e===fe.F16_RG)return"rg16float";if(e===fe.U8_RGBA_RT)return"bgra8unorm";if(e===fe.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===fe.U8_RGBA_NORM)return"rgba8unorm";if(e===fe.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===fe.S8_RGBA_NORM)return"rgba8snorm";if(e===fe.U32_RG)return"rg32uint";if(e===fe.S32_RG)return"rg32sint";if(e===fe.F32_RG)return"rg32float";if(e===fe.U16_RGBA)return"rgba16uint";if(e===fe.S16_RGBA)return"rgba16sint";if(e===fe.F16_RGBA)return"rgba16float";if(e===fe.F32_RGBA)return"rgba32float";if(e===fe.U32_RGBA)return"rgba32uint";if(e===fe.S32_RGBA)return"rgba32sint";if(e===fe.D24)return"depth24plus";if(e===fe.D24_S8)return"depth24plus-stencil8";if(e===fe.D32F)return"depth32float";if(e===fe.D32F_S8)return"depth32float-stencil8";if(e===fe.BC1)return"bc1-rgba-unorm";if(e===fe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===fe.BC2)return"bc2-rgba-unorm";if(e===fe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===fe.BC3)return"bc3-rgba-unorm";if(e===fe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===fe.BC4_SNORM)return"bc4-r-snorm";if(e===fe.BC4_UNORM)return"bc4-r-unorm";if(e===fe.BC5_SNORM)return"bc5-rg-snorm";if(e===fe.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function _r(e){if(e===ee.TEXTURE_2D)return"2d";if(e===ee.TEXTURE_CUBE_MAP)return"cube";if(e===ee.TEXTURE_2D_ARRAY)return"2d-array";if(e===ee.TEXTURE_3D)return"3d";throw Error("whoops")}function hr(e){if(e===z.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===z.REPEAT)return"repeat";if(e===z.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function Er(e){if(e===K.BILINEAR)return"linear";if(e===K.POINT)return"nearest";throw Error("whoops")}function Rr(e){if(e===j.LINEAR)return"linear";if(e===j.NEAREST)return"nearest";if(e===j.NO_MIP)return"nearest";throw Error("whoops")}function vr(e){return e.gpuBuffer}function Tr(e){if(e===se.OcclusionConservative)return"occlusion";throw Error("whoops")}function mr(e){switch(e){case Z.TRIANGLES:return"triangle-list";case Z.POINTS:return"point-list";case Z.TRIANGLE_STRIP:return"triangle-strip";case Z.LINES:return"line-list";case Z.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function Ar(e){if(e===W.NONE)return"none";if(e===W.FRONT)return"front";if(e===W.BACK)return"back";throw Error("whoops")}function gr(e){if(e===X.CCW)return"ccw";if(e===X.CW)return"cw";throw Error("whoops")}function yr(e){if(e===H.ZERO)return"zero";if(e===H.ONE)return"one";if(e===H.SRC)return"src";if(e===H.ONE_MINUS_SRC)return"one-minus-src";if(e===H.DST)return"dst";if(e===H.ONE_MINUS_DST)return"one-minus-dst";if(e===H.SRC_ALPHA)return"src-alpha";if(e===H.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===H.DST_ALPHA)return"dst-alpha";if(e===H.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===H.CONST)return"constant";if(e===H.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===H.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function Sr(e){if(e===Y.ADD)return"add";if(e===Y.SUBSTRACT)return"subtract";if(e===Y.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===Y.MIN)return"min";if(e===Y.MAX)return"max";throw Error("whoops")}function Cr(e){return{operation:Sr(e.blendMode),srcFactor:yr(e.blendSrcFactor),dstFactor:yr(e.blendDstFactor)}}function Pr(e){return e.blendMode===Y.ADD&&e.blendSrcFactor===H.ONE&&e.blendDstFactor===H.ZERO}function Nr(e){return Pr(e.rgbBlendState)&&Pr(e.alphaBlendState)?void 0:{color:Cr(e.rgbBlendState),alpha:Cr(e.alphaBlendState)}}function Mr(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:pr(t),blend:Nr(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function Ir(e){if(e===V.NEVER)return"never";if(e===V.LESS)return"less";if(e===V.EQUAL)return"equal";if(e===V.LEQUAL)return"less-equal";if(e===V.GREATER)return"greater";if(e===V.NOTEQUAL)return"not-equal";if(e===V.GEQUAL)return"greater-equal";if(e===V.ALWAYS)return"always";throw Error("whoops")}function Or(e){if(e===ne.KEEP)return"keep";if(e===ne.REPLACE)return"replace";if(e===ne.ZERO)return"zero";if(e===ne.DECREMENT_CLAMP)return"decrement-clamp";if(e===ne.DECREMENT_WRAP)return"decrement-wrap";if(e===ne.INCREMENT_CLAMP)return"increment-clamp";if(e===ne.INCREMENT_WRAP)return"increment-wrap";if(e===ne.INVERT)return"invert";throw Error("whoops")}function xr(e){if(e===$.VERTEX)return"vertex";if(e===$.INSTANCE)return"instance";throw Error("whoops")}function Br(e){if(e===fe.U8_R)return"uint8x2";if(e===fe.U8_RG)return"uint8x2";if(e===fe.U8_RGB)return"uint8x4";if(e===fe.U8_RGBA)return"uint8x4";if(e===fe.U8_RG_NORM)return"unorm8x2";if(e===fe.U8_RGBA_NORM)return"unorm8x4";if(e===fe.S8_RGB_NORM)return"snorm8x4";if(e===fe.S8_RGBA_NORM)return"snorm8x4";if(e===fe.U16_RG_NORM)return"unorm16x2";if(e===fe.U16_RGBA_NORM)return"unorm16x4";if(e===fe.S16_RG_NORM)return"snorm16x2";if(e===fe.S16_RGBA_NORM)return"snorm16x4";if(e===fe.S16_RG)return"uint16x2";if(e===fe.F16_RG)return"float16x2";if(e===fe.F16_RGBA)return"float16x4";if(e===fe.F32_R)return"float32";if(e===fe.F32_RG)return"float32x2";if(e===fe.F32_RGB)return"float32x3";if(e===fe.F32_RGBA)return"float32x4";throw"whoops"}function Dr(e,t,r,n){switch(void 0===r&&(r=!1),e){case fe.S8_R:case fe.S8_R_NORM:case fe.S8_RG_NORM:case fe.S8_RGB_NORM:case fe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case fe.U8_R:case fe.U8_R_NORM:case fe.U8_RG:case fe.U8_RG_NORM:case fe.U8_RGB:case fe.U8_RGB_NORM:case fe.U8_RGB_SRGB:case fe.U8_RGBA:case fe.U8_RGBA_NORM:case fe.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case fe.S16_R:case fe.S16_RG:case fe.S16_RG_NORM:case fe.S16_RGB_NORM:case fe.S16_RGBA:case fe.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case fe.U16_R:case fe.U16_RGB:case fe.U16_RGBA_5551:case fe.U16_RGBA_NORM:case fe.U16_RG_NORM:case fe.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case fe.S32_R:var l=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&l.set(new Int32Array(n)),l;case fe.U32_R:case fe.U32_RG:var u=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&u.set(new Uint32Array(n)),u;case fe.F32_R:case fe.F32_RG:case fe.F32_RGB:case fe.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}function br(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(fr||(fr={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(dr||(dr={}));var Lr=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return n(t,e),t.prototype.destroy=function(){},t}(de),Fr=function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=k.Bindings;var s=o.pipeline;Ae(!!s);var l=o.uniformBufferBindings,u=o.storageBufferBindings,c=o.samplerBindings,f=o.storageTextureBindings;a.numUniformBuffers=(null==l?void 0:l.length)||0;var d=[[],[],[],[]],p=0;if(l&&l.length)for(var _=0;l.length>_;_++){var h=o.uniformBufferBindings[_],E=h.binding,R=h.size,v=h.offset,T={buffer:vr(h.buffer),offset:null!=v?v:0,size:R};d[0].push({binding:null!=E?E:p++,resource:T})}if(c&&c.length){p=0;for(_=0;c.length>_;_++){var m=i(i({},c[_]),Ke),A=null!==(E=o.samplerBindings[_]).texture?E.texture:a.device.getFallbackTexture(m);if(m.dimension=A.dimension,m.formatKind=me(A.format),d[1].push({binding:null!==(r=E.textureBinding)&&void 0!==r?r:p++,resource:A.gpuTextureView}),-1!==E.samplerBinding){var g=null!==E.sampler?E.sampler:a.device.getFallbackSampler(m),y=g.gpuSampler;d[1].push({binding:null!==(n=E.samplerBinding)&&void 0!==n?n:p++,resource:y})}}}if(u&&u.length){p=0;for(_=0;u.length>_;_++){var S=o.storageBufferBindings[_];E=S.binding,R=S.size,v=S.offset,T={buffer:vr(S.buffer),offset:null!=v?v:0,size:R};d[2].push({binding:null!=E?E:p++,resource:T})}}if(f&&f.length){p=0;for(_=0;f.length>_;_++){var C=o.storageTextureBindings[_];d[3].push({binding:null!=(E=C.binding)?E:p++,resource:(A=C.texture).gpuTextureView})}}var P=d.findLastIndex((function(e){return!!e.length}));return a.gpuBindGroup=d.map((function(e,t){return P>=t&&a.device.device.createBindGroup({layout:s.getBindGroupLayout(t),entries:e})})),a}return n(t,e),t}(Lr),Ur=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&q.MAP_READ);n.usage=function(e){var t=0;return e&q.INDEX&&(t|=GPUBufferUsage.INDEX),e&q.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&q.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&q.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&q.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),e&q.INDIRECT&&(t|=GPUBufferUsage.INDIRECT),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=q.MAP_READ|q.COPY_DST);var s=!E(o);(n.view=E(o)?null:o,n.size=E(o)?Be(o,4):Be(o.byteLength,4),E(o))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(o&&o.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap());return n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var l=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(l),r=0,o=0,a=s,n=s}for(var u=15728640,c=0;a-(o+c)>u;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,u),c+=u;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Lr),wr=function(){function e(){this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null},e.prototype.beginComputePass=function(e){Ae(null===this.gpuComputePassEncoder),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=ge(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){var t=this,r=e;r.gpuBindGroup.forEach((function(e,n){e&&t.gpuComputePassEncoder.setBindGroup(n,r.gpuBindGroup[n])}))},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),Gr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Lr),kr=function(e){function t(t){var r,n,i,o,a=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=k.InputLayout;var u=[];try{for(var c=l(a.vertexBufferDescriptors),f=c.next();!f.done;f=c.next()){var d=f.value,p=d.attributes;u.push({arrayStride:d.arrayStride,stepMode:xr(d.stepMode),attributes:[]});try{for(var _=(i=void 0,l(p)),h=_.next();!h.done;h=_.next()){var E=h.value,R=E.offset;u[u.length-1].attributes.push({shaderLocation:E.shaderLocation,format:Br(E.format),offset:R})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===fe.U16_R)return"uint16";if(e===fe.U32_R)return"uint32";throw Error("whoops")}}(a.indexBufferFormat),s.buffers=u,s}return n(t,e),t}(Lr),Vr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return n(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,o=e.entryPoint,a=e.postprocess,s=e.wgsl;if(!s)try{s=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var u=function(e){if(!s.includes(e))return"continue";s=(s=s.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")}))};try{for(var c=l(["u_TextureFramebufferDepth"]),f=c.next();!f.done;f=c.next()){u(f.value)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return a&&(s=a(s)),{module:this.device.device.createShaderModule({code:s}),entryPoint:o||"main"}},t}(Lr),Xr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:Tr(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(Lr),Wr=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.Readback,r}return n(t,e),t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),a(this,void 0,void 0,(function(){var a,u,c,f,d,p,_;return s(this,(function(s){return 0,u=br((a=e).gpuTextureformat),p=this.device.createBuffer({usage:q.STORAGE|q.MAP_READ|q.COPY_DST,hint:Q.STATIC,viewOrSize:d=(f=256*Math.ceil((c=Math.ceil(n/u.width)*u.length)/256))*i}),(_=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:a.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:p.gpuBuffer,offset:0,bytesPerRow:f},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),[2,this.readBuffer(p,0,o.byteLength===d?o:null,l,d,a.format,!0,!1,c,f,i)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,o,a,s,l,u,c){var f=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=fe.U8_RGB),void 0===a&&(a=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===c&&(c=0);var d=e,p=i||d.size,_=r||d.view,h=_&&_.constructor&&_.constructor.BYTES_PER_ELEMENT||Te(o),E=d;if(!(d.usage&q.MAP_READ&&d.usage&q.COPY_DST)){var R=this.device.device.createCommandEncoder();E=this.device.createBuffer({usage:q.STORAGE|q.MAP_READ|q.COPY_DST,hint:Q.STATIC,viewOrSize:p}),R.copyBufferToBuffer(d.gpuBuffer,t,E.gpuBuffer,0,p),this.device.device.queue.submit([R.finish()])}return new Promise((function(e,r){E.gpuBuffer.mapAsync(dr.READ,t,p).then((function(){var r=E.gpuBuffer.getMappedRange(t,p),n=_;if(a)n=null===n?Dr(o,p,!0,r):Dr(o,n.buffer,void 0,r);else if(null===n)switch(h){case 1:(n=new Uint8Array(p)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,r);break;case 4:(n=new Float32Array(p/4)).set(new Float32Array(r))}else switch(h){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,r,_);break;case 4:var i=_&&_.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}if(l!==u){1!==h||a||(l*=2,u*=2);for(var s=new Uint8Array(n.buffer),d=l,R=0,v=1;c>v;++v){R=v*u;for(var T=0;l>T;++T)s[d++]=s[R++]}n=0===h||a?new Uint8Array(s.buffer,0,d):new Float32Array(s.buffer,0,d/4)}E.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},t}(Lr),Hr=function(){function e(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getEncoder=function(){var e;return(null===(e=this.renderBundle)||void 0===e?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder},e.prototype.getTextureView=function(e,t){return Ae(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,o,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var l=0;e.colorAttachment.length>l;l++){var u=e.colorAttachment[l],c=e.colorResolveTo[l];if(null===u&&null!==c&&(u=c,c=null),this.gfxColorAttachment[l]=u,this.gfxColorResolveTo[l]=c,this.gfxColorAttachmentLevel[l]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[l])||0,this.gfxColorResolveToLevel[l]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[l])||0,null===u){this.gpuColorAttachments.length=l,this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;break}void 0===this.gpuColorAttachments[l]&&(this.gpuColorAttachments[l]={}),(p=this.gpuColorAttachments[l]).view=this.getTextureView(u,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[l])||0);var d=null!==(o=null===(i=e.colorClearColor)||void 0===i?void 0:i[l])&&void 0!==o?o:"load";"load"===d?p.loadOp="load":(p.loadOp="clear",p.clearValue=d),p.storeOp=(null===(a=e.colorStore)||void 0===a?void 0:a[l])?"store":"discard",p.resolveTarget=void 0,null!==c&&(u.sampleCount>1?p.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[l]):p.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var p,_=e.depthStencilAttachment;(p=this.gpuDepthStencilAttachment).view=_.gpuTextureView,!!(Re(_.format)&ce.Depth)?("load"===e.depthClearValue?p.depthLoadOp="load":(p.depthLoadOp="clear",p.depthClearValue=e.depthClearValue),p.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(p.depthLoadOp=void 0,p.depthStoreOp=void 0),!!(Re(_.format)&ce.Stencil)?("load"===e.stencilClearValue?p.stencilLoadOp="load":(p.stencilLoadOp="clear",p.stencilClearValue=e.stencilClearValue),p.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(p.stencilLoadOp=void 0,p.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=f(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e,t){Ae(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(t),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,o){void 0===i&&(i=0),void 0===o&&(o=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,o)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=ge(e.gpuRenderPipeline);this.getEncoder().setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=this.getEncoder(),i=e;null!==r&&n.setIndexBuffer(vr(r.buffer),ge(i.indexFormat),r.offset);for(var o=0;t.length>o;o++){var a=t[o];null!==a&&n.setVertexBuffer(o,vr(a.buffer),a.offset)}}},e.prototype.setBindings=function(e){var t=e,r=this.getEncoder();t.gpuBindGroup.forEach((function(e,n){e&&r.setBindGroup(n,t.gpuBindGroup[n])}))},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.getEncoder().draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.getEncoder().drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.getEncoder().drawIndirect(vr(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.getEncoder().drawIndexedIndirect(vr(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.beginBundle=function(e){this.renderBundle=e},e.prototype.endBundle=function(){this.renderBundle.finish()},e.prototype.executeBundles=function(e){this.gpuRenderPassEncoder.executeBundles(e.map((function(e){return e.renderBundle})))},e.prototype.finish=function(){var e;null===(e=this.gpuRenderPassEncoder)||void 0===e||e.end(),this.gpuRenderPassEncoder=null;for(var t=0;this.gfxColorAttachment.length>t;t++){var r=this.gfxColorAttachment[t],n=this.gfxColorResolveTo[t];null!==r&&null!==n&&1===r.sampleCount&&this.copyAttachment(n,this.gfxColorAttachmentLevel[t],r,this.gfxColorResolveToLevel[t])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null},e.prototype.copyAttachment=function(e,t,r,n){Ae(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};Ae(r.width>>>n==e.width>>>t),Ae(r.height>>>n==e.height>>>t),Ae(!!(r.usage&fr.COPY_SRC)),Ae(!!(e.usage&fr.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),Yr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Lr),zr=function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Sampler;var a=i.lodMinClamp,s=i.mipmapFilter===j.NO_MIP?i.lodMinClamp:i.lodMaxClamp,l=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return l>1&&Ae(i.minFilter===K.BILINEAR&&i.magFilter===K.BILINEAR&&i.mipmapFilter===j.LINEAR),o.gpuSampler=o.device.device.createSampler({addressModeU:hr(i.addressModeU),addressModeV:hr(i.addressModeV),addressModeW:hr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:a,lodMaxClamp:s,minFilter:Er(i.minFilter),magFilter:Er(i.magFilter),mipmapFilter:Rr(i.mipmapFilter),compare:void 0!==i.compareFunction?Ir(i.compareFunction):void 0,maxAnisotropy:l}),o}return n(t,e),t}(Lr),Kr=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Texture,o.flipY=!1;var a=r.format,s=r.dimension,l=r.width,u=r.height,c=r.depthOrArrayLayers,f=r.mipLevelCount,d=r.usage,p=r.pixelStore;return o.flipY=!!(null==p?void 0:p.unpackFlipY),o.device.createTextureShared({format:a,dimension:null!=s?s:ee.TEXTURE_2D,width:l,height:u,depthOrArrayLayers:null!=c?c:1,mipLevelCount:null!=f?f:1,usage:d,sampleCount:null!=i?i:1},o,n),o}return n(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,o={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=e.createTexture(o),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s],flipY:this.flipY},{texture:a,origin:[0,0,s]},[n,i]);return[a,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,o,a=this,s=this.device.device;if(this.isImageBitmapOrCanvases(e))n=(r=u(this.textureFromImageBitmapOrCanvas(s,e,this.depthOrArrayLayers),3))[0],i=r[1],o=r[2];else if(this.isVideo(e))n=s.importExternalTexture({source:e[0]});else{var l=br(this.gpuTextureformat),c=Math.ceil(this.width/l.width)*l.length;e.forEach((function(e){s.queue.writeTexture({texture:a.gpuTexture},e,{bytesPerRow:c},{width:a.width,height:a.height})}))}this.width=i,this.height=o,n&&(this.gpuTexture=n),this.gpuTextureView=this.gpuTexture.createView({dimension:_r(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(Lr),jr=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.RenderBundle,r.renderBundleEncoder=r.device.device.createRenderBundleEncoder({colorFormats:[r.device.swapChainFormat]}),r}return n(t,e),t.prototype.finish=function(){this.renderBundle=this.renderBundleEncoder.finish()},t}(Lr),Zr=function(){function e(e,t,r,n,i,o){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=fr.RENDER_ATTACHMENT|fr.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=oe.UPPER_LEFT,this.clipSpaceNearZ=ae.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.WGSLComposer=o,this.fallbackTexture2D=this.createFallbackTexture(ee.TEXTURE_2D,ie.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(ee.TEXTURE_2D,ie.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(ee.TEXTURE_2D_ARRAY,ie.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(ee.TEXTURE_3D,ie.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(ee.TEXTURE_CUBE_MAP,ie.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:z.REPEAT,addressModeV:z.REPEAT,minFilter:K.POINT,magFilter:K.POINT,mipmapFilter:j.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:z.REPEAT,addressModeV:z.REPEAT,minFilter:K.POINT,magFilter:K.POINT,mipmapFilter:j.NEAREST,compareFunction:V.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Kr({id:0,device:this,descriptor:{format:fe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:ee.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){Ae(0===this.frameCommandEncoderPool.length)},e.prototype.endFrame=function(){Ae(this.frameCommandEncoderPool.every((function(e){return null!==e}))),this.device.queue.submit(this.frameCommandEncoderPool.map((function(e){return e.finish()}))),this.frameCommandEncoderPool=[]},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new Ur({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Kr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new zr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Kr({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:ee.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:te.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=k.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.mipLevelCount,s=e.gpuTexture,l=e.gpuTextureView,u=e.usage;Ae(!!(u&fr.RENDER_ATTACHMENT));var c=new Kr({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:ee.TEXTURE_2D,mipLevelCount:a,usage:u},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=l,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=Lt(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=Lt(this.queryVendorInfo(),"frag",e.fragment.glsl)),new Vr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createProgramSimple=function(e){return new Vr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,o=pr(e.format),a=function(e){if(e===ee.TEXTURE_2D)return"2d";if(e===ee.TEXTURE_CUBE_MAP)return"2d";if(e===ee.TEXTURE_2D_ARRAY)return"2d";if(e===ee.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&te.SAMPLED&&(t|=fr.TEXTURE_BINDING|fr.COPY_DST|fr.COPY_SRC),e&te.STORAGE&&(t|=fr.TEXTURE_BINDING|fr.STORAGE_BINDING|fr.COPY_SRC|fr.COPY_DST),e&te.RENDER_TARGET&&(t|=fr.RENDER_ATTACHMENT|fr.TEXTURE_BINDING|fr.COPY_SRC|fr.COPY_DST),t}(e.usage);if(t.gpuTextureformat=o,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var l=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,sampleCount:e.sampleCount,usage:s}),u=l.createView();t.gpuTexture=l,t.gpuTextureView=u}},e.prototype.getFallbackSampler=function(e){return e.formatKind===ie.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===ee.TEXTURE_2D)return e.formatKind===ie.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===ee.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===ee.TEXTURE_3D)return this.fallbackTexture3D;if(t===ee.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===ie.Float?fe.U8_RGBA_NORM:fe.D24,usage:te.SAMPLED,width:1,height:1,depthOrArrayLayers:e===ee.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new Fr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new kr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new Gr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Yr({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new Xr({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,a=n.program,s=a.vertexStage,l=a.fragmentStage;if(null!==s&&null!==l){var u=n.megaStateDescriptor||{},c=u.stencilBack,d=u.stencilFront,p=o(u,["stencilBack","stencilFront"]),_=Ve(We);n.megaStateDescriptor=i(i(i({},_),{stencilBack:i(i({},_.stencilBack),c),stencilFront:i(i({},_.stencilFront),d)}),p);var h=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach((function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=we(void 0,h))}));var E,R,v=(E=null!==(r=n.topology)&&void 0!==r?r:Z.TRIANGLES,R=n.megaStateDescriptor,{topology:mr(E),cullMode:Ar(R.cullMode),frontFace:gr(R.frontFace)}),T=Mr(n.colorAttachmentFormats,n.megaStateDescriptor),m=function(e,t){if(!f(e))return{format:pr(e),depthWriteEnabled:!!t.depthWrite,depthCompare:Ir(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0,stencilFront:{compare:Ir(t.stencilFront.compare),passOp:Or(t.stencilFront.passOp),failOp:Or(t.stencilFront.failOp),depthFailOp:Or(t.stencilFront.depthFailOp)},stencilBack:{compare:Ir(t.stencilBack.compare),passOp:Or(t.stencilBack.passOp),failOp:Or(t.stencilBack.failOp),depthFailOp:Or(t.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),A=void 0;null!==n.inputLayout&&(A=n.inputLayout.buffers);var g=n.sampleCount,y={layout:"auto",vertex:i(i({},s),{buffers:A}),primitive:v,depthStencil:m,multisample:{count:g},fragment:i(i({},l),{targets:T})};e.gpuRenderPipeline=this.device.createRenderPipeline(y)}}},e.prototype.createReadback=function(){return new Wr({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderBundle=function(){return new jr({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();void 0===t&&(t=new Hr(this));var r=this.frameCommandEncoderPool.pop();return void 0===r&&(r=this.device.createCommandEncoder()),t.beginRenderPass(r,e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();void 0===e&&(e=new wr);var t=this.frameCommandEncoderPool.pop();return void 0===t&&(t=this.device.createCommandEncoder()),e.beginComputePass(t),e},e.prototype.submitPass=function(e){var t=e;t instanceof Hr?(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.renderPassPool.push(t)):t instanceof wr&&(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.computePassPool.push(t))},e.prototype.copySubTexture2D=function(e,t,r,n,i,o,a){var s=this.device.createCommandEncoder(),l=e,u=n,c={texture:u.gpuTexture,origin:[i,o,0],mipLevel:0,aspect:"all"},f={texture:l.gpuTexture,origin:[t,r,0],mipLevel:0,aspect:"all"};Ae(!!(u.usage&fr.COPY_SRC)),Ae(!!(l.usage&fr.COPY_DST)),s.copyTextureToTexture(c,f,[u.width,u.height,a||1]),this.device.queue.submit([s.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_SNORM:case le.BC4_UNORM:case le.BC5_SNORM:case le.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_SNORM:case le.BC4_UNORM:case le.BC5_SNORM:case le.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case fe.U16_RGBA_NORM:case fe.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===k.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===k.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===k.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===k.Sampler){(r=e).gpuSampler.label=t}else if(e.type===k.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),qr=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc","float32-filterable"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(o=this.pluginOptions.onContextLost,i.lost.then((function(){o&&o()}))),null===i)return[2,null];if(!(a=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,cr(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new Zr(t,i,e,a,sr,lr&&new lr)]}}))}))},e}(),Qr={exports:{}};function $r(e,t,r){r=r||2;var n,i,o,a,s,l,u,c=t&&t.length,f=c?t[0]*r:e.length,d=Jr(e,0,f,r,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=Jr(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(fn(a));for(s.sort(sn),i=0;s.length>i;i++)r=en(r=ln(s[i],r),r.next);return r}(e,t,d,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(l=e[_+1])&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-n,a-i))?1/u:0}return tn(d,p,r,n,i,u),p}function Jr(e,t,r,n,i){var o,a;if(i===Sn(e,t,r,n)>0)for(o=t;r>o;o+=n)a=An(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=An(o,e[o],e[o+1],a);return a&&hn(a,a.next)&&(gn(a),a=a.next),a}function en(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!hn(n,n.next)&&0!==_n(n.prev,n,n.next))n=n.next;else{if(gn(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function tn(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=cn(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,u=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;u>t&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0===s||0!==l&&n&&r.z>n.z?(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,u*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?nn(e,n,i,o):rn(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),gn(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?tn(e=on(en(e),t,r),t,r,n,i,o,2):2===a&&an(e,t,r,n,i,o):tn(en(e),t,r,n,i,o,1);break}}}function rn(e){var t=e.prev,r=e,n=e.next;if(_n(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(dn(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&_n(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function nn(e,t,r,n){var i=e.prev,o=e,a=e.next;if(_n(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=cn(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=cn(s,l,t,r,n),f=e.prevZ,d=e.nextZ;f&&f.z>=u&&d&&c>=d.z;){if(f!==e.prev&&f!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&_n(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==e.prev&&d!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&_n(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&_n(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&c>=d.z;){if(d!==e.prev&&d!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&_n(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function on(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!hn(i,o)&&En(i,n,n.next,o)&&Tn(i,o)&&Tn(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),gn(n),gn(n.next),n=e=o),n=n.next}while(n!==e);return en(n)}function an(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&pn(a,s)){var l=mn(a,s);return a=en(a,a.next),l=en(l,l.next),tn(a,t,r,n,i,o),void tn(l,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function sn(e,t){return e.x-t.x}function ln(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var l,u=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!dn(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(l=Math.abs(o-n.y)/(i-n.x),Tn(n,e)&&(d>l||l===d&&(n.x>r.x||n.x===r.x&&un(r,n)))&&(r=n,d=l)),n=n.next}while(n!==u);return r}(e,t);if(!r)return t;var n=mn(r,e),i=en(r,r.next);return en(n,n.next),t===r?i:t}function un(e,t){return 0>_n(e.prev,e,t.prev)&&0>_n(t.next,e,e.next)}function cn(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function fn(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function dn(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function pn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&En(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Tn(e,t)&&Tn(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(_n(e.prev,e,t.prev)||_n(e,t.prev,t))||hn(e,t)&&_n(e.prev,e,e.next)>0&&_n(t.prev,t,t.next)>0)}function _n(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function hn(e,t){return e.x===t.x&&e.y===t.y}function En(e,t,r,n){var i=vn(_n(e,t,r)),o=vn(_n(e,t,n)),a=vn(_n(r,n,e)),s=vn(_n(r,n,t));return i!==o&&a!==s||(!(0!==i||!Rn(e,r,t))||(!(0!==o||!Rn(e,n,t))||(!(0!==a||!Rn(r,e,n))||!(0!==s||!Rn(r,t,n)))))}function Rn(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function vn(e){return e>0?1:0>e?-1:0}function Tn(e,t){return 0>_n(e.prev,e,e.next)?_n(e,t,e.next)>=0&&_n(e,e.prev,t)>=0:0>_n(e,t,e.prev)||0>_n(e,e.next,t)}function mn(e,t){var r=new yn(e.i,e.x,e.y),n=new yn(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function An(e,t,r,n){var i=new yn(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function gn(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function yn(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Sn(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Qr.exports=$r,Qr.exports.default=$r,$r.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(Sn(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(Sn(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var l=0;for(a=0;n.length>a;a+=3){var u=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;l+=Math.abs((e[u]-e[f])*(e[c+1]-e[u+1])-(e[u]-e[c])*(e[f+1]-e[u+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},$r.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var Cn=Qr.exports;function Pn(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function Nn(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function Mn(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function In(e,t,r,n,i,o,a,s,l){if(0===l)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=Pn(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,l){var u=Mn(e,r,i,a,l),c=Mn(t,n,o,s,l),f=Nn(e,t,r,n,l),d=Nn(r,n,i,o,l),p=Nn(i,o,a,s,l),_=Nn(f.x,f.y,d.x,d.y,l),h=Nn(d.x,d.y,p.x,p.y,l);return[[e,t,f.x,f.y,_.x,_.y,u,c],[u,c,h.x,h.y,p.x,p.y,a,s]]}(e,t,r,n,i,o,a,s,.5),d=c(c([],u(f[0]),!1),[l-1],!1),p=c(c([],u(f[1]),!1),[l-1],!1);return In.apply(void 0,c([],u(d),!1))+In.apply(void 0,c([],u(p),!1))}function On(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function xn(e,t,r,n,i,o,a){if(0===a)return(Pn(e,t,r,n)+Pn(r,n,i,o)+Pn(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=On(e,r,i,a),l=On(t,n,o,a),u=Nn(e,t,r,n,a),c=Nn(r,n,i,o,a);return[[e,t,u.x,u.y,s,l],[s,l,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),l=s[0],f=s[1];return l.push(a-1),f.push(a-1),xn.apply(void 0,c([],u(l),!1))+xn.apply(void 0,c([],u(f),!1))}var Bn=function(){function e(){this.drawcalls=[]}return e.tag="c-renderable-3d",e}(),Dn=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),bn=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),Ln=function(){function e(){}return e.prototype.update=function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,o=e.z,a=void 0===o?0:o,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:a,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}},e}(),Fn=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.deleteById=function(e){delete this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=u(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}(),Un=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(f(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return void 0===(t=this.defines[e])?null:t;var t},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&Ae("1"===t),null!==t},e}(),wn=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=De(e,this.uniformBufferWordAlignment),Ae(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=De(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=De(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Ae(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=De(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return ge(this.shadowBufferF32)},e.prototype.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=ge(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:q.UNIFORM,hint:Q.DYNAMIC}));var t=De(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())ge(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Gn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function kn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Vn(e){return 0}var Xn=function(){this.keys=[],this.values=[]},Wn=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Xn);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=l(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=l(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function Hn(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:Lt(e,"vert",t,n),preprocessedFrag:Lt(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function Yn(e,t){return Ae(""!==e.preprocessedVert&&""!==t.preprocessedVert),Ae(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function zn(e,t){return e=Gn(e,t.blendMode),e=Gn(e,t.blendSrcFactor),e=Gn(e,t.blendDstFactor)}function Kn(e,t){return e=zn(e,t.rgbBlendState),e=Gn(e=zn(e,t.alphaBlendState),t.channelWriteMask)}function jn(e,t){for(var r,n,i,o,a,s,l,u,c=0;t.attachmentsState.length>c;c++)e=Kn(e,t.attachmentsState[c]);return e=function(e,t){return Gn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Gn(e,t.depthCompare),e=Gn(e,t.depthWrite?1:0),e=Gn(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=Gn(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=Gn(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=Gn(e,null===(o=t.stencilFront)||void 0===o?void 0:o.depthFailOp),e=Gn(e,null===(a=t.stencilBack)||void 0===a?void 0:a.compare),e=Gn(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=Gn(e,null===(l=t.stencilBack)||void 0===l?void 0:l.failOp),e=Gn(e,null===(u=t.stencilBack)||void 0===u?void 0:u.depthFailOp),e=Gn(e,t.stencilWrite?1:0),e=Gn(e,t.cullMode),e=Gn(e,t.frontFace?1:0),e=Gn(e,t.polygonOffset?1:0)}function Zn(e){var t=0;t=Gn(t,e.program.id),null!==e.inputLayout&&(t=Gn(t,e.inputLayout.id)),t=jn(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=Gn(t,e.colorAttachmentFormats[r]||0);return kn(t=Gn(t,e.depthStencilAttachmentFormat||0))}function qn(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Gn(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Gn(t,n.buffer.id),t=Gn(t,n.binding),t=Gn(t,n.offset),t=Gn(t,n.size))}return kn(t)}var Qn,$n,Jn=function(){function e(e){this.bindingsCache=new Wn(Je,qn),this.renderPipelinesCache=new Wn(ot,Zn),this.inputLayoutsCache=new Wn(lt,Vn),this.programCache=new Wn(Yn,Vn),this.samplerCache=new Wn(ut,Vn),this.device=e}return e.prototype.createBindings=function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Ze(t.samplerBindings,ct),uniformBufferBindings:t.uniformBufferBindings&&Ze(t.uniformBufferBindings,ft),storageBufferBindings:t.storageBufferBindings&&Ze(t.storageBufferBindings,ft),storageTextureBindings:t.storageTextureBindings&&Ze(t.storageTextureBindings,dt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter((function(e){return e.size>0})),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r},e.prototype.createRenderPipeline=function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var o=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&Ve(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});o.colorAttachmentFormats=o.colorAttachmentFormats.filter((function(e){return e})),i=this.device.createRenderPipeline(o),this.renderPipelinesCache.add(o,i)}return i},e.prototype.createInputLayout=function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Ze((t=e).vertexBufferDescriptors,_t),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r},e.prototype.createProgramSimple=function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,o=null;if(i&&n&&(o=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===o){var a=Hn(this.device,e),s=a.preprocessedVert,l=a.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=l;var u={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};o=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:l}},r),this.programCache.add(u,o)}return o},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,u,c;try{for(var f=l(this.bindingsCache.values()),d=f.next();!d.done;d=f.next()){d.value.destroy()}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var p=l(this.renderPipelinesCache.values()),_=p.next();!_.done;_=p.next()){_.value.destroy()}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var h=l(this.inputLayoutsCache.values()),E=h.next();!E.done;E=h.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}try{for(var R=l(this.programCache.values()),v=R.next();!v.done;v=R.next()){v.value.destroy()}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var T=l(this.samplerCache.values()),m=T.next();!m.done;m=T.next()){m.value.destroy()}}catch(e){u={error:e}}finally{try{m&&!m.done&&(c=T.return)&&c.call(T)}finally{if(u)throw u.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(Qn||(Qn={})),function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil"}($n||($n={}));var ei,ti=function(){function e(){this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),Ae(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.exec=function(e){Ae(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){Ae(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),ri=function(){function e(e,t){this.dimension=ee.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=te.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,Ae(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){Ae(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.attachment.destroy()},e}(),ni=function(){function e(e,t){this.dimension=ee.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=te.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){Ae(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),ii=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},oi=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new ri(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new ni(this.device,e)},e.prototype.beginGraphBuilder=function(){Ae(null===this.currentGraph),this.currentGraph=new ii},e.prototype.pushPass=function(e){var t=new ti;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null},e.prototype.resolveRenderTargetPassAttachmentSlot=function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]},e.prototype.findPassForResolveRenderTarget=function(e){var t=ge(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Ae(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);Ae(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return ge(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(Ae(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=ge(this.renderTargetAliveForID[e]);return t?(Ae(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Ae(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Ae(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=ge(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return ge(n.texture)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;Ae(!(a&&s));var l=null,u=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(u=!0),a){Ae(e.resolveTextureRenderTargetIDs[i]===n),Ae(this.resolveTextureUseCount[i]>0),Ae(this.renderTargetOutputCount[n]>0);var f=ge(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])l=null,u=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=ge(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}l=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(l=o,c=t.resolveTextureOutputExternalTextureLevel[r]):l=null;return{resolveTo:l,store:u,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[$n.DepthStencil],n=$n.Color0;$n.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,l=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=l,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[$n.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,$n.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,p=0,_=0,h=0;t.renderTargets.length>h;h++){var E=t.renderTargets[h];if(E){var R=E.width>>>t.renderTargetLevels[h],v=E.height>>>t.renderTargetLevels[h];0===d&&(d=R,p=v,_=E.sampleCount),Ae(R===d),Ae(v===p),Ae(E.sampleCount===_),E.needsClear=!1}}d>0&&p>0&&(t.viewportX*=d,t.viewportY*=p,t.viewportW*=d,t.viewportH*=p);for(h=0;t.resolveTextureInputIDs.length>h;h++){t.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[h])}for(h=0;t.renderTargetIDs.length>h;h++)this.releaseRenderTargetForID(t.renderTargetIDs[h],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){Ae(0===this.renderTargetOutputCount.length),Ae(0===this.renderTargetResolveCount.length),Ae(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;xe(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),xe(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),xe(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)Ae(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)Ae(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)Ae(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)Ae(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){Ae(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0},e.prototype.execute=function(){var e=ge(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Ae(r>=0),ge(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Ae(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)Ae(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(ei||(ei={}));var ai=65536,si=16;function li(e,t,r){void 0===r&&(r=ai);var n=h(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<si)-1)}function ui(e,t){return(16777215&e|(255&t)<<24)>>>0}function ci(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function fi(e,t){return ui(ci(0,t),e)}function di(e,t){return Ae(t>=0),(4294967040&e|t>>>8&255)>>>0}function pi(e){return ui(0,e)}function _i(e,t){return Ae(t>=0),(4278190335&e|t<<8)>>>0}var hi=A(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Ei,Ri=A(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function vi(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(Ei||(Ei={}));var Ti,mi=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Le(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Le(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:Ve(We),program:null,topology:Z.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=Ei.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){var t,r;ke(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],u(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~Ei.InheritedFlags|e.flags&Ei.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],o=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=o.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=o.uniformBufferBindings)||void 0===r?void 0:r.length});for(n=0;Math.min(i.uniformBufferBindings.length,o.uniformBufferBindings.length)>n;n++)i.uniformBufferBindings[n].size=e.bindingDescriptors[0].uniformBufferBindings[n].size;this.setSamplerBindingsFromTextureMappings(o.samplerBindings);for(n=0;e.dynamicUniformBufferByteOffsets.length>n;n++)this.dynamicUniformBufferByteOffsets[n]=e.dynamicUniformBufferByteOffsets[n]},e.prototype.validate=function(){for(var e,t=0;this.bindingDescriptors.length>t;t++)for(var r=this.bindingDescriptors[t],n=0;n<(null===(e=r.uniformBufferBindings)||void 0===e?void 0:e.length);n++)Ae(r.uniformBufferBindings[n].size>0);Ae(this.drawCount>0)},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return ke(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setVertexInput=function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){Ae(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=be(this.flags,Ei.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=be(this.flags,Ei.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=be(this.flags,Ei.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(E(t)||Array.isArray(t)||t instanceof Float32Array){var i=E(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],u(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),l=0;n.length>l;l+=4)a+=vi(s,a,n[l],n[l+1],n[l+2],n[l+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){var r;return Ae((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=be(this.flags,Ei.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:Ae(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:Ae(n==a.sampleCount)),Ae(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&Ei.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=ge(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(s),this.flags&Ei.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0},e}();function Ai(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Ti||(Ti={}));var gi=function(){function e(e,t){void 0===e&&(e=Ai),void 0===t&&(t=Ti.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=Ei.Draw,this.insertSorted(e)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){if(this.ensureSorted(),this.executionOrder===Ti.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(r=this.renderInsts.length-1;r>=0;r--)this.renderInsts[r].drawOnPass(e,t)},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),yi=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new mi),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),Si=function(){function e(e){this.renderCache=e,this.instPool=new yi,this.templatePool=new yi,this.simpleRenderInstList=new gi,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){Ae(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Ei.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Ae(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){ge(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){ge(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),Ci=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Jn(e),this.renderGraph=new oi(this.device),this.renderInstManager=new Si(this.renderCache),this.uniformBuffer=new wn(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Qn.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),Pi=function(){function e(e){this.format=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function Ni(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Mi,Ii=Ni(Se(.88,.88,.88,1)),Oi=Ni(Pe),xi=Ni(Me);function Bi(e,t){var r=function(e){return e.antialiasingMode===Mi.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Di(e,t,r){var n=function(e){if(e===$n.Color0)return fe.U8_RGBA_RT;if(e===$n.DepthStencil)return fe.D24_S8;throw Error("whoops")}(e),i=new Pi(n);return Bi(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(Mi||(Mi={}));var bi,Li=function(){function e(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),Fi=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Ae(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new ni(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),Ui=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(bi||(bi={}));var wi,Gi=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:bi.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);function ki(e,t,r,n){void 0===n&&(n=Q.STATIC);var i=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:n});return i.setSubData(0,new Uint8Array(r)),i}!function(e){e.CHANGED="changed"}(wi||(wi={}));var Vi,Xi,Wi=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=Z.TRIANGLES,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ki(this.device,q.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=fe.U32_R,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===o}));s?(s.format=n,s.offset=i,s.divisor=a):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:o,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=ki(this.device,q.VERTEX,i.buffer,Q.DYNAMIC);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var o=i.arrayStride,a=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(a)this.getVertexBuffer(e).setSubData(a.offset+r*o,n);this.emit(wi.CHANGED)}},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(de),Hi=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",t}return n(t,e),t}(Un),Yi=Le(1,(function(){return new Li}));function zi(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID($n.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(He),a.setBindingLayout({numUniformBuffers:1,numSamplers:1}),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);vi(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var l=new Hi,u=t.renderCache.createProgramSimple(l);a.setProgram(u),Vi||((Vi=new Wi(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),Vi.vertexCount=3,Xi=t.getCache().createInputLayout(Vi.inputLayoutDescriptor)),i.exec((function(e,r){Yi[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Yi),a.setVertexInput(Xi,Vi.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),a.drawOnPass(t.renderCache,e)}))}))}var Ki;!function(e){e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking"}(Ki||(Ki={}));var ji,Zi=function(){function e(e,t,r,n,i){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.options=i,this.renderLists={leftEye:new gi,rightEye:new gi,picking:new gi},this.cameras=[]}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,l=r.config,f=r.renderingContext.root.ownerDocument.defaultView;l.disableRenderHooks=!0;var d=function(e){var t=e.target;t.nodeName!==Ui.tag?t.nodeName!==Gi.tag?(t.renderable3D||(t.renderable3D=new Bn),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},p=function(e){var r,i,o=e.target;if(o.nodeName!==Ui.tag)if(o.nodeName!==Gi.tag){if(o.nodeName===t.Shape.MESH){var a;if(null===(r=o.style.geometry)||void 0===r?void 0:r.meshes)(a=o.style.geometry.meshes.indexOf(o))>-1&&o.style.geometry.meshes.splice(a,1);if(null===(i=o.style.material)||void 0===i?void 0:i.meshes)(a=o.style.material.meshes.indexOf(o))>-1&&o.style.material.meshes.splice(a,1)}n.swapChain&&n.batchManager.remove(o),delete o.renderable3D}else n.lightPool.removeFog(o);else n.lightPool.removeLight(o)},_=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},h=function(e){n.swapChain&&n.batchManager.updateAttribute(e.target,"modelMatrix",null)};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return f.addEventListener(t.ElementEvent.MOUNTED,d),f.addEventListener(t.ElementEvent.UNMOUNTED,p),f.addEventListener(t.ElementEvent.ATTR_MODIFIED,_),f.addEventListener(t.ElementEvent.BOUNDS_CHANGED,h),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((n=this.context.config).width,n.height),o=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return o.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),f.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),f.removeEventListener(t.ElementEvent.MOUNTED,d),f.removeEventListener(t.ElementEvent.UNMOUNTED,p),f.removeEventListener(t.ElementEvent.ATTR_MODIFIED,_),f.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,h),n.device.destroy(),n.device.checkForLeaks(),l.disableRenderHooks=!1})),o.hooks.beginFrame.tap(e.tag,(function(e){var r,i=null==e?void 0:e.session,o=n.context.config,a=o.width,s=o.height;if(i){var l=i.renderState.baseLayer;l||(l=i.renderState.layers[0]),n.swapChain.configureSwapChain(l.framebufferWidth,l.framebufferHeight,l.framebuffer);var f=e.getViewerPose(i.referenceSpace);f&&f.views.forEach((function(e,t){var r=i.renderState.baseLayer.getViewport(e),o=A.apply(b,c([],u(e.transform.matrix),!1));o[12]*=a,o[13]*=s,o[14]*=500,o[12]+=a/2,o[13]-=s/2,o[14]+=250;var f=A.apply(b,c([],u(e.projectionMatrix),!1)),d=y(T(),o);C(d,d,L(1,-1,1));var p=e.transform.position;n.cameras[t]={viewport:{x:r.x/l.framebufferWidth,y:r.y/l.framebufferHeight,width:r.width/l.framebufferWidth,height:r.height/l.framebufferHeight},projectionMatrix:f,viewMatrix:d,cameraPosition:[p.x,p.y,p.z],isOrtho:!1}}))}else{var d=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:d.getPerspective(),viewMatrix:d.getViewTransform(),cameraPosition:d.getPosition(),isOrtho:d.isOrtho()}]}var p,_=n.swapChain.getCanvas(),h=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)p=Ce;else{var E=t.parseColor(n.context.config.background);p=n.context.config.background?Se(Number(E.r)/255*Number(E.alpha),Number(E.g)/255*Number(E.alpha),Number(E.b)/255*Number(E.alpha),Number(E.alpha)):Ne}var R={backbufferWidth:_.width,backbufferHeight:_.height,antialiasingMode:Mi.None},v=Di($n.Color0,R,Ni(p)),m=Di($n.DepthStencil,R,xi),g=n.builder.createRenderTargetID(v,"Main Color"),S=n.builder.createRenderTargetID(m,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID($n.Color0,g),e.attachRenderTargetID($n.DepthStencil,S),e.exec((function(e,t){n.cameras.forEach((function(r,i){var o=r.viewport,a=t.currentPass,s=a.viewportW,l=a.viewportH;e.setViewport(o.x*s,o.y*l,o.width*s,o.height*l),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(h.renderCache,e)}))}))})),(null===(r=n.options)||void 0===r?void 0:r.enableFXAA)&&zi(n.builder,n.renderHelper,R,g),n.builder.resolveRenderTargetToExternalTexture(g,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,o=r.height;if(n.cameras.forEach((function(e,r){var a=e.viewport,s=e.cameraPosition,l=e.viewMatrix,u=e.projectionMatrix,c=e.isOrtho,f=a.width,d=a.height,p=n.renderHelper.pushTemplateRenderInst();p.setBindingLayout({numUniformBuffers:2,numSamplers:0}),p.setMegaStateFlags(Ye({depthWrite:!0,blendConstant:Ce},{rgbBlendMode:Y.ADD,alphaBlendMode:Y.ADD,rgbBlendSrcFactor:H.SRC_ALPHA,alphaBlendSrcFactor:H.ONE,rgbBlendDstFactor:H.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:H.ONE_MINUS_SRC_ALPHA})),p.setUniforms(0,[{name:Ki.PROJECTION_MATRIX,value:u},{name:Ki.VIEW_MATRIX,value:l},{name:Ki.CAMERA_POSITION,value:s},{name:Ki.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Ki.VIEWPORT,value:[i*f,o*d]},{name:Ki.IS_ORTHO,value:c?1:0},{name:Ki.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()})),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var a=n.captureOptions,s=a.type,l=a.encoderOptions,u=n.context.contextService.getDomElement().toDataURL(s,l);n.resolveCapturePromise(u),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),qi=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new Bn);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},u=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,l),o.addEventListener(t.ElementEvent.UNMOUNTED,u)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,l),o.removeEventListener(t.ElementEvent.UNMOUNTED,u),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){return a(n,void 0,void 0,(function(){return s(this,(function(t){return[2,this.pick(e)]}))}))}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,l=this.context.config.height*a,u=i*a,c=o*a;if(!this.renderHelper.renderGraph||u>s||0>u||c>l||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(h(Math.round(u),0,s-1),h(Math.round(c),0,l-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n=this,o=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),u=this.context.camera,c=e.x,f=e.y,d=e.width,p=e.height,_={backbufferWidth:d,backbufferHeight:p,antialiasingMode:Mi.None},h=Di($n.Color0,_,Ni(Ce)),E=l.createRenderTargetID(h,"Picking Color"),R=Di($n.DepthStencil,_,xi),v=l.createRenderTargetID(R,"Picking Depth"),T=i({},u.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID($n.Color0,E),e.attachRenderTargetID($n.DepthStencil,v),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t,i=e.getRenderTargetTexture($n.Color0),a=o.createReadback();T&&T.enabled?u.setViewOffset(T.fullWidth,T.fullHeight,T.offsetX,T.offsetY,T.width,T.height):u.clearViewOffset(),u.setEnableUpdate(!0);try{t=a.readTextureSync(i,0,0,d,p,new Uint8Array(d*p*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var l=n.pickingIdGenerator.getById(s);l&&l.isVisible()&&l.isInteractive()&&(r=l)}a.destroy()}))}));var m=this.renderHelper.pushTemplateRenderInst();m.setBindingLayout({numUniformBuffers:2,numSamplers:0}),m.setMegaStateFlags(Ye({depthWrite:!0},{rgbBlendMode:Y.ADD,rgbBlendSrcFactor:H.ONE,rgbBlendDstFactor:H.ZERO,alphaBlendMode:Y.ADD,alphaBlendSrcFactor:H.ONE,alphaBlendDstFactor:H.ZERO}));var A=this.context.config,g=A.width,y=A.height,S=this.context.contextService.getDPR();return u.setEnableUpdate(!1),u.setViewOffset(g*S,y*S,c,y*S-f,d,p),m.setUniforms(0,[{name:Ki.PROJECTION_MATRIX,value:u.getPerspective()},{name:Ki.VIEW_MATRIX,value:u.getViewTransform()},{name:Ki.CAMERA_POSITION,value:u.getPosition()},{name:Ki.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Ki.VIEWPORT,value:[d,p]},{name:Ki.IS_ORTHO,value:u.isOrtho()?1:0},{name:Ki.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r},e.tag="WebGLPicker",e}(),Qi=5e-4,$i=function(){function e(){this.clipPathMeshCreated=!1}return e.prototype.beforeUploadUBO=function(e,t){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();!function(e){e.CHANGED="changed"}(ji||(ji={}));var Ji=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=Ve(We),a=o.cullMode,s=o.depthCompare,l=o.depthWrite,u=o.stencilFront,c=o.stencilBack,f=o.stencilWrite,d=o.frontFace,p=o.polygonOffset,_=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:l,stencilFront:u,stencilBack:c,stencilWrite:f,frontFace:d,polygonOffset:p,attachmentsState:_,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilFront",{get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilBack",{get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var t=u(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,(function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var l=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},u=0;5>u;u++)l(u);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(J.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),f(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(ji.CHANGED)},t}(de),eo=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Ji);function to(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function ro(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var no=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=u(e,2);return void 0!==t[1]})))};function io(e,t){return 256*(e=h(Math.floor(e),0,255))+(t=h(Math.floor(t),0,255))}var oo,ao,so=1,lo="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX"}(oo||(oo={})),function(e){e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX"}(ao||(ao={}));var uo,co,fo=function(){function e(e,t,r,n,i,o,a){void 0===o&&(o=-1),this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.drawcallCtors=i,this.index=o,this.context=a,this.id=so++,this.gradientAttributeName="fill",this.objects=[],this.program=new Un,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new eo(this.context.device),this.material.defines=i(i({},to(ao)),this.material.defines),this.geometry=new Wi(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(wi.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(ji.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!i&&!o||(!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n])))},e.prototype.shouldMerge=function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r,n,i=this,o=T(),a=T(),s=[],l=[],f=[],d=[],p=this.divisor,_=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var r,n=e.parsedStyle,p=n.fill,h=n.stroke,E=n.opacity,R=void 0===E?1:E,v=n.fillOpacity,T=void 0===v?1:v,A=n.strokeOpacity,g=void 0===A?1:A,y=n.lineWidth,S=void 0===y?1:y,C=n.visibility,N=n.increasedLineWidthForHitTesting,M=void 0===N?0:N,I=[0,0,0,0];t.isCSSRGB(p)&&(I=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var O=[0,0,0,0];t.isCSSRGB(h)&&(O=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),D(a,i.context.camera.getViewTransform(),o);var x=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var B=e.parsedStyle,b=B.x,F=B.y,U=B.z;D(o,e.getWorldTransform(),P(o,L(b,F,U)))}else m(o,e.getWorldTransform());s.push.apply(s,c([],u(o),!1)),l.push(io(I[0],I[1]),io(I[2],I[3]),io(O[0],O[1]),io(O[2],O[3])),f.push(R,T,g,S,"hidden"!==C?1:0,_,_,M),d.push.apply(d,c(c([],u(x),!1),[e.sortable.renderOrder*Qi],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:oo.MODEL_MATRIX,byteStride:64,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.MODEL_MATRIX0,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.MODEL_MATRIX1,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:32,location:ao.MODEL_MATRIX2,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:48,location:ao.MODEL_MATRIX3,divisor:p}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:oo.PACKED_COLOR,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PACKED_COLOR,divisor:p}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:oo.PACKED_STYLE,byteStride:32,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PACKED_STYLE1,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.PACKED_STYLE2,divisor:p}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:oo.PICKING_COLOR,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PICKING_COLOR,divisor:p}],data:new Float32Array(d)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:V.ALWAYS,passOp:ne.REPLACE},this.material.stencilBack={compare:V.ALWAYS,passOp:ne.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:V.EQUAL,passOp:ne.KEEP},this.material.stencilBack={compare:V.EQUAL,passOp:ne.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var o=i({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=i(i(i({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new Li;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:z.CLAMP_TO_EDGE,addressModeV:z.CLAMP_TO_EDGE,minFilter:K.POINT,magFilter:K.BILINEAR,mipmapFilter:j.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ro(o,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),to(ao)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),l=this.renderHelper.getCache().createInputLayout(i(i({},this.geometry.inputLayoutDescriptor),{program:s})),u=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(l,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),u?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),u?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=fi(ei.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){var o,a,s=this;if(0!==e.length){if("fill"===n||"stroke"===n){var l=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=[0,0,0,0];t.isCSSRGB(n)&&(o=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var a=[0,0,0,0];t.isCSSRGB(i)&&(a=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),l.push(io(o[0],o[1]),io(o[2],o[3]),io(a[0],a[1]),io(a[2],a[3]))})),this.geometry.updateVertexBuffer(oo.PACKED_COLOR,ao.PACKED_COLOR,r,new Uint8Array(new Float32Array(l).buffer));var f=this.instance.parsedStyle.fill,d=this.textureMappings.findIndex((function(e){return e.name===lo}));if(t.isCSSRGB(f))0>d||(this.textureMappings.splice(d,-1),this.material.textureDirty=!0);else{var p=this.createFillGradientTextureMapping([this.instance]);0>d||this.textureMappings.splice(d,1,p),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var _=[],h=(null===(o=e[0])||void 0===o?void 0:o.nodeName)===t.Shape.CIRCLE||(null===(a=e[0])||void 0===a?void 0:a.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,o=t.lineWidth,a=t.increasedLineWidthForHitTesting;_.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===o?1:o,"hidden"!==t.visibility?1:0,h,h,void 0===a?0:a)})),this.geometry.updateVertexBuffer(oo.PACKED_STYLE,ao.PACKED_STYLE1,r,new Uint8Array(new Float32Array(_).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var E=[],R=T();e.forEach((function(e){if(s.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;D(R,e.getWorldTransform(),P(R,L(r,n,i)))}else m(R,e.getWorldTransform());E.push.apply(E,c([],u(R),!1))})),this.geometry.updateVertexBuffer(oo.MODEL_MATRIX,ao.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(E).buffer))}else if("pointerEvents"===n){var v=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];v.push.apply(v,c(c([],u(r),!1),[e.sortable.renderOrder*Qi],!1))})),this.geometry.updateVertexBuffer(oo.PICKING_COLOR,ao.PICKING_COLOR,r,new Uint8Array(new Float32Array(v).buffer))}}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)},e.prototype.changeRenderOrder=function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(oo.PICKING_COLOR,ao.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],u(i),!1),[t*Qi],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=oo.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var l=t[i],u=1;e.vertices.length>u;u++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[u].arrayStride)/4,f=0;c>f;f++)e.vertices[u][a*c+f]=n[u][l*c+f];s[i]=a,a++}for(i=oo.PICKING_COLOR+1;e.vertexBuffers.length>i;i++){var d=e.inputLayoutDescriptor.vertexBufferDescriptors[i],p=(o=d.arrayStride,e.inputLayoutDescriptor.vertexBufferDescriptors[i].attributes[0]);if(p)e.setVertexBuffer({bufferIndex:i,byteStride:o,stepMode:d.stepMode,attributes:[{format:p.format,bufferByteOffset:p.offset,location:p.shaderLocation,divisor:p.divisor}],data:e.vertices[i]})}var _=new Float32Array(3*r);for(i=0;r>i;)for(u=0;3>u;u++){_[3*(l=s[i++])+u]=1}e.setVertexBuffer({bufferIndex:oo.BARYCENTRIC,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Number(ao.BARYCENTRIC)}],data:_}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t){},e.prototype.uploadUBO=function(e){var r,n=this,o=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),l=!!s,u=null!==(r=o.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(o.defines.USE_WIREFRAME){var f=t.parseColor(o.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:o.wireframeLineWidth})}if(l&&this.uploadFog(c,s),this.uploadMaterial(c,o),u){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var p=o.blendEquation,_=o.blendEquationAlpha,h=o.blendSrc,E=o.blendDst,R=o.blendSrcAlpha,v=o.blendDstAlpha,T=no({blendConstant:o.blendConstant,depthCompare:o.depthCompare,depthWrite:o.depthWrite,stencilFront:o.stencilFront,stencilBack:o.stencilBack,stencilWrite:o.stencilWrite,stencilRef:o.stencilRef,cullMode:o.cullMode,frontFace:o.frontFace,polygonOffset:o.polygonOffset}),m=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?re.NONE:re.ALL,rgbBlendState:i(i({},m.rgbBlendState),no({blendMode:p,blendSrcFactor:h,blendDstFactor:E})),alphaBlendState:i(i({},m.alphaBlendState),no({blendMode:_,blendSrcFactor:R,blendDstFactor:v}))}]},T)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,l=n.density;if(t.isCSSRGB(o)){var u=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,l]}),e.push({name:"u_FogColor",value:u})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],u(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.parsedStyle[this.gradientAttributeName];if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,pe(fe.U8_RGBA_NORM,1,1,1));if(a){var s=new Li;return s.name=lo,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:z.CLAMP_TO_EDGE,addressModeV:z.CLAMP_TO_EDGE,minFilter:K.POINT,magFilter:K.BILINEAR,mipmapFilter:j.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(uo||(uo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.EXTRUDE=13]="EXTRUDE",e[e.SIZE=14]="SIZE"}(co||(co={}));var po=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],_o=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(co))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[];t.forEach((function(e,t){var o=e,a=o.parsedStyle.radius,s=r.shouldOmitStroke(o.parsedStyle),l=r.getSize(e.parsedStyle,o.nodeName),f=r.getPosition(e.parsedStyle,o.nodeName);n.push.apply(n,c(c([],u(l),!1),[o.parsedStyle.isBillboard?1:0,o.parsedStyle.isSizeAttenuation?1:0,po.indexOf(o.nodeName),a&&a[0]||0,s?1:0],!1)),i.push.apply(i,c([],u(f),!1))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:16,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:co.EXTRUDE},{format:fe.F32_RG,bufferByteOffset:8,location:ao.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:uo.PACKED_STYLE,byteStride:28,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:co.SIZE,divisor:1},{format:fe.F32_RGB,bufferByteOffset:16,location:co.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=u(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],u([n[0],n[1]]),!1),[t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,po.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0],!1))})),this.geometry.updateVertexBuffer(uo.PACKED_STYLE,co.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];t.forEach((function(e){var t=u(o.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])})),this.geometry.updateVertexBuffer(oo.POSITION,ao.POSITION,r,new Uint8Array(new Float32Array(s).buffer))}},r.prototype.getPosition=function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,o=e.cy,a=e.cz;n=[void 0===i?0:i,void 0===o?0:o,void 0===a?0:a]}else if(r===t.Shape.RECT){var s=e.x,l=e.y,u=e.z;n=[void 0===s?0:s,void 0===l?0:l,void 0===u?0:u]}return n},r.prototype.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r}(fo),ho=10,Eo=8,Ro=100;function vo(e,t,r,n,i,o){for(var a=i[i.length-3],s=i[i.length-2],l=null!=o?o:h(xn(a,s,e,t,r,n,3)/ho,Eo,Ro),u=0,c=0,f=1;l>=f;++f){var d=f/l;i.push((u=a+(e-a)*d)+(e+(r-e)*d-u)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function To(e,t,r,n,i,o,a,s){var l=a[a.length-3],u=a[a.length-2];a.length-=3;var c=null!=s?s:h(In(l,u,e,t,r,n,i,o,3)/ho,Eo,Ro),f=0,d=0,p=0,_=0,E=0;a.push(l,u,0);for(var R=1,v=0;c>=R;++R)a.push((p=(d=(f=1-(v=R/c))*f)*f)*l+3*d*v*e+3*f*(_=v*v)*r+(E=_*v)*i,p*u+3*d*v*t+3*f*_*n+E*o,0)}var mo,Ao,go=1e20,yo=function(){function e(e,t){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,l=e.cutoff,u=void 0===l?.25:l,c=e.fontFamily,f=void 0===c?"sans-serif":c,d=e.fontWeight,p=void 0===d?"normal":d,_=e.fontStyle,h=void 0===_?"normal":_,E=e.canvas;this.buffer=o,this.cutoff=u,this.radius=s;var R=this.size=n+4*o,v=t.offscreenCanvasCreator.getOrCreateCanvas(E);v.width=R,v.height=R;var T=t.offscreenCanvasCreator.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=T,T.font="".concat(h," ").concat(p," ").concat(n,"px ").concat(f),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=s+2*this.buffer,c=l+2*this.buffer,f=Math.max(u*c,0),d=new Uint8ClampedArray(f),p={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===l)return p;var _=this,h=_.ctx,E=_.buffer,R=_.gridInner,v=_.gridOuter;h.clearRect(E,E,s,l),h.fillText(e,E,E+a);var T=h.getImageData(E,E,s,l);v.fill(go,0,f),R.fill(0,0,f);for(var m=0;l>m;m++)for(var A=0;s>A;A++){var g=T.data[4*(m*s+A)+3]/255;if(0!==g){var y=(m+E)*u+A+E;if(1===g)v[y]=0,R[y]=go;else v[y]=(C=.5-g)>0?C*C:0,R[y]=0>C?C*C:0}}So(v,0,0,u,c,u,this.f,this.v,this.z),So(R,E,E,s,l,u,this.f,this.v,this.z);for(var S=0;f>S;S++){var C;d[S]=Math.round(255-255*((C=Math.sqrt(v[S])-Math.sqrt(R[S]))/this.radius+this.cutoff))}return p},e}();function So(e,t,r,n,i,o,a,s,l){for(var u=t;t+n>u;u++)Co(e,r*o+u,o,i,a,s,l);for(var c=r;r+i>c;c++)Co(e,c*o+t,1,n,a,s,l)}function Co(e,t,r,n,i,o,a){o[0]=0,a[0]=-go,a[1]=go,i[0]=e[t];for(var s=1,l=0,u=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{u=(i[s]-i[f=o[l]]+c-f*f)/(s-f)/2}while(a[l]>=u&&--l>-1);o[++l]=s,a[l]=u,a[l+1]=go}for(s=0,l=0;n>s;s++){for(;s>a[l+1];)l++;var f,d=s-(f=o[l]);e[t+s*r]=i[f]+d*d}}!function(e){e[e.PACKED=5]="PACKED",e[e.VERTEX_NUM=6]="VERTEX_NUM",e[e.TRAVEL=7]="TRAVEL",e[e.DASH=8]="DASH"}(mo||(mo={})),function(e){e[e.PREV=8]="PREV",e[e.POINT1=9]="POINT1",e[e.POINT2=10]="POINT2",e[e.NEXT=11]="NEXT",e[e.VERTEX_JOINT=12]="VERTEX_JOINT",e[e.VERTEX_NUM=13]="VERTEX_NUM",e[e.TRAVEL=14]="TRAVEL",e[e.DASH=15]="DASH"}(Ao||(Ao={}));function Po(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function No(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!f(r[0][2])}var Mo,Io=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.segmentNum=-1,l.segmentNum=l.calcSegmentNum(i),l.gradientAttributeName="stroke",l}return n(r,e),r.calcSubpathNum=function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter((function(e){return"M"===e[0]})).length:1},r.prototype.calcSegmentNum=function(e){return Bo(e,!1,12,this.calcSubpathIndex(e)).instancedCount},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===wo})).length;return this.index-r}return 0},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.segmentNum===n},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(Ao))},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=[],s=0,l=0;t.forEach((function(e){var t=Bo(e,!1,12,r.calcSubpathIndex(e)),f=t.pointsBuffer,d=t.travelBuffer,p=t.instancedCount,_=e.parsedStyle,h=_.lineDash;a.push(h&&h[0]||0,h&&h[1]||0,_.lineDashOffset||0,Po(_.isBillboard,_.isSizeAttenuation,No(e))),s+=p;for(var E=0;f.length-12>E;E+=4)i.push(f[E],f[E+1],f[E+2],f[E+3],f[E+4],f[E+5],f[E+6],f[E+7],f[E+8],f[E+9],f[E+10],f[E+11],f[E+12],f[E+13],f[E+14],f[E+15]);o.push.apply(o,c([],u(d),!1)),n.push(0+l,2+l,1+l,0+l,3+l,2+l,4+l,6+l,5+l,4+l,7+l,6+l,4+l,7+l,8+l),l+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:mo.PACKED,byteStride:64,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Ao.PREV,divisor:1},{format:fe.F32_RGB,bufferByteOffset:16,location:Ao.POINT1,divisor:1},{format:fe.F32_R,bufferByteOffset:28,location:Ao.VERTEX_JOINT,divisor:1},{format:fe.F32_RGB,bufferByteOffset:32,location:Ao.POINT2,divisor:1},{format:fe.F32_RGB,bufferByteOffset:48,location:Ao.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:mo.VERTEX_NUM,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ao.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:mo.TRAVEL,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ao.TRAVEL,divisor:1}],data:new Float32Array(o)}),this.divisor=s/t.length,this.geometry.setVertexBuffer({bufferIndex:mo.DASH,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Ao.DASH,divisor:this.divisor}],data:new Float32Array(a)}),e.prototype.createGeometry.call(this,t),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var a=[],s=[],l=0;t.forEach((function(e){var t=Bo(e,!1,12,o.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;l=t.instancedCount;for(var i=0;r.length-12>i;i+=4)a.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,c([],u(n),!1))})),this.geometry.updateVertexBuffer(mo.PACKED,Ao.PREV,r*l,new Uint8Array(new Float32Array(a).buffer)),this.geometry.updateVertexBuffer(mo.TRAVEL,Ao.TRAVEL,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var f=[];t.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;f.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,Po(t.isBillboard,t.isSizeAttenuation,No(e)))})),this.geometry.updateVertexBuffer(mo.DASH,Ao.DASH,r,new Uint8Array(new Float32Array(f).buffer))}},r}(fo);!function(e){e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2"}(Mo||(Mo={}));var Oo=3,xo=4;function Bo(e,r,n,i){var o;void 0===r&&(r=!1),void 0===i&&(i=0);var a=e.parsedStyle,s=a.lineCap,l=a.lineJoin,f=e.sortable.renderOrder*Qi,d=0,p=0,_=e.parsedStyle,h=_.markerStart,E=_.markerEnd,R=_.markerStartOffset,v=_.markerEndOffset,m=[],A=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var y=e.parsedStyle.points.points,S=y.length,C=0,P=0,N=0,M=0,I=0;h&&t.isDisplayObject(h)&&R&&(C=Math.cos(I=Math.atan2(y[1][1]-y[0][1],y[1][0]-y[0][0]))*(R||0),P=Math.sin(I)*(R||0)),E&&t.isDisplayObject(E)&&v&&(N=Math.cos(I=Math.atan2(y[S-2][1]-y[S-1][1],y[S-2][0]-y[S-1][0]))*(v||0),M=Math.sin(I)*(v||0));var O=e.nodeName===t.Shape.POLYLINE;if(m[0]=y.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=C,i=P):r===S-1&&(n=N,i=M),e.push(t[0]+n,t[1]+i,O?t[2]||0:f),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return A=Cn(m[0],[],3),{pointsBuffer:m[0],travelBuffer:[],triangles:A,instancedCount:Math.round(m[0].length/Oo)};m[0].push(m[0][0],m[0][1],m[0][2]||f),(o=m[0]).push.apply(o,c([],u(Do(m[0][0],m[0][1],m[0][2]||f,m[0][3],m[0][4],m[0][5]||f)),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var x=void 0;if(e.nodeName!==t.Shape.PATH){if(x=t.parsePath(t.convertToPath(e,g(T()))),e.nodeName===t.Shape.RECT){var B=e.parsedStyle;0>B.width&&(d+=x.rect.width),0>B.height&&(p+=x.rect.height)}}else x=e.parsedStyle.d;var D=x.absolutePath,b=x.segments,L=0,F=0,w=0,G=0;I=0;if(h&&h.parentNode&&t.isDisplayObject(h)&&R){var k=u(h.parentNode.getStartTangent(),2);L=Math.cos(I=Math.atan2((V=k[0])[1]-(X=k[1])[1],V[0]-X[0]))*(R||0),F=Math.sin(I)*(R||0)}if(E&&E.parentNode&&t.isDisplayObject(E)&&v){var V,X,W=u(E.parentNode.getEndTangent(),2);w=Math.cos(I=Math.atan2((V=W[0])[1]-(X=W[1])[1],V[0]-X[0]))*(v||0),G=Math.sin(I)*(v||0)}var H=-1,Y=-1;if(D.forEach((function(r,i){var o,a=u(r),s=a[0],l=a.slice(1),_=D[i+1],h=0===i&&(0!==L||0!==F),E=(i===D.length-1||_&&("M"===_[0]||"Z"===_[0]))&&0!==w&&0!==G;if("M"===s)Y++,m[Y]=[],H=m[Y].length,h?m[Y].push(l[0]-d+L,l[1]-p+F,f,l[0]-d,l[1]-p,f):m[Y].push(l[0]-d,l[1]-p,f);else if("L"===s)E?m[Y].push(l[0]-d+w,l[1]-p+G,f):m[Y].push(l[0]-d,l[1]-p,f);else if("Q"===s)vo(l[0]-d,l[1]-p,l[2]-d,l[3]-p,m[Y],n),E&&m[Y].push(l[2]-d+w,l[3]-p+G,f);else if("A"===s){for(var R=u(b[i].prePoint,2),v=U(R[0],R[1],l[0],l[1],l[2],l[3],l[4],l[5],l[6],void 0),T=0;v.length>T;T+=6)To(v[T]-d,v[T+1]-p,v[T+2]-d,v[T+3]-p,v[T+4]-d,v[T+5]-p,m[Y],n);E&&m[Y].push(l[5]-d+w,l[6]-p+G,f)}else if("C"===s)To(l[0]-d,l[1]-p,l[2]-d,l[3]-p,l[4]-d,l[5]-p,m[Y],n),E&&m[Y].push(l[4]-d+w,l[5]-p+G,f);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A=1e-4;(Math.abs(m[Y][m[Y].length-2]-m[Y][H])>A||Math.abs(m[Y][m[Y].length-1]-m[Y][H+1])>A)&&m[Y].push(m[Y][H],m[Y][H+1],f),(o=m[Y]).push.apply(o,c([],u(Do(m[Y][H],m[Y][H+1],m[Y][H+2],m[Y][H+3],m[Y][H+4],m[Y][H+5])),!1))}})),r)return{pointsBuffer:$=m[i],travelBuffer:[],triangles:A=Cn($,[],3),instancedCount:Math.round($.length/Oo)}}var z=function(e){var t;switch(e){case"bevel":t=Mo.JOINT_BEVEL;break;case"round":t=Mo.JOINT_ROUND;break;default:t=Mo.JOINT_MITER}return t}(l),K=function(e){var t;switch(e){case"square":t=Mo.CAP_SQUARE;break;case"round":t=Mo.CAP_ROUND;break;default:t=Mo.CAP_BUTT}return t}(s),j=K;K===Mo.CAP_ROUND&&(j=Mo.JOINT_CAP_ROUND),K===Mo.CAP_BUTT&&(j=Mo.JOINT_CAP_BUTT),K===Mo.CAP_SQUARE&&(j=Mo.JOINT_CAP_SQUARE);for(var Z=m[i],q=(Math.round(0/Oo)+2)*xo,Q=0,$=[],J=[],ee=0;Z.length>ee;ee+=Oo)ee>1&&(Q+=Math.sqrt(Math.pow(Z[ee]-Z[ee-Oo],2)+Math.pow(Z[ee+1]-Z[ee+1-Oo],2)+Math.pow(Z[ee+2]-Z[ee+2-Oo],2))),J.push(Q),$[q++]=Z[ee],$[q++]=Z[ee+1],$[q++]=Z[ee+2]||0,$[q]=z,0==ee&&K!==Mo.CAP_ROUND&&($[q]+=K),Z.length>ee+2*Oo?Z.length>ee+Oo||($[q]=0):$[q]+=j-z,q++;return $[q++]=Z[Z.length-6],$[q++]=Z[Z.length-5],$[q++]=Z[Z.length-4]||f,$[q++]=0,$[0]=Z[0],$[1]=Z[1],$[2]=Z[2]||f,$[3]=0,$[4]=Z[3],$[5]=Z[4],$[6]=Z[5]||f,$[7]=K===Mo.CAP_ROUND?K:0,{pointsBuffer:$,travelBuffer:J,triangles:A,instancedCount:Math.round(Z.length/Oo)}}function Do(e,t,r,n,i,o){void 0===n&&(n=e),void 0===i&&(i=t),void 0===o&&(o=r);var a=[n-e,i-t,o-r],s=.01;return[e+a[0]*s,t+a[1]*s,r+a[2]*s]}var bo,Lo;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(bo||(bo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3"}(Lo||(Lo={}));var Fo,Uo,wo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.trianglesHash=[[],[]],l.trianglesHash=l.calcSegmentNum(i),l}return n(r,e),r.prototype.calcSegmentNum=function(e){var t=Bo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]},r.prototype.calcSubpathIndex=function(e){return e.nodeName===t.Shape.PATH?this.index:0},r.prototype.compareTrianglesHash=function(e){var t=u(this.trianglesHash,2),r=t[0],n=t[1],i=u(e,2),o=i[0],a=i[1];return r.length===o.length&&n.length===a.length&&(!r.some((function(e,t){return e!==o[t]}))&&!n.some((function(e,t){return e!==a[t]})))},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.compareTrianglesHash(n)},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=0;if(t.forEach((function(e,t){var s=Bo(e,!0,12,r.calcSubpathIndex(e)),l=s.triangles,f=s.pointsBuffer;if(l.length){var d=e.getGeometryBounds().halfExtents,p=[];f.forEach((function(e,t){t%3!=2&&p.push(e/d[t%3]/2)})),a+=i.length/3,i.push.apply(i,c([],u(f),!1)),o.push.apply(o,c([],u(p),!1)),n.push.apply(n,c([],u(l.map((function(e){return e+a}))),!1))}})),i.length){e.prototype.createGeometry.call(this,t);var s=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:bo.PACKED_STYLE,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Lo.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:ao.UV}],data:new Float32Array(o)}),this.geometry.vertexCount=n.length/t.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=i(i(i({},this.material.defines),to(Lo)),{INSTANCED:!0})},r.prototype.updateAttribute=function(t,r,n,i){if(0!==t.length&&(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var o=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;o.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(bo.PACKED_STYLE,Lo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(o).buffer))}},r}(fo),Go=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Fo||(Fo={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(Uo||(Uo={}));var ko,Vo,Xo={butt:1,round:2,square:3},Wo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.gradientAttributeName="stroke",l}return n(r,e),r.isLine=function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,o=0,a=0;n.length>a;a++){if("M"===n[a][0]){if(i===r){o=a;break}i++}}if("M"===n[o][0]&&"L"===n[o+1][0]&&(void 0===n[o+2]||"M"===n[o+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){var s=e.parsedStyle.points.points,l=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]);for(a=1;s.length-1>a;a++)if((s[a+1][0]-s[a+1][1])/(s[a][0]-s[a][1])!==l)return!1;return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(Uo))},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===wo})).length;return this.index-r}return 0},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],l=0;r.forEach((function(e){var r,u;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,u=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:h=c.lineDash,lineDashOffset:E=c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:R=c.markerStart,markerEnd:v=c.markerEnd,markerStartOffset:T=c.markerStartOffset,markerEndOffset:m=c.markerEndOffset},u=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,p=d.d.absolutePath,_=d.lineCap,h=d.lineDash,E=d.lineDashOffset,R=d.markerStart,v=d.markerEnd,T=d.markerStartOffset,m=d.markerEndOffset,A=d.isBillboard,g=d.isSizeAttenuation,y=0,S=0,C=n.calcSubpathIndex(e),P=0;p.length>P;P++){if("M"===p[P][0]){if(y===C){S=P;break}y++}}r={x1:p[S][1],y1:p[S][2],x2:p[S+1][1],y2:p[S+1][2],z1:0,z2:0,lineCap:_,lineDash:h,lineDashOffset:E,isBillboard:A,isSizeAttenuation:g,markerStart:R,markerEnd:v,markerStartOffset:T,markerEndOffset:m},u=e.getTotalLength()}var N=r.x1,M=r.y1,I=r.x2,O=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,w=F.startOffsetY,G=F.endOffsetX,k=F.endOffsetY,V=n.calcDash(r,u),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;o.push(Xo[D]),a.push(X,W,H,b||L?1:0),i.push(N+U,M+w,x,I+G,O+k,B),s.push(0+l,2+l,1+l,0+l,3+l,2+l),l+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:20,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Uo.POSITION,divisor:0},{format:fe.F32_RG,bufferByteOffset:12,location:Uo.UV,divisor:0}],data:new Float32Array(Go)}),this.geometry.setVertexBuffer({bufferIndex:Fo.POINT,byteStride:24,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Uo.POINTA,divisor:1},{format:fe.F32_RGB,bufferByteOffset:12,location:Uo.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Fo.CAP,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,location:Uo.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Fo.DASH,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Uo.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(0!==r.length)if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var o=e.parsedStyle,l=o.d.absolutePath;r={x1:l[0][1],y1:l[0][2],x2:l[1][1],y2:l[1][2],z1:0,z2:0,lineCap:o.lineCap,isBillboard:o.isBillboard,isSizeAttenuation:o.isSizeAttenuation,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var u=r.x1,c=r.y1,f=r.x2,d=r.y2,p=r.z1,_=r.z2,h=a.calcOffset(r);s.push(u+h.startOffsetX,c+h.startOffsetY,p,f+h.endOffsetX,d+h.endOffsetY,_)})),this.geometry.updateVertexBuffer(Fo.POINT,Uo.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var l=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);l.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(Fo.DASH,Uo.DASH,n,new Uint8Array(new Float32Array(l).buffer))}else if("lineCap"===i){var u=[];r.forEach((function(e){u.push(Xo[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Fo.CAP,Uo.CAP,n,new Uint8Array(new Float32Array(u).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,c=0,f=0,d=0,p=0,_=0;return a&&t.isDisplayObject(a)&&l&&(c=Math.cos(_=Math.atan2(o-n,i-r))*(l||0),f=Math.sin(_)*(l||0)),s&&t.isDisplayObject(s)&&u&&(d=Math.cos(_=Math.atan2(n-o,r-i))*(u||0),p=Math.sin(_)*(u||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:p}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(fo);!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE",e[e.SIZE=8]="SIZE"}(ko||(ko={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(Vo||(Vo={}));var Ho=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.src===t.parsedStyle.src},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.src;this.material.defines=i(i({},this.material.defines),to(Vo)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[],i=[];t.forEach((function(e,t){var o=e.parsedStyle,a=o.x,s=o.y,l=o.z,u=o.width,c=o.height,f=o.isBillboard,d=o.billboardRotation,p=o.isSizeAttenuation;r.push(void 0===a?0:a,void 0===s?0:s,void 0===l?0:l),n.push(u,c),i.push(f?1:0,null!=d?d:0,p?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:ko.SIZE,byteStride:8,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:Vo.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:ko.PACKED_STYLE,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Vo.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:ao.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})},t.prototype.updateAttribute=function(t,r,n,i){if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"x"===n||"y"===n||"z"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;o.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)})),this.geometry.updateVertexBuffer(oo.POSITION,ao.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("width"===n||"height"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle;a.push(t.width,t.height)})),this.geometry.updateVertexBuffer(ko.SIZE,Vo.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(ko.PACKED_STYLE,Vo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var l=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:l})}},t}(fo);function Yo(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function zo(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,l=0;i.height>l;l++)for(var u=((r.y+l)*e.width+r.x)*o,c=((n.y+l)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[u+f];return t}var Ko=function(){function e(e,t){Yo(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Yo({},{width:n,height:i},r);zo(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){zo(e,t,r,n,i,1)},e}();var jo=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=l(e),u=s.next();!u.done;u=s.next())o+=(h=u.value).w*h.h,a=Math.max(a,h.w)}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,d=0;try{for(var p=l(e),_=p.next();!_.done;_=p.next())for(var h=_.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=h.w&&R.h>=h.h){if(h.x=R.x,h.y=R.y,d=Math.max(d,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===R.w&&h.h===R.h){var v=c.pop();c.length>E&&(c[E]=v)}else h.h===R.h?(R.x+=h.w,R.w-=h.w):h.w===R.w?(R.y+=h.h,R.h-=h.h):(c.push({x:R.x+h.w,y:R.y,w:R.w-h.w,h:h.h}),R.y+=h.h,R.h-=h.h);break}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}return{w:f,h:d,fill:o/(f*d)||0}}(r),u=new Ko({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&Ko.copy(c.bitmap,u,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=u,this.positions=t};var Zo,qo,Qo,$o=function(){function e(e){this.runtime=e,this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.destroy=function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()},e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,l=[],u=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=l.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(l.push({glyph:n,x:u,y:c,scale:1,fontStack:t}),u+=o.metrics.advance+i)}));for(var o=u-i,a=n;l.length>a;a++)l[a].x=l[a].x-f*o;u=0,c+=r})),l},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var l=this;void 0===t&&(t=""),void 0===o&&(o="");var u=[];this.glyphMap[t]||(u=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&u.push(e)})),u.length){var f=u.map((function(i){return l.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new jo(this.glyphMap);var d=this.glyphAtlas.image,p=d.width,_=d.height,h=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},pe(fe.ALPHA,p,_,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([h])}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new yo({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var l=s.draw(o),u=l.glyphWidth,c=l.glyphHeight,f=l.glyphLeft,d=l.glyphTop,p=l.glyphAdvance;return{id:a,bitmap:new Ko({width:l.width,height:l.height},l.data),metrics:{width:u,height:c,left:f,top:d-24+3,advance:p}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(Zo||(Zo={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(qo||(qo={})),function(e){e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke"}(Qo||(Qo={}));var Jo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.packedBufferObjectMap=new WeakMap,l.tmpMat4=T(),l.fontHash=l.calcFontHash(i),l.glyphManager=new $o(l.context),l}return n(r,e),r.prototype.calcFontHash=function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(this.index===r&&this.fontHash===this.calcFontHash(t))},r.prototype.createGeometry=function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,o=n.letterSpacing,a=void 0===o?0:o,s=r.parsedStyle.textBaseline,l=void 0===s?"alphabetic":s,f=24/(void 0===i?16:i),d=[],p=[],_=[],h=[],E=0;e.forEach((function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,o=r.dy,s=n.font,R=n.lines,v=n.height,T=n.lineHeight,m=void 0===i?0:i,A=void 0===o?0:o;t.context.enableCSSParsing||"alphabetic"!==l||(l="bottom");var g=0;"middle"===l?g+=-v/2:"bottom"===l?g+=-v:"top"===l||"hanging"===l?g+=0:"alphabetic"===l?g+=.25*T-v:"ideographic"===l&&(g+=-v);var y=t.glyphManager.getAtlas(),S=t.buildTextBuffers({object:e,lines:R,fontStack:s,lineHeight:f*T,offsetX:f*m,offsetY:f*(g+A),letterSpacing:f*a,glyphAtlas:y,indicesOffset:E}),C=S.indexBuffer,P=S.charUVOffsetBuffer,N=S.charPositionsBuffer;E=S.indicesOffset;var M=h.length;h.push.apply(h,c([],u(S.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[M,h.length]),_.push.apply(_,c([],u(P),!1)),p.push.apply(p,c([],u(N),!1)),d.push.apply(d,c([],u(C),!1))})),this.geometry.vertexCount=d.length,this.geometry.setIndexBuffer(new Uint32Array(d)),this.geometry.setVertexBuffer({bufferIndex:Zo.INSTANCED,byteStride:128,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.MODEL_MATRIX0},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.MODEL_MATRIX1},{format:fe.F32_RGBA,bufferByteOffset:32,location:ao.MODEL_MATRIX2},{format:fe.F32_RGBA,bufferByteOffset:48,location:ao.MODEL_MATRIX3},{format:fe.F32_RGBA,bufferByteOffset:64,location:ao.PACKED_COLOR},{format:fe.F32_RGBA,bufferByteOffset:80,location:ao.PACKED_STYLE1},{format:fe.F32_RGBA,bufferByteOffset:96,location:ao.PACKED_STYLE2},{format:fe.F32_RGBA,bufferByteOffset:112,location:ao.PICKING_COLOR}],data:new Float32Array(h)}),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(p)}),this.geometry.setVertexBuffer({bufferIndex:Zo.TEX,byteStride:16,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:qo.TEX},{format:fe.F32_RG,bufferByteOffset:8,location:qo.OFFSET}],data:new Float32Array(_)})},r.prototype.createMaterial=function(e){var t;this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=W.BACK,this.material.defines=i(i({},this.material.defines),to(qo));var r=this.instance.parsedStyle,n=r.fontSize,o=void 0===n?16:n,a=r.fontFamily,s=void 0===a?"sans-serif":a,l=r.fontWeight,u=void 0===l?"normal":l,c=r.fontStyle,f=void 0===c?"normal":c,d=r.metrics.font,p=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+u,f,p,this.context.device);var _=this.glyphManager.getAtlasTexture(),h=this.glyphManager.getAtlas();this.context.device.setResourceName(_,"TextSDF Texture");var E=h.image,R=E.width,v=E.height;this.material.setUniforms(((t={})[Qo.SDF_MAP]=_,t[Qo.SDF_MAP_SIZE]=[R,v],t[Qo.FONT_SIZE]=o,t[Qo.GAMMA_SCALE]=1,t[Qo.STROKE_BLUR]=.2,t[Qo.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[Zo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Zo.INSTANCED].arrayStride/4,i=u(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),l=0;a-o>l;l+=n)s[l+n-1]=t*Qi;this.geometry.updateVertexBuffer(Zo.INSTANCED,ao.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(0!==r.length)if(e.prototype.updateAttribute.call(this,r,n,i,o),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[Zo.INSTANCED],l=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Zo.INSTANCED].arrayStride/4;r.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,o=n.stroke,c=n.opacity,f=void 0===c?1:c,d=n.fillOpacity,p=void 0===d?1:d,_=n.strokeOpacity,h=void 0===_?1:_,E=n.lineWidth,R=void 0===E?1:E,v=n.visibility,T=n.isBillboard,A=n.billboardRotation,g=n.isSizeAttenuation,y=[0,0,0,0];t.isCSSRGB(i)&&(y=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var S=[0,0,0,0];t.isCSSRGB(o)&&(S=[Number(o.r),Number(o.g),Number(o.b),255*Number(o.alpha)]);for(var C=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],P=m(a.tmpMat4,e.getWorldTransform()),N=u(a.packedBufferObjectMap.get(e),2),M=N[0],I=N[1],O=s.slice(M,I),x=0;I-M>x;x+=l)O[x+0]=P[0],O[x+1]=P[1],O[x+2]=P[2],O[x+3]=P[3],O[x+4]=P[4],O[x+5]=P[5],O[x+6]=P[6],O[x+7]=P[7],O[x+8]=P[8],O[x+9]=P[9],O[x+10]=P[10],O[x+11]=P[11],O[x+12]=P[12],O[x+13]=P[13],O[x+14]=P[14],O[x+15]=P[15],O[x+16]=io(y[0],y[1]),O[x+17]=io(y[2],y[3]),O[x+18]=io(S[0],S[1]),O[x+19]=io(S[2],S[3]),O[x+20]=f,O[x+21]=p,O[x+22]=h,O[x+23]=R,O[x+24]="hidden"!==v?1:0,O[x+25]=T?1:0,O[x+26]=g?1:0,O[x+27]=null!=A?A:0,O[x+28]=C[0],O[x+29]=C[1],O[x+30]=C[2];a.geometry.updateVertexBuffer(Zo.INSTANCED,ao.MODEL_MATRIX0,M/l,new Uint8Array(O.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,l=e.offsetX,f=e.offsetY,d=e.glyphAtlas,p=e.indicesOffset,_=n.parsedStyle,h=_.textAlign,E=void 0===h?"start":h,R=_.fill,v=_.stroke,T=_.opacity,A=void 0===T?1:T,g=_.fillOpacity,y=void 0===g?1:g,S=_.strokeOpacity,C=void 0===S?1:S,P=_.lineWidth,N=void 0===P?1:P,M=_.visibility,I=_.isBillboard,O=_.billboardRotation,x=_.isSizeAttenuation,B=_.x,D=void 0===B?0:B,b=_.y,L=void 0===b?0:b,F=_.z,U=void 0===F?0:F,w=[0,0,0,0];t.isCSSRGB(R)&&(w=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var G=[0,0,0,0];t.isCSSRGB(v)&&(G=[Number(v.r),Number(v.g),Number(v.b),255*Number(v.alpha)]);var k=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],V=m(this.tmpMat4,n.getWorldTransform()),X=[],W=[],H=[],Y=[],z=p,K=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var l=a.metrics.advance*i.scale/2,u=[i.x+l,i.y],c=(a.metrics.left-4)*i.scale-l+u[0],f=(-a.metrics.top-4)*i.scale+u[1],d=c+s.w*i.scale,p=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:p},br:{x:d,y:p},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,l,f),d.positions);return K.forEach((function(e){var t=[];t.push.apply(t,c([],u(V),!1));var r=c(c(c(c([],u(t),!1),[io(w[0],w[1]),io(w[2],w[3]),io(G[0],G[1]),io(G[2],G[3]),A,y,C,N,"hidden"!==M?1:0,I?1:0,x?1:0,null!=O?O:0],!1),u(k),!1),[n.sortable.renderOrder*Qi],!1);X.push.apply(X,c(c(c(c([],u(r),!1),u(r),!1),u(r),!1),u(r),!1)),W.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),W.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),W.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),W.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),H.push(D,L,U,D,L,U,D,L,U,D,L,U),Y.push(0+z,2+z,1+z),Y.push(2+z,0+z,3+z),z+=4})),{indexBuffer:Y,charUVOffsetBuffer:W,charPositionsBuffer:H,charPackedBuffer:X,indicesOffset:z}},r.prototype.destroy=function(){e.prototype.destroy.call(this),this.glyphManager.destroy()},r}(fo),ea=function(e){function r(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.mergeXYZIntoModelMatrix=!1,t}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){0!==t.length&&(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i))},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(fo),ta=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(_o),this.needDrawStrokeSeparately(e)&&t.push(Io),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}($i),ra=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.getDrawcallCtors=function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=r.opacity,a=r.strokeOpacity,s=r.lineWidth,l=i&&!i.isNone,u=Io.calcSubpathNum(e),c=[];if(e.nodeName!==t.Shape.POLYLINE&&!(null==n?void 0:n.isNone))for(var f=0;u>f;f++)c.push(wo);for(f=0;u>f;f++)if(0!==a&&0!==o&&0!==s&&l){var d=Wo.isLine(e,f);c.push(d?Wo:Io)}return c},r}($i);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e),t.prototype.getDrawcallCtors=function(){return[]}}($i);var na=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Ho]},t}($i),ia=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Jo),t.push(Jo),t},t.prototype.beforeUploadUBO=function(e,t){var r;t.material.setUniforms(((r={})[Qo.HAS_STROKE]=1===t.instance.renderable3D.drawcalls.length?0:1-t.index,r))},t}($i),oa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Wo]},t}($i),aa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[ea]},t}($i),sa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,o=i&&i.length&&i.some((function(e){return e!==i[0]}));return(null==n?void 0:n.isNone)||o||t.push(_o),o&&t.push(wo),(o||this.needDrawStrokeSeparately(e))&&t.push(Io),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}($i),la=1,ua=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.destroy=function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}},e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,o,a){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===o&&t.maxInstances>t.objects.length&&t.shouldMerge(e,o)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,a,o,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[o]=s,s.geometryDirty=!0)}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];if(a){var s=a.getDrawcallCtors(e);if(s.forEach((function(s,l,u){var c=o.drawcalls.find((function(e){return e&&e.index===l&&e.constructor===s}));if(c||((c=o.drawcalls[l])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.drawcalls.splice(i.drawcalls.indexOf(c),1),o.drawcalls[o.drawcalls.indexOf(c)]=void 0),(c=i.drawcalls.find((function(t){return s===t.constructor&&t.index===l&&t.maxInstances>t.objects.length&&t.shouldMerge(e,l)})))?c.geometryDirty=!0:((c=new s(i.renderHelper,i.texturePool,i.lightPool,e,u,l,i.context)).renderer=a,c.init(),i.drawcalls.push(c)),c.objects.push(e),o.drawcalls[l]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,l)){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;i.pendingUpdatePatches[d]||(i.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[d].objectIndices.indexOf(f)&&i.pendingUpdatePatches[d].objectIndices.push(f)}}else i.remove(e),i.add(e);else i.remove(e),i.add(e)})),o.drawcalls.length>s.length)for(var l=o.drawcalls.length-1;l>=s.length;l--){var u=o.drawcalls[l];u.objects.splice(u.objects.indexOf(e),1),u.geometryDirty=!0,0===u.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(u),1),o.drawcalls.pop()}}},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=la++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}},e}(),ca=function(){function e(e,t){this.context=e,this.runtime=t,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,l="string"==typeof r?r:r.src||"";if(l&&this.textureCache[l])(a=this.textureCache[l]).emit(J.LOADED);else if(a=e.createTexture(i({format:fe.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:ee.TEXTURE_2D,usage:te.SAMPLED,pixelStore:{unpackFlipY:!1}},n)),l&&(this.textureCache[l]=a),_(r)){var u,c=this.context.config.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){var e=function(e){s.textureCache[l].setImageData([e]),s.textureCache[l].emit(J.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[l],e)};s.runtime.globalThis.createImageBitmap?s.runtime.globalThis.createImageBitmap(u).then((function(t){return e(t)})).catch((function(){e(u)})):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else a.setImageData([r]),a.emit(J.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,o=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),l=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=o;var u=this.context.imagePool;t.forEach((function(e){var t=u.getOrCreateGradient(i(i({type:e.type},e.value),{width:n,height:o,min:[0,0]}),l);l.fillStyle=t,l.fillRect(0,0,n,o)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,l=r.getGeometryBounds().halfExtents,u=2*l[0]||1,c=2*l[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),p=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);d.width=u,d.height=c;var h=(i=_(o)?this.context.imagePool.getImageSync(o,n):o)&&p.createPattern(i,a);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));h.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}p.fillStyle=h,p.fillRect(0,0,u,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),fa=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="device-renderer",r.parameters={toneMapping:Qn.NONE,toneMappingExposure:1},r}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new Ln;var n=new Ci(this.parameters),i=new Dn,o=new ca(this.context,e),a=new Fn,s=new ta,l=new ra,u=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=l,r[t.Shape.PATH]=l,r[t.Shape.POLYGON]=l,r[t.Shape.RECT]=new sa,r[t.Shape.IMAGE]=new na,r[t.Shape.LINE]=new oa,r[t.Shape.TEXT]=new ia,r[t.Shape.MESH]=new aa,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new ua(n,u,o,i),f=new Zi(n,i,o,c,this.options);this.addRenderingPlugin(f),this.addRenderingPlugin(new qi(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.getSwapChain=function(){return this.getRenderGraphPlugin().getSwapChain()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),da=Object.freeze({__proto__:null,get AntialiasingMode(){return Mi},Batch:$i,BufferGeometry:Wi,DeviceProgram:Un,DynamicUniformBuffer:wn,FILL_TEXTURE_MAPPING:lo,Fog:Gi,get FogType(){return bi},get GeometryEvent(){return wi},HashMap:Wn,ImageDrawcall:Ho,Instanced:fo,InstancedFillDrawcall:wo,InstancedLineDrawcall:Wo,InstancedPathDrawcall:Io,get JOINT_TYPE(){return Mo},Light:Ui,Material:Ji,get MaterialEvent(){return ji},Mesh:bn,MeshDrawcall:ea,Plugin:fa,get RGAttachmentSlot(){return $n},RenderCache:Jn,RenderGraphPlugin:Zi,RenderHelper:Ci,RenderInst:mi,get RenderInstExecutionOrder(){return Ti},get RenderInstFlags(){return Ei},RenderInstList:gi,RenderInstManager:Si,Renderable3D:Bn,get RendererLayer(){return ei},SDFDrawcall:_o,ShaderMaterial:eo,SingleSampledTexture:ni,TemporalTexture:Fi,TextDrawcall:Jo,get TextUniform(){return Qo},TextureMapping:Li,TexturePool:ca,TinySDF:yo,get ToneMapping(){return Qn},get VertexAttributeBufferIndex(){return oo},get VertexAttributeLocation(){return ao},bezierCurveTo:To,compareDefines:ro,definedProps:no,enumToObject:to,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:vi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:kn,hashCodeNumberUpdate:Gn,makeAttachmentClearDescriptor:Ni,makeBackbufferDescSimple:Di,makeDataBuffer:ki,makeDepthKey:li,makeSortKey:function(e,t){return void 0===t&&(t=0),e&ei.TRANSLUCENT?pi(e):fi(e,t)},makeSortKeyOpaque:fi,makeSortKeyTranslucent:pi,nullHashFunc:Vn,opaqueBlackFullClearRenderPassDescriptor:Oi,opaqueWhiteFullClearRenderPassDescriptor:xi,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===ae.NEGATIVE_ONE?function(e){D(e,hi,e)}(e):t===ae.ZERO&&function(e){D(e,Ri,e)}(e))},pushFXAAPass:zi,quadCurveTo:vo,renderInstCompareNone:null,renderInstCompareSortKey:Ai,segmentInstanceGeometry:Go,setBackbufferDescSimple:Bi,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=ai);var n=!!(e>>>31&1),i=li(t,n,r);return n?_i(e,i):di(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?_i(e,t):di(e,t)},setSortKeyLayer:ui,setSortKeyOpaqueDepth:di,setSortKeyProgramKey:ci,setSortKeyTranslucentDepth:_i,standardFullClearRenderPassDescriptor:Ii,updateBuffer:Bo}),pa=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.root.ownerDocument.defaultView,l=function(e){i.hooks.pointerMove.call(e)},u=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},p=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},h=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",l,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",u,!0),r.globalThis.addEventListener("pointercancel",p,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",l,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",u,!0),e.addEventListener("touchmove",l,!0),e.addEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",h,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",l,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",u,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",l,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",u,!0),e.removeEventListener("touchmove",l,!0),e.removeEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",h,!0),e.removeEventListener("wheel",_,!0)}))},e.tag="DOMInteraction",e}(),_a=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new pa)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ha=Object.freeze({__proto__:null,Plugin:_a}),Ea=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e,t){return void 0===t&&(t=[0,0,0]),"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")},e.prototype.apply=function(r,n){var i=this,o=r.camera,a=r.renderingContext,s=r.renderingService;this.context=r;var l=a.root.ownerDocument.defaultView,u=l.context.eventService.nativeHTMLMap,c=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(o));var a=i.getOrCreateEl(r);if(i.$camera.appendChild(a),n.enableCSSParsing){var s=r.ownerDocument.documentElement.attributes;Object.keys(s).forEach((function(e){a.style[e]=s[e]}))}Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),c(r,a),u.set(a,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),u.delete(n))}},p=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},_=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var n=i.getOrCreateEl(r);c(r,n)}},h=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.parentElement.style.width="".concat(e.width||0,"px"),i.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,h),l.addEventListener(t.ElementEvent.MOUNTED,f),l.addEventListener(t.ElementEvent.UNMOUNTED,d),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,p),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,_)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&a.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,h),l.removeEventListener(t.ElementEvent.MOUNTED,f),l.removeEventListener(t.ElementEvent.UNMOUNTED,d),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,p),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,_)}))},e.prototype.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",l=a.querySelector("#"+s);if(!l){var u=(r||document).createElement("div");u.style.overflow="hidden",u.style.pointerEvents="none",u.style.position="absolute",u.style.left="0px",u.style.top="0px",u.style.width="".concat(n||0,"px"),u.style.height="".concat(i||0,"px");var c=(r||document).createElement("div");l=c,c.id=s,c.style.position="absolute",c.style.left="".concat(o.offsetLeft||0,"px"),c.style.top="".concat(o.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.pointerEvents="none",c.style.width="100%",c.style.height="100%",u.appendChild(c),a.appendChild(u)}return l}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;_(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].buildCSSText(null,null,"")," ").concat(o[1].buildCSSText(null,null,""));break;case"width":if(this.context.enableCSSParsing){var a=r.computedStyleMap().get("width");n.style.width=""+a}else{n.style.width=E(a=r.parsedStyle.width)?"".concat(a,"px"):""+a}break;case"height":if(this.context.enableCSSParsing){var s=r.computedStyleMap().get("height");n.style.height=""+s}else{n.style.height=E(s=r.parsedStyle.height)?"".concat(s,"px"):""+s}break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var l=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===l?"auto":l;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var u=r.parsedStyle.fill,c="";t.isCSSRGB(u)?c=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?c=r.getAttribute("fill"):t.isPattern(u),n.style.background=c;break;case"stroke":var d=r.parsedStyle.stroke,p="";t.isCSSRGB(d)?p=d.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(d)?p=r.getAttribute("stroke"):t.isPattern(d),n.style["border-color"]=p,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:f(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}},e.tag="HTMLRendering",e}(),Ra=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new Ea)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),va=Object.freeze({__proto__:null,Plugin:Ra}),Ta=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t(this.imageCache[e]):this.getOrCreateImage(e).then((function(e){t&&t(e)})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o,a){var s=this.generatePatternKey(e);if(s&&this.patternCache[s])return this.patternCache[s];var l,u=e.image,c=e.repetition,f=e.transform,d=!1;_(u)?l=this.getImageSync(u,a):n?(l=n,d=!0):l=u;var p=l&&r.createPattern(l,c);if(p){var h=void 0;h=f?t.parsedTransformToMat4(t.parseTransform(f),new t.DisplayObject({})):g(T()),d&&C(h,h,[1/i,1/i,1]),p.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12]+o[0],f:h[13]+o[1]})}return s&&p&&(this.patternCache[s]=p),p},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.min,s=e.width,l=e.height,u=e.cx,c=e.cy,f=e.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientType.LinearGradient){var p=t.computeLinearGradient(a,s,l,e.angle);d=r.createLinearGradient(p.x1,p.y1,p.x2,p.y2)}else if(i===t.GradientType.RadialGradient){var _=t.computeRadialGradient(a,s,l,u,c,f),h=_.x,E=_.y;d=r.createRadialGradient(h,E,0,h,E,_.r)}return d&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==d||d.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=d),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,o=e.angle,a=e.cx,s=e.cy,l=e.size;return"gradient-".concat(e.type,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==l?void 0:""+l)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return _(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),ma=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e,t,r){var n=e.parsedStyle,i=n.width,o=n.height;i&&!o?e.setAttribute("height",r/t*i):!i&&o&&e.setAttribute("width",t/r*o)},s=function(e){var r=e.target,o=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=o.src,l=o.keepAspectRatio;_(s)&&i.getImageSync(s,(function(e){l&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))}},l=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&_(o)&&i.getOrCreateImage(o).then((function(e){r.attributes.keepAspectRatio&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,l)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,l)}))},e.tag="LoadImage",e}(),Aa=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new Ta(this.context.config),this.addRenderingPlugin(new ma)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ga=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=_(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),ya=function(e){function t(t,r){var n=e.call(this)||this;return n.rendererPlugin=t,n.config=r,n.name="webgpu-context-register",n}return n(t,e),t.prototype.init=function(){this.context.ContextService=ga,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new qr({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),Sa=function(e){function r(r){var n=e.call(this,i({enableSizeAttenuation:!1},r))||this;n.clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var o=new fa;return n.registerPlugin(new ya(o,r)),n.registerPlugin(new Aa),n.registerPlugin(o),n.registerPlugin(new _a),n.registerPlugin(new Ra),n}return n(r,e),r}(t.AbstractRenderer);e.DeviceRenderer=da,e.DomInteraction=ha,e.HTMLRenderer=va,e.Renderer=Sa}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.WebGPU={}),e.window.G)}(this,(function(e,t){"use strict";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};function n(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var i=function(){return i=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},i.apply(this,arguments)};function o(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}function a(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{l(n.next(e))}catch(e){o(e)}}function s(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}l((n=n.apply(e,t||[])).next())}))}function s(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&i[3]>s[1])){a.label=s[1];break}if(6===s[0]&&i[1]>a.label){a.label=i[1],i=s;break}if(i&&i[2]>a.label){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function c(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;o>i;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var f=function(e){return null==e},d={}.toString,p=function(e,t){return d.call(e)==="[object "+t+"]"},_=function(e){return p(e,"String")},h=function(e,t,r){return t>e?t:e>r?r:e},E=function(e){return p(e,"Number")},R=1e-6,v="undefined"!=typeof Float32Array?Float32Array:Array;function T(){var e=new v(16);return v!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function m(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}function A(e,t,r,n,i,o,a,s,l,u,c,f,d,p,_,h){var E=new v(16);return E[0]=e,E[1]=t,E[2]=r,E[3]=n,E[4]=i,E[5]=o,E[6]=a,E[7]=s,E[8]=l,E[9]=u,E[10]=c,E[11]=f,E[12]=d,E[13]=p,E[14]=_,E[15]=h,E}function g(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}function y(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],f=t[9],d=t[10],p=t[11],_=t[12],h=t[13],E=t[14],R=t[15],v=r*s-n*a,T=r*l-i*a,m=r*u-o*a,A=n*l-i*s,g=n*u-o*s,y=i*u-o*l,S=c*h-f*_,C=c*E-d*_,P=c*R-p*_,N=f*E-d*h,M=f*R-p*h,I=d*R-p*E,O=v*I-T*M+m*N+A*P-g*C+y*S;return O?(e[0]=(s*I-l*M+u*N)*(O=1/O),e[1]=(i*M-n*I-o*N)*O,e[2]=(h*y-E*g+R*A)*O,e[3]=(d*g-f*y-p*A)*O,e[4]=(l*P-a*I-u*C)*O,e[5]=(r*I-i*P+o*C)*O,e[6]=(E*m-_*y-R*T)*O,e[7]=(c*y-d*m+p*T)*O,e[8]=(a*M-s*P+u*S)*O,e[9]=(n*P-r*M-o*S)*O,e[10]=(_*g-h*m+R*v)*O,e[11]=(f*m-c*g-p*v)*O,e[12]=(s*C-a*N-l*S)*O,e[13]=(r*N-n*C+i*S)*O,e[14]=(h*T-_*A-E*v)*O,e[15]=(c*A-f*T+d*v)*O,e):null}function S(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],h=t[12],E=t[13],R=t[14],v=t[15],T=r[0],m=r[1],A=r[2],g=r[3];return e[0]=T*n+m*s+A*f+g*h,e[1]=T*i+m*l+A*d+g*E,e[2]=T*o+m*u+A*p+g*R,e[3]=T*a+m*c+A*_+g*v,e[4]=(T=r[4])*n+(m=r[5])*s+(A=r[6])*f+(g=r[7])*h,e[5]=T*i+m*l+A*d+g*E,e[6]=T*o+m*u+A*p+g*R,e[7]=T*a+m*c+A*_+g*v,e[8]=(T=r[8])*n+(m=r[9])*s+(A=r[10])*f+(g=r[11])*h,e[9]=T*i+m*l+A*d+g*E,e[10]=T*o+m*u+A*p+g*R,e[11]=T*a+m*c+A*_+g*v,e[12]=(T=r[12])*n+(m=r[13])*s+(A=r[14])*f+(g=r[15])*h,e[13]=T*i+m*l+A*d+g*E,e[14]=T*o+m*u+A*p+g*R,e[15]=T*a+m*c+A*_+g*v,e}function C(e,t,r){var n=r[0],i=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function P(e,t){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]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function N(e,t,r){var n=t[0],i=t[1],o=t[2],a=t[3],s=n+n,l=i+i,u=o+o,c=n*s,f=n*l,d=n*u,p=i*l,_=i*u,h=o*u,E=a*s,R=a*l,v=a*u;return e[0]=1-(p+h),e[1]=f+v,e[2]=d-R,e[3]=0,e[4]=f-v,e[5]=1-(c+h),e[6]=_+E,e[7]=0,e[8]=d+R,e[9]=_-E,e[10]=1-(c+p),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function M(e,t){var r=t[4],n=t[5],i=t[6],o=t[8],a=t[9],s=t[10];return e[0]=Math.hypot(t[0],t[1],t[2]),e[1]=Math.hypot(r,n,i),e[2]=Math.hypot(o,a,s),e}function I(e,t,r,n,i){var o,a=1/Math.tan(t/2);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+n)*(o=1/(n-i)),e[14]=2*i*n*o):(e[10]=-1,e[14]=-2*n),e}function O(e,t,r,n,i,o,a){var s=1/(t-r),l=1/(n-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*l,e[14]=(a+o)*u,e[15]=1,e}function x(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var B,D=S,b=Object.freeze({__proto__:null,add:function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e},adjoint:function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8],f=t[9],d=t[10],p=t[11],_=t[12],h=t[13],E=t[14],R=t[15];return e[0]=s*(d*R-p*E)-f*(l*R-u*E)+h*(l*p-u*d),e[1]=-(n*(d*R-p*E)-f*(i*R-o*E)+h*(i*p-o*d)),e[2]=n*(l*R-u*E)-s*(i*R-o*E)+h*(i*u-o*l),e[3]=-(n*(l*p-u*d)-s*(i*p-o*d)+f*(i*u-o*l)),e[4]=-(a*(d*R-p*E)-c*(l*R-u*E)+_*(l*p-u*d)),e[5]=r*(d*R-p*E)-c*(i*R-o*E)+_*(i*p-o*d),e[6]=-(r*(l*R-u*E)-a*(i*R-o*E)+_*(i*u-o*l)),e[7]=r*(l*p-u*d)-a*(i*p-o*d)+c*(i*u-o*l),e[8]=a*(f*R-p*h)-c*(s*R-u*h)+_*(s*p-u*f),e[9]=-(r*(f*R-p*h)-c*(n*R-o*h)+_*(n*p-o*f)),e[10]=r*(s*R-u*h)-a*(n*R-o*h)+_*(n*u-o*s),e[11]=-(r*(s*p-u*f)-a*(n*p-o*f)+c*(n*u-o*s)),e[12]=-(a*(f*E-d*h)-c*(s*E-l*h)+_*(s*d-l*f)),e[13]=r*(f*E-d*h)-c*(n*E-i*h)+_*(n*d-i*f),e[14]=-(r*(s*E-l*h)-a*(n*E-i*h)+_*(n*l-i*s)),e[15]=r*(s*d-l*f)-a*(n*d-i*f)+c*(n*l-i*s),e},clone:function(e){var t=new v(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},copy:m,create:T,determinant:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],a=e[5],s=e[6],l=e[7],u=e[8],c=e[9],f=e[10],d=e[11],p=e[12],_=e[13],h=e[14],E=e[15];return(t*a-r*o)*(f*E-d*h)-(t*s-n*o)*(c*E-d*_)+(t*l-i*o)*(c*h-f*_)+(r*s-n*a)*(u*E-d*p)-(r*l-i*a)*(u*h-f*p)+(n*l-i*s)*(u*_-c*p)},equals:function(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],l=e[6],u=e[7],c=e[8],f=e[9],d=e[10],p=e[11],_=e[12],h=e[13],E=e[14],v=e[15],T=t[0],m=t[1],A=t[2],g=t[3],y=t[4],S=t[5],C=t[6],P=t[7],N=t[8],M=t[9],I=t[10],O=t[11],x=t[12],B=t[13],D=t[14],b=t[15];return!(Math.abs(r-T)>R*Math.max(1,Math.abs(r),Math.abs(T))||Math.abs(n-m)>R*Math.max(1,Math.abs(n),Math.abs(m))||Math.abs(i-A)>R*Math.max(1,Math.abs(i),Math.abs(A))||Math.abs(o-g)>R*Math.max(1,Math.abs(o),Math.abs(g))||Math.abs(a-y)>R*Math.max(1,Math.abs(a),Math.abs(y))||Math.abs(s-S)>R*Math.max(1,Math.abs(s),Math.abs(S))||Math.abs(l-C)>R*Math.max(1,Math.abs(l),Math.abs(C))||Math.abs(u-P)>R*Math.max(1,Math.abs(u),Math.abs(P))||Math.abs(c-N)>R*Math.max(1,Math.abs(c),Math.abs(N))||Math.abs(f-M)>R*Math.max(1,Math.abs(f),Math.abs(M))||Math.abs(d-I)>R*Math.max(1,Math.abs(d),Math.abs(I))||Math.abs(p-O)>R*Math.max(1,Math.abs(p),Math.abs(O))||Math.abs(_-x)>R*Math.max(1,Math.abs(_),Math.abs(x))||Math.abs(h-B)>R*Math.max(1,Math.abs(h),Math.abs(B))||Math.abs(E-D)>R*Math.max(1,Math.abs(E),Math.abs(D))||Math.abs(v-b)>R*Math.max(1,Math.abs(v),Math.abs(b)))},exactEquals:function(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]},frob:function(e){return Math.hypot(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])},fromQuat:function(e,t){var r=t[0],n=t[1],i=t[2],o=t[3],a=r+r,s=n+n,l=i+i,u=r*a,c=n*a,f=n*s,d=i*a,p=i*s,_=i*l,h=o*a,E=o*s,R=o*l;return e[0]=1-f-_,e[1]=c+R,e[2]=d-E,e[3]=0,e[4]=c-R,e[5]=1-u-_,e[6]=p+h,e[7]=0,e[8]=d+E,e[9]=p-h,e[10]=1-u-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromQuat2:function(e,t){var r=new v(3),n=-t[0],i=-t[1],o=-t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=n*n+i*i+o*o+a*a;return f>0?(r[0]=2*(s*a+c*n+l*o-u*i)/f,r[1]=2*(l*a+c*i+u*n-s*o)/f,r[2]=2*(u*a+c*o+s*i-l*n)/f):(r[0]=2*(s*a+c*n+l*o-u*i),r[1]=2*(l*a+c*i+u*n-s*o),r[2]=2*(u*a+c*o+s*i-l*n)),N(e,t,r),e},fromRotation:function(e,t,r){var n,i,o,a=r[0],s=r[1],l=r[2],u=Math.hypot(a,s,l);return R>u?null:(a*=u=1/u,s*=u,l*=u,n=Math.sin(t),e[0]=a*a*(o=1-(i=Math.cos(t)))+i,e[1]=s*a*o+l*n,e[2]=l*a*o-s*n,e[3]=0,e[4]=a*s*o-l*n,e[5]=s*s*o+i,e[6]=l*s*o+a*n,e[7]=0,e[8]=a*l*o+s*n,e[9]=s*l*o-a*n,e[10]=l*l*o+i,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)},fromRotationTranslation:N,fromRotationTranslationScale:function(e,t,r,n){var i=t[0],o=t[1],a=t[2],s=t[3],l=i+i,u=o+o,c=a+a,f=i*l,d=i*u,p=i*c,_=o*u,h=o*c,E=a*c,R=s*l,v=s*u,T=s*c,m=n[0],A=n[1],g=n[2];return e[0]=(1-(_+E))*m,e[1]=(d+T)*m,e[2]=(p-v)*m,e[3]=0,e[4]=(d-T)*A,e[5]=(1-(f+E))*A,e[6]=(h+R)*A,e[7]=0,e[8]=(p+v)*g,e[9]=(h-R)*g,e[10]=(1-(f+_))*g,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e},fromRotationTranslationScaleOrigin:function(e,t,r,n,i){var o=t[0],a=t[1],s=t[2],l=t[3],u=o+o,c=a+a,f=s+s,d=o*u,p=o*c,_=o*f,h=a*c,E=a*f,R=s*f,v=l*u,T=l*c,m=l*f,A=n[0],g=n[1],y=n[2],S=i[0],C=i[1],P=i[2],N=(1-(h+R))*A,M=(p+m)*A,I=(_-T)*A,O=(p-m)*g,x=(1-(d+R))*g,B=(E+v)*g,D=(_+T)*y,b=(E-v)*y,L=(1-(d+h))*y;return e[0]=N,e[1]=M,e[2]=I,e[3]=0,e[4]=O,e[5]=x,e[6]=B,e[7]=0,e[8]=D,e[9]=b,e[10]=L,e[11]=0,e[12]=r[0]+S-(N*S+O*C+D*P),e[13]=r[1]+C-(M*S+x*C+b*P),e[14]=r[2]+P-(I*S+B*C+L*P),e[15]=1,e},fromScaling:function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromTranslation:P,fromValues:A,fromXRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromYRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},fromZRotation:function(e,t){var r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,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},frustum:function(e,t,r,n,i,o,a){var s=1/(r-t),l=1/(i-n),u=1/(o-a);return e[0]=2*o*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*l,e[10]=(a+o)*u,e[11]=-1,e[12]=0,e[13]=0,e[14]=a*o*2*u,e[15]=0,e},getRotation:function(e,t){var r=new v(3);M(r,t);var n=1/r[0],i=1/r[1],o=1/r[2],a=t[0]*n,s=t[1]*i,l=t[2]*o,u=t[4]*n,c=t[5]*i,f=t[6]*o,d=t[8]*n,p=t[9]*i,_=t[10]*o,h=a+c+_,E=0;return h>0?(e[3]=.25*(E=2*Math.sqrt(h+1)),e[0]=(f-p)/E,e[1]=(d-l)/E,e[2]=(s-u)/E):a>c&&a>_?(e[3]=(f-p)/(E=2*Math.sqrt(1+a-c-_)),e[0]=.25*E,e[1]=(s+u)/E,e[2]=(d+l)/E):c>_?(e[3]=(d-l)/(E=2*Math.sqrt(1+c-a-_)),e[0]=(s+u)/E,e[1]=.25*E,e[2]=(f+p)/E):(e[3]=(s-u)/(E=2*Math.sqrt(1+_-a-c)),e[0]=(d+l)/E,e[1]=(f+p)/E,e[2]=.25*E),e},getScaling:M,getTranslation:function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e},identity:g,invert:y,lookAt:function(e,t,r,n){var i,o,a,s,l,u,c,f,d,p,_=t[0],h=t[1],E=t[2],v=n[0],T=n[1],m=n[2],A=r[0],y=r[1],S=r[2];return R>Math.abs(_-A)&&R>Math.abs(h-y)&&R>Math.abs(E-S)?g(e):(p=1/Math.hypot(c=_-A,f=h-y,d=E-S),(p=Math.hypot(i=T*(d*=p)-m*(f*=p),o=m*(c*=p)-v*d,a=v*f-T*c))?(i*=p=1/p,o*=p,a*=p):(i=0,o=0,a=0),(p=Math.hypot(s=f*a-d*o,l=d*i-c*a,u=c*o-f*i))?(s*=p=1/p,l*=p,u*=p):(s=0,l=0,u=0),e[0]=i,e[1]=s,e[2]=c,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(i*_+o*h+a*E),e[13]=-(s*_+l*h+u*E),e[14]=-(c*_+f*h+d*E),e[15]=1,e)},mul:D,multiply:S,multiplyScalar:function(e,t,r){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]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e},multiplyScalarAndAdd:function(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e},ortho:O,orthoNO:O,orthoZO:function(e,t,r,n,i,o,a){var s=1/(t-r),l=1/(n-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=u,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*l,e[14]=o*u,e[15]=1,e},perspective:I,perspectiveFromFieldOfView:function(e,t,r,n){var i=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),s=Math.tan(t.rightDegrees*Math.PI/180),l=2/(a+s),u=2/(i+o);return e[0]=l,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=u,e[6]=0,e[7]=0,e[8]=-(a-s)*l*.5,e[9]=(i-o)*u*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e},perspectiveNO:I,perspectiveZO:function(e,t,r,n,i){var o,a=1/Math.tan(t/2);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=i*(o=1/(n-i)),e[14]=i*n*o):(e[10]=-1,e[14]=-n),e},rotate:function(e,t,r,n){var i,o,a,s,l,u,c,f,d,p,_,h,E,v,T,m,A,g,y,S,C,P,N,M,I=n[0],O=n[1],x=n[2],B=Math.hypot(I,O,x);return R>B?null:(I*=B=1/B,O*=B,x*=B,i=Math.sin(r),l=t[1],u=t[2],c=t[3],d=t[5],p=t[6],_=t[7],E=t[9],v=t[10],T=t[11],y=I*O*(a=1-(o=Math.cos(r)))-x*i,S=O*O*a+o,C=x*O*a+I*i,P=I*x*a+O*i,N=O*x*a-I*i,M=x*x*a+o,e[0]=(s=t[0])*(m=I*I*a+o)+(f=t[4])*(A=O*I*a+x*i)+(h=t[8])*(g=x*I*a-O*i),e[1]=l*m+d*A+E*g,e[2]=u*m+p*A+v*g,e[3]=c*m+_*A+T*g,e[4]=s*y+f*S+h*C,e[5]=l*y+d*S+E*C,e[6]=u*y+p*S+v*C,e[7]=c*y+_*S+T*C,e[8]=s*P+f*N+h*M,e[9]=l*P+d*N+E*M,e[10]=u*P+p*N+v*M,e[11]=c*P+_*N+T*M,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)},rotateX:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[4],a=t[5],s=t[6],l=t[7],u=t[8],c=t[9],f=t[10],d=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]=o*i+u*n,e[5]=a*i+c*n,e[6]=s*i+f*n,e[7]=l*i+d*n,e[8]=u*i-o*n,e[9]=c*i-a*n,e[10]=f*i-s*n,e[11]=d*i-l*n,e},rotateY:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],a=t[1],s=t[2],l=t[3],u=t[8],c=t[9],f=t[10],d=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]=o*i-u*n,e[1]=a*i-c*n,e[2]=s*i-f*n,e[3]=l*i-d*n,e[8]=o*n+u*i,e[9]=a*n+c*i,e[10]=s*n+f*i,e[11]=l*n+d*i,e},rotateZ:function(e,t,r){var n=Math.sin(r),i=Math.cos(r),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],f=t[6],d=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]=o*i+u*n,e[1]=a*i+c*n,e[2]=s*i+f*n,e[3]=l*i+d*n,e[4]=u*i-o*n,e[5]=c*i-a*n,e[6]=f*i-s*n,e[7]=d*i-l*n,e},scale:C,set:function(e,t,r,n,i,o,a,s,l,u,c,f,d,p,_,h,E){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=o,e[5]=a,e[6]=s,e[7]=l,e[8]=u,e[9]=c,e[10]=f,e[11]=d,e[12]=p,e[13]=_,e[14]=h,e[15]=E,e},str:function(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]+")"},sub:x,subtract:x,targetTo:function(e,t,r,n){var i=t[0],o=t[1],a=t[2],s=n[0],l=n[1],u=n[2],c=i-r[0],f=o-r[1],d=a-r[2],p=c*c+f*f+d*d;p>0&&(c*=p=1/Math.sqrt(p),f*=p,d*=p);var _=l*d-u*f,h=u*c-s*d,E=s*f-l*c;return(p=_*_+h*h+E*E)>0&&(_*=p=1/Math.sqrt(p),h*=p,E*=p),e[0]=_,e[1]=h,e[2]=E,e[3]=0,e[4]=f*E-d*h,e[5]=d*_-c*E,e[6]=c*h-f*_,e[7]=0,e[8]=c,e[9]=f,e[10]=d,e[11]=0,e[12]=i,e[13]=o,e[14]=a,e[15]=1,e},translate:function(e,t,r){var n,i,o,a,s,l,u,c,f,d,p,_,h=r[0],E=r[1],R=r[2];return t===e?(e[12]=t[0]*h+t[4]*E+t[8]*R+t[12],e[13]=t[1]*h+t[5]*E+t[9]*R+t[13],e[14]=t[2]*h+t[6]*E+t[10]*R+t[14],e[15]=t[3]*h+t[7]*E+t[11]*R+t[15]):(i=t[1],o=t[2],a=t[3],s=t[4],l=t[5],u=t[6],c=t[7],f=t[8],d=t[9],p=t[10],_=t[11],e[0]=n=t[0],e[1]=i,e[2]=o,e[3]=a,e[4]=s,e[5]=l,e[6]=u,e[7]=c,e[8]=f,e[9]=d,e[10]=p,e[11]=_,e[12]=n*h+s*E+f*R+t[12],e[13]=i*h+l*E+d*R+t[13],e[14]=o*h+u*E+p*R+t[14],e[15]=a*h+c*E+_*R+t[15]),e},transpose:function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],o=t[6],a=t[7],s=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=i,e[13]=a,e[14]=s}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}});function L(e,t,r){var n=new v(3);return n[0]=e,n[1]=t,n[2]=r,n}function F(e,t,r){return{x:e*Math.cos(r)-t*Math.sin(r),y:e*Math.sin(r)+t*Math.cos(r)}}function U(e,t,r,n,i,o,a,s,l,u){var c,f,d,p,_,h=e,E=t,R=r,v=n,T=s,m=l,A=120*Math.PI/180,g=Math.PI/180*(+i||0),y=[];if(u)f=u[0],d=u[1],p=u[2],_=u[3];else{E=(c=F(h,E,-g)).y;var S=((h=c.x)-(T=(c=F(T,m,-g)).x))/2,C=(E-(m=c.y))/2,P=S*S/(R*R)+C*C/(v*v);P>1&&(R*=P=Math.sqrt(P),v*=P);var N=R*R,M=v*v,I=(o===a?-1:1)*Math.sqrt(Math.abs((N*M-N*C*C-M*S*S)/(N*C*C+M*S*S)));p=I*R*C/v+(h+T)/2,f=Math.asin(((E-(_=I*-v*S/R+(E+m)/2))/v*1e9>>0)/1e9),d=Math.asin(((m-_)/v*1e9>>0)/1e9),0>(f=p>h?Math.PI-f:f)&&(f=2*Math.PI+f),0>(d=p>T?Math.PI-d:d)&&(d=2*Math.PI+d),a&&f>d&&(f-=2*Math.PI),!a&&d>f&&(d-=2*Math.PI)}var O=d-f;if(Math.abs(O)>A){var x=d,B=T,D=m;y=U(T=p+R*Math.cos(d=f+A*(a&&d>f?1:-1)),m=_+v*Math.sin(d),R,v,i,0,a,B,D,[d,x,p,_])}O=d-f;var b=Math.cos(f),L=Math.sin(f),w=Math.cos(d),G=Math.sin(d),k=Math.tan(O/4),V=4/3*R*k,X=4/3*v*k,W=[h,E],H=[h+V*L,E-X*b],Y=[T+V*G,m-X*w],z=[T,m];if(H[0]=2*W[0]-H[0],H[1]=2*W[1]-H[1],u)return H.concat(Y,z,y);for(var K=[],j=0,Z=(y=H.concat(Y,z,y)).length;Z>j;j+=1)K[j]=j%2?F(y[j-1],y[j],g).y:F(y[j],y[j+1],g).x;return K}B=new v(3),v!=Float32Array&&(B[0]=0,B[1]=0,B[2]=0);var w={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function o(e,t,n,o,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new i(n,o||e,a),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],s]:e._events[l].push(s):(e._events[l]=s,e._eventsCount++),e}function a(e,t){0==--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),s.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},s.prototype.listeners=function(e){var t=this._events[r?r+e:e];if(!t)return[];if(t.fn)return[t.fn];for(var n=0,i=t.length,o=Array(i);i>n;n++)o[n]=t[n].fn;return o},s.prototype.listenerCount=function(e){var t=this._events[r?r+e:e];return t?t.fn?1:t.length:0},s.prototype.emit=function(e,t,n,i,o,a){var s=r?r+e:e;if(!this._events[s])return!1;var l,u,c=this._events[s],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,o),!0;case 6:return c.fn.call(c.context,t,n,i,o,a),!0}for(u=1,l=Array(f-1);f>u;u++)l[u-1]=arguments[u];c.fn.apply(c.context,l)}else{var d,p=c.length;for(u=0;p>u;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,i);break;default:if(!l)for(d=1,l=Array(f-1);f>d;d++)l[d-1]=arguments[d];c[u].fn.apply(c[u].context,l)}}return!0},s.prototype.on=function(e,t,r){return o(this,e,t,r,!1)},s.prototype.once=function(e,t,r){return o(this,e,t,r,!0)},s.prototype.removeListener=function(e,t,n,i){var o=r?r+e:e;if(!this._events[o])return this;if(!t)return a(this,o),this;var s=this._events[o];if(s.fn)s.fn!==t||i&&!s.once||n&&s.context!==n||a(this,o);else{for(var l=0,u=[],c=s.length;c>l;l++)(s[l].fn!==t||i&&!s[l].once||n&&s[l].context!==n)&&u.push(s[l]);u.length?this._events[o]=1===u.length?u[0]:u:a(this,o)}return this},s.prototype.removeAllListeners=function(e){var t;return e?this._events[t=r?r+e:e]&&a(this,t):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=r,s.EventEmitter=s,e.exports=s}(w);var G,k,V,X,W,H,Y,z,K,j,Z,q,Q,$,J,ee,te,re,ne,ie,oe,ae,se,le,ue,ce,fe,de=w.exports;function pe(e,t,r,n){return{dimension:ee.TEXTURE_2D,format:e,width:t,height:r,depthOrArrayLayers:1,mipLevelCount:n,usage:te.SAMPLED}}function _e(e,t,r){return e<<16|t<<8|r}function he(e){return e>>>8&255}function Ee(e){return e>>>16&255}function Re(e){return 255&e}function ve(e){switch(e){case le.F32:case le.U32:case le.S32:return 4;case le.U16:case le.S16:case le.F16:return 2;case le.U8:case le.S8:return 1;default:throw Error("whoops")}}function Te(e){return ve(Ee(e))}function me(e){var t=Re(e);if(t&ce.Depth)return ie.Depth;if(t&ce.Normalized)return ie.Float;var r=Ee(e);if(r===le.F16||r===le.F32)return ie.Float;if(r===le.U8||r===le.U16||r===le.U32)return ie.Uint;if(r===le.S8||r===le.S16||r===le.S32)return ie.Sint;throw Error("whoops")}function Ae(e,t){if(void 0===t&&(t=""),!e)throw Error("Assert fail: ".concat(t))}function ge(e){if(null!=e)return e;throw Error("Missing object")}function ye(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}function Se(e,t,r,n){return void 0===n&&(n=1),{r:e,g:t,b:r,a:n}}!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.ALWAYS=519]="ALWAYS",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.GEQUAL=518]="GEQUAL",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.UNSIGNED_INT_24_8_WEBGL=34042]="UNSIGNED_INT_24_8_WEBGL",e[e.HALF_FLOAT_OES=36193]="HALF_FLOAT_OES",e[e.RGBA32F_EXT=34836]="RGBA32F_EXT",e[e.RGB32F_EXT=34837]="RGB32F_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT",e[e.UNSIGNED_NORMALIZED_EXT=35863]="UNSIGNED_NORMALIZED_EXT",e[e.MIN_EXT=32775]="MIN_EXT",e[e.MAX_EXT=32776]="MAX_EXT",e[e.SRGB_EXT=35904]="SRGB_EXT",e[e.SRGB_ALPHA_EXT=35906]="SRGB_ALPHA_EXT",e[e.SRGB8_ALPHA8_EXT=35907]="SRGB8_ALPHA8_EXT",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT_OES=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT_OES",e[e.COLOR_ATTACHMENT0_WEBGL=36064]="COLOR_ATTACHMENT0_WEBGL",e[e.COLOR_ATTACHMENT1_WEBGL=36065]="COLOR_ATTACHMENT1_WEBGL",e[e.COLOR_ATTACHMENT2_WEBGL=36066]="COLOR_ATTACHMENT2_WEBGL",e[e.COLOR_ATTACHMENT3_WEBGL=36067]="COLOR_ATTACHMENT3_WEBGL",e[e.COLOR_ATTACHMENT4_WEBGL=36068]="COLOR_ATTACHMENT4_WEBGL",e[e.COLOR_ATTACHMENT5_WEBGL=36069]="COLOR_ATTACHMENT5_WEBGL",e[e.COLOR_ATTACHMENT6_WEBGL=36070]="COLOR_ATTACHMENT6_WEBGL",e[e.COLOR_ATTACHMENT7_WEBGL=36071]="COLOR_ATTACHMENT7_WEBGL",e[e.COLOR_ATTACHMENT8_WEBGL=36072]="COLOR_ATTACHMENT8_WEBGL",e[e.COLOR_ATTACHMENT9_WEBGL=36073]="COLOR_ATTACHMENT9_WEBGL",e[e.COLOR_ATTACHMENT10_WEBGL=36074]="COLOR_ATTACHMENT10_WEBGL",e[e.COLOR_ATTACHMENT11_WEBGL=36075]="COLOR_ATTACHMENT11_WEBGL",e[e.COLOR_ATTACHMENT12_WEBGL=36076]="COLOR_ATTACHMENT12_WEBGL",e[e.COLOR_ATTACHMENT13_WEBGL=36077]="COLOR_ATTACHMENT13_WEBGL",e[e.COLOR_ATTACHMENT14_WEBGL=36078]="COLOR_ATTACHMENT14_WEBGL",e[e.COLOR_ATTACHMENT15_WEBGL=36079]="COLOR_ATTACHMENT15_WEBGL",e[e.DRAW_BUFFER0_WEBGL=34853]="DRAW_BUFFER0_WEBGL",e[e.DRAW_BUFFER1_WEBGL=34854]="DRAW_BUFFER1_WEBGL",e[e.DRAW_BUFFER2_WEBGL=34855]="DRAW_BUFFER2_WEBGL",e[e.DRAW_BUFFER3_WEBGL=34856]="DRAW_BUFFER3_WEBGL",e[e.DRAW_BUFFER4_WEBGL=34857]="DRAW_BUFFER4_WEBGL",e[e.DRAW_BUFFER5_WEBGL=34858]="DRAW_BUFFER5_WEBGL",e[e.DRAW_BUFFER6_WEBGL=34859]="DRAW_BUFFER6_WEBGL",e[e.DRAW_BUFFER7_WEBGL=34860]="DRAW_BUFFER7_WEBGL",e[e.DRAW_BUFFER8_WEBGL=34861]="DRAW_BUFFER8_WEBGL",e[e.DRAW_BUFFER9_WEBGL=34862]="DRAW_BUFFER9_WEBGL",e[e.DRAW_BUFFER10_WEBGL=34863]="DRAW_BUFFER10_WEBGL",e[e.DRAW_BUFFER11_WEBGL=34864]="DRAW_BUFFER11_WEBGL",e[e.DRAW_BUFFER12_WEBGL=34865]="DRAW_BUFFER12_WEBGL",e[e.DRAW_BUFFER13_WEBGL=34866]="DRAW_BUFFER13_WEBGL",e[e.DRAW_BUFFER14_WEBGL=34867]="DRAW_BUFFER14_WEBGL",e[e.DRAW_BUFFER15_WEBGL=34868]="DRAW_BUFFER15_WEBGL",e[e.MAX_COLOR_ATTACHMENTS_WEBGL=36063]="MAX_COLOR_ATTACHMENTS_WEBGL",e[e.MAX_DRAW_BUFFERS_WEBGL=34852]="MAX_DRAW_BUFFERS_WEBGL",e[e.VERTEX_ARRAY_BINDING_OES=34229]="VERTEX_ARRAY_BINDING_OES",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT"}(G||(G={})),function(e){e[e.Buffer=0]="Buffer",e[e.Texture=1]="Texture",e[e.RenderTarget=2]="RenderTarget",e[e.Sampler=3]="Sampler",e[e.Program=4]="Program",e[e.Bindings=5]="Bindings",e[e.InputLayout=6]="InputLayout",e[e.RenderPipeline=7]="RenderPipeline",e[e.ComputePipeline=8]="ComputePipeline",e[e.Readback=9]="Readback",e[e.QueryPool=10]="QueryPool",e[e.RenderBundle=11]="RenderBundle"}(k||(k={})),function(e){e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS"}(V||(V={})),function(e){e[e.CCW=2305]="CCW",e[e.CW=2304]="CW"}(X||(X={})),function(e){e[e.NONE=0]="NONE",e[e.FRONT=1]="FRONT",e[e.BACK=2]="BACK",e[e.FRONT_AND_BACK=3]="FRONT_AND_BACK"}(W||(W={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC=768]="SRC",e[e.ONE_MINUS_SRC=769]="ONE_MINUS_SRC",e[e.DST=774]="DST",e[e.ONE_MINUS_DST=775]="ONE_MINUS_DST",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONST=32769]="CONST",e[e.ONE_MINUS_CONSTANT=32770]="ONE_MINUS_CONSTANT",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(H||(H={})),function(e){e[e.ADD=32774]="ADD",e[e.SUBSTRACT=32778]="SUBSTRACT",e[e.REVERSE_SUBSTRACT=32779]="REVERSE_SUBSTRACT",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX"}(Y||(Y={})),function(e){e[e.CLAMP_TO_EDGE=0]="CLAMP_TO_EDGE",e[e.REPEAT=1]="REPEAT",e[e.MIRRORED_REPEAT=2]="MIRRORED_REPEAT"}(z||(z={})),function(e){e[e.POINT=0]="POINT",e[e.BILINEAR=1]="BILINEAR"}(K||(K={})),function(e){e[e.NO_MIP=0]="NO_MIP",e[e.NEAREST=1]="NEAREST",e[e.LINEAR=2]="LINEAR"}(j||(j={})),function(e){e[e.POINTS=0]="POINTS",e[e.TRIANGLES=1]="TRIANGLES",e[e.TRIANGLE_STRIP=2]="TRIANGLE_STRIP",e[e.LINES=3]="LINES",e[e.LINE_STRIP=4]="LINE_STRIP"}(Z||(Z={})),function(e){e[e.MAP_READ=1]="MAP_READ",e[e.MAP_WRITE=2]="MAP_WRITE",e[e.COPY_SRC=4]="COPY_SRC",e[e.COPY_DST=8]="COPY_DST",e[e.INDEX=16]="INDEX",e[e.VERTEX=32]="VERTEX",e[e.UNIFORM=64]="UNIFORM",e[e.STORAGE=128]="STORAGE",e[e.INDIRECT=256]="INDIRECT",e[e.QUERY_RESOLVE=512]="QUERY_RESOLVE"}(q||(q={})),function(e){e[e.STATIC=1]="STATIC",e[e.DYNAMIC=2]="DYNAMIC"}(Q||(Q={})),function(e){e[e.VERTEX=1]="VERTEX",e[e.INSTANCE=2]="INSTANCE"}($||($={})),function(e){e.LOADED="loaded"}(J||(J={})),function(e){e[e.TEXTURE_2D=0]="TEXTURE_2D",e[e.TEXTURE_2D_ARRAY=1]="TEXTURE_2D_ARRAY",e[e.TEXTURE_3D=2]="TEXTURE_3D",e[e.TEXTURE_CUBE_MAP=3]="TEXTURE_CUBE_MAP"}(ee||(ee={})),function(e){e[e.SAMPLED=1]="SAMPLED",e[e.RENDER_TARGET=2]="RENDER_TARGET",e[e.STORAGE=4]="STORAGE"}(te||(te={})),function(e){e[e.NONE=0]="NONE",e[e.RED=1]="RED",e[e.GREEN=2]="GREEN",e[e.BLUE=4]="BLUE",e[e.ALPHA=8]="ALPHA",e[e.RGB=7]="RGB",e[e.ALL=15]="ALL"}(re||(re={})),function(e){e[e.KEEP=7680]="KEEP",e[e.ZERO=0]="ZERO",e[e.REPLACE=7681]="REPLACE",e[e.INVERT=5386]="INVERT",e[e.INCREMENT_CLAMP=7682]="INCREMENT_CLAMP",e[e.DECREMENT_CLAMP=7683]="DECREMENT_CLAMP",e[e.INCREMENT_WRAP=34055]="INCREMENT_WRAP",e[e.DECREMENT_WRAP=34056]="DECREMENT_WRAP"}(ne||(ne={})),function(e){e[e.Float=0]="Float",e[e.UnfilterableFloat=1]="UnfilterableFloat",e[e.Uint=2]="Uint",e[e.Sint=3]="Sint",e[e.Depth=4]="Depth"}(ie||(ie={})),function(e){e[e.LOWER_LEFT=0]="LOWER_LEFT",e[e.UPPER_LEFT=1]="UPPER_LEFT"}(oe||(oe={})),function(e){e[e.NEGATIVE_ONE=0]="NEGATIVE_ONE",e[e.ZERO=1]="ZERO"}(ae||(ae={})),function(e){e[e.OcclusionConservative=0]="OcclusionConservative"}(se||(se={})),function(e){e[e.U8=1]="U8",e[e.U16=2]="U16",e[e.U32=3]="U32",e[e.S8=4]="S8",e[e.S16=5]="S16",e[e.S32=6]="S32",e[e.F16=7]="F16",e[e.F32=8]="F32",e[e.BC1=65]="BC1",e[e.BC2=66]="BC2",e[e.BC3=67]="BC3",e[e.BC4_UNORM=68]="BC4_UNORM",e[e.BC4_SNORM=69]="BC4_SNORM",e[e.BC5_UNORM=70]="BC5_UNORM",e[e.BC5_SNORM=71]="BC5_SNORM",e[e.U16_PACKED_5551=97]="U16_PACKED_5551",e[e.U16_PACKED_565=98]="U16_PACKED_565",e[e.D24=129]="D24",e[e.D32F=130]="D32F",e[e.D24S8=131]="D24S8",e[e.D32FS8=132]="D32FS8"}(le||(le={})),function(e){e[e.R=1]="R",e[e.RG=2]="RG",e[e.RGB=3]="RGB",e[e.RGBA=4]="RGBA",e[e.A=5]="A"}(ue||(ue={})),function(e){e[e.None=0]="None",e[e.Normalized=1]="Normalized",e[e.sRGB=2]="sRGB",e[e.Depth=4]="Depth",e[e.Stencil=8]="Stencil",e[e.RenderTarget=16]="RenderTarget",e[e.Luminance=32]="Luminance"}(ce||(ce={})),function(e){e[e.ALPHA=_e(le.U8,ue.A,ce.None)]="ALPHA",e[e.U8_LUMINANCE=_e(le.U8,ue.A,ce.Luminance)]="U8_LUMINANCE",e[e.F16_LUMINANCE=_e(le.F16,ue.A,ce.Luminance)]="F16_LUMINANCE",e[e.F32_LUMINANCE=_e(le.F32,ue.A,ce.Luminance)]="F32_LUMINANCE",e[e.F16_R=_e(le.F16,ue.R,ce.None)]="F16_R",e[e.F16_RG=_e(le.F16,ue.RG,ce.None)]="F16_RG",e[e.F16_RGB=_e(le.F16,ue.RGB,ce.None)]="F16_RGB",e[e.F16_RGBA=_e(le.F16,ue.RGBA,ce.None)]="F16_RGBA",e[e.F32_R=_e(le.F32,ue.R,ce.None)]="F32_R",e[e.F32_RG=_e(le.F32,ue.RG,ce.None)]="F32_RG",e[e.F32_RGB=_e(le.F32,ue.RGB,ce.None)]="F32_RGB",e[e.F32_RGBA=_e(le.F32,ue.RGBA,ce.None)]="F32_RGBA",e[e.U8_R=_e(le.U8,ue.R,ce.None)]="U8_R",e[e.U8_R_NORM=_e(le.U8,ue.R,ce.Normalized)]="U8_R_NORM",e[e.U8_RG=_e(le.U8,ue.RG,ce.None)]="U8_RG",e[e.U8_RG_NORM=_e(le.U8,ue.RG,ce.Normalized)]="U8_RG_NORM",e[e.U8_RGB=_e(le.U8,ue.RGB,ce.None)]="U8_RGB",e[e.U8_RGB_NORM=_e(le.U8,ue.RGB,ce.Normalized)]="U8_RGB_NORM",e[e.U8_RGB_SRGB=_e(le.U8,ue.RGB,ce.sRGB|ce.Normalized)]="U8_RGB_SRGB",e[e.U8_RGBA=_e(le.U8,ue.RGBA,ce.None)]="U8_RGBA",e[e.U8_RGBA_NORM=_e(le.U8,ue.RGBA,ce.Normalized)]="U8_RGBA_NORM",e[e.U8_RGBA_SRGB=_e(le.U8,ue.RGBA,ce.sRGB|ce.Normalized)]="U8_RGBA_SRGB",e[e.U16_R=_e(le.U16,ue.R,ce.None)]="U16_R",e[e.U16_R_NORM=_e(le.U16,ue.R,ce.Normalized)]="U16_R_NORM",e[e.U16_RG_NORM=_e(le.U16,ue.RG,ce.Normalized)]="U16_RG_NORM",e[e.U16_RGBA_NORM=_e(le.U16,ue.RGBA,ce.Normalized)]="U16_RGBA_NORM",e[e.U16_RGBA=_e(le.U16,ue.RGBA,ce.None)]="U16_RGBA",e[e.U16_RGB=_e(le.U16,ue.RGB,ce.None)]="U16_RGB",e[e.U16_RG=_e(le.U16,ue.RG,ce.None)]="U16_RG",e[e.U32_R=_e(le.U32,ue.R,ce.None)]="U32_R",e[e.U32_RG=_e(le.U32,ue.RG,ce.None)]="U32_RG",e[e.U32_RGB=_e(le.U32,ue.RGB,ce.None)]="U32_RGB",e[e.U32_RGBA=_e(le.U32,ue.RGBA,ce.None)]="U32_RGBA",e[e.S8_R=_e(le.S8,ue.R,ce.None)]="S8_R",e[e.S8_R_NORM=_e(le.S8,ue.R,ce.Normalized)]="S8_R_NORM",e[e.S8_RG_NORM=_e(le.S8,ue.RG,ce.Normalized)]="S8_RG_NORM",e[e.S8_RGB_NORM=_e(le.S8,ue.RGB,ce.Normalized)]="S8_RGB_NORM",e[e.S8_RGBA_NORM=_e(le.S8,ue.RGBA,ce.Normalized)]="S8_RGBA_NORM",e[e.S16_R=_e(le.S16,ue.R,ce.None)]="S16_R",e[e.S16_RG=_e(le.S16,ue.RG,ce.None)]="S16_RG",e[e.S16_RG_NORM=_e(le.S16,ue.RG,ce.Normalized)]="S16_RG_NORM",e[e.S16_RGB_NORM=_e(le.S16,ue.RGB,ce.Normalized)]="S16_RGB_NORM",e[e.S16_RGBA=_e(le.S16,ue.RGBA,ce.None)]="S16_RGBA",e[e.S16_RGBA_NORM=_e(le.S16,ue.RGBA,ce.Normalized)]="S16_RGBA_NORM",e[e.S32_R=_e(le.S32,ue.R,ce.None)]="S32_R",e[e.S32_RG=_e(le.S32,ue.RG,ce.None)]="S32_RG",e[e.S32_RGB=_e(le.S32,ue.RGB,ce.None)]="S32_RGB",e[e.S32_RGBA=_e(le.S32,ue.RGBA,ce.None)]="S32_RGBA",e[e.U16_RGBA_5551=_e(le.U16_PACKED_5551,ue.RGBA,ce.Normalized)]="U16_RGBA_5551",e[e.U16_RGB_565=_e(le.U16_PACKED_565,ue.RGB,ce.Normalized)]="U16_RGB_565",e[e.BC1=_e(le.BC1,ue.RGBA,ce.Normalized)]="BC1",e[e.BC1_SRGB=_e(le.BC1,ue.RGBA,ce.Normalized|ce.sRGB)]="BC1_SRGB",e[e.BC2=_e(le.BC2,ue.RGBA,ce.Normalized)]="BC2",e[e.BC2_SRGB=_e(le.BC2,ue.RGBA,ce.Normalized|ce.sRGB)]="BC2_SRGB",e[e.BC3=_e(le.BC3,ue.RGBA,ce.Normalized)]="BC3",e[e.BC3_SRGB=_e(le.BC3,ue.RGBA,ce.Normalized|ce.sRGB)]="BC3_SRGB",e[e.BC4_UNORM=_e(le.BC4_UNORM,ue.R,ce.Normalized)]="BC4_UNORM",e[e.BC4_SNORM=_e(le.BC4_SNORM,ue.R,ce.Normalized)]="BC4_SNORM",e[e.BC5_UNORM=_e(le.BC5_UNORM,ue.RG,ce.Normalized)]="BC5_UNORM",e[e.BC5_SNORM=_e(le.BC5_SNORM,ue.RG,ce.Normalized)]="BC5_SNORM",e[e.D24=_e(le.D24,ue.R,ce.Depth)]="D24",e[e.D24_S8=_e(le.D24S8,ue.RG,ce.Depth|ce.Stencil)]="D24_S8",e[e.D32F=_e(le.D32F,ue.R,ce.Depth)]="D32F",e[e.D32F_S8=_e(le.D32FS8,ue.RG,ce.Depth|ce.Stencil)]="D32F_S8",e[e.U8_RGB_RT=_e(le.U8,ue.RGB,ce.RenderTarget|ce.Normalized)]="U8_RGB_RT",e[e.U8_RGBA_RT=_e(le.U8,ue.RGBA,ce.RenderTarget|ce.Normalized)]="U8_RGBA_RT",e[e.U8_RGBA_RT_SRGB=_e(le.U8,ue.RGBA,ce.RenderTarget|ce.Normalized|ce.sRGB)]="U8_RGBA_RT_SRGB"}(fe||(fe={}));var Ce=Se(0,0,0,0),Pe=Se(0,0,0,1),Ne=Se(1,1,1,0),Me=Se(1,1,1,1);function Ie(e){return!(!e||0!=(e&e-1))}function Oe(e,t){return null!=e?e:t}function xe(e,t,r){e.length=t,e.fill(r)}function Be(e,t){var r=t-1;return e+r&~r}function De(e,t){return((e+t-1)/t|0)*t}function be(e,t,r){return r?e|=t:e&=~t,e}function Le(e,t){for(var r=Array(e),n=0;e>n;n++)r[n]=t();return r}function Fe(e,t){e.blendDstFactor=t.blendDstFactor,e.blendSrcFactor=t.blendSrcFactor,e.blendMode=t.blendMode}function Ue(e,t){return void 0===e&&(e={}),e.compare=t.compare,e.depthFailOp=t.depthFailOp,e.passOp=t.passOp,e.failOp=t.failOp,e.mask=t.mask,e}function we(e,t){return void 0===e&&(e={rgbBlendState:{},alphaBlendState:{},channelWriteMask:0}),Fe(e.rgbBlendState,t.rgbBlendState),Fe(e.alphaBlendState,t.alphaBlendState),e.channelWriteMask=t.channelWriteMask,e}function Ge(e,t){e.length!==t.length&&(e.length=t.length);for(var r=0;t.length>r;r++)e[r]=we(e[r],t[r])}function ke(e,t){void 0!==t.attachmentsState&&Ge(e.attachmentsState,t.attachmentsState),e.blendConstant&&t.blendConstant&&function(e,t){e.r=t.r,e.g=t.g,e.b=t.b,e.a=t.a}(e.blendConstant,t.blendConstant),e.depthCompare=Oe(t.depthCompare,e.depthCompare),e.depthWrite=Oe(t.depthWrite,e.depthWrite),e.stencilWrite=Oe(t.stencilWrite,e.stencilWrite),e.stencilFront&&t.stencilFront&&Ue(e.stencilFront,t.stencilFront),e.stencilBack&&t.stencilBack&&Ue(e.stencilBack,t.stencilBack),e.cullMode=Oe(t.cullMode,e.cullMode),e.frontFace=Oe(t.frontFace,e.frontFace),e.polygonOffset=Oe(t.polygonOffset,e.polygonOffset)}function Ve(e){var t=Object.assign({},e);return t.attachmentsState=[],Ge(t.attachmentsState,e.attachmentsState),t.blendConstant=t.blendConstant&&ye(t.blendConstant),t.stencilFront=Ue(void 0,e.stencilFront),t.stencilBack=Ue(void 0,e.stencilBack),t}var Xe={blendMode:Y.ADD,blendSrcFactor:H.ONE,blendDstFactor:H.ZERO},We={attachmentsState:[{channelWriteMask:re.ALL,rgbBlendState:Xe,alphaBlendState:Xe}],blendConstant:ye(Ce),depthWrite:!0,depthCompare:V.LEQUAL,stencilWrite:!1,stencilFront:{compare:V.ALWAYS,passOp:ne.KEEP,depthFailOp:ne.KEEP,failOp:ne.KEEP},stencilBack:{compare:V.ALWAYS,passOp:ne.KEEP,depthFailOp:ne.KEEP,failOp:ne.KEEP},cullMode:W.NONE,frontFace:X.CCW,polygonOffset:!1};var He=function(e,t){void 0===e&&(e=null),void 0===t&&(t=We);var r=Ve(t);return null!==e&&ke(r,e),r}({depthCompare:V.ALWAYS,depthWrite:!1},We);function Ye(e,t){return void 0===e.attachmentsState&&(e.attachmentsState=[],Ge(e.attachmentsState,We.attachmentsState)),function(e,t){void 0!==t.channelWriteMask&&(e.channelWriteMask=t.channelWriteMask),void 0!==t.rgbBlendMode&&(e.rgbBlendState.blendMode=t.rgbBlendMode),void 0!==t.alphaBlendMode&&(e.alphaBlendState.blendMode=t.alphaBlendMode),void 0!==t.rgbBlendSrcFactor&&(e.rgbBlendState.blendSrcFactor=t.rgbBlendSrcFactor),void 0!==t.alphaBlendSrcFactor&&(e.alphaBlendState.blendSrcFactor=t.alphaBlendSrcFactor),void 0!==t.rgbBlendDstFactor&&(e.rgbBlendState.blendDstFactor=t.rgbBlendDstFactor),void 0!==t.alphaBlendDstFactor&&(e.alphaBlendState.blendDstFactor=t.alphaBlendDstFactor)}(e.attachmentsState[0],t),e}var ze,Ke={texture:null,sampler:null,formatKind:ie.Float,dimension:ee.TEXTURE_2D};function je(e,t,r){if(e.length!==t.length)return!1;for(var n=0;e.length>n;n++)if(!r(e[n],t[n]))return!1;return!0}function Ze(e,t){for(var r=Array(e.length),n=0;e.length>n;n++)r[n]=t(e[n]);return r}function qe(e,t){return e.texture===t.texture&&e.binding===t.binding}function Qe(e,t){return e.buffer===t.buffer&&e.size===t.size&&e.binding===t.binding&&e.offset===t.offset}function $e(e,t){return null===e?null===t:null!==t&&(e.sampler===t.sampler&&e.texture===t.texture&&e.dimension===t.dimension&&e.formatKind===t.formatKind&&e.comparison===t.comparison)}function Je(e,t){return e.samplerBindings=e.samplerBindings||[],e.uniformBufferBindings=e.uniformBufferBindings||[],e.storageBufferBindings=e.storageBufferBindings||[],e.storageTextureBindings=e.storageTextureBindings||[],t.samplerBindings=t.samplerBindings||[],t.uniformBufferBindings=t.uniformBufferBindings||[],t.storageBufferBindings=t.storageBufferBindings||[],t.storageTextureBindings=t.storageTextureBindings||[],e.samplerBindings.length===t.samplerBindings.length&&(!!je(e.samplerBindings,t.samplerBindings,$e)&&(!!je(e.uniformBufferBindings,t.uniformBufferBindings,Qe)&&(!!je(e.storageBufferBindings,t.storageBufferBindings,Qe)&&!!je(e.storageTextureBindings,t.storageTextureBindings,qe))))}function et(e,t){return e.blendMode==t.blendMode&&e.blendSrcFactor===t.blendSrcFactor&&e.blendDstFactor===t.blendDstFactor}function tt(e,t){return!!et(e.rgbBlendState,t.rgbBlendState)&&(!!et(e.alphaBlendState,t.alphaBlendState)&&e.channelWriteMask===t.channelWriteMask)}function rt(e,t){return e.compare==t.compare&&e.depthFailOp===t.depthFailOp&&e.failOp===t.failOp&&e.passOp===t.passOp&&e.mask===t.mask}function nt(e,t){return e.id===t.id}function it(e,t){return e===t}function ot(e,t){return e.topology===t.topology&&(e.inputLayout===t.inputLayout&&(e.sampleCount===t.sampleCount&&(!(e.megaStateDescriptor&&t.megaStateDescriptor&&!function(e,t){return!(!je(e.attachmentsState,t.attachmentsState,tt)||e.blendConstant&&t.blendConstant&&((r=e.blendConstant).r!==(n=t.blendConstant).r||r.g!==n.g||r.b!==n.b||r.a!==n.a)||e.stencilFront&&t.stencilFront&&!rt(e.stencilFront,t.stencilFront)||e.stencilBack&&t.stencilBack&&!rt(e.stencilBack,t.stencilBack)||e.depthCompare!==t.depthCompare||e.depthWrite!==t.depthWrite||e.stencilWrite!==t.stencilWrite||e.cullMode!==t.cullMode||e.frontFace!==t.frontFace||e.polygonOffset!==t.polygonOffset);var r,n}(e.megaStateDescriptor,t.megaStateDescriptor))&&(!!nt(e.program,t.program)&&(!!je(e.colorAttachmentFormats,t.colorAttachmentFormats,it)&&e.depthStencilAttachmentFormat===t.depthStencilAttachmentFormat)))))}function at(e,t){return e.offset===t.offset&&e.shaderLocation===t.shaderLocation&&e.format===t.format&&e.divisor===t.divisor}function st(e,t){return f(e)?f(t):!f(t)&&(e.arrayStride===t.arrayStride&&e.stepMode===t.stepMode&&je(e.attributes,t.attributes,at))}function lt(e,t){return e.indexBufferFormat===t.indexBufferFormat&&(!!je(e.vertexBufferDescriptors,t.vertexBufferDescriptors,st)&&!!nt(e.program,t.program))}function ut(e,t){return e.addressModeU===t.addressModeU&&e.addressModeV===t.addressModeV&&e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.mipmapFilter===t.mipmapFilter&&e.lodMinClamp===t.lodMinClamp&&e.lodMaxClamp===t.lodMaxClamp&&e.maxAnisotropy===t.maxAnisotropy&&e.compareFunction===t.compareFunction}function ct(e){return{sampler:e.sampler,texture:e.texture,dimension:e.dimension,formatKind:e.formatKind,comparison:e.comparison}}function ft(e){return{binding:e.binding,buffer:e.buffer,offset:e.offset,size:e.size}}function dt(e){return{binding:e.binding,texture:e.texture}}function pt(e){return{shaderLocation:e.shaderLocation,format:e.format,offset:e.offset,divisor:e.divisor}}function _t(e){return f(e)?e:{arrayStride:e.arrayStride,stepMode:e.stepMode,attributes:Ze(e.attributes,pt)}}var ht=/([^[]*)(\[[0-9]+\])?/;function Et(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};var t=e.match(ht);if(!t||2>t.length)throw Error("Failed to parse GLSL uniform name ".concat(e));return{name:t[1],length:Number(t[2])||1,isArray:!!t[2]}}function Rt(){var e=null;return function(t,r,n){var i=e!==n;return i&&(t.uniform1i(r,n),e=n),i}}function vt(e,t,r,n){var i=null,o=null;return function(a,s,l){var u=t(l,r),c=u.length,f=!1;if(null===i)i=new Float32Array(c),o=c,f=!0;else{Ae(o===c,"Uniform length cannot change.");for(var d=0;c>d;++d)if(u[d]!==i[d]){f=!0;break}}return f&&(n(a,e,s,u),i.set(u)),f}}function Tt(e,t,r,n){e[t](r,n)}function mt(e,t,r,n){e[t](r,!1,n)}var At={},gt={},yt={},St=[0];function Ct(e,t,r,n){1===t&&"boolean"==typeof e&&(e=e?1:0),Number.isFinite(e)&&(St[0]=e,e=St);var i=e.length;if(e instanceof r)return e;var o=n[i];o||(o=new r(i),n[i]=o);for(var a=0;i>a;a++)o[a]=e[a];return o}function Pt(e,t){return Ct(e,t,Float32Array,At)}function Nt(e,t){return Ct(e,t,Int32Array,gt)}function Mt(e,t){return Ct(e,t,Uint32Array,yt)}var It=((ze={})[G.FLOAT]=vt.bind(null,"uniform1fv",Pt,1,Tt),ze[G.FLOAT_VEC2]=vt.bind(null,"uniform2fv",Pt,2,Tt),ze[G.FLOAT_VEC3]=vt.bind(null,"uniform3fv",Pt,3,Tt),ze[G.FLOAT_VEC4]=vt.bind(null,"uniform4fv",Pt,4,Tt),ze[G.INT]=vt.bind(null,"uniform1iv",Nt,1,Tt),ze[G.INT_VEC2]=vt.bind(null,"uniform2iv",Nt,2,Tt),ze[G.INT_VEC3]=vt.bind(null,"uniform3iv",Nt,3,Tt),ze[G.INT_VEC4]=vt.bind(null,"uniform4iv",Nt,4,Tt),ze[G.BOOL]=vt.bind(null,"uniform1iv",Nt,1,Tt),ze[G.BOOL_VEC2]=vt.bind(null,"uniform2iv",Nt,2,Tt),ze[G.BOOL_VEC3]=vt.bind(null,"uniform3iv",Nt,3,Tt),ze[G.BOOL_VEC4]=vt.bind(null,"uniform4iv",Nt,4,Tt),ze[G.FLOAT_MAT2]=vt.bind(null,"uniformMatrix2fv",Pt,4,mt),ze[G.FLOAT_MAT3]=vt.bind(null,"uniformMatrix3fv",Pt,9,mt),ze[G.FLOAT_MAT4]=vt.bind(null,"uniformMatrix4fv",Pt,16,mt),ze[G.UNSIGNED_INT]=vt.bind(null,"uniform1uiv",Mt,1,Tt),ze[G.UNSIGNED_INT_VEC2]=vt.bind(null,"uniform2uiv",Mt,2,Tt),ze[G.UNSIGNED_INT_VEC3]=vt.bind(null,"uniform3uiv",Mt,3,Tt),ze[G.UNSIGNED_INT_VEC4]=vt.bind(null,"uniform4uiv",Mt,4,Tt),ze[G.FLOAT_MAT2x3]=vt.bind(null,"uniformMatrix2x3fv",Pt,6,mt),ze[G.FLOAT_MAT2x4]=vt.bind(null,"uniformMatrix2x4fv",Pt,8,mt),ze[G.FLOAT_MAT3x2]=vt.bind(null,"uniformMatrix3x2fv",Pt,6,mt),ze[G.FLOAT_MAT3x4]=vt.bind(null,"uniformMatrix3x4fv",Pt,12,mt),ze[G.FLOAT_MAT4x2]=vt.bind(null,"uniformMatrix4x2fv",Pt,8,mt),ze[G.FLOAT_MAT4x3]=vt.bind(null,"uniformMatrix4x3fv",Pt,12,mt),ze[G.SAMPLER_2D]=Rt,ze[G.SAMPLER_CUBE]=Rt,ze[G.SAMPLER_3D]=Rt,ze[G.SAMPLER_2D_SHADOW]=Rt,ze[G.SAMPLER_2D_ARRAY]=Rt,ze[G.SAMPLER_2D_ARRAY_SHADOW]=Rt,ze[G.SAMPLER_CUBE_SHADOW]=Rt,ze[G.INT_SAMPLER_2D]=Rt,ze[G.INT_SAMPLER_3D]=Rt,ze[G.INT_SAMPLER_CUBE]=Rt,ze[G.INT_SAMPLER_2D_ARRAY]=Rt,ze[G.UNSIGNED_INT_SAMPLER_2D]=Rt,ze[G.UNSIGNED_INT_SAMPLER_3D]=Rt,ze[G.UNSIGNED_INT_SAMPLER_CUBE]=Rt,ze[G.UNSIGNED_INT_SAMPLER_2D_ARRAY]=Rt,ze);function Ot(e,t,r){var n=It[r.type];if(!n)throw Error("Unknown GLSL uniform type ".concat(r.type));return n().bind(null,e,t)}var xt={"[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};function Bt(e,t){return"#define ".concat(e," ").concat(t)}function Dt(e){if(void 0===e)return null;var t=/binding\s*=\s*(\d+)/.exec(e);if(null!==t){var r=parseInt(t[1],10);if(!Number.isNaN(r))return r}return null}function bt(e){return[e,""]}function Lt(e,t,r,n,i){var o;void 0===n&&(n=null),void 0===i&&(i=!0);var a="#version 100"===e.glslVersion,s="frag"===t&&(null===(o=r.match(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm))||void 0===o?void 0:o.length)>1,l=r.replace("\r\n","\n").split("\n").map((function(e){return e.replace(/[/][/].*$/,"")})).filter((function(e){return!(!e||/^\s+$/.test(e))})),c="";null!==n&&(c=Object.keys(n).map((function(e){return Bt(e,n[e])})).join("\n"));var f=l.find((function(e){return e.startsWith("precision")}))||"precision mediump float;",d=i?l.filter((function(e){return!e.startsWith("precision")})).join("\n"):l.join("\n"),p="";if(e.viewportOrigin===oe.UPPER_LEFT&&(p+="".concat(Bt("VIEWPORT_ORIGIN_TL","1"),"\n")),e.clipSpaceNearZ===ae.ZERO&&(p+="".concat(Bt("CLIPSPACE_NEAR_ZERO","1"),"\n")),e.explicitBindingLocations){var _=0,h=0,E=0;d=d.replace(/^\s*(layout\((.*)\))?\s*uniform(.+{)$/gm,(function(e,t,r,n){return"layout(".concat(r?"".concat(r,", "):"","set = ").concat(_,", binding = ").concat(h++,") uniform ").concat(n)})),_++,h=0,Ae(e.separateSamplerTextures),d=d.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,r,n,i,o){var a=Dt(n);null===a&&(a=h++);var s=u(bt(i),2),l=s[0],c=s[1];return"frag"===t?"\nlayout(set = ".concat(_,", binding = ").concat(2*a+0,") uniform texture").concat(l," T_").concat(o,";\nlayout(set = ").concat(_,", binding = ").concat(2*a+1,") uniform sampler").concat(c," S_").concat(o,";").trim():""})),d=d.replace("frag"===t?/^\s*\b(varying|in)\b/gm:/^\s*\b(varying|out)\b/gm,(function(e,t){return"layout(location = ".concat(E++,") ").concat(t)})),p+="".concat(Bt("gl_VertexID","gl_VertexIndex"),"\n"),p+="".concat(Bt("gl_InstanceID","gl_InstanceIndex"),"\n"),f=f.replace(/^precision (.*) sampler(.*);$/gm,"")}else{var R=0;d=d.replace(/^\s*(layout\((.*)\))?\s*uniform sampler(\w+) (.*);/gm,(function(e,t,r,n,i){var o=Dt(r);return null===o&&(o=R++),"uniform sampler".concat(n," ").concat(i,"; // BINDING=").concat(o)}))}if(d=(d=(d=d.replace(/\bPU_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"SAMPLER_".concat(t,"(P_").concat(r,")")}))).replace(/\bPF_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"PP_SAMPLER_".concat(t,"(P_").concat(r,")")}))).replace(/\bPU_TEXTURE\((.*?)\)/g,(function(e,t){return"TEXTURE(P_".concat(t,")")})),e.separateSamplerTextures)d=d.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){var n=u(bt(t),2),i=n[1];return"texture".concat(n[0]," T_P_").concat(r,", sampler").concat(i," S_P_").concat(r)})),d=(d=(d=d.replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"T_".concat(r,", S_").concat(r)}))).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t,"(T_").concat(r,", S_").concat(r,")")}))).replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return"T_".concat(t)}));else{var v=[];d=(d=(d=d.replace(/\bPD_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return"sampler".concat(t," P_").concat(r)}))).replace(/\bPP_SAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return r}))).replace(/\bSAMPLER_(\w+)\((.*?)\)/g,(function(e,t,r){return v.push([r,t]),r})),a&&v.forEach((function(e){var t=u(e,2),r=t[0],n=t[1];d=d.replace(RegExp("texture\\(".concat(r),"g"),(function(){return"texture".concat(n,"(").concat(r)}))})),d=d.replace(/\bTEXTURE\((.*?)\)/g,(function(e,t){return t}))}var T="".concat(a?"":e.glslVersion,"\n").concat(a&&s?"#extension GL_EXT_draw_buffers : require\n":"","\n").concat(a&&"frag"===t?"#extension GL_OES_standard_derivatives : enable\n":"").concat(i?f:"","\n").concat(p||"").concat(c?c+"\n":"","\n").concat(d,"\n").trim();if(e.explicitBindingLocations&&"frag"===t&&(T=T.replace(/^\b(out)\b/g,(function(e,t){return"layout(location = 0) ".concat(t)}))),a){if("frag"===t&&(T=T.replace(/^\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))),"vert"===t&&(T=(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"varying ".concat(t," ").concat(r,";\n")}))).replace(/^\s*layout\(location\s*=\s*\S*\)\s*in\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return"attribute ".concat(t," ").concat(r,";\n")}))),T=T.replace(/\s*uniform\s*.*\s*{((?:\s*.*\s*)*?)};/g,(function(e,t){return t.trim().replace(/^.*$/gm,(function(e){var t=e.trim();return t.startsWith("#")?t:e?"uniform ".concat(t):""}))})),"frag"===t)if(s){var m=[];T=T.replace(/^\s*layout\(location\s*=\s*\d*\)\s*out\s+vec4\s*(.*);$/gm,(function(e,t){return m.push(t),"vec4 ".concat(t,";\n")}));var A=T.lastIndexOf("}");T=T.substring(0,A)+"\n ".concat(m.map((function(e,t){return"gl_FragData[".concat(t,"] = ").concat(e,";\n ")})).join("\n"))+T.substring(A)}else{var g;if(T=T.replace(/^\s*out\s+(\S+)\s*(.*);$/gm,(function(e,t,r){return g=r,"".concat(t," ").concat(r,";\n")})),g){A=T.lastIndexOf("}");T=T.substring(0,A)+"\n gl_FragColor = vec4(".concat(g,");\n")+T.substring(A)}}T=T.replace(/^\s*layout\((.*)\)/gm,"")}return T}var Ft=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,null!==i.device.resourceCreationTracker&&i.device.resourceCreationTracker.trackResourceCreated(i),i}return n(t,e),t.prototype.destroy=function(){null!==this.device.resourceCreationTracker&&this.device.resourceCreationTracker.trackResourceDestroyed(this)},t}(de);function Ut(e){return"undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||!(!e||2!==e._version)}function wt(e){if(Re(e)&ce.Normalized)return!1;var t=Ee(e);return t===le.S8||t===le.S16||t===le.S32||(t===le.U8||t===le.U16||t===le.U32)}function Gt(e){return e&q.INDEX?G.ELEMENT_ARRAY_BUFFER:e&q.VERTEX?G.ARRAY_BUFFER:e&q.UNIFORM?G.UNIFORM_BUFFER:void 0}function kt(e){var t=Ee(e),r=he(e),n=Re(e),i=function(e){switch(e){case le.U8:return G.UNSIGNED_BYTE;case le.U16:return G.UNSIGNED_SHORT;case le.U32:return G.UNSIGNED_INT;case le.S8:return G.BYTE;case le.S16:return G.SHORT;case le.S32:return G.INT;case le.F16:return G.HALF_FLOAT;case le.F32:return G.FLOAT;default:throw Error("whoops")}}(t),o=function(e){switch(e){case ue.R:return 1;case ue.RG:return 2;case ue.RGB:return 3;case ue.RGBA:return 4;default:return 1}}(r);return{size:o,type:i,normalized:!!(n&ce.Normalized)}}function Vt(e){switch(e){case z.CLAMP_TO_EDGE:return G.CLAMP_TO_EDGE;case z.REPEAT:return G.REPEAT;case z.MIRRORED_REPEAT:return G.MIRRORED_REPEAT;default:throw Error("whoops")}}function Xt(e,t){if(t===j.LINEAR&&e===K.BILINEAR)return G.LINEAR_MIPMAP_LINEAR;if(t===j.LINEAR&&e===K.POINT)return G.NEAREST_MIPMAP_LINEAR;if(t===j.NEAREST&&e===K.BILINEAR)return G.LINEAR_MIPMAP_NEAREST;if(t===j.NEAREST&&e===K.POINT)return G.NEAREST_MIPMAP_NEAREST;if(t===j.NO_MIP&&e===K.BILINEAR)return G.LINEAR;if(t===j.NO_MIP&&e===K.POINT)return G.NEAREST;throw Error("Unknown texture filter mode")}function Wt(e,t){void 0===t&&(t=0);return e.gl_buffer_pages[t/e.pageByteSize|0]}!function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.Bindings;var i=r.samplerBindings;return n.uniformBufferBindings=r.uniformBufferBindings||[],n.samplerBindings=i||[],n.bindingLayouts=n.createBindingLayouts(),n}n(t,e),t.prototype.createBindingLayouts=function(){var e=0,t=0,r=[],n=this.uniformBufferBindings.length,i=this.samplerBindings.length;return r.push({firstUniformBuffer:e,numUniformBuffers:n,firstSampler:t,numSamplers:i}),{numUniformBuffers:e+=n,numSamplers:t+=i,bindingLayoutTables:r}}}(Ft),function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=k.Buffer;var o=n.viewOrSize,a=n.usage,s=n.hint,l=void 0===s?Q.STATIC:s,u=r.uniformBufferMaxPageByteSize,c=r.gl,f=a&q.UNIFORM;f||(Ut(c)?c.bindVertexArray(null):r.OES_vertex_array_object.bindVertexArrayOES(null));var d,p=E(o)?Be(o,4):Be(o.byteLength,4);if(i.gl_buffer_pages=[],f){for(var _=p;_>0;)i.gl_buffer_pages.push(i.createBufferPage(Math.min(_,u),a,l)),_-=u;d=u}else i.gl_buffer_pages.push(i.createBufferPage(p,a,l)),d=p;return i.pageByteSize=d,i.byteSize=p,i.usage=a,i.gl_target=Gt(a),E(o)||i.setSubData(0,new Uint8Array(o.buffer)),f||(Ut(c)?c.bindVertexArray(i.device.currentBoundVAO):r.OES_vertex_array_object.bindVertexArrayOES(i.device.currentBoundVAO)),i}n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=t.byteLength-r);for(var i=this.device.gl,o=this.pageByteSize,a=e+n,s=e,l=e%o;a>s;){var u=Ut(i)?i.COPY_WRITE_BUFFER:this.gl_target,c=Wt(this,s);if(c.ubo)return;i.bindBuffer(u,c),Ut(i)?i.bufferSubData(u,l,t,r,Math.min(a-s,o)):i.bufferSubData(u,l,t),s+=o,l=0,r+=o,this.device.debugGroupStatisticsBufferUpload()}},t.prototype.destroy=function(){e.prototype.destroy.call(this);for(var t=0;this.gl_buffer_pages.length>t;t++)this.gl_buffer_pages[t].ubo||this.device.gl.deleteBuffer(this.gl_buffer_pages[t]);this.gl_buffer_pages=[]},t.prototype.createBufferPage=function(e,t,r){var n=this.device.gl,i=t&q.UNIFORM;if(!Ut(n)&&i)return{ubo:!0};var o=this.device.ensureResourceExists(n.createBuffer()),a=Gt(t),s=function(e){switch(e){case Q.STATIC:return G.STATIC_DRAW;case Q.DYNAMIC:return G.DYNAMIC_DRAW}}(r);return n.bindBuffer(a,o),n.bufferData(a,e,s),o}}(Ft),function(e){function t(t){var r,n,i,o,a,s=t.device,u=t.descriptor,c=e.call(this,{id:t.id,device:s})||this;c.type=k.InputLayout;var d=u.vertexBufferDescriptors,p=u.indexBufferFormat,_=u.program;Ae(p===fe.U16_R||p===fe.U32_R||null===p);var h=null!==p?function(e){switch(e){case fe.U8_R:return G.UNSIGNED_BYTE;case fe.U16_R:return G.UNSIGNED_SHORT;case fe.U32_R:return G.UNSIGNED_INT;default:throw Error("whoops")}}(p):null,E=null!==p?Te(p):null,R=c.device.gl,v=c.device.ensureResourceExists(Ut(R)?R.createVertexArray():s.OES_vertex_array_object.createVertexArrayOES());Ut(R)?R.bindVertexArray(v):s.OES_vertex_array_object.bindVertexArrayOES(v),R.bindBuffer(R.ARRAY_BUFFER,Wt(c.device.fallbackVertexBuffer));try{for(var T=l(u.vertexBufferDescriptors),m=T.next();!m.done;m=T.next()){var A=m.value,g=A.stepMode,y=A.attributes;try{for(var S=(i=void 0,l(y)),C=S.next();!C.done;C=S.next()){var P=C.value,N=P.shaderLocation,M=P.format,I=P.divisor,O=void 0===I?1:I,x=Ut(R)?N:null===(a=_.attributes[N])||void 0===a?void 0:a.location,B=kt(M);if(P.vertexFormat=B,!f(x))wt(M),R.vertexAttribPointer(x,B.size,B.type,B.normalized,0,0),g===$.INSTANCE&&(Ut(R)?R.vertexAttribDivisor(x,O):s.ANGLE_instanced_arrays.vertexAttribDivisorANGLE(x,O)),R.enableVertexAttribArray(x)}}catch(e){i={error:e}}finally{try{C&&!C.done&&(o=S.return)&&o.call(S)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{m&&!m.done&&(n=T.return)&&n.call(T)}finally{if(r)throw r.error}}return Ut(R)?R.bindVertexArray(null):s.OES_vertex_array_object.bindVertexArrayOES(null),c.vertexBufferDescriptors=d,c.vao=v,c.indexBufferFormat=p,c.indexBufferType=h,c.indexBufferCompByteSize=E,c.program=_,c}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.currentBoundVAO===this.vao&&(Ut(this.device.gl)?(this.device.gl.bindVertexArray(null),this.device.gl.deleteVertexArray(this.vao)):(this.device.OES_vertex_array_object.bindVertexArrayOES(null),this.device.OES_vertex_array_object.deleteVertexArrayOES(this.vao)),this.device.currentBoundVAO=null)}}(Ft);var Ht,Yt=function(e){function t(t){var r=t.device,n=t.descriptor,o=t.fake,a=e.call(this,{id:t.id,device:r})||this;a.type=k.Texture,n=i({dimension:ee.TEXTURE_2D,depthOrArrayLayers:1,mipLevelCount:1},n);var s,l,u=a.device.gl,c=a.clampmipLevelCount(n);if(a.immutable=n.usage===te.RENDER_TARGET,a.pixelStore=n.pixelStore,a.format=n.format,a.dimension=n.dimension,a.formatKind=me(n.format),a.width=n.width,a.height=n.height,a.depthOrArrayLayers=n.depthOrArrayLayers,a.mipmaps=c>=1,!o){l=a.device.ensureResourceExists(u.createTexture());var f=a.device.translateTextureType(n.format),d=a.device.translateTextureInternalFormat(n.format);if(a.device.setActiveTexture(u.TEXTURE0),a.device.currentTextures[0]=null,a.preprocessImage(),n.dimension===ee.TEXTURE_2D){if(u.bindTexture(s=G.TEXTURE_2D,l),a.immutable)if(Ut(u))u.texStorage2D(s,c,d,n.width,n.height);else{var p=(d===G.DEPTH_COMPONENT||a.isNPOT(),0);(a.format!==fe.D32F&&a.format!==fe.D24_S8||Ut(u)||r.WEBGL_depth_texture)&&(u.texImage2D(s,p,d,n.width,n.height,0,d,f,null),a.mipmaps&&(a.mipmaps=!1,u.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.LINEAR),u.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_S,G.CLAMP_TO_EDGE),u.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_T,G.CLAMP_TO_EDGE)))}Ae(1===n.depthOrArrayLayers)}else if(n.dimension===ee.TEXTURE_2D_ARRAY)u.bindTexture(s=G.TEXTURE_2D_ARRAY,l),a.immutable&&Ut(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else if(n.dimension===ee.TEXTURE_3D)u.bindTexture(s=G.TEXTURE_3D,l),a.immutable&&Ut(u)&&u.texStorage3D(s,c,d,n.width,n.height,n.depthOrArrayLayers);else{if(n.dimension!==ee.TEXTURE_CUBE_MAP)throw Error("whoops");u.bindTexture(s=G.TEXTURE_CUBE_MAP,l),a.immutable&&Ut(u)&&u.texStorage2D(s,c,d,n.width,n.height),Ae(6===n.depthOrArrayLayers)}}return a.gl_texture=l,a.gl_target=s,a.mipLevelCount=c,a}return n(t,e),t.prototype.setImageData=function(e,t){void 0===t&&(t=0);var r=this.device.gl;!function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_UNORM:case le.BC4_SNORM:case le.BC5_UNORM:case le.BC5_SNORM:return!0;default:;}}(this.format);var n=this.gl_target===G.TEXTURE_3D||this.gl_target===G.TEXTURE_2D_ARRAY,i=this.gl_target===G.TEXTURE_CUBE_MAP,o=Object.prototype.toString.call(e[0])in xt;this.device.setActiveTexture(r.TEXTURE0),this.device.currentTextures[0]=null;var a,s,l=e[0];o?(a=this.width,s=this.height):(s=l.height,this.width=a=l.width,this.height=s),r.bindTexture(this.gl_target,this.gl_texture);var u=this.device.translateTextureFormat(this.format),c=Ut(r)?this.device.translateInternalTextureFormat(this.format):u,f=this.device.translateTextureType(this.format);this.preprocessImage();for(var d=0;this.depthOrArrayLayers>d;d++){var p=e[d],_=this.gl_target;i&&(_=G.TEXTURE_CUBE_MAP_POSITIVE_X+d%6),this.immutable?r.texSubImage2D(_,t,0,0,a,s,u,f,p):Ut(r)?n?r.texImage3D(_,t,c,a,s,this.depthOrArrayLayers,0,u,f,p):r.texImage2D(_,t,c,a,s,0,u,f,p):o?r.texImage2D(_,t,u,a,s,0,u,f,p):r.texImage2D(_,t,u,u,f,p)}this.mipmaps&&this.generateMipmap(n)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteTexture(this.gl_texture)},t.prototype.clampmipLevelCount=function(e){if(e.dimension===ee.TEXTURE_2D_ARRAY&&e.depthOrArrayLayers>1&&Ee(e.format)===le.BC1)for(var t=e.width,r=e.height,n=0;e.mipLevelCount>n;n++){if(2>=t||2>=r)return n-1;t=Math.max(t/2|0,1),r=Math.max(r/2|0,1)}return e.mipLevelCount},t.prototype.preprocessImage=function(){var e=this.device.gl;this.pixelStore&&(this.pixelStore.unpackFlipY&&e.pixelStorei(G.UNPACK_FLIP_Y_WEBGL,!0),this.pixelStore.packAlignment&&e.pixelStorei(G.PACK_ALIGNMENT,this.pixelStore.packAlignment),this.pixelStore.unpackAlignment&&e.pixelStorei(G.UNPACK_ALIGNMENT,this.pixelStore.unpackAlignment))},t.prototype.generateMipmap=function(e){void 0===e&&(e=!1);var t=this.device.gl;return!Ut(t)&&this.isNPOT()||this.gl_texture&&this.gl_target&&(t.bindTexture(this.gl_target,this.gl_texture),e?(t.texParameteri(this.gl_target,G.TEXTURE_BASE_LEVEL,0),t.texParameteri(this.gl_target,G.TEXTURE_MAX_LEVEL,Math.log2(this.width)),t.texParameteri(this.gl_target,G.TEXTURE_MIN_FILTER,G.LINEAR_MIPMAP_LINEAR),t.texParameteri(this.gl_target,G.TEXTURE_MAG_FILTER,G.LINEAR)):t.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.NEAREST_MIPMAP_LINEAR),t.generateMipmap(this.gl_target),t.bindTexture(this.gl_target,null)),this},t.prototype.isNPOT=function(){return!Ut(this.device.gl)&&(!Ie(this.width)||!Ie(this.height))},t}(Ft);let zt;!function(e){function t(t){var r=t.device,n=t.descriptor,i=e.call(this,{id:t.id,device:r})||this;i.type=k.RenderTarget,i.gl_renderbuffer=null,i.texture=null;var o=i.device.gl,a=n.format,s=n.width,l=n.height,u=n.sampleCount,c=void 0===u?1:u,f=n.texture,d=!1;if(a!==fe.D32F&&a!==fe.D24_S8||!f||Ut(o)||r.WEBGL_depth_texture||(f.destroy(),i.texture=null,d=!0),!d&&f)i.texture=f;else{i.gl_renderbuffer=i.device.ensureResourceExists(o.createRenderbuffer()),o.bindRenderbuffer(o.RENDERBUFFER,i.gl_renderbuffer);var p=i.device.translateTextureInternalFormat(a,!0);Ut(o)&&c>1?o.renderbufferStorageMultisample(G.RENDERBUFFER,c,p,s,l):o.renderbufferStorage(G.RENDERBUFFER,p,s,l)}return i.format=a,i.width=s,i.height=l,i.sampleCount=c,i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),null!==this.gl_renderbuffer&&this.device.gl.deleteRenderbuffer(this.gl_renderbuffer),this.texture&&this.texture.destroy()}}(Ft),function(e){e[e.NeedsCompile=0]="NeedsCompile",e[e.Compiling=1]="Compiling",e[e.NeedsBind=2]="NeedsBind",e[e.ReadyToUse=3]="ReadyToUse"}(Ht||(Ht={})),function(e){function t(t,r){var n=t.descriptor,i=e.call(this,{id:t.id,device:t.device})||this;i.rawVertexGLSL=r,i.type=k.Program,i.uniformSetters={},i.attributes=[];var o=i.device.gl;return i.descriptor=n,i.gl_program=i.device.ensureResourceExists(o.createProgram()),i.gl_shader_vert=null,i.gl_shader_frag=null,i.compileState=Ht.NeedsCompile,i.tryCompileProgram(),i}n(t,e),t.prototype.destroy=function(){e.prototype.destroy.call(this),this.device.gl.deleteProgram(this.gl_program),this.device.gl.deleteShader(this.gl_shader_vert),this.device.gl.deleteShader(this.gl_shader_frag)},t.prototype.tryCompileProgram=function(){Ae(this.compileState===Ht.NeedsCompile);var e=this.descriptor,t=e.vertex,r=e.fragment,n=this.device.gl;(null==t?void 0:t.glsl)&&(null==r?void 0:r.glsl)&&(this.gl_shader_vert=this.compileShader(t.postprocess?t.postprocess(t.glsl):t.glsl,n.VERTEX_SHADER),this.gl_shader_frag=this.compileShader(r.postprocess?r.postprocess(r.glsl):r.glsl,n.FRAGMENT_SHADER),n.attachShader(this.gl_program,this.gl_shader_vert),n.attachShader(this.gl_program,this.gl_shader_frag),n.linkProgram(this.gl_program),this.compileState=Ht.Compiling,Ut(n)||(this.readUniformLocationsFromLinkedProgram(),this.readAttributesFromLinkedProgram()))},t.prototype.readAttributesFromLinkedProgram=function(){for(var e,t=this.device.gl,r=t.getProgramParameter(this.gl_program,t.ACTIVE_ATTRIBUTES),n=function(e){var t={};return e.replace(/^\s*#define\s*(\S*)\s*(\S*)\s*$/gm,(function(e,r,n){var i=Number(n);return t[r]=isNaN(i)?n:i,""})),t}(this.descriptor.vertex.glsl),i=function(e,t){var r=[];return e.replace(/^\s*layout\(location\s*=\s*(\S*)\)\s*in\s+\S+\s*(.*);$/gm,(function(e,n,i){var o=Number(n);return r.push({location:isNaN(o)?t[n]:o,name:i}),""})),r}(this.rawVertexGLSL,n),o=function(r){var n=t.getActiveAttrib(a.gl_program,r),o=n.name,s=n.type,l=n.size,u=t.getAttribLocation(a.gl_program,o),c=null===(e=i.find((function(e){return e.name===o})))||void 0===e?void 0:e.location;0>u||f(c)||(a.attributes[c]={name:o,location:u,type:s,size:l})},a=this,s=0;r>s;s++)o(s)},t.prototype.readUniformLocationsFromLinkedProgram=function(){for(var e=this.device.gl,t=e.getProgramParameter(this.gl_program,e.ACTIVE_UNIFORMS),r=0;t>r;r++){var n=e.getActiveUniform(this.gl_program,r),i=Et(n.name).name,o=e.getUniformLocation(this.gl_program,i);if(this.uniformSetters[i]=Ot(e,o,n),n&&n.size>1)for(var a=0;n.size>a;a++)o=e.getUniformLocation(this.gl_program,"".concat(i,"[").concat(a,"]")),this.uniformSetters["".concat(i,"[").concat(a,"]")]=Ot(e,o,n)}},t.prototype.compileShader=function(e,t){var r=this.device.gl,n=this.device.ensureResourceExists(r.createShader(t));return r.shaderSource(n,e),r.compileShader(n),n},t.prototype.setUniformsLegacy=function(e){void 0===e&&(e={});var t=this.device.gl;if(!Ut(t)){var r=!1;for(var n in e){r||(t.useProgram(this.gl_program),r=!0);var i=this.uniformSetters[n];if(i){var o=e[n];o instanceof Yt&&(o=o.textureIndex),i(o)}}}return this}}(Ft),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.QueryPool;var i=n.device.gl;if(Ut(i)){var o=r.type;n.gl_query=Le(r.elemCount,(function(){return n.device.ensureResourceExists(i.createQuery())})),n.gl_query_type=function(e){if(e===se.OcclusionConservative)return G.ANY_SAMPLES_PASSED_CONSERVATIVE;throw Error("whoops")}(o)}return n}n(t,e),t.prototype.queryResultOcclusion=function(e){var t=this.device.gl;if(Ut(t)){var r=this.gl_query[e];return t.getQueryParameter(r,t.QUERY_RESULT_AVAILABLE)?!!t.getQueryParameter(r,t.QUERY_RESULT):null}return null},t.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.device.gl;if(Ut(t))for(var r=0;this.gl_query.length>r;r++)t.deleteQuery(this.gl_query[r])}}(Ft),function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.Readback,r.gl_pbo=null,r.gl_sync=null,r}n(t,e),t.prototype.clientWaitAsync=function(e,t,r){void 0===t&&(t=0),void 0===r&&(r=10);var n=this.device.gl;return new Promise((function(i,o){!function a(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?i():setTimeout(a,h(r,0,n.MAX_CLIENT_WAIT_TIMEOUT_WEBGL)):o()}()}))},t.prototype.getBufferSubDataAsync=function(e,t,r,n,i,o){return a(this,void 0,void 0,(function(){var a;return s(this,(function(s){switch(s.label){case 0:return Ut(a=this.device.gl)?(this.gl_sync=a.fenceSync(a.SYNC_GPU_COMMANDS_COMPLETE,0),a.flush(),[4,this.clientWaitAsync(this.gl_sync,0,10)]):[3,2];case 1:return s.sent(),a.bindBuffer(e,t),a.getBufferSubData(e,r,n,i,o),a.bindBuffer(e,null),[2,n];case 2:return[2]}}))}))},t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),void 0===u&&(u=o.byteLength||0),a(this,void 0,void 0,(function(){var a,c,f,d,p;return s(this,(function(s){var _;return a=this.device.gl,f=this.device.translateTextureFormat((c=e).format),d=this.device.translateTextureType(c.format),p=ve(Ee(_=c.format))*he(_),Ut(a)?(this.gl_pbo=this.device.ensureResourceExists(a.createBuffer()),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.bufferData(a.PIXEL_PACK_BUFFER,u,a.STREAM_READ),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),a.bindFramebuffer(G.READ_FRAMEBUFFER,this.device.readbackFramebuffer),a.framebufferTexture2D(G.READ_FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,c.gl_texture,0),a.bindBuffer(a.PIXEL_PACK_BUFFER,this.gl_pbo),a.readPixels(t,r,n,i,f,d,l*p),a.bindBuffer(a.PIXEL_PACK_BUFFER,null),[2,this.getBufferSubDataAsync(a.PIXEL_PACK_BUFFER,this.gl_pbo,0,o,l,0)]):[2,this.readTextureSync(e,t,r,n,i,o,l,u)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){void 0===s&&(s=o.byteLength||0);var l=this.device.gl,u=e,c=this.device.translateTextureType(u.format);return l.bindFramebuffer(G.FRAMEBUFFER,this.device.readbackFramebuffer),l.framebufferTexture2D(G.FRAMEBUFFER,G.COLOR_ATTACHMENT0,G.TEXTURE_2D,u.gl_texture,0),l.pixelStorei(l.PACK_ALIGNMENT,4),l.readPixels(t,r,n,i,l.RGBA,c,o),o},t.prototype.readBuffer=function(e,t,r,n,i){return a(this,void 0,void 0,(function(){var o;return s(this,(function(a){return Ut(o=this.device.gl)?[2,this.getBufferSubDataAsync(o.ARRAY_BUFFER,Wt(e,t),t,r,n,i)]:[2,Promise.reject()]}))}))},t.prototype.destroy=function(){e.prototype.destroy.call(this),Ut(this.device.gl)&&(null!==this.gl_sync&&this.device.gl.deleteSync(this.gl_sync),null!==this.gl_pbo&&this.device.gl.deleteBuffer(this.gl_pbo))}}(Ft),function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;return a.type=k.RenderPipeline,a.drawMode=function(e){switch(e){case Z.TRIANGLES:return G.TRIANGLES;case Z.POINTS:return G.POINTS;case Z.TRIANGLE_STRIP:return G.TRIANGLE_STRIP;case Z.LINES:return G.LINES;case Z.LINE_STRIP:return G.LINE_STRIP;default:throw Error("Unknown primitive topology mode")}}(null!==(r=o.topology)&&void 0!==r?r:Z.TRIANGLES),a.program=o.program,a.inputLayout=o.inputLayout,a.megaState=i(i({},Ve(We)),o.megaStateDescriptor),a.colorAttachmentFormats=o.colorAttachmentFormats.slice(),a.depthStencilAttachmentFormat=o.depthStencilAttachmentFormat,a.sampleCount=null!==(n=o.sampleCount)&&void 0!==n?n:1,a}n(t,e)}(Ft),function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.ComputePipeline,n.descriptor=r,n}n(t,e)}(Ft),function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Sampler;var a=o.device.gl;if(Ut(a)){var s=o.device.ensureResourceExists(a.createSampler());a.samplerParameteri(s,G.TEXTURE_WRAP_S,Vt(i.addressModeU)),a.samplerParameteri(s,G.TEXTURE_WRAP_T,Vt(i.addressModeV)),a.samplerParameteri(s,G.TEXTURE_WRAP_R,Vt(null!==(r=i.addressModeW)&&void 0!==r?r:i.addressModeU)),a.samplerParameteri(s,G.TEXTURE_MIN_FILTER,Xt(i.minFilter,i.mipmapFilter)),a.samplerParameteri(s,G.TEXTURE_MAG_FILTER,Xt(i.magFilter,j.NO_MIP)),void 0!==i.lodMinClamp&&a.samplerParameterf(s,G.TEXTURE_MIN_LOD,i.lodMinClamp),void 0!==i.lodMaxClamp&&a.samplerParameterf(s,G.TEXTURE_MAX_LOD,i.lodMaxClamp),void 0!==i.compareFunction&&(a.samplerParameteri(s,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.samplerParameteri(s,a.TEXTURE_COMPARE_FUNC,i.compareFunction));var l=null!==(n=i.maxAnisotropy)&&void 0!==n?n:1;l>1&&null!==o.device.EXT_texture_filter_anisotropic&&(Ae(i.minFilter===K.BILINEAR&&i.magFilter===K.BILINEAR&&i.mipmapFilter===j.LINEAR),a.samplerParameterf(s,o.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,l)),o.gl_sampler=s}else o.descriptor=i;return o}n(t,e),t.prototype.setTextureParameters=function(e,t,r){var n,i=this.device.gl,o=this.descriptor;this.isNPOT(t,r)?i.texParameteri(G.TEXTURE_2D,G.TEXTURE_MIN_FILTER,G.LINEAR):i.texParameteri(e,G.TEXTURE_MIN_FILTER,Xt(o.minFilter,o.mipmapFilter)),i.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_S,Vt(o.addressModeU)),i.texParameteri(G.TEXTURE_2D,G.TEXTURE_WRAP_T,Vt(o.addressModeV)),i.texParameteri(e,G.TEXTURE_MAG_FILTER,Xt(o.magFilter,j.NO_MIP));var a=null!==(n=o.maxAnisotropy)&&void 0!==n?n:1;a>1&&null!==this.device.EXT_texture_filter_anisotropic&&(Ae(o.minFilter===K.BILINEAR&&o.magFilter===K.BILINEAR&&o.mipmapFilter===j.LINEAR),i.texParameteri(e,this.device.EXT_texture_filter_anisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a))},t.prototype.destroy=function(){e.prototype.destroy.call(this),Ut(this.device.gl)&&this.device.gl.deleteSampler(this.gl_sampler)},t.prototype.isNPOT=function(e,t){return!Ie(e)||!Ie(t)}}(Ft),function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=k.RenderBundle,t.commands=[],t}n(t,e),t.prototype.push=function(e){this.commands.push(e)},t.prototype.replay=function(){this.commands.forEach((function(e){return e()}))}}(Ft);const Kt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&Kt.decode();let jt=null;function Zt(){return null!==jt&&0!==jt.byteLength||(jt=new Uint8Array(zt.memory.buffer)),jt}function qt(e,t){return e>>>=0,Kt.decode(Zt().subarray(e,e+t))}const Qt=Array(128).fill(void 0);Qt.push(void 0,null,!0,!1);let $t=Qt.length;function Jt(e){return Qt[e]}function er(e){const t=Jt(e);return function(e){132>e||(Qt[e]=$t,$t=e)}(e),t}let tr=0;const rr="undefined"!=typeof TextEncoder?new TextEncoder("utf-8"):{encode:()=>{throw Error("TextEncoder not available")}},nr="function"==typeof rr.encodeInto?function(e,t){return rr.encodeInto(e,t)}:function(e,t){const r=rr.encode(e);return t.set(r),{read:e.length,written:r.length}};function ir(e,t,r){if(void 0===r){const r=rr.encode(e),n=t(r.length,1)>>>0;return Zt().subarray(n,n+r.length).set(r),tr=r.length,n}let n=e.length,i=t(n,1)>>>0;const o=Zt();let a=0;for(;n>a;a++){const t=e.charCodeAt(a);if(t>127)break;o[i+a]=t}if(a!==n){0!==a&&(e=e.slice(a)),i=r(i,n,n=a+3*e.length,1)>>>0;const t=Zt().subarray(i+a,i+n);a+=nr(e,t).written}return tr=a,i}let or=null;function ar(){return null!==or&&0!==or.byteLength||(or=new Int32Array(zt.memory.buffer)),or}function sr(e,t,r){let n,i;try{const s=zt.__wbindgen_add_to_stack_pointer(-16),l=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc),u=tr,c=ir(t,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.glsl_compile(s,l,u,c,tr,r);var o=ar()[s/4+0],a=ar()[s/4+1];return n=o,i=a,qt(o,a)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(n,i,1)}}class lr{static __wrap(e){e>>>=0;const t=Object.create(lr.prototype);return t.__wbg_ptr=e,t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,e}free(){const e=this.__destroy_into_raw();zt.__wbg_wgslcomposer_free(e)}constructor(){const e=zt.wgslcomposer_new();return lr.__wrap(e)}load_composable(e){const t=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.wgslcomposer_load_composable(this.__wbg_ptr,t,tr)}wgsl_compile(e){let t,r;try{const o=zt.__wbindgen_add_to_stack_pointer(-16),a=ir(e,zt.__wbindgen_malloc,zt.__wbindgen_realloc);zt.wgslcomposer_wgsl_compile(o,this.__wbg_ptr,a,tr);var n=ar()[o/4+0],i=ar()[o/4+1];return t=n,r=i,qt(n,i)}finally{zt.__wbindgen_add_to_stack_pointer(16),zt.__wbindgen_free(t,r,1)}}}function ur(){const e={wbg:{}};return e.wbg.__wbindgen_string_new=function(e,t){return function(e){$t===Qt.length&&Qt.push(Qt.length+1);const t=$t;return $t=Qt[t],Qt[t]=e,t}(qt(e,t))},e.wbg.__wbindgen_object_drop_ref=function(e){er(e)},e.wbg.__wbg_log_1d3ae0273d8f4f8a=function(e){console.log(Jt(e))},e.wbg.__wbg_log_576ca876af0d4a77=function(e,t){console.log(Jt(e),Jt(t))},e.wbg.__wbindgen_throw=function(e,t){throw Error(qt(e,t))},e}async function cr(e){if(void 0!==zt)return zt;const t=ur();("string"==typeof e||"function"==typeof Request&&e instanceof Request||"function"==typeof URL&&e instanceof URL)&&(e=fetch(e));const{instance:r,module:n}=await async function(e,t){if("function"==typeof Response&&e instanceof Response){if("function"==typeof WebAssembly.instantiateStreaming)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if("application/wasm"==e.headers.get("Content-Type"))throw t;console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",t)}const r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}{const r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}}(await e,t);return function(e,t){return zt=e.exports,cr.__wbindgen_wasm_module=t,or=null,jt=null,zt}(r,n)}var fr,dr;function pr(e){if(e===fe.U8_R_NORM)return"r8unorm";if(e===fe.S8_R_NORM)return"r8snorm";if(e===fe.U8_RG_NORM)return"rg8unorm";if(e===fe.S8_RG_NORM)return"rg8snorm";if(e===fe.U32_R)return"r32uint";if(e===fe.S32_R)return"r32sint";if(e===fe.F32_R)return"r32float";if(e===fe.U16_RG)return"rg16uint";if(e===fe.S16_RG)return"rg16sint";if(e===fe.F16_RG)return"rg16float";if(e===fe.U8_RGBA_RT)return"bgra8unorm";if(e===fe.U8_RGBA_RT_SRGB)return"bgra8unorm-srgb";if(e===fe.U8_RGBA_NORM)return"rgba8unorm";if(e===fe.U8_RGBA_SRGB)return"rgba8unorm-srgb";if(e===fe.S8_RGBA_NORM)return"rgba8snorm";if(e===fe.U32_RG)return"rg32uint";if(e===fe.S32_RG)return"rg32sint";if(e===fe.F32_RG)return"rg32float";if(e===fe.U16_RGBA)return"rgba16uint";if(e===fe.S16_RGBA)return"rgba16sint";if(e===fe.F16_RGBA)return"rgba16float";if(e===fe.F32_RGBA)return"rgba32float";if(e===fe.U32_RGBA)return"rgba32uint";if(e===fe.S32_RGBA)return"rgba32sint";if(e===fe.D24)return"depth24plus";if(e===fe.D24_S8)return"depth24plus-stencil8";if(e===fe.D32F)return"depth32float";if(e===fe.D32F_S8)return"depth32float-stencil8";if(e===fe.BC1)return"bc1-rgba-unorm";if(e===fe.BC1_SRGB)return"bc1-rgba-unorm-srgb";if(e===fe.BC2)return"bc2-rgba-unorm";if(e===fe.BC2_SRGB)return"bc2-rgba-unorm-srgb";if(e===fe.BC3)return"bc3-rgba-unorm";if(e===fe.BC3_SRGB)return"bc3-rgba-unorm-srgb";if(e===fe.BC4_SNORM)return"bc4-r-snorm";if(e===fe.BC4_UNORM)return"bc4-r-unorm";if(e===fe.BC5_SNORM)return"bc5-rg-snorm";if(e===fe.BC5_UNORM)return"bc5-rg-unorm";throw"whoops"}function _r(e){if(e===ee.TEXTURE_2D)return"2d";if(e===ee.TEXTURE_CUBE_MAP)return"cube";if(e===ee.TEXTURE_2D_ARRAY)return"2d-array";if(e===ee.TEXTURE_3D)return"3d";throw Error("whoops")}function hr(e){if(e===z.CLAMP_TO_EDGE)return"clamp-to-edge";if(e===z.REPEAT)return"repeat";if(e===z.MIRRORED_REPEAT)return"mirror-repeat";throw Error("whoops")}function Er(e){if(e===K.BILINEAR)return"linear";if(e===K.POINT)return"nearest";throw Error("whoops")}function Rr(e){if(e===j.LINEAR)return"linear";if(e===j.NEAREST)return"nearest";if(e===j.NO_MIP)return"nearest";throw Error("whoops")}function vr(e){return e.gpuBuffer}function Tr(e){if(e===se.OcclusionConservative)return"occlusion";throw Error("whoops")}function mr(e){switch(e){case Z.TRIANGLES:return"triangle-list";case Z.POINTS:return"point-list";case Z.TRIANGLE_STRIP:return"triangle-strip";case Z.LINES:return"line-list";case Z.LINE_STRIP:return"line-strip";default:throw Error("Unknown primitive topology mode")}}function Ar(e){if(e===W.NONE)return"none";if(e===W.FRONT)return"front";if(e===W.BACK)return"back";throw Error("whoops")}function gr(e){if(e===X.CCW)return"ccw";if(e===X.CW)return"cw";throw Error("whoops")}function yr(e){if(e===H.ZERO)return"zero";if(e===H.ONE)return"one";if(e===H.SRC)return"src";if(e===H.ONE_MINUS_SRC)return"one-minus-src";if(e===H.DST)return"dst";if(e===H.ONE_MINUS_DST)return"one-minus-dst";if(e===H.SRC_ALPHA)return"src-alpha";if(e===H.ONE_MINUS_SRC_ALPHA)return"one-minus-src-alpha";if(e===H.DST_ALPHA)return"dst-alpha";if(e===H.ONE_MINUS_DST_ALPHA)return"one-minus-dst-alpha";if(e===H.CONST)return"constant";if(e===H.ONE_MINUS_CONSTANT)return"one-minus-constant";if(e===H.SRC_ALPHA_SATURATE)return"src-alpha-saturated";throw Error("whoops")}function Sr(e){if(e===Y.ADD)return"add";if(e===Y.SUBSTRACT)return"subtract";if(e===Y.REVERSE_SUBSTRACT)return"reverse-subtract";if(e===Y.MIN)return"min";if(e===Y.MAX)return"max";throw Error("whoops")}function Cr(e){return{operation:Sr(e.blendMode),srcFactor:yr(e.blendSrcFactor),dstFactor:yr(e.blendDstFactor)}}function Pr(e){return e.blendMode===Y.ADD&&e.blendSrcFactor===H.ONE&&e.blendDstFactor===H.ZERO}function Nr(e){return Pr(e.rgbBlendState)&&Pr(e.alphaBlendState)?void 0:{color:Cr(e.rgbBlendState),alpha:Cr(e.alphaBlendState)}}function Mr(e,t){return t.attachmentsState.map((function(t,r){return function(e,t){return{format:pr(t),blend:Nr(e),writeMask:e.channelWriteMask}}(t,e[r])}))}function Ir(e){if(e===V.NEVER)return"never";if(e===V.LESS)return"less";if(e===V.EQUAL)return"equal";if(e===V.LEQUAL)return"less-equal";if(e===V.GREATER)return"greater";if(e===V.NOTEQUAL)return"not-equal";if(e===V.GEQUAL)return"greater-equal";if(e===V.ALWAYS)return"always";throw Error("whoops")}function Or(e){if(e===ne.KEEP)return"keep";if(e===ne.REPLACE)return"replace";if(e===ne.ZERO)return"zero";if(e===ne.DECREMENT_CLAMP)return"decrement-clamp";if(e===ne.DECREMENT_WRAP)return"decrement-wrap";if(e===ne.INCREMENT_CLAMP)return"increment-clamp";if(e===ne.INCREMENT_WRAP)return"increment-wrap";if(e===ne.INVERT)return"invert";throw Error("whoops")}function xr(e){if(e===$.VERTEX)return"vertex";if(e===$.INSTANCE)return"instance";throw Error("whoops")}function Br(e){if(e===fe.U8_R)return"uint8x2";if(e===fe.U8_RG)return"uint8x2";if(e===fe.U8_RGB)return"uint8x4";if(e===fe.U8_RGBA)return"uint8x4";if(e===fe.U8_RG_NORM)return"unorm8x2";if(e===fe.U8_RGBA_NORM)return"unorm8x4";if(e===fe.S8_RGB_NORM)return"snorm8x4";if(e===fe.S8_RGBA_NORM)return"snorm8x4";if(e===fe.U16_RG_NORM)return"unorm16x2";if(e===fe.U16_RGBA_NORM)return"unorm16x4";if(e===fe.S16_RG_NORM)return"snorm16x2";if(e===fe.S16_RGBA_NORM)return"snorm16x4";if(e===fe.S16_RG)return"uint16x2";if(e===fe.F16_RG)return"float16x2";if(e===fe.F16_RGBA)return"float16x4";if(e===fe.F32_R)return"float32";if(e===fe.F32_RG)return"float32x2";if(e===fe.F32_RGB)return"float32x3";if(e===fe.F32_RGBA)return"float32x4";throw"whoops"}function Dr(e,t,r,n){switch(void 0===r&&(r=!1),e){case fe.S8_R:case fe.S8_R_NORM:case fe.S8_RG_NORM:case fe.S8_RGB_NORM:case fe.S8_RGBA_NORM:var i=(ArrayBuffer,new Int8Array(t));return n&&i.set(new Int8Array(n)),i;case fe.U8_R:case fe.U8_R_NORM:case fe.U8_RG:case fe.U8_RG_NORM:case fe.U8_RGB:case fe.U8_RGB_NORM:case fe.U8_RGB_SRGB:case fe.U8_RGBA:case fe.U8_RGBA_NORM:case fe.U8_RGBA_SRGB:var o=(ArrayBuffer,new Uint8Array(t));return n&&o.set(new Uint8Array(n)),o;case fe.S16_R:case fe.S16_RG:case fe.S16_RG_NORM:case fe.S16_RGB_NORM:case fe.S16_RGBA:case fe.S16_RGBA_NORM:var a=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(r?t/2:t);return n&&a.set(new Int16Array(n)),a;case fe.U16_R:case fe.U16_RGB:case fe.U16_RGBA_5551:case fe.U16_RGBA_NORM:case fe.U16_RG_NORM:case fe.U16_R_NORM:var s=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(r?t/2:t);return n&&s.set(new Uint16Array(n)),s;case fe.S32_R:var l=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(r?t/4:t);return n&&l.set(new Int32Array(n)),l;case fe.U32_R:case fe.U32_RG:var u=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(r?t/4:t);return n&&u.set(new Uint32Array(n)),u;case fe.F32_R:case fe.F32_RG:case fe.F32_RGB:case fe.F32_RGBA:var c=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(r?t/4:t);return n&&c.set(new Float32Array(n)),c}var f=(ArrayBuffer,new Uint8Array(t));return n&&f.set(new Uint8Array(n)),f}function br(e){switch(e){case"r8unorm":case"r8snorm":case"r8uint":case"r8sint":return{width:1,height:1,length:1};case"r16uint":case"r16sint":case"r16float":case"rg8unorm":case"rg8snorm":case"rg8uint":case"rg8sint":case"depth16unorm":return{width:1,height:1,length:2};case"r32uint":case"r32sint":case"r32float":case"rg16uint":case"rg16sint":case"rg16float":case"rgba8unorm":case"rgba8unorm-srgb":case"rgba8snorm":case"rgba8uint":case"rgba8sint":case"bgra8unorm":case"bgra8unorm-srgb":case"rgb9e5ufloat":case"rgb10a2unorm":case"rg11b10ufloat":case"depth32float":default:return{width:1,height:1,length:4};case"rg32uint":case"rg32sint":case"rg32float":case"rgba16uint":case"rgba16sint":case"rgba16float":return{width:1,height:1,length:8};case"rgba32uint":case"rgba32sint":case"rgba32float":return{width:1,height:1,length:16};case"stencil8":throw Error("No fixed size for Stencil8 format!");case"depth24plus":throw Error("No fixed size for Depth24Plus format!");case"depth24plus-stencil8":throw Error("No fixed size for Depth24PlusStencil8 format!");case"depth32float-stencil8":return{width:1,height:1,length:5};case"bc7-rgba-unorm":case"bc7-rgba-unorm-srgb":case"bc6h-rgb-ufloat":case"bc6h-rgb-float":case"bc2-rgba-unorm":case"bc2-rgba-unorm-srgb":case"bc3-rgba-unorm":case"bc3-rgba-unorm-srgb":case"bc5-rg-unorm":case"bc5-rg-snorm":return{width:4,height:4,length:16};case"bc4-r-unorm":case"bc4-r-snorm":case"bc1-rgba-unorm":case"bc1-rgba-unorm-srgb":return{width:4,height:4,length:8}}}!function(e){e[e.COPY_SRC=1]="COPY_SRC",e[e.COPY_DST=2]="COPY_DST",e[e.TEXTURE_BINDING=4]="TEXTURE_BINDING",e[e.STORAGE_BINDING=8]="STORAGE_BINDING",e[e.STORAGE=8]="STORAGE",e[e.RENDER_ATTACHMENT=16]="RENDER_ATTACHMENT"}(fr||(fr={})),function(e){e[e.READ=1]="READ",e[e.WRITE=2]="WRITE"}(dr||(dr={}));var Lr=function(e){function t(t){var r=t.id,n=t.device,i=e.call(this)||this;return i.id=r,i.device=n,i}return n(t,e),t.prototype.destroy=function(){},t}(de),Fr=function(e){function t(t){var r,n,o=t.descriptor,a=e.call(this,{id:t.id,device:t.device})||this;a.type=k.Bindings;var s=o.pipeline;Ae(!!s);var l=o.uniformBufferBindings,u=o.storageBufferBindings,c=o.samplerBindings,f=o.storageTextureBindings;a.numUniformBuffers=(null==l?void 0:l.length)||0;var d=[[],[],[],[]],p=0;if(l&&l.length)for(var _=0;l.length>_;_++){var h=o.uniformBufferBindings[_],E=h.binding,R=h.size,v=h.offset,T={buffer:vr(h.buffer),offset:null!=v?v:0,size:R};d[0].push({binding:null!=E?E:p++,resource:T})}if(c&&c.length){p=0;for(_=0;c.length>_;_++){var m=i(i({},c[_]),Ke),A=null!==(E=o.samplerBindings[_]).texture?E.texture:a.device.getFallbackTexture(m);if(m.dimension=A.dimension,m.formatKind=me(A.format),d[1].push({binding:null!==(r=E.textureBinding)&&void 0!==r?r:p++,resource:A.gpuTextureView}),-1!==E.samplerBinding){var g=null!==E.sampler?E.sampler:a.device.getFallbackSampler(m),y=g.gpuSampler;d[1].push({binding:null!==(n=E.samplerBinding)&&void 0!==n?n:p++,resource:y})}}}if(u&&u.length){p=0;for(_=0;u.length>_;_++){var S=o.storageBufferBindings[_];E=S.binding,R=S.size,v=S.offset,T={buffer:vr(S.buffer),offset:null!=v?v:0,size:R};d[2].push({binding:null!=E?E:p++,resource:T})}}if(f&&f.length){p=0;for(_=0;f.length>_;_++){var C=o.storageTextureBindings[_];d[3].push({binding:null!=(E=C.binding)?E:p++,resource:(A=C.texture).gpuTextureView})}}var P=d.findLastIndex((function(e){return!!e.length}));return a.gpuBindGroup=d.map((function(e,t){return P>=t&&a.device.device.createBindGroup({layout:s.getBindGroupLayout(t),entries:e})})),a}return n(t,e),t}(Lr),Ur=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.Buffer;var i=r.usage,o=r.viewOrSize,a=!!(i&q.MAP_READ);n.usage=function(e){var t=0;return e&q.INDEX&&(t|=GPUBufferUsage.INDEX),e&q.VERTEX&&(t|=GPUBufferUsage.VERTEX),e&q.UNIFORM&&(t|=GPUBufferUsage.UNIFORM),e&q.STORAGE&&(t|=GPUBufferUsage.STORAGE),e&q.COPY_SRC&&(t|=GPUBufferUsage.COPY_SRC),e&q.INDIRECT&&(t|=GPUBufferUsage.INDIRECT),t|GPUBufferUsage.COPY_DST}(i),a&&(n.usage=q.MAP_READ|q.COPY_DST);var s=!E(o);(n.view=E(o)?null:o,n.size=E(o)?Be(o,4):Be(o.byteLength,4),E(o))?n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!!a&&s}):(n.gpuBuffer=n.device.device.createBuffer({usage:n.usage,size:n.size,mappedAtCreation:!0}),new(o&&o.constructor||Float32Array)(n.gpuBuffer.getMappedRange()).set(o),n.gpuBuffer.unmap());return n}return n(t,e),t.prototype.setSubData=function(e,t,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var i=this.gpuBuffer,o=t.byteOffset+r,a=o+(n=Math.min(n=n||t.byteLength,this.size-e)),s=n+3&-4;if(s!==n){var l=new Uint8Array(t.buffer.slice(o,a));(t=new Uint8Array(s)).set(l),r=0,o=0,a=s,n=s}for(var u=15728640,c=0;a-(o+c)>u;)this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,u),c+=u;this.device.device.queue.writeBuffer(i,e+c,t.buffer,o+c,n-c)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuBuffer.destroy()},t}(Lr),wr=function(){function e(){this.gpuComputePassEncoder=null}return e.prototype.dispatchWorkgroups=function(e,t,r){this.gpuComputePassEncoder.dispatchWorkgroups(e,t,r)},e.prototype.dispatchWorkgroupsIndirect=function(e,t){this.gpuComputePassEncoder.dispatchWorkgroupsIndirect(e.gpuBuffer,t)},e.prototype.finish=function(){this.gpuComputePassEncoder.end(),this.gpuComputePassEncoder=null,this.frameCommandEncoder=null},e.prototype.beginComputePass=function(e){Ae(null===this.gpuComputePassEncoder),this.frameCommandEncoder=e,this.gpuComputePassEncoder=this.frameCommandEncoder.beginComputePass(this.gpuComputePassDescriptor)},e.prototype.setPipeline=function(e){var t=ge(e.gpuComputePipeline);this.gpuComputePassEncoder.setPipeline(t)},e.prototype.setBindings=function(e){var t=this,r=e;r.gpuBindGroup.forEach((function(e,n){e&&t.gpuComputePassEncoder.setBindGroup(n,r.gpuBindGroup[n])}))},e.prototype.pushDebugGroup=function(e){this.gpuComputePassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuComputePassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuComputePassEncoder.insertDebugMarker(e)},e}(),Gr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.ComputePipeline,n.gpuComputePipeline=null,n.descriptor=r;var o=r.program.computeStage;if(null===o)return n;var a={layout:"auto",compute:i({},o)};return n.gpuComputePipeline=n.device.device.createComputePipeline(a),void 0!==n.name&&(n.gpuComputePipeline.label=n.name),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuComputePipeline.getBindGroupLayout(e)},t}(Lr),kr=function(e){function t(t){var r,n,i,o,a=t.descriptor,s=e.call(this,{id:t.id,device:t.device})||this;s.type=k.InputLayout;var u=[];try{for(var c=l(a.vertexBufferDescriptors),f=c.next();!f.done;f=c.next()){var d=f.value,p=d.attributes;u.push({arrayStride:d.arrayStride,stepMode:xr(d.stepMode),attributes:[]});try{for(var _=(i=void 0,l(p)),h=_.next();!h.done;h=_.next()){var E=h.value,R=E.offset;u[u.length-1].attributes.push({shaderLocation:E.shaderLocation,format:Br(E.format),offset:R})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=_.return)&&o.call(_)}finally{if(i)throw i.error}}}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return s.indexFormat=function(e){if(null!==e){if(e===fe.U16_R)return"uint16";if(e===fe.U32_R)return"uint32";throw Error("whoops")}}(a.indexBufferFormat),s.buffers=u,s}return n(t,e),t}(Lr),Vr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.Program,n.vertexStage=null,n.fragmentStage=null,n.computeStage=null,n.descriptor=r,r.vertex&&(n.vertexStage=n.createShaderStage(r.vertex,"vertex")),r.fragment&&(n.fragmentStage=n.createShaderStage(r.fragment,"fragment")),r.compute&&(n.computeStage=n.createShaderStage(r.compute,"compute")),n}return n(t,e),t.prototype.setUniformsLegacy=function(e){},t.prototype.createShaderStage=function(e,t){var r,n,i=e.glsl,o=e.entryPoint,a=e.postprocess,s=e.wgsl;if(!s)try{s=this.device.glsl_compile(i,t,!1)}catch(e){throw console.error(e,i),Error("whoops")}var u=function(e){if(!s.includes(e))return"continue";s=(s=s.replace("var T_".concat(e,": texture_2d<f32>;"),"var T_".concat(e,": texture_depth_2d;"))).replace(RegExp("textureSample\\(T_".concat(e,"(.*)\\);$"),"gm"),(function(t,r){return"vec4<f32>(textureSample(T_".concat(e).concat(r,"), 0.0, 0.0, 0.0);")}))};try{for(var c=l(["u_TextureFramebufferDepth"]),f=c.next();!f.done;f=c.next()){u(f.value)}}catch(e){r={error:e}}finally{try{f&&!f.done&&(n=c.return)&&n.call(c)}finally{if(r)throw r.error}}return a&&(s=a(s)),{module:this.device.device.createShaderModule({code:s}),entryPoint:o||"main"}},t}(Lr),Xr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;n.type=k.QueryPool;var i=r.elemCount;return n.querySet=n.device.device.createQuerySet({type:Tr(r.type),count:i}),n.resolveBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),n.cpuBuffer=n.device.device.createBuffer({size:8*i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),n.results=null,n}return n(t,e),t.prototype.queryResultOcclusion=function(e){return null===this.results?null:this.results[e]!==BigInt(0)},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.querySet.destroy(),this.resolveBuffer.destroy(),this.cpuBuffer.destroy()},t}(Lr),Wr=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.Readback,r}return n(t,e),t.prototype.readTexture=function(e,t,r,n,i,o,l,u){return void 0===l&&(l=0),a(this,void 0,void 0,(function(){var a,u,c,f,d,p,_;return s(this,(function(s){return 0,u=br((a=e).gpuTextureformat),p=this.device.createBuffer({usage:q.STORAGE|q.MAP_READ|q.COPY_DST,hint:Q.STATIC,viewOrSize:d=(f=256*Math.ceil((c=Math.ceil(n/u.width)*u.length)/256))*i}),(_=this.device.device.createCommandEncoder()).copyTextureToBuffer({texture:a.gpuTexture,mipLevel:0,origin:{x:t,y:r,z:0}},{buffer:p.gpuBuffer,offset:0,bytesPerRow:f},{width:n,height:i,depthOrArrayLayers:1}),this.device.device.queue.submit([_.finish()]),[2,this.readBuffer(p,0,o.byteLength===d?o:null,l,d,a.format,!0,!1,c,f,i)]}))}))},t.prototype.readTextureSync=function(e,t,r,n,i,o,a,s){throw Error("ERROR_MSG_METHOD_NOT_IMPLEMENTED")},t.prototype.readBuffer=function(e,t,r,n,i,o,a,s,l,u,c){var f=this;void 0===t&&(t=0),void 0===r&&(r=null),void 0===i&&(i=0),void 0===o&&(o=fe.U8_RGB),void 0===a&&(a=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===c&&(c=0);var d=e,p=i||d.size,_=r||d.view,h=_&&_.constructor&&_.constructor.BYTES_PER_ELEMENT||Te(o),E=d;if(!(d.usage&q.MAP_READ&&d.usage&q.COPY_DST)){var R=this.device.device.createCommandEncoder();E=this.device.createBuffer({usage:q.STORAGE|q.MAP_READ|q.COPY_DST,hint:Q.STATIC,viewOrSize:p}),R.copyBufferToBuffer(d.gpuBuffer,t,E.gpuBuffer,0,p),this.device.device.queue.submit([R.finish()])}return new Promise((function(e,r){E.gpuBuffer.mapAsync(dr.READ,t,p).then((function(){var r=E.gpuBuffer.getMappedRange(t,p),n=_;if(a)n=null===n?Dr(o,p,!0,r):Dr(o,n.buffer,void 0,r);else if(null===n)switch(h){case 1:(n=new Uint8Array(p)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,r);break;case 4:(n=new Float32Array(p/4)).set(new Float32Array(r))}else switch(h){case 1:(n=new Uint8Array(n.buffer)).set(new Uint8Array(r));break;case 2:n=f.getHalfFloatAsFloatRGBAArrayBuffer(p/2,r,_);break;case 4:var i=_&&_.constructor||Float32Array;(n=new i(n.buffer)).set(new i(r))}if(l!==u){1!==h||a||(l*=2,u*=2);for(var s=new Uint8Array(n.buffer),d=l,R=0,v=1;c>v;++v){R=v*u;for(var T=0;l>T;++T)s[d++]=s[R++]}n=0===h||a?new Uint8Array(s.buffer,0,d):new Float32Array(s.buffer,0,d/4)}E.gpuBuffer.unmap(),e(n)}),(function(e){return r(e)}))}))},t.prototype.getHalfFloatAsFloatRGBAArrayBuffer=function(e,t,r){r||(r=new Float32Array(e));for(var n,i,o,a,s=new Uint16Array(t);e--;)r[e]=(i=void 0,o=void 0,a=void 0,i=(32768&(n=s[e]))>>15,a=1023&n,0===(o=(31744&n)>>10)?(i?-1:1)*Math.pow(2,-14)*(a/1024):31==o?a?NaN:1/0*(i?-1:1):(i?-1:1)*Math.pow(2,o-15)*(1+a/1024));return r},t}(Lr),Hr=function(){function e(e){this.device=e,this.gpuRenderPassEncoder=null,this.gfxColorAttachment=[],this.gfxColorAttachmentLevel=[],this.gfxColorResolveTo=[],this.gfxColorResolveToLevel=[],this.gfxDepthStencilAttachment=null,this.gfxDepthStencilResolveTo=null,this.gpuColorAttachments=[],this.gpuDepthStencilAttachment={view:null,depthLoadOp:"load",depthStoreOp:"store",stencilLoadOp:"load",stencilStoreOp:"store"},this.gpuRenderPassDescriptor={colorAttachments:this.gpuColorAttachments,depthStencilAttachment:this.gpuDepthStencilAttachment}}return e.prototype.getEncoder=function(){var e;return(null===(e=this.renderBundle)||void 0===e?void 0:e.renderBundleEncoder)||this.gpuRenderPassEncoder},e.prototype.getTextureView=function(e,t){return Ae(e.mipLevelCount>t),1===e.mipLevelCount?e.gpuTextureView:e.gpuTexture.createView({baseMipLevel:t,mipLevelCount:1})},e.prototype.setRenderPassDescriptor=function(e){var t,r,n,i,o,a;this.descriptor=e,this.gpuRenderPassDescriptor.colorAttachments=this.gpuColorAttachments;var s=e.colorAttachment.length;this.gfxColorAttachment.length=s,this.gfxColorResolveTo.length=s;for(var l=0;e.colorAttachment.length>l;l++){var u=e.colorAttachment[l],c=e.colorResolveTo[l];if(null===u&&null!==c&&(u=c,c=null),this.gfxColorAttachment[l]=u,this.gfxColorResolveTo[l]=c,this.gfxColorAttachmentLevel[l]=(null===(t=e.colorAttachmentLevel)||void 0===t?void 0:t[l])||0,this.gfxColorResolveToLevel[l]=(null===(r=e.colorResolveToLevel)||void 0===r?void 0:r[l])||0,null===u){this.gpuColorAttachments.length=l,this.gfxColorAttachment.length=l,this.gfxColorResolveTo.length=l;break}void 0===this.gpuColorAttachments[l]&&(this.gpuColorAttachments[l]={}),(p=this.gpuColorAttachments[l]).view=this.getTextureView(u,(null===(n=this.gfxColorAttachmentLevel)||void 0===n?void 0:n[l])||0);var d=null!==(o=null===(i=e.colorClearColor)||void 0===i?void 0:i[l])&&void 0!==o?o:"load";"load"===d?p.loadOp="load":(p.loadOp="clear",p.clearValue=d),p.storeOp=(null===(a=e.colorStore)||void 0===a?void 0:a[l])?"store":"discard",p.resolveTarget=void 0,null!==c&&(u.sampleCount>1?p.resolveTarget=this.getTextureView(c,this.gfxColorResolveToLevel[l]):p.storeOp="store")}if(this.gfxDepthStencilAttachment=e.depthStencilAttachment,this.gfxDepthStencilResolveTo=e.depthStencilResolveTo,e.depthStencilAttachment){var p,_=e.depthStencilAttachment;(p=this.gpuDepthStencilAttachment).view=_.gpuTextureView,!!(Re(_.format)&ce.Depth)?("load"===e.depthClearValue?p.depthLoadOp="load":(p.depthLoadOp="clear",p.depthClearValue=e.depthClearValue),p.depthStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(p.depthLoadOp=void 0,p.depthStoreOp=void 0),!!(Re(_.format)&ce.Stencil)?("load"===e.stencilClearValue?p.stencilLoadOp="load":(p.stencilLoadOp="clear",p.stencilClearValue=e.stencilClearValue),p.stencilStoreOp=e.depthStencilStore||null!==this.gfxDepthStencilResolveTo?"store":"discard"):(p.stencilLoadOp=void 0,p.stencilStoreOp=void 0),this.gpuRenderPassDescriptor.depthStencilAttachment=this.gpuDepthStencilAttachment}else this.gpuRenderPassDescriptor.depthStencilAttachment=void 0;this.gpuRenderPassDescriptor.occlusionQuerySet=f(e.occlusionQueryPool)?void 0:e.occlusionQueryPool.querySet},e.prototype.beginRenderPass=function(e,t){Ae(null===this.gpuRenderPassEncoder),this.setRenderPassDescriptor(t),this.frameCommandEncoder=e,this.gpuRenderPassEncoder=this.frameCommandEncoder.beginRenderPass(this.gpuRenderPassDescriptor)},e.prototype.flipY=function(e,t){return this.device.swapChainHeight-e-t},e.prototype.setViewport=function(e,t,r,n,i,o){void 0===i&&(i=0),void 0===o&&(o=1),this.gpuRenderPassEncoder.setViewport(e,this.flipY(t,n),r,n,i,o)},e.prototype.setScissorRect=function(e,t,r,n){this.gpuRenderPassEncoder.setScissorRect(e,this.flipY(t,n),r,n)},e.prototype.setPipeline=function(e){var t=ge(e.gpuRenderPipeline);this.getEncoder().setPipeline(t)},e.prototype.setVertexInput=function(e,t,r){if(null!==e){var n=this.getEncoder(),i=e;null!==r&&n.setIndexBuffer(vr(r.buffer),ge(i.indexFormat),r.offset);for(var o=0;t.length>o;o++){var a=t[o];null!==a&&n.setVertexBuffer(o,vr(a.buffer),a.offset)}}},e.prototype.setBindings=function(e){var t=e,r=this.getEncoder();t.gpuBindGroup.forEach((function(e,n){e&&r.setBindGroup(n,t.gpuBindGroup[n])}))},e.prototype.setStencilReference=function(e){this.gpuRenderPassEncoder.setStencilReference(e)},e.prototype.draw=function(e,t,r,n){this.getEncoder().draw(e,t,r,n)},e.prototype.drawIndexed=function(e,t,r,n,i){this.getEncoder().drawIndexed(e,t,r,n,i)},e.prototype.drawIndirect=function(e,t){this.getEncoder().drawIndirect(vr(e),t)},e.prototype.drawIndexedIndirect=function(e,t){this.getEncoder().drawIndexedIndirect(vr(e),t)},e.prototype.beginOcclusionQuery=function(e){this.gpuRenderPassEncoder.beginOcclusionQuery(e)},e.prototype.endOcclusionQuery=function(){this.gpuRenderPassEncoder.endOcclusionQuery()},e.prototype.pushDebugGroup=function(e){this.gpuRenderPassEncoder.pushDebugGroup(e)},e.prototype.popDebugGroup=function(){this.gpuRenderPassEncoder.popDebugGroup()},e.prototype.insertDebugMarker=function(e){this.gpuRenderPassEncoder.insertDebugMarker(e)},e.prototype.beginBundle=function(e){this.renderBundle=e},e.prototype.endBundle=function(){this.renderBundle.finish()},e.prototype.executeBundles=function(e){this.gpuRenderPassEncoder.executeBundles(e.map((function(e){return e.renderBundle})))},e.prototype.finish=function(){var e;null===(e=this.gpuRenderPassEncoder)||void 0===e||e.end(),this.gpuRenderPassEncoder=null;for(var t=0;this.gfxColorAttachment.length>t;t++){var r=this.gfxColorAttachment[t],n=this.gfxColorResolveTo[t];null!==r&&null!==n&&1===r.sampleCount&&this.copyAttachment(n,this.gfxColorAttachmentLevel[t],r,this.gfxColorResolveToLevel[t])}this.gfxDepthStencilAttachment&&this.gfxDepthStencilResolveTo&&(this.gfxDepthStencilAttachment.sampleCount>1||this.copyAttachment(this.gfxDepthStencilResolveTo,0,this.gfxDepthStencilAttachment,0)),this.frameCommandEncoder=null},e.prototype.copyAttachment=function(e,t,r,n){Ae(1===r.sampleCount);var i={texture:r.gpuTexture,mipLevel:n},o={texture:e.gpuTexture,mipLevel:t};Ae(r.width>>>n==e.width>>>t),Ae(r.height>>>n==e.height>>>t),Ae(!!(r.usage&fr.COPY_SRC)),Ae(!!(e.usage&fr.COPY_DST)),this.frameCommandEncoder.copyTextureToTexture(i,o,[e.width,e.height,1])},e}(),Yr=function(e){function t(t){var r=t.descriptor,n=e.call(this,{id:t.id,device:t.device})||this;return n.type=k.RenderPipeline,n.isCreatingAsync=!1,n.gpuRenderPipeline=null,n.descriptor=r,n.device.createRenderPipelineInternal(n,!1),n}return n(t,e),t.prototype.getBindGroupLayout=function(e){return this.gpuRenderPipeline.getBindGroupLayout(e)},t}(Lr),zr=function(e){function t(t){var r,n,i=t.descriptor,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Sampler;var a=i.lodMinClamp,s=i.mipmapFilter===j.NO_MIP?i.lodMinClamp:i.lodMaxClamp,l=null!==(r=i.maxAnisotropy)&&void 0!==r?r:1;return l>1&&Ae(i.minFilter===K.BILINEAR&&i.magFilter===K.BILINEAR&&i.mipmapFilter===j.LINEAR),o.gpuSampler=o.device.device.createSampler({addressModeU:hr(i.addressModeU),addressModeV:hr(i.addressModeV),addressModeW:hr(null!==(n=i.addressModeW)&&void 0!==n?n:i.addressModeU),lodMinClamp:a,lodMaxClamp:s,minFilter:Er(i.minFilter),magFilter:Er(i.magFilter),mipmapFilter:Rr(i.mipmapFilter),compare:void 0!==i.compareFunction?Ir(i.compareFunction):void 0,maxAnisotropy:l}),o}return n(t,e),t}(Lr),Kr=function(e){function t(t){var r=t.descriptor,n=t.skipCreate,i=t.sampleCount,o=e.call(this,{id:t.id,device:t.device})||this;o.type=k.Texture,o.flipY=!1;var a=r.format,s=r.dimension,l=r.width,u=r.height,c=r.depthOrArrayLayers,f=r.mipLevelCount,d=r.usage,p=r.pixelStore;return o.flipY=!!(null==p?void 0:p.unpackFlipY),o.device.createTextureShared({format:a,dimension:null!=s?s:ee.TEXTURE_2D,width:l,height:u,depthOrArrayLayers:null!=c?c:1,mipLevelCount:null!=f?f:1,usage:d,sampleCount:null!=i?i:1},o,n),o}return n(t,e),t.prototype.textureFromImageBitmapOrCanvas=function(e,t,r){for(var n=t[0].width,i=t[0].height,o={size:{width:n,height:i,depthOrArrayLayers:r},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT},a=e.createTexture(o),s=0;t.length>s;s++)e.queue.copyExternalImageToTexture({source:t[s],flipY:this.flipY},{texture:a,origin:[0,0,s]},[n,i]);return[a,n,i]},t.prototype.isImageBitmapOrCanvases=function(e){var t=e[0];return t instanceof ImageBitmap||t instanceof HTMLCanvasElement||t instanceof OffscreenCanvas},t.prototype.isVideo=function(e){return e[0]instanceof HTMLVideoElement},t.prototype.setImageData=function(e,t){var r,n,i,o,a=this,s=this.device.device;if(this.isImageBitmapOrCanvases(e))n=(r=u(this.textureFromImageBitmapOrCanvas(s,e,this.depthOrArrayLayers),3))[0],i=r[1],o=r[2];else if(this.isVideo(e))n=s.importExternalTexture({source:e[0]});else{var l=br(this.gpuTextureformat),c=Math.ceil(this.width/l.width)*l.length;e.forEach((function(e){s.queue.writeTexture({texture:a.gpuTexture},e,{bytesPerRow:c},{width:a.width,height:a.height})}))}this.width=i,this.height=o,n&&(this.gpuTexture=n),this.gpuTextureView=this.gpuTexture.createView({dimension:_r(this.dimension)})},t.prototype.destroy=function(){e.prototype.destroy.call(this),this.gpuTexture.destroy()},t}(Lr),jr=function(e){function t(t){var r=e.call(this,{id:t.id,device:t.device})||this;return r.type=k.RenderBundle,r.renderBundleEncoder=r.device.device.createRenderBundleEncoder({colorFormats:[r.device.swapChainFormat]}),r}return n(t,e),t.prototype.finish=function(){this.renderBundle=this.renderBundleEncoder.finish()},t}(Lr),Zr=function(){function e(e,t,r,n,i,o){this.swapChainWidth=0,this.swapChainHeight=0,this.swapChainTextureUsage=fr.RENDER_ATTACHMENT|fr.COPY_DST,this._resourceUniqueId=0,this.renderPassPool=[],this.computePassPool=[],this.frameCommandEncoderPool=[],this.featureTextureCompressionBC=!1,this.platformString="WebGPU",this.glslVersion="#version 440",this.explicitBindingLocations=!0,this.separateSamplerTextures=!0,this.viewportOrigin=oe.UPPER_LEFT,this.clipSpaceNearZ=ae.ZERO,this.supportsSyncPipelineCompilation=!1,this.supportMRT=!0,this.device=t,this.canvas=r,this.canvasContext=n,this.glsl_compile=i,this.WGSLComposer=o,this.fallbackTexture2D=this.createFallbackTexture(ee.TEXTURE_2D,ie.Float),this.setResourceName(this.fallbackTexture2D,"Fallback Texture2D"),this.fallbackTexture2DDepth=this.createFallbackTexture(ee.TEXTURE_2D,ie.Depth),this.setResourceName(this.fallbackTexture2DDepth,"Fallback Depth Texture2D"),this.fallbackTexture2DArray=this.createFallbackTexture(ee.TEXTURE_2D_ARRAY,ie.Float),this.setResourceName(this.fallbackTexture2DArray,"Fallback Texture2DArray"),this.fallbackTexture3D=this.createFallbackTexture(ee.TEXTURE_3D,ie.Float),this.setResourceName(this.fallbackTexture3D,"Fallback Texture3D"),this.fallbackTextureCube=this.createFallbackTexture(ee.TEXTURE_CUBE_MAP,ie.Float),this.setResourceName(this.fallbackTextureCube,"Fallback TextureCube"),this.fallbackSamplerFiltering=this.createSampler({addressModeU:z.REPEAT,addressModeV:z.REPEAT,minFilter:K.POINT,magFilter:K.POINT,mipmapFilter:j.NEAREST}),this.setResourceName(this.fallbackSamplerFiltering,"Fallback Sampler Filtering"),this.fallbackSamplerComparison=this.createSampler({addressModeU:z.REPEAT,addressModeV:z.REPEAT,minFilter:K.POINT,magFilter:K.POINT,mipmapFilter:j.NEAREST,compareFunction:V.ALWAYS}),this.setResourceName(this.fallbackSamplerComparison,"Fallback Sampler Comparison Filtering"),this.device.features&&(this.featureTextureCompressionBC=this.device.features.has("texture-compression-bc")),this.device.onuncapturederror=function(e){console.error(e.error)},this.swapChainFormat=navigator.gpu.getPreferredCanvasFormat(),this.canvasContext.configure({device:this.device,format:this.swapChainFormat,usage:this.swapChainTextureUsage,alphaMode:"premultiplied"})}return e.prototype.destroy=function(){},e.prototype.configureSwapChain=function(e,t){this.swapChainWidth===e&&this.swapChainHeight===t||(this.swapChainWidth=e,this.swapChainHeight=t)},e.prototype.getOnscreenTexture=function(){var e=this.canvasContext.getCurrentTexture(),t=e.createView(),r=new Kr({id:0,device:this,descriptor:{format:fe.U8_RGBA_RT,width:this.swapChainWidth,height:this.swapChainHeight,depthOrArrayLayers:0,dimension:ee.TEXTURE_2D,mipLevelCount:1,usage:this.swapChainTextureUsage},skipCreate:!0});return r.depthOrArrayLayers=1,r.sampleCount=1,r.gpuTexture=e,r.gpuTextureView=t,r.name="Onscreen",this.setResourceName(r,"Onscreen Texture"),r},e.prototype.getDevice=function(){return this},e.prototype.getCanvas=function(){return this.canvas},e.prototype.beginFrame=function(){Ae(0===this.frameCommandEncoderPool.length)},e.prototype.endFrame=function(){Ae(this.frameCommandEncoderPool.every((function(e){return null!==e}))),this.device.queue.submit(this.frameCommandEncoderPool.map((function(e){return e.finish()}))),this.frameCommandEncoderPool=[]},e.prototype.getNextUniqueId=function(){return++this._resourceUniqueId},e.prototype.createBuffer=function(e){return new Ur({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTexture=function(e){return new Kr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createSampler=function(e){return new zr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderTarget=function(e){var t=new Kr({id:this.getNextUniqueId(),device:this,descriptor:i(i({},e),{dimension:ee.TEXTURE_2D,mipLevelCount:1,depthOrArrayLayers:1,usage:te.RENDER_TARGET}),sampleCount:e.sampleCount});return t.depthOrArrayLayers=1,t.type=k.RenderTarget,t},e.prototype.createRenderTargetFromTexture=function(e){var t=e.format,r=e.width,n=e.height,i=e.depthOrArrayLayers,o=e.sampleCount,a=e.mipLevelCount,s=e.gpuTexture,l=e.gpuTextureView,u=e.usage;Ae(!!(u&fr.RENDER_ATTACHMENT));var c=new Kr({id:this.getNextUniqueId(),device:this,descriptor:{format:t,width:r,height:n,depthOrArrayLayers:i,dimension:ee.TEXTURE_2D,mipLevelCount:a,usage:u},skipCreate:!0});return c.depthOrArrayLayers=i,c.sampleCount=o,c.gpuTexture=s,c.gpuTextureView=l,c},e.prototype.createProgram=function(e){var t,r;return(null===(t=e.vertex)||void 0===t?void 0:t.glsl)&&(e.vertex.glsl=Lt(this.queryVendorInfo(),"vert",e.vertex.glsl)),(null===(r=e.fragment)||void 0===r?void 0:r.glsl)&&(e.fragment.glsl=Lt(this.queryVendorInfo(),"frag",e.fragment.glsl)),new Vr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createProgramSimple=function(e){return new Vr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createTextureShared=function(e,t,r){var n={width:e.width,height:e.height,depthOrArrayLayers:e.depthOrArrayLayers},i=e.mipLevelCount,o=pr(e.format),a=function(e){if(e===ee.TEXTURE_2D)return"2d";if(e===ee.TEXTURE_CUBE_MAP)return"2d";if(e===ee.TEXTURE_2D_ARRAY)return"2d";if(e===ee.TEXTURE_3D)return"3d";throw Error("whoops")}(e.dimension),s=function(e){var t=0;return e&te.SAMPLED&&(t|=fr.TEXTURE_BINDING|fr.COPY_DST|fr.COPY_SRC),e&te.STORAGE&&(t|=fr.TEXTURE_BINDING|fr.STORAGE_BINDING|fr.COPY_SRC|fr.COPY_DST),e&te.RENDER_TARGET&&(t|=fr.RENDER_ATTACHMENT|fr.TEXTURE_BINDING|fr.COPY_SRC|fr.COPY_DST),t}(e.usage);if(t.gpuTextureformat=o,t.dimension=e.dimension,t.format=e.format,t.width=e.width,t.height=e.height,t.depthOrArrayLayers=e.depthOrArrayLayers,t.mipLevelCount=i,t.usage=s,t.sampleCount=e.sampleCount,!r){var l=this.device.createTexture({size:n,mipLevelCount:i,format:o,dimension:a,sampleCount:e.sampleCount,usage:s}),u=l.createView();t.gpuTexture=l,t.gpuTextureView=u}},e.prototype.getFallbackSampler=function(e){return e.formatKind===ie.Depth&&e.comparison?this.fallbackSamplerComparison:this.fallbackSamplerFiltering},e.prototype.getFallbackTexture=function(e){var t=e.dimension;if(t===ee.TEXTURE_2D)return e.formatKind===ie.Depth?this.fallbackTexture2DDepth:this.fallbackTexture2D;if(t===ee.TEXTURE_2D_ARRAY)return this.fallbackTexture2DArray;if(t===ee.TEXTURE_3D)return this.fallbackTexture3D;if(t===ee.TEXTURE_CUBE_MAP)return this.fallbackTextureCube;throw Error("whoops")},e.prototype.createFallbackTexture=function(e,t){return this.createTexture({dimension:e,format:t===ie.Float?fe.U8_RGBA_NORM:fe.D24,usage:te.SAMPLED,width:1,height:1,depthOrArrayLayers:e===ee.TEXTURE_CUBE_MAP?6:1,mipLevelCount:1})},e.prototype.createBindings=function(e){return new Fr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createInputLayout=function(e){return new kr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createComputePipeline=function(e){return new Gr({id:this.getNextUniqueId(),device:this,descriptor:e})},e.prototype.createRenderPipeline=function(e){return new Yr({id:this.getNextUniqueId(),device:this,descriptor:i({},e)})},e.prototype.createQueryPool=function(e,t){return new Xr({id:this.getNextUniqueId(),device:this,descriptor:{type:e,elemCount:t}})},e.prototype.createRenderPipelineInternal=function(e,t){var r;if(null===e.gpuRenderPipeline){var n=e.descriptor,a=n.program,s=a.vertexStage,l=a.fragmentStage;if(null!==s&&null!==l){var u=n.megaStateDescriptor||{},c=u.stencilBack,d=u.stencilFront,p=o(u,["stencilBack","stencilFront"]),_=Ve(We);n.megaStateDescriptor=i(i(i({},_),{stencilBack:i(i({},_.stencilBack),c),stencilFront:i(i({},_.stencilFront),d)}),p);var h=n.megaStateDescriptor.attachmentsState[0];n.colorAttachmentFormats.forEach((function(e,t){n.megaStateDescriptor.attachmentsState[t]||(n.megaStateDescriptor.attachmentsState[t]=we(void 0,h))}));var E,R,v=(E=null!==(r=n.topology)&&void 0!==r?r:Z.TRIANGLES,R=n.megaStateDescriptor,{topology:mr(E),cullMode:Ar(R.cullMode),frontFace:gr(R.frontFace)}),T=Mr(n.colorAttachmentFormats,n.megaStateDescriptor),m=function(e,t){if(!f(e))return{format:pr(e),depthWriteEnabled:!!t.depthWrite,depthCompare:Ir(t.depthCompare),depthBias:t.polygonOffset?1:0,depthBiasSlopeScale:t.polygonOffset?1:0,stencilFront:{compare:Ir(t.stencilFront.compare),passOp:Or(t.stencilFront.passOp),failOp:Or(t.stencilFront.failOp),depthFailOp:Or(t.stencilFront.depthFailOp)},stencilBack:{compare:Ir(t.stencilBack.compare),passOp:Or(t.stencilBack.passOp),failOp:Or(t.stencilBack.failOp),depthFailOp:Or(t.stencilBack.depthFailOp)},stencilReadMask:4294967295,stencilWriteMask:4294967295}}(n.depthStencilAttachmentFormat,n.megaStateDescriptor),A=void 0;null!==n.inputLayout&&(A=n.inputLayout.buffers);var g=n.sampleCount,y={layout:"auto",vertex:i(i({},s),{buffers:A}),primitive:v,depthStencil:m,multisample:{count:g},fragment:i(i({},l),{targets:T})};e.gpuRenderPipeline=this.device.createRenderPipeline(y)}}},e.prototype.createReadback=function(){return new Wr({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderBundle=function(){return new jr({id:this.getNextUniqueId(),device:this})},e.prototype.createRenderPass=function(e){var t=this.renderPassPool.pop();void 0===t&&(t=new Hr(this));var r=this.frameCommandEncoderPool.pop();return void 0===r&&(r=this.device.createCommandEncoder()),t.beginRenderPass(r,e),t},e.prototype.createComputePass=function(){var e=this.computePassPool.pop();void 0===e&&(e=new wr);var t=this.frameCommandEncoderPool.pop();return void 0===t&&(t=this.device.createCommandEncoder()),e.beginComputePass(t),e},e.prototype.submitPass=function(e){var t=e;t instanceof Hr?(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.renderPassPool.push(t)):t instanceof wr&&(this.frameCommandEncoderPool.push(t.frameCommandEncoder),t.finish(),this.computePassPool.push(t))},e.prototype.copySubTexture2D=function(e,t,r,n,i,o,a){var s=this.device.createCommandEncoder(),l=e,u=n,c={texture:u.gpuTexture,origin:[i,o,0],mipLevel:0,aspect:"all"},f={texture:l.gpuTexture,origin:[t,r,0],mipLevel:0,aspect:"all"};Ae(!!(u.usage&fr.COPY_SRC)),Ae(!!(l.usage&fr.COPY_DST)),s.copyTextureToTexture(c,f,[u.width,u.height,a||1]),this.device.queue.submit([s.finish()])},e.prototype.queryLimits=function(){return{uniformBufferMaxPageWordSize:this.device.limits.maxUniformBufferBindingSize>>>2,uniformBufferWordAlignment:this.device.limits.minUniformBufferOffsetAlignment>>>2,supportedSampleCounts:[1],occlusionQueriesRecommended:!0,computeShadersSupported:!0}},e.prototype.queryTextureFormatSupported=function(e,t,r){if(function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_SNORM:case le.BC4_UNORM:case le.BC5_SNORM:case le.BC5_UNORM:return!0;default:return!1}}(e)){if(!this.featureTextureCompressionBC)return!1;var n=function(e){switch(Ee(e)){case le.BC1:case le.BC2:case le.BC3:case le.BC4_SNORM:case le.BC4_UNORM:case le.BC5_SNORM:case le.BC5_UNORM:return 4;default:return 1}}(e);return t%n==0&&r%n==0&&this.featureTextureCompressionBC}switch(e){case fe.U16_RGBA_NORM:case fe.F32_RGBA:return!1}return!0},e.prototype.queryPlatformAvailable=function(){return!0},e.prototype.queryVendorInfo=function(){return this},e.prototype.queryRenderPass=function(e){return e.descriptor},e.prototype.queryRenderTarget=function(e){return e},e.prototype.setResourceName=function(e,t){if(e.name=t,e.type===k.Buffer)(r=e).gpuBuffer.label=t;else if(e.type===k.Texture){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===k.RenderTarget){(r=e).gpuTexture.label=t,r.gpuTextureView.label=t}else if(e.type===k.Sampler){(r=e).gpuSampler.label=t}else if(e.type===k.RenderPipeline){var r;null!==(r=e).gpuRenderPipeline&&(r.gpuRenderPipeline.label=t)}},e.prototype.setResourceLeakCheck=function(e,t){},e.prototype.checkForLeaks=function(){},e.prototype.programPatched=function(e){},e.prototype.pipelineQueryReady=function(e){return null!==e.gpuRenderPipeline},e.prototype.pipelineForceReady=function(e){this.createRenderPipelineInternal(e,!1)},e}(),qr=function(){function e(e){this.pluginOptions=e}return e.prototype.createSwapChain=function(e){return a(this,void 0,void 0,(function(){var t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:if(void 0===globalThis.navigator.gpu)return[2,null];t=null,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,globalThis.navigator.gpu.requestAdapter({xrCompatible:this.pluginOptions.xrCompatible})];case 2:return t=s.sent(),[3,4];case 3:return r=s.sent(),console.log(r),[3,4];case 4:return null===t?[2,null]:(n=["depth32float-stencil8","texture-compression-bc","float32-filterable"].filter((function(e){return t.features.has(e)})),[4,t.requestDevice({requiredFeatures:n})]);case 5:if((i=s.sent())&&(o=this.pluginOptions.onContextLost,i.lost.then((function(){o&&o()}))),null===i)return[2,null];if(!(a=e.getContext("webgpu")))return[2,null];s.label=6;case 6:return s.trys.push([6,8,,9]),[4,cr(this.pluginOptions.shaderCompilerPath)];case 7:case 8:return s.sent(),[3,9];case 9:return[2,new Zr(t,i,e,a,sr,lr&&new lr)]}}))}))},e}(),Qr={exports:{}};function $r(e,t,r){r=r||2;var n,i,o,a,s,l,u,c=t&&t.length,f=c?t[0]*r:e.length,d=Jr(e,0,f,r,!0),p=[];if(!d||d.next===d.prev)return p;if(c&&(d=function(e,t,r,n){var i,o,a,s=[];for(i=0,o=t.length;o>i;i++)(a=Jr(e,t[i]*n,o-1>i?t[i+1]*n:e.length,n,!1))===a.next&&(a.steiner=!0),s.push(fn(a));for(s.sort(sn),i=0;s.length>i;i++)r=en(r=ln(s[i],r),r.next);return r}(e,t,d,r)),e.length>80*r){n=o=e[0],i=a=e[1];for(var _=r;f>_;_+=r)n>(s=e[_])&&(n=s),i>(l=e[_+1])&&(i=l),s>o&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-n,a-i))?1/u:0}return tn(d,p,r,n,i,u),p}function Jr(e,t,r,n,i){var o,a;if(i===Sn(e,t,r,n)>0)for(o=t;r>o;o+=n)a=An(o,e[o],e[o+1],a);else for(o=r-n;o>=t;o-=n)a=An(o,e[o],e[o+1],a);return a&&hn(a,a.next)&&(gn(a),a=a.next),a}function en(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!hn(n,n.next)&&0!==_n(n.prev,n,n.next))n=n.next;else{if(gn(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function tn(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=cn(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,l,u=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;u>t&&(s++,n=n.nextZ);t++);for(l=u;s>0||l>0&&n;)0===s||0!==l&&n&&r.z>n.z?(i=n,n=n.nextZ,l--):(i=r,r=r.nextZ,s--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,u*=2}while(a>1)}(i)}(e,n,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?nn(e,n,i,o):rn(e))t.push(s.i/r),t.push(e.i/r),t.push(l.i/r),gn(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?tn(e=on(en(e),t,r),t,r,n,i,o,2):2===a&&an(e,t,r,n,i,o):tn(en(e),t,r,n,i,o,1);break}}}function rn(e){var t=e.prev,r=e,n=e.next;if(_n(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(dn(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&_n(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function nn(e,t,r,n){var i=e.prev,o=e,a=e.next;if(_n(i,o,a)>=0)return!1;for(var s=i.x>o.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,u=cn(o.x>i.x?a.x>i.x?i.x:a.x:a.x>o.x?o.x:a.x,o.y>i.y?a.y>i.y?i.y:a.y:a.y>o.y?o.y:a.y,t,r,n),c=cn(s,l,t,r,n),f=e.prevZ,d=e.nextZ;f&&f.z>=u&&d&&c>=d.z;){if(f!==e.prev&&f!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&_n(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,d!==e.prev&&d!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&_n(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,f.x,f.y)&&_n(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;d&&c>=d.z;){if(d!==e.prev&&d!==e.next&&dn(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&_n(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function on(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!hn(i,o)&&En(i,n,n.next,o)&&Tn(i,o)&&Tn(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),gn(n),gn(n.next),n=e=o),n=n.next}while(n!==e);return en(n)}function an(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&pn(a,s)){var l=mn(a,s);return a=en(a,a.next),l=en(l,l.next),tn(a,t,r,n,i,o),void tn(l,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function sn(e,t){return e.x-t.x}function ln(e,t){var r=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(n.y>=o&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(i>=s&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.next.x>n.x?n:n.next}}n=n.next}while(n!==t);if(!r)return null;if(i===a)return r;var l,u=r,c=r.x,f=r.y,d=1/0;n=r;do{n.x>i||c>n.x||i===n.x||!dn(f>o?i:a,o,c,f,f>o?a:i,o,n.x,n.y)||(l=Math.abs(o-n.y)/(i-n.x),Tn(n,e)&&(d>l||l===d&&(n.x>r.x||n.x===r.x&&un(r,n)))&&(r=n,d=l)),n=n.next}while(n!==u);return r}(e,t);if(!r)return t;var n=mn(r,e),i=en(r,r.next);return en(n,n.next),t===r?i:t}function un(e,t){return 0>_n(e.prev,e,t.prev)&&0>_n(t.next,e,e.next)}function cn(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function fn(e){var t=e,r=e;do{(r.x>t.x||t.x===r.x&&r.y>t.y)&&(r=t),t=t.next}while(t!==e);return r}function dn(e,t,r,n,i,o,a,s){return(i-a)*(t-s)-(e-a)*(o-s)>=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function pn(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&En(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(Tn(e,t)&&Tn(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x>i&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(_n(e.prev,e,t.prev)||_n(e,t.prev,t))||hn(e,t)&&_n(e.prev,e,e.next)>0&&_n(t.prev,t,t.next)>0)}function _n(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function hn(e,t){return e.x===t.x&&e.y===t.y}function En(e,t,r,n){var i=vn(_n(e,t,r)),o=vn(_n(e,t,n)),a=vn(_n(r,n,e)),s=vn(_n(r,n,t));return i!==o&&a!==s||(!(0!==i||!Rn(e,r,t))||(!(0!==o||!Rn(e,n,t))||(!(0!==a||!Rn(r,e,n))||!(0!==s||!Rn(r,t,n)))))}function Rn(e,t,r){return!(t.x>Math.max(e.x,r.x)||Math.min(e.x,r.x)>t.x||t.y>Math.max(e.y,r.y)||Math.min(e.y,r.y)>t.y)}function vn(e){return e>0?1:0>e?-1:0}function Tn(e,t){return 0>_n(e.prev,e,e.next)?_n(e,t,e.next)>=0&&_n(e,e.prev,t)>=0:0>_n(e,t,e.prev)||0>_n(e,e.next,t)}function mn(e,t){var r=new yn(e.i,e.x,e.y),n=new yn(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function An(e,t,r,n){var i=new yn(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function gn(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function yn(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Sn(e,t,r,n){for(var i=0,o=t,a=r-n;r>o;o+=n)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Qr.exports=$r,Qr.exports.default=$r,$r.deviation=function(e,t,r,n){var i=t&&t.length,o=Math.abs(Sn(e,0,i?t[0]*r:e.length,r));if(i)for(var a=0,s=t.length;s>a;a++){o-=Math.abs(Sn(e,t[a]*r,s-1>a?t[a+1]*r:e.length,r))}var l=0;for(a=0;n.length>a;a+=3){var u=n[a]*r,c=n[a+1]*r,f=n[a+2]*r;l+=Math.abs((e[u]-e[f])*(e[c+1]-e[u+1])-(e[u]-e[c])*(e[f+1]-e[u+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},$r.flatten=function(e){for(var t=e[0][0].length,r={vertices:[],holes:[],dimensions:t},n=0,i=0;e.length>i;i++){for(var o=0;e[i].length>o;o++)for(var a=0;t>a;a++)r.vertices.push(e[i][o][a]);i>0&&r.holes.push(n+=e[i-1].length)}return r};var Cn=Qr.exports;function Pn(e,t,r,n){var i=e-r,o=t-n;return Math.sqrt(i*i+o*o)}function Nn(e,t,r,n,i){return{x:(1-i)*e+i*r,y:(1-i)*t+i*n}}function Mn(e,t,r,n,i){var o=1-i;return o*o*o*e+3*t*i*o*o+3*r*i*i*o+n*i*i*i}function In(e,t,r,n,i,o,a,s,l){if(0===l)return function(e,t){for(var r=0,n=e.length,i=0;n>i;i++)r+=Pn(e[i],t[i],e[(i+1)%n],t[(i+1)%n]);return r/2}([e,r,i,a],[t,n,o,s]);var f=function(e,t,r,n,i,o,a,s,l){var u=Mn(e,r,i,a,l),c=Mn(t,n,o,s,l),f=Nn(e,t,r,n,l),d=Nn(r,n,i,o,l),p=Nn(i,o,a,s,l),_=Nn(f.x,f.y,d.x,d.y,l),h=Nn(d.x,d.y,p.x,p.y,l);return[[e,t,f.x,f.y,_.x,_.y,u,c],[u,c,h.x,h.y,p.x,p.y,a,s]]}(e,t,r,n,i,o,a,s,.5),d=c(c([],u(f[0]),!1),[l-1],!1),p=c(c([],u(f[1]),!1),[l-1],!1);return In.apply(void 0,c([],u(d),!1))+In.apply(void 0,c([],u(p),!1))}function On(e,t,r,n){var i=1-n;return i*i*e+2*n*i*t+n*n*r}function xn(e,t,r,n,i,o,a){if(0===a)return(Pn(e,t,r,n)+Pn(r,n,i,o)+Pn(e,t,i,o))/2;var s=function(e,t,r,n,i,o,a){var s=On(e,r,i,a),l=On(t,n,o,a),u=Nn(e,t,r,n,a),c=Nn(r,n,i,o,a);return[[e,t,u.x,u.y,s,l],[s,l,c.x,c.y,i,o]]}(e,t,r,n,i,o,.5),l=s[0],f=s[1];return l.push(a-1),f.push(a-1),xn.apply(void 0,c([],u(l),!1))+xn.apply(void 0,c([],u(f),!1))}var Bn=function(){function e(){this.drawcalls=[]}return e.tag="c-renderable-3d",e}(),Dn=function(){function e(){this.lights=[]}return e.prototype.addLight=function(e){this.lights.push(e),this.sortLights()},e.prototype.removeLight=function(e){var t=this.lights.indexOf(e);this.lights.splice(t,1),this.sortLights()},e.prototype.addFog=function(e){this.fog=e},e.prototype.removeFog=function(e){this.fog=null},e.prototype.getFog=function(){return this.fog},e.prototype.getAllLights=function(){return this.lights},e.prototype.getDefines=function(){var e={USE_LIGHT:!!this.lights.length};return this.lights.forEach((function(t){e[t.define]||(e[t.define]=0),e[t.define]++})),e},e.prototype.sortLights=function(){this.lights.sort((function(e,t){return e.order-t.order}))},e}(),bn=function(e){function r(r){var n=this,a=r.style,s=o(r,["style"]);return(n=e.call(this,i({type:t.Shape.MESH,style:i({x:"",y:"",z:"",lineWidth:0},a)},s))||this).cullable.enable=!1,n.style.geometry.meshes.push(n),n.style.material.meshes.push(n),n}return n(r,e),r.prototype.destroy=function(){e.prototype.destroy.call(this);var t=this.style.geometry.meshes,r=t.indexOf(this);t.splice(r,1),r=(t=this.style.material.meshes).indexOf(this),t.splice(r,1)},r}(t.DisplayObject),Ln=function(){function e(){}return e.prototype.update=function(e){var t=e.x,r=void 0===t?0:t,n=e.y,i=void 0===n?0:n,o=e.z,a=void 0===o?0:o,s=e.geometry.computeBoundingBox();return{cx:r,cy:i,cz:a,hwidth:s.halfExtents[0],hheight:s.halfExtents[1],hdepth:s.halfExtents[2]}},e}(),Fn=function(){function e(){this.counter=0,this.id2DisplayObjectMap={}}return e.prototype.getId=function(e){var t=this.counter++;return this.id2DisplayObjectMap[t]=e,t},e.prototype.getById=function(e){return this.id2DisplayObjectMap[e]},e.prototype.deleteById=function(e){delete this.id2DisplayObjectMap[e]},e.prototype.reset=function(){this.counter=0,this.id2DisplayObjectMap={}},e.prototype.decodePickingColor=function(e){var t=u(e,3);return t[0]+256*t[1]+65536*t[2]-1},e.prototype.encodePickingColor=function(e){return[e+1&255,e+1>>8&255,e+1>>8>>8&255]},e}(),Un=function(){function e(){this.name="(unnamed)",this.preprocessedVert="",this.preprocessedFrag="",this.both="",this.vert="",this.frag="",this.defines={}}return e.prototype.definesChanged=function(){this.preprocessedVert="",this.preprocessedFrag=""},e.prototype.setDefineString=function(e,t){if(null!==t){if(this.defines[e]===t)return!1;this.defines[e]=t}else{if(f(this.defines[e]))return!1;delete this.defines[e]}return this.definesChanged(),!0},e.prototype.setDefineBool=function(e,t){return this.setDefineString(e,t?"1":null)},e.prototype.getDefineString=function(e){return void 0===(t=this.defines[e])?null:t;var t},e.prototype.getDefineBool=function(e){var t=this.getDefineString(e);return null!==t&&Ae("1"===t),null!==t},e}(),wn=function(){function e(e){this.currentBufferWordSize=-1,this.currentWordOffset=0,this.buffer=null,this.shadowBufferF32=null,this.shadowBufferU8=null,this.device=e;var t=e.queryLimits();this.uniformBufferWordAlignment=t.uniformBufferWordAlignment,this.uniformBufferMaxPageWordSize=t.uniformBufferMaxPageWordSize}return e.prototype.isSupportedUBO=function(){return"WebGL1"!==this.device.queryVendorInfo().platformString},e.prototype.findPageIndex=function(e){return e/this.uniformBufferMaxPageWordSize|0},e.prototype.allocateChunk=function(e){e=De(e,this.uniformBufferWordAlignment),Ae(this.uniformBufferMaxPageWordSize>e);var t=this.currentWordOffset;return this.findPageIndex(t)!==this.findPageIndex(t+e-1)&&(t=De(t,this.uniformBufferMaxPageWordSize)),this.currentWordOffset=t+e,this.ensureShadowBuffer(t,e),t},e.prototype.ensureShadowBuffer=function(e,t){if(null===this.shadowBufferU8||null===this.shadowBufferF32){var r=De(this.currentWordOffset,this.uniformBufferMaxPageWordSize);this.shadowBufferU8=new Uint8Array(4*r),this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer)}else if(e+t>=this.shadowBufferF32.length){Ae(this.currentWordOffset>e&&this.currentWordOffset>=e+t);r=De(Math.max(this.currentWordOffset,2*this.shadowBufferF32.length),this.uniformBufferMaxPageWordSize);var n=new Uint8Array(4*r);if(n.set(this.shadowBufferU8,0),this.shadowBufferU8=n,this.shadowBufferF32=new Float32Array(this.shadowBufferU8.buffer),r<this.currentWordOffset)throw Error("Assert fail: this.currentWordOffset [".concat(this.currentWordOffset,"] <= newWordCount [").concat(r,"]"))}},e.prototype.mapBufferF32=function(){return ge(this.shadowBufferF32)},e.prototype.prepareToRender=function(){if(null!==this.shadowBufferF32){var e=ge(this.shadowBufferF32);e.length!==this.currentBufferWordSize&&(this.currentBufferWordSize=e.length,null!==this.buffer&&this.buffer.destroy(),this.buffer=this.device.createBuffer({viewOrSize:4*this.currentBufferWordSize,usage:q.UNIFORM,hint:Q.DYNAMIC}));var t=De(this.currentWordOffset,this.uniformBufferMaxPageWordSize);if(this.currentBufferWordSize<t)throw Error("Assert fail: wordCount [".concat(t,"] (").concat(this.currentWordOffset," aligned ").concat(this.uniformBufferMaxPageWordSize,") <= this.currentBufferWordSize [").concat(this.currentBufferWordSize,"]"));if(this.isSupportedUBO())ge(this.buffer).setSubData(0,this.shadowBufferU8,0,4*t);this.currentWordOffset=0}},e.prototype.destroy=function(){null!==this.buffer&&this.buffer.destroy(),this.shadowBufferF32=null,this.shadowBufferU8=null},e}();function Gn(e,t){return e+=t,e+=e<<10,(e+=e>>>6)>>>0}function kn(e){return e+=e<<3,e^=e>>>11,(e+=e<<15)>>>0}function Vn(e){return 0}var Xn=function(){this.keys=[],this.values=[]},Wn=function(){function e(e,t){this.keyEqualFunc=e,this.keyHashFunc=t,this.buckets=new Map}return e.prototype.findBucketIndex=function(e,t){for(var r=0;e.keys.length>r;r++)if(this.keyEqualFunc(t,e.keys[r]))return r;return-1},e.prototype.findBucket=function(e){var t=this.keyHashFunc(e);return this.buckets.get(t)},e.prototype.get=function(e){var t=this.findBucket(e);if(void 0===t)return null;var r=this.findBucketIndex(t,e);return 0>r?null:t.values[r]},e.prototype.add=function(e,t){var r=this.keyHashFunc(e);void 0===this.buckets.get(r)&&this.buckets.set(r,new Xn);var n=this.buckets.get(r);n.keys.push(e),n.values.push(t)},e.prototype.delete=function(e){var t=this.findBucket(e);if(void 0!==t){var r=this.findBucketIndex(t,e);-1!==r&&(t.keys.splice(r,1),t.values.splice(r,1))}},e.prototype.clear=function(){this.buckets.clear()},e.prototype.size=function(){var e,t,r=0;try{for(var n=l(this.buckets.values()),i=n.next();!i.done;i=n.next()){r+=i.value.values.length}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.values=function(){var e,t,r,n,i,o,a;return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,7,8,9]),e=l(this.buckets.values()),t=e.next(),s.label=1;case 1:if(t.done)return[3,6];n=(r=t.value).values.length-1,s.label=2;case 2:return n<0?[3,5]:[4,r.values[n]];case 3:s.sent(),s.label=4;case 4:return n--,[3,2];case 5:return t=e.next(),[3,1];case 6:return[3,9];case 7:return i=s.sent(),o={error:i},[3,9];case 8:try{t&&!t.done&&(a=e.return)&&a.call(e)}finally{if(o)throw o.error}return[7];case 9:return[2]}}))},e}();function Hn(e,t){var r=void 0!==t.defines?t.defines:null,n=void 0!==t.both?t.both+t.vert:t.vert,i=void 0!==t.both?t.both+t.frag:t.frag;return function(e,t,r,n){return void 0===n&&(n=null),{vert:t,frag:r,preprocessedVert:Lt(e,"vert",t,n),preprocessedFrag:Lt(e,"frag",r,n)}}(e.queryVendorInfo(),n,i,r)}function Yn(e,t){return Ae(""!==e.preprocessedVert&&""!==t.preprocessedVert),Ae(""!==e.preprocessedFrag&&""!==t.preprocessedFrag),e.preprocessedVert===t.preprocessedVert&&e.preprocessedFrag===t.preprocessedFrag}function zn(e,t){return e=Gn(e,t.blendMode),e=Gn(e,t.blendSrcFactor),e=Gn(e,t.blendDstFactor)}function Kn(e,t){return e=zn(e,t.rgbBlendState),e=Gn(e=zn(e,t.alphaBlendState),t.channelWriteMask)}function jn(e,t){for(var r,n,i,o,a,s,l,u,c=0;t.attachmentsState.length>c;c++)e=Kn(e,t.attachmentsState[c]);return e=function(e,t){return Gn(e,t.r<<24|t.g<<16|t.b<<8|t.a)}(e,t.blendConstant),e=Gn(e,t.depthCompare),e=Gn(e,t.depthWrite?1:0),e=Gn(e,null===(r=t.stencilFront)||void 0===r?void 0:r.compare),e=Gn(e,null===(n=t.stencilFront)||void 0===n?void 0:n.passOp),e=Gn(e,null===(i=t.stencilFront)||void 0===i?void 0:i.failOp),e=Gn(e,null===(o=t.stencilFront)||void 0===o?void 0:o.depthFailOp),e=Gn(e,null===(a=t.stencilBack)||void 0===a?void 0:a.compare),e=Gn(e,null===(s=t.stencilBack)||void 0===s?void 0:s.passOp),e=Gn(e,null===(l=t.stencilBack)||void 0===l?void 0:l.failOp),e=Gn(e,null===(u=t.stencilBack)||void 0===u?void 0:u.depthFailOp),e=Gn(e,t.stencilWrite?1:0),e=Gn(e,t.cullMode),e=Gn(e,t.frontFace?1:0),e=Gn(e,t.polygonOffset?1:0)}function Zn(e){var t=0;t=Gn(t,e.program.id),null!==e.inputLayout&&(t=Gn(t,e.inputLayout.id)),t=jn(t,e.megaStateDescriptor);for(var r=0;e.colorAttachmentFormats.length>r;r++)t=Gn(t,e.colorAttachmentFormats[r]||0);return kn(t=Gn(t,e.depthStencilAttachmentFormat||0))}function qn(e){for(var t=0,r=0;e.samplerBindings.length>r;r++){null!==(n=e.samplerBindings[r])&&null!==n.texture&&(t=Gn(t,n.texture.id))}for(r=0;e.uniformBufferBindings.length>r;r++){var n;null!==(n=e.uniformBufferBindings[r])&&null!==n.buffer&&(t=Gn(t,n.buffer.id),t=Gn(t,n.binding),t=Gn(t,n.offset),t=Gn(t,n.size))}return kn(t)}var Qn,$n,Jn=function(){function e(e){this.bindingsCache=new Wn(Je,qn),this.renderPipelinesCache=new Wn(ot,Zn),this.inputLayoutsCache=new Wn(lt,Vn),this.programCache=new Wn(Yn,Vn),this.samplerCache=new Wn(ut,Vn),this.device=e}return e.prototype.createBindings=function(e){var t,r=this.bindingsCache.get(e);if(null===r){var n={samplerBindings:(t=e).samplerBindings&&Ze(t.samplerBindings,ct),uniformBufferBindings:t.uniformBufferBindings&&Ze(t.uniformBufferBindings,ft),storageBufferBindings:t.storageBufferBindings&&Ze(t.storageBufferBindings,ft),storageTextureBindings:t.storageTextureBindings&&Ze(t.storageTextureBindings,dt),pipeline:t.pipeline};n.uniformBufferBindings=n.uniformBufferBindings.filter((function(e){return e.size>0})),r=this.device.createBindings(n),this.bindingsCache.add(n,r)}return r},e.prototype.createRenderPipeline=function(e){var t,r,n,i=this.renderPipelinesCache.get(e);if(null===i){var o=(r=(t=e).program,n=t.topology,{inputLayout:t.inputLayout,megaStateDescriptor:t.megaStateDescriptor&&Ve(t.megaStateDescriptor),program:r,topology:n,colorAttachmentFormats:t.colorAttachmentFormats.slice(),depthStencilAttachmentFormat:t.depthStencilAttachmentFormat,sampleCount:t.sampleCount});o.colorAttachmentFormats=o.colorAttachmentFormats.filter((function(e){return e})),i=this.device.createRenderPipeline(o),this.renderPipelinesCache.add(o,i)}return i},e.prototype.createInputLayout=function(e){e.vertexBufferDescriptors=e.vertexBufferDescriptors.filter((function(e){return!!e}));var t,r=this.inputLayoutsCache.get(e);if(null===r){var n={vertexBufferDescriptors:Ze((t=e).vertexBufferDescriptors,_t),indexBufferFormat:t.indexBufferFormat,program:t.program};r=this.device.createInputLayout(n),this.inputLayoutsCache.add(n,r)}return r},e.prototype.createProgramSimple=function(e){var t,r=e.vert,n=e.preprocessedFrag,i=e.preprocessedVert,o=null;if(i&&n&&(o=this.programCache.get({vert:r,frag:e.frag,preprocessedFrag:n,preprocessedVert:i})),null===o){var a=Hn(this.device,e),s=a.preprocessedVert,l=a.preprocessedFrag;e.preprocessedVert=s,e.preprocessedFrag=l;var u={preprocessedVert:(t=e).preprocessedVert,preprocessedFrag:t.preprocessedFrag,vert:t.vert,frag:t.frag};o=this.device.createProgramSimple({vertex:{glsl:s},fragment:{glsl:l}},r),this.programCache.add(u,o)}return o},e.prototype.createSampler=function(e){var t=this.samplerCache.get(e);return null===t&&(t=this.device.createSampler(e),this.samplerCache.add(e,t)),t},e.prototype.destroy=function(){var e,t,r,n,i,o,a,s,u,c;try{for(var f=l(this.bindingsCache.values()),d=f.next();!d.done;d=f.next()){d.value.destroy()}}catch(t){e={error:t}}finally{try{d&&!d.done&&(t=f.return)&&t.call(f)}finally{if(e)throw e.error}}try{for(var p=l(this.renderPipelinesCache.values()),_=p.next();!_.done;_=p.next()){_.value.destroy()}}catch(e){r={error:e}}finally{try{_&&!_.done&&(n=p.return)&&n.call(p)}finally{if(r)throw r.error}}try{for(var h=l(this.inputLayoutsCache.values()),E=h.next();!E.done;E=h.next()){E.value.destroy()}}catch(e){i={error:e}}finally{try{E&&!E.done&&(o=h.return)&&o.call(h)}finally{if(i)throw i.error}}try{for(var R=l(this.programCache.values()),v=R.next();!v.done;v=R.next()){v.value.destroy()}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=R.return)&&s.call(R)}finally{if(a)throw a.error}}try{for(var T=l(this.samplerCache.values()),m=T.next();!m.done;m=T.next()){m.value.destroy()}}catch(e){u={error:e}}finally{try{m&&!m.done&&(c=T.return)&&c.call(T)}finally{if(u)throw u.error}}this.bindingsCache.clear(),this.renderPipelinesCache.clear(),this.inputLayoutsCache.clear(),this.programCache.clear(),this.samplerCache.clear()},e}();!function(e){e.NONE="none",e.LINEAR="LinearToneMapping",e.REINHARD="ReinhardToneMapping",e.CINEON="OptimizedCineonToneMapping",e.ACES_FILMIC="ACESFilmicToneMapping",e.CUSTOM="CustomToneMapping"}(Qn||(Qn={})),function(e){e[e.Color0=0]="Color0",e[e.Color1=1]="Color1",e[e.Color2=2]="Color2",e[e.Color3=3]="Color3",e[e.ColorMax=3]="ColorMax",e[e.DepthStencil=4]="DepthStencil"}($n||($n={}));var ei,ti=function(){function e(){this.renderTargetIDs=[],this.renderTargetLevels=[],this.resolveTextureOutputIDs=[],this.resolveTextureOutputExternalTextures=[],this.resolveTextureOutputExternalTextureLevel=[],this.resolveTextureInputIDs=[],this.renderTargetExtraRefs=[],this.resolveTextureInputTextures=[],this.renderTargets=[],this.descriptor={colorAttachment:[],colorAttachmentLevel:[],colorResolveTo:[],colorResolveToLevel:[],colorStore:[],depthStencilAttachment:null,depthStencilResolveTo:null,depthStencilStore:!0,colorClearColor:["load"],depthClearValue:"load",stencilClearValue:"load",occlusionQueryPool:null},this.viewportX=0,this.viewportY=0,this.viewportW=1,this.viewportH=1,this.execFunc=null,this.postFunc=null,this.debugThumbnails=[]}return e.prototype.setDebugName=function(e){this.debugName=e},e.prototype.pushDebugThumbnail=function(e){this.debugThumbnails[e]=!0},e.prototype.setViewport=function(e,t,r,n){this.viewportX=e,this.viewportY=t,this.viewportW=r,this.viewportH=n},e.prototype.attachRenderTargetID=function(e,t,r){void 0===r&&(r=0),Ae(void 0===this.renderTargetIDs[e]),this.renderTargetIDs[e]=t,this.renderTargetLevels[e]=r},e.prototype.attachResolveTexture=function(e){this.resolveTextureInputIDs.push(e)},e.prototype.attachOcclusionQueryPool=function(e){this.descriptor.occlusionQueryPool=e},e.prototype.exec=function(e){Ae(null===this.execFunc),this.execFunc=e},e.prototype.post=function(e){Ae(null===this.postFunc),this.postFunc=e},e.prototype.addExtraRef=function(e){this.renderTargetExtraRefs[e]=!0},e}(),ri=function(){function e(e,t){this.dimension=ee.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.width=0,this.height=0,this.sampleCount=0,this.usage=te.RENDER_TARGET,this.needsClear=!0,this.texture=null,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.sampleCount=t.sampleCount,Ae(this.sampleCount>=1),this.sampleCount>1?this.attachment=e.createRenderTarget(this):(this.texture=e.createTexture(this),this.attachment=e.createRenderTargetFromTexture(this.texture))}return e.prototype.setDebugName=function(e,t){this.debugName=t,null!==this.texture&&e.setResourceName(this.texture,this.debugName),e.setResourceName(this.attachment,this.debugName)},e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height&&this.sampleCount===e.sampleCount},e.prototype.reset=function(e){Ae(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.attachment.destroy()},e}(),ni=function(){function e(e,t){this.dimension=ee.TEXTURE_2D,this.depthOrArrayLayers=1,this.mipLevelCount=1,this.usage=te.RENDER_TARGET,this.width=0,this.height=0,this.age=0,this.format=t.format,this.width=t.width,this.height=t.height,this.texture=e.createTexture(this)}return e.prototype.matchesDescription=function(e){return this.format===e.format&&this.width===e.width&&this.height===e.height},e.prototype.reset=function(e){Ae(this.matchesDescription(e)),this.age=0},e.prototype.destroy=function(){this.texture.destroy()},e}(),ii=function(){this.renderTargetDescriptions=[],this.resolveTextureRenderTargetIDs=[],this.passes=[],this.renderTargetDebugNames=[]},oi=function(){function e(e){this.currentPass=null,this.renderTargetDeadPool=[],this.singleSampledTextureDeadPool=[],this.currentGraph=null,this.renderTargetOutputCount=[],this.renderTargetResolveCount=[],this.resolveTextureUseCount=[],this.renderTargetAliveForID=[],this.singleSampledTextureForResolveTextureID=[],this.device=e}return e.prototype.acquireRenderTargetForDescription=function(e){for(var t=0;this.renderTargetDeadPool.length>t;t++){var r=this.renderTargetDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.renderTargetDeadPool.splice(t--,1),r}return new ri(this.device,e)},e.prototype.acquireSingleSampledTextureForDescription=function(e){for(var t=0;this.singleSampledTextureDeadPool.length>t;t++){var r=this.singleSampledTextureDeadPool[t];if(r.matchesDescription(e))return r.reset(e),this.singleSampledTextureDeadPool.splice(t--,1),r}return new ni(this.device,e)},e.prototype.beginGraphBuilder=function(){Ae(null===this.currentGraph),this.currentGraph=new ii},e.prototype.pushPass=function(e){var t=new ti;e(t),this.currentGraph.passes.push(t)},e.prototype.createRenderTargetID=function(e,t){return this.currentGraph.renderTargetDebugNames.push(t),this.currentGraph.renderTargetDescriptions.push(e)-1},e.prototype.createResolveTextureID=function(e){return this.currentGraph.resolveTextureRenderTargetIDs.push(e)-1},e.prototype.findMostRecentPassThatAttachedRenderTarget=function(e){for(var t=this.currentGraph.passes.length-1;t>=0;t--){var r=this.currentGraph.passes[t];if(r.renderTargetIDs.includes(e))return r}return null},e.prototype.resolveRenderTargetPassAttachmentSlot=function(e,t){var r=e;if(void 0===r.resolveTextureOutputIDs[t]){var n=this.createResolveTextureID(r.renderTargetIDs[t]);r.resolveTextureOutputIDs[t]=n}return r.resolveTextureOutputIDs[t]},e.prototype.findPassForResolveRenderTarget=function(e){var t=ge(this.findMostRecentPassThatAttachedRenderTarget(e)),r=t.renderTargetIDs.indexOf(e);return Ae(void 0===t.resolveTextureOutputExternalTextures[r]),t},e.prototype.resolveRenderTarget=function(e){var t=this.findPassForResolveRenderTarget(e),r=t.renderTargetIDs.indexOf(e);return this.resolveRenderTargetPassAttachmentSlot(t,r)},e.prototype.resolveRenderTargetToExternalTexture=function(e,t,r){void 0===r&&(r=0);var n=this.findPassForResolveRenderTarget(e),i=n.renderTargetIDs.indexOf(e);Ae(void 0===n.resolveTextureOutputIDs[i]),n.resolveTextureOutputExternalTextures[i]=t,n.resolveTextureOutputExternalTextureLevel[i]=r},e.prototype.getRenderTargetDescription=function(e){return ge(this.currentGraph.renderTargetDescriptions[e])},e.prototype.scheduleAddUseCount=function(e,t){for(var r=0;t.renderTargetIDs.length>r;r++){void 0!==(i=t.renderTargetIDs[r])&&(this.renderTargetOutputCount[i]++,t.renderTargetExtraRefs[r]&&this.renderTargetOutputCount[i]++)}for(var n=0;t.resolveTextureInputIDs.length>n;n++){var i,o=t.resolveTextureInputIDs[n];if(void 0!==o)this.resolveTextureUseCount[o]++,this.renderTargetResolveCount[i=e.resolveTextureRenderTargetIDs[o]]++}},e.prototype.acquireRenderTargetForID=function(e,t){if(void 0===t)return null;if(Ae(this.renderTargetOutputCount[t]>0),!this.renderTargetAliveForID[t]){var r=this.acquireRenderTargetForDescription(e.renderTargetDescriptions[t]);r.setDebugName(this.device,e.renderTargetDebugNames[t]),this.renderTargetAliveForID[t]=r}return this.renderTargetAliveForID[t]},e.prototype.releaseRenderTargetForID=function(e,t){if(void 0===e)return null;var r=ge(this.renderTargetAliveForID[e]);return t?(Ae(this.renderTargetOutputCount[e]>0),this.renderTargetOutputCount[e]--):(Ae(this.renderTargetResolveCount[e]>0),this.renderTargetResolveCount[e]--),0===this.renderTargetOutputCount[e]&&0===this.renderTargetResolveCount[e]&&(r.needsClear=!0,delete this.renderTargetAliveForID[e],this.renderTargetDeadPool.push(r)),r},e.prototype.acquireResolveTextureInputTextureForID=function(e,t){var r=e.resolveTextureRenderTargetIDs[t];Ae(this.resolveTextureUseCount[t]>0),this.resolveTextureUseCount[t]--;var n=ge(this.releaseRenderTargetForID(r,!1));if(void 0!==this.singleSampledTextureForResolveTextureID[t]){var i=this.singleSampledTextureForResolveTextureID[t];return 0===this.resolveTextureUseCount[t]&&this.singleSampledTextureDeadPool.push(i),i.texture}return ge(n.texture)},e.prototype.determineResolveParam=function(e,t,r){var n=t.renderTargetIDs[r],i=t.resolveTextureOutputIDs[r],o=t.resolveTextureOutputExternalTextures[r],a=void 0!==i,s=void 0!==o;Ae(!(a&&s));var l=null,u=!1,c=0;if(this.renderTargetOutputCount[n]>1&&(u=!0),a){Ae(e.resolveTextureRenderTargetIDs[i]===n),Ae(this.resolveTextureUseCount[i]>0),Ae(this.renderTargetOutputCount[n]>0);var f=ge(this.renderTargetAliveForID[n]);if(null!==f.texture&&1===this.renderTargetOutputCount[n])l=null,u=!0;else{if(!this.singleSampledTextureForResolveTextureID[i]){var d=ge(e.renderTargetDescriptions[n]);this.singleSampledTextureForResolveTextureID[i]=this.acquireSingleSampledTextureForDescription(d),this.device.setResourceName(this.singleSampledTextureForResolveTextureID[i].texture,f.debugName+" (Resolve ".concat(i,")"))}l=this.singleSampledTextureForResolveTextureID[i].texture}}else s?(l=o,c=t.resolveTextureOutputExternalTextureLevel[r]):l=null;return{resolveTo:l,store:u,level:c}},e.prototype.schedulePass=function(e,t){for(var r=t.renderTargetIDs[$n.DepthStencil],n=$n.Color0;$n.ColorMax>=n;n++){var i=t.renderTargetIDs[n],o=this.acquireRenderTargetForID(e,i);t.renderTargets[n]=o,t.descriptor.colorAttachment[n]=null!==o?o.attachment:null,t.descriptor.colorAttachmentLevel[n]=t.renderTargetLevels[n];var a=this.determineResolveParam(e,t,n),s=a.store,l=a.level;t.descriptor.colorResolveTo[n]=a.resolveTo,t.descriptor.colorResolveToLevel[n]=l,t.descriptor.colorStore[n]=s,t.descriptor.colorClearColor[n]=null!==o&&o.needsClear?e.renderTargetDescriptions[i].colorClearColor:"load"}var u=this.acquireRenderTargetForID(e,r);t.renderTargets[$n.DepthStencil]=u,t.descriptor.depthStencilAttachment=null!==u?u.attachment:null;var c=this.determineResolveParam(e,t,$n.DepthStencil),f=c.store;t.descriptor.depthStencilResolveTo=c.resolveTo,t.descriptor.depthStencilStore=f,t.descriptor.depthClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].depthClearValue:"load",t.descriptor.stencilClearValue=null!==u&&u.needsClear?e.renderTargetDescriptions[r].stencilClearValue:"load";for(var d=0,p=0,_=0,h=0;t.renderTargets.length>h;h++){var E=t.renderTargets[h];if(E){var R=E.width>>>t.renderTargetLevels[h],v=E.height>>>t.renderTargetLevels[h];0===d&&(d=R,p=v,_=E.sampleCount),Ae(R===d),Ae(v===p),Ae(E.sampleCount===_),E.needsClear=!1}}d>0&&p>0&&(t.viewportX*=d,t.viewportY*=p,t.viewportW*=d,t.viewportH*=p);for(h=0;t.resolveTextureInputIDs.length>h;h++){t.resolveTextureInputTextures[h]=this.acquireResolveTextureInputTextureForID(e,t.resolveTextureInputIDs[h])}for(h=0;t.renderTargetIDs.length>h;h++)this.releaseRenderTargetForID(t.renderTargetIDs[h],!0);for(n=0;t.renderTargetExtraRefs.length>n;n++)t.renderTargetExtraRefs[n]&&this.releaseRenderTargetForID(t.renderTargetIDs[n],!0)},e.prototype.scheduleGraph=function(e){Ae(0===this.renderTargetOutputCount.length),Ae(0===this.renderTargetResolveCount.length),Ae(0===this.resolveTextureUseCount.length);for(var t=0;this.renderTargetDeadPool.length>t;t++)this.renderTargetDeadPool[t].age++;for(t=0;this.singleSampledTextureDeadPool.length>t;t++)this.singleSampledTextureDeadPool[t].age++;xe(this.renderTargetOutputCount,e.renderTargetDescriptions.length,0),xe(this.renderTargetResolveCount,e.renderTargetDescriptions.length,0),xe(this.resolveTextureUseCount,e.resolveTextureRenderTargetIDs.length,0);for(t=0;e.passes.length>t;t++)this.scheduleAddUseCount(e,e.passes[t]);for(t=0;e.passes.length>t;t++)this.schedulePass(e,e.passes[t]);for(t=0;this.renderTargetOutputCount.length>t;t++)Ae(0===this.renderTargetOutputCount[t]);for(t=0;this.renderTargetResolveCount.length>t;t++)Ae(0===this.renderTargetResolveCount[t]);for(t=0;this.resolveTextureUseCount.length>t;t++)Ae(0===this.resolveTextureUseCount[t]);for(t=0;this.renderTargetAliveForID.length>t;t++)Ae(void 0===this.renderTargetAliveForID[t]);for(t=0;this.renderTargetDeadPool.length>t;t++)1>this.renderTargetDeadPool[t].age||(this.renderTargetDeadPool[t].destroy(),this.renderTargetDeadPool.splice(t--,1));for(t=0;this.singleSampledTextureDeadPool.length>t;t++)1>this.singleSampledTextureDeadPool[t].age||(this.singleSampledTextureDeadPool[t].destroy(),this.singleSampledTextureDeadPool.splice(t--,1));this.renderTargetResolveCount.length=0,this.renderTargetOutputCount.length=0,this.resolveTextureUseCount.length=0},e.prototype.execPass=function(e){Ae(null===this.currentPass),this.currentPass=e;var t=this.device.createRenderPass(e.descriptor);t.pushDebugGroup(e.debugName),t.setViewport(e.viewportX,e.viewportY,e.viewportW,e.viewportH),null!==e.execFunc&&e.execFunc(t,this),t.popDebugGroup(),this.device.submitPass(t),null!==e.postFunc&&e.postFunc(this),this.currentPass=null},e.prototype.execGraph=function(e){var t=this;this.scheduleGraph(e),this.device.beginFrame(),e.passes.forEach((function(e){t.execPass(e)})),this.device.endFrame(),this.singleSampledTextureForResolveTextureID.length=0},e.prototype.execute=function(){var e=ge(this.currentGraph);this.execGraph(e),this.currentGraph=null},e.prototype.getDebug=function(){return this},e.prototype.getPasses=function(){return this.currentGraph.passes},e.prototype.getPassDebugThumbnails=function(e){return e.debugThumbnails},e.prototype.getPassRenderTargetID=function(e,t){return e.renderTargetIDs[t]},e.prototype.getRenderTargetIDDebugName=function(e){return this.currentGraph.renderTargetDebugNames[e]},e.prototype.getResolveTextureForID=function(e){var t=this.currentPass,r=t.resolveTextureInputIDs.indexOf(e);return Ae(r>=0),ge(t.resolveTextureInputTextures[r])},e.prototype.getRenderTargetAttachment=function(e){var t=this.currentPass.renderTargets[e];return t?t.attachment:null},e.prototype.getRenderTargetTexture=function(e){var t=this.currentPass.renderTargets[e];return t?t.texture:null},e.prototype.newGraphBuilder=function(){return this.beginGraphBuilder(),this},e.prototype.destroy=function(){for(var e=0;this.renderTargetAliveForID.length>e;e++)Ae(void 0===this.renderTargetAliveForID[e]);for(e=0;this.singleSampledTextureForResolveTextureID.length>e;e++)Ae(void 0===this.singleSampledTextureForResolveTextureID[e]);for(e=0;this.renderTargetDeadPool.length>e;e++)this.renderTargetDeadPool[e].destroy();for(e=0;this.singleSampledTextureDeadPool.length>e;e++)this.singleSampledTextureDeadPool[e].destroy()},e}();!function(e){e[e.BACKGROUND=0]="BACKGROUND",e[e.ALPHA_TEST=16]="ALPHA_TEST",e[e.OPAQUE=32]="OPAQUE",e[e.TRANSLUCENT=128]="TRANSLUCENT"}(ei||(ei={}));var ai=65536,si=16;function li(e,t,r){void 0===r&&(r=ai);var n=h(e,0,r)/r;return t&&(n=1-n),65535&n*((1<<si)-1)}function ui(e,t){return(16777215&e|(255&t)<<24)>>>0}function ci(e,t){return!!(e>>>31&1)?e:(4278190335&e|(65535&t)<<8)>>>0}function fi(e,t){return ui(ci(0,t),e)}function di(e,t){return Ae(t>=0),(4294967040&e|t>>>8&255)>>>0}function pi(e){return ui(0,e)}function _i(e,t){return Ae(t>=0),(4278190335&e|t<<8)>>>0}var hi=A(1,0,0,0,0,1,0,0,0,0,2,0,0,0,-1,1);var Ei,Ri=A(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1);function vi(e,t,r,n,i,o){return void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=0),e[t+0]=r,e[t+1]=n,e[t+2]=i,e[t+3]=o,4}!function(e){e[e.None=0]="None",e[e.Indexed=1]="Indexed",e[e.AllowSkippingIfPipelineNotReady=2]="AllowSkippingIfPipelineNotReady",e[e.Template=4]="Template",e[e.Draw=8]="Draw",e[e.InheritedFlags=3]="InheritedFlags"}(Ei||(Ei={}));var Ti,mi=function(){function e(){this.sortKey=0,this.debug=null,this.uniforms=[],this.bindingDescriptors=Le(1,(function(){return{bindingLayout:null,samplerBindings:[],uniformBufferBindings:[]}})),this.dynamicUniformBufferByteOffsets=Le(4,(function(){return 0})),this.flags=0,this.vertexBuffers=null,this.indexBuffer=null,this.drawStart=0,this.drawCount=0,this.drawInstanceCount=0,this.renderPipelineDescriptor={inputLayout:null,megaStateDescriptor:Ve(We),program:null,topology:Z.TRIANGLES,colorAttachmentFormats:[],depthStencilAttachmentFormat:null,sampleCount:1},this.reset()}return e.prototype.reset=function(){this.sortKey=0,this.flags=Ei.AllowSkippingIfPipelineNotReady,this.vertexBuffers=null,this.indexBuffer=null,this.renderPipelineDescriptor.inputLayout=null},e.prototype.setFromTemplate=function(e){var t,r;ke(this.renderPipelineDescriptor.megaStateDescriptor,e.renderPipelineDescriptor.megaStateDescriptor),this.renderPipelineDescriptor.program=e.renderPipelineDescriptor.program,this.renderPipelineDescriptor.inputLayout=e.renderPipelineDescriptor.inputLayout,this.renderPipelineDescriptor.topology=e.renderPipelineDescriptor.topology,this.renderPipelineDescriptor.colorAttachmentFormats.length=Math.max(this.renderPipelineDescriptor.colorAttachmentFormats.length,e.renderPipelineDescriptor.colorAttachmentFormats.length);for(var n=0;e.renderPipelineDescriptor.colorAttachmentFormats.length>n;n++)this.renderPipelineDescriptor.colorAttachmentFormats[n]=e.renderPipelineDescriptor.colorAttachmentFormats[n];this.renderPipelineDescriptor.depthStencilAttachmentFormat=e.renderPipelineDescriptor.depthStencilAttachmentFormat,this.renderPipelineDescriptor.sampleCount=e.renderPipelineDescriptor.sampleCount,this.uniformBuffer=e.uniformBuffer,this.uniforms=c([],u(e.uniforms),!1),this.drawCount=e.drawCount,this.drawStart=e.drawStart,this.drawInstanceCount=e.drawInstanceCount,this.vertexBuffers=e.vertexBuffers,this.indexBuffer=e.indexBuffer,this.flags=this.flags&~Ei.InheritedFlags|e.flags&Ei.InheritedFlags,this.sortKey=e.sortKey;var i=this.bindingDescriptors[0],o=e.bindingDescriptors[0];this.setBindingLayout({numSamplers:null===(t=o.samplerBindings)||void 0===t?void 0:t.length,numUniformBuffers:null===(r=o.uniformBufferBindings)||void 0===r?void 0:r.length});for(n=0;Math.min(i.uniformBufferBindings.length,o.uniformBufferBindings.length)>n;n++)i.uniformBufferBindings[n].size=e.bindingDescriptors[0].uniformBufferBindings[n].size;this.setSamplerBindingsFromTextureMappings(o.samplerBindings);for(n=0;e.dynamicUniformBufferByteOffsets.length>n;n++)this.dynamicUniformBufferByteOffsets[n]=e.dynamicUniformBufferByteOffsets[n]},e.prototype.validate=function(){for(var e,t=0;this.bindingDescriptors.length>t;t++)for(var r=this.bindingDescriptors[t],n=0;n<(null===(e=r.uniformBufferBindings)||void 0===e?void 0:e.length);n++)Ae(r.uniformBufferBindings[n].size>0);Ae(this.drawCount>0)},e.prototype.setProgram=function(e){this.renderPipelineDescriptor.program=e},e.prototype.setMegaStateFlags=function(e){return ke(this.renderPipelineDescriptor.megaStateDescriptor,e),this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.getMegaStateFlags=function(){return this.renderPipelineDescriptor.megaStateDescriptor},e.prototype.setVertexInput=function(e,t,r){this.vertexBuffers=t,this.indexBuffer=r,this.renderPipelineDescriptor.inputLayout=e},e.prototype.setBindingLayout=function(e){Ae(this.dynamicUniformBufferByteOffsets.length>e.numUniformBuffers);for(var t=this.bindingDescriptors[0].uniformBufferBindings.length;e.numUniformBuffers>t;t++)this.bindingDescriptors[0].uniformBufferBindings.push({binding:t,buffer:null,size:0});for(t=this.bindingDescriptors[0].samplerBindings.length;e.numSamplers>t;t++)this.bindingDescriptors[0].samplerBindings.push({sampler:null,texture:null})},e.prototype.drawIndexes=function(e,t){void 0===t&&(t=0),this.flags=be(this.flags,Ei.Indexed,!0),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.drawIndexesInstanced=function(e,t,r){void 0===r&&(r=0),this.flags=be(this.flags,Ei.Indexed,!0),this.drawCount=e,this.drawStart=r,this.drawInstanceCount=t},e.prototype.drawPrimitives=function(e,t){void 0===t&&(t=0),this.flags=be(this.flags,Ei.Indexed,!1),this.drawCount=e,this.drawStart=t,this.drawInstanceCount=1},e.prototype.setUniforms=function(e,t){if(0!==t.length){this.uniforms[e]=t;var r=0,n=[];t.forEach((function(e){var t=e.value;if(E(t)||Array.isArray(t)||t instanceof Float32Array){var i=E(t)?[t]:t,o=4-r%4;if(4!==o)if(o<(i.length>4?4:i.length)){r+=o;for(var a=0;o>a;a++)n.push(0)}else;r+=i.length,n.push.apply(n,c([],u(i),!1))}}));var i=4-n.length%4;if(4!==i)for(var o=0;i>o;o++)n.push(0);for(var a=this.allocateUniformBuffer(e,n.length),s=this.mapUniformBufferF32(e),l=0;n.length>l;l+=4)a+=vi(s,a,n[l],n[l+1],n[l+2],n[l+3])}},e.prototype.setUniformBuffer=function(e){this.uniformBuffer=e},e.prototype.allocateUniformBuffer=function(e,t){var r;return Ae((null===(r=this.bindingDescriptors[0].uniformBufferBindings)||void 0===r?void 0:r.length)<this.dynamicUniformBufferByteOffsets.length),this.dynamicUniformBufferByteOffsets[e]=this.uniformBuffer.allocateChunk(t)<<2,this.bindingDescriptors[0].uniformBufferBindings[e].size=t<<2,this.getUniformBufferOffset(e)},e.prototype.getUniformBufferOffset=function(e){return this.dynamicUniformBufferByteOffsets[e]>>>2},e.prototype.mapUniformBufferF32=function(e){return this.uniformBuffer.mapBufferF32()},e.prototype.getUniformBuffer=function(){return this.uniformBuffer},e.prototype.setSamplerBindingsFromTextureMappings=function(e){e=e.filter((function(e){return e}));for(var t=0;this.bindingDescriptors[0].samplerBindings.length>t;t++){var r=this.bindingDescriptors[0].samplerBindings[t],n=e[t];null!=n?(r.texture=n.texture,r.sampler=n.sampler):(r.texture=null,r.sampler=null)}},e.prototype.setAllowSkippingIfPipelineNotReady=function(e){this.flags=be(this.flags,Ei.AllowSkippingIfPipelineNotReady,e)},e.prototype.setAttachmentFormatsFromRenderPass=function(e,t){for(var r=e.queryRenderPass(t),n=-1,i=0;r.colorAttachment.length>i;i++){var o=null!==r.colorAttachment[i]?e.queryRenderTarget(r.colorAttachment[i]):null;this.renderPipelineDescriptor.colorAttachmentFormats[i]=null!==o?o.format:null,null!==o&&(-1===n?n=o.sampleCount:Ae(n===o.sampleCount))}var a=null!==r.depthStencilAttachment?e.queryRenderTarget(r.depthStencilAttachment):null;this.renderPipelineDescriptor.depthStencilAttachmentFormat=null!==a?a.format:null,null!==a&&(-1===n?n=a.sampleCount:Ae(n==a.sampleCount)),Ae(n>0),this.renderPipelineDescriptor.sampleCount=n},e.prototype.drawOnPass=function(e,t){var r=this,n=e.device;this.setAttachmentFormatsFromRenderPass(n,t);var o=e.createRenderPipeline(this.renderPipelineDescriptor);if(!n.pipelineQueryReady(o)){if(this.flags&Ei.AllowSkippingIfPipelineNotReady)return!1;n.pipelineForceReady(o)}t.setPipeline(o),t.setVertexInput(this.renderPipelineDescriptor.inputLayout,this.vertexBuffers,this.indexBuffer);for(var a=0;this.bindingDescriptors[0].uniformBufferBindings.length>a;a++)this.bindingDescriptors[0].uniformBufferBindings[a].buffer=ge(this.uniformBuffer.buffer),this.bindingDescriptors[0].uniformBufferBindings[a].offset=this.dynamicUniformBufferByteOffsets[a];this.renderPipelineDescriptor.program.gl_program&&this.uniforms.forEach((function(e){var t={};e.forEach((function(e){t[e.name]=e.value})),r.renderPipelineDescriptor.program.setUniformsLegacy(t)}));var s=e.createBindings(i(i({},this.bindingDescriptors[0]),{pipeline:o}));return t.setBindings(s),this.flags&Ei.Indexed?t.drawIndexed(this.drawCount,this.drawInstanceCount,this.drawStart,0,0):t.draw(this.drawCount,this.drawInstanceCount,this.drawStart,0),!0},e}();function Ai(e,t){return e.sortKey-t.sortKey}!function(e){e[e.Forwards=0]="Forwards",e[e.Backwards=1]="Backwards"}(Ti||(Ti={}));var gi=function(){function e(e,t){void 0===e&&(e=Ai),void 0===t&&(t=Ti.Forwards),this.renderInsts=[],this.usePostSort=!1,this.compareFunction=e,this.executionOrder=t}return e.prototype.checkUsePostSort=function(){this.usePostSort=null!==this.compareFunction&&this.renderInsts.length>=500},e.prototype.insertSorted=function(e){var t,r,n;null===this.compareFunction||this.usePostSort?this.renderInsts.push(e):(n=function(e,t,r){for(var n=0,i=e.length;i>n;){var o=n+(i-n>>>1);0>r(t,e[o])?i=o:n=o+1}return n}(t=this.renderInsts,r=e,this.compareFunction),t.splice(n,0,r)),this.checkUsePostSort()},e.prototype.submitRenderInst=function(e){e.flags|=Ei.Draw,this.insertSorted(e)},e.prototype.ensureSorted=function(){this.usePostSort&&(0!==this.renderInsts.length&&this.renderInsts.sort(this.compareFunction),this.usePostSort=!1)},e.prototype.drawOnPassRendererNoReset=function(e,t){if(this.ensureSorted(),this.executionOrder===Ti.Forwards)for(var r=0;this.renderInsts.length>r;r++)this.renderInsts[r].drawOnPass(e,t);else for(r=this.renderInsts.length-1;r>=0;r--)this.renderInsts[r].drawOnPass(e,t)},e.prototype.reset=function(){this.renderInsts.length=0},e.prototype.drawOnPassRenderer=function(e,t){this.drawOnPassRendererNoReset(e,t),this.reset()},e}(),yi=function(){function e(){this.pool=[],this.allocCount=0}return e.prototype.allocRenderInstIndex=function(){return this.allocCount++,this.allocCount>this.pool.length&&this.pool.push(new mi),this.allocCount-1},e.prototype.popRenderInst=function(){this.allocCount--},e.prototype.reset=function(){for(var e=0;this.pool.length>e;e++)this.pool[e].reset();this.allocCount=0},e.prototype.destroy=function(){this.pool.length=0,this.allocCount=0},e}(),Si=function(){function e(e){this.renderCache=e,this.instPool=new yi,this.templatePool=new yi,this.simpleRenderInstList=new gi,this.currentRenderInstList=this.simpleRenderInstList}return e.prototype.newRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.instPool.allocRenderInstIndex(),r=this.instPool.pool[t];return r.debug=null,0>e||r.setFromTemplate(this.templatePool.pool[e]),r},e.prototype.submitRenderInst=function(e,t){void 0===t&&(t=this.currentRenderInstList),t.submitRenderInst(e)},e.prototype.setCurrentRenderInstList=function(e){Ae(null===this.simpleRenderInstList),this.currentRenderInstList=e},e.prototype.pushTemplateRenderInst=function(){var e=this.templatePool.allocCount-1,t=this.templatePool.allocRenderInstIndex(),r=this.templatePool.pool[t];return 0>e||r.setFromTemplate(this.templatePool.pool[e]),r.flags|=Ei.Template,r},e.prototype.popTemplateRenderInst=function(){this.templatePool.popRenderInst()},e.prototype.getTemplateRenderInst=function(){return this.templatePool.pool[this.templatePool.allocCount-1]},e.prototype.resetRenderInsts=function(){this.instPool.reset(),null!==this.simpleRenderInstList&&this.simpleRenderInstList.reset(),Ae(0===this.templatePool.allocCount)},e.prototype.destroy=function(){this.instPool.destroy(),this.renderCache.destroy()},e.prototype.disableSimpleMode=function(){this.simpleRenderInstList=null},e.prototype.drawOnPassRenderer=function(e){ge(this.simpleRenderInstList).drawOnPassRenderer(this.renderCache,e)},e.prototype.drawOnPassRendererNoReset=function(e){ge(this.simpleRenderInstList).drawOnPassRendererNoReset(this.renderCache,e)},e}(),Ci=function(){function e(e){this.parameters=e}return e.prototype.getDevice=function(){return this.device},e.prototype.setDevice=function(e){this.device=e,this.renderCache=new Jn(e),this.renderGraph=new oi(this.device),this.renderInstManager=new Si(this.renderCache),this.uniformBuffer=new wn(this.device)},e.prototype.pushTemplateRenderInst=function(){var e=this.renderInstManager.pushTemplateRenderInst();return e.setUniformBuffer(this.uniformBuffer),e},e.prototype.prepareToRender=function(){this.uniformBuffer.prepareToRender()},e.prototype.destroy=function(){this.uniformBuffer&&this.uniformBuffer.destroy(),this.renderInstManager&&this.renderInstManager.destroy(),this.renderCache&&this.renderCache.destroy(),this.renderGraph&&this.renderGraph.destroy()},e.prototype.getCache=function(){return this.renderCache},e.prototype.getDefines=function(){var e,t,r;return{USE_TONEMAPPING:(null===(e=this.parameters)||void 0===e?void 0:e.toneMapping)&&(null===(t=this.parameters)||void 0===t?void 0:t.toneMapping)!==Qn.NONE,toneMapping:null===(r=this.parameters)||void 0===r?void 0:r.toneMapping}},e}(),Pi=function(){function e(e){this.format=e,this.width=0,this.height=0,this.sampleCount=0,this.colorClearColor="load",this.depthClearValue="load",this.stencilClearValue="load"}return e.prototype.setDimensions=function(e,t,r){this.width=e,this.height=t,this.sampleCount=r},e.prototype.copyDimensions=function(e){this.width=e.width,this.height=e.height,this.sampleCount=e.sampleCount},e}();function Ni(e){return{colorClearColor:e,depthClearValue:1,stencilClearValue:0}}var Mi,Ii=Ni(Se(.88,.88,.88,1)),Oi=Ni(Pe),xi=Ni(Me);function Bi(e,t){var r=function(e){return e.antialiasingMode===Mi.MSAAx4?4:1}(t);e.setDimensions(t.backbufferWidth,t.backbufferHeight,r)}function Di(e,t,r){var n=function(e){if(e===$n.Color0)return fe.U8_RGBA_RT;if(e===$n.DepthStencil)return fe.D24_S8;throw Error("whoops")}(e),i=new Pi(n);return Bi(i,t),null!==r&&(i.colorClearColor=r.colorClearColor,i.depthClearValue=r.depthClearValue,i.stencilClearValue=r.stencilClearValue),i}!function(e){e[e.None=0]="None",e[e.FXAA=1]="FXAA",e[e.MSAAx4=2]="MSAAx4"}(Mi||(Mi={}));var bi,Li=function(){function e(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0}return e.prototype.reset=function(){this.texture=null,this.sampler=null,this.width=0,this.height=0,this.lodBias=0},e.prototype.copy=function(e){this.texture=e.texture,this.sampler=e.sampler,this.width=e.width,this.height=e.height,this.lodBias=e.lodBias},e}(),Fi=function(){function e(){this.inputTexture=null,this.outputTexture=null}return e.prototype.setDescription=function(e,t){this.inputTexture!==this.outputTexture&&(null!==this.inputTexture&&this.inputTexture.destroy(),this.inputTexture=this.outputTexture),Ae(this.inputTexture===this.outputTexture),null!==this.outputTexture&&this.outputTexture.matchesDescription(t)||(this.outputTexture=new ni(e,t),null===this.inputTexture&&(this.inputTexture=this.outputTexture))},e.prototype.getTextureForSampling=function(){return null!==this.inputTexture?this.inputTexture.texture:null},e.prototype.getTextureForResolving=function(){var e;return null===(e=this.outputTexture)||void 0===e?void 0:e.texture},e.prototype.destroy=function(){null!==this.outputTexture&&this.outputTexture!==this.inputTexture&&(this.outputTexture.destroy(),this.outputTexture=null),null!==this.inputTexture&&(this.inputTexture.destroy(),this.inputTexture=null)},e}(),Ui=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({intensity:Math.PI},n)},a))||this}return n(t,e),t.tag="light",t}(t.DisplayObject);!function(e){e[e.NONE=0]="NONE",e[e.EXP=1]="EXP",e[e.EXP2=2]="EXP2",e[e.LINEAR=3]="LINEAR"}(bi||(bi={}));var wi,Gi=function(e){function t(r){void 0===r&&(r={});var n=r.style,a=o(r,["style"]);return e.call(this,i({type:t.tag,style:i({type:bi.NONE,fill:"black",start:1,end:1e3,density:0},n)},a))||this}return n(t,e),t.tag="fog",t}(t.DisplayObject);function ki(e,t,r,n){void 0===n&&(n=Q.STATIC);var i=e.createBuffer({viewOrSize:r.byteLength,usage:t,hint:n});return i.setSubData(0,new Uint8Array(r)),i}!function(e){e.CHANGED="changed"}(wi||(wi={}));var Vi,Xi,Wi=function(e){function r(t,r){void 0===r&&(r={});var n=e.call(this)||this;return n.device=t,n.props=r,n.drawMode=Z.TRIANGLES,n.vertexBuffers=[],n.vertices=[],n.inputLayoutDescriptor={vertexBufferDescriptors:[],indexBufferFormat:null,program:null},n.vertexCount=0,n.instancedCount=0,n.indexStart=0,n.primitiveStart=0,n.dirty=!0,n.meshes=[],n}return n(r,e),r.prototype.validate=function(e){return!0},r.prototype.build=function(e){},r.prototype.computeBoundingBox=function(){return new t.AABB},r.prototype.setIndexBuffer=function(e){return this.indexBuffer&&this.indexBuffer.destroy(),this.indexBuffer=ki(this.device,q.INDEX,new Uint32Array(ArrayBuffer.isView(e)?e.buffer:e).buffer),this.indices=e,this.inputLayoutDescriptor.indexBufferFormat=fe.U32_R,this},r.prototype.setVertexBuffer=function(e){var t=this,r=e.bufferIndex,n=e.attributes,i=e.data;this.inputLayoutDescriptor.vertexBufferDescriptors[r]={arrayStride:e.byteStride,stepMode:e.stepMode,attributes:[]},this.vertices[r]=i,n.forEach((function(e){var n=e.format,i=e.bufferByteOffset,o=e.location,a=e.divisor,s=t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.find((function(e){return e.shaderLocation===o}));s?(s.format=n,s.offset=i,s.divisor=a):t.inputLayoutDescriptor.vertexBufferDescriptors[r].attributes.push({format:n,offset:i,shaderLocation:o,divisor:a})})),this.vertexBuffers[r]&&this.vertexBuffers[r].destroy();var o=ki(this.device,q.VERTEX,i.buffer,Q.DYNAMIC);return this.vertexBuffers[r]=o,this},r.prototype.getVertexBuffer=function(e){return this.vertexBuffers[e]},r.prototype.updateVertexBuffer=function(e,t,r,n){var i=this.inputLayoutDescriptor.vertexBufferDescriptors[e];if(i){var o=i.arrayStride,a=this.inputLayoutDescriptor.vertexBufferDescriptors[e].attributes.find((function(e){return e.shaderLocation===t}));if(a)this.getVertexBuffer(e).setSubData(a.offset+r*o,n);this.emit(wi.CHANGED)}},r.prototype.updateIndices=function(e,t){return void 0===t&&(t=0),this.indexBuffer&&this.indexBuffer.setSubData(t,new Uint8Array(ArrayBuffer.isView(e)?e:new Uint32Array(e))),this},r.prototype.destroy=function(){this.vertexBuffers.forEach((function(e){e&&e.destroy()})),this.indexBuffer&&this.indexBuffer.destroy(),this.inputLayoutDescriptor.vertexBufferDescriptors=[],this.indexBuffer=void 0,this.vertexBuffers=[],this.indices=void 0,this.vertices=[],this.vertexCount=0,this.instancedCount=0},r}(de),Hi=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.features={},t.both="\nlayout(std140) uniform ub_Params {\n vec4 u_Misc[1];\n};\n#define u_InvResolution (u_Misc[0].xy)\n",t.vert="#define GLSLIFY 1\nlayout(location = 0) in vec2 a_Position;\n\nout vec2 v_TexCoord;\n\nvoid main() {\n v_TexCoord = 0.5 * (a_Position + 1.0);\n gl_Position = vec4(a_Position, 0., 1.);\n\n #ifdef VIEWPORT_ORIGIN_TL\n v_TexCoord.y = 1.0 - v_TexCoord.y;\n #endif\n}",t.frag="#define GLSLIFY 1\nuniform sampler2D u_Texture;\nin vec2 v_TexCoord;\n\nout vec4 outputColor;\n\nfloat MonochromeNTSC(vec3 t_Color) {\n // NTSC primaries.\n return dot(t_Color.rgb, vec3(0.299, 0.587, 0.114));\n}\n\nvec4 FXAA(PD_SAMPLER_2D(t_Texture), in vec2 t_PixelCenter, in vec2 t_InvResolution) {\n // FXAA v2, based on implementations:\n // http://www.geeks3d.com/20110405/fxaa-fast-approximate-anti-aliasing-demo-glsl-opengl-test-radeon-geforce/\n // https://github.com/mitsuhiko/webgl-meincraft\n\n float lumaMM = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy).rgb);\n\n #if 1\n vec2 t_PixelTopLeft = t_PixelCenter.xy - t_InvResolution.xy * 0.5;\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy) .rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 0.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(0.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelTopLeft.xy + vec2(1.0, 1.0)).rgb);\n #else\n // We're at the pixel center -- pixel edges are 0.5 units away.\n // NOTE(jstpierre): mitsuhiko's port seems to get this wrong?\n vec2 t_PixelSize = t_InvResolution.xy * 0.5;\n\n float lumaNW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, -1.0)).rgb);\n float lumaNE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, -1.0)).rgb);\n float lumaSW = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2(-1.0, 1.0)).rgb);\n float lumaSE = MonochromeNTSC(texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + t_PixelSize * vec2( 1.0, 1.0)).rgb);\n #endif\n\n vec2 dir; \n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n\n const float FXAA_REDUCE_MIN = 1.0/128.0;\n const float FXAA_REDUCE_MUL = 1.0/8.0;\n const float FXAA_SPAN_MAX = 8.0;\n\n float dirReduce = max(\n (lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),\n FXAA_REDUCE_MIN);\n\n float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);\n dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_InvResolution.xy;\n\n float lumaMin = min(lumaMM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));\n float lumaMax = max(lumaMM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));\n\n vec4 rgbA = (1.0/2.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (1.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (2.0/3.0 - 0.5)));\n vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (0.0/3.0 - 0.5)) +\n texture(PU_SAMPLER_2D(t_Texture), t_PixelCenter.xy + dir * (3.0/3.0 - 0.5)));\n float lumaB = MonochromeNTSC(rgbB.rgb);\n\n vec4 rgbOutput = ((lumaB < lumaMin) || (lumaB > lumaMax)) ? rgbA : rgbB;\n return rgbOutput;\n}\n\nvoid main() {\n outputColor = FXAA(PP_SAMPLER_2D(u_Texture), v_TexCoord.xy, u_InvResolution.xy);\n}",t}return n(t,e),t}(Un),Yi=Le(1,(function(){return new Li}));function zi(e,t,r,n){e.pushPass((function(i){i.setDebugName("FXAA"),i.attachRenderTargetID($n.Color0,n);var o=e.resolveRenderTarget(n);i.attachResolveTexture(o);var a=t.renderInstManager.newRenderInst();a.setUniformBuffer(t.uniformBuffer),a.setAllowSkippingIfPipelineNotReady(!1),a.setMegaStateFlags(He),a.setBindingLayout({numUniformBuffers:1,numSamplers:1}),a.drawPrimitives(3);var s=a.allocateUniformBuffer(0,4);vi(a.mapUniformBufferF32(0),s,1/r.backbufferWidth,1/r.backbufferHeight);var l=new Hi,u=t.renderCache.createProgramSimple(l);a.setProgram(u),Vi||((Vi=new Wi(t.getDevice())).setVertexBuffer({bufferIndex:0,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:0}],data:new Float32Array([1,3,-3,-1,1,-1])}),Vi.vertexCount=3,Xi=t.getCache().createInputLayout(Vi.inputLayoutDescriptor)),i.exec((function(e,r){Yi[0].texture=r.getResolveTextureForID(o),a.setSamplerBindingsFromTextureMappings(Yi),a.setVertexInput(Xi,Vi.vertexBuffers.map((function(e){return{buffer:e,byteOffset:0}})),null),a.drawOnPass(t.renderCache,e)}))}))}var Ki;!function(e){e.PROJECTION_MATRIX="u_ProjectionMatrix",e.VIEW_MATRIX="u_ViewMatrix",e.CAMERA_POSITION="u_CameraPosition",e.DEVICE_PIXEL_RATIO="u_DevicePixelRatio",e.VIEWPORT="u_Viewport",e.IS_ORTHO="u_IsOrtho",e.IS_PICKING="u_IsPicking"}(Ki||(Ki={}));var ji,Zi=function(){function e(e,t,r,n,i){this.renderHelper=e,this.lightPool=t,this.texturePool=r,this.batchManager=n,this.options=i,this.renderLists={leftEye:new gi,rightEye:new gi,picking:new gi},this.cameras=[]}return e.prototype.getDevice=function(){return this.device},e.prototype.getSwapChain=function(){return this.swapChain},e.prototype.getRenderLists=function(){return this.renderLists},e.prototype.apply=function(r){var n=this;this.context=r;var o=r.renderingService,l=r.config,f=r.renderingContext.root.ownerDocument.defaultView;l.disableRenderHooks=!0;var d=function(e){var t=e.target;t.nodeName!==Ui.tag?t.nodeName!==Gi.tag?(t.renderable3D||(t.renderable3D=new Bn),n.batchManager.add(t)):n.lightPool.addFog(t):n.lightPool.addLight(t)},p=function(e){var r,i,o=e.target;if(o.nodeName!==Ui.tag)if(o.nodeName!==Gi.tag){if(o.nodeName===t.Shape.MESH){var a;if(null===(r=o.style.geometry)||void 0===r?void 0:r.meshes)(a=o.style.geometry.meshes.indexOf(o))>-1&&o.style.geometry.meshes.splice(a,1);if(null===(i=o.style.material)||void 0===i?void 0:i.meshes)(a=o.style.material.meshes.indexOf(o))>-1&&o.style.material.meshes.splice(a,1)}n.swapChain&&n.batchManager.remove(o),delete o.renderable3D}else n.lightPool.removeFog(o);else n.lightPool.removeLight(o)},_=function(e){if(n.swapChain){var t=e.target,r=e.attrName,i=e.newValue;"zIndex"===r?t.parentNode.forEach((function(e){n.batchManager.changeRenderOrder(e,e.sortable.renderOrder)})):n.batchManager.updateAttribute(t,r,i)}},h=function(e){if(n.swapChain){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){n.batchManager.updateAttribute(e,"modelMatrix",null)}))}};o.hooks.initAsync.tapPromise(e.tag,(function(){return a(n,void 0,void 0,(function(){var e,n,o,a=this;return s(this,(function(s){switch(s.label){case 0:return f.addEventListener(t.ElementEvent.MOUNTED,d),f.addEventListener(t.ElementEvent.UNMOUNTED,p),f.addEventListener(t.ElementEvent.ATTR_MODIFIED,_),f.addEventListener(t.ElementEvent.BOUNDS_CHANGED,h),this.context.config.renderer.getConfig().enableDirtyRectangleRendering=!1,e=this.context.contextService.getDomElement(),this.context.contextService.resize((n=this.context.config).width,n.height),o=this,[4,this.context.deviceContribution.createSwapChain(e)];case 1:return o.swapChain=s.sent(),this.device=this.swapChain.getDevice(),this.renderHelper.setDevice(this.device),this.renderHelper.renderInstManager.disableSimpleMode(),this.swapChain.configureSwapChain(e.width,e.height),f.addEventListener(t.CanvasEvent.RESIZE,(function(){a.swapChain.configureSwapChain(e.width,e.height)})),this.batchManager.attach(i({device:this.device},r)),[2]}}))}))})),o.hooks.destroy.tap(e.tag,(function(){n.renderHelper.destroy(),n.batchManager.destroy(),n.texturePool.destroy(),f.removeEventListener(t.ElementEvent.MOUNTED,d),f.removeEventListener(t.ElementEvent.UNMOUNTED,p),f.removeEventListener(t.ElementEvent.ATTR_MODIFIED,_),f.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,h),n.device.destroy(),n.device.checkForLeaks(),l.disableRenderHooks=!1})),o.hooks.beginFrame.tap(e.tag,(function(e){var r,i=null==e?void 0:e.session,o=n.context.config,a=o.width,s=o.height;if(i){var l=i.renderState.baseLayer;l||(l=i.renderState.layers[0]),n.swapChain.configureSwapChain(l.framebufferWidth,l.framebufferHeight,l.framebuffer);var f=e.getViewerPose(i.referenceSpace);f&&f.views.forEach((function(e,t){var r=i.renderState.baseLayer.getViewport(e),o=A.apply(b,c([],u(e.transform.matrix),!1));o[12]*=a,o[13]*=s,o[14]*=500,o[12]+=a/2,o[13]-=s/2,o[14]+=250;var f=A.apply(b,c([],u(e.projectionMatrix),!1)),d=y(T(),o);C(d,d,L(1,-1,1));var p=e.transform.position;n.cameras[t]={viewport:{x:r.x/l.framebufferWidth,y:r.y/l.framebufferHeight,width:r.width/l.framebufferWidth,height:r.height/l.framebufferHeight},projectionMatrix:f,viewMatrix:d,cameraPosition:[p.x,p.y,p.z],isOrtho:!1}}))}else{var d=n.context.camera;n.cameras=[{viewport:{x:0,y:0,width:1,height:1},projectionMatrix:d.getPerspective(),viewMatrix:d.getViewTransform(),cameraPosition:d.getPosition(),isOrtho:d.isOrtho()}]}var p,_=n.swapChain.getCanvas(),h=n.renderHelper.renderInstManager;if(n.builder=n.renderHelper.renderGraph.newGraphBuilder(),"transparent"===n.context.config.background)p=Ce;else{var E=t.parseColor(n.context.config.background);p=n.context.config.background?Se(Number(E.r)/255*Number(E.alpha),Number(E.g)/255*Number(E.alpha),Number(E.b)/255*Number(E.alpha),Number(E.alpha)):Ne}var R={backbufferWidth:_.width,backbufferHeight:_.height,antialiasingMode:Mi.None},v=Di($n.Color0,R,Ni(p)),m=Di($n.DepthStencil,R,xi),g=n.builder.createRenderTargetID(v,"Main Color"),S=n.builder.createRenderTargetID(m,"Main Depth");n.builder.pushPass((function(e){e.setDebugName("Main Render Pass"),e.attachRenderTargetID($n.Color0,g),e.attachRenderTargetID($n.DepthStencil,S),e.exec((function(e,t){n.cameras.forEach((function(r,i){var o=r.viewport,a=t.currentPass,s=a.viewportW,l=a.viewportH;e.setViewport(o.x*s,o.y*l,o.width*s,o.height*l),(0===i?n.renderLists.leftEye:n.renderLists.rightEye).drawOnPassRenderer(h.renderCache,e)}))}))})),(null===(r=n.options)||void 0===r?void 0:r.enableFXAA)&&zi(n.builder,n.renderHelper,R,g),n.builder.resolveRenderTargetToExternalTexture(g,n.swapChain.getOnscreenTexture())})),o.hooks.endFrame.tap(e.tag,(function(e){var t=n.renderHelper.renderInstManager,r=n.context.config,i=r.width,o=r.height;if(n.cameras.forEach((function(e,r){var a=e.viewport,s=e.cameraPosition,l=e.viewMatrix,u=e.projectionMatrix,c=e.isOrtho,f=a.width,d=a.height,p=n.renderHelper.pushTemplateRenderInst();p.setBindingLayout({numUniformBuffers:2,numSamplers:0}),p.setMegaStateFlags(Ye({depthWrite:!0,blendConstant:Ce},{rgbBlendMode:Y.ADD,alphaBlendMode:Y.ADD,rgbBlendSrcFactor:H.SRC_ALPHA,alphaBlendSrcFactor:H.ONE,rgbBlendDstFactor:H.ONE_MINUS_SRC_ALPHA,alphaBlendDstFactor:H.ONE_MINUS_SRC_ALPHA})),p.setUniforms(0,[{name:Ki.PROJECTION_MATRIX,value:u},{name:Ki.VIEW_MATRIX,value:l},{name:Ki.CAMERA_POSITION,value:s},{name:Ki.DEVICE_PIXEL_RATIO,value:n.context.contextService.getDPR()},{name:Ki.VIEWPORT,value:[i*f,o*d]},{name:Ki.IS_ORTHO,value:c?1:0},{name:Ki.IS_PICKING,value:0}]),n.batchManager.render(0===r?n.renderLists.leftEye:n.renderLists.rightEye),t.popTemplateRenderInst()})),n.renderHelper.prepareToRender(),n.renderHelper.renderGraph.execute(),t.resetRenderInsts(),n.enableCapture&&n.resolveCapturePromise){var a=n.captureOptions,s=a.type,l=a.encoderOptions,u=n.context.contextService.getDomElement().toDataURL(s,l);n.resolveCapturePromise(u),n.enableCapture=!1,n.captureOptions=void 0,n.resolveCapturePromise=void 0}}))},e.prototype.loadTexture=function(e,t,r){return this.texturePool.getOrCreateTexture(this.device,e,t,(function(e){r&&r(e)}))},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){var t=this;return s(this,(function(r){return this.enableCapture=!0,this.captureOptions=e,this.capturePromise=new Promise((function(e){t.resolveCapturePromise=function(t){e(t)}})),[2,this.capturePromise]}))}))},e.tag="RenderGraph",e}(),qi=function(){function e(e,t,r,n){this.renderHelper=e,this.renderGraphPlugin=t,this.pickingIdGenerator=r,this.batchManager=n}return e.prototype.apply=function(r){var n=this;this.context=r;var i=r.renderingService,o=r.renderingContext.root.ownerDocument.defaultView,l=function(e){var t=e.target;t.renderable3D||(t.renderable3D=new Bn);var r=t.renderable3D,i=n.pickingIdGenerator.getId(t);r.pickingId=i,r.encodedPickingColor=n.pickingIdGenerator.encodePickingColor(i)},u=function(e){var t=e.target.renderable3D;t&&n.pickingIdGenerator.deleteById(t.pickingId)};i.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,l),o.addEventListener(t.ElementEvent.UNMOUNTED,u)})),i.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,l),o.removeEventListener(t.ElementEvent.UNMOUNTED,u),n.pickingIdGenerator.reset()})),i.hooks.pickSync.tap(e.tag,(function(e){return n.pick(e)})),i.hooks.pick.tapPromise(e.tag,(function(e){return a(n,void 0,void 0,(function(){return s(this,(function(t){return[2,this.pick(e)]}))}))}))},e.prototype.pick=function(e){var r=e.topmost,n=e.position,i=n.viewportX,o=n.viewportY,a=this.context.contextService.getDPR(),s=this.context.config.width*a,l=this.context.config.height*a,u=i*a,c=o*a;if(!this.renderHelper.renderGraph||u>s||0>u||c>l||0>c)return e.picked=[],e;var f=this.pickByRectangleInDepth(new t.Rectangle(h(Math.round(u),0,s-1),h(Math.round(c),0,l-1),1,1),r?1:100);return e.picked=f,e},e.prototype.pickByRectangleInDepth=function(e,t){void 0===t&&(t=100);var r=null,n=1,i=[];do{if(!(r=this.pickByRectangle(e,r)))break;n++,i.push(r)}while(r&&t>=n);return t>1&&this.restorePickingColor(i),i},e.prototype.restorePickingColor=function(e){var t=this;e.forEach((function(e){t.batchManager.updateAttribute(e,"pointerEvents",!0,!0)}))},e.prototype.pickByRectangle=function(e,t){var r,n=this,o=this.renderGraphPlugin.getDevice(),a=this.renderGraphPlugin.getRenderLists(),s=this.renderHelper.renderInstManager,l=this.renderHelper.renderGraph.newGraphBuilder(),u=this.context.camera,c=e.x,f=e.y,d=e.width,p=e.height,_={backbufferWidth:d,backbufferHeight:p,antialiasingMode:Mi.None},h=Di($n.Color0,_,Ni(Ce)),E=l.createRenderTargetID(h,"Picking Color"),R=Di($n.DepthStencil,_,xi),v=l.createRenderTargetID(R,"Picking Depth"),T=i({},u.getView());this.renderHelper.renderGraph.renderTargetDeadPool.forEach((function(e){e.age=-1})),l.pushPass((function(e){e.setDebugName("Picking Pass"),e.attachRenderTargetID($n.Color0,E),e.attachRenderTargetID($n.DepthStencil,v),e.exec((function(e){a.picking.drawOnPassRenderer(s.renderCache,e)})),e.post((function(e){var t,i=e.getRenderTargetTexture($n.Color0),a=o.createReadback();T&&T.enabled?u.setViewOffset(T.fullWidth,T.fullHeight,T.offsetX,T.offsetY,T.width,T.height):u.clearViewOffset(),u.setEnableUpdate(!0);try{t=a.readTextureSync(i,0,0,d,p,new Uint8Array(d*p*4))}catch(e){}var s=-1;if(!t||0===t[0]&&0===t[1]&&0===t[2]||(s=n.pickingIdGenerator.decodePickingColor(t)),s>-1){var l=n.pickingIdGenerator.getById(s);l&&l.isVisible()&&l.isInteractive()&&(r=l)}a.destroy()}))}));var m=this.renderHelper.pushTemplateRenderInst();m.setBindingLayout({numUniformBuffers:2,numSamplers:0}),m.setMegaStateFlags(Ye({depthWrite:!0},{rgbBlendMode:Y.ADD,rgbBlendSrcFactor:H.ONE,rgbBlendDstFactor:H.ZERO,alphaBlendMode:Y.ADD,alphaBlendSrcFactor:H.ONE,alphaBlendDstFactor:H.ZERO}));var A=this.context.config,g=A.width,y=A.height,S=this.context.contextService.getDPR();return u.setEnableUpdate(!1),u.setViewOffset(g*S,y*S,c,y*S-f,d,p),m.setUniforms(0,[{name:Ki.PROJECTION_MATRIX,value:u.getPerspective()},{name:Ki.VIEW_MATRIX,value:u.getViewTransform()},{name:Ki.CAMERA_POSITION,value:u.getPosition()},{name:Ki.DEVICE_PIXEL_RATIO,value:this.context.contextService.getDPR()},{name:Ki.VIEWPORT,value:[d,p]},{name:Ki.IS_ORTHO,value:u.isOrtho()?1:0},{name:Ki.IS_PICKING,value:1}]),t&&this.batchManager.updateAttribute(t,"pointerEvents",!1,!0),this.batchManager.render(a.picking,!0),s.popTemplateRenderInst(),this.renderHelper.prepareToRender(),this.renderHelper.renderGraph.execute(),s.resetRenderInsts(),r},e.tag="WebGLPicker",e}(),Qi=5e-4,$i=function(){function e(){this.clipPathMeshCreated=!1}return e.prototype.beforeUploadUBO=function(e,t){},e.prototype.beforeInitMesh=function(e){},e.prototype.afterInitMesh=function(e){},e}();!function(e){e.CHANGED="changed"}(ji||(ji={}));var Ji=function(e){function t(t,r){var n=e.call(this)||this;n.props={},n.meshes=[],n.defines={},n.uniforms={},n.uboBuffer=[],n.textures={},n.samplers=[],n.programDirty=!0,n.textureDirty=!0,n.geometryDirty=!0;var o=Ve(We),a=o.cullMode,s=o.depthCompare,l=o.depthWrite,u=o.stencilFront,c=o.stencilBack,f=o.stencilWrite,d=o.frontFace,p=o.polygonOffset,_=o.attachmentsState;return n.device=t,n.props=i({cullMode:a,depthTest:!0,depthCompare:s,depthWrite:l,stencilFront:u,stencilBack:c,stencilWrite:f,frontFace:d,polygonOffset:p,attachmentsState:_,dithering:!1,wireframe:!1,wireframeColor:"black",wireframeLineWidth:1,vertexShader:"",fragmentShader:""},r),n.compile(),n}return n(t,e),Object.defineProperty(t.prototype,"cullMode",{get:function(){return this.props.cullMode},set:function(e){this.props.cullMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frontFace",{get:function(){return this.props.frontFace},set:function(e){this.props.frontFace=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendConstant",{get:function(){return this.props.blendConstant},set:function(e){this.props.blendConstant=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquation",{get:function(){return this.props.blendEquation},set:function(e){this.props.blendEquation=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendEquationAlpha",{get:function(){return this.props.blendEquationAlpha},set:function(e){this.props.blendEquationAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrc",{get:function(){return this.props.blendSrc},set:function(e){this.props.blendSrc=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDst",{get:function(){return this.props.blendDst},set:function(e){this.props.blendDst=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendSrcAlpha",{get:function(){return this.props.blendSrcAlpha},set:function(e){this.props.blendSrcAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendDstAlpha",{get:function(){return this.props.blendDstAlpha},set:function(e){this.props.blendDstAlpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthCompare",{get:function(){return this.props.depthCompare},set:function(e){this.props.depthCompare=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTest",{get:function(){return this.props.depthTest},set:function(e){this.props.depthTest=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthWrite",{get:function(){return this.props.depthWrite},set:function(e){this.props.depthWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilFront",{get:function(){return this.props.stencilFront},set:function(e){this.props.stencilFront=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilBack",{get:function(){return this.props.stencilBack},set:function(e){this.props.stencilBack=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilWrite",{get:function(){return this.props.stencilWrite},set:function(e){this.props.stencilWrite=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"stencilRef",{get:function(){return this.props.stencilRef},set:function(e){this.props.stencilRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"polygonOffset",{get:function(){return this.props.polygonOffset},set:function(e){this.props.polygonOffset=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dithering",{get:function(){return this.props.dithering},set:function(e){this.props.dithering=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this.props.wireframe},set:function(e){this.props.wireframe!==e&&(this.geometryDirty=!0,this.programDirty=!0,this.props.wireframe=e,this.dispatchMutationEvent()),this.defines.USE_WIREFRAME=!!e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeColor",{get:function(){return this.props.wireframeColor},set:function(e){this.props.wireframeColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wireframeLineWidth",{get:function(){return this.props.wireframeLineWidth},set:function(e){this.props.wireframeLineWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShader",{get:function(){return this.props.vertexShader},set:function(e){this.props.vertexShader!==e&&(this.programDirty=!0,this.props.vertexShader=e,this.compile())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fragmentShader",{get:function(){return this.props.fragmentShader},set:function(e){this.props.fragmentShader!==e&&(this.programDirty=!0,this.props.fragmentShader=e,this.compile())},enumerable:!1,configurable:!0}),t.prototype.compile=function(){var e=this;this.props.fragmentShader.replace(/^\s*uniform\s*sampler2D\s*(.*)\s*;$/gm,(function(t,r){return e.samplers.push(r),""})),this.uniformNames=function(e){var t=[],r=[];return e.replace(/\s*struct\s*(.*)\s*{((?:\s*.*\s*)*?)};/g,(function(e,t,n){var i=[];return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var t=u(e.trim().split(/\s+/),2),r=t[1];i.push({type:t[0].trim(),name:r.replace(";","").trim()})})),r.push({type:t.trim(),uniforms:i}),""})),e.replace(/\s*uniform(?:\s+)(?:\w+)(?:\s?){([^]*?)};?/g,(function(e,n){return n.trim().replace("\r\n","\n").split("\n").forEach((function(e){var n=e.trim().split(" "),i=n[0]||"",o=n[1]||"",a=o.indexOf("[")>-1;if(o=o.replace(";","").replace("[","").trim(),!i.startsWith("#")){if(i){var s=r.find((function(e){return i===e.type}));if(s)if(a)for(var l=function(e){s.uniforms.forEach((function(r){t.push("".concat(o,"[").concat(e,"].").concat(r.name))}))},u=0;5>u;u++)l(u);else s.uniforms.forEach((function(e){t.push("".concat(o,".").concat(e.name))}))}o&&t.push(o)}})),""})),t}(this.props.fragmentShader)},t.prototype.setUniforms=function(e){var t=this,r=!1;Object.keys(e).forEach((function(n){var i,o=e[n],a=t.textures[n];a&&a!==o&&(t.textureDirty=!0),(i=o)&&i.type?(t.textures[n]=o,t.textureDirty=!0,o.on(J.LOADED,(function(){t.dispatchMutationEvent()}))):(t.uniforms[n]=o,r=!0),f(e[n])&&(delete t.textures[n],delete t.uniforms[n])})),r&&this.dispatchMutationEvent()},t.prototype.dispatchMutationEvent=function(){this.emit(ji.CHANGED)},t}(de),eo=function(e){function t(t,r){var n=e.call(this,t,i({},r))||this;return n.defines=i(i({},n.defines),{USE_UV:!1,USE_MAP:!1,USE_WIREFRAME:!1,USE_FOG:!1,USE_LIGHT:!1}),n}return n(t,e),t}(Ji);function to(e){var t={};return Object.keys(e).forEach((function(r){"number"==typeof e[r]&&(t[r]=e[r])})),t}function ro(e,t){var r=Object.keys(e);return r.length===Object.keys(t).length&&r.every((function(r){return e[r]===t[r]}))}var no=function(e){return Object.fromEntries(Object.entries(e).filter((function(e){var t=u(e,2);return void 0!==t[1]})))};function io(e,t){return 256*(e=h(Math.floor(e),0,255))+(t=h(Math.floor(t),0,255))}var oo,ao,so=1,lo="FillTextureMapping";!function(e){e[e.MODEL_MATRIX=0]="MODEL_MATRIX",e[e.PACKED_COLOR=1]="PACKED_COLOR",e[e.PACKED_STYLE=2]="PACKED_STYLE",e[e.PICKING_COLOR=3]="PICKING_COLOR",e[e.POSITION=4]="POSITION",e[e.NORMAL=5]="NORMAL",e[e.UV=6]="UV",e[e.BARYCENTRIC=7]="BARYCENTRIC",e[e.MAX=8]="MAX"}(oo||(oo={})),function(e){e[e.MODEL_MATRIX0=0]="MODEL_MATRIX0",e[e.MODEL_MATRIX1=1]="MODEL_MATRIX1",e[e.MODEL_MATRIX2=2]="MODEL_MATRIX2",e[e.MODEL_MATRIX3=3]="MODEL_MATRIX3",e[e.PACKED_COLOR=4]="PACKED_COLOR",e[e.PACKED_STYLE1=5]="PACKED_STYLE1",e[e.PACKED_STYLE2=6]="PACKED_STYLE2",e[e.PICKING_COLOR=7]="PICKING_COLOR",e[e.POSITION=8]="POSITION",e[e.NORMAL=9]="NORMAL",e[e.UV=10]="UV",e[e.BARYCENTRIC=11]="BARYCENTRIC",e[e.MAX=12]="MAX"}(ao||(ao={}));var uo,co,fo=function(){function e(e,t,r,n,i,o,a){void 0===o&&(o=-1),this.renderHelper=e,this.texturePool=t,this.lightPool=r,this.drawcallCtors=i,this.index=o,this.context=a,this.id=so++,this.gradientAttributeName="fill",this.objects=[],this.program=new Un,this.geometryDirty=!0,this.materialDirty=!0,this.textureMappings=[],this.divisor=1,this.mergeXYZIntoModelMatrix=!1,this.checkNodeName=!0,this.maxInstances=1/0,this.inited=!1}return Object.defineProperty(e.prototype,"instance",{get:function(){return this.objects[0]},enumerable:!1,configurable:!0}),e.prototype.init=function(){this.inited||(this.renderer.beforeInitMesh(this),this.material=new eo(this.context.device),this.material.defines=i(i({},to(ao)),this.material.defines),this.geometry=new Wi(this.context.device),this.geometry.meshes=this.objects,this.material.meshes=this.objects,this.observeGeometryChanged(),this.observeMaterialChanged(),this.inited=!0,this.renderer.afterInitMesh(this))},e.prototype.observeGeometryChanged=function(){var e=this;this.geometry.on(wi.CHANGED,(function(){e.geometry.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.observeMaterialChanged=function(){var e=this;this.material.on(ji.CHANGED,(function(){e.material.meshes.forEach((function(e){e.renderable.dirty=!0})),e.context.renderingService.dirtify()}))},e.prototype.shouldMergeColor=function(e,r,n){var i=e.parsedStyle[n],o=r.parsedStyle[n];return!i&&!o||(!(!t.isCSSRGB(i)||!t.isCSSRGB(o))||(!(!t.isPattern(i)||!t.isPattern(o)||i.image!==o.image)||!(!Array.isArray(i)||!Array.isArray(o)||e.style[n]!==r.style[n])))},e.prototype.shouldMerge=function(e,t){return!this.instance||(!this.checkNodeName||this.instance.nodeName===e.nodeName)&&(!e.parsedStyle.clipPath&&!(!this.shouldMergeColor(this.instance,e,"fill")||!this.shouldMergeColor(this.instance,e,"stroke")))},e.prototype.createGeometry=function(e){var r,n,i=this,o=T(),a=T(),s=[],l=[],f=[],d=[],p=this.divisor,_=(null===(r=e[0])||void 0===r?void 0:r.nodeName)===t.Shape.CIRCLE||(null===(n=e[0])||void 0===n?void 0:n.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var r,n=e.parsedStyle,p=n.fill,h=n.stroke,E=n.opacity,R=void 0===E?1:E,v=n.fillOpacity,T=void 0===v?1:v,A=n.strokeOpacity,g=void 0===A?1:A,y=n.lineWidth,S=void 0===y?1:y,C=n.visibility,N=n.increasedLineWidthForHitTesting,M=void 0===N?0:N,I=[0,0,0,0];t.isCSSRGB(p)&&(I=[Number(p.r),Number(p.g),Number(p.b),255*Number(p.alpha)]);var O=[0,0,0,0];t.isCSSRGB(h)&&(O=[Number(h.r),Number(h.g),Number(h.b),255*Number(h.alpha)]),D(a,i.context.camera.getViewTransform(),o);var x=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];if(i.mergeXYZIntoModelMatrix){var B=e.parsedStyle,b=B.x,F=B.y,U=B.z;D(o,e.getWorldTransform(),P(o,L(b,F,U)))}else m(o,e.getWorldTransform());s.push.apply(s,c([],u(o),!1)),l.push(io(I[0],I[1]),io(I[2],I[3]),io(O[0],O[1]),io(O[2],O[3])),f.push(R,T,g,S,"hidden"!==C?1:0,_,_,M),d.push.apply(d,c(c([],u(x),!1),[e.sortable.renderOrder*Qi],!1))})),this.geometry.instancedCount=e.length,this.geometry.setVertexBuffer({bufferIndex:oo.MODEL_MATRIX,byteStride:64,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.MODEL_MATRIX0,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.MODEL_MATRIX1,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:32,location:ao.MODEL_MATRIX2,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:48,location:ao.MODEL_MATRIX3,divisor:p}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:oo.PACKED_COLOR,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PACKED_COLOR,divisor:p}],data:new Float32Array(l)}),this.geometry.setVertexBuffer({bufferIndex:oo.PACKED_STYLE,byteStride:32,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PACKED_STYLE1,divisor:p},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.PACKED_STYLE2,divisor:p}],data:new Float32Array(f)}),this.geometry.setVertexBuffer({bufferIndex:oo.PICKING_COLOR,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.PICKING_COLOR,divisor:p}],data:new Float32Array(d)})},e.prototype.destroy=function(){this.geometry&&this.geometry.destroy()},e.prototype.applyRenderInst=function(e,t){var r=this,n=!!this.lightPool.getFog();this.clipPathTarget||this.clipPath?this.clipPathTarget?(this.material.stencilWrite=!0,this.material.depthWrite=!1,this.material.stencilFront={compare:V.ALWAYS,passOp:ne.REPLACE},this.material.stencilBack={compare:V.ALWAYS,passOp:ne.REPLACE}):(this.material.stencilWrite=!1,this.material.depthWrite=!0,this.material.stencilFront={compare:V.EQUAL,passOp:ne.KEEP},this.material.stencilBack={compare:V.EQUAL,passOp:ne.KEEP}):this.material.stencilWrite=!1,(this.materialDirty||this.material.programDirty)&&this.createMaterial(t);var o=i({},this.material.defines);if(this.material.defines.USE_FOG=n,this.material.defines=i(i(i({},this.lightPool.getDefines()),this.material.defines),this.renderHelper.getDefines()),this.material.textureDirty){this.textureMappings=[];var a=this.createFillGradientTextureMapping(t);a&&this.textureMappings.push(a),Object.keys(this.material.textures).sort((function(e,t){return r.material.samplers.indexOf(e)-r.material.samplers.indexOf(t)})).forEach((function(e){var t=new Li;t.name=e,t.texture=r.material.textures[e],r.context.device.setResourceName(t.texture,"Material Texture "+e),t.sampler=r.renderHelper.getCache().createSampler({addressModeU:z.CLAMP_TO_EDGE,addressModeV:z.CLAMP_TO_EDGE,minFilter:K.POINT,magFilter:K.BILINEAR,mipmapFilter:j.LINEAR,lodMinClamp:0,lodMaxClamp:0}),r.textureMappings.push(t)})),this.textureMappings.length?(this.material.defines.USE_UV=!0,this.material.defines.USE_MAP=!0):(this.material.defines.USE_UV=!1,this.material.defines.USE_MAP=!1),this.material.textureDirty=!1}(!ro(o,this.material.defines)||this.material.programDirty||this.materialDirty)&&(this.material.defines=i(i({},this.material.defines),to(ao)),Object.keys(this.material.defines).forEach((function(e){var t=r.material.defines[e];"boolean"==typeof t?r.program.setDefineBool(e,t):r.program.setDefineString(e,"".concat(t))})),this.program.vert=this.material.vertexShader,this.program.frag=this.material.fragmentShader,this.material.programDirty=!1,this.materialDirty=!1),this.material.geometryDirty&&(this.geometryDirty=!0,this.material.geometryDirty=!1),(this.geometryDirty||this.geometry.dirty)&&(this.geometry&&this.geometry.destroy(),this.createGeometry(t),this.material.wireframe&&this.generateWireframe(this.geometry),this.geometryDirty=!1,this.geometry.dirty=!1);var s=this.renderHelper.getCache().createProgramSimple(this.program),l=this.renderHelper.getCache().createInputLayout(i(i({},this.geometry.inputLayoutDescriptor),{program:s})),u=!!this.geometry.indexBuffer;e.renderPipelineDescriptor.topology=this.geometry.drawMode,e.setProgram(s),e.setVertexInput(l,this.geometry.vertexBuffers.filter((function(e){return!!e})).map((function(e){return{buffer:e,byteOffset:0}})),u?{buffer:this.geometry.indexBuffer,offset:0}:null),this.renderer.beforeUploadUBO(e,this),this.uploadUBO(e),u?e.drawIndexesInstanced(this.geometry.vertexCount,this.geometry.instancedCount,this.geometry.indexStart):e.drawPrimitives(this.geometry.vertexCount,this.geometry.primitiveStart),e.sortKey=fi(ei.OPAQUE,t[0].sortable.renderOrder)},e.prototype.updateBatchedAttribute=function(e,r,n,i){var o,a,s=this;if(0!==e.length){if("fill"===n||"stroke"===n){var l=[];e.forEach((function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=[0,0,0,0];t.isCSSRGB(n)&&(o=[Number(n.r),Number(n.g),Number(n.b),255*Number(n.alpha)]);var a=[0,0,0,0];t.isCSSRGB(i)&&(a=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]),l.push(io(o[0],o[1]),io(o[2],o[3]),io(a[0],a[1]),io(a[2],a[3]))})),this.geometry.updateVertexBuffer(oo.PACKED_COLOR,ao.PACKED_COLOR,r,new Uint8Array(new Float32Array(l).buffer));var f=this.instance.parsedStyle.fill,d=this.textureMappings.findIndex((function(e){return e.name===lo}));if(t.isCSSRGB(f))0>d||(this.textureMappings.splice(d,-1),this.material.textureDirty=!0);else{var p=this.createFillGradientTextureMapping([this.instance]);0>d||this.textureMappings.splice(d,1,p),this.material.textureDirty=!0}}else if(["opacity","fillOpacity","strokeOpacity","lineWidth","visibility","anchor","increasedLineWidthForHitTesting"].indexOf(n)>-1){var _=[],h=(null===(o=e[0])||void 0===o?void 0:o.nodeName)===t.Shape.CIRCLE||(null===(a=e[0])||void 0===a?void 0:a.nodeName)===t.Shape.ELLIPSE?.5:0;e.forEach((function(e){var t=e.parsedStyle,r=t.opacity,n=t.fillOpacity,i=t.strokeOpacity,o=t.lineWidth,a=t.increasedLineWidthForHitTesting;_.push(void 0===r?1:r,void 0===n?1:n,void 0===i?1:i,void 0===o?1:o,"hidden"!==t.visibility?1:0,h,h,void 0===a?0:a)})),this.geometry.updateVertexBuffer(oo.PACKED_STYLE,ao.PACKED_STYLE1,r,new Uint8Array(new Float32Array(_).buffer))}else if("modelMatrix"===n||this.mergeXYZIntoModelMatrix&&("x"===n||"y"===n||"z"===n)){var E=[],R=T();e.forEach((function(e){if(s.mergeXYZIntoModelMatrix){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;D(R,e.getWorldTransform(),P(R,L(r,n,i)))}else m(R,e.getWorldTransform());E.push.apply(E,c([],u(R),!1))})),this.geometry.updateVertexBuffer(oo.MODEL_MATRIX,ao.MODEL_MATRIX0,r,new Uint8Array(new Float32Array(E).buffer))}else if("pointerEvents"===n){var v=[];e.forEach((function(e){var t,r=i&&e.isInteractive()&&(null===(t=e.renderable3D)||void 0===t?void 0:t.encodedPickingColor)||[0,0,0];v.push.apply(v,c(c([],u(r),!1),[e.sortable.renderOrder*Qi],!1))})),this.geometry.updateVertexBuffer(oo.PICKING_COLOR,ao.PICKING_COLOR,r,new Uint8Array(new Float32Array(v).buffer))}}},e.prototype.updateAttribute=function(e,t,r,n){"clipPath"===r&&this.clipPath&&(this.geometryDirty=!0),!0===this.geometryDirty&&0!==this.objects.length&&(this.geometry&&this.geometry.destroy(),this.createGeometry(this.objects),this.geometryDirty=!1)},e.prototype.changeRenderOrder=function(e,t){var r,n=this.objects.indexOf(e),i=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0];this.geometry.updateVertexBuffer(oo.PICKING_COLOR,ao.PICKING_COLOR,n,new Uint8Array(new Float32Array(c(c([],u(i),!1),[t*Qi],!1)).buffer))},e.prototype.generateWireframe=function(e){for(var t=e.indices,r=e.indices.length,n=e.vertices.map((function(e){return e.slice()})),i=oo.PICKING_COLOR;e.vertexBuffers.length>i;i++){var o=e.inputLayoutDescriptor.vertexBufferDescriptors[i].arrayStride;e.vertices[i]=new Float32Array(o/4*r)}var a=0,s=new Uint32Array(r);for(i=0;r>i;i++){for(var l=t[i],u=1;e.vertices.length>u;u++)for(var c=(o=e.inputLayoutDescriptor.vertexBufferDescriptors[u].arrayStride)/4,f=0;c>f;f++)e.vertices[u][a*c+f]=n[u][l*c+f];s[i]=a,a++}for(i=oo.PICKING_COLOR+1;e.vertexBuffers.length>i;i++){var d=e.inputLayoutDescriptor.vertexBufferDescriptors[i],p=(o=d.arrayStride,e.inputLayoutDescriptor.vertexBufferDescriptors[i].attributes[0]);if(p)e.setVertexBuffer({bufferIndex:i,byteStride:o,stepMode:d.stepMode,attributes:[{format:p.format,bufferByteOffset:p.offset,location:p.shaderLocation,divisor:p.divisor}],data:e.vertices[i]})}var _=new Float32Array(3*r);for(i=0;r>i;)for(u=0;3>u;u++){_[3*(l=s[i++])+u]=1}e.setVertexBuffer({bufferIndex:oo.BARYCENTRIC,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Number(ao.BARYCENTRIC)}],data:_}),e.setIndexBuffer(s)},e.prototype.beforeUploadUBO=function(e,t){},e.prototype.uploadUBO=function(e){var r,n=this,o=this.material,a=this.lightPool.getAllLights(),s=this.lightPool.getFog(),l=!!s,u=null!==(r=o.defines.USE_LIGHT)&&void 0!==r?r:!!a.length,c=[];if(o.defines.USE_WIREFRAME){var f=t.parseColor(o.wireframeColor);c.push({name:"u_WireframeLineColor",value:[Number(f.r)/255,Number(f.g)/255,Number(f.b)/255]}),c.push({name:"u_WireframeLineWidth",value:o.wireframeLineWidth})}if(l&&this.uploadFog(c,s),this.uploadMaterial(c,o),u){var d={};a.forEach((function(e){d[e.define]||(d[e.define]=-1),d[e.define]++,e.uploadUBO(c,d[e.define])}))}c.sort((function(e,t){return n.material.uniformNames.indexOf(e.name)-n.material.uniformNames.indexOf(t.name)})),e.setUniforms(1,c);var p=o.blendEquation,_=o.blendEquationAlpha,h=o.blendSrc,E=o.blendDst,R=o.blendSrcAlpha,v=o.blendDstAlpha,T=no({blendConstant:o.blendConstant,depthCompare:o.depthCompare,depthWrite:o.depthWrite,stencilFront:o.stencilFront,stencilBack:o.stencilBack,stencilWrite:o.stencilWrite,stencilRef:o.stencilRef,cullMode:o.cullMode,frontFace:o.frontFace,polygonOffset:o.polygonOffset}),m=e.getMegaStateFlags().attachmentsState[0];e.setMegaStateFlags(i({attachmentsState:[{channelWriteMask:this.material.stencilWrite?re.NONE:re.ALL,rgbBlendState:i(i({},m.rgbBlendState),no({blendMode:p,blendSrcFactor:h,blendDstFactor:E})),alphaBlendState:i(i({},m.alphaBlendState),no({blendMode:_,blendSrcFactor:R,blendDstFactor:v}))}]},T)),e.setBindingLayout({numUniformBuffers:1,numSamplers:this.textureMappings.length}),e.setSamplerBindingsFromTextureMappings(this.textureMappings)},e.prototype.uploadFog=function(e,r){var n=r.parsedStyle,i=n.type,o=n.fill,a=n.start,s=n.end,l=n.density;if(t.isCSSRGB(o)){var u=[Number(o.r)/255,Number(o.g)/255,Number(o.b)/255,Number(o.alpha)];e.push({name:"u_FogInfos",value:[i,a,s,l]}),e.push({name:"u_FogColor",value:u})}},e.prototype.uploadMaterial=function(e,t){var r=Object.keys(t.uniforms).map((function(e){return{name:e,value:t.uniforms[e]}}));e.push.apply(e,c([],u(r),!1))},e.prototype.createFillGradientTextureMapping=function(e){var r,n=this,i=e[0],o=i.parsedStyle[this.gradientAttributeName];if(o&&(t.isPattern(o)||Array.isArray(o))){Array.isArray(o)?(this.program.setDefineBool("USE_PATTERN",!1),this.texturePool.getOrCreateGradient({gradients:o,width:128,height:128,instance:i})):t.isPattern(o)&&(this.program.setDefineBool("USE_PATTERN",!0),this.texturePool.getOrCreatePattern(o,i,(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0}))),r=this.texturePool.getOrCreateCanvas();var a=this.texturePool.getOrCreateTexture(this.context.device,r,pe(fe.U8_RGBA_NORM,1,1,1));if(a){var s=new Li;return s.name=lo,s.texture=a,s.texture.on("loaded",(function(){e.forEach((function(e){e.renderable.dirty=!0})),n.material.textureDirty=!0})),this.context.device.setResourceName(s.texture,"Fill Texture"+this.id),s.sampler=this.renderHelper.getCache().createSampler({addressModeU:z.CLAMP_TO_EDGE,addressModeV:z.CLAMP_TO_EDGE,minFilter:K.POINT,magFilter:K.BILINEAR,mipmapFilter:j.LINEAR,lodMinClamp:0,lodMaxClamp:0}),s}}return null},e}();!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(uo||(uo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.EXTRUDE=13]="EXTRUDE",e[e.SIZE=14]="SIZE"}(co||(co={}));var po=[t.Shape.CIRCLE,t.Shape.ELLIPSE,t.Shape.RECT],_o=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = EXTRUDE) in vec2 a_Extrude;\n// shape, radius, omitStroke, isBillboard\nlayout(location = PACKED_STYLE3) in vec3 a_StylePacked3;\nlayout(location = SIZE) in vec4 a_Size;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nout vec2 v_Data;\nout vec2 v_Radius;\nout vec3 v_StylePacked3;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n\n bool omitStroke = a_StylePacked3.z == 1.0;\n vec2 radius = a_Size.xy + vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n vec2 offset = (a_Extrude + vec2(1.0) - 2.0 * u_Anchor.xy) * a_Size.xy + a_Extrude * vec2(omitStroke ? 0.0 : strokeWidth / 2.0);\n\n bool isBillboard = a_Size.z > 0.5;\n if (isBillboard) {\n float rotation = 0.0;\n bool isSizeAttenuation = a_Size.w > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n \n v_Radius = radius;\n v_Data = vec2(a_Extrude * radius / radius.y);\n v_StylePacked3 = a_StylePacked3;\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec2 v_Data;\nin vec2 v_Radius;\nin vec3 v_StylePacked3;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\n/**\n * 2D signed distance field functions\n * @see http://www.iquilezles.org/www/articles/distfunctions2d/distfunctions2d.htm\n */\n\nfloat sdCircle(vec2 p, float r) {\n return length(p) - r;\n}\n\n// @see http://www.iquilezles.org/www/articles/ellipsoids/ellipsoids.htm\nfloat sdEllipsoidApproximated(vec2 p, vec2 r) {\n float k0 = length(p / r);\n float k1 = length(p / (r * r));\n return k0 * (k0 - 1.0) / k1;\n}\n\n// @see https://www.shadertoy.com/view/4llXD7\nfloat sdRoundedBox(vec2 p, vec2 b, float r) {\n p = abs(p) - b + r;\n return length(max(p, 0.0)) + min(max(p.x, p.y), 0.0) - r;\n}\n\nvoid main() {\n int shape = int(floor(v_StylePacked3.x + 0.5));\n\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n bool omitStroke = v_StylePacked3.z == 1.0;\n\n vec2 r = (v_Radius - (omitStroke ? 0.0 : u_StrokeWidth)) / v_Radius.y;\n float wh = v_Radius.x / v_Radius.y;\n\n float dist = length(v_Data);\n float antialiased_blur = -fwidth(dist);\n\n float outer_df;\n float inner_df;\n // 'circle', 'ellipse', 'rect'\n if (shape == 0) {\n outer_df = sdCircle(v_Data, 1.0);\n inner_df = sdCircle(v_Data, r.x);\n } else if (shape == 1) {\n outer_df = sdEllipsoidApproximated(v_Data, vec2(wh, 1.0));\n inner_df = sdEllipsoidApproximated(v_Data, r);\n } else if (shape == 2) {\n bool useRadius = v_StylePacked3.y > epsilon;\n outer_df = sdRoundedBox(v_Data, vec2(wh, 1.0), useRadius ? (v_StylePacked3.y + u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n inner_df = sdRoundedBox(v_Data, r, useRadius ? (v_StylePacked3.y - u_StrokeWidth / 2.0) / v_Radius.y : 0.0);\n }\n\n float opacity_t = smoothstep(0.0, antialiased_blur, outer_df);\n\n float color_t = u_StrokeWidth < 0.01 ? 0.0 : smoothstep(\n antialiased_blur,\n 0.0,\n inner_df\n );\n\n vec4 diffuseColor;\n vec4 strokeColor;\n if (u_IsPicking > 0.5) {\n diffuseColor = vec4(u_PickingColor, 1.0);\n strokeColor = vec4(u_PickingColor, 1.0);\n } else {\n diffuseColor = u_Color;\n strokeColor = (u_StrokeColor == vec4(0) || omitStroke) ? vec4(0.0) : u_StrokeColor;\n }\n\n outputColor = mix(vec4(diffuseColor.rgb, diffuseColor.a * u_FillOpacity), strokeColor * u_StrokeOpacity, color_t);\n outputColor.a = outputColor.a * u_Opacity * opacity_t;\n\n if (outputColor.a < epsilon)\n discard;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(co))},r.prototype.createGeometry=function(t){var r=this;e.prototype.createGeometry.call(this,t);var n=[],i=[];t.forEach((function(e,t){var o=e,a=o.parsedStyle.radius,s=r.shouldOmitStroke(o.parsedStyle),l=r.getSize(e.parsedStyle,o.nodeName),f=r.getPosition(e.parsedStyle,o.nodeName);n.push.apply(n,c(c([],u(l),!1),[o.parsedStyle.isBillboard?1:0,o.parsedStyle.isSizeAttenuation?1:0,po.indexOf(o.nodeName),a&&a[0]||0,s?1:0],!1)),i.push.apply(i,c([],u(f),!1))})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:16,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:co.EXTRUDE},{format:fe.F32_RG,bufferByteOffset:8,location:ao.UV}],data:new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1])}),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:uo.PACKED_STYLE,byteStride:28,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:co.SIZE,divisor:1},{format:fe.F32_RGB,bufferByteOffset:16,location:co.PACKED_STYLE3,divisor:1}],data:new Float32Array(n)})},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"lineWidth"===n||"stroke"===n||"lineDash"===n||"strokeOpacity"===n||"radius"===n||"isBillboard"===n||"isSizeAttenuation"===n){var a=[];t.forEach((function(e){var t=e,r=o.shouldOmitStroke(t.parsedStyle),n=u(o.getSize(e.parsedStyle,e.nodeName),2);a.push.apply(a,c(c([],u([n[0],n[1]]),!1),[t.parsedStyle.isBillboard?1:0,t.parsedStyle.isSizeAttenuation?1:0,po.indexOf(e.nodeName),e.parsedStyle.radius&&e.parsedStyle.radius[0]||0,r?1:0],!1))})),this.geometry.updateVertexBuffer(uo.PACKED_STYLE,co.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}else if("cx"===n||"cy"===n||"x"===n||"y"===n){var s=[];t.forEach((function(e){var t=u(o.getPosition(e.parsedStyle,e.nodeName),2);s.push(t[0],t[1])})),this.geometry.updateVertexBuffer(oo.POSITION,ao.POSITION,r,new Uint8Array(new Float32Array(s).buffer))}},r.prototype.getPosition=function(e,r){var n=[0,0,0];if(r===t.Shape.CIRCLE||r===t.Shape.ELLIPSE){var i=e.cx,o=e.cy,a=e.cz;n=[void 0===i?0:i,void 0===o?0:o,void 0===a?0:a]}else if(r===t.Shape.RECT){var s=e.x,l=e.y,u=e.z;n=[void 0===s?0:s,void 0===l?0:l,void 0===u?0:u]}return n},r.prototype.getSize=function(e,r){var n=[0,0];if(r===t.Shape.CIRCLE){var i=e.r;n=[i,i]}else if(r===t.Shape.ELLIPSE){n=[e.rx,e.ry]}else if(r===t.Shape.RECT){n=[e.width/2,e.height/2]}return n},r.prototype.shouldOmitStroke=function(e){var t=e.lineDash,r=e.stroke,n=e.strokeOpacity,i=r&&!r.isNone,o=t&&t.length&&t.every((function(e){return 0!==e}));return!i||i&&(o||1>n)},r}(fo),ho=10,Eo=8,Ro=100;function vo(e,t,r,n,i,o){for(var a=i[i.length-3],s=i[i.length-2],l=null!=o?o:h(xn(a,s,e,t,r,n,3)/ho,Eo,Ro),u=0,c=0,f=1;l>=f;++f){var d=f/l;i.push((u=a+(e-a)*d)+(e+(r-e)*d-u)*d,(c=s+(t-s)*d)+(t+(n-t)*d-c)*d,0)}}function To(e,t,r,n,i,o,a,s){var l=a[a.length-3],u=a[a.length-2];a.length-=3;var c=null!=s?s:h(In(l,u,e,t,r,n,i,o,3)/ho,Eo,Ro),f=0,d=0,p=0,_=0,E=0;a.push(l,u,0);for(var R=1,v=0;c>=R;++R)a.push((p=(d=(f=1-(v=R/c))*f)*f)*l+3*d*v*e+3*f*(_=v*v)*r+(E=_*v)*i,p*u+3*d*v*t+3*f*_*n+E*o,0)}var mo,Ao,go=1e20,yo=function(){function e(e,t){var r=e.fontSize,n=void 0===r?24:r,i=e.buffer,o=void 0===i?3:i,a=e.radius,s=void 0===a?8:a,l=e.cutoff,u=void 0===l?.25:l,c=e.fontFamily,f=void 0===c?"sans-serif":c,d=e.fontWeight,p=void 0===d?"normal":d,_=e.fontStyle,h=void 0===_?"normal":_,E=e.canvas;this.buffer=o,this.cutoff=u,this.radius=s;var R=this.size=n+4*o,v=t.offscreenCanvasCreator.getOrCreateCanvas(E);v.width=R,v.height=R;var T=t.offscreenCanvasCreator.getOrCreateContext(E,{willReadFrequently:!0});this.ctx=T,T.font="".concat(h," ").concat(p," ").concat(n,"px ").concat(f),T.textBaseline="alphabetic",T.textAlign="left",T.fillStyle="black",this.gridOuter=new Float64Array(R*R),this.gridInner=new Float64Array(R*R),this.f=new Float64Array(R),this.z=new Float64Array(R+1),this.v=new Uint16Array(R)}return e.prototype.draw=function(e){var t=this.ctx.measureText(e),r=t.width,n=t.actualBoundingBoxDescent,i=t.actualBoundingBoxLeft,o=t.actualBoundingBoxRight,a=Math.ceil(t.actualBoundingBoxAscent),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(n)),u=s+2*this.buffer,c=l+2*this.buffer,f=Math.max(u*c,0),d=new Uint8ClampedArray(f),p={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:r};if(0===s||0===l)return p;var _=this,h=_.ctx,E=_.buffer,R=_.gridInner,v=_.gridOuter;h.clearRect(E,E,s,l),h.fillText(e,E,E+a);var T=h.getImageData(E,E,s,l);v.fill(go,0,f),R.fill(0,0,f);for(var m=0;l>m;m++)for(var A=0;s>A;A++){var g=T.data[4*(m*s+A)+3]/255;if(0!==g){var y=(m+E)*u+A+E;if(1===g)v[y]=0,R[y]=go;else v[y]=(C=.5-g)>0?C*C:0,R[y]=0>C?C*C:0}}So(v,0,0,u,c,u,this.f,this.v,this.z),So(R,E,E,s,l,u,this.f,this.v,this.z);for(var S=0;f>S;S++){var C;d[S]=Math.round(255-255*((C=Math.sqrt(v[S])-Math.sqrt(R[S]))/this.radius+this.cutoff))}return p},e}();function So(e,t,r,n,i,o,a,s,l){for(var u=t;t+n>u;u++)Co(e,r*o+u,o,i,a,s,l);for(var c=r;r+i>c;c++)Co(e,c*o+t,1,n,a,s,l)}function Co(e,t,r,n,i,o,a){o[0]=0,a[0]=-go,a[1]=go,i[0]=e[t];for(var s=1,l=0,u=0;n>s;s++){i[s]=e[t+s*r];var c=s*s;do{u=(i[s]-i[f=o[l]]+c-f*f)/(s-f)/2}while(a[l]>=u&&--l>-1);o[++l]=s,a[l]=u,a[l+1]=go}for(s=0,l=0;n>s;s++){for(;s>a[l+1];)l++;var f,d=s-(f=o[l]);e[t+s*r]=i[f]+d*d}}!function(e){e[e.PACKED=5]="PACKED",e[e.VERTEX_NUM=6]="VERTEX_NUM",e[e.TRAVEL=7]="TRAVEL",e[e.DASH=8]="DASH"}(mo||(mo={})),function(e){e[e.PREV=8]="PREV",e[e.POINT1=9]="POINT1",e[e.POINT2=10]="POINT2",e[e.NEXT=11]="NEXT",e[e.VERTEX_JOINT=12]="VERTEX_JOINT",e[e.VERTEX_NUM=13]="VERTEX_NUM",e[e.TRAVEL=14]="TRAVEL",e[e.DASH=15]="DASH"}(Ao||(Ao={}));function Po(e,t,r){return 4*(e?1:0)+2*(t?1:0)+(r?1:0)}function No(e){if(!(e.nodeName===t.Shape.POLYLINE))return!1;var r=e.parsedStyle.points.points;return r.length&&!f(r[0][2])}var Mo,Io=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.segmentNum=-1,l.segmentNum=l.calcSegmentNum(i),l.gradientAttributeName="stroke",l}return n(r,e),r.calcSubpathNum=function(e){return e.nodeName===t.Shape.PATH?e.parsedStyle.d.absolutePath.filter((function(e){return"M"===e[0]})).length:1},r.prototype.calcSegmentNum=function(e){return Bo(e,!1,12,this.calcSubpathIndex(e)).instancedCount},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===wo})).length;return this.index-r}return 0},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.segmentNum===n},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = PREV) in vec3 a_Prev;\nlayout(location = POINT1) in vec3 a_Point1;\nlayout(location = POINT2) in vec3 a_Point2;\nlayout(location = NEXT) in vec3 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\nout vec4 v_Dash;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nconst float u_Expand = 1.0;\nconst float u_MiterLimit = 5.0;\nconst float u_ScaleMode = 1.0;\nconst float u_Alignment = 0.5;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\nout float v_ScalingFactor;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvec2 clip2ScreenSpace(vec4 clip) {\n return u_Viewport * (0.5 * clip.xy / clip.w + 0.5);\n}\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n v_Dash = a_Dash;\n\n vec2 pointA;\n vec2 pointB;\n vec4 clip0;\n vec4 clip1;\n\n float compressed = a_Dash.w;\n float is_billboard = floor(compressed / 4.0);\n compressed -= is_billboard * 4.0;\n float is_size_attenuation = floor(compressed / 2.0);\n compressed -= is_size_attenuation * 2.0;\n float is_3d_polyline = compressed;\n\n bool isBillboard = is_billboard > 0.5;\n bool isSizeAttenuation = is_size_attenuation > 0.5;\n bool is3DPolyline = is_3d_polyline > 0.5;\n if (isBillboard) {\n clip0 = billboard(a_Point1.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n clip1 = billboard(a_Point2.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else if (is3DPolyline) {\n clip0 = project(vec4(a_Point1, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n clip1 = project(vec4(a_Point2, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n if (isBillboard || is3DPolyline) {\n pointA = clip2ScreenSpace(clip0);\n pointB = clip2ScreenSpace(clip1);\n } else {\n pointA = (u_ModelMatrix * vec4(a_Point1, 1.0)).xy;\n pointB = (u_ModelMatrix * vec4(a_Point2, 1.0)).xy;\n }\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Prev.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Prev, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Prev, 1.0)).xy;\n }\n\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n } else {\n if (isBillboard) {\n next = clip2ScreenSpace(billboard(a_Next.xy, 0.0, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0)));\n } else if (is3DPolyline) {\n next = clip2ScreenSpace(project(vec4(a_Next, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix));\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 1.0)).xy;\n }\n \n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n // TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n v_ScalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n\n if (isBillboard || is3DPolyline) {\n vec4 clip = mix(clip0, clip1, 0.5);\n gl_Position = vec4(clip.w * (2.0 * pos / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\nin float v_ScalingFactor;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n float u_Dash = v_Dash.x;\n float u_Gap = v_Dash.y;\n float u_DashOffset = v_Dash.z;\n if (u_Dash + u_Gap > 1.0) {\n float travel = mod(v_Travel + u_Gap * v_ScalingFactor * 0.5 + u_DashOffset, u_Dash * v_ScalingFactor + u_Gap * v_ScalingFactor) - (u_Gap * v_ScalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * v_ScalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(Ao))},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=[],s=0,l=0;t.forEach((function(e){var t=Bo(e,!1,12,r.calcSubpathIndex(e)),f=t.pointsBuffer,d=t.travelBuffer,p=t.instancedCount,_=e.parsedStyle,h=_.lineDash;a.push(h&&h[0]||0,h&&h[1]||0,_.lineDashOffset||0,Po(_.isBillboard,_.isSizeAttenuation,No(e))),s+=p;for(var E=0;f.length-12>E;E+=4)i.push(f[E],f[E+1],f[E+2],f[E+3],f[E+4],f[E+5],f[E+6],f[E+7],f[E+8],f[E+9],f[E+10],f[E+11],f[E+12],f[E+13],f[E+14],f[E+15]);o.push.apply(o,c([],u(d),!1)),n.push(0+l,2+l,1+l,0+l,3+l,2+l,4+l,6+l,5+l,4+l,7+l,6+l,4+l,7+l,8+l),l+=9})),i.length&&(this.geometry.setVertexBuffer({bufferIndex:mo.PACKED,byteStride:64,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Ao.PREV,divisor:1},{format:fe.F32_RGB,bufferByteOffset:16,location:Ao.POINT1,divisor:1},{format:fe.F32_R,bufferByteOffset:28,location:Ao.VERTEX_JOINT,divisor:1},{format:fe.F32_RGB,bufferByteOffset:32,location:Ao.POINT2,divisor:1},{format:fe.F32_RGB,bufferByteOffset:48,location:Ao.NEXT,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:mo.VERTEX_NUM,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ao.VERTEX_NUM,divisor:0}],data:new Float32Array([0,1,2,3,4,5,6,7,8])}),this.geometry.setVertexBuffer({bufferIndex:mo.TRAVEL,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,byteStride:4,location:Ao.TRAVEL,divisor:1}],data:new Float32Array(o)}),this.divisor=s/t.length,this.geometry.setVertexBuffer({bufferIndex:mo.DASH,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Ao.DASH,divisor:this.divisor}],data:new Float32Array(a)}),e.prototype.createGeometry.call(this,t),this.geometry.vertexCount=15,this.geometry.instancedCount=s,this.geometry.setIndexBuffer(new Uint32Array(n)))},r.prototype.updateAttribute=function(t,r,n,i){var o=this;if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"r"===n||"rx"===n||"ry"===n||"width"===n||"height"===n||"radius"===n||"x1"===n||"y1"===n||"x2"===n||"y2"===n||"points"===n||"path"===n||"d"===n||"lineJoin"===n||"lineCap"===n||"markerStartOffset"===n||"markerEndOffset"===n||"markerStart"===n||"markerEnd"===n){var a=[],s=[],l=0;t.forEach((function(e){var t=Bo(e,!1,12,o.calcSubpathIndex(e)),r=t.pointsBuffer,n=t.travelBuffer;l=t.instancedCount;for(var i=0;r.length-12>i;i+=4)a.push(r[i],r[i+1],r[i+2],r[i+3],r[i+4],r[i+5],r[i+6],r[i+7],r[i+8],r[i+9],r[i+10],r[i+11],r[i+12],r[i+13],r[i+14],r[i+15]);s.push.apply(s,c([],u(n),!1))})),this.geometry.updateVertexBuffer(mo.PACKED,Ao.PREV,r*l,new Uint8Array(new Float32Array(a).buffer)),this.geometry.updateVertexBuffer(mo.TRAVEL,Ao.TRAVEL,r,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===n||"lineDash"===n||"isBillboard"===n||"isSizeAttenuation"===n){var f=[];t.forEach((function(e){var t=e.parsedStyle,r=t.lineDash;f.push(r&&r[0]||0,r&&r[1]||0,t.lineDashOffset||0,Po(t.isBillboard,t.isSizeAttenuation,No(e)))})),this.geometry.updateVertexBuffer(mo.DASH,Ao.DASH,r,new Uint8Array(new Float32Array(f).buffer))}},r}(fo);!function(e){e[e.NONE=0]="NONE",e[e.FILL=1]="FILL",e[e.JOINT_BEVEL=4]="JOINT_BEVEL",e[e.JOINT_MITER=8]="JOINT_MITER",e[e.JOINT_ROUND=12]="JOINT_ROUND",e[e.JOINT_CAP_BUTT=16]="JOINT_CAP_BUTT",e[e.JOINT_CAP_SQUARE=18]="JOINT_CAP_SQUARE",e[e.JOINT_CAP_ROUND=20]="JOINT_CAP_ROUND",e[e.FILL_EXPAND=24]="FILL_EXPAND",e[e.CAP_BUTT=32]="CAP_BUTT",e[e.CAP_SQUARE=64]="CAP_SQUARE",e[e.CAP_ROUND=96]="CAP_ROUND",e[e.CAP_BUTT2=128]="CAP_BUTT2"}(Mo||(Mo={}));var Oo=3,xo=4;function Bo(e,r,n,i){var o;void 0===r&&(r=!1),void 0===i&&(i=0);var a=e.parsedStyle,s=a.lineCap,l=a.lineJoin,f=e.sortable.renderOrder*Qi,d=0,p=0,_=e.parsedStyle,h=_.markerStart,E=_.markerEnd,R=_.markerStartOffset,v=_.markerEndOffset,m=[],A=[];if(e.nodeName===t.Shape.POLYLINE||e.nodeName===t.Shape.POLYGON){var y=e.parsedStyle.points.points,S=y.length,C=0,P=0,N=0,M=0,I=0;h&&t.isDisplayObject(h)&&R&&(C=Math.cos(I=Math.atan2(y[1][1]-y[0][1],y[1][0]-y[0][0]))*(R||0),P=Math.sin(I)*(R||0)),E&&t.isDisplayObject(E)&&v&&(N=Math.cos(I=Math.atan2(y[S-2][1]-y[S-1][1],y[S-2][0]-y[S-1][0]))*(v||0),M=Math.sin(I)*(v||0));var O=e.nodeName===t.Shape.POLYLINE;if(m[0]=y.reduce((function(e,t,r){var n=0,i=0;return 0===r?(n=C,i=P):r===S-1&&(n=N,i=M),e.push(t[0]+n,t[1]+i,O?t[2]||0:f),e}),[]),e.nodeName===t.Shape.POLYGON){if(r)return A=Cn(m[0],[],3),{pointsBuffer:m[0],travelBuffer:[],triangles:A,instancedCount:Math.round(m[0].length/Oo)};m[0].push(m[0][0],m[0][1],m[0][2]||f),(o=m[0]).push.apply(o,c([],u(Do(m[0][0],m[0][1],m[0][2]||f,m[0][3],m[0][4],m[0][5]||f)),!1))}}else if(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.CIRCLE||e.nodeName===t.Shape.ELLIPSE||e.nodeName===t.Shape.RECT){var x=void 0;if(e.nodeName!==t.Shape.PATH){if(x=t.parsePath(t.convertToPath(e,g(T()))),e.nodeName===t.Shape.RECT){var B=e.parsedStyle;0>B.width&&(d+=x.rect.width),0>B.height&&(p+=x.rect.height)}}else x=e.parsedStyle.d;var D=x.absolutePath,b=x.segments,L=0,F=0,w=0,G=0;I=0;if(h&&h.parentNode&&t.isDisplayObject(h)&&R){var k=u(h.parentNode.getStartTangent(),2);L=Math.cos(I=Math.atan2((V=k[0])[1]-(X=k[1])[1],V[0]-X[0]))*(R||0),F=Math.sin(I)*(R||0)}if(E&&E.parentNode&&t.isDisplayObject(E)&&v){var V,X,W=u(E.parentNode.getEndTangent(),2);w=Math.cos(I=Math.atan2((V=W[0])[1]-(X=W[1])[1],V[0]-X[0]))*(v||0),G=Math.sin(I)*(v||0)}var H=-1,Y=-1;if(D.forEach((function(r,i){var o,a=u(r),s=a[0],l=a.slice(1),_=D[i+1],h=0===i&&(0!==L||0!==F),E=(i===D.length-1||_&&("M"===_[0]||"Z"===_[0]))&&0!==w&&0!==G;if("M"===s)Y++,m[Y]=[],H=m[Y].length,h?m[Y].push(l[0]-d+L,l[1]-p+F,f,l[0]-d,l[1]-p,f):m[Y].push(l[0]-d,l[1]-p,f);else if("L"===s)E?m[Y].push(l[0]-d+w,l[1]-p+G,f):m[Y].push(l[0]-d,l[1]-p,f);else if("Q"===s)vo(l[0]-d,l[1]-p,l[2]-d,l[3]-p,m[Y],n),E&&m[Y].push(l[2]-d+w,l[3]-p+G,f);else if("A"===s){for(var R=u(b[i].prePoint,2),v=U(R[0],R[1],l[0],l[1],l[2],l[3],l[4],l[5],l[6],void 0),T=0;v.length>T;T+=6)To(v[T]-d,v[T+1]-p,v[T+2]-d,v[T+3]-p,v[T+4]-d,v[T+5]-p,m[Y],n);E&&m[Y].push(l[5]-d+w,l[6]-p+G,f)}else if("C"===s)To(l[0]-d,l[1]-p,l[2]-d,l[3]-p,l[4]-d,l[5]-p,m[Y],n),E&&m[Y].push(l[4]-d+w,l[5]-p+G,f);else if("Z"===s&&(e.nodeName===t.Shape.PATH||e.nodeName===t.Shape.RECT)){var A=1e-4;(Math.abs(m[Y][m[Y].length-2]-m[Y][H])>A||Math.abs(m[Y][m[Y].length-1]-m[Y][H+1])>A)&&m[Y].push(m[Y][H],m[Y][H+1],f),(o=m[Y]).push.apply(o,c([],u(Do(m[Y][H],m[Y][H+1],m[Y][H+2],m[Y][H+3],m[Y][H+4],m[Y][H+5])),!1))}})),r)return{pointsBuffer:$=m[i],travelBuffer:[],triangles:A=Cn($,[],3),instancedCount:Math.round($.length/Oo)}}var z=function(e){var t;switch(e){case"bevel":t=Mo.JOINT_BEVEL;break;case"round":t=Mo.JOINT_ROUND;break;default:t=Mo.JOINT_MITER}return t}(l),K=function(e){var t;switch(e){case"square":t=Mo.CAP_SQUARE;break;case"round":t=Mo.CAP_ROUND;break;default:t=Mo.CAP_BUTT}return t}(s),j=K;K===Mo.CAP_ROUND&&(j=Mo.JOINT_CAP_ROUND),K===Mo.CAP_BUTT&&(j=Mo.JOINT_CAP_BUTT),K===Mo.CAP_SQUARE&&(j=Mo.JOINT_CAP_SQUARE);for(var Z=m[i],q=(Math.round(0/Oo)+2)*xo,Q=0,$=[],J=[],ee=0;Z.length>ee;ee+=Oo)ee>1&&(Q+=Math.sqrt(Math.pow(Z[ee]-Z[ee-Oo],2)+Math.pow(Z[ee+1]-Z[ee+1-Oo],2)+Math.pow(Z[ee+2]-Z[ee+2-Oo],2))),J.push(Q),$[q++]=Z[ee],$[q++]=Z[ee+1],$[q++]=Z[ee+2]||0,$[q]=z,0==ee&&K!==Mo.CAP_ROUND&&($[q]+=K),Z.length>ee+2*Oo?Z.length>ee+Oo||($[q]=0):$[q]+=j-z,q++;return $[q++]=Z[Z.length-6],$[q++]=Z[Z.length-5],$[q++]=Z[Z.length-4]||f,$[q++]=0,$[0]=Z[0],$[1]=Z[1],$[2]=Z[2]||f,$[3]=0,$[4]=Z[3],$[5]=Z[4],$[6]=Z[5]||f,$[7]=K===Mo.CAP_ROUND?K:0,{pointsBuffer:$,travelBuffer:J,triangles:A,instancedCount:Math.round(Z.length/Oo)}}function Do(e,t,r,n,i,o){void 0===n&&(n=e),void 0===i&&(i=t),void 0===o&&(o=r);var a=[n-e,i-t,o-r],s=.01;return[e+a[0]*s,t+a[1]*s,r+a[2]*s]}var bo,Lo;!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE"}(bo||(bo={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3"}(Lo||(Lo={}));var Fo,Uo,wo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.trianglesHash=[[],[]],l.trianglesHash=l.calcSegmentNum(i),l}return n(r,e),r.prototype.calcSegmentNum=function(e){var t=Bo(e,!0,12,this.calcSubpathIndex(e));return[t.triangles,t.pointsBuffer]},r.prototype.calcSubpathIndex=function(e){return e.nodeName===t.Shape.PATH?this.index:0},r.prototype.compareTrianglesHash=function(e){var t=u(this.trianglesHash,2),r=t[0],n=t[1],i=u(e,2),o=i[0],a=i[1];return r.length===o.length&&n.length===a.length&&(!r.some((function(e,t){return e!==o[t]}))&&!n.some((function(e,t){return e!==a[t]})))},r.prototype.shouldMerge=function(t,r){if(!e.prototype.shouldMerge.call(this,t,r))return!1;if(this.index!==r)return!1;var n=this.calcSegmentNum(t);return this.compareTrianglesHash(n)},r.prototype.createGeometry=function(t){var r=this,n=[],i=[],o=[],a=0;if(t.forEach((function(e,t){var s=Bo(e,!0,12,r.calcSubpathIndex(e)),l=s.triangles,f=s.pointsBuffer;if(l.length){var d=e.getGeometryBounds().halfExtents,p=[];f.forEach((function(e,t){t%3!=2&&p.push(e/d[t%3]/2)})),a+=i.length/3,i.push.apply(i,c([],u(f),!1)),o.push.apply(o,c([],u(p),!1)),n.push.apply(n,c([],u(l.map((function(e){return e+a}))),!1))}})),i.length){e.prototype.createGeometry.call(this,t);var s=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:bo.PACKED_STYLE,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Lo.PACKED_STYLE3,divisor:1}],data:new Float32Array(s)}),this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:ao.UV}],data:new Float32Array(o)}),this.geometry.vertexCount=n.length/t.length,this.geometry.setIndexBuffer(new Uint32Array(n))}},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(a_Position.xy, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, vec3(0.0));\n } else {\n gl_Position = project(vec4(a_Position.xy, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main(){\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}",this.material.defines=i(i(i({},this.material.defines),to(Lo)),{INSTANCED:!0})},r.prototype.updateAttribute=function(t,r,n,i){if(0!==t.length&&(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n)){var o=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;o.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(bo.PACKED_STYLE,Lo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(o).buffer))}},r}(fo),Go=[0,-.5,0,0,0,1,-.5,1,1,0,1,.5,1,1,1,0,.5,0,0,1];!function(e){e[e.POINT=5]="POINT",e[e.CAP=6]="CAP",e[e.DASH=7]="DASH"}(Fo||(Fo={})),function(e){e[e.POSITION=8]="POSITION",e[e.UV=10]="UV",e[e.POINTA=9]="POINTA",e[e.POINTB=11]="POINTB",e[e.CAP=12]="CAP",e[e.DASH=13]="DASH"}(Uo||(Uo={}));var ko,Vo,Xo={butt:1,round:2,square:3},Wo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.gradientAttributeName="stroke",l}return n(r,e),r.isLine=function(e,r){if(e.nodeName===t.Shape.PATH){for(var n=e.parsedStyle.d.absolutePath,i=0,o=0,a=0;n.length>a;a++){if("M"===n[a][0]){if(i===r){o=a;break}i++}}if("M"===n[o][0]&&"L"===n[o+1][0]&&(void 0===n[o+2]||"M"===n[o+2][0]))return!0}else if(e.nodeName===t.Shape.POLYLINE){var s=e.parsedStyle.points.points,l=(s[1][0]-s[1][1])/(s[0][0]-s[0][1]);for(a=1;s.length-1>a;a++)if((s[a+1][0]-s[a+1][1])/(s[a][0]-s[a][1])!==l)return!1;return!0}return!1},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)},r.prototype.createMaterial=function(e){this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = POINTA) in vec3 a_PointA;\nlayout(location = POINTB) in vec3 a_PointB;\nlayout(location = CAP) in float a_Cap;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\nlayout(location = DASH) in vec4 a_Dash;\n\nout vec4 v_Dash;\nout vec2 v_Distance;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n float strokeWidth;\n if (u_IsPicking > 0.5) {\n strokeWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n strokeWidth = u_StrokeWidth;\n }\n float clampedStrokeWidth = max(strokeWidth, 1.0);\n\n bool isSizeAttenuation = a_Dash.w > 0.5;\n if (isSizeAttenuation) {\n vec4 clip0 = project(vec4(a_PointA, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n vec4 clip1 = project(vec4(a_PointB, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n // screen space\n vec2 screen0 = u_Viewport * (0.5 * clip0.xy / clip0.w + 0.5);\n vec2 screen1 = u_Viewport * (0.5 * clip1.xy / clip1.w + 0.5);\n vec2 xBasis = normalize(screen1 - screen0);\n vec2 yBasis = vec2(-xBasis.y, xBasis.x);\n vec2 pt0 = screen0 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt1 = screen1 + clampedStrokeWidth * (a_Position.x * xBasis + a_Position.y * yBasis);\n vec2 pt = mix(pt0, pt1, a_Position.z);\n vec4 clip = mix(clip0, clip1, a_Position.z);\n gl_Position = vec4(clip.w * (2.0 * pt / u_Viewport - 1.0), clip.z, clip.w);\n } else {\n vec2 xBasis = a_PointB.xy - a_PointA.xy;\n vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));\n\n vec2 point = a_PointA.xy + xBasis * a_Position.x + yBasis * clampedStrokeWidth * a_Position.y;\n point = point - u_Anchor.xy * abs(xBasis);\n\n // round & square\n if (a_Cap > 1.0) {\n point += sign(a_Position.x - 0.5) * normalize(xBasis) * vec2(clampedStrokeWidth / 2.0);\n }\n gl_Position = project(vec4(point, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n float antialiasblur = 1.0 / strokeWidth;\n v_Distance = vec2(a_Position.y * 2.0, antialiasblur);\n v_Dash = vec4(a_Position.x, a_Dash.xyz);\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nin vec4 v_Dash;\nin vec2 v_Distance;\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n #ifdef USE_MAP\n outputColor = u_Color;\n #endif\n\n float blur;\n if (v_Distance.y < 1.0) {\n blur = smoothstep(0.0, v_Distance.y, 1.0 - abs(v_Distance.x));\n } else {\n blur = 1.0 / v_Distance.y;\n }\n float u_dash_offset = v_Dash.y;\n float u_dash_array = v_Dash.z;\n float u_dash_ratio = v_Dash.w;\n\n outputColor.a = outputColor.a\n * max(blur, 0.5)\n * u_Opacity * u_StrokeOpacity\n * (u_dash_array < 1.0 ? (ceil((u_dash_array * u_dash_ratio) - mod(v_Dash.x + u_dash_offset, u_dash_array))) : 1.0);\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}",this.material.defines=i(i({},this.material.defines),to(Uo))},r.prototype.calcSubpathIndex=function(e){if(e.nodeName===t.Shape.PATH){var r=this.drawcallCtors.filter((function(e){return e===wo})).length;return this.index-r}return 0},r.prototype.createGeometry=function(r){var n=this;e.prototype.createGeometry.call(this,r);var i=[],o=[],a=[],s=[],l=0;r.forEach((function(e){var r,u;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle,u=e.getTotalLength();else if(e.nodeName===t.Shape.POLYLINE){var c=e.parsedStyle,f=c.points.points;r={x1:f[0][0],y1:f[0][1],x2:f[f.length-1][0],y2:f[f.length-1][1],z1:0,z2:0,lineCap:c.lineCap,lineDash:h=c.lineDash,lineDashOffset:E=c.lineDashOffset,isBillboard:c.isBillboard,isSizeAttenuation:c.isSizeAttenuation,markerStart:R=c.markerStart,markerEnd:v=c.markerEnd,markerStartOffset:T=c.markerStartOffset,markerEndOffset:m=c.markerEndOffset},u=e.getTotalLength()}else if(e.nodeName===t.Shape.PATH){for(var d=e.parsedStyle,p=d.d.absolutePath,_=d.lineCap,h=d.lineDash,E=d.lineDashOffset,R=d.markerStart,v=d.markerEnd,T=d.markerStartOffset,m=d.markerEndOffset,A=d.isBillboard,g=d.isSizeAttenuation,y=0,S=0,C=n.calcSubpathIndex(e),P=0;p.length>P;P++){if("M"===p[P][0]){if(y===C){S=P;break}y++}}r={x1:p[S][1],y1:p[S][2],x2:p[S+1][1],y2:p[S+1][2],z1:0,z2:0,lineCap:_,lineDash:h,lineDashOffset:E,isBillboard:A,isSizeAttenuation:g,markerStart:R,markerEnd:v,markerStartOffset:T,markerEndOffset:m},u=e.getTotalLength()}var N=r.x1,M=r.y1,I=r.x2,O=r.y2,x=r.z1,B=r.z2,D=r.lineCap,b=r.isBillboard,L=r.isSizeAttenuation,F=n.calcOffset(r),U=F.startOffsetX,w=F.startOffsetY,G=F.endOffsetX,k=F.endOffsetY,V=n.calcDash(r,u),X=V.dashOffset,W=V.dashSegmentPercent,H=V.dashRatioInEachSegment;o.push(Xo[D]),a.push(X,W,H,b||L?1:0),i.push(N+U,M+w,x,I+G,O+k,B),s.push(0+l,2+l,1+l,0+l,3+l,2+l),l+=4})),this.geometry.setIndexBuffer(new Uint32Array(s)),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:20,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Uo.POSITION,divisor:0},{format:fe.F32_RG,bufferByteOffset:12,location:Uo.UV,divisor:0}],data:new Float32Array(Go)}),this.geometry.setVertexBuffer({bufferIndex:Fo.POINT,byteStride:24,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:Uo.POINTA,divisor:1},{format:fe.F32_RGB,bufferByteOffset:12,location:Uo.POINTB,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:Fo.CAP,byteStride:4,stepMode:$.INSTANCE,attributes:[{format:fe.F32_R,bufferByteOffset:0,location:Uo.CAP,divisor:1}],data:new Float32Array(o)}),this.geometry.setVertexBuffer({bufferIndex:Fo.DASH,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Uo.DASH,divisor:1}],data:new Float32Array(a)})},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(0!==r.length)if(e.prototype.updateAttribute.call(this,r,n,i,o),this.updateBatchedAttribute(r,n,i,o),"x1"===i||"y1"===i||"x2"===i||"y2"===i||"z1"===i||"z2"===i||"markerStartOffset"===i||"markerEndOffset"===i||"markerStart"===i||"markerEnd"===i||"points"===i||"d"===i){var s=[];r.forEach((function(e){var r;if(e.nodeName===t.Shape.LINE)r=e.parsedStyle;else if(e.nodeName===t.Shape.POLYLINE){var n=e.parsedStyle,i=n.points.points;r={x1:i[0][0],y1:i[0][1],x2:i[i.length-1][0],y2:i[i.length-1][1],z1:0,z2:0,lineCap:n.lineCap,isSizeAttenuation:n.isSizeAttenuation,isBillboard:n.isBillboard,markerStart:n.markerStart,markerEnd:n.markerEnd,markerStartOffset:n.markerStartOffset,markerEndOffset:n.markerEndOffset}}else if(e.nodeName===t.Shape.PATH){var o=e.parsedStyle,l=o.d.absolutePath;r={x1:l[0][1],y1:l[0][2],x2:l[1][1],y2:l[1][2],z1:0,z2:0,lineCap:o.lineCap,isBillboard:o.isBillboard,isSizeAttenuation:o.isSizeAttenuation,markerStart:o.markerStart,markerEnd:o.markerEnd,markerStartOffset:o.markerStartOffset,markerEndOffset:o.markerEndOffset}}var u=r.x1,c=r.y1,f=r.x2,d=r.y2,p=r.z1,_=r.z2,h=a.calcOffset(r);s.push(u+h.startOffsetX,c+h.startOffsetY,p,f+h.endOffsetX,d+h.endOffsetY,_)})),this.geometry.updateVertexBuffer(Fo.POINT,Uo.POINTA,n,new Uint8Array(new Float32Array(s).buffer))}else if("lineDashOffset"===i||"lineDash"===i||"isSizeAttenuation"===i||"isBillboard"===i){var l=[];r.forEach((function(e){var t=e.getTotalLength(),r=a.calcDash(e.parsedStyle,t);l.push(r.dashOffset,r.dashSegmentPercent,r.dashRatioInEachSegment,e.parsedStyle.isBillboard||e.parsedStyle.isSizeAttenuation?1:0)})),this.geometry.updateVertexBuffer(Fo.DASH,Uo.DASH,n,new Uint8Array(new Float32Array(l).buffer))}else if("lineCap"===i){var u=[];r.forEach((function(e){u.push(Xo[e.parsedStyle.lineCap])})),this.geometry.updateVertexBuffer(Fo.CAP,Uo.CAP,n,new Uint8Array(new Float32Array(u).buffer))}},r.prototype.calcOffset=function(e){var r=e.x1,n=e.y1,i=e.x2,o=e.y2,a=e.markerStart,s=e.markerEnd,l=e.markerStartOffset,u=e.markerEndOffset,c=0,f=0,d=0,p=0,_=0;return a&&t.isDisplayObject(a)&&l&&(c=Math.cos(_=Math.atan2(o-n,i-r))*(l||0),f=Math.sin(_)*(l||0)),s&&t.isDisplayObject(s)&&u&&(d=Math.cos(_=Math.atan2(n-o,r-i))*(u||0),p=Math.sin(_)*(u||0)),{startOffsetX:c,startOffsetY:f,endOffsetX:d,endOffsetY:p}},r.prototype.calcDash=function(e,t){var r=e.lineDash,n=0,i=1,o=0;if(r&&r.length){n=(e.lineDashOffset||0)/t;var a=r.reduce((function(e,t){return e+t}),0);0===a?(i=1,o=0):(i=a/t,o=r[1]/a)}return{dashOffset:n,dashSegmentPercent:i,dashRatioInEachSegment:o}},r}(fo);!function(e){e[e.PACKED_STYLE=5]="PACKED_STYLE",e[e.SIZE=8]="SIZE"}(ko||(ko={})),function(e){e[e.PACKED_STYLE3=12]="PACKED_STYLE3",e[e.SIZE=13]="SIZE"}(Vo||(Vo={}));var Ho=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&this.instance.parsedStyle.src===t.parsedStyle.src},t.prototype.createMaterial=function(e){var t=e[0].parsedStyle.src;this.material.defines=i(i({},this.material.defines),to(Vo)),this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = SIZE) in vec2 a_Size;\nlayout(location = PACKED_STYLE3) in vec4 a_StylePacked3;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n bool isBillboard = a_StylePacked3.x > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked3.y;\n bool isSizeAttenuation = a_StylePacked3.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position);\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n#endif\n\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n\n // TODO: pointer-events: non-transparent-pixel\n // if (u_Color.x == 0.0 && u_Color.y == 0.0 && u_Color.z == 0.0) {\n // discard;\n // }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n\n if (outputColor.a < epsilon) {\n discard;\n }\n }\n}";var r=this.texturePool.getOrCreateTexture(this.context.device,t,void 0);this.material.setUniforms({u_Map:r})},t.prototype.createGeometry=function(t){e.prototype.createGeometry.call(this,t);var r=[],n=[],i=[];t.forEach((function(e,t){var o=e.parsedStyle,a=o.x,s=o.y,l=o.z,u=o.width,c=o.height,f=o.isBillboard,d=o.billboardRotation,p=o.isSizeAttenuation;r.push(void 0===a?0:a,void 0===s?0:s,void 0===l?0:l),n.push(u,c),i.push(f?1:0,null!=d?d:0,p?1:0,0)})),this.geometry.setIndexBuffer(new Uint32Array([0,2,1,0,3,2])),this.geometry.vertexCount=6,this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(r)}),this.geometry.setVertexBuffer({bufferIndex:ko.SIZE,byteStride:8,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:Vo.SIZE}],data:new Float32Array(n)}),this.geometry.setVertexBuffer({bufferIndex:ko.PACKED_STYLE,byteStride:16,stepMode:$.INSTANCE,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:Vo.PACKED_STYLE3,divisor:1}],data:new Float32Array(i)}),this.geometry.setVertexBuffer({bufferIndex:oo.UV,byteStride:8,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:ao.UV}],data:new Float32Array([0,0,1,0,1,1,0,1])})},t.prototype.updateAttribute=function(t,r,n,i){if(0!==t.length)if(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i),"x"===n||"y"===n||"z"===n){var o=[];t.forEach((function(e){var t=e.parsedStyle,r=t.x,n=t.y,i=t.z;o.push(void 0===r?0:r,void 0===n?0:n,void 0===i?0:i)})),this.geometry.updateVertexBuffer(oo.POSITION,ao.POSITION,r,new Uint8Array(new Float32Array(o).buffer))}else if("width"===n||"height"===n){var a=[];t.forEach((function(e){var t=e.parsedStyle;a.push(t.width,t.height)})),this.geometry.updateVertexBuffer(ko.SIZE,Vo.SIZE,r,new Uint8Array(new Float32Array(a).buffer))}else if("isBillboard"===n||"billboardRotation"===n||"isSizeAttenuation"===n){var s=[];t.forEach((function(e){var t=e.parsedStyle,r=t.billboardRotation;s.push(t.isBillboard?1:0,null!=r?r:0,t.isSizeAttenuation?1:0,0)})),this.geometry.updateVertexBuffer(ko.PACKED_STYLE,Vo.PACKED_STYLE3,r,new Uint8Array(new Float32Array(s).buffer))}else if("src"===n){var l=this.texturePool.getOrCreateTexture(this.context.device,i);this.material.setUniforms({u_Map:l})}},t}(fo);function Yo(e,t,r,n){var i=t.width,o=t.height;if(n){if(n.length!==i*o*r)throw new RangeError("mismatched image size")}else n=new Uint8Array(i*o*r);return e.width=i,e.height=o,e.data=n,e}function zo(e,t,r,n,i,o){if(0===i.width||0===i.height)return t;if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");for(var a=e.data,s=t.data,l=0;i.height>l;l++)for(var u=((r.y+l)*e.width+r.x)*o,c=((n.y+l)*t.width+n.x)*o,f=0;i.width*o>f;f++)s[c+f]=a[u+f];return t}var Ko=function(){function e(e,t){Yo(this,e,1,t)}return e.prototype.resize=function(e){!function(e,t,r){var n=t.width,i=t.height;if(n!==e.width||i!==e.height){var o=Yo({},{width:n,height:i},r);zo(e,o,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,n),height:Math.min(e.height,i)},r),e.width=n,e.height=i,e.data=o.data}}(this,e,1)},e.prototype.clone=function(){return new e({width:this.width,height:this.height},new Uint8Array(this.data))},e.copy=function(e,t,r,n,i){zo(e,t,r,n,i,1)},e}();var jo=function(e){var t={},r=[];for(var n in e){var i=e[n],o=t[n]={};for(var a in i)(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&(r.push(f={x:0,y:0,w:c.bitmap.width+2,h:c.bitmap.height+2}),o[a]={rect:f,metrics:c.metrics})}var s=function(e){var t,r,n,i,o=0,a=0;try{for(var s=l(e),u=s.next();!u.done;u=s.next())o+=(h=u.value).w*h.h,a=Math.max(a,h.w)}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}e.sort((function(e,t){return t.h-e.h}));var c=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(o/.95)),a),h:1/0}],f=0,d=0;try{for(var p=l(e),_=p.next();!_.done;_=p.next())for(var h=_.value,E=c.length-1;E>=0;E--){var R=c[E];if(R.w>=h.w&&R.h>=h.h){if(h.x=R.x,h.y=R.y,d=Math.max(d,h.y+h.h),f=Math.max(f,h.x+h.w),h.w===R.w&&h.h===R.h){var v=c.pop();c.length>E&&(c[E]=v)}else h.h===R.h?(R.x+=h.w,R.w-=h.w):h.w===R.w?(R.y+=h.h,R.h-=h.h):(c.push({x:R.x+h.w,y:R.y,w:R.w-h.w,h:h.h}),R.y+=h.h,R.h-=h.h);break}}}catch(e){n={error:e}}finally{try{_&&!_.done&&(i=p.return)&&i.call(p)}finally{if(n)throw n.error}}return{w:f,h:d,fill:o/(f*d)||0}}(r),u=new Ko({width:s.w||1,height:s.h||1});for(var n in e)for(var a in i=e[n]){var c,f;(c=i[+a])&&0!==c.bitmap.width&&0!==c.bitmap.height&&Ko.copy(c.bitmap,u,{x:0,y:0},{x:(f=t[n][a].rect).x+1,y:f.y+1},c.bitmap)}this.image=u,this.positions=t};var Zo,qo,Qo,$o=function(){function e(e){this.runtime=e,this.sdfGeneratorCache={},this.textMetricsCache={},this.glyphMap={}}return e.prototype.destroy=function(){this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy()},e.prototype.getMap=function(){return this.glyphMap},e.prototype.getAtlas=function(){return this.glyphAtlas},e.prototype.getAtlasTexture=function(){return this.glyphAtlasTexture},e.prototype.layout=function(e,t,r,n,i,o,a){var s=this,l=[],u=o,c=a,f="right"===n||"end"===n?1:"left"===n||"start"===n?0:.5;return e.forEach((function(e){var n=l.length;Array.from(e).forEach((function(e){var r=s.glyphMap[t],n=e.charCodeAt(0),o=r&&r[n];o&&(l.push({glyph:n,x:u,y:c,scale:1,fontStack:t}),u+=o.metrics.advance+i)}));for(var o=u-i,a=n;l.length>a;a++)l[a].x=l[a].x-f*o;u=0,c+=r})),l},e.prototype.generateAtlas=function(e,t,r,n,o,a,s){var l=this;void 0===t&&(t=""),void 0===o&&(o="");var u=[];this.glyphMap[t]||(u=function(){for(var e=[],t=32;128>t;t++)e.push(String.fromCharCode(t));return e}());var c=Object.keys(this.glyphMap[t]||{});if(Array.from(new Set(a.split(""))).forEach((function(e){-1===c.indexOf(""+e.charCodeAt(0))&&u.push(e)})),u.length){var f=u.map((function(i){return l.generateSDF(e,t,r,n,o,i)})).reduce((function(e,t){return e[t.id]=t,e}),{});this.glyphMap[t]=i(i({},this.glyphMap[t]),f),this.glyphAtlas=new jo(this.glyphMap);var d=this.glyphAtlas.image,p=d.width,_=d.height,h=d.data;this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.glyphAtlasTexture=s.createTexture(i(i({},pe(fe.ALPHA,p,_,1)),{pixelStore:{unpackFlipY:!1,unpackAlignment:1}})),this.glyphAtlasTexture.setImageData([h])}},e.prototype.generateSDF=function(e,t,r,n,i,o){void 0===t&&(t="");var a=o.charCodeAt(0),s=this.sdfGeneratorCache[t];s||(s=this.sdfGeneratorCache[t]=new yo({canvas:e,fontSize:24,fontFamily:r,fontWeight:n,fontStyle:i,buffer:3,radius:8,cutoff:.25},this.runtime)),this.textMetricsCache[t]||(this.textMetricsCache[t]={}),this.textMetricsCache[t][o]||(this.textMetricsCache[t][o]=s.ctx.measureText(o).width);var l=s.draw(o),u=l.glyphWidth,c=l.glyphHeight,f=l.glyphLeft,d=l.glyphTop,p=l.glyphAdvance;return{id:a,bitmap:new Ko({width:l.width,height:l.height},l.data),metrics:{width:u,height:c,left:f,top:d-24+3,advance:p}}},e}();!function(e){e[e.INSTANCED=5]="INSTANCED",e[e.TEX=6]="TEX"}(Zo||(Zo={})),function(e){e[e.TEX=12]="TEX",e[e.OFFSET=13]="OFFSET"}(qo||(qo={})),function(e){e.SDF_MAP="u_SDFMap",e.SDF_MAP_SIZE="u_SDFMapSize",e.FONT_SIZE="u_FontSize",e.GAMMA_SCALE="u_GammaScale",e.STROKE_BLUR="u_StrokeBlur",e.HAS_STROKE="u_HasStroke"}(Qo||(Qo={}));var Jo=function(e){function r(t,r,n,i,o,a,s){var l=e.call(this,t,r,n,i,o,a,s)||this;return l.renderHelper=t,l.texturePool=r,l.lightPool=n,l.packedBufferObjectMap=new WeakMap,l.tmpMat4=T(),l.fontHash=l.calcFontHash(i),l.glyphManager=new $o(l.context),l}return n(r,e),r.prototype.calcFontHash=function(e){e.getBounds();return e.parsedStyle.metrics.font+["fontSize","fontFamily","fontWeight","textBaseline","letterSpacing"].reduce((function(t,r){return t+e.parsedStyle[r]}),"")},r.prototype.shouldMerge=function(t,r){return!!e.prototype.shouldMerge.call(this,t,r)&&(this.index===r&&this.fontHash===this.calcFontHash(t))},r.prototype.createGeometry=function(e){var t=this,r=this.instance,n=r.parsedStyle,i=n.fontSize,o=n.letterSpacing,a=void 0===o?0:o,s=r.parsedStyle.textBaseline,l=void 0===s?"alphabetic":s,f=24/(void 0===i?16:i),d=[],p=[],_=[],h=[],E=0;e.forEach((function(e){var r=e.parsedStyle,n=r.metrics,i=r.dx,o=r.dy,s=n.font,R=n.lines,v=n.height,T=n.lineHeight,m=void 0===i?0:i,A=void 0===o?0:o;"alphabetic"===l&&(l="bottom");var g=0;"middle"===l?g+=-v/2:"bottom"===l?g+=-v:"top"===l||"hanging"===l?g+=0:"ideographic"===l&&(g+=-v);var y=t.glyphManager.getAtlas(),S=t.buildTextBuffers({object:e,lines:R,fontStack:s,lineHeight:f*T,offsetX:f*m,offsetY:f*(g+A),letterSpacing:f*a,glyphAtlas:y,indicesOffset:E}),C=S.indexBuffer,P=S.charUVOffsetBuffer,N=S.charPositionsBuffer;E=S.indicesOffset;var M=h.length;h.push.apply(h,c([],u(S.charPackedBuffer),!1)),t.packedBufferObjectMap.set(e,[M,h.length]),_.push.apply(_,c([],u(P),!1)),p.push.apply(p,c([],u(N),!1)),d.push.apply(d,c([],u(C),!1))})),this.geometry.vertexCount=d.length,this.geometry.setIndexBuffer(new Uint32Array(d)),this.geometry.setVertexBuffer({bufferIndex:Zo.INSTANCED,byteStride:128,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGBA,bufferByteOffset:0,location:ao.MODEL_MATRIX0},{format:fe.F32_RGBA,bufferByteOffset:16,location:ao.MODEL_MATRIX1},{format:fe.F32_RGBA,bufferByteOffset:32,location:ao.MODEL_MATRIX2},{format:fe.F32_RGBA,bufferByteOffset:48,location:ao.MODEL_MATRIX3},{format:fe.F32_RGBA,bufferByteOffset:64,location:ao.PACKED_COLOR},{format:fe.F32_RGBA,bufferByteOffset:80,location:ao.PACKED_STYLE1},{format:fe.F32_RGBA,bufferByteOffset:96,location:ao.PACKED_STYLE2},{format:fe.F32_RGBA,bufferByteOffset:112,location:ao.PICKING_COLOR}],data:new Float32Array(h)}),this.geometry.setVertexBuffer({bufferIndex:oo.POSITION,byteStride:12,stepMode:$.VERTEX,attributes:[{format:fe.F32_RGB,bufferByteOffset:0,location:ao.POSITION}],data:new Float32Array(p)}),this.geometry.setVertexBuffer({bufferIndex:Zo.TEX,byteStride:16,stepMode:$.VERTEX,attributes:[{format:fe.F32_RG,bufferByteOffset:0,location:qo.TEX},{format:fe.F32_RG,bufferByteOffset:8,location:qo.OFFSET}],data:new Float32Array(_)})},r.prototype.createMaterial=function(e){var t;this.material.vertexShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = PACKED_COLOR) in vec4 a_PackedColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\n\nvec2 unpack_float(const float packedValue) {\n int packedIntValue = int(packedValue);\n int v0 = packedIntValue / 256;\n return vec2(v0, packedIntValue - v0 * 256);\n}\nvec4 decode_color(const vec2 encodedColor) {\n return vec4(\n unpack_float(encodedColor[0]) / 255.0,\n unpack_float(encodedColor[1]) / 255.0\n );\n}\n\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nbool isPerspectiveMatrix(mat4 m) {\n return m[2][3] == -1.0;\n}\n\nvec4 billboard(vec2 offset, float rotation, bool isSizeAttenuation, mat4 pm, mat4 vm, mat4 mm, vec3 position) {\n vec4 mvPosition = vm * mm * vec4(position, 1.0);\n vec2 scale;\n scale.x = length(vec3(mm[0][0], mm[0][1], mm[0][2]));\n scale.y = length(vec3(mm[1][0], mm[1][1], mm[1][2]));\n\n if (isSizeAttenuation) {\n bool isPerspective = isPerspectiveMatrix(pm);\n if (isPerspective) {\n scale *= -mvPosition.z / 250.0;\n }\n }\n\n vec2 alignedPosition = offset * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\n rotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\n\n mvPosition.xy += rotatedPosition;\n return pm * mvPosition;\n}\n\nlayout(location = POSITION) in vec3 a_Position;\nlayout(location = TEX) in vec2 a_Tex;\nlayout(location = OFFSET) in vec2 a_Offset;\n\nout vec2 v_Uv;\n\nvoid main() {\n vec4 a_Color = decode_color(a_PackedColor.xy);\nvec4 a_StrokeColor = decode_color(a_PackedColor.zw);\n\nmat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n// #ifdef CLIPSPACE_NEAR_ZERO\n// gl_Position.z = (gl_Position.z + gl_Position.w) * 0.5;\n// #endif\n\n v_Uv = a_Tex / u_SDFMapSize;\n float fontScale = u_FontSize / 24.;\n\n vec2 bufferOffset = vec2(0.7, 2.0);\n vec2 offset = a_Offset * fontScale + + bufferOffset;\n\n bool isBillboard = a_StylePacked2.y > 0.5;\n if (isBillboard) {\n float rotation = a_StylePacked2.w;\n bool isSizeAttenuation = a_StylePacked2.z > 0.5;\n gl_Position = billboard(offset, rotation, isSizeAttenuation, u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix, a_Position );\n } else {\n gl_Position = project(vec4(a_Position.xy + offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n}",this.material.fragmentShader="#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\nlayout(std140) uniform ub_ObjectParams {\n vec2 u_SDFMapSize;\n float u_FontSize;\n float u_GammaScale;\n float u_StrokeBlur;\n float u_HasStroke;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n\nuniform sampler2D u_SDFMap;\n\n#define SDF_PX 8.0\n\nout vec4 outputColor;\nfloat epsilon = 0.000001;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n\n float dist = texture(SAMPLER_2D(u_SDFMap), v_Uv).a;\n\n float fontScale = u_FontSize / 24.0;\n lowp vec4 color = u_Color;\n lowp float buff = (256.0 - 64.0) / 256.0;\n float opacity = u_FillOpacity;\n if (u_HasStroke > 0.5 && u_StrokeWidth > 0.0) {\n color = u_StrokeColor;\n buff = (6.0 - u_StrokeWidth / fontScale / 2.0) / SDF_PX;\n opacity = u_StrokeOpacity;\n }\n\n highp float gamma_scaled = fwidth(dist);\n highp float alpha = smoothstep(buff - gamma_scaled, buff + gamma_scaled, dist);\n\n opacity *= alpha * u_Opacity;\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n\n if (opacity < epsilon) {\n discard;\n }\n\n outputColor = color;\n outputColor.a *= opacity;\n }\n}",this.material.cullMode=W.BACK,this.material.defines=i(i({},this.material.defines),to(qo));var r=this.instance.parsedStyle,n=r.fontSize,o=void 0===n?16:n,a=r.fontFamily,s=void 0===a?"sans-serif":a,l=r.fontWeight,u=void 0===l?"normal":l,c=r.fontStyle,f=void 0===c?"normal":c,d=r.metrics.font,p=e.map((function(e){return e.parsedStyle.text})).join("");this.glyphManager.generateAtlas(this.texturePool.context.config.offscreenCanvas,d,s,""+u,f,p,this.context.device);var _=this.glyphManager.getAtlasTexture(),h=this.glyphManager.getAtlas();this.context.device.setResourceName(_,"TextSDF Texture");var E=h.image,R=E.width,v=E.height;this.material.setUniforms(((t={})[Qo.SDF_MAP]=_,t[Qo.SDF_MAP_SIZE]=[R,v],t[Qo.FONT_SIZE]=o,t[Qo.GAMMA_SCALE]=1,t[Qo.STROKE_BLUR]=.2,t[Qo.HAS_STROKE]=this.index,t))},r.prototype.changeRenderOrder=function(e,t){for(var r=this.geometry.vertices[Zo.INSTANCED],n=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Zo.INSTANCED].arrayStride/4,i=u(this.packedBufferObjectMap.get(e),2),o=i[0],a=i[1],s=r.slice(o,a),l=0;a-o>l;l+=n)s[l+n-1]=t*Qi;this.geometry.updateVertexBuffer(Zo.INSTANCED,ao.MODEL_MATRIX0,o/n,new Uint8Array(s.buffer))},r.prototype.updateAttribute=function(r,n,i,o){var a=this;if(0!==r.length)if(e.prototype.updateAttribute.call(this,r,n,i,o),"text"===i||"fontFamily"===i||"fontSize"===i||"fontWeight"===i||"fontStyle"===i||"fontVariant"===i||"textBaseline"===i||"letterSpacing"===i||"wordWrapWidth"===i||"lineHeight"===i||"wordWrap"===i||"textAlign"===i||"x"===i||"y"===i||"dx"===i||"dy"===i)this.material.programDirty=!0,this.material.geometryDirty=!0,this.material.textureDirty=!0;else if("modelMatrix"===i||"fill"===i||"fillOpacity"===i||"stroke"===i||"strokeOpacity"===i||"opacity"===i||"lineWidth"===i||"visibility"===i||"pointerEvents"===i||"isBillboard"===i||"billboardRotation"===i||"isSizeAttenuation"===i){var s=this.geometry.vertices[Zo.INSTANCED],l=this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[Zo.INSTANCED].arrayStride/4;r.forEach((function(e){var r,n=e.parsedStyle,i=n.fill,o=n.stroke,c=n.opacity,f=void 0===c?1:c,d=n.fillOpacity,p=void 0===d?1:d,_=n.strokeOpacity,h=void 0===_?1:_,E=n.lineWidth,R=void 0===E?1:E,v=n.visibility,T=n.isBillboard,A=n.billboardRotation,g=n.isSizeAttenuation,y=[0,0,0,0];t.isCSSRGB(i)&&(y=[Number(i.r),Number(i.g),Number(i.b),255*Number(i.alpha)]);var S=[0,0,0,0];t.isCSSRGB(o)&&(S=[Number(o.r),Number(o.g),Number(o.b),255*Number(o.alpha)]);for(var C=e.isInteractive()&&(null===(r=e.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],P=m(a.tmpMat4,e.getWorldTransform()),N=u(a.packedBufferObjectMap.get(e),2),M=N[0],I=N[1],O=s.slice(M,I),x=0;I-M>x;x+=l)O[x+0]=P[0],O[x+1]=P[1],O[x+2]=P[2],O[x+3]=P[3],O[x+4]=P[4],O[x+5]=P[5],O[x+6]=P[6],O[x+7]=P[7],O[x+8]=P[8],O[x+9]=P[9],O[x+10]=P[10],O[x+11]=P[11],O[x+12]=P[12],O[x+13]=P[13],O[x+14]=P[14],O[x+15]=P[15],O[x+16]=io(y[0],y[1]),O[x+17]=io(y[2],y[3]),O[x+18]=io(S[0],S[1]),O[x+19]=io(S[2],S[3]),O[x+20]=f,O[x+21]=p,O[x+22]=h,O[x+23]=R,O[x+24]="hidden"!==v?1:0,O[x+25]=T?1:0,O[x+26]=g?1:0,O[x+27]=null!=A?A:0,O[x+28]=C[0],O[x+29]=C[1],O[x+30]=C[2];a.geometry.updateVertexBuffer(Zo.INSTANCED,ao.MODEL_MATRIX0,M/l,new Uint8Array(O.buffer))}))}},r.prototype.buildTextBuffers=function(e){var r,n=e.object,i=e.lines,o=e.fontStack,a=e.lineHeight,s=e.letterSpacing,l=e.offsetX,f=e.offsetY,d=e.glyphAtlas,p=e.indicesOffset,_=n.parsedStyle,h=_.textAlign,E=void 0===h?"start":h,R=_.fill,v=_.stroke,T=_.opacity,A=void 0===T?1:T,g=_.fillOpacity,y=void 0===g?1:g,S=_.strokeOpacity,C=void 0===S?1:S,P=_.lineWidth,N=void 0===P?1:P,M=_.visibility,I=_.isBillboard,O=_.billboardRotation,x=_.isSizeAttenuation,B=_.x,D=void 0===B?0:B,b=_.y,L=void 0===b?0:b,F=_.z,U=void 0===F?0:F,w=[0,0,0,0];t.isCSSRGB(R)&&(w=[Number(R.r),Number(R.g),Number(R.b),255*Number(R.alpha)]);var G=[0,0,0,0];t.isCSSRGB(v)&&(G=[Number(v.r),Number(v.g),Number(v.b),255*Number(v.alpha)]);var k=n.isInteractive()&&(null===(r=n.renderable3D)||void 0===r?void 0:r.encodedPickingColor)||[0,0,0],V=m(this.tmpMat4,n.getWorldTransform()),X=[],W=[],H=[],Y=[],z=p,K=function(e,t){for(var r=[],n=0;e.length>n;n++){var i=e[n],o=t[i.fontStack],a=o&&o[i.glyph];if(a){var s=a.rect;if(s){var l=a.metrics.advance*i.scale/2,u=[i.x+l,i.y],c=(a.metrics.left-4)*i.scale-l+u[0],f=(-a.metrics.top-4)*i.scale+u[1],d=c+s.w*i.scale,p=f+s.h*i.scale;r.push({tl:{x:c,y:f},tr:{x:d,y:f},bl:{x:c,y:p},br:{x:d,y:p},tex:s,glyphOffset:[0,0]})}}}return r}(this.glyphManager.layout(i,o,a,E,s,l,f),d.positions);return K.forEach((function(e){var t=[];t.push.apply(t,c([],u(V),!1));var r=c(c(c(c([],u(t),!1),[io(w[0],w[1]),io(w[2],w[3]),io(G[0],G[1]),io(G[2],G[3]),A,y,C,N,"hidden"!==M?1:0,I?1:0,x?1:0,null!=O?O:0],!1),u(k),!1),[n.sortable.renderOrder*Qi],!1);X.push.apply(X,c(c(c(c([],u(r),!1),u(r),!1),u(r),!1),u(r),!1)),W.push(e.tex.x,e.tex.y,e.tl.x,e.tl.y),W.push(e.tex.x+e.tex.w,e.tex.y,e.tr.x,e.tr.y),W.push(e.tex.x+e.tex.w,e.tex.y+e.tex.h,e.br.x,e.br.y),W.push(e.tex.x,e.tex.y+e.tex.h,e.bl.x,e.bl.y),H.push(D,L,U,D,L,U,D,L,U,D,L,U),Y.push(0+z,2+z,1+z),Y.push(2+z,0+z,3+z),z+=4})),{indexBuffer:Y,charUVOffsetBuffer:W,charPositionsBuffer:H,charPackedBuffer:X,indicesOffset:z}},r.prototype.destroy=function(){e.prototype.destroy.call(this),this.glyphManager.destroy()},r}(fo),ea=function(e){function r(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.mergeXYZIntoModelMatrix=!1,t}return n(r,e),r.prototype.shouldMerge=function(r,n){return!!e.prototype.shouldMerge.call(this,r,n)&&(this.instance.nodeName!==t.Shape.MESH||this.instance.parsedStyle.material===r.parsedStyle.material&&this.instance.parsedStyle.geometry===r.parsedStyle.geometry)},r.prototype.updateAttribute=function(t,r,n,i){0!==t.length&&(e.prototype.updateAttribute.call(this,t,r,n,i),this.updateBatchedAttribute(t,r,n,i))},r.prototype.createMaterial=function(e){this.material=this.instance.parsedStyle.material,this.observeMaterialChanged()},r.prototype.createGeometry=function(t){this.geometry=this.instance.parsedStyle.geometry,e.prototype.createGeometry.call(this,t),this.geometry.build(t),this.observeGeometryChanged()},r}(fo),ta=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle.fill;return r&&!r.isNone&&t.push(_o),this.needDrawStrokeSeparately(e)&&t.push(Io),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}($i),ra=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return n(r,e),r.prototype.getDrawcallCtors=function(e){var r=e.parsedStyle,n=r.fill,i=r.stroke,o=r.opacity,a=r.strokeOpacity,s=r.lineWidth,l=i&&!i.isNone,u=Io.calcSubpathNum(e),c=[];if(e.nodeName!==t.Shape.POLYLINE&&!(null==n?void 0:n.isNone))for(var f=0;u>f;f++)c.push(wo);for(f=0;u>f;f++)if(0!==a&&0!==o&&0!==s&&l){var d=Wo.isLine(e,f);c.push(d?Wo:Io)}return c},r}($i);!function(e){function t(){return null!==e&&e.apply(this,arguments)||this}n(t,e),t.prototype.getDrawcallCtors=function(){return[]}}($i);var na=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Ho]},t}($i),ia=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.stroke,i=r.lineWidth;return!(!n||n.isNone||!(void 0===i?1:i))&&t.push(Jo),t.push(Jo),t},t.prototype.beforeUploadUBO=function(e,t){var r;t.material.setUniforms(((r={})[Qo.HAS_STROKE]=1===t.instance.renderable3D.drawcalls.length?0:1-t.index,r))},t}($i),oa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[Wo]},t}($i),aa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(){return[ea]},t}($i),sa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getDrawcallCtors=function(e){var t=[],r=e.parsedStyle,n=r.fill,i=r.radius,o=i&&i.length&&i.some((function(e){return e!==i[0]}));return(null==n?void 0:n.isNone)||o||t.push(_o),o&&t.push(wo),(o||this.needDrawStrokeSeparately(e))&&t.push(Io),t},t.prototype.needDrawStrokeSeparately=function(e){var t=e.parsedStyle,r=t.fill,n=t.stroke,i=t.lineDash,o=t.lineWidth,a=t.strokeOpacity,s=r&&!r.isNone,l=n&&!n.isNone,u=i&&i.length&&i.every((function(e){return 0!==e}));return!s||l&&o>0&&(1>a||u)},t}($i),la=1,ua=function(){function e(e,t,r,n){this.renderHelper=e,this.rendererFactory=t,this.texturePool=r,this.lightPool=n,this.drawcalls=[],this.pendingUpdatePatches={},this.stencilRefCache={}}return e.prototype.destroy=function(){this.drawcalls.forEach((function(e){e.destroy()})),this.drawcalls=[],this.pendingUpdatePatches={}},e.prototype.render=function(e,t){var r=this;void 0===t&&(t=!1),t||this.updatePendingPatches(),this.drawcalls.forEach((function(n){n.init();var i=n.objects;n.clipPathTarget&&(i=[n.clipPath]);var o=r.renderHelper.renderInstManager.newRenderInst();o.setAllowSkippingIfPipelineNotReady(!1),n.applyRenderInst(o,i),r.renderHelper.renderInstManager.submitRenderInst(o,e),t||n.objects.forEach((function(e){e.renderable.dirty=!1}))}))},e.prototype.attach=function(e){this.context=e},e.prototype.add=function(e){var t=this,r=e.renderable3D;if(r&&!r.drawcalls.length){var n=this.rendererFactory[e.nodeName];n&&n.getDrawcallCtors(e).forEach((function(i,o,a){var s=t.drawcalls.find((function(t){return i===t.constructor&&t.index===o&&t.maxInstances>t.objects.length&&t.shouldMerge(e,o)}));s&&s.key===e.parsedStyle.batchKey||((s=new i(t.renderHelper,t.texturePool,t.lightPool,e,a,o,t.context)).renderer=n,t.drawcalls.push(s),e.parsedStyle.batchKey&&(s.key=e.parsedStyle.batchKey)),s&&(s.objects.push(e),r.drawcalls[o]=s,s.geometryDirty=!0)}))}},e.prototype.remove=function(e){var t=this,r=e.renderable3D;r&&(r.drawcalls.forEach((function(r){if(r){var n=r.objects.indexOf(e);if(n>-1&&(r.objects.splice(n,1),r.geometryDirty=!0),0===r.objects.length)t.drawcalls.splice(t.drawcalls.indexOf(r),1).forEach((function(e){e.destroy()}))}})),r.drawcalls=[])},e.prototype.updateAttribute=function(e,t,r,n){var i=this;void 0===n&&(n=!1);var o=e.renderable3D,a=this.rendererFactory[e.nodeName];if(a){var s=a.getDrawcallCtors(e);if(s.forEach((function(s,l,u){var c=o.drawcalls.find((function(e){return e&&e.index===l&&e.constructor===s}));if(c||((c=o.drawcalls[l])&&(c.objects.splice(c.objects.indexOf(e),1),c.geometryDirty=!0,0===c.objects.length&&i.drawcalls.splice(i.drawcalls.indexOf(c),1),o.drawcalls[o.drawcalls.indexOf(c)]=void 0),(c=i.drawcalls.find((function(t){return s===t.constructor&&t.index===l&&t.maxInstances>t.objects.length&&t.shouldMerge(e,l)})))?c.geometryDirty=!0:((c=new s(i.renderHelper,i.texturePool,i.lightPool,e,u,l,i.context)).renderer=a,c.init(),i.drawcalls.push(c)),c.objects.push(e),o.drawcalls[l]=c),c.inited&&!c.geometryDirty)if(c.shouldMerge(e,l)){var f=c.objects.indexOf(e);if(n)e.parsedStyle[t]=r,c.updateAttribute([e],f,t,r);else{var d=c.id+t;i.pendingUpdatePatches[d]||(i.pendingUpdatePatches[d]={instance:c,objectIndices:[],name:t,value:r}),-1===i.pendingUpdatePatches[d].objectIndices.indexOf(f)&&i.pendingUpdatePatches[d].objectIndices.push(f)}}else i.remove(e),i.add(e);else i.remove(e),i.add(e)})),o.drawcalls.length>s.length)for(var l=o.drawcalls.length-1;l>=s.length;l--){var u=o.drawcalls[l];u.objects.splice(u.objects.indexOf(e),1),u.geometryDirty=!0,0===u.objects.length&&this.drawcalls.splice(this.drawcalls.indexOf(u),1),o.drawcalls.pop()}}},e.prototype.changeRenderOrder=function(e,t){var r=e.renderable3D;r&&r.drawcalls.length&&r.drawcalls.forEach((function(r){r&&r.inited&&!r.geometryDirty&&r.inited&&r.changeRenderOrder(e,t)}))},e.prototype.getStencilRef=function(e){return this.stencilRefCache[e.entity]||(this.stencilRefCache[e.entity]=la++),this.stencilRefCache[e.entity]},e.prototype.updatePendingPatches=function(){var e=this;Object.keys(this.pendingUpdatePatches).forEach((function(t){var r=e.pendingUpdatePatches[t],n=r.instance,i=r.objectIndices,o=r.name,a=r.value;i.sort((function(e,t){return e-t}));var s=[];i.forEach((function(e){var t=s[s.length-1];t&&e===t[t.length-1]+1?t.push(e):s.push([e])})),s.forEach((function(e){n.updateAttribute(n.objects.slice(e[0],e[0]+e.length),e[0],o,a)}))})),this.pendingUpdatePatches={}},e}(),ca=function(){function e(e,t){this.context=e,this.runtime=t,this.textureCache={}}return e.prototype.getOrCreateTexture=function(e,r,n,o){var a,s=this,l="string"==typeof r?r:r.src||"";if(l&&this.textureCache[l])(a=this.textureCache[l]).emit(J.LOADED);else if(a=e.createTexture(i({format:fe.U8_RGBA_NORM,width:1,height:1,depthOrArrayLayers:1,mipLevelCount:1,dimension:ee.TEXTURE_2D,usage:te.SAMPLED,pixelStore:{unpackFlipY:!1}},n)),l&&(this.textureCache[l]=a),_(r)){var u,c=this.context.config.createImage;c?u=c(r):t.isBrowser&&(u=new window.Image),u&&(u.onload=function(){var e=function(e){s.textureCache[l].setImageData([e]),s.textureCache[l].emit(J.LOADED),s.context.renderingService.dirtify(),o&&o(s.textureCache[l],e)};s.runtime.globalThis.createImageBitmap?s.runtime.globalThis.createImageBitmap(u).then((function(t){return e(t)})).catch((function(){e(u)})):e(u)},u.onerror=function(){},u.crossOrigin="Anonymous",u.src=r)}else a.setImageData([r]),a.emit(J.LOADED),this.context.renderingService.dirtify();return a},e.prototype.getOrCreateCanvas=function(){return this.runtime.offscreenCanvasCreator.getOrCreateCanvas(this.context.config.offscreenCanvas)},e.prototype.getOrCreateGradient=function(e){var t=e.gradients,r=e.instance.getGeometryBounds().halfExtents,n=2*r[0]||1,o=2*r[1]||1,a=this.context.config.offscreenCanvas,s=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(a),l=this.runtime.offscreenCanvasCreator.getOrCreateContext(a);s.width=n,s.height=o;var u=this.context.imagePool;t.forEach((function(e){var t=u.getOrCreateGradient(i(i({type:e.type},e.value),{width:n,height:o,min:[0,0]}),l);l.fillStyle=t,l.fillRect(0,0,n,o)}))},e.prototype.getOrCreatePattern=function(e,r,n){var i,o=e.image,a=e.repetition,s=e.transform,l=r.getGeometryBounds().halfExtents,u=2*l[0]||1,c=2*l[1]||1,f=this.context.config.offscreenCanvas,d=this.runtime.offscreenCanvasCreator.getOrCreateCanvas(f),p=this.runtime.offscreenCanvasCreator.getOrCreateContext(f);d.width=u,d.height=c;var h=(i=_(o)?this.context.imagePool.getImageSync(o,n):o)&&p.createPattern(i,a);if(s){var E=t.parsedTransformToMat4(t.parseTransform(s),new t.DisplayObject({}));h.setTransform({a:E[0],b:E[1],c:E[4],d:E[5],e:E[12],f:E[13]})}p.fillStyle=h,p.fillRect(0,0,u,c)},e.prototype.destroy=function(){for(var e in this.textureCache)this.textureCache[e].destroy();this.textureCache={}},e}(),fa=function(e){function r(t){void 0===t&&(t={});var r=e.call(this)||this;return r.options=t,r.name="device-renderer",r.parameters={toneMapping:Qn.NONE,toneMappingExposure:1},r}return n(r,e),r.prototype.init=function(e){var r;e.geometryUpdaterFactory[t.Shape.MESH]=new Ln;var n=new Ci(this.parameters),i=new Dn,o=new ca(this.context,e),a=new Fn,s=new ta,l=new ra,u=((r={})[t.Shape.CIRCLE]=s,r[t.Shape.ELLIPSE]=s,r[t.Shape.POLYLINE]=l,r[t.Shape.PATH]=l,r[t.Shape.POLYGON]=l,r[t.Shape.RECT]=new sa,r[t.Shape.IMAGE]=new na,r[t.Shape.LINE]=new oa,r[t.Shape.TEXT]=new ia,r[t.Shape.MESH]=new aa,r[t.Shape.GROUP]=void 0,r[t.Shape.HTML]=void 0,r),c=new ua(n,u,o,i),f=new Zi(n,i,o,c,this.options);this.addRenderingPlugin(f),this.addRenderingPlugin(new qi(n,f,a,c))},r.prototype.destroy=function(e){delete e.geometryUpdaterFactory[t.Shape.MESH]},r.prototype.getRenderGraphPlugin=function(){return this.plugins[0]},r.prototype.getDevice=function(){return this.getRenderGraphPlugin().getDevice()},r.prototype.getSwapChain=function(){return this.getRenderGraphPlugin().getSwapChain()},r.prototype.loadTexture=function(e,t,r){return this.getRenderGraphPlugin().loadTexture(e,t,r)},r.prototype.toDataURL=function(e){return this.getRenderGraphPlugin().toDataURL(e)},r.prototype.setParameters=function(e){this.parameters=i(i({},this.parameters),e)},r}(t.AbstractRendererPlugin),da=Object.freeze({__proto__:null,get AntialiasingMode(){return Mi},Batch:$i,BufferGeometry:Wi,DeviceProgram:Un,DynamicUniformBuffer:wn,FILL_TEXTURE_MAPPING:lo,Fog:Gi,get FogType(){return bi},get GeometryEvent(){return wi},HashMap:Wn,ImageDrawcall:Ho,Instanced:fo,InstancedFillDrawcall:wo,InstancedLineDrawcall:Wo,InstancedPathDrawcall:Io,get JOINT_TYPE(){return Mo},Light:Ui,Material:Ji,get MaterialEvent(){return ji},Mesh:bn,MeshDrawcall:ea,Plugin:fa,get RGAttachmentSlot(){return $n},RenderCache:Jn,RenderGraphPlugin:Zi,RenderHelper:Ci,RenderInst:mi,get RenderInstExecutionOrder(){return Ti},get RenderInstFlags(){return Ei},RenderInstList:gi,RenderInstManager:Si,Renderable3D:Bn,get RendererLayer(){return ei},SDFDrawcall:_o,ShaderMaterial:eo,SingleSampledTexture:ni,TemporalTexture:Fi,TextDrawcall:Jo,get TextUniform(){return Qo},TextureMapping:Li,TexturePool:ca,TinySDF:yo,get ToneMapping(){return Qn},get VertexAttributeBufferIndex(){return oo},get VertexAttributeLocation(){return ao},bezierCurveTo:To,compareDefines:ro,definedProps:no,enumToObject:to,fillColor:function(e,t,r,n){return void 0===n&&(n=r.a),e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=n,4},fillMatrix4x4:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],e[t+4]=r[4],e[t+5]=r[5],e[t+6]=r[6],e[t+7]=r[7],e[t+8]=r[8],e[t+9]=r[9],e[t+10]=r[10],e[t+11]=r[11],e[t+12]=r[12],e[t+13]=r[13],e[t+14]=r[14],e[t+15]=r[15],16},fillVec3v:function(e,t,r,n){return void 0===n&&(n=0),e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=n,4},fillVec4:vi,fillVec4v:function(e,t,r){return e[t+0]=r[0],e[t+1]=r[1],e[t+2]=r[2],e[t+3]=r[3],4},getSortKeyDepth:function(e){return!!(e>>>31&1)?e>>>8&65535:e>>>8&65532|3&e},getSortKeyLayer:function(e){return e>>>24&255},hashCodeNumberFinish:kn,hashCodeNumberUpdate:Gn,makeAttachmentClearDescriptor:Ni,makeBackbufferDescSimple:Di,makeDataBuffer:ki,makeDepthKey:li,makeSortKey:function(e,t){return void 0===t&&(t=0),e&ei.TRANSLUCENT?pi(e):fi(e,t)},makeSortKeyOpaque:fi,makeSortKeyTranslucent:pi,nullHashFunc:Vn,opaqueBlackFullClearRenderPassDescriptor:Oi,opaqueWhiteFullClearRenderPassDescriptor:xi,projectionMatrixConvertClipSpaceNearZ:function(e,t,r){t!==r&&(t===ae.NEGATIVE_ONE?function(e){D(e,hi,e)}(e):t===ae.ZERO&&function(e){D(e,Ri,e)}(e))},pushFXAAPass:zi,quadCurveTo:vo,renderInstCompareNone:null,renderInstCompareSortKey:Ai,segmentInstanceGeometry:Go,setBackbufferDescSimple:Bi,setSortKeyBias:function(e,t){return!!(e>>>31&1)?(4294967040&e|255&t)>>>0:e},setSortKeyDepth:function(e,t,r){void 0===r&&(r=ai);var n=!!(e>>>31&1),i=li(t,n,r);return n?_i(e,i):di(e,i)},setSortKeyDepthKey:function(e,t){return!!(e>>>31&1)?_i(e,t):di(e,t)},setSortKeyLayer:ui,setSortKeyOpaqueDepth:di,setSortKeyProgramKey:ci,setSortKeyTranslucentDepth:_i,standardFullClearRenderPassDescriptor:Ii,updateBuffer:Bo}),pa=function(){function e(){}return e.prototype.apply=function(t,r){var n=this,i=t.renderingService,o=t.renderingContext,a=t.config;this.context=t;var s=o.root.ownerDocument.defaultView,l=function(e){i.hooks.pointerMove.call(e)},u=function(e){i.hooks.pointerUp.call(e)},c=function(e){i.hooks.pointerDown.call(e)},f=function(e){i.hooks.pointerOver.call(e)},d=function(e){i.hooks.pointerOut.call(e)},p=function(e){i.hooks.pointerCancel.call(e)},_=function(e){i.hooks.pointerWheel.call(e)},h=function(e){i.hooks.click.call(e)};i.hooks.init.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="none",e.style.msTouchAction="none"):s.supportsPointerEvents&&(e.style.touchAction="none"),s.supportsPointerEvents?function(e){r.globalThis.document.addEventListener("pointermove",l,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("pointerleave",d,!0),e.addEventListener("pointerover",f,!0),r.globalThis.addEventListener("pointerup",u,!0),r.globalThis.addEventListener("pointercancel",p,!0)}(e):function(e){r.globalThis.document.addEventListener("mousemove",l,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("mouseout",d,!0),e.addEventListener("mouseover",f,!0),r.globalThis.addEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.addEventListener("touchstart",c,!0),e.addEventListener("touchend",u,!0),e.addEventListener("touchmove",l,!0),e.addEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.addEventListener("click",h,!0),e.addEventListener("wheel",_,{passive:!0,capture:!0})})),i.hooks.destroy.tap(e.tag,(function(){var e=n.context.contextService.getDomElement();r.globalThis.navigator.msPointerEnabled?(e.style.msContentZooming="",e.style.msTouchAction=""):s.supportsPointerEvents&&(e.style.touchAction=""),s.supportsPointerEvents?function(e){r.globalThis.document.removeEventListener("pointermove",l,!0),e.removeEventListener("pointerdown",c,!0),e.removeEventListener("pointerleave",d,!0),e.removeEventListener("pointerover",f,!0),r.globalThis.removeEventListener("pointerup",u,!0),r.globalThis.removeEventListener("pointercancel",p,!0)}(e):function(e){r.globalThis.document.removeEventListener("mousemove",l,!0),e.removeEventListener("mousedown",c,!0),e.removeEventListener("mouseout",d,!0),e.removeEventListener("mouseover",f,!0),r.globalThis.removeEventListener("mouseup",u,!0)}(e),s.supportsTouchEvents&&function(e){e.removeEventListener("touchstart",c,!0),e.removeEventListener("touchend",u,!0),e.removeEventListener("touchmove",l,!0),e.removeEventListener("touchcancel",p,!0)}(e),a.useNativeClickEvent&&e.removeEventListener("click",h,!0),e.removeEventListener("wheel",_,!0)}))},e.tag="DOMInteraction",e}(),_a=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="dom-interaction",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new pa)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ha=Object.freeze({__proto__:null,Plugin:_a}),Ea=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e,t){return void 0===t&&(t=[0,0,0]),"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")},e.prototype.apply=function(r,n){var i=this,o=r.camera,a=r.renderingContext,s=r.renderingService;this.context=r;var l=a.root.ownerDocument.defaultView,u=l.context.eventService.nativeHTMLMap,c=function(e,t){t.style.transform=i.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){i.$camera||(i.$camera=i.createCamera(o));var n=i.getOrCreateEl(r);i.$camera.appendChild(n),Object.keys(r.attributes).forEach((function(e){i.updateAttribute(e,r)})),c(r,n),u.set(n,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&i.$camera){var n=i.getOrCreateEl(r);n&&(n.remove(),u.delete(n))}},p=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&i.updateAttribute(e.attrName,r)},_=function(e){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){if(e.nodeName===t.Shape.HTML){var r=i.getOrCreateEl(e);c(e,r)}}))},h=function(){if(i.$camera){var e=i.context.config,t=e.height;i.$camera.parentElement.style.width="".concat(e.width||0,"px"),i.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,h),l.addEventListener(t.ElementEvent.MOUNTED,f),l.addEventListener(t.ElementEvent.UNMOUNTED,d),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,p),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,_)})),s.hooks.endFrame.tap(e.tag,(function(){i.$camera&&a.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(i.$camera.style.transform=i.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){i.$camera&&i.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,h),l.removeEventListener(t.ElementEvent.MOUNTED,f),l.removeEventListener(t.ElementEvent.UNMOUNTED,d),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,p),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,_)}))},e.prototype.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,i=t.height,o=this.context.contextService.getDomElement(),a=o.parentNode;if(a){var s="g-canvas-camera",l=a.querySelector("#"+s);if(!l){var u=(r||document).createElement("div");u.style.overflow="hidden",u.style.pointerEvents="none",u.style.position="absolute",u.style.left="0px",u.style.top="0px",u.style.width="".concat(n||0,"px"),u.style.height="".concat(i||0,"px");var c=(r||document).createElement("div");l=c,c.id=s,c.style.position="absolute",c.style.left="".concat(o.offsetLeft||0,"px"),c.style.top="".concat(o.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.pointerEvents="none",c.style.width="100%",c.style.height="100%",u.appendChild(c),a.appendChild(u)}return l}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r},e.prototype.updateAttribute=function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var i=r.parsedStyle.innerHTML;_(i)?n.innerHTML=i:(n.innerHTML="",n.appendChild(i));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].buildCSSText(null,null,"")," ").concat(o[1].buildCSSText(null,null,""));break;case"width":var a=r.parsedStyle.width;n.style.width=E(a)?"".concat(a,"px"):""+a;break;case"height":var s=r.parsedStyle.height;n.style.height=E(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var l=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===l?"auto":l;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var u=r.parsedStyle.fill,c="";t.isCSSRGB(u)?c=u.isNone?"transparent":r.getAttribute("fill"):Array.isArray(u)?c=r.getAttribute("fill"):t.isPattern(u),n.style.background=c;break;case"stroke":var d=r.parsedStyle.stroke,p="";t.isCSSRGB(d)?p=d.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(d)?p=r.getAttribute("stroke"):t.isPattern(d),n.style["border-color"]=p,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:f(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}},e.tag="HTMLRendering",e}(),Ra=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="html-renderer",t}return n(t,e),t.prototype.init=function(){this.addRenderingPlugin(new Ea)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),va=Object.freeze({__proto__:null,Plugin:Ra}),Ta=function(){function e(e){this.canvasConfig=e,this.imageCache={},this.gradientCache={},this.patternCache={}}return e.prototype.getImageSync=function(e,t){return this.imageCache[e]?t&&t(this.imageCache[e]):this.getOrCreateImage(e).then((function(e){t&&t(e)})),this.imageCache[e]},e.prototype.getOrCreateImage=function(e){var r=this;if(this.imageCache[e])return Promise.resolve(this.imageCache[e]);var n=this.canvasConfig.createImage;return new Promise((function(i,o){var a;n?a=n(e):t.isBrowser&&(a=new window.Image),a&&(a.onload=function(){r.imageCache[e]=a,i(a)},a.onerror=function(e){o(e)},a.crossOrigin="Anonymous",a.src=e)}))},e.prototype.getOrCreatePatternSync=function(e,r,n,i,o,a){var s=this.generatePatternKey(e);if(s&&this.patternCache[s])return this.patternCache[s];var l,u=e.image,c=e.repetition,f=e.transform,d=!1;_(u)?l=this.getImageSync(u,a):n?(l=n,d=!0):l=u;var p=l&&r.createPattern(l,c);if(p){var h=void 0;h=f?t.parsedTransformToMat4(t.parseTransform(f),new t.DisplayObject({})):g(T()),d&&C(h,h,[1/i,1/i,1]),p.setTransform({a:h[0],b:h[1],c:h[4],d:h[5],e:h[12]+o[0],f:h[13]+o[1]})}return s&&p&&(this.patternCache[s]=p),p},e.prototype.getOrCreateGradient=function(e,r){var n=this.generateGradientKey(e),i=e.type,o=e.steps,a=e.min,s=e.width,l=e.height,u=e.cx,c=e.cy,f=e.size;if(this.gradientCache[n])return this.gradientCache[n];var d=null;if(i===t.GradientType.LinearGradient){var p=t.computeLinearGradient(a,s,l,e.angle);d=r.createLinearGradient(p.x1,p.y1,p.x2,p.y2)}else if(i===t.GradientType.RadialGradient){var _=t.computeRadialGradient(a,s,l,u,c,f),h=_.x,E=_.y;d=r.createRadialGradient(h,E,0,h,E,_.r)}return d&&(o.forEach((function(e){var r=e.offset;r.unit===t.UnitType.kPercentage&&(null==d||d.addColorStop(r.value/100,""+e.color))})),this.gradientCache[n]=d),this.gradientCache[n]},e.prototype.generateGradientKey=function(e){var t=e.min,r=e.width,n=e.height,i=e.steps,o=e.angle,a=e.cx,s=e.cy,l=e.size;return"gradient-".concat(e.type,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==s?void 0:""+s)||0,"-").concat((null==l?void 0:""+l)||0,"-").concat(t[0],"-").concat(t[1],"-").concat(r,"-").concat(n,"-").concat(i.map((function(e){var t=e.color;return"".concat(e.offset).concat(t)})).join("-"))},e.prototype.generatePatternKey=function(e){var t=e.image,r=e.repetition;return _(t)?"pattern-".concat(t,"-").concat(r):"rect"===t.nodeName?"pattern-".concat(t.entity,"-").concat(r):void 0},e}(),ma=function(){function e(){}return e.prototype.apply=function(r){var n=r.renderingService,i=r.imagePool,o=r.renderingContext.root.ownerDocument.defaultView,a=function(e,t,r){var n=e.parsedStyle,i=n.width,o=n.height;i&&!o?e.setAttribute("height",r/t*i):!i&&o&&e.setAttribute("width",t/r*o)},s=function(e){var r=e.target,o=r.attributes;if(r.nodeName===t.Shape.IMAGE){var s=o.src,l=o.keepAspectRatio;_(s)&&i.getImageSync(s,(function(e){l&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))}},l=function(e){var r=e.target,o=e.newValue;r.nodeName===t.Shape.IMAGE&&"src"===e.attrName&&_(o)&&i.getOrCreateImage(o).then((function(e){r.attributes.keepAspectRatio&&a(r,e.width,e.height),r.renderable.dirty=!0,n.dirtify()}))};n.hooks.init.tap(e.tag,(function(){o.addEventListener(t.ElementEvent.MOUNTED,s),o.addEventListener(t.ElementEvent.ATTR_MODIFIED,l)})),n.hooks.destroy.tap(e.tag,(function(){o.removeEventListener(t.ElementEvent.MOUNTED,s),o.removeEventListener(t.ElementEvent.ATTR_MODIFIED,l)}))},e.tag="LoadImage",e}(),Aa=function(e){function t(){var t=e.apply(this,c([],u(arguments),!1))||this;return t.name="image-loader",t}return n(t,e),t.prototype.init=function(){this.context.imagePool=new Ta(this.context.config),this.addRenderingPlugin(new ma)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin),ga=function(){function e(e){this.canvasConfig=e.config,this.deviceRendererPlugin=e.deviceRendererPlugin}return e.prototype.init=function(){var e=this.canvasConfig,t=e.container,r=e.canvas;if(r)this.$canvas=r,t&&r.parentElement!==t&&t.appendChild(r),this.$container=r.parentElement,this.canvasConfig.container=this.$container;else if(t&&(this.$container=_(t)?document.getElementById(t):t,this.$container)){var n=document.createElement("canvas");this.$container.appendChild(n),this.$container.style.position||(this.$container.style.position="relative"),this.$canvas=n}this.resize(this.canvasConfig.width,this.canvasConfig.height)},e.prototype.getDomElement=function(){return this.$canvas},e.prototype.getContext=function(){return this.deviceRendererPlugin.getDevice().canvasContext},e.prototype.getBoundingClientRect=function(){if(this.$canvas.getBoundingClientRect)return this.$canvas.getBoundingClientRect()},e.prototype.destroy=function(){this.$container&&this.$canvas&&this.$canvas.parentNode&&this.$container.removeChild(this.$canvas)},e.prototype.resize=function(e,r){var n=this.canvasConfig.devicePixelRatio||t.isBrowser&&window.devicePixelRatio||1;if(this.dpr=n=1>n?1:Math.ceil(n),this.$canvas){var i=this.getDPR();this.$canvas.width=i*e,this.$canvas.height=i*r,t.setDOMSize(this.$canvas,e,r)}},e.prototype.getDPR=function(){return this.dpr},e.prototype.applyCursorStyle=function(e){this.$container&&this.$container.style&&(this.$container.style.cursor=e)},e.prototype.toDataURL=function(e){return a(this,void 0,void 0,(function(){return s(this,(function(e){return[2,""]}))}))},e}(),ya=function(e){function t(t,r){var n=e.call(this)||this;return n.rendererPlugin=t,n.config=r,n.name="webgpu-context-register",n}return n(t,e),t.prototype.init=function(){this.context.ContextService=ga,this.context.deviceRendererPlugin=this.rendererPlugin;var e=this.config;this.context.deviceContribution=new qr({shaderCompilerPath:null==e?void 0:e.shaderCompilerPath,onContextLost:null==e?void 0:e.onContextLost})},t.prototype.destroy=function(){delete this.context.ContextService},t}(t.AbstractRendererPlugin),Sa=function(e){function r(r){var n=e.call(this,i({enableSizeAttenuation:!1},r))||this;n.clipSpaceNearZ=t.ClipSpaceNearZ.ZERO;var o=new fa;return n.registerPlugin(new ya(o,r)),n.registerPlugin(new Aa),n.registerPlugin(o),n.registerPlugin(new _a),n.registerPlugin(new Ra),n}return n(r,e),r}(t.AbstractRenderer);e.DeviceRenderer=da,e.DomInteraction=ha,e.HTMLRenderer=va,e.Renderer=Sa}));
|
|
2
2
|
//# sourceMappingURL=index.umd.min.js.map
|